Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-cgmp.c
blob0dfde94dcbcc9c0dff8619215dd1ce36aa930e19
1 /* packet-cgmp.c
2 * Routines for the disassembly of the Cisco Group Management Protocol
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 */
11 #include "config.h"
13 #include <epan/packet.h>
14 #include <epan/cisco_pid.h>
17 * See
19 * http://www.barnett.sk/software/bbooks/cisco_multicasting_routing/chap04.html
21 * for some information on CGMP.
23 void proto_register_cgmp(void);
24 void proto_reg_handoff_cgmp(void);
26 static dissector_handle_t cgmp_handle;
28 static int proto_cgmp;
29 static int hf_cgmp_version;
30 static int hf_cgmp_type;
31 static int hf_cgmp_reserved;
32 static int hf_cgmp_count;
33 static int hf_cgmp_gda;
34 static int hf_cgmp_usa;
36 static int ett_cgmp;
38 static const value_string type_vals[] = {
39 { 0, "Join" },
40 { 1, "Leave" },
41 { 0, NULL },
44 static int
45 dissect_cgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
47 proto_item *ti;
48 proto_tree *cgmp_tree = NULL;
49 int offset = 0;
50 uint8_t count;
52 col_set_str(pinfo->cinfo, COL_PROTOCOL, "CGMP");
53 col_set_str(pinfo->cinfo, COL_INFO, "Cisco Group Management Protocol");
55 if (tree) {
56 ti = proto_tree_add_item(tree, proto_cgmp, tvb, offset, -1,
57 ENC_NA);
58 cgmp_tree = proto_item_add_subtree(ti, ett_cgmp);
60 proto_tree_add_item(cgmp_tree, hf_cgmp_version, tvb, offset, 1,
61 ENC_BIG_ENDIAN);
62 proto_tree_add_item(cgmp_tree, hf_cgmp_type, tvb, offset, 1,
63 ENC_BIG_ENDIAN);
64 offset += 1;
66 proto_tree_add_item(cgmp_tree, hf_cgmp_reserved, tvb, offset, 2,
67 ENC_BIG_ENDIAN);
68 offset += 2;
70 count = tvb_get_uint8(tvb, offset);
71 proto_tree_add_uint(cgmp_tree, hf_cgmp_count, tvb, offset, 1,
72 count);
73 offset += 1;
75 while (count != 0) {
76 proto_tree_add_item(cgmp_tree, hf_cgmp_gda, tvb, offset, 6,
77 ENC_NA);
78 offset += 6;
80 proto_tree_add_item(cgmp_tree, hf_cgmp_usa, tvb, offset, 6,
81 ENC_NA);
82 offset += 6;
84 count--;
87 return tvb_captured_length(tvb);
90 void
91 proto_register_cgmp(void)
93 static hf_register_info hf[] = {
94 { &hf_cgmp_version,
95 { "Version", "cgmp.version", FT_UINT8, BASE_DEC, NULL, 0xF0,
96 NULL, HFILL }},
98 { &hf_cgmp_type,
99 { "Type", "cgmp.type", FT_UINT8, BASE_DEC, VALS(type_vals), 0x0F,
100 NULL, HFILL }},
102 { &hf_cgmp_reserved,
103 { "Reserved", "cgmp.reserved", FT_UINT16, BASE_HEX, NULL, 0x0,
104 NULL, HFILL }},
106 { &hf_cgmp_count,
107 { "Count", "cgmp.count", FT_UINT8, BASE_DEC, NULL, 0x0,
108 NULL, HFILL }},
110 { &hf_cgmp_gda,
111 { "Group Destination Address", "cgmp.gda", FT_ETHER, BASE_NONE, NULL, 0x0,
112 NULL, HFILL }},
114 { &hf_cgmp_usa,
115 { "Unicast Source Address", "cgmp.usa", FT_ETHER, BASE_NONE, NULL, 0x0,
116 NULL, HFILL }},
118 static int *ett[] = {
119 &ett_cgmp,
122 proto_cgmp = proto_register_protocol("Cisco Group Management Protocol",
123 "CGMP", "cgmp");
124 proto_register_field_array(proto_cgmp, hf, array_length(hf));
125 proto_register_subtree_array(ett, array_length(ett));
127 cgmp_handle = register_dissector("cgmp", dissect_cgmp, proto_cgmp);
130 void
131 proto_reg_handoff_cgmp(void)
133 dissector_add_uint("llc.cisco_pid", CISCO_PID_CGMP, cgmp_handle);
134 dissector_add_uint("ethertype", 0x2001, cgmp_handle);
138 * Editor modelines - https://www.wireshark.org/tools/modelines.html
140 * Local variables:
141 * c-basic-offset: 8
142 * tab-width: 8
143 * indent-tabs-mode: t
144 * End:
146 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
147 * :indentSize=8:tabSize=8:noTabs=false: