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