Coverage Report

Created: 2026-11-12 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-batadv.c
Line
Count
Source
1
/* packet-batadv.c
2
 * Routines for B.A.T.M.A.N. Advanced dissection
3
 * Copyright 2008-2010  Sven Eckelmann <sven@narfation.org>
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
12
#include "config.h"
13
14
#include <epan/packet.h>
15
#include <epan/prefs.h>
16
#include <epan/tap.h>
17
#include <epan/addr_resolv.h>
18
#include <epan/reassemble.h>
19
#include <epan/expert.h>
20
#include <epan/tfs.h>
21
#include <epan/unit_strings.h>
22
23
#include <wsutil/crc32.h>
24
25
/* Start content from packet-batadv.h */
26
#define ETH_P_BATMAN  0x4305
27
28
92
#define BATADV_PACKET_V5         0x01
29
9
#define BATADV_ICMP_V5           0x02
30
0
#define BATADV_UNICAST_V5        0x03
31
0
#define BATADV_BCAST_V5          0x04
32
18
#define BATADV_VIS_V5            0x05
33
1
#define BATADV_UNICAST_FRAG_V12  0x06
34
19
#define BATADV_TT_QUERY_V14      0x07
35
#define BATADV_ROAM_ADV_V14      0x08
36
1
#define BATADV_ROAM_ADV_V14      0x08
37
0
#define BATADV_UNICAST_4ADDR_V14 0x09
38
39
0
#define BATADV_IV_OGM_V15        0x00
40
1
#define BATADV_BCAST_V15         0x01
41
0
#define BATADV_CODED_V15         0x02
42
0
#define BATADV_ELP_V15           0x03
43
1
#define BATADV_OGM2_V15          0x04
44
0
#define BATADV_UNICAST_V15       0x40
45
0
#define BATADV_UNICAST_FRAG_V15  0x41
46
0
#define BATADV_UNICAST_4ADDR_V15 0x42
47
0
#define BATADV_ICMP_V15          0x43
48
0
#define BATADV_UNICAST_TVLV_V15  0x44
49
50
0
#define BATADV_TVLV_V15_GW       0x01
51
0
#define BATADV_TVLV_V15_DAT      0x02
52
0
#define BATADV_TVLV_V15_NC       0x03
53
0
#define BATADV_TVLV_V15_TT       0x04
54
0
#define BATADV_TVLV_V15_ROAM     0x05
55
0
#define BATADV_TVLV_V15_MCAST    0x06
56
57
#define ECHO_REPLY 0
58
#define DESTINATION_UNREACHABLE 3
59
#define ECHO_REQUEST 8
60
#define TTL_EXCEEDED 11
61
0
#define BATADV_TP 15
62
63
22
#define TT_TYPE_MASK    0x3
64
2
#define TT_REQUEST      0
65
14
#define TT_RESPONSE     1
66
67
16
#define TT_FULL_TABLE   0x04
68
69
16
#define TT_CHANGE_DEL   0x01
70
16
#define TT_CLIENT_ROAM  0x02
71
72
45
#define BAT_RR_LEN 16
73
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
78
79
16
#define BATADV_TVLVL_TT_TYPE_MASK      0x0F
80
#define BATADV_TVLVL_TT_OGM_DIFF       0x01
81
#define BATADV_TVLVL_TT_REQUEST        0x02
82
0
#define BATADV_TVLVL_TT_RESPONSE       0x04
83
16
#define BATADV_TVLVL_TT_FULL_TABLE     0x10
84
85
16
#define BATADV_TVLVL_TT_CHANGE_DEL     0x01
86
16
#define BATADV_TVLVL_TT_CHANGE_ROAM    0x02
87
16
#define BATADV_TVLVL_TT_CHANGE_WIFI    0x10
88
16
#define BATADV_TVLVL_TT_CHANGE_ISOLATE 0x20
89
90
struct batman_packet_v5 {
91
  uint8_t packet_type;
92
  uint8_t version;  /* batman version field */
93
  uint8_t flags;    /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
94
  uint8_t ttl;
95
  uint8_t gwflags;  /* flags related to gateway functions: gateway class */
96
  uint8_t tq;
97
  uint16_t seqno;
98
  address orig;
99
  address prev_sender;
100
  uint8_t num_tt;
101
  uint8_t pad;
102
};
103
31
#define BATMAN_PACKET_V5_SIZE 22
104
105
struct batman_packet_v7 {
106
  uint8_t packet_type;
107
  uint8_t version;  /* batman version field */
108
  uint8_t flags;    /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
109
  uint8_t tq;
110
  uint16_t seqno;
111
  address orig;
112
  address prev_sender;
113
  uint8_t ttl;
114
  uint8_t num_tt;
115
};
116
9
#define BATMAN_PACKET_V7_SIZE 20
117
118
struct batman_packet_v9 {
119
  uint8_t packet_type;
120
  uint8_t version;  /* batman version field */
121
  uint8_t flags;    /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
122
  uint8_t tq;
123
  uint16_t seqno;
124
  address orig;
125
  address prev_sender;
126
  uint8_t ttl;
127
  uint8_t num_tt;
128
  uint8_t gwflags;
129
  uint8_t pad;
130
};
131
0
#define BATMAN_PACKET_V9_SIZE 22
132
133
struct batman_packet_v10 {
134
  uint8_t packet_type;
135
  uint8_t version;  /* batman version field */
136
  uint8_t flags;    /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
137
  uint8_t tq;
138
  uint32_t seqno;
139
  address orig;
140
  address prev_sender;
141
  uint8_t ttl;
142
  uint8_t num_tt;
143
  uint8_t gwflags;
144
  uint8_t pad;
145
};
146
20
#define BATMAN_PACKET_V10_SIZE 24
147
148
struct batman_packet_v11 {
149
  uint8_t packet_type;
150
  uint8_t version;  /* batman version field */
151
  uint8_t flags;    /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
152
  uint8_t tq;
153
  uint32_t seqno;
154
  address orig;
155
  address prev_sender;
156
  uint8_t ttl;
157
  uint8_t num_tt;
158
};
159
6
#define BATMAN_PACKET_V11_SIZE 22
160
161
struct batman_packet_v14 {
162
  uint8_t packet_type;
163
  uint8_t version;  /* batman version field */
164
  uint8_t ttl;
165
  uint8_t flags;    /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
166
  uint32_t seqno;
167
  address orig;
168
  address prev_sender;
169
  uint8_t gw_flags;  /* flags related to gateway class */
170
  uint8_t tq;
171
  uint8_t tt_num_changes;
172
  uint8_t ttvn; /* translation table version number */
173
  uint16_t tt_crc;
174
};
175
4
#define BATMAN_PACKET_V14_SIZE 26
176
177
struct iv_ogm_packet_v15 {
178
  uint8_t packet_type;
179
  uint8_t version;  /* batman version field */
180
  uint8_t ttl;
181
  uint8_t flags;
182
  uint32_t seqno;
183
  address orig;
184
  address prev_sender;
185
  uint8_t reserved;
186
  uint8_t tq;
187
  uint16_t tvlv_len;
188
};
189
0
#define IV_OGM_PACKET_V15_SIZE 24
190
191
struct elp_packet_v15 {
192
  uint8_t packet_type;
193
  uint8_t version;
194
  address orig;
195
  uint32_t seqno;
196
  uint32_t interval;
197
};
198
0
#define ELP_PACKET_V15_SIZE 16
199
200
struct ogm2_packet_v15 {
201
  uint8_t packet_type;
202
  uint8_t version;
203
  uint8_t ttl;
204
  uint8_t flags;
205
  uint32_t seqno;
206
  address orig;
207
  uint16_t tvlv_len;
208
  uint32_t throughput;
209
};
210
0
#define OGM2_PACKET_V15_SIZE 20
211
212
struct icmp_packet_v6 {
213
  uint8_t packet_type;
214
  uint8_t version;  /* batman version field */
215
  uint8_t msg_type;   /* 0 = ECHO REPLY, 3 = DESTINATION_UNREACHABLE, 8 = ECHO_REQUEST, 11 = TTL exceeded */
216
  address dst;
217
  address orig;
218
  uint8_t ttl;
219
  uint8_t uid;
220
  uint16_t seqno;
221
};
222
0
#define ICMP_PACKET_V6_SIZE 19
223
224
struct icmp_packet_v7 {
225
  uint8_t packet_type;
226
  uint8_t version;  /* batman version field */
227
  uint8_t msg_type;   /* 0 = ECHO REPLY, 3 = DESTINATION_UNREACHABLE, 8 = ECHO_REQUEST, 11 = TTL exceeded */
228
  uint8_t ttl;
229
  address dst;
230
  address orig;
231
  uint16_t seqno;
232
  uint8_t uid;
233
};
234
3
#define ICMP_PACKET_V7_SIZE 19
235
236
struct icmp_packet_v14 {
237
  uint8_t packet_type;
238
  uint8_t version;  /* batman version field */
239
  uint8_t ttl;
240
  uint8_t msg_type; /* see ICMP message types above */
241
  address dst;
242
  address orig;
243
  uint16_t seqno;
244
  uint8_t uid;
245
  uint8_t reserved;
246
};
247
0
#define ICMP_PACKET_V14_SIZE 20
248
249
struct icmp_packet_v15 {
250
  uint8_t packet_type;
251
  uint8_t version;  /* batman version field */
252
  uint8_t ttl;
253
  uint8_t msg_type; /* see ICMP message types above */
254
  address dst;
255
  address orig;
256
  uint8_t uid;
257
  uint8_t rr_ptr;
258
  uint16_t seqno;
259
};
260
#define ICMP_PACKET_V15_SIZE 20
261
262
struct icmp_tp_packet_v15 {
263
  uint8_t packet_type;
264
  uint8_t version;  /* batman version field */
265
  uint8_t ttl;
266
  uint8_t msg_type; /* see ICMP message types above */
267
  address dst;
268
  address orig;
269
  uint8_t uid;
270
  uint8_t subtype;
271
  uint16_t session;
272
  uint32_t seqno;
273
  uint32_t timestamp;
274
};
275
#define ICMP_TP_PACKET_V15_SIZE 28
276
277
struct unicast_packet_v6 {
278
  uint8_t packet_type;
279
  uint8_t version;
280
  address dest;
281
  uint8_t ttl;
282
};
283
0
#define UNICAST_PACKET_V6_SIZE 9
284
285
struct unicast_packet_v14 {
286
  uint8_t packet_type;
287
  uint8_t version;  /* batman version field */
288
  uint8_t ttl;
289
  uint8_t ttvn; /* destination translation table version number */
290
  address dest;
291
};
292
0
#define UNICAST_PACKET_V14_SIZE 10
293
294
struct unicast_4addr_packet_v14 {
295
  uint8_t packet_type;
296
  uint8_t version;  /* batman version field */
297
  uint8_t ttl;
298
  uint8_t ttvn; /* destination translation table version number */
299
  address dest;
300
  address src;
301
  uint8_t subtype;
302
  uint8_t reserved;
303
};
304
0
#define UNICAST_4ADDR_PACKET_V14_SIZE 18
305
306
struct unicast_frag_packet_v12 {
307
  uint8_t  packet_type;
308
  uint8_t  version;
309
  address  dest;
310
  uint8_t  ttl;
311
  uint8_t  flags;
312
  address  orig;
313
  uint16_t seqno;
314
};
315
0
#define UNICAST_FRAG_PACKET_V12_SIZE 18
316
317
struct unicast_frag_packet_v14 {
318
  uint8_t packet_type;
319
  uint8_t version;  /* batman version field */
320
  uint8_t ttl;
321
  uint8_t ttvn; /* destination translation table version number */
322
  address dest;
323
  uint8_t flags;
324
  uint8_t align;
325
  address orig;
326
  uint16_t seqno;
327
};
328
0
#define UNICAST_FRAG_PACKET_V14_SIZE 20
329
330
struct unicast_frag_packet_v15 {
331
  uint8_t packet_type;
332
  uint8_t version;  /* batman version field */
333
  uint8_t ttl;
334
  uint8_t no; /* only upper 4 bit are used */
335
  address dest;
336
  address orig;
337
  uint16_t seqno;
338
  uint16_t total_size;
339
};
340
0
#define UNICAST_FRAG_PACKET_V15_SIZE 20
341
342
struct bcast_packet_v6 {
343
  uint8_t packet_type;
344
  uint8_t version;  /* batman version field */
345
  address orig;
346
  uint16_t seqno;
347
};
348
0
#define BCAST_PACKET_V6_SIZE 10
349
350
struct bcast_packet_v10 {
351
  uint8_t packet_type;
352
  uint8_t version;  /* batman version field */
353
  address orig;
354
  uint8_t ttl;
355
  uint32_t seqno;
356
};
357
0
#define BCAST_PACKET_V10_SIZE 13
358
359
struct bcast_packet_v14 {
360
  uint8_t packet_type;
361
  uint8_t version;  /* batman version field */
362
  uint8_t ttl;
363
  uint8_t reserved;
364
  uint32_t seqno;
365
  address orig;
366
};
367
0
#define BCAST_PACKET_V14_SIZE 14
368
369
struct vis_packet_v6 {
370
  uint8_t packet_type;
371
  uint8_t version;      /* batman version field */
372
  uint8_t vis_type;     /* which type of vis-participant sent this? */
373
  uint8_t seqno;        /* sequence number */
374
  uint8_t entries;      /* number of entries behind this struct */
375
  uint8_t ttl;          /* TTL */
376
  address vis_orig;     /* originator that informs about its neighbours */
377
  address target_orig;  /* who should receive this packet */
378
  address sender_orig;  /* who sent or rebroadcasted this packet */
379
};
380
6
#define VIS_PACKET_V6_SIZE 24
381
382
struct vis_packet_v10 {
383
  uint8_t packet_type;
384
  uint8_t version;      /* batman version field */
385
  uint8_t vis_type;     /* which type of vis-participant sent this? */
386
  uint8_t entries;      /* number of entries behind this struct */
387
  uint32_t seqno;        /* sequence number */
388
  uint8_t ttl;          /* TTL */
389
  address vis_orig;     /* originator that informs about its neighbours */
390
  address target_orig;  /* who should receive this packet */
391
  address sender_orig;  /* who sent or rebroadcasted this packet */
392
};
393
0
#define VIS_PACKET_V10_SIZE 27
394
395
struct vis_packet_v14 {
396
  uint8_t packet_type;
397
  uint8_t version;        /* batman version field */
398
  uint8_t ttl;     /* TTL */
399
  uint8_t vis_type;  /* which type of vis-participant sent this? */
400
  uint32_t seqno;    /* sequence number */
401
  uint8_t entries;   /* number of entries behind this struct */
402
  uint8_t reserved;
403
  address vis_orig;  /* originator that announces its neighbors */
404
  address target_orig; /* who should receive this packet */
405
  address sender_orig; /* who sent or rebroadcasted this packet */
406
};
407
0
#define VIS_PACKET_V14_SIZE 28
408
409
0
#define VIS_ENTRY_V6_SIZE 7
410
81
#define VIS_ENTRY_V8_SIZE 13
411
412
#define VIS_TYPE_SERVER_SYNC  0
413
#define VIS_TYPE_CLIENT_UPDATE  1
414
415
struct tt_query_packet_v14 {
416
  uint8_t packet_type;
417
  uint8_t version;  /* batman version field */
418
  uint8_t ttl;
419
  uint8_t flags;
420
  address dst;
421
  address src;
422
  uint8_t ttvn;
423
  uint16_t tt_data;
424
};
425
6
#define TT_QUERY_PACKET_V14_SIZE 19
426
427
315
#define TT_ENTRY_V14_SIZE 7
428
429
struct roam_adv_packet_v14 {
430
  uint8_t packet_type;
431
  uint8_t version;
432
  uint8_t ttl;
433
  uint8_t reserved;
434
  address dst;
435
  address src;
436
  address client;
437
};
438
0
#define ROAM_ADV_PACKET_V14_SIZE 22
439
440
struct coded_packet_v15 {
441
  uint8_t packet_type;
442
  uint8_t version;  /* batman version field */
443
  uint8_t ttl;
444
  uint8_t first_ttvn;
445
  address first_source;
446
  address first_orig_dest;
447
  uint32_t first_crc;
448
  uint8_t second_ttl;
449
  uint8_t second_ttvn;
450
  address second_dest;
451
  address second_source;
452
  address second_orig_dest;
453
  uint32_t second_crc;
454
  uint16_t coded_len;
455
};
456
0
#define CODED_PACKET_V15_SIZE 46
457
458
struct unicast_tvlv_packet_v15 {
459
  uint8_t packet_type;
460
  uint8_t version;  /* batman version field */
461
  uint8_t ttl;
462
  uint8_t reserved;
463
  address dest;
464
  address src;
465
  uint16_t tvlv_len;
466
  uint16_t align;
467
};
468
0
#define UNICAST_TVLV_PACKET_V15_SIZE 20
469
470
0
#define TLVLV_TT_VLAN_V15_SIZE 8
471
0
#define TLVLV_TT_CHANGE_V15_SIZE 12
472
473
/* End content from packet-batadv.h */
474
475
/* trees */
476
static int ett_batadv_batman;
477
static int ett_batadv_batman_flags;
478
static int ett_batadv_batman_gwflags;
479
static int ett_batadv_batman_tt;
480
static int ett_batadv_iv_ogm;
481
static int ett_batadv_iv_ogm_flags;
482
static int ett_batadv_elp;
483
static int ett_batadv_ogm2;
484
//static int ett_batadv_ogm2_flags;
485
static int ett_batadv_bcast;
486
static int ett_batadv_icmp;
487
static int ett_batadv_icmp_rr;
488
static int ett_batadv_unicast;
489
static int ett_batadv_unicast_4addr;
490
static int ett_batadv_unicast_frag;
491
static int ett_batadv_unicast_tvlv;
492
static int ett_batadv_vis;
493
static int ett_batadv_vis_entry;
494
static int ett_batadv_tt_query;
495
static int ett_batadv_tt_query_flags;
496
static int ett_batadv_tt_entry;
497
static int ett_batadv_tt_entry_flags;
498
static int ett_batadv_roam_adv;
499
static int ett_batadv_coded;
500
static int ett_batadv_tvlv;
501
static int ett_batadv_tvlv_mcast_flags;
502
static int ett_batadv_tvlv_vid;
503
static int ett_batadv_tvlv_tt_flags;
504
static int ett_batadv_tvlv_tt_vlan;
505
static int ett_batadv_tvlv_tt_change;
506
static int ett_msg_fragment;
507
static int ett_msg_fragments;
508
509
static expert_field ei_batadv_too_deep;
510
static expert_field ei_batadv_tvlv_unknown_version;
511
static expert_field ei_batadv_tvlv_tt_vlan_crc;
512
static expert_field ei_batadv_tvlv_tt_vlan_empty;
513
514
/* hfs */
515
static int hf_batadv_packet_type;
516
517
static int hf_batadv_batman_version;
518
static int hf_batadv_batman_flags;
519
static int hf_batadv_batman_ttl;
520
static int hf_batadv_batman_gwflags;
521
static int hf_batadv_batman_gwflags_dl_speed;
522
static int hf_batadv_batman_gwflags_ul_speed;
523
static int hf_batadv_batman_tq;
524
static int hf_batadv_batman_seqno;
525
static int hf_batadv_batman_seqno32;
526
static int hf_batadv_batman_orig;
527
static int hf_batadv_batman_prev_sender;
528
static int hf_batadv_batman_num_tt;
529
static int hf_batadv_batman_tt_num_changes;
530
static int hf_batadv_batman_ttvn;
531
static int hf_batadv_batman_tt_crc;
532
static int hf_batadv_batman_tt;
533
534
static int hf_batadv_iv_ogm_version;
535
static int hf_batadv_iv_ogm_ttl;
536
static int hf_batadv_iv_ogm_flags;
537
static int hf_batadv_iv_ogm_seqno;
538
static int hf_batadv_iv_ogm_orig;
539
static int hf_batadv_iv_ogm_prev_sender;
540
static int hf_batadv_iv_ogm_tq;
541
static int hf_batadv_iv_ogm_tvlv_len;
542
543
static int hf_batadv_elp_version;
544
static int hf_batadv_elp_orig;
545
static int hf_batadv_elp_seqno;
546
static int hf_batadv_elp_interval;
547
548
static int hf_batadv_ogm2_version;
549
static int hf_batadv_ogm2_ttl;
550
static int hf_batadv_ogm2_flags;
551
static int hf_batadv_ogm2_seqno;
552
static int hf_batadv_ogm2_orig;
553
static int hf_batadv_ogm2_tvlv_len;
554
static int hf_batadv_ogm2_throughput;
555
556
static int hf_batadv_bcast_version;
557
static int hf_batadv_bcast_orig;
558
static int hf_batadv_bcast_seqno;
559
static int hf_batadv_bcast_seqno32;
560
static int hf_batadv_bcast_ttl;
561
562
static int hf_batadv_icmp_version;
563
static int hf_batadv_icmp_msg_type;
564
static int hf_batadv_icmp_dst;
565
static int hf_batadv_icmp_orig;
566
static int hf_batadv_icmp_ttl;
567
static int hf_batadv_icmp_uid;
568
static int hf_batadv_icmp_seqno;
569
570
static int hf_batadv_icmp_rr_pointer;
571
static int hf_batadv_icmp_rr_ether;
572
573
static int hf_batadv_icmp_tp_subtype;
574
static int hf_batadv_icmp_tp_session;
575
static int hf_batadv_icmp_tp_seqno;
576
static int hf_batadv_icmp_tp_timestamp;
577
578
static int hf_batadv_unicast_version;
579
static int hf_batadv_unicast_dst;
580
static int hf_batadv_unicast_ttl;
581
static int hf_batadv_unicast_ttvn;
582
583
static int hf_batadv_unicast_4addr_version;
584
static int hf_batadv_unicast_4addr_dst;
585
static int hf_batadv_unicast_4addr_ttl;
586
static int hf_batadv_unicast_4addr_ttvn;
587
static int hf_batadv_unicast_4addr_src;
588
static int hf_batadv_unicast_4addr_subtype;
589
590
static int hf_batadv_unicast_frag_version;
591
static int hf_batadv_unicast_frag_dst;
592
static int hf_batadv_unicast_frag_ttl;
593
static int hf_batadv_unicast_frag_ttvn;
594
static int hf_batadv_unicast_frag_flags;
595
static int hf_batadv_unicast_frag_orig;
596
static int hf_batadv_unicast_frag_seqno;
597
static int hf_batadv_unicast_frag_no;
598
static int hf_batadv_unicast_frag_priority;
599
static int hf_batadv_unicast_frag_total_size;
600
601
static int hf_batadv_unicast_tvlv_version;
602
static int hf_batadv_unicast_tvlv_ttl;
603
static int hf_batadv_unicast_tvlv_dst;
604
static int hf_batadv_unicast_tvlv_src;
605
static int hf_batadv_unicast_tvlv_len;
606
607
static int hf_batadv_vis_version;
608
static int hf_batadv_vis_type;
609
static int hf_batadv_vis_seqno;
610
static int hf_batadv_vis_seqno32;
611
static int hf_batadv_vis_entries;
612
static int hf_batadv_vis_ttl;
613
static int hf_batadv_vis_vis_orig;
614
static int hf_batadv_vis_target_orig;
615
static int hf_batadv_vis_sender_orig;
616
static int hf_batadv_vis_entry_src;
617
static int hf_batadv_vis_entry_dst;
618
static int hf_batadv_vis_entry_quality;
619
620
static int hf_batadv_tt_query_version;
621
static int hf_batadv_tt_query_ttl;
622
static int hf_batadv_tt_query_flags;
623
static int hf_batadv_tt_query_flags_type;
624
static int hf_batadv_tt_query_flags_full_table;
625
static int hf_batadv_tt_query_dst;
626
static int hf_batadv_tt_query_src;
627
static int hf_batadv_tt_query_ttvn;
628
static int hf_batadv_tt_query_tt_crc;
629
static int hf_batadv_tt_query_entries;
630
static int hf_batadv_tt_entry;
631
static int hf_batadv_tt_entry_flags;
632
static int hf_batadv_tt_entry_flags_change_del;
633
static int hf_batadv_tt_entry_flags_client_roam;
634
635
static int hf_batadv_roam_adv_version;
636
static int hf_batadv_roam_adv_ttl;
637
static int hf_batadv_roam_adv_dst;
638
static int hf_batadv_roam_adv_src;
639
static int hf_batadv_roam_adv_client;
640
641
static int hf_batadv_coded_version;
642
static int hf_batadv_coded_ttl;
643
static int hf_batadv_coded_first_ttvn;
644
static int hf_batadv_coded_first_source;
645
static int hf_batadv_coded_first_orig_dest;
646
static int hf_batadv_coded_first_crc;
647
static int hf_batadv_coded_second_ttl;
648
static int hf_batadv_coded_second_ttvn;
649
static int hf_batadv_coded_second_dest;
650
static int hf_batadv_coded_second_source;
651
static int hf_batadv_coded_second_orig_dest;
652
static int hf_batadv_coded_second_crc;
653
static int hf_batadv_coded_coded_len;
654
655
static int hf_msg_fragments;
656
static int hf_msg_fragment;
657
static int hf_msg_fragment_overlap;
658
static int hf_msg_fragment_overlap_conflicts;
659
static int hf_msg_fragment_multiple_tails;
660
static int hf_msg_fragment_too_long_fragment;
661
static int hf_msg_fragment_error;
662
static int hf_msg_fragment_count;
663
static int hf_msg_reassembled_in;
664
static int hf_msg_reassembled_length;
665
666
static int hf_batadv_tvlv_type;
667
static int hf_batadv_tvlv_version;
668
static int hf_batadv_tvlv_len;
669
670
static int hf_batadv_tvlv_gw_download;
671
static int hf_batadv_tvlv_gw_upload;
672
673
static int hf_batadv_tvlv_roam_addr;
674
static int hf_batadv_tvlv_roam_vid;
675
static int hf_batadv_tvlv_vid_vlan;
676
static int hf_batadv_tvlv_vid_tagged;
677
678
static int hf_batadv_tvlv_tt_flags;
679
static int hf_batadv_tvlv_tt_flags_type;
680
static int hf_batadv_tvlv_tt_flags_full_table;
681
static int hf_batadv_tvlv_tt_ttvn;
682
static int hf_batadv_tvlv_tt_num_vlan;
683
static int hf_batadv_tvlv_tt_vlan_crc;
684
static int hf_batadv_tvlv_tt_vlan_crc_status;
685
static int hf_batadv_tvlv_tt_vlan_vid;
686
static int hf_batadv_tvlv_tt_change_flags;
687
static int hf_batadv_tvlv_tt_change_vid;
688
static int hf_batadv_tvlv_tt_change_addr;
689
690
/* flags */
691
static int hf_batadv_batman_flags_directlink;
692
static int hf_batadv_batman_flags_vis_server;
693
static int hf_batadv_batman_flags_not_best_next_hop;
694
static int hf_batadv_batman_flags_primaries_first_hop;
695
static int hf_batadv_unicast_frag_flags_head;
696
static int hf_batadv_unicast_frag_flags_largetail;
697
static int hf_batadv_iv_ogm_flags_not_best_next_hop;
698
static int hf_batadv_iv_ogm_flags_primaries_first_hop;
699
static int hf_batadv_iv_ogm_flags_directlink;
700
static int hf_batadv_tvlv_mcast_flags;
701
static int hf_batadv_tvlv_mcast_flags_unsnoopables;
702
static int hf_batadv_tvlv_mcast_flags_ipv4;
703
static int hf_batadv_tvlv_mcast_flags_ipv6;
704
static int hf_batadv_tvlv_mcast_flags_no_rtr4;
705
static int hf_batadv_tvlv_mcast_flags_no_rtr6;
706
static int hf_batadv_tvlv_tt_change_flags_del;
707
static int hf_batadv_tvlv_tt_change_flags_roam;
708
static int hf_batadv_tvlv_tt_change_flags_wifi;
709
static int hf_batadv_tvlv_tt_change_flags_isolate;
710
711
static const value_string unicast_4addr_typenames[] = {
712
  { UNICAST_4ADDR_DATA, "Data" },
713
  { UNICAST_4ADDR_DAT_DHT_GET, "DHT Get" },
714
  { UNICAST_4ADDR_DAT_DHT_PUT, "DHT Put" },
715
  { UNICAST_4ADDR_DAT_CACHE_REPLY, "DHT Cache Reply" },
716
  { 0, NULL }
717
};
718
719
static const value_string tvlv_v15_typenames[] = {
720
  { BATADV_TVLV_V15_GW, "Gateway information" },
721
  { BATADV_TVLV_V15_DAT, "Distributed ARP Table" },
722
  { BATADV_TVLV_V15_NC, "Network Coding" },
723
  { BATADV_TVLV_V15_TT, "Translation Table" },
724
  { BATADV_TVLV_V15_ROAM, "Roaming" },
725
  { BATADV_TVLV_V15_MCAST, "Multicast" },
726
  { 0, NULL }
727
};
728
729
static const value_string icmp_packettypenames[] = {
730
  { ECHO_REPLY, "ECHO_REPLY" },
731
  { DESTINATION_UNREACHABLE, "DESTINATION UNREACHABLE" },
732
  { ECHO_REQUEST, "ECHO_REQUEST" },
733
  { TTL_EXCEEDED, "TTL exceeded" },
734
  { BATADV_TP, "Throughput Meter" },
735
  { 0, NULL }
736
};
737
738
static const value_string icmp_tp_packettypenames[] = {
739
  { 0, "Message" },
740
  { 1, "Acknowledgement" },
741
  { 0, NULL }
742
};
743
744
static const value_string vis_packettypenames[] = {
745
  { VIS_TYPE_SERVER_SYNC, "SERVER_SYNC" },
746
  { VIS_TYPE_CLIENT_UPDATE, "CLIENT_UPDATE" },
747
  { 0, NULL }
748
};
749
750
static const value_string tt_query_type_v14[] = {
751
  {TT_REQUEST, "Request"},
752
  {TT_RESPONSE, "Response"},
753
  {0, NULL}
754
};
755
756
static const value_string tvlv_tt_typenames[] = {
757
  {BATADV_TVLVL_TT_OGM_DIFF, "OGM Diff"},
758
  {BATADV_TVLVL_TT_REQUEST, "Request"},
759
  {BATADV_TVLVL_TT_RESPONSE, "Response"},
760
  {0, NULL}
761
};
762
763
static int * const batman_v5_flags[] = {
764
  &hf_batadv_batman_flags_directlink,
765
  &hf_batadv_batman_flags_vis_server,
766
  NULL
767
};
768
769
static int * const batman_v9_flags[] = {
770
  &hf_batadv_batman_flags_directlink,
771
  &hf_batadv_batman_flags_vis_server,
772
  &hf_batadv_batman_flags_primaries_first_hop,
773
  NULL
774
};
775
776
static int * const batman_v14_flags[] = {
777
  &hf_batadv_batman_flags_directlink,
778
  &hf_batadv_batman_flags_vis_server,
779
  &hf_batadv_batman_flags_primaries_first_hop,
780
  &hf_batadv_batman_flags_not_best_next_hop,
781
  NULL
782
};
783
784
static int * const unicast_frag_flags[] = {
785
  &hf_batadv_unicast_frag_flags_head,
786
  &hf_batadv_unicast_frag_flags_largetail,
787
  NULL
788
};
789
790
static int * const tt_query_flags[] = {
791
  &hf_batadv_tt_query_flags_type,
792
  &hf_batadv_tt_query_flags_full_table,
793
  NULL
794
};
795
796
static int * const tt_entry_flags[] = {
797
  &hf_batadv_tt_entry_flags_change_del,
798
  &hf_batadv_tt_entry_flags_client_roam,
799
  NULL
800
};
801
802
static const fragment_items msg_frag_items = {
803
  /* Fragment subtrees */
804
  &ett_msg_fragment,
805
  &ett_msg_fragments,
806
  /* Fragment fields */
807
  &hf_msg_fragments,
808
  &hf_msg_fragment,
809
  &hf_msg_fragment_overlap,
810
  &hf_msg_fragment_overlap_conflicts,
811
  &hf_msg_fragment_multiple_tails,
812
  &hf_msg_fragment_too_long_fragment,
813
  &hf_msg_fragment_error,
814
  &hf_msg_fragment_count,
815
  /* Reassembled in field */
816
  &hf_msg_reassembled_in,
817
  &hf_msg_reassembled_length,
818
  /* Reassembled data field */
819
  NULL,
820
  /* Tag */
821
  "Message fragments"
822
};
823
824
825
/* forward declaration */
826
void proto_register_batadv(void);
827
void proto_reg_handoff_batadv(void);
828
829
static dissector_handle_t batman_handle;
830
831
/* supported packet dissectors */
832
static void dissect_batadv_v5(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
833
static void dissect_batadv_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
834
static void dissect_batadv_batman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
835
static unsigned dissect_batadv_batman_v5(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree);
836
static unsigned dissect_batadv_batman_v7(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree);
837
static unsigned dissect_batadv_batman_v9(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree);
838
static unsigned dissect_batadv_batman_v10(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree);
839
static unsigned dissect_batadv_batman_v11(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree);
840
static unsigned dissect_batadv_batman_v14(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree);
841
842
static void dissect_batadv_iv_ogm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
843
static unsigned dissect_batadv_iv_ogm_v15(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree);
844
845
static void dissect_batadv_elp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
846
static void dissect_batadv_elp_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
847
848
static void dissect_batadv_ogm2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
849
static unsigned dissect_batadv_ogm2_v15(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree);
850
851
static void dissect_batadv_bcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
852
static void dissect_batadv_bcast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
853
static void dissect_batadv_bcast_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
854
static void dissect_batadv_bcast_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
855
856
static void dissect_batadv_icmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
857
static void dissect_batadv_icmp_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
858
static void dissect_batadv_icmp_v7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
859
static void dissect_batadv_icmp_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
860
static void dissect_batadv_icmp_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
861
862
static void dissect_batadv_unicast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
863
static void dissect_batadv_unicast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
864
static void dissect_batadv_unicast_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
865
866
static void dissect_batadv_unicast_4addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
867
static void dissect_batadv_unicast_4addr_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
868
869
static void dissect_batadv_unicast_frag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
870
static void dissect_batadv_unicast_frag_v12(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
871
static void dissect_batadv_unicast_frag_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
872
static void dissect_batadv_unicast_frag_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
873
874
static void dissect_batadv_vis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
875
static void dissect_batadv_vis_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
876
static void dissect_batadv_vis_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
877
static void dissect_batadv_vis_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
878
879
static void dissect_batadv_tt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
880
static void dissect_vis_entry_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
881
static void dissect_vis_entry_v8(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
882
883
static void dissect_batadv_tt_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
884
static void dissect_batadv_tt_query_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
885
static void dissect_tt_entry_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
886
887
static void dissect_batadv_roam_adv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
888
static void dissect_batadv_roam_adv_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
889
890
static void dissect_batadv_coded(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
891
static void dissect_batadv_coded_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
892
893
static void dissect_batadv_unicast_tvlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
894
static void dissect_batadv_unicast_tvlv_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
895
896
static void dissect_batadv_tvlv_v15(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
897
static void dissect_batadv_tvlv_v15_header(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, uint8_t type);
898
static void dissect_batadv_tvlv_v15_dat(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t version);
899
static void dissect_batadv_tvlv_v15_nc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t version);
900
static void dissect_batadv_tvlv_v15_mcast(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t version);
901
static void dissect_batadv_tvlv_v15_gw(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t version);
902
static void dissect_batadv_tvlv_v15_roam(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t version);
903
static void dissect_batadv_tvlv_v15_tt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t version);
904
static unsigned dissect_batadv_tvlv_v15_tt_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset, uint8_t tt_flags, int changes_offset);
905
static unsigned dissect_batadv_tvlv_v15_tt_change(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
906
907
908
/* other dissectors */
909
static dissector_handle_t eth_handle;
910
911
static int proto_batadv_plugin;
912
913
/* tap */
914
static int batadv_tap;
915
static int batadv_follow_tap;
916
917
/* segmented messages */
918
static reassembly_table msg_reassembly_table;
919
920
static unsigned int batadv_ethertype = ETH_P_BATMAN;
921
922
static int dissect_batadv_plugin(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
923
44
{
924
44
  uint8_t version;
925
926
44
  col_clear(pinfo->cinfo, COL_INFO);
927
928
  /* The payload may carry B.A.T.M.A.N. again; stop before the layer limit */
929
44
  if (wmem_list_count(pinfo->layers) + 16 >= prefs.gui_max_tree_depth) {
930
0
    proto_tree_add_expert_remaining(tree, pinfo, &ei_batadv_too_deep, tvb, 0);
931
0
    return tvb_captured_length(tvb);
932
0
  }
933
934
44
  version = tvb_get_uint8(tvb, 1);
935
44
  if (version < 15)
936
41
    dissect_batadv_v5(tvb, pinfo, tree);
937
3
  else
938
3
    dissect_batadv_v15(tvb, pinfo, tree);
939
940
44
  return tvb_captured_length(tvb);
941
44
}
942
943
static void dissect_batadv_v5(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
944
41
{
945
41
  uint8_t type;
946
947
41
  type = tvb_get_uint8(tvb, 0);
948
949
41
  switch (type) {
950
23
  case BATADV_PACKET_V5:
951
23
    dissect_batadv_batman(tvb, pinfo, tree);
952
23
    break;
953
3
  case BATADV_ICMP_V5:
954
3
    dissect_batadv_icmp(tvb, pinfo, tree);
955
3
    break;
956
0
  case BATADV_UNICAST_V5:
957
0
    dissect_batadv_unicast(tvb, pinfo, tree);
958
0
    break;
959
1
  case BATADV_UNICAST_FRAG_V12:
960
1
    dissect_batadv_unicast_frag(tvb, pinfo, tree);
961
1
    break;
962
0
  case BATADV_BCAST_V5:
963
0
    dissect_batadv_bcast(tvb, pinfo, tree);
964
0
    break;
965
6
  case BATADV_VIS_V5:
966
6
    dissect_batadv_vis(tvb, pinfo, tree);
967
6
    break;
968
7
  case BATADV_TT_QUERY_V14:
969
7
    dissect_batadv_tt_query(tvb, pinfo, tree);
970
7
    break;
971
1
  case BATADV_ROAM_ADV_V14:
972
1
    dissect_batadv_roam_adv(tvb, pinfo, tree);
973
1
    break;
974
0
  case BATADV_UNICAST_4ADDR_V14:
975
0
    dissect_batadv_unicast_4addr(tvb, pinfo, tree);
976
0
    break;
977
0
  default:
978
    /* dunno */
979
0
  {
980
0
    tvbuff_t *next_tvb;
981
0
    int length_remaining;
982
983
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_???");
984
985
0
    length_remaining = tvb_reported_length_remaining(tvb, 0);
986
0
    if (length_remaining > 0) {
987
0
      next_tvb = tvb_new_subset_remaining(tvb, 0);
988
0
      call_data_dissector(next_tvb, pinfo, tree);
989
0
    }
990
0
    break;
991
0
  }
992
41
  }
993
41
}
994
995
static void dissect_batadv_v15(tvbuff_t *tvb, packet_info *pinfo,
996
             proto_tree *tree)
997
3
{
998
3
  uint8_t type;
999
1000
3
  type = tvb_get_uint8(tvb, 0);
1001
1002
3
  switch (type) {
1003
0
  case BATADV_IV_OGM_V15:
1004
0
    dissect_batadv_iv_ogm(tvb, pinfo, tree);
1005
0
    break;
1006
1
  case BATADV_BCAST_V15:
1007
1
    dissect_batadv_bcast(tvb, pinfo, tree);
1008
1
    break;
1009
0
  case BATADV_CODED_V15:
1010
0
    dissect_batadv_coded(tvb, pinfo, tree);
1011
0
    break;
1012
0
  case BATADV_ELP_V15:
1013
0
    dissect_batadv_elp(tvb, pinfo, tree);
1014
0
    break;
1015
1
  case BATADV_OGM2_V15:
1016
1
    dissect_batadv_ogm2(tvb, pinfo, tree);
1017
1
    break;
1018
0
  case BATADV_UNICAST_V15:
1019
0
    dissect_batadv_unicast(tvb, pinfo, tree);
1020
0
    break;
1021
0
  case BATADV_UNICAST_FRAG_V15:
1022
0
    dissect_batadv_unicast_frag(tvb, pinfo, tree);
1023
0
    break;
1024
0
  case BATADV_UNICAST_4ADDR_V15:
1025
0
    dissect_batadv_unicast_4addr(tvb, pinfo, tree);
1026
0
    break;
1027
0
  case BATADV_ICMP_V15:
1028
0
    dissect_batadv_icmp(tvb, pinfo, tree);
1029
0
    break;
1030
0
  case BATADV_UNICAST_TVLV_V15:
1031
0
    dissect_batadv_unicast_tvlv(tvb, pinfo, tree);
1032
0
    break;
1033
1
  default:
1034
    /* dunno */
1035
1
  {
1036
1
    tvbuff_t *next_tvb;
1037
1
    int length_remaining;
1038
1039
1
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_???");
1040
1041
1
    length_remaining = tvb_reported_length_remaining(tvb, 0);
1042
1
    if (length_remaining > 0) {
1043
1
      next_tvb = tvb_new_subset_remaining(tvb, 0);
1044
1
      call_data_dissector(next_tvb, pinfo, tree);
1045
1
    }
1046
1
    break;
1047
0
  }
1048
3
  }
1049
3
}
1050
1051
static void dissect_batadv_batman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1052
23
{
1053
23
  uint8_t version;
1054
23
  unsigned offset = 0;
1055
1056
  /* set protocol name */
1057
23
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_BATMAN");
1058
1059
23
  version = tvb_get_uint8(tvb, 1);
1060
23
  switch (version) {
1061
0
  case 5:
1062
10
  case 6:
1063
21
    while (tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V5_SIZE) {
1064
11
      offset = dissect_batadv_batman_v5(tvb, offset, pinfo, tree);
1065
11
    }
1066
10
    break;
1067
3
  case 7:
1068
3
  case 8:
1069
6
    while (tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V7_SIZE) {
1070
3
      offset = dissect_batadv_batman_v7(tvb, offset, pinfo, tree);
1071
3
    }
1072
3
    break;
1073
0
  case 9:
1074
0
    while (tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V9_SIZE) {
1075
0
      offset = dissect_batadv_batman_v9(tvb, offset, pinfo, tree);
1076
0
    }
1077
0
    break;
1078
2
  case 11:
1079
2
  case 13:
1080
4
    while (tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V11_SIZE) {
1081
2
      offset = dissect_batadv_batman_v11(tvb, offset, pinfo, tree);
1082
2
    }
1083
2
    break;
1084
3
  case 10:
1085
6
  case 12:
1086
14
    while (tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V10_SIZE) {
1087
8
      offset = dissect_batadv_batman_v10(tvb, offset, pinfo, tree);
1088
8
    }
1089
6
    break;
1090
1
  case 14:
1091
3
    while (tvb_reported_length_remaining(tvb, offset) >= BATMAN_PACKET_V14_SIZE) {
1092
2
      offset = dissect_batadv_batman_v14(tvb, offset, pinfo, tree);
1093
2
    }
1094
1
    break;
1095
1
  default:
1096
1
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
1097
1
    call_data_dissector(tvb, pinfo, tree);
1098
1
    break;
1099
23
  }
1100
23
}
1101
1102
static void dissect_batadv_gwflags(tvbuff_t *tvb, uint8_t gwflags, unsigned offset, proto_item *tgw)
1103
17
{
1104
17
  proto_tree *gwflags_tree;
1105
17
  uint8_t s = (gwflags & 0x80) >> 7;
1106
17
  uint8_t downbits = (gwflags & 0x78) >> 3;
1107
17
  uint8_t upbits = (gwflags & 0x07);
1108
17
  unsigned down, up;
1109
1110
17
  if (gwflags == 0) {
1111
5
    down = 0;
1112
5
    up = 0;
1113
12
  } else {
1114
12
    down = 32 * (s + 2) * (1 << downbits);
1115
12
    up = ((upbits + 1) * down) / 8;
1116
12
  }
1117
1118
17
  gwflags_tree =  proto_item_add_subtree(tgw, ett_batadv_batman_gwflags);
1119
17
  proto_tree_add_uint(gwflags_tree, hf_batadv_batman_gwflags_dl_speed, tvb, offset, 1, down);
1120
17
  proto_tree_add_uint(gwflags_tree, hf_batadv_batman_gwflags_ul_speed, tvb, offset, 1, up);
1121
17
}
1122
1123
static unsigned dissect_batadv_batman_v5(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree)
1124
11
{
1125
11
  proto_item *ti, *tgw;
1126
11
  proto_tree *batadv_batman_tree;
1127
11
  uint8_t type;
1128
11
  struct batman_packet_v5 *batman_packeth;
1129
11
  int i;
1130
1131
11
  tvbuff_t *next_tvb;
1132
1133
11
  batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v5);
1134
1135
11
  type = tvb_get_uint8(tvb, offset+0);
1136
11
  batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1137
1138
  /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1139
11
  if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1140
1
    return tvb_reported_length(tvb);
1141
1
  }
1142
1143
10
  batman_packeth->flags = tvb_get_uint8(tvb, offset+2);
1144
10
  batman_packeth->ttl = tvb_get_uint8(tvb, offset+3);
1145
10
  batman_packeth->gwflags = tvb_get_uint8(tvb, offset+4);
1146
10
  batman_packeth->tq = tvb_get_uint8(tvb, offset+5);
1147
10
  batman_packeth->seqno = tvb_get_ntohs(tvb, offset+6);
1148
10
  set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+8);
1149
10
  copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1150
10
  copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1151
10
  set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+14);
1152
1153
10
  batman_packeth->num_tt = tvb_get_uint8(tvb, offset+20);
1154
10
  batman_packeth->pad = tvb_get_uint8(tvb, offset+21);
1155
1156
  /* Set info column */
1157
10
  col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1158
1159
  /* Set tree info */
1160
10
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V5_SIZE,
1161
10
                "B.A.T.M.A.N., Orig: %s",
1162
10
                address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1163
10
  batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1164
1165
  /* items */
1166
10
  proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1167
10
          "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1168
10
  offset += 1;
1169
1170
10
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1171
10
  offset += 1;
1172
1173
10
  proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1174
10
          ett_batadv_batman_flags, batman_v5_flags, ENC_BIG_ENDIAN);
1175
10
  offset += 1;
1176
1177
10
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1178
10
  offset += 1;
1179
1180
10
  tgw = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_gwflags, tvb, offset, 1, ENC_BIG_ENDIAN);
