types.h 40 KB

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