batadv_packet.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) */
  2. /* Copyright (C) 2007-2020 B.A.T.M.A.N. contributors:
  3. *
  4. * Marek Lindner, Simon Wunderlich
  5. */
  6. #ifndef _LINUX_BATADV_PACKET_H_
  7. #define _LINUX_BATADV_PACKET_H_
  8. #include <asm/byteorder.h>
  9. #include <linux/if_ether.h>
  10. #include <linux/types.h>
  11. /**
  12. * batadv_tp_is_error() - Check throughput meter return code for error
  13. * @n: throughput meter return code
  14. *
  15. * Return: 0 when not error was detected, != 0 otherwise
  16. */
  17. #define batadv_tp_is_error(n) ((__u8)(n) > 127 ? 1 : 0)
  18. /**
  19. * enum batadv_packettype - types for batman-adv encapsulated packets
  20. * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
  21. * @BATADV_BCAST: broadcast packets carrying broadcast payload
  22. * @BATADV_CODED: network coded packets
  23. * @BATADV_ELP: echo location packets for B.A.T.M.A.N. V
  24. * @BATADV_OGM2: originator messages for B.A.T.M.A.N. V
  25. *
  26. * @BATADV_UNICAST: unicast packets carrying unicast payload traffic
  27. * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
  28. * payload packet
  29. * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of
  30. * the sender
  31. * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute
  32. * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers
  33. */
  34. enum batadv_packettype {
  35. /* 0x00 - 0x3f: local packets or special rules for handling */
  36. BATADV_IV_OGM = 0x00,
  37. BATADV_BCAST = 0x01,
  38. BATADV_CODED = 0x02,
  39. BATADV_ELP = 0x03,
  40. BATADV_OGM2 = 0x04,
  41. /* 0x40 - 0x7f: unicast */
  42. #define BATADV_UNICAST_MIN 0x40
  43. BATADV_UNICAST = 0x40,
  44. BATADV_UNICAST_FRAG = 0x41,
  45. BATADV_UNICAST_4ADDR = 0x42,
  46. BATADV_ICMP = 0x43,
  47. BATADV_UNICAST_TVLV = 0x44,
  48. #define BATADV_UNICAST_MAX 0x7f
  49. /* 0x80 - 0xff: reserved */
  50. };
  51. /**
  52. * enum batadv_subtype - packet subtype for unicast4addr
  53. * @BATADV_P_DATA: user payload
  54. * @BATADV_P_DAT_DHT_GET: DHT request message
  55. * @BATADV_P_DAT_DHT_PUT: DHT store message
  56. * @BATADV_P_DAT_CACHE_REPLY: ARP reply generated by DAT
  57. */
  58. enum batadv_subtype {
  59. BATADV_P_DATA = 0x01,
  60. BATADV_P_DAT_DHT_GET = 0x02,
  61. BATADV_P_DAT_DHT_PUT = 0x03,
  62. BATADV_P_DAT_CACHE_REPLY = 0x04,
  63. };
  64. /* this file is included by batctl which needs these defines */
  65. #define BATADV_COMPAT_VERSION 15
  66. /**
  67. * enum batadv_iv_flags - flags used in B.A.T.M.A.N. IV OGM packets
  68. * @BATADV_NOT_BEST_NEXT_HOP: flag is set when ogm packet is forwarded and was
  69. * previously received from someone else than the best neighbor.
  70. * @BATADV_PRIMARIES_FIRST_HOP: flag unused.
  71. * @BATADV_DIRECTLINK: flag is for the first hop or if rebroadcasted from a
  72. * one hop neighbor on the interface where it was originally received.
  73. */
  74. enum batadv_iv_flags {
  75. BATADV_NOT_BEST_NEXT_HOP = 1UL << 0,
  76. BATADV_PRIMARIES_FIRST_HOP = 1UL << 1,
  77. BATADV_DIRECTLINK = 1UL << 2,
  78. };
  79. /**
  80. * enum batadv_icmp_packettype - ICMP message types
  81. * @BATADV_ECHO_REPLY: success reply to BATADV_ECHO_REQUEST
  82. * @BATADV_DESTINATION_UNREACHABLE: failure when route to destination not found
  83. * @BATADV_ECHO_REQUEST: request BATADV_ECHO_REPLY from destination
  84. * @BATADV_TTL_EXCEEDED: error after BATADV_ECHO_REQUEST traversed too many hops
  85. * @BATADV_PARAMETER_PROBLEM: return code for malformed messages
  86. * @BATADV_TP: throughput meter packet
  87. */
  88. enum batadv_icmp_packettype {
  89. BATADV_ECHO_REPLY = 0,
  90. BATADV_DESTINATION_UNREACHABLE = 3,
  91. BATADV_ECHO_REQUEST = 8,
  92. BATADV_TTL_EXCEEDED = 11,
  93. BATADV_PARAMETER_PROBLEM = 12,
  94. BATADV_TP = 15,
  95. };
  96. /**
  97. * enum batadv_mcast_flags - flags for multicast capabilities and settings
  98. * @BATADV_MCAST_WANT_ALL_UNSNOOPABLES: we want all packets destined for
  99. * 224.0.0.0/24 or ff02::1
  100. * @BATADV_MCAST_WANT_ALL_IPV4: we want all IPv4 multicast packets
  101. * (both link-local and routable ones)
  102. * @BATADV_MCAST_WANT_ALL_IPV6: we want all IPv6 multicast packets
  103. * (both link-local and routable ones)
  104. * @BATADV_MCAST_WANT_NO_RTR4: we have no IPv4 multicast router and therefore
  105. * only need routable IPv4 multicast packets we signed up for explicitly
  106. * @BATADV_MCAST_WANT_NO_RTR6: we have no IPv6 multicast router and therefore
  107. * only need routable IPv6 multicast packets we signed up for explicitly
  108. */
  109. enum batadv_mcast_flags {
  110. BATADV_MCAST_WANT_ALL_UNSNOOPABLES = 1UL << 0,
  111. BATADV_MCAST_WANT_ALL_IPV4 = 1UL << 1,
  112. BATADV_MCAST_WANT_ALL_IPV6 = 1UL << 2,
  113. BATADV_MCAST_WANT_NO_RTR4 = 1UL << 3,
  114. BATADV_MCAST_WANT_NO_RTR6 = 1UL << 4,
  115. };
  116. /* tt data subtypes */
  117. #define BATADV_TT_DATA_TYPE_MASK 0x0F
  118. /**
  119. * enum batadv_tt_data_flags - flags for tt data tvlv
  120. * @BATADV_TT_OGM_DIFF: TT diff propagated through OGM
  121. * @BATADV_TT_REQUEST: TT request message
  122. * @BATADV_TT_RESPONSE: TT response message
  123. * @BATADV_TT_FULL_TABLE: contains full table to replace existing table
  124. */
  125. enum batadv_tt_data_flags {
  126. BATADV_TT_OGM_DIFF = 1UL << 0,
  127. BATADV_TT_REQUEST = 1UL << 1,
  128. BATADV_TT_RESPONSE = 1UL << 2,
  129. BATADV_TT_FULL_TABLE = 1UL << 4,
  130. };
  131. /**
  132. * enum batadv_vlan_flags - flags for the four MSB of any vlan ID field
  133. * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not
  134. */
  135. enum batadv_vlan_flags {
  136. BATADV_VLAN_HAS_TAG = 1UL << 15,
  137. };
  138. /**
  139. * enum batadv_bla_claimframe - claim frame types for the bridge loop avoidance
  140. * @BATADV_CLAIM_TYPE_CLAIM: claim of a client mac address
  141. * @BATADV_CLAIM_TYPE_UNCLAIM: unclaim of a client mac address
  142. * @BATADV_CLAIM_TYPE_ANNOUNCE: announcement of backbone with current crc
  143. * @BATADV_CLAIM_TYPE_REQUEST: request of full claim table
  144. * @BATADV_CLAIM_TYPE_LOOPDETECT: mesh-traversing loop detect packet
  145. */
  146. enum batadv_bla_claimframe {
  147. BATADV_CLAIM_TYPE_CLAIM = 0x00,
  148. BATADV_CLAIM_TYPE_UNCLAIM = 0x01,
  149. BATADV_CLAIM_TYPE_ANNOUNCE = 0x02,
  150. BATADV_CLAIM_TYPE_REQUEST = 0x03,
  151. BATADV_CLAIM_TYPE_LOOPDETECT = 0x04,
  152. };
  153. /**
  154. * enum batadv_tvlv_type - tvlv type definitions
  155. * @BATADV_TVLV_GW: gateway tvlv
  156. * @BATADV_TVLV_DAT: distributed arp table tvlv
  157. * @BATADV_TVLV_NC: network coding tvlv
  158. * @BATADV_TVLV_TT: translation table tvlv
  159. * @BATADV_TVLV_ROAM: roaming advertisement tvlv
  160. * @BATADV_TVLV_MCAST: multicast capability tvlv
  161. */
  162. enum batadv_tvlv_type {
  163. BATADV_TVLV_GW = 0x01,
  164. BATADV_TVLV_DAT = 0x02,
  165. BATADV_TVLV_NC = 0x03,
  166. BATADV_TVLV_TT = 0x04,
  167. BATADV_TVLV_ROAM = 0x05,
  168. BATADV_TVLV_MCAST = 0x06,
  169. };
  170. #pragma pack(2)
  171. /* the destination hardware field in the ARP frame is used to
  172. * transport the claim type and the group id
  173. */
  174. struct batadv_bla_claim_dst {
  175. __u8 magic[3]; /* FF:43:05 */
  176. __u8 type; /* bla_claimframe */
  177. __be16 group; /* group id */
  178. };
  179. /**
  180. * struct batadv_ogm_packet - ogm (routing protocol) packet
  181. * @packet_type: batman-adv packet type, part of the general header
  182. * @version: batman-adv protocol version, part of the genereal header
  183. * @ttl: time to live for this packet, part of the genereal header
  184. * @flags: contains routing relevant flags - see enum batadv_iv_flags
  185. * @seqno: sequence identification
  186. * @orig: address of the source node
  187. * @prev_sender: address of the previous sender
  188. * @reserved: reserved byte for alignment
  189. * @tq: transmission quality
  190. * @tvlv_len: length of tvlv data following the ogm header
  191. */
  192. struct batadv_ogm_packet {
  193. __u8 packet_type;
  194. __u8 version;
  195. __u8 ttl;
  196. __u8 flags;
  197. __be32 seqno;
  198. __u8 orig[ETH_ALEN];
  199. __u8 prev_sender[ETH_ALEN];
  200. __u8 reserved;
  201. __u8 tq;
  202. __be16 tvlv_len;
  203. };
  204. #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
  205. /**
  206. * struct batadv_ogm2_packet - ogm2 (routing protocol) packet
  207. * @packet_type: batman-adv packet type, part of the general header
  208. * @version: batman-adv protocol version, part of the general header
  209. * @ttl: time to live for this packet, part of the general header
  210. * @flags: reserved for routing relevant flags - currently always 0
  211. * @seqno: sequence number
  212. * @orig: originator mac address
  213. * @tvlv_len: length of the appended tvlv buffer (in bytes)
  214. * @throughput: the currently flooded path throughput
  215. */
  216. struct batadv_ogm2_packet {
  217. __u8 packet_type;
  218. __u8 version;
  219. __u8 ttl;
  220. __u8 flags;
  221. __be32 seqno;
  222. __u8 orig[ETH_ALEN];
  223. __be16 tvlv_len;
  224. __be32 throughput;
  225. };
  226. #define BATADV_OGM2_HLEN sizeof(struct batadv_ogm2_packet)
  227. /**
  228. * struct batadv_elp_packet - elp (neighbor discovery) packet
  229. * @packet_type: batman-adv packet type, part of the general header
  230. * @version: batman-adv protocol version, part of the genereal header
  231. * @orig: originator mac address
  232. * @seqno: sequence number
  233. * @elp_interval: currently used ELP sending interval in ms
  234. */
  235. struct batadv_elp_packet {
  236. __u8 packet_type;
  237. __u8 version;
  238. __u8 orig[ETH_ALEN];
  239. __be32 seqno;
  240. __be32 elp_interval;
  241. };
  242. #define BATADV_ELP_HLEN sizeof(struct batadv_elp_packet)
  243. /**
  244. * struct batadv_icmp_header - common members among all the ICMP packets
  245. * @packet_type: batman-adv packet type, part of the general header
  246. * @version: batman-adv protocol version, part of the genereal header
  247. * @ttl: time to live for this packet, part of the genereal header
  248. * @msg_type: ICMP packet type
  249. * @dst: address of the destination node
  250. * @orig: address of the source node
  251. * @uid: local ICMP socket identifier
  252. * @align: not used - useful for alignment purposes only
  253. *
  254. * This structure is used for ICMP packets parsing only and it is never sent
  255. * over the wire. The alignment field at the end is there to ensure that
  256. * members are padded the same way as they are in real packets.
  257. */
  258. struct batadv_icmp_header {
  259. __u8 packet_type;
  260. __u8 version;
  261. __u8 ttl;
  262. __u8 msg_type; /* see ICMP message types above */
  263. __u8 dst[ETH_ALEN];
  264. __u8 orig[ETH_ALEN];
  265. __u8 uid;
  266. __u8 align[3];
  267. };
  268. /**
  269. * struct batadv_icmp_packet - ICMP packet
  270. * @packet_type: batman-adv packet type, part of the general header
  271. * @version: batman-adv protocol version, part of the genereal header
  272. * @ttl: time to live for this packet, part of the genereal header
  273. * @msg_type: ICMP packet type
  274. * @dst: address of the destination node
  275. * @orig: address of the source node
  276. * @uid: local ICMP socket identifier
  277. * @reserved: not used - useful for alignment
  278. * @seqno: ICMP sequence number
  279. */
  280. struct batadv_icmp_packet {
  281. __u8 packet_type;
  282. __u8 version;
  283. __u8 ttl;
  284. __u8 msg_type; /* see ICMP message types above */
  285. __u8 dst[ETH_ALEN];
  286. __u8 orig[ETH_ALEN];
  287. __u8 uid;
  288. __u8 reserved;
  289. __be16 seqno;
  290. };
  291. /**
  292. * struct batadv_icmp_tp_packet - ICMP TP Meter packet
  293. * @packet_type: batman-adv packet type, part of the general header
  294. * @version: batman-adv protocol version, part of the genereal header
  295. * @ttl: time to live for this packet, part of the genereal header
  296. * @msg_type: ICMP packet type
  297. * @dst: address of the destination node
  298. * @orig: address of the source node
  299. * @uid: local ICMP socket identifier
  300. * @subtype: TP packet subtype (see batadv_icmp_tp_subtype)
  301. * @session: TP session identifier
  302. * @seqno: the TP sequence number
  303. * @timestamp: time when the packet has been sent. This value is filled in a
  304. * TP_MSG and echoed back in the next TP_ACK so that the sender can compute the
  305. * RTT. Since it is read only by the host which wrote it, there is no need to
  306. * store it using network order
  307. */
  308. struct batadv_icmp_tp_packet {
  309. __u8 packet_type;
  310. __u8 version;
  311. __u8 ttl;
  312. __u8 msg_type; /* see ICMP message types above */
  313. __u8 dst[ETH_ALEN];
  314. __u8 orig[ETH_ALEN];
  315. __u8 uid;
  316. __u8 subtype;
  317. __u8 session[2];
  318. __be32 seqno;
  319. __be32 timestamp;
  320. };
  321. /**
  322. * enum batadv_icmp_tp_subtype - ICMP TP Meter packet subtypes
  323. * @BATADV_TP_MSG: Msg from sender to receiver
  324. * @BATADV_TP_ACK: acknowledgment from receiver to sender
  325. */
  326. enum batadv_icmp_tp_subtype {
  327. BATADV_TP_MSG = 0,
  328. BATADV_TP_ACK,
  329. };
  330. #define BATADV_RR_LEN 16
  331. /**
  332. * struct batadv_icmp_packet_rr - ICMP RouteRecord packet
  333. * @packet_type: batman-adv packet type, part of the general header
  334. * @version: batman-adv protocol version, part of the genereal header
  335. * @ttl: time to live for this packet, part of the genereal header
  336. * @msg_type: ICMP packet type
  337. * @dst: address of the destination node
  338. * @orig: address of the source node
  339. * @uid: local ICMP socket identifier
  340. * @rr_cur: number of entries the rr array
  341. * @seqno: ICMP sequence number
  342. * @rr: route record array
  343. */
  344. struct batadv_icmp_packet_rr {
  345. __u8 packet_type;
  346. __u8 version;
  347. __u8 ttl;
  348. __u8 msg_type; /* see ICMP message types above */
  349. __u8 dst[ETH_ALEN];
  350. __u8 orig[ETH_ALEN];
  351. __u8 uid;
  352. __u8 rr_cur;
  353. __be16 seqno;
  354. __u8 rr[BATADV_RR_LEN][ETH_ALEN];
  355. };
  356. #define BATADV_ICMP_MAX_PACKET_SIZE sizeof(struct batadv_icmp_packet_rr)
  357. /* All packet headers in front of an ethernet header have to be completely
  358. * divisible by 2 but not by 4 to make the payload after the ethernet
  359. * header again 4 bytes boundary aligned.
  360. *
  361. * A packing of 2 is necessary to avoid extra padding at the end of the struct
  362. * caused by a structure member which is larger than two bytes. Otherwise
  363. * the structure would not fulfill the previously mentioned rule to avoid the
  364. * misalignment of the payload after the ethernet header. It may also lead to
  365. * leakage of information when the padding it not initialized before sending.
  366. */
  367. /**
  368. * struct batadv_unicast_packet - unicast packet for network payload
  369. * @packet_type: batman-adv packet type, part of the general header
  370. * @version: batman-adv protocol version, part of the genereal header
  371. * @ttl: time to live for this packet, part of the genereal header
  372. * @ttvn: translation table version number
  373. * @dest: originator destination of the unicast packet
  374. */
  375. struct batadv_unicast_packet {
  376. __u8 packet_type;
  377. __u8 version;
  378. __u8 ttl;
  379. __u8 ttvn; /* destination translation table version number */
  380. __u8 dest[ETH_ALEN];
  381. /* "4 bytes boundary + 2 bytes" long to make the payload after the
  382. * following ethernet header again 4 bytes boundary aligned
  383. */
  384. };
  385. /**
  386. * struct batadv_unicast_4addr_packet - extended unicast packet
  387. * @u: common unicast packet header
  388. * @src: address of the source
  389. * @subtype: packet subtype
  390. * @reserved: reserved byte for alignment
  391. */
  392. struct batadv_unicast_4addr_packet {
  393. struct batadv_unicast_packet u;
  394. __u8 src[ETH_ALEN];
  395. __u8 subtype;
  396. __u8 reserved;
  397. /* "4 bytes boundary + 2 bytes" long to make the payload after the
  398. * following ethernet header again 4 bytes boundary aligned
  399. */
  400. };
  401. /**
  402. * struct batadv_frag_packet - fragmented packet
  403. * @packet_type: batman-adv packet type, part of the general header
  404. * @version: batman-adv protocol version, part of the genereal header
  405. * @ttl: time to live for this packet, part of the genereal header
  406. * @dest: final destination used when routing fragments
  407. * @orig: originator of the fragment used when merging the packet
  408. * @no: fragment number within this sequence
  409. * @priority: priority of frame, from ToS IP precedence or 802.1p
  410. * @reserved: reserved byte for alignment
  411. * @seqno: sequence identification
  412. * @total_size: size of the merged packet
  413. */
  414. struct batadv_frag_packet {
  415. __u8 packet_type;
  416. __u8 version; /* batman version field */
  417. __u8 ttl;
  418. #if defined(__BIG_ENDIAN_BITFIELD)
  419. __u8 no:4;
  420. __u8 priority:3;
  421. __u8 reserved:1;
  422. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  423. __u8 reserved:1;
  424. __u8 priority:3;
  425. __u8 no:4;
  426. #else
  427. #error "unknown bitfield endianness"
  428. #endif
  429. __u8 dest[ETH_ALEN];
  430. __u8 orig[ETH_ALEN];
  431. __be16 seqno;
  432. __be16 total_size;
  433. };
  434. /**
  435. * struct batadv_bcast_packet - broadcast packet for network payload
  436. * @packet_type: batman-adv packet type, part of the general header
  437. * @version: batman-adv protocol version, part of the genereal header
  438. * @ttl: time to live for this packet, part of the genereal header
  439. * @reserved: reserved byte for alignment
  440. * @seqno: sequence identification
  441. * @orig: originator of the broadcast packet
  442. */
  443. struct batadv_bcast_packet {
  444. __u8 packet_type;
  445. __u8 version; /* batman version field */
  446. __u8 ttl;
  447. __u8 reserved;
  448. __be32 seqno;
  449. __u8 orig[ETH_ALEN];
  450. /* "4 bytes boundary + 2 bytes" long to make the payload after the
  451. * following ethernet header again 4 bytes boundary aligned
  452. */
  453. };
  454. /**
  455. * struct batadv_coded_packet - network coded packet
  456. * @packet_type: batman-adv packet type, part of the general header
  457. * @version: batman-adv protocol version, part of the genereal header
  458. * @ttl: time to live for this packet, part of the genereal header
  459. * @first_source: original source of first included packet
  460. * @first_orig_dest: original destinal of first included packet
  461. * @first_crc: checksum of first included packet
  462. * @first_ttvn: tt-version number of first included packet
  463. * @second_ttl: ttl of second packet
  464. * @second_dest: second receiver of this coded packet
  465. * @second_source: original source of second included packet
  466. * @second_orig_dest: original destination of second included packet
  467. * @second_crc: checksum of second included packet
  468. * @second_ttvn: tt version number of second included packet
  469. * @coded_len: length of network coded part of the payload
  470. */
  471. struct batadv_coded_packet {
  472. __u8 packet_type;
  473. __u8 version; /* batman version field */
  474. __u8 ttl;
  475. __u8 first_ttvn;
  476. /* __u8 first_dest[ETH_ALEN]; - saved in mac header destination */
  477. __u8 first_source[ETH_ALEN];
  478. __u8 first_orig_dest[ETH_ALEN];
  479. __be32 first_crc;
  480. __u8 second_ttl;
  481. __u8 second_ttvn;
  482. __u8 second_dest[ETH_ALEN];
  483. __u8 second_source[ETH_ALEN];
  484. __u8 second_orig_dest[ETH_ALEN];
  485. __be32 second_crc;
  486. __be16 coded_len;
  487. };
  488. /**
  489. * struct batadv_unicast_tvlv_packet - generic unicast packet with tvlv payload
  490. * @packet_type: batman-adv packet type, part of the general header
  491. * @version: batman-adv protocol version, part of the genereal header
  492. * @ttl: time to live for this packet, part of the genereal header
  493. * @reserved: reserved field (for packet alignment)
  494. * @src: address of the source
  495. * @dst: address of the destination
  496. * @tvlv_len: length of tvlv data following the unicast tvlv header
  497. * @align: 2 bytes to align the header to a 4 byte boundary
  498. */
  499. struct batadv_unicast_tvlv_packet {
  500. __u8 packet_type;
  501. __u8 version; /* batman version field */
  502. __u8 ttl;
  503. __u8 reserved;
  504. __u8 dst[ETH_ALEN];
  505. __u8 src[ETH_ALEN];
  506. __be16 tvlv_len;
  507. __u16 align;
  508. };
  509. /**
  510. * struct batadv_tvlv_hdr - base tvlv header struct
  511. * @type: tvlv container type (see batadv_tvlv_type)
  512. * @version: tvlv container version
  513. * @len: tvlv container length
  514. */
  515. struct batadv_tvlv_hdr {
  516. __u8 type;
  517. __u8 version;
  518. __be16 len;
  519. };
  520. /**
  521. * struct batadv_tvlv_gateway_data - gateway data propagated through gw tvlv
  522. * container
  523. * @bandwidth_down: advertised uplink download bandwidth
  524. * @bandwidth_up: advertised uplink upload bandwidth
  525. */
  526. struct batadv_tvlv_gateway_data {
  527. __be32 bandwidth_down;
  528. __be32 bandwidth_up;
  529. };
  530. /**
  531. * struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container
  532. * @flags: translation table flags (see batadv_tt_data_flags)
  533. * @ttvn: translation table version number
  534. * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by
  535. * one batadv_tvlv_tt_vlan_data object per announced vlan
  536. */
  537. struct batadv_tvlv_tt_data {
  538. __u8 flags;
  539. __u8 ttvn;
  540. __be16 num_vlan;
  541. };
  542. /**
  543. * struct batadv_tvlv_tt_vlan_data - vlan specific tt data propagated through
  544. * the tt tvlv container
  545. * @crc: crc32 checksum of the entries belonging to this vlan
  546. * @vid: vlan identifier
  547. * @reserved: unused, useful for alignment purposes
  548. */
  549. struct batadv_tvlv_tt_vlan_data {
  550. __be32 crc;
  551. __be16 vid;
  552. __u16 reserved;
  553. };
  554. /**
  555. * struct batadv_tvlv_tt_change - translation table diff data
  556. * @flags: status indicators concerning the non-mesh client (see
  557. * batadv_tt_client_flags)
  558. * @reserved: reserved field - useful for alignment purposes only
  559. * @addr: mac address of non-mesh client that triggered this tt change
  560. * @vid: VLAN identifier
  561. */
  562. struct batadv_tvlv_tt_change {
  563. __u8 flags;
  564. __u8 reserved[3];
  565. __u8 addr[ETH_ALEN];
  566. __be16 vid;
  567. };
  568. /**
  569. * struct batadv_tvlv_roam_adv - roaming advertisement
  570. * @client: mac address of roaming client
  571. * @vid: VLAN identifier
  572. */
  573. struct batadv_tvlv_roam_adv {
  574. __u8 client[ETH_ALEN];
  575. __be16 vid;
  576. };
  577. /**
  578. * struct batadv_tvlv_mcast_data - payload of a multicast tvlv
  579. * @flags: multicast flags announced by the orig node
  580. * @reserved: reserved field
  581. */
  582. struct batadv_tvlv_mcast_data {
  583. __u8 flags;
  584. __u8 reserved[3];
  585. };
  586. #pragma pack()
  587. #endif /* _LINUX_BATADV_PACKET_H_ */