1181
10
  dissect_batadv_gwflags(tvb, batman_packeth->gwflags, offset, tgw);
1182
10
  offset += 1;
1183
1184
10
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1185
10
  offset += 1;
1186
1187
10
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
1188
10
  offset += 2;
1189
1190
10
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1191
10
  offset += 6;
1192
1193
10
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1194
10
  offset += 6;
1195
1196
10
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_tt, tvb, offset, 1, ENC_BIG_ENDIAN);
1197
10
  offset += 1;
1198
1199
  /* Skip 1 byte of padding. */
1200
10
  offset += 1;
1201
1202
10
  tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1203
1204
811
  for (i = 0; i < batman_packeth->num_tt; i++) {
1205
801
    next_tvb = tvb_new_subset_length(tvb, offset, 6);
1206
1207
801
    if (have_tap_listener(batadv_follow_tap)) {
1208
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1209
0
    }
1210
1211
801
    dissect_batadv_tt(next_tvb, pinfo, batadv_batman_tree);
1212
801
    offset += 6;
1213
801
  }
1214
1215
10
  return offset;
1216
11
}
1217
1218
static unsigned dissect_batadv_batman_v7(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree)
1219
3
{
1220
3
  proto_tree *batadv_batman_tree;
1221
3
  proto_item *ti;
1222
3
  uint8_t type;
1223
3
  struct batman_packet_v7 *batman_packeth;
1224
3
  int i;
1225
1226
3
  tvbuff_t *next_tvb;
1227
1228
3
  batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v7);
1229
1230
3
  type = tvb_get_uint8(tvb, offset+0);
1231
3
  batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1232
1233
  /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1234
3
  if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1235
0
    return tvb_reported_length(tvb);
1236
0
  }
1237
1238
3
  batman_packeth->flags = tvb_get_uint8(tvb, offset+2);
1239
3
  batman_packeth->tq = tvb_get_uint8(tvb, offset+3);
1240
3
  batman_packeth->seqno = tvb_get_ntohs(tvb, offset+4);
1241
3
  set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+6);
1242
3
  copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1243
3
  copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1244
3
  set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+12);
1245
3
  batman_packeth->ttl = tvb_get_uint8(tvb, offset+18);
1246
3
  batman_packeth->num_tt = tvb_get_uint8(tvb, offset+19);
1247
1248
  /* Set info column */
1249
3
  col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1250
1251
  /* Set tree info */
1252
3
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V7_SIZE,
1253
3
                "B.A.T.M.A.N., Orig: %s",
1254
3
                address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1255
3
  batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1256
1257
  /* items */
1258
3
  proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1259
3
          "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1260
3
  offset += 1;
1261
1262
3
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1263
3
  offset += 1;
1264
1265
3
  proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1266
3
          ett_batadv_batman_flags, batman_v5_flags, ENC_BIG_ENDIAN);
1267
3
  offset += 1;
1268
1269
3
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1270
3
  offset += 1;
1271
1272
3
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
1273
3
  offset += 2;
1274
1275
3
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1276
3
  offset += 6;
1277
1278
3
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1279
3
  offset += 6;
1280
1281
3
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1282
3
  offset += 1;
1283
1284
3
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_tt, tvb, offset, 1, ENC_BIG_ENDIAN);
1285
3
  offset += 1;
1286
1287
3
  tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1288
1289
91
  for (i = 0; i < batman_packeth->num_tt; i++) {
1290
88
    next_tvb = tvb_new_subset_length(tvb, offset, 6);
1291
1292
88
    if (have_tap_listener(batadv_follow_tap)) {
1293
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1294
0
    }
1295
1296
88
    dissect_batadv_tt(next_tvb, pinfo, batadv_batman_tree);
1297
88
    offset += 6;
1298
88
  }
1299
1300
3
  return offset;
1301
3
}
1302
1303
static unsigned dissect_batadv_batman_v9(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree)
1304
0
{
1305
0
  proto_item *ti, *tgw;
1306
0
  proto_tree *batadv_batman_tree;
1307
0
  uint8_t type;
1308
0
  struct batman_packet_v9 *batman_packeth;
1309
0
  int i;
1310
1311
0
  tvbuff_t *next_tvb;
1312
1313
0
  batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v9);
1314
1315
0
  type = tvb_get_uint8(tvb, offset+0);
1316
0
  batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1317
1318
  /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1319
0
  if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1320
0
    return tvb_reported_length(tvb);
1321
0
  }
1322
1323
0
  batman_packeth->flags = tvb_get_uint8(tvb, offset+2);
1324
0
  batman_packeth->tq = tvb_get_uint8(tvb, offset+3);
1325
0
  batman_packeth->seqno = tvb_get_ntohs(tvb, offset+4);
1326
0
  set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+6);
1327
0
  copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1328
0
  copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1329
0
  set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+12);
1330
0
  batman_packeth->ttl = tvb_get_uint8(tvb, offset+18);
1331
0
  batman_packeth->num_tt = tvb_get_uint8(tvb, offset+19);
1332
0
  batman_packeth->gwflags = tvb_get_uint8(tvb, offset+20);
1333
1334
  /* Set info column */
1335
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1336
1337
  /* Set tree info */
1338
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V9_SIZE,
1339
0
                "B.A.T.M.A.N., Orig: %s",
1340
0
                address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1341
0
  batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1342
1343
  /* items */
1344
0
  proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1345
0
          "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1346
0
  offset += 1;
1347
1348
0
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1349
0
  offset += 1;
1350
1351
0
  proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1352
0
          ett_batadv_batman_flags, batman_v9_flags, ENC_BIG_ENDIAN);
1353
0
  offset += 1;
1354
1355
0
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1356
0
  offset += 1;
1357
1358
0
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
1359
0
  offset += 2;
1360
1361
0
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1362
0
  offset += 6;
1363
1364
0
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1365
0
  offset += 6;
1366
1367
0
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1368
0
  offset += 1;
1369
1370
0
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_tt, tvb, offset, 1, ENC_BIG_ENDIAN);
1371
0
  offset += 1;
1372
1373
0
  tgw = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_gwflags, tvb, offset, 1, ENC_BIG_ENDIAN);
1374
0
  dissect_batadv_gwflags(tvb, batman_packeth->gwflags, offset, tgw);
1375
0
  offset += 1;
1376
1377
  /* Skip 1 byte of padding. */
1378
0
  offset += 1;
1379
1380
0
  tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1381
1382
0
  for (i = 0; i < batman_packeth->num_tt; i++) {
1383
0
    next_tvb = tvb_new_subset_length(tvb, offset, 6);
1384
1385
0
    if (have_tap_listener(batadv_follow_tap)) {
1386
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1387
0
    }
1388
1389
0
    dissect_batadv_tt(next_tvb, pinfo, batadv_batman_tree);
1390
0
    offset += 6;
1391
0
  }
1392
1393
0
  return offset;
1394
0
}
1395
1396
static unsigned dissect_batadv_batman_v10(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree)
1397
8
{
1398
8
  proto_item *ti, *tgw;
1399
8
  proto_tree *batadv_batman_tree;
1400
8
  uint8_t type;
1401
8
  struct batman_packet_v10 *batman_packeth;
1402
8
  int i;
1403
1404
8
  tvbuff_t *next_tvb;
1405
1406
8
  batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v10);
1407
1408
8
  type = tvb_get_uint8(tvb, offset+0);
1409
8
  batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1410
1411
  /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1412
8
  if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1413
2
    return tvb_reported_length(tvb);
1414
2
  }
1415
1416
6
  batman_packeth->flags = tvb_get_uint8(tvb, offset+2);
1417
6
  batman_packeth->tq = tvb_get_uint8(tvb, offset+3);
1418
6
  batman_packeth->seqno = tvb_get_ntohl(tvb, offset+4);
1419
6
  set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+8);
1420
6
  copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1421
6
  copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1422
6
  set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+14);
1423
6
  batman_packeth->ttl = tvb_get_uint8(tvb, offset+20);
1424
6
  batman_packeth->num_tt = tvb_get_uint8(tvb, offset+21);
1425
6
  batman_packeth->gwflags = tvb_get_uint8(tvb, offset+22);
1426
1427
  /* Set info column */
1428
6
  col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1429
1430
  /* Set tree info */
1431
6
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V10_SIZE,
1432
6
                "B.A.T.M.A.N., Orig: %s",
1433
6
                address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1434
6
  batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1435
1436
  /* items */
1437
6
  proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1438
6
          "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1439
6
  offset += 1;
1440
1441
6
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1442
6
  offset += 1;
1443
1444
6
  proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1445
6
          ett_batadv_batman_flags, batman_v9_flags, ENC_BIG_ENDIAN);
1446
6
  offset += 1;
1447
1448
6
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1449
6
  offset += 1;
1450
1451
6
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
1452
6
  offset += 4;
1453
1454
6
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1455
6
  offset += 6;
1456
1457
6
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1458
6
  offset += 6;
1459
1460
6
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1461
6
  offset += 1;
1462
1463
6
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_tt, tvb, offset, 1, ENC_BIG_ENDIAN);
1464
6
  offset += 1;
1465
1466
6
  tgw = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_gwflags, tvb, offset, 1, ENC_BIG_ENDIAN);
1467
6
  dissect_batadv_gwflags(tvb, batman_packeth->gwflags, offset, tgw);
1468
6
  offset += 1;
1469
1470
  /* Skip 1 byte of padding. */
1471
6
  offset += 1;
1472
1473
6
  tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1474
1475
389
  for (i = 0; i < batman_packeth->num_tt; i++) {
1476
383
    next_tvb = tvb_new_subset_length(tvb, offset, 6);
1477
1478
383
    if (have_tap_listener(batadv_follow_tap)) {
1479
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1480
0
    }
1481
1482
383
    dissect_batadv_tt(next_tvb, pinfo, batadv_batman_tree);
1483
383
    offset += 6;
1484
383
  }
1485
1486
6
  return offset;
1487
8
}
1488
1489
static unsigned dissect_batadv_batman_v11(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree)
1490
2
{
1491
2
  proto_tree *batadv_batman_tree;
1492
2
  proto_item *ti;
1493
2
  uint8_t type;
1494
2
  struct batman_packet_v11 *batman_packeth;
1495
2
  int i;
1496
1497
2
  tvbuff_t *next_tvb;
1498
1499
2
  batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v11);
1500
1501
2
  type = tvb_get_uint8(tvb, offset+0);
1502
2
  batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1503
1504
  /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1505
2
  if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1506
0
    return tvb_reported_length(tvb);
1507
0
  }
1508
1509
2
  batman_packeth->flags = tvb_get_uint8(tvb, offset+2);
1510
2
  batman_packeth->tq = tvb_get_uint8(tvb, offset+3);
1511
2
  batman_packeth->seqno = tvb_get_ntohl(tvb, offset+4);
1512
2
  set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+8);
1513
2
  copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1514
2
  copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1515
2
  set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+14);
1516
2
  batman_packeth->ttl = tvb_get_uint8(tvb, offset+20);
1517
2
  batman_packeth->num_tt = tvb_get_uint8(tvb, offset+21);
1518
1519
  /* Set info column */
1520
2
  col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1521
1522
  /* Set tree info */
1523
2
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V11_SIZE,
1524
2
                "B.A.T.M.A.N., Orig: %s",
1525
2
                address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1526
2
  batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1527
1528
  /* items */
1529
2
  proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1530
2
          "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1531
2
  offset += 1;
1532
1533
2
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1534
2
  offset += 1;
1535
1536
2
  proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1537
2
          ett_batadv_batman_flags, batman_v9_flags, ENC_BIG_ENDIAN);
1538
2
  offset += 1;
1539
1540
2
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1541
2
  offset += 1;
1542
1543
2
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
1544
2
  offset += 4;
1545
1546
2
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1547
2
  offset += 6;
1548
1549
2
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1550
2
  offset += 6;
1551
1552
2
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1553
2
  offset += 1;
1554
1555
2
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_num_tt, tvb, offset, 1, ENC_BIG_ENDIAN);
1556
2
  offset += 1;
1557
1558
2
  tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1559
1560
260
  for (i = 0; i < batman_packeth->num_tt; i++) {
1561
258
    next_tvb = tvb_new_subset_length(tvb, offset, 6);
1562
1563
258
    if (have_tap_listener(batadv_follow_tap)) {
1564
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1565
0
    }
1566
1567
258
    dissect_batadv_tt(next_tvb, pinfo, batadv_batman_tree);
1568
258
    offset += 6;
1569
258
  }
1570
1571
2
  return offset;
