diff options
author | Michael Mann <mmann78@netscape.net> | 2014-11-07 07:47:43 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2014-11-08 16:33:50 +0000 |
commit | 421913b721d5b12c1f6c8a09daec35d8bae58bb5 (patch) | |
tree | 1c039d5db023456f106d3bd1d221401463639daf /epan | |
parent | bd5384c84a53a88c64fb79094444c063756ca183 (diff) |
Create real subdissectors to the IGMP protocol.
Change-Id: I79ee9413b87722bfe4782342737cff03cfc34495
Reviewed-on: https://code.wireshark.org/review/5179
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/Makefile.common | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-dvmrp.c | 30 | ||||
-rw-r--r-- | epan/dissectors/packet-dvmrp.h | 29 | ||||
-rw-r--r-- | epan/dissectors/packet-igap.c | 26 | ||||
-rw-r--r-- | epan/dissectors/packet-igap.h | 33 | ||||
-rw-r--r-- | epan/dissectors/packet-igmp.c | 321 | ||||
-rw-r--r-- | epan/dissectors/packet-igmp.h | 31 | ||||
-rw-r--r-- | epan/dissectors/packet-mrdisc.c | 46 | ||||
-rw-r--r-- | epan/dissectors/packet-mrdisc.h | 29 | ||||
-rw-r--r-- | epan/dissectors/packet-msnip.c | 32 | ||||
-rw-r--r-- | epan/dissectors/packet-msnip.h | 29 | ||||
-rw-r--r-- | epan/dissectors/packet-pim.c | 25 | ||||
-rw-r--r-- | epan/dissectors/packet-pim.h | 28 | ||||
-rw-r--r-- | epan/dissectors/packet-rgmp.c | 42 | ||||
-rw-r--r-- | epan/dissectors/packet-rgmp.h | 34 |
15 files changed, 281 insertions, 460 deletions
diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common index a4af54e1e9..053e757d53 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -1435,7 +1435,6 @@ DISSECTOR_INCLUDES = \ packet-dvbci.h \ packet-enip.h \ packet-erf.h \ - packet-dvmrp.h \ packet-e164.h \ packet-e212.h \ packet-edonkey.h \ @@ -1501,7 +1500,6 @@ DISSECTOR_INCLUDES = \ packet-ieee8021ah.h \ packet-ieee8023.h \ packet-ieee802a.h \ - packet-igap.h \ packet-igmp.h \ packet-imf.h \ packet-inap.h \ @@ -1546,8 +1544,6 @@ DISSECTOR_INCLUDES = \ packet-mpeg-sect.h \ packet-mpls.h \ packet-mq.h \ - packet-mrdisc.h \ - packet-msnip.h \ packet-msrp.h \ packet-mstp.h \ packet-mtp3.h \ @@ -1577,7 +1573,6 @@ DISSECTOR_INCLUDES = \ packet-pcnfsd.h \ packet-pdcp-lte.h \ packet-per.h \ - packet-pim.h \ packet-pkcs1.h \ packet-pkcs12.h \ packet-pkix1explicit.h \ @@ -1606,7 +1601,6 @@ DISSECTOR_INCLUDES = \ packet-raw.h \ packet-rdt.h \ packet-reload.h \ - packet-rgmp.h \ packet-rlc.h \ packet-rlc-lte.h \ packet-rmi.h \ diff --git a/epan/dissectors/packet-dvmrp.c b/epan/dissectors/packet-dvmrp.c index 067cd26e99..b4ef0af794 100644 --- a/epan/dissectors/packet-dvmrp.c +++ b/epan/dissectors/packet-dvmrp.c @@ -57,7 +57,6 @@ #include <epan/ipproto.h> #include <epan/prefs.h> #include "packet-igmp.h" -#include "packet-dvmrp.h" void proto_register_dvmrp(void); @@ -678,25 +677,17 @@ dissect_dvmrp_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int /* This function is only called from the IGMP dissector */ int -dissect_dvmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) +dissect_dvmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) { proto_tree *tree; proto_item *item; - - if (!proto_is_protocol_enabled(find_protocol_by_id(proto_dvmrp))) { - /* we are not enabled, skip entire packet to be nice - to the igmp layer. (so clicking on IGMP will display the data) - */ - return offset+tvb_length_remaining(tvb, offset); - } - - item = proto_tree_add_item(parent_tree, proto_dvmrp, tvb, offset, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_dvmrp); - + int offset = 0; col_set_str(pinfo->cinfo, COL_PROTOCOL, "DVMRP"); col_clear(pinfo->cinfo, COL_INFO); + item = proto_tree_add_item(parent_tree, proto_dvmrp, tvb, offset, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_dvmrp); if ((tvb_length_remaining(tvb, offset)>=8) && (((tvb_get_guint8(tvb, 6)==0xff) @@ -892,8 +883,7 @@ proto_register_dvmrp(void) }; module_t *module_dvmrp; - proto_dvmrp = proto_register_protocol("Distance Vector Multicast Routing Protocol", - "DVMRP", "dvmrp"); + proto_dvmrp = proto_register_protocol("Distance Vector Multicast Routing Protocol", "DVMRP", "dvmrp"); proto_register_field_array(proto_dvmrp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -904,6 +894,16 @@ proto_register_dvmrp(void) &strict_v3); } +void +proto_reg_handoff_dvmrp(void) +{ + dissector_handle_t dvmrp_handle; + + dvmrp_handle = new_create_dissector_handle(dissect_dvmrp, proto_dvmrp); + dissector_add_uint("igmp.type", IGMP_DVMRP, dvmrp_handle); +} + + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * diff --git a/epan/dissectors/packet-dvmrp.h b/epan/dissectors/packet-dvmrp.h deleted file mode 100644 index d93f0e2a8e..0000000000 --- a/epan/dissectors/packet-dvmrp.h +++ /dev/null @@ -1,29 +0,0 @@ -/* packet-dvmrp.h 2001 Ronnie Sahlberg <See AUTHORS for email> - * Declarations of routines for IGMP/DVMRP packet disassembly - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PACKET_DVMRP_H__ -#define __PACKET_DVMRP_H__ - -int dissect_dvmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset); - -#endif - diff --git a/epan/dissectors/packet-igap.c b/epan/dissectors/packet-igap.c index 85b9e4bf80..779612f3b4 100644 --- a/epan/dissectors/packet-igap.c +++ b/epan/dissectors/packet-igap.c @@ -46,7 +46,6 @@ #include <epan/packet.h> #include <epan/to_str.h> #include "packet-igmp.h" -#include "packet-igap.h" void proto_register_igap(void); @@ -134,20 +133,14 @@ static const value_string igap_account_status[] = { /* This function is only called from the IGMP dissector */ int -dissect_igap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) +dissect_igap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) { proto_tree *tree; proto_item *item; guint8 type, tsecs, subtype, asize, msize; + int offset = 0; guchar account[ACCOUNT_SIZE+1], message[MESSAGE_SIZE+1]; - if (!proto_is_protocol_enabled(find_protocol_by_id(proto_igap))) { - /* we are not enabled, skip entire packet to be nice - to the igmp layer. (so clicking on IGMP will display the data) - */ - return offset + tvb_length_remaining(tvb, offset); - } - item = proto_tree_add_item(parent_tree, proto_igap, tvb, offset, -1, ENC_NA); tree = proto_item_add_subtree(item, ett_igap); @@ -342,13 +335,22 @@ proto_register_igap(void) &ett_igap }; - proto_igap = proto_register_protocol - ("Internet Group membership Authentication Protocol", - "IGAP", "igap"); + proto_igap = proto_register_protocol("Internet Group membership Authentication Protocol", "IGAP", "igap"); proto_register_field_array(proto_igap, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } +void +proto_reg_handoff_igap(void) +{ + dissector_handle_t igap_handle; + + igap_handle = new_create_dissector_handle(dissect_igap, proto_igap); + dissector_add_uint("igmp.type", IGMP_IGAP_JOIN, igap_handle); + dissector_add_uint("igmp.type", IGMP_IGAP_QUERY, igap_handle); + dissector_add_uint("igmp.type", IGMP_IGAP_LEAVE, igap_handle); +} + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * diff --git a/epan/dissectors/packet-igap.h b/epan/dissectors/packet-igap.h deleted file mode 100644 index 4ae24669cf..0000000000 --- a/epan/dissectors/packet-igap.h +++ /dev/null @@ -1,33 +0,0 @@ -/* packet-igap.h - * Declarations of routines for IGMP/IGAP packet disassembly - * 2003, Endoh Akira <See AUTHORS for email> - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PACKET_IGAP_H__ -#define __PACKET_IGAP_H__ - -#define IGMP_IGAP_JOIN 0x40 -#define IGMP_IGAP_QUERY 0x41 -#define IGMP_IGAP_LEAVE 0x42 - -int dissect_igap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset); - -#endif diff --git a/epan/dissectors/packet-igmp.c b/epan/dissectors/packet-igmp.c index 3ce05e6bfa..968aba7f29 100644 --- a/epan/dissectors/packet-igmp.c +++ b/epan/dissectors/packet-igmp.c @@ -112,16 +112,11 @@ #include <glib.h> #include <epan/packet.h> +#include <epan/range.h> #include <epan/to_str.h> #include <epan/ipproto.h> #include <epan/in_cksum.h> #include "packet-igmp.h" -#include "packet-dvmrp.h" -#include "packet-pim.h" -#include "packet-mrdisc.h" -#include "packet-msnip.h" -#include "packet-igap.h" -#include "packet-rgmp.h" void proto_register_igmp(void); void proto_reg_handoff_igmp(void); @@ -176,32 +171,7 @@ static int ett_sqrv_bits = -1; static int ett_max_resp = -1; static int ett_mtrace_block = -1; -#define MC_ALL_ROUTERS 0xe0000002 -#define MC_ALL_IGMPV3_ROUTERS 0xe0000016 -#define MC_RGMP 0xe0000019 - - -#define IGMP_V0_CREATE_GROUP_REQUEST 0x01 -#define IGMP_V0_CREATE_GROUP_REPLY 0x02 -#define IGMP_V0_JOIN_GROUP_REQUEST 0x03 -#define IGMP_V0_JOIN_GROUP_REPLY 0x04 -#define IGMP_V0_LEAVE_GROUP_REQUEST 0x05 -#define IGMP_V0_LEAVE_GROUP_REPLY 0x06 -#define IGMP_V0_CONFIRM_GROUP_REQUEST 0x07 -#define IGMP_V0_CONFIRM_GROUP_REPLY 0x08 -#define IGMP_V1_HOST_MEMBERSHIP_QUERY 0x11 -#define IGMP_V1_HOST_MEMBERSHIP_REPORT 0x12 -#define IGMP_DVMRP 0x13 -#define IGMP_V1_PIM_ROUTING_MESSAGE 0x14 -#define IGMP_V2_MEMBERSHIP_REPORT 0x16 -#define IGMP_V2_LEAVE_GROUP 0x17 -#define IGMP_TRACEROUTE_RESPONSE 0x1e -#define IGMP_TRACEROUTE_QUERY_REQ 0x1f -#define IGMP_V3_MEMBERSHIP_REPORT 0x22 -#define IGMP_TYPE_0x23 0x23 -#define IGMP_TYPE_0x24 0x24 -#define IGMP_TYPE_0x25 0x25 -#define IGMP_TYPE_0x26 0x26 +static dissector_table_t subdissector_table; #define IGMP_TRACEROUTE_HDR_LEN 24 #define IGMP_TRACEROUTE_RSP_LEN 32 @@ -313,20 +283,6 @@ static const value_string mtrace_fwd_code_vals[] = { {0, NULL} }; -#define PRINT_IGMP_VERSION(version) \ - do { \ - proto_item *ti; \ - col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "IGMPv%d",version); \ - col_add_fstr(pinfo->cinfo, COL_INFO, \ - "%s",val_to_str(type, commands, "Unknown Type:0x%02x")); \ - /* version of IGMP protocol */ \ - ti = proto_tree_add_uint(tree, hf_version, tvb, 0, 0, version); \ - PROTO_ITEM_SET_GENERATED(ti); \ - /* type of command */ \ - proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type);\ - offset += 1; \ - } while (0); - void igmp_checksum(proto_tree *tree, tvbuff_t *tvb, int hf_index, int hf_index_bad, packet_info *pinfo, guint len) { @@ -368,13 +324,50 @@ void igmp_checksum(proto_tree *tree, tvbuff_t *tvb, int hf_index, return; } +static proto_tree* +dissect_igmp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int* offset, unsigned char* type, int version) +{ + proto_item* ti; + proto_tree* igmp_tree; + + col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "IGMPv%d", version); + col_clear(pinfo->cinfo, COL_INFO); + + ti = proto_tree_add_item(tree, proto_igmp, tvb, 0, -1, ENC_NA); + igmp_tree = proto_item_add_subtree(ti, ett_igmp); + + *type = tvb_get_guint8(tvb, 0); + col_add_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str(*type, commands, "Unknown Type:0x%02x")); + + /* version of IGMP protocol */ + ti = proto_tree_add_uint(igmp_tree, hf_version, tvb, 0, 0, version); + PROTO_ITEM_SET_GENERATED(ti); + + /* type of command */ + proto_tree_add_item(igmp_tree, hf_type, tvb, 0, 1, ENC_NA); + *offset = 1; + + return igmp_tree; +} + /* Unknown IGMP message type */ static int -dissect_igmp_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset) +dissect_igmp_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { + proto_item* ti; + proto_tree* tree; int len; + int offset = 0; + unsigned char type; + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "IGMP"); + col_clear(pinfo->cinfo, COL_INFO); + + ti = proto_tree_add_item(parent_tree, proto_igmp, tvb, offset, -1, ENC_NA); + tree = proto_item_add_subtree(ti, ett_igmp); + type = tvb_get_guint8(tvb, offset); col_add_str(pinfo->cinfo, COL_INFO, val_to_str(type, commands, "Unknown Type:0x%02x")); @@ -565,11 +558,14 @@ dissect_v3_group_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tr /* dissectors for version 3, rfc3376 */ static int -dissect_igmp_v3_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset) +dissect_igmp_v3_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) { + proto_tree* tree; guint16 num; + int offset; + unsigned char type; - PRINT_IGMP_VERSION(3); + tree = dissect_igmp_common(tvb, pinfo, parent_tree, &offset, &type, 3); /* skip reserved field*/ offset += 1; @@ -596,12 +592,15 @@ dissect_igmp_v3_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int } static int -dissect_igmp_v3_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset) +dissect_igmp_v3_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) { + proto_tree* tree; guint16 num; guint32 maddr; + int offset; + unsigned char type; - PRINT_IGMP_VERSION(3); + tree = dissect_igmp_common(tvb, pinfo, parent_tree, &offset, &type, 3); num = tvb_get_ntohs(tvb, offset+9); /* max resp code */ @@ -648,12 +647,15 @@ dissect_igmp_v3_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int t /* dissector for version 2 query and report, rfc2236 */ static int -dissect_igmp_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset) +dissect_igmp_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) { + proto_tree* tree; guint8 tsecs; guint32 maddr; + int offset; + unsigned char type; - PRINT_IGMP_VERSION(2); + tree = dissect_igmp_common(tvb, pinfo, parent_tree, &offset, &type, 2); /* max resp time */ tsecs = tvb_get_guint8(tvb, offset); @@ -672,15 +674,17 @@ dissect_igmp_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, i if (! maddr) { col_append_str(pinfo->cinfo, COL_INFO, ", general"); } else { - if (type == IGMP_V2_LEAVE_GROUP) { - col_append_fstr(pinfo->cinfo, COL_INFO, - " %s", ip_to_str((guint8*)&maddr)); - } else if (type == IGMP_V1_HOST_MEMBERSHIP_QUERY) { - col_append_fstr(pinfo->cinfo, COL_INFO, - ", specific for group %s", ip_to_str((guint8*)&maddr)); - } else { /* IGMP_V2_MEMBERSHIP_REPORT is the only case left */ - col_append_fstr(pinfo->cinfo, COL_INFO, - " group %s", ip_to_str((guint8*)&maddr)); + switch(type) + { + case IGMP_V2_LEAVE_GROUP: + col_append_fstr(pinfo->cinfo, COL_INFO, " %s", ip_to_str((guint8*)&maddr)); + break; + case IGMP_V1_HOST_MEMBERSHIP_QUERY: + col_append_fstr(pinfo->cinfo, COL_INFO, ", specific for group %s", ip_to_str((guint8*)&maddr)); + break; + default: /* IGMP_V2_MEMBERSHIP_REPORT is the only case left */ + col_append_fstr(pinfo->cinfo, COL_INFO, " group %s", ip_to_str((guint8*)&maddr)); + break; } } offset +=4; @@ -690,9 +694,13 @@ dissect_igmp_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, i /* dissector for version 1 query and report, rfc1054 */ static int -dissect_igmp_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset) +dissect_igmp_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) { - PRINT_IGMP_VERSION(1); + proto_tree* tree; + int offset; + unsigned char type; + + tree = dissect_igmp_common(tvb, pinfo, parent_tree, &offset, &type, 1); /* skip unused byte */ offset += 1; @@ -710,11 +718,14 @@ dissect_igmp_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, i /* dissector for version 0, rfc988 */ static int -dissect_igmp_v0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset) +dissect_igmp_v0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) { + proto_tree* tree; unsigned char code; + int offset; + unsigned char type; - PRINT_IGMP_VERSION(0); + tree = dissect_igmp_common(tvb, pinfo, parent_tree, &offset, &type, 0); /* Code */ code = tvb_get_guint8(tvb, offset); @@ -748,13 +759,39 @@ dissect_igmp_v0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, i return offset; } +static int +dissect_igmp_mquery(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) +{ + if ( tvb_reported_length(tvb)>=12 ) { + /* version 3 */ + return dissect_igmp_v3_query(tvb, pinfo, parent_tree, data); + } + + /* v1 and v2 differs in second byte of header */ + if (tvb_get_guint8(tvb, 1)) { + return dissect_igmp_v2(tvb, pinfo, parent_tree, data); + } + + return dissect_igmp_v1(tvb, pinfo, parent_tree, data); +} + /* dissector for multicast traceroute, rfc???? */ static int -dissect_igmp_mtrace(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset) +dissect_igmp_mtrace(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) { + proto_tree* tree; + proto_item* ti; + int offset = 0; + unsigned char type; const char *typestr, *blocks = NULL; char buf[20]; + ti = proto_tree_add_item(parent_tree, proto_igmp, tvb, offset, -1, ENC_NA); + tree = proto_item_add_subtree(ti, ett_igmp); + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "IGMP"); + col_clear(pinfo->cinfo, COL_INFO); + /* All multicast traceroute packets (Query, Request and * Response) have the same fixed header. Request and Response * have one or more response data blocks following this fixed @@ -763,6 +800,7 @@ dissect_igmp_mtrace(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int typ * IGMP packet length. Queries are only * IGMP_TRACEROUTE_HDR_LEN bytes long. */ + type = tvb_get_guint8(tvb, offset); if (type == IGMP_TRACEROUTE_RESPONSE) { int i = (tvb_reported_length_remaining(tvb, offset) - IGMP_TRACEROUTE_HDR_LEN) / IGMP_TRACEROUTE_RSP_LEN; g_snprintf(buf, sizeof buf, ", %d block%s", i, plurality(i, "", "s")); @@ -881,126 +919,15 @@ dissect_igmp_mtrace(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int typ static void dissect_igmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_tree *tree; - proto_item *item; int offset = 0; unsigned char type; - guint32 dst; - - item = proto_tree_add_item(parent_tree, proto_igmp, tvb, offset, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_igmp); - - col_set_str(pinfo->cinfo, COL_PROTOCOL, "IGMP"); - col_clear(pinfo->cinfo, COL_INFO); type = tvb_get_guint8(tvb, offset); - /* version 0 */ - if ((type&0xf0)==0){ - offset = dissect_igmp_v0(tvb, pinfo, tree, type, offset); + if (!dissector_try_uint(subdissector_table, type, tvb, pinfo, parent_tree)) + { + dissect_igmp_unknown(tvb, pinfo, parent_tree); } - - switch (type) { - case IGMP_V1_HOST_MEMBERSHIP_QUERY: /* 0x11 v1/v2/v3 */ - if ( tvb_reported_length(tvb)>=12 ) { - /* version 3 */ - offset = dissect_igmp_v3_query(tvb, pinfo, tree, type, offset); - } else { - /* v1 and v2 differs in second byte of header */ - if (tvb_get_guint8(tvb, offset+1)) { - offset = dissect_igmp_v2(tvb, pinfo, tree, type, offset); - } else { - offset = dissect_igmp_v1(tvb, pinfo, tree, type, offset); - } - } - break; - - case IGMP_V1_HOST_MEMBERSHIP_REPORT: /* 0x12 v1 only */ - offset = dissect_igmp_v1(tvb, pinfo, tree, type, offset); - break; - - case IGMP_DVMRP: - offset = dissect_dvmrp(tvb, pinfo, parent_tree, offset); - break; - - case IGMP_V1_PIM_ROUTING_MESSAGE: - offset = dissect_pimv1(tvb, pinfo, parent_tree, offset); - break; - - case IGMP_V2_MEMBERSHIP_REPORT: - case IGMP_V2_LEAVE_GROUP: - offset = dissect_igmp_v2(tvb, pinfo, tree, type, offset); - break; - - case IGMP_TRACEROUTE_RESPONSE: - case IGMP_TRACEROUTE_QUERY_REQ: - offset = dissect_igmp_mtrace(tvb, pinfo, tree, type, offset); - break; - - case IGMP_V3_MEMBERSHIP_REPORT: - offset = dissect_igmp_v3_report(tvb, pinfo, tree, type, offset); - break; - - case IGMP_TYPE_0x23: - dst = g_htonl(MC_ALL_IGMPV3_ROUTERS); - if (!memcmp(pinfo->dst.data, &dst, 4)) { - offset = dissect_msnip(tvb, pinfo, parent_tree, offset); - } - break; - - case IGMP_TYPE_0x24: - dst = g_htonl(MC_ALL_ROUTERS); - if (!memcmp(pinfo->dst.data, &dst, 4)) { - offset = dissect_mrdisc(tvb, pinfo, parent_tree, offset); - } - dst = g_htonl(MC_ALL_IGMPV3_ROUTERS); - if (!memcmp(pinfo->dst.data, &dst, 4)) { - offset = dissect_msnip(tvb, pinfo, parent_tree, offset); - } - break; - - case IGMP_TYPE_0x25: - if ( tvb_reported_length(tvb)>=8 ) { - /* if len of igmp packet>=8 we assume it is MSNIP */ - offset = dissect_msnip(tvb, pinfo, parent_tree, offset); - } else { - /* ok it's not MSNIP, check if it might be MRDISC */ - dst = g_htonl(MC_ALL_ROUTERS); - if (!memcmp(pinfo->dst.data, &dst, 4)) { - offset = dissect_mrdisc(tvb, pinfo, parent_tree, offset); - } - } - break; - - case IGMP_TYPE_0x26: - dst = g_htonl(MC_ALL_ROUTERS); - if (!memcmp(pinfo->dst.data, &dst, 4)) { - offset = dissect_mrdisc(tvb, pinfo, parent_tree, offset); - } - break; - - case IGMP_IGAP_JOIN: - case IGMP_IGAP_QUERY: - case IGMP_IGAP_LEAVE: - offset = dissect_igap(tvb, pinfo, parent_tree, offset); - break; - - case IGMP_RGMP_HELLO: - case IGMP_RGMP_BYE: - case IGMP_RGMP_JOIN: - case IGMP_RGMP_LEAVE: - dst = g_htonl(MC_RGMP); - if (!memcmp(pinfo->dst.data, &dst, 4)) { - offset = dissect_rgmp(tvb, pinfo, parent_tree, offset); - } - break; - - default: - offset = dissect_igmp_unknown(tvb, pinfo, tree, type, offset); - break; - } - - proto_item_set_len(item, offset); } void @@ -1188,15 +1115,45 @@ proto_register_igmp(void) "IGMP", "igmp"); proto_register_field_array(proto_igmp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + + subdissector_table = register_dissector_table("igmp.type", "IGMP commands", FT_UINT32, BASE_HEX); + } void proto_reg_handoff_igmp(void) { - dissector_handle_t igmp_handle; + dissector_handle_t igmp_handle, igmpv0_handle, igmpv1_handle, igmpv2_handle, + igmp_mquery_handle, igmp_mtrace_handle, igmp_report_handle; + range_t *igmpv0_range; igmp_handle = create_dissector_handle(dissect_igmp, proto_igmp); dissector_add_uint("ip.proto", IP_PROTO_IGMP, igmp_handle); + + /* IGMP v0 */ + range_convert_str(&igmpv0_range, "0-15", 15); + igmpv0_handle = new_create_dissector_handle(dissect_igmp_v0, proto_igmp); + dissector_add_uint_range("igmp.type", igmpv0_range, igmpv0_handle); + + /* IGMP v1 */ + igmpv1_handle = new_create_dissector_handle(dissect_igmp_v1, proto_igmp); + dissector_add_uint("igmp.type", IGMP_V1_HOST_MEMBERSHIP_REPORT, igmpv1_handle); + + /* IGMP v2 */ + igmpv2_handle = new_create_dissector_handle(dissect_igmp_v2, proto_igmp); + dissector_add_uint("igmp.type", IGMP_V2_MEMBERSHIP_REPORT, igmpv2_handle); + dissector_add_uint("igmp.type", IGMP_V2_LEAVE_GROUP, igmpv2_handle); + + /* IGMP_V1_HOST_MEMBERSHIP_QUERY, all versions */ + igmp_mquery_handle = new_create_dissector_handle(dissect_igmp_mquery, proto_igmp); + dissector_add_uint("igmp.type", IGMP_V1_HOST_MEMBERSHIP_QUERY, igmp_mquery_handle); + + igmp_report_handle = new_create_dissector_handle(dissect_igmp_v3_report, proto_igmp); + dissector_add_uint("igmp.type", IGMP_V3_MEMBERSHIP_REPORT, igmp_report_handle); + + igmp_mtrace_handle = new_create_dissector_handle(dissect_igmp_mtrace, proto_igmp); + dissector_add_uint("igmp.type", IGMP_TRACEROUTE_RESPONSE, igmp_mtrace_handle); + dissector_add_uint("igmp.type", IGMP_TRACEROUTE_QUERY_REQ, igmp_mtrace_handle); } /* diff --git a/epan/dissectors/packet-igmp.h b/epan/dissectors/packet-igmp.h index 41e3f84df3..b0abb74299 100644 --- a/epan/dissectors/packet-igmp.h +++ b/epan/dissectors/packet-igmp.h @@ -23,6 +23,37 @@ #ifndef __PACKET_IGMP_H__ #define __PACKET_IGMP_H__ +#define IGMP_V0_CREATE_GROUP_REQUEST 0x01 +#define IGMP_V0_CREATE_GROUP_REPLY 0x02 +#define IGMP_V0_JOIN_GROUP_REQUEST 0x03 +#define IGMP_V0_JOIN_GROUP_REPLY 0x04 +#define IGMP_V0_LEAVE_GROUP_REQUEST 0x05 +#define IGMP_V0_LEAVE_GROUP_REPLY 0x06 +#define IGMP_V0_CONFIRM_GROUP_REQUEST 0x07 +#define IGMP_V0_CONFIRM_GROUP_REPLY 0x08 +#define IGMP_V1_HOST_MEMBERSHIP_QUERY 0x11 +#define IGMP_V1_HOST_MEMBERSHIP_REPORT 0x12 +#define IGMP_DVMRP 0x13 +#define IGMP_V1_PIM_ROUTING_MESSAGE 0x14 +#define IGMP_V2_MEMBERSHIP_REPORT 0x16 +#define IGMP_V2_LEAVE_GROUP 0x17 +#define IGMP_TRACEROUTE_RESPONSE 0x1e +#define IGMP_TRACEROUTE_QUERY_REQ 0x1f +#define IGMP_V3_MEMBERSHIP_REPORT 0x22 +#define IGMP_TYPE_0x23 0x23 +#define IGMP_TYPE_0x24 0x24 +#define IGMP_TYPE_0x25 0x25 +#define IGMP_TYPE_0x26 0x26 + +#define IGMP_IGAP_JOIN 0x40 +#define IGMP_IGAP_QUERY 0x41 +#define IGMP_IGAP_LEAVE 0x42 + +#define IGMP_RGMP_LEAVE 0xFC +#define IGMP_RGMP_JOIN 0xFD +#define IGMP_RGMP_BYE 0xFE +#define IGMP_RGMP_HELLO 0xFF + void igmp_checksum(proto_tree *tree, tvbuff_t *tvb, int hf_index, int hf_index_bad, packet_info *pinfo, guint len); diff --git a/epan/dissectors/packet-mrdisc.c b/epan/dissectors/packet-mrdisc.c index 4b0fbf9c27..71db82feb2 100644 --- a/epan/dissectors/packet-mrdisc.c +++ b/epan/dissectors/packet-mrdisc.c @@ -42,7 +42,6 @@ #include <epan/exceptions.h> #include "packet-igmp.h" -#include "packet-mrdisc.h" void proto_register_mrdisc(void); @@ -62,6 +61,8 @@ static int hf_option_bytes = -1; static int ett_mrdisc = -1; static int ett_options = -1; +#define MC_ALL_ROUTERS 0xe0000002 + #define MRDISC_MRA 0x24 #define MRDISC_MRS 0x25 #define MRDISC_MRT 0x26 @@ -183,26 +184,23 @@ dissect_mrdisc_mrst(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, /* This function is only called from the IGMP dissector */ int -dissect_mrdisc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) +dissect_mrdisc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) { proto_tree *tree; proto_item *item; guint8 type; + int offset = 0; + guint32 dst = g_htonl(MC_ALL_ROUTERS); - if (!proto_is_protocol_enabled(find_protocol_by_id(proto_mrdisc))) { - /* we are not enabled, skip entire packet to be nice - to the igmp layer. (so clicking on IGMP will display the data) - */ - return offset+tvb_length_remaining(tvb, offset); - } - - item = proto_tree_add_item(parent_tree, proto_mrdisc, tvb, offset, 0, ENC_NA); - tree = proto_item_add_subtree(item, ett_mrdisc); - + /* Shouldn't be destined for us */ + if (memcmp(pinfo->dst.data, &dst, 4)) + return 0; col_set_str(pinfo->cinfo, COL_PROTOCOL, "MRDISC"); col_clear(pinfo->cinfo, COL_INFO); + item = proto_tree_add_item(parent_tree, proto_mrdisc, tvb, offset, 0, ENC_NA); + tree = proto_item_add_subtree(item, ett_mrdisc); type = tvb_get_guint8(tvb, offset); col_add_str(pinfo->cinfo, COL_INFO, @@ -245,11 +243,11 @@ proto_register_mrdisc(void) { &hf_advint, { "Advertising Interval", "mrdisc.adv_int", FT_UINT8, BASE_DEC, - NULL, 0, "MRDISC Advertising Interval in seconds", HFILL }}, + NULL, 0, "MRDISC Advertising Interval in seconds", HFILL }}, { &hf_numopts, { "Number Of Options", "mrdisc.num_opts", FT_UINT16, BASE_DEC, - NULL, 0, "MRDISC Number Of Options", HFILL }}, + NULL, 0, "MRDISC Number Of Options", HFILL }}, { &hf_options, { "Options", "mrdisc.options", FT_NONE, BASE_NONE, @@ -265,15 +263,15 @@ proto_register_mrdisc(void) { &hf_qi, { "Query Interval", "mrdisc.query_int", FT_UINT16, BASE_DEC, - NULL, 0, "MRDISC Query Interval", HFILL }}, + NULL, 0, "MRDISC Query Interval", HFILL }}, { &hf_rv, { "Robustness Variable", "mrdisc.rob_var", FT_UINT16, BASE_DEC, - NULL, 0, "MRDISC Robustness Variable", HFILL }}, + NULL, 0, "MRDISC Robustness Variable", HFILL }}, { &hf_option_bytes, { "Data", "mrdisc.option_data", FT_BYTES, BASE_NONE, - NULL, 0, "MRDISC Unknown Option Data", HFILL }}, + NULL, 0, "MRDISC Unknown Option Data", HFILL }}, }; static gint *ett[] = { @@ -281,12 +279,22 @@ proto_register_mrdisc(void) &ett_options, }; - proto_mrdisc = proto_register_protocol("Multicast Router DISCovery protocol", - "MRDISC", "mrdisc"); + proto_mrdisc = proto_register_protocol("Multicast Router DISCovery protocol", "MRDISC", "mrdisc"); proto_register_field_array(proto_mrdisc, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } +void +proto_reg_handoff_mrdisc(void) +{ + dissector_handle_t mrdisc_handle; + + mrdisc_handle = new_create_dissector_handle(dissect_mrdisc, proto_mrdisc); + dissector_add_uint("igmp.type", IGMP_TYPE_0x24, mrdisc_handle); + dissector_add_uint("igmp.type", IGMP_TYPE_0x25, mrdisc_handle); + dissector_add_uint("igmp.type", IGMP_TYPE_0x26, mrdisc_handle); +} + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * diff --git a/epan/dissectors/packet-mrdisc.h b/epan/dissectors/packet-mrdisc.h deleted file mode 100644 index 2a1c115ec5..0000000000 --- a/epan/dissectors/packet-mrdisc.h +++ /dev/null @@ -1,29 +0,0 @@ -/* packet-mrdisc.h 2001 Ronnie Sahlberg <See AUTHORS for email> - * Declarations of routines for IGMP/MRDISC packet disassembly - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PACKET_MRDISC_H__ -#define __PACKET_MRDISC_H__ - -int dissect_mrdisc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset); - -#endif - diff --git a/epan/dissectors/packet-msnip.c b/epan/dissectors/packet-msnip.c index 3f4a92914c..dd85598f5c 100644 --- a/epan/dissectors/packet-msnip.c +++ b/epan/dissectors/packet-msnip.c @@ -40,7 +40,6 @@ #include <epan/packet.h> #include <epan/to_str.h> #include "packet-igmp.h" -#include "packet-msnip.h" void proto_register_msnip(void); @@ -60,6 +59,7 @@ static int hf_rec_type = -1; static int ett_msnip = -1; static int ett_groups = -1; +#define MC_ALL_IGMPV3_ROUTERS 0xe0000016 #define MSNIP_GM 0x23 #define MSNIP_IS 0x24 @@ -212,26 +212,23 @@ dissect_msnip_gm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int /* This function is only called from the IGMP dissector */ int -dissect_msnip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) +dissect_msnip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) { proto_tree *tree; proto_item *item; guint8 type; + int offset = 0; + guint32 dst = g_htonl(MC_ALL_IGMPV3_ROUTERS); - if (!proto_is_protocol_enabled(find_protocol_by_id(proto_msnip))) { - /* we are not enabled, skip entire packet to be nice - to the igmp layer. (so clicking on IGMP will display the data) - */ - return offset+tvb_length_remaining(tvb, offset); - } - - item = proto_tree_add_item(parent_tree, proto_msnip, tvb, offset, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_msnip); - + /* Shouldn't be destined for us */ + if (memcmp(pinfo->dst.data, &dst, 4)) + return 0; col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSNIP"); col_clear(pinfo->cinfo, COL_INFO); + item = proto_tree_add_item(parent_tree, proto_msnip, tvb, offset, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_msnip); type = tvb_get_guint8(tvb, offset); col_add_str(pinfo->cinfo, COL_INFO, @@ -322,6 +319,17 @@ proto_register_msnip(void) proto_register_subtree_array(ett, array_length(ett)); } +void +proto_reg_handoff_msnip(void) +{ + dissector_handle_t msnip_handle; + + msnip_handle = new_create_dissector_handle(dissect_msnip, proto_msnip); + dissector_add_uint("igmp.type", IGMP_TYPE_0x23, msnip_handle); + dissector_add_uint("igmp.type", IGMP_TYPE_0x24, msnip_handle); + dissector_add_uint("igmp.type", IGMP_TYPE_0x25, msnip_handle); +} + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * diff --git a/epan/dissectors/packet-msnip.h b/epan/dissectors/packet-msnip.h deleted file mode 100644 index 1c41ded3e9..0000000000 --- a/epan/dissectors/packet-msnip.h +++ /dev/null @@ -1,29 +0,0 @@ -/* packet-msnip.h 2001 Ronnie Sahlberg <See AUTHORS for email> - * Declarations of routines for IGMP/MSNIP packet disassembly - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PACKET_MSNIP_H__ -#define __PACKET_MSNIP_H__ - -int dissect_msnip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset); - -#endif - diff --git a/epan/dissectors/packet-pim.c b/epan/dissectors/packet-pim.c index f204e7ed48..b563fa2cf9 100644 --- a/epan/dissectors/packet-pim.c +++ b/epan/dissectors/packet-pim.c @@ -32,8 +32,7 @@ #include <epan/in_cksum.h> #include <epan/wmem/wmem.h> #include <epan/to_str.h> - -#include "packet-pim.h" +#include "packet-igmp.h" void proto_register_pim(void); void proto_reg_handoff_pim(void); @@ -266,8 +265,7 @@ static const value_string pimv1_modevals[] = { /* This function is only called from the IGMP dissector */ int -dissect_pimv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - int offset) { +dissect_pimv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { guint8 pim_type; guint8 pim_ver; guint length, pim_length; @@ -276,14 +274,7 @@ dissect_pimv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *pim_tree = NULL; proto_item *ti; proto_tree *pimopt_tree = NULL; - - if (!proto_is_protocol_enabled(find_protocol_by_id(proto_pim))) { - /* - * We are not enabled; skip entire packet to be nice to the - * IGMP layer (so clicking on IGMP will display the data). - */ - return offset+tvb_reported_length_remaining(tvb, offset); - } + int offset = 0; col_set_str(pinfo->cinfo, COL_PROTOCOL, "PIMv1"); col_clear(pinfo->cinfo, COL_INFO); @@ -370,7 +361,7 @@ dissect_pimv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (tvb_reported_length_remaining(tvb, offset) > 0) { pimopt_tree = proto_tree_add_subtree(pim_tree, tvb, offset, -1, ett_pim_opts, NULL, "PIM options"); } else - goto done; + return offset; /* version 1 decoder */ switch (pim_type) { @@ -582,9 +573,8 @@ dissect_pimv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, default: break; } -done:; - return offset+tvb_reported_length_remaining(tvb, offset); + return tvb_reported_length(tvb); } static gboolean @@ -1746,11 +1736,14 @@ proto_register_pim(void) void proto_reg_handoff_pim(void) { - dissector_handle_t pim_handle; + dissector_handle_t pim_handle, pimv1_handle; pim_handle = create_dissector_handle(dissect_pim, proto_pim); dissector_add_uint("ip.proto", IP_PROTO_PIM, pim_handle); + pimv1_handle = new_create_dissector_handle(dissect_pimv1, proto_pim); + dissector_add_uint("igmp.type", IGMP_V1_PIM_ROUTING_MESSAGE, pimv1_handle); + /* * Get handles for the IPv4 and IPv6 dissectors. */ diff --git a/epan/dissectors/packet-pim.h b/epan/dissectors/packet-pim.h deleted file mode 100644 index d7d2e90628..0000000000 --- a/epan/dissectors/packet-pim.h +++ /dev/null @@ -1,28 +0,0 @@ -/* packet-pim.h - * Declarations of routines for IGMP/PIMv1 packet disassembly - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PACKET_PIM_H__ -#define __PACKET_PIM_H__ - -int dissect_pimv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset); - -#endif diff --git a/epan/dissectors/packet-rgmp.c b/epan/dissectors/packet-rgmp.c index 34b413d6d1..9641773f10 100644 --- a/epan/dissectors/packet-rgmp.c +++ b/epan/dissectors/packet-rgmp.c @@ -25,9 +25,6 @@ Based on RFC3488 This is a setup for RGMP dissection, a simple protocol bolted on IGMP. - The trick is to have IGMP dissector call this function (which by itself is not - registered as dissector). IGAP and other do the same. - */ #include "config.h" @@ -36,7 +33,6 @@ #include <epan/packet.h> #include <epan/strutil.h> #include "packet-igmp.h" -#include "packet-rgmp.h" void proto_register_rgmp(void); @@ -48,6 +44,8 @@ static int hf_maddr = -1; static int ett_rgmp = -1; +#define MC_RGMP 0xe0000019 + static const value_string rgmp_types[] = { {IGMP_RGMP_LEAVE, "Leave"}, {IGMP_RGMP_JOIN, "Join"}, @@ -58,25 +56,24 @@ static const value_string rgmp_types[] = { /* This function is only called from the IGMP dissector */ int -dissect_rgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) +dissect_rgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_) { proto_tree *tree; proto_item *item; guint8 type; + int offset = 0; + guint32 dst = g_htonl(MC_RGMP); - if (!proto_is_protocol_enabled(find_protocol_by_id(proto_rgmp))) { - /* we are not enabled, skip entire packet to be nice - to the igmp layer. (so clicking on IGMP will display the data) - */ - return offset + tvb_length_remaining(tvb, offset); - } - - item = proto_tree_add_item(parent_tree, proto_rgmp, tvb, offset, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_rgmp); + /* Shouldn't be destined for us */ + if (memcmp(pinfo->dst.data, &dst, 4)) + return 0; col_set_str(pinfo->cinfo, COL_PROTOCOL, "RGMP"); col_clear(pinfo->cinfo, COL_INFO); + item = proto_tree_add_item(parent_tree, proto_rgmp, tvb, offset, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_rgmp); + type = tvb_get_guint8(tvb, offset); col_add_str(pinfo->cinfo, COL_INFO, val_to_str(type, rgmp_types, "Unknown Type: 0x%02x")); @@ -126,10 +123,23 @@ proto_register_rgmp(void) &ett_rgmp }; - proto_rgmp = proto_register_protocol - ("Router-port Group Management Protocol", "RGMP", "rgmp"); + proto_rgmp = proto_register_protocol("Router-port Group Management Protocol", "RGMP", "rgmp"); proto_register_field_array(proto_rgmp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + + new_register_dissector("rgmp", dissect_rgmp, proto_rgmp); +} + +void +proto_reg_handoff_rgmp(void) +{ + dissector_handle_t rgmp_handle; + + rgmp_handle = new_create_dissector_handle(dissect_rgmp, proto_rgmp); + dissector_add_uint("igmp.type", IGMP_RGMP_HELLO, rgmp_handle); + dissector_add_uint("igmp.type", IGMP_RGMP_BYE, rgmp_handle); + dissector_add_uint("igmp.type", IGMP_RGMP_JOIN, rgmp_handle); + dissector_add_uint("igmp.type", IGMP_RGMP_LEAVE, rgmp_handle); } /* diff --git a/epan/dissectors/packet-rgmp.h b/epan/dissectors/packet-rgmp.h deleted file mode 100644 index e3e2dbe5f1..0000000000 --- a/epan/dissectors/packet-rgmp.h +++ /dev/null @@ -1,34 +0,0 @@ -/* packet-rgmp.h - * Declarations of routines for IGMP/RGMP packet disassembly - * Copyright 2006 Jaap Keuter - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PACKET_RGMP_H__ -#define __PACKET_RGMP_H__ - -#define IGMP_RGMP_LEAVE 0xFC -#define IGMP_RGMP_JOIN 0xFD -#define IGMP_RGMP_BYE 0xFE -#define IGMP_RGMP_HELLO 0xFF - -int dissect_rgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset); - -#endif |