2
* Routines for B.A.T.M.A.N. Advanced dissection
3
* Copyright 2008-2010 Sven Eckelmann <sven.eckelmann@gmx.de>
5
* $Id: packet-batadv.c 33075 2010-06-03 18:56:39Z wmeier $
7
* Wireshark - Network traffic analyzer
8
* By Gerald Combs <gerald@wireshark.org>
9
* Copyright 1998 Gerald Combs
11
* This program is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU General Public License
13
* as published by the Free Software Foundation; either version 2
14
* of the License, or (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
#include <epan/packet.h>
31
#include <epan/prefs.h>
33
#include <epan/addr_resolv.h>
35
/* Start content from packet-batadv.h */
36
#define ETH_P_BATMAN 0x4305
38
#define BATADV_PACKET 0x01
39
#define BATADV_ICMP 0x02
40
#define BATADV_UNICAST 0x03
41
#define BATADV_BCAST 0x04
42
#define BATADV_VIS 0x05
45
#define DESTINATION_UNREACHABLE 3
46
#define ECHO_REQUEST 8
47
#define TTL_EXCEEDED 11
49
struct batman_packet_v5 {
51
guint8 version; /* batman version field */
52
guint8 flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
54
guint8 gwflags; /* flags related to gateway functions: gateway class */
62
#define BATMAN_PACKET_V5_SIZE 22
64
struct batman_packet_v7 {
66
guint8 version; /* batman version field */
67
guint8 flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
75
#define BATMAN_PACKET_V7_SIZE 20
77
struct batman_packet_v9 {
79
guint8 version; /* batman version field */
80
guint8 flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
90
#define BATMAN_PACKET_V9_SIZE 22
92
struct batman_packet_v10 {
94
guint8 version; /* batman version field */
95
guint8 flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
105
#define BATMAN_PACKET_V10_SIZE 24
107
struct icmp_packet_v6 {
109
guint8 version; /* batman version field */
110
guint8 msg_type; /* 0 = ECHO REPLY, 3 = DESTINATION_UNREACHABLE, 8 = ECHO_REQUEST, 11 = TTL exceeded */
117
#define ICMP_PACKET_V6_SIZE 19
119
struct icmp_packet_v7 {
121
guint8 version; /* batman version field */
122
guint8 msg_type; /* 0 = ECHO REPLY, 3 = DESTINATION_UNREACHABLE, 8 = ECHO_REQUEST, 11 = TTL exceeded */
129
#define ICMP_PACKET_V7_SIZE 18
131
struct unicast_packet_v6 {
137
#define UNICAST_PACKET_V6_SIZE 9
139
struct bcast_packet_v6 {
141
guint8 version; /* batman version field */
145
#define BCAST_PACKET_V6_SIZE 10
147
struct bcast_packet_v10 {
149
guint8 version; /* batman version field */
154
#define BCAST_PACKET_V10_SIZE 13
156
struct vis_packet_v6 {
158
guint8 version; /* batman version field */
159
guint8 vis_type; /* which type of vis-participant sent this? */
160
guint8 seqno; /* sequence number */
161
guint8 entries; /* number of entries behind this struct */
162
guint8 ttl; /* TTL */
163
address vis_orig; /* originator that informs about its neighbours */
164
address target_orig; /* who should receive this packet */
165
address sender_orig; /* who sent or rebroadcasted this packet */
167
#define VIS_PACKET_V6_SIZE 24
169
struct vis_packet_v10 {
171
guint8 version; /* batman version field */
172
guint8 vis_type; /* which type of vis-participant sent this? */
173
guint8 entries; /* number of entries behind this struct */
174
guint32 seqno; /* sequence number */
175
guint8 ttl; /* TTL */
176
address vis_orig; /* originator that informs about its neighbours */
177
address target_orig; /* who should receive this packet */
178
address sender_orig; /* who sent or rebroadcasted this packet */
180
#define VIS_PACKET_V10_SIZE 27
182
#define VIS_ENTRY_V6_SIZE 7
183
#define VIS_ENTRY_V8_SIZE 13
185
#define VIS_TYPE_SERVER_SYNC 0
186
#define VIS_TYPE_CLIENT_UPDATE 1
187
/* End content from packet-batadv.h */
190
static gint ett_batadv_batman = -1;
191
static gint ett_batadv_batman_flags = -1;
192
static gint ett_batadv_batman_gwflags = -1;
193
static gint ett_batadv_batman_hna = -1;
194
static gint ett_batadv_bcast = -1;
195
static gint ett_batadv_icmp = -1;
196
static gint ett_batadv_unicast = -1;
197
static gint ett_batadv_vis = -1;
198
static gint ett_batadv_vis_entry = -1;
201
static int hf_batadv_packet_type = -1;
203
static int hf_batadv_batman_version = -1;
204
static int hf_batadv_batman_flags = -1;
205
static int hf_batadv_batman_ttl = -1;
206
static int hf_batadv_batman_gwflags = -1;
207
static int hf_batadv_batman_tq = -1;
208
static int hf_batadv_batman_seqno = -1;
209
static int hf_batadv_batman_seqno32 = -1;
210
static int hf_batadv_batman_orig = -1;
211
static int hf_batadv_batman_prev_sender = -1;
212
static int hf_batadv_batman_num_hna = -1;
213
static int hf_batadv_batman_pad = -1;
214
static int hf_batadv_batman_hna = -1;
216
static int hf_batadv_bcast_version = -1;
217
static int hf_batadv_bcast_pad = -1;
218
static int hf_batadv_bcast_orig = -1;
219
static int hf_batadv_bcast_seqno = -1;
220
static int hf_batadv_bcast_seqno32 = -1;
221
static int hf_batadv_bcast_ttl = -1;
223
static int hf_batadv_icmp_version = -1;
224
static int hf_batadv_icmp_msg_type = -1;
225
static int hf_batadv_icmp_dst = -1;
226
static int hf_batadv_icmp_orig = -1;
227
static int hf_batadv_icmp_ttl = -1;
228
static int hf_batadv_icmp_uid = -1;
229
static int hf_batadv_icmp_seqno = -1;
231
static int hf_batadv_unicast_version = -1;
232
static int hf_batadv_unicast_dst = -1;
233
static int hf_batadv_unicast_ttl = -1;
235
static int hf_batadv_vis_version = -1;
236
static int hf_batadv_vis_type = -1;
237
static int hf_batadv_vis_seqno = -1;
238
static int hf_batadv_vis_seqno32 = -1;
239
static int hf_batadv_vis_entries = -1;
240
static int hf_batadv_vis_ttl = -1;
241
static int hf_batadv_vis_vis_orig = -1;
242
static int hf_batadv_vis_target_orig = -1;
243
static int hf_batadv_vis_sender_orig = -1;
244
static int hf_batadv_vis_entry_src = -1;
245
static int hf_batadv_vis_entry_dst = -1;
246
static int hf_batadv_vis_entry_quality = -1;
249
static int hf_batadv_batman_flags_directlink = -1;
250
static int hf_batadv_batman_flags_vis_server = -1;
251
static int hf_batadv_batman_flags_primaries_first_hop = -1;
253
static const value_string icmp_packettypenames[] = {
254
{ ECHO_REPLY, "ECHO_REPLY" },
255
{ DESTINATION_UNREACHABLE, "DESTINATION UNREACHABLE" },
256
{ ECHO_REQUEST, "ECHO_REQUEST" },
257
{ TTL_EXCEEDED, "TTL exceeded" },
261
static const value_string vis_packettypenames[] = {
262
{ VIS_TYPE_SERVER_SYNC, "SERVER_SYNC" },
263
{ VIS_TYPE_CLIENT_UPDATE, "CLIENT_UPDATE" },
268
/* forward declaration */
269
void proto_reg_handoff_batadv(void);
271
static dissector_handle_t batman_handle;
273
/* supported packet dissectors */
274
static void dissect_batadv_batman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
275
static int dissect_batadv_batman_v5(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
276
static int dissect_batadv_batman_v7(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
277
static int dissect_batadv_batman_v9(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
278
static int dissect_batadv_batman_v10(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
280
static void dissect_batadv_bcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
281
static void dissect_batadv_bcast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
282
static void dissect_batadv_bcast_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
284
static void dissect_batadv_icmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
285
static void dissect_batadv_icmp_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
286
static void dissect_batadv_icmp_v7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
288
static void dissect_batadv_unicast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
289
static void dissect_batadv_unicast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
291
static void dissect_batadv_vis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
292
static void dissect_batadv_vis_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
293
static void dissect_batadv_vis_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
295
static void dissect_batadv_hna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
296
static void dissect_vis_entry_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
297
static void dissect_vis_entry_v8(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
299
/* other dissectors */
300
static dissector_handle_t data_handle;
301
static dissector_handle_t eth_handle;
303
static int proto_batadv_plugin = -1;
306
static int batadv_tap = -1;
307
static int batadv_follow_tap = -1;
309
static unsigned int batadv_ethertype = ETH_P_BATMAN;
311
static void dissect_batman_plugin(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
315
col_clear(pinfo->cinfo, COL_INFO);
317
type = tvb_get_guint8(tvb, 0);
321
dissect_batadv_batman(tvb, pinfo, tree);
324
dissect_batadv_icmp(tvb, pinfo, tree);
327
dissect_batadv_unicast(tvb, pinfo, tree);
330
dissect_batadv_bcast(tvb, pinfo, tree);
333
dissect_batadv_vis(tvb, pinfo, tree);
339
guint length_remaining;
341
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_???");
343
length_remaining = tvb_length_remaining(tvb, 1);
344
next_tvb = tvb_new_subset(tvb, 0, length_remaining, -1);
345
call_dissector(data_handle, next_tvb, pinfo, tree);
351
static void dissect_batadv_batman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
356
/* set protocol name */
357
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_BATMAN");
359
version = tvb_get_guint8(tvb, 1);
363
while (offset != -1 && tvb_length_remaining(tvb, offset) >= BATMAN_PACKET_V5_SIZE) {
364
offset = dissect_batadv_batman_v5(tvb, offset, pinfo, tree);
369
while (offset != -1 && tvb_length_remaining(tvb, offset) >= BATMAN_PACKET_V7_SIZE) {
370
offset = dissect_batadv_batman_v7(tvb, offset, pinfo, tree);
374
while (offset != -1 && tvb_length_remaining(tvb, offset) >= BATMAN_PACKET_V9_SIZE) {
375
offset = dissect_batadv_batman_v9(tvb, offset, pinfo, tree);
379
while (offset != -1 && tvb_length_remaining(tvb, offset) >= BATMAN_PACKET_V10_SIZE) {
380
offset = dissect_batadv_batman_v10(tvb, offset, pinfo, tree);
384
col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
385
call_dissector(data_handle, tvb, pinfo, tree);
390
static void dissect_batadv_gwflags(tvbuff_t *tvb, guint8 gwflags, int offset, proto_item *tgw)
392
proto_tree *gwflags_tree;
393
guint8 s = (gwflags & 0x80) >> 7;
394
guint8 downbits = (gwflags & 0x78) >> 3;
395
guint8 upbits = (gwflags & 0x07);
402
down = 32 * (s + 2) * (1 << downbits);
403
up = ((upbits + 1) * down) / 8;
406
gwflags_tree = proto_item_add_subtree(tgw, ett_batadv_batman_gwflags);
407
proto_tree_add_text(gwflags_tree, tvb, offset, 1, "Download Speed: %dkbit", down);
408
proto_tree_add_text(gwflags_tree, tvb, offset, 1, "Upload Speed: %dkbit", up);
412
static int dissect_batadv_batman_v5(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
414
proto_item *tf, *tgw;
415
proto_tree *batadv_batman_tree = NULL, *flag_tree;
417
struct batman_packet_v5 *batman_packeth;
418
const guint8 *prev_sender_addr, *orig_addr;
423
batman_packeth = ep_alloc(sizeof(struct batman_packet_v5));
425
type = tvb_get_guint8(tvb, offset+0);
426
batman_packeth->version = tvb_get_guint8(tvb, offset+1);
428
/* don't interpret padding as B.A.T.M.A.N. advanced packet */
429
if (batman_packeth->version == 0 || type != BATADV_PACKET) {
433
batman_packeth->flags = tvb_get_guint8(tvb, offset+2);
434
batman_packeth->ttl = tvb_get_guint8(tvb, offset+3);
435
batman_packeth->gwflags = tvb_get_guint8(tvb, offset+4);
436
batman_packeth->tq = tvb_get_guint8(tvb, offset+5);
437
batman_packeth->seqno = tvb_get_ntohs(tvb, offset+6);
438
orig_addr = tvb_get_ptr(tvb, offset+8, 6);
439
SET_ADDRESS(&batman_packeth->orig, AT_ETHER, 6, orig_addr);
440
prev_sender_addr = tvb_get_ptr(tvb, offset+14, 6);
441
SET_ADDRESS(&batman_packeth->prev_sender, AT_ETHER, 6, prev_sender_addr);
442
batman_packeth->num_hna = tvb_get_guint8(tvb, offset+20);
443
batman_packeth->pad = tvb_get_guint8(tvb, offset+21);
445
/* Set info column */
446
col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
452
if (PTREE_DATA(tree)->visible) {
453
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V5_SIZE,
454
"B.A.T.M.A.N., Orig: %s (%s)",
455
get_ether_name(orig_addr), ether_to_str(orig_addr));
457
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V5_SIZE, FALSE);
459
batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
463
proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET,
464
"Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET);
467
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, FALSE);
470
tf = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_flags, tvb, offset, 1, FALSE);
472
flag_tree = proto_item_add_subtree(tf, ett_batadv_batman_flags);
473
proto_tree_add_boolean(flag_tree, hf_batadv_batman_flags_directlink, tvb, offset, 1, batman_packeth->flags);
474
proto_tree_add_boolean(flag_tree, hf_batadv_batman_flags_vis_server, tvb, offset, 1, batman_packeth->flags);
478
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, FALSE);
481
tgw = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_gwflags, tvb, offset, 1, FALSE);
482
dissect_batadv_gwflags(tvb, batman_packeth->gwflags, offset, tgw);
485
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, FALSE);
488
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno, tvb, offset, 2, FALSE);
491
proto_tree_add_ether(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, orig_addr);
494
proto_tree_add_ether(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, prev_sender_addr);
497
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_hna, tvb, offset, 1, FALSE);
500
/* Hidden: proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_pad, tvb, offset, 1, FALSE); */
503
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, orig_addr);
504
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, orig_addr);
506
tap_queue_packet(batadv_tap, pinfo, batman_packeth);
508
for (i = 0; i < batman_packeth->num_hna; i++) {
509
next_tvb = tvb_new_subset(tvb, offset, 6, 6);
511
if (have_tap_listener(batadv_follow_tap)) {
512
tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
515
dissect_batadv_hna(next_tvb, pinfo, batadv_batman_tree);
522
static int dissect_batadv_batman_v7(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
525
proto_tree *batadv_batman_tree = NULL, *flag_tree;
527
struct batman_packet_v7 *batman_packeth;
528
const guint8 *prev_sender_addr, *orig_addr;
533
batman_packeth = ep_alloc(sizeof(struct batman_packet_v7));
535
type = tvb_get_guint8(tvb, offset+0);
536
batman_packeth->version = tvb_get_guint8(tvb, offset+1);
538
/* don't interpret padding as B.A.T.M.A.N. advanced packet */
539
if (batman_packeth->version == 0 || type != BATADV_PACKET) {
543
batman_packeth->flags = tvb_get_guint8(tvb, offset+2);
544
batman_packeth->tq = tvb_get_guint8(tvb, offset+3);
545
batman_packeth->seqno = tvb_get_ntohs(tvb, offset+4);
546
orig_addr = tvb_get_ptr(tvb, offset+6, 6);
547
SET_ADDRESS(&batman_packeth->orig, AT_ETHER, 6, orig_addr);
548
prev_sender_addr = tvb_get_ptr(tvb, offset+12, 6);
549
SET_ADDRESS(&batman_packeth->prev_sender, AT_ETHER, 6, prev_sender_addr);
550
batman_packeth->ttl = tvb_get_guint8(tvb, offset+18);
551
batman_packeth->num_hna = tvb_get_guint8(tvb, offset+19);
553
/* Set info column */
554
col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
560
if (PTREE_DATA(tree)->visible) {
561
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V7_SIZE,
562
"B.A.T.M.A.N., Orig: %s (%s)",
563
get_ether_name(orig_addr), ether_to_str(orig_addr));
565
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V7_SIZE, FALSE);
567
batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
571
proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET,
572
"Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET);
575
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, FALSE);
578
tf = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_flags, tvb, offset, 1, FALSE);
580
flag_tree = proto_item_add_subtree(tf, ett_batadv_batman_flags);
581
proto_tree_add_boolean(flag_tree, hf_batadv_batman_flags_directlink, tvb, offset, 1, batman_packeth->flags);
582
proto_tree_add_boolean(flag_tree, hf_batadv_batman_flags_vis_server, tvb, offset, 1, batman_packeth->flags);
586
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, FALSE);
589
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno, tvb, offset, 2, FALSE);
592
proto_tree_add_ether(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, orig_addr);
595
proto_tree_add_ether(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, prev_sender_addr);
598
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, FALSE);
601
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_hna, tvb, offset, 1, FALSE);
604
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, orig_addr);
605
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, orig_addr);
607
tap_queue_packet(batadv_tap, pinfo, batman_packeth);
609
for (i = 0; i < batman_packeth->num_hna; i++) {
610
next_tvb = tvb_new_subset(tvb, offset, 6, 6);
612
if (have_tap_listener(batadv_follow_tap)) {
613
tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
616
dissect_batadv_hna(next_tvb, pinfo, batadv_batman_tree);
623
static int dissect_batadv_batman_v9(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
625
proto_item *tf, *tgw;
626
proto_tree *batadv_batman_tree = NULL, *flag_tree;
628
struct batman_packet_v9 *batman_packeth;
629
const guint8 *prev_sender_addr, *orig_addr;
634
batman_packeth = ep_alloc(sizeof(struct batman_packet_v9));
636
type = tvb_get_guint8(tvb, offset+0);
637
batman_packeth->version = tvb_get_guint8(tvb, offset+1);
639
/* don't interpret padding as B.A.T.M.A.N. advanced packet */
640
if (batman_packeth->version == 0 || type != BATADV_PACKET) {
644
batman_packeth->flags = tvb_get_guint8(tvb, offset+2);
645
batman_packeth->tq = tvb_get_guint8(tvb, offset+3);
646
batman_packeth->seqno = tvb_get_ntohs(tvb, offset+4);
647
orig_addr = tvb_get_ptr(tvb, offset+6, 6);
648
SET_ADDRESS(&batman_packeth->orig, AT_ETHER, 6, orig_addr);
649
prev_sender_addr = tvb_get_ptr(tvb, offset+12, 6);
650
SET_ADDRESS(&batman_packeth->prev_sender, AT_ETHER, 6, prev_sender_addr);
651
batman_packeth->ttl = tvb_get_guint8(tvb, offset+18);
652
batman_packeth->num_hna = tvb_get_guint8(tvb, offset+19);
653
batman_packeth->gwflags = tvb_get_guint8(tvb, offset+20);
655
/* Set info column */
656
col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
662
if (PTREE_DATA(tree)->visible) {
663
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V9_SIZE,
664
"B.A.T.M.A.N., Orig: %s (%s)",
665
get_ether_name(orig_addr), ether_to_str(orig_addr));
667
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V9_SIZE, FALSE);
669
batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
673
proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET,
674
"Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET);
677
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, FALSE);
680
tf = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_flags, tvb, offset, 1, FALSE);
682
flag_tree = proto_item_add_subtree(tf, ett_batadv_batman_flags);
683
proto_tree_add_boolean(flag_tree, hf_batadv_batman_flags_directlink, tvb, offset, 1, batman_packeth->flags);
684
proto_tree_add_boolean(flag_tree, hf_batadv_batman_flags_vis_server, tvb, offset, 1, batman_packeth->flags);
685
proto_tree_add_boolean(flag_tree, hf_batadv_batman_flags_primaries_first_hop, tvb, offset, 1, batman_packeth->flags);
689
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, FALSE);
692
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno, tvb, offset, 2, FALSE);
695
proto_tree_add_ether(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, orig_addr);
698
proto_tree_add_ether(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, prev_sender_addr);
701
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, FALSE);
704
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_hna, tvb, offset, 1, FALSE);
707
tgw = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_gwflags, tvb, offset, 1, FALSE);
708
dissect_batadv_gwflags(tvb, batman_packeth->gwflags, offset, tgw);
711
/* Hidden: proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_pad, tvb, offset, 1, FALSE); */
714
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, orig_addr);
715
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, orig_addr);
717
tap_queue_packet(batadv_tap, pinfo, batman_packeth);
719
for (i = 0; i < batman_packeth->num_hna; i++) {
720
next_tvb = tvb_new_subset(tvb, offset, 6, 6);
722
if (have_tap_listener(batadv_follow_tap)) {
723
tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
726
dissect_batadv_hna(next_tvb, pinfo, batadv_batman_tree);
733
static int dissect_batadv_batman_v10(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
735
proto_item *tf, *tgw;
736
proto_tree *batadv_batman_tree = NULL, *flag_tree;
738
struct batman_packet_v10 *batman_packeth;
739
const guint8 *prev_sender_addr, *orig_addr;
744
batman_packeth = ep_alloc(sizeof(struct batman_packet_v10));
746
type = tvb_get_guint8(tvb, offset+0);
747
batman_packeth->version = tvb_get_guint8(tvb, offset+1);
749
/* don't interpret padding as B.A.T.M.A.N. advanced packet */
750
if (batman_packeth->version == 0 || type != BATADV_PACKET) {
754
batman_packeth->flags = tvb_get_guint8(tvb, offset+2);
755
batman_packeth->tq = tvb_get_guint8(tvb, offset+3);
756
batman_packeth->seqno = tvb_get_ntohl(tvb, offset+4);
757
orig_addr = tvb_get_ptr(tvb, offset+8, 6);
758
SET_ADDRESS(&batman_packeth->orig, AT_ETHER, 6, orig_addr);
759
prev_sender_addr = tvb_get_ptr(tvb, offset+14, 6);
760
SET_ADDRESS(&batman_packeth->prev_sender, AT_ETHER, 6, prev_sender_addr);
761
batman_packeth->ttl = tvb_get_guint8(tvb, offset+20);
762
batman_packeth->num_hna = tvb_get_guint8(tvb, offset+21);
763
batman_packeth->gwflags = tvb_get_guint8(tvb, offset+22);
765
/* Set info column */
766
col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
772
if (PTREE_DATA(tree)->visible) {
773
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V10_SIZE,
774
"B.A.T.M.A.N., Orig: %s (%s)",
775
get_ether_name(orig_addr), ether_to_str(orig_addr));
777
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V10_SIZE, FALSE);
779
batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
783
proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET,
784
"Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET);
787
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, FALSE);
790
tf = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_flags, tvb, offset, 1, FALSE);
792
flag_tree = proto_item_add_subtree(tf, ett_batadv_batman_flags);
793
proto_tree_add_boolean(flag_tree, hf_batadv_batman_flags_directlink, tvb, offset, 1, batman_packeth->flags);
794
proto_tree_add_boolean(flag_tree, hf_batadv_batman_flags_vis_server, tvb, offset, 1, batman_packeth->flags);
795
proto_tree_add_boolean(flag_tree, hf_batadv_batman_flags_primaries_first_hop, tvb, offset, 1, batman_packeth->flags);
799
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, FALSE);
802
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno32, tvb, offset, 4, FALSE);
805
proto_tree_add_ether(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, orig_addr);
808
proto_tree_add_ether(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, prev_sender_addr);
811
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, FALSE);
814
proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_hna, tvb, offset, 1, FALSE);
817
tgw = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_gwflags, tvb, offset, 1, FALSE);
818
dissect_batadv_gwflags(tvb, batman_packeth->gwflags, offset, tgw);
821
/* Hidden: proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_pad, tvb, offset, 1, FALSE); */
824
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, orig_addr);
825
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, orig_addr);
827
tap_queue_packet(batadv_tap, pinfo, batman_packeth);
829
for (i = 0; i < batman_packeth->num_hna; i++) {
830
next_tvb = tvb_new_subset(tvb, offset, 6, 6);
832
if (have_tap_listener(batadv_follow_tap)) {
833
tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
836
dissect_batadv_hna(next_tvb, pinfo, batadv_batman_tree);
843
static void dissect_batadv_hna(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
847
hna = tvb_get_ptr(tvb, 0, 6);
852
proto_tree *batadv_batman_hna_tree;
854
if (PTREE_DATA(tree)->visible) {
855
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, 6,
856
"B.A.T.M.A.N. HNA: %s (%s)",
857
get_ether_name(hna), ether_to_str(hna));
859
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, 0, 6, FALSE);
861
batadv_batman_hna_tree = proto_item_add_subtree(ti, ett_batadv_batman_hna);
863
proto_tree_add_ether(batadv_batman_hna_tree, hf_batadv_batman_hna, tvb, 0, 6, hna);
867
static void dissect_batadv_bcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
871
/* set protocol name */
872
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_BCAST");
874
version = tvb_get_guint8(tvb, 1);
880
dissect_batadv_bcast_v6(tvb, pinfo, tree);
883
dissect_batadv_bcast_v10(tvb, pinfo, tree);
886
col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
887
call_dissector(data_handle, tvb, pinfo, tree);
892
static void dissect_batadv_bcast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
894
struct bcast_packet_v6 *bcast_packeth;
895
const guint8 *orig_addr;
898
guint length_remaining;
901
bcast_packeth = ep_alloc(sizeof(struct bcast_packet_v6));
903
bcast_packeth->version = tvb_get_guint8(tvb, 1);
904
orig_addr = tvb_get_ptr(tvb, 2, 6);
905
SET_ADDRESS(&bcast_packeth->orig, AT_ETHER, 6, orig_addr);
906
bcast_packeth->seqno = tvb_get_ntohs(tvb, 8);
908
/* Set info column */
909
col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", bcast_packeth->seqno);
914
proto_tree *batadv_bcast_tree;
916
if (PTREE_DATA(tree)->visible) {
917
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, BCAST_PACKET_V6_SIZE,
918
"B.A.T.M.A.N. Bcast, Orig: %s (%s)",
919
get_ether_name(orig_addr), ether_to_str(orig_addr));
921
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, 0, BCAST_PACKET_V6_SIZE, FALSE);
923
batadv_bcast_tree = proto_item_add_subtree(ti, ett_batadv_bcast);
926
proto_tree_add_uint_format(batadv_bcast_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_BCAST,
927
"Packet Type: %s (%u)", "BATADV_BCAST", BATADV_BCAST);
930
proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_version, tvb, offset, 1, FALSE);
933
proto_tree_add_ether(batadv_bcast_tree, hf_batadv_bcast_orig, tvb, offset, 6, orig_addr);
936
proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_seqno, tvb, offset, 2, FALSE);
940
/* Calculate offset even when we got no tree */
941
offset = BCAST_PACKET_V6_SIZE;
943
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, orig_addr);
944
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, orig_addr);
946
tap_queue_packet(batadv_tap, pinfo, bcast_packeth);
948
length_remaining = tvb_length_remaining(tvb, offset);
950
if (length_remaining != 0) {
951
next_tvb = tvb_new_subset(tvb, offset, length_remaining, -1);
953
if (have_tap_listener(batadv_follow_tap)) {
954
tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
957
call_dissector(eth_handle, next_tvb, pinfo, tree);
961
static void dissect_batadv_bcast_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
963
struct bcast_packet_v10 *bcast_packeth;
964
const guint8 *orig_addr;
967
guint length_remaining;
970
bcast_packeth = ep_alloc(sizeof(struct bcast_packet_v10));
972
bcast_packeth->version = tvb_get_guint8(tvb, 1);
973
orig_addr = tvb_get_ptr(tvb, 2, 6);
974
SET_ADDRESS(&bcast_packeth->orig, AT_ETHER, 6, orig_addr);
975
bcast_packeth->ttl = tvb_get_guint8(tvb, 8);
976
bcast_packeth->seqno = tvb_get_ntohl(tvb, 9);
978
/* Set info column */
979
col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", bcast_packeth->seqno);
984
proto_tree *batadv_bcast_tree;
986
if (PTREE_DATA(tree)->visible) {
987
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, BCAST_PACKET_V10_SIZE,
988
"B.A.T.M.A.N. Bcast, Orig: %s (%s)",
989
get_ether_name(orig_addr), ether_to_str(orig_addr));
991
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, 0, BCAST_PACKET_V10_SIZE, FALSE);
993
batadv_bcast_tree = proto_item_add_subtree(ti, ett_batadv_bcast);
996
proto_tree_add_uint_format(batadv_bcast_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_BCAST,
997
"Packet Type: %s (%u)", "BATADV_BCAST", BATADV_BCAST);
1000
proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_version, tvb, offset, 1, FALSE);
1003
proto_tree_add_ether(batadv_bcast_tree, hf_batadv_bcast_orig, tvb, offset, 6, orig_addr);
1006
proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_ttl, tvb, offset, 1, FALSE);
1009
proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_seqno32, tvb, offset, 4, FALSE);
1013
/* Calculate offset even when we got no tree */
1014
offset = BCAST_PACKET_V10_SIZE;
1016
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, orig_addr);
1017
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, orig_addr);
1019
tap_queue_packet(batadv_tap, pinfo, bcast_packeth);
1021
length_remaining = tvb_length_remaining(tvb, offset);
1023
if (length_remaining != 0) {
1024
next_tvb = tvb_new_subset(tvb, offset, length_remaining, -1);
1026
if (have_tap_listener(batadv_follow_tap)) {
1027
tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1030
call_dissector(eth_handle, next_tvb, pinfo, tree);
1034
static void dissect_batadv_icmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1038
/* set protocol name */
1039
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_ICMP");
1041
version = tvb_get_guint8(tvb, 1);
1044
dissect_batadv_icmp_v6(tvb, pinfo, tree);
1050
dissect_batadv_icmp_v7(tvb, pinfo, tree);
1053
col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
1054
call_dissector(data_handle, tvb, pinfo, tree);
1059
static void dissect_batadv_icmp_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1061
struct icmp_packet_v6 *icmp_packeth;
1062
const guint8 *dst_addr, *orig_addr;
1065
guint length_remaining;
1068
icmp_packeth = ep_alloc(sizeof(struct icmp_packet_v6));
1070
icmp_packeth->version = tvb_get_guint8(tvb, 1);
1071
icmp_packeth->msg_type = tvb_get_guint8(tvb, 2);
1072
dst_addr = tvb_get_ptr(tvb, 3, 6);
1073
SET_ADDRESS(&icmp_packeth->dst, AT_ETHER, 6, dst_addr);
1074
orig_addr = tvb_get_ptr(tvb, 9, 6);
1075
SET_ADDRESS(&icmp_packeth->orig, AT_ETHER, 6, orig_addr);
1076
icmp_packeth->ttl = tvb_get_guint8(tvb, 15);
1077
icmp_packeth->uid = tvb_get_guint8(tvb, 16);
1078
icmp_packeth->seqno = tvb_get_ntohs(tvb, 17);
1080
/* Set info column */
1081
if (check_col(pinfo->cinfo, COL_INFO)) {
1082
col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
1083
val_to_str(icmp_packeth->msg_type, icmp_packettypenames, "Unknown (0x%02x)"),
1084
icmp_packeth->seqno);
1089
proto_tree *batadv_icmp_tree;
1091
if (PTREE_DATA(tree)->visible) {
1092
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, ICMP_PACKET_V6_SIZE,
1093
"B.A.T.M.A.N. ICMP, Orig: %s (%s), Dst: %s (%s)",
1094
get_ether_name(orig_addr), ether_to_str(orig_addr), get_ether_name(dst_addr), ether_to_str(dst_addr));
1096
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, 0, ICMP_PACKET_V6_SIZE, FALSE);
1098
batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
1101
proto_tree_add_uint_format(batadv_icmp_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_ICMP,
1102
"Packet Type: %s (%u)", "BATADV_ICMP", BATADV_ICMP);
1105
proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb, offset, 1, FALSE);
1108
proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_msg_type, tvb, offset, 1, FALSE);
1111
proto_tree_add_ether(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset, 6, dst_addr);
1114
proto_tree_add_ether(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset, 6, orig_addr);
1117
proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset, 1, FALSE);
1120
proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset, 1, FALSE);
1123
proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_seqno, tvb, offset, 1, FALSE);
1127
/* Calculate offset even when we got no tree */
1128
offset = ICMP_PACKET_V6_SIZE;
1130
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, orig_addr);
1131
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, orig_addr);
1133
SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, orig_addr);
1134
SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, orig_addr);
1136
tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
1138
length_remaining = tvb_length_remaining(tvb, offset);
1140
if (length_remaining != 0) {
1141
next_tvb = tvb_new_subset(tvb, offset, length_remaining, -1);
1143
call_dissector(data_handle, next_tvb, pinfo, tree);
1147
static void dissect_batadv_icmp_v7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1149
struct icmp_packet_v7 *icmp_packeth;
1150
const guint8 *dst_addr, *orig_addr;
1153
guint length_remaining;
1156
icmp_packeth = ep_alloc(sizeof(struct icmp_packet_v7));
1158
icmp_packeth->version = tvb_get_guint8(tvb, 1);
1159
icmp_packeth->msg_type = tvb_get_guint8(tvb, 2);
1160
icmp_packeth->ttl = tvb_get_guint8(tvb, 3);
1161
dst_addr = tvb_get_ptr(tvb, 4, 6);
1162
SET_ADDRESS(&icmp_packeth->dst, AT_ETHER, 6, dst_addr);
1163
orig_addr = tvb_get_ptr(tvb, 10, 6);
1164
SET_ADDRESS(&icmp_packeth->orig, AT_ETHER, 6, orig_addr);
1165
icmp_packeth->seqno = tvb_get_ntohs(tvb, 16);
1166
icmp_packeth->uid = tvb_get_guint8(tvb, 17);
1168
/* Set info column */
1169
if (check_col(pinfo->cinfo, COL_INFO)) {
1170
col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
1171
val_to_str(icmp_packeth->msg_type, icmp_packettypenames, "Unknown (0x%02x)"),
1172
icmp_packeth->seqno);
1177
proto_tree *batadv_icmp_tree;
1179
if (PTREE_DATA(tree)->visible) {
1180
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, ICMP_PACKET_V7_SIZE,
1181
"B.A.T.M.A.N. ICMP, Orig: %s (%s), Dst: %s (%s)",
1182
get_ether_name(orig_addr), ether_to_str(orig_addr), get_ether_name(dst_addr), ether_to_str(dst_addr));
1184
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, 0, ICMP_PACKET_V7_SIZE, FALSE);
1186
batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
1189
proto_tree_add_uint_format(batadv_icmp_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_ICMP,
1190
"Packet Type: %s (%u)", "BATADV_ICMP", BATADV_ICMP);
1193
proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb, offset, 1, FALSE);
1196
proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_msg_type, tvb, offset, 1, FALSE);
1199
proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset, 1, FALSE);
1202
proto_tree_add_ether(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset, 6, dst_addr);
1205
proto_tree_add_ether(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset, 6, orig_addr);
1208
proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_seqno, tvb, offset, 1, FALSE);
1211
proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset, 1, FALSE);
1215
/* Calculate offset even when we got no tree */
1216
offset = ICMP_PACKET_V7_SIZE;
1218
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, orig_addr);
1219
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, orig_addr);
1221
SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, orig_addr);
1222
SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, orig_addr);
1224
tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
1226
length_remaining = tvb_length_remaining(tvb, offset);
1228
if (length_remaining != 0) {
1229
next_tvb = tvb_new_subset(tvb, offset, length_remaining, -1);
1231
call_dissector(data_handle, next_tvb, pinfo, tree);
1235
static void dissect_batadv_unicast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1239
/* set protocol name */
1240
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_UNICAST");
1242
version = tvb_get_guint8(tvb, 1);
1249
dissect_batadv_unicast_v6(tvb, pinfo, tree);
1252
col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
1253
call_dissector(data_handle, tvb, pinfo, tree);
1258
static void dissect_batadv_unicast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1260
struct unicast_packet_v6 *unicast_packeth;
1261
const guint8 *dest_addr;
1264
guint length_remaining;
1267
unicast_packeth = ep_alloc(sizeof(struct unicast_packet_v6));
1269
unicast_packeth->version = tvb_get_guint8(tvb, 1);
1270
dest_addr = tvb_get_ptr(tvb, 2, 6);
1271
SET_ADDRESS(&unicast_packeth->dest, AT_ETHER, 6, dest_addr);
1272
unicast_packeth->ttl = tvb_get_guint8(tvb, 8);
1274
/* Set info column */
1275
col_clear(pinfo->cinfo, COL_INFO);
1280
proto_tree *batadv_unicast_tree;
1282
if (PTREE_DATA(tree)->visible) {
1283
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, UNICAST_PACKET_V6_SIZE,
1284
"B.A.T.M.A.N. Unicast, Dst: %s (%s)",
1285
get_ether_name(dest_addr), ether_to_str(dest_addr));
1287
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, 0, UNICAST_PACKET_V6_SIZE, FALSE);
1289
batadv_unicast_tree = proto_item_add_subtree(ti, ett_batadv_unicast);
1292
proto_tree_add_uint_format(batadv_unicast_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_UNICAST,
1293
"Packet Type: %s (%u)", "BATADV_UNICAST", BATADV_UNICAST);
1296
proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_version, tvb, offset, 1, FALSE);
1299
proto_tree_add_ether(batadv_unicast_tree, hf_batadv_unicast_dst, tvb, offset, 6, dest_addr);
1302
proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_ttl, tvb, offset, 1, FALSE);
1306
/* Calculate offset even when we got no tree */
1307
offset = UNICAST_PACKET_V6_SIZE;
1309
SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dest_addr);
1310
SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, dest_addr);
1312
tap_queue_packet(batadv_tap, pinfo, unicast_packeth);
1314
length_remaining = tvb_length_remaining(tvb, offset);
1316
if (length_remaining != 0) {
1317
next_tvb = tvb_new_subset(tvb, offset, length_remaining, -1);
1319
if (have_tap_listener(batadv_follow_tap)) {
1320
tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1323
call_dissector(eth_handle, next_tvb, pinfo, tree);
1327
static void dissect_batadv_vis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1331
/* set protocol name */
1332
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_VIS");
1334
version = tvb_get_guint8(tvb, 1);
1340
dissect_batadv_vis_v6(tvb, pinfo, tree);
1343
dissect_batadv_vis_v10(tvb, pinfo, tree);
1346
col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
1347
call_dissector(data_handle, tvb, pinfo, tree);
1352
static void dissect_batadv_vis_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1354
struct vis_packet_v6 *vis_packeth;
1355
const guint8 *vis_orig_addr, *target_orig_addr, *sender_orig_addr;
1356
proto_tree *batadv_vis_tree = NULL;
1359
guint length_remaining, entry_size;
1362
vis_packeth = ep_alloc(sizeof(struct vis_packet_v6));
1364
vis_packeth->version = tvb_get_guint8(tvb, 1);
1365
vis_packeth->vis_type = tvb_get_guint8(tvb, 2);
1366
vis_packeth->seqno = tvb_get_guint8(tvb, 3);
1367
vis_packeth->entries = tvb_get_guint8(tvb, 4);
1368
vis_packeth->ttl = tvb_get_guint8(tvb, 5);
1370
vis_orig_addr = tvb_get_ptr(tvb, 6, 6);
1371
SET_ADDRESS(&vis_packeth->vis_orig, AT_ETHER, 6, vis_orig_addr);
1372
target_orig_addr = tvb_get_ptr(tvb, 12, 6);
1373
SET_ADDRESS(&vis_packeth->target_orig, AT_ETHER, 6, target_orig_addr);
1374
sender_orig_addr = tvb_get_ptr(tvb, 18, 6);
1375
SET_ADDRESS(&vis_packeth->sender_orig, AT_ETHER, 6, sender_orig_addr);
1377
/* Set info column */
1378
if (check_col(pinfo->cinfo, COL_INFO)) {
1379
col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
1380
val_to_str(vis_packeth->vis_type, vis_packettypenames, "Unknown (0x%02x)"),
1381
vis_packeth->seqno);
1387
if (PTREE_DATA(tree)->visible) {
1388
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_PACKET_V6_SIZE,
1389
"B.A.T.M.A.N. Vis, Orig: %s (%s)",
1390
get_ether_name(vis_orig_addr), ether_to_str(vis_orig_addr));
1392
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, 0, VIS_PACKET_V6_SIZE, FALSE);
1394
batadv_vis_tree = proto_item_add_subtree(ti, ett_batadv_vis);
1397
proto_tree_add_uint_format(batadv_vis_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_VIS,
1398
"Packet Type: %s (%u)", "BATADV_VIS", BATADV_VIS);
1401
proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_version, tvb, offset, 1, FALSE);
1404
proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_type, tvb, offset, 1, FALSE);
1407
proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_seqno, tvb, offset, 1, FALSE);
1410
proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_entries, tvb, offset, 1, FALSE);
1413
proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_ttl, tvb, offset, 1, FALSE);
1416
proto_tree_add_ether(batadv_vis_tree, hf_batadv_vis_vis_orig, tvb, offset, 6, vis_orig_addr);
1419
proto_tree_add_ether(batadv_vis_tree, hf_batadv_vis_target_orig, tvb, offset, 6, target_orig_addr);
1422
proto_tree_add_ether(batadv_vis_tree, hf_batadv_vis_sender_orig, tvb, offset, 6, sender_orig_addr);
1426
/* Calculate offset even when we got no tree */
1427
offset = VIS_PACKET_V6_SIZE;
1429
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, sender_orig_addr);
1430
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, vis_orig_addr);
1432
SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, target_orig_addr);
1433
SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, target_orig_addr);
1435
tap_queue_packet(batadv_tap, pinfo, vis_packeth);
1437
switch (vis_packeth->version) {
1440
entry_size = VIS_ENTRY_V6_SIZE;
1445
entry_size = VIS_ENTRY_V8_SIZE;
1449
for (i = 0; i < vis_packeth->entries; i++) {
1450
next_tvb = tvb_new_subset(tvb, offset, entry_size, entry_size);
1452
if (have_tap_listener(batadv_follow_tap)) {
1453
tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1456
if (batadv_vis_tree != NULL) {
1457
switch (vis_packeth->version) {
1460
dissect_vis_entry_v6(next_tvb, pinfo, batadv_vis_tree);
1465
dissect_vis_entry_v8(next_tvb, pinfo, batadv_vis_tree);
1470
offset += entry_size;
1473
length_remaining = tvb_length_remaining(tvb, offset);
1474
if (length_remaining != 0) {
1475
next_tvb = tvb_new_subset(tvb, offset, length_remaining, -1);
1477
if (have_tap_listener(batadv_follow_tap)) {
1478
tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1481
call_dissector(data_handle, next_tvb, pinfo, tree);
1485
static void dissect_batadv_vis_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1487
struct vis_packet_v10 *vis_packeth;
1488
const guint8 *vis_orig_addr, *target_orig_addr, *sender_orig_addr;
1489
proto_tree *batadv_vis_tree = NULL;
1492
guint length_remaining;
1495
vis_packeth = ep_alloc(sizeof(struct vis_packet_v10));
1497
vis_packeth->version = tvb_get_guint8(tvb, 1);
1498
vis_packeth->vis_type = tvb_get_guint8(tvb, 2);
1499
vis_packeth->entries = tvb_get_guint8(tvb, 3);
1500
vis_packeth->seqno = tvb_get_ntohl(tvb, 4);
1501
vis_packeth->ttl = tvb_get_guint8(tvb, 8);
1503
vis_orig_addr = tvb_get_ptr(tvb, 9, 6);
1504
SET_ADDRESS(&vis_packeth->vis_orig, AT_ETHER, 6, vis_orig_addr);
1505
target_orig_addr = tvb_get_ptr(tvb, 15, 6);
1506
SET_ADDRESS(&vis_packeth->target_orig, AT_ETHER, 6, target_orig_addr);
1507
sender_orig_addr = tvb_get_ptr(tvb, 21, 6);
1508
SET_ADDRESS(&vis_packeth->sender_orig, AT_ETHER, 6, sender_orig_addr);
1510
/* Set info column */
1511
col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
1512
val_to_str(vis_packeth->vis_type, vis_packettypenames, "Unknown (0x%02x)"),
1513
vis_packeth->seqno);
1519
if (PTREE_DATA(tree)->visible) {
1520
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_PACKET_V10_SIZE,
1521
"B.A.T.M.A.N. Vis, Orig: %s (%s)",
1522
get_ether_name(vis_orig_addr), ether_to_str(vis_orig_addr));
1524
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, 0, VIS_PACKET_V10_SIZE, FALSE);
1526
batadv_vis_tree = proto_item_add_subtree(ti, ett_batadv_vis);
1529
proto_tree_add_uint_format(batadv_vis_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_VIS,
1530
"Packet Type: %s (%u)", "BATADV_VIS", BATADV_VIS);
1533
proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_version, tvb, offset, 1, FALSE);
1536
proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_type, tvb, offset, 1, FALSE);
1539
proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_entries, tvb, offset, 1, FALSE);
1542
proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_seqno32, tvb, offset, 4, FALSE);
1545
proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_ttl, tvb, offset, 1, FALSE);
1548
proto_tree_add_ether(batadv_vis_tree, hf_batadv_vis_vis_orig, tvb, offset, 6, vis_orig_addr);
1551
proto_tree_add_ether(batadv_vis_tree, hf_batadv_vis_target_orig, tvb, offset, 6, target_orig_addr);
1554
proto_tree_add_ether(batadv_vis_tree, hf_batadv_vis_sender_orig, tvb, offset, 6, sender_orig_addr);
1558
/* Calculate offset even when we got no tree */
1559
offset = VIS_PACKET_V10_SIZE;
1561
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, sender_orig_addr);
1562
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, vis_orig_addr);
1564
SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, target_orig_addr);
1565
SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, target_orig_addr);
1567
tap_queue_packet(batadv_tap, pinfo, vis_packeth);
1569
for (i = 0; i < vis_packeth->entries; i++) {
1570
next_tvb = tvb_new_subset(tvb, offset, VIS_ENTRY_V8_SIZE, VIS_ENTRY_V8_SIZE);
1572
if (have_tap_listener(batadv_follow_tap)) {
1573
tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1576
dissect_vis_entry_v8(next_tvb, pinfo, batadv_vis_tree);
1577
offset += VIS_ENTRY_V8_SIZE;
1580
length_remaining = tvb_length_remaining(tvb, offset);
1581
if (length_remaining != 0) {
1582
next_tvb = tvb_new_subset(tvb, offset, length_remaining, -1);
1584
if (have_tap_listener(batadv_follow_tap)) {
1585
tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1588
call_dissector(data_handle, next_tvb, pinfo, tree);
1592
static void dissect_vis_entry_v6(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1598
proto_tree *batadv_vis_entry_tree;
1600
dst = tvb_get_ptr(tvb, 0, 6);
1602
if (PTREE_DATA(tree)->visible) {
1603
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_ENTRY_V6_SIZE,
1604
"VIS Entry: %s (%s)",
1605
get_ether_name(dst), ether_to_str(dst));
1607
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, 0, VIS_ENTRY_V6_SIZE, FALSE);
1609
batadv_vis_entry_tree = proto_item_add_subtree(ti, ett_batadv_vis_entry);
1611
proto_tree_add_ether(batadv_vis_entry_tree, hf_batadv_vis_entry_dst, tvb, 0, 6, dst);
1612
proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_quality, tvb, 6, 1, FALSE);
1616
static void dissect_vis_entry_v8(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1620
const guint8 *dst, *src;
1622
proto_tree *batadv_vis_entry_tree;
1624
src = tvb_get_ptr(tvb, 0, 6);
1625
dst = tvb_get_ptr(tvb, 6, 6);
1627
if (PTREE_DATA(tree)->visible) {
1628
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_ENTRY_V8_SIZE,
1629
"VIS Entry: %s (%s)",
1630
get_ether_name(dst), ether_to_str(dst));
1632
ti = proto_tree_add_item(tree, proto_batadv_plugin, tvb, 0, VIS_ENTRY_V8_SIZE, FALSE);
1634
batadv_vis_entry_tree = proto_item_add_subtree(ti, ett_batadv_vis_entry);
1636
proto_tree_add_ether(batadv_vis_entry_tree, hf_batadv_vis_entry_src, tvb, 0, 6, src);
1637
proto_tree_add_ether(batadv_vis_entry_tree, hf_batadv_vis_entry_dst, tvb, 6, 6, dst);
1638
proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_quality, tvb, 12, 1, FALSE);
1642
void proto_register_batadv(void)
1644
module_t *batadv_module;
1646
static hf_register_info hf[] = {
1647
{ &hf_batadv_packet_type,
1648
{ "Packet Type", "batadv.batman.packet_type",
1649
FT_UINT8, BASE_DEC, NULL, 0x0,
1652
{ &hf_batadv_batman_version,
1653
{ "Version", "batadv.batman.version",
1654
FT_UINT8, BASE_DEC, NULL, 0x0,
1657
{ &hf_batadv_batman_flags,
1658
{ "Flags", "batadv.batman.flags",
1659
FT_UINT8, BASE_HEX, NULL, 0x0,
1662
{ &hf_batadv_batman_ttl,
1663
{ "Time to Live", "batadv.batman.ttl",
1664
FT_UINT8, BASE_DEC, NULL, 0x0,
1667
{ &hf_batadv_batman_gwflags,
1668
{ "Gateway Flags", "batadv.batman.gwflags",
1669
FT_UINT8, BASE_HEX, NULL, 0x0,
1672
{ &hf_batadv_batman_tq,
1673
{ "Transmission Quality", "batadv.batman.tq",
1674
FT_UINT8, BASE_DEC, NULL, 0x0,
1677
{ &hf_batadv_batman_seqno,
1678
{ "Sequence number", "batadv.batman.seq",
1679
FT_UINT16, BASE_DEC, NULL, 0x0,
1682
{ &hf_batadv_batman_seqno32,
1683
{ "Sequence number", "batadv.batman.seq",
1684
FT_UINT32, BASE_DEC, NULL, 0x0,
1687
{ &hf_batadv_batman_orig,
1688
{ "Originator", "batadv.batman.orig",
1689
FT_ETHER, BASE_NONE, NULL, 0x0,
1692
{ &hf_batadv_batman_prev_sender,
1693
{ "Received from", "batadv.batman.prev_sender",
1694
FT_ETHER, BASE_NONE, NULL, 0x0,
1697
{ &hf_batadv_batman_num_hna,
1698
{ "Number of HNAs", "batadv.batman.num_hna",
1699
FT_UINT8, BASE_DEC, NULL, 0x0,
1702
{ &hf_batadv_batman_pad,
1703
{ "Padding", "batadv.batman.pad",
1704
FT_UINT8, BASE_DEC, NULL, 0x0,
1707
{ &hf_batadv_batman_flags_directlink,
1708
{ "DirectLink", "batadv.batman.flags.directlink",
1709
FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x40,
1712
{ &hf_batadv_batman_flags_vis_server,
1713
{ "VIS_SERVER", "batadv.batman.flags.vis_server",
1714
FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x20,
1717
{ &hf_batadv_batman_flags_primaries_first_hop,
1718
{ "PRIMARIES_FIRST_HOP", "batadv.batman.flags.primaries_first_hop",
1719
FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x10,
1722
{ &hf_batadv_batman_hna,
1723
{ "Host Network Announcement", "batadv.batman.hna",
1724
FT_ETHER, BASE_NONE, NULL, 0x0,
1727
{ &hf_batadv_bcast_version,
1728
{ "Version", "batadv.bcast.version",
1729
FT_UINT8, BASE_DEC, NULL, 0x0,
1732
{ &hf_batadv_bcast_pad,
1733
{ "Padding", "batadv.bcast.pad",
1734
FT_UINT8, BASE_DEC, NULL, 0x0,
1737
{ &hf_batadv_bcast_orig,
1738
{ "Originator", "batadv.bcast.orig",
1739
FT_ETHER, BASE_NONE, NULL, 0x0,
1742
{ &hf_batadv_bcast_seqno,
1743
{ "Sequence number", "batadv.bcast.seq",
1744
FT_UINT16, BASE_DEC, NULL, 0x0,
1747
{ &hf_batadv_bcast_seqno32,
1748
{ "Sequence number", "batadv.bcast.seq",
1749
FT_UINT32, BASE_DEC, NULL, 0x0,
1752
{ &hf_batadv_bcast_ttl,
1753
{ "Time to Live", "batadv.bcast.ttl",
1754
FT_UINT8, BASE_DEC, NULL, 0x0,
1757
{ &hf_batadv_icmp_version,
1758
{ "Version", "batadv.icmp.version",
1759
FT_UINT8, BASE_DEC, NULL, 0x0,
1762
{ &hf_batadv_icmp_msg_type,
1763
{ "Message Type", "batadv.icmp.msg_type",
1764
FT_UINT8, BASE_DEC, VALS(icmp_packettypenames), 0x0,
1767
{ &hf_batadv_icmp_dst,
1768
{ "Destination", "batadv.icmp.dst",
1769
FT_ETHER, BASE_NONE, NULL, 0x0,
1772
{ &hf_batadv_icmp_orig,
1773
{ "Originator", "batadv.icmp.orig",
1774
FT_ETHER, BASE_NONE, NULL, 0x0,
1777
{ &hf_batadv_icmp_ttl,
1778
{ "Time to Live", "batadv.icmp.ttl",
1779
FT_UINT8, BASE_DEC, NULL, 0x0,
1782
{ &hf_batadv_icmp_uid,
1783
{ "UID", "batadv.icmp.uid",
1784
FT_UINT8, BASE_DEC, NULL, 0x0,
1787
{ &hf_batadv_icmp_seqno,
1788
{ "Sequence number", "batadv.icmp.seq",
1789
FT_UINT16, BASE_DEC, NULL, 0x0,
1792
{ &hf_batadv_unicast_version,
1793
{ "Version", "batadv.unicast.version",
1794
FT_UINT8, BASE_DEC, NULL, 0x0,
1797
{ &hf_batadv_unicast_dst,
1798
{ "Destination", "batadv.unicast.dst",
1799
FT_ETHER, BASE_NONE, NULL, 0x0,
1802
{ &hf_batadv_unicast_ttl,
1803
{ "Time to Live", "batadv.unicast.ttl",
1804
FT_UINT8, BASE_DEC, NULL, 0x0,
1807
{ &hf_batadv_vis_version,
1808
{ "Version", "batadv.vis.version",
1809
FT_UINT8, BASE_DEC, NULL, 0x0,
1812
{ &hf_batadv_vis_type,
1813
{ "Type", "batadv.vis.type",
1814
FT_UINT8, BASE_DEC, VALS(vis_packettypenames), 0x0,
1817
{ &hf_batadv_vis_seqno,
1818
{ "Sequence number", "batadv.vis.seq",
1819
FT_UINT8, BASE_DEC, NULL, 0x0,
1822
{ &hf_batadv_vis_seqno32,
1823
{ "Sequence number", "batadv.vis.seq",
1824
FT_UINT32, BASE_DEC, NULL, 0x0,
1827
{ &hf_batadv_vis_entries,
1828
{ "Entries", "batadv.vis.entries",
1829
FT_UINT8, BASE_DEC, NULL, 0x0,
1830
"Number of entries", HFILL}
1832
{ &hf_batadv_vis_ttl,
1833
{ "Time to Live", "batadv.vis.ttl",
1834
FT_UINT8, BASE_DEC, NULL, 0x0,
1837
{ &hf_batadv_vis_vis_orig,
1838
{ "Originator", "batadv.vis.vis_orig",
1839
FT_ETHER, BASE_NONE, NULL, 0x0,
1842
{ &hf_batadv_vis_target_orig,
1843
{ "Target Originator", "batadv.vis.target_orig",
1844
FT_ETHER, BASE_NONE, NULL, 0x0,
1847
{ &hf_batadv_vis_sender_orig,
1848
{ "Forwarding Originator", "batadv.vis.sender_orig",
1849
FT_ETHER, BASE_NONE, NULL, 0x0,
1852
{ &hf_batadv_vis_entry_src,
1853
{ "Source", "hf_batadv_vis_entry.src",
1854
FT_ETHER, BASE_NONE, NULL, 0x0,
1857
{ &hf_batadv_vis_entry_dst,
1858
{ "Destination", "hf_batadv_vis_entry.dst",
1859
FT_ETHER, BASE_NONE, NULL, 0x0,
1862
{ &hf_batadv_vis_entry_quality,
1863
{ "Quality", "batadv.vis.quality",
1864
FT_UINT8, BASE_DEC, NULL, 0x0,
1869
/* Setup protocol subtree array */
1870
static gint *ett[] = {
1872
&ett_batadv_batman_flags,
1873
&ett_batadv_batman_hna,
1874
&ett_batadv_batman_gwflags,
1877
&ett_batadv_unicast,
1879
&ett_batadv_vis_entry
1882
proto_batadv_plugin = proto_register_protocol(
1883
"B.A.T.M.A.N. Advanced Protocol",
1884
"BATADV", /* short name */
1885
"batadv" /* abbrev */
1888
batadv_module = prefs_register_protocol(proto_batadv_plugin,
1889
proto_reg_handoff_batadv);
1891
prefs_register_uint_preference(batadv_module, "batmanadv.ethertype",
1893
"Ethertype used to indicate B.A.T.M.A.N. packet.",
1894
16, &batadv_ethertype);
1896
proto_register_subtree_array(ett, array_length(ett));
1897
proto_register_field_array(proto_batadv_plugin, hf, array_length(hf));
1900
void proto_reg_handoff_batadv(void)
1902
static gboolean inited = FALSE;
1903
static unsigned int old_batadv_ethertype;
1906
batman_handle = create_dissector_handle(dissect_batman_plugin, proto_batadv_plugin);
1908
data_handle = find_dissector("data");
1909
eth_handle = find_dissector("eth");
1911
batadv_tap = register_tap("batman");
1912
batadv_follow_tap = register_tap("batman_follow");
1916
dissector_delete("ethertype", old_batadv_ethertype, batman_handle);
1919
old_batadv_ethertype = batadv_ethertype;
1920
dissector_add("ethertype", batadv_ethertype, batman_handle);