Commit | Line | Data |
---|---|---|
fec149f5 | 1 | /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) */ |
cfa55c6d | 2 | /* Copyright (C) B.A.T.M.A.N. contributors: |
c6c8fea2 SE |
3 | * |
4 | * Marek Lindner, Simon Wunderlich | |
c6c8fea2 SE |
5 | */ |
6 | ||
fec149f5 SE |
7 | #ifndef _UAPI_LINUX_BATADV_PACKET_H_ |
8 | #define _UAPI_LINUX_BATADV_PACKET_H_ | |
c6c8fea2 | 9 | |
1e2c2a4f | 10 | #include <asm/byteorder.h> |
4e58452b | 11 | #include <linux/if_ether.h> |
1e2c2a4f SE |
12 | #include <linux/types.h> |
13 | ||
6a3038f0 SE |
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 | */ | |
adbf9b73 | 20 | #define batadv_tp_is_error(n) ((__u8)(n) > 127 ? 1 : 0) |
33a3bb4a | 21 | |
ef261577 ML |
22 | /** |
23 | * enum batadv_packettype - types for batman-adv encapsulated packets | |
a1f1ac5c SW |
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 | |
d6f94d91 | 27 | * @BATADV_ELP: echo location packets for B.A.T.M.A.N. V |
0da00359 | 28 | * @BATADV_OGM2: originator messages for B.A.T.M.A.N. V |
a1f1ac5c SW |
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 | |
ef261577 ML |
36 | * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers |
37 | */ | |
acd34afa | 38 | enum batadv_packettype { |
a1f1ac5c SW |
39 | /* 0x00 - 0x3f: local packets or special rules for handling */ |
40 | BATADV_IV_OGM = 0x00, | |
41 | BATADV_BCAST = 0x01, | |
42 | BATADV_CODED = 0x02, | |
d6f94d91 | 43 | BATADV_ELP = 0x03, |
0da00359 | 44 | BATADV_OGM2 = 0x04, |
a1f1ac5c SW |
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 */ | |
7cdcf6dd AQ |
54 | }; |
55 | ||
56 | /** | |
57 | * enum batadv_subtype - packet subtype for unicast4addr | |
58 | * @BATADV_P_DATA: user payload | |
5c3a0e55 AQ |
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 | |
7cdcf6dd AQ |
62 | */ |
63 | enum batadv_subtype { | |
5c3a0e55 AQ |
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, | |
e8958dbf | 68 | }; |
c6c8fea2 SE |
69 | |
70 | /* this file is included by batctl which needs these defines */ | |
60cf7981 | 71 | #define BATADV_COMPAT_VERSION 15 |
e8958dbf | 72 | |
18c68d59 SW |
73 | /** |
74 | * enum batadv_iv_flags - flags used in B.A.T.M.A.N. IV OGM packets | |
bccb48c8 SE |
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. | |
143d157c | 77 | * @BATADV_PRIMARIES_FIRST_HOP: flag unused. |
18c68d59 SW |
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 | */ | |
acd34afa | 81 | enum batadv_iv_flags { |
a6cb82b5 SE |
82 | BATADV_NOT_BEST_NEXT_HOP = 1UL << 0, |
83 | BATADV_PRIMARIES_FIRST_HOP = 1UL << 1, | |
84 | BATADV_DIRECTLINK = 1UL << 2, | |
e8958dbf | 85 | }; |
c6c8fea2 | 86 | |
6a3038f0 SE |
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 | */ | |
acd34afa SE |
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, | |
33a3bb4a | 102 | BATADV_TP = 15, |
e8958dbf | 103 | }; |
c6c8fea2 | 104 | |
ab49886e LL |
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 | |
4c8755d6 | 109 | * @BATADV_MCAST_WANT_ALL_IPV4: we want all IPv4 multicast packets |
61caf3d1 | 110 | * (both link-local and routable ones) |
4c8755d6 | 111 | * @BATADV_MCAST_WANT_ALL_IPV6: we want all IPv6 multicast packets |
61caf3d1 LL |
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 | |
ab49886e LL |
117 | */ |
118 | enum batadv_mcast_flags { | |
a6cb82b5 SE |
119 | BATADV_MCAST_WANT_ALL_UNSNOOPABLES = 1UL << 0, |
120 | BATADV_MCAST_WANT_ALL_IPV4 = 1UL << 1, | |
121 | BATADV_MCAST_WANT_ALL_IPV6 = 1UL << 2, | |
61caf3d1 LL |
122 | BATADV_MCAST_WANT_NO_RTR4 = 1UL << 3, |
123 | BATADV_MCAST_WANT_NO_RTR6 = 1UL << 4, | |
ab49886e LL |
124 | }; |
125 | ||
e1bf0c14 ML |
126 | /* tt data subtypes */ |
127 | #define BATADV_TT_DATA_TYPE_MASK 0x0F | |
a73105b8 | 128 | |
e1bf0c14 ML |
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 { | |
a6cb82b5 SE |
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, | |
a73105b8 AQ |
141 | }; |
142 | ||
c018ad3d | 143 | /** |
6f68b002 | 144 | * enum batadv_vlan_flags - flags for the four MSB of any vlan ID field |
c018ad3d AQ |
145 | * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not |
146 | */ | |
147 | enum batadv_vlan_flags { | |
a6cb82b5 | 148 | BATADV_VLAN_HAS_TAG = 1UL << 15, |
c018ad3d AQ |
149 | }; |
150 | ||
6a3038f0 SE |
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 | */ | |
acd34afa | 159 | enum batadv_bla_claimframe { |
3eb8773e SW |
160 | BATADV_CLAIM_TYPE_CLAIM = 0x00, |
161 | BATADV_CLAIM_TYPE_UNCLAIM = 0x01, | |
acd34afa SE |
162 | BATADV_CLAIM_TYPE_ANNOUNCE = 0x02, |
163 | BATADV_CLAIM_TYPE_REQUEST = 0x03, | |
cd9c7bfb | 164 | BATADV_CLAIM_TYPE_LOOPDETECT = 0x04, |
23721387 SW |
165 | }; |
166 | ||
414254e3 ML |
167 | /** |
168 | * enum batadv_tvlv_type - tvlv type definitions | |
169 | * @BATADV_TVLV_GW: gateway tvlv | |
17cf0ea4 | 170 | * @BATADV_TVLV_DAT: distributed arp table tvlv |
3f4841ff | 171 | * @BATADV_TVLV_NC: network coding tvlv |
e1bf0c14 | 172 | * @BATADV_TVLV_TT: translation table tvlv |
122edaa0 | 173 | * @BATADV_TVLV_ROAM: roaming advertisement tvlv |
60432d75 | 174 | * @BATADV_TVLV_MCAST: multicast capability tvlv |
414254e3 ML |
175 | */ |
176 | enum batadv_tvlv_type { | |
177 | BATADV_TVLV_GW = 0x01, | |
17cf0ea4 | 178 | BATADV_TVLV_DAT = 0x02, |
3f4841ff | 179 | BATADV_TVLV_NC = 0x03, |
e1bf0c14 | 180 | BATADV_TVLV_TT = 0x04, |
122edaa0 | 181 | BATADV_TVLV_ROAM = 0x05, |
60432d75 | 182 | BATADV_TVLV_MCAST = 0x06, |
414254e3 ML |
183 | }; |
184 | ||
2f7a3182 | 185 | #pragma pack(2) |
23721387 SW |
186 | /* the destination hardware field in the ARP frame is used to |
187 | * transport the claim type and the group id | |
188 | */ | |
96412690 | 189 | struct batadv_bla_claim_dst { |
adbf9b73 SE |
190 | __u8 magic[3]; /* FF:43:05 */ |
191 | __u8 type; /* bla_claimframe */ | |
3e2f1a1b | 192 | __be16 group; /* group id */ |
f6c57a46 | 193 | }; |
aa143d28 | 194 | |
ef261577 ML |
195 | /** |
196 | * struct batadv_ogm_packet - ogm (routing protocol) packet | |
a40d9b07 | 197 | * @packet_type: batman-adv packet type, part of the general header |
bccb48c8 SE |
198 | * @version: batman-adv protocol version, part of the general header |
199 | * @ttl: time to live for this packet, part of the general header | |
18c68d59 | 200 | * @flags: contains routing relevant flags - see enum batadv_iv_flags |
7afcbbef SE |
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 | |
ef261577 ML |
206 | * @tvlv_len: length of tvlv data following the ogm header |
207 | */ | |
96412690 | 208 | struct batadv_ogm_packet { |
adbf9b73 SE |
209 | __u8 packet_type; |
210 | __u8 version; | |
211 | __u8 ttl; | |
212 | __u8 flags; | |
6b5e971a | 213 | __be32 seqno; |
adbf9b73 SE |
214 | __u8 orig[ETH_ALEN]; |
215 | __u8 prev_sender[ETH_ALEN]; | |
216 | __u8 reserved; | |
217 | __u8 tq; | |
6b5e971a | 218 | __be16 tvlv_len; |
9284a47e | 219 | }; |
c6c8fea2 | 220 | |
96412690 | 221 | #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet) |
c6c8fea2 | 222 | |
0da00359 AQ |
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 | |
180cf62c | 228 | * @flags: reserved for routing relevant flags - currently always 0 |
0da00359 AQ |
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 { | |
adbf9b73 SE |
235 | __u8 packet_type; |
236 | __u8 version; | |
237 | __u8 ttl; | |
238 | __u8 flags; | |
0da00359 | 239 | __be32 seqno; |
adbf9b73 | 240 | __u8 orig[ETH_ALEN]; |
0da00359 AQ |
241 | __be16 tvlv_len; |
242 | __be32 throughput; | |
0da00359 AQ |
243 | }; |
244 | ||
245 | #define BATADV_OGM2_HLEN sizeof(struct batadv_ogm2_packet) | |
246 | ||
d6f94d91 LL |
247 | /** |
248 | * struct batadv_elp_packet - elp (neighbor discovery) packet | |
249 | * @packet_type: batman-adv packet type, part of the general header | |
bccb48c8 | 250 | * @version: batman-adv protocol version, part of the general header |
d6f94d91 LL |
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 { | |
adbf9b73 SE |
256 | __u8 packet_type; |
257 | __u8 version; | |
258 | __u8 orig[ETH_ALEN]; | |
d6f94d91 LL |
259 | __be32 seqno; |
260 | __be32 elp_interval; | |
261 | }; | |
262 | ||
263 | #define BATADV_ELP_HLEN sizeof(struct batadv_elp_packet) | |
264 | ||
0bf84c16 | 265 | /** |
6f68b002 | 266 | * struct batadv_icmp_header - common members among all the ICMP packets |
a40d9b07 | 267 | * @packet_type: batman-adv packet type, part of the general header |
bccb48c8 SE |
268 | * @version: batman-adv protocol version, part of the general header |
269 | * @ttl: time to live for this packet, part of the general header | |
0bf84c16 AQ |
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 | |
27a417e6 AQ |
274 | * @align: not used - useful for alignment purposes only |
275 | * | |
bccb48c8 | 276 | * This structure is used for ICMP packet parsing only and it is never sent |
27a417e6 AQ |
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. | |
0bf84c16 AQ |
279 | */ |
280 | struct batadv_icmp_header { | |
adbf9b73 SE |
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]; | |
0bf84c16 AQ |
289 | }; |
290 | ||
291 | /** | |
6f68b002 | 292 | * struct batadv_icmp_packet - ICMP packet |
27a417e6 | 293 | * @packet_type: batman-adv packet type, part of the general header |
bccb48c8 SE |
294 | * @version: batman-adv protocol version, part of the general header |
295 | * @ttl: time to live for this packet, part of the general header | |
27a417e6 AQ |
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 | |
0bf84c16 AQ |
300 | * @reserved: not used - useful for alignment |
301 | * @seqno: ICMP sequence number | |
302 | */ | |
303 | struct batadv_icmp_packet { | |
adbf9b73 SE |
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; | |
6b5e971a | 312 | __be16 seqno; |
f6c57a46 | 313 | }; |
c6c8fea2 | 314 | |
33a3bb4a AQ |
315 | /** |
316 | * struct batadv_icmp_tp_packet - ICMP TP Meter packet | |
317 | * @packet_type: batman-adv packet type, part of the general header | |
bccb48c8 SE |
318 | * @version: batman-adv protocol version, part of the general header |
319 | * @ttl: time to live for this packet, part of the general header | |
33a3bb4a AQ |
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 { | |
adbf9b73 SE |
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]; | |
33a3bb4a AQ |
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 | ||
7e071c79 | 356 | #define BATADV_RR_LEN 16 |
c6c8fea2 | 357 | |
0bf84c16 | 358 | /** |
6f68b002 | 359 | * struct batadv_icmp_packet_rr - ICMP RouteRecord packet |
27a417e6 | 360 | * @packet_type: batman-adv packet type, part of the general header |
bccb48c8 SE |
361 | * @version: batman-adv protocol version, part of the general header |
362 | * @ttl: time to live for this packet, part of the general header | |
27a417e6 AQ |
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 | |
0bf84c16 AQ |
367 | * @rr_cur: number of entries the rr array |
368 | * @seqno: ICMP sequence number | |
369 | * @rr: route record array | |
9cfc7bd6 | 370 | */ |
96412690 | 371 | struct batadv_icmp_packet_rr { |
adbf9b73 SE |
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; | |
6b5e971a | 380 | __be16 seqno; |
adbf9b73 | 381 | __u8 rr[BATADV_RR_LEN][ETH_ALEN]; |
f6c57a46 | 382 | }; |
c6c8fea2 | 383 | |
da6b8c20 SW |
384 | #define BATADV_ICMP_MAX_PACKET_SIZE sizeof(struct batadv_icmp_packet_rr) |
385 | ||
e022b956 SE |
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 | */ | |
e022b956 | 396 | |
a40d9b07 SW |
397 | /** |
398 | * struct batadv_unicast_packet - unicast packet for network payload | |
399 | * @packet_type: batman-adv packet type, part of the general header | |
bccb48c8 SE |
400 | * @version: batman-adv protocol version, part of the general header |
401 | * @ttl: time to live for this packet, part of the general header | |
a40d9b07 SW |
402 | * @ttvn: translation table version number |
403 | * @dest: originator destination of the unicast packet | |
404 | */ | |
96412690 | 405 | struct batadv_unicast_packet { |
adbf9b73 SE |
406 | __u8 packet_type; |
407 | __u8 version; | |
408 | __u8 ttl; | |
409 | __u8 ttvn; /* destination translation table version number */ | |
410 | __u8 dest[ETH_ALEN]; | |
f6c57a46 SE |
411 | /* "4 bytes boundary + 2 bytes" long to make the payload after the |
412 | * following ethernet header again 4 bytes boundary aligned | |
413 | */ | |
414 | }; | |
c6c8fea2 | 415 | |
7cdcf6dd AQ |
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 | |
7afcbbef | 421 | * @reserved: reserved byte for alignment |
7cdcf6dd AQ |
422 | */ |
423 | struct batadv_unicast_4addr_packet { | |
424 | struct batadv_unicast_packet u; | |
adbf9b73 SE |
425 | __u8 src[ETH_ALEN]; |
426 | __u8 subtype; | |
427 | __u8 reserved; | |
7cdcf6dd AQ |
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 | ||
610bfc6b MH |
433 | /** |
434 | * struct batadv_frag_packet - fragmented packet | |
a40d9b07 | 435 | * @packet_type: batman-adv packet type, part of the general header |
bccb48c8 SE |
436 | * @version: batman-adv protocol version, part of the general header |
437 | * @ttl: time to live for this packet, part of the general header | |
610bfc6b MH |
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 | |
c0f25c80 | 441 | * @priority: priority of frame, from ToS IP precedence or 802.1p |
610bfc6b MH |
442 | * @reserved: reserved byte for alignment |
443 | * @seqno: sequence identification | |
444 | * @total_size: size of the merged packet | |
445 | */ | |
446 | struct batadv_frag_packet { | |
adbf9b73 SE |
447 | __u8 packet_type; |
448 | __u8 version; /* batman version field */ | |
449 | __u8 ttl; | |
610bfc6b | 450 | #if defined(__BIG_ENDIAN_BITFIELD) |
adbf9b73 SE |
451 | __u8 no:4; |
452 | __u8 priority:3; | |
453 | __u8 reserved:1; | |
610bfc6b | 454 | #elif defined(__LITTLE_ENDIAN_BITFIELD) |
adbf9b73 SE |
455 | __u8 reserved:1; |
456 | __u8 priority:3; | |
457 | __u8 no:4; | |
610bfc6b | 458 | #else |
3f68785e | 459 | #error "unknown bitfield endianness" |
610bfc6b | 460 | #endif |
adbf9b73 SE |
461 | __u8 dest[ETH_ALEN]; |
462 | __u8 orig[ETH_ALEN]; | |
6b5e971a SE |
463 | __be16 seqno; |
464 | __be16 total_size; | |
610bfc6b MH |
465 | }; |
466 | ||
a40d9b07 SW |
467 | /** |
468 | * struct batadv_bcast_packet - broadcast packet for network payload | |
469 | * @packet_type: batman-adv packet type, part of the general header | |
bccb48c8 SE |
470 | * @version: batman-adv protocol version, part of the general header |
471 | * @ttl: time to live for this packet, part of the general header | |
a40d9b07 SW |
472 | * @reserved: reserved byte for alignment |
473 | * @seqno: sequence identification | |
474 | * @orig: originator of the broadcast packet | |
475 | */ | |
96412690 | 476 | struct batadv_bcast_packet { |
adbf9b73 SE |
477 | __u8 packet_type; |
478 | __u8 version; /* batman version field */ | |
479 | __u8 ttl; | |
480 | __u8 reserved; | |
6b5e971a | 481 | __be32 seqno; |
adbf9b73 | 482 | __u8 orig[ETH_ALEN]; |
f6c57a46 SE |
483 | /* "4 bytes boundary + 2 bytes" long to make the payload after the |
484 | * following ethernet header again 4 bytes boundary aligned | |
485 | */ | |
e022b956 SE |
486 | }; |
487 | ||
3c12de9a MH |
488 | /** |
489 | * struct batadv_coded_packet - network coded packet | |
a40d9b07 | 490 | * @packet_type: batman-adv packet type, part of the general header |
bccb48c8 SE |
491 | * @version: batman-adv protocol version, part of the general header |
492 | * @ttl: time to live for this packet, part of the general header | |
3c12de9a | 493 | * @first_source: original source of first included packet |
bccb48c8 | 494 | * @first_orig_dest: original destination of first included packet |
3c12de9a MH |
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 { | |
adbf9b73 SE |
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]; | |
6b5e971a | 513 | __be32 first_crc; |
adbf9b73 SE |
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]; | |
6b5e971a SE |
519 | __be32 second_crc; |
520 | __be16 coded_len; | |
3c12de9a MH |
521 | }; |
522 | ||
ef261577 | 523 | /** |
6d030de8 | 524 | * struct batadv_unicast_tvlv_packet - generic unicast packet with tvlv payload |
a40d9b07 | 525 | * @packet_type: batman-adv packet type, part of the general header |
bccb48c8 SE |
526 | * @version: batman-adv protocol version, part of the general header |
527 | * @ttl: time to live for this packet, part of the general header | |
ef261577 ML |
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 | |
3f68785e | 532 | * @align: 2 bytes to align the header to a 4 byte boundary |
ef261577 ML |
533 | */ |
534 | struct batadv_unicast_tvlv_packet { | |
adbf9b73 SE |
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]; | |
6b5e971a | 541 | __be16 tvlv_len; |
adbf9b73 | 542 | __u16 align; |
ef261577 ML |
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 { | |
adbf9b73 SE |
552 | __u8 type; |
553 | __u8 version; | |
6b5e971a | 554 | __be16 len; |
ef261577 ML |
555 | }; |
556 | ||
414254e3 ML |
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 | ||
e1bf0c14 ML |
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 | |
e51f0397 | 572 | * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by |
7ea7b4a1 | 573 | * one batadv_tvlv_tt_vlan_data object per announced vlan |
e1bf0c14 ML |
574 | */ |
575 | struct batadv_tvlv_tt_data { | |
adbf9b73 SE |
576 | __u8 flags; |
577 | __u8 ttvn; | |
6b5e971a | 578 | __be16 num_vlan; |
7ea7b4a1 AQ |
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 { | |
6b5e971a SE |
589 | __be32 crc; |
590 | __be16 vid; | |
adbf9b73 | 591 | __u16 reserved; |
e1bf0c14 ML |
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) | |
ca663046 | 598 | * @reserved: reserved field - useful for alignment purposes only |
e1bf0c14 | 599 | * @addr: mac address of non-mesh client that triggered this tt change |
c018ad3d | 600 | * @vid: VLAN identifier |
e1bf0c14 ML |
601 | */ |
602 | struct batadv_tvlv_tt_change { | |
adbf9b73 SE |
603 | __u8 flags; |
604 | __u8 reserved[3]; | |
605 | __u8 addr[ETH_ALEN]; | |
c018ad3d | 606 | __be16 vid; |
e1bf0c14 ML |
607 | }; |
608 | ||
122edaa0 ML |
609 | /** |
610 | * struct batadv_tvlv_roam_adv - roaming advertisement | |
611 | * @client: mac address of roaming client | |
c018ad3d | 612 | * @vid: VLAN identifier |
122edaa0 ML |
613 | */ |
614 | struct batadv_tvlv_roam_adv { | |
adbf9b73 | 615 | __u8 client[ETH_ALEN]; |
c018ad3d | 616 | __be16 vid; |
122edaa0 ML |
617 | }; |
618 | ||
60432d75 LL |
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 { | |
adbf9b73 SE |
625 | __u8 flags; |
626 | __u8 reserved[3]; | |
60432d75 LL |
627 | }; |
628 | ||
a163dc22 MS |
629 | #pragma pack() |
630 | ||
fec149f5 | 631 | #endif /* _UAPI_LINUX_BATADV_PACKET_H_ */ |