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