diff options
Diffstat (limited to 'net/batman-adv/main.h')
-rw-r--r-- | net/batman-adv/main.h | 85 |
1 files changed, 64 insertions, 21 deletions
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 148b49e02642..a6df61a6933b 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h | |||
@@ -27,8 +27,9 @@ | |||
27 | #define DRIVER_DESC "B.A.T.M.A.N. advanced" | 27 | #define DRIVER_DESC "B.A.T.M.A.N. advanced" |
28 | #define DRIVER_DEVICE "batman-adv" | 28 | #define DRIVER_DEVICE "batman-adv" |
29 | 29 | ||
30 | #define SOURCE_VERSION "next" | 30 | #ifndef SOURCE_VERSION |
31 | 31 | #define SOURCE_VERSION "2011.3.0" | |
32 | #endif | ||
32 | 33 | ||
33 | /* B.A.T.M.A.N. parameters */ | 34 | /* B.A.T.M.A.N. parameters */ |
34 | 35 | ||
@@ -42,15 +43,25 @@ | |||
42 | * -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE */ | 43 | * -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE */ |
43 | #define PURGE_TIMEOUT 200 | 44 | #define PURGE_TIMEOUT 200 |
44 | #define TT_LOCAL_TIMEOUT 3600 /* in seconds */ | 45 | #define TT_LOCAL_TIMEOUT 3600 /* in seconds */ |
45 | 46 | #define TT_CLIENT_ROAM_TIMEOUT 600 | |
46 | /* sliding packet range of received originator messages in squence numbers | 47 | /* sliding packet range of received originator messages in squence numbers |
47 | * (should be a multiple of our word size) */ | 48 | * (should be a multiple of our word size) */ |
48 | #define TQ_LOCAL_WINDOW_SIZE 64 | 49 | #define TQ_LOCAL_WINDOW_SIZE 64 |
50 | #define TT_REQUEST_TIMEOUT 3 /* seconds we have to keep pending tt_req */ | ||
51 | |||
49 | #define TQ_GLOBAL_WINDOW_SIZE 5 | 52 | #define TQ_GLOBAL_WINDOW_SIZE 5 |
50 | #define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 | 53 | #define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 |
51 | #define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1 | 54 | #define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1 |
52 | #define TQ_TOTAL_BIDRECT_LIMIT 1 | 55 | #define TQ_TOTAL_BIDRECT_LIMIT 1 |
53 | 56 | ||
57 | #define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */ | ||
58 | |||
59 | #define ROAMING_MAX_TIME 20 /* Time in which a client can roam at most | ||
60 | * ROAMING_MAX_COUNT times */ | ||
61 | #define ROAMING_MAX_COUNT 5 | ||
62 | |||
63 | #define NO_FLAGS 0 | ||
64 | |||
54 | #define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE) | 65 | #define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE) |
55 | 66 | ||
56 | #define LOG_BUF_LEN 8192 /* has to be a power of 2 */ | 67 | #define LOG_BUF_LEN 8192 /* has to be a power of 2 */ |
@@ -72,13 +83,27 @@ | |||
72 | #define RESET_PROTECTION_MS 30000 | 83 | #define RESET_PROTECTION_MS 30000 |
73 | #define EXPECTED_SEQNO_RANGE 65536 | 84 | #define EXPECTED_SEQNO_RANGE 65536 |
74 | 85 | ||
75 | #define MESH_INACTIVE 0 | 86 | enum mesh_state { |
76 | #define MESH_ACTIVE 1 | 87 | MESH_INACTIVE, |
77 | #define MESH_DEACTIVATING 2 | 88 | MESH_ACTIVE, |
89 | MESH_DEACTIVATING | ||
90 | }; | ||
78 | 91 | ||
79 | #define BCAST_QUEUE_LEN 256 | 92 | #define BCAST_QUEUE_LEN 256 |
80 | #define BATMAN_QUEUE_LEN 256 | 93 | #define BATMAN_QUEUE_LEN 256 |
81 | 94 | ||
95 | enum uev_action { | ||
96 | UEV_ADD = 0, | ||
97 | UEV_DEL, | ||
98 | UEV_CHANGE | ||
99 | }; | ||
100 | |||
101 | enum uev_type { | ||
102 | UEV_GW = 0 | ||
103 | }; | ||
104 | |||
105 | #define GW_THRESHOLD 50 | ||
106 | |||
82 | /* | 107 | /* |
83 | * Debug Messages | 108 | * Debug Messages |
84 | */ | 109 | */ |
@@ -89,10 +114,12 @@ | |||
89 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 114 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
90 | 115 | ||
91 | /* all messages related to routing / flooding / broadcasting / etc */ | 116 | /* all messages related to routing / flooding / broadcasting / etc */ |
92 | #define DBG_BATMAN 1 | 117 | enum dbg_level { |
93 | /* route or tt entry added / changed / deleted */ | 118 | DBG_BATMAN = 1 << 0, |
94 | #define DBG_ROUTES 2 | 119 | DBG_ROUTES = 1 << 1, /* route added / changed / deleted */ |
95 | #define DBG_ALL 3 | 120 | DBG_TT = 1 << 2, /* translation table operations */ |
121 | DBG_ALL = 7 | ||
122 | }; | ||
96 | 123 | ||
97 | 124 | ||
98 | /* | 125 | /* |
@@ -118,12 +145,6 @@ | |||
118 | #include <linux/seq_file.h> | 145 | #include <linux/seq_file.h> |
119 | #include "types.h" | 146 | #include "types.h" |
120 | 147 | ||
121 | #ifndef REVISION_VERSION | ||
122 | #define REVISION_VERSION_STR "" | ||
123 | #else | ||
124 | #define REVISION_VERSION_STR " "REVISION_VERSION | ||
125 | #endif | ||
126 | |||
127 | extern struct list_head hardif_list; | 148 | extern struct list_head hardif_list; |
128 | 149 | ||
129 | extern unsigned char broadcast_addr[]; | 150 | extern unsigned char broadcast_addr[]; |
@@ -133,10 +154,10 @@ int mesh_init(struct net_device *soft_iface); | |||
133 | void mesh_free(struct net_device *soft_iface); | 154 | void mesh_free(struct net_device *soft_iface); |
134 | void inc_module_count(void); | 155 | void inc_module_count(void); |
135 | void dec_module_count(void); | 156 | void dec_module_count(void); |
136 | int is_my_mac(uint8_t *addr); | 157 | int is_my_mac(const uint8_t *addr); |
137 | 158 | ||
138 | #ifdef CONFIG_BATMAN_ADV_DEBUG | 159 | #ifdef CONFIG_BATMAN_ADV_DEBUG |
139 | int debug_log(struct bat_priv *bat_priv, char *fmt, ...); | 160 | int debug_log(struct bat_priv *bat_priv, const char *fmt, ...) __printf(2, 3); |
140 | 161 | ||
141 | #define bat_dbg(type, bat_priv, fmt, arg...) \ | 162 | #define bat_dbg(type, bat_priv, fmt, arg...) \ |
142 | do { \ | 163 | do { \ |
@@ -145,9 +166,10 @@ int debug_log(struct bat_priv *bat_priv, char *fmt, ...); | |||
145 | } \ | 166 | } \ |
146 | while (0) | 167 | while (0) |
147 | #else /* !CONFIG_BATMAN_ADV_DEBUG */ | 168 | #else /* !CONFIG_BATMAN_ADV_DEBUG */ |
148 | static inline void bat_dbg(char type __always_unused, | 169 | __printf(3, 4) |
170 | static inline void bat_dbg(int type __always_unused, | ||
149 | struct bat_priv *bat_priv __always_unused, | 171 | struct bat_priv *bat_priv __always_unused, |
150 | char *fmt __always_unused, ...) | 172 | const char *fmt __always_unused, ...) |
151 | { | 173 | { |
152 | } | 174 | } |
153 | #endif | 175 | #endif |
@@ -172,11 +194,32 @@ static inline void bat_dbg(char type __always_unused, | |||
172 | * | 194 | * |
173 | * note: can't use compare_ether_addr() as it requires aligned memory | 195 | * note: can't use compare_ether_addr() as it requires aligned memory |
174 | */ | 196 | */ |
175 | static inline int compare_eth(void *data1, void *data2) | 197 | |
198 | static inline int compare_eth(const void *data1, const void *data2) | ||
176 | { | 199 | { |
177 | return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); | 200 | return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); |
178 | } | 201 | } |
179 | 202 | ||
203 | |||
180 | #define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) | 204 | #define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) |
181 | 205 | ||
206 | /* Returns the smallest signed integer in two's complement with the sizeof x */ | ||
207 | #define smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u))) | ||
208 | |||
209 | /* Checks if a sequence number x is a predecessor/successor of y. | ||
210 | * they handle overflows/underflows and can correctly check for a | ||
211 | * predecessor/successor unless the variable sequence number has grown by | ||
212 | * more then 2**(bitwidth(x)-1)-1. | ||
213 | * This means that for a uint8_t with the maximum value 255, it would think: | ||
214 | * - when adding nothing - it is neither a predecessor nor a successor | ||
215 | * - before adding more than 127 to the starting value - it is a predecessor, | ||
216 | * - when adding 128 - it is neither a predecessor nor a successor, | ||
217 | * - after adding more than 127 to the starting value - it is a successor */ | ||
218 | #define seq_before(x, y) ({typeof(x) _d1 = (x); \ | ||
219 | typeof(y) _d2 = (y); \ | ||
220 | typeof(x) _dummy = (_d1 - _d2); \ | ||
221 | (void) (&_d1 == &_d2); \ | ||
222 | _dummy > smallest_signed_int(_dummy); }) | ||
223 | #define seq_after(x, y) seq_before(y, x) | ||
224 | |||
182 | #endif /* _NET_BATMAN_ADV_MAIN_H_ */ | 225 | #endif /* _NET_BATMAN_ADV_MAIN_H_ */ |