File Index
Files and directories
Sign in
FILE

types.h

File preview with syntax highlighting.

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