Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-batadv.c
blob1de40f87c8d7f2c064b8d621242d0cb03e5c2383
1 /* packet-batadv.c
2 * Routines for B.A.T.M.A.N. Advanced dissection
3 * Copyright 2008-2010 Sven Eckelmann <sven@narfation.org>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <epan/packet.h>
15 #include <epan/prefs.h>
16 #include <epan/tap.h>
17 #include <epan/addr_resolv.h>
18 #include <epan/reassemble.h>
19 #include <epan/expert.h>
20 #include <epan/tfs.h>
21 #include <epan/unit_strings.h>
23 #include <wsutil/crc32.h>
25 /* Start content from packet-batadv.h */
26 #define ETH_P_BATMAN 0x4305
28 #define BATADV_PACKET_V5 0x01
29 #define BATADV_ICMP_V5 0x02
30 #define BATADV_UNICAST_V5 0x03
31 #define BATADV_BCAST_V5 0x04
32 #define BATADV_VIS_V5 0x05
33 #define BATADV_UNICAST_FRAG_V12 0x06
34 #define BATADV_TT_QUERY_V14 0x07
35 #define BATADV_ROAM_ADV_V14 0x08
36 #define BATADV_ROAM_ADV_V14 0x08
37 #define BATADV_UNICAST_4ADDR_V14 0x09
39 #define BATADV_IV_OGM_V15 0x00
40 #define BATADV_BCAST_V15 0x01
41 #define BATADV_CODED_V15 0x02
42 #define BATADV_ELP_V15 0x03
43 #define BATADV_OGM2_V15 0x04
44 #define BATADV_UNICAST_V15 0x40
45 #define BATADV_UNICAST_FRAG_V15 0x41
46 #define BATADV_UNICAST_4ADDR_V15 0x42
47 #define BATADV_ICMP_V15 0x43
48 #define BATADV_UNICAST_TVLV_V15 0x44
50 #define BATADV_TVLV_V15_GW 0x01
51 #define BATADV_TVLV_V15_DAT 0x02
52 #define BATADV_TVLV_V15_NC 0x03
53 #define BATADV_TVLV_V15_TT 0x04
54 #define BATADV_TVLV_V15_ROAM 0x05
55 #define BATADV_TVLV_V15_MCAST 0x06
57 #define ECHO_REPLY 0
58 #define DESTINATION_UNREACHABLE 3
59 #define ECHO_REQUEST 8
60 #define TTL_EXCEEDED 11
61 #define BATADV_TP 15
63 #define TT_TYPE_MASK 0x3
64 #define TT_REQUEST 0
65 #define TT_RESPONSE 1
67 #define TT_FULL_TABLE 0x04
69 #define TT_CHANGE_DEL 0x01
70 #define TT_CLIENT_ROAM 0x02
72 #define BAT_RR_LEN 16
74 #define UNICAST_4ADDR_DATA 0x01
75 #define UNICAST_4ADDR_DAT_DHT_GET 0x02
76 #define UNICAST_4ADDR_DAT_DHT_PUT 0x03
77 #define UNICAST_4ADDR_DAT_CACHE_REPLY 0x04
79 #define BATADV_TVLVL_TT_TYPE_MASK 0x0F
80 #define BATADV_TVLVL_TT_OGM_DIFF 0x01
81 #define BATADV_TVLVL_TT_REQUEST 0x02
82 #define BATADV_TVLVL_TT_RESPONSE 0x04
83 #define BATADV_TVLVL_TT_FULL_TABLE 0x10
85 #define BATADV_TVLVL_TT_CHANGE_DEL 0x01
86 #define BATADV_TVLVL_TT_CHANGE_ROAM 0x02
87 #define BATADV_TVLVL_TT_CHANGE_WIFI 0x10
88 #define BATADV_TVLVL_TT_CHANGE_ISOLATE 0x20
90 struct batman_packet_v5 {
91 uint8_t packet_type;
92 uint8_t version; /* batman version field */
93 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
94 uint8_t ttl;
95 uint8_t gwflags; /* flags related to gateway functions: gateway class */
96 uint8_t tq;
97 uint16_t seqno;
98 address orig;
99 address prev_sender;
100 uint8_t num_tt;
101 uint8_t pad;
103 #define BATMAN_PACKET_V5_SIZE 22
105 struct batman_packet_v7 {
106 uint8_t packet_type;
107 uint8_t version; /* batman version field */
108 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
109 uint8_t tq;
110 uint16_t seqno;
111 address orig;
112 address prev_sender;
113 uint8_t ttl;
114 uint8_t num_tt;
116 #define BATMAN_PACKET_V7_SIZE 20
118 struct batman_packet_v9 {
119 uint8_t packet_type;
120 uint8_t version; /* batman version field */
121 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
122 uint8_t tq;
123 uint16_t seqno;
124 address orig;
125 address prev_sender;
126 uint8_t ttl;
127 uint8_t num_tt;
128 uint8_t gwflags;
129 uint8_t pad;
131 #define BATMAN_PACKET_V9_SIZE 22
133 struct batman_packet_v10 {
134 uint8_t packet_type;
135 uint8_t version; /* batman version field */
136 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
137 uint8_t tq;
138 uint32_t seqno;
139 address orig;
140 address prev_sender;
141 uint8_t ttl;
142 uint8_t num_tt;
143 uint8_t gwflags;
144 uint8_t pad;
146 #define BATMAN_PACKET_V10_SIZE 24
148 struct batman_packet_v11 {
149 uint8_t packet_type;
150 uint8_t version; /* batman version field */
151 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
152 uint8_t tq;
153 uint32_t seqno;
154 address orig;
155 address prev_sender;
156 uint8_t ttl;
157 uint8_t num_tt;
159 #define BATMAN_PACKET_V11_SIZE 22
161 struct batman_packet_v14 {
162 uint8_t packet_type;
163 uint8_t version; /* batman version field */
164 uint8_t ttl;
165 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
166 uint32_t seqno;
167 address orig;
168 address prev_sender;
169 uint8_t gw_flags; /* flags related to gateway class */
170 uint8_t tq;
171 uint8_t tt_num_changes;
172 uint8_t ttvn; /* translation table version number */
173 uint16_t tt_crc;
175 #define BATMAN_PACKET_V14_SIZE 26
177 struct iv_ogm_packet_v15 {
178 uint8_t packet_type;
179 uint8_t version; /* batman version field */
180 uint8_t ttl;
181 uint8_t flags;
182 uint32_t seqno;
183 address orig;
184 address prev_sender;
185 uint8_t reserved;
186 uint8_t tq;
187 uint16_t tvlv_len;
189 #define IV_OGM_PACKET_V15_SIZE 24
191 struct elp_packet_v15 {
192 uint8_t packet_type;
193 uint8_t version;
194 address orig;
195 uint32_t seqno;
196 uint32_t interval;
198 #define ELP_PACKET_V15_SIZE 16
200 struct ogm2_packet_v15 {
201 uint8_t packet_type;
202 uint8_t version;
203 uint8_t ttl;
204 uint8_t flags;
205 uint32_t seqno;
206 address orig;
207 uint16_t tvlv_len;
208 uint32_t throughput;
210 #define OGM2_PACKET_V15_SIZE 20
212 struct icmp_packet_v6 {
213 uint8_t packet_type;
214 uint8_t version; /* batman version field */
215 uint8_t msg_type; /* 0 = ECHO REPLY, 3 = DESTINATION_UNREACHABLE, 8 = ECHO_REQUEST, 11 = TTL exceeded */
216 address dst;
217 address orig;
218 uint8_t ttl;
219 uint8_t uid;
220 uint16_t seqno;
222 #define ICMP_PACKET_V6_SIZE 19
224 struct icmp_packet_v7 {
225 uint8_t packet_type;
226 uint8_t version; /* batman version field */
227 uint8_t msg_type; /* 0 = ECHO REPLY, 3 = DESTINATION_UNREACHABLE, 8 = ECHO_REQUEST, 11 = TTL exceeded */
228 uint8_t ttl;
229 address dst;
230 address orig;
231 uint16_t seqno;
232 uint8_t uid;
234 #define ICMP_PACKET_V7_SIZE 19
236 struct icmp_packet_v14 {
237 uint8_t packet_type;
238 uint8_t version; /* batman version field */
239 uint8_t ttl;
240 uint8_t msg_type; /* see ICMP message types above */
241 address dst;
242 address orig;
243 uint16_t seqno;
244 uint8_t uid;
245 uint8_t reserved;
247 #define ICMP_PACKET_V14_SIZE 20
249 struct icmp_packet_v15 {
250 uint8_t packet_type;
251 uint8_t version; /* batman version field */
252 uint8_t ttl;
253 uint8_t msg_type; /* see ICMP message types above */
254 address dst;
255 address orig;
256 uint8_t uid;
257 uint8_t rr_ptr;
258 uint16_t seqno;
260 #define ICMP_PACKET_V15_SIZE 20
262 struct icmp_tp_packet_v15 {
263 uint8_t packet_type;
264 uint8_t version; /* batman version field */
265 uint8_t ttl;
266 uint8_t msg_type; /* see ICMP message types above */
267 address dst;
268 address orig;
269 uint8_t uid;
270 uint8_t subtype;
271 uint16_t session;
272 uint32_t seqno;
273 uint32_t timestamp;
275 #define ICMP_TP_PACKET_V15_SIZE 28
277 struct unicast_packet_v6 {
278 uint8_t packet_type;
279 uint8_t version;
280 address dest;
281 uint8_t ttl;
283 #define UNICAST_PACKET_V6_SIZE 9
285 struct unicast_packet_v14 {
286 uint8_t packet_type;
287 uint8_t version; /* batman version field */
288 uint8_t ttl;
289 uint8_t ttvn; /* destination translation table version number */
290 address dest;
292 #define UNICAST_PACKET_V14_SIZE 10
294 struct unicast_4addr_packet_v14 {
295 uint8_t packet_type;
296 uint8_t version; /* batman version field */
297 uint8_t ttl;
298 uint8_t ttvn; /* destination translation table version number */
299 address dest;
300 address src;
301 uint8_t subtype;
302 uint8_t reserved;
304 #define UNICAST_4ADDR_PACKET_V14_SIZE 18
306 struct unicast_frag_packet_v12 {
307 uint8_t packet_type;
308 uint8_t version;
309 address dest;
310 uint8_t ttl;
311 uint8_t flags;
312 address orig;
313 uint16_t seqno;
315 #define UNICAST_FRAG_PACKET_V12_SIZE 18
317 struct unicast_frag_packet_v14 {
318 uint8_t packet_type;
319 uint8_t version; /* batman version field */
320 uint8_t ttl;
321 uint8_t ttvn; /* destination translation table version number */
322 address dest;
323 uint8_t flags;
324 uint8_t align;
325 address orig;
326 uint16_t seqno;
328 #define UNICAST_FRAG_PACKET_V14_SIZE 20
330 struct unicast_frag_packet_v15 {
331 uint8_t packet_type;
332 uint8_t version; /* batman version field */
333 uint8_t ttl;
334 uint8_t no; /* only upper 4 bit are used */
335 address dest;
336 address orig;
337 uint16_t seqno;
338 uint16_t total_size;
340 #define UNICAST_FRAG_PACKET_V15_SIZE 20
342 struct bcast_packet_v6 {
343 uint8_t packet_type;
344 uint8_t version; /* batman version field */
345 address orig;
346 uint16_t seqno;
348 #define BCAST_PACKET_V6_SIZE 10
350 struct bcast_packet_v10 {
351 uint8_t packet_type;
352 uint8_t version; /* batman version field */
353 address orig;
354 uint8_t ttl;
355 uint32_t seqno;
357 #define BCAST_PACKET_V10_SIZE 13
359 struct bcast_packet_v14 {
360 uint8_t packet_type;
361 uint8_t version; /* batman version field */
362 uint8_t ttl;
363 uint8_t reserved;
364 uint32_t seqno;
365 address orig;
367 #define BCAST_PACKET_V14_SIZE 14
369 struct vis_packet_v6 {
370 uint8_t packet_type;
371 uint8_t version; /* batman version field */
372 uint8_t vis_type; /* which type of vis-participant sent this? */
373 uint8_t seqno; /* sequence number */
374 uint8_t entries; /* number of entries behind this struct */
375 uint8_t ttl; /* TTL */
376 address vis_orig; /* originator that informs about its neighbours */
377 address target_orig; /* who should receive this packet */
378 address sender_orig; /* who sent or rebroadcasted this packet */
380 #define VIS_PACKET_V6_SIZE 24
382 struct vis_packet_v10 {
383 uint8_t packet_type;
384 uint8_t version; /* batman version field */
385 uint8_t vis_type; /* which type of vis-participant sent this? */
386 uint8_t entries; /* number of entries behind this struct */
387 uint32_t seqno; /* sequence number */
388 uint8_t ttl; /* TTL */
389 address vis_orig; /* originator that informs about its neighbours */
390 address target_orig; /* who should receive this packet */
391 address sender_orig; /* who sent or rebroadcasted this packet */
393 #define VIS_PACKET_V10_SIZE 27
395 struct vis_packet_v14 {
396 uint8_t packet_type;
397 uint8_t version; /* batman version field */
398 uint8_t ttl; /* TTL */
399 uint8_t vis_type; /* which type of vis-participant sent this? */
400 uint32_t seqno; /* sequence number */
401 uint8_t entries; /* number of entries behind this struct */
402 uint8_t reserved;
403 address vis_orig; /* originator that announces its neighbors */
404 address target_orig; /* who should receive this packet */
405 address sender_orig; /* who sent or rebroadcasted this packet */
407 #define VIS_PACKET_V14_SIZE 28
409 #define VIS_ENTRY_V6_SIZE 7
410 #define VIS_ENTRY_V8_SIZE 13
412 #define VIS_TYPE_SERVER_SYNC 0
413 #define VIS_TYPE_CLIENT_UPDATE 1
415 struct tt_query_packet_v14 {
416 uint8_t packet_type;
417 uint8_t version; /* batman version field */
418 uint8_t ttl;
419 uint8_t flags;
420 address dst;
421 address src;
422 uint8_t ttvn;
423 uint16_t tt_data;
425 #define TT_QUERY_PACKET_V14_SIZE 19
427 #define TT_ENTRY_V14_SIZE 7
429 struct roam_adv_packet_v14 {
430 uint8_t packet_type;
431 uint8_t version;
432 uint8_t ttl;
433 uint8_t reserved;
434 address dst;
435 address src;
436 address client;
438 #define ROAM_ADV_PACKET_V14_SIZE 22
440 struct coded_packet_v15 {
441 uint8_t packet_type;
442 uint8_t version; /* batman version field */
443 uint8_t ttl;
444 uint8_t first_ttvn;
445 address first_source;
446 address first_orig_dest;
447 uint32_t first_crc;
448 uint8_t second_ttl;
449 uint8_t second_ttvn;
450 address second_dest;
451 address second_source;
452 address second_orig_dest;
453 uint32_t second_crc;
454 uint16_t coded_len;
456 #define CODED_PACKET_V15_SIZE 46
458 struct unicast_tvlv_packet_v15 {
459 uint8_t packet_type;
460 uint8_t version; /* batman version field */
461 uint8_t ttl;
462 uint8_t reserved;
463 address dest;
464 address src;
465 uint16_t tvlv_len;
466 uint16_t align;
468 #define UNICAST_TVLV_PACKET_V15_SIZE 20
470 #define TLVLV_TT_VLAN_V15_SIZE 8
471 #define TLVLV_TT_CHANGE_V15_SIZE 12
473 /* End content from packet-batadv.h */
475 /* trees */
476 static int ett_batadv_batman;
477 static int ett_batadv_batman_flags;
478 static int ett_batadv_batman_gwflags;
479 static int ett_batadv_batman_tt;
480 static int ett_batadv_iv_ogm;
481 static int ett_batadv_iv_ogm_flags;
482 static int ett_batadv_elp;
483 static int ett_batadv_ogm2;
484 //static int ett_batadv_ogm2_flags;
485 static int ett_batadv_bcast;
486 static int ett_batadv_icmp;
487 static int ett_batadv_icmp_rr;
488 static int ett_batadv_unicast;
489 static int ett_batadv_unicast_4addr;
490 static int ett_batadv_unicast_frag;
491 static int ett_batadv_unicast_tvlv;
492 static int ett_batadv_vis;
493 static int ett_batadv_vis_entry;
494 static int ett_batadv_tt_query;
495 static int ett_batadv_tt_query_flags;
496 static int ett_batadv_tt_entry;
497 static int ett_batadv_tt_entry_flags;
498 static int ett_batadv_roam_adv;
499 static int ett_batadv_coded;
500 static int ett_batadv_tvlv;
501 static int ett_batadv_tvlv_mcast_flags;
502 static int ett_batadv_tvlv_vid;
503 static int ett_batadv_tvlv_tt_flags;
504 static int ett_batadv_tvlv_tt_vlan;
505 static int ett_batadv_tvlv_tt_change;
506 static int ett_msg_fragment;
507 static int ett_msg_fragments;
509 static expert_field ei_batadv_tvlv_unknown_version;
510 static expert_field ei_batadv_tvlv_tt_vlan_crc;
511 static expert_field ei_batadv_tvlv_tt_vlan_empty;
513 /* hfs */
514 static int hf_batadv_packet_type;
516 static int hf_batadv_batman_version;
517 static int hf_batadv_batman_flags;
518 static int hf_batadv_batman_ttl;
519 static int hf_batadv_batman_gwflags;
520 static int hf_batadv_batman_gwflags_dl_speed;
521 static int hf_batadv_batman_gwflags_ul_speed;
522 static int hf_batadv_batman_tq;
523 static int hf_batadv_batman_seqno;
524 static int hf_batadv_batman_seqno32;
525 static int hf_batadv_batman_orig;
526 static int hf_batadv_batman_prev_sender;
527 static int hf_batadv_batman_num_tt;
528 static int hf_batadv_batman_tt_num_changes;
529 static int hf_batadv_batman_ttvn;
530 static int hf_batadv_batman_tt_crc;
531 static int hf_batadv_batman_tt;
533 static int hf_batadv_iv_ogm_version;
534 static int hf_batadv_iv_ogm_ttl;
535 static int hf_batadv_iv_ogm_flags;
536 static int hf_batadv_iv_ogm_seqno;
537 static int hf_batadv_iv_ogm_orig;
538 static int hf_batadv_iv_ogm_prev_sender;
539 static int hf_batadv_iv_ogm_tq;
540 static int hf_batadv_iv_ogm_tvlv_len;
542 static int hf_batadv_elp_version;
543 static int hf_batadv_elp_orig;
544 static int hf_batadv_elp_seqno;
545 static int hf_batadv_elp_interval;
547 static int hf_batadv_ogm2_version;
548 static int hf_batadv_ogm2_ttl;
549 static int hf_batadv_ogm2_flags;
550 static int hf_batadv_ogm2_seqno;
551 static int hf_batadv_ogm2_orig;
552 static int hf_batadv_ogm2_tvlv_len;
553 static int hf_batadv_ogm2_throughput;
555 static int hf_batadv_bcast_version;
556 static int hf_batadv_bcast_orig;
557 static int hf_batadv_bcast_seqno;
558 static int hf_batadv_bcast_seqno32;
559 static int hf_batadv_bcast_ttl;
561 static int hf_batadv_icmp_version;
562 static int hf_batadv_icmp_msg_type;
563 static int hf_batadv_icmp_dst;
564 static int hf_batadv_icmp_orig;
565 static int hf_batadv_icmp_ttl;
566 static int hf_batadv_icmp_uid;
567 static int hf_batadv_icmp_seqno;
569 static int hf_batadv_icmp_rr_pointer;
570 static int hf_batadv_icmp_rr_ether;
572 static int hf_batadv_icmp_tp_subtype;
573 static int hf_batadv_icmp_tp_session;
574 static int hf_batadv_icmp_tp_seqno;
575 static int hf_batadv_icmp_tp_timestamp;
577 static int hf_batadv_unicast_version;
578 static int hf_batadv_unicast_dst;
579 static int hf_batadv_unicast_ttl;
580 static int hf_batadv_unicast_ttvn;
582 static int hf_batadv_unicast_4addr_version;
583 static int hf_batadv_unicast_4addr_dst;
584 static int hf_batadv_unicast_4addr_ttl;
585 static int hf_batadv_unicast_4addr_ttvn;
586 static int hf_batadv_unicast_4addr_src;
587 static int hf_batadv_unicast_4addr_subtype;
589 static int hf_batadv_unicast_frag_version;
590 static int hf_batadv_unicast_frag_dst;
591 static int hf_batadv_unicast_frag_ttl;
592 static int hf_batadv_unicast_frag_ttvn;
593 static int hf_batadv_unicast_frag_flags;
594 static int hf_batadv_unicast_frag_orig;
595 static int hf_batadv_unicast_frag_seqno;
596 static int hf_batadv_unicast_frag_no;
597 static int hf_batadv_unicast_frag_priority;
598 static int hf_batadv_unicast_frag_total_size;
600 static int hf_batadv_unicast_tvlv_version;
601 static int hf_batadv_unicast_tvlv_ttl;
602 static int hf_batadv_unicast_tvlv_dst;
603 static int hf_batadv_unicast_tvlv_src;
604 static int hf_batadv_unicast_tvlv_len;
606 static int hf_batadv_vis_version;
607 static int hf_batadv_vis_type;
608 static int hf_batadv_vis_seqno;
609 static int hf_batadv_vis_seqno32;
610 static int hf_batadv_vis_entries;
611 static int hf_batadv_vis_ttl;
612 static int hf_batadv_vis_vis_orig;
613 static int hf_batadv_vis_target_orig;
614 static int hf_batadv_vis_sender_orig;
615 static int hf_batadv_vis_entry_src;
616 static int hf_batadv_vis_entry_dst;
617 static int hf_batadv_vis_entry_quality;
619 static int hf_batadv_tt_query_version;
620 static int hf_batadv_tt_query_ttl;
621 static int hf_batadv_tt_query_flags;
622 static int hf_batadv_tt_query_flags_type;
623 static int hf_batadv_tt_query_flags_full_table;
624 static int hf_batadv_tt_query_dst;
625 static int hf_batadv_tt_query_src;
626 static int hf_batadv_tt_query_ttvn;
627 static int hf_batadv_tt_query_tt_crc;
628 static int hf_batadv_tt_query_entries;
629 static int hf_batadv_tt_entry;
630 static int hf_batadv_tt_entry_flags;
631 static int hf_batadv_tt_entry_flags_change_del;
632 static int hf_batadv_tt_entry_flags_client_roam;
634 static int hf_batadv_roam_adv_version;
635 static int hf_batadv_roam_adv_ttl;
636 static int hf_batadv_roam_adv_dst;
637 static int hf_batadv_roam_adv_src;
638 static int hf_batadv_roam_adv_client;
640 static int hf_batadv_coded_version;
641 static int hf_batadv_coded_ttl;
642 static int hf_batadv_coded_first_ttvn;
643 static int hf_batadv_coded_first_source;
644 static int hf_batadv_coded_first_orig_dest;
645 static int hf_batadv_coded_first_crc;
646 static int hf_batadv_coded_second_ttl;
647 static int hf_batadv_coded_second_ttvn;
648 static int hf_batadv_coded_second_dest;
649 static int hf_batadv_coded_second_source;
650 static int hf_batadv_coded_second_orig_dest;
651 static int hf_batadv_coded_second_crc;
652 static int hf_batadv_coded_coded_len;
654 static int hf_msg_fragments;
655 static int hf_msg_fragment;
656 static int hf_msg_fragment_overlap;
657 static int hf_msg_fragment_overlap_conflicts;
658 static int hf_msg_fragment_multiple_tails;
659 static int hf_msg_fragment_too_long_fragment;
660 static int hf_msg_fragment_error;
661 static int hf_msg_fragment_count;
662 static int hf_msg_reassembled_in;
663 static int hf_msg_reassembled_length;
665 static int hf_batadv_tvlv_type;
666 static int hf_batadv_tvlv_version;
667 static int hf_batadv_tvlv_len;
669 static int hf_batadv_tvlv_gw_download;
670 static int hf_batadv_tvlv_gw_upload;
672 static int hf_batadv_tvlv_roam_addr;
673 static int hf_batadv_tvlv_roam_vid;
674 static int hf_batadv_tvlv_vid_vlan;
675 static int hf_batadv_tvlv_vid_tagged;
677 static int hf_batadv_tvlv_tt_flags;
678 static int hf_batadv_tvlv_tt_flags_type;
679 static int hf_batadv_tvlv_tt_flags_full_table;
680 static int hf_batadv_tvlv_tt_ttvn;
681 static int hf_batadv_tvlv_tt_num_vlan;
682 static int hf_batadv_tvlv_tt_vlan_crc;
683 static int hf_batadv_tvlv_tt_vlan_crc_status;
684 static int hf_batadv_tvlv_tt_vlan_vid;
685 static int hf_batadv_tvlv_tt_change_flags;
686 static int hf_batadv_tvlv_tt_change_vid;
687 static int hf_batadv_tvlv_tt_change_addr;
689 /* flags */
690 static int hf_batadv_batman_flags_directlink;
691 static int hf_batadv_batman_flags_vis_server;
692 static int hf_batadv_batman_flags_not_best_next_hop;
693 static int hf_batadv_batman_flags_primaries_first_hop;
694 static int hf_batadv_unicast_frag_flags_head;
695 static int hf_batadv_unicast_frag_flags_largetail;
696 static int hf_batadv_iv_ogm_flags_not_best_next_hop;
697 static int hf_batadv_iv_ogm_flags_primaries_first_hop;
698 static int hf_batadv_iv_ogm_flags_directlink;
699 static int hf_batadv_tvlv_mcast_flags;
700 static int hf_batadv_tvlv_mcast_flags_unsnoopables;
701 static int hf_batadv_tvlv_mcast_flags_ipv4;
702 static int hf_batadv_tvlv_mcast_flags_ipv6;
703 static int hf_batadv_tvlv_mcast_flags_no_rtr4;
704 static int hf_batadv_tvlv_mcast_flags_no_rtr6;
705 static int hf_batadv_tvlv_tt_change_flags_del;
706 static int hf_batadv_tvlv_tt_change_flags_roam;
707 static int hf_batadv_tvlv_tt_change_flags_wifi;
708 static int hf_batadv_tvlv_tt_change_flags_isolate;
710 static const value_string unicast_4addr_typenames[] = {
711 { UNICAST_4ADDR_DATA, "Data" },
712 { UNICAST_4ADDR_DAT_DHT_GET, "DHT Get" },
713 { UNICAST_4ADDR_DAT_DHT_PUT, "DHT Put" },
714 { UNICAST_4ADDR_DAT_CACHE_REPLY, "DHT Cache Reply" },
715 { 0, NULL }
718 static const value_string tvlv_v15_typenames[] = {
719 { BATADV_TVLV_V15_GW, "Gateway information" },
720 { BATADV_TVLV_V15_DAT, "Distributed ARP Table" },
721 { BATADV_TVLV_V15_NC, "Network Coding" },
722 { BATADV_TVLV_V15_TT, "Translation Table" },
723 { BATADV_TVLV_V15_ROAM, "Roaming" },
724 { BATADV_TVLV_V15_MCAST, "Multicast" },
725 { 0, NULL }
728 static const value_string icmp_packettypenames[] = {
729 { ECHO_REPLY, "ECHO_REPLY" },
730 { DESTINATION_UNREACHABLE, "DESTINATION UNREACHABLE" },
731 { ECHO_REQUEST, "ECHO_REQUEST" },
732 { TTL_EXCEEDED, "TTL exceeded" },
733 { BATADV_TP, "Throughput Meter" },
734 { 0, NULL }
737 static const value_string icmp_tp_packettypenames[] = {
738 { 0, "Message" },
739 { 1, "Acknowledgement" },
740 { 0, NULL }
743 static const value_string vis_packettypenames[] = {
744 { VIS_TYPE_SERVER_SYNC, "SERVER_SYNC" },
745 { VIS_TYPE_CLIENT_UPDATE, "CLIENT_UPDATE" },
746 { 0, NULL }
749 static const value_string tt_query_type_v14[] = {
750 {TT_REQUEST, "Request"},
751 {TT_RESPONSE, "Response"},
752 {0, NULL}
755 static const value_string tvlv_tt_typenames[] = {
756 {BATADV_TVLVL_TT_OGM_DIFF, "OGM Diff"},
757 {BATADV_TVLVL_TT_REQUEST, "Request"},
758 {BATADV_TVLVL_TT_RESPONSE, "Response"},
759 {0, NULL}
762 static int * const batman_v5_flags[] = {
763 &hf_batadv_batman_flags_directlink,
764 &hf_batadv_batman_flags_vis_server,
765 NULL
768 static int * const batman_v9_flags[] = {
769 &hf_batadv_batman_flags_directlink,
770 &hf_batadv_batman_flags_vis_server,
771 &hf_batadv_batman_flags_primaries_first_hop,
772 NULL
775 static int * const batman_v14_flags[] = {
776 &hf_batadv_batman_flags_directlink,
777 &hf_batadv_batman_flags_vis_server,
778 &hf_batadv_batman_flags_primaries_first_hop,
779 &hf_batadv_batman_flags_not_best_next_hop,
780 NULL
783 static int * const unicast_frag_flags[] = {
784 &hf_batadv_unicast_frag_flags_head,
785 &hf_batadv_unicast_frag_flags_largetail,
786 NULL
789 static int * const tt_query_flags[] = {
790 &hf_batadv_tt_query_flags_type,
791 &hf_batadv_tt_query_flags_full_table,
792 NULL
795 static int * const tt_entry_flags[] = {
796 &hf_batadv_tt_entry_flags_change_del,
797 &hf_batadv_tt_entry_flags_client_roam,
798 NULL
801 static const fragment_items msg_frag_items = {
802 /* Fragment subtrees */
803 &ett_msg_fragment,
804 &ett_msg_fragments,
805 /* Fragment fields */
806 &hf_msg_fragments,
807 &hf_msg_fragment,
808 &hf_msg_fragment_overlap,
809 &hf_msg_fragment_overlap_conflicts,
810 &hf_msg_fragment_multiple_tails,
811 &hf_msg_fragment_too_long_fragment,
812 &hf_msg_fragment_error,
813 &hf_msg_fragment_count,
814 /* Reassembled in field */
815 &hf_msg_reassembled_in,
816 &hf_msg_reassembled_length,
817 /* Reassembled data field */
818 NULL,
819 /* Tag */
820 "Message fragments"
824 /* forward declaration */
825 void proto_register_batadv(void);
826 void proto_reg_handoff_batadv(void);
828 static dissector_handle_t batman_handle;
830 /* supported packet dissectors */
831 static void dissect_batadv_v5(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
832 static void dissect_batadv_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
833 static void dissect_batadv_batman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
834 static int dissect_batadv_batman_v5(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
835 static int dissect_batadv_batman_v7(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
836 static int dissect_batadv_batman_v9(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
837 static int dissect_batadv_batman_v10(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
838 static int dissect_batadv_batman_v11(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
839 static int dissect_batadv_batman_v14(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
841 static void dissect_batadv_iv_ogm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
842 static int dissect_batadv_iv_ogm_v15(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
844 static void dissect_batadv_elp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
845 static void dissect_batadv_elp_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
847 static void dissect_batadv_ogm2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
848 static int dissect_batadv_ogm2_v15(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
850 static void dissect_batadv_bcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
851 static void dissect_batadv_bcast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
852 static void dissect_batadv_bcast_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
853 static void dissect_batadv_bcast_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
855 static void dissect_batadv_icmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
856 static void dissect_batadv_icmp_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
857 static void dissect_batadv_icmp_v7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
858 static void dissect_batadv_icmp_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
859 static void dissect_batadv_icmp_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
861 static void dissect_batadv_unicast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
862 static void dissect_batadv_unicast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
863 static void dissect_batadv_unicast_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
865 static void dissect_batadv_unicast_4addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
866 static void dissect_batadv_unicast_4addr_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
868 static void dissect_batadv_unicast_frag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
869 static void dissect_batadv_unicast_frag_v12(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
870 static void dissect_batadv_unicast_frag_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
871 static void dissect_batadv_unicast_frag_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
873 static void dissect_batadv_vis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
874 static void dissect_batadv_vis_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
875 static void dissect_batadv_vis_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
876 static void dissect_batadv_vis_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
878 static void dissect_batadv_tt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
879 static void dissect_vis_entry_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
880 static void dissect_vis_entry_v8(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
882 static void dissect_batadv_tt_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
883 static void dissect_batadv_tt_query_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
884 static void dissect_tt_entry_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
886 static void dissect_batadv_roam_adv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
887 static void dissect_batadv_roam_adv_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
889 static void dissect_batadv_coded(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
890 static void dissect_batadv_coded_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
892 static void dissect_batadv_unicast_tvlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
893 static void dissect_batadv_unicast_tvlv_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
895 static void dissect_batadv_tvlv_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
896 static void dissect_batadv_tvlv_v15_header(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, uint8_t type);
897 static void dissect_batadv_tvlv_v15_dat(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, uint8_t version);
898 static void dissect_batadv_tvlv_v15_nc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, uint8_t version);
899 static void dissect_batadv_tvlv_v15_mcast(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, uint8_t version);
900 static void dissect_batadv_tvlv_v15_gw(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, uint8_t version);
901 static void dissect_batadv_tvlv_v15_roam(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, uint8_t version);
902 static void dissect_batadv_tvlv_v15_tt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, uint8_t version);
903 static int dissect_batadv_tvlv_v15_tt_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, uint8_t tt_flags, int changes_offset);
904 static int dissect_batadv_tvlv_v15_tt_change(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset);
907 /* other dissectors */
908 static dissector_handle_t eth_handle;
910 static int proto_batadv_plugin;
912 /* tap */
913 static int batadv_tap;
914 static int batadv_follow_tap;
916 /* segmented messages */
917 static reassembly_table msg_reassembly_table;
919 static unsigned int batadv_ethertype = ETH_P_BATMAN;
921 static int dissect_batadv_plugin(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
923 uint8_t version;
925 col_clear(pinfo->cinfo, COL_INFO);
927 version = tvb_get_uint8(tvb, 1);
928 if (version < 15)
929 dissect_batadv_v5(tvb, pinfo, tree);
930 else
931 dissect_batadv_v15(tvb, pinfo, tree);
933 return tvb_captured_length(tvb);
936 static void dissect_batadv_v5(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
938 uint8_t type;
940 type = tvb_get_uint8(tvb, 0);
942 switch (type) {
943 case BATADV_PACKET_V5:
944 dissect_batadv_batman(tvb, pinfo, tree);
945 break;
946 case BATADV_ICMP_V5:
947 dissect_batadv_icmp(tvb, pinfo, tree);
948 break;
949 case BATADV_UNICAST_V5:
950 dissect_batadv_unicast(tvb, pinfo, tree);
951 break;
952 case BATADV_UNICAST_FRAG_V12:
953 dissect_batadv_unicast_frag(tvb, pinfo, tree);
954 break;
955 case BATADV_BCAST_V5:
956 dissect_batadv_bcast(tvb, pinfo, tree);
957 break;
958 case BATADV_VIS_V5:
959 dissect_batadv_vis(tvb, pinfo, tree);
960 break;
961 case BATADV_TT_QUERY_V14:
962 dissect_batadv_tt_query(tvb, pinfo, tree);
963 break;
964 case BATADV_ROAM_ADV_V14:
965 dissect_batadv_roam_adv(tvb, pinfo, tree);
966 break;
967 case BATADV_UNICAST_4ADDR_V14:
968 dissect_batadv_unicast_4addr(tvb, pinfo, tree);
969 break;
970 default:
971 /* dunno */
973 tvbuff_t *next_tvb;
974 int length_remaining;
976 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_???");
978 length_remaining = tvb_reported_length_remaining(tvb, 0);
979 if (length_remaining > 0) {
980 next_tvb = tvb_new_subset_remaining(tvb, 0);
981 call_data_dissector(next_tvb, pinfo, tree);
983 break;
988 static void dissect_batadv_v15(tvbuff_t *tvb, packet_info *pinfo,
989 proto_tree *tree)
991 uint8_t type;
993 type = tvb_get_uint8(tvb, 0);
995 switch (type) {
996 case BATADV_IV_OGM_V15:
997 dissect_batadv_iv_ogm(tvb, pinfo, tree);
998 break;
999 case BATADV_BCAST_V15:
1000 dissect_batadv_bcast(tvb, pinfo, tree);
1001 break;
1002 case BATADV_CODED_V15:
1003 dissect_batadv_coded(tvb, pinfo, tree);
1004 break;
1005 case BATADV_ELP_V15:
1006 dissect_batadv_elp(tvb, pinfo, tree);
1007 break;
1008 case BATADV_OGM2_V15:
1009 dissect_batadv_ogm2(tvb, pinfo, tree);
1010 break;
1011 case BATADV_UNICAST_V15:
1012 dissect_batadv_unicast(tvb, pinfo, tree);
1013 break;
1014 case BATADV_UNICAST_FRAG_V15:
1015 dissect_batadv_unicast_frag(tvb, pinfo, tree);
1016 break;
1017 case BATADV_UNICAST_4ADDR_V15:
1018 dissect_batadv_unicast_4addr(tvb, pinfo, tree);
1019 break;
1020 case BATADV_ICMP_V15:
1021 dissect_batadv_icmp(tvb, pinfo, tree);
1022 break;
1023 case BATADV_UNICAST_TVLV_V15:
1024 dissect_batadv_unicast_tvlv(tvb, pinfo, tree);
1025 break;
1026 default:
1027 /* dunno */
1029 tvbuff_t *next_tvb;
1030 int length_remaining;
1032 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_???");
1034 length_remaining = tvb_reported_length_remaining(tvb, 0);
1035 if (length_remaining > 0) {
1036 next_tvb = tvb_new_subset_remaining(tvb, 0);
1037 call_data_dissector(next_tvb, pinfo, tree);
1039 break;
1044 static void dissect_batadv_batman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1046 uint8_t version;
1047 int offset = 0;
1049 /* set protocol name */
1050 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_BATMAN");
1052 version = tvb_get_uint8(tvb, 1);
1053 switch (version) {
1054 case 5:
1055 case 6:
1056 while (offset != -1 && tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V5_SIZE) {
1057 offset = dissect_batadv_batman_v5(tvb, offset, pinfo, tree);
1059 break;
1060 case 7:
1061 case 8:
1062 while (offset != -1 && tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V7_SIZE) {
1063 offset = dissect_batadv_batman_v7(tvb, offset, pinfo, tree);
1065 break;
1066 case 9:
1067 while (offset != -1 && tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V9_SIZE) {
1068 offset = dissect_batadv_batman_v9(tvb, offset, pinfo, tree);
1070 break;
1071 case 11:
1072 case 13:
1073 while (offset != -1 && tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V11_SIZE) {
1074 offset = dissect_batadv_batman_v11(tvb, offset, pinfo, tree);
1076 break;
1077 case 10:
1078 case 12:
1079 while (offset != -1 && tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V10_SIZE) {
1080 offset = dissect_batadv_batman_v10(tvb, offset, pinfo, tree);
1082 break;
1083 case 14:
1084 while (offset != -1 && tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V14_SIZE) {
1085 offset = dissect_batadv_batman_v14(tvb, offset, pinfo, tree);
1087 break;
1088 default:
1089 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
1090 call_data_dissector(tvb, pinfo, tree);
1091 break;
1095 static void dissect_batadv_gwflags(tvbuff_t *tvb, uint8_t gwflags, int offset, proto_item *tgw)
1097 proto_tree *gwflags_tree;
1098 uint8_t s = (gwflags & 0x80) >> 7;
1099 uint8_t downbits = (gwflags & 0x78) >> 3;
1100 uint8_t upbits = (gwflags & 0x07);
1101 unsigned down, up;
1103 if (gwflags == 0) {
1104 down = 0;
1105 up = 0;
1106 } else {
1107 down = 32 * (s + 2) * (1 << downbits);
1108 up = ((upbits + 1) * down) / 8;
1111 gwflags_tree = proto_item_add_subtree(tgw, ett_batadv_batman_gwflags);
1112 proto_tree_add_uint(gwflags_tree, hf_batadv_batman_gwflags_dl_speed, tvb, offset, 1, down);
1113 proto_tree_add_uint(gwflags_tree, hf_batadv_batman_gwflags_ul_speed, tvb, offset, 1, up);
1116 static int dissect_batadv_batman_v5(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
1118 proto_item *ti, *tgw;
1119 proto_tree *batadv_batman_tree;
1120 uint8_t type;
1121 struct batman_packet_v5 *batman_packeth;
1122 int i;
1124 tvbuff_t *next_tvb;
1126 batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v5);
1128 type = tvb_get_uint8(tvb, offset+0);
1129 batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1131 /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1132 if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1133 return -1;
1136 batman_packeth->flags = tvb_get_uint8(tvb, offset+2);
1137 batman_packeth->ttl = tvb_get_uint8(tvb, offset+3);
1138 batman_packeth->gwflags = tvb_get_uint8(tvb, offset+4);
1139 batman_packeth->tq = tvb_get_uint8(tvb, offset+5);
1140 batman_packeth->seqno = tvb_get_ntohs(tvb, offset+6);
1141 set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+8);
1142 copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1143 copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1144 set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+14);
1146 batman_packeth->num_tt = tvb_get_uint8(tvb, offset+20);
1147 batman_packeth->pad = tvb_get_uint8(tvb, offset+21);
1149 /* Set info column */
1150 col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1152 /* Set tree info */
1153 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V5_SIZE,
1154 "B.A.T.M.A.N., Orig: %s",
1155 address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1156 batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1158 /* items */
1159 proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1160 "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1161 offset += 1;
1163 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1164 offset += 1;
1166 proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1167 ett_batadv_batman_flags, batman_v5_flags, ENC_BIG_ENDIAN);
1168 offset += 1;
1170 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1171 offset += 1;
1173 tgw = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_gwflags, tvb, offset, 1, ENC_BIG_ENDIAN);
1174 dissect_batadv_gwflags(tvb, batman_packeth->gwflags, offset, tgw);
1175 offset += 1;
1177 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1178 offset += 1;
1180 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
1181 offset += 2;
1183 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1184 offset += 6;
1186 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1187 offset += 6;
1189 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_tt, tvb, offset, 1, ENC_BIG_ENDIAN);
1190 offset += 1;
1192 /* Skip 1 byte of padding. */
1193 offset += 1;
1195 tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1197 for (i = 0; i < batman_packeth->num_tt; i++) {
1198 next_tvb = tvb_new_subset_length(tvb, offset, 6);
1200 if (have_tap_listener(batadv_follow_tap)) {
1201 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1204 dissect_batadv_tt(next_tvb, pinfo, batadv_batman_tree);
1205 offset += 6;
1208 return offset;
1211 static int dissect_batadv_batman_v7(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
1213 proto_tree *batadv_batman_tree;
1214 proto_item *ti;
1215 uint8_t type;
1216 struct batman_packet_v7 *batman_packeth;
1217 int i;
1219 tvbuff_t *next_tvb;
1221 batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v7);
1223 type = tvb_get_uint8(tvb, offset+0);
1224 batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1226 /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1227 if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1228 return -1;
1231 batman_packeth->flags = tvb_get_uint8(tvb, offset+2);
1232 batman_packeth->tq = tvb_get_uint8(tvb, offset+3);
1233 batman_packeth->seqno = tvb_get_ntohs(tvb, offset+4);
1234 set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+6);
1235 copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1236 copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1237 set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+12);
1238 batman_packeth->ttl = tvb_get_uint8(tvb, offset+18);
1239 batman_packeth->num_tt = tvb_get_uint8(tvb, offset+19);
1241 /* Set info column */
1242 col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1244 /* Set tree info */
1245 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V7_SIZE,
1246 "B.A.T.M.A.N., Orig: %s",
1247 address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1248 batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1250 /* items */
1251 proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1252 "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1253 offset += 1;
1255 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1256 offset += 1;
1258 proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1259 ett_batadv_batman_flags, batman_v5_flags, ENC_BIG_ENDIAN);
1260 offset += 1;
1262 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1263 offset += 1;
1265 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
1266 offset += 2;
1268 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1269 offset += 6;
1271 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1272 offset += 6;
1274 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1275 offset += 1;
1277 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_tt, tvb, offset, 1, ENC_BIG_ENDIAN);
1278 offset += 1;
1280 tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1282 for (i = 0; i < batman_packeth->num_tt; i++) {
1283 next_tvb = tvb_new_subset_length(tvb, offset, 6);
1285 if (have_tap_listener(batadv_follow_tap)) {
1286 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1289 dissect_batadv_tt(next_tvb, pinfo, batadv_batman_tree);
1290 offset += 6;
1293 return offset;
1296 static int dissect_batadv_batman_v9(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
1298 proto_item *ti, *tgw;
1299 proto_tree *batadv_batman_tree;
1300 uint8_t type;
1301 struct batman_packet_v9 *batman_packeth;
1302 int i;
1304 tvbuff_t *next_tvb;
1306 batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v9);
1308 type = tvb_get_uint8(tvb, offset+0);
1309 batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1311 /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1312 if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1313 return -1;
1316 batman_packeth->flags = tvb_get_uint8(tvb, offset+2);
1317 batman_packeth->tq = tvb_get_uint8(tvb, offset+3);
1318 batman_packeth->seqno = tvb_get_ntohs(tvb, offset+4);
1319 set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+6);
1320 copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1321 copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1322 set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+12);
1323 batman_packeth->ttl = tvb_get_uint8(tvb, offset+18);
1324 batman_packeth->num_tt = tvb_get_uint8(tvb, offset+19);
1325 batman_packeth->gwflags = tvb_get_uint8(tvb, offset+20);
1327 /* Set info column */
1328 col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1330 /* Set tree info */
1331 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V9_SIZE,
1332 "B.A.T.M.A.N., Orig: %s",
1333 address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1334 batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1336 /* items */
1337 proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1338 "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1339 offset += 1;
1341 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1342 offset += 1;
1344 proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1345 ett_batadv_batman_flags, batman_v9_flags, ENC_BIG_ENDIAN);
1346 offset += 1;
1348 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1349 offset += 1;
1351 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
1352 offset += 2;
1354 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1355 offset += 6;
1357 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1358 offset += 6;
1360 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1361 offset += 1;
1363 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_tt, tvb, offset, 1, ENC_BIG_ENDIAN);
1364 offset += 1;
1366 tgw = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_gwflags, tvb, offset, 1, ENC_BIG_ENDIAN);
1367 dissect_batadv_gwflags(tvb, batman_packeth->gwflags, offset, tgw);
1368 offset += 1;
1370 /* Skip 1 byte of padding. */
1371 offset += 1;
1373 tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1375 for (i = 0; i < batman_packeth->num_tt; i++) {
1376 next_tvb = tvb_new_subset_length(tvb, offset, 6);
1378 if (have_tap_listener(batadv_follow_tap)) {
1379 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1382 dissect_batadv_tt(next_tvb, pinfo, batadv_batman_tree);
1383 offset += 6;
1386 return offset;
1389 static int dissect_batadv_batman_v10(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
1391 proto_item *ti, *tgw;
1392 proto_tree *batadv_batman_tree;
1393 uint8_t type;
1394 struct batman_packet_v10 *batman_packeth;
1395 int i;
1397 tvbuff_t *next_tvb;
1399 batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v10);
1401 type = tvb_get_uint8(tvb, offset+0);
1402 batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1404 /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1405 if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1406 return -1;
1409 batman_packeth->flags = tvb_get_uint8(tvb, offset+2);
1410 batman_packeth->tq = tvb_get_uint8(tvb, offset+3);
1411 batman_packeth->seqno = tvb_get_ntohl(tvb, offset+4);
1412 set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+8);
1413 copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1414 copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1415 set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+14);
1416 batman_packeth->ttl = tvb_get_uint8(tvb, offset+20);
1417 batman_packeth->num_tt = tvb_get_uint8(tvb, offset+21);
1418 batman_packeth->gwflags = tvb_get_uint8(tvb, offset+22);
1420 /* Set info column */
1421 col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1423 /* Set tree info */
1424 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V10_SIZE,
1425 "B.A.T.M.A.N., Orig: %s",
1426 address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1427 batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1429 /* items */
1430 proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1431 "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1432 offset += 1;
1434 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1435 offset += 1;
1437 proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1438 ett_batadv_batman_flags, batman_v9_flags, ENC_BIG_ENDIAN);
1439 offset += 1;
1441 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1442 offset += 1;
1444 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
1445 offset += 4;
1447 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1448 offset += 6;
1450 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1451 offset += 6;
1453 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1454 offset += 1;
1456 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_tt, tvb, offset, 1, ENC_BIG_ENDIAN);
1457 offset += 1;
1459 tgw = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_gwflags, tvb, offset, 1, ENC_BIG_ENDIAN);
1460 dissect_batadv_gwflags(tvb, batman_packeth->gwflags, offset, tgw);
1461 offset += 1;
1463 /* Skip 1 byte of padding. */
1464 offset += 1;
1466 tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1468 for (i = 0; i < batman_packeth->num_tt; i++) {
1469 next_tvb = tvb_new_subset_length(tvb, offset, 6);
1471 if (have_tap_listener(batadv_follow_tap)) {
1472 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1475 dissect_batadv_tt(next_tvb, pinfo, batadv_batman_tree);
1476 offset += 6;
1479 return offset;
1482 static int dissect_batadv_batman_v11(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
1484 proto_tree *batadv_batman_tree;
1485 proto_item *ti;
1486 uint8_t type;
1487 struct batman_packet_v11 *batman_packeth;
1488 int i;
1490 tvbuff_t *next_tvb;
1492 batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v11);
1494 type = tvb_get_uint8(tvb, offset+0);
1495 batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1497 /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1498 if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1499 return -1;
1502 batman_packeth->flags = tvb_get_uint8(tvb, offset+2);
1503 batman_packeth->tq = tvb_get_uint8(tvb, offset+3);
1504 batman_packeth->seqno = tvb_get_ntohl(tvb, offset+4);
1505 set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+8);
1506 copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1507 copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1508 set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+14);
1509 batman_packeth->ttl = tvb_get_uint8(tvb, offset+20);
1510 batman_packeth->num_tt = tvb_get_uint8(tvb, offset+21);
1512 /* Set info column */
1513 col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1515 /* Set tree info */
1516 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V11_SIZE,
1517 "B.A.T.M.A.N., Orig: %s",
1518 address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1519 batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1521 /* items */
1522 proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1523 "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1524 offset += 1;
1526 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1527 offset += 1;
1529 proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1530 ett_batadv_batman_flags, batman_v9_flags, ENC_BIG_ENDIAN);
1531 offset += 1;
1533 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1534 offset += 1;
1536 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
1537 offset += 4;
1539 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1540 offset += 6;
1542 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1543 offset += 6;
1545 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1546 offset += 1;
1548 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_tt, tvb, offset, 1, ENC_BIG_ENDIAN);
1549 offset += 1;
1551 tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1553 for (i = 0; i < batman_packeth->num_tt; i++) {
1554 next_tvb = tvb_new_subset_length(tvb, offset, 6);
1556 if (have_tap_listener(batadv_follow_tap)) {
1557 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1560 dissect_batadv_tt(next_tvb, pinfo, batadv_batman_tree);
1561 offset += 6;
1564 return offset;
1567 static int dissect_batadv_batman_v14(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
1569 proto_item *ti, *tgw;
1570 proto_tree *batadv_batman_tree;
1571 uint8_t type;
1572 struct batman_packet_v14 *batman_packeth;
1573 int i;
1575 tvbuff_t *next_tvb;
1576 int length_remaining;
1578 batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v14);
1580 type = tvb_get_uint8(tvb, offset+0);
1581 batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1583 /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1584 if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1585 return -1;
1588 batman_packeth->ttl = tvb_get_uint8(tvb, offset+2);
1589 batman_packeth->flags = tvb_get_uint8(tvb, offset+3);
1590 batman_packeth->seqno = tvb_get_ntohl(tvb, offset+4);
1591 set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+8);
1592 copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1593 copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1594 set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+14);
1595 batman_packeth->gw_flags = tvb_get_uint8(tvb, offset+20);
1596 batman_packeth->tq = tvb_get_uint8(tvb, offset+21);
1597 batman_packeth->tt_num_changes = tvb_get_uint8(tvb, offset+22);
1598 batman_packeth->ttvn = tvb_get_uint8(tvb, offset+23);
1599 batman_packeth->tt_crc = tvb_get_ntohs(tvb, offset+24);
1601 /* Set info column */
1602 col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1604 /* Set tree info */
1605 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V14_SIZE,
1606 "B.A.T.M.A.N., Orig: %s",
1607 address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1608 batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1610 /* items */
1611 proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1612 "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1613 offset += 1;
1615 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1616 offset += 1;
1618 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1619 offset += 1;
1621 proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1622 ett_batadv_batman_flags, batman_v14_flags, ENC_BIG_ENDIAN);
1623 offset += 1;
1625 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
1626 offset += 4;
1628 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1629 offset += 6;
1631 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1632 offset += 6;
1634 tgw = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_gwflags, tvb, offset, 1, ENC_BIG_ENDIAN);
1635 dissect_batadv_gwflags(tvb, batman_packeth->gw_flags, offset, tgw);
1636 offset += 1;
1638 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1639 offset += 1;
1641 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tt_num_changes, tvb, offset, 1, ENC_BIG_ENDIAN);
1642 offset += 1;
1644 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttvn, tvb, offset, 1, ENC_BIG_ENDIAN);
1645 offset += 1;
1647 proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tt_crc, tvb, offset, 2, ENC_BIG_ENDIAN);
1648 offset += 2;
1650 tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1652 for (i = 0; i < batman_packeth->tt_num_changes; i++) {
1653 next_tvb = tvb_new_subset_length(tvb, offset, TT_ENTRY_V14_SIZE);
1655 if (have_tap_listener(batadv_follow_tap)) {
1656 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1659 dissect_tt_entry_v14(next_tvb, pinfo, batadv_batman_tree);
1660 offset += TT_ENTRY_V14_SIZE;
1663 length_remaining = tvb_reported_length_remaining(tvb, offset);
1664 if (length_remaining > 0) {
1665 next_tvb = tvb_new_subset_remaining(tvb, offset);
1666 call_data_dissector(next_tvb, pinfo, tree);
1669 return offset;
1672 static void dissect_batadv_iv_ogm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1674 uint8_t version;
1675 int offset = 0;
1677 /* set protocol name */
1678 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_IV_OGM");
1680 version = tvb_get_uint8(tvb, 1);
1681 switch (version) {
1682 case 15:
1683 while (offset != -1 &&
1684 tvb_reported_length_remaining(tvb, offset) >= IV_OGM_PACKET_V15_SIZE) {
1685 offset = dissect_batadv_iv_ogm_v15(tvb, offset, pinfo, tree);
1687 break;
1688 default:
1689 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
1690 call_data_dissector(tvb, pinfo, tree);
1691 break;
1695 static int dissect_batadv_iv_ogm_v15(tvbuff_t *tvb, int offset,
1696 packet_info *pinfo, proto_tree *tree)
1698 proto_tree *batadv_iv_ogm_tree;
1699 proto_item *ti;
1700 uint8_t type, version;
1701 struct iv_ogm_packet_v15 *iv_ogm_packeth;
1702 tvbuff_t *next_tvb;
1703 static int * const flags[] = {
1704 &hf_batadv_iv_ogm_flags_directlink,
1705 &hf_batadv_iv_ogm_flags_primaries_first_hop,
1706 &hf_batadv_iv_ogm_flags_not_best_next_hop,
1707 NULL
1710 type = tvb_get_uint8(tvb, offset+0);
1711 version = tvb_get_uint8(tvb, offset+1);
1713 /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1714 if (version == 0 || type != BATADV_IV_OGM_V15)
1715 return -1;
1717 iv_ogm_packeth = wmem_new(pinfo->pool, struct iv_ogm_packet_v15);
1719 /* Set info column */
1720 col_clear(pinfo->cinfo, COL_INFO);
1722 /* Set tree info */
1723 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
1724 tvb, offset,
1725 IV_OGM_PACKET_V15_SIZE,
1726 "B.A.T.M.A.N. IV OGM, Orig: %s",
1727 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, offset + 8));
1728 batadv_iv_ogm_tree = proto_item_add_subtree(ti, ett_batadv_iv_ogm);
1730 /* items */
1731 iv_ogm_packeth->packet_type = tvb_get_uint8(tvb, offset);
1732 proto_tree_add_uint_format_value(batadv_iv_ogm_tree,
1733 hf_batadv_packet_type,
1734 tvb, offset, 1, BATADV_IV_OGM_V15,
1735 "%s (%u)", "BATADV_IV_OGM",
1736 BATADV_IV_OGM_V15);
1737 offset += 1;
1739 iv_ogm_packeth->version = tvb_get_uint8(tvb, offset);
1740 proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_version, tvb,
1741 offset, 1, ENC_BIG_ENDIAN);
1742 offset += 1;
1744 iv_ogm_packeth->ttl = tvb_get_uint8(tvb, offset);
1745 proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_ttl, tvb,
1746 offset, 1, ENC_BIG_ENDIAN);
1747 offset += 1;
1749 iv_ogm_packeth->flags = tvb_get_uint8(tvb, offset);
1750 proto_tree_add_bitmask(batadv_iv_ogm_tree, tvb, offset,
1751 hf_batadv_iv_ogm_flags, ett_batadv_iv_ogm_flags,
1752 flags, ENC_NA);
1753 offset += 1;
1755 proto_tree_add_item_ret_uint(batadv_iv_ogm_tree, hf_batadv_iv_ogm_seqno,
1756 tvb, offset, 4, ENC_BIG_ENDIAN,
1757 &iv_ogm_packeth->seqno);
1758 col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", iv_ogm_packeth->seqno);
1759 offset += 4;
1761 set_address_tvb(&iv_ogm_packeth->orig, AT_ETHER, 6, tvb, offset);
1762 set_address_tvb(&pinfo->dl_src, AT_ETHER, 6, tvb, offset);
1763 set_address_tvb(&pinfo->src, AT_ETHER, 6, tvb, offset);
1764 proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_orig, tvb,
1765 offset, 6, ENC_NA);
1766 offset += 6;
1768 set_address_tvb(&iv_ogm_packeth->prev_sender, AT_ETHER, 6, tvb, offset);
1769 proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_prev_sender, tvb,
1770 offset, 6, ENC_NA);
1771 offset += 6;
1773 /* Skip 1 byte of padding. */
1774 iv_ogm_packeth->reserved = tvb_get_uint8(tvb, offset);
1775 offset += 1;
1777 iv_ogm_packeth->tq = tvb_get_uint8(tvb, offset);
1778 proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_tq, tvb,
1779 offset, 1, ENC_BIG_ENDIAN);
1780 offset += 1;
1782 iv_ogm_packeth->tvlv_len = tvb_get_ntohs(tvb, offset);
1783 proto_item_set_len(ti, IV_OGM_PACKET_V15_SIZE + iv_ogm_packeth->tvlv_len);
1784 proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_tvlv_len, tvb,
1785 offset, 2, ENC_BIG_ENDIAN);
1786 offset += 2;
1788 tap_queue_packet(batadv_tap, pinfo, iv_ogm_packeth);
1790 if (iv_ogm_packeth->tvlv_len > 0) {
1791 next_tvb = tvb_new_subset_length(tvb, offset,
1792 iv_ogm_packeth->tvlv_len);
1794 if (have_tap_listener(batadv_follow_tap)) {
1795 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1798 dissect_batadv_tvlv_v15(next_tvb, pinfo, batadv_iv_ogm_tree);
1799 offset += iv_ogm_packeth->tvlv_len;
1802 return offset;
1805 static void dissect_batadv_tt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1807 proto_tree *batadv_batman_tt_tree;
1808 proto_item *ti;
1810 /* Set tree info */
1811 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, 6,
1812 "B.A.T.M.A.N. TT: %s",
1813 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 0));
1814 batadv_batman_tt_tree = proto_item_add_subtree(ti, ett_batadv_batman_tt);
1816 proto_tree_add_item(batadv_batman_tt_tree, hf_batadv_batman_tt, tvb, 0, 6, ENC_NA);
1819 static void dissect_batadv_bcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1821 uint8_t version;
1823 /* set protocol name */
1824 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_BCAST");
1826 version = tvb_get_uint8(tvb, 1);
1827 switch (version) {
1828 case 6:
1829 case 7:
1830 case 8:
1831 case 9:
1832 dissect_batadv_bcast_v6(tvb, pinfo, tree);
1833 break;
1834 case 10:
1835 case 11:
1836 case 12:
1837 case 13:
1838 dissect_batadv_bcast_v10(tvb, pinfo, tree);
1839 break;
1840 case 14:
1841 case 15:
1842 dissect_batadv_bcast_v14(tvb, pinfo, tree);
1843 break;
1844 default:
1845 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
1846 call_data_dissector(tvb, pinfo, tree);
1847 break;
1851 static void dissect_batadv_bcast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1853 struct bcast_packet_v6 *bcast_packeth;
1855 tvbuff_t *next_tvb;
1856 int length_remaining;
1857 int offset = 0;
1858 proto_tree *batadv_bcast_tree;
1859 proto_item *ti;
1861 bcast_packeth = wmem_new(pinfo->pool, struct bcast_packet_v6);
1863 bcast_packeth->version = tvb_get_uint8(tvb, 1);
1864 set_address_tvb(&bcast_packeth->orig, AT_ETHER, 6, tvb, 2);
1865 copy_address_shallow(&pinfo->dl_src, &bcast_packeth->orig);
1866 copy_address_shallow(&pinfo->src, &bcast_packeth->orig);
1867 bcast_packeth->seqno = tvb_get_ntohs(tvb, 8);
1869 /* Set info column */
1870 col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", bcast_packeth->seqno);
1872 /* Set tree info */
1873 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, BCAST_PACKET_V6_SIZE,
1874 "B.A.T.M.A.N. Bcast, Orig: %s",
1875 address_with_resolution_to_str(pinfo->pool, &bcast_packeth->orig));
1876 batadv_bcast_tree = proto_item_add_subtree(ti, ett_batadv_bcast);
1878 /* items */
1879 proto_tree_add_uint_format(batadv_bcast_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_BCAST_V5,
1880 "Packet Type: %s (%u)", "BATADV_BCAST", BATADV_BCAST_V5);
1881 offset += 1;
1883 proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1884 offset += 1;
1886 proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_orig, tvb, offset, 6, ENC_NA);
1887 offset += 6;
1889 proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
1890 offset += 2;
1892 tap_queue_packet(batadv_tap, pinfo, bcast_packeth);
1894 length_remaining = tvb_reported_length_remaining(tvb, offset);
1895 if (length_remaining > 0) {
1896 next_tvb = tvb_new_subset_remaining(tvb, offset);
1897 if (have_tap_listener(batadv_follow_tap)) {
1898 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1901 call_dissector(eth_handle, next_tvb, pinfo, tree);
1905 static void dissect_batadv_bcast_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1907 struct bcast_packet_v10 *bcast_packeth;
1909 tvbuff_t *next_tvb;
1910 int length_remaining;
1911 int offset = 0;
1912 proto_tree *batadv_bcast_tree;
1913 proto_item *ti;
1915 bcast_packeth = wmem_new(pinfo->pool, struct bcast_packet_v10);
1917 bcast_packeth->version = tvb_get_uint8(tvb, 1);
1918 set_address_tvb(&bcast_packeth->orig, AT_ETHER, 6, tvb, 2);
1919 copy_address_shallow(&pinfo->dl_src, &bcast_packeth->orig);
1920 copy_address_shallow(&pinfo->src, &bcast_packeth->orig);
1921 bcast_packeth->ttl = tvb_get_uint8(tvb, 8);
1922 bcast_packeth->seqno = tvb_get_ntohl(tvb, 9);
1924 /* Set info column */
1925 col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", bcast_packeth->seqno);
1927 /* Set tree info */
1928 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, BCAST_PACKET_V10_SIZE,
1929 "B.A.T.M.A.N. Bcast, Orig: %s",
1930 address_with_resolution_to_str(pinfo->pool, &bcast_packeth->orig));
1931 batadv_bcast_tree = proto_item_add_subtree(ti, ett_batadv_bcast);
1933 /* items */
1934 proto_tree_add_uint_format(batadv_bcast_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_BCAST_V5,
1935 "Packet Type: %s (%u)", "BATADV_BCAST", BATADV_BCAST_V5);
1936 offset += 1;
1938 proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1939 offset += 1;
1941 proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_orig, tvb, offset, 6, ENC_NA);
1942 offset += 6;
1944 proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1945 offset += 1;
1947 proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
1948 offset += 4;
1950 tap_queue_packet(batadv_tap, pinfo, bcast_packeth);
1952 length_remaining = tvb_reported_length_remaining(tvb, offset);
1953 if (length_remaining > 0) {
1954 next_tvb = tvb_new_subset_remaining(tvb, offset);
1956 if (have_tap_listener(batadv_follow_tap)) {
1957 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1960 call_dissector(eth_handle, next_tvb, pinfo, tree);
1964 static void dissect_batadv_bcast_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1966 struct bcast_packet_v14 *bcast_packeth;
1968 tvbuff_t *next_tvb;
1969 int length_remaining;
1970 int offset = 0;
1971 proto_tree *batadv_bcast_tree;
1972 proto_item *ti;
1974 bcast_packeth = wmem_new(pinfo->pool, struct bcast_packet_v14);
1976 bcast_packeth->packet_type = tvb_get_uint8(tvb, 0);
1977 bcast_packeth->version = tvb_get_uint8(tvb, 1);
1978 bcast_packeth->ttl = tvb_get_uint8(tvb, 2);
1979 bcast_packeth->reserved = tvb_get_uint8(tvb, 3);
1980 bcast_packeth->seqno = tvb_get_ntohl(tvb, 4);
1981 set_address_tvb(&bcast_packeth->orig, AT_ETHER, 6, tvb, 8);
1982 copy_address_shallow(&pinfo->dl_src, &bcast_packeth->orig);
1983 copy_address_shallow(&pinfo->src, &bcast_packeth->orig);
1985 /* Set info column */
1986 col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", bcast_packeth->seqno);
1988 /* Set tree info */
1989 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, BCAST_PACKET_V14_SIZE,
1990 "B.A.T.M.A.N. Bcast, Orig: %s",
1991 address_with_resolution_to_str(pinfo->pool, &bcast_packeth->orig));
1992 batadv_bcast_tree = proto_item_add_subtree(ti, ett_batadv_bcast);
1994 /* items */
1995 proto_tree_add_uint_format_value(batadv_bcast_tree,
1996 hf_batadv_packet_type, tvb, offset, 1,
1997 bcast_packeth->packet_type,
1998 "%s (%u)", "BATADV_BCAST",
1999 bcast_packeth->packet_type);
2000 offset += 1;
2002 proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2003 offset += 1;
2005 proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2006 offset += 1;
2008 /* Skip 1 byte of padding. */
2009 offset += 1;
2011 proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
2012 offset += 4;
2014 proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_orig, tvb, offset, 6, ENC_NA);
2015 offset += 6;
2017 tap_queue_packet(batadv_tap, pinfo, bcast_packeth);
2019 length_remaining = tvb_reported_length_remaining(tvb, offset);
2020 if (length_remaining > 0) {
2021 next_tvb = tvb_new_subset_remaining(tvb, offset);
2023 if (have_tap_listener(batadv_follow_tap)) {
2024 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
2027 call_dissector(eth_handle, next_tvb, pinfo, tree);
2031 static void dissect_batadv_icmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2033 uint8_t version;
2035 /* set protocol name */
2036 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_ICMP");
2038 version = tvb_get_uint8(tvb, 1);
2039 switch (version) {
2040 case 6:
2041 dissect_batadv_icmp_v6(tvb, pinfo, tree);
2042 break;
2043 case 7:
2044 case 8:
2045 case 9:
2046 case 10:
2047 case 11:
2048 case 12:
2049 case 13:
2050 dissect_batadv_icmp_v7(tvb, pinfo, tree);
2051 break;
2052 case 14:
2053 dissect_batadv_icmp_v14(tvb, pinfo, tree);
2054 break;
2055 case 15:
2056 dissect_batadv_icmp_v15(tvb, pinfo, tree);
2057 break;
2058 default:
2059 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
2060 call_data_dissector(tvb, pinfo, tree);
2061 break;
2065 static void dissect_batadv_icmp_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2067 struct icmp_packet_v6 *icmp_packeth;
2068 tvbuff_t *next_tvb;
2069 int length_remaining;
2070 int offset = 0;
2071 proto_tree *batadv_icmp_tree;
2072 proto_item *ti;
2074 icmp_packeth = wmem_new(pinfo->pool, struct icmp_packet_v6);
2076 icmp_packeth->version = tvb_get_uint8(tvb, 1);
2077 icmp_packeth->msg_type = tvb_get_uint8(tvb, 2);
2078 set_address_tvb(&icmp_packeth->dst, AT_ETHER, 6, tvb, 3);
2079 set_address_tvb(&icmp_packeth->orig, AT_ETHER, 6, tvb, 9);
2081 copy_address_shallow(&pinfo->dl_src, &icmp_packeth->orig);
2082 copy_address_shallow(&pinfo->src, &icmp_packeth->orig);
2083 copy_address_shallow(&pinfo->dl_dst, &icmp_packeth->dst);
2084 copy_address_shallow(&pinfo->dst, &icmp_packeth->dst);
2086 icmp_packeth->ttl = tvb_get_uint8(tvb, 15);
2087 icmp_packeth->uid = tvb_get_uint8(tvb, 16);
2088 icmp_packeth->seqno = tvb_get_ntohs(tvb, 17);
2090 /* Set info column */
2091 col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
2092 val_to_str(icmp_packeth->msg_type, icmp_packettypenames, "Unknown (0x%02x)"),
2093 icmp_packeth->seqno);
2094 /* Set tree info */
2095 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, ICMP_PACKET_V6_SIZE,
2096 "B.A.T.M.A.N. ICMP, Orig: %s, Dst: %s",
2097 address_with_resolution_to_str(pinfo->pool, &icmp_packeth->orig),
2098 address_with_resolution_to_str(pinfo->pool, &icmp_packeth->dst));
2099 batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
2101 /* items */
2102 proto_tree_add_uint_format(batadv_icmp_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_ICMP_V5,
2103 "Packet Type: %s (%u)", "BATADV_ICMP", BATADV_ICMP_V5);
2104 offset += 1;
2106 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2107 offset += 1;
2109 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2110 offset += 1;
2112 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset, 6, ENC_NA);
2113 offset += 6;
2115 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset, 6, ENC_NA);
2116 offset += 6;
2118 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2119 offset += 1;
2121 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset, 1, ENC_BIG_ENDIAN);
2122 offset += 1;
2124 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
2125 offset += 2;
2127 tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
2129 length_remaining = tvb_reported_length_remaining(tvb, offset);
2130 if (length_remaining > 0) {
2131 next_tvb = tvb_new_subset_remaining(tvb, offset);
2133 call_data_dissector(next_tvb, pinfo, tree);
2137 static void
2138 dissect_batadv_icmp_rr(packet_info *pinfo, proto_tree *batadv_icmp_tree, tvbuff_t *tvb, int offset)
2140 proto_tree *field_tree;
2141 int ptr, i;
2143 ptr = tvb_get_uint8(tvb, offset);
2144 if (ptr < 1 || ptr > BAT_RR_LEN)
2145 return;
2147 field_tree = proto_tree_add_subtree(batadv_icmp_tree, tvb, offset, 1+ 6 * BAT_RR_LEN,
2148 ett_batadv_icmp_rr, NULL, "ICMP RR");
2149 proto_tree_add_item(field_tree, hf_batadv_icmp_rr_pointer, tvb, offset, 1, ENC_BIG_ENDIAN);
2151 ptr--;
2152 offset++;
2153 for (i = 0; i < BAT_RR_LEN; i++) {
2154 proto_tree_add_ether_format(field_tree, hf_batadv_icmp_rr_ether, tvb, offset, 6, tvb_get_ptr(tvb, offset, 6),
2155 "%s%s", (i > ptr) ? "-" : tvb_ether_to_str(pinfo->pool, tvb, offset),
2156 (i == ptr) ? " <- (current)" : "");
2158 offset += 6;
2162 static void
2163 dissect_batadv_icmp_rr_v15(packet_info *pinfo, proto_tree *batadv_icmp_tree, tvbuff_t *tvb,
2164 int offset, int ptr)
2166 proto_tree *field_tree;
2167 int i;
2169 field_tree = proto_tree_add_subtree(batadv_icmp_tree, tvb, offset,
2170 6 * BAT_RR_LEN,
2171 ett_batadv_icmp_rr, NULL,
2172 "ICMP RR");
2173 ptr--;
2175 for (i = 0; i < BAT_RR_LEN; i++) {
2176 proto_tree_add_ether_format(field_tree, hf_batadv_icmp_rr_ether,
2177 tvb, offset, 6,
2178 tvb_get_ptr(tvb, offset, 6),
2179 "%s%s",
2180 (i > ptr) ? "-" : tvb_ether_to_str(pinfo->pool, tvb, offset),
2181 (i == ptr) ? " <- (current)" : "");
2183 offset += 6;
2187 static void dissect_batadv_icmp_v7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2189 struct icmp_packet_v7 *icmp_packeth;
2190 proto_item *ti;
2191 proto_tree *batadv_icmp_tree;
2193 tvbuff_t *next_tvb;
2194 int length_remaining;
2195 int offset = 0;
2197 icmp_packeth = wmem_new(pinfo->pool, struct icmp_packet_v7);
2199 icmp_packeth->version = tvb_get_uint8(tvb, 1);
2200 icmp_packeth->msg_type = tvb_get_uint8(tvb, 2);
2201 icmp_packeth->ttl = tvb_get_uint8(tvb, 3);
2202 set_address_tvb(&icmp_packeth->dst, AT_ETHER, 6, tvb, 4);
2203 set_address_tvb(&icmp_packeth->orig, AT_ETHER, 6, tvb, 10);
2205 copy_address_shallow(&pinfo->dl_src, &icmp_packeth->orig);
2206 copy_address_shallow(&pinfo->src, &icmp_packeth->orig);
2207 copy_address_shallow(&pinfo->dl_dst, &icmp_packeth->dst);
2208 copy_address_shallow(&pinfo->dst, &icmp_packeth->dst);
2210 icmp_packeth->seqno = tvb_get_ntohs(tvb, 16);
2211 icmp_packeth->uid = tvb_get_uint8(tvb, 17);
2213 /* Set info column */
2214 col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
2215 val_to_str(icmp_packeth->msg_type, icmp_packettypenames, "Unknown (0x%02x)"),
2216 icmp_packeth->seqno);
2218 /* Set tree info */
2219 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, ICMP_PACKET_V7_SIZE,
2220 "B.A.T.M.A.N. ICMP, Orig: %s, Dst: %s",
2221 address_with_resolution_to_str(pinfo->pool, &icmp_packeth->orig),
2222 address_with_resolution_to_str(pinfo->pool, &icmp_packeth->dst));
2223 batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
2225 /* items */
2226 proto_tree_add_uint_format(batadv_icmp_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_ICMP_V5,
2227 "Packet Type: %s (%u)", "BATADV_ICMP", BATADV_ICMP_V5);
2228 offset += 1;
2230 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2231 offset += 1;
2233 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2234 offset += 1;
2236 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2237 offset += 1;
2239 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset, 6, ENC_NA);
2240 offset += 6;
2242 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset, 6, ENC_NA);
2243 offset += 6;
2245 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
2246 offset += 2;
2248 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset, 1, ENC_BIG_ENDIAN);
2249 offset += 1;
2251 /* rr data available? */
2252 length_remaining = tvb_reported_length_remaining(tvb, offset);
2253 if (length_remaining >= 1 + BAT_RR_LEN * 6) {
2254 dissect_batadv_icmp_rr(pinfo, batadv_icmp_tree, tvb, offset);
2255 offset += 1 + BAT_RR_LEN * 6;
2258 tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
2260 length_remaining = tvb_reported_length_remaining(tvb, offset);
2261 if (length_remaining > 0) {
2262 next_tvb = tvb_new_subset_remaining(tvb, offset);
2263 call_data_dissector(next_tvb, pinfo, tree);
2267 static void dissect_batadv_icmp_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2269 struct icmp_packet_v14 *icmp_packeth;
2270 proto_item *ti;
2271 proto_tree *batadv_icmp_tree;
2273 tvbuff_t *next_tvb;
2274 int length_remaining;
2275 int offset = 0;
2277 icmp_packeth = wmem_new(pinfo->pool, struct icmp_packet_v14);
2279 icmp_packeth->version = tvb_get_uint8(tvb, 1);
2280 icmp_packeth->ttl = tvb_get_uint8(tvb, 2);
2281 icmp_packeth->msg_type = tvb_get_uint8(tvb, 3);
2282 set_address_tvb(&icmp_packeth->dst, AT_ETHER, 6, tvb, 4);
2283 set_address_tvb(&icmp_packeth->orig, AT_ETHER, 6, tvb, 10);
2285 copy_address_shallow(&pinfo->dl_src, &icmp_packeth->orig);
2286 copy_address_shallow(&pinfo->src, &icmp_packeth->orig);
2287 copy_address_shallow(&pinfo->dl_dst, &icmp_packeth->dst);
2288 copy_address_shallow(&pinfo->dst, &icmp_packeth->dst);
2290 icmp_packeth->seqno = tvb_get_ntohs(tvb, 16);
2291 icmp_packeth->uid = tvb_get_uint8(tvb, 17);
2292 icmp_packeth->reserved = tvb_get_uint8(tvb, 18);
2294 /* Set info column */
2295 col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
2296 val_to_str(icmp_packeth->msg_type, icmp_packettypenames, "Unknown (0x%02x)"),
2297 icmp_packeth->seqno);
2299 /* Set tree info */
2300 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, ICMP_PACKET_V14_SIZE,
2301 "B.A.T.M.A.N. ICMP, Orig: %s, Dst: %s",
2302 address_with_resolution_to_str(pinfo->pool, &icmp_packeth->orig),
2303 address_with_resolution_to_str(pinfo->pool, &icmp_packeth->dst));
2304 batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
2306 /* items */
2307 proto_tree_add_uint_format(batadv_icmp_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_ICMP_V5,
2308 "Packet Type: %s (%u)", "BATADV_ICMP", BATADV_ICMP_V5);
2309 offset += 1;
2311 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2312 offset += 1;
2314 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2315 offset += 1;
2317 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2318 offset += 1;
2320 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset, 6, ENC_NA);
2321 offset += 6;
2323 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset, 6, ENC_NA);
2324 offset += 6;
2326 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
2327 offset += 2;
2329 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset, 1, ENC_BIG_ENDIAN);
2330 offset += 1;
2332 /* Skip 1 byte of padding. */
2333 offset += 1;
2335 /* rr data available? */
2336 length_remaining = tvb_reported_length_remaining(tvb, offset);
2337 if (length_remaining >= 1 + BAT_RR_LEN * 6) {
2338 dissect_batadv_icmp_rr(pinfo, batadv_icmp_tree, tvb, offset);
2339 offset += 1 + BAT_RR_LEN * 6;
2342 tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
2344 length_remaining = tvb_reported_length_remaining(tvb, offset);
2345 if (length_remaining > 0) {
2346 next_tvb = tvb_new_subset_remaining(tvb, offset);
2347 call_data_dissector(next_tvb, pinfo, tree);
2351 static void dissect_batadv_icmp_tp_v15(tvbuff_t *tvb, packet_info *pinfo,
2352 proto_tree *tree)
2354 struct icmp_tp_packet_v15 *icmp_packeth;
2355 proto_item *ti;
2356 proto_tree *batadv_icmp_tree = NULL;
2358 tvbuff_t *next_tvb;
2359 int length_remaining;
2360 uint32_t msg_type;
2361 int offset = 0;
2363 icmp_packeth = wmem_new(pinfo->pool, struct icmp_tp_packet_v15);
2365 /* Set info column */
2366 col_clear(pinfo->cinfo, COL_INFO);
2368 /* Set tree info */
2369 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
2370 tvb, 0, ICMP_PACKET_V14_SIZE,
2371 "B.A.T.M.A.N. ICMP TP, Orig: %s, Dst: %s",
2372 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 10),
2373 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 4));
2374 batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
2376 /* items */
2377 icmp_packeth->packet_type = tvb_get_uint8(tvb, offset);
2378 proto_tree_add_uint_format_value(batadv_icmp_tree,
2379 hf_batadv_packet_type, tvb,
2380 offset, 1, icmp_packeth->packet_type,
2381 "%s (%u)", "BATADV_ICMP",
2382 icmp_packeth->packet_type);
2383 offset += 1;
2385 icmp_packeth->version = tvb_get_uint8(tvb, offset);
2386 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb,
2387 offset, 1, ENC_BIG_ENDIAN);
2388 offset += 1;
2390 icmp_packeth->ttl = tvb_get_uint8(tvb, offset);
2391 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset,
2392 1, ENC_BIG_ENDIAN);
2393 offset += 1;
2395 icmp_packeth->msg_type = tvb_get_uint8(tvb, offset);
2396 proto_tree_add_item_ret_uint(batadv_icmp_tree, hf_batadv_icmp_msg_type,
2397 tvb, offset, 1, ENC_BIG_ENDIAN, &msg_type);
2398 col_add_fstr(pinfo->cinfo, COL_INFO, "[%s]",
2399 val_to_str(msg_type, icmp_packettypenames,
2400 "Unknown (0x%02x)"));
2401 offset += 1;
2403 set_address_tvb(&icmp_packeth->dst, AT_ETHER, 6, tvb, offset);
2404 copy_address_shallow(&pinfo->dl_dst, &icmp_packeth->dst);
2405 copy_address_shallow(&pinfo->dst, &icmp_packeth->dst);
2407 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset,
2408 6, ENC_NA);
2409 offset += 6;
2411 set_address_tvb(&icmp_packeth->orig, AT_ETHER, 6, tvb, offset);
2412 copy_address_shallow(&pinfo->dl_src, &icmp_packeth->orig);
2413 copy_address_shallow(&pinfo->src, &icmp_packeth->orig);
2414 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset,
2415 6, ENC_NA);
2416 offset += 6;
2418 icmp_packeth->uid = tvb_get_uint8(tvb, offset);
2419 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset,
2420 1, ENC_BIG_ENDIAN);
2421 offset += 1;
2423 icmp_packeth->subtype = tvb_get_uint8(tvb, offset);
2424 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_tp_subtype, tvb,
2425 offset, 1, ENC_BIG_ENDIAN);
2426 offset += 1;
2428 icmp_packeth->session = tvb_get_ntohs(tvb, offset);
2429 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_tp_session, tvb,
2430 offset, 2, ENC_BIG_ENDIAN);
2431 offset += 2;
2433 proto_tree_add_item_ret_uint(batadv_icmp_tree, hf_batadv_icmp_tp_seqno,
2434 tvb, offset, 4, ENC_BIG_ENDIAN,
2435 &icmp_packeth->seqno);
2436 col_append_fstr(pinfo->cinfo, COL_INFO, " Seq=%u", icmp_packeth->seqno);
2437 offset += 4;
2439 icmp_packeth->timestamp = tvb_get_ntohl(tvb, offset);
2440 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_tp_timestamp, tvb,
2441 offset, 4, ENC_BIG_ENDIAN);
2442 offset += 4;
2444 tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
2446 length_remaining = tvb_reported_length_remaining(tvb, offset);
2447 if (length_remaining > 0) {
2448 next_tvb = tvb_new_subset_remaining(tvb, offset);
2449 call_data_dissector(next_tvb, pinfo, tree);
2453 static void dissect_batadv_icmp_simple_v15(tvbuff_t *tvb, packet_info *pinfo,
2454 proto_tree *tree)
2456 struct icmp_packet_v15 *icmp_packeth;
2457 proto_item *ti;
2458 proto_tree *batadv_icmp_tree;
2460 tvbuff_t *next_tvb;
2461 int length_remaining;
2462 uint32_t msg_type;
2463 int offset = 0;
2464 uint32_t seqno;
2466 icmp_packeth = wmem_new(pinfo->pool, struct icmp_packet_v15);
2468 /* Set info column */
2469 col_clear(pinfo->cinfo, COL_INFO);
2471 /* Set tree info */
2472 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
2473 tvb, 0, ICMP_PACKET_V14_SIZE,
2474 "B.A.T.M.A.N. ICMP, Orig: %s, Dst: %s",
2475 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 10),
2476 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 4));
2477 batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
2479 /* items */
2480 icmp_packeth->packet_type = tvb_get_uint8(tvb, offset);
2481 proto_tree_add_uint_format_value(batadv_icmp_tree,
2482 hf_batadv_packet_type, tvb,
2483 offset, 1, icmp_packeth->packet_type,
2484 "%s (%u)", "BATADV_ICMP",
2485 icmp_packeth->packet_type);
2486 offset += 1;
2488 icmp_packeth->version = tvb_get_uint8(tvb, offset);
2489 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb,
2490 offset, 1, ENC_BIG_ENDIAN);
2491 offset += 1;
2493 icmp_packeth->ttl = tvb_get_uint8(tvb, offset);
2494 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset,
2495 1, ENC_BIG_ENDIAN);
2496 offset += 1;
2498 icmp_packeth->msg_type = tvb_get_uint8(tvb, offset);
2499 proto_tree_add_item_ret_uint(batadv_icmp_tree, hf_batadv_icmp_msg_type,
2500 tvb, offset, 1, ENC_BIG_ENDIAN, &msg_type);
2501 col_add_fstr(pinfo->cinfo, COL_INFO, "[%s]",
2502 val_to_str(msg_type, icmp_packettypenames,
2503 "Unknown (0x%02x)"));
2504 offset += 1;
2506 set_address_tvb(&icmp_packeth->dst, AT_ETHER, 6, tvb, offset);
2507 copy_address_shallow(&pinfo->dl_dst, &icmp_packeth->dst);
2508 copy_address_shallow(&pinfo->dst, &icmp_packeth->dst);
2510 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset,
2511 6, ENC_NA);
2512 offset += 6;
2514 set_address_tvb(&icmp_packeth->orig, AT_ETHER, 6, tvb, offset);
2515 copy_address_shallow(&pinfo->dl_src, &icmp_packeth->orig);
2516 copy_address_shallow(&pinfo->src, &icmp_packeth->orig);
2517 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset,
2518 6, ENC_NA);
2519 offset += 6;
2521 icmp_packeth->uid = tvb_get_uint8(tvb, offset);
2522 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset,
2523 1, ENC_BIG_ENDIAN);
2524 offset += 1;
2526 icmp_packeth->rr_ptr = tvb_get_uint8(tvb, offset);
2527 proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_rr_pointer, tvb,
2528 offset, 1, ENC_BIG_ENDIAN);
2529 offset += 1;
2531 icmp_packeth->seqno = tvb_get_ntohs(tvb, offset);
2532 proto_tree_add_item_ret_uint(batadv_icmp_tree, hf_batadv_icmp_seqno,
2533 tvb, offset, 2, ENC_BIG_ENDIAN, &seqno);
2534 col_append_fstr(pinfo->cinfo, COL_INFO, " Seq=%u", seqno);
2535 offset += 2;
2537 /* rr data available? */
2538 length_remaining = tvb_reported_length_remaining(tvb, offset);
2539 if (length_remaining >= BAT_RR_LEN * 6) {
2540 dissect_batadv_icmp_rr_v15(pinfo, batadv_icmp_tree, tvb, offset,
2541 icmp_packeth->rr_ptr);
2542 offset += BAT_RR_LEN * 6;
2545 tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
2547 length_remaining = tvb_reported_length_remaining(tvb, offset);
2548 if (length_remaining > 0) {
2549 next_tvb = tvb_new_subset_remaining(tvb, offset);
2550 call_data_dissector(next_tvb, pinfo, tree);
2554 static void dissect_batadv_icmp_v15(tvbuff_t *tvb, packet_info *pinfo,
2555 proto_tree *tree)
2557 uint8_t msg_type;
2559 msg_type = tvb_get_uint8(tvb, 3);
2560 switch (msg_type) {
2561 case BATADV_TP:
2562 dissect_batadv_icmp_tp_v15(tvb, pinfo, tree);
2563 break;
2564 default:
2565 dissect_batadv_icmp_simple_v15(tvb, pinfo, tree);
2566 break;
2570 static void dissect_batadv_unicast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2572 uint8_t version;
2574 /* set protocol name */
2575 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_UNICAST");
2577 version = tvb_get_uint8(tvb, 1);
2578 switch (version) {
2579 case 6:
2580 case 7:
2581 case 8:
2582 case 9:
2583 case 10:
2584 case 11:
2585 case 12:
2586 case 13:
2587 dissect_batadv_unicast_v6(tvb, pinfo, tree);
2588 break;
2589 case 14:
2590 case 15:
2591 dissect_batadv_unicast_v14(tvb, pinfo, tree);
2592 break;
2593 default:
2594 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
2595 call_data_dissector(tvb, pinfo, tree);
2596 break;
2600 static void dissect_batadv_unicast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2602 struct unicast_packet_v6 *unicast_packeth;
2604 tvbuff_t *next_tvb;
2605 int length_remaining;
2606 int offset = 0;
2607 proto_tree *batadv_unicast_tree;
2608 proto_item *ti;
2610 unicast_packeth = wmem_new(pinfo->pool, struct unicast_packet_v6);
2612 unicast_packeth->version = tvb_get_uint8(tvb, 1);
2613 set_address_tvb(&unicast_packeth->dest, AT_ETHER, 6, tvb, 2);
2614 copy_address_shallow(&pinfo->dl_dst, &unicast_packeth->dest);
2615 copy_address_shallow(&pinfo->dst, &unicast_packeth->dest);
2617 unicast_packeth->ttl = tvb_get_uint8(tvb, 8);
2619 /* Set info column */
2620 col_clear(pinfo->cinfo, COL_INFO);
2622 /* Set tree info */
2623 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, UNICAST_PACKET_V6_SIZE,
2624 "B.A.T.M.A.N. Unicast, Dst: %s",
2625 address_with_resolution_to_str(pinfo->pool, &unicast_packeth->dest));
2626 batadv_unicast_tree = proto_item_add_subtree(ti, ett_batadv_unicast);
2628 /* items */
2629 proto_tree_add_uint_format(batadv_unicast_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_UNICAST_V5,
2630 "Packet Type: %s (%u)", "BATADV_UNICAST", BATADV_UNICAST_V5);
2631 offset += 1;
2633 proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2634 offset += 1;
2636 proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_dst, tvb, offset, 6, ENC_NA);
2637 offset += 6;
2639 proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2640 offset += 1;
2642 tap_queue_packet(batadv_tap, pinfo, unicast_packeth);
2644 length_remaining = tvb_reported_length_remaining(tvb, offset);
2645 if (length_remaining > 0) {
2646 next_tvb = tvb_new_subset_remaining(tvb, offset);
2648 if (have_tap_listener(batadv_follow_tap)) {
2649 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
2652 call_dissector(eth_handle, next_tvb, pinfo, tree);
2656 static void dissect_batadv_unicast_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2658 struct unicast_packet_v14 *unicast_packeth;
2660 tvbuff_t *next_tvb;
2661 int length_remaining;
2662 int offset = 0;
2663 proto_tree *batadv_unicast_tree;
2664 proto_item *ti;
2666 unicast_packeth = wmem_new(pinfo->pool, struct unicast_packet_v14);
2668 unicast_packeth->packet_type = tvb_get_uint8(tvb, 0);
2669 unicast_packeth->version = tvb_get_uint8(tvb, 1);
2670 unicast_packeth->ttl = tvb_get_uint8(tvb, 2);
2671 unicast_packeth->ttvn = tvb_get_uint8(tvb, 3);
2672 set_address_tvb(&unicast_packeth->dest, AT_ETHER, 6, tvb, 4);
2673 copy_address_shallow(&pinfo->dl_dst, &unicast_packeth->dest);
2674 copy_address_shallow(&pinfo->dst, &unicast_packeth->dest);
2676 /* Set info column */
2677 col_clear(pinfo->cinfo, COL_INFO);
2679 /* Set tree info */
2680 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, UNICAST_PACKET_V14_SIZE,
2681 "B.A.T.M.A.N. Unicast, Dst: %s",
2682 address_with_resolution_to_str(pinfo->pool, &unicast_packeth->dest));
2683 batadv_unicast_tree = proto_item_add_subtree(ti, ett_batadv_unicast);
2685 /* items */
2686 proto_tree_add_uint_format_value(batadv_unicast_tree,
2687 hf_batadv_packet_type, tvb, offset, 1,
2688 unicast_packeth->packet_type,
2689 "%s (%u)",
2690 "BATADV_UNICAST",
2691 unicast_packeth->packet_type);
2692 offset += 1;
2694 proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2695 offset += 1;
2697 proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2698 offset += 1;
2700 proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_ttvn, tvb, offset, 1, ENC_BIG_ENDIAN);
2701 offset += 1;
2703 proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_dst, tvb, offset, 6, ENC_NA);
2704 offset += 6;
2706 tap_queue_packet(batadv_tap, pinfo, unicast_packeth);
2708 length_remaining = tvb_reported_length_remaining(tvb, offset);
2709 if (length_remaining > 0) {
2710 next_tvb = tvb_new_subset_remaining(tvb, offset);
2712 if (have_tap_listener(batadv_follow_tap)) {
2713 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
2716 call_dissector(eth_handle, next_tvb, pinfo, tree);
2720 static void dissect_batadv_unicast_4addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2722 uint8_t version;
2724 /* set protocol name */
2725 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_UNICAST_4ADDR");
2727 version = tvb_get_uint8(tvb, 1);
2728 switch (version) {
2729 case 14:
2730 case 15:
2731 dissect_batadv_unicast_4addr_v14(tvb, pinfo, tree);
2732 break;
2733 default:
2734 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
2735 call_data_dissector(tvb, pinfo, tree);
2736 break;
2740 static void dissect_batadv_unicast_4addr_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2742 struct unicast_4addr_packet_v14 *unicast_4addr_packeth;
2744 tvbuff_t *next_tvb;
2745 int length_remaining;
2746 int offset = 0;
2747 proto_tree *batadv_unicast_4addr_tree;
2748 proto_item *ti;
2750 unicast_4addr_packeth = wmem_new(pinfo->pool, struct unicast_4addr_packet_v14);
2752 unicast_4addr_packeth->packet_type = tvb_get_uint8(tvb, 0);
2753 unicast_4addr_packeth->version = tvb_get_uint8(tvb, 1);
2754 unicast_4addr_packeth->ttl = tvb_get_uint8(tvb, 2);
2755 unicast_4addr_packeth->ttvn = tvb_get_uint8(tvb, 3);
2756 set_address_tvb(&unicast_4addr_packeth->dest, AT_ETHER, 6, tvb, 4);
2757 copy_address_shallow(&pinfo->dl_dst, &unicast_4addr_packeth->dest);
2758 copy_address_shallow(&pinfo->dst, &unicast_4addr_packeth->dest);
2760 set_address_tvb(&unicast_4addr_packeth->src, AT_ETHER, 6, tvb, 10);
2761 copy_address_shallow(&pinfo->dl_src, &unicast_4addr_packeth->src);
2762 copy_address_shallow(&pinfo->src, &unicast_4addr_packeth->src);
2763 unicast_4addr_packeth->subtype = tvb_get_uint8(tvb, 16);
2764 unicast_4addr_packeth->reserved = tvb_get_uint8(tvb, 17);
2766 /* Set info column */
2767 col_add_str(pinfo->cinfo, COL_INFO,
2768 val_to_str(unicast_4addr_packeth->subtype, unicast_4addr_typenames, "Unknown (0x%02x)"));
2770 /* Set tree info */
2771 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, UNICAST_4ADDR_PACKET_V14_SIZE,
2772 "B.A.T.M.A.N. Unicast 4Addr, Dst: %s",
2773 address_with_resolution_to_str(pinfo->pool, &unicast_4addr_packeth->dest));
2774 batadv_unicast_4addr_tree = proto_item_add_subtree(ti, ett_batadv_unicast_4addr);
2776 /* items */
2777 proto_tree_add_uint_format_value(batadv_unicast_4addr_tree,
2778 hf_batadv_packet_type, tvb, offset, 1,
2779 unicast_4addr_packeth->packet_type,
2780 "%s (%u)", "BATADV_UNICAST_4ADDR",
2781 unicast_4addr_packeth->packet_type);
2782 offset += 1;
2784 proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2785 offset += 1;
2787 proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2788 offset += 1;
2790 proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_ttvn, tvb, offset, 1, ENC_BIG_ENDIAN);
2791 offset += 1;
2793 proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_dst, tvb, offset, 6, ENC_NA);
2794 offset += 6;
2796 proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_src, tvb, offset, 6, ENC_NA);
2797 offset += 6;
2799 proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_subtype, tvb, offset, 1, ENC_BIG_ENDIAN);
2800 offset += 1;
2802 /* Skip 1 byte of padding. */
2803 offset += 1;
2805 tap_queue_packet(batadv_tap, pinfo, unicast_4addr_packeth);
2807 length_remaining = tvb_reported_length_remaining(tvb, offset);
2808 if (length_remaining > 0) {
2809 next_tvb = tvb_new_subset_remaining(tvb, offset);
2811 if (have_tap_listener(batadv_follow_tap)) {
2812 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
2815 call_dissector(eth_handle, next_tvb, pinfo, tree);
2819 static void dissect_batadv_unicast_frag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2821 uint8_t version;
2823 /* set protocol name */
2824 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_UNICAST_FRAG");
2826 version = tvb_get_uint8(tvb, 1);
2827 switch (version) {
2828 case 12:
2829 case 13:
2830 dissect_batadv_unicast_frag_v12(tvb, pinfo, tree);
2831 break;
2832 case 14:
2833 dissect_batadv_unicast_frag_v14(tvb, pinfo, tree);
2834 break;
2835 case 15:
2836 dissect_batadv_unicast_frag_v15(tvb, pinfo, tree);
2837 break;
2838 default:
2839 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
2840 call_data_dissector(tvb, pinfo, tree);
2841 break;
2845 static void dissect_batadv_unicast_frag_v12(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2847 struct unicast_frag_packet_v12 *unicast_frag_packeth;
2848 bool save_fragmented;
2849 fragment_head *frag_msg = NULL;
2850 proto_tree *batadv_unicast_frag_tree;
2851 proto_item *ti;
2853 tvbuff_t *new_tvb;
2854 int offset = 0;
2855 int head = 0;
2856 int length_remaining;
2858 unicast_frag_packeth = wmem_new(pinfo->pool, struct unicast_frag_packet_v12);
2860 unicast_frag_packeth->version = tvb_get_uint8(tvb, 1);
2861 set_address_tvb(&unicast_frag_packeth->dest, AT_ETHER, 6, tvb, 2);
2862 copy_address_shallow(&pinfo->dl_dst, &unicast_frag_packeth->dest);
2863 copy_address_shallow(&pinfo->dst, &unicast_frag_packeth->dest);
2864 unicast_frag_packeth->ttl = tvb_get_uint8(tvb, 8);
2865 unicast_frag_packeth->flags = tvb_get_uint8(tvb, 9);
2866 set_address_tvb(&unicast_frag_packeth->orig, AT_ETHER, 6, tvb, 10);
2867 copy_address_shallow(&pinfo->dl_src, &unicast_frag_packeth->orig);
2868 copy_address_shallow(&pinfo->src, &unicast_frag_packeth->orig);
2869 unicast_frag_packeth->seqno = tvb_get_ntohs(tvb, 16);
2871 save_fragmented = pinfo->fragmented;
2872 pinfo->fragmented = true;
2874 /* Set info column */
2875 col_clear(pinfo->cinfo, COL_INFO);
2877 /* Set tree info */
2878 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, UNICAST_FRAG_PACKET_V12_SIZE,
2879 "B.A.T.M.A.N. Unicast Fragment, Dst: %s",
2880 address_with_resolution_to_str(pinfo->pool, &unicast_frag_packeth->dest));
2881 batadv_unicast_frag_tree = proto_item_add_subtree(ti, ett_batadv_unicast_frag);
2883 /* items */
2884 proto_tree_add_uint_format(batadv_unicast_frag_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_UNICAST_FRAG_V12,
2885 "Packet Type: %s (%u)", "BATADV_UNICAST_FRAG", BATADV_UNICAST_FRAG_V12);
2886 offset += 1;
2888 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2889 offset += 1;
2891 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_dst, tvb, offset, 6, ENC_NA);
2892 offset += 6;
2894 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2895 offset += 1;
2897 proto_tree_add_bitmask(batadv_unicast_frag_tree, tvb, offset, hf_batadv_unicast_frag_flags,
2898 ett_batadv_batman_flags, unicast_frag_flags, ENC_BIG_ENDIAN);
2899 offset += 1;
2901 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_orig, tvb, offset, 6, ENC_NA);
2902 offset += 6;
2904 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
2905 offset += 2;
2907 tap_queue_packet(batadv_tap, pinfo, unicast_frag_packeth);
2909 head = (unicast_frag_packeth->flags & 0x1);
2910 length_remaining = tvb_reported_length_remaining(tvb, offset);
2911 if (length_remaining < 0)
2912 length_remaining = 0;
2913 frag_msg = fragment_add_seq_check(&msg_reassembly_table,
2914 tvb, offset,
2915 pinfo, unicast_frag_packeth->seqno + head, NULL,
2916 1 - head,
2917 length_remaining,
2918 head);
2920 new_tvb = process_reassembled_data(tvb, offset, pinfo,
2921 "Reassembled Message", frag_msg, &msg_frag_items,
2922 NULL, batadv_unicast_frag_tree);
2923 if (new_tvb) {
2924 if (have_tap_listener(batadv_follow_tap)) {
2925 tap_queue_packet(batadv_follow_tap, pinfo, new_tvb);
2928 call_dissector(eth_handle, new_tvb, pinfo, tree);
2931 pinfo->fragmented = save_fragmented;
2934 static void dissect_batadv_unicast_frag_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2936 struct unicast_frag_packet_v14 *unicast_frag_packeth;
2937 bool save_fragmented;
2938 fragment_head *frag_msg = NULL;
2939 proto_tree *batadv_unicast_frag_tree;
2940 proto_item *ti;
2942 tvbuff_t *new_tvb;
2943 int offset = 0;
2944 int head = 0;
2945 int length_remaining;
2947 unicast_frag_packeth = wmem_new(pinfo->pool, struct unicast_frag_packet_v14);
2949 unicast_frag_packeth->version = tvb_get_uint8(tvb, 1);
2950 unicast_frag_packeth->ttl = tvb_get_uint8(tvb, 2);
2951 unicast_frag_packeth->ttvn = tvb_get_uint8(tvb, 3);
2952 set_address_tvb(&unicast_frag_packeth->dest, AT_ETHER, 6, tvb, 4);
2953 copy_address_shallow(&pinfo->dl_dst, &unicast_frag_packeth->dest);
2954 copy_address_shallow(&pinfo->dst, &unicast_frag_packeth->dest);
2955 unicast_frag_packeth->flags = tvb_get_uint8(tvb, 10);
2956 unicast_frag_packeth->align = tvb_get_uint8(tvb, 11);
2957 set_address_tvb(&unicast_frag_packeth->orig, AT_ETHER, 6, tvb, 12);
2958 copy_address_shallow(&pinfo->dl_src, &unicast_frag_packeth->orig);
2959 copy_address_shallow(&pinfo->src, &unicast_frag_packeth->orig);
2960 unicast_frag_packeth->seqno = tvb_get_ntohs(tvb, 18);
2962 save_fragmented = pinfo->fragmented;
2963 pinfo->fragmented = true;
2965 /* Set info column */
2966 col_clear(pinfo->cinfo, COL_INFO);
2968 /* Set tree info */
2969 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, UNICAST_FRAG_PACKET_V14_SIZE,
2970 "B.A.T.M.A.N. Unicast Fragment, Dst: %s",
2971 address_with_resolution_to_str(pinfo->pool, &unicast_frag_packeth->dest));
2972 batadv_unicast_frag_tree = proto_item_add_subtree(ti, ett_batadv_unicast_frag);
2974 /* items */
2975 proto_tree_add_uint_format(batadv_unicast_frag_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_UNICAST_FRAG_V12,
2976 "Packet Type: %s (%u)", "BATADV_UNICAST", BATADV_UNICAST_FRAG_V12);
2977 offset += 1;
2979 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2980 offset += 1;
2982 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2983 offset += 1;
2985 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_ttvn, tvb, offset, 1, ENC_BIG_ENDIAN);
2986 offset += 1;
2988 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_dst, tvb, offset, 6, ENC_NA);
2989 offset += 6;
2991 proto_tree_add_bitmask(batadv_unicast_frag_tree, tvb, offset, hf_batadv_unicast_frag_flags,
2992 ett_batadv_batman_flags, unicast_frag_flags, ENC_BIG_ENDIAN);
2993 offset += 1;
2995 /* Skip 1 byte of padding. */
2996 offset += 1;
2998 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_orig, tvb, offset, 6, ENC_NA);
2999 offset += 6;
3001 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
3002 offset += 2;
3004 tap_queue_packet(batadv_tap, pinfo, unicast_frag_packeth);
3006 head = (unicast_frag_packeth->flags & 0x1);
3007 length_remaining = tvb_reported_length_remaining(tvb, offset);
3008 if (length_remaining < 0)
3009 length_remaining = 0;
3010 frag_msg = fragment_add_seq_check(&msg_reassembly_table,
3011 tvb, offset,
3012 pinfo, unicast_frag_packeth->seqno + head, NULL,
3013 1 - head,
3014 length_remaining,
3015 head);
3017 new_tvb = process_reassembled_data(tvb, offset, pinfo,
3018 "Reassembled Message", frag_msg, &msg_frag_items,
3019 NULL, batadv_unicast_frag_tree);
3020 if (new_tvb) {
3021 if (have_tap_listener(batadv_follow_tap)) {
3022 tap_queue_packet(batadv_follow_tap, pinfo, new_tvb);
3025 call_dissector(eth_handle, new_tvb, pinfo, tree);
3028 pinfo->fragmented = save_fragmented;
3031 static void dissect_batadv_unicast_frag_v15(tvbuff_t *tvb, packet_info *pinfo,
3032 proto_tree *tree)
3034 struct unicast_frag_packet_v15 *unicast_frag_packeth;
3035 bool save_fragmented;
3036 fragment_head *frag_msg = NULL;
3037 proto_tree *batadv_unicast_frag_tree;
3038 proto_item *ti;
3040 tvbuff_t *new_tvb;
3041 int offset = 0;
3042 int frag_no = 0;
3043 int length_remaining;
3045 unicast_frag_packeth = wmem_new(pinfo->pool, struct unicast_frag_packet_v15);
3047 save_fragmented = pinfo->fragmented;
3048 pinfo->fragmented = true;
3050 /* Set info column */
3051 col_clear(pinfo->cinfo, COL_INFO);
3053 /* Set tree info */
3054 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
3055 tvb, 0,
3056 UNICAST_FRAG_PACKET_V15_SIZE,
3057 "B.A.T.M.A.N. Unicast Fragment, Dst: %s",
3058 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 4));
3059 batadv_unicast_frag_tree = proto_item_add_subtree(ti,
3060 ett_batadv_unicast_frag);
3062 /* items */
3063 unicast_frag_packeth->packet_type = tvb_get_uint8(tvb, offset);
3064 proto_tree_add_uint_format_value(batadv_unicast_frag_tree,
3065 hf_batadv_packet_type, tvb, offset, 1,
3066 unicast_frag_packeth->packet_type,
3067 "%s (%u)", "BATADV_UNICAST",
3068 unicast_frag_packeth->packet_type);
3069 offset += 1;
3071 unicast_frag_packeth->version = tvb_get_uint8(tvb, offset);
3072 proto_tree_add_item(batadv_unicast_frag_tree,
3073 hf_batadv_unicast_frag_version, tvb, offset, 1,
3074 ENC_BIG_ENDIAN);
3075 offset += 1;
3077 unicast_frag_packeth->ttl = tvb_get_uint8(tvb, offset);
3078 proto_tree_add_item(batadv_unicast_frag_tree,
3079 hf_batadv_unicast_frag_ttl, tvb, offset, 1,
3080 ENC_BIG_ENDIAN);
3081 offset += 1;
3083 unicast_frag_packeth->no = tvb_get_uint8(tvb, offset);
3084 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_no,
3085 tvb, offset, 1, ENC_BIG_ENDIAN);
3087 proto_tree_add_item(batadv_unicast_frag_tree,
3088 hf_batadv_unicast_frag_priority,
3089 tvb, offset, 1, ENC_BIG_ENDIAN);
3090 offset += 1;
3092 set_address_tvb(&unicast_frag_packeth->dest, AT_ETHER, 6, tvb, offset);
3093 copy_address_shallow(&pinfo->dl_dst, &unicast_frag_packeth->dest);
3094 copy_address_shallow(&pinfo->dst, &unicast_frag_packeth->dest);
3095 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_dst,
3096 tvb, offset, 6, ENC_NA);
3097 offset += 6;
3099 set_address_tvb(&unicast_frag_packeth->orig, AT_ETHER, 6, tvb, offset);
3100 copy_address_shallow(&pinfo->dl_src, &unicast_frag_packeth->orig);
3101 copy_address_shallow(&pinfo->src, &unicast_frag_packeth->orig);
3102 proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_orig,
3103 tvb, offset, 6, ENC_NA);
3104 offset += 6;
3106 unicast_frag_packeth->seqno = tvb_get_ntohs(tvb, offset);
3107 proto_tree_add_item(batadv_unicast_frag_tree,
3108 hf_batadv_unicast_frag_seqno, tvb, offset, 2,
3109 ENC_BIG_ENDIAN);
3110 offset += 2;
3112 unicast_frag_packeth->total_size = tvb_get_ntohs(tvb, offset);
3113 proto_tree_add_item(batadv_unicast_frag_tree,
3114 hf_batadv_unicast_frag_total_size, tvb, offset, 2,
3115 ENC_BIG_ENDIAN);
3116 offset += 2;
3118 tap_queue_packet(batadv_tap, pinfo, unicast_frag_packeth);
3120 frag_no = unicast_frag_packeth->no >> 4;
3121 /* only support 2 fragments */
3122 if (frag_no > 1)
3123 return;
3125 length_remaining = tvb_captured_length_remaining(tvb, offset);
3126 if (length_remaining < 0)
3127 length_remaining = 0;
3128 frag_msg = fragment_add_seq_check(&msg_reassembly_table,
3129 tvb, offset, pinfo,
3130 unicast_frag_packeth->seqno, NULL,
3131 1 - frag_no, length_remaining, true);
3133 /* Assemble 2 fragments */
3134 fragment_set_tot_len(&msg_reassembly_table, pinfo,
3135 unicast_frag_packeth->seqno, NULL, 1);
3137 new_tvb = process_reassembled_data(tvb, offset, pinfo,
3138 "Reassembled Message", frag_msg, &msg_frag_items,
3139 NULL, batadv_unicast_frag_tree);
3140 if (new_tvb) {
3141 if (have_tap_listener(batadv_follow_tap)) {
3142 tap_queue_packet(batadv_follow_tap, pinfo, new_tvb);
3145 call_dissector(batman_handle, new_tvb, pinfo, tree);
3148 pinfo->fragmented = save_fragmented;
3151 static void dissect_batadv_vis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3153 uint8_t version;
3155 /* set protocol name */
3156 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_VIS");
3158 version = tvb_get_uint8(tvb, 1);
3159 switch (version) {
3160 case 6:
3161 case 7:
3162 case 8:
3163 case 9:
3164 dissect_batadv_vis_v6(tvb, pinfo, tree);
3165 break;
3166 case 10:
3167 case 11:
3168 case 12:
3169 case 13:
3170 dissect_batadv_vis_v10(tvb, pinfo, tree);
3171 break;
3172 case 14:
3173 dissect_batadv_vis_v14(tvb, pinfo, tree);
3174 break;
3175 default:
3176 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
3177 call_data_dissector(tvb, pinfo, tree);
3178 break;
3182 static void dissect_batadv_vis_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3184 struct vis_packet_v6 *vis_packeth;
3185 proto_tree *batadv_vis_tree;
3186 proto_item *ti;
3188 tvbuff_t *next_tvb;
3189 unsigned entry_size;
3190 int length_remaining;
3191 int offset = 0, i;
3193 vis_packeth = wmem_new(pinfo->pool, struct vis_packet_v6);
3195 vis_packeth->version = tvb_get_uint8(tvb, 1);
3196 vis_packeth->vis_type = tvb_get_uint8(tvb, 2);
3197 vis_packeth->seqno = tvb_get_uint8(tvb, 3);
3198 vis_packeth->entries = tvb_get_uint8(tvb, 4);
3199 vis_packeth->ttl = tvb_get_uint8(tvb, 5);
3201 set_address_tvb(&vis_packeth->vis_orig, AT_ETHER, 6, tvb, 6);
3202 copy_address_shallow(&pinfo->src, &vis_packeth->vis_orig);
3203 set_address_tvb(&vis_packeth->target_orig, AT_ETHER, 6, tvb, 12);
3204 copy_address_shallow(&pinfo->dl_dst, &vis_packeth->target_orig);
3205 copy_address_shallow(&pinfo->dst, &vis_packeth->target_orig);
3206 set_address_tvb(&vis_packeth->sender_orig, AT_ETHER, 6, tvb, 18);
3207 copy_address_shallow(&pinfo->dl_src, &vis_packeth->sender_orig);
3210 /* Set info column */
3211 col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
3212 val_to_str(vis_packeth->vis_type, vis_packettypenames, "Unknown (0x%02x)"),
3213 vis_packeth->seqno);
3214 /* Set tree info */
3215 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_PACKET_V6_SIZE,
3216 "B.A.T.M.A.N. Vis, Orig: %s",
3217 address_with_resolution_to_str(pinfo->pool, &vis_packeth->vis_orig));
3218 batadv_vis_tree = proto_item_add_subtree(ti, ett_batadv_vis);
3220 /* items */
3221 proto_tree_add_uint_format(batadv_vis_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_VIS_V5,
3222 "Packet Type: %s (%u)", "BATADV_VIS", BATADV_VIS_V5);
3223 offset += 1;
3225 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_version, tvb, offset, 1, ENC_BIG_ENDIAN);
3226 offset += 1;
3228 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3229 offset += 1;
3231 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_seqno, tvb, offset, 1, ENC_BIG_ENDIAN);
3232 offset += 1;
3234 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_entries, tvb, offset, 1, ENC_BIG_ENDIAN);
3235 offset += 1;
3237 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
3238 offset += 1;
3240 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_vis_orig, tvb, offset, 6, ENC_NA);
3241 offset += 6;
3243 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_target_orig, tvb, offset, 6, ENC_NA);
3244 offset += 6;
3246 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_sender_orig, tvb, offset, 6, ENC_NA);
3247 offset += 6;
3249 tap_queue_packet(batadv_tap, pinfo, vis_packeth);
3251 switch (vis_packeth->version) {
3252 case 6:
3253 case 7:
3254 entry_size = VIS_ENTRY_V6_SIZE;
3255 break;
3256 default:
3257 case 8:
3258 case 9:
3259 entry_size = VIS_ENTRY_V8_SIZE;
3260 break;
3263 for (i = 0; i < vis_packeth->entries; i++) {
3264 next_tvb = tvb_new_subset_length(tvb, offset, entry_size);
3266 if (have_tap_listener(batadv_follow_tap)) {
3267 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3270 if (batadv_vis_tree != NULL) {
3271 switch (vis_packeth->version) {
3272 case 6:
3273 case 7:
3274 dissect_vis_entry_v6(next_tvb, pinfo, batadv_vis_tree);
3275 break;
3276 default:
3277 case 8:
3278 case 9:
3279 dissect_vis_entry_v8(next_tvb, pinfo, batadv_vis_tree);
3280 break;
3284 offset += entry_size;
3287 length_remaining = tvb_reported_length_remaining(tvb, offset);
3288 if (length_remaining > 0) {
3289 next_tvb = tvb_new_subset_remaining(tvb, offset);
3291 if (have_tap_listener(batadv_follow_tap)) {
3292 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3295 call_data_dissector(next_tvb, pinfo, tree);
3299 static void dissect_batadv_vis_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3301 struct vis_packet_v10 *vis_packeth;
3302 proto_tree *batadv_vis_tree;
3303 proto_item *ti;
3305 tvbuff_t *next_tvb;
3306 int length_remaining;
3307 int offset = 0, i;
3309 vis_packeth = wmem_new(pinfo->pool, struct vis_packet_v10);
3311 vis_packeth->version = tvb_get_uint8(tvb, 1);
3312 vis_packeth->vis_type = tvb_get_uint8(tvb, 2);
3313 vis_packeth->entries = tvb_get_uint8(tvb, 3);
3314 vis_packeth->seqno = tvb_get_ntohl(tvb, 4);
3315 vis_packeth->ttl = tvb_get_uint8(tvb, 8);
3317 set_address_tvb(&vis_packeth->vis_orig, AT_ETHER, 6, tvb, 9);
3318 copy_address_shallow(&pinfo->src, &vis_packeth->vis_orig);
3319 set_address_tvb(&vis_packeth->target_orig, AT_ETHER, 6, tvb, 15);
3320 copy_address_shallow(&pinfo->dl_dst, &vis_packeth->target_orig);
3321 copy_address_shallow(&pinfo->dst, &vis_packeth->target_orig);
3322 set_address_tvb(&vis_packeth->sender_orig, AT_ETHER, 6, tvb, 21);
3323 copy_address_shallow(&pinfo->dl_src, &vis_packeth->sender_orig);
3326 /* Set info column */
3327 col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
3328 val_to_str(vis_packeth->vis_type, vis_packettypenames, "Unknown (0x%02x)"),
3329 vis_packeth->seqno);
3331 /* Set tree info */
3332 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_PACKET_V10_SIZE,
3333 "B.A.T.M.A.N. Vis, Orig: %s",
3334 address_with_resolution_to_str(pinfo->pool, &vis_packeth->vis_orig));
3335 batadv_vis_tree = proto_item_add_subtree(ti, ett_batadv_vis);
3337 /* items */
3338 proto_tree_add_uint_format(batadv_vis_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_VIS_V5,
3339 "Packet Type: %s (%u)", "BATADV_VIS", BATADV_VIS_V5);
3340 offset += 1;
3342 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_version, tvb, offset, 1, ENC_BIG_ENDIAN);
3343 offset += 1;
3345 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3346 offset += 1;
3348 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_entries, tvb, offset, 1, ENC_BIG_ENDIAN);
3349 offset += 1;
3351 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
3352 offset += 4;
3354 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
3355 offset += 1;
3357 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_vis_orig, tvb, offset, 6, ENC_NA);
3358 offset += 6;
3360 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_target_orig, tvb, offset, 6, ENC_NA);
3361 offset += 6;
3363 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_sender_orig, tvb, offset, 6, ENC_NA);
3364 offset += 6;
3366 tap_queue_packet(batadv_tap, pinfo, vis_packeth);
3368 for (i = 0; i < vis_packeth->entries; i++) {
3369 next_tvb = tvb_new_subset_length(tvb, offset, VIS_ENTRY_V8_SIZE);
3371 if (have_tap_listener(batadv_follow_tap)) {
3372 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3375 dissect_vis_entry_v8(next_tvb, pinfo, batadv_vis_tree);
3376 offset += VIS_ENTRY_V8_SIZE;
3379 length_remaining = tvb_reported_length_remaining(tvb, offset);
3380 if (length_remaining > 0) {
3381 next_tvb = tvb_new_subset_remaining(tvb, offset);
3383 if (have_tap_listener(batadv_follow_tap)) {
3384 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3387 call_data_dissector(next_tvb, pinfo, tree);
3391 static void dissect_batadv_vis_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3393 struct vis_packet_v14 *vis_packeth;
3394 proto_tree *batadv_vis_tree;
3395 proto_item *ti;
3397 tvbuff_t *next_tvb;
3398 int length_remaining;
3399 int offset = 0, i;
3401 vis_packeth = wmem_new(pinfo->pool, struct vis_packet_v14);
3403 vis_packeth->version = tvb_get_uint8(tvb, 1);
3404 vis_packeth->ttl = tvb_get_uint8(tvb, 2);
3405 vis_packeth->vis_type = tvb_get_uint8(tvb, 3);
3406 vis_packeth->seqno = tvb_get_ntohl(tvb, 4);
3407 vis_packeth->entries = tvb_get_uint8(tvb, 8);
3408 vis_packeth->reserved = tvb_get_uint8(tvb, 9);
3410 set_address_tvb(&vis_packeth->vis_orig, AT_ETHER, 6, tvb, 10);
3411 copy_address_shallow(&pinfo->src, &vis_packeth->vis_orig);
3412 set_address_tvb(&vis_packeth->target_orig, AT_ETHER, 6, tvb, 16);
3413 copy_address_shallow(&pinfo->dl_dst, &vis_packeth->target_orig);
3414 copy_address_shallow(&pinfo->dst, &vis_packeth->target_orig);
3415 set_address_tvb(&vis_packeth->sender_orig, AT_ETHER, 6, tvb, 22);
3416 copy_address_shallow(&pinfo->dl_src, &vis_packeth->sender_orig);
3418 /* Set info column */
3419 col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
3420 val_to_str(vis_packeth->vis_type, vis_packettypenames, "Unknown (0x%02x)"),
3421 vis_packeth->seqno);
3423 /* Set tree info */
3424 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_PACKET_V14_SIZE,
3425 "B.A.T.M.A.N. Vis, Orig: %s",
3426 address_with_resolution_to_str(pinfo->pool, &vis_packeth->vis_orig));
3427 batadv_vis_tree = proto_item_add_subtree(ti, ett_batadv_vis);
3429 /* items */
3430 proto_tree_add_uint_format(batadv_vis_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_VIS_V5,
3431 "Packet Type: %s (%u)", "BATADV_VIS", BATADV_VIS_V5);
3432 offset += 1;
3434 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_version, tvb, offset, 1, ENC_BIG_ENDIAN);
3435 offset += 1;
3437 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
3438 offset += 1;
3440 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3441 offset += 1;
3443 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
3444 offset += 4;
3446 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_entries, tvb, offset, 1, ENC_BIG_ENDIAN);
3447 offset += 1;
3449 /* Skip 1 byte of padding. */
3450 offset += 1;
3452 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_vis_orig, tvb, offset, 6, ENC_NA);
3453 offset += 6;
3455 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_target_orig, tvb, offset, 6, ENC_NA);
3456 offset += 6;
3458 proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_sender_orig, tvb, offset, 6, ENC_NA);
3459 offset += 6;
3461 tap_queue_packet(batadv_tap, pinfo, vis_packeth);
3463 for (i = 0; i < vis_packeth->entries; i++) {
3464 next_tvb = tvb_new_subset_length(tvb, offset, VIS_ENTRY_V8_SIZE);
3466 if (have_tap_listener(batadv_follow_tap)) {
3467 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3470 dissect_vis_entry_v8(next_tvb, pinfo, batadv_vis_tree);
3471 offset += VIS_ENTRY_V8_SIZE;
3474 length_remaining = tvb_reported_length_remaining(tvb, offset);
3475 if (length_remaining > 0) {
3476 next_tvb = tvb_new_subset_remaining(tvb, offset);
3478 if (have_tap_listener(batadv_follow_tap)) {
3479 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3482 call_data_dissector(next_tvb, pinfo, tree);
3486 static void dissect_vis_entry_v6(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
3488 proto_tree *batadv_vis_entry_tree;
3489 proto_item *ti;
3491 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_ENTRY_V6_SIZE,
3492 "VIS Entry: %s",
3493 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 0));
3494 batadv_vis_entry_tree = proto_item_add_subtree(ti, ett_batadv_vis_entry);
3496 proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_dst, tvb, 0, 6, ENC_NA);
3497 proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_quality, tvb, 6, 1, ENC_BIG_ENDIAN);
3500 static void dissect_vis_entry_v8(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
3502 proto_tree *batadv_vis_entry_tree;
3503 proto_item *ti;
3505 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_ENTRY_V8_SIZE,
3506 "VIS Entry: %s",
3507 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 6));
3508 batadv_vis_entry_tree = proto_item_add_subtree(ti, ett_batadv_vis_entry);
3510 proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_src, tvb, 0, 6, ENC_NA);
3511 proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_dst, tvb, 6, 6, ENC_NA);
3512 proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_quality, tvb, 12, 1, ENC_BIG_ENDIAN);
3515 static void dissect_batadv_tt_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3517 uint8_t version;
3519 /* set protocol name */
3520 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_TT_QUERY");
3522 version = tvb_get_uint8(tvb, 1);
3523 switch (version) {
3524 case 14:
3525 dissect_batadv_tt_query_v14(tvb, pinfo, tree);
3526 break;
3527 default:
3528 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
3529 call_data_dissector(tvb, pinfo, tree);
3530 break;
3534 static void dissect_batadv_tt_query_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3536 struct tt_query_packet_v14 *tt_query_packeth;
3537 proto_tree *batadv_tt_query_tree;
3538 proto_item *ti;
3540 tvbuff_t *next_tvb;
3541 int length_remaining;
3542 int offset = 0, i;
3543 int tt_type;
3545 tt_query_packeth = wmem_new(pinfo->pool, struct tt_query_packet_v14);
3547 tt_query_packeth->version = tvb_get_uint8(tvb, 1);
3548 tt_query_packeth->ttl = tvb_get_uint8(tvb, 2);
3549 tt_query_packeth->flags = tvb_get_uint8(tvb, 3);
3551 set_address_tvb(&tt_query_packeth->dst, AT_ETHER, 6, tvb, 4);
3552 copy_address_shallow(&pinfo->dl_dst, &tt_query_packeth->dst);
3553 copy_address_shallow(&pinfo->dst, &tt_query_packeth->dst);
3555 set_address_tvb(&tt_query_packeth->src, AT_ETHER, 6, tvb, 10);
3556 copy_address_shallow(&pinfo->dl_src, &tt_query_packeth->src);
3557 copy_address_shallow(&pinfo->src, &tt_query_packeth->src);
3559 tt_query_packeth->ttvn = tvb_get_uint8(tvb, 16);
3560 tt_query_packeth->tt_data = tvb_get_ntohs(tvb, 17);
3562 tt_type = TT_TYPE_MASK & tt_query_packeth->flags;
3564 /* Set info column */
3565 switch (tt_type) {
3566 case TT_REQUEST:
3567 col_add_fstr(pinfo->cinfo, COL_INFO, "Request=%u", tt_query_packeth->ttvn);
3568 break;
3569 case TT_RESPONSE:
3570 col_add_fstr(pinfo->cinfo, COL_INFO, "Response=%u", tt_query_packeth->ttvn);
3571 break;
3572 default:
3573 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Type %u", tt_type);
3574 break;
3577 /* Set tree info */
3578 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, TT_QUERY_PACKET_V14_SIZE,
3579 "B.A.T.M.A.N. TT Query, Dst: %s",
3580 address_with_resolution_to_str(pinfo->pool, &tt_query_packeth->dst));
3581 batadv_tt_query_tree = proto_item_add_subtree(ti, ett_batadv_tt_query);
3583 /* items */
3584 proto_tree_add_uint_format(batadv_tt_query_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_TT_QUERY_V14,
3585 "Packet Type: %s (%u)", "BATADV_TT_QUERY", BATADV_TT_QUERY_V14);
3586 offset += 1;
3588 proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_version, tvb, offset, 1, ENC_BIG_ENDIAN);
3589 offset += 1;
3591 proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
3592 offset += 1;
3594 proto_tree_add_bitmask(batadv_tt_query_tree, tvb, offset, hf_batadv_tt_query_flags,
3595 ett_batadv_tt_query_flags, tt_query_flags, ENC_BIG_ENDIAN);
3596 offset += 1;
3598 proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_dst, tvb, offset, 6, ENC_NA);
3599 offset += 6;
3601 proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_src, tvb, offset, 6, ENC_NA);
3602 offset += 6;
3604 proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_ttvn, tvb, offset, 1, ENC_BIG_ENDIAN);
3605 offset += 1;
3607 switch (tt_type) {
3608 case TT_REQUEST:
3609 proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_tt_crc, tvb, offset, 2, ENC_BIG_ENDIAN);
3610 break;
3611 case TT_RESPONSE:
3612 proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_entries, tvb, offset, 2, ENC_BIG_ENDIAN);
3613 break;
3614 default:
3615 break;
3617 offset += 2;
3619 tap_queue_packet(batadv_tap, pinfo, tt_query_packeth);
3621 if (tt_type == TT_RESPONSE) {
3622 for (i = 0; i < tt_query_packeth->tt_data; i++) {
3623 next_tvb = tvb_new_subset_length(tvb, offset, TT_ENTRY_V14_SIZE);
3625 if (have_tap_listener(batadv_follow_tap)) {
3626 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3629 dissect_tt_entry_v14(next_tvb, pinfo, batadv_tt_query_tree);
3630 offset += TT_ENTRY_V14_SIZE;
3634 length_remaining = tvb_reported_length_remaining(tvb, offset);
3635 if (length_remaining > 0) {
3636 next_tvb = tvb_new_subset_remaining(tvb, offset);
3638 if (have_tap_listener(batadv_follow_tap)) {
3639 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3642 call_data_dissector(next_tvb, pinfo, tree);
3646 static void dissect_tt_entry_v14(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
3648 proto_tree *batadv_tt_entry_tree;
3649 proto_item *ti;
3651 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, TT_ENTRY_V14_SIZE,
3652 "TT Entry: %s",
3653 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 1));
3654 batadv_tt_entry_tree = proto_item_add_subtree(ti, ett_batadv_tt_entry);
3656 proto_tree_add_bitmask(batadv_tt_entry_tree, tvb, 0, hf_batadv_tt_entry_flags,
3657 ett_batadv_tt_entry_flags, tt_entry_flags, ENC_BIG_ENDIAN);
3658 proto_tree_add_item(batadv_tt_entry_tree, hf_batadv_tt_entry, tvb, 1, 6, ENC_NA);
3661 static void dissect_batadv_roam_adv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3663 uint8_t version;
3665 /* set protocol name */
3666 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_ROAM_ADV");
3668 version = tvb_get_uint8(tvb, 1);
3669 switch (version) {
3670 case 14:
3671 dissect_batadv_roam_adv_v14(tvb, pinfo, tree);
3672 break;
3673 default:
3674 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
3675 call_data_dissector(tvb, pinfo, tree);
3676 break;
3680 static void dissect_batadv_roam_adv_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3682 struct roam_adv_packet_v14 *roam_adv_packeth;
3683 proto_tree *batadv_roam_adv_tree;
3684 proto_item *ti;
3686 tvbuff_t *next_tvb;
3687 int length_remaining;
3688 int offset = 0;
3690 roam_adv_packeth = wmem_new(pinfo->pool, struct roam_adv_packet_v14);
3692 roam_adv_packeth->version = tvb_get_uint8(tvb, 1);
3693 roam_adv_packeth->ttl = tvb_get_uint8(tvb, 2);
3694 set_address_tvb(&roam_adv_packeth->dst, AT_ETHER, 6, tvb, 4);
3695 copy_address_shallow(&pinfo->dl_dst, &roam_adv_packeth->dst);
3696 copy_address_shallow(&pinfo->dst, &roam_adv_packeth->dst);
3697 set_address_tvb(&roam_adv_packeth->src, AT_ETHER, 6, tvb, 10);
3698 copy_address_shallow(&pinfo->dl_src, &roam_adv_packeth->src);
3699 copy_address_shallow(&pinfo->src, &roam_adv_packeth->src);
3700 set_address_tvb(&roam_adv_packeth->client, AT_ETHER, 6, tvb, 16);
3702 /* Set info column */
3703 col_add_fstr(pinfo->cinfo, COL_INFO, "Client %s", address_with_resolution_to_str(pinfo->pool, &roam_adv_packeth->client));
3705 /* Set tree info */
3706 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, ROAM_ADV_PACKET_V14_SIZE,
3707 "B.A.T.M.A.N. Roam: %s",
3708 address_with_resolution_to_str(pinfo->pool, &roam_adv_packeth->client));
3709 batadv_roam_adv_tree = proto_item_add_subtree(ti, ett_batadv_roam_adv);
3711 /* items */
3712 proto_tree_add_uint_format(batadv_roam_adv_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_ROAM_ADV_V14,
3713 "Packet Type: %s (%u)", "BATADV_ROAM_ADV", BATADV_ROAM_ADV_V14);
3714 offset += 1;
3716 proto_tree_add_item(batadv_roam_adv_tree, hf_batadv_roam_adv_version, tvb, offset, 1, ENC_BIG_ENDIAN);
3717 offset += 1;
3719 proto_tree_add_item(batadv_roam_adv_tree, hf_batadv_roam_adv_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
3720 offset += 1;
3722 /* Skip 1 byte of padding. */
3723 offset += 1;
3725 proto_tree_add_item(batadv_roam_adv_tree, hf_batadv_roam_adv_dst, tvb, offset, 6, ENC_NA);
3726 offset += 6;
3728 proto_tree_add_item(batadv_roam_adv_tree, hf_batadv_roam_adv_src, tvb, offset, 6, ENC_NA);
3729 offset += 6;
3731 proto_tree_add_item(batadv_roam_adv_tree, hf_batadv_roam_adv_client, tvb, offset, 6, ENC_NA);
3732 offset += 6;
3734 tap_queue_packet(batadv_tap, pinfo, roam_adv_packeth);
3736 length_remaining = tvb_reported_length_remaining(tvb, offset);
3737 if (length_remaining > 0) {
3738 next_tvb = tvb_new_subset_remaining(tvb, offset);
3740 if (have_tap_listener(batadv_follow_tap)) {
3741 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3744 call_data_dissector(next_tvb, pinfo, tree);
3748 static void dissect_batadv_coded(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3750 uint8_t version;
3752 /* set protocol name */
3753 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_CODED");
3755 version = tvb_get_uint8(tvb, 1);
3756 switch (version) {
3757 case 15:
3758 dissect_batadv_coded_v15(tvb, pinfo, tree);
3759 break;
3760 default:
3761 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
3762 call_data_dissector(tvb, pinfo, tree);
3763 break;
3767 static void dissect_batadv_coded_v15(tvbuff_t *tvb, packet_info *pinfo,
3768 proto_tree *tree)
3770 struct coded_packet_v15 *coded_packeth;
3771 proto_tree *batadv_coded_tree;
3772 proto_item *ti;
3774 tvbuff_t *next_tvb;
3775 int length_remaining;
3776 int offset = 0;
3778 coded_packeth = wmem_new(pinfo->pool, struct coded_packet_v15);
3780 /* Set tree info */
3781 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
3782 tvb, 0,
3783 CODED_PACKET_V15_SIZE,
3784 "B.A.T.M.A.N. Coded");
3785 batadv_coded_tree = proto_item_add_subtree(ti, ett_batadv_coded);
3787 /* items */
3788 coded_packeth->packet_type = tvb_get_uint8(tvb, offset);
3789 proto_tree_add_uint_format_value(batadv_coded_tree,
3790 hf_batadv_packet_type,
3791 tvb, offset, 1,
3792 coded_packeth->packet_type,
3793 "%s (%u)", "BATADV_CODED",
3794 coded_packeth->packet_type);
3795 offset += 1;
3797 coded_packeth->version = tvb_get_uint8(tvb, offset);
3798 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_version, tvb,
3799 offset, 1, ENC_BIG_ENDIAN);
3800 offset += 1;
3802 coded_packeth->ttl = tvb_get_uint8(tvb, offset);
3803 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_ttl, tvb, offset,
3804 1, ENC_BIG_ENDIAN);
3805 offset += 1;
3807 coded_packeth->first_ttvn = tvb_get_uint8(tvb, offset);
3808 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_first_ttvn, tvb,
3809 offset, 1, ENC_BIG_ENDIAN);
3810 offset += 1;
3812 set_address_tvb(&coded_packeth->first_source, AT_ETHER, 6, tvb, offset);
3813 copy_address_shallow(&pinfo->dl_src, &coded_packeth->first_source);
3814 copy_address_shallow(&pinfo->src, &coded_packeth->first_source);
3815 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_first_source,
3816 tvb, offset, 6, ENC_NA);
3817 offset += 6;
3819 set_address_tvb(&coded_packeth->first_orig_dest, AT_ETHER, 6, tvb, offset);
3820 copy_address_shallow(&pinfo->dl_dst, &coded_packeth->first_orig_dest);
3821 copy_address_shallow(&pinfo->dst, &coded_packeth->first_orig_dest);
3822 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_first_orig_dest,
3823 tvb, offset, 6, ENC_NA);
3824 offset += 6;
3826 coded_packeth->first_crc = tvb_get_ntohl(tvb, offset);
3827 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_first_crc, tvb,
3828 offset, 4, ENC_BIG_ENDIAN);
3829 offset += 4;
3831 coded_packeth->second_ttl = tvb_get_uint8(tvb, offset);
3832 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_ttl, tvb,
3833 offset, 1, ENC_BIG_ENDIAN);
3834 offset += 1;
3836 coded_packeth->second_ttvn = tvb_get_uint8(tvb, offset);
3837 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_ttvn, tvb,
3838 offset, 1, ENC_BIG_ENDIAN);
3839 offset += 1;
3841 set_address_tvb(&coded_packeth->second_dest, AT_ETHER, 6, tvb, offset);
3842 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_dest,
3843 tvb, offset, 6, ENC_NA);
3844 offset += 6;
3846 set_address_tvb(&coded_packeth->second_source, AT_ETHER, 6, tvb, offset);
3847 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_source,
3848 tvb, offset, 6, ENC_NA);
3849 offset += 6;
3851 set_address_tvb(&coded_packeth->second_orig_dest, AT_ETHER, 6, tvb, offset);
3852 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_orig_dest,
3853 tvb, offset, 6, ENC_NA);
3854 offset += 6;
3856 coded_packeth->second_crc = tvb_get_ntohl(tvb, offset);
3857 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_crc, tvb,
3858 offset, 4, ENC_BIG_ENDIAN);
3859 offset += 4;
3861 coded_packeth->coded_len = tvb_get_ntohs(tvb, offset);
3862 proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_coded_len, tvb,
3863 offset, 2, ENC_BIG_ENDIAN);
3864 offset += 2;
3866 tap_queue_packet(batadv_tap, pinfo, coded_packeth);
3868 length_remaining = tvb_reported_length_remaining(tvb, offset);
3869 if (length_remaining > 0) {
3870 next_tvb = tvb_new_subset_remaining(tvb, offset);
3872 if (have_tap_listener(batadv_follow_tap)) {
3873 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3876 call_data_dissector(next_tvb, pinfo, tree);
3880 static void dissect_batadv_elp(tvbuff_t *tvb, packet_info *pinfo,
3881 proto_tree *tree)
3883 uint8_t version;
3885 /* set protocol name */
3886 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_ELP");
3888 version = tvb_get_uint8(tvb, 1);
3889 switch (version) {
3890 case 15:
3891 dissect_batadv_elp_v15(tvb, pinfo, tree);
3892 break;
3893 default:
3894 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d",
3895 version);
3896 call_data_dissector(tvb, pinfo, tree);
3897 break;
3901 static void dissect_batadv_elp_v15(tvbuff_t *tvb, packet_info *pinfo,
3902 proto_tree *tree)
3904 struct elp_packet_v15 *elp_packeth;
3905 proto_tree *batadv_elp_tree;
3906 proto_item *ti;
3908 tvbuff_t *next_tvb;
3909 int length_remaining;
3910 int offset = 0;
3912 elp_packeth = wmem_new(pinfo->pool, struct elp_packet_v15);
3914 /* Set tree info */
3915 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
3916 tvb, 0,
3917 ELP_PACKET_V15_SIZE,
3918 "B.A.T.M.A.N. ELP");
3919 batadv_elp_tree = proto_item_add_subtree(ti, ett_batadv_elp);
3921 /* items */
3922 elp_packeth->packet_type = tvb_get_uint8(tvb, offset);
3923 proto_tree_add_uint_format_value(batadv_elp_tree,
3924 hf_batadv_packet_type,
3925 tvb, offset, 1,
3926 elp_packeth->packet_type,
3927 "%s (%u)", "BATADV_ELP",
3928 elp_packeth->packet_type);
3929 offset += 1;
3931 elp_packeth->version = tvb_get_uint8(tvb, offset);
3932 proto_tree_add_item(batadv_elp_tree, hf_batadv_elp_version, tvb,
3933 offset, 1, ENC_BIG_ENDIAN);
3934 offset += 1;
3936 set_address_tvb(&elp_packeth->orig, AT_ETHER, 6, tvb, offset);
3937 set_address_tvb(&pinfo->dl_src, AT_ETHER, 6, tvb, offset);
3938 set_address_tvb(&pinfo->src, AT_ETHER, 6, tvb, offset);
3939 proto_tree_add_item(batadv_elp_tree, hf_batadv_elp_orig, tvb,
3940 offset, 6, ENC_NA);
3941 offset += 6;
3943 elp_packeth->seqno = tvb_get_ntohl(tvb, offset);
3944 proto_tree_add_item(batadv_elp_tree, hf_batadv_elp_seqno, tvb,
3945 offset, 4, ENC_BIG_ENDIAN);
3946 offset += 4;
3948 elp_packeth->interval = tvb_get_ntohl(tvb, offset);
3949 proto_tree_add_item(batadv_elp_tree, hf_batadv_elp_interval, tvb,
3950 offset, 4, ENC_BIG_ENDIAN);
3951 offset += 4;
3953 tap_queue_packet(batadv_tap, pinfo, elp_packeth);
3955 length_remaining = tvb_reported_length_remaining(tvb, offset);
3956 if (length_remaining > 0) {
3957 next_tvb = tvb_new_subset_remaining(tvb, offset);
3959 if (have_tap_listener(batadv_follow_tap)) {
3960 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3963 call_data_dissector(next_tvb, pinfo, tree);
3967 static void dissect_batadv_ogm2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3969 uint8_t version;
3970 int offset = 0;
3972 /* set protocol name */
3973 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_OGM2");
3975 version = tvb_get_uint8(tvb, 1);
3976 switch (version) {
3977 case 15:
3978 while (offset != -1 &&
3979 tvb_reported_length_remaining(tvb, offset) >= OGM2_PACKET_V15_SIZE) {
3980 offset = dissect_batadv_ogm2_v15(tvb, offset, pinfo, tree);
3982 break;
3983 default:
3984 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
3985 call_data_dissector(tvb, pinfo, tree);
3986 break;
3990 static int dissect_batadv_ogm2_v15(tvbuff_t *tvb, int offset,
3991 packet_info *pinfo, proto_tree *tree)
3993 proto_tree *batadv_ogm2_tree;
3994 proto_item *ti, *throughput_item;
3995 uint8_t type, version;
3996 struct ogm2_packet_v15 *ogm2_packeth;
3997 tvbuff_t *next_tvb;
3998 #if 0
3999 /* OGM2 flags field is unused, it is illegal to call
4000 * proto_tree_add_bitmask with an empty list of fields.
4002 static int * const flags[] = {
4003 NULL
4005 #endif
4007 type = tvb_get_uint8(tvb, offset+0);
4008 version = tvb_get_uint8(tvb, offset+1);
4010 /* don't interpret padding as B.A.T.M.A.N. advanced packet */
4011 if (version == 0 || type != BATADV_OGM2_V15)
4012 return -1;
4014 ogm2_packeth = wmem_new(pinfo->pool, struct ogm2_packet_v15);
4016 /* Set tree info */
4017 ogm2_packeth->tvlv_len = tvb_get_ntohs(tvb, 16);
4018 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
4019 tvb, offset,
4020 OGM2_PACKET_V15_SIZE + ogm2_packeth->tvlv_len,
4021 "B.A.T.M.A.N. OGM2, Orig: %s",
4022 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, offset + 8));
4023 batadv_ogm2_tree = proto_item_add_subtree(ti, ett_batadv_ogm2);
4025 /* items */
4026 ogm2_packeth->packet_type = tvb_get_uint8(tvb, offset);
4027 proto_tree_add_uint_format_value(batadv_ogm2_tree,
4028 hf_batadv_packet_type,
4029 tvb, offset, 1, BATADV_OGM2_V15,
4030 "%s (%u)", "BATADV_OGM2",
4031 BATADV_OGM2_V15);
4032 offset += 1;
4034 ogm2_packeth->version = tvb_get_uint8(tvb, offset);
4035 proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_version, tvb,
4036 offset, 1, ENC_BIG_ENDIAN);
4037 offset += 1;
4039 ogm2_packeth->ttl = tvb_get_uint8(tvb, offset);
4040 proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_ttl, tvb,
4041 offset, 1, ENC_BIG_ENDIAN);
4042 offset += 1;
4044 ogm2_packeth->flags = tvb_get_uint8(tvb, offset);
4045 proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_flags, tvb,
4046 offset, 1, ENC_NA);
4047 offset += 1;
4049 ogm2_packeth->seqno = tvb_get_ntohl(tvb, offset);
4050 proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_seqno, tvb,
4051 offset, 4, ENC_BIG_ENDIAN);
4052 col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", ogm2_packeth->seqno);
4053 offset += 4;
4055 set_address_tvb(&ogm2_packeth->orig, AT_ETHER, 6, tvb, offset);
4056 set_address_tvb(&pinfo->dl_src, AT_ETHER, 6, tvb, offset);
4057 set_address_tvb(&pinfo->src, AT_ETHER, 6, tvb, offset);
4058 proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_orig, tvb,
4059 offset, 6, ENC_NA);
4060 offset += 6;
4062 ogm2_packeth->tvlv_len = tvb_get_ntohs(tvb, offset);
4063 proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_tvlv_len, tvb,
4064 offset, 2, ENC_BIG_ENDIAN);
4065 offset += 2;
4067 ogm2_packeth->throughput = tvb_get_ntohl(tvb, offset);
4068 throughput_item = proto_tree_add_item(batadv_ogm2_tree,
4069 hf_batadv_ogm2_throughput, tvb,
4070 offset, 4, ENC_BIG_ENDIAN);
4071 proto_item_set_text(throughput_item, "Throughput: %u.%u Mbit/s",
4072 ogm2_packeth->throughput / 10,
4073 ogm2_packeth->throughput % 10);
4074 offset += 4;
4076 tap_queue_packet(batadv_tap, pinfo, ogm2_packeth);
4078 if (ogm2_packeth->tvlv_len > 0) {
4079 next_tvb = tvb_new_subset_length(tvb, offset,
4080 ogm2_packeth->tvlv_len);
4082 if (have_tap_listener(batadv_follow_tap)) {
4083 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
4086 dissect_batadv_tvlv_v15(next_tvb, pinfo, batadv_ogm2_tree);
4087 offset += ogm2_packeth->tvlv_len;
4090 return offset;
4093 static void dissect_batadv_unicast_tvlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
4095 uint8_t version;
4097 /* set protocol name */
4098 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_UNICAST_TVLV");
4100 version = tvb_get_uint8(tvb, 1);
4101 switch (version) {
4102 case 15:
4103 dissect_batadv_unicast_tvlv_v15(tvb, pinfo, tree);
4104 break;
4105 default:
4106 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d",
4107 version);
4108 call_data_dissector(tvb, pinfo, tree);
4109 break;
4113 static void dissect_batadv_unicast_tvlv_v15(tvbuff_t *tvb, packet_info *pinfo,
4114 proto_tree *tree)
4116 struct unicast_tvlv_packet_v15 *unicast_tvlv_packeth;
4118 tvbuff_t *next_tvb;
4119 int offset = 0;
4120 proto_tree *batadv_unicast_tvlv_tree;
4121 proto_item *ti;
4123 unicast_tvlv_packeth = wmem_new(pinfo->pool, struct unicast_tvlv_packet_v15);
4125 /* Set info column */
4126 col_clear(pinfo->cinfo, COL_INFO);
4128 /* Set tree info */
4129 unicast_tvlv_packeth->tvlv_len = tvb_get_ntohs(tvb, 16);
4130 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
4131 tvb, 0,
4132 UNICAST_TVLV_PACKET_V15_SIZE + unicast_tvlv_packeth->tvlv_len,
4133 "B.A.T.M.A.N. Unicast TVLV, Src: %s Dst: %s",
4134 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 10),
4135 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 4));
4136 batadv_unicast_tvlv_tree = proto_item_add_subtree(ti, ett_batadv_unicast_tvlv);
4138 /* items */
4139 unicast_tvlv_packeth->packet_type = tvb_get_uint8(tvb, offset);
4140 proto_tree_add_uint_format_value(batadv_unicast_tvlv_tree,
4141 hf_batadv_packet_type, tvb, offset, 1,
4142 unicast_tvlv_packeth->packet_type,
4143 "%s (%u)", "BATADV_UNICAST_TVLV",
4144 unicast_tvlv_packeth->packet_type);
4145 offset += 1;
4147 unicast_tvlv_packeth->version = tvb_get_uint8(tvb, offset);
4148 proto_tree_add_item(batadv_unicast_tvlv_tree,
4149 hf_batadv_unicast_tvlv_version, tvb, offset, 1,
4150 ENC_BIG_ENDIAN);
4151 offset += 1;
4153 unicast_tvlv_packeth->ttl = tvb_get_uint8(tvb, offset);
4154 proto_tree_add_item(batadv_unicast_tvlv_tree,
4155 hf_batadv_unicast_tvlv_ttl, tvb, offset, 1,
4156 ENC_BIG_ENDIAN);
4157 offset += 1;
4159 /* Skip 1 byte of padding. */
4160 offset += 1;
4162 set_address_tvb(&unicast_tvlv_packeth->dest, AT_ETHER, 6, tvb, offset);
4163 copy_address_shallow(&pinfo->dl_dst, &unicast_tvlv_packeth->dest);
4164 copy_address_shallow(&pinfo->dst, &unicast_tvlv_packeth->dest);
4165 proto_tree_add_item(batadv_unicast_tvlv_tree, hf_batadv_unicast_tvlv_dst,
4166 tvb, offset, 6, ENC_NA);
4167 offset += 6;
4169 set_address_tvb(&unicast_tvlv_packeth->src, AT_ETHER, 6, tvb, offset);
4170 copy_address_shallow(&pinfo->dl_src, &unicast_tvlv_packeth->src);
4171 copy_address_shallow(&pinfo->src, &unicast_tvlv_packeth->src);
4172 proto_tree_add_item(batadv_unicast_tvlv_tree, hf_batadv_unicast_tvlv_src,
4173 tvb, offset, 6, ENC_NA);
4174 offset += 6;
4176 unicast_tvlv_packeth->tvlv_len = tvb_get_ntohs(tvb, offset);
4177 proto_tree_add_item(batadv_unicast_tvlv_tree,
4178 hf_batadv_unicast_tvlv_len, tvb, offset, 2,
4179 ENC_BIG_ENDIAN);
4180 offset += 2;
4182 /* Skip 2 byte of padding. */
4183 offset += 2;
4185 tap_queue_packet(batadv_tap, pinfo, unicast_tvlv_packeth);
4187 if (unicast_tvlv_packeth->tvlv_len > 0) {
4188 next_tvb = tvb_new_subset_length(tvb, offset,
4189 unicast_tvlv_packeth->tvlv_len);
4191 if (have_tap_listener(batadv_follow_tap)) {
4192 tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
4195 dissect_batadv_tvlv_v15(next_tvb, pinfo,
4196 batadv_unicast_tvlv_tree);
4197 /*offset += unicast_tvlv_packeth->tvlv_len;*/
4201 static void dissect_batadv_tvlv_v15(tvbuff_t *tvb, packet_info *pinfo,
4202 proto_tree *tree)
4204 uint8_t type, version;
4205 uint16_t length;
4206 int offset = 0;
4207 tvbuff_t *next_tvb;
4208 proto_tree *batadv_tvlv_tree;
4209 proto_item *ti;
4211 while (offset != -1 && tvb_reported_length_remaining(tvb, offset) >= 4) {
4213 type = tvb_get_uint8(tvb, offset + 0);
4214 version = tvb_get_uint8(tvb, offset + 1);
4215 length = tvb_get_ntohs(tvb, offset + 2) + 4;
4216 next_tvb = tvb_new_subset_length(tvb, offset, length);
4218 /* Set tree info */
4219 ti = proto_tree_add_protocol_format(tree,
4220 proto_batadv_plugin,
4221 next_tvb, 0, length,
4222 "TVLV, %s",
4223 val_to_str(type,
4224 tvlv_v15_typenames,
4225 "Unknown (0x%02x)"));
4226 batadv_tvlv_tree = proto_item_add_subtree(ti, ett_batadv_tvlv);
4228 dissect_batadv_tvlv_v15_header(next_tvb, pinfo,
4229 batadv_tvlv_tree, type);
4231 switch (type) {
4232 case BATADV_TVLV_V15_GW:
4233 dissect_batadv_tvlv_v15_gw(next_tvb, pinfo,
4234 batadv_tvlv_tree, 4,
4235 version);
4236 break;
4237 case BATADV_TVLV_V15_DAT:
4238 dissect_batadv_tvlv_v15_dat(next_tvb, pinfo,
4239 batadv_tvlv_tree, 4,
4240 version);
4241 break;
4242 case BATADV_TVLV_V15_NC:
4243 dissect_batadv_tvlv_v15_nc(next_tvb, pinfo,
4244 batadv_tvlv_tree, 4,
4245 version);
4246 break;
4247 case BATADV_TVLV_V15_TT:
4248 dissect_batadv_tvlv_v15_tt(next_tvb, pinfo,
4249 batadv_tvlv_tree, 4,
4250 version);
4251 break;
4252 case BATADV_TVLV_V15_ROAM:
4253 dissect_batadv_tvlv_v15_roam(next_tvb, pinfo,
4254 batadv_tvlv_tree, 4,
4255 version);
4256 break;
4257 case BATADV_TVLV_V15_MCAST:
4258 dissect_batadv_tvlv_v15_mcast(next_tvb, pinfo,
4259 batadv_tvlv_tree, 4,
4260 version);
4261 break;
4262 default:
4263 call_data_dissector(next_tvb, pinfo,
4264 batadv_tvlv_tree);
4265 break;
4267 offset += length;
4271 static void dissect_batadv_tvlv_v15_header(tvbuff_t *tvb,
4272 packet_info *pinfo _U_,
4273 proto_tree *tree, uint8_t type)
4275 int offset = 0;
4277 /* items */
4278 proto_tree_add_uint_format_value(tree, hf_batadv_tvlv_type, tvb, offset,
4279 1, type, "%s",
4280 val_to_str(type, tvlv_v15_typenames,
4281 "Unknown (0x%02x)"));
4282 offset += 1;
4284 proto_tree_add_item(tree, hf_batadv_tvlv_version, tvb, offset, 1,
4285 ENC_BIG_ENDIAN);
4286 offset += 1;
4288 proto_tree_add_item(tree, hf_batadv_tvlv_len, tvb, offset, 2,
4289 ENC_BIG_ENDIAN);
4292 static void dissect_batadv_tvlv_v15_dat(tvbuff_t *tvb, packet_info *pinfo,
4293 proto_tree *tree, int offset,
4294 uint8_t version)
4296 if (version != 0x01) {
4297 proto_tree_add_expert_format(
4298 tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4299 offset, 0, "Unknown version (0x%02x)", version);
4300 return;
4304 static void dissect_batadv_tvlv_v15_nc(tvbuff_t *tvb, packet_info *pinfo,
4305 proto_tree *tree, int offset,
4306 uint8_t version)
4308 if (version != 0x01) {
4309 proto_tree_add_expert_format(
4310 tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4311 offset, 0, "Unknown version (0x%02x)", version);
4312 return;
4316 static void dissect_batadv_tvlv_v15_mcast(tvbuff_t *tvb, packet_info *pinfo,
4317 proto_tree *tree, int offset,
4318 uint8_t version)
4320 static int * const flags[] = {
4321 &hf_batadv_tvlv_mcast_flags_unsnoopables,
4322 &hf_batadv_tvlv_mcast_flags_ipv4,
4323 &hf_batadv_tvlv_mcast_flags_ipv6,
4324 &hf_batadv_tvlv_mcast_flags_no_rtr4,
4325 &hf_batadv_tvlv_mcast_flags_no_rtr6,
4326 NULL
4329 if (version != 0x01 && version != 0x02) {
4330 proto_tree_add_expert_format(
4331 tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4332 offset, 0, "Unknown version (0x%02x)", version);
4333 return;
4336 proto_tree_add_bitmask(tree, tvb, offset, hf_batadv_tvlv_mcast_flags,
4337 ett_batadv_tvlv_mcast_flags, flags, ENC_NA);
4339 /* 3 byte of padding. */
4342 static void dissect_batadv_tvlv_v15_gw(tvbuff_t *tvb, packet_info *pinfo,
4343 proto_tree *tree, int offset,
4344 uint8_t version)
4346 uint32_t down, up;
4348 if (version != 0x01) {
4349 proto_tree_add_expert_format(
4350 tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4351 offset, 0, "Unknown version (0x%02x)", version);
4352 return;
4355 down = tvb_get_ntohl(tvb, offset);
4356 proto_tree_add_uint_format_value(tree, hf_batadv_tvlv_gw_download,
4357 tvb, offset, 4, down, "%u.%uMbit",
4358 down / 10, down % 10);
4359 offset += 4;
4361 up = tvb_get_ntohl(tvb, offset);
4362 proto_tree_add_uint_format_value(tree, hf_batadv_tvlv_gw_upload, tvb,
4363 offset, 4, up, "%u.%uMbit",
4364 up / 10, up % 10);
4367 static void dissect_batadv_tvlv_v15_roam(tvbuff_t *tvb, packet_info *pinfo,
4368 proto_tree *tree, int offset,
4369 uint8_t version)
4371 static int * const flags[] = {
4372 &hf_batadv_tvlv_vid_vlan,
4373 &hf_batadv_tvlv_vid_tagged,
4374 NULL
4377 if (version != 0x01) {
4378 proto_tree_add_expert_format(
4379 tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4380 offset, 0, "Unknown version (0x%02x)", version);
4381 return;
4384 proto_tree_add_item(tree, hf_batadv_tvlv_roam_addr, tvb, offset, 6,
4385 ENC_NA);
4386 offset += 6;
4388 proto_tree_add_bitmask(tree, tvb, offset, hf_batadv_tvlv_roam_vid,
4389 ett_batadv_tvlv_vid, flags, ENC_NA);
4392 static void dissect_batadv_tvlv_v15_tt(tvbuff_t *tvb, packet_info *pinfo,
4393 proto_tree *tree, int offset,
4394 uint8_t version)
4396 uint16_t num_vlan;
4397 int i;
4398 int length_remaining;
4399 static int * const flags[] = {
4400 &hf_batadv_tvlv_tt_flags_type,
4401 &hf_batadv_tvlv_tt_flags_full_table,
4402 NULL
4404 uint8_t tt_flags;
4405 int changes_offset;
4407 tt_flags = tvb_get_uint8(tvb, offset);
4409 if (version != 0x01) {
4410 proto_tree_add_expert_format(
4411 tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4412 offset, 0, "Unknown version (0x%02x)", version);
4413 return;
4416 proto_tree_add_bitmask(tree, tvb, offset, hf_batadv_tvlv_tt_flags,
4417 ett_batadv_tvlv_tt_flags, flags, ENC_NA);
4418 offset += 1;
4420 proto_tree_add_item(tree, hf_batadv_tvlv_tt_ttvn, tvb, offset, 1,
4421 ENC_BIG_ENDIAN);
4422 offset += 1;
4424 num_vlan = tvb_get_ntohs(tvb, offset);
4425 proto_tree_add_item(tree, hf_batadv_tvlv_tt_num_vlan, tvb, offset, 2,
4426 ENC_BIG_ENDIAN);
4427 offset += 2;
4429 changes_offset = offset + num_vlan * TLVLV_TT_VLAN_V15_SIZE;
4431 for (i = 0; i < num_vlan; i++)
4432 offset = dissect_batadv_tvlv_v15_tt_vlan(tvb, pinfo, tree,
4433 offset, tt_flags,
4434 changes_offset);
4436 length_remaining = tvb_reported_length_remaining(tvb, offset);
4437 while (length_remaining > 0) {
4438 offset = dissect_batadv_tvlv_v15_tt_change(tvb, pinfo, tree,
4439 offset);
4440 length_remaining = tvb_reported_length_remaining(tvb, offset);
4444 static void dissect_batadv_tvlv_v15_tt_vlan_checksum(tvbuff_t *tvb,
4445 proto_item *ti,
4446 packet_info *pinfo,
4447 proto_tree *tree,
4448 uint16_t vlan_id,
4449 int crc_offset,
4450 uint8_t tt_flags,
4451 int offset)
4453 const uint8_t *buf;
4454 uint32_t crc32;
4455 uint32_t crc = 0;
4456 int length_remaining;
4457 uint16_t vid;
4458 unsigned int num_entries = 0;
4459 uint8_t full_response = (BATADV_TVLVL_TT_RESPONSE | BATADV_TVLVL_TT_FULL_TABLE);
4461 /* checksum checks are not possible with non full responses */
4462 if (tt_flags != full_response) {
4463 proto_tree_add_item(tree, hf_batadv_tvlv_tt_vlan_crc, tvb,
4464 crc_offset, 4, ENC_BIG_ENDIAN);
4465 return;
4468 length_remaining = tvb_reported_length_remaining(tvb, offset);
4469 while (length_remaining >= TLVLV_TT_CHANGE_V15_SIZE) {
4471 vid = tvb_get_ntohs(tvb, offset + 10);
4472 if (vid != vlan_id)
4473 goto skip;
4475 buf = tvb_get_ptr(tvb, offset, TLVLV_TT_CHANGE_V15_SIZE);
4476 if (!buf)
4477 goto skip;
4479 num_entries++;
4481 /* checksum over vid, flags, address */
4482 crc32 = 0;
4483 crc32 = crc32c_calculate_no_swap(&buf[10], 2, crc32);
4484 crc32 = crc32c_calculate_no_swap(buf, 1, crc32);
4485 crc32 = crc32c_calculate_no_swap(&buf[4], 6, crc32);
4486 crc ^= crc32;
4488 skip:
4489 offset += TLVLV_TT_CHANGE_V15_SIZE;
4490 length_remaining = tvb_reported_length_remaining(tvb, offset);
4493 proto_tree_add_checksum(tree, tvb, crc_offset,
4494 hf_batadv_tvlv_tt_vlan_crc,
4495 hf_batadv_tvlv_tt_vlan_crc_status,
4496 &ei_batadv_tvlv_tt_vlan_crc, pinfo, crc,
4497 ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
4499 if (num_entries == 0)
4500 expert_add_info(pinfo, ti, &ei_batadv_tvlv_tt_vlan_empty);
4503 static int dissect_batadv_tvlv_v15_tt_vlan(tvbuff_t *tvb,
4504 packet_info *pinfo,
4505 proto_tree *tree, int offset,
4506 uint8_t tt_flags,
4507 int changes_offset)
4509 proto_tree *vlan_tree = NULL;
4510 uint16_t vid;
4511 proto_item *ti = NULL;
4512 static int * const flags[] = {
4513 &hf_batadv_tvlv_vid_vlan,
4514 &hf_batadv_tvlv_vid_tagged,
4515 NULL
4518 vid = tvb_get_ntohs(tvb, offset + 4);
4520 /* Set tree info */
4521 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
4522 tvb, offset, 8,
4523 "VLAN, %04x", vid);
4524 vlan_tree = proto_item_add_subtree(ti, ett_batadv_tvlv_tt_vlan);
4526 dissect_batadv_tvlv_v15_tt_vlan_checksum(tvb, ti, pinfo, vlan_tree, vid,
4527 offset, tt_flags,
4528 changes_offset);
4529 offset += 4;
4531 proto_tree_add_bitmask(vlan_tree, tvb, offset,
4532 hf_batadv_tvlv_tt_vlan_vid,
4533 ett_batadv_tvlv_vid, flags, ENC_NA);
4534 offset += 2;
4536 /* Skip 2 byte of padding. */
4537 offset += 2;
4539 return offset;
4542 static int dissect_batadv_tvlv_v15_tt_change(tvbuff_t *tvb,
4543 packet_info *pinfo _U_,
4544 proto_tree *tree, int offset)
4546 proto_tree *change_tree;
4547 proto_item *ti;
4548 static int * const flags[] = {
4549 &hf_batadv_tvlv_tt_change_flags_del,
4550 &hf_batadv_tvlv_tt_change_flags_roam,
4551 &hf_batadv_tvlv_tt_change_flags_wifi,
4552 &hf_batadv_tvlv_tt_change_flags_isolate,
4553 NULL
4555 static int * const flags_vlan[] = {
4556 &hf_batadv_tvlv_vid_vlan,
4557 &hf_batadv_tvlv_vid_tagged,
4558 NULL
4561 /* Set tree info */
4562 ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
4563 tvb, offset, 12,
4564 "Entry, %s",
4565 tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, offset + 4));
4566 change_tree = proto_item_add_subtree(ti, ett_batadv_tvlv_tt_change);
4568 proto_tree_add_bitmask(change_tree, tvb, offset,
4569 hf_batadv_tvlv_tt_change_flags,
4570 ett_batadv_batman_flags, flags, ENC_NA);
4571 offset += 1;
4573 /* Skip 3 byte of padding. */
4574 offset += 3;
4576 proto_tree_add_item(change_tree, hf_batadv_tvlv_tt_change_addr, tvb,
4577 offset, 6, ENC_NA);
4578 offset += 6;
4580 proto_tree_add_bitmask(change_tree, tvb, offset,
4581 hf_batadv_tvlv_tt_change_vid,
4582 ett_batadv_tvlv_vid, flags_vlan, ENC_NA);
4583 offset += 2;
4585 return offset;
4588 void proto_register_batadv(void)
4590 module_t *batadv_module;
4591 expert_module_t* expert_batadv;
4593 static hf_register_info hf[] = {
4594 { &hf_batadv_packet_type,
4595 { "Packet Type", "batadv.batman.packet_type",
4596 FT_UINT8, BASE_DEC, NULL, 0x0,
4597 NULL, HFILL }
4599 { &hf_batadv_batman_version,
4600 { "Version", "batadv.batman.version",
4601 FT_UINT8, BASE_DEC, NULL, 0x0,
4602 NULL, HFILL }
4604 { &hf_batadv_batman_flags,
4605 { "Flags", "batadv.batman.flags",
4606 FT_UINT8, BASE_HEX, NULL, 0x0,
4607 NULL, HFILL }
4609 { &hf_batadv_batman_ttl,
4610 { "Time to Live", "batadv.batman.ttl",
4611 FT_UINT8, BASE_DEC, NULL, 0x0,
4612 NULL, HFILL }
4614 { &hf_batadv_batman_gwflags,
4615 { "Gateway Flags", "batadv.batman.gwflags",
4616 FT_UINT8, BASE_HEX, NULL, 0x0,
4617 NULL, HFILL }
4619 { &hf_batadv_batman_gwflags_dl_speed,
4620 { "Download Speed", "batadv.batman.gwflags.dl_speed",
4621 FT_UINT32, BASE_DEC|BASE_UNIT_STRING, UNS(&units_kbit), 0x0,
4622 NULL, HFILL }
4624 { &hf_batadv_batman_gwflags_ul_speed,
4625 { "Upload Speed", "batadv.batman.gwflags.ul_speed",
4626 FT_UINT32, BASE_DEC|BASE_UNIT_STRING, UNS(&units_kbit), 0x0,
4627 NULL, HFILL }
4629 { &hf_batadv_batman_tq,
4630 { "Transmission Quality", "batadv.batman.tq",
4631 FT_UINT8, BASE_DEC, NULL, 0x0,
4632 NULL, HFILL }
4634 { &hf_batadv_batman_seqno,
4635 { "Sequence number", "batadv.batman.seq",
4636 FT_UINT16, BASE_DEC, NULL, 0x0,
4637 NULL, HFILL }
4639 { &hf_batadv_batman_seqno32,
4640 { "Sequence number", "batadv.batman.seq",
4641 FT_UINT32, BASE_DEC, NULL, 0x0,
4642 NULL, HFILL }
4644 { &hf_batadv_batman_orig,
4645 { "Originator", "batadv.batman.orig",
4646 FT_ETHER, BASE_NONE, NULL, 0x0,
4647 NULL, HFILL }
4649 { &hf_batadv_batman_prev_sender,
4650 { "Received from", "batadv.batman.prev_sender",
4651 FT_ETHER, BASE_NONE, NULL, 0x0,
4652 NULL, HFILL }
4654 { &hf_batadv_batman_num_tt,
4655 { "Number of TTs", "batadv.batman.num_tt",
4656 FT_UINT8, BASE_DEC, NULL, 0x0,
4657 NULL, HFILL }
4659 { &hf_batadv_batman_tt_num_changes,
4660 { "Number of TT Changes", "batadv.batman.tt_num_changes",
4661 FT_UINT8, BASE_DEC, NULL, 0x0,
4662 NULL, HFILL }
4664 { &hf_batadv_batman_ttvn,
4665 { "TT Version", "batadv.batman.ttvn",
4666 FT_UINT8, BASE_DEC, NULL, 0x0,
4667 NULL, HFILL }
4669 { &hf_batadv_batman_tt_crc,
4670 { "CRC of TT", "batadv.batman.tt_crc",
4671 FT_UINT16, BASE_HEX, NULL, 0x0,
4672 NULL, HFILL }
4674 { &hf_batadv_batman_flags_directlink,
4675 { "DirectLink", "batadv.batman.flags.directlink",
4676 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x40,
4677 NULL, HFILL }
4679 { &hf_batadv_batman_flags_vis_server,
4680 { "VIS_SERVER", "batadv.batman.flags.vis_server",
4681 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x20,
4682 NULL, HFILL }
4684 { &hf_batadv_batman_flags_primaries_first_hop,
4685 { "PRIMARIES_FIRST_HOP", "batadv.batman.flags.primaries_first_hop",
4686 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x10,
4687 NULL, HFILL }
4689 { &hf_batadv_batman_flags_not_best_next_hop,
4690 { "NOT_BEST_NEXT_HOP", "batadv.batman.flags.not_best_next_hop",
4691 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x8,
4692 NULL, HFILL }
4694 { &hf_batadv_iv_ogm_version,
4695 { "Version", "batadv.iv_ogm.version",
4696 FT_UINT8, BASE_DEC, NULL, 0x0,
4697 NULL, HFILL }
4699 { &hf_batadv_iv_ogm_ttl,
4700 { "Time to Live", "batadv.iv_ogm.ttl",
4701 FT_UINT8, BASE_DEC, NULL, 0x0,
4702 NULL, HFILL }
4704 { &hf_batadv_iv_ogm_flags,
4705 { "Flags", "batadv.iv_ogm.flags",
4706 FT_UINT8, BASE_HEX, NULL, 0x0,
4707 NULL, HFILL }
4709 { &hf_batadv_iv_ogm_seqno,
4710 { "Sequence number", "batadv.iv_ogm.seq",
4711 FT_UINT32, BASE_DEC, NULL, 0x0,
4712 NULL, HFILL }
4714 { &hf_batadv_iv_ogm_orig,
4715 { "Originator", "batadv.iv_ogm.orig",
4716 FT_ETHER, BASE_NONE, NULL, 0x0,
4717 NULL, HFILL }
4719 { &hf_batadv_iv_ogm_prev_sender,
4720 { "Received from", "batadv.iv_ogm.prev_sender",
4721 FT_ETHER, BASE_NONE, NULL, 0x0,
4722 NULL, HFILL }
4724 { &hf_batadv_iv_ogm_tq,
4725 { "Transmission Quality", "batadv.iv_ogm.tq",
4726 FT_UINT8, BASE_DEC, NULL, 0x0,
4727 NULL, HFILL }
4729 { &hf_batadv_iv_ogm_tvlv_len,
4730 { "Length of TVLV", "batadv.iv_ogm.tvlv_len",
4731 FT_UINT16, BASE_DEC, NULL, 0x0,
4732 NULL, HFILL }
4734 { &hf_batadv_iv_ogm_flags_not_best_next_hop,
4735 { "NOT_BEST_NEXT_HOP", "batadv.iv_ogm.flags.not_best_next_hop",
4736 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x1,
4737 NULL, HFILL }
4739 { &hf_batadv_iv_ogm_flags_primaries_first_hop,
4740 { "PRIMARIES_FIRST_HOP", "batadv.iv_ogm.flags.primaries_first_hop",
4741 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x2,
4742 NULL, HFILL }
4744 { &hf_batadv_iv_ogm_flags_directlink,
4745 { "DirectLink", "batadv.iv_ogm.flags.directlink",
4746 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x4,
4747 NULL, HFILL }
4749 { &hf_batadv_ogm2_version,
4750 { "Version", "batadv.ogm2.version",
4751 FT_UINT8, BASE_DEC, NULL, 0x0,
4752 NULL, HFILL }
4754 { &hf_batadv_ogm2_ttl,
4755 { "Time to Live", "batadv.ogm2.ttl",
4756 FT_UINT8, BASE_DEC, NULL, 0x0,
4757 NULL, HFILL }
4759 { &hf_batadv_ogm2_flags,
4760 { "Flags", "batadv.ogm2.flags",
4761 FT_UINT8, BASE_HEX, NULL, 0x0,
4762 "Unused", HFILL }
4764 { &hf_batadv_ogm2_seqno,
4765 { "Sequence number", "batadv.ogm2.seq",
4766 FT_UINT32, BASE_DEC, NULL, 0x0,
4767 NULL, HFILL }
4769 { &hf_batadv_ogm2_orig,
4770 { "Originator", "batadv.ogm2.orig",
4771 FT_ETHER, BASE_NONE, NULL, 0x0,
4772 NULL, HFILL }
4774 { &hf_batadv_ogm2_tvlv_len,
4775 { "Length of TVLV", "batadv.ogm2.tvlv_len",
4776 FT_UINT16, BASE_DEC, NULL, 0x0,
4777 NULL, HFILL }
4779 { &hf_batadv_ogm2_throughput,
4780 { "Throughput", "batadv.ogm2.throughput",
4781 FT_UINT32, BASE_DEC, NULL, 0x0,
4782 NULL, HFILL }
4784 { &hf_batadv_batman_tt,
4785 { "Translation Table", "batadv.batman.tt",
4786 FT_ETHER, BASE_NONE, NULL, 0x0,
4787 NULL, HFILL }
4789 { &hf_batadv_elp_version,
4790 { "Version", "batadv.elp.version",
4791 FT_UINT8, BASE_DEC, NULL, 0x0,
4792 NULL, HFILL }
4794 { &hf_batadv_elp_orig,
4795 { "Originator", "batadv.elp.orig",
4796 FT_ETHER, BASE_NONE, NULL, 0x0,
4797 NULL, HFILL }
4799 { &hf_batadv_elp_seqno,
4800 { "Sequence number", "batadv.elp.seq",
4801 FT_UINT32, BASE_DEC, NULL, 0x0,
4802 NULL, HFILL }
4804 { &hf_batadv_elp_interval,
4805 { "ELP Interval", "batadv.elp.interval",
4806 FT_UINT32, BASE_DEC, NULL, 0x0,
4807 NULL, HFILL }
4809 { &hf_batadv_bcast_version,
4810 { "Version", "batadv.bcast.version",
4811 FT_UINT8, BASE_DEC, NULL, 0x0,
4812 NULL, HFILL }
4814 { &hf_batadv_bcast_orig,
4815 { "Originator", "batadv.bcast.orig",
4816 FT_ETHER, BASE_NONE, NULL, 0x0,
4817 NULL, HFILL }
4819 { &hf_batadv_bcast_seqno,
4820 { "Sequence number", "batadv.bcast.seq",
4821 FT_UINT16, BASE_DEC, NULL, 0x0,
4822 NULL, HFILL }
4824 { &hf_batadv_bcast_seqno32,
4825 { "Sequence number", "batadv.bcast.seq",
4826 FT_UINT32, BASE_DEC, NULL, 0x0,
4827 NULL, HFILL }
4829 { &hf_batadv_bcast_ttl,
4830 { "Time to Live", "batadv.bcast.ttl",
4831 FT_UINT8, BASE_DEC, NULL, 0x0,
4832 NULL, HFILL }
4834 { &hf_batadv_icmp_version,
4835 { "Version", "batadv.icmp.version",
4836 FT_UINT8, BASE_DEC, NULL, 0x0,
4837 NULL, HFILL }
4839 { &hf_batadv_icmp_msg_type,
4840 { "Message Type", "batadv.icmp.msg_type",
4841 FT_UINT8, BASE_DEC, VALS(icmp_packettypenames), 0x0,
4842 NULL, HFILL }
4844 { &hf_batadv_icmp_dst,
4845 { "Destination", "batadv.icmp.dst",
4846 FT_ETHER, BASE_NONE, NULL, 0x0,
4847 NULL, HFILL }
4849 { &hf_batadv_icmp_orig,
4850 { "Originator", "batadv.icmp.orig",
4851 FT_ETHER, BASE_NONE, NULL, 0x0,
4852 NULL, HFILL }
4854 { &hf_batadv_icmp_ttl,
4855 { "Time to Live", "batadv.icmp.ttl",
4856 FT_UINT8, BASE_DEC, NULL, 0x0,
4857 NULL, HFILL}
4859 { &hf_batadv_icmp_uid,
4860 { "UID", "batadv.icmp.uid",
4861 FT_UINT8, BASE_DEC, NULL, 0x0,
4862 NULL, HFILL}
4864 { &hf_batadv_icmp_seqno,
4865 { "Sequence number", "batadv.icmp.seq",
4866 FT_UINT16, BASE_DEC, NULL, 0x0,
4867 NULL, HFILL}
4869 { &hf_batadv_icmp_rr_pointer,
4870 { "Pointer", "batadv.icmp.rr_pointer",
4871 FT_UINT8, BASE_DEC, NULL, 0x0,
4872 NULL, HFILL}
4874 { &hf_batadv_icmp_rr_ether,
4875 { "RR MAC", "batadv.icmp.rr_ether",
4876 FT_ETHER, BASE_NONE, NULL, 0x0,
4877 NULL, HFILL}
4879 { &hf_batadv_icmp_tp_subtype,
4880 { "Subtype", "batadv.icmp.tp.subtype",
4881 FT_UINT8, BASE_DEC, VALS(icmp_tp_packettypenames), 0x0,
4882 NULL, HFILL}
4884 { &hf_batadv_icmp_tp_session,
4885 { "Session", "batadv.icmp.tp.session",
4886 FT_UINT16, BASE_DEC, NULL, 0x0,
4887 NULL, HFILL}
4889 { &hf_batadv_icmp_tp_seqno,
4890 { "Sequence number", "batadv.icmp.tp.seqno",
4891 FT_UINT32, BASE_DEC, NULL, 0x0,
4892 NULL, HFILL}
4894 { &hf_batadv_icmp_tp_timestamp,
4895 { "Timestamp", "batadv.icmp.tp.timestamp",
4896 FT_UINT32, BASE_DEC, NULL, 0x0,
4897 NULL, HFILL}
4899 { &hf_batadv_unicast_version,
4900 { "Version", "batadv.unicast.version",
4901 FT_UINT8, BASE_DEC, NULL, 0x0,
4902 NULL, HFILL }
4904 { &hf_batadv_unicast_dst,
4905 { "Destination", "batadv.unicast.dst",
4906 FT_ETHER, BASE_NONE, NULL, 0x0,
4907 NULL, HFILL }
4909 { &hf_batadv_unicast_ttl,
4910 { "Time to Live", "batadv.unicast.ttl",
4911 FT_UINT8, BASE_DEC, NULL, 0x0,
4912 NULL, HFILL }
4914 { &hf_batadv_unicast_ttvn,
4915 { "TT Version", "batadv.unicast.ttvn",
4916 FT_UINT8, BASE_DEC, NULL, 0x0,
4917 NULL, HFILL }
4919 { &hf_batadv_unicast_4addr_version,
4920 { "Version", "batadv.unicast_4addr.version",
4921 FT_UINT8, BASE_DEC, NULL, 0x0,
4922 NULL, HFILL }
4924 { &hf_batadv_unicast_4addr_dst,
4925 { "Destination", "batadv.unicast_4addr.dst",
4926 FT_ETHER, BASE_NONE, NULL, 0x0,
4927 NULL, HFILL }
4929 { &hf_batadv_unicast_4addr_ttl,
4930 { "Time to Live", "batadv.unicast_4addr.ttl",
4931 FT_UINT8, BASE_DEC, NULL, 0x0,
4932 NULL, HFILL }
4934 { &hf_batadv_unicast_4addr_ttvn,
4935 { "TT Version", "batadv.unicast_4addr.ttvn",
4936 FT_UINT8, BASE_DEC, NULL, 0x0,
4937 NULL, HFILL }
4939 { &hf_batadv_unicast_4addr_src,
4940 { "Source", "batadv.unicast_4addr.src",
4941 FT_ETHER, BASE_NONE, NULL, 0x0,
4942 NULL, HFILL }
4944 { &hf_batadv_unicast_4addr_subtype,
4945 { "Subtype", "batadv.unicast_4addr.subtype",
4946 FT_UINT8, BASE_DEC, VALS (unicast_4addr_typenames), 0x0,
4947 NULL, HFILL }
4949 { &hf_batadv_unicast_frag_version,
4950 { "Version", "batadv.unicast_frag.version",
4951 FT_UINT8, BASE_DEC, NULL, 0x0,
4952 NULL, HFILL }
4954 { &hf_batadv_unicast_frag_dst,
4955 { "Destination", "batadv.unicast_frag.dst",
4956 FT_ETHER, BASE_NONE, NULL, 0x0,
4957 NULL, HFILL }
4959 { &hf_batadv_unicast_frag_ttl,
4960 { "Time to Live", "batadv.unicast_frag.ttl",
4961 FT_UINT8, BASE_DEC, NULL, 0x0,
4962 NULL, HFILL }
4964 { &hf_batadv_unicast_frag_ttvn,
4965 { "TT Version", "batadv.unicast_frag.ttvn",
4966 FT_UINT8, BASE_DEC, NULL, 0x0,
4967 NULL, HFILL }
4969 { &hf_batadv_unicast_frag_flags,
4970 { "Flags", "batadv.unicast_frag.flags",
4971 FT_UINT8, BASE_HEX, NULL, 0x0,
4972 NULL, HFILL }
4974 { &hf_batadv_unicast_frag_flags_head,
4975 { "Head", "batadv.unicast_frag.flags.head",
4976 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x01,
4977 NULL, HFILL }
4979 { &hf_batadv_unicast_frag_flags_largetail,
4980 { "Largetail", "batadv.unicast_frag.flags.largetail",
4981 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x02,
4982 NULL, HFILL }
4984 { &hf_batadv_unicast_frag_orig,
4985 { "Originator", "batadv.unicast_frag.orig",
4986 FT_ETHER, BASE_NONE, NULL, 0x0,
4987 NULL, HFILL }
4989 { &hf_batadv_unicast_frag_seqno,
4990 { "Sequence number", "batadv.unicast_frag.seq",
4991 FT_UINT16, BASE_DEC, NULL, 0x0,
4992 NULL, HFILL }
4994 { &hf_batadv_unicast_frag_no,
4995 { "Fragment number", "batadv.unicast_frag.no",
4996 FT_UINT8, BASE_DEC, NULL, 0xF0,
4997 NULL, HFILL }
4999 { &hf_batadv_unicast_frag_priority,
5000 { "Priority", "batadv.unicast_frag.priority",
5001 FT_UINT8, BASE_DEC, NULL, 0xE,
5002 NULL, HFILL }
5004 { &hf_batadv_unicast_frag_total_size,
5005 { "Complete Size", "batadv.unicast_frag.total_size",
5006 FT_UINT16, BASE_DEC, NULL, 0x0,
5007 NULL, HFILL }
5009 { &hf_batadv_unicast_tvlv_version,
5010 { "Version", "batadv.unicast_tvlv.version",
5011 FT_UINT8, BASE_DEC, NULL, 0x0,
5012 NULL, HFILL }
5014 { &hf_batadv_unicast_tvlv_ttl,
5015 { "Time to Live", "batadv.unicast_tvlv.ttl",
5016 FT_UINT8, BASE_DEC, NULL, 0x0,
5017 NULL, HFILL }
5019 { &hf_batadv_unicast_tvlv_dst,
5020 { "Destination", "batadv.unicast_tvlv.dst",
5021 FT_ETHER, BASE_NONE, NULL, 0x0,
5022 NULL, HFILL }
5024 { &hf_batadv_unicast_tvlv_src,
5025 { "Source", "batadv.unicast_tvlv.src",
5026 FT_ETHER, BASE_NONE, NULL, 0x0,
5027 NULL, HFILL }
5029 { &hf_batadv_unicast_tvlv_len,
5030 { "Length of TVLV", "batadv.unicast_tvlv.len",
5031 FT_UINT16, BASE_DEC, NULL, 0x0,
5032 NULL, HFILL }
5034 { &hf_batadv_vis_version,
5035 { "Version", "batadv.vis.version",
5036 FT_UINT8, BASE_DEC, NULL, 0x0,
5037 NULL, HFILL }
5039 { &hf_batadv_vis_type,
5040 { "Type", "batadv.vis.type",
5041 FT_UINT8, BASE_DEC, VALS(vis_packettypenames), 0x0,
5042 NULL, HFILL }
5044 { &hf_batadv_vis_seqno,
5045 { "Sequence number", "batadv.vis.seq",
5046 FT_UINT8, BASE_DEC, NULL, 0x0,
5047 NULL, HFILL}
5049 { &hf_batadv_vis_seqno32,
5050 { "Sequence number", "batadv.vis.seq",
5051 FT_UINT32, BASE_DEC, NULL, 0x0,
5052 NULL, HFILL}
5054 { &hf_batadv_vis_entries,
5055 { "Entries", "batadv.vis.entries",
5056 FT_UINT8, BASE_DEC, NULL, 0x0,
5057 "Number of entries", HFILL}
5059 { &hf_batadv_vis_ttl,
5060 { "Time to Live", "batadv.vis.ttl",
5061 FT_UINT8, BASE_DEC, NULL, 0x0,
5062 NULL, HFILL}
5064 { &hf_batadv_vis_vis_orig,
5065 { "Originator", "batadv.vis.vis_orig",
5066 FT_ETHER, BASE_NONE, NULL, 0x0,
5067 NULL, HFILL }
5069 { &hf_batadv_vis_target_orig,
5070 { "Target Originator", "batadv.vis.target_orig",
5071 FT_ETHER, BASE_NONE, NULL, 0x0,
5072 NULL, HFILL }
5074 { &hf_batadv_vis_sender_orig,
5075 { "Forwarding Originator", "batadv.vis.sender_orig",
5076 FT_ETHER, BASE_NONE, NULL, 0x0,
5077 NULL, HFILL }
5079 { &hf_batadv_vis_entry_src,
5080 { "Source", "batadv.vis.src",
5081 FT_ETHER, BASE_NONE, NULL, 0x0,
5082 NULL, HFILL }
5084 { &hf_batadv_vis_entry_dst,
5085 { "Destination", "batadv.vis.dst",
5086 FT_ETHER, BASE_NONE, NULL, 0x0,
5087 NULL, HFILL }
5089 { &hf_batadv_vis_entry_quality,
5090 { "Quality", "batadv.vis.quality",
5091 FT_UINT8, BASE_DEC, NULL, 0x0,
5092 NULL, HFILL }
5094 { &hf_batadv_tt_query_version,
5095 { "Version", "batadv.tt_query.version",
5096 FT_UINT8, BASE_DEC, NULL, 0x0,
5097 NULL, HFILL }
5099 { &hf_batadv_tt_query_ttl,
5100 { "Time to Live", "batadv.tt_query.ttl",
5101 FT_UINT8, BASE_DEC, NULL, 0x0,
5102 NULL, HFILL}
5104 { &hf_batadv_tt_query_flags,
5105 { "Flags", "batadv.tt_query.flags",
5106 FT_UINT8, BASE_HEX, NULL, 0x0,
5107 NULL, HFILL }
5109 { &hf_batadv_tt_query_flags_type,
5110 { "Query Type", "batadv.tt_query.flags.type",
5111 FT_UINT8, BASE_HEX, VALS (tt_query_type_v14), TT_TYPE_MASK,
5112 NULL, HFILL }
5114 { &hf_batadv_tt_query_flags_full_table,
5115 { "Full Table", "batadv.tt_query.flags.full_table",
5116 FT_BOOLEAN, 8, TFS(&tfs_set_notset), TT_FULL_TABLE,
5117 NULL, HFILL }
5119 { &hf_batadv_tt_query_dst,
5120 { "Destination", "batadv.tt_query.dst",
5121 FT_ETHER, BASE_NONE, NULL, 0x0,
5122 NULL, HFILL }
5124 { &hf_batadv_tt_query_src,
5125 { "Source", "batadv.tt_query.src",
5126 FT_ETHER, BASE_NONE, NULL, 0x0,
5127 NULL, HFILL }
5129 { &hf_batadv_tt_query_ttvn,
5130 { "TT Version", "batadv.tt_query.ttvn",
5131 FT_UINT8, BASE_DEC, NULL, 0x0,
5132 NULL, HFILL }
5134 { &hf_batadv_tt_query_tt_crc,
5135 { "CRC of TT", "batadv.tt_query.tt_crc",
5136 FT_UINT16, BASE_HEX, NULL, 0x0,
5137 NULL, HFILL }
5139 { &hf_batadv_tt_query_entries,
5140 { "Entries", "batadv.tt_query.entries",
5141 FT_UINT16, BASE_DEC, NULL, 0x0,
5142 "Number of entries", HFILL }
5144 { &hf_batadv_roam_adv_version,
5145 { "Version", "batadv.roam_adv.version",
5146 FT_UINT8, BASE_DEC, NULL, 0x0,
5147 NULL, HFILL }
5149 { &hf_batadv_roam_adv_ttl,
5150 { "Time to Live", "batadv.roam_adv.ttl",
5151 FT_UINT8, BASE_DEC, NULL, 0x0,
5152 NULL, HFILL}
5154 { &hf_batadv_roam_adv_src,
5155 { "Source", "batadv.roam_adv.src",
5156 FT_ETHER, BASE_NONE, NULL, 0x0,
5157 NULL, HFILL }
5159 { &hf_batadv_roam_adv_dst,
5160 { "Destination", "batadv.roam_adv.dst",
5161 FT_ETHER, BASE_NONE, NULL, 0x0,
5162 NULL, HFILL }
5164 { &hf_batadv_roam_adv_client,
5165 { "Client", "batadv.roam_adv.client",
5166 FT_ETHER, BASE_NONE, NULL, 0x0,
5167 NULL, HFILL }
5169 { &hf_batadv_coded_version,
5170 { "Version", "batadv.coded.version",
5171 FT_UINT8, BASE_DEC, NULL, 0x0,
5172 NULL, HFILL }
5174 { &hf_batadv_coded_ttl,
5175 { "Time to Live", "batadv.coded.ttl",
5176 FT_UINT8, BASE_DEC, NULL, 0x0,
5177 NULL, HFILL}
5179 { &hf_batadv_coded_first_ttvn,
5180 { "TT Version (First)", "batadv.coded.first_ttvn",
5181 FT_UINT8, BASE_DEC, NULL, 0x0,
5182 NULL, HFILL}
5184 { &hf_batadv_coded_first_source,
5185 { "Source (First)", "batadv.coded.first_src",
5186 FT_ETHER, BASE_NONE, NULL, 0x0,
5187 NULL, HFILL }
5189 { &hf_batadv_coded_first_orig_dest,
5190 { "Original Destination (First)", "batadv.coded.first_orig_dst",
5191 FT_ETHER, BASE_NONE, NULL, 0x0,
5192 NULL, HFILL }
5194 { &hf_batadv_coded_first_crc,
5195 { "CRC (First)", "batadv.coded.first_crc",
5196 FT_UINT32, BASE_HEX, NULL, 0x0,
5197 NULL, HFILL }
5199 { &hf_batadv_coded_second_ttl,
5200 { "Time to Live (Second)", "batadv.coded.second_ttl",
5201 FT_UINT8, BASE_DEC, NULL, 0x0,
5202 NULL, HFILL}
5204 { &hf_batadv_coded_second_ttvn,
5205 { "TT Version (Second)", "batadv.coded.second_ttvn",
5206 FT_UINT8, BASE_DEC, NULL, 0x0,
5207 NULL, HFILL}
5209 { &hf_batadv_coded_second_dest,
5210 { "Destination (Second)", "batadv.coded.second_dst",
5211 FT_ETHER, BASE_NONE, NULL, 0x0,
5212 NULL, HFILL }
5214 { &hf_batadv_coded_second_source,
5215 { "Source (Second)", "batadv.coded.second_src",
5216 FT_ETHER, BASE_NONE, NULL, 0x0,
5217 NULL, HFILL }
5219 { &hf_batadv_coded_second_orig_dest,
5220 { "Original Destination (Second)", "batadv.coded.second_orig_dst",
5221 FT_ETHER, BASE_NONE, NULL, 0x0,
5222 NULL, HFILL }
5224 { &hf_batadv_coded_second_crc,
5225 { "CRC (Second)", "batadv.coded.second_crc",
5226 FT_UINT32, BASE_HEX, NULL, 0x0,
5227 NULL, HFILL }
5229 { &hf_batadv_coded_coded_len,
5230 { "Length", "batadv.coded.length",
5231 FT_UINT16, BASE_DEC, NULL, 0x0,
5232 NULL, HFILL }
5234 { &hf_msg_fragments,
5235 {"Message fragments", "batadv.unicast_frag.fragments",
5236 FT_NONE, BASE_NONE, NULL, 0x00,
5237 NULL, HFILL }
5239 { &hf_batadv_tt_entry,
5240 { "Entry", "batadv.tt_entry.entry",
5241 FT_ETHER, BASE_NONE, NULL, 0x0,
5242 NULL, HFILL }
5244 { &hf_batadv_tt_entry_flags,
5245 { "Flags", "batadv.tt_entry.flags",
5246 FT_UINT8, BASE_HEX, NULL, 0x0,
5247 NULL, HFILL }
5249 { &hf_batadv_tt_entry_flags_change_del,
5250 { "Delete", "batadv.tt_entry.flags.change_del",
5251 FT_BOOLEAN, 8, TFS(&tfs_set_notset), TT_CHANGE_DEL,
5252 NULL, HFILL }
5254 { &hf_batadv_tt_entry_flags_client_roam,
5255 { "Client Roam", "batadv.tt_entry.flags.client_roam",
5256 FT_BOOLEAN, 8, TFS(&tfs_set_notset), TT_CLIENT_ROAM,
5257 NULL, HFILL }
5259 { &hf_msg_fragment,
5260 {"Message fragment", "batadv.unicast_frag.fragment",
5261 FT_FRAMENUM, BASE_NONE, NULL, 0x00,
5262 NULL, HFILL }
5264 { &hf_msg_fragment_overlap,
5265 {"Message fragment overlap", "batadv.unicast_frag.fragment.overlap",
5266 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
5267 NULL, HFILL }
5269 { &hf_msg_fragment_overlap_conflicts,
5270 {"Message fragment overlapping with conflicting data",
5271 "batadv.unicast_frag.fragment.overlap.conflicts",
5272 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
5273 NULL, HFILL }
5275 { &hf_msg_fragment_multiple_tails,
5276 {"Message has multiple tail fragments",
5277 "batadv.unicast_frag.fragment.multiple_tails",
5278 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
5279 NULL, HFILL }
5281 { &hf_msg_fragment_too_long_fragment,
5282 {"Message fragment too long", "batadv.unicast_frag.fragment.too_long_fragment",
5283 FT_BOOLEAN, BASE_NONE, NULL, 0x00,
5284 NULL, HFILL }
5286 { &hf_msg_fragment_error,
5287 {"Message defragmentation error", "batadv.unicast_frag.fragment.error",
5288 FT_FRAMENUM, BASE_NONE, NULL, 0x00,
5289 NULL, HFILL }
5291 { &hf_msg_fragment_count,
5292 {"Message fragment count", "batadv.unicast_frag.fragment.count",
5293 FT_UINT32, BASE_DEC, NULL, 0x00,
5294 NULL, HFILL }
5296 { &hf_msg_reassembled_in,
5297 {"Reassembled in", "batadv.msg.reassembled.in",
5298 FT_FRAMENUM, BASE_NONE, NULL, 0x00,
5299 NULL, HFILL }
5301 { &hf_msg_reassembled_length,
5302 {"Reassembled length", "batadv.msg.reassembled.length",
5303 FT_UINT32, BASE_DEC, NULL, 0x00,
5304 NULL, HFILL }
5306 { &hf_batadv_tvlv_type,
5307 { "Type", "batadv.tvlv.length",
5308 FT_UINT8, BASE_HEX, NULL, 0x0,
5309 NULL, HFILL }
5311 { &hf_batadv_tvlv_version,
5312 { "Version", "batadv.tvlv.version",
5313 FT_UINT8, BASE_HEX, NULL, 0x0,
5314 NULL, HFILL }
5316 { &hf_batadv_tvlv_len,
5317 { "Length", "batadv.tvlv.len",
5318 FT_UINT16, BASE_DEC, NULL, 0x0,
5319 NULL, HFILL }
5321 { &hf_batadv_tvlv_mcast_flags,
5322 { "Flags", "batadv.tvlv.mcast.flags",
5323 FT_UINT8, BASE_HEX, NULL, 0x0,
5324 NULL, HFILL }
5326 { &hf_batadv_tvlv_mcast_flags_unsnoopables,
5327 { "Unsnoopables", "batadv.tvlv.mcast.flags.unsnoopables",
5328 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x1,
5329 NULL, HFILL }
5331 { &hf_batadv_tvlv_mcast_flags_ipv4,
5332 { "IPv4", "batadv.tvlv.mcast.flags.ipv4",
5333 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x2,
5334 NULL, HFILL }
5336 { &hf_batadv_tvlv_mcast_flags_ipv6,
5337 { "IPv6", "batadv.tvlv.mcast.flags.ipv6",
5338 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x4,
5339 NULL, HFILL }
5341 { &hf_batadv_tvlv_mcast_flags_no_rtr4,
5342 { "No IPv4 multicast router", "batadv.tvlv.mcast.flags.no_rtr4",
5343 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x8,
5344 NULL, HFILL }
5346 { &hf_batadv_tvlv_mcast_flags_no_rtr6,
5347 { "No IPv6 multicast router", "batadv.tvlv.mcast.flags.no_rtr6",
5348 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x10,
5349 NULL, HFILL }
5351 { &hf_batadv_tvlv_gw_download,
5352 { "Download Speed", "batadv.tvlv.gw.dl_speed",
5353 FT_UINT32, BASE_DEC, NULL, 0x0,
5354 NULL, HFILL }
5356 { &hf_batadv_tvlv_gw_upload,
5357 { "Upload Speed", "batadv.tvlv.gw.ul_speed",
5358 FT_UINT32, BASE_DEC, NULL, 0x0,
5359 NULL, HFILL }
5361 { &hf_batadv_tvlv_roam_addr,
5362 { "Address", "batadv.batman.addr",
5363 FT_ETHER, BASE_NONE, NULL, 0x0,
5364 NULL, HFILL }
5366 { &hf_batadv_tvlv_roam_vid,
5367 { "VID", "batadv.tvlv.roam.vid",
5368 FT_UINT16, BASE_HEX, NULL, 0x0,
5369 NULL, HFILL }
5371 { &hf_batadv_tvlv_vid_vlan,
5372 { "VLAN ID", "batadv.tvlv.vid_vlan",
5373 FT_UINT16, BASE_DEC, NULL, 0x7fff,
5374 NULL, HFILL }
5376 { &hf_batadv_tvlv_vid_tagged,
5377 { "VLAN Tagged", "batadv.tvlv.vid_tagged",
5378 FT_UINT16, BASE_DEC, NULL, 0x8000,
5379 NULL, HFILL }
5381 { &hf_batadv_tvlv_tt_flags,
5382 { "Flags", "batadv.tvlv.tt.flags",
5383 FT_UINT8, BASE_HEX, NULL, 0x0,
5384 NULL, HFILL }
5386 { &hf_batadv_tvlv_tt_flags_type,
5387 { "Query Type", "batadv.tvlv.tt.flags.type",
5388 FT_UINT8, BASE_HEX, VALS(tvlv_tt_typenames),
5389 BATADV_TVLVL_TT_TYPE_MASK,
5390 NULL, HFILL }
5392 { &hf_batadv_tvlv_tt_flags_full_table,
5393 { "Full Table", "batadv.tvlv.tt.flags.full_table",
5394 FT_BOOLEAN, 8, TFS(&tfs_set_notset),
5395 BATADV_TVLVL_TT_FULL_TABLE,
5396 NULL, HFILL }
5398 { &hf_batadv_tvlv_tt_ttvn,
5399 { "TT Version", "batadv.tvlv.tt.ttvn",
5400 FT_UINT8, BASE_DEC, NULL, 0x0,
5401 NULL, HFILL }
5403 { &hf_batadv_tvlv_tt_num_vlan,
5404 { "VLAN Entries", "batadv.tvlv.tt.num_vlan",
5405 FT_UINT16, BASE_DEC, NULL, 0x0,
5406 NULL, HFILL }
5408 { &hf_batadv_tvlv_tt_vlan_crc,
5409 { "CRC", "batadv.tvlv.tt.vlan.crc",
5410 FT_UINT32, BASE_HEX, NULL, 0x0,
5411 NULL, HFILL }
5413 { &hf_batadv_tvlv_tt_vlan_crc_status,
5414 { "Checksum Status", "batadv.tvlv.tt.vlan.crc.status",
5415 FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
5416 NULL, HFILL }
5418 { &hf_batadv_tvlv_tt_vlan_vid,
5419 { "VID", "batadv.tvlv.tt.vlan.vid",
5420 FT_UINT16, BASE_HEX, NULL, 0x0,
5421 NULL, HFILL }
5423 { &hf_batadv_tvlv_tt_change_flags,
5424 { "Flags", "batadv.tvlv.tt.change.flags",
5425 FT_UINT8, BASE_HEX, NULL, 0x0,
5426 NULL, HFILL }
5428 { &hf_batadv_tvlv_tt_change_flags_del,
5429 { "Delete", "batadv.tvlv.tt.change.flags.del",
5430 FT_BOOLEAN, 8, TFS(&tfs_set_notset),
5431 BATADV_TVLVL_TT_CHANGE_DEL,
5432 NULL, HFILL }
5434 { &hf_batadv_tvlv_tt_change_flags_roam,
5435 { "Client Roam", "batadv.tvlv.tt.change.flags.roam",
5436 FT_BOOLEAN, 8, TFS(&tfs_set_notset),
5437 BATADV_TVLVL_TT_CHANGE_ROAM,
5438 NULL, HFILL }
5440 { &hf_batadv_tvlv_tt_change_flags_wifi,
5441 { "Wifi Client", "batadv.tvlv.tt.change.flags.wifi",
5442 FT_BOOLEAN, 8, TFS(&tfs_set_notset),
5443 BATADV_TVLVL_TT_CHANGE_WIFI,
5444 NULL, HFILL }
5446 { &hf_batadv_tvlv_tt_change_flags_isolate,
5447 { "Isolate", "batadv.tvlv.tt.change.flags.isolate",
5448 FT_BOOLEAN, 8, TFS(&tfs_set_notset),
5449 BATADV_TVLVL_TT_CHANGE_ISOLATE,
5450 NULL, HFILL }
5452 { &hf_batadv_tvlv_tt_change_addr,
5453 { "Address", "batadv.tvlv.tt.change.addr",
5454 FT_ETHER, BASE_NONE, NULL, 0x0,
5455 NULL, HFILL }
5457 { &hf_batadv_tvlv_tt_change_vid,
5458 { "VID", "batadv.tvlv.tt.change.vid",
5459 FT_UINT16, BASE_HEX, NULL, 0x0,
5460 NULL, HFILL }
5464 /* Setup protocol subtree array */
5465 static int *ett[] = {
5466 &ett_batadv_batman,
5467 &ett_batadv_batman_flags,
5468 &ett_batadv_batman_tt,
5469 &ett_batadv_batman_gwflags,
5470 &ett_batadv_iv_ogm,
5471 &ett_batadv_iv_ogm_flags,
5472 &ett_batadv_elp,
5473 &ett_batadv_ogm2,
5474 //&ett_batadv_ogm2_flags,
5475 &ett_batadv_bcast,
5476 &ett_batadv_icmp,
5477 &ett_batadv_icmp_rr,
5478 &ett_batadv_unicast,
5479 &ett_batadv_unicast_4addr,
5480 &ett_batadv_unicast_frag,
5481 &ett_batadv_unicast_tvlv,
5482 &ett_batadv_vis,
5483 &ett_batadv_vis_entry,
5484 &ett_batadv_tt_query,
5485 &ett_batadv_tt_query_flags,
5486 &ett_batadv_tt_entry,
5487 &ett_batadv_tt_entry_flags,
5488 &ett_batadv_roam_adv,
5489 &ett_batadv_coded,
5490 &ett_batadv_tvlv,
5491 &ett_batadv_tvlv_vid,
5492 &ett_batadv_tvlv_mcast_flags,
5493 &ett_batadv_tvlv_tt_flags,
5494 &ett_batadv_tvlv_tt_vlan,
5495 &ett_batadv_tvlv_tt_change,
5496 &ett_msg_fragment,
5497 &ett_msg_fragments
5500 static ei_register_info ei[] = {
5501 { &ei_batadv_tvlv_unknown_version, { "batadv.error.tvlv_version_unknown", PI_UNDECODED, PI_ERROR, "BATADV Error: unknown TVLV version", EXPFILL }},
5502 { &ei_batadv_tvlv_tt_vlan_crc, { "batadv.tvlv_tt_crc_bad", PI_UNDECODED, PI_ERROR, "BATADV Error: bad TT VLAN crc", EXPFILL }},
5503 { &ei_batadv_tvlv_tt_vlan_empty, { "batadv.tvlv_tt_vlan_empty", PI_SEQUENCE, PI_WARN, "BATADV Warn: empty VLAN", EXPFILL }},
5506 proto_batadv_plugin = proto_register_protocol("B.A.T.M.A.N. Advanced Protocol", "BATADV", "batadv");
5508 batman_handle = register_dissector("batadv",dissect_batadv_plugin,proto_batadv_plugin);
5510 batadv_module = prefs_register_protocol(proto_batadv_plugin,
5511 proto_reg_handoff_batadv);
5513 prefs_register_uint_preference(batadv_module, "batmanadv.ethertype",
5514 "Ethertype",
5515 "Ethertype used to indicate B.A.T.M.A.N. packet.",
5516 16, &batadv_ethertype);
5518 proto_register_subtree_array(ett, array_length(ett));
5519 proto_register_field_array(proto_batadv_plugin, hf, array_length(hf));
5521 expert_batadv = expert_register_protocol(proto_batadv_plugin);
5522 expert_register_field_array(expert_batadv, ei, array_length(ei));
5524 reassembly_table_register(&msg_reassembly_table,
5525 &addresses_reassembly_table_functions);
5527 batadv_tap = register_tap("batman");
5528 batadv_follow_tap = register_tap("batman_follow");
5531 void proto_reg_handoff_batadv(void)
5533 static bool inited = false;
5534 static unsigned int old_batadv_ethertype;
5536 if (!inited) {
5537 eth_handle = find_dissector_add_dependency("eth_withoutfcs", proto_batadv_plugin);
5539 inited = true;
5540 } else {
5541 dissector_delete_uint("ethertype", old_batadv_ethertype, batman_handle);
5544 old_batadv_ethertype = batadv_ethertype;
5545 dissector_add_uint("ethertype", batadv_ethertype, batman_handle);
5549 * Editor modelines - https://www.wireshark.org/tools/modelines.html
5551 * Local variables:
5552 * c-basic-offset: 8
5553 * tab-width: 8
5554 * indent-tabs-mode: t
5555 * End:
5557 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
5558 * :indentSize=8:tabSize=8:noTabs=false: