types.h 40 KB

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