From 4b81b2dbc971f3273c385bf99005dbec8f30b4c7 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 5 Feb 2000 05:54:17 +0000 Subject: [PATCH] Cisco Group Management Protocol dissector. svn path=/trunk/; revision=1601 --- Makefile.am | 3 +- Makefile.nmake | 1 + packet-cgmp.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++ packet-llc.c | 6 ++- packet.h | 3 +- 5 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 packet-cgmp.c diff --git a/Makefile.am b/Makefile.am index 1cbfe80b24..036530fb48 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Ethereal # -# $Id: Makefile.am,v 1.160 2000/01/30 16:57:20 nneul Exp $ +# $Id: Makefile.am,v 1.161 2000/02/05 05:54:17 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs @@ -50,6 +50,7 @@ DISSECTOR_SOURCES = \ packet-bootparams.h \ packet-bpdu.c \ packet-cdp.c \ + packet-cgmp.c \ packet-clip.c \ packet-data.c \ packet-dns.c \ diff --git a/Makefile.nmake b/Makefile.nmake index ee10e8df9e..bfa854550c 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -33,6 +33,7 @@ DISSECTOR_OBJECTS = \ packet-bootparams.obj \ packet-bpdu.obj \ packet-cdp.obj \ + packet-cgmp.obj \ packet-clip.obj \ packet-data.obj \ packet-dns.obj \ diff --git a/packet-cgmp.c b/packet-cgmp.c new file mode 100644 index 0000000000..f07a6908fd --- /dev/null +++ b/packet-cgmp.c @@ -0,0 +1,139 @@ +/* packet-cgmp.c + * Routines for the disassembly of the Cisco Group Management Protocol + * + * $Id: packet-cgmp.c,v 1.1 2000/02/05 05:54:15 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#include +#include + +#include +#include "packet.h" + +/* + * See + * + * http://www.barnett.sk/software/bbooks/cisco_multicasting_routing/chap04.html + * + * for some information on CGMP. + */ + +static int proto_cgmp = -1; +static int hf_cgmp_version = -1; +static int hf_cgmp_type = -1; +static int hf_cgmp_count = -1; +static int hf_cgmp_gda = -1; +static int hf_cgmp_usa = -1; + +static gint ett_cgmp = -1; + +static const value_string type_vals[] = { + { 0, "Join" }, + { 1, "Leave" }, + { 0, NULL }, +}; + +void +dissect_cgmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) +{ + proto_item *ti; + proto_tree *cgmp_tree = NULL; + guint8 count; + + if (check_col(fd, COL_PROTOCOL)) + col_add_str(fd, COL_PROTOCOL, "CGMP"); + if (check_col(fd, COL_INFO)) + col_add_str(fd, COL_INFO, "Cisco Group Management Protocol"); + + if (tree) { + ti = proto_tree_add_item(tree, proto_cgmp, offset, END_OF_FRAME, NULL); + cgmp_tree = proto_item_add_subtree(ti, ett_cgmp); + + proto_tree_add_item(cgmp_tree, hf_cgmp_version, offset, 1, + pd[offset]); + proto_tree_add_item(cgmp_tree, hf_cgmp_type, offset, 1, + pd[offset]); + offset += 1; + + offset += 2; /* skip reserved field */ + + count = pd[offset]; + proto_tree_add_item(cgmp_tree, hf_cgmp_count, offset, 1, + count); + offset += 1; + + while (count != 0) { + if (!BYTES_ARE_IN_FRAME(offset, 6)) + break; + proto_tree_add_item(cgmp_tree, hf_cgmp_gda, offset, 6, + &pd[offset]); + offset += 6; + + if (!BYTES_ARE_IN_FRAME(offset, 6)) + break; + proto_tree_add_item(cgmp_tree, hf_cgmp_usa, offset, 6, + &pd[offset]); + offset += 6; + + count--; + } + } +} + +void +proto_register_cgmp(void) +{ + static hf_register_info hf[] = { + { &hf_cgmp_version, + { "Version", "cgmp.version", FT_UINT8, BASE_DEC, NULL, 0xF0, + "" }}, + + { &hf_cgmp_type, + { "Type", "cgmp.type", FT_UINT8, BASE_DEC, VALS(type_vals), 0x0F, + "" }}, + + { &hf_cgmp_count, + { "Count", "cgmp.count", FT_UINT8, BASE_DEC, NULL, 0x0, + "" }}, + + { &hf_cgmp_gda, + { "Group Destination Address", "cgmp.gda", FT_ETHER, BASE_NONE, NULL, 0x0, + "Group Destination Address" }}, + + { &hf_cgmp_usa, + { "Unicast Source Address", "cgmp.usa", FT_ETHER, BASE_NONE, NULL, 0x0, + "Unicast Source Address" }}, + }; + static gint *ett[] = { + &ett_cgmp, + }; + + proto_cgmp = proto_register_protocol("Cisco Group Management Protocol", "cgmp"); + proto_register_field_array(proto_cgmp, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); +} diff --git a/packet-llc.c b/packet-llc.c index 1ccc5d00cb..e8dd8d42aa 100644 --- a/packet-llc.c +++ b/packet-llc.c @@ -2,7 +2,7 @@ * Routines for IEEE 802.2 LLC layer * Gilbert Ramirez * - * $Id: packet-llc.c,v 1.44 2000/01/24 02:44:52 guy Exp $ + * $Id: packet-llc.c,v 1.45 2000/02/05 05:54:15 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -397,6 +397,10 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { dissect_cdp(pd, offset+8, fd, tree); break; + case 0x2001: + dissect_cgmp(pd, offset+8, fd, tree); + break; + default: dissect_data(pd, offset+8, fd, tree); break; diff --git a/packet.h b/packet.h index ba3b735fad..64e1aae453 100644 --- a/packet.h +++ b/packet.h @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.168 2000/01/24 18:46:45 guy Exp $ + * $Id: packet.h,v 1.169 2000/02/05 05:54:16 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -334,6 +334,7 @@ void dissect_bgp(const u_char *, int, frame_data *, proto_tree *); void dissect_bootp(const u_char *, int, frame_data *, proto_tree *); void dissect_bpdu(const u_char *, int, frame_data *, proto_tree *); void dissect_cdp(const u_char *, int, frame_data *, proto_tree *); +void dissect_cgmp(const u_char *, int, frame_data *, proto_tree *); void dissect_cotp(const u_char *, int, frame_data *, proto_tree *); void dissect_data(const u_char *, int, frame_data *, proto_tree *); void dissect_ddp(const u_char *, int, frame_data *, proto_tree *);