batadv_packet.h 20 KB

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