1572
2
}
1573
1574
static unsigned dissect_batadv_batman_v14(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree)
1575
2
{
1576
2
  proto_item *ti, *tgw;
1577
2
  proto_tree *batadv_batman_tree;
1578
2
  uint8_t type;
1579
2
  struct batman_packet_v14 *batman_packeth;
1580
2
  int i;
1581
1582
2
  tvbuff_t *next_tvb;
1583
2
  int length_remaining;
1584
1585
2
  batman_packeth = wmem_new(pinfo->pool, struct batman_packet_v14);
1586
1587
2
  type = tvb_get_uint8(tvb, offset+0);
1588
2
  batman_packeth->version = tvb_get_uint8(tvb, offset+1);
1589
1590
  /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1591
2
  if (batman_packeth->version == 0 || type != BATADV_PACKET_V5) {
1592
1
    return tvb_reported_length(tvb);
1593
1
  }
1594
1595
1
  batman_packeth->ttl = tvb_get_uint8(tvb, offset+2);
1596
1
  batman_packeth->flags = tvb_get_uint8(tvb, offset+3);
1597
1
  batman_packeth->seqno = tvb_get_ntohl(tvb, offset+4);
1598
1
  set_address_tvb(&batman_packeth->orig, AT_ETHER, 6, tvb, offset+8);
1599
1
  copy_address_shallow(&pinfo->dl_src, &batman_packeth->orig);
1600
1
  copy_address_shallow(&pinfo->src, &batman_packeth->orig);
1601
1
  set_address_tvb(&batman_packeth->prev_sender, AT_ETHER, 6, tvb, offset+14);
1602
1
  batman_packeth->gw_flags = tvb_get_uint8(tvb, offset+20);
1603
1
  batman_packeth->tq = tvb_get_uint8(tvb, offset+21);
1604
1
  batman_packeth->tt_num_changes = tvb_get_uint8(tvb, offset+22);
1605
1
  batman_packeth->ttvn = tvb_get_uint8(tvb, offset+23);
1606
1
  batman_packeth->tt_crc = tvb_get_ntohs(tvb, offset+24);
1607
1608
  /* Set info column */
1609
1
  col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", batman_packeth->seqno);
1610
1611
  /* Set tree info */
1612
1
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, offset, BATMAN_PACKET_V14_SIZE,
1613
1
                "B.A.T.M.A.N., Orig: %s",
1614
1
                address_with_resolution_to_str(pinfo->pool, &batman_packeth->orig));
1615
1
  batadv_batman_tree = proto_item_add_subtree(ti, ett_batadv_batman);
1616
1617
  /* items */
1618
1
  proto_tree_add_uint_format(batadv_batman_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_PACKET_V5,
1619
1
          "Packet Type: %s (%u)", "BATADV_PACKET", BATADV_PACKET_V5);
1620
1
  offset += 1;
1621
1622
1
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1623
1
  offset += 1;
1624
1625
1
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1626
1
  offset += 1;
1627
1628
1
  proto_tree_add_bitmask(batadv_batman_tree, tvb, offset, hf_batadv_batman_flags,
1629
1
          ett_batadv_batman_flags, batman_v14_flags, ENC_BIG_ENDIAN);
1630
1
  offset += 1;
1631
1632
1
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
1633
1
  offset += 4;
1634
1635
1
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_orig, tvb, offset, 6, ENC_NA);
1636
1
  offset += 6;
1637
1638
1
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_prev_sender, tvb, offset, 6, ENC_NA);
1639
1
  offset += 6;
1640
1641
1
  tgw = proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_gwflags, tvb, offset, 1, ENC_BIG_ENDIAN);
1642
1
  dissect_batadv_gwflags(tvb, batman_packeth->gw_flags, offset, tgw);
1643
1
  offset += 1;
1644
1645
1
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tq, tvb, offset, 1, ENC_BIG_ENDIAN);
1646
1
  offset += 1;
1647
1648
1
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tt_num_changes, tvb, offset, 1, ENC_BIG_ENDIAN);
1649
1
  offset += 1;
1650
1651
1
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_ttvn, tvb, offset, 1, ENC_BIG_ENDIAN);
1652
1
  offset += 1;
1653
1654
1
  proto_tree_add_item(batadv_batman_tree, hf_batadv_batman_tt_crc, tvb, offset, 2, ENC_BIG_ENDIAN);
1655
1
  offset += 2;
1656
1657
1
  tap_queue_packet(batadv_tap, pinfo, batman_packeth);
1658
1659
66
  for (i = 0; i < batman_packeth->tt_num_changes; i++) {
1660
65
    next_tvb = tvb_new_subset_length(tvb, offset, TT_ENTRY_V14_SIZE);
1661
1662
65
    if (have_tap_listener(batadv_follow_tap)) {
1663
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1664
0
    }
1665
1666
65
    dissect_tt_entry_v14(next_tvb, pinfo, batadv_batman_tree);
1667
65
    offset += TT_ENTRY_V14_SIZE;
1668
65
  }
1669
1670
1
  length_remaining = tvb_reported_length_remaining(tvb, offset);
1671
1
  if (length_remaining > 0) {
1672
1
    next_tvb = tvb_new_subset_remaining(tvb, offset);
1673
1
    call_data_dissector(next_tvb, pinfo, tree);
1674
1
  }
1675
1676
1
  return offset;
1677
2
}
1678
1679
static void dissect_batadv_iv_ogm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1680
0
{
1681
0
  uint8_t version;
1682
0
  unsigned offset = 0;
1683
1684
  /* set protocol name */
1685
0
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_IV_OGM");
1686
1687
0
  version = tvb_get_uint8(tvb, 1);
1688
0
  switch (version) {
1689
0
  case 15:
1690
0
    while (tvb_reported_length_remaining(tvb, offset) >= IV_OGM_PACKET_V15_SIZE) {
1691
0
      offset = dissect_batadv_iv_ogm_v15(tvb, offset, pinfo, tree);
1692
0
    }
1693
0
    break;
1694
0
  default:
1695
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
1696
0
    call_data_dissector(tvb, pinfo, tree);
1697
0
    break;
1698
0
  }
1699
0
}
1700
1701
static unsigned dissect_batadv_iv_ogm_v15(tvbuff_t *tvb, unsigned offset,
1702
             packet_info *pinfo, proto_tree *tree)
1703
0
{
1704
0
  proto_tree *batadv_iv_ogm_tree;
1705
0
  proto_item *ti;
1706
0
  uint8_t type, version;
1707
0
  struct iv_ogm_packet_v15 *iv_ogm_packeth;
1708
0
  tvbuff_t *next_tvb;
1709
0
  static int * const flags[] = {
1710
0
    &hf_batadv_iv_ogm_flags_directlink,
1711
0
    &hf_batadv_iv_ogm_flags_primaries_first_hop,
1712
0
    &hf_batadv_iv_ogm_flags_not_best_next_hop,
1713
0
    NULL
1714
0
  };
1715
1716
0
  type = tvb_get_uint8(tvb, offset+0);
1717
0
  version = tvb_get_uint8(tvb, offset+1);
1718
1719
  /* don't interpret padding as B.A.T.M.A.N. advanced packet */
1720
0
  if (version == 0 || type != BATADV_IV_OGM_V15)
1721
0
    return tvb_reported_length(tvb);
1722
1723
0
  iv_ogm_packeth = wmem_new(pinfo->pool, struct iv_ogm_packet_v15);
1724
1725
  /* Set info column */
1726
0
  col_clear(pinfo->cinfo, COL_INFO);
1727
1728
  /* Set tree info */
1729
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
1730
0
              tvb, offset,
1731
0
              IV_OGM_PACKET_V15_SIZE,
1732
0
              "B.A.T.M.A.N. IV OGM, Orig: %s",
1733
0
              tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, offset + 8));
1734
0
  batadv_iv_ogm_tree = proto_item_add_subtree(ti, ett_batadv_iv_ogm);
1735
1736
  /* items */
1737
0
  iv_ogm_packeth->packet_type = tvb_get_uint8(tvb, offset);
1738
0
  proto_tree_add_uint_format_value(batadv_iv_ogm_tree,
1739
0
           hf_batadv_packet_type,
1740
0
           tvb, offset, 1, BATADV_IV_OGM_V15,
1741
0
           "%s (%u)", "BATADV_IV_OGM",
1742
0
           BATADV_IV_OGM_V15);
1743
0
  offset += 1;
1744
1745
0
  iv_ogm_packeth->version = tvb_get_uint8(tvb, offset);
1746
0
  proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_version, tvb,
1747
0
          offset, 1, ENC_BIG_ENDIAN);
1748
0
  offset += 1;
1749
1750
0
  iv_ogm_packeth->ttl = tvb_get_uint8(tvb, offset);
1751
0
  proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_ttl, tvb,
1752
0
          offset, 1, ENC_BIG_ENDIAN);
1753
0
  offset += 1;
1754
1755
0
  iv_ogm_packeth->flags = tvb_get_uint8(tvb, offset);
1756
0
  proto_tree_add_bitmask(batadv_iv_ogm_tree, tvb, offset,
1757
0
             hf_batadv_iv_ogm_flags, ett_batadv_iv_ogm_flags,
1758
0
             flags, ENC_NA);
1759
0
  offset += 1;
1760
1761
0
  proto_tree_add_item_ret_uint(batadv_iv_ogm_tree, hf_batadv_iv_ogm_seqno,
1762
0
             tvb, offset, 4, ENC_BIG_ENDIAN,
1763
0
             &iv_ogm_packeth->seqno);
1764
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", iv_ogm_packeth->seqno);
1765
0
  offset += 4;
1766
1767
0
  set_address_tvb(&iv_ogm_packeth->orig, AT_ETHER, 6, tvb, offset);
1768
0
  set_address_tvb(&pinfo->dl_src, AT_ETHER, 6, tvb, offset);
1769
0
  set_address_tvb(&pinfo->src, AT_ETHER, 6, tvb, offset);
1770
0
  proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_orig, tvb,
1771
0
          offset, 6, ENC_NA);
1772
0
  offset += 6;
1773
1774
0
  set_address_tvb(&iv_ogm_packeth->prev_sender, AT_ETHER, 6, tvb, offset);
1775
0
  proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_prev_sender, tvb,
1776
0
          offset, 6, ENC_NA);
1777
0
  offset += 6;
1778
1779
  /* Skip 1 byte of padding. */
1780
0
  iv_ogm_packeth->reserved = tvb_get_uint8(tvb, offset);
1781
0
  offset += 1;
1782
1783
0
  iv_ogm_packeth->tq = tvb_get_uint8(tvb, offset);
1784
0
  proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_tq, tvb,
1785
0
          offset, 1, ENC_BIG_ENDIAN);
1786
0
  offset += 1;
1787
1788
0
  iv_ogm_packeth->tvlv_len = tvb_get_ntohs(tvb, offset);
1789
0
  proto_item_set_len(ti, IV_OGM_PACKET_V15_SIZE + iv_ogm_packeth->tvlv_len);
1790
0
  proto_tree_add_item(batadv_iv_ogm_tree, hf_batadv_iv_ogm_tvlv_len, tvb,
1791
0
          offset, 2, ENC_BIG_ENDIAN);
1792
0
  offset += 2;
1793
1794
0
  tap_queue_packet(batadv_tap, pinfo, iv_ogm_packeth);
1795
1796
0
  if (iv_ogm_packeth->tvlv_len > 0) {
1797
0
    next_tvb = tvb_new_subset_length(tvb, offset,
1798
0
             iv_ogm_packeth->tvlv_len);
1799
1800
0
    if (have_tap_listener(batadv_follow_tap)) {
1801
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1802
0
    }
1803
1804
0
    dissect_batadv_tvlv_v15(next_tvb, pinfo, batadv_iv_ogm_tree);
1805
0
    offset += iv_ogm_packeth->tvlv_len;
1806
0
  }
1807
1808
0
  return offset;
1809
0
}
1810
1811
static void dissect_batadv_tt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1812
1.53k
{
1813
1.53k
  proto_tree *batadv_batman_tt_tree;
1814
1.53k
  proto_item *ti;
1815
1816
  /* Set tree info */
1817
1.53k
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, 6,
1818
1.53k
              "B.A.T.M.A.N. TT: %s",
1819
1.53k
              tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 0));
1820
1.53k
  batadv_batman_tt_tree = proto_item_add_subtree(ti, ett_batadv_batman_tt);
1821
1822
1.53k
  proto_tree_add_item(batadv_batman_tt_tree, hf_batadv_batman_tt, tvb, 0, 6, ENC_NA);
1823
1.53k
}
1824
1825
static void dissect_batadv_bcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1826
1
{
1827
1
  uint8_t version;
1828
1829
  /* set protocol name */
1830
1
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_BCAST");
1831
1832
1
  version = tvb_get_uint8(tvb, 1);
1833
1
  switch (version) {
1834
0
  case 6:
1835
0
  case 7:
1836
0
  case 8:
1837
0
  case 9:
1838
0
    dissect_batadv_bcast_v6(tvb, pinfo, tree);
1839
0
    break;
1840
0
  case 10:
1841
0
  case 11:
1842
0
  case 12:
1843
0
  case 13:
1844
0
    dissect_batadv_bcast_v10(tvb, pinfo, tree);
1845
0
    break;
1846
0
  case 14:
1847
0
  case 15:
1848
0
    dissect_batadv_bcast_v14(tvb, pinfo, tree);
1849
0
    break;
1850
1
  default:
1851
1
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
1852
1
    call_data_dissector(tvb, pinfo, tree);
1853
1
    break;
1854
1
  }
1855
1
}
1856
1857
static void dissect_batadv_bcast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1858
0
{
1859
0
  struct bcast_packet_v6 *bcast_packeth;
1860
1861
0
  tvbuff_t *next_tvb;
1862
0
  int length_remaining;
1863
0
  unsigned offset = 0;
1864
0
  proto_tree *batadv_bcast_tree;
1865
0
  proto_item *ti;
1866
1867
0
  bcast_packeth = wmem_new(pinfo->pool, struct bcast_packet_v6);
1868
1869
0
  bcast_packeth->version = tvb_get_uint8(tvb, 1);
1870
0
  set_address_tvb(&bcast_packeth->orig, AT_ETHER, 6, tvb, 2);
1871
0
  copy_address_shallow(&pinfo->dl_src, &bcast_packeth->orig);
1872
0
  copy_address_shallow(&pinfo->src, &bcast_packeth->orig);
1873
0
  bcast_packeth->seqno = tvb_get_ntohs(tvb, 8);
1874
1875
  /* Set info column */
1876
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", bcast_packeth->seqno);
1877
1878
  /* Set tree info */
1879
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, BCAST_PACKET_V6_SIZE,
1880
0
                "B.A.T.M.A.N. Bcast, Orig: %s",
1881
0
                address_with_resolution_to_str(pinfo->pool, &bcast_packeth->orig));
1882
0
  batadv_bcast_tree = proto_item_add_subtree(ti, ett_batadv_bcast);
1883
1884
  /* items */
1885
0
  proto_tree_add_uint_format(batadv_bcast_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_BCAST_V5,
1886
0
          "Packet Type: %s (%u)", "BATADV_BCAST", BATADV_BCAST_V5);
1887
0
  offset += 1;
1888
1889
0
  proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1890
0
  offset += 1;
1891
1892
0
  proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_orig, tvb, offset, 6, ENC_NA);
1893
0
  offset += 6;
1894
1895
0
  proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
1896
0
  offset += 2;
1897
1898
0
  tap_queue_packet(batadv_tap, pinfo, bcast_packeth);
1899
1900
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
1901
0
  if (length_remaining > 0) {
1902
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
1903
0
    if (have_tap_listener(batadv_follow_tap)) {
1904
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1905
0
    }
1906
1907
0
    call_dissector(eth_handle, next_tvb, pinfo, tree);
1908
0
  }
1909
0
}
1910
1911
static void dissect_batadv_bcast_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1912
0
{
1913
0
  struct bcast_packet_v10 *bcast_packeth;
1914
1915
0
  tvbuff_t *next_tvb;
1916
0
  int length_remaining;
1917
0
  unsigned offset = 0;
1918
0
  proto_tree *batadv_bcast_tree;
1919
0
  proto_item *ti;
1920
1921
0
  bcast_packeth = wmem_new(pinfo->pool, struct bcast_packet_v10);
1922
1923
0
  bcast_packeth->version = tvb_get_uint8(tvb, 1);
1924
0
  set_address_tvb(&bcast_packeth->orig, AT_ETHER, 6, tvb, 2);
1925
0
  copy_address_shallow(&pinfo->dl_src, &bcast_packeth->orig);
1926
0
  copy_address_shallow(&pinfo->src, &bcast_packeth->orig);
1927
0
  bcast_packeth->ttl = tvb_get_uint8(tvb, 8);
1928
0
  bcast_packeth->seqno = tvb_get_ntohl(tvb, 9);
1929
1930
  /* Set info column */
1931
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", bcast_packeth->seqno);
1932
1933
  /* Set tree info */
1934
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, BCAST_PACKET_V10_SIZE,
1935
0
                "B.A.T.M.A.N. Bcast, Orig: %s",
1936
0
                address_with_resolution_to_str(pinfo->pool, &bcast_packeth->orig));
1937
0
  batadv_bcast_tree = proto_item_add_subtree(ti, ett_batadv_bcast);
1938
1939
  /* items */
1940
0
  proto_tree_add_uint_format(batadv_bcast_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_BCAST_V5,
1941
0
          "Packet Type: %s (%u)", "BATADV_BCAST", BATADV_BCAST_V5);
1942
0
  offset += 1;
1943
1944
0
  proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1945
0
  offset += 1;
1946
1947
0
  proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_orig, tvb, offset, 6, ENC_NA);
1948
0
  offset += 6;
1949
1950
0
  proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1951
0
  offset += 1;
1952
1953
0
  proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
1954
0
  offset += 4;
1955
1956
0
  tap_queue_packet(batadv_tap, pinfo, bcast_packeth);
1957
1958
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
1959
0
  if (length_remaining > 0) {
1960
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
1961
1962
0
    if (have_tap_listener(batadv_follow_tap)) {
1963
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
1964
0
    }
1965
1966
0
    call_dissector(eth_handle, next_tvb, pinfo, tree);
1967
0
  }
1968
0
}
1969
1970
static void dissect_batadv_bcast_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1971
0
{
1972
0
  struct bcast_packet_v14 *bcast_packeth;
1973
1974
0
  tvbuff_t *next_tvb;
1975
0
  int length_remaining;
1976
0
  unsigned offset = 0;
1977
0
  proto_tree *batadv_bcast_tree;
1978
0
  proto_item *ti;
1979
1980
0
  bcast_packeth = wmem_new(pinfo->pool, struct bcast_packet_v14);
1981
1982
0
  bcast_packeth->packet_type = tvb_get_uint8(tvb, 0);
1983
0
  bcast_packeth->version = tvb_get_uint8(tvb, 1);
1984
0
  bcast_packeth->ttl = tvb_get_uint8(tvb, 2);
1985
0
  bcast_packeth->reserved = tvb_get_uint8(tvb, 3);
1986
0
  bcast_packeth->seqno = tvb_get_ntohl(tvb, 4);
1987
0
  set_address_tvb(&bcast_packeth->orig, AT_ETHER, 6, tvb, 8);
1988
0
  copy_address_shallow(&pinfo->dl_src, &bcast_packeth->orig);
1989
0
  copy_address_shallow(&pinfo->src, &bcast_packeth->orig);
1990
1991
  /* Set info column */
1992
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", bcast_packeth->seqno);
1993
1994
  /* Set tree info */
1995
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, BCAST_PACKET_V14_SIZE,
1996
0
                "B.A.T.M.A.N. Bcast, Orig: %s",
1997
0
                address_with_resolution_to_str(pinfo->pool, &bcast_packeth->orig));
1998
0
  batadv_bcast_tree = proto_item_add_subtree(ti, ett_batadv_bcast);
1999
2000
  /* items */
2001
0
  proto_tree_add_uint_format_value(batadv_bcast_tree,
2002
0
           hf_batadv_packet_type, tvb, offset, 1,
2003
0
           bcast_packeth->packet_type,
2004
0
           "%s (%u)", "BATADV_BCAST",
2005
0
           bcast_packeth->packet_type);
2006
0
  offset += 1;
2007
2008
0
  proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2009
0
  offset += 1;
2010
2011
0
  proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2012
0
  offset += 1;
2013
2014
  /* Skip 1 byte of padding. */
2015
0
  offset += 1;
2016
2017
0
  proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
2018
0
  offset += 4;
2019
2020
0
  proto_tree_add_item(batadv_bcast_tree, hf_batadv_bcast_orig, tvb, offset, 6, ENC_NA);
2021
0
  offset += 6;
2022
2023
0
  tap_queue_packet(batadv_tap, pinfo, bcast_packeth);
2024
2025
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2026
0
  if (length_remaining > 0) {
2027
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2028
2029
0
    if (have_tap_listener(batadv_follow_tap)) {
2030
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
2031
0
    }
2032
2033
0
    call_dissector(eth_handle, next_tvb, pinfo, tree);
2034
0
  }
2035
0
}
2036
2037
static void dissect_batadv_icmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2038
3
{
2039
3
  uint8_t version;
2040
2041
  /* set protocol name */
2042
3
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_ICMP");
2043
2044
3
  version = tvb_get_uint8(tvb, 1);
2045
3
  switch (version) {
2046
0
  case 6:
2047
0
    dissect_batadv_icmp_v6(tvb, pinfo, tree);
2048
0
    break;
2049
0
  case 7:
2050
0
  case 8:
2051
0
  case 9:
2052
0
  case 10:
2053
0
  case 11:
2054
0
  case 12:
2055
3
  case 13:
2056
3
    dissect_batadv_icmp_v7(tvb, pinfo, tree);
2057
3
    break;
2058
0
  case 14:
2059
0
    dissect_batadv_icmp_v14(tvb, pinfo, tree);
2060
0
    break;
2061
0
  case 15:
2062
0
    dissect_batadv_icmp_v15(tvb, pinfo, tree);
2063
0
    break;
2064
0
  default:
2065
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
2066
0
    call_data_dissector(tvb, pinfo, tree);
2067
0
    break;
2068
3
  }
2069
3
}
2070
2071
static void dissect_batadv_icmp_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2072
0
{
2073
0
  struct icmp_packet_v6 *icmp_packeth;
2074
0
  tvbuff_t *next_tvb;
2075
0
  int length_remaining;
2076
0
  unsigned offset = 0;
2077
0
  proto_tree *batadv_icmp_tree;
2078
0
  proto_item *ti;
2079
2080
0
  icmp_packeth = wmem_new(pinfo->pool, struct icmp_packet_v6);
2081
2082
0
  icmp_packeth->version = tvb_get_uint8(tvb, 1);
2083
0
  icmp_packeth->msg_type = tvb_get_uint8(tvb, 2);
2084
0
  set_address_tvb(&icmp_packeth->dst, AT_ETHER, 6, tvb, 3);
2085
0
  set_address_tvb(&icmp_packeth->orig, AT_ETHER, 6, tvb, 9);
2086
2087
0
  copy_address_shallow(&pinfo->dl_src, &icmp_packeth->orig);
2088
0
  copy_address_shallow(&pinfo->src, &icmp_packeth->orig);
2089
0
  copy_address_shallow(&pinfo->dl_dst, &icmp_packeth->dst);
2090
0
  copy_address_shallow(&pinfo->dst, &icmp_packeth->dst);
2091
2092
0
  icmp_packeth->ttl = tvb_get_uint8(tvb, 15);
2093
0
  icmp_packeth->uid = tvb_get_uint8(tvb, 16);
2094
0
  icmp_packeth->seqno = tvb_get_ntohs(tvb, 17);
2095
2096
  /* Set info column */
2097
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
2098
0
         val_to_str(pinfo->pool, icmp_packeth->msg_type, icmp_packettypenames, "Unknown (0x%02x)"),
2099
0
         icmp_packeth->seqno);
2100
  /* Set tree info */
2101
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, ICMP_PACKET_V6_SIZE,
2102
0
                "B.A.T.M.A.N. ICMP, Orig: %s, Dst: %s",
2103
0
                address_with_resolution_to_str(pinfo->pool, &icmp_packeth->orig),
2104
0
                address_with_resolution_to_str(pinfo->pool, &icmp_packeth->dst));
2105
0
  batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
2106
2107
  /* items */
2108
0
  proto_tree_add_uint_format(batadv_icmp_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_ICMP_V5,
2109
0
          "Packet Type: %s (%u)", "BATADV_ICMP", BATADV_ICMP_V5);
2110
0
  offset += 1;
2111
2112
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2113
0
  offset += 1;
2114
2115
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2116
0
  offset += 1;
2117
2118
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset, 6, ENC_NA);
2119
0
  offset += 6;
2120
2121
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset, 6, ENC_NA);
2122
0
  offset += 6;
2123
2124
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2125
0
  offset += 1;
2126
2127
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset, 1, ENC_BIG_ENDIAN);
2128
0
  offset += 1;
2129
2130
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
2131
0
  offset += 2;
2132
2133
0
  tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
2134
2135
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2136
0
  if (length_remaining > 0) {
2137
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2138
2139
0
    call_data_dissector(next_tvb, pinfo, tree);
2140
0
  }
2141
0
}
2142
2143
static void
2144
dissect_batadv_icmp_rr(packet_info *pinfo, proto_tree *batadv_icmp_tree, tvbuff_t *tvb, unsigned offset)
2145
3
{
2146
3
  proto_tree *field_tree;
2147
3
  int ptr, i;
2148
2149
3
  ptr = tvb_get_uint8(tvb, offset);
2150
3
  if (ptr < 1 || ptr > BAT_RR_LEN)
2151
1
    return;
2152
2153
2
  field_tree = proto_tree_add_subtree(batadv_icmp_tree, tvb, offset, 1+ 6 * BAT_RR_LEN,
2154
2
                    ett_batadv_icmp_rr, NULL, "ICMP RR");
2155
2
  proto_tree_add_item(field_tree, hf_batadv_icmp_rr_pointer, tvb, offset, 1, ENC_BIG_ENDIAN);
2156
2157
2
  ptr--;
2158
2
  offset++;
2159
34
  for (i = 0; i < BAT_RR_LEN; i++) {
2160
32
    proto_tree_add_ether_format(field_tree, hf_batadv_icmp_rr_ether, tvb, offset, 6, tvb_get_ptr(tvb, offset, 6),
2161
32
            "%s%s", (i > ptr) ? "-" : tvb_ether_to_str(pinfo->pool, tvb, offset),
2162
32
            (i == ptr) ? " <- (current)" : "");
2163
2164
32
    offset += 6;
2165
32
  }
2166
2
}
2167
2168
static void
2169
dissect_batadv_icmp_rr_v15(packet_info *pinfo, proto_tree *batadv_icmp_tree, tvbuff_t *tvb,
2170
         unsigned offset, int ptr)
2171
0
{
2172
0
  proto_tree *field_tree;
2173
0
  int i;
2174
2175
0
  field_tree = proto_tree_add_subtree(batadv_icmp_tree, tvb, offset,
2176
0
              6 * BAT_RR_LEN,
2177
0
              ett_batadv_icmp_rr, NULL,
2178
0
              "ICMP RR");
2179
0
  ptr--;
2180
2181
0
  for (i = 0; i < BAT_RR_LEN; i++) {
2182
0
    proto_tree_add_ether_format(field_tree, hf_batadv_icmp_rr_ether,
2183
0
              tvb, offset, 6,
2184
0
              tvb_get_ptr(tvb, offset, 6),
2185
0
              "%s%s",
2186
0
              (i > ptr) ? "-" : tvb_ether_to_str(pinfo->pool, tvb, offset),
2187
0
              (i == ptr) ? " <- (current)" : "");
2188
2189
0
    offset += 6;
2190
0
  }
2191
0
}
2192
2193
static void dissect_batadv_icmp_v7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2194
3
{
2195
3
  struct icmp_packet_v7 *icmp_packeth;
2196
3
  proto_item *ti;
2197
3
  proto_tree *batadv_icmp_tree;
2198
2199
3
  tvbuff_t *next_tvb;
2200
3
  int length_remaining;
2201
3
  unsigned offset = 0;
2202
2203
3
  icmp_packeth = wmem_new(pinfo->pool, struct icmp_packet_v7);
2204
2205
3
  icmp_packeth->version = tvb_get_uint8(tvb, 1);
2206
3
  icmp_packeth->msg_type = tvb_get_uint8(tvb, 2);
2207
3
  icmp_packeth->ttl = tvb_get_uint8(tvb, 3);
2208
3
  set_address_tvb(&icmp_packeth->dst, AT_ETHER, 6, tvb, 4);
2209
3
  set_address_tvb(&icmp_packeth->orig, AT_ETHER, 6, tvb, 10);
2210
2211
3
  copy_address_shallow(&pinfo->dl_src, &icmp_packeth->orig);
2212
3
  copy_address_shallow(&pinfo->src, &icmp_packeth->orig);
2213
3
  copy_address_shallow(&pinfo->dl_dst, &icmp_packeth->dst);
2214
3
  copy_address_shallow(&pinfo->dst, &icmp_packeth->dst);
2215
2216
3
  icmp_packeth->seqno = tvb_get_ntohs(tvb, 16);
2217
3
  icmp_packeth->uid = tvb_get_uint8(tvb, 18);
2218
2219
  /* Set info column */
2220
3
  col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
2221
3
         val_to_str(pinfo->pool, icmp_packeth->msg_type, icmp_packettypenames, "Unknown (0x%02x)"),
2222
3
         icmp_packeth->seqno);
2223
2224
  /* Set tree info */
2225
3
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, ICMP_PACKET_V7_SIZE,
2226
3
              "B.A.T.M.A.N. ICMP, Orig: %s, Dst: %s",
2227
3
              address_with_resolution_to_str(pinfo->pool, &icmp_packeth->orig),
2228
3
              address_with_resolution_to_str(pinfo->pool, &icmp_packeth->dst));
2229
3
  batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
2230
2231
  /* items */
2232
3
  proto_tree_add_uint_format(batadv_icmp_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_ICMP_V5,
2233
3
          "Packet Type: %s (%u)", "BATADV_ICMP", BATADV_ICMP_V5);
2234
3
  offset += 1;
2235
2236
3
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2237
3
  offset += 1;
2238
2239
3
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2240
3
  offset += 1;
2241
2242
3
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2243
3
  offset += 1;
2244
2245
3
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset, 6, ENC_NA);
2246
3
  offset += 6;
2247
2248
3
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset, 6, ENC_NA);
2249
3
  offset += 6;
2250
2251
3
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
2252
3
  offset += 2;
2253
2254
3
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset, 1, ENC_BIG_ENDIAN);
2255
3
  offset += 1;
2256
2257
  /* rr data available? */
2258
3
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2259
3
  if (length_remaining >= 1 + BAT_RR_LEN * 6) {
2260
3
    dissect_batadv_icmp_rr(pinfo, batadv_icmp_tree, tvb, offset);
2261
3
    offset += 1 + BAT_RR_LEN * 6;
2262
3
  }
2263
2264
3
  tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
2265
2266
3
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2267
3
  if (length_remaining > 0) {
2268
3
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2269
3
    call_data_dissector(next_tvb, pinfo, tree);
2270
3
  }
