]>
Commit | Line | Data |
---|---|---|
0b873931 | 1 | /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors: |
c6c8fea2 SE |
2 | * |
3 | * Marek Lindner, Simon Wunderlich | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or | |
6 | * modify it under the terms of version 2 of the GNU General Public | |
7 | * License as published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but | |
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | * General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write to the Free Software | |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
17 | * 02110-1301, USA | |
c6c8fea2 SE |
18 | */ |
19 | ||
c6c8fea2 SE |
20 | #ifndef _NET_BATMAN_ADV_TYPES_H_ |
21 | #define _NET_BATMAN_ADV_TYPES_H_ | |
22 | ||
23 | #include "packet.h" | |
24 | #include "bitarray.h" | |
c11fdfae | 25 | #include <linux/kernel.h> |
c6c8fea2 | 26 | |
88a32c9a ML |
27 | /** |
28 | * Maximum overhead for the encapsulation for a payload packet | |
29 | */ | |
c11fdfae | 30 | #define BATADV_HEADER_LEN \ |
96412690 SE |
31 | (ETH_HLEN + max(sizeof(struct batadv_unicast_packet), \ |
32 | sizeof(struct batadv_bcast_packet))) | |
c6c8fea2 | 33 | |
17224474 AQ |
34 | #ifdef CONFIG_BATMAN_ADV_DAT |
35 | ||
785ea114 AQ |
36 | /* batadv_dat_addr_t is the type used for all DHT addresses. If it is changed, |
37 | * BATADV_DAT_ADDR_MAX is changed as well. | |
38 | * | |
39 | * *Please be careful: batadv_dat_addr_t must be UNSIGNED* | |
40 | */ | |
41 | #define batadv_dat_addr_t uint16_t | |
42 | ||
17224474 AQ |
43 | #endif /* CONFIG_BATMAN_ADV_DAT */ |
44 | ||
14511519 ML |
45 | /** |
46 | * struct batadv_hard_iface_bat_iv - per hard interface B.A.T.M.A.N. IV data | |
47 | * @ogm_buff: buffer holding the OGM packet | |
48 | * @ogm_buff_len: length of the OGM packet buffer | |
49 | * @ogm_seqno: OGM sequence number - used to identify each OGM | |
50 | */ | |
51 | struct batadv_hard_iface_bat_iv { | |
52 | unsigned char *ogm_buff; | |
53 | int ogm_buff_len; | |
54 | atomic_t ogm_seqno; | |
55 | }; | |
56 | ||
88a32c9a ML |
57 | /** |
58 | * struct batadv_hard_iface - network device known to batman-adv | |
59 | * @list: list node for batadv_hardif_list | |
60 | * @if_num: identificator of the interface | |
61 | * @if_status: status of the interface for batman-adv | |
62 | * @net_dev: pointer to the net_device | |
63 | * @frag_seqno: last fragment sequence number sent by this interface | |
caf65bfc | 64 | * @num_bcasts: number of payload re-broadcasts on this interface (ARQ) |
88a32c9a ML |
65 | * @hardif_obj: kobject of the per interface sysfs "mesh" directory |
66 | * @refcount: number of contexts the object is used | |
67 | * @batman_adv_ptype: packet type describing packets that should be processed by | |
68 | * batman-adv for this interface | |
69 | * @soft_iface: the batman-adv interface which uses this network interface | |
70 | * @rcu: struct used for freeing in an RCU-safe manner | |
71 | * @bat_iv: BATMAN IV specific per hard interface data | |
5bc44dc8 | 72 | * @cleanup_work: work queue callback item for hard interface deinit |
88a32c9a | 73 | */ |
56303d34 | 74 | struct batadv_hard_iface { |
c6c8fea2 SE |
75 | struct list_head list; |
76 | int16_t if_num; | |
77 | char if_status; | |
78 | struct net_device *net_dev; | |
c6c8fea2 | 79 | atomic_t frag_seqno; |
caf65bfc | 80 | uint8_t num_bcasts; |
c6c8fea2 | 81 | struct kobject *hardif_obj; |
ed75ccbe | 82 | atomic_t refcount; |
c6c8fea2 SE |
83 | struct packet_type batman_adv_ptype; |
84 | struct net_device *soft_iface; | |
85 | struct rcu_head rcu; | |
14511519 | 86 | struct batadv_hard_iface_bat_iv bat_iv; |
5bc44dc8 | 87 | struct work_struct cleanup_work; |
c6c8fea2 SE |
88 | }; |
89 | ||
2c53040f | 90 | /** |
b6d0ab7c | 91 | * struct batadv_orig_node - structure for orig_list maintaining nodes of mesh |
88a32c9a | 92 | * @orig: originator ethernet address |
b6d0ab7c | 93 | * @primary_addr: hosts primary interface address |
88a32c9a ML |
94 | * @router: router that should be used to reach this originator |
95 | * @batadv_dat_addr_t: address of the orig node in the distributed hash | |
96 | * @bcast_own: bitfield containing the number of our OGMs this orig_node | |
97 | * rebroadcasted "back" to us (relative to last_real_seqno) | |
98 | * @bcast_own_sum: counted result of bcast_own | |
99 | * @last_seen: time when last packet from this node was received | |
b6d0ab7c ML |
100 | * @bcast_seqno_reset: time when the broadcast seqno window was reset |
101 | * @batman_seqno_reset: time when the batman seqno window was reset | |
102 | * @gw_flags: flags related to gateway class | |
103 | * @flags: for now only VIS_SERVER flag | |
88a32c9a ML |
104 | * @last_ttvn: last seen translation table version number |
105 | * @tt_crc: CRC of the translation table | |
106 | * @tt_buff: last tt changeset this node received from the orig node | |
107 | * @tt_buff_len: length of the last tt changeset this node received from the | |
108 | * orig node | |
109 | * @tt_buff_lock: lock that protects tt_buff and tt_buff_len | |
110 | * @tt_size: number of global TT entries announced by the orig node | |
111 | * @tt_initialised: bool keeping track of whether or not this node have received | |
112 | * any translation table information from the orig node yet | |
b6d0ab7c ML |
113 | * @last_real_seqno: last and best known sequence number |
114 | * @last_ttl: ttl of last received packet | |
88a32c9a ML |
115 | * @bcast_bits: bitfield containing the info which payload broadcast originated |
116 | * from this orig node this host already has seen (relative to | |
117 | * last_bcast_seqno) | |
b6d0ab7c | 118 | * @last_bcast_seqno: last broadcast sequence number received by this host |
88a32c9a ML |
119 | * @neigh_list: list of potential next hop neighbor towards this orig node |
120 | * @frag_list: fragmentation buffer list for fragment re-assembly | |
121 | * @last_frag_packet: time when last fragmented packet from this node was | |
122 | * received | |
123 | * @neigh_list_lock: lock protecting neigh_list, router and bonding_list | |
124 | * @hash_entry: hlist node for batadv_priv::orig_hash | |
125 | * @bat_priv: pointer to soft_iface this orig node belongs to | |
126 | * @ogm_cnt_lock: lock protecting bcast_own, bcast_own_sum, | |
127 | * neigh_node->real_bits & neigh_node->real_packet_count | |
128 | * @bcast_seqno_lock: lock protecting bcast_bits & last_bcast_seqno | |
129 | * @bond_candidates: how many candidates are available | |
130 | * @bond_list: list of bonding candidates | |
131 | * @refcount: number of contexts the object is used | |
132 | * @rcu: struct used for freeing in an RCU-safe manner | |
d56b1705 MH |
133 | * @in_coding_list: list of nodes this orig can hear |
134 | * @out_coding_list: list of nodes that can hear this orig | |
135 | * @in_coding_list_lock: protects in_coding_list | |
136 | * @out_coding_list_lock: protects out_coding_list | |
c6c8fea2 | 137 | */ |
56303d34 | 138 | struct batadv_orig_node { |
c6c8fea2 SE |
139 | uint8_t orig[ETH_ALEN]; |
140 | uint8_t primary_addr[ETH_ALEN]; | |
56303d34 | 141 | struct batadv_neigh_node __rcu *router; /* rcu protected pointer */ |
17224474 | 142 | #ifdef CONFIG_BATMAN_ADV_DAT |
785ea114 | 143 | batadv_dat_addr_t dat_addr; |
17224474 | 144 | #endif |
c6c8fea2 SE |
145 | unsigned long *bcast_own; |
146 | uint8_t *bcast_own_sum; | |
d7b2a97e | 147 | unsigned long last_seen; |
c6c8fea2 SE |
148 | unsigned long bcast_seqno_reset; |
149 | unsigned long batman_seqno_reset; | |
150 | uint8_t gw_flags; | |
151 | uint8_t flags; | |
88a32c9a | 152 | atomic_t last_ttvn; |
a73105b8 | 153 | uint16_t tt_crc; |
2dafb49d AQ |
154 | unsigned char *tt_buff; |
155 | int16_t tt_buff_len; | |
88a32c9a | 156 | spinlock_t tt_buff_lock; /* protects tt_buff & tt_buff_len */ |
a73105b8 | 157 | atomic_t tt_size; |
17071578 | 158 | bool tt_initialised; |
c6c8fea2 SE |
159 | uint32_t last_real_seqno; |
160 | uint8_t last_ttl; | |
42d0b044 | 161 | DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); |
c6c8fea2 | 162 | uint32_t last_bcast_seqno; |
9591a79f | 163 | struct hlist_head neigh_list; |
c6c8fea2 | 164 | struct list_head frag_list; |
88a32c9a ML |
165 | unsigned long last_frag_packet; |
166 | /* neigh_list_lock protects: neigh_list, router & bonding_list */ | |
167 | spinlock_t neigh_list_lock; | |
7aadf889 | 168 | struct hlist_node hash_entry; |
56303d34 | 169 | struct batadv_priv *bat_priv; |
6e215fd8 | 170 | /* ogm_cnt_lock protects: bcast_own, bcast_own_sum, |
88a32c9a | 171 | * neigh_node->real_bits & neigh_node->real_packet_count |
9cfc7bd6 | 172 | */ |
6e215fd8 | 173 | spinlock_t ogm_cnt_lock; |
88a32c9a | 174 | /* bcast_seqno_lock protects: bcast_bits & last_bcast_seqno */ |
6e215fd8 | 175 | spinlock_t bcast_seqno_lock; |
a4c135c5 SW |
176 | atomic_t bond_candidates; |
177 | struct list_head bond_list; | |
88a32c9a ML |
178 | atomic_t refcount; |
179 | struct rcu_head rcu; | |
d56b1705 MH |
180 | #ifdef CONFIG_BATMAN_ADV_NC |
181 | struct list_head in_coding_list; | |
182 | struct list_head out_coding_list; | |
183 | spinlock_t in_coding_list_lock; /* Protects in_coding_list */ | |
184 | spinlock_t out_coding_list_lock; /* Protects out_coding_list */ | |
185 | #endif | |
c6c8fea2 SE |
186 | }; |
187 | ||
88a32c9a ML |
188 | /** |
189 | * struct batadv_gw_node - structure for orig nodes announcing gw capabilities | |
190 | * @list: list node for batadv_priv_gw::list | |
191 | * @orig_node: pointer to corresponding orig node | |
192 | * @deleted: this struct is scheduled for deletion | |
193 | * @refcount: number of contexts the object is used | |
194 | * @rcu: struct used for freeing in an RCU-safe manner | |
195 | */ | |
56303d34 | 196 | struct batadv_gw_node { |
c6c8fea2 | 197 | struct hlist_node list; |
56303d34 | 198 | struct batadv_orig_node *orig_node; |
c6c8fea2 | 199 | unsigned long deleted; |
25b6d3c1 | 200 | atomic_t refcount; |
c6c8fea2 SE |
201 | struct rcu_head rcu; |
202 | }; | |
203 | ||
88a32c9a ML |
204 | /** |
205 | * struct batadv_neigh_node - structure for single hop neighbors | |
206 | * @list: list node for batadv_orig_node::neigh_list | |
207 | * @addr: mac address of neigh node | |
208 | * @tq_recv: ring buffer of received TQ values from this neigh node | |
209 | * @tq_index: ring buffer index | |
210 | * @tq_avg: averaged tq of all tq values in the ring buffer (tq_recv) | |
211 | * @last_ttl: last received ttl from this neigh node | |
212 | * @bonding_list: list node for batadv_orig_node::bond_list | |
213 | * @last_seen: when last packet via this neighbor was received | |
214 | * @real_bits: bitfield containing the number of OGMs received from this neigh | |
215 | * node (relative to orig_node->last_real_seqno) | |
216 | * @real_packet_count: counted result of real_bits | |
217 | * @orig_node: pointer to corresponding orig_node | |
218 | * @if_incoming: pointer to incoming hard interface | |
219 | * @lq_update_lock: lock protecting tq_recv & tq_index | |
220 | * @refcount: number of contexts the object is used | |
221 | * @rcu: struct used for freeing in an RCU-safe manner | |
c6c8fea2 | 222 | */ |
56303d34 | 223 | struct batadv_neigh_node { |
9591a79f | 224 | struct hlist_node list; |
c6c8fea2 | 225 | uint8_t addr[ETH_ALEN]; |
42d0b044 | 226 | uint8_t tq_recv[BATADV_TQ_GLOBAL_WINDOW_SIZE]; |
c6c8fea2 SE |
227 | uint8_t tq_index; |
228 | uint8_t tq_avg; | |
229 | uint8_t last_ttl; | |
a4c135c5 | 230 | struct list_head bonding_list; |
d7b2a97e | 231 | unsigned long last_seen; |
42d0b044 | 232 | DECLARE_BITMAP(real_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); |
88a32c9a | 233 | uint8_t real_packet_count; |
56303d34 SE |
234 | struct batadv_orig_node *orig_node; |
235 | struct batadv_hard_iface *if_incoming; | |
88a32c9a ML |
236 | spinlock_t lq_update_lock; /* protects tq_recv & tq_index */ |
237 | atomic_t refcount; | |
238 | struct rcu_head rcu; | |
c6c8fea2 SE |
239 | }; |
240 | ||
88a32c9a ML |
241 | /** |
242 | * struct batadv_bcast_duplist_entry - structure for LAN broadcast suppression | |
243 | * @orig[ETH_ALEN]: mac address of orig node orginating the broadcast | |
244 | * @crc: crc32 checksum of broadcast payload | |
245 | * @entrytime: time when the broadcast packet was received | |
246 | */ | |
7a5cc242 | 247 | #ifdef CONFIG_BATMAN_ADV_BLA |
56303d34 | 248 | struct batadv_bcast_duplist_entry { |
fe2da6ff | 249 | uint8_t orig[ETH_ALEN]; |
004e86fc | 250 | __be32 crc; |
fe2da6ff SW |
251 | unsigned long entrytime; |
252 | }; | |
7a5cc242 | 253 | #endif |
c6c8fea2 | 254 | |
88a32c9a ML |
255 | /** |
256 | * enum batadv_counters - indices for traffic counters | |
257 | * @BATADV_CNT_TX: transmitted payload traffic packet counter | |
258 | * @BATADV_CNT_TX_BYTES: transmitted payload traffic bytes counter | |
259 | * @BATADV_CNT_TX_DROPPED: dropped transmission payload traffic packet counter | |
260 | * @BATADV_CNT_RX: received payload traffic packet counter | |
261 | * @BATADV_CNT_RX_BYTES: received payload traffic bytes counter | |
262 | * @BATADV_CNT_FORWARD: forwarded payload traffic packet counter | |
263 | * @BATADV_CNT_FORWARD_BYTES: forwarded payload traffic bytes counter | |
264 | * @BATADV_CNT_MGMT_TX: transmitted routing protocol traffic packet counter | |
265 | * @BATADV_CNT_MGMT_TX_BYTES: transmitted routing protocol traffic bytes counter | |
266 | * @BATADV_CNT_MGMT_RX: received routing protocol traffic packet counter | |
267 | * @BATADV_CNT_MGMT_RX_BYTES: received routing protocol traffic bytes counter | |
268 | * @BATADV_CNT_TT_REQUEST_TX: transmitted tt req traffic packet counter | |
269 | * @BATADV_CNT_TT_REQUEST_RX: received tt req traffic packet counter | |
270 | * @BATADV_CNT_TT_RESPONSE_TX: transmitted tt resp traffic packet counter | |
271 | * @BATADV_CNT_TT_RESPONSE_RX: received tt resp traffic packet counter | |
272 | * @BATADV_CNT_TT_ROAM_ADV_TX: transmitted tt roam traffic packet counter | |
273 | * @BATADV_CNT_TT_ROAM_ADV_RX: received tt roam traffic packet counter | |
274 | * @BATADV_CNT_DAT_GET_TX: transmitted dht GET traffic packet counter | |
275 | * @BATADV_CNT_DAT_GET_RX: received dht GET traffic packet counter | |
276 | * @BATADV_CNT_DAT_PUT_TX: transmitted dht PUT traffic packet counter | |
277 | * @BATADV_CNT_DAT_PUT_RX: received dht PUT traffic packet counter | |
278 | * @BATADV_CNT_DAT_CACHED_REPLY_TX: transmitted dat cache reply traffic packet | |
279 | * counter | |
3c12de9a MH |
280 | * @BATADV_CNT_NC_CODE: transmitted nc-combined traffic packet counter |
281 | * @BATADV_CNT_NC_CODE_BYTES: transmitted nc-combined traffic bytes counter | |
282 | * @BATADV_CNT_NC_RECODE: transmitted nc-recombined traffic packet counter | |
283 | * @BATADV_CNT_NC_RECODE_BYTES: transmitted nc-recombined traffic bytes counter | |
612d2b4f | 284 | * @BATADV_CNT_NC_BUFFER: counter for packets buffered for later nc decoding |
2df5278b MH |
285 | * @BATADV_CNT_NC_DECODE: received and nc-decoded traffic packet counter |
286 | * @BATADV_CNT_NC_DECODE_BYTES: received and nc-decoded traffic bytes counter | |
287 | * @BATADV_CNT_NC_DECODE_FAILED: received and decode-failed traffic packet | |
288 | * counter | |
289 | * @BATADV_CNT_NC_SNIFFED: counter for nc-decoded packets received in promisc | |
290 | * mode. | |
88a32c9a ML |
291 | * @BATADV_CNT_NUM: number of traffic counters |
292 | */ | |
d69909d2 | 293 | enum batadv_counters { |
1c9b0550 ML |
294 | BATADV_CNT_TX, |
295 | BATADV_CNT_TX_BYTES, | |
296 | BATADV_CNT_TX_DROPPED, | |
297 | BATADV_CNT_RX, | |
298 | BATADV_CNT_RX_BYTES, | |
d69909d2 SE |
299 | BATADV_CNT_FORWARD, |
300 | BATADV_CNT_FORWARD_BYTES, | |
301 | BATADV_CNT_MGMT_TX, | |
302 | BATADV_CNT_MGMT_TX_BYTES, | |
303 | BATADV_CNT_MGMT_RX, | |
304 | BATADV_CNT_MGMT_RX_BYTES, | |
305 | BATADV_CNT_TT_REQUEST_TX, | |
306 | BATADV_CNT_TT_REQUEST_RX, | |
307 | BATADV_CNT_TT_RESPONSE_TX, | |
308 | BATADV_CNT_TT_RESPONSE_RX, | |
309 | BATADV_CNT_TT_ROAM_ADV_TX, | |
310 | BATADV_CNT_TT_ROAM_ADV_RX, | |
4046b24a MH |
311 | #ifdef CONFIG_BATMAN_ADV_DAT |
312 | BATADV_CNT_DAT_GET_TX, | |
313 | BATADV_CNT_DAT_GET_RX, | |
314 | BATADV_CNT_DAT_PUT_TX, | |
315 | BATADV_CNT_DAT_PUT_RX, | |
316 | BATADV_CNT_DAT_CACHED_REPLY_TX, | |
3c12de9a MH |
317 | #endif |
318 | #ifdef CONFIG_BATMAN_ADV_NC | |
319 | BATADV_CNT_NC_CODE, | |
320 | BATADV_CNT_NC_CODE_BYTES, | |
321 | BATADV_CNT_NC_RECODE, | |
322 | BATADV_CNT_NC_RECODE_BYTES, | |
612d2b4f | 323 | BATADV_CNT_NC_BUFFER, |
2df5278b MH |
324 | BATADV_CNT_NC_DECODE, |
325 | BATADV_CNT_NC_DECODE_BYTES, | |
326 | BATADV_CNT_NC_DECODE_FAILED, | |
327 | BATADV_CNT_NC_SNIFFED, | |
4046b24a | 328 | #endif |
d69909d2 | 329 | BATADV_CNT_NUM, |
f8214865 MH |
330 | }; |
331 | ||
807736f6 SE |
332 | /** |
333 | * struct batadv_priv_tt - per mesh interface translation table data | |
334 | * @vn: translation table version number | |
88a32c9a | 335 | * @ogm_append_cnt: counter of number of OGMs containing the local tt diff |
807736f6 | 336 | * @local_changes: changes registered in an originator interval |
807736f6 | 337 | * @changes_list: tracks tt local changes within an originator interval |
88a32c9a ML |
338 | * @local_hash: local translation table hash table |
339 | * @global_hash: global translation table hash table | |
340 | * @req_list: list of pending & unanswered tt_requests | |
341 | * @roam_list: list of the last roaming events of each client limiting the | |
342 | * number of roaming events to avoid route flapping | |
343 | * @changes_list_lock: lock protecting changes_list | |
344 | * @req_list_lock: lock protecting req_list | |
345 | * @roam_list_lock: lock protecting roam_list | |
346 | * @local_entry_num: number of entries in the local hash table | |
807736f6 | 347 | * @local_crc: Checksum of the local table, recomputed before sending a new OGM |
88a32c9a ML |
348 | * @last_changeset: last tt changeset this host has generated |
349 | * @last_changeset_len: length of last tt changeset this host has generated | |
350 | * @last_changeset_lock: lock protecting last_changeset & last_changeset_len | |
351 | * @work: work queue callback item for translation table purging | |
807736f6 SE |
352 | */ |
353 | struct batadv_priv_tt { | |
354 | atomic_t vn; | |
355 | atomic_t ogm_append_cnt; | |
356 | atomic_t local_changes; | |
807736f6 SE |
357 | struct list_head changes_list; |
358 | struct batadv_hashtable *local_hash; | |
359 | struct batadv_hashtable *global_hash; | |
360 | struct list_head req_list; | |
361 | struct list_head roam_list; | |
362 | spinlock_t changes_list_lock; /* protects changes */ | |
363 | spinlock_t req_list_lock; /* protects req_list */ | |
364 | spinlock_t roam_list_lock; /* protects roam_list */ | |
365 | atomic_t local_entry_num; | |
366 | uint16_t local_crc; | |
367 | unsigned char *last_changeset; | |
368 | int16_t last_changeset_len; | |
88a32c9a ML |
369 | /* protects last_changeset & last_changeset_len */ |
370 | spinlock_t last_changeset_lock; | |
807736f6 SE |
371 | struct delayed_work work; |
372 | }; | |
373 | ||
88a32c9a ML |
374 | /** |
375 | * struct batadv_priv_bla - per mesh interface bridge loope avoidance data | |
376 | * @num_requests; number of bla requests in flight | |
377 | * @claim_hash: hash table containing mesh nodes this host has claimed | |
378 | * @backbone_hash: hash table containing all detected backbone gateways | |
379 | * @bcast_duplist: recently received broadcast packets array (for broadcast | |
380 | * duplicate suppression) | |
381 | * @bcast_duplist_curr: index of last broadcast packet added to bcast_duplist | |
382 | * @bcast_duplist_lock: lock protecting bcast_duplist & bcast_duplist_curr | |
383 | * @claim_dest: local claim data (e.g. claim group) | |
384 | * @work: work queue callback item for cleanups & bla announcements | |
385 | */ | |
807736f6 SE |
386 | #ifdef CONFIG_BATMAN_ADV_BLA |
387 | struct batadv_priv_bla { | |
88a32c9a | 388 | atomic_t num_requests; |
807736f6 SE |
389 | struct batadv_hashtable *claim_hash; |
390 | struct batadv_hashtable *backbone_hash; | |
391 | struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; | |
392 | int bcast_duplist_curr; | |
88a32c9a | 393 | /* protects bcast_duplist & bcast_duplist_curr */ |
7dac7b76 | 394 | spinlock_t bcast_duplist_lock; |
807736f6 SE |
395 | struct batadv_bla_claim_dst claim_dest; |
396 | struct delayed_work work; | |
397 | }; | |
398 | #endif | |
399 | ||
88a32c9a ML |
400 | /** |
401 | * struct batadv_debug_log - debug logging data | |
402 | * @log_buff: buffer holding the logs (ring bufer) | |
403 | * @log_start: index of next character to read | |
404 | * @log_end: index of next character to write | |
405 | * @lock: lock protecting log_buff, log_start & log_end | |
406 | * @queue_wait: log reader's wait queue | |
407 | */ | |
0abf5d81 ML |
408 | #ifdef CONFIG_BATMAN_ADV_DEBUG |
409 | struct batadv_priv_debug_log { | |
410 | char log_buff[BATADV_LOG_BUF_LEN]; | |
411 | unsigned long log_start; | |
412 | unsigned long log_end; | |
413 | spinlock_t lock; /* protects log_buff, log_start and log_end */ | |
414 | wait_queue_head_t queue_wait; | |
415 | }; | |
416 | #endif | |
417 | ||
88a32c9a ML |
418 | /** |
419 | * struct batadv_priv_gw - per mesh interface gateway data | |
420 | * @list: list of available gateway nodes | |
421 | * @list_lock: lock protecting gw_list & curr_gw | |
422 | * @curr_gw: pointer to currently selected gateway node | |
423 | * @reselect: bool indicating a gateway re-selection is in progress | |
424 | */ | |
807736f6 SE |
425 | struct batadv_priv_gw { |
426 | struct hlist_head list; | |
88a32c9a | 427 | spinlock_t list_lock; /* protects gw_list & curr_gw */ |
807736f6 SE |
428 | struct batadv_gw_node __rcu *curr_gw; /* rcu protected pointer */ |
429 | atomic_t reselect; | |
430 | }; | |
431 | ||
ef261577 ML |
432 | /** |
433 | * struct batadv_priv_tvlv - per mesh interface tvlv data | |
434 | * @container_list: list of registered tvlv containers to be sent with each OGM | |
435 | * @handler_list: list of the various tvlv content handlers | |
436 | * @container_list_lock: protects tvlv container list access | |
437 | * @handler_list_lock: protects handler list access | |
438 | */ | |
439 | struct batadv_priv_tvlv { | |
440 | struct hlist_head container_list; | |
441 | struct hlist_head handler_list; | |
442 | spinlock_t container_list_lock; /* protects container_list */ | |
443 | spinlock_t handler_list_lock; /* protects handler_list */ | |
444 | }; | |
445 | ||
88a32c9a ML |
446 | /** |
447 | * struct batadv_priv_vis - per mesh interface vis data | |
448 | * @send_list: list of batadv_vis_info packets to sent | |
449 | * @hash: hash table containing vis data from other nodes in the network | |
450 | * @hash_lock: lock protecting the hash table | |
451 | * @list_lock: lock protecting my_info::recv_list | |
452 | * @work: work queue callback item for vis packet sending | |
453 | * @my_info: holds this node's vis data sent on a regular basis | |
454 | */ | |
807736f6 SE |
455 | struct batadv_priv_vis { |
456 | struct list_head send_list; | |
457 | struct batadv_hashtable *hash; | |
458 | spinlock_t hash_lock; /* protects hash */ | |
88a32c9a | 459 | spinlock_t list_lock; /* protects my_info::recv_list */ |
807736f6 SE |
460 | struct delayed_work work; |
461 | struct batadv_vis_info *my_info; | |
462 | }; | |
463 | ||
785ea114 AQ |
464 | /** |
465 | * struct batadv_priv_dat - per mesh interface DAT private data | |
466 | * @addr: node DAT address | |
2f1dfbe1 AQ |
467 | * @hash: hashtable representing the local ARP cache |
468 | * @work: work queue callback item for cache purging | |
785ea114 | 469 | */ |
17224474 | 470 | #ifdef CONFIG_BATMAN_ADV_DAT |
785ea114 AQ |
471 | struct batadv_priv_dat { |
472 | batadv_dat_addr_t addr; | |
2f1dfbe1 AQ |
473 | struct batadv_hashtable *hash; |
474 | struct delayed_work work; | |
785ea114 | 475 | }; |
17224474 | 476 | #endif |
785ea114 | 477 | |
d353d8d4 MH |
478 | /** |
479 | * struct batadv_priv_nc - per mesh interface network coding private data | |
480 | * @work: work queue callback item for cleanup | |
d56b1705 MH |
481 | * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs |
482 | * @min_tq: only consider neighbors for encoding if neigh_tq > min_tq | |
95332477 | 483 | * @max_fwd_delay: maximum packet forward delay to allow coding of packets |
612d2b4f | 484 | * @max_buffer_time: buffer time for sniffed packets used to decoding |
95332477 | 485 | * @timestamp_fwd_flush: timestamp of last forward packet queue flush |
612d2b4f | 486 | * @timestamp_sniffed_purge: timestamp of last sniffed packet queue purge |
95332477 MH |
487 | * @coding_hash: Hash table used to buffer skbs while waiting for another |
488 | * incoming skb to code it with. Skbs are added to the buffer just before being | |
489 | * forwarded in routing.c | |
612d2b4f MH |
490 | * @decoding_hash: Hash table used to buffer skbs that might be needed to decode |
491 | * a received coded skb. The buffer is used for 1) skbs arriving on the | |
492 | * soft-interface; 2) skbs overheard on the hard-interface; and 3) skbs | |
493 | * forwarded by batman-adv. | |
d353d8d4 MH |
494 | */ |
495 | struct batadv_priv_nc { | |
496 | struct delayed_work work; | |
d56b1705 MH |
497 | struct dentry *debug_dir; |
498 | u8 min_tq; | |
95332477 | 499 | u32 max_fwd_delay; |
612d2b4f | 500 | u32 max_buffer_time; |
95332477 | 501 | unsigned long timestamp_fwd_flush; |
612d2b4f | 502 | unsigned long timestamp_sniffed_purge; |
95332477 | 503 | struct batadv_hashtable *coding_hash; |
612d2b4f | 504 | struct batadv_hashtable *decoding_hash; |
d353d8d4 MH |
505 | }; |
506 | ||
88a32c9a ML |
507 | /** |
508 | * struct batadv_priv - per mesh interface data | |
509 | * @mesh_state: current status of the mesh (inactive/active/deactivating) | |
5bc44dc8 | 510 | * @soft_iface: net device which holds this struct as private data |
88a32c9a ML |
511 | * @stats: structure holding the data for the ndo_get_stats() call |
512 | * @bat_counters: mesh internal traffic statistic counters (see batadv_counters) | |
513 | * @aggregated_ogms: bool indicating whether OGM aggregation is enabled | |
514 | * @bonding: bool indicating whether traffic bonding is enabled | |
515 | * @fragmentation: bool indicating whether traffic fragmentation is enabled | |
516 | * @ap_isolation: bool indicating whether ap isolation is enabled | |
517 | * @bridge_loop_avoidance: bool indicating whether bridge loop avoidance is | |
518 | * enabled | |
519 | * @distributed_arp_table: bool indicating whether distributed ARP table is | |
520 | * enabled | |
521 | * @vis_mode: vis operation: client or server (see batadv_vis_packettype) | |
522 | * @gw_mode: gateway operation: off, client or server (see batadv_gw_modes) | |
523 | * @gw_sel_class: gateway selection class (applies if gw_mode client) | |
524 | * @gw_bandwidth: gateway announced bandwidth (applies if gw_mode server) | |
525 | * @orig_interval: OGM broadcast interval in milliseconds | |
526 | * @hop_penalty: penalty which will be applied to an OGM's tq-field on every hop | |
527 | * @log_level: configured log level (see batadv_dbg_level) | |
528 | * @bcast_seqno: last sent broadcast packet sequence number | |
529 | * @bcast_queue_left: number of remaining buffered broadcast packet slots | |
530 | * @batman_queue_left: number of remaining OGM packet slots | |
531 | * @num_ifaces: number of interfaces assigned to this mesh interface | |
532 | * @mesh_obj: kobject for sysfs mesh subdirectory | |
533 | * @debug_dir: dentry for debugfs batman-adv subdirectory | |
534 | * @forw_bat_list: list of aggregated OGMs that will be forwarded | |
535 | * @forw_bcast_list: list of broadcast packets that will be rebroadcasted | |
536 | * @orig_hash: hash table containing mesh participants (orig nodes) | |
537 | * @forw_bat_list_lock: lock protecting forw_bat_list | |
538 | * @forw_bcast_list_lock: lock protecting forw_bcast_list | |
539 | * @orig_work: work queue callback item for orig node purging | |
5bc44dc8 | 540 | * @cleanup_work: work queue callback item for soft interface deinit |
88a32c9a ML |
541 | * @primary_if: one of the hard interfaces assigned to this mesh interface |
542 | * becomes the primary interface | |
543 | * @bat_algo_ops: routing algorithm used by this mesh interface | |
544 | * @bla: bridge loope avoidance data | |
545 | * @debug_log: holding debug logging relevant data | |
546 | * @gw: gateway data | |
547 | * @tt: translation table data | |
ef261577 | 548 | * @tvlv: type-version-length-value data |
88a32c9a ML |
549 | * @vis: vis data |
550 | * @dat: distributed arp table data | |
d353d8d4 MH |
551 | * @network_coding: bool indicating whether network coding is enabled |
552 | * @batadv_priv_nc: network coding data | |
88a32c9a | 553 | */ |
56303d34 | 554 | struct batadv_priv { |
c6c8fea2 | 555 | atomic_t mesh_state; |
5bc44dc8 | 556 | struct net_device *soft_iface; |
c6c8fea2 | 557 | struct net_device_stats stats; |
f8214865 | 558 | uint64_t __percpu *bat_counters; /* Per cpu counters */ |
88a32c9a ML |
559 | atomic_t aggregated_ogms; |
560 | atomic_t bonding; | |
561 | atomic_t fragmentation; | |
562 | atomic_t ap_isolation; | |
fa706554 | 563 | #ifdef CONFIG_BATMAN_ADV_BLA |
88a32c9a | 564 | atomic_t bridge_loop_avoidance; |
fa706554 | 565 | #endif |
33af49ad | 566 | #ifdef CONFIG_BATMAN_ADV_DAT |
88a32c9a | 567 | atomic_t distributed_arp_table; |
33af49ad | 568 | #endif |
88a32c9a ML |
569 | atomic_t vis_mode; |
570 | atomic_t gw_mode; | |
571 | atomic_t gw_sel_class; | |
572 | atomic_t gw_bandwidth; | |
573 | atomic_t orig_interval; | |
574 | atomic_t hop_penalty; | |
0c430d0d | 575 | #ifdef CONFIG_BATMAN_ADV_DEBUG |
88a32c9a | 576 | atomic_t log_level; |
0c430d0d | 577 | #endif |
c6c8fea2 SE |
578 | atomic_t bcast_seqno; |
579 | atomic_t bcast_queue_left; | |
580 | atomic_t batman_queue_left; | |
581 | char num_ifaces; | |
c6c8fea2 SE |
582 | struct kobject *mesh_obj; |
583 | struct dentry *debug_dir; | |
584 | struct hlist_head forw_bat_list; | |
585 | struct hlist_head forw_bcast_list; | |
5bf74e9c | 586 | struct batadv_hashtable *orig_hash; |
c6c8fea2 | 587 | spinlock_t forw_bat_list_lock; /* protects forw_bat_list */ |
a7528f8d | 588 | spinlock_t forw_bcast_list_lock; /* protects forw_bcast_list */ |
c6c8fea2 | 589 | struct delayed_work orig_work; |
5bc44dc8 | 590 | struct work_struct cleanup_work; |
56303d34 | 591 | struct batadv_hard_iface __rcu *primary_if; /* rcu protected pointer */ |
56303d34 | 592 | struct batadv_algo_ops *bat_algo_ops; |
807736f6 SE |
593 | #ifdef CONFIG_BATMAN_ADV_BLA |
594 | struct batadv_priv_bla bla; | |
0abf5d81 ML |
595 | #endif |
596 | #ifdef CONFIG_BATMAN_ADV_DEBUG | |
597 | struct batadv_priv_debug_log *debug_log; | |
807736f6 SE |
598 | #endif |
599 | struct batadv_priv_gw gw; | |
600 | struct batadv_priv_tt tt; | |
ef261577 | 601 | struct batadv_priv_tvlv tvlv; |
807736f6 | 602 | struct batadv_priv_vis vis; |
17224474 | 603 | #ifdef CONFIG_BATMAN_ADV_DAT |
785ea114 | 604 | struct batadv_priv_dat dat; |
17224474 | 605 | #endif |
d353d8d4 MH |
606 | #ifdef CONFIG_BATMAN_ADV_NC |
607 | atomic_t network_coding; | |
608 | struct batadv_priv_nc nc; | |
609 | #endif /* CONFIG_BATMAN_ADV_NC */ | |
c6c8fea2 SE |
610 | }; |
611 | ||
88a32c9a ML |
612 | /** |
613 | * struct batadv_socket_client - layer2 icmp socket client data | |
614 | * @queue_list: packet queue for packets destined for this socket client | |
615 | * @queue_len: number of packets in the packet queue (queue_list) | |
616 | * @index: socket client's index in the batadv_socket_client_hash | |
617 | * @lock: lock protecting queue_list, queue_len & index | |
618 | * @queue_wait: socket client's wait queue | |
619 | * @bat_priv: pointer to soft_iface this client belongs to | |
620 | */ | |
56303d34 | 621 | struct batadv_socket_client { |
c6c8fea2 SE |
622 | struct list_head queue_list; |
623 | unsigned int queue_len; | |
624 | unsigned char index; | |
88a32c9a | 625 | spinlock_t lock; /* protects queue_list, queue_len & index */ |
c6c8fea2 | 626 | wait_queue_head_t queue_wait; |
56303d34 | 627 | struct batadv_priv *bat_priv; |
c6c8fea2 SE |
628 | }; |
629 | ||
88a32c9a ML |
630 | /** |
631 | * struct batadv_socket_packet - layer2 icmp packet for socket client | |
632 | * @list: list node for batadv_socket_client::queue_list | |
633 | * @icmp_len: size of the layer2 icmp packet | |
634 | * @icmp_packet: layer2 icmp packet | |
635 | */ | |
56303d34 | 636 | struct batadv_socket_packet { |
c6c8fea2 SE |
637 | struct list_head list; |
638 | size_t icmp_len; | |
96412690 | 639 | struct batadv_icmp_packet_rr icmp_packet; |
c6c8fea2 SE |
640 | }; |
641 | ||
88a32c9a ML |
642 | /** |
643 | * struct batadv_bla_backbone_gw - batman-adv gateway bridged into the LAN | |
644 | * @orig: originator address of backbone node (mac address of primary iface) | |
645 | * @vid: vlan id this gateway was detected on | |
646 | * @hash_entry: hlist node for batadv_priv_bla::backbone_hash | |
647 | * @bat_priv: pointer to soft_iface this backbone gateway belongs to | |
648 | * @lasttime: last time we heard of this backbone gw | |
649 | * @wait_periods: grace time for bridge forward delays and bla group forming at | |
650 | * bootup phase - no bcast traffic is formwared until it has elapsed | |
651 | * @request_sent: if this bool is set to true we are out of sync with this | |
652 | * backbone gateway - no bcast traffic is formwared until the situation was | |
653 | * resolved | |
654 | * @crc: crc16 checksum over all claims | |
655 | * @refcount: number of contexts the object is used | |
656 | * @rcu: struct used for freeing in an RCU-safe manner | |
657 | */ | |
2006fea8 | 658 | #ifdef CONFIG_BATMAN_ADV_BLA |
bae98774 | 659 | struct batadv_bla_backbone_gw { |
2006fea8 | 660 | uint8_t orig[ETH_ALEN]; |
eb2deb6b | 661 | unsigned short vid; |
2006fea8 ML |
662 | struct hlist_node hash_entry; |
663 | struct batadv_priv *bat_priv; | |
88a32c9a | 664 | unsigned long lasttime; |
2006fea8 ML |
665 | atomic_t wait_periods; |
666 | atomic_t request_sent; | |
88a32c9a | 667 | uint16_t crc; |
2006fea8 ML |
668 | atomic_t refcount; |
669 | struct rcu_head rcu; | |
2006fea8 ML |
670 | }; |
671 | ||
88a32c9a ML |
672 | /** |
673 | * struct batadv_bla_claim - claimed non-mesh client structure | |
674 | * @addr: mac address of claimed non-mesh client | |
675 | * @vid: vlan id this client was detected on | |
676 | * @batadv_bla_backbone_gw: pointer to backbone gw claiming this client | |
677 | * @lasttime: last time we heard of claim (locals only) | |
678 | * @hash_entry: hlist node for batadv_priv_bla::claim_hash | |
679 | * @refcount: number of contexts the object is used | |
680 | * @rcu: struct used for freeing in an RCU-safe manner | |
681 | */ | |
712bbfe4 | 682 | struct batadv_bla_claim { |
2006fea8 | 683 | uint8_t addr[ETH_ALEN]; |
eb2deb6b | 684 | unsigned short vid; |
bae98774 | 685 | struct batadv_bla_backbone_gw *backbone_gw; |
88a32c9a ML |
686 | unsigned long lasttime; |
687 | struct hlist_node hash_entry; | |
2006fea8 ML |
688 | struct rcu_head rcu; |
689 | atomic_t refcount; | |
2006fea8 ML |
690 | }; |
691 | #endif | |
692 | ||
88a32c9a ML |
693 | /** |
694 | * struct batadv_tt_common_entry - tt local & tt global common data | |
695 | * @addr: mac address of non-mesh client | |
696 | * @hash_entry: hlist node for batadv_priv_tt::local_hash or for | |
697 | * batadv_priv_tt::global_hash | |
698 | * @flags: various state handling flags (see batadv_tt_client_flags) | |
699 | * @added_at: timestamp used for purging stale tt common entries | |
700 | * @refcount: number of contexts the object is used | |
701 | * @rcu: struct used for freeing in an RCU-safe manner | |
702 | */ | |
56303d34 | 703 | struct batadv_tt_common_entry { |
c6c8fea2 | 704 | uint8_t addr[ETH_ALEN]; |
93840ac4 | 705 | struct hlist_node hash_entry; |
5fbc1598 | 706 | uint16_t flags; |
30cfd02b | 707 | unsigned long added_at; |
7683fdc1 AQ |
708 | atomic_t refcount; |
709 | struct rcu_head rcu; | |
c6c8fea2 SE |
710 | }; |
711 | ||
88a32c9a ML |
712 | /** |
713 | * struct batadv_tt_local_entry - translation table local entry data | |
714 | * @common: general translation table data | |
715 | * @last_seen: timestamp used for purging stale tt local entries | |
716 | */ | |
56303d34 SE |
717 | struct batadv_tt_local_entry { |
718 | struct batadv_tt_common_entry common; | |
48100bac AQ |
719 | unsigned long last_seen; |
720 | }; | |
721 | ||
88a32c9a ML |
722 | /** |
723 | * struct batadv_tt_global_entry - translation table global entry data | |
724 | * @common: general translation table data | |
725 | * @orig_list: list of orig nodes announcing this non-mesh client | |
726 | * @list_lock: lock protecting orig_list | |
727 | * @roam_at: time at which TT_GLOBAL_ROAM was set | |
728 | */ | |
56303d34 SE |
729 | struct batadv_tt_global_entry { |
730 | struct batadv_tt_common_entry common; | |
db08e6e5 | 731 | struct hlist_head orig_list; |
88a32c9a ML |
732 | spinlock_t list_lock; /* protects orig_list */ |
733 | unsigned long roam_at; | |
db08e6e5 SW |
734 | }; |
735 | ||
88a32c9a ML |
736 | /** |
737 | * struct batadv_tt_orig_list_entry - orig node announcing a non-mesh client | |
738 | * @orig_node: pointer to orig node announcing this non-mesh client | |
739 | * @ttvn: translation table version number which added the non-mesh client | |
740 | * @list: list node for batadv_tt_global_entry::orig_list | |
741 | * @refcount: number of contexts the object is used | |
742 | * @rcu: struct used for freeing in an RCU-safe manner | |
743 | */ | |
56303d34 SE |
744 | struct batadv_tt_orig_list_entry { |
745 | struct batadv_orig_node *orig_node; | |
a73105b8 | 746 | uint8_t ttvn; |
88a32c9a | 747 | struct hlist_node list; |
d657e621 | 748 | atomic_t refcount; |
db08e6e5 | 749 | struct rcu_head rcu; |
c6c8fea2 SE |
750 | }; |
751 | ||
88a32c9a ML |
752 | /** |
753 | * struct batadv_tt_change_node - structure for tt changes occured | |
754 | * @list: list node for batadv_priv_tt::changes_list | |
755 | * @change: holds the actual translation table diff data | |
756 | */ | |
56303d34 | 757 | struct batadv_tt_change_node { |
a73105b8 | 758 | struct list_head list; |
96412690 | 759 | struct batadv_tt_change change; |
a73105b8 AQ |
760 | }; |
761 | ||
88a32c9a ML |
762 | /** |
763 | * struct batadv_tt_req_node - data to keep track of the tt requests in flight | |
764 | * @addr: mac address address of the originator this request was sent to | |
765 | * @issued_at: timestamp used for purging stale tt requests | |
766 | * @list: list node for batadv_priv_tt::req_list | |
767 | */ | |
56303d34 | 768 | struct batadv_tt_req_node { |
a73105b8 AQ |
769 | uint8_t addr[ETH_ALEN]; |
770 | unsigned long issued_at; | |
771 | struct list_head list; | |
772 | }; | |
773 | ||
88a32c9a ML |
774 | /** |
775 | * struct batadv_tt_roam_node - roaming client data | |
776 | * @addr: mac address of the client in the roaming phase | |
777 | * @counter: number of allowed roaming events per client within a single | |
778 | * OGM interval (changes are committed with each OGM) | |
779 | * @first_time: timestamp used for purging stale roaming node entries | |
780 | * @list: list node for batadv_priv_tt::roam_list | |
781 | */ | |
56303d34 | 782 | struct batadv_tt_roam_node { |
cc47f66e AQ |
783 | uint8_t addr[ETH_ALEN]; |
784 | atomic_t counter; | |
785 | unsigned long first_time; | |
786 | struct list_head list; | |
787 | }; | |
788 | ||
d56b1705 MH |
789 | /** |
790 | * struct batadv_nc_node - network coding node | |
791 | * @list: next and prev pointer for the list handling | |
792 | * @addr: the node's mac address | |
793 | * @refcount: number of contexts the object is used by | |
794 | * @rcu: struct used for freeing in an RCU-safe manner | |
795 | * @orig_node: pointer to corresponding orig node struct | |
796 | * @last_seen: timestamp of last ogm received from this node | |
797 | */ | |
798 | struct batadv_nc_node { | |
799 | struct list_head list; | |
800 | uint8_t addr[ETH_ALEN]; | |
801 | atomic_t refcount; | |
802 | struct rcu_head rcu; | |
803 | struct batadv_orig_node *orig_node; | |
804 | unsigned long last_seen; | |
805 | }; | |
806 | ||
95332477 MH |
807 | /** |
808 | * struct batadv_nc_path - network coding path | |
809 | * @hash_entry: next and prev pointer for the list handling | |
810 | * @rcu: struct used for freeing in an RCU-safe manner | |
811 | * @refcount: number of contexts the object is used by | |
812 | * @packet_list: list of buffered packets for this path | |
813 | * @packet_list_lock: access lock for packet list | |
814 | * @next_hop: next hop (destination) of path | |
815 | * @prev_hop: previous hop (source) of path | |
816 | * @last_valid: timestamp for last validation of path | |
817 | */ | |
818 | struct batadv_nc_path { | |
819 | struct hlist_node hash_entry; | |
820 | struct rcu_head rcu; | |
821 | atomic_t refcount; | |
822 | struct list_head packet_list; | |
823 | spinlock_t packet_list_lock; /* Protects packet_list */ | |
824 | uint8_t next_hop[ETH_ALEN]; | |
825 | uint8_t prev_hop[ETH_ALEN]; | |
826 | unsigned long last_valid; | |
827 | }; | |
828 | ||
829 | /** | |
830 | * struct batadv_nc_packet - network coding packet used when coding and | |
831 | * decoding packets | |
832 | * @list: next and prev pointer for the list handling | |
833 | * @packet_id: crc32 checksum of skb data | |
834 | * @timestamp: field containing the info when the packet was added to path | |
835 | * @neigh_node: pointer to original next hop neighbor of skb | |
836 | * @skb: skb which can be encoded or used for decoding | |
837 | * @nc_path: pointer to path this nc packet is attached to | |
838 | */ | |
839 | struct batadv_nc_packet { | |
840 | struct list_head list; | |
841 | __be32 packet_id; | |
842 | unsigned long timestamp; | |
843 | struct batadv_neigh_node *neigh_node; | |
844 | struct sk_buff *skb; | |
845 | struct batadv_nc_path *nc_path; | |
846 | }; | |
847 | ||
3c12de9a MH |
848 | /** |
849 | * batadv_skb_cb - control buffer structure used to store private data relevant | |
850 | * to batman-adv in the skb->cb buffer in skbs. | |
851 | * @decoded: Marks a skb as decoded, which is checked when searching for coding | |
852 | * opportunities in network-coding.c | |
853 | */ | |
854 | struct batadv_skb_cb { | |
855 | bool decoded; | |
856 | }; | |
857 | ||
88a32c9a ML |
858 | /** |
859 | * struct batadv_forw_packet - structure for bcast packets to be sent/forwarded | |
860 | * @list: list node for batadv_socket_client::queue_list | |
861 | * @send_time: execution time for delayed_work (packet sending) | |
862 | * @own: bool for locally generated packets (local OGMs are re-scheduled after | |
863 | * sending) | |
864 | * @skb: bcast packet's skb buffer | |
865 | * @packet_len: size of aggregated OGM packet inside the skb buffer | |
866 | * @direct_link_flags: direct link flags for aggregated OGM packets | |
867 | * @num_packets: counter for bcast packet retransmission | |
868 | * @delayed_work: work queue callback item for packet sending | |
869 | * @if_incoming: pointer incoming hard-iface or primary iface if locally | |
870 | * generated packet | |
c6c8fea2 | 871 | */ |
56303d34 | 872 | struct batadv_forw_packet { |
c6c8fea2 SE |
873 | struct hlist_node list; |
874 | unsigned long send_time; | |
875 | uint8_t own; | |
876 | struct sk_buff *skb; | |
877 | uint16_t packet_len; | |
878 | uint32_t direct_link_flags; | |
879 | uint8_t num_packets; | |
880 | struct delayed_work delayed_work; | |
56303d34 | 881 | struct batadv_hard_iface *if_incoming; |
c6c8fea2 SE |
882 | }; |
883 | ||
88a32c9a ML |
884 | /** |
885 | * struct batadv_frag_packet_list_entry - storage for fragment packet | |
886 | * @list: list node for orig_node::frag_list | |
887 | * @seqno: sequence number of the fragment | |
888 | * @skb: fragment's skb buffer | |
889 | */ | |
56303d34 | 890 | struct batadv_frag_packet_list_entry { |
c6c8fea2 SE |
891 | struct list_head list; |
892 | uint16_t seqno; | |
893 | struct sk_buff *skb; | |
894 | }; | |
895 | ||
88a32c9a ML |
896 | /** |
897 | * struct batadv_vis_info - local data for vis information | |
898 | * @first_seen: timestamp used for purging stale vis info entries | |
899 | * @recv_list: List of server-neighbors we have received this packet from. This | |
900 | * packet should not be re-forward to them again. List elements are struct | |
901 | * batadv_vis_recvlist_node | |
902 | * @send_list: list of packets to be forwarded | |
903 | * @refcount: number of contexts the object is used | |
904 | * @hash_entry: hlist node for batadv_priv_vis::hash | |
905 | * @bat_priv: pointer to soft_iface this orig node belongs to | |
906 | * @skb_packet: contains the vis packet | |
907 | */ | |
56303d34 | 908 | struct batadv_vis_info { |
40219672 | 909 | unsigned long first_seen; |
40219672 | 910 | struct list_head recv_list; |
c6c8fea2 SE |
911 | struct list_head send_list; |
912 | struct kref refcount; | |
7aadf889 | 913 | struct hlist_node hash_entry; |
56303d34 | 914 | struct batadv_priv *bat_priv; |
c6c8fea2 | 915 | struct sk_buff *skb_packet; |
aa0adb1a | 916 | } __packed; |
c6c8fea2 | 917 | |
88a32c9a ML |
918 | /** |
919 | * struct batadv_vis_info_entry - contains link information for vis | |
920 | * @src: source MAC of the link, all zero for local TT entry | |
921 | * @dst: destination MAC of the link, client mac address for local TT entry | |
922 | * @quality: transmission quality of the link, or 0 for local TT entry | |
923 | */ | |
56303d34 | 924 | struct batadv_vis_info_entry { |
c6c8fea2 SE |
925 | uint8_t src[ETH_ALEN]; |
926 | uint8_t dest[ETH_ALEN]; | |
88a32c9a | 927 | uint8_t quality; |
aa0adb1a | 928 | } __packed; |
c6c8fea2 | 929 | |
88a32c9a ML |
930 | /** |
931 | * struct batadv_vis_recvlist_node - list entry for batadv_vis_info::recv_list | |
932 | * @list: list node for batadv_vis_info::recv_list | |
933 | * @mac: MAC address of the originator from where the vis_info was received | |
934 | */ | |
28500f07 | 935 | struct batadv_vis_recvlist_node { |
c6c8fea2 SE |
936 | struct list_head list; |
937 | uint8_t mac[ETH_ALEN]; | |
938 | }; | |
939 | ||
88a32c9a ML |
940 | /** |
941 | * struct batadv_vis_if_list_entry - auxiliary data for vis data generation | |
942 | * @addr: MAC address of the interface | |
943 | * @primary: true if this interface is the primary interface | |
944 | * @list: list node the interface list | |
945 | * | |
946 | * While scanning for vis-entries of a particular vis-originator | |
015b4ae4 ML |
947 | * this list collects its interfaces to create a subgraph/cluster |
948 | * out of them later | |
949 | */ | |
950 | struct batadv_vis_if_list_entry { | |
951 | uint8_t addr[ETH_ALEN]; | |
952 | bool primary; | |
953 | struct hlist_node list; | |
954 | }; | |
955 | ||
88a32c9a ML |
956 | /** |
957 | * struct batadv_algo_ops - mesh algorithm callbacks | |
958 | * @list: list node for the batadv_algo_list | |
959 | * @name: name of the algorithm | |
960 | * @bat_iface_enable: init routing info when hard-interface is enabled | |
961 | * @bat_iface_disable: de-init routing info when hard-interface is disabled | |
962 | * @bat_iface_update_mac: (re-)init mac addresses of the protocol information | |
963 | * belonging to this hard-interface | |
964 | * @bat_primary_iface_set: called when primary interface is selected / changed | |
965 | * @bat_ogm_schedule: prepare a new outgoing OGM for the send queue | |
966 | * @bat_ogm_emit: send scheduled OGM | |
967 | */ | |
56303d34 | 968 | struct batadv_algo_ops { |
1c280471 ML |
969 | struct hlist_node list; |
970 | char *name; | |
56303d34 | 971 | int (*bat_iface_enable)(struct batadv_hard_iface *hard_iface); |
56303d34 | 972 | void (*bat_iface_disable)(struct batadv_hard_iface *hard_iface); |
56303d34 | 973 | void (*bat_iface_update_mac)(struct batadv_hard_iface *hard_iface); |
56303d34 | 974 | void (*bat_primary_iface_set)(struct batadv_hard_iface *hard_iface); |
56303d34 | 975 | void (*bat_ogm_schedule)(struct batadv_hard_iface *hard_iface); |
56303d34 | 976 | void (*bat_ogm_emit)(struct batadv_forw_packet *forw_packet); |
1c280471 ML |
977 | }; |
978 | ||
2f1dfbe1 AQ |
979 | /** |
980 | * struct batadv_dat_entry - it is a single entry of batman-adv ARP backend. It | |
981 | * is used to stored ARP entries needed for the global DAT cache | |
982 | * @ip: the IPv4 corresponding to this DAT/ARP entry | |
983 | * @mac_addr: the MAC address associated to the stored IPv4 | |
984 | * @last_update: time in jiffies when this entry was refreshed last time | |
985 | * @hash_entry: hlist node for batadv_priv_dat::hash | |
986 | * @refcount: number of contexts the object is used | |
987 | * @rcu: struct used for freeing in an RCU-safe manner | |
988 | */ | |
989 | struct batadv_dat_entry { | |
990 | __be32 ip; | |
991 | uint8_t mac_addr[ETH_ALEN]; | |
992 | unsigned long last_update; | |
993 | struct hlist_node hash_entry; | |
994 | atomic_t refcount; | |
995 | struct rcu_head rcu; | |
996 | }; | |
997 | ||
785ea114 AQ |
998 | /** |
999 | * struct batadv_dat_candidate - candidate destination for DAT operations | |
1000 | * @type: the type of the selected candidate. It can one of the following: | |
1001 | * - BATADV_DAT_CANDIDATE_NOT_FOUND | |
1002 | * - BATADV_DAT_CANDIDATE_ORIG | |
1003 | * @orig_node: if type is BATADV_DAT_CANDIDATE_ORIG this field points to the | |
1004 | * corresponding originator node structure | |
1005 | */ | |
1006 | struct batadv_dat_candidate { | |
1007 | int type; | |
1008 | struct batadv_orig_node *orig_node; | |
1009 | }; | |
1010 | ||
ef261577 ML |
1011 | /** |
1012 | * struct batadv_tvlv_container - container for tvlv appended to OGMs | |
1013 | * @list: hlist node for batadv_priv_tvlv::container_list | |
1014 | * @tvlv_hdr: tvlv header information needed to construct the tvlv | |
1015 | * @value_len: length of the buffer following this struct which contains | |
1016 | * the actual tvlv payload | |
1017 | * @refcount: number of contexts the object is used | |
1018 | */ | |
1019 | struct batadv_tvlv_container { | |
1020 | struct hlist_node list; | |
1021 | struct batadv_tvlv_hdr tvlv_hdr; | |
1022 | atomic_t refcount; | |
1023 | }; | |
1024 | ||
1025 | /** | |
1026 | * struct batadv_tvlv_handler - handler for specific tvlv type and version | |
1027 | * @list: hlist node for batadv_priv_tvlv::handler_list | |
1028 | * @ogm_handler: handler callback which is given the tvlv payload to process on | |
1029 | * incoming OGM packets | |
1030 | * @unicast_handler: handler callback which is given the tvlv payload to process | |
1031 | * on incoming unicast tvlv packets | |
1032 | * @type: tvlv type this handler feels responsible for | |
1033 | * @version: tvlv version this handler feels responsible for | |
1034 | * @flags: tvlv handler flags | |
1035 | * @refcount: number of contexts the object is used | |
1036 | * @rcu: struct used for freeing in an RCU-safe manner | |
1037 | */ | |
1038 | struct batadv_tvlv_handler { | |
1039 | struct hlist_node list; | |
1040 | void (*ogm_handler)(struct batadv_priv *bat_priv, | |
1041 | struct batadv_orig_node *orig, | |
1042 | uint8_t flags, | |
1043 | void *tvlv_value, uint16_t tvlv_value_len); | |
1044 | int (*unicast_handler)(struct batadv_priv *bat_priv, | |
1045 | uint8_t *src, uint8_t *dst, | |
1046 | void *tvlv_value, uint16_t tvlv_value_len); | |
1047 | uint8_t type; | |
1048 | uint8_t version; | |
1049 | uint8_t flags; | |
1050 | atomic_t refcount; | |
1051 | struct rcu_head rcu; | |
1052 | }; | |
1053 | ||
1054 | /** | |
1055 | * enum batadv_tvlv_handler_flags - tvlv handler flags definitions | |
1056 | * @BATADV_TVLV_HANDLER_OGM_CIFNOTFND: tvlv ogm processing function will call | |
1057 | * this handler even if its type was not found (with no data) | |
1058 | * @BATADV_TVLV_HANDLER_OGM_CALLED: interval tvlv handling flag - the API marks | |
1059 | * a handler as being called, so it won't be called if the | |
1060 | * BATADV_TVLV_HANDLER_OGM_CIFNOTFND flag was set | |
1061 | */ | |
1062 | enum batadv_tvlv_handler_flags { | |
1063 | BATADV_TVLV_HANDLER_OGM_CIFNOTFND = BIT(1), | |
1064 | BATADV_TVLV_HANDLER_OGM_CALLED = BIT(2), | |
1065 | }; | |
1066 | ||
c6c8fea2 | 1067 | #endif /* _NET_BATMAN_ADV_TYPES_H_ */ |