1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef _NET_BATMAN_ADV_MAIN_H_
23#define _NET_BATMAN_ADV_MAIN_H_
24
25#define DRIVER_AUTHOR "Marek Lindner <lindner_marek@yahoo.de>, " \
26 "Simon Wunderlich <siwu@hrz.tu-chemnitz.de>"
27#define DRIVER_DESC "B.A.T.M.A.N. advanced"
28#define DRIVER_DEVICE "batman-adv"
29
30#ifndef SOURCE_VERSION
31#define SOURCE_VERSION "2011.4.0"
32#endif
33
34
35
36#define TQ_MAX_VALUE 255
37#define JITTER 20
38
39
40#define TTL 50
41
42
43
44#define PURGE_TIMEOUT 200
45#define TT_LOCAL_TIMEOUT 3600
46#define TT_CLIENT_ROAM_TIMEOUT 600
47
48
49#define TQ_LOCAL_WINDOW_SIZE 64
50#define TT_REQUEST_TIMEOUT 3
51
52#define TQ_GLOBAL_WINDOW_SIZE 5
53#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1
54#define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1
55#define TQ_TOTAL_BIDRECT_LIMIT 1
56
57#define TT_OGM_APPEND_MAX 3
58
59#define ROAMING_MAX_TIME 20
60
61#define ROAMING_MAX_COUNT 5
62
63#define NO_FLAGS 0
64
65#define NULL_IFINDEX 0
66
67#define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)
68
69#define LOG_BUF_LEN 8192
70
71#define VIS_INTERVAL 5000
72
73
74
75#define BONDING_TQ_THRESHOLD 50
76
77
78
79#define MAX_AGGREGATION_BYTES 512
80#define MAX_AGGREGATION_MS 100
81
82#define SOFTIF_NEIGH_TIMEOUT 180000
83
84
85#define RESET_PROTECTION_MS 30000
86#define EXPECTED_SEQNO_RANGE 65536
87
88enum mesh_state {
89 MESH_INACTIVE,
90 MESH_ACTIVE,
91 MESH_DEACTIVATING
92};
93
94#define BCAST_QUEUE_LEN 256
95#define BATMAN_QUEUE_LEN 256
96
97enum uev_action {
98 UEV_ADD = 0,
99 UEV_DEL,
100 UEV_CHANGE
101};
102
103enum uev_type {
104 UEV_GW = 0
105};
106
107#define GW_THRESHOLD 50
108
109
110
111
112#ifdef pr_fmt
113#undef pr_fmt
114#endif
115
116#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
117
118
119enum dbg_level {
120 DBG_BATMAN = 1 << 0,
121 DBG_ROUTES = 1 << 1,
122 DBG_TT = 1 << 2,
123 DBG_ALL = 7
124};
125
126
127
128
129
130
131
132
133
134
135#include <linux/mutex.h>
136#include <linux/module.h>
137#include <linux/netdevice.h>
138#include <linux/etherdevice.h>
139#include <linux/if_ether.h>
140#include <linux/poll.h>
141#include <linux/kthread.h>
142#include <linux/pkt_sched.h>
143#include <linux/workqueue.h>
144#include <linux/slab.h>
145#include <net/sock.h>
146#include <linux/jiffies.h>
147#include <linux/seq_file.h>
148#include "types.h"
149
150extern struct list_head hardif_list;
151
152extern unsigned char broadcast_addr[];
153extern struct workqueue_struct *bat_event_workqueue;
154
155int mesh_init(struct net_device *soft_iface);
156void mesh_free(struct net_device *soft_iface);
157void inc_module_count(void);
158void dec_module_count(void);
159int is_my_mac(const uint8_t *addr);
160
161#ifdef CONFIG_BATMAN_ADV_DEBUG
162int debug_log(struct bat_priv *bat_priv, const char *fmt, ...) __printf(2, 3);
163
164#define bat_dbg(type, bat_priv, fmt, arg...) \
165 do { \
166 if (atomic_read(&bat_priv->log_level) & type) \
167 debug_log(bat_priv, fmt, ## arg); \
168 } \
169 while (0)
170#else
171__printf(3, 4)
172static inline void bat_dbg(int type __always_unused,
173 struct bat_priv *bat_priv __always_unused,
174 const char *fmt __always_unused, ...)
175{
176}
177#endif
178
179#define bat_info(net_dev, fmt, arg...) \
180 do { \
181 struct net_device *_netdev = (net_dev); \
182 struct bat_priv *_batpriv = netdev_priv(_netdev); \
183 bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
184 pr_info("%s: " fmt, _netdev->name, ## arg); \
185 } while (0)
186#define bat_err(net_dev, fmt, arg...) \
187 do { \
188 struct net_device *_netdev = (net_dev); \
189 struct bat_priv *_batpriv = netdev_priv(_netdev); \
190 bat_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
191 pr_err("%s: " fmt, _netdev->name, ## arg); \
192 } while (0)
193
194
195
196
197
198
199
200static inline int compare_eth(const void *data1, const void *data2)
201{
202 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
203}
204
205
206#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
207
208
209#define smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u)))
210
211
212
213
214
215
216
217
218
219
220#define seq_before(x, y) ({typeof(x) _d1 = (x); \
221 typeof(y) _d2 = (y); \
222 typeof(x) _dummy = (_d1 - _d2); \
223 (void) (&_d1 == &_d2); \
224 _dummy > smallest_signed_int(_dummy); })
225#define seq_after(x, y) seq_before(y, x)
226
227#endif
228