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
14 #include <epan/packet.h>
15 #include <epan/prefs.h>
17 #include <epan/addr_resolv.h>
18 #include <epan/reassemble.h>
19 #include <epan/expert.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
58 #define DESTINATION_UNREACHABLE 3
59 #define ECHO_REQUEST 8
60 #define TTL_EXCEEDED 11
63 #define TT_TYPE_MASK 0x3
67 #define TT_FULL_TABLE 0x04
69 #define TT_CHANGE_DEL 0x01
70 #define TT_CLIENT_ROAM 0x02
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
{
92 uint8_t version
; /* batman version field */
93 uint8_t flags
; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
95 uint8_t gwflags
; /* flags related to gateway functions: gateway class */
103 #define BATMAN_PACKET_V5_SIZE 22
105 struct batman_packet_v7
{
107 uint8_t version
; /* batman version field */
108 uint8_t flags
; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
116 #define BATMAN_PACKET_V7_SIZE 20
118 struct batman_packet_v9
{
120 uint8_t version
; /* batman version field */
121 uint8_t flags
; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
131 #define BATMAN_PACKET_V9_SIZE 22
133 struct batman_packet_v10
{
135 uint8_t version
; /* batman version field */
136 uint8_t flags
; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
146 #define BATMAN_PACKET_V10_SIZE 24
148 struct batman_packet_v11
{
150 uint8_t version
; /* batman version field */
151 uint8_t flags
; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
159 #define BATMAN_PACKET_V11_SIZE 22
161 struct batman_packet_v14
{
163 uint8_t version
; /* batman version field */
165 uint8_t flags
; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
169 uint8_t gw_flags
; /* flags related to gateway class */
171 uint8_t tt_num_changes
;
172 uint8_t ttvn
; /* translation table version number */
175 #define BATMAN_PACKET_V14_SIZE 26
177 struct iv_ogm_packet_v15
{
179 uint8_t version
; /* batman version field */
189 #define IV_OGM_PACKET_V15_SIZE 24
191 struct elp_packet_v15
{
198 #define ELP_PACKET_V15_SIZE 16
200 struct ogm2_packet_v15
{
210 #define OGM2_PACKET_V15_SIZE 20
212 struct icmp_packet_v6
{
214 uint8_t version
; /* batman version field */
215 uint8_t msg_type
; /* 0 = ECHO REPLY, 3 = DESTINATION_UNREACHABLE, 8 = ECHO_REQUEST, 11 = TTL exceeded */
222 #define ICMP_PACKET_V6_SIZE 19
224 struct icmp_packet_v7
{
226 uint8_t version
; /* batman version field */
227 uint8_t msg_type
; /* 0 = ECHO REPLY, 3 = DESTINATION_UNREACHABLE, 8 = ECHO_REQUEST, 11 = TTL exceeded */
234 #define ICMP_PACKET_V7_SIZE 19
236 struct icmp_packet_v14
{
238 uint8_t version
; /* batman version field */
240 uint8_t msg_type
; /* see ICMP message types above */
247 #define ICMP_PACKET_V14_SIZE 20
249 struct icmp_packet_v15
{
251 uint8_t version
; /* batman version field */
253 uint8_t msg_type
; /* see ICMP message types above */
260 #define ICMP_PACKET_V15_SIZE 20
262 struct icmp_tp_packet_v15
{
264 uint8_t version
; /* batman version field */
266 uint8_t msg_type
; /* see ICMP message types above */
275 #define ICMP_TP_PACKET_V15_SIZE 28
277 struct unicast_packet_v6
{
283 #define UNICAST_PACKET_V6_SIZE 9
285 struct unicast_packet_v14
{
287 uint8_t version
; /* batman version field */
289 uint8_t ttvn
; /* destination translation table version number */
292 #define UNICAST_PACKET_V14_SIZE 10
294 struct unicast_4addr_packet_v14
{
296 uint8_t version
; /* batman version field */
298 uint8_t ttvn
; /* destination translation table version number */
304 #define UNICAST_4ADDR_PACKET_V14_SIZE 18
306 struct unicast_frag_packet_v12
{
315 #define UNICAST_FRAG_PACKET_V12_SIZE 18
317 struct unicast_frag_packet_v14
{
319 uint8_t version
; /* batman version field */
321 uint8_t ttvn
; /* destination translation table version number */
328 #define UNICAST_FRAG_PACKET_V14_SIZE 20
330 struct unicast_frag_packet_v15
{
332 uint8_t version
; /* batman version field */
334 uint8_t no
; /* only upper 4 bit are used */
340 #define UNICAST_FRAG_PACKET_V15_SIZE 20
342 struct bcast_packet_v6
{
344 uint8_t version
; /* batman version field */
348 #define BCAST_PACKET_V6_SIZE 10
350 struct bcast_packet_v10
{
352 uint8_t version
; /* batman version field */
357 #define BCAST_PACKET_V10_SIZE 13
359 struct bcast_packet_v14
{
361 uint8_t version
; /* batman version field */
367 #define BCAST_PACKET_V14_SIZE 14
369 struct vis_packet_v6
{
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
{
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
{
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 */
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
{
417 uint8_t version
; /* batman version field */
425 #define TT_QUERY_PACKET_V14_SIZE 19
427 #define TT_ENTRY_V14_SIZE 7
429 struct roam_adv_packet_v14
{
438 #define ROAM_ADV_PACKET_V14_SIZE 22
440 struct coded_packet_v15
{
442 uint8_t version
; /* batman version field */
445 address first_source
;
446 address first_orig_dest
;
451 address second_source
;
452 address second_orig_dest
;
456 #define CODED_PACKET_V15_SIZE 46
458 struct unicast_tvlv_packet_v15
{
460 uint8_t version
; /* batman version field */
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 */
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
;
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
;
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" },
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" },
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" },
737 static const value_string icmp_tp_packettypenames
[] = {
739 { 1, "Acknowledgement" },
743 static const value_string vis_packettypenames
[] = {
744 { VIS_TYPE_SERVER_SYNC
, "SERVER_SYNC" },
745 { VIS_TYPE_CLIENT_UPDATE
, "CLIENT_UPDATE" },
749 static const value_string tt_query_type_v14
[] = {
750 {TT_REQUEST
, "Request"},
751 {TT_RESPONSE
, "Response"},
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"},
762 static int * const batman_v5_flags
[] = {
763 &hf_batadv_batman_flags_directlink
,
764 &hf_batadv_batman_flags_vis_server
,
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
,
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
,
783 static int * const unicast_frag_flags
[] = {
784 &hf_batadv_unicast_frag_flags_head
,
785 &hf_batadv_unicast_frag_flags_largetail
,
789 static int * const tt_query_flags
[] = {
790 &hf_batadv_tt_query_flags_type
,
791 &hf_batadv_tt_query_flags_full_table
,
795 static int * const tt_entry_flags
[] = {
796 &hf_batadv_tt_entry_flags_change_del
,
797 &hf_batadv_tt_entry_flags_client_roam
,
801 static const fragment_items msg_frag_items
= {
802 /* Fragment subtrees */
805 /* Fragment fields */
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 */
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
;
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_
)
925 col_clear(pinfo
->cinfo
, COL_INFO
);
927 version
= tvb_get_uint8(tvb
, 1);
929 dissect_batadv_v5(tvb
, pinfo
, tree
);
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
)
940 type
= tvb_get_uint8(tvb
, 0);
943 case BATADV_PACKET_V5
:
944 dissect_batadv_batman(tvb
, pinfo
, tree
);
947 dissect_batadv_icmp(tvb
, pinfo
, tree
);
949 case BATADV_UNICAST_V5
:
950 dissect_batadv_unicast(tvb
, pinfo
, tree
);
952 case BATADV_UNICAST_FRAG_V12
:
953 dissect_batadv_unicast_frag(tvb
, pinfo
, tree
);
955 case BATADV_BCAST_V5
:
956 dissect_batadv_bcast(tvb
, pinfo
, tree
);
959 dissect_batadv_vis(tvb
, pinfo
, tree
);
961 case BATADV_TT_QUERY_V14
:
962 dissect_batadv_tt_query(tvb
, pinfo
, tree
);
964 case BATADV_ROAM_ADV_V14
:
965 dissect_batadv_roam_adv(tvb
, pinfo
, tree
);
967 case BATADV_UNICAST_4ADDR_V14
:
968 dissect_batadv_unicast_4addr(tvb
, pinfo
, tree
);
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
);
988 static void dissect_batadv_v15(tvbuff_t
*tvb
, packet_info
*pinfo
,
993 type
= tvb_get_uint8(tvb
, 0);
996 case BATADV_IV_OGM_V15
:
997 dissect_batadv_iv_ogm(tvb
, pinfo
, tree
);
999 case BATADV_BCAST_V15
:
1000 dissect_batadv_bcast(tvb
, pinfo
, tree
);
1002 case BATADV_CODED_V15
:
1003 dissect_batadv_coded(tvb
, pinfo
, tree
);
1005 case BATADV_ELP_V15
:
1006 dissect_batadv_elp(tvb
, pinfo
, tree
);
1008 case BATADV_OGM2_V15
:
1009 dissect_batadv_ogm2(tvb
, pinfo
, tree
);
1011 case BATADV_UNICAST_V15
:
1012 dissect_batadv_unicast(tvb
, pinfo
, tree
);
1014 case BATADV_UNICAST_FRAG_V15
:
1015 dissect_batadv_unicast_frag(tvb
, pinfo
, tree
);
1017 case BATADV_UNICAST_4ADDR_V15
:
1018 dissect_batadv_unicast_4addr(tvb
, pinfo
, tree
);
1020 case BATADV_ICMP_V15
:
1021 dissect_batadv_icmp(tvb
, pinfo
, tree
);
1023 case BATADV_UNICAST_TVLV_V15
:
1024 dissect_batadv_unicast_tvlv(tvb
, pinfo
, tree
);
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
);
1044 static void dissect_batadv_batman(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
1049 /* set protocol name */
1050 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_BATMAN");
1052 version
= tvb_get_uint8(tvb
, 1);
1056 while (offset
!= -1 && tvb_reported_length_remaining(tvb
, offset
) >= BATMAN_PACKET_V5_SIZE
) {
1057 offset
= dissect_batadv_batman_v5(tvb
, offset
, pinfo
, tree
);
1062 while (offset
!= -1 && tvb_reported_length_remaining(tvb
, offset
) >= BATMAN_PACKET_V7_SIZE
) {
1063 offset
= dissect_batadv_batman_v7(tvb
, offset
, pinfo
, tree
);
1067 while (offset
!= -1 && tvb_reported_length_remaining(tvb
, offset
) >= BATMAN_PACKET_V9_SIZE
) {
1068 offset
= dissect_batadv_batman_v9(tvb
, offset
, pinfo
, tree
);
1073 while (offset
!= -1 && tvb_reported_length_remaining(tvb
, offset
) >= BATMAN_PACKET_V11_SIZE
) {
1074 offset
= dissect_batadv_batman_v11(tvb
, offset
, pinfo
, tree
);
1079 while (offset
!= -1 && tvb_reported_length_remaining(tvb
, offset
) >= BATMAN_PACKET_V10_SIZE
) {
1080 offset
= dissect_batadv_batman_v10(tvb
, offset
, pinfo
, tree
);
1084 while (offset
!= -1 && tvb_reported_length_remaining(tvb
, offset
) >= BATMAN_PACKET_V14_SIZE
) {
1085 offset
= dissect_batadv_batman_v14(tvb
, offset
, pinfo
, tree
);
1089 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
1090 call_data_dissector(tvb
, pinfo
, tree
);
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);
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
;
1121 struct batman_packet_v5
*batman_packeth
;
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
) {
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
);
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
);
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
);
1163 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
1170 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
1177 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_tq
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1180 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_seqno
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1183 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_orig
, tvb
, offset
, 6, ENC_NA
);
1186 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_prev_sender
, tvb
, offset
, 6, ENC_NA
);
1189 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_num_tt
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1192 /* Skip 1 byte of padding. */
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
);
1211 static int dissect_batadv_batman_v7(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo
, proto_tree
*tree
)
1213 proto_tree
*batadv_batman_tree
;
1216 struct batman_packet_v7
*batman_packeth
;
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
) {
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
);
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
);
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
);
1255 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
1262 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_tq
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1265 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_seqno
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1268 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_orig
, tvb
, offset
, 6, ENC_NA
);
1271 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_prev_sender
, tvb
, offset
, 6, ENC_NA
);
1274 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1277 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_num_tt
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
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
;
1301 struct batman_packet_v9
*batman_packeth
;
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
) {
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
);
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
);
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
);
1341 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
1348 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_tq
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1351 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_seqno
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1354 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_orig
, tvb
, offset
, 6, ENC_NA
);
1357 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_prev_sender
, tvb
, offset
, 6, ENC_NA
);
1360 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1363 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_num_tt
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
1370 /* Skip 1 byte of padding. */
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
);
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
;
1394 struct batman_packet_v10
*batman_packeth
;
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
) {
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
);
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
);
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
);
1434 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
1441 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_tq
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1444 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_seqno32
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
1447 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_orig
, tvb
, offset
, 6, ENC_NA
);
1450 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_prev_sender
, tvb
, offset
, 6, ENC_NA
);
1453 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1456 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_num_tt
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
1463 /* Skip 1 byte of padding. */
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
);
1482 static int dissect_batadv_batman_v11(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo
, proto_tree
*tree
)
1484 proto_tree
*batadv_batman_tree
;
1487 struct batman_packet_v11
*batman_packeth
;
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
) {
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
);
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
);
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
);
1526 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
1533 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_tq
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1536 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_seqno32
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
1539 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_orig
, tvb
, offset
, 6, ENC_NA
);
1542 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_prev_sender
, tvb
, offset
, 6, ENC_NA
);
1545 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1548 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_num_tt
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
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
;
1572 struct batman_packet_v14
*batman_packeth
;
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
) {
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
);
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
);
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
);
1615 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1618 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
1625 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_seqno32
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
1628 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_orig
, tvb
, offset
, 6, ENC_NA
);
1631 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_prev_sender
, tvb
, offset
, 6, ENC_NA
);
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
);
1638 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_tq
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1641 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_tt_num_changes
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1644 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_ttvn
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1647 proto_tree_add_item(batadv_batman_tree
, hf_batadv_batman_tt_crc
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
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
);
1672 static void dissect_batadv_iv_ogm(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
1677 /* set protocol name */
1678 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_IV_OGM");
1680 version
= tvb_get_uint8(tvb
, 1);
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
);
1689 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
1690 call_data_dissector(tvb
, pinfo
, tree
);
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
;
1700 uint8_t type
, version
;
1701 struct iv_ogm_packet_v15
*iv_ogm_packeth
;
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
,
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
)
1717 iv_ogm_packeth
= wmem_new(pinfo
->pool
, struct iv_ogm_packet_v15
);
1719 /* Set info column */
1720 col_clear(pinfo
->cinfo
, COL_INFO
);
1723 ti
= proto_tree_add_protocol_format(tree
, proto_batadv_plugin
,
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
);
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",
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
);
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
);
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
,
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
);
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
,
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
,
1773 /* Skip 1 byte of padding. */
1774 iv_ogm_packeth
->reserved
= tvb_get_uint8(tvb
, offset
);
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
);
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
);
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
;
1805 static void dissect_batadv_tt(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
)
1807 proto_tree
*batadv_batman_tt_tree
;
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
)
1823 /* set protocol name */
1824 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_BCAST");
1826 version
= tvb_get_uint8(tvb
, 1);
1832 dissect_batadv_bcast_v6(tvb
, pinfo
, tree
);
1838 dissect_batadv_bcast_v10(tvb
, pinfo
, tree
);
1842 dissect_batadv_bcast_v14(tvb
, pinfo
, tree
);
1845 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
1846 call_data_dissector(tvb
, pinfo
, tree
);
1851 static void dissect_batadv_bcast_v6(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
1853 struct bcast_packet_v6
*bcast_packeth
;
1856 int length_remaining
;
1858 proto_tree
*batadv_bcast_tree
;
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
);
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
);
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
);
1883 proto_tree_add_item(batadv_bcast_tree
, hf_batadv_bcast_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1886 proto_tree_add_item(batadv_bcast_tree
, hf_batadv_bcast_orig
, tvb
, offset
, 6, ENC_NA
);
1889 proto_tree_add_item(batadv_bcast_tree
, hf_batadv_bcast_seqno
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
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
;
1910 int length_remaining
;
1912 proto_tree
*batadv_bcast_tree
;
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
);
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
);
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
);
1938 proto_tree_add_item(batadv_bcast_tree
, hf_batadv_bcast_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1941 proto_tree_add_item(batadv_bcast_tree
, hf_batadv_bcast_orig
, tvb
, offset
, 6, ENC_NA
);
1944 proto_tree_add_item(batadv_bcast_tree
, hf_batadv_bcast_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1947 proto_tree_add_item(batadv_bcast_tree
, hf_batadv_bcast_seqno32
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
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
;
1969 int length_remaining
;
1971 proto_tree
*batadv_bcast_tree
;
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
);
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
);
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
);
2002 proto_tree_add_item(batadv_bcast_tree
, hf_batadv_bcast_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2005 proto_tree_add_item(batadv_bcast_tree
, hf_batadv_bcast_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2008 /* Skip 1 byte of padding. */
2011 proto_tree_add_item(batadv_bcast_tree
, hf_batadv_bcast_seqno32
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
2014 proto_tree_add_item(batadv_bcast_tree
, hf_batadv_bcast_orig
, tvb
, offset
, 6, ENC_NA
);
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
)
2035 /* set protocol name */
2036 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_ICMP");
2038 version
= tvb_get_uint8(tvb
, 1);
2041 dissect_batadv_icmp_v6(tvb
, pinfo
, tree
);
2050 dissect_batadv_icmp_v7(tvb
, pinfo
, tree
);
2053 dissect_batadv_icmp_v14(tvb
, pinfo
, tree
);
2056 dissect_batadv_icmp_v15(tvb
, pinfo
, tree
);
2059 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
2060 call_data_dissector(tvb
, pinfo
, tree
);
2065 static void dissect_batadv_icmp_v6(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
2067 struct icmp_packet_v6
*icmp_packeth
;
2069 int length_remaining
;
2071 proto_tree
*batadv_icmp_tree
;
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
);
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
);
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
);
2106 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2109 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_msg_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2112 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_dst
, tvb
, offset
, 6, ENC_NA
);
2115 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_orig
, tvb
, offset
, 6, ENC_NA
);
2118 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2121 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_uid
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2124 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_seqno
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
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
);
2138 dissect_batadv_icmp_rr(packet_info
*pinfo
, proto_tree
*batadv_icmp_tree
, tvbuff_t
*tvb
, int offset
)
2140 proto_tree
*field_tree
;
2143 ptr
= tvb_get_uint8(tvb
, offset
);
2144 if (ptr
< 1 || ptr
> BAT_RR_LEN
)
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
);
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)" : "");
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
;
2169 field_tree
= proto_tree_add_subtree(batadv_icmp_tree
, tvb
, offset
,
2171 ett_batadv_icmp_rr
, NULL
,
2175 for (i
= 0; i
< BAT_RR_LEN
; i
++) {
2176 proto_tree_add_ether_format(field_tree
, hf_batadv_icmp_rr_ether
,
2178 tvb_get_ptr(tvb
, offset
, 6),
2180 (i
> ptr
) ? "-" : tvb_ether_to_str(pinfo
->pool
, tvb
, offset
),
2181 (i
== ptr
) ? " <- (current)" : "");
2187 static void dissect_batadv_icmp_v7(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
2189 struct icmp_packet_v7
*icmp_packeth
;
2191 proto_tree
*batadv_icmp_tree
;
2194 int length_remaining
;
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
);
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
);
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
);
2230 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2233 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_msg_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2236 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2239 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_dst
, tvb
, offset
, 6, ENC_NA
);
2242 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_orig
, tvb
, offset
, 6, ENC_NA
);
2245 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_seqno
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2248 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_uid
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
;
2271 proto_tree
*batadv_icmp_tree
;
2274 int length_remaining
;
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
);
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
);
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
);
2311 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2314 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2317 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_msg_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2320 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_dst
, tvb
, offset
, 6, ENC_NA
);
2323 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_orig
, tvb
, offset
, 6, ENC_NA
);
2326 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_seqno
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2329 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_uid
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2332 /* Skip 1 byte of padding. */
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
,
2354 struct icmp_tp_packet_v15
*icmp_packeth
;
2356 proto_tree
*batadv_icmp_tree
= NULL
;
2359 int length_remaining
;
2363 icmp_packeth
= wmem_new(pinfo
->pool
, struct icmp_tp_packet_v15
);
2365 /* Set info column */
2366 col_clear(pinfo
->cinfo
, COL_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
);
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
);
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
);
2390 icmp_packeth
->ttl
= tvb_get_uint8(tvb
, offset
);
2391 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_ttl
, tvb
, offset
,
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)"));
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
,
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
,
2418 icmp_packeth
->uid
= tvb_get_uint8(tvb
, offset
);
2419 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_uid
, tvb
, offset
,
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
);
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
);
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
);
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
);
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
,
2456 struct icmp_packet_v15
*icmp_packeth
;
2458 proto_tree
*batadv_icmp_tree
;
2461 int length_remaining
;
2466 icmp_packeth
= wmem_new(pinfo
->pool
, struct icmp_packet_v15
);
2468 /* Set info column */
2469 col_clear(pinfo
->cinfo
, COL_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
);
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
);
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
);
2493 icmp_packeth
->ttl
= tvb_get_uint8(tvb
, offset
);
2494 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_ttl
, tvb
, offset
,
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)"));
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
,
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
,
2521 icmp_packeth
->uid
= tvb_get_uint8(tvb
, offset
);
2522 proto_tree_add_item(batadv_icmp_tree
, hf_batadv_icmp_uid
, tvb
, offset
,
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
);
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
);
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
,
2559 msg_type
= tvb_get_uint8(tvb
, 3);
2562 dissect_batadv_icmp_tp_v15(tvb
, pinfo
, tree
);
2565 dissect_batadv_icmp_simple_v15(tvb
, pinfo
, tree
);
2570 static void dissect_batadv_unicast(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
2574 /* set protocol name */
2575 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_UNICAST");
2577 version
= tvb_get_uint8(tvb
, 1);
2587 dissect_batadv_unicast_v6(tvb
, pinfo
, tree
);
2591 dissect_batadv_unicast_v14(tvb
, pinfo
, tree
);
2594 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
2595 call_data_dissector(tvb
, pinfo
, tree
);
2600 static void dissect_batadv_unicast_v6(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
2602 struct unicast_packet_v6
*unicast_packeth
;
2605 int length_remaining
;
2607 proto_tree
*batadv_unicast_tree
;
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
);
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
);
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
);
2633 proto_tree_add_item(batadv_unicast_tree
, hf_batadv_unicast_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2636 proto_tree_add_item(batadv_unicast_tree
, hf_batadv_unicast_dst
, tvb
, offset
, 6, ENC_NA
);
2639 proto_tree_add_item(batadv_unicast_tree
, hf_batadv_unicast_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
;
2661 int length_remaining
;
2663 proto_tree
*batadv_unicast_tree
;
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
);
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
);
2686 proto_tree_add_uint_format_value(batadv_unicast_tree
,
2687 hf_batadv_packet_type
, tvb
, offset
, 1,
2688 unicast_packeth
->packet_type
,
2691 unicast_packeth
->packet_type
);
2694 proto_tree_add_item(batadv_unicast_tree
, hf_batadv_unicast_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2697 proto_tree_add_item(batadv_unicast_tree
, hf_batadv_unicast_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2700 proto_tree_add_item(batadv_unicast_tree
, hf_batadv_unicast_ttvn
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2703 proto_tree_add_item(batadv_unicast_tree
, hf_batadv_unicast_dst
, tvb
, offset
, 6, ENC_NA
);
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
)
2724 /* set protocol name */
2725 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_UNICAST_4ADDR");
2727 version
= tvb_get_uint8(tvb
, 1);
2731 dissect_batadv_unicast_4addr_v14(tvb
, pinfo
, tree
);
2734 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
2735 call_data_dissector(tvb
, pinfo
, tree
);
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
;
2745 int length_remaining
;
2747 proto_tree
*batadv_unicast_4addr_tree
;
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)"));
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
);
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
);
2784 proto_tree_add_item(batadv_unicast_4addr_tree
, hf_batadv_unicast_4addr_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2787 proto_tree_add_item(batadv_unicast_4addr_tree
, hf_batadv_unicast_4addr_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2790 proto_tree_add_item(batadv_unicast_4addr_tree
, hf_batadv_unicast_4addr_ttvn
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2793 proto_tree_add_item(batadv_unicast_4addr_tree
, hf_batadv_unicast_4addr_dst
, tvb
, offset
, 6, ENC_NA
);
2796 proto_tree_add_item(batadv_unicast_4addr_tree
, hf_batadv_unicast_4addr_src
, tvb
, offset
, 6, ENC_NA
);
2799 proto_tree_add_item(batadv_unicast_4addr_tree
, hf_batadv_unicast_4addr_subtype
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2802 /* Skip 1 byte of padding. */
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
)
2823 /* set protocol name */
2824 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_UNICAST_FRAG");
2826 version
= tvb_get_uint8(tvb
, 1);
2830 dissect_batadv_unicast_frag_v12(tvb
, pinfo
, tree
);
2833 dissect_batadv_unicast_frag_v14(tvb
, pinfo
, tree
);
2836 dissect_batadv_unicast_frag_v15(tvb
, pinfo
, tree
);
2839 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
2840 call_data_dissector(tvb
, pinfo
, tree
);
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
;
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
);
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
);
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
);
2888 proto_tree_add_item(batadv_unicast_frag_tree
, hf_batadv_unicast_frag_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2891 proto_tree_add_item(batadv_unicast_frag_tree
, hf_batadv_unicast_frag_dst
, tvb
, offset
, 6, ENC_NA
);
2894 proto_tree_add_item(batadv_unicast_frag_tree
, hf_batadv_unicast_frag_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
2901 proto_tree_add_item(batadv_unicast_frag_tree
, hf_batadv_unicast_frag_orig
, tvb
, offset
, 6, ENC_NA
);
2904 proto_tree_add_item(batadv_unicast_frag_tree
, hf_batadv_unicast_frag_seqno
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
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
,
2915 pinfo
, unicast_frag_packeth
->seqno
+ head
, NULL
,
2920 new_tvb
= process_reassembled_data(tvb
, offset
, pinfo
,
2921 "Reassembled Message", frag_msg
, &msg_frag_items
,
2922 NULL
, batadv_unicast_frag_tree
);
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
;
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
);
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
);
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
);
2979 proto_tree_add_item(batadv_unicast_frag_tree
, hf_batadv_unicast_frag_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2982 proto_tree_add_item(batadv_unicast_frag_tree
, hf_batadv_unicast_frag_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2985 proto_tree_add_item(batadv_unicast_frag_tree
, hf_batadv_unicast_frag_ttvn
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2988 proto_tree_add_item(batadv_unicast_frag_tree
, hf_batadv_unicast_frag_dst
, tvb
, offset
, 6, ENC_NA
);
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
);
2995 /* Skip 1 byte of padding. */
2998 proto_tree_add_item(batadv_unicast_frag_tree
, hf_batadv_unicast_frag_orig
, tvb
, offset
, 6, ENC_NA
);
3001 proto_tree_add_item(batadv_unicast_frag_tree
, hf_batadv_unicast_frag_seqno
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
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
,
3012 pinfo
, unicast_frag_packeth
->seqno
+ head
, NULL
,
3017 new_tvb
= process_reassembled_data(tvb
, offset
, pinfo
,
3018 "Reassembled Message", frag_msg
, &msg_frag_items
,
3019 NULL
, batadv_unicast_frag_tree
);
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
,
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
;
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
);
3054 ti
= proto_tree_add_protocol_format(tree
, proto_batadv_plugin
,
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
);
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
);
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,
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,
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
);
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
);
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
);
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,
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,
3118 tap_queue_packet(batadv_tap
, pinfo
, unicast_frag_packeth
);
3120 frag_no
= unicast_frag_packeth
->no
>> 4;
3121 /* only support 2 fragments */
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
,
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
);
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
)
3155 /* set protocol name */
3156 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_VIS");
3158 version
= tvb_get_uint8(tvb
, 1);
3164 dissect_batadv_vis_v6(tvb
, pinfo
, tree
);
3170 dissect_batadv_vis_v10(tvb
, pinfo
, tree
);
3173 dissect_batadv_vis_v14(tvb
, pinfo
, tree
);
3176 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
3177 call_data_dissector(tvb
, pinfo
, tree
);
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
;
3189 unsigned entry_size
;
3190 int length_remaining
;
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
);
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
);
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
);
3225 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3228 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3231 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_seqno
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3234 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_entries
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3237 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3240 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_vis_orig
, tvb
, offset
, 6, ENC_NA
);
3243 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_target_orig
, tvb
, offset
, 6, ENC_NA
);
3246 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_sender_orig
, tvb
, offset
, 6, ENC_NA
);
3249 tap_queue_packet(batadv_tap
, pinfo
, vis_packeth
);
3251 switch (vis_packeth
->version
) {
3254 entry_size
= VIS_ENTRY_V6_SIZE
;
3259 entry_size
= VIS_ENTRY_V8_SIZE
;
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
) {
3274 dissect_vis_entry_v6(next_tvb
, pinfo
, batadv_vis_tree
);
3279 dissect_vis_entry_v8(next_tvb
, pinfo
, batadv_vis_tree
);
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
;
3306 int length_remaining
;
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
);
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
);
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
);
3342 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3345 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3348 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_entries
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3351 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_seqno32
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
3354 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3357 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_vis_orig
, tvb
, offset
, 6, ENC_NA
);
3360 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_target_orig
, tvb
, offset
, 6, ENC_NA
);
3363 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_sender_orig
, tvb
, offset
, 6, ENC_NA
);
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
;
3398 int length_remaining
;
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
);
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
);
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
);
3434 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3437 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3440 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3443 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_seqno32
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
3446 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_entries
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3449 /* Skip 1 byte of padding. */
3452 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_vis_orig
, tvb
, offset
, 6, ENC_NA
);
3455 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_target_orig
, tvb
, offset
, 6, ENC_NA
);
3458 proto_tree_add_item(batadv_vis_tree
, hf_batadv_vis_sender_orig
, tvb
, offset
, 6, ENC_NA
);
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
;
3491 ti
= proto_tree_add_protocol_format(tree
, proto_batadv_plugin
, tvb
, 0, VIS_ENTRY_V6_SIZE
,
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
;
3505 ti
= proto_tree_add_protocol_format(tree
, proto_batadv_plugin
, tvb
, 0, VIS_ENTRY_V8_SIZE
,
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
)
3519 /* set protocol name */
3520 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_TT_QUERY");
3522 version
= tvb_get_uint8(tvb
, 1);
3525 dissect_batadv_tt_query_v14(tvb
, pinfo
, tree
);
3528 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
3529 call_data_dissector(tvb
, pinfo
, tree
);
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
;
3541 int length_remaining
;
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 */
3567 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Request=%u", tt_query_packeth
->ttvn
);
3570 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Response=%u", tt_query_packeth
->ttvn
);
3573 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Type %u", tt_type
);
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
);
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
);
3588 proto_tree_add_item(batadv_tt_query_tree
, hf_batadv_tt_query_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3591 proto_tree_add_item(batadv_tt_query_tree
, hf_batadv_tt_query_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
3598 proto_tree_add_item(batadv_tt_query_tree
, hf_batadv_tt_query_dst
, tvb
, offset
, 6, ENC_NA
);
3601 proto_tree_add_item(batadv_tt_query_tree
, hf_batadv_tt_query_src
, tvb
, offset
, 6, ENC_NA
);
3604 proto_tree_add_item(batadv_tt_query_tree
, hf_batadv_tt_query_ttvn
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3609 proto_tree_add_item(batadv_tt_query_tree
, hf_batadv_tt_query_tt_crc
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
3612 proto_tree_add_item(batadv_tt_query_tree
, hf_batadv_tt_query_entries
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
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
;
3651 ti
= proto_tree_add_protocol_format(tree
, proto_batadv_plugin
, tvb
, 0, TT_ENTRY_V14_SIZE
,
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
)
3665 /* set protocol name */
3666 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_ROAM_ADV");
3668 version
= tvb_get_uint8(tvb
, 1);
3671 dissect_batadv_roam_adv_v14(tvb
, pinfo
, tree
);
3674 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
3675 call_data_dissector(tvb
, pinfo
, tree
);
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
;
3687 int length_remaining
;
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
));
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
);
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
);
3716 proto_tree_add_item(batadv_roam_adv_tree
, hf_batadv_roam_adv_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3719 proto_tree_add_item(batadv_roam_adv_tree
, hf_batadv_roam_adv_ttl
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
3722 /* Skip 1 byte of padding. */
3725 proto_tree_add_item(batadv_roam_adv_tree
, hf_batadv_roam_adv_dst
, tvb
, offset
, 6, ENC_NA
);
3728 proto_tree_add_item(batadv_roam_adv_tree
, hf_batadv_roam_adv_src
, tvb
, offset
, 6, ENC_NA
);
3731 proto_tree_add_item(batadv_roam_adv_tree
, hf_batadv_roam_adv_client
, tvb
, offset
, 6, ENC_NA
);
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
)
3752 /* set protocol name */
3753 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_CODED");
3755 version
= tvb_get_uint8(tvb
, 1);
3758 dissect_batadv_coded_v15(tvb
, pinfo
, tree
);
3761 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
3762 call_data_dissector(tvb
, pinfo
, tree
);
3767 static void dissect_batadv_coded_v15(tvbuff_t
*tvb
, packet_info
*pinfo
,
3770 struct coded_packet_v15
*coded_packeth
;
3771 proto_tree
*batadv_coded_tree
;
3775 int length_remaining
;
3778 coded_packeth
= wmem_new(pinfo
->pool
, struct coded_packet_v15
);
3781 ti
= proto_tree_add_protocol_format(tree
, proto_batadv_plugin
,
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
);
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
,
3792 coded_packeth
->packet_type
,
3793 "%s (%u)", "BATADV_CODED",
3794 coded_packeth
->packet_type
);
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
);
3802 coded_packeth
->ttl
= tvb_get_uint8(tvb
, offset
);
3803 proto_tree_add_item(batadv_coded_tree
, hf_batadv_coded_ttl
, tvb
, offset
,
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
,
3885 /* set protocol name */
3886 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_ELP");
3888 version
= tvb_get_uint8(tvb
, 1);
3891 dissect_batadv_elp_v15(tvb
, pinfo
, tree
);
3894 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d",
3896 call_data_dissector(tvb
, pinfo
, tree
);
3901 static void dissect_batadv_elp_v15(tvbuff_t
*tvb
, packet_info
*pinfo
,
3904 struct elp_packet_v15
*elp_packeth
;
3905 proto_tree
*batadv_elp_tree
;
3909 int length_remaining
;
3912 elp_packeth
= wmem_new(pinfo
->pool
, struct elp_packet_v15
);
3915 ti
= proto_tree_add_protocol_format(tree
, proto_batadv_plugin
,
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
);
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
,
3926 elp_packeth
->packet_type
,
3927 "%s (%u)", "BATADV_ELP",
3928 elp_packeth
->packet_type
);
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
);
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
,
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
);
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
);
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
)
3972 /* set protocol name */
3973 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_OGM2");
3975 version
= tvb_get_uint8(tvb
, 1);
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
);
3984 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d", version
);
3985 call_data_dissector(tvb
, pinfo
, tree
);
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
;
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
[] = {
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
)
4014 ogm2_packeth
= wmem_new(pinfo
->pool
, struct ogm2_packet_v15
);
4017 ogm2_packeth
->tvlv_len
= tvb_get_ntohs(tvb
, 16);
4018 ti
= proto_tree_add_protocol_format(tree
, proto_batadv_plugin
,
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
);
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",
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
);
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
);
4044 ogm2_packeth
->flags
= tvb_get_uint8(tvb
, offset
);
4045 proto_tree_add_item(batadv_ogm2_tree
, hf_batadv_ogm2_flags
, tvb
,
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
);
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
,
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
);
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);
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
;
4093 static void dissect_batadv_unicast_tvlv(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
4097 /* set protocol name */
4098 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BATADV_UNICAST_TVLV");
4100 version
= tvb_get_uint8(tvb
, 1);
4103 dissect_batadv_unicast_tvlv_v15(tvb
, pinfo
, tree
);
4106 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported Version %d",
4108 call_data_dissector(tvb
, pinfo
, tree
);
4113 static void dissect_batadv_unicast_tvlv_v15(tvbuff_t
*tvb
, packet_info
*pinfo
,
4116 struct unicast_tvlv_packet_v15
*unicast_tvlv_packeth
;
4120 proto_tree
*batadv_unicast_tvlv_tree
;
4123 unicast_tvlv_packeth
= wmem_new(pinfo
->pool
, struct unicast_tvlv_packet_v15
);
4125 /* Set info column */
4126 col_clear(pinfo
->cinfo
, COL_INFO
);
4129 unicast_tvlv_packeth
->tvlv_len
= tvb_get_ntohs(tvb
, 16);
4130 ti
= proto_tree_add_protocol_format(tree
, proto_batadv_plugin
,
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
);
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
);
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,
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,
4159 /* Skip 1 byte of padding. */
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
);
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
);
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,
4182 /* Skip 2 byte of padding. */
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
,
4204 uint8_t type
, version
;
4208 proto_tree
*batadv_tvlv_tree
;
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
);
4219 ti
= proto_tree_add_protocol_format(tree
,
4220 proto_batadv_plugin
,
4221 next_tvb
, 0, length
,
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
);
4232 case BATADV_TVLV_V15_GW
:
4233 dissect_batadv_tvlv_v15_gw(next_tvb
, pinfo
,
4234 batadv_tvlv_tree
, 4,
4237 case BATADV_TVLV_V15_DAT
:
4238 dissect_batadv_tvlv_v15_dat(next_tvb
, pinfo
,
4239 batadv_tvlv_tree
, 4,
4242 case BATADV_TVLV_V15_NC
:
4243 dissect_batadv_tvlv_v15_nc(next_tvb
, pinfo
,
4244 batadv_tvlv_tree
, 4,
4247 case BATADV_TVLV_V15_TT
:
4248 dissect_batadv_tvlv_v15_tt(next_tvb
, pinfo
,
4249 batadv_tvlv_tree
, 4,
4252 case BATADV_TVLV_V15_ROAM
:
4253 dissect_batadv_tvlv_v15_roam(next_tvb
, pinfo
,
4254 batadv_tvlv_tree
, 4,
4257 case BATADV_TVLV_V15_MCAST
:
4258 dissect_batadv_tvlv_v15_mcast(next_tvb
, pinfo
,
4259 batadv_tvlv_tree
, 4,
4263 call_data_dissector(next_tvb
, pinfo
,
4271 static void dissect_batadv_tvlv_v15_header(tvbuff_t
*tvb
,
4272 packet_info
*pinfo _U_
,
4273 proto_tree
*tree
, uint8_t type
)
4278 proto_tree_add_uint_format_value(tree
, hf_batadv_tvlv_type
, tvb
, offset
,
4280 val_to_str(type
, tvlv_v15_typenames
,
4281 "Unknown (0x%02x)"));
4284 proto_tree_add_item(tree
, hf_batadv_tvlv_version
, tvb
, offset
, 1,
4288 proto_tree_add_item(tree
, hf_batadv_tvlv_len
, tvb
, offset
, 2,
4292 static void dissect_batadv_tvlv_v15_dat(tvbuff_t
*tvb
, packet_info
*pinfo
,
4293 proto_tree
*tree
, int offset
,
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
);
4304 static void dissect_batadv_tvlv_v15_nc(tvbuff_t
*tvb
, packet_info
*pinfo
,
4305 proto_tree
*tree
, int offset
,
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
);
4316 static void dissect_batadv_tvlv_v15_mcast(tvbuff_t
*tvb
, packet_info
*pinfo
,
4317 proto_tree
*tree
, int offset
,
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
,
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
);
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
,
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
);
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);
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",
4367 static void dissect_batadv_tvlv_v15_roam(tvbuff_t
*tvb
, packet_info
*pinfo
,
4368 proto_tree
*tree
, int offset
,
4371 static int * const flags
[] = {
4372 &hf_batadv_tvlv_vid_vlan
,
4373 &hf_batadv_tvlv_vid_tagged
,
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
);
4384 proto_tree_add_item(tree
, hf_batadv_tvlv_roam_addr
, tvb
, 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
,
4398 int length_remaining
;
4399 static int * const flags
[] = {
4400 &hf_batadv_tvlv_tt_flags_type
,
4401 &hf_batadv_tvlv_tt_flags_full_table
,
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
);
4416 proto_tree_add_bitmask(tree
, tvb
, offset
, hf_batadv_tvlv_tt_flags
,
4417 ett_batadv_tvlv_tt_flags
, flags
, ENC_NA
);
4420 proto_tree_add_item(tree
, hf_batadv_tvlv_tt_ttvn
, tvb
, 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,
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
,
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
,
4440 length_remaining
= tvb_reported_length_remaining(tvb
, offset
);
4444 static void dissect_batadv_tvlv_v15_tt_vlan_checksum(tvbuff_t
*tvb
,
4456 int length_remaining
;
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
);
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);
4475 buf
= tvb_get_ptr(tvb
, offset
, TLVLV_TT_CHANGE_V15_SIZE
);
4481 /* checksum over vid, flags, address */
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
);
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
,
4505 proto_tree
*tree
, int offset
,
4509 proto_tree
*vlan_tree
= NULL
;
4511 proto_item
*ti
= NULL
;
4512 static int * const flags
[] = {
4513 &hf_batadv_tvlv_vid_vlan
,
4514 &hf_batadv_tvlv_vid_tagged
,
4518 vid
= tvb_get_ntohs(tvb
, offset
+ 4);
4521 ti
= proto_tree_add_protocol_format(tree
, proto_batadv_plugin
,
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
,
4531 proto_tree_add_bitmask(vlan_tree
, tvb
, offset
,
4532 hf_batadv_tvlv_tt_vlan_vid
,
4533 ett_batadv_tvlv_vid
, flags
, ENC_NA
);
4536 /* Skip 2 byte of padding. */
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
;
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
,
4555 static int * const flags_vlan
[] = {
4556 &hf_batadv_tvlv_vid_vlan
,
4557 &hf_batadv_tvlv_vid_tagged
,
4562 ti
= proto_tree_add_protocol_format(tree
, proto_batadv_plugin
,
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
);
4573 /* Skip 3 byte of padding. */
4576 proto_tree_add_item(change_tree
, hf_batadv_tvlv_tt_change_addr
, tvb
,
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
);
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,
4599 { &hf_batadv_batman_version
,
4600 { "Version", "batadv.batman.version",
4601 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4604 { &hf_batadv_batman_flags
,
4605 { "Flags", "batadv.batman.flags",
4606 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
4609 { &hf_batadv_batman_ttl
,
4610 { "Time to Live", "batadv.batman.ttl",
4611 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4614 { &hf_batadv_batman_gwflags
,
4615 { "Gateway Flags", "batadv.batman.gwflags",
4616 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
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,
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,
4629 { &hf_batadv_batman_tq
,
4630 { "Transmission Quality", "batadv.batman.tq",
4631 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4634 { &hf_batadv_batman_seqno
,
4635 { "Sequence number", "batadv.batman.seq",
4636 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
4639 { &hf_batadv_batman_seqno32
,
4640 { "Sequence number", "batadv.batman.seq",
4641 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
4644 { &hf_batadv_batman_orig
,
4645 { "Originator", "batadv.batman.orig",
4646 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4649 { &hf_batadv_batman_prev_sender
,
4650 { "Received from", "batadv.batman.prev_sender",
4651 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4654 { &hf_batadv_batman_num_tt
,
4655 { "Number of TTs", "batadv.batman.num_tt",
4656 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4659 { &hf_batadv_batman_tt_num_changes
,
4660 { "Number of TT Changes", "batadv.batman.tt_num_changes",
4661 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4664 { &hf_batadv_batman_ttvn
,
4665 { "TT Version", "batadv.batman.ttvn",
4666 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4669 { &hf_batadv_batman_tt_crc
,
4670 { "CRC of TT", "batadv.batman.tt_crc",
4671 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
4674 { &hf_batadv_batman_flags_directlink
,
4675 { "DirectLink", "batadv.batman.flags.directlink",
4676 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x40,
4679 { &hf_batadv_batman_flags_vis_server
,
4680 { "VIS_SERVER", "batadv.batman.flags.vis_server",
4681 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x20,
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,
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,
4694 { &hf_batadv_iv_ogm_version
,
4695 { "Version", "batadv.iv_ogm.version",
4696 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4699 { &hf_batadv_iv_ogm_ttl
,
4700 { "Time to Live", "batadv.iv_ogm.ttl",
4701 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4704 { &hf_batadv_iv_ogm_flags
,
4705 { "Flags", "batadv.iv_ogm.flags",
4706 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
4709 { &hf_batadv_iv_ogm_seqno
,
4710 { "Sequence number", "batadv.iv_ogm.seq",
4711 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
4714 { &hf_batadv_iv_ogm_orig
,
4715 { "Originator", "batadv.iv_ogm.orig",
4716 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4719 { &hf_batadv_iv_ogm_prev_sender
,
4720 { "Received from", "batadv.iv_ogm.prev_sender",
4721 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4724 { &hf_batadv_iv_ogm_tq
,
4725 { "Transmission Quality", "batadv.iv_ogm.tq",
4726 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4729 { &hf_batadv_iv_ogm_tvlv_len
,
4730 { "Length of TVLV", "batadv.iv_ogm.tvlv_len",
4731 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
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,
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,
4744 { &hf_batadv_iv_ogm_flags_directlink
,
4745 { "DirectLink", "batadv.iv_ogm.flags.directlink",
4746 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x4,
4749 { &hf_batadv_ogm2_version
,
4750 { "Version", "batadv.ogm2.version",
4751 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4754 { &hf_batadv_ogm2_ttl
,
4755 { "Time to Live", "batadv.ogm2.ttl",
4756 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4759 { &hf_batadv_ogm2_flags
,
4760 { "Flags", "batadv.ogm2.flags",
4761 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
4764 { &hf_batadv_ogm2_seqno
,
4765 { "Sequence number", "batadv.ogm2.seq",
4766 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
4769 { &hf_batadv_ogm2_orig
,
4770 { "Originator", "batadv.ogm2.orig",
4771 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4774 { &hf_batadv_ogm2_tvlv_len
,
4775 { "Length of TVLV", "batadv.ogm2.tvlv_len",
4776 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
4779 { &hf_batadv_ogm2_throughput
,
4780 { "Throughput", "batadv.ogm2.throughput",
4781 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
4784 { &hf_batadv_batman_tt
,
4785 { "Translation Table", "batadv.batman.tt",
4786 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4789 { &hf_batadv_elp_version
,
4790 { "Version", "batadv.elp.version",
4791 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4794 { &hf_batadv_elp_orig
,
4795 { "Originator", "batadv.elp.orig",
4796 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4799 { &hf_batadv_elp_seqno
,
4800 { "Sequence number", "batadv.elp.seq",
4801 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
4804 { &hf_batadv_elp_interval
,
4805 { "ELP Interval", "batadv.elp.interval",
4806 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
4809 { &hf_batadv_bcast_version
,
4810 { "Version", "batadv.bcast.version",
4811 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4814 { &hf_batadv_bcast_orig
,
4815 { "Originator", "batadv.bcast.orig",
4816 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4819 { &hf_batadv_bcast_seqno
,
4820 { "Sequence number", "batadv.bcast.seq",
4821 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
4824 { &hf_batadv_bcast_seqno32
,
4825 { "Sequence number", "batadv.bcast.seq",
4826 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
4829 { &hf_batadv_bcast_ttl
,
4830 { "Time to Live", "batadv.bcast.ttl",
4831 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4834 { &hf_batadv_icmp_version
,
4835 { "Version", "batadv.icmp.version",
4836 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4839 { &hf_batadv_icmp_msg_type
,
4840 { "Message Type", "batadv.icmp.msg_type",
4841 FT_UINT8
, BASE_DEC
, VALS(icmp_packettypenames
), 0x0,
4844 { &hf_batadv_icmp_dst
,
4845 { "Destination", "batadv.icmp.dst",
4846 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4849 { &hf_batadv_icmp_orig
,
4850 { "Originator", "batadv.icmp.orig",
4851 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4854 { &hf_batadv_icmp_ttl
,
4855 { "Time to Live", "batadv.icmp.ttl",
4856 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4859 { &hf_batadv_icmp_uid
,
4860 { "UID", "batadv.icmp.uid",
4861 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4864 { &hf_batadv_icmp_seqno
,
4865 { "Sequence number", "batadv.icmp.seq",
4866 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
4869 { &hf_batadv_icmp_rr_pointer
,
4870 { "Pointer", "batadv.icmp.rr_pointer",
4871 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4874 { &hf_batadv_icmp_rr_ether
,
4875 { "RR MAC", "batadv.icmp.rr_ether",
4876 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4879 { &hf_batadv_icmp_tp_subtype
,
4880 { "Subtype", "batadv.icmp.tp.subtype",
4881 FT_UINT8
, BASE_DEC
, VALS(icmp_tp_packettypenames
), 0x0,
4884 { &hf_batadv_icmp_tp_session
,
4885 { "Session", "batadv.icmp.tp.session",
4886 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
4889 { &hf_batadv_icmp_tp_seqno
,
4890 { "Sequence number", "batadv.icmp.tp.seqno",
4891 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
4894 { &hf_batadv_icmp_tp_timestamp
,
4895 { "Timestamp", "batadv.icmp.tp.timestamp",
4896 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
4899 { &hf_batadv_unicast_version
,
4900 { "Version", "batadv.unicast.version",
4901 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4904 { &hf_batadv_unicast_dst
,
4905 { "Destination", "batadv.unicast.dst",
4906 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4909 { &hf_batadv_unicast_ttl
,
4910 { "Time to Live", "batadv.unicast.ttl",
4911 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4914 { &hf_batadv_unicast_ttvn
,
4915 { "TT Version", "batadv.unicast.ttvn",
4916 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4919 { &hf_batadv_unicast_4addr_version
,
4920 { "Version", "batadv.unicast_4addr.version",
4921 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4924 { &hf_batadv_unicast_4addr_dst
,
4925 { "Destination", "batadv.unicast_4addr.dst",
4926 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4929 { &hf_batadv_unicast_4addr_ttl
,
4930 { "Time to Live", "batadv.unicast_4addr.ttl",
4931 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4934 { &hf_batadv_unicast_4addr_ttvn
,
4935 { "TT Version", "batadv.unicast_4addr.ttvn",
4936 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4939 { &hf_batadv_unicast_4addr_src
,
4940 { "Source", "batadv.unicast_4addr.src",
4941 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4944 { &hf_batadv_unicast_4addr_subtype
,
4945 { "Subtype", "batadv.unicast_4addr.subtype",
4946 FT_UINT8
, BASE_DEC
, VALS (unicast_4addr_typenames
), 0x0,
4949 { &hf_batadv_unicast_frag_version
,
4950 { "Version", "batadv.unicast_frag.version",
4951 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4954 { &hf_batadv_unicast_frag_dst
,
4955 { "Destination", "batadv.unicast_frag.dst",
4956 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4959 { &hf_batadv_unicast_frag_ttl
,
4960 { "Time to Live", "batadv.unicast_frag.ttl",
4961 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4964 { &hf_batadv_unicast_frag_ttvn
,
4965 { "TT Version", "batadv.unicast_frag.ttvn",
4966 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
4969 { &hf_batadv_unicast_frag_flags
,
4970 { "Flags", "batadv.unicast_frag.flags",
4971 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
4974 { &hf_batadv_unicast_frag_flags_head
,
4975 { "Head", "batadv.unicast_frag.flags.head",
4976 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x01,
4979 { &hf_batadv_unicast_frag_flags_largetail
,
4980 { "Largetail", "batadv.unicast_frag.flags.largetail",
4981 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x02,
4984 { &hf_batadv_unicast_frag_orig
,
4985 { "Originator", "batadv.unicast_frag.orig",
4986 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
4989 { &hf_batadv_unicast_frag_seqno
,
4990 { "Sequence number", "batadv.unicast_frag.seq",
4991 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
4994 { &hf_batadv_unicast_frag_no
,
4995 { "Fragment number", "batadv.unicast_frag.no",
4996 FT_UINT8
, BASE_DEC
, NULL
, 0xF0,
4999 { &hf_batadv_unicast_frag_priority
,
5000 { "Priority", "batadv.unicast_frag.priority",
5001 FT_UINT8
, BASE_DEC
, NULL
, 0xE,
5004 { &hf_batadv_unicast_frag_total_size
,
5005 { "Complete Size", "batadv.unicast_frag.total_size",
5006 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
5009 { &hf_batadv_unicast_tvlv_version
,
5010 { "Version", "batadv.unicast_tvlv.version",
5011 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5014 { &hf_batadv_unicast_tvlv_ttl
,
5015 { "Time to Live", "batadv.unicast_tvlv.ttl",
5016 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5019 { &hf_batadv_unicast_tvlv_dst
,
5020 { "Destination", "batadv.unicast_tvlv.dst",
5021 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5024 { &hf_batadv_unicast_tvlv_src
,
5025 { "Source", "batadv.unicast_tvlv.src",
5026 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5029 { &hf_batadv_unicast_tvlv_len
,
5030 { "Length of TVLV", "batadv.unicast_tvlv.len",
5031 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
5034 { &hf_batadv_vis_version
,
5035 { "Version", "batadv.vis.version",
5036 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5039 { &hf_batadv_vis_type
,
5040 { "Type", "batadv.vis.type",
5041 FT_UINT8
, BASE_DEC
, VALS(vis_packettypenames
), 0x0,
5044 { &hf_batadv_vis_seqno
,
5045 { "Sequence number", "batadv.vis.seq",
5046 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5049 { &hf_batadv_vis_seqno32
,
5050 { "Sequence number", "batadv.vis.seq",
5051 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
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,
5064 { &hf_batadv_vis_vis_orig
,
5065 { "Originator", "batadv.vis.vis_orig",
5066 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5069 { &hf_batadv_vis_target_orig
,
5070 { "Target Originator", "batadv.vis.target_orig",
5071 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5074 { &hf_batadv_vis_sender_orig
,
5075 { "Forwarding Originator", "batadv.vis.sender_orig",
5076 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5079 { &hf_batadv_vis_entry_src
,
5080 { "Source", "batadv.vis.src",
5081 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5084 { &hf_batadv_vis_entry_dst
,
5085 { "Destination", "batadv.vis.dst",
5086 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5089 { &hf_batadv_vis_entry_quality
,
5090 { "Quality", "batadv.vis.quality",
5091 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5094 { &hf_batadv_tt_query_version
,
5095 { "Version", "batadv.tt_query.version",
5096 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5099 { &hf_batadv_tt_query_ttl
,
5100 { "Time to Live", "batadv.tt_query.ttl",
5101 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5104 { &hf_batadv_tt_query_flags
,
5105 { "Flags", "batadv.tt_query.flags",
5106 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
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
,
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
,
5119 { &hf_batadv_tt_query_dst
,
5120 { "Destination", "batadv.tt_query.dst",
5121 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5124 { &hf_batadv_tt_query_src
,
5125 { "Source", "batadv.tt_query.src",
5126 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5129 { &hf_batadv_tt_query_ttvn
,
5130 { "TT Version", "batadv.tt_query.ttvn",
5131 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5134 { &hf_batadv_tt_query_tt_crc
,
5135 { "CRC of TT", "batadv.tt_query.tt_crc",
5136 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
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,
5149 { &hf_batadv_roam_adv_ttl
,
5150 { "Time to Live", "batadv.roam_adv.ttl",
5151 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5154 { &hf_batadv_roam_adv_src
,
5155 { "Source", "batadv.roam_adv.src",
5156 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5159 { &hf_batadv_roam_adv_dst
,
5160 { "Destination", "batadv.roam_adv.dst",
5161 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5164 { &hf_batadv_roam_adv_client
,
5165 { "Client", "batadv.roam_adv.client",
5166 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5169 { &hf_batadv_coded_version
,
5170 { "Version", "batadv.coded.version",
5171 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5174 { &hf_batadv_coded_ttl
,
5175 { "Time to Live", "batadv.coded.ttl",
5176 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5179 { &hf_batadv_coded_first_ttvn
,
5180 { "TT Version (First)", "batadv.coded.first_ttvn",
5181 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5184 { &hf_batadv_coded_first_source
,
5185 { "Source (First)", "batadv.coded.first_src",
5186 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5189 { &hf_batadv_coded_first_orig_dest
,
5190 { "Original Destination (First)", "batadv.coded.first_orig_dst",
5191 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5194 { &hf_batadv_coded_first_crc
,
5195 { "CRC (First)", "batadv.coded.first_crc",
5196 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
5199 { &hf_batadv_coded_second_ttl
,
5200 { "Time to Live (Second)", "batadv.coded.second_ttl",
5201 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5204 { &hf_batadv_coded_second_ttvn
,
5205 { "TT Version (Second)", "batadv.coded.second_ttvn",
5206 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5209 { &hf_batadv_coded_second_dest
,
5210 { "Destination (Second)", "batadv.coded.second_dst",
5211 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5214 { &hf_batadv_coded_second_source
,
5215 { "Source (Second)", "batadv.coded.second_src",
5216 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5219 { &hf_batadv_coded_second_orig_dest
,
5220 { "Original Destination (Second)", "batadv.coded.second_orig_dst",
5221 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5224 { &hf_batadv_coded_second_crc
,
5225 { "CRC (Second)", "batadv.coded.second_crc",
5226 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
5229 { &hf_batadv_coded_coded_len
,
5230 { "Length", "batadv.coded.length",
5231 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
5234 { &hf_msg_fragments
,
5235 {"Message fragments", "batadv.unicast_frag.fragments",
5236 FT_NONE
, BASE_NONE
, NULL
, 0x00,
5239 { &hf_batadv_tt_entry
,
5240 { "Entry", "batadv.tt_entry.entry",
5241 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5244 { &hf_batadv_tt_entry_flags
,
5245 { "Flags", "batadv.tt_entry.flags",
5246 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
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
,
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
,
5260 {"Message fragment", "batadv.unicast_frag.fragment",
5261 FT_FRAMENUM
, BASE_NONE
, NULL
, 0x00,
5264 { &hf_msg_fragment_overlap
,
5265 {"Message fragment overlap", "batadv.unicast_frag.fragment.overlap",
5266 FT_BOOLEAN
, BASE_NONE
, NULL
, 0x00,
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,
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,
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,
5286 { &hf_msg_fragment_error
,
5287 {"Message defragmentation error", "batadv.unicast_frag.fragment.error",
5288 FT_FRAMENUM
, BASE_NONE
, NULL
, 0x00,
5291 { &hf_msg_fragment_count
,
5292 {"Message fragment count", "batadv.unicast_frag.fragment.count",
5293 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
5296 { &hf_msg_reassembled_in
,
5297 {"Reassembled in", "batadv.msg.reassembled.in",
5298 FT_FRAMENUM
, BASE_NONE
, NULL
, 0x00,
5301 { &hf_msg_reassembled_length
,
5302 {"Reassembled length", "batadv.msg.reassembled.length",
5303 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
5306 { &hf_batadv_tvlv_type
,
5307 { "Type", "batadv.tvlv.length",
5308 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
5311 { &hf_batadv_tvlv_version
,
5312 { "Version", "batadv.tvlv.version",
5313 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
5316 { &hf_batadv_tvlv_len
,
5317 { "Length", "batadv.tvlv.len",
5318 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
5321 { &hf_batadv_tvlv_mcast_flags
,
5322 { "Flags", "batadv.tvlv.mcast.flags",
5323 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
5326 { &hf_batadv_tvlv_mcast_flags_unsnoopables
,
5327 { "Unsnoopables", "batadv.tvlv.mcast.flags.unsnoopables",
5328 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x1,
5331 { &hf_batadv_tvlv_mcast_flags_ipv4
,
5332 { "IPv4", "batadv.tvlv.mcast.flags.ipv4",
5333 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x2,
5336 { &hf_batadv_tvlv_mcast_flags_ipv6
,
5337 { "IPv6", "batadv.tvlv.mcast.flags.ipv6",
5338 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x4,
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,
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,
5351 { &hf_batadv_tvlv_gw_download
,
5352 { "Download Speed", "batadv.tvlv.gw.dl_speed",
5353 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
5356 { &hf_batadv_tvlv_gw_upload
,
5357 { "Upload Speed", "batadv.tvlv.gw.ul_speed",
5358 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
5361 { &hf_batadv_tvlv_roam_addr
,
5362 { "Address", "batadv.batman.addr",
5363 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5366 { &hf_batadv_tvlv_roam_vid
,
5367 { "VID", "batadv.tvlv.roam.vid",
5368 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
5371 { &hf_batadv_tvlv_vid_vlan
,
5372 { "VLAN ID", "batadv.tvlv.vid_vlan",
5373 FT_UINT16
, BASE_DEC
, NULL
, 0x7fff,
5376 { &hf_batadv_tvlv_vid_tagged
,
5377 { "VLAN Tagged", "batadv.tvlv.vid_tagged",
5378 FT_UINT16
, BASE_DEC
, NULL
, 0x8000,
5381 { &hf_batadv_tvlv_tt_flags
,
5382 { "Flags", "batadv.tvlv.tt.flags",
5383 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
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
,
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
,
5398 { &hf_batadv_tvlv_tt_ttvn
,
5399 { "TT Version", "batadv.tvlv.tt.ttvn",
5400 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
5403 { &hf_batadv_tvlv_tt_num_vlan
,
5404 { "VLAN Entries", "batadv.tvlv.tt.num_vlan",
5405 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
5408 { &hf_batadv_tvlv_tt_vlan_crc
,
5409 { "CRC", "batadv.tvlv.tt.vlan.crc",
5410 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
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,
5418 { &hf_batadv_tvlv_tt_vlan_vid
,
5419 { "VID", "batadv.tvlv.tt.vlan.vid",
5420 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
5423 { &hf_batadv_tvlv_tt_change_flags
,
5424 { "Flags", "batadv.tvlv.tt.change.flags",
5425 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
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
,
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
,
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
,
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
,
5452 { &hf_batadv_tvlv_tt_change_addr
,
5453 { "Address", "batadv.tvlv.tt.change.addr",
5454 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
5457 { &hf_batadv_tvlv_tt_change_vid
,
5458 { "VID", "batadv.tvlv.tt.change.vid",
5459 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
5464 /* Setup protocol subtree array */
5465 static int *ett
[] = {
5467 &ett_batadv_batman_flags
,
5468 &ett_batadv_batman_tt
,
5469 &ett_batadv_batman_gwflags
,
5471 &ett_batadv_iv_ogm_flags
,
5474 //&ett_batadv_ogm2_flags,
5477 &ett_batadv_icmp_rr
,
5478 &ett_batadv_unicast
,
5479 &ett_batadv_unicast_4addr
,
5480 &ett_batadv_unicast_frag
,
5481 &ett_batadv_unicast_tvlv
,
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
,
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
,
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",
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
;
5537 eth_handle
= find_dissector_add_dependency("eth_withoutfcs", proto_batadv_plugin
);
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
5554 * indent-tabs-mode: t
5557 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
5558 * :indentSize=8:tabSize=8:noTabs=false: