diff options
Diffstat (limited to 'net/batman-adv/packet.h')
-rw-r--r-- | net/batman-adv/packet.h | 124 |
1 files changed, 94 insertions, 30 deletions
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index 207459b62966..2dd8f2422550 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h | |||
@@ -155,6 +155,7 @@ enum batadv_tvlv_type { | |||
155 | BATADV_TVLV_ROAM = 0x05, | 155 | BATADV_TVLV_ROAM = 0x05, |
156 | }; | 156 | }; |
157 | 157 | ||
158 | #pragma pack(2) | ||
158 | /* the destination hardware field in the ARP frame is used to | 159 | /* the destination hardware field in the ARP frame is used to |
159 | * transport the claim type and the group id | 160 | * transport the claim type and the group id |
160 | */ | 161 | */ |
@@ -163,24 +164,20 @@ struct batadv_bla_claim_dst { | |||
163 | uint8_t type; /* bla_claimframe */ | 164 | uint8_t type; /* bla_claimframe */ |
164 | __be16 group; /* group id */ | 165 | __be16 group; /* group id */ |
165 | }; | 166 | }; |
166 | 167 | #pragma pack() | |
167 | struct batadv_header { | ||
168 | uint8_t packet_type; | ||
169 | uint8_t version; /* batman version field */ | ||
170 | uint8_t ttl; | ||
171 | /* the parent struct has to add a byte after the header to make | ||
172 | * everything 4 bytes aligned again | ||
173 | */ | ||
174 | }; | ||
175 | 168 | ||
176 | /** | 169 | /** |
177 | * struct batadv_ogm_packet - ogm (routing protocol) packet | 170 | * struct batadv_ogm_packet - ogm (routing protocol) packet |
178 | * @header: common batman packet header | 171 | * @packet_type: batman-adv packet type, part of the general header |
172 | * @version: batman-adv protocol version, part of the genereal header | ||
173 | * @ttl: time to live for this packet, part of the genereal header | ||
179 | * @flags: contains routing relevant flags - see enum batadv_iv_flags | 174 | * @flags: contains routing relevant flags - see enum batadv_iv_flags |
180 | * @tvlv_len: length of tvlv data following the ogm header | 175 | * @tvlv_len: length of tvlv data following the ogm header |
181 | */ | 176 | */ |
182 | struct batadv_ogm_packet { | 177 | struct batadv_ogm_packet { |
183 | struct batadv_header header; | 178 | uint8_t packet_type; |
179 | uint8_t version; | ||
180 | uint8_t ttl; | ||
184 | uint8_t flags; | 181 | uint8_t flags; |
185 | __be32 seqno; | 182 | __be32 seqno; |
186 | uint8_t orig[ETH_ALEN]; | 183 | uint8_t orig[ETH_ALEN]; |
@@ -196,29 +193,51 @@ struct batadv_ogm_packet { | |||
196 | #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet) | 193 | #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet) |
197 | 194 | ||
198 | /** | 195 | /** |
199 | * batadv_icmp_header - common ICMP header | 196 | * batadv_icmp_header - common members among all the ICMP packets |
200 | * @header: common batman header | 197 | * @packet_type: batman-adv packet type, part of the general header |
198 | * @version: batman-adv protocol version, part of the genereal header | ||
199 | * @ttl: time to live for this packet, part of the genereal header | ||
201 | * @msg_type: ICMP packet type | 200 | * @msg_type: ICMP packet type |
202 | * @dst: address of the destination node | 201 | * @dst: address of the destination node |
203 | * @orig: address of the source node | 202 | * @orig: address of the source node |
204 | * @uid: local ICMP socket identifier | 203 | * @uid: local ICMP socket identifier |
204 | * @align: not used - useful for alignment purposes only | ||
205 | * | ||
206 | * This structure is used for ICMP packets parsing only and it is never sent | ||
207 | * over the wire. The alignment field at the end is there to ensure that | ||
208 | * members are padded the same way as they are in real packets. | ||
205 | */ | 209 | */ |
206 | struct batadv_icmp_header { | 210 | struct batadv_icmp_header { |
207 | struct batadv_header header; | 211 | uint8_t packet_type; |
212 | uint8_t version; | ||
213 | uint8_t ttl; | ||
208 | uint8_t msg_type; /* see ICMP message types above */ | 214 | uint8_t msg_type; /* see ICMP message types above */ |
209 | uint8_t dst[ETH_ALEN]; | 215 | uint8_t dst[ETH_ALEN]; |
210 | uint8_t orig[ETH_ALEN]; | 216 | uint8_t orig[ETH_ALEN]; |
211 | uint8_t uid; | 217 | uint8_t uid; |
218 | uint8_t align[3]; | ||
212 | }; | 219 | }; |
213 | 220 | ||
214 | /** | 221 | /** |
215 | * batadv_icmp_packet - ICMP packet | 222 | * batadv_icmp_packet - ICMP packet |
216 | * @icmph: common ICMP header | 223 | * @packet_type: batman-adv packet type, part of the general header |
224 | * @version: batman-adv protocol version, part of the genereal header | ||
225 | * @ttl: time to live for this packet, part of the genereal header | ||
226 | * @msg_type: ICMP packet type | ||
227 | * @dst: address of the destination node | ||
228 | * @orig: address of the source node | ||
229 | * @uid: local ICMP socket identifier | ||
217 | * @reserved: not used - useful for alignment | 230 | * @reserved: not used - useful for alignment |
218 | * @seqno: ICMP sequence number | 231 | * @seqno: ICMP sequence number |
219 | */ | 232 | */ |
220 | struct batadv_icmp_packet { | 233 | struct batadv_icmp_packet { |
221 | struct batadv_icmp_header icmph; | 234 | uint8_t packet_type; |
235 | uint8_t version; | ||
236 | uint8_t ttl; | ||
237 | uint8_t msg_type; /* see ICMP message types above */ | ||
238 | uint8_t dst[ETH_ALEN]; | ||
239 | uint8_t orig[ETH_ALEN]; | ||
240 | uint8_t uid; | ||
222 | uint8_t reserved; | 241 | uint8_t reserved; |
223 | __be16 seqno; | 242 | __be16 seqno; |
224 | }; | 243 | }; |
@@ -227,13 +246,25 @@ struct batadv_icmp_packet { | |||
227 | 246 | ||
228 | /** | 247 | /** |
229 | * batadv_icmp_packet_rr - ICMP RouteRecord packet | 248 | * batadv_icmp_packet_rr - ICMP RouteRecord packet |
230 | * @icmph: common ICMP header | 249 | * @packet_type: batman-adv packet type, part of the general header |
250 | * @version: batman-adv protocol version, part of the genereal header | ||
251 | * @ttl: time to live for this packet, part of the genereal header | ||
252 | * @msg_type: ICMP packet type | ||
253 | * @dst: address of the destination node | ||
254 | * @orig: address of the source node | ||
255 | * @uid: local ICMP socket identifier | ||
231 | * @rr_cur: number of entries the rr array | 256 | * @rr_cur: number of entries the rr array |
232 | * @seqno: ICMP sequence number | 257 | * @seqno: ICMP sequence number |
233 | * @rr: route record array | 258 | * @rr: route record array |
234 | */ | 259 | */ |
235 | struct batadv_icmp_packet_rr { | 260 | struct batadv_icmp_packet_rr { |
236 | struct batadv_icmp_header icmph; | 261 | uint8_t packet_type; |
262 | uint8_t version; | ||
263 | uint8_t ttl; | ||
264 | uint8_t msg_type; /* see ICMP message types above */ | ||
265 | uint8_t dst[ETH_ALEN]; | ||
266 | uint8_t orig[ETH_ALEN]; | ||
267 | uint8_t uid; | ||
237 | uint8_t rr_cur; | 268 | uint8_t rr_cur; |
238 | __be16 seqno; | 269 | __be16 seqno; |
239 | uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; | 270 | uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; |
@@ -253,8 +284,18 @@ struct batadv_icmp_packet_rr { | |||
253 | */ | 284 | */ |
254 | #pragma pack(2) | 285 | #pragma pack(2) |
255 | 286 | ||
287 | /** | ||
288 | * struct batadv_unicast_packet - unicast packet for network payload | ||
289 | * @packet_type: batman-adv packet type, part of the general header | ||
290 | * @version: batman-adv protocol version, part of the genereal header | ||
291 | * @ttl: time to live for this packet, part of the genereal header | ||
292 | * @ttvn: translation table version number | ||
293 | * @dest: originator destination of the unicast packet | ||
294 | */ | ||
256 | struct batadv_unicast_packet { | 295 | struct batadv_unicast_packet { |
257 | struct batadv_header header; | 296 | uint8_t packet_type; |
297 | uint8_t version; | ||
298 | uint8_t ttl; | ||
258 | uint8_t ttvn; /* destination translation table version number */ | 299 | uint8_t ttvn; /* destination translation table version number */ |
259 | uint8_t dest[ETH_ALEN]; | 300 | uint8_t dest[ETH_ALEN]; |
260 | /* "4 bytes boundary + 2 bytes" long to make the payload after the | 301 | /* "4 bytes boundary + 2 bytes" long to make the payload after the |
@@ -280,7 +321,9 @@ struct batadv_unicast_4addr_packet { | |||
280 | 321 | ||
281 | /** | 322 | /** |
282 | * struct batadv_frag_packet - fragmented packet | 323 | * struct batadv_frag_packet - fragmented packet |
283 | * @header: common batman packet header with type, compatversion, and ttl | 324 | * @packet_type: batman-adv packet type, part of the general header |
325 | * @version: batman-adv protocol version, part of the genereal header | ||
326 | * @ttl: time to live for this packet, part of the genereal header | ||
284 | * @dest: final destination used when routing fragments | 327 | * @dest: final destination used when routing fragments |
285 | * @orig: originator of the fragment used when merging the packet | 328 | * @orig: originator of the fragment used when merging the packet |
286 | * @no: fragment number within this sequence | 329 | * @no: fragment number within this sequence |
@@ -289,7 +332,9 @@ struct batadv_unicast_4addr_packet { | |||
289 | * @total_size: size of the merged packet | 332 | * @total_size: size of the merged packet |
290 | */ | 333 | */ |
291 | struct batadv_frag_packet { | 334 | struct batadv_frag_packet { |
292 | struct batadv_header header; | 335 | uint8_t packet_type; |
336 | uint8_t version; /* batman version field */ | ||
337 | uint8_t ttl; | ||
293 | #if defined(__BIG_ENDIAN_BITFIELD) | 338 | #if defined(__BIG_ENDIAN_BITFIELD) |
294 | uint8_t no:4; | 339 | uint8_t no:4; |
295 | uint8_t reserved:4; | 340 | uint8_t reserved:4; |
@@ -305,8 +350,19 @@ struct batadv_frag_packet { | |||
305 | __be16 total_size; | 350 | __be16 total_size; |
306 | }; | 351 | }; |
307 | 352 | ||
353 | /** | ||
354 | * struct batadv_bcast_packet - broadcast packet for network payload | ||
355 | * @packet_type: batman-adv packet type, part of the general header | ||
356 | * @version: batman-adv protocol version, part of the genereal header | ||
357 | * @ttl: time to live for this packet, part of the genereal header | ||
358 | * @reserved: reserved byte for alignment | ||
359 | * @seqno: sequence identification | ||
360 | * @orig: originator of the broadcast packet | ||
361 | */ | ||
308 | struct batadv_bcast_packet { | 362 | struct batadv_bcast_packet { |
309 | struct batadv_header header; | 363 | uint8_t packet_type; |
364 | uint8_t version; /* batman version field */ | ||
365 | uint8_t ttl; | ||
310 | uint8_t reserved; | 366 | uint8_t reserved; |
311 | __be32 seqno; | 367 | __be32 seqno; |
312 | uint8_t orig[ETH_ALEN]; | 368 | uint8_t orig[ETH_ALEN]; |
@@ -315,11 +371,11 @@ struct batadv_bcast_packet { | |||
315 | */ | 371 | */ |
316 | }; | 372 | }; |
317 | 373 | ||
318 | #pragma pack() | ||
319 | |||
320 | /** | 374 | /** |
321 | * struct batadv_coded_packet - network coded packet | 375 | * struct batadv_coded_packet - network coded packet |
322 | * @header: common batman packet header and ttl of first included packet | 376 | * @packet_type: batman-adv packet type, part of the general header |
377 | * @version: batman-adv protocol version, part of the genereal header | ||
378 | * @ttl: time to live for this packet, part of the genereal header | ||
323 | * @reserved: Align following fields to 2-byte boundaries | 379 | * @reserved: Align following fields to 2-byte boundaries |
324 | * @first_source: original source of first included packet | 380 | * @first_source: original source of first included packet |
325 | * @first_orig_dest: original destinal of first included packet | 381 | * @first_orig_dest: original destinal of first included packet |
@@ -334,7 +390,9 @@ struct batadv_bcast_packet { | |||
334 | * @coded_len: length of network coded part of the payload | 390 | * @coded_len: length of network coded part of the payload |
335 | */ | 391 | */ |
336 | struct batadv_coded_packet { | 392 | struct batadv_coded_packet { |
337 | struct batadv_header header; | 393 | uint8_t packet_type; |
394 | uint8_t version; /* batman version field */ | ||
395 | uint8_t ttl; | ||
338 | uint8_t first_ttvn; | 396 | uint8_t first_ttvn; |
339 | /* uint8_t first_dest[ETH_ALEN]; - saved in mac header destination */ | 397 | /* uint8_t first_dest[ETH_ALEN]; - saved in mac header destination */ |
340 | uint8_t first_source[ETH_ALEN]; | 398 | uint8_t first_source[ETH_ALEN]; |
@@ -349,9 +407,13 @@ struct batadv_coded_packet { | |||
349 | __be16 coded_len; | 407 | __be16 coded_len; |
350 | }; | 408 | }; |
351 | 409 | ||
410 | #pragma pack() | ||
411 | |||
352 | /** | 412 | /** |
353 | * struct batadv_unicast_tvlv - generic unicast packet with tvlv payload | 413 | * struct batadv_unicast_tvlv - generic unicast packet with tvlv payload |
354 | * @header: common batman packet header | 414 | * @packet_type: batman-adv packet type, part of the general header |
415 | * @version: batman-adv protocol version, part of the genereal header | ||
416 | * @ttl: time to live for this packet, part of the genereal header | ||
355 | * @reserved: reserved field (for packet alignment) | 417 | * @reserved: reserved field (for packet alignment) |
356 | * @src: address of the source | 418 | * @src: address of the source |
357 | * @dst: address of the destination | 419 | * @dst: address of the destination |
@@ -359,7 +421,9 @@ struct batadv_coded_packet { | |||
359 | * @align: 2 bytes to align the header to a 4 byte boundry | 421 | * @align: 2 bytes to align the header to a 4 byte boundry |
360 | */ | 422 | */ |
361 | struct batadv_unicast_tvlv_packet { | 423 | struct batadv_unicast_tvlv_packet { |
362 | struct batadv_header header; | 424 | uint8_t packet_type; |
425 | uint8_t version; /* batman version field */ | ||
426 | uint8_t ttl; | ||
363 | uint8_t reserved; | 427 | uint8_t reserved; |
364 | uint8_t dst[ETH_ALEN]; | 428 | uint8_t dst[ETH_ALEN]; |
365 | uint8_t src[ETH_ALEN]; | 429 | uint8_t src[ETH_ALEN]; |
@@ -420,13 +484,13 @@ struct batadv_tvlv_tt_vlan_data { | |||
420 | * struct batadv_tvlv_tt_change - translation table diff data | 484 | * struct batadv_tvlv_tt_change - translation table diff data |
421 | * @flags: status indicators concerning the non-mesh client (see | 485 | * @flags: status indicators concerning the non-mesh client (see |
422 | * batadv_tt_client_flags) | 486 | * batadv_tt_client_flags) |
423 | * @reserved: reserved field | 487 | * @reserved: reserved field - useful for alignment purposes only |
424 | * @addr: mac address of non-mesh client that triggered this tt change | 488 | * @addr: mac address of non-mesh client that triggered this tt change |
425 | * @vid: VLAN identifier | 489 | * @vid: VLAN identifier |
426 | */ | 490 | */ |
427 | struct batadv_tvlv_tt_change { | 491 | struct batadv_tvlv_tt_change { |
428 | uint8_t flags; | 492 | uint8_t flags; |
429 | uint8_t reserved; | 493 | uint8_t reserved[3]; |
430 | uint8_t addr[ETH_ALEN]; | 494 | uint8_t addr[ETH_ALEN]; |
431 | __be16 vid; | 495 | __be16 vid; |
432 | }; | 496 | }; |