2271
3
}
2272
2273
static void dissect_batadv_icmp_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2274
0
{
2275
0
  struct icmp_packet_v14 *icmp_packeth;
2276
0
  proto_item *ti;
2277
0
  proto_tree *batadv_icmp_tree;
2278
2279
0
  tvbuff_t *next_tvb;
2280
0
  int length_remaining;
2281
0
  unsigned offset = 0;
2282
2283
0
  icmp_packeth = wmem_new(pinfo->pool, struct icmp_packet_v14);
2284
2285
0
  icmp_packeth->version = tvb_get_uint8(tvb, 1);
2286
0
  icmp_packeth->ttl = tvb_get_uint8(tvb, 2);
2287
0
  icmp_packeth->msg_type = tvb_get_uint8(tvb, 3);
2288
0
  set_address_tvb(&icmp_packeth->dst, AT_ETHER, 6, tvb, 4);
2289
0
  set_address_tvb(&icmp_packeth->orig, AT_ETHER, 6, tvb, 10);
2290
2291
0
  copy_address_shallow(&pinfo->dl_src, &icmp_packeth->orig);
2292
0
  copy_address_shallow(&pinfo->src, &icmp_packeth->orig);
2293
0
  copy_address_shallow(&pinfo->dl_dst, &icmp_packeth->dst);
2294
0
  copy_address_shallow(&pinfo->dst, &icmp_packeth->dst);
2295
2296
0
  icmp_packeth->seqno = tvb_get_ntohs(tvb, 16);
2297
0
  icmp_packeth->uid = tvb_get_uint8(tvb, 18);
2298
0
  icmp_packeth->reserved = tvb_get_uint8(tvb, 19);
2299
2300
  /* Set info column */
2301
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
2302
0
         val_to_str(pinfo->pool, icmp_packeth->msg_type, icmp_packettypenames, "Unknown (0x%02x)"),
2303
0
         icmp_packeth->seqno);
2304
2305
  /* Set tree info */
2306
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, ICMP_PACKET_V14_SIZE,
2307
0
              "B.A.T.M.A.N. ICMP, Orig: %s, Dst: %s",
2308
0
              address_with_resolution_to_str(pinfo->pool, &icmp_packeth->orig),
2309
0
              address_with_resolution_to_str(pinfo->pool, &icmp_packeth->dst));
2310
0
  batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
2311
2312
  /* items */
2313
0
  proto_tree_add_uint_format(batadv_icmp_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_ICMP_V5,
2314
0
          "Packet Type: %s (%u)", "BATADV_ICMP", BATADV_ICMP_V5);
2315
0
  offset += 1;
2316
2317
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2318
0
  offset += 1;
2319
2320
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2321
0
  offset += 1;
2322
2323
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2324
0
  offset += 1;
2325
2326
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset, 6, ENC_NA);
2327
0
  offset += 6;
2328
2329
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset, 6, ENC_NA);
2330
0
  offset += 6;
2331
2332
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
2333
0
  offset += 2;
2334
2335
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset, 1, ENC_BIG_ENDIAN);
2336
0
  offset += 1;
2337
2338
  /* Skip 1 byte of padding. */
2339
0
  offset += 1;
2340
2341
  /* rr data available? */
2342
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2343
0
  if (length_remaining >= 1 + BAT_RR_LEN * 6) {
2344
0
    dissect_batadv_icmp_rr(pinfo, batadv_icmp_tree, tvb, offset);
2345
0
    offset += 1 + BAT_RR_LEN * 6;
2346
0
  }
2347
2348
0
  tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
2349
2350
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2351
0
  if (length_remaining > 0) {
2352
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2353
0
    call_data_dissector(next_tvb, pinfo, tree);
2354
0
  }
2355
0
}
2356
2357
static void dissect_batadv_icmp_tp_v15(tvbuff_t *tvb, packet_info *pinfo,
2358
               proto_tree *tree)
2359
0
{
2360
0
  struct icmp_tp_packet_v15 *icmp_packeth;
2361
0
  proto_item *ti;
2362
0
  proto_tree *batadv_icmp_tree = NULL;
2363
2364
0
  tvbuff_t *next_tvb;
2365
0
  int length_remaining;
2366
0
  uint32_t msg_type;
2367
0
  unsigned offset = 0;
2368
2369
0
  icmp_packeth = wmem_new(pinfo->pool, struct icmp_tp_packet_v15);
2370
2371
  /* Set info column */
2372
0
  col_clear(pinfo->cinfo, COL_INFO);
2373
2374
  /* Set tree info */
2375
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
2376
0
              tvb, 0, ICMP_PACKET_V14_SIZE,
2377
0
              "B.A.T.M.A.N. ICMP TP, Orig: %s, Dst: %s",
2378
0
              tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 10),
2379
0
              tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 4));
2380
0
  batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
2381
2382
  /* items */
2383
0
  icmp_packeth->packet_type = tvb_get_uint8(tvb, offset);
2384
0
  proto_tree_add_uint_format_value(batadv_icmp_tree,
2385
0
           hf_batadv_packet_type, tvb,
2386
0
           offset, 1, icmp_packeth->packet_type,
2387
0
           "%s (%u)", "BATADV_ICMP",
2388
0
           icmp_packeth->packet_type);
2389
0
  offset += 1;
2390
2391
0
  icmp_packeth->version = tvb_get_uint8(tvb, offset);
2392
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb,
2393
0
          offset, 1, ENC_BIG_ENDIAN);
2394
0
  offset += 1;
2395
2396
0
  icmp_packeth->ttl = tvb_get_uint8(tvb, offset);
2397
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset,
2398
0
          1, ENC_BIG_ENDIAN);
2399
0
  offset += 1;
2400
2401
0
  icmp_packeth->msg_type = tvb_get_uint8(tvb, offset);
2402
0
  proto_tree_add_item_ret_uint(batadv_icmp_tree, hf_batadv_icmp_msg_type,
2403
0
             tvb, offset, 1, ENC_BIG_ENDIAN, &msg_type);
2404
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "[%s]",
2405
0
         val_to_str(pinfo->pool, msg_type, icmp_packettypenames,
2406
0
        "Unknown (0x%02x)"));
2407
0
  offset += 1;
2408
2409
0
  set_address_tvb(&icmp_packeth->dst, AT_ETHER, 6, tvb, offset);
2410
0
  copy_address_shallow(&pinfo->dl_dst, &icmp_packeth->dst);
2411
0
  copy_address_shallow(&pinfo->dst, &icmp_packeth->dst);
2412
2413
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset,
2414
0
          6, ENC_NA);
2415
0
  offset += 6;
2416
2417
0
  set_address_tvb(&icmp_packeth->orig, AT_ETHER, 6, tvb, offset);
2418
0
  copy_address_shallow(&pinfo->dl_src, &icmp_packeth->orig);
2419
0
  copy_address_shallow(&pinfo->src, &icmp_packeth->orig);
2420
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset,
2421
0
          6, ENC_NA);
2422
0
  offset += 6;
2423
2424
0
  icmp_packeth->uid = tvb_get_uint8(tvb, offset);
2425
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset,
2426
0
          1, ENC_BIG_ENDIAN);
2427
0
  offset += 1;
2428
2429
0
  icmp_packeth->subtype = tvb_get_uint8(tvb, offset);
2430
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_tp_subtype, tvb,
2431
0
          offset, 1, ENC_BIG_ENDIAN);
2432
0
  offset += 1;
2433
2434
0
  icmp_packeth->session = tvb_get_ntohs(tvb, offset);
2435
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_tp_session, tvb,
2436
0
          offset, 2, ENC_BIG_ENDIAN);
2437
0
  offset += 2;
2438
2439
0
  proto_tree_add_item_ret_uint(batadv_icmp_tree, hf_batadv_icmp_tp_seqno,
2440
0
             tvb, offset, 4, ENC_BIG_ENDIAN,
2441
0
             &icmp_packeth->seqno);
2442
0
  col_append_fstr(pinfo->cinfo, COL_INFO, " Seq=%u", icmp_packeth->seqno);
2443
0
  offset += 4;
2444
2445
0
  icmp_packeth->timestamp = tvb_get_ntohl(tvb, offset);
2446
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_tp_timestamp, tvb,
2447
0
          offset, 4, ENC_BIG_ENDIAN);
2448
0
  offset += 4;
2449
2450
0
  tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
2451
2452
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2453
0
  if (length_remaining > 0) {
2454
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2455
0
    call_data_dissector(next_tvb, pinfo, tree);
2456
0
  }
2457
0
}
2458
2459
static void dissect_batadv_icmp_simple_v15(tvbuff_t *tvb, packet_info *pinfo,
2460
             proto_tree *tree)
2461
0
{
2462
0
  struct icmp_packet_v15 *icmp_packeth;
2463
0
  proto_item *ti;
2464
0
  proto_tree *batadv_icmp_tree;
2465
2466
0
  tvbuff_t *next_tvb;
2467
0
  int length_remaining;
2468
0
  uint32_t msg_type;
2469
0
  unsigned offset = 0;
2470
0
  uint32_t seqno;
2471
2472
0
  icmp_packeth = wmem_new(pinfo->pool, struct icmp_packet_v15);
2473
2474
  /* Set info column */
2475
0
  col_clear(pinfo->cinfo, COL_INFO);
2476
2477
  /* Set tree info */
2478
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
2479
0
              tvb, 0, ICMP_PACKET_V14_SIZE,
2480
0
              "B.A.T.M.A.N. ICMP, Orig: %s, Dst: %s",
2481
0
              tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 10),
2482
0
              tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 4));
2483
0
  batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
2484
2485
  /* items */
2486
0
  icmp_packeth->packet_type = tvb_get_uint8(tvb, offset);
2487
0
  proto_tree_add_uint_format_value(batadv_icmp_tree,
2488
0
           hf_batadv_packet_type, tvb,
2489
0
           offset, 1, icmp_packeth->packet_type,
2490
0
           "%s (%u)", "BATADV_ICMP",
2491
0
           icmp_packeth->packet_type);
2492
0
  offset += 1;
2493
2494
0
  icmp_packeth->version = tvb_get_uint8(tvb, offset);
2495
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_version, tvb,
2496
0
          offset, 1, ENC_BIG_ENDIAN);
2497
0
  offset += 1;
2498
2499
0
  icmp_packeth->ttl = tvb_get_uint8(tvb, offset);
2500
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_ttl, tvb, offset,
2501
0
          1, ENC_BIG_ENDIAN);
2502
0
  offset += 1;
2503
2504
0
  icmp_packeth->msg_type = tvb_get_uint8(tvb, offset);
2505
0
  proto_tree_add_item_ret_uint(batadv_icmp_tree, hf_batadv_icmp_msg_type,
2506
0
             tvb, offset, 1, ENC_BIG_ENDIAN, &msg_type);
2507
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "[%s]",
2508
0
         val_to_str(pinfo->pool, msg_type, icmp_packettypenames,
2509
0
        "Unknown (0x%02x)"));
2510
0
  offset += 1;
2511
2512
0
  set_address_tvb(&icmp_packeth->dst, AT_ETHER, 6, tvb, offset);
2513
0
  copy_address_shallow(&pinfo->dl_dst, &icmp_packeth->dst);
2514
0
  copy_address_shallow(&pinfo->dst, &icmp_packeth->dst);
2515
2516
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_dst, tvb, offset,
2517
0
          6, ENC_NA);
2518
0
  offset += 6;
2519
2520
0
  set_address_tvb(&icmp_packeth->orig, AT_ETHER, 6, tvb, offset);
2521
0
  copy_address_shallow(&pinfo->dl_src, &icmp_packeth->orig);
2522
0
  copy_address_shallow(&pinfo->src, &icmp_packeth->orig);
2523
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_orig, tvb, offset,
2524
0
          6, ENC_NA);
2525
0
  offset += 6;
2526
2527
0
  icmp_packeth->uid = tvb_get_uint8(tvb, offset);
2528
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_uid, tvb, offset,
2529
0
          1, ENC_BIG_ENDIAN);
2530
0
  offset += 1;
2531
2532
0
  icmp_packeth->rr_ptr = tvb_get_uint8(tvb, offset);
2533
0
  proto_tree_add_item(batadv_icmp_tree, hf_batadv_icmp_rr_pointer, tvb,
2534
0
          offset, 1, ENC_BIG_ENDIAN);
2535
0
  offset += 1;
2536
2537
0
  icmp_packeth->seqno = tvb_get_ntohs(tvb, offset);
2538
0
  proto_tree_add_item_ret_uint(batadv_icmp_tree, hf_batadv_icmp_seqno,
2539
0
             tvb, offset, 2, ENC_BIG_ENDIAN, &seqno);
2540
0
  col_append_fstr(pinfo->cinfo, COL_INFO, " Seq=%u", seqno);
2541
0
  offset += 2;
2542
2543
  /* rr data available? */
2544
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2545
0
  if (length_remaining >= BAT_RR_LEN * 6) {
2546
0
    dissect_batadv_icmp_rr_v15(pinfo, batadv_icmp_tree, tvb, offset,
2547
0
             icmp_packeth->rr_ptr);
2548
0
    offset += BAT_RR_LEN * 6;
2549
0
  }
2550
2551
0
  tap_queue_packet(batadv_tap, pinfo, icmp_packeth);
2552
2553
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2554
0
  if (length_remaining > 0) {
2555
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2556
0
    call_data_dissector(next_tvb, pinfo, tree);
2557
0
  }
2558
0
}
2559
2560
static void dissect_batadv_icmp_v15(tvbuff_t *tvb, packet_info *pinfo,
2561
            proto_tree *tree)
2562
0
{
2563
0
  uint8_t msg_type;
2564
2565
0
  msg_type = tvb_get_uint8(tvb, 3);
2566
0
  switch (msg_type) {
2567
0
  case BATADV_TP:
2568
0
    dissect_batadv_icmp_tp_v15(tvb, pinfo, tree);
2569
0
    break;
2570
0
  default:
2571
0
    dissect_batadv_icmp_simple_v15(tvb, pinfo, tree);
2572
0
    break;
2573
0
  }
2574
0
}
2575
2576
static void dissect_batadv_unicast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2577
0
{
2578
0
  uint8_t version;
2579
2580
  /* set protocol name */
2581
0
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_UNICAST");
2582
2583
0
  version = tvb_get_uint8(tvb, 1);
2584
0
  switch (version) {
2585
0
  case 6:
2586
0
  case 7:
2587
0
  case 8:
2588
0
  case 9:
2589
0
  case 10:
2590
0
  case 11:
2591
0
  case 12:
2592
0
  case 13:
2593
0
    dissect_batadv_unicast_v6(tvb, pinfo, tree);
2594
0
    break;
2595
0
  case 14:
2596
0
  case 15:
2597
0
    dissect_batadv_unicast_v14(tvb, pinfo, tree);
2598
0
    break;
2599
0
  default:
2600
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
2601
0
    call_data_dissector(tvb, pinfo, tree);
2602
0
    break;
2603
0
  }
2604
0
}
2605
2606
static void dissect_batadv_unicast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2607
0
{
2608
0
  struct unicast_packet_v6 *unicast_packeth;
2609
2610
0
  tvbuff_t *next_tvb;
2611
0
  int length_remaining;
2612
0
  unsigned offset = 0;
2613
0
  proto_tree *batadv_unicast_tree;
2614
0
  proto_item *ti;
2615
2616
0
  unicast_packeth = wmem_new(pinfo->pool, struct unicast_packet_v6);
2617
2618
0
  unicast_packeth->version = tvb_get_uint8(tvb, 1);
2619
0
  set_address_tvb(&unicast_packeth->dest, AT_ETHER, 6, tvb, 2);
2620
0
  copy_address_shallow(&pinfo->dl_dst, &unicast_packeth->dest);
2621
0
  copy_address_shallow(&pinfo->dst, &unicast_packeth->dest);
2622
2623
0
  unicast_packeth->ttl = tvb_get_uint8(tvb, 8);
2624
2625
  /* Set info column */
2626
0
  col_clear(pinfo->cinfo, COL_INFO);
2627
2628
  /* Set tree info */
2629
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, UNICAST_PACKET_V6_SIZE,
2630
0
                "B.A.T.M.A.N. Unicast, Dst: %s",
2631
0
                address_with_resolution_to_str(pinfo->pool, &unicast_packeth->dest));
2632
0
  batadv_unicast_tree = proto_item_add_subtree(ti, ett_batadv_unicast);
2633
2634
  /* items */
2635
0
  proto_tree_add_uint_format(batadv_unicast_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_UNICAST_V5,
2636
0
          "Packet Type: %s (%u)", "BATADV_UNICAST", BATADV_UNICAST_V5);
2637
0
  offset += 1;
2638
2639
0
  proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2640
0
  offset += 1;
2641
2642
0
  proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_dst, tvb, offset, 6, ENC_NA);
2643
0
  offset += 6;
2644
2645
0
  proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2646
0
  offset += 1;
2647
2648
0
  tap_queue_packet(batadv_tap, pinfo, unicast_packeth);
2649
2650
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2651
0
  if (length_remaining > 0) {
2652
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2653
2654
0
    if (have_tap_listener(batadv_follow_tap)) {
2655
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
2656
0
    }
2657
2658
0
    call_dissector(eth_handle, next_tvb, pinfo, tree);
2659
0
  }
2660
0
}
2661
2662
static void dissect_batadv_unicast_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2663
0
{
2664
0
  struct unicast_packet_v14 *unicast_packeth;
2665
2666
0
  tvbuff_t *next_tvb;
2667
0
  int length_remaining;
2668
0
  unsigned offset = 0;
2669
0
  proto_tree *batadv_unicast_tree;
2670
0
  proto_item *ti;
2671
2672
0
  unicast_packeth = wmem_new(pinfo->pool, struct unicast_packet_v14);
2673
2674
0
  unicast_packeth->packet_type = tvb_get_uint8(tvb, 0);
2675
0
  unicast_packeth->version = tvb_get_uint8(tvb, 1);
2676
0
  unicast_packeth->ttl = tvb_get_uint8(tvb, 2);
2677
0
  unicast_packeth->ttvn = tvb_get_uint8(tvb, 3);
2678
0
  set_address_tvb(&unicast_packeth->dest, AT_ETHER, 6, tvb, 4);
2679
0
  copy_address_shallow(&pinfo->dl_dst, &unicast_packeth->dest);
2680
0
  copy_address_shallow(&pinfo->dst, &unicast_packeth->dest);
2681
2682
  /* Set info column */
2683
0
  col_clear(pinfo->cinfo, COL_INFO);
2684
2685
  /* Set tree info */
2686
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, UNICAST_PACKET_V14_SIZE,
2687
0
                "B.A.T.M.A.N. Unicast, Dst: %s",
2688
0
                address_with_resolution_to_str(pinfo->pool, &unicast_packeth->dest));
2689
0
  batadv_unicast_tree = proto_item_add_subtree(ti, ett_batadv_unicast);
2690
2691
  /* items */
2692
0
  proto_tree_add_uint_format_value(batadv_unicast_tree,
2693
0
           hf_batadv_packet_type, tvb, offset, 1,
2694
0
           unicast_packeth->packet_type,
2695
0
           "%s (%u)",
2696
0
           "BATADV_UNICAST",
2697
0
           unicast_packeth->packet_type);
2698
0
  offset += 1;
2699
2700
0
  proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2701
0
  offset += 1;
2702
2703
0
  proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2704
0
  offset += 1;
2705
2706
0
  proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_ttvn, tvb, offset, 1, ENC_BIG_ENDIAN);
2707
0
  offset += 1;
2708
2709
0
  proto_tree_add_item(batadv_unicast_tree, hf_batadv_unicast_dst, tvb, offset, 6, ENC_NA);
2710
0
  offset += 6;
2711
2712
0
  tap_queue_packet(batadv_tap, pinfo, unicast_packeth);
2713
2714
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2715
0
  if (length_remaining > 0) {
2716
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2717
2718
0
    if (have_tap_listener(batadv_follow_tap)) {
2719
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
2720
0
    }
2721
2722
0
    call_dissector(eth_handle, next_tvb, pinfo, tree);
2723
0
  }
2724
0
}
2725
2726
static void dissect_batadv_unicast_4addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2727
0
{
2728
0
  uint8_t version;
2729
2730
  /* set protocol name */
2731
0
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_UNICAST_4ADDR");
2732
2733
0
  version = tvb_get_uint8(tvb, 1);
2734
0
  switch (version) {
2735
0
  case 14:
2736
0
  case 15:
2737
0
    dissect_batadv_unicast_4addr_v14(tvb, pinfo, tree);
2738
0
    break;
2739
0
  default:
2740
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
2741
0
    call_data_dissector(tvb, pinfo, tree);
2742
0
    break;
2743
0
  }
2744
0
}
2745
2746
static void dissect_batadv_unicast_4addr_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2747
0
{
2748
0
  struct unicast_4addr_packet_v14 *unicast_4addr_packeth;
2749
2750
0
  tvbuff_t *next_tvb;
2751
0
  int length_remaining;
2752
0
  unsigned offset = 0;
2753
0
  proto_tree *batadv_unicast_4addr_tree;
2754
0
  proto_item *ti;
2755
2756
0
  unicast_4addr_packeth = wmem_new(pinfo->pool, struct unicast_4addr_packet_v14);
2757
2758
0
  unicast_4addr_packeth->packet_type = tvb_get_uint8(tvb, 0);
2759
0
  unicast_4addr_packeth->version = tvb_get_uint8(tvb, 1);
2760
0
  unicast_4addr_packeth->ttl = tvb_get_uint8(tvb, 2);
2761
0
  unicast_4addr_packeth->ttvn = tvb_get_uint8(tvb, 3);
2762
0
  set_address_tvb(&unicast_4addr_packeth->dest, AT_ETHER, 6, tvb, 4);
2763
0
  copy_address_shallow(&pinfo->dl_dst, &unicast_4addr_packeth->dest);
2764
0
  copy_address_shallow(&pinfo->dst, &unicast_4addr_packeth->dest);
2765
2766
0
  set_address_tvb(&unicast_4addr_packeth->src, AT_ETHER, 6, tvb, 10);
2767
0
  copy_address_shallow(&pinfo->dl_src, &unicast_4addr_packeth->src);
2768
0
  copy_address_shallow(&pinfo->src, &unicast_4addr_packeth->src);
2769
0
  unicast_4addr_packeth->subtype = tvb_get_uint8(tvb, 16);
2770
0
  unicast_4addr_packeth->reserved = tvb_get_uint8(tvb, 17);
2771
2772
  /* Set info column */
2773
0
  col_add_str(pinfo->cinfo, COL_INFO,
2774
0
         val_to_str(pinfo->pool, unicast_4addr_packeth->subtype, unicast_4addr_typenames, "Unknown (0x%02x)"));
2775
2776
  /* Set tree info */
2777
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, UNICAST_4ADDR_PACKET_V14_SIZE,
2778
0
              "B.A.T.M.A.N. Unicast 4Addr, Dst: %s",
2779
0
              address_with_resolution_to_str(pinfo->pool, &unicast_4addr_packeth->dest));
2780
0
  batadv_unicast_4addr_tree = proto_item_add_subtree(ti, ett_batadv_unicast_4addr);
2781
2782
  /* items */
2783
0
  proto_tree_add_uint_format_value(batadv_unicast_4addr_tree,
2784
0
           hf_batadv_packet_type, tvb, offset, 1,
2785
0
           unicast_4addr_packeth->packet_type,
2786
0
          "%s (%u)", "BATADV_UNICAST_4ADDR",
2787
0
           unicast_4addr_packeth->packet_type);
2788
0
  offset += 1;
2789
2790
0
  proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2791
0
  offset += 1;
2792
2793
0
  proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2794
0
  offset += 1;
2795
2796
0
  proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_ttvn, tvb, offset, 1, ENC_BIG_ENDIAN);
2797
0
  offset += 1;
2798
2799
0
  proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_dst, tvb, offset, 6, ENC_NA);
2800
0
  offset += 6;
2801
2802
0
  proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_src, tvb, offset, 6, ENC_NA);
2803
0
  offset += 6;
2804
2805
0
  proto_tree_add_item(batadv_unicast_4addr_tree, hf_batadv_unicast_4addr_subtype, tvb, offset, 1, ENC_BIG_ENDIAN);
2806
0
  offset += 1;
2807
2808
  /* Skip 1 byte of padding. */
2809
0
  offset += 1;
2810
2811
0
  tap_queue_packet(batadv_tap, pinfo, unicast_4addr_packeth);
2812
2813
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2814
0
  if (length_remaining > 0) {
2815
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2816
2817
0
    if (have_tap_listener(batadv_follow_tap)) {
2818
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
2819
0
    }
2820
2821
0
    call_dissector(eth_handle, next_tvb, pinfo, tree);
2822
0
  }
2823
0
}
2824
2825
static void dissect_batadv_unicast_frag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2826
1
{
2827
1
  uint8_t version;
2828
2829
  /* set protocol name */
2830
1
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_UNICAST_FRAG");
2831
2832
1
  version = tvb_get_uint8(tvb, 1);
2833
1
  switch (version) {
2834
0
  case 12:
2835
0
  case 13:
2836
0
    dissect_batadv_unicast_frag_v12(tvb, pinfo, tree);
2837
0
    break;
2838
0
  case 14:
2839
0
    dissect_batadv_unicast_frag_v14(tvb, pinfo, tree);
2840
0
    break;
2841
0
  case 15:
2842
0
    dissect_batadv_unicast_frag_v15(tvb, pinfo, tree);
2843
0
    break;
2844
1
  default:
2845
1
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
2846
1
    call_data_dissector(tvb, pinfo, tree);
2847
1
    break;
2848
1
  }
2849
1
}
2850
2851
static void dissect_batadv_unicast_frag_v12(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2852
0
{
2853
0
  struct unicast_frag_packet_v12 *unicast_frag_packeth;
2854
0
  bool save_fragmented;
2855
0
  fragment_head *frag_msg = NULL;
2856
0
  proto_tree *batadv_unicast_frag_tree;
2857
0
  proto_item *ti;
2858
2859
0
  tvbuff_t *new_tvb;
2860
0
  unsigned offset = 0;
2861
0
  int head = 0;
2862
0
  int length_remaining;
2863
2864
0
  unicast_frag_packeth = wmem_new(pinfo->pool, struct unicast_frag_packet_v12);
2865
2866
0
  unicast_frag_packeth->version = tvb_get_uint8(tvb, 1);
2867
0
  set_address_tvb(&unicast_frag_packeth->dest, AT_ETHER, 6, tvb, 2);
2868
0
  copy_address_shallow(&pinfo->dl_dst, &unicast_frag_packeth->dest);
2869
0
  copy_address_shallow(&pinfo->dst, &unicast_frag_packeth->dest);
2870
0
  unicast_frag_packeth->ttl = tvb_get_uint8(tvb, 8);
2871
0
  unicast_frag_packeth->flags = tvb_get_uint8(tvb, 9);
2872
0
  set_address_tvb(&unicast_frag_packeth->orig, AT_ETHER, 6, tvb, 10);
2873
0
  copy_address_shallow(&pinfo->dl_src, &unicast_frag_packeth->orig);
2874
0
  copy_address_shallow(&pinfo->src, &unicast_frag_packeth->orig);
2875
0
  unicast_frag_packeth->seqno = tvb_get_ntohs(tvb, 16);
2876
2877
0
  save_fragmented = pinfo->fragmented;
2878
0
  pinfo->fragmented = true;
2879
2880
  /* Set info column */
2881
0
  col_clear(pinfo->cinfo, COL_INFO);
2882
2883
  /* Set tree info */
2884
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, UNICAST_FRAG_PACKET_V12_SIZE,
2885
0
                "B.A.T.M.A.N. Unicast Fragment, Dst: %s",
2886
0
                address_with_resolution_to_str(pinfo->pool, &unicast_frag_packeth->dest));
2887
0
  batadv_unicast_frag_tree = proto_item_add_subtree(ti, ett_batadv_unicast_frag);
2888
2889
  /* items */
2890
0
  proto_tree_add_uint_format(batadv_unicast_frag_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_UNICAST_FRAG_V12,
2891
0
          "Packet Type: %s (%u)", "BATADV_UNICAST_FRAG", BATADV_UNICAST_FRAG_V12);
2892
0
  offset += 1;
2893
2894
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2895
0
  offset += 1;
2896
2897
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_dst, tvb, offset, 6, ENC_NA);
2898
0
  offset += 6;
2899
2900
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2901
0
  offset += 1;
2902
2903
0
  proto_tree_add_bitmask(batadv_unicast_frag_tree, tvb, offset, hf_batadv_unicast_frag_flags,
2904
0
          ett_batadv_batman_flags, unicast_frag_flags, ENC_BIG_ENDIAN);
2905
0
  offset += 1;
2906
2907
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_orig, tvb, offset, 6, ENC_NA);
2908
0
  offset += 6;
2909
2910
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
2911
0
  offset += 2;
2912
2913
0
  tap_queue_packet(batadv_tap, pinfo, unicast_frag_packeth);
2914
2915
0
  head = (unicast_frag_packeth->flags & 0x1);
2916
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
2917
0
  if (length_remaining < 0)
2918
0
    length_remaining = 0;
2919
0
  frag_msg = fragment_add_seq_check(&msg_reassembly_table,
2920
0
    tvb, offset,
2921
0
    pinfo, unicast_frag_packeth->seqno + head, NULL,
2922
0
    1 - head,
2923
0
    length_remaining,
2924
0
    head);
2925
2926
0
  new_tvb = process_reassembled_data(tvb, offset, pinfo,
2927
0
    "Reassembled Message", frag_msg, &msg_frag_items,
2928
0
    NULL, batadv_unicast_frag_tree);
2929
0
  if (new_tvb) {
2930
0
    if (have_tap_listener(batadv_follow_tap)) {
2931
0
      tap_queue_packet(batadv_follow_tap, pinfo, new_tvb);
2932
0
    }
2933
2934
0
    call_dissector(eth_handle, new_tvb, pinfo, tree);
2935
0
  }
2936
2937
0
  pinfo->fragmented = save_fragmented;
