epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-dvmrp.c
blob8f8b1687179034ae76044b644abdd5d45058ecde
1 /* packet-dvmrp.c 2001 Ronnie Sahlberg <See AUTHORS for email>
2 * Routines for IGMP/DVMRP packet disassembly
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
13 DVMRP DVMRP
14 code v1 v3
16 0x01 * *
17 0x02 * *
18 0x03 x
19 0x04 x
20 0x07 x
21 0x08 x
22 0x09 x
25 * V3 has len>=8 and byte[6]==0xff and byte[7]==0x03
28 DVMRP is defined in the following RFCs
29 RFC1075 Version 1
30 draft-ietf-idmr-dvmrp-v3-10.txt Version 3
32 V1 and V3 can be distinguished by looking at bytes 6 and 7 in the
33 IGMP/DVMRP header.
34 If header[6]==0xff and header[7]==0x03 we have version 3.
37 RFC1075 has typos in 3.12.2 and 3.12.4, see if you can spot them.
40 #include "config.h"
42 #include <epan/packet.h>
43 #include <epan/prefs.h>
44 #include <epan/expert.h>
45 #include <epan/tfs.h>
46 #include "packet-igmp.h"
48 void proto_register_dvmrp(void);
49 void proto_reg_handoff_dvmrp(void);
51 static dissector_handle_t dvmrp_handle;
53 static int proto_dvmrp;
54 static int hf_version;
55 static int hf_type;
56 static int hf_code_v1;
57 static int hf_checksum;
58 static int hf_checksum_status;
59 static int hf_reserved;
60 static int hf_commands;
61 static int hf_command;
62 static int hf_count;
63 static int hf_afi;
64 static int hf_netmask;
65 static int hf_metric;
66 static int hf_dest_unr;
67 static int hf_split_horiz;
68 static int hf_infinity;
69 static int hf_daddr;
70 static int hf_maddr;
71 static int hf_hold;
72 static int hf_code_v3;
73 static int hf_capabilities;
74 static int hf_cap_leaf;
75 static int hf_cap_prune;
76 static int hf_cap_genid;
77 static int hf_cap_mtrace;
78 static int hf_cap_snmp;
79 static int hf_cap_netmask;
80 static int hf_min_ver;
81 static int hf_maj_ver;
82 static int hf_genid;
83 static int hf_route;
84 static int hf_saddr;
85 static int hf_life;
86 static int hf_local;
87 static int hf_threshold;
88 static int hf_flags;
89 static int hf_flag_tunnel;
90 static int hf_flag_srcroute;
91 static int hf_flag_down;
92 static int hf_flag_disabled;
93 static int hf_flag_querier;
94 static int hf_flag_leaf;
95 static int hf_ncount;
96 static int hf_neighbor;
98 static int ett_dvmrp;
99 static int ett_commands;
100 static int ett_capabilities;
101 static int ett_flags;
102 static int ett_route;
104 static expert_field ei_checksum;
106 static bool strict_v3;
108 #define DVMRP_TYPE 0x13
109 static const value_string dvmrp_type[] = {
110 {DVMRP_TYPE, "DVMRP" },
111 {0, NULL}
114 #define DVMRP_V1_RESPONSE 1
115 #define DVMRP_V1_REQUEST 2
116 #define DVMRP_V1_NON_MEMBERSHIP_REPORT 3
117 #define DVMRP_V1_NON_MEMBERSHIP_CANCELLATION 4
118 static const value_string code_v1[] = {
119 {DVMRP_V1_RESPONSE, "Response" },
120 {DVMRP_V1_REQUEST, "Request" },
121 {DVMRP_V1_NON_MEMBERSHIP_REPORT, "Non-membership report" },
122 {DVMRP_V1_NON_MEMBERSHIP_CANCELLATION, "Non-membership cancellation" },
123 {0, NULL}
126 #define DVMRP_V3_PROBE 0x1
127 #define DVMRP_V3_REPORT 0x2
128 #define DVMRP_V3_ASK_NEIGHBORS 0x3
129 #define DVMRP_V3_NEIGHBORS 0x4
130 #define DVMRP_V3_ASK_NEIGHBORS_2 0x5
131 #define DVMRP_V3_NEIGHBORS_2 0x6
132 #define DVMRP_V3_PRUNE 0x7
133 #define DVMRP_V3_GRAFT 0x8
134 #define DVMRP_V3_GRAFT_ACK 0x9
135 static const value_string code_v3[] = {
136 {DVMRP_V3_PROBE, "Probe"},
137 {DVMRP_V3_REPORT, "Report"},
138 {DVMRP_V3_ASK_NEIGHBORS, "Ask Neighbors"},
139 {DVMRP_V3_NEIGHBORS, "Neighbors"},
140 {DVMRP_V3_ASK_NEIGHBORS_2, "Ask Neighbors 2"},
141 {DVMRP_V3_NEIGHBORS_2, "Neighbors 2"},
142 {DVMRP_V3_PRUNE, "Prune"},
143 {DVMRP_V3_GRAFT, "Graft"},
144 {DVMRP_V3_GRAFT_ACK, "Graft ACK"},
145 {0, NULL}
148 #define DVMRP_V3_CAP_LEAF 0x01
149 #define DVMRP_V3_CAP_PRUNE 0x02
150 #define DVMRP_V3_CAP_GENID 0x04
151 #define DVMRP_V3_CAP_MTRACE 0x08
152 #define DVMRP_V3_CAP_SNMP 0x10
153 #define DVMRP_V3_CAP_NETMASK 0x20
155 #define DVMRP_V3_FLAG_TUNNEL 0x01
156 #define DVMRP_V3_FLAG_SRCROUTE 0x02
157 #define DVMRP_V3_FLAG_DOWN 0x10
158 #define DVMRP_V3_FLAG_DISABLED 0x20
159 #define DVMRP_V3_FLAG_QUERIER 0x40
160 #define DVMRP_V3_FLAG_LEAF 0x80
163 #define V1_COMMAND_NULL 0
164 #define V1_COMMAND_AFI 2
165 #define V1_COMMAND_SUBNETMASK 3
166 #define V1_COMMAND_METRIC 4
167 #define V1_COMMAND_FLAGS0 5
168 #define V1_COMMAND_INFINITY 6
169 #define V1_COMMAND_DA 7
170 #define V1_COMMAND_RDA 8
171 #define V1_COMMAND_NMR 9
172 #define V1_COMMAND_NMR_CANCEL 10
173 static const value_string command[] = {
174 {V1_COMMAND_NULL, "NULL" },
175 {V1_COMMAND_AFI, "Address Family Indicator"},
176 {V1_COMMAND_SUBNETMASK, "Subnetmask"},
177 {V1_COMMAND_METRIC, "Metric"},
178 {V1_COMMAND_FLAGS0, "Flags0"},
179 {V1_COMMAND_INFINITY, "Infinity"},
180 {V1_COMMAND_DA, "Destination Address"},
181 {V1_COMMAND_RDA, "Requested Destination Address"},
182 {V1_COMMAND_NMR, "Non-Membership Report"},
183 {V1_COMMAND_NMR_CANCEL, "Non-Membership Report Cancel"},
184 {0, NULL}
187 #define V1_AFI_IP 2
188 static const value_string afi[] = {
189 {V1_AFI_IP, "IP v4 Family"},
190 {0, NULL}
193 static const true_false_string tfs_dest_unreach = {
194 "Destination Unreachable",
195 "NOT Destination Unreachable"
198 static const true_false_string tfs_split_horiz = {
199 "Split Horizon concealed route",
200 "NOT Split Horizon concealed route"
203 static const true_false_string tfs_cap_leaf = {
204 "Leaf",
205 "NOT Leaf"
207 static const true_false_string tfs_cap_prune = {
208 "Prune capable",
209 "NOT Prune capable"
211 static const true_false_string tfs_cap_genid = {
212 "Genid capable",
213 "NOT Genid capable"
215 static const true_false_string tfs_cap_mtrace = {
216 "Multicast Traceroute capable",
217 "NOT Multicast Traceroute capable"
219 static const true_false_string tfs_cap_snmp = {
220 "SNMP capable",
221 "NOT SNMP capable"
223 static const true_false_string tfs_cap_netmask = {
224 "Netmask capable",
225 "NOT Netmask capable"
228 static int
229 dissect_v3_report(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
231 uint8_t m0,m1,m2,m3;
232 uint8_t s0,s1,s2,s3;
233 uint8_t metric;
234 uint32_t ip;
236 while (tvb_reported_length_remaining(tvb, offset) > 0) {
237 proto_tree *tree;
238 proto_item *item;
239 int old_offset_a = offset;
241 item = proto_tree_add_item(parent_tree, hf_route,
242 tvb, offset, -1, ENC_NA);
243 tree = proto_item_add_subtree(item, ett_route);
245 m0 = 0xff;
246 /* read the mask */
247 m1 = tvb_get_uint8(tvb, offset);
248 m2 = tvb_get_uint8(tvb, offset+1);
249 m3 = tvb_get_uint8(tvb, offset+2);
251 ip = m3;
252 ip = (ip<<8)|m2;
253 ip = (ip<<8)|m1;
254 ip = (ip<<8)|m0;
255 proto_tree_add_ipv4(tree, hf_netmask, tvb, offset, 3, ip);
257 offset += 3;
259 /* read every srcnet, metric pairs */
260 do {
261 int old_offset_b = offset;
262 m0 = 0xff;
264 s1 = 0;
265 s2 = 0;
266 s3 = 0;
268 s0 = tvb_get_uint8(tvb, offset);
269 offset += 1;
270 if (m1) {
271 s1 = tvb_get_uint8(tvb, offset);
272 offset += 1;
274 if (m2) {
275 s2 = tvb_get_uint8(tvb, offset);
276 offset += 1;
278 if (m3) {
279 s3 = tvb_get_uint8(tvb, offset);
280 offset += 1;
283 /* handle special case for default route V3/3.4.3 */
284 if ((!m1)&&(!m2)&&(!m3)&&(!s0)) {
285 m0 = 0;
288 ip = s3;
289 ip = (ip<<8)|s2;
290 ip = (ip<<8)|s1;
291 ip = (ip<<8)|s0;
292 proto_tree_add_ipv4_format(tree, hf_saddr, tvb,
293 old_offset_b, offset-old_offset_b, ip,
294 "%s %d.%d.%d.%d (netmask %d.%d.%d.%d)",
295 m0?"Source Network":"Default Route",
296 s0,s1,s2,s3,m0,m1,m2,m3);
298 metric = tvb_get_uint8(tvb, offset);
299 proto_tree_add_uint(tree, hf_metric, tvb,
300 offset, 1, metric&0x7f);
301 offset += 1;
304 } while (!(metric&0x80));
306 proto_item_set_len(item, offset-old_offset_a);
309 return offset;
312 static int
313 dissect_dvmrp_v3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
315 uint8_t code;
317 /* version */
318 proto_tree_add_uint(parent_tree, hf_version, tvb, 0, 0, 3);
320 /* type of command */
321 proto_tree_add_uint(parent_tree, hf_type, tvb, offset, 1, 0x13);
322 offset += 1;
324 /* code */
325 code = tvb_get_uint8(tvb, offset);
326 proto_tree_add_uint(parent_tree, hf_code_v3, tvb, offset, 1, code);
327 offset += 1;
328 col_add_fstr(pinfo->cinfo, COL_INFO,
329 "V%d %s",3 ,val_to_str(code, code_v3,
330 "Unknown Type:0x%02x"));
332 /* checksum */
333 igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_status, &ei_checksum, pinfo, 0);
334 offset += 2;
336 /* skip unused byte */
337 proto_tree_add_item(parent_tree, hf_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
338 offset += 1;
340 /* PROBE and NEIGHBORS 2 packets have capabilities flags, unused
341 for other packets */
342 if (code==DVMRP_V3_PROBE || code==DVMRP_V3_NEIGHBORS_2) {
343 static int * const capabilities[] = {
344 &hf_cap_netmask,
345 &hf_cap_snmp,
346 &hf_cap_mtrace,
347 &hf_cap_genid,
348 &hf_cap_prune,
349 &hf_cap_leaf,
350 NULL
353 proto_tree_add_bitmask(parent_tree, tvb, offset, hf_capabilities,
354 ett_capabilities, capabilities, ENC_NA);
356 offset += 1;
358 /* minor version */
359 proto_tree_add_item(parent_tree, hf_min_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
360 offset += 1;
362 /* major version */
363 proto_tree_add_item(parent_tree, hf_maj_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
364 offset += 1;
366 switch (code) {
367 case DVMRP_V3_PROBE:
368 /* generation id */
369 proto_tree_add_item(parent_tree, hf_genid, tvb,
370 offset, 4, ENC_BIG_ENDIAN);
371 offset += 4;
372 while (tvb_reported_length_remaining(tvb, offset)>=4) {
373 proto_tree_add_item(parent_tree, hf_neighbor,
374 tvb, offset, 4, ENC_BIG_ENDIAN);
375 offset += 4;
377 break;
378 case DVMRP_V3_REPORT:
379 offset = dissect_v3_report(tvb, parent_tree, offset);
380 break;
381 case DVMRP_V3_PRUNE:
382 /* source address */
383 proto_tree_add_item(parent_tree, hf_saddr,
384 tvb, offset, 4, ENC_BIG_ENDIAN);
385 offset += 4;
386 /* group address */
387 proto_tree_add_item(parent_tree, hf_maddr,
388 tvb, offset, 4, ENC_BIG_ENDIAN);
389 offset += 4;
390 /* prune lifetime */
391 proto_tree_add_item(parent_tree, hf_life,
392 tvb, offset, 4, ENC_BIG_ENDIAN);
393 offset += 4;
394 /* source netmask */
395 if (tvb_reported_length_remaining(tvb, offset)>=4) {
396 proto_tree_add_item(parent_tree, hf_netmask,
397 tvb, offset, 4, ENC_BIG_ENDIAN);
398 offset += 4;
400 break;
401 case DVMRP_V3_GRAFT:
402 /* source address */
403 proto_tree_add_item(parent_tree, hf_saddr,
404 tvb, offset, 4, ENC_BIG_ENDIAN);
405 offset += 4;
406 /* group address */
407 proto_tree_add_item(parent_tree, hf_maddr,
408 tvb, offset, 4, ENC_BIG_ENDIAN);
409 offset += 4;
410 /* source netmask */
411 if (tvb_reported_length_remaining(tvb, offset)>=4) {
412 proto_tree_add_item(parent_tree, hf_netmask,
413 tvb, offset, 4, ENC_BIG_ENDIAN);
414 offset += 4;
416 break;
417 case DVMRP_V3_GRAFT_ACK:
418 /* source address */
419 proto_tree_add_item(parent_tree, hf_saddr,
420 tvb, offset, 4, ENC_BIG_ENDIAN);
421 offset += 4;
422 /* group address */
423 proto_tree_add_item(parent_tree, hf_maddr,
424 tvb, offset, 4, ENC_BIG_ENDIAN);
425 offset += 4;
426 /* source netmask */
427 if (tvb_reported_length_remaining(tvb, offset)>=4) {
428 proto_tree_add_item(parent_tree, hf_netmask,
429 tvb, offset, 4, ENC_BIG_ENDIAN);
430 offset += 4;
432 break;
433 case DVMRP_V3_ASK_NEIGHBORS:
434 case DVMRP_V3_NEIGHBORS:
435 /* XXX - obsolete, and the draft doesn't describe them */
436 break;
437 case DVMRP_V3_ASK_NEIGHBORS_2:
438 /* No data */
439 break;
440 case DVMRP_V3_NEIGHBORS_2:
441 while (tvb_reported_length_remaining(tvb, offset)>=12) {
442 uint8_t neighbor_count;
444 /* local address */
445 proto_tree_add_item(parent_tree, hf_local,
446 tvb, offset, 4, ENC_BIG_ENDIAN);
447 offset += 4;
448 /* Metric */
449 proto_tree_add_item(parent_tree, hf_metric,
450 tvb, offset, 1, ENC_BIG_ENDIAN);
451 offset += 1;
452 /* Threshold */
453 proto_tree_add_item(parent_tree, hf_threshold,
454 tvb, offset, 1, ENC_BIG_ENDIAN);
455 offset += 1;
456 /* Flags */
458 proto_tree *tree;
459 proto_item *item;
461 item = proto_tree_add_item(parent_tree, hf_flags,
462 tvb, offset, 1, ENC_NA);
463 tree = proto_item_add_subtree(item, ett_flags);
465 proto_tree_add_item(tree, hf_flag_tunnel, tvb,
466 offset, 1, ENC_BIG_ENDIAN);
467 proto_tree_add_item(tree, hf_flag_srcroute, tvb,
468 offset, 1, ENC_BIG_ENDIAN);
469 proto_tree_add_item(tree, hf_flag_down, tvb,
470 offset, 1, ENC_BIG_ENDIAN);
471 proto_tree_add_item(tree, hf_flag_disabled, tvb,
472 offset, 1, ENC_BIG_ENDIAN);
473 proto_tree_add_item(tree, hf_flag_querier, tvb,
474 offset, 1, ENC_BIG_ENDIAN);
475 proto_tree_add_item(tree, hf_flag_leaf, tvb,
476 offset, 1, ENC_BIG_ENDIAN);
478 offset += 1;
479 /* Neighbor count */
480 neighbor_count = tvb_get_uint8(tvb, offset);
481 proto_tree_add_item(parent_tree, hf_ncount,
482 tvb, offset, 1, ENC_BIG_ENDIAN);
483 offset += 1;
485 while ((tvb_reported_length_remaining(tvb, offset)>=4)
486 && (neighbor_count>0)) {
487 proto_tree_add_item(parent_tree, hf_neighbor,
488 tvb, offset, 4, ENC_BIG_ENDIAN);
489 offset += 4;
490 neighbor_count--;
493 break;
496 return offset;
500 static int
501 dissect_dvmrp_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
503 uint8_t code;
504 uint8_t af=2; /* default */
506 /* version */
507 proto_tree_add_uint(parent_tree, hf_version, tvb, 0, 0, 1);
509 /* type of command */
510 proto_tree_add_uint(parent_tree, hf_type, tvb, offset, 1, 0x13);
511 offset += 1;
513 /* code */
514 code = tvb_get_uint8(tvb, offset);
515 proto_tree_add_uint(parent_tree, hf_code_v1, tvb, offset, 1, code);
516 offset += 1;
517 col_add_fstr(pinfo->cinfo, COL_INFO,
518 "V%d %s",1 ,val_to_str(code, code_v1,
519 "Unknown Type:0x%02x"));
521 /* checksum */
522 igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_status, &ei_checksum, pinfo, 0);
523 offset += 2;
525 /* decode all the v1 commands */
526 while (tvb_reported_length_remaining(tvb, offset) > 0) {
527 proto_tree *tree;
528 proto_item *item;
529 uint8_t cmd,count;
530 int old_offset = offset;
532 item = proto_tree_add_item(parent_tree, hf_commands,
533 tvb, offset, -1, ENC_NA);
534 tree = proto_item_add_subtree(item, ett_commands);
536 cmd = tvb_get_uint8(tvb, offset);
537 proto_tree_add_uint(tree, hf_command, tvb,
538 offset, 1, cmd);
539 offset += 1;
541 switch (cmd){
542 case V1_COMMAND_NULL:
543 offset += 1; /* skip ignored/pad byte*/
544 if (item) {
545 proto_item_set_text(item, "Command: NULL");
547 break;
548 case V1_COMMAND_AFI:
549 af = tvb_get_uint8(tvb, offset);
550 proto_tree_add_uint(tree, hf_afi, tvb,
551 offset, 1, af);
552 offset += 1;
553 if (item) {
554 proto_item_set_text(item, "%s: %s",
555 val_to_str(cmd, command, "Unknown Command:0x%02x"),
556 val_to_str(af, afi, "Unknown Family:0x%02x")
559 break;
560 case V1_COMMAND_SUBNETMASK:
561 count = tvb_get_uint8(tvb, offset);
562 proto_tree_add_uint(tree, hf_count, tvb,
563 offset, 1, count);
564 offset += 1;
565 if (count) { /* must be 0 or 1 */
566 proto_tree_add_item(tree, hf_netmask,
567 tvb, offset, 4, ENC_BIG_ENDIAN);
568 if (item) {
569 proto_item_set_text(item, "%s: %d.%d.%d.%d",
570 val_to_str(cmd, command, "Unknown Command:0x%02x"),
571 tvb_get_uint8(tvb, offset),
572 tvb_get_uint8(tvb, offset+1),
573 tvb_get_uint8(tvb, offset+2),
574 tvb_get_uint8(tvb, offset+3));
576 offset += 4;
577 } else {
578 if (item) {
579 proto_item_set_text(item, "%s: <no mask supplied>",
580 val_to_str(cmd, command, "Unknown Command:0x%02x"));
583 break;
584 case V1_COMMAND_METRIC:
585 proto_tree_add_item(tree, hf_metric, tvb,
586 offset, 1, ENC_BIG_ENDIAN);
587 if (item) {
588 proto_item_set_text(item, "%s: %d",
589 val_to_str(cmd, command, "Unknown Command:0x%02x"),
590 tvb_get_uint8(tvb, offset));
592 offset += 1;
593 break;
594 case V1_COMMAND_FLAGS0:
595 count = tvb_get_uint8(tvb, offset);
596 proto_tree_add_boolean(tree, hf_dest_unr, tvb, offset, 1, count);
597 proto_tree_add_boolean(tree, hf_split_horiz, tvb, offset, 1, count);
598 if (item) {
599 proto_item_set_text(item, "%s: 0x%02x",
600 val_to_str(cmd, command, "Unknown Command:0x%02x"), count);
602 offset += 1;
603 break;
604 case V1_COMMAND_INFINITY:
605 proto_tree_add_item(tree, hf_infinity, tvb,
606 offset, 1, ENC_BIG_ENDIAN);
607 if (item) {
608 proto_item_set_text(item, "%s: %d",
609 val_to_str(cmd, command, "Unknown Command:0x%02x"), tvb_get_uint8(tvb, offset));
611 offset += 1;
612 break;
613 case V1_COMMAND_DA:
614 case V1_COMMAND_RDA: /* same as DA */
615 count = tvb_get_uint8(tvb, offset);
616 proto_tree_add_uint(tree, hf_count, tvb,
617 offset, 1, count);
618 offset += 1;
619 while (count--) {
620 proto_tree_add_item(tree, hf_daddr,
621 tvb, offset, 4, ENC_BIG_ENDIAN);
622 offset += 4;
624 if (item) {
625 proto_item_set_text(item, "%s",
626 val_to_str(cmd, command, "Unknown Command:0x%02x"));
628 break;
629 case V1_COMMAND_NMR:
630 count = tvb_get_uint8(tvb, offset);
631 proto_tree_add_uint(tree, hf_count, tvb,
632 offset, 1, count);
633 offset += 1;
634 while (count--) {
635 proto_tree_add_item(tree, hf_maddr,
636 tvb, offset, 4, ENC_BIG_ENDIAN);
637 offset += 4;
638 proto_tree_add_item(tree, hf_hold, tvb,
639 offset, 4, ENC_BIG_ENDIAN);
640 offset += 4;
642 if (item) {
643 proto_item_set_text(item, "%s",
644 val_to_str(cmd, command, "Unknown Command:0x%02x"));
646 break;
647 case V1_COMMAND_NMR_CANCEL:
648 count = tvb_get_uint8(tvb, offset);
649 proto_tree_add_uint(tree, hf_count, tvb,
650 offset, 1, count);
651 offset += 1;
652 while (count--) {
653 proto_tree_add_item(tree, hf_maddr,
654 tvb, offset, 4, ENC_BIG_ENDIAN);
655 offset += 4;
657 if (item) {
658 proto_item_set_text(item, "%s",
659 val_to_str(cmd, command, "Unknown Command:0x%02x"));
661 break;
664 proto_item_set_len(item, offset-old_offset);
667 return offset;
670 /* This function is only called from the IGMP dissector */
671 static int
672 dissect_dvmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
674 proto_tree *tree;
675 proto_item *item;
676 int offset = 0;
678 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DVMRP");
679 col_clear(pinfo->cinfo, COL_INFO);
681 item = proto_tree_add_item(parent_tree, proto_dvmrp, tvb, offset, -1, ENC_NA);
682 tree = proto_item_add_subtree(item, ett_dvmrp);
684 if ((tvb_captured_length_remaining(tvb, offset)>=8)
685 && (((tvb_get_uint8(tvb, 6)==0xff)
686 && (tvb_get_uint8(tvb, 7)==0x03))
687 || !strict_v3)) {
688 offset = dissect_dvmrp_v3(tvb, pinfo, tree, offset);
689 } else {
690 offset = dissect_dvmrp_v1(tvb, pinfo, tree, offset);
693 proto_item_set_len(item, offset);
694 return offset;
697 void
698 proto_register_dvmrp(void)
700 static hf_register_info hf[] = {
701 { &hf_version,
702 { "DVMRP Version", "dvmrp.version", FT_UINT8, BASE_DEC,
703 NULL, 0, NULL, HFILL }},
705 { &hf_type,
706 { "Type", "dvmrp.type", FT_UINT8, BASE_HEX,
707 VALS(dvmrp_type), 0, "DVMRP Packet Type", HFILL }},
709 { &hf_code_v1,
710 { "Code", "dvmrp.v1.code", FT_UINT8, BASE_HEX,
711 VALS(code_v1), 0, "DVMRP Packet Code", HFILL }},
713 { &hf_checksum,
714 { "Checksum", "dvmrp.checksum", FT_UINT16, BASE_HEX,
715 NULL, 0, "DVMRP Checksum", HFILL }},
717 { &hf_checksum_status,
718 { "Checksum Status", "dvmrp.checksum.status", FT_UINT8, BASE_NONE,
719 VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
721 { &hf_reserved,
722 { "Reserved", "dvmrp.reserved", FT_UINT16, BASE_HEX,
723 NULL, 0, "DVMRP v3 Reserved", HFILL }},
725 { &hf_commands,
726 { "Commands", "dvmrp.commands", FT_NONE, BASE_NONE,
727 NULL, 0, "DVMRP V1 Commands", HFILL }},
729 { &hf_command,
730 { "Command", "dvmrp.command", FT_UINT8, BASE_HEX,
731 VALS(command), 0, "DVMRP V1 Command", HFILL }},
733 { &hf_afi,
734 { "Address Family", "dvmrp.afi", FT_UINT8, BASE_HEX,
735 VALS(afi), 0, "DVMRP Address Family Indicator", HFILL }},
737 { &hf_count,
738 { "Count", "dvmrp.count", FT_UINT8, BASE_HEX,
739 NULL, 0, NULL, HFILL }},
741 { &hf_netmask,
742 { "Netmask", "dvmrp.netmask", FT_IPv4, BASE_NETMASK,
743 NULL, 0, "DVMRP Netmask", HFILL }},
745 { &hf_metric,
746 { "Metric", "dvmrp.metric", FT_UINT8, BASE_DEC,
747 NULL, 0, "DVMRP Metric", HFILL }},
749 {&hf_dest_unr,
750 { "Destination Unreachable", "dvmrp.dest_unreach", FT_BOOLEAN, 8,
751 TFS(&tfs_dest_unreach), 0x01, NULL, HFILL }},
753 {&hf_split_horiz,
754 { "Split Horizon", "dvmrp.split_horiz", FT_BOOLEAN, 8,
755 TFS(&tfs_split_horiz), 0x02, "Split Horizon concealed route", HFILL }},
757 { &hf_infinity,
758 { "Infinity", "dvmrp.infinity", FT_UINT8, BASE_DEC,
759 NULL, 0, "DVMRP Infinity", HFILL }},
761 { &hf_daddr,
762 { "Dest Addr", "dvmrp.daddr", FT_IPv4, BASE_NONE,
763 NULL, 0, "DVMRP Destination Address", HFILL }},
765 { &hf_maddr,
766 { "Multicast Addr", "dvmrp.maddr", FT_IPv4, BASE_NONE,
767 NULL, 0, "DVMRP Multicast Address", HFILL }},
769 { &hf_hold,
770 { "Hold Time", "dvmrp.hold", FT_UINT32, BASE_DEC,
771 NULL, 0, "DVMRP Hold Time in seconds", HFILL }},
773 { &hf_code_v3,
774 { "Code", "dvmrp.v3.code", FT_UINT8, BASE_HEX,
775 VALS(code_v3), 0, "DVMRP Packet Code", HFILL }},
777 { &hf_capabilities,
778 { "Capabilities", "dvmrp.capabilities", FT_UINT8, BASE_HEX,
779 NULL, 0, "DVMRP V3 Capabilities", HFILL }},
781 {&hf_cap_leaf,
782 { "Leaf", "dvmrp.cap.leaf", FT_BOOLEAN, 8,
783 TFS(&tfs_cap_leaf), DVMRP_V3_CAP_LEAF, NULL, HFILL }},
785 {&hf_cap_prune,
786 { "Prune", "dvmrp.cap.prune", FT_BOOLEAN, 8,
787 TFS(&tfs_cap_prune), DVMRP_V3_CAP_PRUNE, "Prune capability", HFILL }},
789 {&hf_cap_genid,
790 { "Genid", "dvmrp.cap.genid", FT_BOOLEAN, 8,
791 TFS(&tfs_cap_genid), DVMRP_V3_CAP_GENID, "Genid capability", HFILL }},
793 {&hf_cap_mtrace,
794 { "Mtrace", "dvmrp.cap.mtrace", FT_BOOLEAN, 8,
795 TFS(&tfs_cap_mtrace), DVMRP_V3_CAP_MTRACE, "Mtrace capability", HFILL }},
797 {&hf_cap_snmp,
798 { "SNMP", "dvmrp.cap.snmp", FT_BOOLEAN, 8,
799 TFS(&tfs_cap_snmp), DVMRP_V3_CAP_SNMP, "SNMP capability", HFILL }},
801 {&hf_cap_netmask,
802 { "Netmask", "dvmrp.cap.netmask", FT_BOOLEAN, 8,
803 TFS(&tfs_cap_netmask), DVMRP_V3_CAP_NETMASK, "Netmask capability", HFILL }},
805 { &hf_min_ver,
806 { "Minor Version", "dvmrp.min_ver", FT_UINT8, BASE_HEX,
807 NULL, 0, "DVMRP Minor Version", HFILL }},
809 { &hf_maj_ver,
810 { "Major Version", "dvmrp.maj_ver", FT_UINT8, BASE_HEX,
811 NULL, 0, "DVMRP Major Version", HFILL }},
813 { &hf_genid,
814 { "Generation ID", "dvmrp.genid", FT_UINT32, BASE_DEC,
815 NULL, 0, "DVMRP Generation ID", HFILL }},
817 { &hf_route,
818 { "Route", "dvmrp.route", FT_NONE, BASE_NONE,
819 NULL, 0, "DVMRP V3 Route Report", HFILL }},
821 { &hf_saddr,
822 { "Source Addr", "dvmrp.saddr", FT_IPv4, BASE_NONE,
823 NULL, 0, "DVMRP Source Address", HFILL }},
825 { &hf_life,
826 { "Prune lifetime", "dvmrp.lifetime", FT_UINT32, BASE_DEC,
827 NULL, 0, "DVMRP Prune Lifetime", HFILL }},
829 { &hf_local,
830 { "Local Addr", "dvmrp.local", FT_IPv4, BASE_NONE,
831 NULL, 0, "DVMRP Local Address", HFILL }},
833 { &hf_threshold,
834 { "Threshold", "dvmrp.threshold", FT_UINT8, BASE_DEC,
835 NULL, 0, "DVMRP Interface Threshold", HFILL }},
837 { &hf_flags,
838 { "Flags", "dvmrp.flags", FT_NONE, BASE_NONE,
839 NULL, 0, "DVMRP Interface Flags", HFILL }},
841 { &hf_flag_tunnel,
842 { "Tunnel", "dvmrp.flag.tunnel", FT_BOOLEAN, 8,
843 NULL, DVMRP_V3_FLAG_TUNNEL, "Neighbor reached via tunnel", HFILL }},
845 { &hf_flag_srcroute,
846 { "Source Route", "dvmrp.flag.srcroute", FT_BOOLEAN, 8,
847 NULL, DVMRP_V3_FLAG_SRCROUTE, "Tunnel uses IP source routing", HFILL }},
849 { &hf_flag_down,
850 { "Down", "dvmrp.flag.down", FT_BOOLEAN, 8,
851 NULL, DVMRP_V3_FLAG_DOWN, "Operational status down", HFILL }},
853 { &hf_flag_disabled,
854 { "Disabled", "dvmrp.flag.disabled", FT_BOOLEAN, 8,
855 NULL, DVMRP_V3_FLAG_DISABLED, "Administrative status down", HFILL }},
857 { &hf_flag_querier,
858 { "Querier", "dvmrp.flag.querier", FT_BOOLEAN, 8,
859 NULL, DVMRP_V3_FLAG_QUERIER, "Querier for interface", HFILL }},
861 { &hf_flag_leaf,
862 { "Leaf", "dvmrp.flag.leaf", FT_BOOLEAN, 8,
863 NULL, DVMRP_V3_FLAG_LEAF, "No downstream neighbors on interface", HFILL }},
865 { &hf_ncount,
866 { "Neighbor Count", "dvmrp.ncount", FT_UINT8, BASE_DEC,
867 NULL, 0, "DVMRP Neighbor Count", HFILL }},
869 { &hf_neighbor,
870 { "Neighbor Addr", "dvmrp.neighbor", FT_IPv4, BASE_NONE,
871 NULL, 0, "DVMRP Neighbor Address", HFILL }}
873 static int *ett[] = {
874 &ett_dvmrp,
875 &ett_commands,
876 &ett_capabilities,
877 &ett_flags,
878 &ett_route
881 static ei_register_info ei[] = {
882 { &ei_checksum, { "dvmrp.bad_checksum", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
885 expert_module_t* expert_dvmrp;
887 module_t *module_dvmrp;
889 proto_dvmrp = proto_register_protocol("Distance Vector Multicast Routing Protocol", "DVMRP", "dvmrp");
890 proto_register_field_array(proto_dvmrp, hf, array_length(hf));
891 proto_register_subtree_array(ett, array_length(ett));
892 expert_dvmrp = expert_register_protocol(proto_dvmrp);
893 expert_register_field_array(expert_dvmrp, ei, array_length(ei));
895 module_dvmrp = prefs_register_protocol(proto_dvmrp, NULL);
897 prefs_register_bool_preference(module_dvmrp, "strict_v3", "Allow strict DVMRP V3 only",
898 "Allow only packets with Major=0x03//Minor=0xFF as DVMRP V3 packets",
899 &strict_v3);
901 dvmrp_handle = register_dissector("dvmrp", dissect_dvmrp, proto_dvmrp);
904 void
905 proto_reg_handoff_dvmrp(void)
907 dissector_add_uint("igmp.type", IGMP_DVMRP, dvmrp_handle);
912 * Editor modelines - https://www.wireshark.org/tools/modelines.html
914 * Local variables:
915 * c-basic-offset: 8
916 * tab-width: 8
917 * indent-tabs-mode: t
918 * End:
920 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
921 * :indentSize=8:tabSize=8:noTabs=false: