epan/dissectors/pidl/ C99 drsuapi
[wireshark-sm.git] / epan / dissectors / packet-rgmp.c
blob03723d8636a1d4d9c689f2aeef984223770555ed
1 /* packet-rgmp.c
2 * Routines for IGMP/RGMP packet disassembly
3 * Copyright 2006 Jaap Keuter
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
13 Based on RFC3488
15 This is a setup for RGMP dissection, a simple protocol bolted on IGMP.
18 #include "config.h"
20 #include <epan/packet.h>
21 #include <epan/expert.h>
22 #include "packet-igmp.h"
24 void proto_register_rgmp(void);
25 void proto_reg_handoff_rgmp(void);
27 static int proto_rgmp;
28 static int hf_type;
29 static int hf_reserved;
30 static int hf_checksum;
31 static int hf_checksum_status;
32 static int hf_maddr;
34 static int ett_rgmp;
36 static expert_field ei_checksum;
38 static dissector_handle_t rgmp_handle;
40 #define MC_RGMP 0xe0000019
42 static const value_string rgmp_types[] = {
43 {IGMP_RGMP_LEAVE, "Leave"},
44 {IGMP_RGMP_JOIN, "Join"},
45 {IGMP_RGMP_BYE, "Bye"},
46 {IGMP_RGMP_HELLO, "Hello"},
47 {0, NULL}
50 /* This function is only called from the IGMP dissector */
51 static int
52 dissect_rgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
54 proto_tree *tree;
55 proto_item *item;
56 uint8_t type;
57 int offset = 0;
58 uint32_t dst = g_htonl(MC_RGMP);
60 /* Shouldn't be destined for us */
61 if ((pinfo->dst.type != AT_IPv4) || memcmp(pinfo->dst.data, &dst, 4))
62 return 0;
64 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RGMP");
65 col_clear(pinfo->cinfo, COL_INFO);
67 item = proto_tree_add_item(parent_tree, proto_rgmp, tvb, offset, -1, ENC_NA);
68 tree = proto_item_add_subtree(item, ett_rgmp);
70 type = tvb_get_uint8(tvb, offset);
71 col_add_str(pinfo->cinfo, COL_INFO,
72 val_to_str(type, rgmp_types, "Unknown Type: 0x%02x"));
73 proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type);
74 offset += 1;
76 /* reserved */
77 proto_tree_add_item(tree, hf_reserved, tvb, offset, 1, ENC_NA);
78 offset += 1;
80 igmp_checksum(tree, tvb, hf_checksum, hf_checksum_status, &ei_checksum, pinfo, 0);
81 offset += 2;
83 proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, ENC_BIG_ENDIAN);
84 offset += 4;
86 return offset;
90 void
91 proto_register_rgmp(void)
93 static hf_register_info hf[] = {
94 { &hf_type,
95 { "Type", "rgmp.type", FT_UINT8, BASE_HEX,
96 VALS(rgmp_types), 0, "RGMP Packet Type", HFILL }
99 { &hf_reserved,
100 { "Reserved", "rgmp.reserved", FT_UINT8, BASE_HEX,
101 NULL, 0, "RGMP Reserved", HFILL }
104 { &hf_checksum,
105 { "Checksum", "rgmp.checksum", FT_UINT16, BASE_HEX,
106 NULL, 0, NULL, HFILL }
109 { &hf_checksum_status,
110 { "Checksum Status", "rgmp.checksum.status", FT_UINT8, BASE_NONE,
111 VALS(proto_checksum_vals), 0x0, NULL, HFILL }
114 { &hf_maddr,
115 { "Multicast group address", "rgmp.maddr", FT_IPv4, BASE_NONE,
116 NULL, 0, NULL, HFILL }
120 static int *ett[] = {
121 &ett_rgmp
124 static ei_register_info ei[] = {
125 { &ei_checksum, { "rgmp.bad_checksum", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
128 expert_module_t* expert_rgmp;
130 proto_rgmp = proto_register_protocol("Router-port Group Management Protocol", "RGMP", "rgmp");
131 proto_register_field_array(proto_rgmp, hf, array_length(hf));
132 proto_register_subtree_array(ett, array_length(ett));
133 expert_rgmp = expert_register_protocol(proto_rgmp);
134 expert_register_field_array(expert_rgmp, ei, array_length(ei));
136 rgmp_handle = register_dissector("rgmp", dissect_rgmp, proto_rgmp);
139 void
140 proto_reg_handoff_rgmp(void)
142 dissector_add_uint("igmp.type", IGMP_RGMP_HELLO, rgmp_handle);
143 dissector_add_uint("igmp.type", IGMP_RGMP_BYE, rgmp_handle);
144 dissector_add_uint("igmp.type", IGMP_RGMP_JOIN, rgmp_handle);
145 dissector_add_uint("igmp.type", IGMP_RGMP_LEAVE, rgmp_handle);
149 * Editor modelines - https://www.wireshark.org/tools/modelines.html
151 * Local variables:
152 * c-basic-offset: 4
153 * tab-width: 8
154 * indent-tabs-mode: nil
155 * End:
157 * vi: set shiftwidth=4 tabstop=8 expandtab:
158 * :indentSize=4:tabSize=8:noTabs=true: