types.h 38 KB

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