types.h 39 KB

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