2938
0
}
2939
2940
static void dissect_batadv_unicast_frag_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2941
0
{
2942
0
  struct unicast_frag_packet_v14 *unicast_frag_packeth;
2943
0
  bool save_fragmented;
2944
0
  fragment_head *frag_msg = NULL;
2945
0
  proto_tree *batadv_unicast_frag_tree;
2946
0
  proto_item *ti;
2947
2948
0
  tvbuff_t *new_tvb;
2949
0
  unsigned offset = 0;
2950
0
  int head = 0;
2951
0
  int length_remaining;
2952
2953
0
  unicast_frag_packeth = wmem_new(pinfo->pool, struct unicast_frag_packet_v14);
2954
2955
0
  unicast_frag_packeth->version = tvb_get_uint8(tvb, 1);
2956
0
  unicast_frag_packeth->ttl = tvb_get_uint8(tvb, 2);
2957
0
  unicast_frag_packeth->ttvn = tvb_get_uint8(tvb, 3);
2958
0
  set_address_tvb(&unicast_frag_packeth->dest, AT_ETHER, 6, tvb, 4);
2959
0
  copy_address_shallow(&pinfo->dl_dst, &unicast_frag_packeth->dest);
2960
0
  copy_address_shallow(&pinfo->dst, &unicast_frag_packeth->dest);
2961
0
  unicast_frag_packeth->flags = tvb_get_uint8(tvb, 10);
2962
0
  unicast_frag_packeth->align = tvb_get_uint8(tvb, 11);
2963
0
  set_address_tvb(&unicast_frag_packeth->orig, AT_ETHER, 6, tvb, 12);
2964
0
  copy_address_shallow(&pinfo->dl_src, &unicast_frag_packeth->orig);
2965
0
  copy_address_shallow(&pinfo->src, &unicast_frag_packeth->orig);
2966
0
  unicast_frag_packeth->seqno = tvb_get_ntohs(tvb, 18);
2967
2968
0
  save_fragmented = pinfo->fragmented;
2969
0
  pinfo->fragmented = true;
2970
2971
  /* Set info column */
2972
0
  col_clear(pinfo->cinfo, COL_INFO);
2973
2974
  /* Set tree info */
2975
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, UNICAST_FRAG_PACKET_V14_SIZE,
2976
0
                "B.A.T.M.A.N. Unicast Fragment, Dst: %s",
2977
0
                address_with_resolution_to_str(pinfo->pool, &unicast_frag_packeth->dest));
2978
0
  batadv_unicast_frag_tree = proto_item_add_subtree(ti, ett_batadv_unicast_frag);
2979
2980
  /* items */
2981
0
  proto_tree_add_uint_format(batadv_unicast_frag_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_UNICAST_FRAG_V12,
2982
0
          "Packet Type: %s (%u)", "BATADV_UNICAST", BATADV_UNICAST_FRAG_V12);
2983
0
  offset += 1;
2984
2985
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2986
0
  offset += 1;
2987
2988
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2989
0
  offset += 1;
2990
2991
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_ttvn, tvb, offset, 1, ENC_BIG_ENDIAN);
2992
0
  offset += 1;
2993
2994
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_dst, tvb, offset, 6, ENC_NA);
2995
0
  offset += 6;
2996
2997
0
  proto_tree_add_bitmask(batadv_unicast_frag_tree, tvb, offset, hf_batadv_unicast_frag_flags,
2998
0
          ett_batadv_batman_flags, unicast_frag_flags, ENC_BIG_ENDIAN);
2999
0
  offset += 1;
3000
3001
  /* Skip 1 byte of padding. */
3002
0
  offset += 1;
3003
3004
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_orig, tvb, offset, 6, ENC_NA);
3005
0
  offset += 6;
3006
3007
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_seqno, tvb, offset, 2, ENC_BIG_ENDIAN);
3008
0
  offset += 2;
3009
3010
0
  tap_queue_packet(batadv_tap, pinfo, unicast_frag_packeth);
3011
3012
0
  head = (unicast_frag_packeth->flags & 0x1);
3013
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
3014
0
  if (length_remaining < 0)
3015
0
    length_remaining = 0;
3016
0
  frag_msg = fragment_add_seq_check(&msg_reassembly_table,
3017
0
    tvb, offset,
3018
0
    pinfo, unicast_frag_packeth->seqno + head, NULL,
3019
0
    1 - head,
3020
0
    length_remaining,
3021
0
    head);
3022
3023
0
  new_tvb = process_reassembled_data(tvb, offset, pinfo,
3024
0
    "Reassembled Message", frag_msg, &msg_frag_items,
3025
0
    NULL, batadv_unicast_frag_tree);
3026
0
  if (new_tvb) {
3027
0
    if (have_tap_listener(batadv_follow_tap)) {
3028
0
      tap_queue_packet(batadv_follow_tap, pinfo, new_tvb);
3029
0
    }
3030
3031
0
    call_dissector(eth_handle, new_tvb, pinfo, tree);
3032
0
  }
3033
3034
0
  pinfo->fragmented = save_fragmented;
3035
0
}
3036
3037
static void dissect_batadv_unicast_frag_v15(tvbuff_t *tvb, packet_info *pinfo,
3038
              proto_tree *tree)
3039
0
{
3040
0
  struct unicast_frag_packet_v15 *unicast_frag_packeth;
3041
0
  bool save_fragmented;
3042
0
  fragment_head *frag_msg = NULL;
3043
0
  proto_tree *batadv_unicast_frag_tree;
3044
0
  proto_item *ti;
3045
3046
0
  tvbuff_t *new_tvb;
3047
0
  unsigned offset = 0;
3048
0
  int frag_no = 0;
3049
0
  int length_remaining;
3050
3051
0
  unicast_frag_packeth = wmem_new(pinfo->pool, struct unicast_frag_packet_v15);
3052
3053
0
  save_fragmented = pinfo->fragmented;
3054
0
  pinfo->fragmented = true;
3055
3056
  /* Set info column */
3057
0
  col_clear(pinfo->cinfo, COL_INFO);
3058
3059
  /* Set tree info */
3060
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
3061
0
              tvb, 0,
3062
0
              UNICAST_FRAG_PACKET_V15_SIZE,
3063
0
              "B.A.T.M.A.N. Unicast Fragment, Dst: %s",
3064
0
              tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 4));
3065
0
  batadv_unicast_frag_tree = proto_item_add_subtree(ti,
3066
0
                ett_batadv_unicast_frag);
3067
3068
  /* items */
3069
0
  unicast_frag_packeth->packet_type = tvb_get_uint8(tvb, offset);
3070
0
  proto_tree_add_uint_format_value(batadv_unicast_frag_tree,
3071
0
           hf_batadv_packet_type, tvb, offset, 1,
3072
0
           unicast_frag_packeth->packet_type,
3073
0
           "%s (%u)", "BATADV_UNICAST",
3074
0
           unicast_frag_packeth->packet_type);
3075
0
  offset += 1;
3076
3077
0
  unicast_frag_packeth->version = tvb_get_uint8(tvb, offset);
3078
0
  proto_tree_add_item(batadv_unicast_frag_tree,
3079
0
          hf_batadv_unicast_frag_version, tvb, offset, 1,
3080
0
          ENC_BIG_ENDIAN);
3081
0
  offset += 1;
3082
3083
0
  unicast_frag_packeth->ttl = tvb_get_uint8(tvb, offset);
3084
0
  proto_tree_add_item(batadv_unicast_frag_tree,
3085
0
          hf_batadv_unicast_frag_ttl, tvb, offset, 1,
3086
0
          ENC_BIG_ENDIAN);
3087
0
  offset += 1;
3088
3089
0
  unicast_frag_packeth->no = tvb_get_uint8(tvb, offset);
3090
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_no,
3091
0
          tvb, offset, 1, ENC_BIG_ENDIAN);
3092
3093
0
  proto_tree_add_item(batadv_unicast_frag_tree,
3094
0
          hf_batadv_unicast_frag_priority,
3095
0
          tvb, offset, 1, ENC_BIG_ENDIAN);
3096
0
  offset += 1;
3097
3098
0
  set_address_tvb(&unicast_frag_packeth->dest, AT_ETHER, 6, tvb, offset);
3099
0
  copy_address_shallow(&pinfo->dl_dst, &unicast_frag_packeth->dest);
3100
0
  copy_address_shallow(&pinfo->dst, &unicast_frag_packeth->dest);
3101
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_dst,
3102
0
          tvb, offset, 6, ENC_NA);
3103
0
  offset += 6;
3104
3105
0
  set_address_tvb(&unicast_frag_packeth->orig, AT_ETHER, 6, tvb, offset);
3106
0
  copy_address_shallow(&pinfo->dl_src, &unicast_frag_packeth->orig);
3107
0
  copy_address_shallow(&pinfo->src, &unicast_frag_packeth->orig);
3108
0
  proto_tree_add_item(batadv_unicast_frag_tree, hf_batadv_unicast_frag_orig,
3109
0
          tvb, offset, 6, ENC_NA);
3110
0
  offset += 6;
3111
3112
0
  unicast_frag_packeth->seqno = tvb_get_ntohs(tvb, offset);
3113
0
  proto_tree_add_item(batadv_unicast_frag_tree,
3114
0
          hf_batadv_unicast_frag_seqno, tvb, offset, 2,
3115
0
          ENC_BIG_ENDIAN);
3116
0
  offset += 2;
3117
3118
0
  unicast_frag_packeth->total_size = tvb_get_ntohs(tvb, offset);
3119
0
  proto_tree_add_item(batadv_unicast_frag_tree,
3120
0
          hf_batadv_unicast_frag_total_size, tvb, offset, 2,
3121
0
          ENC_BIG_ENDIAN);
3122
0
  offset += 2;
3123
3124
0
  tap_queue_packet(batadv_tap, pinfo, unicast_frag_packeth);
3125
3126
0
  frag_no = unicast_frag_packeth->no >> 4;
3127
  /* only support 2 fragments */
3128
0
  if (frag_no > 1) {
3129
0
    pinfo->fragmented = save_fragmented;
3130
0
    return;
3131
0
  }
3132
3133
0
  length_remaining = tvb_captured_length_remaining(tvb, offset);
3134
0
  if (length_remaining < 0)
3135
0
    length_remaining = 0;
3136
0
  frag_msg = fragment_add_seq_check(&msg_reassembly_table,
3137
0
            tvb, offset, pinfo,
3138
0
            unicast_frag_packeth->seqno, NULL,
3139
0
            1 - frag_no, length_remaining, true);
3140
3141
  /* Assemble 2 fragments */
3142
0
  fragment_set_tot_len(&msg_reassembly_table, pinfo,
3143
0
           unicast_frag_packeth->seqno, NULL, 1);
3144
3145
0
  new_tvb = process_reassembled_data(tvb, offset, pinfo,
3146
0
    "Reassembled Message", frag_msg, &msg_frag_items,
3147
0
    NULL, batadv_unicast_frag_tree);
3148
0
  if (new_tvb) {
3149
0
    if (have_tap_listener(batadv_follow_tap)) {
3150
0
      tap_queue_packet(batadv_follow_tap, pinfo, new_tvb);
3151
0
    }
3152
3153
0
    call_dissector(batman_handle, new_tvb, pinfo, tree);
3154
0
  }
3155
3156
0
  pinfo->fragmented = save_fragmented;
3157
0
}
3158
3159
static void dissect_batadv_vis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3160
6
{
3161
6
  uint8_t version;
3162
3163
  /* set protocol name */
3164
6
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_VIS");
3165
3166
6
  version = tvb_get_uint8(tvb, 1);
3167
6
  switch (version) {
3168
0
  case 6:
3169
0
  case 7:
3170
6
  case 8:
3171
6
  case 9:
3172
6
    dissect_batadv_vis_v6(tvb, pinfo, tree);
3173
6
    break;
3174
0
  case 10:
3175
0
  case 11:
3176
0
  case 12:
3177
0
  case 13:
3178
0
    dissect_batadv_vis_v10(tvb, pinfo, tree);
3179
0
    break;
3180
0
  case 14:
3181
0
    dissect_batadv_vis_v14(tvb, pinfo, tree);
3182
0
    break;
3183
0
  default:
3184
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
3185
0
    call_data_dissector(tvb, pinfo, tree);
3186
0
    break;
3187
6
  }
3188
6
}
3189
3190
static void dissect_batadv_vis_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3191
6
{
3192
6
  struct vis_packet_v6 *vis_packeth;
3193
6
  proto_tree *batadv_vis_tree;
3194
6
  proto_item *ti;
3195
3196
6
  tvbuff_t *next_tvb;
3197
6
  unsigned entry_size;
3198
6
  int length_remaining;
3199
6
  unsigned offset = 0;
3200
6
  int i;
3201
3202
6
  vis_packeth = wmem_new(pinfo->pool, struct vis_packet_v6);
3203
3204
6
  vis_packeth->version = tvb_get_uint8(tvb, 1);
3205
6
  vis_packeth->vis_type = tvb_get_uint8(tvb, 2);
3206
6
  vis_packeth->seqno = tvb_get_uint8(tvb, 3);
3207
6
  vis_packeth->entries = tvb_get_uint8(tvb, 4);
3208
6
  vis_packeth->ttl = tvb_get_uint8(tvb, 5);
3209
3210
6
  set_address_tvb(&vis_packeth->vis_orig, AT_ETHER, 6, tvb, 6);
3211
6
  copy_address_shallow(&pinfo->src, &vis_packeth->vis_orig);
3212
6
  set_address_tvb(&vis_packeth->target_orig, AT_ETHER, 6, tvb, 12);
3213
6
  copy_address_shallow(&pinfo->dl_dst, &vis_packeth->target_orig);
3214
6
  copy_address_shallow(&pinfo->dst, &vis_packeth->target_orig);
3215
6
  set_address_tvb(&vis_packeth->sender_orig, AT_ETHER, 6, tvb, 18);
3216
6
  copy_address_shallow(&pinfo->dl_src, &vis_packeth->sender_orig);
3217
3218
3219
  /* Set info column */
3220
6
  col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
3221
6
         val_to_str(pinfo->pool, vis_packeth->vis_type, vis_packettypenames, "Unknown (0x%02x)"),
3222
6
         vis_packeth->seqno);
3223
  /* Set tree info */
3224
6
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_PACKET_V6_SIZE,
3225
6
                "B.A.T.M.A.N. Vis, Orig: %s",
3226
6
                address_with_resolution_to_str(pinfo->pool, &vis_packeth->vis_orig));
3227
6
  batadv_vis_tree = proto_item_add_subtree(ti, ett_batadv_vis);
3228
3229
  /* items */
3230
6
  proto_tree_add_uint_format(batadv_vis_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_VIS_V5,
3231
6
          "Packet Type: %s (%u)", "BATADV_VIS", BATADV_VIS_V5);
3232
6
  offset += 1;
3233
3234
6
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_version, tvb, offset, 1, ENC_BIG_ENDIAN);
3235
6
  offset += 1;
3236
3237
6
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3238
6
  offset += 1;
3239
3240
6
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_seqno, tvb, offset, 1, ENC_BIG_ENDIAN);
3241
6
  offset += 1;
3242
3243
6
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_entries, tvb, offset, 1, ENC_BIG_ENDIAN);
3244
6
  offset += 1;
3245
3246
6
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
3247
6
  offset += 1;
3248
3249
6
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_vis_orig, tvb, offset, 6, ENC_NA);
3250
6
  offset += 6;
3251
3252
6
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_target_orig, tvb, offset, 6, ENC_NA);
3253
6
  offset += 6;
3254
3255
6
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_sender_orig, tvb, offset, 6, ENC_NA);
3256
6
  offset += 6;
3257
3258
6
  tap_queue_packet(batadv_tap, pinfo, vis_packeth);
3259
3260
6
  switch (vis_packeth->version) {
3261
0
  case 6:
3262
0
  case 7:
3263
0
    entry_size = VIS_ENTRY_V6_SIZE;
3264
0
    break;
3265
0
  default:
3266
6
  case 8:
3267
6
  case 9:
3268
6
    entry_size = VIS_ENTRY_V8_SIZE;
3269
6
    break;
3270
6
  }
3271
3272
75
  for (i = 0; i < vis_packeth->entries; i++) {
3273
75
    next_tvb = tvb_new_subset_length(tvb, offset, entry_size);
3274
3275
75
    if (have_tap_listener(batadv_follow_tap)) {
3276
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3277
0
    }
3278
3279
75
    if (batadv_vis_tree != NULL) {
3280
75
      switch (vis_packeth->version) {
3281
0
      case 6:
3282
0
      case 7:
3283
0
        dissect_vis_entry_v6(next_tvb, pinfo, batadv_vis_tree);
3284
0
        break;
3285
0
      default:
3286
75
      case 8:
3287
75
      case 9:
3288
75
        dissect_vis_entry_v8(next_tvb, pinfo, batadv_vis_tree);
3289
75
        break;
3290
75
      }
3291
75
    }
3292
3293
69
    offset += entry_size;
3294
69
  }
3295
3296
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
3297
0
  if (length_remaining > 0) {
3298
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
3299
3300
0
    if (have_tap_listener(batadv_follow_tap)) {
3301
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3302
0
    }
3303
3304
0
    call_data_dissector(next_tvb, pinfo, tree);
3305
0
  }
3306
0
}
3307
3308
static void dissect_batadv_vis_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3309
0
{
3310
0
  struct vis_packet_v10 *vis_packeth;
3311
0
  proto_tree *batadv_vis_tree;
3312
0
  proto_item *ti;
3313
3314
0
  tvbuff_t *next_tvb;
3315
0
  int length_remaining;
3316
0
  unsigned offset = 0;
3317
0
  int i;
3318
3319
0
  vis_packeth = wmem_new(pinfo->pool, struct vis_packet_v10);
3320
3321
0
  vis_packeth->version = tvb_get_uint8(tvb, 1);
3322
0
  vis_packeth->vis_type = tvb_get_uint8(tvb, 2);
3323
0
  vis_packeth->entries = tvb_get_uint8(tvb, 3);
3324
0
  vis_packeth->seqno = tvb_get_ntohl(tvb, 4);
3325
0
  vis_packeth->ttl = tvb_get_uint8(tvb, 8);
3326
3327
0
  set_address_tvb(&vis_packeth->vis_orig, AT_ETHER, 6, tvb, 9);
3328
0
  copy_address_shallow(&pinfo->src, &vis_packeth->vis_orig);
3329
0
  set_address_tvb(&vis_packeth->target_orig, AT_ETHER, 6, tvb, 15);
3330
0
  copy_address_shallow(&pinfo->dl_dst, &vis_packeth->target_orig);
3331
0
  copy_address_shallow(&pinfo->dst, &vis_packeth->target_orig);
3332
0
    set_address_tvb(&vis_packeth->sender_orig, AT_ETHER, 6, tvb, 21);
3333
0
  copy_address_shallow(&pinfo->dl_src, &vis_packeth->sender_orig);
3334
3335
3336
  /* Set info column */
3337
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
3338
0
         val_to_str(pinfo->pool, vis_packeth->vis_type, vis_packettypenames, "Unknown (0x%02x)"),
3339
0
         vis_packeth->seqno);
3340
3341
  /* Set tree info */
3342
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_PACKET_V10_SIZE,
3343
0
                "B.A.T.M.A.N. Vis, Orig: %s",
3344
0
                address_with_resolution_to_str(pinfo->pool, &vis_packeth->vis_orig));
3345
0
  batadv_vis_tree = proto_item_add_subtree(ti, ett_batadv_vis);
3346
3347
  /* items */
3348
0
  proto_tree_add_uint_format(batadv_vis_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_VIS_V5,
3349
0
          "Packet Type: %s (%u)", "BATADV_VIS", BATADV_VIS_V5);
3350
0
  offset += 1;
3351
3352
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_version, tvb, offset, 1, ENC_BIG_ENDIAN);
3353
0
  offset += 1;
3354
3355
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3356
0
  offset += 1;
3357
3358
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_entries, tvb, offset, 1, ENC_BIG_ENDIAN);
3359
0
  offset += 1;
3360
3361
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
3362
0
  offset += 4;
3363
3364
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
3365
0
  offset += 1;
3366
3367
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_vis_orig, tvb, offset, 6, ENC_NA);
3368
0
  offset += 6;
3369
3370
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_target_orig, tvb, offset, 6, ENC_NA);
3371
0
  offset += 6;
3372
3373
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_sender_orig, tvb, offset, 6, ENC_NA);
3374
0
  offset += 6;
3375
3376
0
  tap_queue_packet(batadv_tap, pinfo, vis_packeth);
3377
3378
0
  for (i = 0; i < vis_packeth->entries; i++) {
3379
0
    next_tvb = tvb_new_subset_length(tvb, offset, VIS_ENTRY_V8_SIZE);
3380
3381
0
    if (have_tap_listener(batadv_follow_tap)) {
3382
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3383
0
    }
3384
3385
0
    dissect_vis_entry_v8(next_tvb, pinfo, batadv_vis_tree);
3386
0
    offset += VIS_ENTRY_V8_SIZE;
3387
0
  }
3388
3389
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
3390
0
  if (length_remaining > 0) {
3391
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
3392
3393
0
    if (have_tap_listener(batadv_follow_tap)) {
3394
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3395
0
    }
3396
3397
0
    call_data_dissector(next_tvb, pinfo, tree);
3398
0
  }
3399
0
}
3400
3401
static void dissect_batadv_vis_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3402
0
{
3403
0
  struct vis_packet_v14 *vis_packeth;
3404
0
  proto_tree *batadv_vis_tree;
3405
0
  proto_item *ti;
3406
3407
0
  tvbuff_t *next_tvb;
3408
0
  int length_remaining;
3409
0
  unsigned offset = 0;
3410
0
  int i;
3411
3412
0
  vis_packeth = wmem_new(pinfo->pool, struct vis_packet_v14);
3413
3414
0
  vis_packeth->version = tvb_get_uint8(tvb, 1);
3415
0
  vis_packeth->ttl = tvb_get_uint8(tvb, 2);
3416
0
  vis_packeth->vis_type = tvb_get_uint8(tvb, 3);
3417
0
  vis_packeth->seqno = tvb_get_ntohl(tvb, 4);
3418
0
  vis_packeth->entries = tvb_get_uint8(tvb, 8);
3419
0
  vis_packeth->reserved = tvb_get_uint8(tvb, 9);
3420
3421
0
  set_address_tvb(&vis_packeth->vis_orig, AT_ETHER, 6, tvb, 10);
3422
0
  copy_address_shallow(&pinfo->src, &vis_packeth->vis_orig);
3423
0
  set_address_tvb(&vis_packeth->target_orig, AT_ETHER, 6, tvb, 16);
3424
0
  copy_address_shallow(&pinfo->dl_dst, &vis_packeth->target_orig);
3425
0
  copy_address_shallow(&pinfo->dst, &vis_packeth->target_orig);
3426
0
  set_address_tvb(&vis_packeth->sender_orig, AT_ETHER, 6, tvb, 22);
3427
0
  copy_address_shallow(&pinfo->dl_src, &vis_packeth->sender_orig);
3428
3429
  /* Set info column */
3430
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] Seq=%u",
3431
0
         val_to_str(pinfo->pool, vis_packeth->vis_type, vis_packettypenames, "Unknown (0x%02x)"),
3432
0
         vis_packeth->seqno);
3433
3434
  /* Set tree info */
3435
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_PACKET_V14_SIZE,
3436
0
                "B.A.T.M.A.N. Vis, Orig: %s",
3437
0
                address_with_resolution_to_str(pinfo->pool, &vis_packeth->vis_orig));
3438
0
  batadv_vis_tree = proto_item_add_subtree(ti, ett_batadv_vis);
3439
3440
  /* items */
3441
0
  proto_tree_add_uint_format(batadv_vis_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_VIS_V5,
3442
0
          "Packet Type: %s (%u)", "BATADV_VIS", BATADV_VIS_V5);
3443
0
  offset += 1;
3444
3445
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_version, tvb, offset, 1, ENC_BIG_ENDIAN);
3446
0
  offset += 1;
3447
3448
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
3449
0
  offset += 1;
3450
3451
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3452
0
  offset += 1;
3453
3454
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_seqno32, tvb, offset, 4, ENC_BIG_ENDIAN);
3455
0
  offset += 4;
3456
3457
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_entries, tvb, offset, 1, ENC_BIG_ENDIAN);
3458
0
  offset += 1;
3459
3460
  /* Skip 1 byte of padding. */
3461
0
  offset += 1;
3462
3463
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_vis_orig, tvb, offset, 6, ENC_NA);
3464
0
  offset += 6;
3465
3466
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_target_orig, tvb, offset, 6, ENC_NA);
3467
0
  offset += 6;
3468
3469
0
  proto_tree_add_item(batadv_vis_tree, hf_batadv_vis_sender_orig, tvb, offset, 6, ENC_NA);
3470
0
  offset += 6;
3471
3472
0
  tap_queue_packet(batadv_tap, pinfo, vis_packeth);
3473
3474
0
  for (i = 0; i < vis_packeth->entries; i++) {
3475
0
    next_tvb = tvb_new_subset_length(tvb, offset, VIS_ENTRY_V8_SIZE);
3476
3477
0
    if (have_tap_listener(batadv_follow_tap)) {
3478
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3479
0
    }
3480
3481
0
    dissect_vis_entry_v8(next_tvb, pinfo, batadv_vis_tree);
3482
0
    offset += VIS_ENTRY_V8_SIZE;
3483
0
  }
3484
3485
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
3486
0
  if (length_remaining > 0) {
3487
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
3488
3489
0
    if (have_tap_listener(batadv_follow_tap)) {
3490
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3491
0
    }
3492
3493
0
    call_data_dissector(next_tvb, pinfo, tree);
3494
0
  }
3495
0
}
3496
3497
static void dissect_vis_entry_v6(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
3498
0
{
3499
0
  proto_tree    *batadv_vis_entry_tree;
3500
0
  proto_item    *ti;
3501
3502
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_ENTRY_V6_SIZE,
3503
0
                  "VIS Entry: %s",
3504
0
                  tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 0));
3505
0
  batadv_vis_entry_tree = proto_item_add_subtree(ti, ett_batadv_vis_entry);
3506
3507
0
  proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_dst, tvb, 0, 6, ENC_NA);
3508
0
  proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_quality, tvb, 6, 1, ENC_BIG_ENDIAN);
3509
0
}
3510
3511
static void dissect_vis_entry_v8(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
3512
75
{
3513
75
  proto_tree *batadv_vis_entry_tree;
3514
75
  proto_item *ti;
3515
3516
75
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_ENTRY_V8_SIZE,
3517
75
                  "VIS Entry: %s",
3518
75
                  tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 6));
3519
75
  batadv_vis_entry_tree = proto_item_add_subtree(ti, ett_batadv_vis_entry);
3520
3521
75
  proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_src, tvb, 0, 6, ENC_NA);
3522
75
  proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_dst, tvb, 6, 6, ENC_NA);
3523
75
  proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_quality, tvb, 12, 1, ENC_BIG_ENDIAN);
3524
75
}
3525
3526
static void dissect_batadv_tt_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3527
7
{
3528
7
  uint8_t version;
3529
3530
  /* set protocol name */
3531
7
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_TT_QUERY");
3532
3533
7
  version = tvb_get_uint8(tvb, 1);
3534
7
  switch (version) {
3535
6
  case 14:
3536
6
    dissect_batadv_tt_query_v14(tvb, pinfo, tree);
3537
6
    break;
3538
1
  default:
3539
1
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
3540
1
    call_data_dissector(tvb, pinfo, tree);
3541
1
    break;
3542
7
  }
3543
7
}
3544
3545
static void dissect_batadv_tt_query_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3546
6
{
3547
6
  struct tt_query_packet_v14 *tt_query_packeth;
3548
6
  proto_tree *batadv_tt_query_tree;
3549
6
  proto_item *ti;
3550
3551
6
  tvbuff_t *next_tvb;
3552
6
  int length_remaining;
3553
6
  unsigned offset = 0;
3554
6
  int i;
3555
6
  int tt_type;
3556
3557
6
  tt_query_packeth = wmem_new(pinfo->pool, struct tt_query_packet_v14);
3558
3559
6
  tt_query_packeth->version = tvb_get_uint8(tvb, 1);
3560
6
  tt_query_packeth->ttl = tvb_get_uint8(tvb, 2);
3561
6
  tt_query_packeth->flags = tvb_get_uint8(tvb, 3);
3562
3563
6
  set_address_tvb(&tt_query_packeth->dst, AT_ETHER, 6, tvb, 4);
3564
6
  copy_address_shallow(&pinfo->dl_dst, &tt_query_packeth->dst);
3565
6
  copy_address_shallow(&pinfo->dst, &tt_query_packeth->dst);
3566
3567
6
  set_address_tvb(&tt_query_packeth->src, AT_ETHER, 6, tvb, 10);
3568
6
  copy_address_shallow(&pinfo->dl_src, &tt_query_packeth->src);
3569
6
  copy_address_shallow(&pinfo->src, &tt_query_packeth->src);
3570
3571
6
  tt_query_packeth->ttvn = tvb_get_uint8(tvb, 16);
3572
6
  tt_query_packeth->tt_data = tvb_get_ntohs(tvb, 17);
3573
3574
6
  tt_type = TT_TYPE_MASK & tt_query_packeth->flags;
3575
3576
  /* Set info column */
3577
6
  switch (tt_type) {
3578
1
  case TT_REQUEST:
3579
1
    col_add_fstr(pinfo->cinfo, COL_INFO, "Request=%u", tt_query_packeth->ttvn);
3580
1
    break;
3581
4
  case TT_RESPONSE:
3582
4
    col_add_fstr(pinfo->cinfo, COL_INFO, "Response=%u", tt_query_packeth->ttvn);
3583
4
    break;
3584
1
  default:
3585
1
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Type %u", tt_type);
3586
1
    break;
3587
6
  }
3588
3589
  /* Set tree info */
3590
6
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, TT_QUERY_PACKET_V14_SIZE,
3591
6
                "B.A.T.M.A.N. TT Query, Dst: %s",
3592
6
                address_with_resolution_to_str(pinfo->pool, &tt_query_packeth->dst));
3593
6
  batadv_tt_query_tree = proto_item_add_subtree(ti, ett_batadv_tt_query);
3594
3595
  /* items */
3596
6
  proto_tree_add_uint_format(batadv_tt_query_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_TT_QUERY_V14,
3597
6
          "Packet Type: %s (%u)", "BATADV_TT_QUERY", BATADV_TT_QUERY_V14);
3598
6
  offset += 1;
3599
3600
6
  proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_version, tvb, offset, 1, ENC_BIG_ENDIAN);
3601
6
  offset += 1;
3602
3603
6
  proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
3604
6
  offset += 1;
3605
3606
6
  proto_tree_add_bitmask(batadv_tt_query_tree, tvb, offset, hf_batadv_tt_query_flags,
3607
6
          ett_batadv_tt_query_flags, tt_query_flags, ENC_BIG_ENDIAN);
3608
6
  offset += 1;
3609
3610
6
  proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_dst, tvb, offset, 6, ENC_NA);
3611
6
  offset += 6;
3612
3613
6
  proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_src, tvb, offset, 6, ENC_NA);
3614
6
  offset += 6;
3615
3616
6
  proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_ttvn, tvb, offset, 1, ENC_BIG_ENDIAN);
3617
6
  offset += 1;
3618
3619
6
  switch (tt_type) {
3620
1
  case TT_REQUEST:
3621
1
    proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_tt_crc, tvb, offset, 2, ENC_BIG_ENDIAN);
3622
1
    break;
3623
4
  case TT_RESPONSE:
3624
4
    proto_tree_add_item(batadv_tt_query_tree, hf_batadv_tt_query_entries, tvb, offset, 2, ENC_BIG_ENDIAN);
3625
4
    break;
3626
1
  default:
3627
1
    break;
3628
6
  }
3629
6
  offset += 2;
3630
3631
6
  tap_queue_packet(batadv_tap, pinfo, tt_query_packeth);
3632
3633
6
  if (tt_type == TT_RESPONSE) {
3634
44
    for (i = 0; i < tt_query_packeth->tt_data; i++) {
3635
40
      next_tvb = tvb_new_subset_length(tvb, offset, TT_ENTRY_V14_SIZE);
3636
3637
40
      if (have_tap_listener(batadv_follow_tap)) {
3638
0
        tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3639
0
      }
3640
3641
40
      dissect_tt_entry_v14(next_tvb, pinfo, batadv_tt_query_tree);
3642
40
      offset += TT_ENTRY_V14_SIZE;
3643
40
    }
3644
4
  }
3645
3646
6
  length_remaining = tvb_reported_length_remaining(tvb, offset);
3647
6
  if (length_remaining > 0) {
3648
3
    next_tvb = tvb_new_subset_remaining(tvb, offset);
3649
3650
3
    if (have_tap_listener(batadv_follow_tap)) {
3651
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3652
0
    }
3653
3654
3
    call_data_dissector(next_tvb, pinfo, tree);
3655
3
  }
3656
6
}
3657
3658
static void dissect_tt_entry_v14(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
3659
105
{
3660
105
  proto_tree *batadv_tt_entry_tree;
3661
105
  proto_item *ti;
3662
3663
105
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, TT_ENTRY_V14_SIZE,
3664
105
                  "TT Entry: %s",
3665
105
                  tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 1));
3666
105
  batadv_tt_entry_tree = proto_item_add_subtree(ti, ett_batadv_tt_entry);
3667
3668
105
  proto_tree_add_bitmask(batadv_tt_entry_tree, tvb, 0, hf_batadv_tt_entry_flags,
3669
105
          ett_batadv_tt_entry_flags, tt_entry_flags, ENC_BIG_ENDIAN);
3670
105
  proto_tree_add_item(batadv_tt_entry_tree, hf_batadv_tt_entry, tvb, 1, 6, ENC_NA);
3671
105
}
3672
3673
static void dissect_batadv_roam_adv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3674
1
{
3675
1
  uint8_t version;
3676
3677
  /* set protocol name */
3678
1
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_ROAM_ADV");
3679
3680
1
  version = tvb_get_uint8(tvb, 1);
3681
1
  switch (version) {
3682
0
  case 14:
3683
0
    dissect_batadv_roam_adv_v14(tvb, pinfo, tree);
3684
0
    break;
3685
1
  default:
3686
1
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
3687
1
    call_data_dissector(tvb, pinfo, tree);
3688
1
    break;
3689
1
  }
3690
1
}
3691
3692
static void dissect_batadv_roam_adv_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3693
0
{
3694
0
  struct roam_adv_packet_v14 *roam_adv_packeth;
3695
0
  proto_tree *batadv_roam_adv_tree;
3696
0
  proto_item *ti;
3697
3698
0
  tvbuff_t *next_tvb;
3699
0
  int length_remaining;
3700
0
  unsigned offset = 0;
3701
3702
0
  roam_adv_packeth = wmem_new(pinfo->pool, struct roam_adv_packet_v14);
3703
3704
0
  roam_adv_packeth->version = tvb_get_uint8(tvb, 1);
3705
0
  roam_adv_packeth->ttl = tvb_get_uint8(tvb, 2);
3706
0
  set_address_tvb(&roam_adv_packeth->dst, AT_ETHER, 6, tvb, 4);
3707
0
  copy_address_shallow(&pinfo->dl_dst, &roam_adv_packeth->dst);
3708
0
  copy_address_shallow(&pinfo->dst, &roam_adv_packeth->dst);
3709
0
  set_address_tvb(&roam_adv_packeth->src, AT_ETHER, 6, tvb, 10);
3710
0
  copy_address_shallow(&pinfo->dl_src, &roam_adv_packeth->src);
3711
0
  copy_address_shallow(&pinfo->src, &roam_adv_packeth->src);
3712
0
  set_address_tvb(&roam_adv_packeth->client, AT_ETHER, 6, tvb, 16);
3713
3714
  /* Set info column */
3715
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "Client %s", address_with_resolution_to_str(pinfo->pool, &roam_adv_packeth->client));
3716
3717
  /* Set tree info */
3718
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, ROAM_ADV_PACKET_V14_SIZE,
3719
0
                "B.A.T.M.A.N. Roam: %s",
3720
0
                address_with_resolution_to_str(pinfo->pool, &roam_adv_packeth->client));
3721
0
  batadv_roam_adv_tree = proto_item_add_subtree(ti, ett_batadv_roam_adv);
3722
3723
  /* items */
3724
0
  proto_tree_add_uint_format(batadv_roam_adv_tree, hf_batadv_packet_type, tvb, offset, 1, BATADV_ROAM_ADV_V14,
3725
0
          "Packet Type: %s (%u)", "BATADV_ROAM_ADV", BATADV_ROAM_ADV_V14);
3726
0
  offset += 1;
3727
3728
0
  proto_tree_add_item(batadv_roam_adv_tree, hf_batadv_roam_adv_version, tvb, offset, 1, ENC_BIG_ENDIAN);
3729
0
  offset += 1;
3730
3731
0
  proto_tree_add_item(batadv_roam_adv_tree, hf_batadv_roam_adv_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
3732
0
  offset += 1;
3733
3734
  /* Skip 1 byte of padding. */
3735
0
  offset += 1;
3736
3737
0
  proto_tree_add_item(batadv_roam_adv_tree, hf_batadv_roam_adv_dst, tvb, offset, 6, ENC_NA);
3738
0
  offset += 6;
3739
3740
0
  proto_tree_add_item(batadv_roam_adv_tree, hf_batadv_roam_adv_src, tvb, offset, 6, ENC_NA);
3741
0
  offset += 6;
3742
3743
0
  proto_tree_add_item(batadv_roam_adv_tree, hf_batadv_roam_adv_client, tvb, offset, 6, ENC_NA);
3744
0
  offset += 6;
3745
3746
0
  tap_queue_packet(batadv_tap, pinfo, roam_adv_packeth);
3747
3748
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
3749
0
  if (length_remaining > 0) {
3750
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
3751
3752
0
    if (have_tap_listener(batadv_follow_tap)) {
3753
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3754
0
    }
3755
3756
0
    call_data_dissector(next_tvb, pinfo, tree);
3757
0
  }
3758
0
}
3759
3760
static void dissect_batadv_coded(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3761
0
{
3762
0
  uint8_t version;
3763
3764
  /* set protocol name */
3765
0
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_CODED");
3766
3767
0
  version = tvb_get_uint8(tvb, 1);
3768
0
  switch (version) {
3769
0
  case 15:
3770
0
    dissect_batadv_coded_v15(tvb, pinfo, tree);
3771
0
    break;
3772
0
  default:
3773
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
3774
0
    call_data_dissector(tvb, pinfo, tree);
3775
0
    break;
3776
0
  }
3777
0
}
3778
3779
static void dissect_batadv_coded_v15(tvbuff_t *tvb, packet_info *pinfo,
3780
             proto_tree *tree)
3781
0
{
3782
0
  struct coded_packet_v15 *coded_packeth;
3783
0
  proto_tree *batadv_coded_tree;
3784
0
  proto_item *ti;
3785
3786
0
  tvbuff_t *next_tvb;
3787
0
  int length_remaining;
3788
0
  unsigned offset = 0;
3789
3790
0
  coded_packeth = wmem_new(pinfo->pool, struct coded_packet_v15);
3791
3792
  /* Set tree info */
3793
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
3794
0
              tvb, 0,
3795
0
              CODED_PACKET_V15_SIZE,
3796
0
              "B.A.T.M.A.N. Coded");
3797
0
  batadv_coded_tree = proto_item_add_subtree(ti, ett_batadv_coded);
3798
3799
  /* items */
3800
0
  coded_packeth->packet_type = tvb_get_uint8(tvb, offset);
3801
0
  proto_tree_add_uint_format_value(batadv_coded_tree,
3802
0
           hf_batadv_packet_type,
3803
0
           tvb, offset, 1,
3804
0
           coded_packeth->packet_type,
3805
0
           "%s (%u)", "BATADV_CODED",
3806
0
           coded_packeth->packet_type);
3807
0
  offset += 1;
3808
3809
0
  coded_packeth->version = tvb_get_uint8(tvb, offset);
3810
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_version, tvb,
3811
0
          offset, 1, ENC_BIG_ENDIAN);
3812
0
  offset += 1;
3813
3814
0
  coded_packeth->ttl = tvb_get_uint8(tvb, offset);
3815
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_ttl, tvb, offset,
3816
0
          1, ENC_BIG_ENDIAN);
3817
0
  offset += 1;
3818
3819
0
  coded_packeth->first_ttvn = tvb_get_uint8(tvb, offset);
3820
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_first_ttvn, tvb,
3821
0
          offset, 1, ENC_BIG_ENDIAN);
3822
0
  offset += 1;
3823
3824
0
  set_address_tvb(&coded_packeth->first_source, AT_ETHER, 6, tvb, offset);
3825
0
  copy_address_shallow(&pinfo->dl_src, &coded_packeth->first_source);
3826
0
  copy_address_shallow(&pinfo->src, &coded_packeth->first_source);
3827
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_first_source,
3828
0
          tvb, offset, 6, ENC_NA);
3829
0
  offset += 6;
3830
3831
0
  set_address_tvb(&coded_packeth->first_orig_dest, AT_ETHER, 6, tvb, offset);
3832
0
  copy_address_shallow(&pinfo->dl_dst, &coded_packeth->first_orig_dest);
3833
0
  copy_address_shallow(&pinfo->dst, &coded_packeth->first_orig_dest);
3834
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_first_orig_dest,
3835
0
          tvb, offset, 6, ENC_NA);
3836
0
  offset += 6;
3837
3838
0
  coded_packeth->first_crc = tvb_get_ntohl(tvb, offset);
3839
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_first_crc, tvb,
3840
0
          offset, 4, ENC_BIG_ENDIAN);
3841
0
  offset += 4;
3842
3843
0
  coded_packeth->second_ttl = tvb_get_uint8(tvb, offset);
3844
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_ttl, tvb,
3845
0
          offset, 1, ENC_BIG_ENDIAN);
3846
0
  offset += 1;
3847
3848
0
  coded_packeth->second_ttvn = tvb_get_uint8(tvb, offset);
3849
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_ttvn, tvb,
3850
0
          offset, 1, ENC_BIG_ENDIAN);
3851
0
  offset += 1;
3852
3853
0
  set_address_tvb(&coded_packeth->second_dest, AT_ETHER, 6, tvb, offset);
3854
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_dest,
3855
0
          tvb, offset, 6, ENC_NA);
3856
0
  offset += 6;
3857
3858
0
  set_address_tvb(&coded_packeth->second_source, AT_ETHER, 6, tvb, offset);
3859
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_source,
3860
0
          tvb, offset, 6, ENC_NA);
3861
0
  offset += 6;
3862
3863
0
  set_address_tvb(&coded_packeth->second_orig_dest, AT_ETHER, 6, tvb, offset);
3864
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_orig_dest,
3865
0
          tvb, offset, 6, ENC_NA);
3866
0
  offset += 6;
3867
3868
0
  coded_packeth->second_crc = tvb_get_ntohl(tvb, offset);
3869
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_second_crc, tvb,
3870
0
          offset, 4, ENC_BIG_ENDIAN);
3871
0
  offset += 4;
3872
3873
0
  coded_packeth->coded_len = tvb_get_ntohs(tvb, offset);
3874
0
  proto_tree_add_item(batadv_coded_tree, hf_batadv_coded_coded_len, tvb,
3875
0
          offset, 2, ENC_BIG_ENDIAN);
3876
0
  offset += 2;
3877
3878
0
  tap_queue_packet(batadv_tap, pinfo, coded_packeth);
3879
3880
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
3881
0
  if (length_remaining > 0) {
3882
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
3883
3884
0
    if (have_tap_listener(batadv_follow_tap)) {
3885
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3886
0
    }
3887
3888
0
    call_data_dissector(next_tvb, pinfo, tree);
3889
0
  }
3890
0
}
3891
3892
static void dissect_batadv_elp(tvbuff_t *tvb, packet_info *pinfo,
3893
             proto_tree *tree)
3894
0
{
3895
0
  uint8_t version;
3896
3897
  /* set protocol name */
3898
0
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_ELP");
3899
3900
0
  version = tvb_get_uint8(tvb, 1);
3901
0
  switch (version) {
3902
0
  case 15:
3903
0
    dissect_batadv_elp_v15(tvb, pinfo, tree);
3904
0
    break;
3905
0
  default:
3906
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d",
3907
0
           version);
3908
0
    call_data_dissector(tvb, pinfo, tree);
3909
0
    break;
3910
0
  }
3911
0
}
3912
3913
static void dissect_batadv_elp_v15(tvbuff_t *tvb, packet_info *pinfo,
3914
           proto_tree *tree)
3915
0
{
3916
0
  struct elp_packet_v15 *elp_packeth;
3917
0
  proto_tree *batadv_elp_tree;
3918
0
  proto_item *ti;
3919
3920
0
  tvbuff_t *next_tvb;
3921
0
  int length_remaining;
3922
0
  unsigned offset = 0;
3923
3924
0
  elp_packeth = wmem_new(pinfo->pool, struct elp_packet_v15);
3925
3926
  /* Set tree info */
3927
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
3928
0
              tvb, 0,
3929
0
              ELP_PACKET_V15_SIZE,
3930
0
              "B.A.T.M.A.N. ELP");
3931
0
  batadv_elp_tree = proto_item_add_subtree(ti, ett_batadv_elp);
3932
3933
  /* items */
3934
0
  elp_packeth->packet_type = tvb_get_uint8(tvb, offset);
3935
0
  proto_tree_add_uint_format_value(batadv_elp_tree,
3936
0
           hf_batadv_packet_type,
3937
0
           tvb, offset, 1,
3938
0
           elp_packeth->packet_type,
3939
0
           "%s (%u)", "BATADV_ELP",
3940
0
           elp_packeth->packet_type);
3941
0
  offset += 1;
3942
3943
0
  elp_packeth->version = tvb_get_uint8(tvb, offset);
3944
0
  proto_tree_add_item(batadv_elp_tree, hf_batadv_elp_version, tvb,
3945
0
          offset, 1, ENC_BIG_ENDIAN);
3946
0
  offset += 1;
3947
3948
0
  set_address_tvb(&elp_packeth->orig, AT_ETHER, 6, tvb, offset);
3949
0
  set_address_tvb(&pinfo->dl_src, AT_ETHER, 6, tvb, offset);
3950
0
  set_address_tvb(&pinfo->src, AT_ETHER, 6, tvb, offset);
3951
0
  proto_tree_add_item(batadv_elp_tree, hf_batadv_elp_orig, tvb,
3952
0
          offset, 6, ENC_NA);
3953
0
  offset += 6;
3954
3955
0
  elp_packeth->seqno = tvb_get_ntohl(tvb, offset);
3956
0
  proto_tree_add_item(batadv_elp_tree, hf_batadv_elp_seqno, tvb,
3957
0
          offset, 4, ENC_BIG_ENDIAN);
3958
0
  offset += 4;
3959
3960
0
  elp_packeth->interval = tvb_get_ntohl(tvb, offset);
3961
0
  proto_tree_add_item(batadv_elp_tree, hf_batadv_elp_interval, tvb,
3962
0
          offset, 4, ENC_BIG_ENDIAN);
3963
0
  offset += 4;
3964
3965
0
  tap_queue_packet(batadv_tap, pinfo, elp_packeth);
3966
3967
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
3968
0
  if (length_remaining > 0) {
3969
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
3970
3971
0
    if (have_tap_listener(batadv_follow_tap)) {
3972
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
3973
0
    }
3974
3975
0
    call_data_dissector(next_tvb, pinfo, tree);
3976
0
  }
3977
0
}
3978
3979
static void dissect_batadv_ogm2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3980
1
{
3981
1
  uint8_t version;
3982
1
  unsigned offset = 0;
3983
3984
  /* set protocol name */
3985
1
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_OGM2");
3986
3987
1
  version = tvb_get_uint8(tvb, 1);
3988
1
  switch (version) {
3989
0
  case 15:
3990
0
    while (tvb_reported_length_remaining(tvb, offset) >= OGM2_PACKET_V15_SIZE) {
3991
0
      offset = dissect_batadv_ogm2_v15(tvb, offset, pinfo, tree);
3992
0
    }
3993
0
    break;
3994
1
  default:
3995
1
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
3996
1
    call_data_dissector(tvb, pinfo, tree);
3997
1
    break;
3998
1
  }
3999
1
}
4000
4001
static unsigned dissect_batadv_ogm2_v15(tvbuff_t *tvb, unsigned offset,
4002
           packet_info *pinfo, proto_tree *tree)
4003
0
{
4004
0
  proto_tree *batadv_ogm2_tree;
4005
0
  proto_item *ti, *throughput_item;
4006
0
  uint8_t type, version;
4007
0
  struct ogm2_packet_v15 *ogm2_packeth;
4008
0
  tvbuff_t *next_tvb;
4009
#if 0
4010
  /* OGM2 flags field is unused, it is illegal to call
4011
   * proto_tree_add_bitmask with an empty list of fields.
4012
   */
4013
  static int * const flags[] = {
4014
    NULL
4015
  };
4016
#endif
4017
4018
0
  type = tvb_get_uint8(tvb, offset+0);
4019
0
  version = tvb_get_uint8(tvb, offset+1);
4020
4021
  /* don't interpret padding as B.A.T.M.A.N. advanced packet */
4022
0
  if (version == 0 || type != BATADV_OGM2_V15)
4023
0
    return tvb_reported_length(tvb);
4024
4025
0
  ogm2_packeth = wmem_new(pinfo->pool, struct ogm2_packet_v15);
4026
4027
  /* Set tree info */
4028
0
  ogm2_packeth->tvlv_len = tvb_get_ntohs(tvb, offset + 14);
4029
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
4030
0
              tvb, offset,
4031
0
              OGM2_PACKET_V15_SIZE + ogm2_packeth->tvlv_len,
4032
0
              "B.A.T.M.A.N. OGM2, Orig: %s",
4033
0
              tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, offset + 8));
4034
0
  batadv_ogm2_tree = proto_item_add_subtree(ti, ett_batadv_ogm2);
4035
4036
  /* items */
4037
0
  ogm2_packeth->packet_type = tvb_get_uint8(tvb, offset);
4038
0
  proto_tree_add_uint_format_value(batadv_ogm2_tree,
4039
0
           hf_batadv_packet_type,
4040
0
           tvb, offset, 1, BATADV_OGM2_V15,
4041
0
           "%s (%u)", "BATADV_OGM2",
4042
0
           BATADV_OGM2_V15);
4043
0
  offset += 1;
4044
4045
0
  ogm2_packeth->version = tvb_get_uint8(tvb, offset);
4046
0
  proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_version, tvb,
4047
0
          offset, 1, ENC_BIG_ENDIAN);
4048
0
  offset += 1;
4049
4050
0
  ogm2_packeth->ttl = tvb_get_uint8(tvb, offset);
4051
0
  proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_ttl, tvb,
4052
0
          offset, 1, ENC_BIG_ENDIAN);
4053
0
  offset += 1;
4054
4055
0
  ogm2_packeth->flags = tvb_get_uint8(tvb, offset);
4056
0
  proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_flags, tvb,
4057
0
          offset, 1, ENC_NA);
4058
0
  offset += 1;
4059
4060
0
  ogm2_packeth->seqno = tvb_get_ntohl(tvb, offset);
4061
0
  proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_seqno, tvb,
4062
0
          offset, 4, ENC_BIG_ENDIAN);
4063
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "Seq=%u", ogm2_packeth->seqno);
4064
0
  offset += 4;
4065
4066
0
  set_address_tvb(&ogm2_packeth->orig, AT_ETHER, 6, tvb, offset);
4067
0
  set_address_tvb(&pinfo->dl_src, AT_ETHER, 6, tvb, offset);
4068
0
  set_address_tvb(&pinfo->src, AT_ETHER, 6, tvb, offset);
4069
0
  proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_orig, tvb,
4070
0
          offset, 6, ENC_NA);
4071
0
  offset += 6;
4072
4073
0
  ogm2_packeth->tvlv_len = tvb_get_ntohs(tvb, offset);
4074
0
  proto_tree_add_item(batadv_ogm2_tree, hf_batadv_ogm2_tvlv_len, tvb,
4075
0
          offset, 2, ENC_BIG_ENDIAN);
4076
0
  offset += 2;
4077
4078
0
  ogm2_packeth->throughput = tvb_get_ntohl(tvb, offset);
4079
0
  throughput_item = proto_tree_add_item(batadv_ogm2_tree,
4080
0
                hf_batadv_ogm2_throughput, tvb,
4081
0
                offset, 4, ENC_BIG_ENDIAN);
4082
0
  proto_item_set_text(throughput_item, "Throughput: %u.%u Mbit/s",
4083
0
          ogm2_packeth->throughput / 10,
4084
0
          ogm2_packeth->throughput % 10);
4085
0
  offset += 4;
4086
4087
0
  tap_queue_packet(batadv_tap, pinfo, ogm2_packeth);
4088
4089
0
  if (ogm2_packeth->tvlv_len > 0) {
4090
0
    next_tvb = tvb_new_subset_length(tvb, offset,
4091
0
             ogm2_packeth->tvlv_len);
4092
4093
0
    if (have_tap_listener(batadv_follow_tap)) {
4094
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
4095
0
    }
4096
4097
0
    dissect_batadv_tvlv_v15(next_tvb, pinfo, batadv_ogm2_tree);
4098
0
    offset += ogm2_packeth->tvlv_len;
4099
0
  }
4100
4101
0
  return offset;
4102
0
}
4103
4104
static void dissect_batadv_unicast_tvlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
4105
0
{
4106
0
  uint8_t version;
4107
4108
  /* set protocol name */
4109
0
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "BATADV_UNICAST_TVLV");
4110
4111
0
  version = tvb_get_uint8(tvb, 1);
4112
0
  switch (version) {
4113
0
  case 15:
4114
0
    dissect_batadv_unicast_tvlv_v15(tvb, pinfo, tree);
4115
0
    break;
4116
0
  default:
4117
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d",
4118
0
           version);
4119
0
    call_data_dissector(tvb, pinfo, tree);
4120
0
    break;
4121
0
  }
4122
0
}
4123
4124
static void dissect_batadv_unicast_tvlv_v15(tvbuff_t *tvb, packet_info *pinfo,
4125
              proto_tree *tree)
4126
0
{
4127
0
  struct unicast_tvlv_packet_v15 *unicast_tvlv_packeth;
4128
4129
0
  tvbuff_t *next_tvb;
4130
0
  unsigned offset = 0;
4131
0
  proto_tree *batadv_unicast_tvlv_tree;
4132
0
  proto_item *ti;
4133
4134
0
  unicast_tvlv_packeth = wmem_new(pinfo->pool, struct unicast_tvlv_packet_v15);
4135
4136
  /* Set info column */
4137
0
  col_clear(pinfo->cinfo, COL_INFO);
4138
4139
  /* Set tree info */
4140
0
  unicast_tvlv_packeth->tvlv_len = tvb_get_ntohs(tvb, 16);
4141
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
4142
0
              tvb, 0,
4143
0
              UNICAST_TVLV_PACKET_V15_SIZE + unicast_tvlv_packeth->tvlv_len,
4144
0
              "B.A.T.M.A.N. Unicast TVLV, Src: %s Dst: %s",
4145
0
              tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 10),
4146
0
              tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, 4));
4147
0
  batadv_unicast_tvlv_tree = proto_item_add_subtree(ti, ett_batadv_unicast_tvlv);
4148
4149
  /* items */
4150
0
  unicast_tvlv_packeth->packet_type = tvb_get_uint8(tvb, offset);
4151
0
  proto_tree_add_uint_format_value(batadv_unicast_tvlv_tree,
4152
0
           hf_batadv_packet_type, tvb, offset, 1,
4153
0
           unicast_tvlv_packeth->packet_type,
4154
0
           "%s (%u)", "BATADV_UNICAST_TVLV",
4155
0
           unicast_tvlv_packeth->packet_type);
4156
0
  offset += 1;
4157
4158
0
  unicast_tvlv_packeth->version = tvb_get_uint8(tvb, offset);
4159
0
  proto_tree_add_item(batadv_unicast_tvlv_tree,
4160
0
          hf_batadv_unicast_tvlv_version, tvb, offset, 1,
4161
0
          ENC_BIG_ENDIAN);
4162
0
  offset += 1;
4163
4164
0
  unicast_tvlv_packeth->ttl = tvb_get_uint8(tvb, offset);
4165
0
  proto_tree_add_item(batadv_unicast_tvlv_tree,
4166
0
          hf_batadv_unicast_tvlv_ttl, tvb, offset, 1,
4167
0
          ENC_BIG_ENDIAN);
4168
0
  offset += 1;
4169
4170
  /* Skip 1 byte of padding. */
4171
0
  offset += 1;
4172
4173
0
  set_address_tvb(&unicast_tvlv_packeth->dest, AT_ETHER, 6, tvb, offset);
4174
0
  copy_address_shallow(&pinfo->dl_dst, &unicast_tvlv_packeth->dest);
4175
0
  copy_address_shallow(&pinfo->dst, &unicast_tvlv_packeth->dest);
4176
0
  proto_tree_add_item(batadv_unicast_tvlv_tree, hf_batadv_unicast_tvlv_dst,
4177
0
          tvb, offset, 6, ENC_NA);
4178
0
  offset += 6;
4179
4180
0
  set_address_tvb(&unicast_tvlv_packeth->src, AT_ETHER, 6, tvb, offset);
4181
0
  copy_address_shallow(&pinfo->dl_src, &unicast_tvlv_packeth->src);
4182
0
  copy_address_shallow(&pinfo->src, &unicast_tvlv_packeth->src);
4183
0
  proto_tree_add_item(batadv_unicast_tvlv_tree, hf_batadv_unicast_tvlv_src,
4184
0
          tvb, offset, 6, ENC_NA);
4185
0
  offset += 6;
4186
4187
0
  unicast_tvlv_packeth->tvlv_len = tvb_get_ntohs(tvb, offset);
4188
0
  proto_tree_add_item(batadv_unicast_tvlv_tree,
4189
0
          hf_batadv_unicast_tvlv_len, tvb, offset, 2,
4190
0
          ENC_BIG_ENDIAN);
4191
0
  offset += 2;
4192
4193
  /* Skip 2 byte of padding. */
4194
0
  offset += 2;
4195
4196
0
  tap_queue_packet(batadv_tap, pinfo, unicast_tvlv_packeth);
4197
4198
0
  if (unicast_tvlv_packeth->tvlv_len > 0) {
4199
0
    next_tvb = tvb_new_subset_length(tvb, offset,
4200
0
             unicast_tvlv_packeth->tvlv_len);
4201
4202
0
    if (have_tap_listener(batadv_follow_tap)) {
4203
0
      tap_queue_packet(batadv_follow_tap, pinfo, next_tvb);
4204
0
    }
4205
4206
0
    dissect_batadv_tvlv_v15(next_tvb, pinfo,
4207
0
          batadv_unicast_tvlv_tree);
4208
    /*offset += unicast_tvlv_packeth->tvlv_len;*/
4209
0
  }
4210
0
}
4211
4212
static void dissect_batadv_tvlv_v15(tvbuff_t *tvb, packet_info *pinfo,
4213
            proto_tree *tree)
4214
0
{
4215
0
  uint8_t type, version;
4216
0
  unsigned length;
4217
0
  unsigned offset = 0;
4218
0
  tvbuff_t *next_tvb;
4219
0
  proto_tree *batadv_tvlv_tree;
4220
0
  proto_item *ti;
4221
4222
0
  while (tvb_reported_length_remaining(tvb, offset) >= 4) {
4223
4224
0
    type = tvb_get_uint8(tvb, offset + 0);
4225
0
    version = tvb_get_uint8(tvb, offset + 1);
4226
0
    length = tvb_get_ntohs(tvb, offset + 2) + 4;
4227
0
    next_tvb = tvb_new_subset_length(tvb, offset, length);
4228
4229
    /* Set tree info */
4230
0
    ti = proto_tree_add_protocol_format(tree,
4231
0
                proto_batadv_plugin,
4232
0
                next_tvb, 0, length,
4233
0
                "TVLV, %s",
4234
0
                val_to_str(pinfo->pool, type,
4235
0
                     tvlv_v15_typenames,
4236
0
                     "Unknown (0x%02x)"));
4237
0
    batadv_tvlv_tree = proto_item_add_subtree(ti, ett_batadv_tvlv);
4238
4239
0
    dissect_batadv_tvlv_v15_header(next_tvb, pinfo,
4240
0
                 batadv_tvlv_tree, type);
4241
4242
0
    switch (type) {
4243
0
    case BATADV_TVLV_V15_GW:
4244
0
      dissect_batadv_tvlv_v15_gw(next_tvb, pinfo,
4245
0
               batadv_tvlv_tree, 4,
4246
0
               version);
4247
0
      break;
4248
0
    case BATADV_TVLV_V15_DAT:
4249
0
      dissect_batadv_tvlv_v15_dat(next_tvb, pinfo,
4250
0
                batadv_tvlv_tree, 4,
4251
0
                version);
4252
0
      break;
4253
0
    case BATADV_TVLV_V15_NC:
4254
0
      dissect_batadv_tvlv_v15_nc(next_tvb, pinfo,
4255
0
               batadv_tvlv_tree, 4,
4256
0
               version);
4257
0
      break;
4258
0
    case BATADV_TVLV_V15_TT:
4259
0
      dissect_batadv_tvlv_v15_tt(next_tvb, pinfo,
4260
0
               batadv_tvlv_tree, 4,
4261
0
               version);
4262
0
      break;
4263
0
    case BATADV_TVLV_V15_ROAM:
4264
0
      dissect_batadv_tvlv_v15_roam(next_tvb, pinfo,
4265
0
                 batadv_tvlv_tree, 4,
4266
0
                 version);
4267
0
      break;
4268
0
    case BATADV_TVLV_V15_MCAST:
4269
0
      dissect_batadv_tvlv_v15_mcast(next_tvb, pinfo,
4270
0
                  batadv_tvlv_tree, 4,
4271
0
                  version);
4272
0
      break;
4273
0
    default:
4274
0
      call_data_dissector(next_tvb, pinfo,
4275
0
               batadv_tvlv_tree);
4276
0
      break;
4277
0
    }
4278
0
    offset += length;
4279
0
  }
4280
0
}
4281
4282
static void dissect_batadv_tvlv_v15_header(tvbuff_t *tvb,
4283
             packet_info *pinfo _U_,
4284
             proto_tree *tree, uint8_t type)
4285
0
{
4286
0
  unsigned offset = 0;
4287
4288
  /* items */
4289
0
  proto_tree_add_uint_format_value(tree, hf_batadv_tvlv_type, tvb, offset,
4290
0
           1, type, "%s",
4291
0
           val_to_str(pinfo->pool, type, tvlv_v15_typenames,
4292
0
                "Unknown (0x%02x)"));
4293
0
  offset += 1;
4294
4295
0
  proto_tree_add_item(tree, hf_batadv_tvlv_version, tvb, offset, 1,
4296
0
          ENC_BIG_ENDIAN);
4297
0
  offset += 1;
4298
4299
0
  proto_tree_add_item(tree, hf_batadv_tvlv_len, tvb, offset, 2,
4300
0
          ENC_BIG_ENDIAN);
4301
0
}
4302
4303
static void dissect_batadv_tvlv_v15_dat(tvbuff_t *tvb, packet_info *pinfo,
4304
          proto_tree *tree, unsigned offset,
4305
          uint8_t version)
4306
0
{
4307
0
  if (version != 0x01) {
4308
0
    proto_tree_add_expert_format(
4309
0
      tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4310
0
      offset, 0, "Unknown version (0x%02x)", version);
4311
0
    return;
4312
0
  }
4313
0
}
4314
4315
static void dissect_batadv_tvlv_v15_nc(tvbuff_t *tvb, packet_info *pinfo,
4316
               proto_tree *tree, unsigned offset,
4317
               uint8_t version)
4318
0
{
4319
0
  if (version != 0x01) {
4320
0
    proto_tree_add_expert_format(
4321
0
      tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4322
0
      offset, 0, "Unknown version (0x%02x)", version);
4323
0
    return;
4324
0
  }
4325
0
}
4326
4327
static void dissect_batadv_tvlv_v15_mcast(tvbuff_t *tvb, packet_info *pinfo,
4328
            proto_tree *tree, unsigned offset,
4329
            uint8_t version)
4330
0
{
4331
0
  static int * const flags[] = {
4332
0
    &hf_batadv_tvlv_mcast_flags_unsnoopables,
4333
0
    &hf_batadv_tvlv_mcast_flags_ipv4,
4334
0
    &hf_batadv_tvlv_mcast_flags_ipv6,
4335
0
    &hf_batadv_tvlv_mcast_flags_no_rtr4,
4336
0
    &hf_batadv_tvlv_mcast_flags_no_rtr6,
4337
0
    NULL
4338
0
  };
4339
4340
0
  if (version != 0x01 && version != 0x02) {
4341
0
    proto_tree_add_expert_format(
4342
0
      tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4343
0
      offset, 0, "Unknown version (0x%02x)", version);
4344
0
    return;
4345
0
  }
4346
4347
0
  proto_tree_add_bitmask(tree, tvb, offset, hf_batadv_tvlv_mcast_flags,
4348
0
             ett_batadv_tvlv_mcast_flags, flags, ENC_NA);
4349
4350
  /* 3 byte of padding. */
4351
0
}
4352
4353
static void dissect_batadv_tvlv_v15_gw(tvbuff_t *tvb, packet_info *pinfo,
4354
               proto_tree *tree, unsigned offset,
4355
               uint8_t version)
4356
0
{
4357
0
  uint32_t down, up;
4358
4359
0
  if (version != 0x01) {
4360
0
    proto_tree_add_expert_format(
4361
0
      tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4362
0
      offset, 0, "Unknown version (0x%02x)", version);
4363
0
    return;
4364
0
  }
4365
4366
0
  down = tvb_get_ntohl(tvb, offset);
4367
0
  proto_tree_add_uint_format_value(tree, hf_batadv_tvlv_gw_download,
4368
0
           tvb, offset, 4, down, "%u.%uMbit",
4369
0
           down / 10, down % 10);
4370
0
  offset += 4;
4371
4372
0
  up = tvb_get_ntohl(tvb, offset);
4373
0
  proto_tree_add_uint_format_value(tree, hf_batadv_tvlv_gw_upload, tvb,
4374
0
           offset, 4, up, "%u.%uMbit",
4375
0
           up / 10, up % 10);
4376
0
}
4377
4378
static void dissect_batadv_tvlv_v15_roam(tvbuff_t *tvb, packet_info *pinfo,
4379
           proto_tree *tree, unsigned offset,
4380
           uint8_t version)
4381
0
{
4382
0
  static int * const flags[] = {
4383
0
    &hf_batadv_tvlv_vid_vlan,
4384
0
    &hf_batadv_tvlv_vid_tagged,
4385
0
    NULL
4386
0
  };
4387
4388
0
  if (version != 0x01) {
4389
0
    proto_tree_add_expert_format(
4390
0
      tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4391
0
      offset, 0, "Unknown version (0x%02x)", version);
4392
0
    return;
4393
0
  }
4394
4395
0
  proto_tree_add_item(tree, hf_batadv_tvlv_roam_addr, tvb, offset, 6,
4396
0
          ENC_NA);
4397
0
  offset += 6;
4398
4399
0
  proto_tree_add_bitmask(tree, tvb, offset, hf_batadv_tvlv_roam_vid,
4400
0
             ett_batadv_tvlv_vid, flags, ENC_BIG_ENDIAN);
4401
0
}
4402
4403
static void dissect_batadv_tvlv_v15_tt(tvbuff_t *tvb, packet_info *pinfo,
4404
               proto_tree *tree, unsigned offset,
4405
               uint8_t version)
4406
0
{
4407
0
  uint16_t num_vlan;
4408
0
  int i;
4409
0
  int length_remaining;
4410
0
  static int * const flags[] = {
4411
0
    &hf_batadv_tvlv_tt_flags_type,
4412
0
    &hf_batadv_tvlv_tt_flags_full_table,
4413
0
    NULL
4414
0
  };
4415
0
  uint8_t tt_flags;
4416
0
  int changes_offset;
4417
4418
0
  tt_flags = tvb_get_uint8(tvb, offset);
4419
4420
0
  if (version != 0x01) {
4421
0
    proto_tree_add_expert_format(
4422
0
      tree, pinfo, &ei_batadv_tvlv_unknown_version, tvb,
4423
0
      offset, 0, "Unknown version (0x%02x)", version);
4424
0
    return;
4425
0
  }
4426
4427
0
  proto_tree_add_bitmask(tree, tvb, offset, hf_batadv_tvlv_tt_flags,
4428
0
             ett_batadv_tvlv_tt_flags, flags, ENC_NA);
4429
0
  offset += 1;
4430
4431
0
  proto_tree_add_item(tree, hf_batadv_tvlv_tt_ttvn, tvb, offset, 1,
4432
0
          ENC_BIG_ENDIAN);
4433
0
  offset += 1;
4434
4435
0
  num_vlan = tvb_get_ntohs(tvb, offset);
4436
0
  proto_tree_add_item(tree, hf_batadv_tvlv_tt_num_vlan, tvb, offset, 2,
4437
0
          ENC_BIG_ENDIAN);
4438
0
  offset += 2;
4439
4440
0
  changes_offset = offset + num_vlan * TLVLV_TT_VLAN_V15_SIZE;
4441
4442
0
  for (i = 0; i < num_vlan; i++)
4443
0
    offset = dissect_batadv_tvlv_v15_tt_vlan(tvb, pinfo, tree,
4444
0
               offset, tt_flags,
4445
0
               changes_offset);
4446
4447
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
4448
0
  while (length_remaining > 0) {
4449
0
    offset = dissect_batadv_tvlv_v15_tt_change(tvb, pinfo, tree,
4450
0
                 offset);
4451
0
    length_remaining = tvb_reported_length_remaining(tvb, offset);
4452
0
  }
4453
0
}
4454
4455
static void dissect_batadv_tvlv_v15_tt_vlan_checksum(tvbuff_t *tvb,
4456
                 proto_item *ti,
4457
                 packet_info *pinfo,
4458
                 proto_tree *tree,
4459
                 uint16_t vlan_id,
4460
                 int crc_offset,
4461
                 uint8_t tt_flags,
4462
                 unsigned offset)
4463
0
{
4464
0
  const uint8_t *buf;
4465
0
  uint32_t crc32;
4466
0
  uint32_t crc = 0;
4467
0
  int length_remaining;
4468
0
  uint16_t vid;
4469
0
  unsigned int num_entries = 0;
4470
0
  uint8_t full_response = (BATADV_TVLVL_TT_RESPONSE | BATADV_TVLVL_TT_FULL_TABLE);
4471
4472
  /* checksum checks are not possible with non full responses */
4473
0
  if (tt_flags != full_response) {
4474
0
    proto_tree_add_item(tree, hf_batadv_tvlv_tt_vlan_crc, tvb,
4475
0
            crc_offset, 4, ENC_BIG_ENDIAN);
4476
0
    return;
4477
0
  }
4478
4479
0
  length_remaining = tvb_reported_length_remaining(tvb, offset);
4480
0
  while (length_remaining >= TLVLV_TT_CHANGE_V15_SIZE) {
4481
4482
0
    vid = tvb_get_ntohs(tvb, offset + 10);
4483
0
    if (vid != vlan_id)
4484
0
      goto skip;
4485
4486
0
    buf = tvb_get_ptr(tvb, offset, TLVLV_TT_CHANGE_V15_SIZE);
4487
0
    if (!buf)
4488
0
      goto skip;
4489
4490
0
    num_entries++;
4491
4492
    /* checksum over vid, flags, address */
4493
0
    crc32 = 0;
4494
0
    crc32 = crc32c_calculate_no_swap(&buf[10], 2, crc32);
4495
0
    crc32 = crc32c_calculate_no_swap(buf, 1, crc32);
4496
0
    crc32 = crc32c_calculate_no_swap(&buf[4], 6, crc32);
4497
0
    crc ^= crc32;
4498
4499
0
skip:
4500
0
    offset += TLVLV_TT_CHANGE_V15_SIZE;
4501
0
    length_remaining = tvb_reported_length_remaining(tvb, offset);
4502
0
  }
4503
4504
0
        proto_tree_add_checksum(tree, tvb, crc_offset,
4505
0
        hf_batadv_tvlv_tt_vlan_crc,
4506
0
        hf_batadv_tvlv_tt_vlan_crc_status,
4507
0
        &ei_batadv_tvlv_tt_vlan_crc, pinfo, crc,
4508
0
        ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
4509
4510
0
  if (num_entries == 0)
4511
0
    expert_add_info(pinfo, ti, &ei_batadv_tvlv_tt_vlan_empty);
4512
0
}
4513
4514
static unsigned dissect_batadv_tvlv_v15_tt_vlan(tvbuff_t *tvb,
4515
             packet_info *pinfo,
4516
             proto_tree *tree, unsigned offset,
4517
             uint8_t tt_flags,
4518
             int changes_offset)
4519
0
{
4520
0
  proto_tree *vlan_tree = NULL;
4521
0
  uint16_t vid;
4522
0
  proto_item *ti = NULL;
4523
0
  static int * const flags[] = {
4524
0
    &hf_batadv_tvlv_vid_vlan,
4525
0
    &hf_batadv_tvlv_vid_tagged,
4526
0
    NULL
4527
0
  };
4528
4529
0
  vid = tvb_get_ntohs(tvb, offset + 4);
4530
4531
  /* Set tree info */
4532
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
4533
0
              tvb, offset, 8,
4534
0
              "VLAN, %04x", vid);
4535
0
  vlan_tree = proto_item_add_subtree(ti, ett_batadv_tvlv_tt_vlan);
4536
4537
0
  dissect_batadv_tvlv_v15_tt_vlan_checksum(tvb, ti, pinfo, vlan_tree, vid,
4538
0
             offset, tt_flags,
4539
0
             changes_offset);
4540
0
  offset += 4;
4541
4542
0
  proto_tree_add_bitmask(vlan_tree, tvb, offset,
4543
0
             hf_batadv_tvlv_tt_vlan_vid,
4544
0
             ett_batadv_tvlv_vid, flags, ENC_BIG_ENDIAN);
4545
0
  offset += 2;
4546
4547
  /* Skip 2 byte of padding. */
4548
0
  offset += 2;
4549
4550
0
  return offset;
4551
0
}
4552
4553
static unsigned dissect_batadv_tvlv_v15_tt_change(tvbuff_t *tvb,
4554
               packet_info *pinfo _U_,
4555
               proto_tree *tree, unsigned offset)
4556
0
{
4557
0
  proto_tree *change_tree;
4558
0
  proto_item *ti;
4559
0
  static int * const flags[] = {
4560
0
    &hf_batadv_tvlv_tt_change_flags_del,
4561
0
    &hf_batadv_tvlv_tt_change_flags_roam,
4562
0
    &hf_batadv_tvlv_tt_change_flags_wifi,
4563
0
    &hf_batadv_tvlv_tt_change_flags_isolate,
4564
0
    NULL
4565
0
  };
4566
0
  static int * const flags_vlan[] = {
4567
0
    &hf_batadv_tvlv_vid_vlan,
4568
0
    &hf_batadv_tvlv_vid_tagged,
4569
0
    NULL
4570
0
  };
4571
4572
  /* Set tree info */
4573
0
  ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
4574
0
              tvb, offset, 12,
4575
0
              "Entry, %s",
4576
0
              tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_ETHER, offset + 4));
4577
0
  change_tree = proto_item_add_subtree(ti, ett_batadv_tvlv_tt_change);
4578
4579
0
  proto_tree_add_bitmask(change_tree, tvb, offset,
4580
0
             hf_batadv_tvlv_tt_change_flags,
4581
0
      ett_batadv_batman_flags, flags, ENC_NA);
4582
0
  offset += 1;
4583
4584
  /* Skip 3 byte of padding. */
4585
0
  offset += 3;
4586
4587
0
  proto_tree_add_item(change_tree, hf_batadv_tvlv_tt_change_addr, tvb,
4588
0
          offset, 6, ENC_NA);
4589
0
  offset += 6;
4590
4591
0
  proto_tree_add_bitmask(change_tree, tvb, offset,
4592
0
             hf_batadv_tvlv_tt_change_vid,
4593
0
             ett_batadv_tvlv_vid, flags_vlan, ENC_BIG_ENDIAN);
4594
0
  offset += 2;
4595
4596
0
  return offset;
