1 From: Sven Eckelmann <sven.eckelmann@openmesh.com>
2 Date: Thu, 21 Dec 2017 10:17:41 +0100
3 Subject: [PATCH] batman-adv: Convert packet.h to uapi header
5 The header file is used by different userspace programs to inject packets
6 or to decode sniffed packets. It should therefore be available to them as
9 Also other components in the kernel (like the flow dissector) require
10 access to the packet definitions to be able to decode ETH_P_BATMAN ethernet
13 Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
16 rename net/batman-adv/packet.h => include/uapi/linux/batadv_packet.h (99%)
20 @@ -2551,6 +2551,7 @@ S: Maintained
21 F: Documentation/ABI/testing/sysfs-class-net-batman-adv
22 F: Documentation/ABI/testing/sysfs-class-net-mesh
23 F: Documentation/networking/batman-adv.rst
24 +F: include/uapi/linux/batadv_packet.h
25 F: include/uapi/linux/batman_adv.h
28 --- a/net/batman-adv/bat_iv_ogm.c
29 +++ b/net/batman-adv/bat_iv_ogm.c
31 #include <linux/workqueue.h>
32 #include <net/genetlink.h>
33 #include <net/netlink.h>
34 +#include <uapi/linux/batadv_packet.h>
35 #include <uapi/linux/batman_adv.h>
40 #include "network-coding.h"
41 #include "originator.h"
45 #include "translation-table.h"
46 --- a/net/batman-adv/bat_v.c
47 +++ b/net/batman-adv/bat_v.c
49 #include <linux/workqueue.h>
50 #include <net/genetlink.h>
51 #include <net/netlink.h>
52 +#include <uapi/linux/batadv_packet.h>
53 #include <uapi/linux/batman_adv.h>
59 #include "originator.h"
64 --- a/net/batman-adv/bat_v_elp.c
65 +++ b/net/batman-adv/bat_v_elp.c
67 #include <linux/types.h>
68 #include <linux/workqueue.h>
69 #include <net/cfg80211.h>
70 +#include <uapi/linux/batadv_packet.h>
73 #include "bat_v_ogm.h"
74 #include "hard-interface.h"
76 #include "originator.h"
81 --- a/net/batman-adv/bat_v_ogm.c
82 +++ b/net/batman-adv/bat_v_ogm.c
84 #include <linux/string.h>
85 #include <linux/types.h>
86 #include <linux/workqueue.h>
87 +#include <uapi/linux/batadv_packet.h>
90 #include "hard-interface.h"
93 #include "originator.h"
97 #include "translation-table.h"
98 --- a/net/batman-adv/bridge_loop_avoidance.c
99 +++ b/net/batman-adv/bridge_loop_avoidance.c
101 #include <net/genetlink.h>
102 #include <net/netlink.h>
103 #include <net/sock.h>
104 +#include <uapi/linux/batadv_packet.h>
105 #include <uapi/linux/batman_adv.h>
107 #include "hard-interface.h"
111 #include "originator.h"
113 #include "soft-interface.h"
115 #include "translation-table.h"
116 --- a/net/batman-adv/distributed-arp-table.h
117 +++ b/net/batman-adv/distributed-arp-table.h
119 #include <linux/compiler.h>
120 #include <linux/netdevice.h>
121 #include <linux/types.h>
122 +#include <uapi/linux/batadv_packet.h>
124 #include "originator.h"
129 --- a/net/batman-adv/fragmentation.c
130 +++ b/net/batman-adv/fragmentation.c
132 #include <linux/slab.h>
133 #include <linux/spinlock.h>
134 #include <linux/string.h>
135 +#include <uapi/linux/batadv_packet.h>
137 #include "hard-interface.h"
138 #include "originator.h"
142 #include "soft-interface.h"
143 --- a/net/batman-adv/gateway_client.c
144 +++ b/net/batman-adv/gateway_client.c
146 #include <linux/stddef.h>
147 #include <linux/udp.h>
148 #include <net/sock.h>
149 +#include <uapi/linux/batadv_packet.h>
150 #include <uapi/linux/batman_adv.h>
152 #include "gateway_common.h"
156 #include "originator.h"
159 #include "soft-interface.h"
161 --- a/net/batman-adv/gateway_common.c
162 +++ b/net/batman-adv/gateway_common.c
164 #include <linux/netdevice.h>
165 #include <linux/stddef.h>
166 #include <linux/string.h>
167 +#include <uapi/linux/batadv_packet.h>
169 #include "gateway_client.h"
175 --- a/net/batman-adv/hard-interface.c
176 +++ b/net/batman-adv/hard-interface.c
178 #include <linux/spinlock.h>
179 #include <net/net_namespace.h>
180 #include <net/rtnetlink.h>
181 +#include <uapi/linux/batadv_packet.h>
184 #include "bridge_loop_avoidance.h"
186 #include "gateway_client.h"
188 #include "originator.h"
191 #include "soft-interface.h"
193 --- a/net/batman-adv/icmp_socket.c
194 +++ b/net/batman-adv/icmp_socket.c
196 #include <linux/string.h>
197 #include <linux/uaccess.h>
198 #include <linux/wait.h>
199 +#include <uapi/linux/batadv_packet.h>
201 #include "hard-interface.h"
203 #include "originator.h"
207 static struct batadv_socket_client *batadv_socket_client_hash[256];
208 --- a/net/batman-adv/main.c
209 +++ b/net/batman-adv/main.c
211 #include <linux/workqueue.h>
212 #include <net/dsfield.h>
213 #include <net/rtnetlink.h>
214 +#include <uapi/linux/batadv_packet.h>
215 #include <uapi/linux/batman_adv.h>
217 #include "bat_algo.h"
220 #include "network-coding.h"
221 #include "originator.h"
225 #include "soft-interface.h"
226 --- a/net/batman-adv/main.h
227 +++ b/net/batman-adv/main.h
228 @@ -190,8 +190,8 @@ enum batadv_uev_type {
229 #include <linux/jiffies.h>
230 #include <linux/percpu.h>
231 #include <linux/types.h>
232 +#include <uapi/linux/batadv_packet.h>
238 --- a/net/batman-adv/multicast.c
239 +++ b/net/batman-adv/multicast.c
241 #include <net/if_inet6.h>
243 #include <net/ipv6.h>
244 +#include <uapi/linux/batadv_packet.h>
246 #include "hard-interface.h"
250 #include "translation-table.h"
253 --- a/net/batman-adv/netlink.c
254 +++ b/net/batman-adv/netlink.c
256 #include <net/genetlink.h>
257 #include <net/netlink.h>
258 #include <net/sock.h>
259 +#include <uapi/linux/batadv_packet.h>
260 #include <uapi/linux/batman_adv.h>
262 #include "bat_algo.h"
264 #include "gateway_client.h"
265 #include "hard-interface.h"
266 #include "originator.h"
268 #include "soft-interface.h"
269 #include "tp_meter.h"
270 #include "translation-table.h"
271 --- a/net/batman-adv/network-coding.c
272 +++ b/net/batman-adv/network-coding.c
274 #include <linux/stddef.h>
275 #include <linux/string.h>
276 #include <linux/workqueue.h>
277 +#include <uapi/linux/batadv_packet.h>
279 #include "hard-interface.h"
282 #include "originator.h"
287 --- a/net/batman-adv/packet.h
290 -/* Copyright (C) 2007-2017 B.A.T.M.A.N. contributors:
292 - * Marek Lindner, Simon Wunderlich
294 - * This program is free software; you can redistribute it and/or
295 - * modify it under the terms of version 2 of the GNU General Public
296 - * License as published by the Free Software Foundation.
298 - * This program is distributed in the hope that it will be useful, but
299 - * WITHOUT ANY WARRANTY; without even the implied warranty of
300 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
301 - * General Public License for more details.
303 - * You should have received a copy of the GNU General Public License
304 - * along with this program; if not, see <http://www.gnu.org/licenses/>.
307 -#ifndef _NET_BATMAN_ADV_PACKET_H_
308 -#define _NET_BATMAN_ADV_PACKET_H_
310 -#include <asm/byteorder.h>
311 -#include <linux/if_ether.h>
312 -#include <linux/types.h>
314 -#define batadv_tp_is_error(n) ((__u8)(n) > 127 ? 1 : 0)
317 - * enum batadv_packettype - types for batman-adv encapsulated packets
318 - * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
319 - * @BATADV_BCAST: broadcast packets carrying broadcast payload
320 - * @BATADV_CODED: network coded packets
321 - * @BATADV_ELP: echo location packets for B.A.T.M.A.N. V
322 - * @BATADV_OGM2: originator messages for B.A.T.M.A.N. V
324 - * @BATADV_UNICAST: unicast packets carrying unicast payload traffic
325 - * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
327 - * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of
329 - * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute
330 - * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers
332 -enum batadv_packettype {
333 - /* 0x00 - 0x3f: local packets or special rules for handling */
334 - BATADV_IV_OGM = 0x00,
335 - BATADV_BCAST = 0x01,
336 - BATADV_CODED = 0x02,
338 - BATADV_OGM2 = 0x04,
339 - /* 0x40 - 0x7f: unicast */
340 -#define BATADV_UNICAST_MIN 0x40
341 - BATADV_UNICAST = 0x40,
342 - BATADV_UNICAST_FRAG = 0x41,
343 - BATADV_UNICAST_4ADDR = 0x42,
344 - BATADV_ICMP = 0x43,
345 - BATADV_UNICAST_TVLV = 0x44,
346 -#define BATADV_UNICAST_MAX 0x7f
347 - /* 0x80 - 0xff: reserved */
351 - * enum batadv_subtype - packet subtype for unicast4addr
352 - * @BATADV_P_DATA: user payload
353 - * @BATADV_P_DAT_DHT_GET: DHT request message
354 - * @BATADV_P_DAT_DHT_PUT: DHT store message
355 - * @BATADV_P_DAT_CACHE_REPLY: ARP reply generated by DAT
357 -enum batadv_subtype {
358 - BATADV_P_DATA = 0x01,
359 - BATADV_P_DAT_DHT_GET = 0x02,
360 - BATADV_P_DAT_DHT_PUT = 0x03,
361 - BATADV_P_DAT_CACHE_REPLY = 0x04,
364 -/* this file is included by batctl which needs these defines */
365 -#define BATADV_COMPAT_VERSION 15
368 - * enum batadv_iv_flags - flags used in B.A.T.M.A.N. IV OGM packets
369 - * @BATADV_NOT_BEST_NEXT_HOP: flag is set when ogm packet is forwarded and was
370 - * previously received from someone else than the best neighbor.
371 - * @BATADV_PRIMARIES_FIRST_HOP: flag unused.
372 - * @BATADV_DIRECTLINK: flag is for the first hop or if rebroadcasted from a
373 - * one hop neighbor on the interface where it was originally received.
375 -enum batadv_iv_flags {
376 - BATADV_NOT_BEST_NEXT_HOP = 1UL << 0,
377 - BATADV_PRIMARIES_FIRST_HOP = 1UL << 1,
378 - BATADV_DIRECTLINK = 1UL << 2,
381 -/* ICMP message types */
382 -enum batadv_icmp_packettype {
383 - BATADV_ECHO_REPLY = 0,
384 - BATADV_DESTINATION_UNREACHABLE = 3,
385 - BATADV_ECHO_REQUEST = 8,
386 - BATADV_TTL_EXCEEDED = 11,
387 - BATADV_PARAMETER_PROBLEM = 12,
392 - * enum batadv_mcast_flags - flags for multicast capabilities and settings
393 - * @BATADV_MCAST_WANT_ALL_UNSNOOPABLES: we want all packets destined for
394 - * 224.0.0.0/24 or ff02::1
395 - * @BATADV_MCAST_WANT_ALL_IPV4: we want all IPv4 multicast packets
396 - * @BATADV_MCAST_WANT_ALL_IPV6: we want all IPv6 multicast packets
398 -enum batadv_mcast_flags {
399 - BATADV_MCAST_WANT_ALL_UNSNOOPABLES = 1UL << 0,
400 - BATADV_MCAST_WANT_ALL_IPV4 = 1UL << 1,
401 - BATADV_MCAST_WANT_ALL_IPV6 = 1UL << 2,
404 -/* tt data subtypes */
405 -#define BATADV_TT_DATA_TYPE_MASK 0x0F
408 - * enum batadv_tt_data_flags - flags for tt data tvlv
409 - * @BATADV_TT_OGM_DIFF: TT diff propagated through OGM
410 - * @BATADV_TT_REQUEST: TT request message
411 - * @BATADV_TT_RESPONSE: TT response message
412 - * @BATADV_TT_FULL_TABLE: contains full table to replace existing table
414 -enum batadv_tt_data_flags {
415 - BATADV_TT_OGM_DIFF = 1UL << 0,
416 - BATADV_TT_REQUEST = 1UL << 1,
417 - BATADV_TT_RESPONSE = 1UL << 2,
418 - BATADV_TT_FULL_TABLE = 1UL << 4,
422 - * enum batadv_vlan_flags - flags for the four MSB of any vlan ID field
423 - * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not
425 -enum batadv_vlan_flags {
426 - BATADV_VLAN_HAS_TAG = 1UL << 15,
429 -/* claim frame types for the bridge loop avoidance */
430 -enum batadv_bla_claimframe {
431 - BATADV_CLAIM_TYPE_CLAIM = 0x00,
432 - BATADV_CLAIM_TYPE_UNCLAIM = 0x01,
433 - BATADV_CLAIM_TYPE_ANNOUNCE = 0x02,
434 - BATADV_CLAIM_TYPE_REQUEST = 0x03,
435 - BATADV_CLAIM_TYPE_LOOPDETECT = 0x04,
439 - * enum batadv_tvlv_type - tvlv type definitions
440 - * @BATADV_TVLV_GW: gateway tvlv
441 - * @BATADV_TVLV_DAT: distributed arp table tvlv
442 - * @BATADV_TVLV_NC: network coding tvlv
443 - * @BATADV_TVLV_TT: translation table tvlv
444 - * @BATADV_TVLV_ROAM: roaming advertisement tvlv
445 - * @BATADV_TVLV_MCAST: multicast capability tvlv
447 -enum batadv_tvlv_type {
448 - BATADV_TVLV_GW = 0x01,
449 - BATADV_TVLV_DAT = 0x02,
450 - BATADV_TVLV_NC = 0x03,
451 - BATADV_TVLV_TT = 0x04,
452 - BATADV_TVLV_ROAM = 0x05,
453 - BATADV_TVLV_MCAST = 0x06,
457 -/* the destination hardware field in the ARP frame is used to
458 - * transport the claim type and the group id
460 -struct batadv_bla_claim_dst {
461 - __u8 magic[3]; /* FF:43:05 */
462 - __u8 type; /* bla_claimframe */
463 - __be16 group; /* group id */
469 - * struct batadv_ogm_packet - ogm (routing protocol) packet
470 - * @packet_type: batman-adv packet type, part of the general header
471 - * @version: batman-adv protocol version, part of the genereal header
472 - * @ttl: time to live for this packet, part of the genereal header
473 - * @flags: contains routing relevant flags - see enum batadv_iv_flags
474 - * @seqno: sequence identification
475 - * @orig: address of the source node
476 - * @prev_sender: address of the previous sender
477 - * @reserved: reserved byte for alignment
478 - * @tq: transmission quality
479 - * @tvlv_len: length of tvlv data following the ogm header
481 -struct batadv_ogm_packet {
487 - __u8 orig[ETH_ALEN];
488 - __u8 prev_sender[ETH_ALEN];
492 - /* __packed is not needed as the struct size is divisible by 4,
493 - * and the largest data type in this struct has a size of 4.
497 -#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
500 - * struct batadv_ogm2_packet - ogm2 (routing protocol) packet
501 - * @packet_type: batman-adv packet type, part of the general header
502 - * @version: batman-adv protocol version, part of the general header
503 - * @ttl: time to live for this packet, part of the general header
504 - * @flags: reseved for routing relevant flags - currently always 0
505 - * @seqno: sequence number
506 - * @orig: originator mac address
507 - * @tvlv_len: length of the appended tvlv buffer (in bytes)
508 - * @throughput: the currently flooded path throughput
510 -struct batadv_ogm2_packet {
516 - __u8 orig[ETH_ALEN];
519 - /* __packed is not needed as the struct size is divisible by 4,
520 - * and the largest data type in this struct has a size of 4.
524 -#define BATADV_OGM2_HLEN sizeof(struct batadv_ogm2_packet)
527 - * struct batadv_elp_packet - elp (neighbor discovery) packet
528 - * @packet_type: batman-adv packet type, part of the general header
529 - * @version: batman-adv protocol version, part of the genereal header
530 - * @orig: originator mac address
531 - * @seqno: sequence number
532 - * @elp_interval: currently used ELP sending interval in ms
534 -struct batadv_elp_packet {
537 - __u8 orig[ETH_ALEN];
539 - __be32 elp_interval;
542 -#define BATADV_ELP_HLEN sizeof(struct batadv_elp_packet)
545 - * struct batadv_icmp_header - common members among all the ICMP packets
546 - * @packet_type: batman-adv packet type, part of the general header
547 - * @version: batman-adv protocol version, part of the genereal header
548 - * @ttl: time to live for this packet, part of the genereal header
549 - * @msg_type: ICMP packet type
550 - * @dst: address of the destination node
551 - * @orig: address of the source node
552 - * @uid: local ICMP socket identifier
553 - * @align: not used - useful for alignment purposes only
555 - * This structure is used for ICMP packets parsing only and it is never sent
556 - * over the wire. The alignment field at the end is there to ensure that
557 - * members are padded the same way as they are in real packets.
559 -struct batadv_icmp_header {
563 - __u8 msg_type; /* see ICMP message types above */
564 - __u8 dst[ETH_ALEN];
565 - __u8 orig[ETH_ALEN];
571 - * struct batadv_icmp_packet - ICMP packet
572 - * @packet_type: batman-adv packet type, part of the general header
573 - * @version: batman-adv protocol version, part of the genereal header
574 - * @ttl: time to live for this packet, part of the genereal header
575 - * @msg_type: ICMP packet type
576 - * @dst: address of the destination node
577 - * @orig: address of the source node
578 - * @uid: local ICMP socket identifier
579 - * @reserved: not used - useful for alignment
580 - * @seqno: ICMP sequence number
582 -struct batadv_icmp_packet {
586 - __u8 msg_type; /* see ICMP message types above */
587 - __u8 dst[ETH_ALEN];
588 - __u8 orig[ETH_ALEN];
595 - * struct batadv_icmp_tp_packet - ICMP TP Meter packet
596 - * @packet_type: batman-adv packet type, part of the general header
597 - * @version: batman-adv protocol version, part of the genereal header
598 - * @ttl: time to live for this packet, part of the genereal header
599 - * @msg_type: ICMP packet type
600 - * @dst: address of the destination node
601 - * @orig: address of the source node
602 - * @uid: local ICMP socket identifier
603 - * @subtype: TP packet subtype (see batadv_icmp_tp_subtype)
604 - * @session: TP session identifier
605 - * @seqno: the TP sequence number
606 - * @timestamp: time when the packet has been sent. This value is filled in a
607 - * TP_MSG and echoed back in the next TP_ACK so that the sender can compute the
608 - * RTT. Since it is read only by the host which wrote it, there is no need to
609 - * store it using network order
611 -struct batadv_icmp_tp_packet {
615 - __u8 msg_type; /* see ICMP message types above */
616 - __u8 dst[ETH_ALEN];
617 - __u8 orig[ETH_ALEN];
626 - * enum batadv_icmp_tp_subtype - ICMP TP Meter packet subtypes
627 - * @BATADV_TP_MSG: Msg from sender to receiver
628 - * @BATADV_TP_ACK: acknowledgment from receiver to sender
630 -enum batadv_icmp_tp_subtype {
635 -#define BATADV_RR_LEN 16
638 - * struct batadv_icmp_packet_rr - ICMP RouteRecord packet
639 - * @packet_type: batman-adv packet type, part of the general header
640 - * @version: batman-adv protocol version, part of the genereal header
641 - * @ttl: time to live for this packet, part of the genereal header
642 - * @msg_type: ICMP packet type
643 - * @dst: address of the destination node
644 - * @orig: address of the source node
645 - * @uid: local ICMP socket identifier
646 - * @rr_cur: number of entries the rr array
647 - * @seqno: ICMP sequence number
648 - * @rr: route record array
650 -struct batadv_icmp_packet_rr {
654 - __u8 msg_type; /* see ICMP message types above */
655 - __u8 dst[ETH_ALEN];
656 - __u8 orig[ETH_ALEN];
660 - __u8 rr[BATADV_RR_LEN][ETH_ALEN];
663 -#define BATADV_ICMP_MAX_PACKET_SIZE sizeof(struct batadv_icmp_packet_rr)
665 -/* All packet headers in front of an ethernet header have to be completely
666 - * divisible by 2 but not by 4 to make the payload after the ethernet
667 - * header again 4 bytes boundary aligned.
669 - * A packing of 2 is necessary to avoid extra padding at the end of the struct
670 - * caused by a structure member which is larger than two bytes. Otherwise
671 - * the structure would not fulfill the previously mentioned rule to avoid the
672 - * misalignment of the payload after the ethernet header. It may also lead to
673 - * leakage of information when the padding it not initialized before sending.
678 - * struct batadv_unicast_packet - unicast packet for network payload
679 - * @packet_type: batman-adv packet type, part of the general header
680 - * @version: batman-adv protocol version, part of the genereal header
681 - * @ttl: time to live for this packet, part of the genereal header
682 - * @ttvn: translation table version number
683 - * @dest: originator destination of the unicast packet
685 -struct batadv_unicast_packet {
689 - __u8 ttvn; /* destination translation table version number */
690 - __u8 dest[ETH_ALEN];
691 - /* "4 bytes boundary + 2 bytes" long to make the payload after the
692 - * following ethernet header again 4 bytes boundary aligned
697 - * struct batadv_unicast_4addr_packet - extended unicast packet
698 - * @u: common unicast packet header
699 - * @src: address of the source
700 - * @subtype: packet subtype
701 - * @reserved: reserved byte for alignment
703 -struct batadv_unicast_4addr_packet {
704 - struct batadv_unicast_packet u;
705 - __u8 src[ETH_ALEN];
708 - /* "4 bytes boundary + 2 bytes" long to make the payload after the
709 - * following ethernet header again 4 bytes boundary aligned
714 - * struct batadv_frag_packet - fragmented packet
715 - * @packet_type: batman-adv packet type, part of the general header
716 - * @version: batman-adv protocol version, part of the genereal header
717 - * @ttl: time to live for this packet, part of the genereal header
718 - * @dest: final destination used when routing fragments
719 - * @orig: originator of the fragment used when merging the packet
720 - * @no: fragment number within this sequence
721 - * @priority: priority of frame, from ToS IP precedence or 802.1p
722 - * @reserved: reserved byte for alignment
723 - * @seqno: sequence identification
724 - * @total_size: size of the merged packet
726 -struct batadv_frag_packet {
728 - __u8 version; /* batman version field */
730 -#if defined(__BIG_ENDIAN_BITFIELD)
734 -#elif defined(__LITTLE_ENDIAN_BITFIELD)
739 -#error "unknown bitfield endianness"
741 - __u8 dest[ETH_ALEN];
742 - __u8 orig[ETH_ALEN];
748 - * struct batadv_bcast_packet - broadcast packet for network payload
749 - * @packet_type: batman-adv packet type, part of the general header
750 - * @version: batman-adv protocol version, part of the genereal header
751 - * @ttl: time to live for this packet, part of the genereal header
752 - * @reserved: reserved byte for alignment
753 - * @seqno: sequence identification
754 - * @orig: originator of the broadcast packet
756 -struct batadv_bcast_packet {
758 - __u8 version; /* batman version field */
762 - __u8 orig[ETH_ALEN];
763 - /* "4 bytes boundary + 2 bytes" long to make the payload after the
764 - * following ethernet header again 4 bytes boundary aligned
769 - * struct batadv_coded_packet - network coded packet
770 - * @packet_type: batman-adv packet type, part of the general header
771 - * @version: batman-adv protocol version, part of the genereal header
772 - * @ttl: time to live for this packet, part of the genereal header
773 - * @first_source: original source of first included packet
774 - * @first_orig_dest: original destinal of first included packet
775 - * @first_crc: checksum of first included packet
776 - * @first_ttvn: tt-version number of first included packet
777 - * @second_ttl: ttl of second packet
778 - * @second_dest: second receiver of this coded packet
779 - * @second_source: original source of second included packet
780 - * @second_orig_dest: original destination of second included packet
781 - * @second_crc: checksum of second included packet
782 - * @second_ttvn: tt version number of second included packet
783 - * @coded_len: length of network coded part of the payload
785 -struct batadv_coded_packet {
787 - __u8 version; /* batman version field */
790 - /* __u8 first_dest[ETH_ALEN]; - saved in mac header destination */
791 - __u8 first_source[ETH_ALEN];
792 - __u8 first_orig_dest[ETH_ALEN];
796 - __u8 second_dest[ETH_ALEN];
797 - __u8 second_source[ETH_ALEN];
798 - __u8 second_orig_dest[ETH_ALEN];
806 - * struct batadv_unicast_tvlv_packet - generic unicast packet with tvlv payload
807 - * @packet_type: batman-adv packet type, part of the general header
808 - * @version: batman-adv protocol version, part of the genereal header
809 - * @ttl: time to live for this packet, part of the genereal header
810 - * @reserved: reserved field (for packet alignment)
811 - * @src: address of the source
812 - * @dst: address of the destination
813 - * @tvlv_len: length of tvlv data following the unicast tvlv header
814 - * @align: 2 bytes to align the header to a 4 byte boundary
816 -struct batadv_unicast_tvlv_packet {
818 - __u8 version; /* batman version field */
821 - __u8 dst[ETH_ALEN];
822 - __u8 src[ETH_ALEN];
828 - * struct batadv_tvlv_hdr - base tvlv header struct
829 - * @type: tvlv container type (see batadv_tvlv_type)
830 - * @version: tvlv container version
831 - * @len: tvlv container length
833 -struct batadv_tvlv_hdr {
840 - * struct batadv_tvlv_gateway_data - gateway data propagated through gw tvlv
842 - * @bandwidth_down: advertised uplink download bandwidth
843 - * @bandwidth_up: advertised uplink upload bandwidth
845 -struct batadv_tvlv_gateway_data {
846 - __be32 bandwidth_down;
847 - __be32 bandwidth_up;
851 - * struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container
852 - * @flags: translation table flags (see batadv_tt_data_flags)
853 - * @ttvn: translation table version number
854 - * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by
855 - * one batadv_tvlv_tt_vlan_data object per announced vlan
857 -struct batadv_tvlv_tt_data {
864 - * struct batadv_tvlv_tt_vlan_data - vlan specific tt data propagated through
865 - * the tt tvlv container
866 - * @crc: crc32 checksum of the entries belonging to this vlan
867 - * @vid: vlan identifier
868 - * @reserved: unused, useful for alignment purposes
870 -struct batadv_tvlv_tt_vlan_data {
877 - * struct batadv_tvlv_tt_change - translation table diff data
878 - * @flags: status indicators concerning the non-mesh client (see
879 - * batadv_tt_client_flags)
880 - * @reserved: reserved field - useful for alignment purposes only
881 - * @addr: mac address of non-mesh client that triggered this tt change
882 - * @vid: VLAN identifier
884 -struct batadv_tvlv_tt_change {
887 - __u8 addr[ETH_ALEN];
892 - * struct batadv_tvlv_roam_adv - roaming advertisement
893 - * @client: mac address of roaming client
894 - * @vid: VLAN identifier
896 -struct batadv_tvlv_roam_adv {
897 - __u8 client[ETH_ALEN];
902 - * struct batadv_tvlv_mcast_data - payload of a multicast tvlv
903 - * @flags: multicast flags announced by the orig node
904 - * @reserved: reserved field
906 -struct batadv_tvlv_mcast_data {
911 -#endif /* _NET_BATMAN_ADV_PACKET_H_ */
912 --- a/net/batman-adv/routing.c
913 +++ b/net/batman-adv/routing.c
915 #include <linux/skbuff.h>
916 #include <linux/spinlock.h>
917 #include <linux/stddef.h>
918 +#include <uapi/linux/batadv_packet.h>
920 #include "bitarray.h"
921 #include "bridge_loop_avoidance.h"
924 #include "network-coding.h"
925 #include "originator.h"
928 #include "soft-interface.h"
929 #include "tp_meter.h"
930 --- a/net/batman-adv/send.h
931 +++ b/net/batman-adv/send.h
933 #include <linux/compiler.h>
934 #include <linux/spinlock.h>
935 #include <linux/types.h>
938 +#include <uapi/linux/batadv_packet.h>
942 --- a/net/batman-adv/soft-interface.c
943 +++ b/net/batman-adv/soft-interface.c
945 #include <linux/stddef.h>
946 #include <linux/string.h>
947 #include <linux/types.h>
948 +#include <uapi/linux/batadv_packet.h>
950 #include "bat_algo.h"
951 #include "bridge_loop_avoidance.h"
953 #include "multicast.h"
954 #include "network-coding.h"
955 #include "originator.h"
959 #include "translation-table.h"
960 --- a/net/batman-adv/sysfs.c
961 +++ b/net/batman-adv/sysfs.c
963 #include <linux/string.h>
964 #include <linux/stringify.h>
965 #include <linux/workqueue.h>
966 +#include <uapi/linux/batadv_packet.h>
968 #include "bridge_loop_avoidance.h"
969 #include "distributed-arp-table.h"
971 #include "hard-interface.h"
973 #include "network-coding.h"
975 #include "soft-interface.h"
977 static struct net_device *batadv_kobj_to_netdev(struct kobject *obj)
978 --- a/net/batman-adv/tp_meter.c
979 +++ b/net/batman-adv/tp_meter.c
981 #include <linux/timer.h>
982 #include <linux/wait.h>
983 #include <linux/workqueue.h>
984 +#include <uapi/linux/batadv_packet.h>
985 #include <uapi/linux/batman_adv.h>
987 #include "hard-interface.h"
990 #include "originator.h"
995 --- a/net/batman-adv/translation-table.c
996 +++ b/net/batman-adv/translation-table.c
998 #include <net/genetlink.h>
999 #include <net/netlink.h>
1000 #include <net/sock.h>
1001 +#include <uapi/linux/batadv_packet.h>
1002 #include <uapi/linux/batman_adv.h>
1004 #include "bridge_loop_avoidance.h"
1007 #include "netlink.h"
1008 #include "originator.h"
1009 -#include "packet.h"
1010 #include "soft-interface.h"
1013 --- a/net/batman-adv/tvlv.c
1014 +++ b/net/batman-adv/tvlv.c
1016 #include <linux/stddef.h>
1017 #include <linux/string.h>
1018 #include <linux/types.h>
1019 +#include <uapi/linux/batadv_packet.h>
1021 #include "originator.h"
1022 -#include "packet.h"
1026 --- a/net/batman-adv/types.h
1027 +++ b/net/batman-adv/types.h
1029 #include <linux/types.h>
1030 #include <linux/wait.h>
1031 #include <linux/workqueue.h>
1032 +#include <uapi/linux/batadv_packet.h>
1033 #include <uapi/linux/batman_adv.h>
1035 -#include "packet.h"
1039 #ifdef CONFIG_BATMAN_ADV_DAT
1041 +++ b/include/uapi/linux/batadv_packet.h
1043 +/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) */
1044 +/* Copyright (C) 2007-2017 B.A.T.M.A.N. contributors:
1046 + * Marek Lindner, Simon Wunderlich
1048 + * This program is free software; you can redistribute it and/or
1049 + * modify it under the terms of version 2 of the GNU General Public
1050 + * License as published by the Free Software Foundation.
1052 + * This program is distributed in the hope that it will be useful, but
1053 + * WITHOUT ANY WARRANTY; without even the implied warranty of
1054 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1055 + * General Public License for more details.
1057 + * You should have received a copy of the GNU General Public License
1058 + * along with this program; if not, see <http://www.gnu.org/licenses/>.
1061 +#ifndef _UAPI_LINUX_BATADV_PACKET_H_
1062 +#define _UAPI_LINUX_BATADV_PACKET_H_
1064 +#include <asm/byteorder.h>
1065 +#include <linux/if_ether.h>
1066 +#include <linux/types.h>
1068 +#define batadv_tp_is_error(n) ((__u8)(n) > 127 ? 1 : 0)
1071 + * enum batadv_packettype - types for batman-adv encapsulated packets
1072 + * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
1073 + * @BATADV_BCAST: broadcast packets carrying broadcast payload
1074 + * @BATADV_CODED: network coded packets
1075 + * @BATADV_ELP: echo location packets for B.A.T.M.A.N. V
1076 + * @BATADV_OGM2: originator messages for B.A.T.M.A.N. V
1078 + * @BATADV_UNICAST: unicast packets carrying unicast payload traffic
1079 + * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
1081 + * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of
1083 + * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute
1084 + * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers
1086 +enum batadv_packettype {
1087 + /* 0x00 - 0x3f: local packets or special rules for handling */
1088 + BATADV_IV_OGM = 0x00,
1089 + BATADV_BCAST = 0x01,
1090 + BATADV_CODED = 0x02,
1091 + BATADV_ELP = 0x03,
1092 + BATADV_OGM2 = 0x04,
1093 + /* 0x40 - 0x7f: unicast */
1094 +#define BATADV_UNICAST_MIN 0x40
1095 + BATADV_UNICAST = 0x40,
1096 + BATADV_UNICAST_FRAG = 0x41,
1097 + BATADV_UNICAST_4ADDR = 0x42,
1098 + BATADV_ICMP = 0x43,
1099 + BATADV_UNICAST_TVLV = 0x44,
1100 +#define BATADV_UNICAST_MAX 0x7f
1101 + /* 0x80 - 0xff: reserved */
1105 + * enum batadv_subtype - packet subtype for unicast4addr
1106 + * @BATADV_P_DATA: user payload
1107 + * @BATADV_P_DAT_DHT_GET: DHT request message
1108 + * @BATADV_P_DAT_DHT_PUT: DHT store message
1109 + * @BATADV_P_DAT_CACHE_REPLY: ARP reply generated by DAT
1111 +enum batadv_subtype {
1112 + BATADV_P_DATA = 0x01,
1113 + BATADV_P_DAT_DHT_GET = 0x02,
1114 + BATADV_P_DAT_DHT_PUT = 0x03,
1115 + BATADV_P_DAT_CACHE_REPLY = 0x04,
1118 +/* this file is included by batctl which needs these defines */
1119 +#define BATADV_COMPAT_VERSION 15
1122 + * enum batadv_iv_flags - flags used in B.A.T.M.A.N. IV OGM packets
1123 + * @BATADV_NOT_BEST_NEXT_HOP: flag is set when ogm packet is forwarded and was
1124 + * previously received from someone else than the best neighbor.
1125 + * @BATADV_PRIMARIES_FIRST_HOP: flag unused.
1126 + * @BATADV_DIRECTLINK: flag is for the first hop or if rebroadcasted from a
1127 + * one hop neighbor on the interface where it was originally received.
1129 +enum batadv_iv_flags {
1130 + BATADV_NOT_BEST_NEXT_HOP = 1UL << 0,
1131 + BATADV_PRIMARIES_FIRST_HOP = 1UL << 1,
1132 + BATADV_DIRECTLINK = 1UL << 2,
1135 +/* ICMP message types */
1136 +enum batadv_icmp_packettype {
1137 + BATADV_ECHO_REPLY = 0,
1138 + BATADV_DESTINATION_UNREACHABLE = 3,
1139 + BATADV_ECHO_REQUEST = 8,
1140 + BATADV_TTL_EXCEEDED = 11,
1141 + BATADV_PARAMETER_PROBLEM = 12,
1146 + * enum batadv_mcast_flags - flags for multicast capabilities and settings
1147 + * @BATADV_MCAST_WANT_ALL_UNSNOOPABLES: we want all packets destined for
1148 + * 224.0.0.0/24 or ff02::1
1149 + * @BATADV_MCAST_WANT_ALL_IPV4: we want all IPv4 multicast packets
1150 + * @BATADV_MCAST_WANT_ALL_IPV6: we want all IPv6 multicast packets
1152 +enum batadv_mcast_flags {
1153 + BATADV_MCAST_WANT_ALL_UNSNOOPABLES = 1UL << 0,
1154 + BATADV_MCAST_WANT_ALL_IPV4 = 1UL << 1,
1155 + BATADV_MCAST_WANT_ALL_IPV6 = 1UL << 2,
1158 +/* tt data subtypes */
1159 +#define BATADV_TT_DATA_TYPE_MASK 0x0F
1162 + * enum batadv_tt_data_flags - flags for tt data tvlv
1163 + * @BATADV_TT_OGM_DIFF: TT diff propagated through OGM
1164 + * @BATADV_TT_REQUEST: TT request message
1165 + * @BATADV_TT_RESPONSE: TT response message
1166 + * @BATADV_TT_FULL_TABLE: contains full table to replace existing table
1168 +enum batadv_tt_data_flags {
1169 + BATADV_TT_OGM_DIFF = 1UL << 0,
1170 + BATADV_TT_REQUEST = 1UL << 1,
1171 + BATADV_TT_RESPONSE = 1UL << 2,
1172 + BATADV_TT_FULL_TABLE = 1UL << 4,
1176 + * enum batadv_vlan_flags - flags for the four MSB of any vlan ID field
1177 + * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not
1179 +enum batadv_vlan_flags {
1180 + BATADV_VLAN_HAS_TAG = 1UL << 15,
1183 +/* claim frame types for the bridge loop avoidance */
1184 +enum batadv_bla_claimframe {
1185 + BATADV_CLAIM_TYPE_CLAIM = 0x00,
1186 + BATADV_CLAIM_TYPE_UNCLAIM = 0x01,
1187 + BATADV_CLAIM_TYPE_ANNOUNCE = 0x02,
1188 + BATADV_CLAIM_TYPE_REQUEST = 0x03,
1189 + BATADV_CLAIM_TYPE_LOOPDETECT = 0x04,
1193 + * enum batadv_tvlv_type - tvlv type definitions
1194 + * @BATADV_TVLV_GW: gateway tvlv
1195 + * @BATADV_TVLV_DAT: distributed arp table tvlv
1196 + * @BATADV_TVLV_NC: network coding tvlv
1197 + * @BATADV_TVLV_TT: translation table tvlv
1198 + * @BATADV_TVLV_ROAM: roaming advertisement tvlv
1199 + * @BATADV_TVLV_MCAST: multicast capability tvlv
1201 +enum batadv_tvlv_type {
1202 + BATADV_TVLV_GW = 0x01,
1203 + BATADV_TVLV_DAT = 0x02,
1204 + BATADV_TVLV_NC = 0x03,
1205 + BATADV_TVLV_TT = 0x04,
1206 + BATADV_TVLV_ROAM = 0x05,
1207 + BATADV_TVLV_MCAST = 0x06,
1211 +/* the destination hardware field in the ARP frame is used to
1212 + * transport the claim type and the group id
1214 +struct batadv_bla_claim_dst {
1215 + __u8 magic[3]; /* FF:43:05 */
1216 + __u8 type; /* bla_claimframe */
1217 + __be16 group; /* group id */
1223 + * struct batadv_ogm_packet - ogm (routing protocol) packet
1224 + * @packet_type: batman-adv packet type, part of the general header
1225 + * @version: batman-adv protocol version, part of the genereal header
1226 + * @ttl: time to live for this packet, part of the genereal header
1227 + * @flags: contains routing relevant flags - see enum batadv_iv_flags
1228 + * @seqno: sequence identification
1229 + * @orig: address of the source node
1230 + * @prev_sender: address of the previous sender
1231 + * @reserved: reserved byte for alignment
1232 + * @tq: transmission quality
1233 + * @tvlv_len: length of tvlv data following the ogm header
1235 +struct batadv_ogm_packet {
1241 + __u8 orig[ETH_ALEN];
1242 + __u8 prev_sender[ETH_ALEN];
1246 + /* __packed is not needed as the struct size is divisible by 4,
1247 + * and the largest data type in this struct has a size of 4.
1251 +#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
1254 + * struct batadv_ogm2_packet - ogm2 (routing protocol) packet
1255 + * @packet_type: batman-adv packet type, part of the general header
1256 + * @version: batman-adv protocol version, part of the general header
1257 + * @ttl: time to live for this packet, part of the general header
1258 + * @flags: reseved for routing relevant flags - currently always 0
1259 + * @seqno: sequence number
1260 + * @orig: originator mac address
1261 + * @tvlv_len: length of the appended tvlv buffer (in bytes)
1262 + * @throughput: the currently flooded path throughput
1264 +struct batadv_ogm2_packet {
1270 + __u8 orig[ETH_ALEN];
1272 + __be32 throughput;
1273 + /* __packed is not needed as the struct size is divisible by 4,
1274 + * and the largest data type in this struct has a size of 4.
1278 +#define BATADV_OGM2_HLEN sizeof(struct batadv_ogm2_packet)
1281 + * struct batadv_elp_packet - elp (neighbor discovery) packet
1282 + * @packet_type: batman-adv packet type, part of the general header
1283 + * @version: batman-adv protocol version, part of the genereal header
1284 + * @orig: originator mac address
1285 + * @seqno: sequence number
1286 + * @elp_interval: currently used ELP sending interval in ms
1288 +struct batadv_elp_packet {
1291 + __u8 orig[ETH_ALEN];
1293 + __be32 elp_interval;
1296 +#define BATADV_ELP_HLEN sizeof(struct batadv_elp_packet)
1299 + * struct batadv_icmp_header - common members among all the ICMP packets
1300 + * @packet_type: batman-adv packet type, part of the general header
1301 + * @version: batman-adv protocol version, part of the genereal header
1302 + * @ttl: time to live for this packet, part of the genereal header
1303 + * @msg_type: ICMP packet type
1304 + * @dst: address of the destination node
1305 + * @orig: address of the source node
1306 + * @uid: local ICMP socket identifier
1307 + * @align: not used - useful for alignment purposes only
1309 + * This structure is used for ICMP packets parsing only and it is never sent
1310 + * over the wire. The alignment field at the end is there to ensure that
1311 + * members are padded the same way as they are in real packets.
1313 +struct batadv_icmp_header {
1317 + __u8 msg_type; /* see ICMP message types above */
1318 + __u8 dst[ETH_ALEN];
1319 + __u8 orig[ETH_ALEN];
1325 + * struct batadv_icmp_packet - ICMP packet
1326 + * @packet_type: batman-adv packet type, part of the general header
1327 + * @version: batman-adv protocol version, part of the genereal header
1328 + * @ttl: time to live for this packet, part of the genereal header
1329 + * @msg_type: ICMP packet type
1330 + * @dst: address of the destination node
1331 + * @orig: address of the source node
1332 + * @uid: local ICMP socket identifier
1333 + * @reserved: not used - useful for alignment
1334 + * @seqno: ICMP sequence number
1336 +struct batadv_icmp_packet {
1340 + __u8 msg_type; /* see ICMP message types above */
1341 + __u8 dst[ETH_ALEN];
1342 + __u8 orig[ETH_ALEN];
1349 + * struct batadv_icmp_tp_packet - ICMP TP Meter packet
1350 + * @packet_type: batman-adv packet type, part of the general header
1351 + * @version: batman-adv protocol version, part of the genereal header
1352 + * @ttl: time to live for this packet, part of the genereal header
1353 + * @msg_type: ICMP packet type
1354 + * @dst: address of the destination node
1355 + * @orig: address of the source node
1356 + * @uid: local ICMP socket identifier
1357 + * @subtype: TP packet subtype (see batadv_icmp_tp_subtype)
1358 + * @session: TP session identifier
1359 + * @seqno: the TP sequence number
1360 + * @timestamp: time when the packet has been sent. This value is filled in a
1361 + * TP_MSG and echoed back in the next TP_ACK so that the sender can compute the
1362 + * RTT. Since it is read only by the host which wrote it, there is no need to
1363 + * store it using network order
1365 +struct batadv_icmp_tp_packet {
1369 + __u8 msg_type; /* see ICMP message types above */
1370 + __u8 dst[ETH_ALEN];
1371 + __u8 orig[ETH_ALEN];
1380 + * enum batadv_icmp_tp_subtype - ICMP TP Meter packet subtypes
1381 + * @BATADV_TP_MSG: Msg from sender to receiver
1382 + * @BATADV_TP_ACK: acknowledgment from receiver to sender
1384 +enum batadv_icmp_tp_subtype {
1385 + BATADV_TP_MSG = 0,
1389 +#define BATADV_RR_LEN 16
1392 + * struct batadv_icmp_packet_rr - ICMP RouteRecord packet
1393 + * @packet_type: batman-adv packet type, part of the general header
1394 + * @version: batman-adv protocol version, part of the genereal header
1395 + * @ttl: time to live for this packet, part of the genereal header
1396 + * @msg_type: ICMP packet type
1397 + * @dst: address of the destination node
1398 + * @orig: address of the source node
1399 + * @uid: local ICMP socket identifier
1400 + * @rr_cur: number of entries the rr array
1401 + * @seqno: ICMP sequence number
1402 + * @rr: route record array
1404 +struct batadv_icmp_packet_rr {
1408 + __u8 msg_type; /* see ICMP message types above */
1409 + __u8 dst[ETH_ALEN];
1410 + __u8 orig[ETH_ALEN];
1414 + __u8 rr[BATADV_RR_LEN][ETH_ALEN];
1417 +#define BATADV_ICMP_MAX_PACKET_SIZE sizeof(struct batadv_icmp_packet_rr)
1419 +/* All packet headers in front of an ethernet header have to be completely
1420 + * divisible by 2 but not by 4 to make the payload after the ethernet
1421 + * header again 4 bytes boundary aligned.
1423 + * A packing of 2 is necessary to avoid extra padding at the end of the struct
1424 + * caused by a structure member which is larger than two bytes. Otherwise
1425 + * the structure would not fulfill the previously mentioned rule to avoid the
1426 + * misalignment of the payload after the ethernet header. It may also lead to
1427 + * leakage of information when the padding it not initialized before sending.
1432 + * struct batadv_unicast_packet - unicast packet for network payload
1433 + * @packet_type: batman-adv packet type, part of the general header
1434 + * @version: batman-adv protocol version, part of the genereal header
1435 + * @ttl: time to live for this packet, part of the genereal header
1436 + * @ttvn: translation table version number
1437 + * @dest: originator destination of the unicast packet
1439 +struct batadv_unicast_packet {
1443 + __u8 ttvn; /* destination translation table version number */
1444 + __u8 dest[ETH_ALEN];
1445 + /* "4 bytes boundary + 2 bytes" long to make the payload after the
1446 + * following ethernet header again 4 bytes boundary aligned
1451 + * struct batadv_unicast_4addr_packet - extended unicast packet
1452 + * @u: common unicast packet header
1453 + * @src: address of the source
1454 + * @subtype: packet subtype
1455 + * @reserved: reserved byte for alignment
1457 +struct batadv_unicast_4addr_packet {
1458 + struct batadv_unicast_packet u;
1459 + __u8 src[ETH_ALEN];
1462 + /* "4 bytes boundary + 2 bytes" long to make the payload after the
1463 + * following ethernet header again 4 bytes boundary aligned
1468 + * struct batadv_frag_packet - fragmented packet
1469 + * @packet_type: batman-adv packet type, part of the general header
1470 + * @version: batman-adv protocol version, part of the genereal header
1471 + * @ttl: time to live for this packet, part of the genereal header
1472 + * @dest: final destination used when routing fragments
1473 + * @orig: originator of the fragment used when merging the packet
1474 + * @no: fragment number within this sequence
1475 + * @priority: priority of frame, from ToS IP precedence or 802.1p
1476 + * @reserved: reserved byte for alignment
1477 + * @seqno: sequence identification
1478 + * @total_size: size of the merged packet
1480 +struct batadv_frag_packet {
1482 + __u8 version; /* batman version field */
1484 +#if defined(__BIG_ENDIAN_BITFIELD)
1488 +#elif defined(__LITTLE_ENDIAN_BITFIELD)
1493 +#error "unknown bitfield endianness"
1495 + __u8 dest[ETH_ALEN];
1496 + __u8 orig[ETH_ALEN];
1498 + __be16 total_size;
1502 + * struct batadv_bcast_packet - broadcast packet for network payload
1503 + * @packet_type: batman-adv packet type, part of the general header
1504 + * @version: batman-adv protocol version, part of the genereal header
1505 + * @ttl: time to live for this packet, part of the genereal header
1506 + * @reserved: reserved byte for alignment
1507 + * @seqno: sequence identification
1508 + * @orig: originator of the broadcast packet
1510 +struct batadv_bcast_packet {
1512 + __u8 version; /* batman version field */
1516 + __u8 orig[ETH_ALEN];
1517 + /* "4 bytes boundary + 2 bytes" long to make the payload after the
1518 + * following ethernet header again 4 bytes boundary aligned
1523 + * struct batadv_coded_packet - network coded packet
1524 + * @packet_type: batman-adv packet type, part of the general header
1525 + * @version: batman-adv protocol version, part of the genereal header
1526 + * @ttl: time to live for this packet, part of the genereal header
1527 + * @first_source: original source of first included packet
1528 + * @first_orig_dest: original destinal of first included packet
1529 + * @first_crc: checksum of first included packet
1530 + * @first_ttvn: tt-version number of first included packet
1531 + * @second_ttl: ttl of second packet
1532 + * @second_dest: second receiver of this coded packet
1533 + * @second_source: original source of second included packet
1534 + * @second_orig_dest: original destination of second included packet
1535 + * @second_crc: checksum of second included packet
1536 + * @second_ttvn: tt version number of second included packet
1537 + * @coded_len: length of network coded part of the payload
1539 +struct batadv_coded_packet {
1541 + __u8 version; /* batman version field */
1544 + /* __u8 first_dest[ETH_ALEN]; - saved in mac header destination */
1545 + __u8 first_source[ETH_ALEN];
1546 + __u8 first_orig_dest[ETH_ALEN];
1550 + __u8 second_dest[ETH_ALEN];
1551 + __u8 second_source[ETH_ALEN];
1552 + __u8 second_orig_dest[ETH_ALEN];
1553 + __be32 second_crc;
1560 + * struct batadv_unicast_tvlv_packet - generic unicast packet with tvlv payload
1561 + * @packet_type: batman-adv packet type, part of the general header
1562 + * @version: batman-adv protocol version, part of the genereal header
1563 + * @ttl: time to live for this packet, part of the genereal header
1564 + * @reserved: reserved field (for packet alignment)
1565 + * @src: address of the source
1566 + * @dst: address of the destination
1567 + * @tvlv_len: length of tvlv data following the unicast tvlv header
1568 + * @align: 2 bytes to align the header to a 4 byte boundary
1570 +struct batadv_unicast_tvlv_packet {
1572 + __u8 version; /* batman version field */
1575 + __u8 dst[ETH_ALEN];
1576 + __u8 src[ETH_ALEN];
1582 + * struct batadv_tvlv_hdr - base tvlv header struct
1583 + * @type: tvlv container type (see batadv_tvlv_type)
1584 + * @version: tvlv container version
1585 + * @len: tvlv container length
1587 +struct batadv_tvlv_hdr {
1594 + * struct batadv_tvlv_gateway_data - gateway data propagated through gw tvlv
1596 + * @bandwidth_down: advertised uplink download bandwidth
1597 + * @bandwidth_up: advertised uplink upload bandwidth
1599 +struct batadv_tvlv_gateway_data {
1600 + __be32 bandwidth_down;
1601 + __be32 bandwidth_up;
1605 + * struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container
1606 + * @flags: translation table flags (see batadv_tt_data_flags)
1607 + * @ttvn: translation table version number
1608 + * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by
1609 + * one batadv_tvlv_tt_vlan_data object per announced vlan
1611 +struct batadv_tvlv_tt_data {
1618 + * struct batadv_tvlv_tt_vlan_data - vlan specific tt data propagated through
1619 + * the tt tvlv container
1620 + * @crc: crc32 checksum of the entries belonging to this vlan
1621 + * @vid: vlan identifier
1622 + * @reserved: unused, useful for alignment purposes
1624 +struct batadv_tvlv_tt_vlan_data {
1631 + * struct batadv_tvlv_tt_change - translation table diff data
1632 + * @flags: status indicators concerning the non-mesh client (see
1633 + * batadv_tt_client_flags)
1634 + * @reserved: reserved field - useful for alignment purposes only
1635 + * @addr: mac address of non-mesh client that triggered this tt change
1636 + * @vid: VLAN identifier
1638 +struct batadv_tvlv_tt_change {
1641 + __u8 addr[ETH_ALEN];
1646 + * struct batadv_tvlv_roam_adv - roaming advertisement
1647 + * @client: mac address of roaming client
1648 + * @vid: VLAN identifier
1650 +struct batadv_tvlv_roam_adv {
1651 + __u8 client[ETH_ALEN];
1656 + * struct batadv_tvlv_mcast_data - payload of a multicast tvlv
1657 + * @flags: multicast flags announced by the orig node
1658 + * @reserved: reserved field
1660 +struct batadv_tvlv_mcast_data {
1665 +#endif /* _UAPI_LINUX_BATADV_PACKET_H_ */