~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/batman-adv/types.h

Version: ~ [ linux-5.10-rc5 ] ~ [ linux-5.9.10 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.79 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.159 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.208 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.245 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.245 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /* Copyright (C) 2007-2019  B.A.T.M.A.N. contributors:
  3  *
  4  * Marek Lindner, Simon Wunderlich
  5  */
  6 
  7 #ifndef _NET_BATMAN_ADV_TYPES_H_
  8 #define _NET_BATMAN_ADV_TYPES_H_
  9 
 10 #ifndef _NET_BATMAN_ADV_MAIN_H_
 11 #error only "main.h" can be included directly
 12 #endif
 13 
 14 #include <linux/average.h>
 15 #include <linux/bitops.h>
 16 #include <linux/compiler.h>
 17 #include <linux/if.h>
 18 #include <linux/if_ether.h>
 19 #include <linux/kref.h>
 20 #include <linux/netdevice.h>
 21 #include <linux/netlink.h>
 22 #include <linux/sched.h> /* for linux/wait.h */
 23 #include <linux/seq_file.h>
 24 #include <linux/skbuff.h>
 25 #include <linux/spinlock.h>
 26 #include <linux/timer.h>
 27 #include <linux/types.h>
 28 #include <linux/wait.h>
 29 #include <linux/workqueue.h>
 30 #include <uapi/linux/batadv_packet.h>
 31 #include <uapi/linux/batman_adv.h>
 32 
 33 #ifdef CONFIG_BATMAN_ADV_DAT
 34 
 35 /**
 36  * typedef batadv_dat_addr_t - type used for all DHT addresses
 37  *
 38  * If it is changed, BATADV_DAT_ADDR_MAX is changed as well.
 39  *
 40  * *Please be careful: batadv_dat_addr_t must be UNSIGNED*
 41  */
 42 typedef u16 batadv_dat_addr_t;
 43 
 44 #endif /* CONFIG_BATMAN_ADV_DAT */
 45 
 46 /**
 47  * enum batadv_dhcp_recipient - dhcp destination
 48  */
 49 enum batadv_dhcp_recipient {
 50         /** @BATADV_DHCP_NO: packet is not a dhcp message */
 51         BATADV_DHCP_NO = 0,
 52 
 53         /** @BATADV_DHCP_TO_SERVER: dhcp message is directed to a server */
 54         BATADV_DHCP_TO_SERVER,
 55 
 56         /** @BATADV_DHCP_TO_CLIENT: dhcp message is directed to a client */
 57         BATADV_DHCP_TO_CLIENT,
 58 };
 59 
 60 /**
 61  * BATADV_TT_REMOTE_MASK - bitmask selecting the flags that are sent over the
 62  *  wire only
 63  */
 64 #define BATADV_TT_REMOTE_MASK   0x00FF
 65 
 66 /**
 67  * BATADV_TT_SYNC_MASK - bitmask of the flags that need to be kept in sync
 68  *  among the nodes. These flags are used to compute the global/local CRC
 69  */
 70 #define BATADV_TT_SYNC_MASK     0x00F0
 71 
 72 /**
 73  * struct batadv_hard_iface_bat_iv - per hard-interface B.A.T.M.A.N. IV data
 74  */
 75 struct batadv_hard_iface_bat_iv {
 76         /** @ogm_buff: buffer holding the OGM packet */
 77         unsigned char *ogm_buff;
 78 
 79         /** @ogm_buff_len: length of the OGM packet buffer */
 80         int ogm_buff_len;
 81 
 82         /** @ogm_seqno: OGM sequence number - used to identify each OGM */
 83         atomic_t ogm_seqno;
 84 
 85         /** @ogm_buff_mutex: lock protecting ogm_buff and ogm_buff_len */
 86         struct mutex ogm_buff_mutex;
 87 };
 88 
 89 /**
 90  * enum batadv_v_hard_iface_flags - interface flags useful to B.A.T.M.A.N. V
 91  */
 92 enum batadv_v_hard_iface_flags {
 93         /**
 94          * @BATADV_FULL_DUPLEX: tells if the connection over this link is
 95          *  full-duplex
 96          */
 97         BATADV_FULL_DUPLEX      = BIT(0),
 98 
 99         /**
100          * @BATADV_WARNING_DEFAULT: tells whether we have warned the user that
101          *  no throughput data is available for this interface and that default
102          *  values are assumed.
103          */
104         BATADV_WARNING_DEFAULT  = BIT(1),
105 };
106 
107 /**
108  * struct batadv_hard_iface_bat_v - per hard-interface B.A.T.M.A.N. V data
109  */
110 struct batadv_hard_iface_bat_v {
111         /** @elp_interval: time interval between two ELP transmissions */
112         atomic_t elp_interval;
113 
114         /** @elp_seqno: current ELP sequence number */
115         atomic_t elp_seqno;
116 
117         /** @elp_skb: base skb containing the ELP message to send */
118         struct sk_buff *elp_skb;
119 
120         /** @elp_wq: workqueue used to schedule ELP transmissions */
121         struct delayed_work elp_wq;
122 
123         /**
124          * @throughput_override: throughput override to disable link
125          *  auto-detection
126          */
127         atomic_t throughput_override;
128 
129         /** @flags: interface specific flags */
130         u8 flags;
131 };
132 
133 /**
134  * enum batadv_hard_iface_wifi_flags - Flags describing the wifi configuration
135  *  of a batadv_hard_iface
136  */
137 enum batadv_hard_iface_wifi_flags {
138         /** @BATADV_HARDIF_WIFI_WEXT_DIRECT: it is a wext wifi device */
139         BATADV_HARDIF_WIFI_WEXT_DIRECT = BIT(0),
140 
141         /** @BATADV_HARDIF_WIFI_CFG80211_DIRECT: it is a cfg80211 wifi device */
142         BATADV_HARDIF_WIFI_CFG80211_DIRECT = BIT(1),
143 
144         /**
145          * @BATADV_HARDIF_WIFI_WEXT_INDIRECT: link device is a wext wifi device
146          */
147         BATADV_HARDIF_WIFI_WEXT_INDIRECT = BIT(2),
148 
149         /**
150          * @BATADV_HARDIF_WIFI_CFG80211_INDIRECT: link device is a cfg80211 wifi
151          * device
152          */
153         BATADV_HARDIF_WIFI_CFG80211_INDIRECT = BIT(3),
154 };
155 
156 /**
157  * struct batadv_hard_iface - network device known to batman-adv
158  */
159 struct batadv_hard_iface {
160         /** @list: list node for batadv_hardif_list */
161         struct list_head list;
162 
163         /** @if_status: status of the interface for batman-adv */
164         char if_status;
165 
166         /**
167          * @num_bcasts: number of payload re-broadcasts on this interface (ARQ)
168          */
169         u8 num_bcasts;
170 
171         /**
172          * @wifi_flags: flags whether this is (directly or indirectly) a wifi
173          *  interface
174          */
175         u32 wifi_flags;
176 
177         /** @net_dev: pointer to the net_device */
178         struct net_device *net_dev;
179 
180         /** @hardif_obj: kobject of the per interface sysfs "mesh" directory */
181         struct kobject *hardif_obj;
182 
183         /** @refcount: number of contexts the object is used */
184         struct kref refcount;
185 
186         /**
187          * @batman_adv_ptype: packet type describing packets that should be
188          * processed by batman-adv for this interface
189          */
190         struct packet_type batman_adv_ptype;
191 
192         /**
193          * @soft_iface: the batman-adv interface which uses this network
194          *  interface
195          */
196         struct net_device *soft_iface;
197 
198         /** @rcu: struct used for freeing in an RCU-safe manner */
199         struct rcu_head rcu;
200 
201         /** @bat_iv: per hard-interface B.A.T.M.A.N. IV data */
202         struct batadv_hard_iface_bat_iv bat_iv;
203 
204 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
205         /** @bat_v: per hard-interface B.A.T.M.A.N. V data */
206         struct batadv_hard_iface_bat_v bat_v;
207 #endif
208 
209 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
210         /**
211          * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs
212          */
213         struct dentry *debug_dir;
214 #endif
215 
216         /**
217          * @neigh_list: list of unique single hop neighbors via this interface
218          */
219         struct hlist_head neigh_list;
220 
221         /** @neigh_list_lock: lock protecting neigh_list */
222         spinlock_t neigh_list_lock;
223 };
224 
225 /**
226  * struct batadv_orig_ifinfo - B.A.T.M.A.N. IV private orig_ifinfo members
227  */
228 struct batadv_orig_ifinfo_bat_iv {
229         /**
230          * @bcast_own: bitfield which counts the number of our OGMs this
231          * orig_node rebroadcasted "back" to us  (relative to last_real_seqno)
232          */
233         DECLARE_BITMAP(bcast_own, BATADV_TQ_LOCAL_WINDOW_SIZE);
234 
235         /** @bcast_own_sum: sum of bcast_own */
236         u8 bcast_own_sum;
237 };
238 
239 /**
240  * struct batadv_orig_ifinfo - originator info per outgoing interface
241  */
242 struct batadv_orig_ifinfo {
243         /** @list: list node for &batadv_orig_node.ifinfo_list */
244         struct hlist_node list;
245 
246         /** @if_outgoing: pointer to outgoing hard-interface */
247         struct batadv_hard_iface *if_outgoing;
248 
249         /** @router: router that should be used to reach this originator */
250         struct batadv_neigh_node __rcu *router;
251 
252         /** @last_real_seqno: last and best known sequence number */
253         u32 last_real_seqno;
254 
255         /** @last_ttl: ttl of last received packet */
256         u8 last_ttl;
257 
258         /** @last_seqno_forwarded: seqno of the OGM which was forwarded last */
259         u32 last_seqno_forwarded;
260 
261         /** @batman_seqno_reset: time when the batman seqno window was reset */
262         unsigned long batman_seqno_reset;
263 
264         /** @bat_iv: B.A.T.M.A.N. IV private structure */
265         struct batadv_orig_ifinfo_bat_iv bat_iv;
266 
267         /** @refcount: number of contexts the object is used */
268         struct kref refcount;
269 
270         /** @rcu: struct used for freeing in an RCU-safe manner */
271         struct rcu_head rcu;
272 };
273 
274 /**
275  * struct batadv_frag_table_entry - head in the fragment buffer table
276  */
277 struct batadv_frag_table_entry {
278         /** @fragment_list: head of list with fragments */
279         struct hlist_head fragment_list;
280 
281         /** @lock: lock to protect the list of fragments */
282         spinlock_t lock;
283 
284         /** @timestamp: time (jiffie) of last received fragment */
285         unsigned long timestamp;
286 
287         /** @seqno: sequence number of the fragments in the list */
288         u16 seqno;
289 
290         /** @size: accumulated size of packets in list */
291         u16 size;
292 
293         /** @total_size: expected size of the assembled packet */
294         u16 total_size;
295 };
296 
297 /**
298  * struct batadv_frag_list_entry - entry in a list of fragments
299  */
300 struct batadv_frag_list_entry {
301         /** @list: list node information */
302         struct hlist_node list;
303 
304         /** @skb: fragment */
305         struct sk_buff *skb;
306 
307         /** @no: fragment number in the set */
308         u8 no;
309 };
310 
311 /**
312  * struct batadv_vlan_tt - VLAN specific TT attributes
313  */
314 struct batadv_vlan_tt {
315         /** @crc: CRC32 checksum of the entries belonging to this vlan */
316         u32 crc;
317 
318         /** @num_entries: number of TT entries for this VLAN */
319         atomic_t num_entries;
320 };
321 
322 /**
323  * struct batadv_orig_node_vlan - VLAN specific data per orig_node
324  */
325 struct batadv_orig_node_vlan {
326         /** @vid: the VLAN identifier */
327         unsigned short vid;
328 
329         /** @tt: VLAN specific TT attributes */
330         struct batadv_vlan_tt tt;
331 
332         /** @list: list node for &batadv_orig_node.vlan_list */
333         struct hlist_node list;
334 
335         /**
336          * @refcount: number of context where this object is currently in use
337          */
338         struct kref refcount;
339 
340         /** @rcu: struct used for freeing in a RCU-safe manner */
341         struct rcu_head rcu;
342 };
343 
344 /**
345  * struct batadv_orig_bat_iv - B.A.T.M.A.N. IV private orig_node members
346  */
347 struct batadv_orig_bat_iv {
348         /**
349          * @ogm_cnt_lock: lock protecting &batadv_orig_ifinfo_bat_iv.bcast_own,
350          * &batadv_orig_ifinfo_bat_iv.bcast_own_sum,
351          * &batadv_neigh_ifinfo_bat_iv.bat_iv.real_bits and
352          * &batadv_neigh_ifinfo_bat_iv.real_packet_count
353          */
354         spinlock_t ogm_cnt_lock;
355 };
356 
357 /**
358  * struct batadv_orig_node - structure for orig_list maintaining nodes of mesh
359  */
360 struct batadv_orig_node {
361         /** @orig: originator ethernet address */
362         u8 orig[ETH_ALEN];
363 
364         /** @ifinfo_list: list for routers per outgoing interface */
365         struct hlist_head ifinfo_list;
366 
367         /**
368          * @last_bonding_candidate: pointer to last ifinfo of last used router
369          */
370         struct batadv_orig_ifinfo *last_bonding_candidate;
371 
372 #ifdef CONFIG_BATMAN_ADV_DAT
373         /** @dat_addr: address of the orig node in the distributed hash */
374         batadv_dat_addr_t dat_addr;
375 #endif
376 
377         /** @last_seen: time when last packet from this node was received */
378         unsigned long last_seen;
379 
380         /**
381          * @bcast_seqno_reset: time when the broadcast seqno window was reset
382          */
383         unsigned long bcast_seqno_reset;
384 
385 #ifdef CONFIG_BATMAN_ADV_MCAST
386         /**
387          * @mcast_handler_lock: synchronizes mcast-capability and -flag changes
388          */
389         spinlock_t mcast_handler_lock;
390 
391         /** @mcast_flags: multicast flags announced by the orig node */
392         u8 mcast_flags;
393 
394         /**
395          * @mcast_want_all_unsnoopables_node: a list node for the
396          *  mcast.want_all_unsnoopables list
397          */
398         struct hlist_node mcast_want_all_unsnoopables_node;
399 
400         /**
401          * @mcast_want_all_ipv4_node: a list node for the mcast.want_all_ipv4
402          *  list
403          */
404         struct hlist_node mcast_want_all_ipv4_node;
405         /**
406          * @mcast_want_all_ipv6_node: a list node for the mcast.want_all_ipv6
407          *  list
408          */
409         struct hlist_node mcast_want_all_ipv6_node;
410 
411         /**
412          * @mcast_want_all_rtr4_node: a list node for the mcast.want_all_rtr4
413          *  list
414          */
415         struct hlist_node mcast_want_all_rtr4_node;
416         /**
417          * @mcast_want_all_rtr6_node: a list node for the mcast.want_all_rtr6
418          *  list
419          */
420         struct hlist_node mcast_want_all_rtr6_node;
421 #endif
422 
423         /** @capabilities: announced capabilities of this originator */
424         unsigned long capabilities;
425 
426         /**
427          * @capa_initialized: bitfield to remember whether a capability was
428          *  initialized
429          */
430         unsigned long capa_initialized;
431 
432         /** @last_ttvn: last seen translation table version number */
433         atomic_t last_ttvn;
434 
435         /** @tt_buff: last tt changeset this node received from the orig node */
436         unsigned char *tt_buff;
437 
438         /**
439          * @tt_buff_len: length of the last tt changeset this node received
440          *  from the orig node
441          */
442         s16 tt_buff_len;
443 
444         /** @tt_buff_lock: lock that protects tt_buff and tt_buff_len */
445         spinlock_t tt_buff_lock;
446 
447         /**
448          * @tt_lock: prevents from updating the table while reading it. Table
449          *  update is made up by two operations (data structure update and
450          *  metdata -CRC/TTVN-recalculation) and they have to be executed
451          *  atomically in order to avoid another thread to read the
452          *  table/metadata between those.
453          */
454         spinlock_t tt_lock;
455 
456         /**
457          * @bcast_bits: bitfield containing the info which payload broadcast
458          *  originated from this orig node this host already has seen (relative
459          *  to last_bcast_seqno)
460          */
461         DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
462 
463         /**
464          * @last_bcast_seqno: last broadcast sequence number received by this
465          *  host
466          */
467         u32 last_bcast_seqno;
468 
469         /**
470          * @neigh_list: list of potential next hop neighbor towards this orig
471          *  node
472          */
473         struct hlist_head neigh_list;
474 
475         /**
476          * @neigh_list_lock: lock protecting neigh_list, ifinfo_list,
477          *  last_bonding_candidate and router
478          */
479         spinlock_t neigh_list_lock;
480 
481         /** @hash_entry: hlist node for &batadv_priv.orig_hash */
482         struct hlist_node hash_entry;
483 
484         /** @bat_priv: pointer to soft_iface this orig node belongs to */
485         struct batadv_priv *bat_priv;
486 
487         /** @bcast_seqno_lock: lock protecting bcast_bits & last_bcast_seqno */
488         spinlock_t bcast_seqno_lock;
489 
490         /** @refcount: number of contexts the object is used */
491         struct kref refcount;
492 
493         /** @rcu: struct used for freeing in an RCU-safe manner */
494         struct rcu_head rcu;
495 
496 #ifdef CONFIG_BATMAN_ADV_NC
497         /** @in_coding_list: list of nodes this orig can hear */
498         struct list_head in_coding_list;
499 
500         /** @out_coding_list: list of nodes that can hear this orig */
501         struct list_head out_coding_list;
502 
503         /** @in_coding_list_lock: protects in_coding_list */
504         spinlock_t in_coding_list_lock;
505 
506         /** @out_coding_list_lock: protects out_coding_list */
507         spinlock_t out_coding_list_lock;
508 #endif
509 
510         /** @fragments: array with heads for fragment chains */
511         struct batadv_frag_table_entry fragments[BATADV_FRAG_BUFFER_COUNT];
512 
513         /**
514          * @vlan_list: a list of orig_node_vlan structs, one per VLAN served by
515          *  the originator represented by this object
516          */
517         struct hlist_head vlan_list;
518 
519         /** @vlan_list_lock: lock protecting vlan_list */
520         spinlock_t vlan_list_lock;
521 
522         /** @bat_iv: B.A.T.M.A.N. IV private structure */
523         struct batadv_orig_bat_iv bat_iv;
524 };
525 
526 /**
527  * enum batadv_orig_capabilities - orig node capabilities
528  */
529 enum batadv_orig_capabilities {
530         /**
531          * @BATADV_ORIG_CAPA_HAS_DAT: orig node has distributed arp table
532          *  enabled
533          */
534         BATADV_ORIG_CAPA_HAS_DAT,
535 
536         /** @BATADV_ORIG_CAPA_HAS_NC: orig node has network coding enabled */
537         BATADV_ORIG_CAPA_HAS_NC,
538 
539         /** @BATADV_ORIG_CAPA_HAS_TT: orig node has tt capability */
540         BATADV_ORIG_CAPA_HAS_TT,
541 
542         /**
543          * @BATADV_ORIG_CAPA_HAS_MCAST: orig node has some multicast capability
544          *  (= orig node announces a tvlv of type BATADV_TVLV_MCAST)
545          */
546         BATADV_ORIG_CAPA_HAS_MCAST,
547 };
548 
549 /**
550  * struct batadv_gw_node - structure for orig nodes announcing gw capabilities
551  */
552 struct batadv_gw_node {
553         /** @list: list node for &batadv_priv_gw.list */
554         struct hlist_node list;
555 
556         /** @orig_node: pointer to corresponding orig node */
557         struct batadv_orig_node *orig_node;
558 
559         /** @bandwidth_down: advertised uplink download bandwidth */
560         u32 bandwidth_down;
561 
562         /** @bandwidth_up: advertised uplink upload bandwidth */
563         u32 bandwidth_up;
564 
565         /** @refcount: number of contexts the object is used */
566         struct kref refcount;
567 
568         /** @rcu: struct used for freeing in an RCU-safe manner */
569         struct rcu_head rcu;
570 };
571 
572 DECLARE_EWMA(throughput, 10, 8)
573 
574 /**
575  * struct batadv_hardif_neigh_node_bat_v - B.A.T.M.A.N. V private neighbor
576  *  information
577  */
578 struct batadv_hardif_neigh_node_bat_v {
579         /** @throughput: ewma link throughput towards this neighbor */
580         struct ewma_throughput throughput;
581 
582         /** @elp_interval: time interval between two ELP transmissions */
583         u32 elp_interval;
584 
585         /** @elp_latest_seqno: latest and best known ELP sequence number */
586         u32 elp_latest_seqno;
587 
588         /**
589          * @last_unicast_tx: when the last unicast packet has been sent to this
590          *  neighbor
591          */
592         unsigned long last_unicast_tx;
593 
594         /** @metric_work: work queue callback item for metric update */
595         struct work_struct metric_work;
596 };
597 
598 /**
599  * struct batadv_hardif_neigh_node - unique neighbor per hard-interface
600  */
601 struct batadv_hardif_neigh_node {
602         /** @list: list node for &batadv_hard_iface.neigh_list */
603         struct hlist_node list;
604 
605         /** @addr: the MAC address of the neighboring interface */
606         u8 addr[ETH_ALEN];
607 
608         /**
609          * @orig: the address of the originator this neighbor node belongs to
610          */
611         u8 orig[ETH_ALEN];
612 
613         /** @if_incoming: pointer to incoming hard-interface */
614         struct batadv_hard_iface *if_incoming;
615 
616         /** @last_seen: when last packet via this neighbor was received */
617         unsigned long last_seen;
618 
619 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
620         /** @bat_v: B.A.T.M.A.N. V private data */
621         struct batadv_hardif_neigh_node_bat_v bat_v;
622 #endif
623 
624         /** @refcount: number of contexts the object is used */
625         struct kref refcount;
626 
627         /** @rcu: struct used for freeing in a RCU-safe manner */
628         struct rcu_head rcu;
629 };
630 
631 /**
632  * struct batadv_neigh_node - structure for single hops neighbors
633  */
634 struct batadv_neigh_node {
635         /** @list: list node for &batadv_orig_node.neigh_list */
636         struct hlist_node list;
637 
638         /** @orig_node: pointer to corresponding orig_node */
639         struct batadv_orig_node *orig_node;
640 
641         /** @addr: the MAC address of the neighboring interface */
642         u8 addr[ETH_ALEN];
643 
644         /** @ifinfo_list: list for routing metrics per outgoing interface */
645         struct hlist_head ifinfo_list;
646 
647         /** @ifinfo_lock: lock protecting ifinfo_list and its members */
648         spinlock_t ifinfo_lock;
649 
650         /** @if_incoming: pointer to incoming hard-interface */
651         struct batadv_hard_iface *if_incoming;
652 
653         /** @last_seen: when last packet via this neighbor was received */
654         unsigned long last_seen;
655 
656         /** @hardif_neigh: hardif_neigh of this neighbor */
657         struct batadv_hardif_neigh_node *hardif_neigh;
658 
659         /** @refcount: number of contexts the object is used */
660         struct kref refcount;
661 
662         /** @rcu: struct used for freeing in an RCU-safe manner */
663         struct rcu_head rcu;
664 };
665 
666 /**
667  * struct batadv_neigh_ifinfo_bat_iv - neighbor information per outgoing
668  *  interface for B.A.T.M.A.N. IV
669  */
670 struct batadv_neigh_ifinfo_bat_iv {
671         /** @tq_recv: ring buffer of received TQ values from this neigh node */
672         u8 tq_recv[BATADV_TQ_GLOBAL_WINDOW_SIZE];
673 
674         /** @tq_index: ring buffer index */
675         u8 tq_index;
676 
677         /**
678          * @tq_avg: averaged tq of all tq values in the ring buffer (tq_recv)
679          */
680         u8 tq_avg;
681 
682         /**
683          * @real_bits: bitfield containing the number of OGMs received from this
684          *  neigh node (relative to orig_node->last_real_seqno)
685          */
686         DECLARE_BITMAP(real_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
687 
688         /** @real_packet_count: counted result of real_bits */
689         u8 real_packet_count;
690 };
691 
692 /**
693  * struct batadv_neigh_ifinfo_bat_v - neighbor information per outgoing
694  *  interface for B.A.T.M.A.N. V
695  */
696 struct batadv_neigh_ifinfo_bat_v {
697         /**
698          * @throughput: last throughput metric received from originator via this
699          *  neigh
700          */
701         u32 throughput;
702 
703         /** @last_seqno: last sequence number known for this neighbor */
704         u32 last_seqno;
705 };
706 
707 /**
708  * struct batadv_neigh_ifinfo - neighbor information per outgoing interface
709  */
710 struct batadv_neigh_ifinfo {
711         /** @list: list node for &batadv_neigh_node.ifinfo_list */
712         struct hlist_node list;
713 
714         /** @if_outgoing: pointer to outgoing hard-interface */
715         struct batadv_hard_iface *if_outgoing;
716 
717         /** @bat_iv: B.A.T.M.A.N. IV private structure */
718         struct batadv_neigh_ifinfo_bat_iv bat_iv;
719 
720 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
721         /** @bat_v: B.A.T.M.A.N. V private data */
722         struct batadv_neigh_ifinfo_bat_v bat_v;
723 #endif
724 
725         /** @last_ttl: last received ttl from this neigh node */
726         u8 last_ttl;
727 
728         /** @refcount: number of contexts the object is used */
729         struct kref refcount;
730 
731         /** @rcu: struct used for freeing in a RCU-safe manner */
732         struct rcu_head rcu;
733 };
734 
735 #ifdef CONFIG_BATMAN_ADV_BLA
736 
737 /**
738  * struct batadv_bcast_duplist_entry - structure for LAN broadcast suppression
739  */
740 struct batadv_bcast_duplist_entry {
741         /** @orig: mac address of orig node orginating the broadcast */
742         u8 orig[ETH_ALEN];
743 
744         /** @crc: crc32 checksum of broadcast payload */
745         __be32 crc;
746 
747         /** @entrytime: time when the broadcast packet was received */
748         unsigned long entrytime;
749 };
750 #endif
751 
752 /**
753  * enum batadv_counters - indices for traffic counters
754  */
755 enum batadv_counters {
756         /** @BATADV_CNT_TX: transmitted payload traffic packet counter */
757         BATADV_CNT_TX,
758 
759         /** @BATADV_CNT_TX_BYTES: transmitted payload traffic bytes counter */
760         BATADV_CNT_TX_BYTES,
761 
762         /**
763          * @BATADV_CNT_TX_DROPPED: dropped transmission payload traffic packet
764          *  counter
765          */
766         BATADV_CNT_TX_DROPPED,
767 
768         /** @BATADV_CNT_RX: received payload traffic packet counter */
769         BATADV_CNT_RX,
770 
771         /** @BATADV_CNT_RX_BYTES: received payload traffic bytes counter */
772         BATADV_CNT_RX_BYTES,
773 
774         /** @BATADV_CNT_FORWARD: forwarded payload traffic packet counter */
775         BATADV_CNT_FORWARD,
776 
777         /**
778          * @BATADV_CNT_FORWARD_BYTES: forwarded payload traffic bytes counter
779          */
780         BATADV_CNT_FORWARD_BYTES,
781 
782         /**
783          * @BATADV_CNT_MGMT_TX: transmitted routing protocol traffic packet
784          *  counter
785          */
786         BATADV_CNT_MGMT_TX,
787 
788         /**
789          * @BATADV_CNT_MGMT_TX_BYTES: transmitted routing protocol traffic bytes
790          *  counter
791          */
792         BATADV_CNT_MGMT_TX_BYTES,
793 
794         /**
795          * @BATADV_CNT_MGMT_RX: received routing protocol traffic packet counter
796          */
797         BATADV_CNT_MGMT_RX,
798 
799         /**
800          * @BATADV_CNT_MGMT_RX_BYTES: received routing protocol traffic bytes
801          *  counter
802          */
803         BATADV_CNT_MGMT_RX_BYTES,
804 
805         /** @BATADV_CNT_FRAG_TX: transmitted fragment traffic packet counter */
806         BATADV_CNT_FRAG_TX,
807 
808         /**
809          * @BATADV_CNT_FRAG_TX_BYTES: transmitted fragment traffic bytes counter
810          */
811         BATADV_CNT_FRAG_TX_BYTES,
812 
813         /** @BATADV_CNT_FRAG_RX: received fragment traffic packet counter */
814         BATADV_CNT_FRAG_RX,
815 
816         /**
817          * @BATADV_CNT_FRAG_RX_BYTES: received fragment traffic bytes counter
818          */
819         BATADV_CNT_FRAG_RX_BYTES,
820 
821         /** @BATADV_CNT_FRAG_FWD: forwarded fragment traffic packet counter */
822         BATADV_CNT_FRAG_FWD,
823 
824         /**
825          * @BATADV_CNT_FRAG_FWD_BYTES: forwarded fragment traffic bytes counter
826          */
827         BATADV_CNT_FRAG_FWD_BYTES,
828 
829         /**
830          * @BATADV_CNT_TT_REQUEST_TX: transmitted tt req traffic packet counter
831          */
832         BATADV_CNT_TT_REQUEST_TX,
833 
834         /** @BATADV_CNT_TT_REQUEST_RX: received tt req traffic packet counter */
835         BATADV_CNT_TT_REQUEST_RX,
836 
837         /**
838          * @BATADV_CNT_TT_RESPONSE_TX: transmitted tt resp traffic packet
839          *  counter
840          */
841         BATADV_CNT_TT_RESPONSE_TX,
842 
843         /**
844          * @BATADV_CNT_TT_RESPONSE_RX: received tt resp traffic packet counter
845          */
846         BATADV_CNT_TT_RESPONSE_RX,
847 
848         /**
849          * @BATADV_CNT_TT_ROAM_ADV_TX: transmitted tt roam traffic packet
850          *  counter
851          */
852         BATADV_CNT_TT_ROAM_ADV_TX,
853 
854         /**
855          * @BATADV_CNT_TT_ROAM_ADV_RX: received tt roam traffic packet counter
856          */
857         BATADV_CNT_TT_ROAM_ADV_RX,
858 
859 #ifdef CONFIG_BATMAN_ADV_DAT
860         /**
861          * @BATADV_CNT_DAT_GET_TX: transmitted dht GET traffic packet counter
862          */
863         BATADV_CNT_DAT_GET_TX,
864 
865         /** @BATADV_CNT_DAT_GET_RX: received dht GET traffic packet counter */
866         BATADV_CNT_DAT_GET_RX,
867 
868         /**
869          * @BATADV_CNT_DAT_PUT_TX: transmitted dht PUT traffic packet counter
870          */
871         BATADV_CNT_DAT_PUT_TX,
872 
873         /** @BATADV_CNT_DAT_PUT_RX: received dht PUT traffic packet counter */
874         BATADV_CNT_DAT_PUT_RX,
875 
876         /**
877          * @BATADV_CNT_DAT_CACHED_REPLY_TX: transmitted dat cache reply traffic
878          *  packet counter
879          */
880         BATADV_CNT_DAT_CACHED_REPLY_TX,
881 #endif
882 
883 #ifdef CONFIG_BATMAN_ADV_NC
884         /**
885          * @BATADV_CNT_NC_CODE: transmitted nc-combined traffic packet counter
886          */
887         BATADV_CNT_NC_CODE,
888 
889         /**
890          * @BATADV_CNT_NC_CODE_BYTES: transmitted nc-combined traffic bytes
891          *  counter
892          */
893         BATADV_CNT_NC_CODE_BYTES,
894 
895         /**
896          * @BATADV_CNT_NC_RECODE: transmitted nc-recombined traffic packet
897          *  counter
898          */
899         BATADV_CNT_NC_RECODE,
900 
901         /**
902          * @BATADV_CNT_NC_RECODE_BYTES: transmitted nc-recombined traffic bytes
903          *  counter
904          */
905         BATADV_CNT_NC_RECODE_BYTES,
906 
907         /**
908          * @BATADV_CNT_NC_BUFFER: counter for packets buffered for later nc
909          *  decoding
910          */
911         BATADV_CNT_NC_BUFFER,
912 
913         /**
914          * @BATADV_CNT_NC_DECODE: received and nc-decoded traffic packet counter
915          */
916         BATADV_CNT_NC_DECODE,
917 
918         /**
919          * @BATADV_CNT_NC_DECODE_BYTES: received and nc-decoded traffic bytes
920          *  counter
921          */
922         BATADV_CNT_NC_DECODE_BYTES,
923 
924         /**
925          * @BATADV_CNT_NC_DECODE_FAILED: received and decode-failed traffic
926          *  packet counter
927          */
928         BATADV_CNT_NC_DECODE_FAILED,
929 
930         /**
931          * @BATADV_CNT_NC_SNIFFED: counter for nc-decoded packets received in
932          *  promisc mode.
933          */
934         BATADV_CNT_NC_SNIFFED,
935 #endif
936 
937         /** @BATADV_CNT_NUM: number of traffic counters */
938         BATADV_CNT_NUM,
939 };
940 
941 /**
942  * struct batadv_priv_tt - per mesh interface translation table data
943  */
944 struct batadv_priv_tt {
945         /** @vn: translation table version number */
946         atomic_t vn;
947 
948         /**
949          * @ogm_append_cnt: counter of number of OGMs containing the local tt
950          *  diff
951          */
952         atomic_t ogm_append_cnt;
953 
954         /** @local_changes: changes registered in an originator interval */
955         atomic_t local_changes;
956 
957         /**
958          * @changes_list: tracks tt local changes within an originator interval
959          */
960         struct list_head changes_list;
961 
962         /** @local_hash: local translation table hash table */
963         struct batadv_hashtable *local_hash;
964 
965         /** @global_hash: global translation table hash table */
966         struct batadv_hashtable *global_hash;
967 
968         /** @req_list: list of pending & unanswered tt_requests */
969         struct hlist_head req_list;
970 
971         /**
972          * @roam_list: list of the last roaming events of each client limiting
973          *  the number of roaming events to avoid route flapping
974          */
975         struct list_head roam_list;
976 
977         /** @changes_list_lock: lock protecting changes_list */
978         spinlock_t changes_list_lock;
979 
980         /** @req_list_lock: lock protecting req_list */
981         spinlock_t req_list_lock;
982 
983         /** @roam_list_lock: lock protecting roam_list */
984         spinlock_t roam_list_lock;
985 
986         /** @last_changeset: last tt changeset this host has generated */
987         unsigned char *last_changeset;
988 
989         /**
990          * @last_changeset_len: length of last tt changeset this host has
991          *  generated
992          */
993         s16 last_changeset_len;
994 
995         /**
996          * @last_changeset_lock: lock protecting last_changeset &
997          *  last_changeset_len
998          */
999         spinlock_t last_changeset_lock;
1000 
1001         /**
1002          * @commit_lock: prevents from executing a local TT commit while reading
1003          *  the local table. The local TT commit is made up by two operations
1004          *  (data structure update and metdata -CRC/TTVN- recalculation) and
1005          *  they have to be executed atomically in order to avoid another thread
1006          *  to read the table/metadata between those.
1007          */
1008         spinlock_t commit_lock;
1009 
1010         /** @work: work queue callback item for translation table purging */
1011         struct delayed_work work;
1012 };
1013 
1014 #ifdef CONFIG_BATMAN_ADV_BLA
1015 
1016 /**
1017  * struct batadv_priv_bla - per mesh interface bridge loope avoidance data
1018  */
1019 struct batadv_priv_bla {
1020         /** @num_requests: number of bla requests in flight */
1021         atomic_t num_requests;
1022 
1023         /**
1024          * @claim_hash: hash table containing mesh nodes this host has claimed
1025          */
1026         struct batadv_hashtable *claim_hash;
1027 
1028         /**
1029          * @backbone_hash: hash table containing all detected backbone gateways
1030          */
1031         struct batadv_hashtable *backbone_hash;
1032 
1033         /** @loopdetect_addr: MAC address used for own loopdetection frames */
1034         u8 loopdetect_addr[ETH_ALEN];
1035 
1036         /**
1037          * @loopdetect_lasttime: time when the loopdetection frames were sent
1038          */
1039         unsigned long loopdetect_lasttime;
1040 
1041         /**
1042          * @loopdetect_next: how many periods to wait for the next loopdetect
1043          *  process
1044          */
1045         atomic_t loopdetect_next;
1046 
1047         /**
1048          * @bcast_duplist: recently received broadcast packets array (for
1049          *  broadcast duplicate suppression)
1050          */
1051         struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE];
1052 
1053         /**
1054          * @bcast_duplist_curr: index of last broadcast packet added to
1055          *  bcast_duplist
1056          */
1057         int bcast_duplist_curr;
1058 
1059         /**
1060          * @bcast_duplist_lock: lock protecting bcast_duplist &
1061          *  bcast_duplist_curr
1062          */
1063         spinlock_t bcast_duplist_lock;
1064 
1065         /** @claim_dest: local claim data (e.g. claim group) */
1066         struct batadv_bla_claim_dst claim_dest;
1067 
1068         /** @work: work queue callback item for cleanups & bla announcements */
1069         struct delayed_work work;
1070 };
1071 #endif
1072 
1073 #ifdef CONFIG_BATMAN_ADV_DEBUG
1074 
1075 /**
1076  * struct batadv_priv_debug_log - debug logging data
1077  */
1078 struct batadv_priv_debug_log {
1079         /** @log_buff: buffer holding the logs (ring bufer) */
1080         char log_buff[BATADV_LOG_BUF_LEN];
1081 
1082         /** @log_start: index of next character to read */
1083         unsigned long log_start;
1084 
1085         /** @log_end: index of next character to write */
1086         unsigned long log_end;
1087 
1088         /** @lock: lock protecting log_buff, log_start & log_end */
1089         spinlock_t lock;
1090 
1091         /** @queue_wait: log reader's wait queue */
1092         wait_queue_head_t queue_wait;
1093 };
1094 #endif
1095 
1096 /**
1097  * struct batadv_priv_gw - per mesh interface gateway data
1098  */
1099 struct batadv_priv_gw {
1100         /** @gateway_list: list of available gateway nodes */
1101         struct hlist_head gateway_list;
1102 
1103         /** @list_lock: lock protecting gateway_list, curr_gw, generation */
1104         spinlock_t list_lock;
1105 
1106         /** @curr_gw: pointer to currently selected gateway node */
1107         struct batadv_gw_node __rcu *curr_gw;
1108 
1109         /** @generation: current (generation) sequence number */
1110         unsigned int generation;
1111 
1112         /**
1113          * @mode: gateway operation: off, client or server (see batadv_gw_modes)
1114          */
1115         atomic_t mode;
1116 
1117         /** @sel_class: gateway selection class (applies if gw_mode client) */
1118         atomic_t sel_class;
1119 
1120         /**
1121          * @bandwidth_down: advertised uplink download bandwidth (if gw_mode
1122          *  server)
1123          */
1124         atomic_t bandwidth_down;
1125 
1126         /**
1127          * @bandwidth_up: advertised uplink upload bandwidth (if gw_mode server)
1128          */
1129         atomic_t bandwidth_up;
1130 
1131         /** @reselect: bool indicating a gateway re-selection is in progress */
1132         atomic_t reselect;
1133 };
1134 
1135 /**
1136  * struct batadv_priv_tvlv - per mesh interface tvlv data
1137  */
1138 struct batadv_priv_tvlv {
1139         /**
1140          * @container_list: list of registered tvlv containers to be sent with
1141          *  each OGM
1142          */
1143         struct hlist_head container_list;
1144 
1145         /** @handler_list: list of the various tvlv content handlers */
1146         struct hlist_head handler_list;
1147 
1148         /** @container_list_lock: protects tvlv container list access */
1149         spinlock_t container_list_lock;
1150 
1151         /** @handler_list_lock: protects handler list access */
1152         spinlock_t handler_list_lock;
1153 };
1154 
1155 #ifdef CONFIG_BATMAN_ADV_DAT
1156 
1157 /**
1158  * struct batadv_priv_dat - per mesh interface DAT private data
1159  */
1160 struct batadv_priv_dat {
1161         /** @addr: node DAT address */
1162         batadv_dat_addr_t addr;
1163 
1164         /** @hash: hashtable representing the local ARP cache */
1165         struct batadv_hashtable *hash;
1166 
1167         /** @work: work queue callback item for cache purging */
1168         struct delayed_work work;
1169 };
1170 #endif
1171 
1172 #ifdef CONFIG_BATMAN_ADV_MCAST
1173 /**
1174  * struct batadv_mcast_querier_state - IGMP/MLD querier state when bridged
1175  */
1176 struct batadv_mcast_querier_state {
1177         /** @exists: whether a querier exists in the mesh */
1178         unsigned char exists:1;
1179 
1180         /**
1181          * @shadowing: if a querier exists, whether it is potentially shadowing
1182          *  multicast listeners (i.e. querier is behind our own bridge segment)
1183          */
1184         unsigned char shadowing:1;
1185 };
1186 
1187 /**
1188  * struct batadv_mcast_mla_flags - flags for the querier, bridge and tvlv state
1189  */
1190 struct batadv_mcast_mla_flags {
1191         /** @querier_ipv4: the current state of an IGMP querier in the mesh */
1192         struct batadv_mcast_querier_state querier_ipv4;
1193 
1194         /** @querier_ipv6: the current state of an MLD querier in the mesh */
1195         struct batadv_mcast_querier_state querier_ipv6;
1196 
1197         /** @enabled: whether the multicast tvlv is currently enabled */
1198         unsigned char enabled:1;
1199 
1200         /** @bridged: whether the soft interface has a bridge on top */
1201         unsigned char bridged:1;
1202 
1203         /** @tvlv_flags: the flags we have last sent in our mcast tvlv */
1204         u8 tvlv_flags;
1205 };
1206 
1207 /**
1208  * struct batadv_priv_mcast - per mesh interface mcast data
1209  */
1210 struct batadv_priv_mcast {
1211         /**
1212          * @mla_list: list of multicast addresses we are currently announcing
1213          *  via TT
1214          */
1215         struct hlist_head mla_list; /* see __batadv_mcast_mla_update() */
1216 
1217         /**
1218          * @want_all_unsnoopables_list: a list of orig_nodes wanting all
1219          *  unsnoopable multicast traffic
1220          */
1221         struct hlist_head want_all_unsnoopables_list;
1222 
1223         /**
1224          * @want_all_ipv4_list: a list of orig_nodes wanting all IPv4 multicast
1225          *  traffic
1226          */
1227         struct hlist_head want_all_ipv4_list;
1228 
1229         /**
1230          * @want_all_ipv6_list: a list of orig_nodes wanting all IPv6 multicast
1231          *  traffic
1232          */
1233         struct hlist_head want_all_ipv6_list;
1234 
1235         /**
1236          * @want_all_rtr4_list: a list of orig_nodes wanting all routable IPv4
1237          *  multicast traffic
1238          */
1239         struct hlist_head want_all_rtr4_list;
1240 
1241         /**
1242          * @want_all_rtr6_list: a list of orig_nodes wanting all routable IPv6
1243          *  multicast traffic
1244          */
1245         struct hlist_head want_all_rtr6_list;
1246 
1247         /**
1248          * @mla_flags: flags for the querier, bridge and tvlv state
1249          */
1250         struct batadv_mcast_mla_flags mla_flags;
1251 
1252         /**
1253          * @mla_lock: a lock protecting mla_list and mla_flags
1254          */
1255         spinlock_t mla_lock;
1256 
1257         /**
1258          * @num_want_all_unsnoopables: number of nodes wanting unsnoopable IP
1259          *  traffic
1260          */
1261         atomic_t num_want_all_unsnoopables;
1262 
1263         /** @num_want_all_ipv4: counter for items in want_all_ipv4_list */
1264         atomic_t num_want_all_ipv4;
1265 
1266         /** @num_want_all_ipv6: counter for items in want_all_ipv6_list */
1267         atomic_t num_want_all_ipv6;
1268 
1269         /** @num_want_all_rtr4: counter for items in want_all_rtr4_list */
1270         atomic_t num_want_all_rtr4;
1271 
1272         /** @num_want_all_rtr6: counter for items in want_all_rtr6_list */
1273         atomic_t num_want_all_rtr6;
1274 
1275         /**
1276          * @want_lists_lock: lock for protecting modifications to mcasts
1277          *  want_all_{unsnoopables,ipv4,ipv6}_list (traversals are rcu-locked)
1278          */
1279         spinlock_t want_lists_lock;
1280 
1281         /** @work: work queue callback item for multicast TT and TVLV updates */
1282         struct delayed_work work;
1283 };
1284 #endif
1285 
1286 /**
1287  * struct batadv_priv_nc - per mesh interface network coding private data
1288  */
1289 struct batadv_priv_nc {
1290         /** @work: work queue callback item for cleanup */
1291         struct delayed_work work;
1292 
1293 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
1294         /**
1295          * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs
1296          */
1297         struct dentry *debug_dir;
1298 #endif
1299 
1300         /**
1301          * @min_tq: only consider neighbors for encoding if neigh_tq > min_tq
1302          */
1303         u8 min_tq;
1304 
1305         /**
1306          * @max_fwd_delay: maximum packet forward delay to allow coding of
1307          *  packets
1308          */
1309         u32 max_fwd_delay;
1310 
1311         /**
1312          * @max_buffer_time: buffer time for sniffed packets used to decoding
1313          */
1314         u32 max_buffer_time;
1315 
1316         /**
1317          * @timestamp_fwd_flush: timestamp of last forward packet queue flush
1318          */
1319         unsigned long timestamp_fwd_flush;
1320 
1321         /**
1322          * @timestamp_sniffed_purge: timestamp of last sniffed packet queue
1323          *  purge
1324          */
1325         unsigned long timestamp_sniffed_purge;
1326 
1327         /**
1328          * @coding_hash: Hash table used to buffer skbs while waiting for
1329          *  another incoming skb to code it with. Skbs are added to the buffer
1330          *  just before being forwarded in routing.c
1331          */
1332         struct batadv_hashtable *coding_hash;
1333 
1334         /**
1335          * @decoding_hash: Hash table used to buffer skbs that might be needed
1336          *  to decode a received coded skb. The buffer is used for 1) skbs
1337          *  arriving on the soft-interface; 2) skbs overheard on the
1338          *  hard-interface; and 3) skbs forwarded by batman-adv.
1339          */
1340         struct batadv_hashtable *decoding_hash;
1341 };
1342 
1343 /**
1344  * struct batadv_tp_unacked - unacked packet meta-information
1345  *
1346  * This struct is supposed to represent a buffer unacked packet. However, since
1347  * the purpose of the TP meter is to count the traffic only, there is no need to
1348  * store the entire sk_buff, the starting offset and the length are enough
1349  */
1350 struct batadv_tp_unacked {
1351         /** @seqno: seqno of the unacked packet */
1352         u32 seqno;
1353 
1354         /** @len: length of the packet */
1355         u16 len;
1356 
1357         /** @list: list node for &batadv_tp_vars.unacked_list */
1358         struct list_head list;
1359 };
1360 
1361 /**
1362  * enum batadv_tp_meter_role - Modus in tp meter session
1363  */
1364 enum batadv_tp_meter_role {
1365         /** @BATADV_TP_RECEIVER: Initialized as receiver */
1366         BATADV_TP_RECEIVER,
1367 
1368         /** @BATADV_TP_SENDER: Initialized as sender */
1369         BATADV_TP_SENDER
1370 };
1371 
1372 /**
1373  * struct batadv_tp_vars - tp meter private variables per session
1374  */
1375 struct batadv_tp_vars {
1376         /** @list: list node for &bat_priv.tp_list */
1377         struct hlist_node list;
1378 
1379         /** @timer: timer for ack (receiver) and retry (sender) */
1380         struct timer_list timer;
1381 
1382         /** @bat_priv: pointer to the mesh object */
1383         struct batadv_priv *bat_priv;
1384 
1385         /** @start_time: start time in jiffies */
1386         unsigned long start_time;
1387 
1388         /** @other_end: mac address of remote */
1389         u8 other_end[ETH_ALEN];
1390 
1391         /** @role: receiver/sender modi */
1392         enum batadv_tp_meter_role role;
1393 
1394         /** @sending: sending binary semaphore: 1 if sending, 0 is not */
1395         atomic_t sending;
1396 
1397         /** @reason: reason for a stopped session */
1398         enum batadv_tp_meter_reason reason;
1399 
1400         /** @finish_work: work item for the finishing procedure */
1401         struct delayed_work finish_work;
1402 
1403         /** @test_length: test length in milliseconds */
1404         u32 test_length;
1405 
1406         /** @session: TP session identifier */
1407         u8 session[2];
1408 
1409         /** @icmp_uid: local ICMP "socket" index */
1410         u8 icmp_uid;
1411 
1412         /* sender variables */
1413 
1414         /** @dec_cwnd: decimal part of the cwnd used during linear growth */
1415         u16 dec_cwnd;
1416 
1417         /** @cwnd: current size of the congestion window */
1418         u32 cwnd;
1419 
1420         /** @cwnd_lock: lock do protect @cwnd & @dec_cwnd */
1421         spinlock_t cwnd_lock;
1422 
1423         /**
1424          * @ss_threshold: Slow Start threshold. Once cwnd exceeds this value the
1425          *  connection switches to the Congestion Avoidance state
1426          */
1427         u32 ss_threshold;
1428 
1429         /** @last_acked: last acked byte */
1430         atomic_t last_acked;
1431 
1432         /** @last_sent: last sent byte, not yet acked */
1433         u32 last_sent;
1434 
1435         /** @tot_sent: amount of data sent/ACKed so far */
1436         atomic64_t tot_sent;
1437 
1438         /** @dup_acks: duplicate ACKs counter */
1439         atomic_t dup_acks;
1440 
1441         /** @fast_recovery: true if in Fast Recovery mode */
1442         unsigned char fast_recovery:1;
1443 
1444         /** @recover: last sent seqno when entering Fast Recovery */
1445         u32 recover;
1446 
1447         /** @rto: sender timeout */
1448         u32 rto;
1449 
1450         /** @srtt: smoothed RTT scaled by 2^3 */
1451         u32 srtt;
1452 
1453         /** @rttvar: RTT variation scaled by 2^2 */
1454         u32 rttvar;
1455 
1456         /**
1457          * @more_bytes: waiting queue anchor when waiting for more ack/retry
1458          *  timeout
1459          */
1460         wait_queue_head_t more_bytes;
1461 
1462         /** @prerandom_offset: offset inside the prerandom buffer */
1463         u32 prerandom_offset;
1464 
1465         /** @prerandom_lock: spinlock protecting access to prerandom_offset */
1466         spinlock_t prerandom_lock;
1467 
1468         /* receiver variables */
1469 
1470         /** @last_recv: last in-order received packet */
1471         u32 last_recv;
1472 
1473         /** @unacked_list: list of unacked packets (meta-info only) */
1474         struct list_head unacked_list;
1475 
1476         /** @unacked_lock: protect unacked_list */
1477         spinlock_t unacked_lock;
1478 
1479         /** @last_recv_time: time time (jiffies) a msg was received */
1480         unsigned long last_recv_time;
1481 
1482         /** @refcount: number of context where the object is used */
1483         struct kref refcount;
1484 
1485         /** @rcu: struct used for freeing in an RCU-safe manner */
1486         struct rcu_head rcu;
1487 };
1488 
1489 /**
1490  * struct batadv_softif_vlan - per VLAN attributes set
1491  */
1492 struct batadv_softif_vlan {
1493         /** @bat_priv: pointer to the mesh object */
1494         struct batadv_priv *bat_priv;
1495 
1496         /** @vid: VLAN identifier */
1497         unsigned short vid;
1498 
1499         /** @kobj: kobject for sysfs vlan subdirectory */
1500         struct kobject *kobj;
1501 
1502         /** @ap_isolation: AP isolation state */
1503         atomic_t ap_isolation;          /* boolean */
1504 
1505         /** @tt: TT private attributes (VLAN specific) */
1506         struct batadv_vlan_tt tt;
1507 
1508         /** @list: list node for &bat_priv.softif_vlan_list */
1509         struct hlist_node list;
1510 
1511         /**
1512          * @refcount: number of context where this object is currently in use
1513          */
1514         struct kref refcount;
1515 
1516         /** @rcu: struct used for freeing in a RCU-safe manner */
1517         struct rcu_head rcu;
1518 };
1519 
1520 /**
1521  * struct batadv_priv_bat_v - B.A.T.M.A.N. V per soft-interface private data
1522  */
1523 struct batadv_priv_bat_v {
1524         /** @ogm_buff: buffer holding the OGM packet */
1525         unsigned char *ogm_buff;
1526 
1527         /** @ogm_buff_len: length of the OGM packet buffer */
1528         int ogm_buff_len;
1529 
1530         /** @ogm_seqno: OGM sequence number - used to identify each OGM */
1531         atomic_t ogm_seqno;
1532 
1533         /** @ogm_wq: workqueue used to schedule OGM transmissions */
1534         struct delayed_work ogm_wq;
1535 };
1536 
1537 /**
1538  * struct batadv_priv - per mesh interface data
1539  */
1540 struct batadv_priv {
1541         /**
1542          * @mesh_state: current status of the mesh
1543          *  (inactive/active/deactivating)
1544          */
1545         atomic_t mesh_state;
1546 
1547         /** @soft_iface: net device which holds this struct as private data */
1548         struct net_device *soft_iface;
1549 
1550         /**
1551          * @bat_counters: mesh internal traffic statistic counters (see
1552          *  batadv_counters)
1553          */
1554         u64 __percpu *bat_counters; /* Per cpu counters */
1555 
1556         /**
1557          * @aggregated_ogms: bool indicating whether OGM aggregation is enabled
1558          */
1559         atomic_t aggregated_ogms;
1560 
1561         /** @bonding: bool indicating whether traffic bonding is enabled */
1562         atomic_t bonding;
1563 
1564         /**
1565          * @fragmentation: bool indicating whether traffic fragmentation is
1566          *  enabled
1567          */
1568         atomic_t fragmentation;
1569 
1570         /**
1571          * @packet_size_max: max packet size that can be transmitted via
1572          *  multiple fragmented skbs or a single frame if fragmentation is
1573          *  disabled
1574          */
1575         atomic_t packet_size_max;
1576 
1577         /**
1578          * @frag_seqno: incremental counter to identify chains of egress
1579          *  fragments
1580          */
1581         atomic_t frag_seqno;
1582 
1583 #ifdef CONFIG_BATMAN_ADV_BLA
1584         /**
1585          * @bridge_loop_avoidance: bool indicating whether bridge loop
1586          *  avoidance is enabled
1587          */
1588         atomic_t bridge_loop_avoidance;
1589 #endif
1590 
1591 #ifdef CONFIG_BATMAN_ADV_DAT
1592         /**
1593          * @distributed_arp_table: bool indicating whether distributed ARP table
1594          *  is enabled
1595          */
1596         atomic_t distributed_arp_table;
1597 #endif
1598 
1599 #ifdef CONFIG_BATMAN_ADV_MCAST
1600         /**
1601          * @multicast_mode: Enable or disable multicast optimizations on this
1602          *  node's sender/originating side
1603          */
1604         atomic_t multicast_mode;
1605 
1606         /**
1607          * @multicast_fanout: Maximum number of packet copies to generate for a
1608          *  multicast-to-unicast conversion
1609          */
1610         atomic_t multicast_fanout;
1611 #endif
1612 
1613         /** @orig_interval: OGM broadcast interval in milliseconds */
1614         atomic_t orig_interval;
1615 
1616         /**
1617          * @hop_penalty: penalty which will be applied to an OGM's tq-field on
1618          *  every hop
1619          */
1620         atomic_t hop_penalty;
1621 
1622 #ifdef CONFIG_BATMAN_ADV_DEBUG
1623         /** @log_level: configured log level (see batadv_dbg_level) */
1624         atomic_t log_level;
1625 #endif
1626 
1627         /**
1628          * @isolation_mark: the skb->mark value used to match packets for AP
1629          *  isolation
1630          */
1631         u32 isolation_mark;
1632 
1633         /**
1634          * @isolation_mark_mask: bitmask identifying the bits in skb->mark to be
1635          *  used for the isolation mark
1636          */
1637         u32 isolation_mark_mask;
1638 
1639         /** @bcast_seqno: last sent broadcast packet sequence number */
1640         atomic_t bcast_seqno;
1641 
1642         /**
1643          * @bcast_queue_left: number of remaining buffered broadcast packet
1644          *  slots
1645          */
1646         atomic_t bcast_queue_left;
1647 
1648         /** @batman_queue_left: number of remaining OGM packet slots */
1649         atomic_t batman_queue_left;
1650 
1651         /** @mesh_obj: kobject for sysfs mesh subdirectory */
1652         struct kobject *mesh_obj;
1653 
1654 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
1655         /** @debug_dir: dentry for debugfs batman-adv subdirectory */
1656         struct dentry *debug_dir;
1657 #endif
1658 
1659         /** @forw_bat_list: list of aggregated OGMs that will be forwarded */
1660         struct hlist_head forw_bat_list;
1661 
1662         /**
1663          * @forw_bcast_list: list of broadcast packets that will be
1664          *  rebroadcasted
1665          */
1666         struct hlist_head forw_bcast_list;
1667 
1668         /** @tp_list: list of tp sessions */
1669         struct hlist_head tp_list;
1670 
1671         /** @tp_num: number of currently active tp sessions */
1672         struct batadv_hashtable *orig_hash;
1673 
1674         /** @orig_hash: hash table containing mesh participants (orig nodes) */
1675         spinlock_t forw_bat_list_lock;
1676 
1677         /** @forw_bat_list_lock: lock protecting forw_bat_list */
1678         spinlock_t forw_bcast_list_lock;
1679 
1680         /** @forw_bcast_list_lock: lock protecting forw_bcast_list */
1681         spinlock_t tp_list_lock;
1682 
1683         /** @tp_list_lock: spinlock protecting @tp_list */
1684         atomic_t tp_num;
1685 
1686         /** @orig_work: work queue callback item for orig node purging */
1687         struct delayed_work orig_work;
1688 
1689         /**
1690          * @primary_if: one of the hard-interfaces assigned to this mesh
1691          *  interface becomes the primary interface
1692          */
1693         struct batadv_hard_iface __rcu *primary_if;  /* rcu protected pointer */
1694 
1695         /** @algo_ops: routing algorithm used by this mesh interface */
1696         struct batadv_algo_ops *algo_ops;
1697 
1698         /**
1699          * @softif_vlan_list: a list of softif_vlan structs, one per VLAN
1700          *  created on top of the mesh interface represented by this object
1701          */
1702         struct hlist_head softif_vlan_list;
1703 
1704         /** @softif_vlan_list_lock: lock protecting softif_vlan_list */
1705         spinlock_t softif_vlan_list_lock;
1706 
1707 #ifdef CONFIG_BATMAN_ADV_BLA
1708         /** @bla: bridge loope avoidance data */
1709         struct batadv_priv_bla bla;
1710 #endif
1711 
1712 #ifdef CONFIG_BATMAN_ADV_DEBUG
1713         /** @debug_log: holding debug logging relevant data */
1714         struct batadv_priv_debug_log *debug_log;
1715 #endif
1716 
1717         /** @gw: gateway data */
1718         struct batadv_priv_gw gw;
1719 
1720         /** @tt: translation table data */
1721         struct batadv_priv_tt tt;
1722 
1723         /** @tvlv: type-version-length-value data */
1724         struct batadv_priv_tvlv tvlv;
1725 
1726 #ifdef CONFIG_BATMAN_ADV_DAT
1727         /** @dat: distributed arp table data */
1728         struct batadv_priv_dat dat;
1729 #endif
1730 
1731 #ifdef CONFIG_BATMAN_ADV_MCAST
1732         /** @mcast: multicast data */
1733         struct batadv_priv_mcast mcast;
1734 #endif
1735 
1736 #ifdef CONFIG_BATMAN_ADV_NC
1737         /**
1738          * @network_coding: bool indicating whether network coding is enabled
1739          */
1740         atomic_t network_coding;
1741 
1742         /** @nc: network coding data */
1743         struct batadv_priv_nc nc;
1744 #endif /* CONFIG_BATMAN_ADV_NC */
1745 
1746 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
1747         /** @bat_v: B.A.T.M.A.N. V per soft-interface private data */
1748         struct batadv_priv_bat_v bat_v;
1749 #endif
1750 };
1751 
1752 /**
1753  * struct batadv_socket_client - layer2 icmp socket client data
1754  */
1755 struct batadv_socket_client {
1756         /**
1757          * @queue_list: packet queue for packets destined for this socket client
1758          */
1759         struct list_head queue_list;
1760 
1761         /** @queue_len: number of packets in the packet queue (queue_list) */
1762         unsigned int queue_len;
1763 
1764         /** @index: socket client's index in the batadv_socket_client_hash */
1765         unsigned char index;
1766 
1767         /** @lock: lock protecting queue_list, queue_len & index */
1768         spinlock_t lock;
1769 
1770         /** @queue_wait: socket client's wait queue */
1771         wait_queue_head_t queue_wait;
1772 
1773         /** @bat_priv: pointer to soft_iface this client belongs to */
1774         struct batadv_priv *bat_priv;
1775 };
1776 
1777 /**
1778  * struct batadv_socket_packet - layer2 icmp packet for socket client
1779  */
1780 struct batadv_socket_packet {
1781         /** @list: list node for &batadv_socket_client.queue_list */
1782         struct list_head list;
1783 
1784         /** @icmp_len: size of the layer2 icmp packet */
1785         size_t icmp_len;
1786 
1787         /** @icmp_packet: layer2 icmp packet */
1788         u8 icmp_packet[BATADV_ICMP_MAX_PACKET_SIZE];
1789 };
1790 
1791 #ifdef CONFIG_BATMAN_ADV_BLA
1792 
1793 /**
1794  * struct batadv_bla_backbone_gw - batman-adv gateway bridged into the LAN
1795  */
1796 struct batadv_bla_backbone_gw {
1797         /**
1798          * @orig: originator address of backbone node (mac address of primary
1799          *  iface)
1800          */
1801         u8 orig[ETH_ALEN];
1802 
1803         /** @vid: vlan id this gateway was detected on */
1804         unsigned short vid;
1805 
1806         /** @hash_entry: hlist node for &batadv_priv_bla.backbone_hash */
1807         struct hlist_node hash_entry;
1808 
1809         /** @bat_priv: pointer to soft_iface this backbone gateway belongs to */
1810         struct batadv_priv *bat_priv;
1811 
1812         /** @lasttime: last time we heard of this backbone gw */
1813         unsigned long lasttime;
1814 
1815         /**
1816          * @wait_periods: grace time for bridge forward delays and bla group
1817          *  forming at bootup phase - no bcast traffic is formwared until it has
1818          *  elapsed
1819          */
1820         atomic_t wait_periods;
1821 
1822         /**
1823          * @request_sent: if this bool is set to true we are out of sync with
1824          *  this backbone gateway - no bcast traffic is formwared until the
1825          *  situation was resolved
1826          */
1827         atomic_t request_sent;
1828 
1829         /** @crc: crc16 checksum over all claims */
1830         u16 crc;
1831 
1832         /** @crc_lock: lock protecting crc */
1833         spinlock_t crc_lock;
1834 
1835         /** @report_work: work struct for reporting detected loops */
1836         struct work_struct report_work;
1837 
1838         /** @refcount: number of contexts the object is used */
1839         struct kref refcount;
1840 
1841         /** @rcu: struct used for freeing in an RCU-safe manner */
1842         struct rcu_head rcu;
1843 };
1844 
1845 /**
1846  * struct batadv_bla_claim - claimed non-mesh client structure
1847  */
1848 struct batadv_bla_claim {
1849         /** @addr: mac address of claimed non-mesh client */
1850         u8 addr[ETH_ALEN];
1851 
1852         /** @vid: vlan id this client was detected on */
1853         unsigned short vid;
1854 
1855         /** @backbone_gw: pointer to backbone gw claiming this client */
1856         struct batadv_bla_backbone_gw *backbone_gw;
1857 
1858         /** @backbone_lock: lock protecting backbone_gw pointer */
1859         spinlock_t backbone_lock;
1860 
1861         /** @lasttime: last time we heard of claim (locals only) */
1862         unsigned long lasttime;
1863 
1864         /** @hash_entry: hlist node for &batadv_priv_bla.claim_hash */
1865         struct hlist_node hash_entry;
1866 
1867         /** @refcount: number of contexts the object is used */
1868         struct rcu_head rcu;
1869 
1870         /** @rcu: struct used for freeing in an RCU-safe manner */
1871         struct kref refcount;
1872 };
1873 #endif
1874 
1875 /**
1876  * struct batadv_tt_common_entry - tt local & tt global common data
1877  */
1878 struct batadv_tt_common_entry {
1879         /** @addr: mac address of non-mesh client */
1880         u8 addr[ETH_ALEN];
1881 
1882         /** @vid: VLAN identifier */
1883         unsigned short vid;
1884 
1885         /**
1886          * @hash_entry: hlist node for &batadv_priv_tt.local_hash or for
1887          *  &batadv_priv_tt.global_hash
1888          */
1889         struct hlist_node hash_entry;
1890 
1891         /** @flags: various state handling flags (see batadv_tt_client_flags) */
1892         u16 flags;
1893 
1894         /** @added_at: timestamp used for purging stale tt common entries */
1895         unsigned long added_at;
1896 
1897         /** @refcount: number of contexts the object is used */
1898         struct kref refcount;
1899 
1900         /** @rcu: struct used for freeing in an RCU-safe manner */
1901         struct rcu_head rcu;
1902 };
1903 
1904 /**
1905  * struct batadv_tt_local_entry - translation table local entry data
1906  */
1907 struct batadv_tt_local_entry {
1908         /** @common: general translation table data */
1909         struct batadv_tt_common_entry common;
1910 
1911         /** @last_seen: timestamp used for purging stale tt local entries */
1912         unsigned long last_seen;
1913 
1914         /** @vlan: soft-interface vlan of the entry */
1915         struct batadv_softif_vlan *vlan;
1916 };
1917 
1918 /**
1919  * struct batadv_tt_global_entry - translation table global entry data
1920  */
1921 struct batadv_tt_global_entry {
1922         /** @common: general translation table data */
1923         struct batadv_tt_common_entry common;
1924 
1925         /** @orig_list: list of orig nodes announcing this non-mesh client */
1926         struct hlist_head orig_list;
1927 
1928         /** @orig_list_count: number of items in the orig_list */
1929         atomic_t orig_list_count;
1930 
1931         /** @list_lock: lock protecting orig_list */
1932         spinlock_t list_lock;
1933 
1934         /** @roam_at: time at which TT_GLOBAL_ROAM was set */
1935         unsigned long roam_at;
1936 };
1937 
1938 /**
1939  * struct batadv_tt_orig_list_entry - orig node announcing a non-mesh client
1940  */
1941 struct batadv_tt_orig_list_entry {
1942         /** @orig_node: pointer to orig node announcing this non-mesh client */
1943         struct batadv_orig_node *orig_node;
1944 
1945         /**
1946          * @ttvn: translation table version number which added the non-mesh
1947          *  client
1948          */
1949         u8 ttvn;
1950 
1951         /** @flags: per orig entry TT sync flags */
1952         u8 flags;
1953 
1954         /** @list: list node for &batadv_tt_global_entry.orig_list */
1955         struct hlist_node list;
1956 
1957         /** @refcount: number of contexts the object is used */
1958         struct kref refcount;
1959 
1960         /** @rcu: struct used for freeing in an RCU-safe manner */
1961         struct rcu_head rcu;
1962 };
1963 
1964 /**
1965  * struct batadv_tt_change_node - structure for tt changes occurred
1966  */
1967 struct batadv_tt_change_node {
1968         /** @list: list node for &batadv_priv_tt.changes_list */
1969         struct list_head list;
1970 
1971         /** @change: holds the actual translation table diff data */
1972         struct batadv_tvlv_tt_change change;
1973 };
1974 
1975 /**
1976  * struct batadv_tt_req_node - data to keep track of the tt requests in flight
1977  */
1978 struct batadv_tt_req_node {
1979         /**
1980          * @addr: mac address address of the originator this request was sent to
1981          */
1982         u8 addr[ETH_ALEN];
1983 
1984         /** @issued_at: timestamp used for purging stale tt requests */
1985         unsigned long issued_at;
1986 
1987         /** @refcount: number of contexts the object is used by */
1988         struct kref refcount;
1989 
1990         /** @list: list node for &batadv_priv_tt.req_list */
1991         struct hlist_node list;
1992 };
1993 
1994 /**
1995  * struct batadv_tt_roam_node - roaming client data
1996  */
1997 struct batadv_tt_roam_node {
1998         /** @addr: mac address of the client in the roaming phase */
1999         u8 addr[ETH_ALEN];
2000 
2001         /**
2002          * @counter: number of allowed roaming events per client within a single
2003          * OGM interval (changes are committed with each OGM)
2004          */
2005         atomic_t counter;
2006 
2007         /**
2008          * @first_time: timestamp used for purging stale roaming node entries
2009          */
2010         unsigned long first_time;
2011 
2012         /** @list: list node for &batadv_priv_tt.roam_list */
2013         struct list_head list;
2014 };
2015 
2016 /**
2017  * struct batadv_nc_node - network coding node
2018  */
2019 struct batadv_nc_node {
2020         /** @list: next and prev pointer for the list handling */
2021         struct list_head list;
2022 
2023         /** @addr: the node's mac address */
2024         u8 addr[ETH_ALEN];
2025 
2026         /** @refcount: number of contexts the object is used by */
2027         struct kref refcount;
2028 
2029         /** @rcu: struct used for freeing in an RCU-safe manner */
2030         struct rcu_head rcu;
2031 
2032         /** @orig_node: pointer to corresponding orig node struct */
2033         struct batadv_orig_node *orig_node;
2034 
2035         /** @last_seen: timestamp of last ogm received from this node */
2036         unsigned long last_seen;
2037 };
2038 
2039 /**
2040  * struct batadv_nc_path - network coding path
2041  */
2042 struct batadv_nc_path {
2043         /** @hash_entry: next and prev pointer for the list handling */
2044         struct hlist_node hash_entry;
2045 
2046         /** @rcu: struct used for freeing in an RCU-safe manner */
2047         struct rcu_head rcu;
2048 
2049         /** @refcount: number of contexts the object is used by */
2050         struct kref refcount;
2051 
2052         /** @packet_list: list of buffered packets for this path */
2053         struct list_head packet_list;
2054 
2055         /** @packet_list_lock: access lock for packet list */
2056         spinlock_t packet_list_lock;
2057 
2058         /** @next_hop: next hop (destination) of path */
2059         u8 next_hop[ETH_ALEN];
2060 
2061         /** @prev_hop: previous hop (source) of path */
2062         u8 prev_hop[ETH_ALEN];
2063 
2064         /** @last_valid: timestamp for last validation of path */
2065         unsigned long last_valid;
2066 };
2067 
2068 /**
2069  * struct batadv_nc_packet - network coding packet used when coding and
2070  *  decoding packets
2071  */
2072 struct batadv_nc_packet {
2073         /** @list: next and prev pointer for the list handling */
2074         struct list_head list;
2075 
2076         /** @packet_id: crc32 checksum of skb data */
2077         __be32 packet_id;
2078 
2079         /**
2080          * @timestamp: field containing the info when the packet was added to
2081          *  path
2082          */
2083         unsigned long timestamp;
2084 
2085         /** @neigh_node: pointer to original next hop neighbor of skb */
2086         struct batadv_neigh_node *neigh_node;
2087 
2088         /** @skb: skb which can be encoded or used for decoding */
2089         struct sk_buff *skb;
2090 
2091         /** @nc_path: pointer to path this nc packet is attached to */
2092         struct batadv_nc_path *nc_path;
2093 };
2094 
2095 /**
2096  * struct batadv_skb_cb - control buffer structure used to store private data
2097  *  relevant to batman-adv in the skb->cb buffer in skbs.
2098  */
2099 struct batadv_skb_cb {
2100         /**
2101          * @decoded: Marks a skb as decoded, which is checked when searching for
2102          *  coding opportunities in network-coding.c
2103          */
2104         unsigned char decoded:1;
2105 
2106         /** @num_bcasts: Counter for broadcast packet retransmissions */
2107         unsigned char num_bcasts;
2108 };
2109 
2110 /**
2111  * struct batadv_forw_packet - structure for bcast packets to be sent/forwarded
2112  */
2113 struct batadv_forw_packet {
2114         /**
2115          * @list: list node for &batadv_priv.forw.bcast_list and
2116          *  &batadv_priv.forw.bat_list
2117          */
2118         struct hlist_node list;
2119 
2120         /** @cleanup_list: list node for purging functions */
2121         struct hlist_node cleanup_list;
2122 
2123         /** @send_time: execution time for delayed_work (packet sending) */
2124         unsigned long send_time;
2125 
2126         /**
2127          * @own: bool for locally generated packets (local OGMs are re-scheduled
2128          * after sending)
2129          */
2130         u8 own;
2131 
2132         /** @skb: bcast packet's skb buffer */
2133         struct sk_buff *skb;
2134 
2135         /** @packet_len: size of aggregated OGM packet inside the skb buffer */
2136         u16 packet_len;
2137 
2138         /** @direct_link_flags: direct link flags for aggregated OGM packets */
2139         u32 direct_link_flags;
2140 
2141         /** @num_packets: counter for aggregated OGMv1 packets */
2142         u8 num_packets;
2143 
2144         /** @delayed_work: work queue callback item for packet sending */
2145         struct delayed_work delayed_work;
2146 
2147         /**
2148          * @if_incoming: pointer to incoming hard-iface or primary iface if
2149          *  locally generated packet
2150          */
2151         struct batadv_hard_iface *if_incoming;
2152 
2153         /**
2154          * @if_outgoing: packet where the packet should be sent to, or NULL if
2155          *  unspecified
2156          */
2157         struct batadv_hard_iface *if_outgoing;
2158 
2159         /** @queue_left: The queue (counter) this packet was applied to */
2160         atomic_t *queue_left;
2161 };
2162 
2163 /**
2164  * struct batadv_algo_iface_ops - mesh algorithm callbacks (interface specific)
2165  */
2166 struct batadv_algo_iface_ops {
2167         /**
2168          * @activate: start routing mechanisms when hard-interface is brought up
2169          *  (optional)
2170          */
2171         void (*activate)(struct batadv_hard_iface *hard_iface);
2172 
2173         /** @enable: init routing info when hard-interface is enabled */
2174         int (*enable)(struct batadv_hard_iface *hard_iface);
2175 
2176         /** @enabled: notification when hard-interface was enabled (optional) */
2177         void (*enabled)(struct batadv_hard_iface *hard_iface);
2178 
2179         /** @disable: de-init routing info when hard-interface is disabled */
2180         void (*disable)(struct batadv_hard_iface *hard_iface);
2181 
2182         /**
2183          * @update_mac: (re-)init mac addresses of the protocol information
2184          *  belonging to this hard-interface
2185          */
2186         void (*update_mac)(struct batadv_hard_iface *hard_iface);
2187 
2188         /** @primary_set: called when primary interface is selected / changed */
2189         void (*primary_set)(struct batadv_hard_iface *hard_iface);
2190 };
2191 
2192 /**
2193  * struct batadv_algo_neigh_ops - mesh algorithm callbacks (neighbour specific)
2194  */
2195 struct batadv_algo_neigh_ops {
2196         /** @hardif_init: called on creation of single hop entry (optional) */
2197         void (*hardif_init)(struct batadv_hardif_neigh_node *neigh);
2198 
2199         /**
2200          * @cmp: compare the metrics of two neighbors for their respective
2201          *  outgoing interfaces
2202          */
2203         int (*cmp)(struct batadv_neigh_node *neigh1,
2204                    struct batadv_hard_iface *if_outgoing1,
2205                    struct batadv_neigh_node *neigh2,
2206                    struct batadv_hard_iface *if_outgoing2);
2207 
2208         /**
2209          * @is_similar_or_better: check if neigh1 is equally similar or better
2210          *  than neigh2 for their respective outgoing interface from the metric
2211          *  prospective
2212          */
2213         bool (*is_similar_or_better)(struct batadv_neigh_node *neigh1,
2214                                      struct batadv_hard_iface *if_outgoing1,
2215                                      struct batadv_neigh_node *neigh2,
2216                                      struct batadv_hard_iface *if_outgoing2);
2217 
2218 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
2219         /** @print: print the single hop neighbor list (optional) */
2220         void (*print)(struct batadv_priv *priv, struct seq_file *seq);
2221 #endif
2222 
2223         /** @dump: dump neighbors to a netlink socket (optional) */
2224         void (*dump)(struct sk_buff *msg, struct netlink_callback *cb,
2225                      struct batadv_priv *priv,
2226                      struct batadv_hard_iface *hard_iface);
2227 };
2228 
2229 /**
2230  * struct batadv_algo_orig_ops - mesh algorithm callbacks (originator specific)
2231  */
2232 struct batadv_algo_orig_ops {
2233 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
2234         /** @print: print the originator table (optional) */
2235         void (*print)(struct batadv_priv *priv, struct seq_file *seq,
2236                       struct batadv_hard_iface *hard_iface);
2237 #endif
2238 
2239         /** @dump: dump originators to a netlink socket (optional) */
2240         void (*dump)(struct sk_buff *msg, struct netlink_callback *cb,
2241                      struct batadv_priv *priv,
2242                      struct batadv_hard_iface *hard_iface);
2243 };
2244 
2245 /**
2246  * struct batadv_algo_gw_ops - mesh algorithm callbacks (GW specific)
2247  */
2248 struct batadv_algo_gw_ops {
2249         /** @init_sel_class: initialize GW selection class (optional) */
2250         void (*init_sel_class)(struct batadv_priv *bat_priv);
2251 
2252         /**
2253          * @store_sel_class: parse and stores a new GW selection class
2254          *  (optional)
2255          */
2256         ssize_t (*store_sel_class)(struct batadv_priv *bat_priv, char *buff,
2257                                    size_t count);
2258 
2259         /** @show_sel_class: prints the current GW selection class (optional) */
2260         ssize_t (*show_sel_class)(struct batadv_priv *bat_priv, char *buff);
2261 
2262         /**
2263          * @get_best_gw_node: select the best GW from the list of available
2264          *  nodes (optional)
2265          */
2266         struct batadv_gw_node *(*get_best_gw_node)
2267                 (struct batadv_priv *bat_priv);
2268 
2269         /**
2270          * @is_eligible: check if a newly discovered GW is a potential candidate
2271          *  for the election as best GW (optional)
2272          */
2273         bool (*is_eligible)(struct batadv_priv *bat_priv,
2274                             struct batadv_orig_node *curr_gw_orig,
2275                             struct batadv_orig_node *orig_node);
2276 
2277 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
2278         /** @print: print the gateway table (optional) */
2279         void (*print)(struct batadv_priv *bat_priv, struct seq_file *seq);
2280 #endif
2281 
2282         /** @dump: dump gateways to a netlink socket (optional) */
2283         void (*dump)(struct sk_buff *msg, struct netlink_callback *cb,
2284                      struct batadv_priv *priv);
2285 };
2286 
2287 /**
2288  * struct batadv_algo_ops - mesh algorithm callbacks
2289  */
2290 struct batadv_algo_ops {
2291         /** @list: list node for the batadv_algo_list */
2292         struct hlist_node list;
2293 
2294         /** @name: name of the algorithm */
2295         char *name;
2296 
2297         /** @iface: callbacks related to interface handling */
2298         struct batadv_algo_iface_ops iface;
2299 
2300         /** @neigh: callbacks related to neighbors handling */
2301         struct batadv_algo_neigh_ops neigh;
2302 
2303         /** @orig: callbacks related to originators handling */
2304         struct batadv_algo_orig_ops orig;
2305 
2306         /** @gw: callbacks related to GW mode */
2307         struct batadv_algo_gw_ops gw;
2308 };
2309 
2310 /**
2311  * struct batadv_dat_entry - it is a single entry of batman-adv ARP backend. It
2312  * is used to stored ARP entries needed for the global DAT cache
2313  */
2314 struct batadv_dat_entry {
2315         /** @ip: the IPv4 corresponding to this DAT/ARP entry */
2316         __be32 ip;
2317 
2318         /** @mac_addr: the MAC address associated to the stored IPv4 */
2319         u8 mac_addr[ETH_ALEN];
2320 
2321         /** @vid: the vlan ID associated to this entry */
2322         unsigned short vid;
2323 
2324         /**
2325          * @last_update: time in jiffies when this entry was refreshed last time
2326          */
2327         unsigned long last_update;
2328 
2329         /** @hash_entry: hlist node for &batadv_priv_dat.hash */
2330         struct hlist_node hash_entry;
2331 
2332         /** @refcount: number of contexts the object is used */
2333         struct kref refcount;
2334 
2335         /** @rcu: struct used for freeing in an RCU-safe manner */
2336         struct rcu_head rcu;
2337 };
2338 
2339 /**
2340  * struct batadv_hw_addr - a list entry for a MAC address
2341  */
2342 struct batadv_hw_addr {
2343         /** @list: list node for the linking of entries */
2344         struct hlist_node list;
2345 
2346         /** @addr: the MAC address of this list entry */
2347         unsigned char addr[ETH_ALEN];
2348 };
2349 
2350 /**
2351  * struct batadv_dat_candidate - candidate destination for DAT operations
2352  */
2353 struct batadv_dat_candidate {
2354         /**
2355          * @type: the type of the selected candidate. It can one of the
2356          *  following:
2357          *        - BATADV_DAT_CANDIDATE_NOT_FOUND
2358          *        - BATADV_DAT_CANDIDATE_ORIG
2359          */
2360         int type;
2361 
2362         /**
2363          * @orig_node: if type is BATADV_DAT_CANDIDATE_ORIG this field points to
2364          * the corresponding originator node structure
2365          */
2366         struct batadv_orig_node *orig_node;
2367 };
2368 
2369 /**
2370  * struct batadv_tvlv_container - container for tvlv appended to OGMs
2371  */
2372 struct batadv_tvlv_container {
2373         /** @list: hlist node for &batadv_priv_tvlv.container_list */
2374         struct hlist_node list;
2375 
2376         /** @tvlv_hdr: tvlv header information needed to construct the tvlv */
2377         struct batadv_tvlv_hdr tvlv_hdr;
2378 
2379         /** @refcount: number of contexts the object is used */
2380         struct kref refcount;
2381 };
2382 
2383 /**
2384  * struct batadv_tvlv_handler - handler for specific tvlv type and version
2385  */
2386 struct batadv_tvlv_handler {
2387         /** @list: hlist node for &batadv_priv_tvlv.handler_list */
2388         struct hlist_node list;
2389 
2390         /**
2391          * @ogm_handler: handler callback which is given the tvlv payload to
2392          *  process on incoming OGM packets
2393          */
2394         void (*ogm_handler)(struct batadv_priv *bat_priv,
2395                             struct batadv_orig_node *orig,
2396                             u8 flags, void *tvlv_value, u16 tvlv_value_len);
2397 
2398         /**
2399          * @unicast_handler: handler callback which is given the tvlv payload to
2400          *  process on incoming unicast tvlv packets
2401          */
2402         int (*unicast_handler)(struct batadv_priv *bat_priv,
2403                                u8 *src, u8 *dst,
2404                                void *tvlv_value, u16 tvlv_value_len);
2405 
2406         /** @type: tvlv type this handler feels responsible for */
2407         u8 type;
2408 
2409         /** @version: tvlv version this handler feels responsible for */
2410         u8 version;
2411 
2412         /** @flags: tvlv handler flags */
2413         u8 flags;
2414 
2415         /** @refcount: number of contexts the object is used */
2416         struct kref refcount;
2417 
2418         /** @rcu: struct used for freeing in an RCU-safe manner */
2419         struct rcu_head rcu;
2420 };
2421 
2422 /**
2423  * enum batadv_tvlv_handler_flags - tvlv handler flags definitions
2424  */
2425 enum batadv_tvlv_handler_flags {
2426         /**
2427          * @BATADV_TVLV_HANDLER_OGM_CIFNOTFND: tvlv ogm processing function
2428          *  will call this handler even if its type was not found (with no data)
2429          */
2430         BATADV_TVLV_HANDLER_OGM_CIFNOTFND = BIT(1),
2431 
2432         /**
2433          * @BATADV_TVLV_HANDLER_OGM_CALLED: interval tvlv handling flag - the
2434          *  API marks a handler as being called, so it won't be called if the
2435          *  BATADV_TVLV_HANDLER_OGM_CIFNOTFND flag was set
2436          */
2437         BATADV_TVLV_HANDLER_OGM_CALLED = BIT(2),
2438 };
2439 
2440 /**
2441  * struct batadv_store_mesh_work - Work queue item to detach add/del interface
2442  *  from sysfs locks
2443  */
2444 struct batadv_store_mesh_work {
2445         /**
2446          * @net_dev: netdevice to add/remove to/from batman-adv soft-interface
2447          */
2448         struct net_device *net_dev;
2449 
2450         /** @soft_iface_name: name of soft-interface to modify */
2451         char soft_iface_name[IFNAMSIZ];
2452 
2453         /** @work: work queue item */
2454         struct work_struct work;
2455 };
2456 
2457 #endif /* _NET_BATMAN_ADV_TYPES_H_ */
2458 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp