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