types.h 39 KB

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