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>
18 @@ -2551,6 +2551,7 @@ S: Maintained
19 F: Documentation/ABI/testing/sysfs-class-net-batman-adv
20 F: Documentation/ABI/testing/sysfs-class-net-mesh
21 F: Documentation/networking/batman-adv.rst
22 +F: include/uapi/linux/batadv_packet.h
23 F: include/uapi/linux/batman_adv.h
26 --- a/net/batman-adv/bat_iv_ogm.c
27 +++ b/net/batman-adv/bat_iv_ogm.c
29 #include <linux/workqueue.h>
30 #include <net/genetlink.h>
31 #include <net/netlink.h>
32 +#include <uapi/linux/batadv_packet.h>
33 #include <uapi/linux/batman_adv.h>
38 #include "network-coding.h"
39 #include "originator.h"
43 #include "translation-table.h"
44 --- a/net/batman-adv/bat_v.c
45 +++ b/net/batman-adv/bat_v.c
47 #include <linux/workqueue.h>
48 #include <net/genetlink.h>
49 #include <net/netlink.h>
50 +#include <uapi/linux/batadv_packet.h>
51 #include <uapi/linux/batman_adv.h>
57 #include "originator.h"
62 --- a/net/batman-adv/bat_v_elp.c
63 +++ b/net/batman-adv/bat_v_elp.c
65 #include <linux/types.h>
66 #include <linux/workqueue.h>
67 #include <net/cfg80211.h>
68 +#include <uapi/linux/batadv_packet.h>
71 #include "bat_v_ogm.h"
72 #include "hard-interface.h"
74 #include "originator.h"
79 --- a/net/batman-adv/bat_v_ogm.c
80 +++ b/net/batman-adv/bat_v_ogm.c
82 #include <linux/string.h>
83 #include <linux/types.h>
84 #include <linux/workqueue.h>
85 +#include <uapi/linux/batadv_packet.h>
88 #include "hard-interface.h"
91 #include "originator.h"
95 #include "translation-table.h"
96 --- a/net/batman-adv/bridge_loop_avoidance.c
97 +++ b/net/batman-adv/bridge_loop_avoidance.c
99 #include <net/genetlink.h>
100 #include <net/netlink.h>
101 #include <net/sock.h>
102 +#include <uapi/linux/batadv_packet.h>
103 #include <uapi/linux/batman_adv.h>
105 #include "hard-interface.h"
109 #include "originator.h"
111 #include "soft-interface.h"
113 #include "translation-table.h"
114 --- a/net/batman-adv/distributed-arp-table.h
115 +++ b/net/batman-adv/distributed-arp-table.h
117 #include <linux/compiler.h>
118 #include <linux/netdevice.h>
119 #include <linux/types.h>
120 +#include <uapi/linux/batadv_packet.h>
122 #include "originator.h"
127 --- a/net/batman-adv/fragmentation.c
128 +++ b/net/batman-adv/fragmentation.c
130 #include <linux/slab.h>
131 #include <linux/spinlock.h>
132 #include <linux/string.h>
133 +#include <uapi/linux/batadv_packet.h>
135 #include "hard-interface.h"
136 #include "originator.h"
140 #include "soft-interface.h"
141 --- a/net/batman-adv/gateway_client.c
142 +++ b/net/batman-adv/gateway_client.c
144 #include <linux/stddef.h>
145 #include <linux/udp.h>
146 #include <net/sock.h>
147 +#include <uapi/linux/batadv_packet.h>
148 #include <uapi/linux/batman_adv.h>
150 #include "gateway_common.h"
154 #include "originator.h"
157 #include "soft-interface.h"
159 --- a/net/batman-adv/gateway_common.c
160 +++ b/net/batman-adv/gateway_common.c
162 #include <linux/netdevice.h>
163 #include <linux/stddef.h>
164 #include <linux/string.h>
165 +#include <uapi/linux/batadv_packet.h>
167 #include "gateway_client.h"
173 --- a/net/batman-adv/hard-interface.c
174 +++ b/net/batman-adv/hard-interface.c
176 #include <linux/spinlock.h>
177 #include <net/net_namespace.h>
178 #include <net/rtnetlink.h>
179 +#include <uapi/linux/batadv_packet.h>
182 #include "bridge_loop_avoidance.h"
184 #include "gateway_client.h"
186 #include "originator.h"
189 #include "soft-interface.h"
191 --- a/net/batman-adv/icmp_socket.c
192 +++ b/net/batman-adv/icmp_socket.c
194 #include <linux/string.h>
195 #include <linux/uaccess.h>
196 #include <linux/wait.h>
197 +#include <uapi/linux/batadv_packet.h>
199 #include "hard-interface.h"
201 #include "originator.h"
205 static struct batadv_socket_client *batadv_socket_client_hash[256];
206 --- a/net/batman-adv/main.c
207 +++ b/net/batman-adv/main.c
209 #include <linux/workqueue.h>
210 #include <net/dsfield.h>
211 #include <net/rtnetlink.h>
212 +#include <uapi/linux/batadv_packet.h>
213 #include <uapi/linux/batman_adv.h>
215 #include "bat_algo.h"
218 #include "network-coding.h"
219 #include "originator.h"
223 #include "soft-interface.h"
224 --- a/net/batman-adv/main.h
225 +++ b/net/batman-adv/main.h
226 @@ -190,8 +190,8 @@ enum batadv_uev_type {
227 #include <linux/jiffies.h>
228 #include <linux/percpu.h>
229 #include <linux/types.h>
230 +#include <uapi/linux/batadv_packet.h>
236 --- a/net/batman-adv/multicast.c
237 +++ b/net/batman-adv/multicast.c
239 #include <net/if_inet6.h>
241 #include <net/ipv6.h>
242 +#include <uapi/linux/batadv_packet.h>
244 #include "bridge_loop_avoidance.h"
245 #include "hard-interface.h"
250 #include "translation-table.h"
252 --- a/net/batman-adv/netlink.c
253 +++ b/net/batman-adv/netlink.c
255 #include <net/genetlink.h>
256 #include <net/netlink.h>
257 #include <net/sock.h>
258 +#include <uapi/linux/batadv_packet.h>
259 #include <uapi/linux/batman_adv.h>
261 #include "bat_algo.h"
263 #include "gateway_client.h"
264 #include "hard-interface.h"
265 #include "originator.h"
267 #include "soft-interface.h"
268 #include "tp_meter.h"
269 #include "translation-table.h"
270 --- a/net/batman-adv/network-coding.c
271 +++ b/net/batman-adv/network-coding.c
273 #include <linux/stddef.h>
274 #include <linux/string.h>
275 #include <linux/workqueue.h>
276 +#include <uapi/linux/batadv_packet.h>
278 #include "hard-interface.h"
281 #include "originator.h"
286 --- a/net/batman-adv/packet.h
289 -/* Copyright (C) 2007-2017 B.A.T.M.A.N. contributors:
291 - * Marek Lindner, Simon Wunderlich
293 - * This program is free software; you can redistribute it and/or
294 - * modify it under the terms of version 2 of the GNU General Public
295 - * License as published by the Free Software Foundation.
297 - * This program is distributed in the hope that it will be useful, but
298 - * WITHOUT ANY WARRANTY; without even the implied warranty of
299 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
300 - * General Public License for more details.
302 - * You should have received a copy of the GNU General Public License
303 - * along with this program; if not, see <http://www.gnu.org/licenses/>.
306 -#ifndef _NET_BATMAN_ADV_PACKET_H_
307 -#define _NET_BATMAN_ADV_PACKET_H_
309 -#include <asm/byteorder.h>
310 -#include <linux/if_ether.h>
311 -#include <linux/types.h>
313 -#define batadv_tp_is_error(n) ((__u8)(n) > 127 ? 1 : 0)
316 - * enum batadv_packettype - types for batman-adv encapsulated packets
317 - * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
318 - * @BATADV_BCAST: broadcast packets carrying broadcast payload
319 - * @BATADV_CODED: network coded packets
320 - * @BATADV_ELP: echo location packets for B.A.T.M.A.N. V
321 - * @BATADV_OGM2: originator messages for B.A.T.M.A.N. V
323 - * @BATADV_UNICAST: unicast packets carrying unicast payload traffic
324 - * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
326 - * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of
328 - * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute
329 - * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers
331 -enum batadv_packettype {
332 - /* 0x00 - 0x3f: local packets or special rules for handling */
333 - BATADV_IV_OGM = 0x00,
334 - BATADV_BCAST = 0x01,
335 - BATADV_CODED = 0x02,
337 - BATADV_OGM2 = 0x04,
338 - /* 0x40 - 0x7f: unicast */
339 -#define BATADV_UNICAST_MIN 0x40
340 - BATADV_UNICAST = 0x40,
341 - BATADV_UNICAST_FRAG = 0x41,
342 - BATADV_UNICAST_4ADDR = 0x42,
343 - BATADV_ICMP = 0x43,
344 - BATADV_UNICAST_TVLV = 0x44,
345 -#define BATADV_UNICAST_MAX 0x7f
346 - /* 0x80 - 0xff: reserved */
350 - * enum batadv_subtype - packet subtype for unicast4addr
351 - * @BATADV_P_DATA: user payload
352 - * @BATADV_P_DAT_DHT_GET: DHT request message
353 - * @BATADV_P_DAT_DHT_PUT: DHT store message
354 - * @BATADV_P_DAT_CACHE_REPLY: ARP reply generated by DAT
356 -enum batadv_subtype {
357 - BATADV_P_DATA = 0x01,
358 - BATADV_P_DAT_DHT_GET = 0x02,
359 - BATADV_P_DAT_DHT_PUT = 0x03,
360 - BATADV_P_DAT_CACHE_REPLY = 0x04,
363 -/* this file is included by batctl which needs these defines */
364 -#define BATADV_COMPAT_VERSION 15
367 - * enum batadv_iv_flags - flags used in B.A.T.M.A.N. IV OGM packets
368 - * @BATADV_NOT_BEST_NEXT_HOP: flag is set when ogm packet is forwarded and was
369 - * previously received from someone else than the best neighbor.
370 - * @BATADV_PRIMARIES_FIRST_HOP: flag unused.
371 - * @BATADV_DIRECTLINK: flag is for the first hop or if rebroadcasted from a
372 - * one hop neighbor on the interface where it was originally received.
374 -enum batadv_iv_flags {
375 - BATADV_NOT_BEST_NEXT_HOP = 1UL << 0,
376 - BATADV_PRIMARIES_FIRST_HOP = 1UL << 1,
377 - BATADV_DIRECTLINK = 1UL << 2,
380 -/* ICMP message types */
381 -enum batadv_icmp_packettype {
382 - BATADV_ECHO_REPLY = 0,
383 - BATADV_DESTINATION_UNREACHABLE = 3,
384 - BATADV_ECHO_REQUEST = 8,
385 - BATADV_TTL_EXCEEDED = 11,
386 - BATADV_PARAMETER_PROBLEM = 12,
391 - * enum batadv_mcast_flags - flags for multicast capabilities and settings
392 - * @BATADV_MCAST_WANT_ALL_UNSNOOPABLES: we want all packets destined for
393 - * 224.0.0.0/24 or ff02::1
394 - * @BATADV_MCAST_WANT_ALL_IPV4: we want all IPv4 multicast packets
395 - * @BATADV_MCAST_WANT_ALL_IPV6: we want all IPv6 multicast packets
397 -enum batadv_mcast_flags {
398 - BATADV_MCAST_WANT_ALL_UNSNOOPABLES = 1UL << 0,
399 - BATADV_MCAST_WANT_ALL_IPV4 = 1UL << 1,
400 - BATADV_MCAST_WANT_ALL_IPV6 = 1UL << 2,
403 -/* tt data subtypes */
404 -#define BATADV_TT_DATA_TYPE_MASK 0x0F
407 - * enum batadv_tt_data_flags - flags for tt data tvlv
408 - * @BATADV_TT_OGM_DIFF: TT diff propagated through OGM
409 - * @BATADV_TT_REQUEST: TT request message
410 - * @BATADV_TT_RESPONSE: TT response message
411 - * @BATADV_TT_FULL_TABLE: contains full table to replace existing table
413 -enum batadv_tt_data_flags {
414 - BATADV_TT_OGM_DIFF = 1UL << 0,
415 - BATADV_TT_REQUEST = 1UL << 1,
416 - BATADV_TT_RESPONSE = 1UL << 2,
417 - BATADV_TT_FULL_TABLE = 1UL << 4,
421 - * enum batadv_vlan_flags - flags for the four MSB of any vlan ID field
422 - * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not
424 -enum batadv_vlan_flags {
425 - BATADV_VLAN_HAS_TAG = 1UL << 15,
428 -/* claim frame types for the bridge loop avoidance */
429 -enum batadv_bla_claimframe {
430 - BATADV_CLAIM_TYPE_CLAIM = 0x00,
431 - BATADV_CLAIM_TYPE_UNCLAIM = 0x01,
432 - BATADV_CLAIM_TYPE_ANNOUNCE = 0x02,
433 - BATADV_CLAIM_TYPE_REQUEST = 0x03,
434 - BATADV_CLAIM_TYPE_LOOPDETECT = 0x04,
438 - * enum batadv_tvlv_type - tvlv type definitions
439 - * @BATADV_TVLV_GW: gateway tvlv
440 - * @BATADV_TVLV_DAT: distributed arp table tvlv
441 - * @BATADV_TVLV_NC: network coding tvlv
442 - * @BATADV_TVLV_TT: translation table tvlv
443 - * @BATADV_TVLV_ROAM: roaming advertisement tvlv
444 - * @BATADV_TVLV_MCAST: multicast capability tvlv
446 -enum batadv_tvlv_type {
447 - BATADV_TVLV_GW = 0x01,
448 - BATADV_TVLV_DAT = 0x02,
449 - BATADV_TVLV_NC = 0x03,
450 - BATADV_TVLV_TT = 0x04,
451 - BATADV_TVLV_ROAM = 0x05,
452 - BATADV_TVLV_MCAST = 0x06,
456 -/* the destination hardware field in the ARP frame is used to
457 - * transport the claim type and the group id
459 -struct batadv_bla_claim_dst {
460 - __u8 magic[3]; /* FF:43:05 */
461 - __u8 type; /* bla_claimframe */
462 - __be16 group; /* group id */
468 - * struct batadv_ogm_packet - ogm (routing protocol) packet
469 - * @packet_type: batman-adv packet type, part of the general header
470 - * @version: batman-adv protocol version, part of the genereal header
471 - * @ttl: time to live for this packet, part of the genereal header
472 - * @flags: contains routing relevant flags - see enum batadv_iv_flags
473 - * @seqno: sequence identification
474 - * @orig: address of the source node
475 - * @prev_sender: address of the previous sender
476 - * @reserved: reserved byte for alignment
477 - * @tq: transmission quality
478 - * @tvlv_len: length of tvlv data following the ogm header
480 -struct batadv_ogm_packet {
486 - __u8 orig[ETH_ALEN];
487 - __u8 prev_sender[ETH_ALEN];
491 - /* __packed is not needed as the struct size is divisible by 4,
492 - * and the largest data type in this struct has a size of 4.
496 -#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
499 - * struct batadv_ogm2_packet - ogm2 (routing protocol) packet
500 - * @packet_type: batman-adv packet type, part of the general header
501 - * @version: batman-adv protocol version, part of the general header
502 - * @ttl: time to live for this packet, part of the general header
503 - * @flags: reseved for routing relevant flags - currently always 0
504 - * @seqno: sequence number
505 - * @orig: originator mac address
506 - * @tvlv_len: length of the appended tvlv buffer (in bytes)
507 - * @throughput: the currently flooded path throughput
509 -struct batadv_ogm2_packet {
515 - __u8 orig[ETH_ALEN];
518 - /* __packed is not needed as the struct size is divisible by 4,
519 - * and the largest data type in this struct has a size of 4.
523 -#define BATADV_OGM2_HLEN sizeof(struct batadv_ogm2_packet)
526 - * struct batadv_elp_packet - elp (neighbor discovery) packet
527 - * @packet_type: batman-adv packet type, part of the general header
528 - * @version: batman-adv protocol version, part of the genereal header
529 - * @orig: originator mac address
530 - * @seqno: sequence number
531 - * @elp_interval: currently used ELP sending interval in ms
533 -struct batadv_elp_packet {
536 - __u8 orig[ETH_ALEN];
538 - __be32 elp_interval;
541 -#define BATADV_ELP_HLEN sizeof(struct batadv_elp_packet)
544 - * struct batadv_icmp_header - common members among all the ICMP packets
545 - * @packet_type: batman-adv packet type, part of the general header
546 - * @version: batman-adv protocol version, part of the genereal header
547 - * @ttl: time to live for this packet, part of the genereal header
548 - * @msg_type: ICMP packet type
549 - * @dst: address of the destination node
550 - * @orig: address of the source node
551 - * @uid: local ICMP socket identifier
552 - * @align: not used - useful for alignment purposes only
554 - * This structure is used for ICMP packets parsing only and it is never sent
555 - * over the wire. The alignment field at the end is there to ensure that
556 - * members are padded the same way as they are in real packets.
558 -struct batadv_icmp_header {
562 - __u8 msg_type; /* see ICMP message types above */
563 - __u8 dst[ETH_ALEN];
564 - __u8 orig[ETH_ALEN];
570 - * struct batadv_icmp_packet - ICMP packet
571 - * @packet_type: batman-adv packet type, part of the general header
572 - * @version: batman-adv protocol version, part of the genereal header
573 - * @ttl: time to live for this packet, part of the genereal header
574 - * @msg_type: ICMP packet type
575 - * @dst: address of the destination node
576 - * @orig: address of the source node
577 - * @uid: local ICMP socket identifier
578 - * @reserved: not used - useful for alignment
579 - * @seqno: ICMP sequence number
581 -struct batadv_icmp_packet {
585 - __u8 msg_type; /* see ICMP message types above */
586 - __u8 dst[ETH_ALEN];
587 - __u8 orig[ETH_ALEN];
594 - * struct batadv_icmp_tp_packet - ICMP TP Meter packet
595 - * @packet_type: batman-adv packet type, part of the general header
596 - * @version: batman-adv protocol version, part of the genereal header
597 - * @ttl: time to live for this packet, part of the genereal header
598 - * @msg_type: ICMP packet type
599 - * @dst: address of the destination node
600 - * @orig: address of the source node
601 - * @uid: local ICMP socket identifier
602 - * @subtype: TP packet subtype (see batadv_icmp_tp_subtype)
603 - * @session: TP session identifier
604 - * @seqno: the TP sequence number
605 - * @timestamp: time when the packet has been sent. This value is filled in a
606 - * TP_MSG and echoed back in the next TP_ACK so that the sender can compute the
607 - * RTT. Since it is read only by the host which wrote it, there is no need to
608 - * store it using network order
610 -struct batadv_icmp_tp_packet {
614 - __u8 msg_type; /* see ICMP message types above */
615 - __u8 dst[ETH_ALEN];
616 - __u8 orig[ETH_ALEN];
625 - * enum batadv_icmp_tp_subtype - ICMP TP Meter packet subtypes
626 - * @BATADV_TP_MSG: Msg from sender to receiver
627 - * @BATADV_TP_ACK: acknowledgment from receiver to sender
629 -enum batadv_icmp_tp_subtype {
634 -#define BATADV_RR_LEN 16
637 - * struct batadv_icmp_packet_rr - ICMP RouteRecord packet
638 - * @packet_type: batman-adv packet type, part of the general header
639 - * @version: batman-adv protocol version, part of the genereal header
640 - * @ttl: time to live for this packet, part of the genereal header
641 - * @msg_type: ICMP packet type
642 - * @dst: address of the destination node
643 - * @orig: address of the source node
644 - * @uid: local ICMP socket identifier
645 - * @rr_cur: number of entries the rr array
646 - * @seqno: ICMP sequence number
647 - * @rr: route record array
649 -struct batadv_icmp_packet_rr {
653 - __u8 msg_type; /* see ICMP message types above */
654 - __u8 dst[ETH_ALEN];
655 - __u8 orig[ETH_ALEN];
659 - __u8 rr[BATADV_RR_LEN][ETH_ALEN];
662 -#define BATADV_ICMP_MAX_PACKET_SIZE sizeof(struct batadv_icmp_packet_rr)
664 -/* All packet headers in front of an ethernet header have to be completely
665 - * divisible by 2 but not by 4 to make the payload after the ethernet
666 - * header again 4 bytes boundary aligned.
668 - * A packing of 2 is necessary to avoid extra padding at the end of the struct
669 - * caused by a structure member which is larger than two bytes. Otherwise
670 - * the structure would not fulfill the previously mentioned rule to avoid the
671 - * misalignment of the payload after the ethernet header. It may also lead to
672 - * leakage of information when the padding it not initialized before sending.
677 - * struct batadv_unicast_packet - unicast packet for network payload
678 - * @packet_type: batman-adv packet type, part of the general header
679 - * @version: batman-adv protocol version, part of the genereal header
680 - * @ttl: time to live for this packet, part of the genereal header
681 - * @ttvn: translation table version number
682 - * @dest: originator destination of the unicast packet
684 -struct batadv_unicast_packet {
688 - __u8 ttvn; /* destination translation table version number */
689 - __u8 dest[ETH_ALEN];
690 - /* "4 bytes boundary + 2 bytes" long to make the payload after the
691 - * following ethernet header again 4 bytes boundary aligned
696 - * struct batadv_unicast_4addr_packet - extended unicast packet
697 - * @u: common unicast packet header
698 - * @src: address of the source
699 - * @subtype: packet subtype
700 - * @reserved: reserved byte for alignment
702 -struct batadv_unicast_4addr_packet {
703 - struct batadv_unicast_packet u;
704 - __u8 src[ETH_ALEN];
707 - /* "4 bytes boundary + 2 bytes" long to make the payload after the
708 - * following ethernet header again 4 bytes boundary aligned
713 - * struct batadv_frag_packet - fragmented packet
714 - * @packet_type: batman-adv packet type, part of the general header
715 - * @version: batman-adv protocol version, part of the genereal header
716 - * @ttl: time to live for this packet, part of the genereal header
717 - * @dest: final destination used when routing fragments
718 - * @orig: originator of the fragment used when merging the packet
719 - * @no: fragment number within this sequence
720 - * @priority: priority of frame, from ToS IP precedence or 802.1p
721 - * @reserved: reserved byte for alignment
722 - * @seqno: sequence identification
723 - * @total_size: size of the merged packet
725 -struct batadv_frag_packet {
727 - __u8 version; /* batman version field */
729 -#if defined(__BIG_ENDIAN_BITFIELD)
733 -#elif defined(__LITTLE_ENDIAN_BITFIELD)
738 -#error "unknown bitfield endianness"
740 - __u8 dest[ETH_ALEN];
741 - __u8 orig[ETH_ALEN];
747 - * struct batadv_bcast_packet - broadcast packet for network payload
748 - * @packet_type: batman-adv packet type, part of the general header
749 - * @version: batman-adv protocol version, part of the genereal header
750 - * @ttl: time to live for this packet, part of the genereal header
751 - * @reserved: reserved byte for alignment
752 - * @seqno: sequence identification
753 - * @orig: originator of the broadcast packet
755 -struct batadv_bcast_packet {
757 - __u8 version; /* batman version field */
761 - __u8 orig[ETH_ALEN];
762 - /* "4 bytes boundary + 2 bytes" long to make the payload after the
763 - * following ethernet header again 4 bytes boundary aligned
768 - * struct batadv_coded_packet - network coded packet
769 - * @packet_type: batman-adv packet type, part of the general header
770 - * @version: batman-adv protocol version, part of the genereal header
771 - * @ttl: time to live for this packet, part of the genereal header
772 - * @first_source: original source of first included packet
773 - * @first_orig_dest: original destinal of first included packet
774 - * @first_crc: checksum of first included packet
775 - * @first_ttvn: tt-version number of first included packet
776 - * @second_ttl: ttl of second packet
777 - * @second_dest: second receiver of this coded packet
778 - * @second_source: original source of second included packet
779 - * @second_orig_dest: original destination of second included packet
780 - * @second_crc: checksum of second included packet
781 - * @second_ttvn: tt version number of second included packet
782 - * @coded_len: length of network coded part of the payload
784 -struct batadv_coded_packet {
786 - __u8 version; /* batman version field */
789 - /* __u8 first_dest[ETH_ALEN]; - saved in mac header destination */
790 - __u8 first_source[ETH_ALEN];
791 - __u8 first_orig_dest[ETH_ALEN];
795 - __u8 second_dest[ETH_ALEN];
796 - __u8 second_source[ETH_ALEN];
797 - __u8 second_orig_dest[ETH_ALEN];
805 - * struct batadv_unicast_tvlv_packet - generic unicast packet with tvlv payload
806 - * @packet_type: batman-adv packet type, part of the general header
807 - * @version: batman-adv protocol version, part of the genereal header
808 - * @ttl: time to live for this packet, part of the genereal header
809 - * @reserved: reserved field (for packet alignment)
810 - * @src: address of the source
811 - * @dst: address of the destination
812 - * @tvlv_len: length of tvlv data following the unicast tvlv header
813 - * @align: 2 bytes to align the header to a 4 byte boundary
815 -struct batadv_unicast_tvlv_packet {
817 - __u8 version; /* batman version field */
820 - __u8 dst[ETH_ALEN];
821 - __u8 src[ETH_ALEN];
827 - * struct batadv_tvlv_hdr - base tvlv header struct
828 - * @type: tvlv container type (see batadv_tvlv_type)
829 - * @version: tvlv container version
830 - * @len: tvlv container length
832 -struct batadv_tvlv_hdr {
839 - * struct batadv_tvlv_gateway_data - gateway data propagated through gw tvlv
841 - * @bandwidth_down: advertised uplink download bandwidth
842 - * @bandwidth_up: advertised uplink upload bandwidth
844 -struct batadv_tvlv_gateway_data {
845 - __be32 bandwidth_down;
846 - __be32 bandwidth_up;
850 - * struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container
851 - * @flags: translation table flags (see batadv_tt_data_flags)
852 - * @ttvn: translation table version number
853 - * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by
854 - * one batadv_tvlv_tt_vlan_data object per announced vlan
856 -struct batadv_tvlv_tt_data {
863 - * struct batadv_tvlv_tt_vlan_data - vlan specific tt data propagated through
864 - * the tt tvlv container
865 - * @crc: crc32 checksum of the entries belonging to this vlan
866 - * @vid: vlan identifier
867 - * @reserved: unused, useful for alignment purposes
869 -struct batadv_tvlv_tt_vlan_data {
876 - * struct batadv_tvlv_tt_change - translation table diff data
877 - * @flags: status indicators concerning the non-mesh client (see
878 - * batadv_tt_client_flags)
879 - * @reserved: reserved field - useful for alignment purposes only
880 - * @addr: mac address of non-mesh client that triggered this tt change
881 - * @vid: VLAN identifier
883 -struct batadv_tvlv_tt_change {
886 - __u8 addr[ETH_ALEN];
891 - * struct batadv_tvlv_roam_adv - roaming advertisement
892 - * @client: mac address of roaming client
893 - * @vid: VLAN identifier
895 -struct batadv_tvlv_roam_adv {
896 - __u8 client[ETH_ALEN];
901 - * struct batadv_tvlv_mcast_data - payload of a multicast tvlv
902 - * @flags: multicast flags announced by the orig node
903 - * @reserved: reserved field
905 -struct batadv_tvlv_mcast_data {
910 -#endif /* _NET_BATMAN_ADV_PACKET_H_ */
911 --- a/net/batman-adv/routing.c
912 +++ b/net/batman-adv/routing.c
914 #include <linux/skbuff.h>
915 #include <linux/spinlock.h>
916 #include <linux/stddef.h>
917 +#include <uapi/linux/batadv_packet.h>
919 #include "bitarray.h"
920 #include "bridge_loop_avoidance.h"
923 #include "network-coding.h"
924 #include "originator.h"
927 #include "soft-interface.h"
928 #include "tp_meter.h"
929 --- a/net/batman-adv/send.h
930 +++ b/net/batman-adv/send.h
932 #include <linux/compiler.h>
933 #include <linux/spinlock.h>
934 #include <linux/types.h>
937 +#include <uapi/linux/batadv_packet.h>
941 --- a/net/batman-adv/soft-interface.c
942 +++ b/net/batman-adv/soft-interface.c
944 #include <linux/stddef.h>
945 #include <linux/string.h>
946 #include <linux/types.h>
947 +#include <uapi/linux/batadv_packet.h>
949 #include "bat_algo.h"
950 #include "bridge_loop_avoidance.h"
952 #include "multicast.h"
953 #include "network-coding.h"
954 #include "originator.h"
958 #include "translation-table.h"
959 --- a/net/batman-adv/sysfs.c
960 +++ b/net/batman-adv/sysfs.c
962 #include <linux/string.h>
963 #include <linux/stringify.h>
964 #include <linux/workqueue.h>
965 +#include <uapi/linux/batadv_packet.h>
967 #include "bridge_loop_avoidance.h"
968 #include "distributed-arp-table.h"
970 #include "hard-interface.h"
972 #include "network-coding.h"
974 #include "soft-interface.h"
976 static struct net_device *batadv_kobj_to_netdev(struct kobject *obj)
977 --- a/net/batman-adv/tp_meter.c
978 +++ b/net/batman-adv/tp_meter.c
980 #include <linux/timer.h>
981 #include <linux/wait.h>
982 #include <linux/workqueue.h>
983 +#include <uapi/linux/batadv_packet.h>
984 #include <uapi/linux/batman_adv.h>
986 #include "hard-interface.h"
989 #include "originator.h"
994 --- a/net/batman-adv/translation-table.c
995 +++ b/net/batman-adv/translation-table.c
997 #include <net/genetlink.h>
998 #include <net/netlink.h>
999 #include <net/sock.h>
1000 +#include <uapi/linux/batadv_packet.h>
1001 #include <uapi/linux/batman_adv.h>
1003 #include "bridge_loop_avoidance.h"
1006 #include "netlink.h"
1007 #include "originator.h"
1008 -#include "packet.h"
1009 #include "soft-interface.h"
1012 --- a/net/batman-adv/tvlv.c
1013 +++ b/net/batman-adv/tvlv.c
1015 #include <linux/stddef.h>
1016 #include <linux/string.h>
1017 #include <linux/types.h>
1018 +#include <uapi/linux/batadv_packet.h>
1020 #include "originator.h"
1021 -#include "packet.h"
1025 --- a/net/batman-adv/types.h
1026 +++ b/net/batman-adv/types.h
1028 #include <linux/types.h>
1029 #include <linux/wait.h>
1030 #include <linux/workqueue.h>
1031 +#include <uapi/linux/batadv_packet.h>
1032 #include <uapi/linux/batman_adv.h>
1034 -#include "packet.h"
1038 #ifdef CONFIG_BATMAN_ADV_DAT
1040 +++ b/include/uapi/linux/batadv_packet.h
1042 +/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) */
1043 +/* Copyright (C) 2007-2017 B.A.T.M.A.N. contributors:
1045 + * Marek Lindner, Simon Wunderlich
1047 + * This program is free software; you can redistribute it and/or
1048 + * modify it under the terms of version 2 of the GNU General Public
1049 + * License as published by the Free Software Foundation.
1051 + * This program is distributed in the hope that it will be useful, but
1052 + * WITHOUT ANY WARRANTY; without even the implied warranty of
1053 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1054 + * General Public License for more details.
1056 + * You should have received a copy of the GNU General Public License
1057 + * along with this program; if not, see <http://www.gnu.org/licenses/>.
1060 +#ifndef _UAPI_LINUX_BATADV_PACKET_H_
1061 +#define _UAPI_LINUX_BATADV_PACKET_H_
1063 +#include <asm/byteorder.h>
1064 +#include <linux/if_ether.h>
1065 +#include <linux/types.h>
1067 +#define batadv_tp_is_error(n) ((__u8)(n) > 127 ? 1 : 0)
1070 + * enum batadv_packettype - types for batman-adv encapsulated packets
1071 + * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
1072 + * @BATADV_BCAST: broadcast packets carrying broadcast payload
1073 + * @BATADV_CODED: network coded packets
1074 + * @BATADV_ELP: echo location packets for B.A.T.M.A.N. V
1075 + * @BATADV_OGM2: originator messages for B.A.T.M.A.N. V
1077 + * @BATADV_UNICAST: unicast packets carrying unicast payload traffic
1078 + * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
1080 + * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of
1082 + * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute
1083 + * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers
1085 +enum batadv_packettype {
1086 + /* 0x00 - 0x3f: local packets or special rules for handling */
1087 + BATADV_IV_OGM = 0x00,
1088 + BATADV_BCAST = 0x01,
1089 + BATADV_CODED = 0x02,
1090 + BATADV_ELP = 0x03,
1091 + BATADV_OGM2 = 0x04,
1092 + /* 0x40 - 0x7f: unicast */
1093 +#define BATADV_UNICAST_MIN 0x40
1094 + BATADV_UNICAST = 0x40,
1095 + BATADV_UNICAST_FRAG = 0x41,
1096 + BATADV_UNICAST_4ADDR = 0x42,
1097 + BATADV_ICMP = 0x43,
1098 + BATADV_UNICAST_TVLV = 0x44,
1099 +#define BATADV_UNICAST_MAX 0x7f
1100 + /* 0x80 - 0xff: reserved */
1104 + * enum batadv_subtype - packet subtype for unicast4addr
1105 + * @BATADV_P_DATA: user payload
1106 + * @BATADV_P_DAT_DHT_GET: DHT request message
1107 + * @BATADV_P_DAT_DHT_PUT: DHT store message
1108 + * @BATADV_P_DAT_CACHE_REPLY: ARP reply generated by DAT
1110 +enum batadv_subtype {
1111 + BATADV_P_DATA = 0x01,
1112 + BATADV_P_DAT_DHT_GET = 0x02,
1113 + BATADV_P_DAT_DHT_PUT = 0x03,
1114 + BATADV_P_DAT_CACHE_REPLY = 0x04,
1117 +/* this file is included by batctl which needs these defines */
1118 +#define BATADV_COMPAT_VERSION 15
1121 + * enum batadv_iv_flags - flags used in B.A.T.M.A.N. IV OGM packets
1122 + * @BATADV_NOT_BEST_NEXT_HOP: flag is set when ogm packet is forwarded and was
1123 + * previously received from someone else than the best neighbor.
1124 + * @BATADV_PRIMARIES_FIRST_HOP: flag unused.
1125 + * @BATADV_DIRECTLINK: flag is for the first hop or if rebroadcasted from a
1126 + * one hop neighbor on the interface where it was originally received.
1128 +enum batadv_iv_flags {
1129 + BATADV_NOT_BEST_NEXT_HOP = 1UL << 0,
1130 + BATADV_PRIMARIES_FIRST_HOP = 1UL << 1,
1131 + BATADV_DIRECTLINK = 1UL << 2,
1134 +/* ICMP message types */
1135 +enum batadv_icmp_packettype {
1136 + BATADV_ECHO_REPLY = 0,
1137 + BATADV_DESTINATION_UNREACHABLE = 3,
1138 + BATADV_ECHO_REQUEST = 8,
1139 + BATADV_TTL_EXCEEDED = 11,
1140 + BATADV_PARAMETER_PROBLEM = 12,
1145 + * enum batadv_mcast_flags - flags for multicast capabilities and settings
1146 + * @BATADV_MCAST_WANT_ALL_UNSNOOPABLES: we want all packets destined for
1147 + * 224.0.0.0/24 or ff02::1
1148 + * @BATADV_MCAST_WANT_ALL_IPV4: we want all IPv4 multicast packets
1149 + * @BATADV_MCAST_WANT_ALL_IPV6: we want all IPv6 multicast packets
1151 +enum batadv_mcast_flags {
1152 + BATADV_MCAST_WANT_ALL_UNSNOOPABLES = 1UL << 0,
1153 + BATADV_MCAST_WANT_ALL_IPV4 = 1UL << 1,
1154 + BATADV_MCAST_WANT_ALL_IPV6 = 1UL << 2,
1157 +/* tt data subtypes */
1158 +#define BATADV_TT_DATA_TYPE_MASK 0x0F
1161 + * enum batadv_tt_data_flags - flags for tt data tvlv
1162 + * @BATADV_TT_OGM_DIFF: TT diff propagated through OGM
1163 + * @BATADV_TT_REQUEST: TT request message
1164 + * @BATADV_TT_RESPONSE: TT response message
1165 + * @BATADV_TT_FULL_TABLE: contains full table to replace existing table
1167 +enum batadv_tt_data_flags {
1168 + BATADV_TT_OGM_DIFF = 1UL << 0,
1169 + BATADV_TT_REQUEST = 1UL << 1,
1170 + BATADV_TT_RESPONSE = 1UL << 2,
1171 + BATADV_TT_FULL_TABLE = 1UL << 4,
1175 + * enum batadv_vlan_flags - flags for the four MSB of any vlan ID field
1176 + * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not
1178 +enum batadv_vlan_flags {
1179 + BATADV_VLAN_HAS_TAG = 1UL << 15,
1182 +/* claim frame types for the bridge loop avoidance */
1183 +enum batadv_bla_claimframe {
1184 + BATADV_CLAIM_TYPE_CLAIM = 0x00,
1185 + BATADV_CLAIM_TYPE_UNCLAIM = 0x01,
1186 + BATADV_CLAIM_TYPE_ANNOUNCE = 0x02,
1187 + BATADV_CLAIM_TYPE_REQUEST = 0x03,
1188 + BATADV_CLAIM_TYPE_LOOPDETECT = 0x04,
1192 + * enum batadv_tvlv_type - tvlv type definitions
1193 + * @BATADV_TVLV_GW: gateway tvlv
1194 + * @BATADV_TVLV_DAT: distributed arp table tvlv
1195 + * @BATADV_TVLV_NC: network coding tvlv
1196 + * @BATADV_TVLV_TT: translation table tvlv
1197 + * @BATADV_TVLV_ROAM: roaming advertisement tvlv
1198 + * @BATADV_TVLV_MCAST: multicast capability tvlv
1200 +enum batadv_tvlv_type {
1201 + BATADV_TVLV_GW = 0x01,
1202 + BATADV_TVLV_DAT = 0x02,
1203 + BATADV_TVLV_NC = 0x03,
1204 + BATADV_TVLV_TT = 0x04,
1205 + BATADV_TVLV_ROAM = 0x05,
1206 + BATADV_TVLV_MCAST = 0x06,
1210 +/* the destination hardware field in the ARP frame is used to
1211 + * transport the claim type and the group id
1213 +struct batadv_bla_claim_dst {
1214 + __u8 magic[3]; /* FF:43:05 */
1215 + __u8 type; /* bla_claimframe */
1216 + __be16 group; /* group id */
1222 + * struct batadv_ogm_packet - ogm (routing protocol) packet
1223 + * @packet_type: batman-adv packet type, part of the general header
1224 + * @version: batman-adv protocol version, part of the genereal header
1225 + * @ttl: time to live for this packet, part of the genereal header
1226 + * @flags: contains routing relevant flags - see enum batadv_iv_flags
1227 + * @seqno: sequence identification
1228 + * @orig: address of the source node
1229 + * @prev_sender: address of the previous sender
1230 + * @reserved: reserved byte for alignment
1231 + * @tq: transmission quality
1232 + * @tvlv_len: length of tvlv data following the ogm header
1234 +struct batadv_ogm_packet {
1240 + __u8 orig[ETH_ALEN];
1241 + __u8 prev_sender[ETH_ALEN];
1245 + /* __packed is not needed as the struct size is divisible by 4,
1246 + * and the largest data type in this struct has a size of 4.
1250 +#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
1253 + * struct batadv_ogm2_packet - ogm2 (routing protocol) packet
1254 + * @packet_type: batman-adv packet type, part of the general header
1255 + * @version: batman-adv protocol version, part of the general header
1256 + * @ttl: time to live for this packet, part of the general header
1257 + * @flags: reseved for routing relevant flags - currently always 0
1258 + * @seqno: sequence number
1259 + * @orig: originator mac address
1260 + * @tvlv_len: length of the appended tvlv buffer (in bytes)
1261 + * @throughput: the currently flooded path throughput
1263 +struct batadv_ogm2_packet {
1269 + __u8 orig[ETH_ALEN];
1271 + __be32 throughput;
1272 + /* __packed is not needed as the struct size is divisible by 4,
1273 + * and the largest data type in this struct has a size of 4.
1277 +#define BATADV_OGM2_HLEN sizeof(struct batadv_ogm2_packet)
1280 + * struct batadv_elp_packet - elp (neighbor discovery) packet
1281 + * @packet_type: batman-adv packet type, part of the general header
1282 + * @version: batman-adv protocol version, part of the genereal header
1283 + * @orig: originator mac address
1284 + * @seqno: sequence number
1285 + * @elp_interval: currently used ELP sending interval in ms
1287 +struct batadv_elp_packet {
1290 + __u8 orig[ETH_ALEN];
1292 + __be32 elp_interval;
1295 +#define BATADV_ELP_HLEN sizeof(struct batadv_elp_packet)
1298 + * struct batadv_icmp_header - common members among all the ICMP packets
1299 + * @packet_type: batman-adv packet type, part of the general header
1300 + * @version: batman-adv protocol version, part of the genereal header
1301 + * @ttl: time to live for this packet, part of the genereal header
1302 + * @msg_type: ICMP packet type
1303 + * @dst: address of the destination node
1304 + * @orig: address of the source node
1305 + * @uid: local ICMP socket identifier
1306 + * @align: not used - useful for alignment purposes only
1308 + * This structure is used for ICMP packets parsing only and it is never sent
1309 + * over the wire. The alignment field at the end is there to ensure that
1310 + * members are padded the same way as they are in real packets.
1312 +struct batadv_icmp_header {
1316 + __u8 msg_type; /* see ICMP message types above */
1317 + __u8 dst[ETH_ALEN];
1318 + __u8 orig[ETH_ALEN];
1324 + * struct batadv_icmp_packet - ICMP packet
1325 + * @packet_type: batman-adv packet type, part of the general header
1326 + * @version: batman-adv protocol version, part of the genereal header
1327 + * @ttl: time to live for this packet, part of the genereal header
1328 + * @msg_type: ICMP packet type
1329 + * @dst: address of the destination node
1330 + * @orig: address of the source node
1331 + * @uid: local ICMP socket identifier
1332 + * @reserved: not used - useful for alignment
1333 + * @seqno: ICMP sequence number
1335 +struct batadv_icmp_packet {
1339 + __u8 msg_type; /* see ICMP message types above */
1340 + __u8 dst[ETH_ALEN];
1341 + __u8 orig[ETH_ALEN];
1348 + * struct batadv_icmp_tp_packet - ICMP TP Meter packet
1349 + * @packet_type: batman-adv packet type, part of the general header
1350 + * @version: batman-adv protocol version, part of the genereal header
1351 + * @ttl: time to live for this packet, part of the genereal header
1352 + * @msg_type: ICMP packet type
1353 + * @dst: address of the destination node
1354 + * @orig: address of the source node
1355 + * @uid: local ICMP socket identifier
1356 + * @subtype: TP packet subtype (see batadv_icmp_tp_subtype)
1357 + * @session: TP session identifier
1358 + * @seqno: the TP sequence number
1359 + * @timestamp: time when the packet has been sent. This value is filled in a
1360 + * TP_MSG and echoed back in the next TP_ACK so that the sender can compute the
1361 + * RTT. Since it is read only by the host which wrote it, there is no need to
1362 + * store it using network order
1364 +struct batadv_icmp_tp_packet {
1368 + __u8 msg_type; /* see ICMP message types above */
1369 + __u8 dst[ETH_ALEN];
1370 + __u8 orig[ETH_ALEN];
1379 + * enum batadv_icmp_tp_subtype - ICMP TP Meter packet subtypes
1380 + * @BATADV_TP_MSG: Msg from sender to receiver
1381 + * @BATADV_TP_ACK: acknowledgment from receiver to sender
1383 +enum batadv_icmp_tp_subtype {
1384 + BATADV_TP_MSG = 0,
1388 +#define BATADV_RR_LEN 16
1391 + * struct batadv_icmp_packet_rr - ICMP RouteRecord packet
1392 + * @packet_type: batman-adv packet type, part of the general header
1393 + * @version: batman-adv protocol version, part of the genereal header
1394 + * @ttl: time to live for this packet, part of the genereal header
1395 + * @msg_type: ICMP packet type
1396 + * @dst: address of the destination node
1397 + * @orig: address of the source node
1398 + * @uid: local ICMP socket identifier
1399 + * @rr_cur: number of entries the rr array
1400 + * @seqno: ICMP sequence number
1401 + * @rr: route record array
1403 +struct batadv_icmp_packet_rr {
1407 + __u8 msg_type; /* see ICMP message types above */
1408 + __u8 dst[ETH_ALEN];
1409 + __u8 orig[ETH_ALEN];
1413 + __u8 rr[BATADV_RR_LEN][ETH_ALEN];
1416 +#define BATADV_ICMP_MAX_PACKET_SIZE sizeof(struct batadv_icmp_packet_rr)
1418 +/* All packet headers in front of an ethernet header have to be completely
1419 + * divisible by 2 but not by 4 to make the payload after the ethernet
1420 + * header again 4 bytes boundary aligned.
1422 + * A packing of 2 is necessary to avoid extra padding at the end of the struct
1423 + * caused by a structure member which is larger than two bytes. Otherwise
1424 + * the structure would not fulfill the previously mentioned rule to avoid the
1425 + * misalignment of the payload after the ethernet header. It may also lead to
1426 + * leakage of information when the padding it not initialized before sending.
1431 + * struct batadv_unicast_packet - unicast packet for network payload
1432 + * @packet_type: batman-adv packet type, part of the general header
1433 + * @version: batman-adv protocol version, part of the genereal header
1434 + * @ttl: time to live for this packet, part of the genereal header
1435 + * @ttvn: translation table version number
1436 + * @dest: originator destination of the unicast packet
1438 +struct batadv_unicast_packet {
1442 + __u8 ttvn; /* destination translation table version number */
1443 + __u8 dest[ETH_ALEN];
1444 + /* "4 bytes boundary + 2 bytes" long to make the payload after the
1445 + * following ethernet header again 4 bytes boundary aligned
1450 + * struct batadv_unicast_4addr_packet - extended unicast packet
1451 + * @u: common unicast packet header
1452 + * @src: address of the source
1453 + * @subtype: packet subtype
1454 + * @reserved: reserved byte for alignment
1456 +struct batadv_unicast_4addr_packet {
1457 + struct batadv_unicast_packet u;
1458 + __u8 src[ETH_ALEN];
1461 + /* "4 bytes boundary + 2 bytes" long to make the payload after the
1462 + * following ethernet header again 4 bytes boundary aligned
1467 + * struct batadv_frag_packet - fragmented packet
1468 + * @packet_type: batman-adv packet type, part of the general header
1469 + * @version: batman-adv protocol version, part of the genereal header
1470 + * @ttl: time to live for this packet, part of the genereal header
1471 + * @dest: final destination used when routing fragments
1472 + * @orig: originator of the fragment used when merging the packet
1473 + * @no: fragment number within this sequence
1474 + * @priority: priority of frame, from ToS IP precedence or 802.1p
1475 + * @reserved: reserved byte for alignment
1476 + * @seqno: sequence identification
1477 + * @total_size: size of the merged packet
1479 +struct batadv_frag_packet {
1481 + __u8 version; /* batman version field */
1483 +#if defined(__BIG_ENDIAN_BITFIELD)
1487 +#elif defined(__LITTLE_ENDIAN_BITFIELD)
1492 +#error "unknown bitfield endianness"
1494 + __u8 dest[ETH_ALEN];
1495 + __u8 orig[ETH_ALEN];
1497 + __be16 total_size;
1501 + * struct batadv_bcast_packet - broadcast packet for network payload
1502 + * @packet_type: batman-adv packet type, part of the general header
1503 + * @version: batman-adv protocol version, part of the genereal header
1504 + * @ttl: time to live for this packet, part of the genereal header
1505 + * @reserved: reserved byte for alignment
1506 + * @seqno: sequence identification
1507 + * @orig: originator of the broadcast packet
1509 +struct batadv_bcast_packet {
1511 + __u8 version; /* batman version field */
1515 + __u8 orig[ETH_ALEN];
1516 + /* "4 bytes boundary + 2 bytes" long to make the payload after the
1517 + * following ethernet header again 4 bytes boundary aligned
1522 + * struct batadv_coded_packet - network coded packet
1523 + * @packet_type: batman-adv packet type, part of the general header
1524 + * @version: batman-adv protocol version, part of the genereal header
1525 + * @ttl: time to live for this packet, part of the genereal header
1526 + * @first_source: original source of first included packet
1527 + * @first_orig_dest: original destinal of first included packet
1528 + * @first_crc: checksum of first included packet
1529 + * @first_ttvn: tt-version number of first included packet
1530 + * @second_ttl: ttl of second packet
1531 + * @second_dest: second receiver of this coded packet
1532 + * @second_source: original source of second included packet
1533 + * @second_orig_dest: original destination of second included packet
1534 + * @second_crc: checksum of second included packet
1535 + * @second_ttvn: tt version number of second included packet
1536 + * @coded_len: length of network coded part of the payload
1538 +struct batadv_coded_packet {
1540 + __u8 version; /* batman version field */
1543 + /* __u8 first_dest[ETH_ALEN]; - saved in mac header destination */
1544 + __u8 first_source[ETH_ALEN];
1545 + __u8 first_orig_dest[ETH_ALEN];
1549 + __u8 second_dest[ETH_ALEN];
1550 + __u8 second_source[ETH_ALEN];
1551 + __u8 second_orig_dest[ETH_ALEN];
1552 + __be32 second_crc;
1559 + * struct batadv_unicast_tvlv_packet - generic unicast packet with tvlv payload
1560 + * @packet_type: batman-adv packet type, part of the general header
1561 + * @version: batman-adv protocol version, part of the genereal header
1562 + * @ttl: time to live for this packet, part of the genereal header
1563 + * @reserved: reserved field (for packet alignment)
1564 + * @src: address of the source
1565 + * @dst: address of the destination
1566 + * @tvlv_len: length of tvlv data following the unicast tvlv header
1567 + * @align: 2 bytes to align the header to a 4 byte boundary
1569 +struct batadv_unicast_tvlv_packet {
1571 + __u8 version; /* batman version field */
1574 + __u8 dst[ETH_ALEN];
1575 + __u8 src[ETH_ALEN];
1581 + * struct batadv_tvlv_hdr - base tvlv header struct
1582 + * @type: tvlv container type (see batadv_tvlv_type)
1583 + * @version: tvlv container version
1584 + * @len: tvlv container length
1586 +struct batadv_tvlv_hdr {
1593 + * struct batadv_tvlv_gateway_data - gateway data propagated through gw tvlv
1595 + * @bandwidth_down: advertised uplink download bandwidth
1596 + * @bandwidth_up: advertised uplink upload bandwidth
1598 +struct batadv_tvlv_gateway_data {
1599 + __be32 bandwidth_down;
1600 + __be32 bandwidth_up;
1604 + * struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container
1605 + * @flags: translation table flags (see batadv_tt_data_flags)
1606 + * @ttvn: translation table version number
1607 + * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by
1608 + * one batadv_tvlv_tt_vlan_data object per announced vlan
1610 +struct batadv_tvlv_tt_data {
1617 + * struct batadv_tvlv_tt_vlan_data - vlan specific tt data propagated through
1618 + * the tt tvlv container
1619 + * @crc: crc32 checksum of the entries belonging to this vlan
1620 + * @vid: vlan identifier
1621 + * @reserved: unused, useful for alignment purposes
1623 +struct batadv_tvlv_tt_vlan_data {
1630 + * struct batadv_tvlv_tt_change - translation table diff data
1631 + * @flags: status indicators concerning the non-mesh client (see
1632 + * batadv_tt_client_flags)
1633 + * @reserved: reserved field - useful for alignment purposes only
1634 + * @addr: mac address of non-mesh client that triggered this tt change
1635 + * @vid: VLAN identifier
1637 +struct batadv_tvlv_tt_change {
1640 + __u8 addr[ETH_ALEN];
1645 + * struct batadv_tvlv_roam_adv - roaming advertisement
1646 + * @client: mac address of roaming client
1647 + * @vid: VLAN identifier
1649 +struct batadv_tvlv_roam_adv {
1650 + __u8 client[ETH_ALEN];
1655 + * struct batadv_tvlv_mcast_data - payload of a multicast tvlv
1656 + * @flags: multicast flags announced by the orig node
1657 + * @reserved: reserved field
1659 +struct batadv_tvlv_mcast_data {
1664 +#endif /* _UAPI_LINUX_BATADV_PACKET_H_ */