4597
0
}
4598
4599
void proto_register_batadv(void)
4600
16
{
4601
16
  module_t *batadv_module;
4602
16
  expert_module_t* expert_batadv;
4603
4604
16
  static hf_register_info hf[] = {
4605
16
    { &hf_batadv_packet_type,
4606
16
      { "Packet Type", "batadv.batman.packet_type",
4607
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4608
16
        NULL, HFILL }
4609
16
    },
4610
16
    { &hf_batadv_batman_version,
4611
16
      { "Version", "batadv.batman.version",
4612
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4613
16
        NULL, HFILL }
4614
16
    },
4615
16
    { &hf_batadv_batman_flags,
4616
16
      { "Flags", "batadv.batman.flags",
4617
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
4618
16
        NULL, HFILL }
4619
16
    },
4620
16
    { &hf_batadv_batman_ttl,
4621
16
      { "Time to Live", "batadv.batman.ttl",
4622
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4623
16
        NULL, HFILL }
4624
16
    },
4625
16
    { &hf_batadv_batman_gwflags,
4626
16
      { "Gateway Flags", "batadv.batman.gwflags",
4627
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
4628
16
        NULL, HFILL }
4629
16
    },
4630
16
    { &hf_batadv_batman_gwflags_dl_speed,
4631
16
      { "Download Speed", "batadv.batman.gwflags.dl_speed",
4632
16
        FT_UINT32, BASE_DEC|BASE_UNIT_STRING, UNS(&units_kbit), 0x0,
4633
16
        NULL, HFILL }
4634
16
    },
4635
16
    { &hf_batadv_batman_gwflags_ul_speed,
4636
16
      { "Upload Speed", "batadv.batman.gwflags.ul_speed",
4637
16
        FT_UINT32, BASE_DEC|BASE_UNIT_STRING, UNS(&units_kbit), 0x0,
4638
16
        NULL, HFILL }
4639
16
    },
4640
16
    { &hf_batadv_batman_tq,
4641
16
      { "Transmission Quality", "batadv.batman.tq",
4642
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4643
16
        NULL, HFILL }
4644
16
    },
4645
16
    { &hf_batadv_batman_seqno,
4646
16
      { "Sequence number", "batadv.batman.seq",
4647
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
4648
16
        NULL, HFILL }
4649
16
    },
4650
16
    { &hf_batadv_batman_seqno32,
4651
16
      { "Sequence number", "batadv.batman.seq",
4652
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
4653
16
        NULL, HFILL }
4654
16
    },
4655
16
    { &hf_batadv_batman_orig,
4656
16
      { "Originator", "batadv.batman.orig",
4657
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4658
16
        NULL, HFILL }
4659
16
    },
4660
16
    { &hf_batadv_batman_prev_sender,
4661
16
      { "Received from", "batadv.batman.prev_sender",
4662
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4663
16
        NULL, HFILL }
4664
16
    },
4665
16
    { &hf_batadv_batman_num_tt,
4666
16
      { "Number of TTs", "batadv.batman.num_tt",
4667
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4668
16
        NULL, HFILL }
4669
16
    },
4670
16
    { &hf_batadv_batman_tt_num_changes,
4671
16
      { "Number of TT Changes", "batadv.batman.tt_num_changes",
4672
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4673
16
        NULL, HFILL }
4674
16
    },
4675
16
    { &hf_batadv_batman_ttvn,
4676
16
      { "TT Version", "batadv.batman.ttvn",
4677
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4678
16
        NULL, HFILL }
4679
16
    },
4680
16
    { &hf_batadv_batman_tt_crc,
4681
16
      { "CRC of TT", "batadv.batman.tt_crc",
4682
16
        FT_UINT16, BASE_HEX, NULL, 0x0,
4683
16
        NULL, HFILL }
4684
16
    },
4685
16
    { &hf_batadv_batman_flags_directlink,
4686
16
      { "DirectLink", "batadv.batman.flags.directlink",
4687
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x40,
4688
16
        NULL, HFILL }
4689
16
    },
4690
16
    { &hf_batadv_batman_flags_vis_server,
4691
16
      { "VIS_SERVER", "batadv.batman.flags.vis_server",
4692
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x20,
4693
16
        NULL, HFILL }
4694
16
    },
4695
16
    { &hf_batadv_batman_flags_primaries_first_hop,
4696
16
      { "PRIMARIES_FIRST_HOP", "batadv.batman.flags.primaries_first_hop",
4697
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x10,
4698
16
        NULL, HFILL }
4699
16
    },
4700
16
    { &hf_batadv_batman_flags_not_best_next_hop,
4701
16
      { "NOT_BEST_NEXT_HOP", "batadv.batman.flags.not_best_next_hop",
4702
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x8,
4703
16
        NULL, HFILL }
4704
16
    },
4705
16
    { &hf_batadv_iv_ogm_version,
4706
16
      { "Version", "batadv.iv_ogm.version",
4707
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4708
16
        NULL, HFILL }
4709
16
    },
4710
16
    { &hf_batadv_iv_ogm_ttl,
4711
16
      { "Time to Live", "batadv.iv_ogm.ttl",
4712
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4713
16
        NULL, HFILL }
4714
16
    },
4715
16
    { &hf_batadv_iv_ogm_flags,
4716
16
      { "Flags", "batadv.iv_ogm.flags",
4717
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
4718
16
        NULL, HFILL }
4719
16
    },
4720
16
    { &hf_batadv_iv_ogm_seqno,
4721
16
      { "Sequence number", "batadv.iv_ogm.seq",
4722
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
4723
16
        NULL, HFILL }
4724
16
    },
4725
16
    { &hf_batadv_iv_ogm_orig,
4726
16
      { "Originator", "batadv.iv_ogm.orig",
4727
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4728
16
        NULL, HFILL }
4729
16
    },
4730
16
    { &hf_batadv_iv_ogm_prev_sender,
4731
16
      { "Received from", "batadv.iv_ogm.prev_sender",
4732
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4733
16
        NULL, HFILL }
4734
16
    },
4735
16
    { &hf_batadv_iv_ogm_tq,
4736
16
      { "Transmission Quality", "batadv.iv_ogm.tq",
4737
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4738
16
        NULL, HFILL }
4739
16
    },
4740
16
    { &hf_batadv_iv_ogm_tvlv_len,
4741
16
      { "Length of TVLV", "batadv.iv_ogm.tvlv_len",
4742
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
4743
16
        NULL, HFILL }
4744
16
    },
4745
16
    { &hf_batadv_iv_ogm_flags_not_best_next_hop,
4746
16
      { "NOT_BEST_NEXT_HOP", "batadv.iv_ogm.flags.not_best_next_hop",
4747
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x1,
4748
16
        NULL, HFILL }
4749
16
    },
4750
16
    { &hf_batadv_iv_ogm_flags_primaries_first_hop,
4751
16
      { "PRIMARIES_FIRST_HOP", "batadv.iv_ogm.flags.primaries_first_hop",
4752
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x2,
4753
16
        NULL, HFILL }
4754
16
    },
4755
16
    { &hf_batadv_iv_ogm_flags_directlink,
4756
16
      { "DirectLink", "batadv.iv_ogm.flags.directlink",
4757
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x4,
4758
16
        NULL, HFILL }
4759
16
    },
4760
16
    { &hf_batadv_ogm2_version,
4761
16
      { "Version", "batadv.ogm2.version",
4762
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4763
16
        NULL, HFILL }
4764
16
    },
4765
16
    { &hf_batadv_ogm2_ttl,
4766
16
      { "Time to Live", "batadv.ogm2.ttl",
4767
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4768
16
        NULL, HFILL }
4769
16
    },
4770
16
    { &hf_batadv_ogm2_flags,
4771
16
      { "Flags", "batadv.ogm2.flags",
4772
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
4773
16
        "Unused", HFILL }
4774
16
    },
4775
16
    { &hf_batadv_ogm2_seqno,
4776
16
      { "Sequence number", "batadv.ogm2.seq",
4777
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
4778
16
        NULL, HFILL }
4779
16
    },
4780
16
    { &hf_batadv_ogm2_orig,
4781
16
      { "Originator", "batadv.ogm2.orig",
4782
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4783
16
        NULL, HFILL }
4784
16
    },
4785
16
    { &hf_batadv_ogm2_tvlv_len,
4786
16
      { "Length of TVLV", "batadv.ogm2.tvlv_len",
4787
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
4788
16
        NULL, HFILL }
4789
16
    },
4790
16
    { &hf_batadv_ogm2_throughput,
4791
16
      { "Throughput", "batadv.ogm2.throughput",
4792
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
4793
16
        NULL, HFILL }
4794
16
    },
4795
16
    { &hf_batadv_batman_tt,
4796
16
      { "Translation Table", "batadv.batman.tt",
4797
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4798
16
        NULL, HFILL }
4799
16
    },
4800
16
    { &hf_batadv_elp_version,
4801
16
      { "Version", "batadv.elp.version",
4802
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4803
16
        NULL, HFILL }
4804
16
    },
4805
16
    { &hf_batadv_elp_orig,
4806
16
      { "Originator", "batadv.elp.orig",
4807
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4808
16
        NULL, HFILL }
4809
16
    },
4810
16
    { &hf_batadv_elp_seqno,
4811
16
      { "Sequence number", "batadv.elp.seq",
4812
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
4813
16
        NULL, HFILL }
4814
16
    },
4815
16
    { &hf_batadv_elp_interval,
4816
16
      { "ELP Interval", "batadv.elp.interval",
4817
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
4818
16
        NULL, HFILL }
4819
16
    },
4820
16
    { &hf_batadv_bcast_version,
4821
16
      { "Version", "batadv.bcast.version",
4822
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4823
16
        NULL, HFILL }
4824
16
    },
4825
16
    { &hf_batadv_bcast_orig,
4826
16
      { "Originator", "batadv.bcast.orig",
4827
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4828
16
        NULL, HFILL }
4829
16
    },
4830
16
    { &hf_batadv_bcast_seqno,
4831
16
      { "Sequence number", "batadv.bcast.seq",
4832
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
4833
16
        NULL, HFILL }
4834
16
    },
4835
16
    { &hf_batadv_bcast_seqno32,
4836
16
      { "Sequence number", "batadv.bcast.seq",
4837
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
4838
16
        NULL, HFILL }
4839
16
    },
4840
16
    { &hf_batadv_bcast_ttl,
4841
16
      { "Time to Live", "batadv.bcast.ttl",
4842
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4843
16
        NULL, HFILL }
4844
16
    },
4845
16
    { &hf_batadv_icmp_version,
4846
16
      { "Version", "batadv.icmp.version",
4847
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4848
16
        NULL, HFILL }
4849
16
    },
4850
16
    { &hf_batadv_icmp_msg_type,
4851
16
      { "Message Type", "batadv.icmp.msg_type",
4852
16
        FT_UINT8, BASE_DEC, VALS(icmp_packettypenames), 0x0,
4853
16
        NULL, HFILL }
4854
16
    },
4855
16
    { &hf_batadv_icmp_dst,
4856
16
      { "Destination", "batadv.icmp.dst",
4857
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4858
16
        NULL, HFILL }
4859
16
    },
4860
16
    { &hf_batadv_icmp_orig,
4861
16
      { "Originator", "batadv.icmp.orig",
4862
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4863
16
        NULL, HFILL }
4864
16
    },
4865
16
    { &hf_batadv_icmp_ttl,
4866
16
      { "Time to Live", "batadv.icmp.ttl",
4867
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4868
16
        NULL, HFILL}
4869
16
    },
4870
16
    { &hf_batadv_icmp_uid,
4871
16
      { "UID", "batadv.icmp.uid",
4872
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4873
16
        NULL, HFILL}
4874
16
    },
4875
16
    { &hf_batadv_icmp_seqno,
4876
16
      { "Sequence number", "batadv.icmp.seq",
4877
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
4878
16
        NULL, HFILL}
4879
16
    },
4880
16
    { &hf_batadv_icmp_rr_pointer,
4881
16
      { "Pointer", "batadv.icmp.rr_pointer",
4882
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4883
16
        NULL, HFILL}
4884
16
    },
4885
16
    { &hf_batadv_icmp_rr_ether,
4886
16
      { "RR MAC", "batadv.icmp.rr_ether",
4887
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4888
16
        NULL, HFILL}
4889
16
    },
4890
16
    { &hf_batadv_icmp_tp_subtype,
4891
16
      { "Subtype", "batadv.icmp.tp.subtype",
4892
16
        FT_UINT8, BASE_DEC, VALS(icmp_tp_packettypenames), 0x0,
4893
16
        NULL, HFILL}
4894
16
    },
4895
16
    { &hf_batadv_icmp_tp_session,
4896
16
      { "Session", "batadv.icmp.tp.session",
4897
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
4898
16
        NULL, HFILL}
4899
16
    },
4900
16
    { &hf_batadv_icmp_tp_seqno,
4901
16
      { "Sequence number", "batadv.icmp.tp.seqno",
4902
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
4903
16
        NULL, HFILL}
4904
16
    },
4905
16
    { &hf_batadv_icmp_tp_timestamp,
4906
16
      { "Timestamp", "batadv.icmp.tp.timestamp",
4907
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
4908
16
        NULL, HFILL}
4909
16
    },
4910
16
    { &hf_batadv_unicast_version,
4911
16
      { "Version", "batadv.unicast.version",
4912
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4913
16
        NULL, HFILL }
4914
16
    },
4915
16
    { &hf_batadv_unicast_dst,
4916
16
      { "Destination", "batadv.unicast.dst",
4917
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4918
16
        NULL, HFILL }
4919
16
    },
4920
16
    { &hf_batadv_unicast_ttl,
4921
16
      { "Time to Live", "batadv.unicast.ttl",
4922
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4923
16
        NULL, HFILL }
4924
16
    },
4925
16
    { &hf_batadv_unicast_ttvn,
4926
16
      { "TT Version", "batadv.unicast.ttvn",
4927
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4928
16
        NULL, HFILL }
4929
16
    },
4930
16
    { &hf_batadv_unicast_4addr_version,
4931
16
      { "Version", "batadv.unicast_4addr.version",
4932
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4933
16
        NULL, HFILL }
4934
16
    },
4935
16
    { &hf_batadv_unicast_4addr_dst,
4936
16
      { "Destination", "batadv.unicast_4addr.dst",
4937
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4938
16
        NULL, HFILL }
4939
16
    },
4940
16
    { &hf_batadv_unicast_4addr_ttl,
4941
16
      { "Time to Live", "batadv.unicast_4addr.ttl",
4942
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4943
16
        NULL, HFILL }
4944
16
    },
4945
16
    { &hf_batadv_unicast_4addr_ttvn,
4946
16
      { "TT Version", "batadv.unicast_4addr.ttvn",
4947
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4948
16
        NULL, HFILL }
4949
16
    },
4950
16
    { &hf_batadv_unicast_4addr_src,
4951
16
      { "Source", "batadv.unicast_4addr.src",
4952
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4953
16
        NULL, HFILL }
4954
16
    },
4955
16
    { &hf_batadv_unicast_4addr_subtype,
4956
16
      { "Subtype", "batadv.unicast_4addr.subtype",
4957
16
        FT_UINT8, BASE_DEC, VALS (unicast_4addr_typenames), 0x0,
4958
16
        NULL, HFILL }
4959
16
    },
4960
16
    { &hf_batadv_unicast_frag_version,
4961
16
      { "Version", "batadv.unicast_frag.version",
4962
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4963
16
        NULL, HFILL }
4964
16
    },
4965
16
    { &hf_batadv_unicast_frag_dst,
4966
16
      { "Destination", "batadv.unicast_frag.dst",
4967
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4968
16
        NULL, HFILL }
4969
16
    },
4970
16
    { &hf_batadv_unicast_frag_ttl,
4971
16
      { "Time to Live", "batadv.unicast_frag.ttl",
4972
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4973
16
        NULL, HFILL }
4974
16
    },
4975
16
    { &hf_batadv_unicast_frag_ttvn,
4976
16
      { "TT Version", "batadv.unicast_frag.ttvn",
4977
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
4978
16
        NULL, HFILL }
4979
16
    },
4980
16
    { &hf_batadv_unicast_frag_flags,
4981
16
      { "Flags", "batadv.unicast_frag.flags",
4982
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
4983
16
        NULL, HFILL }
4984
16
    },
4985
16
    { &hf_batadv_unicast_frag_flags_head,
4986
16
      { "Head", "batadv.unicast_frag.flags.head",
4987
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x01,
4988
16
        NULL, HFILL }
4989
16
    },
4990
16
    { &hf_batadv_unicast_frag_flags_largetail,
4991
16
      { "Largetail", "batadv.unicast_frag.flags.largetail",
4992
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x02,
4993
16
        NULL, HFILL }
4994
16
    },
4995
16
    { &hf_batadv_unicast_frag_orig,
4996
16
      { "Originator", "batadv.unicast_frag.orig",
4997
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
4998
16
        NULL, HFILL }
4999
16
    },
5000
16
    { &hf_batadv_unicast_frag_seqno,
5001
16
      { "Sequence number", "batadv.unicast_frag.seq",
5002
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
5003
16
        NULL, HFILL }
5004
16
    },
5005
16
    { &hf_batadv_unicast_frag_no,
5006
16
      { "Fragment number", "batadv.unicast_frag.no",
5007
16
        FT_UINT8, BASE_DEC, NULL, 0xF0,
5008
16
        NULL, HFILL }
5009
16
    },
5010
16
    { &hf_batadv_unicast_frag_priority,
5011
16
      { "Priority", "batadv.unicast_frag.priority",
5012
16
        FT_UINT8, BASE_DEC, NULL, 0xE,
5013
16
        NULL, HFILL }
5014
16
    },
5015
16
    { &hf_batadv_unicast_frag_total_size,
5016
16
      { "Complete Size", "batadv.unicast_frag.total_size",
5017
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
5018
16
        NULL, HFILL }
5019
16
    },
5020
16
    { &hf_batadv_unicast_tvlv_version,
5021
16
      { "Version", "batadv.unicast_tvlv.version",
5022
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5023
16
        NULL, HFILL }
5024
16
    },
5025
16
    { &hf_batadv_unicast_tvlv_ttl,
5026
16
      { "Time to Live", "batadv.unicast_tvlv.ttl",
5027
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5028
16
        NULL, HFILL }
5029
16
    },
5030
16
    { &hf_batadv_unicast_tvlv_dst,
5031
16
      { "Destination", "batadv.unicast_tvlv.dst",
5032
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5033
16
        NULL, HFILL }
5034
16
    },
5035
16
    { &hf_batadv_unicast_tvlv_src,
5036
16
      { "Source", "batadv.unicast_tvlv.src",
5037
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5038
16
        NULL, HFILL }
5039
16
    },
5040
16
    { &hf_batadv_unicast_tvlv_len,
5041
16
      { "Length of TVLV", "batadv.unicast_tvlv.len",
5042
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
5043
16
        NULL, HFILL }
5044
16
    },
5045
16
    { &hf_batadv_vis_version,
5046
16
      { "Version", "batadv.vis.version",
5047
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5048
16
        NULL, HFILL }
5049
16
    },
5050
16
    { &hf_batadv_vis_type,
5051
16
      { "Type", "batadv.vis.type",
5052
16
        FT_UINT8, BASE_DEC, VALS(vis_packettypenames), 0x0,
5053
16
        NULL, HFILL }
5054
16
    },
5055
16
    { &hf_batadv_vis_seqno,
5056
16
      { "Sequence number", "batadv.vis.seq",
5057
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5058
16
        NULL, HFILL}
5059
16
    },
5060
16
    { &hf_batadv_vis_seqno32,
5061
16
      { "Sequence number", "batadv.vis.seq",
5062
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
5063
16
        NULL, HFILL}
5064
16
    },
5065
16
    { &hf_batadv_vis_entries,
5066
16
      { "Entries", "batadv.vis.entries",
5067
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5068
16
        "Number of entries", HFILL}
5069
16
    },
5070
16
    { &hf_batadv_vis_ttl,
5071
16
      { "Time to Live", "batadv.vis.ttl",
5072
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5073
16
        NULL, HFILL}
5074
16
    },
5075
16
    { &hf_batadv_vis_vis_orig,
5076
16
      { "Originator", "batadv.vis.vis_orig",
5077
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5078
16
        NULL, HFILL }
5079
16
    },
5080
16
    { &hf_batadv_vis_target_orig,
5081
16
      { "Target Originator", "batadv.vis.target_orig",
5082
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5083
16
        NULL, HFILL }
5084
16
    },
5085
16
    { &hf_batadv_vis_sender_orig,
5086
16
      { "Forwarding Originator", "batadv.vis.sender_orig",
5087
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5088
16
        NULL, HFILL }
5089
16
    },
5090
16
    { &hf_batadv_vis_entry_src,
5091
16
      { "Source", "batadv.vis.src",
5092
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5093
16
        NULL, HFILL }
5094
16
    },
5095
16
    { &hf_batadv_vis_entry_dst,
5096
16
      { "Destination", "batadv.vis.dst",
5097
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5098
16
        NULL, HFILL }
5099
16
    },
5100
16
    { &hf_batadv_vis_entry_quality,
5101
16
      { "Quality", "batadv.vis.quality",
5102
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5103
16
        NULL, HFILL }
5104
16
    },
5105
16
    { &hf_batadv_tt_query_version,
5106
16
      { "Version", "batadv.tt_query.version",
5107
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5108
16
        NULL, HFILL }
5109
16
    },
5110
16
    { &hf_batadv_tt_query_ttl,
5111
16
      { "Time to Live", "batadv.tt_query.ttl",
5112
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5113
16
        NULL, HFILL}
5114
16
    },
5115
16
    { &hf_batadv_tt_query_flags,
5116
16
      { "Flags", "batadv.tt_query.flags",
5117
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
5118
16
        NULL, HFILL }
5119
16
    },
5120
16
    { &hf_batadv_tt_query_flags_type,
5121
16
      { "Query Type", "batadv.tt_query.flags.type",
5122
16
        FT_UINT8, BASE_HEX, VALS (tt_query_type_v14), TT_TYPE_MASK,
5123
16
        NULL, HFILL }
5124
16
    },
5125
16
    { &hf_batadv_tt_query_flags_full_table,
5126
16
      { "Full Table", "batadv.tt_query.flags.full_table",
5127
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), TT_FULL_TABLE,
5128
16
        NULL, HFILL }
5129
16
    },
5130
16
    { &hf_batadv_tt_query_dst,
5131
16
      { "Destination", "batadv.tt_query.dst",
5132
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5133
16
        NULL, HFILL }
5134
16
    },
5135
16
    { &hf_batadv_tt_query_src,
5136
16
      { "Source", "batadv.tt_query.src",
5137
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5138
16
        NULL, HFILL }
5139
16
    },
5140
16
    { &hf_batadv_tt_query_ttvn,
5141
16
      { "TT Version", "batadv.tt_query.ttvn",
5142
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5143
16
        NULL, HFILL }
5144
16
    },
5145
16
    { &hf_batadv_tt_query_tt_crc,
5146
16
      { "CRC of TT", "batadv.tt_query.tt_crc",
5147
16
        FT_UINT16, BASE_HEX, NULL, 0x0,
5148
16
        NULL, HFILL }
5149
16
    },
5150
16
    { &hf_batadv_tt_query_entries,
5151
16
      { "Entries", "batadv.tt_query.entries",
5152
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
5153
16
        "Number of entries", HFILL }
5154
16
    },
5155
16
    { &hf_batadv_roam_adv_version,
5156
16
      { "Version", "batadv.roam_adv.version",
5157
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5158
16
        NULL, HFILL }
5159
16
    },
5160
16
    { &hf_batadv_roam_adv_ttl,
5161
16
      { "Time to Live", "batadv.roam_adv.ttl",
5162
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5163
16
        NULL, HFILL}
5164
16
    },
5165
16
    { &hf_batadv_roam_adv_src,
5166
16
      { "Source", "batadv.roam_adv.src",
5167
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5168
16
        NULL, HFILL }
5169
16
    },
5170
16
    { &hf_batadv_roam_adv_dst,
5171
16
      { "Destination", "batadv.roam_adv.dst",
5172
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5173
16
        NULL, HFILL }
5174
16
    },
5175
16
    { &hf_batadv_roam_adv_client,
5176
16
      { "Client", "batadv.roam_adv.client",
5177
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5178
16
        NULL, HFILL }
5179
16
    },
5180
16
    { &hf_batadv_coded_version,
5181
16
      { "Version", "batadv.coded.version",
5182
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5183
16
        NULL, HFILL }
5184
16
    },
5185
16
    { &hf_batadv_coded_ttl,
5186
16
      { "Time to Live", "batadv.coded.ttl",
5187
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5188
16
        NULL, HFILL}
5189
16
    },
5190
16
    { &hf_batadv_coded_first_ttvn,
5191
16
      { "TT Version (First)", "batadv.coded.first_ttvn",
5192
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5193
16
        NULL, HFILL}
5194
16
    },
5195
16
    { &hf_batadv_coded_first_source,
5196
16
      { "Source (First)", "batadv.coded.first_src",
5197
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5198
16
        NULL, HFILL }
5199
16
    },
5200
16
    { &hf_batadv_coded_first_orig_dest,
5201
16
      { "Original Destination (First)", "batadv.coded.first_orig_dst",
5202
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5203
16
        NULL, HFILL }
5204
16
    },
5205
16
    { &hf_batadv_coded_first_crc,
5206
16
      { "CRC (First)", "batadv.coded.first_crc",
5207
16
        FT_UINT32, BASE_HEX, NULL, 0x0,
5208
16
        NULL, HFILL }
5209
16
    },
5210
16
    { &hf_batadv_coded_second_ttl,
5211
16
      { "Time to Live (Second)", "batadv.coded.second_ttl",
5212
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5213
16
        NULL, HFILL}
5214
16
    },
5215
16
    { &hf_batadv_coded_second_ttvn,
5216
16
      { "TT Version (Second)", "batadv.coded.second_ttvn",
5217
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5218
16
        NULL, HFILL}
5219
16
    },
5220
16
    { &hf_batadv_coded_second_dest,
5221
16
      { "Destination (Second)", "batadv.coded.second_dst",
5222
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5223
16
        NULL, HFILL }
5224
16
    },
5225
16
    { &hf_batadv_coded_second_source,
5226
16
      { "Source (Second)", "batadv.coded.second_src",
5227
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5228
16
        NULL, HFILL }
5229
16
    },
5230
16
    { &hf_batadv_coded_second_orig_dest,
5231
16
      { "Original Destination (Second)", "batadv.coded.second_orig_dst",
5232
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5233
16
        NULL, HFILL }
5234
16
    },
5235
16
    { &hf_batadv_coded_second_crc,
5236
16
      { "CRC (Second)", "batadv.coded.second_crc",
5237
16
        FT_UINT32, BASE_HEX, NULL, 0x0,
5238
16
        NULL, HFILL }
5239
16
    },
5240
16
    { &hf_batadv_coded_coded_len,
5241
16
      { "Length", "batadv.coded.length",
5242
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
5243
16
        NULL, HFILL }
5244
16
    },
5245
16
    { &hf_msg_fragments,
5246
16
      {"Message fragments", "batadv.unicast_frag.fragments",
5247
16
        FT_NONE, BASE_NONE, NULL, 0x00,
5248
16
        NULL, HFILL }
5249
16
    },
5250
16
    { &hf_batadv_tt_entry,
5251
16
      { "Entry", "batadv.tt_entry.entry",
5252
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5253
16
        NULL, HFILL }
5254
16
    },
5255
16
    { &hf_batadv_tt_entry_flags,
5256
16
      { "Flags", "batadv.tt_entry.flags",
5257
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
5258
16
        NULL, HFILL }
5259
16
    },
5260
16
    { &hf_batadv_tt_entry_flags_change_del,
5261
16
      { "Delete", "batadv.tt_entry.flags.change_del",
5262
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), TT_CHANGE_DEL,
5263
16
        NULL, HFILL }
5264
16
    },
5265
16
    { &hf_batadv_tt_entry_flags_client_roam,
5266
16
      { "Client Roam", "batadv.tt_entry.flags.client_roam",
5267
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), TT_CLIENT_ROAM,
5268
16
        NULL, HFILL }
5269
16
    },
5270
16
    { &hf_msg_fragment,
5271
16
      {"Message fragment", "batadv.unicast_frag.fragment",
5272
16
        FT_FRAMENUM, BASE_NONE, NULL, 0x00,
5273
16
        NULL, HFILL }
5274
16
    },
5275
16
    { &hf_msg_fragment_overlap,
5276
16
      {"Message fragment overlap", "batadv.unicast_frag.fragment.overlap",
5277
16
        FT_BOOLEAN, BASE_NONE, NULL, 0x00,
5278
16
        NULL, HFILL }
5279
16
    },
5280
16
    { &hf_msg_fragment_overlap_conflicts,
5281
16
       {"Message fragment overlapping with conflicting data",
5282
16
        "batadv.unicast_frag.fragment.overlap.conflicts",
5283
16
        FT_BOOLEAN, BASE_NONE, NULL, 0x00,
5284
16
        NULL, HFILL }
5285
16
    },
5286
16
    { &hf_msg_fragment_multiple_tails,
5287
16
      {"Message has multiple tail fragments",
5288
16
        "batadv.unicast_frag.fragment.multiple_tails",
5289
16
        FT_BOOLEAN, BASE_NONE, NULL, 0x00,
5290
16
        NULL, HFILL }
5291
16
    },
5292
16
    { &hf_msg_fragment_too_long_fragment,
5293
16
      {"Message fragment too long", "batadv.unicast_frag.fragment.too_long_fragment",
5294
16
        FT_BOOLEAN, BASE_NONE, NULL, 0x00,
5295
16
        NULL, HFILL }
5296
16
    },
5297
16
    { &hf_msg_fragment_error,
5298
16
      {"Message defragmentation error", "batadv.unicast_frag.fragment.error",
5299
16
        FT_FRAMENUM, BASE_NONE, NULL, 0x00,
5300
16
        NULL, HFILL }
5301
16
    },
5302
16
    { &hf_msg_fragment_count,
5303
16
      {"Message fragment count", "batadv.unicast_frag.fragment.count",
5304
16
        FT_UINT32, BASE_DEC, NULL, 0x00,
5305
16
        NULL, HFILL }
5306
16
    },
5307
16
    { &hf_msg_reassembled_in,
5308
16
      {"Reassembled in", "batadv.msg.reassembled.in",
5309
16
        FT_FRAMENUM, BASE_NONE, NULL, 0x00,
5310
16
        NULL, HFILL }
5311
16
    },
5312
16
    { &hf_msg_reassembled_length,
5313
16
      {"Reassembled length", "batadv.msg.reassembled.length",
5314
16
        FT_UINT32, BASE_DEC, NULL, 0x00,
5315
16
        NULL, HFILL }
5316
16
    },
5317
16
    { &hf_batadv_tvlv_type,
5318
16
      { "Type", "batadv.tvlv.length",
5319
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
5320
16
        NULL, HFILL }
5321
16
    },
5322
16
    { &hf_batadv_tvlv_version,
5323
16
      { "Version", "batadv.tvlv.version",
5324
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
5325
16
        NULL, HFILL }
5326
16
    },
5327
16
    { &hf_batadv_tvlv_len,
5328
16
      { "Length", "batadv.tvlv.len",
5329
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
5330
16
        NULL, HFILL }
5331
16
    },
5332
16
    { &hf_batadv_tvlv_mcast_flags,
5333
16
      { "Flags", "batadv.tvlv.mcast.flags",
5334
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
5335
16
        NULL, HFILL }
5336
16
    },
5337
16
    { &hf_batadv_tvlv_mcast_flags_unsnoopables,
5338
16
      { "Unsnoopables", "batadv.tvlv.mcast.flags.unsnoopables",
5339
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x1,
5340
16
        NULL, HFILL }
5341
16
    },
5342
16
    { &hf_batadv_tvlv_mcast_flags_ipv4,
5343
16
      { "IPv4", "batadv.tvlv.mcast.flags.ipv4",
5344
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x2,
5345
16
        NULL, HFILL }
5346
16
    },
5347
16
    { &hf_batadv_tvlv_mcast_flags_ipv6,
5348
16
      { "IPv6", "batadv.tvlv.mcast.flags.ipv6",
5349
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x4,
5350
16
        NULL, HFILL }
5351
16
    },
5352
16
    { &hf_batadv_tvlv_mcast_flags_no_rtr4,
5353
16
      { "No IPv4 multicast router", "batadv.tvlv.mcast.flags.no_rtr4",
5354
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x8,
5355
16
        NULL, HFILL }
5356
16
    },
5357
16
    { &hf_batadv_tvlv_mcast_flags_no_rtr6,
5358
16
      { "No IPv6 multicast router", "batadv.tvlv.mcast.flags.no_rtr6",
5359
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x10,
5360
16
        NULL, HFILL }
5361
16
    },
5362
16
    { &hf_batadv_tvlv_gw_download,
5363
16
      { "Download Speed", "batadv.tvlv.gw.dl_speed",
5364
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
5365
16
        NULL, HFILL }
5366
16
    },
5367
16
    { &hf_batadv_tvlv_gw_upload,
5368
16
      { "Upload Speed", "batadv.tvlv.gw.ul_speed",
5369
16
        FT_UINT32, BASE_DEC, NULL, 0x0,
5370
16
        NULL, HFILL }
5371
16
    },
5372
16
    { &hf_batadv_tvlv_roam_addr,
5373
16
      { "Address", "batadv.batman.addr",
5374
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5375
16
        NULL, HFILL }
5376
16
    },
5377
16
    { &hf_batadv_tvlv_roam_vid,
5378
16
      { "VID", "batadv.tvlv.roam.vid",
5379
16
        FT_UINT16, BASE_HEX, NULL, 0x0,
5380
16
        NULL, HFILL }
5381
16
    },
5382
16
    { &hf_batadv_tvlv_vid_vlan,
5383
16
      { "VLAN ID", "batadv.tvlv.vid_vlan",
5384
16
        FT_UINT16, BASE_DEC, NULL, 0x7fff,
5385
16
        NULL, HFILL }
5386
16
    },
5387
16
    { &hf_batadv_tvlv_vid_tagged,
5388
16
      { "VLAN Tagged", "batadv.tvlv.vid_tagged",
5389
16
        FT_UINT16, BASE_DEC, NULL, 0x8000,
5390
16
        NULL, HFILL }
5391
16
    },
5392
16
    { &hf_batadv_tvlv_tt_flags,
5393
16
      { "Flags", "batadv.tvlv.tt.flags",
5394
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
5395
16
        NULL, HFILL }
5396
16
    },
5397
16
    { &hf_batadv_tvlv_tt_flags_type,
5398
16
      { "Query Type", "batadv.tvlv.tt.flags.type",
5399
16
        FT_UINT8, BASE_HEX, VALS(tvlv_tt_typenames),
5400
16
        BATADV_TVLVL_TT_TYPE_MASK,
5401
16
        NULL, HFILL }
5402
16
    },
5403
16
    { &hf_batadv_tvlv_tt_flags_full_table,
5404
16
      { "Full Table", "batadv.tvlv.tt.flags.full_table",
5405
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset),
5406
16
        BATADV_TVLVL_TT_FULL_TABLE,
5407
16
        NULL, HFILL }
5408
16
    },
5409
16
    { &hf_batadv_tvlv_tt_ttvn,
5410
16
      { "TT Version", "batadv.tvlv.tt.ttvn",
5411
16
        FT_UINT8, BASE_DEC, NULL, 0x0,
5412
16
        NULL, HFILL }
5413
16
    },
5414
16
    { &hf_batadv_tvlv_tt_num_vlan,
5415
16
      { "VLAN Entries", "batadv.tvlv.tt.num_vlan",
5416
16
        FT_UINT16, BASE_DEC, NULL, 0x0,
5417
16
        NULL, HFILL }
5418
16
    },
5419
16
    { &hf_batadv_tvlv_tt_vlan_crc,
5420
16
      { "CRC", "batadv.tvlv.tt.vlan.crc",
5421
16
        FT_UINT32, BASE_HEX, NULL, 0x0,
5422
16
        NULL, HFILL }
5423
16
    },
5424
16
    { &hf_batadv_tvlv_tt_vlan_crc_status,
5425
16
      { "Checksum Status", "batadv.tvlv.tt.vlan.crc.status",
5426
16
        FT_UINT8,   BASE_NONE, VALS(proto_checksum_vals), 0x0,
5427
16
        NULL, HFILL }
5428
16
    },
5429
16
    { &hf_batadv_tvlv_tt_vlan_vid,
5430
16
      { "VID", "batadv.tvlv.tt.vlan.vid",
5431
16
        FT_UINT16, BASE_HEX, NULL, 0x0,
5432
16
        NULL, HFILL }
5433
16
    },
5434
16
    { &hf_batadv_tvlv_tt_change_flags,
5435
16
      { "Flags", "batadv.tvlv.tt.change.flags",
5436
16
        FT_UINT8, BASE_HEX, NULL, 0x0,
5437
16
        NULL, HFILL }
5438
16
    },
5439
16
    { &hf_batadv_tvlv_tt_change_flags_del,
5440
16
      { "Delete", "batadv.tvlv.tt.change.flags.del",
5441
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset),
5442
16
        BATADV_TVLVL_TT_CHANGE_DEL,
5443
16
        NULL, HFILL }
5444
16
    },
5445
16
    { &hf_batadv_tvlv_tt_change_flags_roam,
5446
16
      { "Client Roam", "batadv.tvlv.tt.change.flags.roam",
5447
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset),
5448
16
        BATADV_TVLVL_TT_CHANGE_ROAM,
5449
16
        NULL, HFILL }
5450
16
    },
5451
16
    { &hf_batadv_tvlv_tt_change_flags_wifi,
5452
16
      { "Wifi Client", "batadv.tvlv.tt.change.flags.wifi",
5453
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset),
5454
16
        BATADV_TVLVL_TT_CHANGE_WIFI,
5455
16
        NULL, HFILL }
5456
16
    },
5457
16
    { &hf_batadv_tvlv_tt_change_flags_isolate,
5458
16
      { "Isolate", "batadv.tvlv.tt.change.flags.isolate",
5459
16
        FT_BOOLEAN, 8, TFS(&tfs_set_notset),
5460
16
        BATADV_TVLVL_TT_CHANGE_ISOLATE,
5461
16
        NULL, HFILL }
5462
16
    },
5463
16
    { &hf_batadv_tvlv_tt_change_addr,
5464
16
      { "Address", "batadv.tvlv.tt.change.addr",
5465
16
        FT_ETHER, BASE_NONE, NULL, 0x0,
5466
16
        NULL, HFILL }
5467
16
    },
5468
16
    { &hf_batadv_tvlv_tt_change_vid,
5469
16
      { "VID", "batadv.tvlv.tt.change.vid",
5470
16
        FT_UINT16, BASE_HEX, NULL, 0x0,
5471
16
        NULL, HFILL }
5472
16
    },
5473
16
  };
5474
5475
  /* Setup protocol subtree array */
5476
16
  static int *ett[] = {
5477
16
    &ett_batadv_batman,
5478
16
    &ett_batadv_batman_flags,
5479
16
    &ett_batadv_batman_tt,
5480
16
    &ett_batadv_batman_gwflags,
5481
16
    &ett_batadv_iv_ogm,
5482
16
    &ett_batadv_iv_ogm_flags,
5483
16
    &ett_batadv_elp,
5484
16
    &ett_batadv_ogm2,
5485
    //&ett_batadv_ogm2_flags,
5486
16
    &ett_batadv_bcast,
5487
16
    &ett_batadv_icmp,
5488
16
    &ett_batadv_icmp_rr,
5489
16
    &ett_batadv_unicast,
5490
16
    &ett_batadv_unicast_4addr,
5491
16
    &ett_batadv_unicast_frag,
5492
16
    &ett_batadv_unicast_tvlv,
5493
16
    &ett_batadv_vis,
5494
16
    &ett_batadv_vis_entry,
5495
16
    &ett_batadv_tt_query,
5496
16
    &ett_batadv_tt_query_flags,
5497
16
    &ett_batadv_tt_entry,
5498
16
    &ett_batadv_tt_entry_flags,
5499
16
    &ett_batadv_roam_adv,
5500
16
    &ett_batadv_coded,
5501
16
    &ett_batadv_tvlv,
5502
16
    &ett_batadv_tvlv_vid,
5503
16
    &ett_batadv_tvlv_mcast_flags,
5504
16
    &ett_batadv_tvlv_tt_flags,
5505
16
    &ett_batadv_tvlv_tt_vlan,
5506
16
    &ett_batadv_tvlv_tt_change,
5507
16
    &ett_msg_fragment,
5508
16
    &ett_msg_fragments
5509
16
  };
5510
5511
16
  static ei_register_info ei[] = {
5512
16
    { &ei_batadv_too_deep, { "batadv.too_deep", PI_UNDECODED, PI_WARN, "Payload nested too deep, not dissected", EXPFILL }},
5513
16
    { &ei_batadv_tvlv_unknown_version, { "batadv.error.tvlv_version_unknown", PI_UNDECODED, PI_ERROR, "BATADV Error: unknown TVLV version", EXPFILL }},
5514
16
    { &ei_batadv_tvlv_tt_vlan_crc, { "batadv.tvlv_tt_crc_bad", PI_UNDECODED, PI_ERROR, "BATADV Error: bad TT VLAN crc", EXPFILL }},
5515
16
    { &ei_batadv_tvlv_tt_vlan_empty, { "batadv.tvlv_tt_vlan_empty", PI_SEQUENCE, PI_WARN, "BATADV Warn: empty VLAN", EXPFILL }},
5516
16
  };
5517
5518
16
  proto_batadv_plugin = proto_register_protocol("B.A.T.M.A.N. Advanced Protocol", "BATADV", "batadv");
5519
5520
16
  batman_handle = register_dissector("batadv",dissect_batadv_plugin,proto_batadv_plugin);
5521
5522
16
  batadv_module = prefs_register_protocol(proto_batadv_plugin,
5523
16
            proto_reg_handoff_batadv);
5524
5525
16
  prefs_register_uint_preference(batadv_module, "batmanadv.ethertype",
5526
16
               "Ethertype",
5527
16
               "Ethertype used to indicate B.A.T.M.A.N. packet.",
5528
16
               16, &batadv_ethertype);
5529
5530
16
  proto_register_subtree_array(ett, array_length(ett));
5531
16
  proto_register_field_array(proto_batadv_plugin, hf, array_length(hf));
5532
5533
16
  expert_batadv = expert_register_protocol(proto_batadv_plugin);
5534
16
  expert_register_field_array(expert_batadv, ei, array_length(ei));
5535
5536
16
  reassembly_table_register(&msg_reassembly_table,
5537
16
            &addresses_reassembly_table_functions);
5538
5539
16
  batadv_tap = register_tap("batman");
5540
16
  batadv_follow_tap = register_tap("batman_follow");
5541
16
}
5542
5543
void proto_reg_handoff_batadv(void)
5544
16
{
5545
16
  static bool inited = false;
5546
16
  static unsigned int old_batadv_ethertype;
5547
5548
16
  if (!inited) {
5549
16
    eth_handle = find_dissector_add_dependency("eth_withoutfcs", proto_batadv_plugin);
5550
5551
16
    inited = true;
5552
16
  } else {
5553
0
    dissector_delete_uint("ethertype", old_batadv_ethertype, batman_handle);
5554
0
  }
5555
5556
16
  old_batadv_ethertype = batadv_ethertype;
5557
16
  dissector_add_uint("ethertype", batadv_ethertype, batman_handle);
5558
16
}
5559
5560
/*
5561
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
5562
 *
5563
 * Local variables:
5564
 * c-basic-offset: 8
5565
 * tab-width: 8
5566
 * indent-tabs-mode: t
5567
 * End:
5568
 *
5569
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
5570
 * :indentSize=8:tabSize=8:noTabs=false:
5571
 */