Based on RFC3488. This is a setup for RGMP dissection, a simple protocol bolted on...
authorjake <jake@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 28 Oct 2006 21:52:38 +0000 (21:52 +0000)
committerjake <jake@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 28 Oct 2006 21:52:38 +0000 (21:52 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@19722 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/Makefile.common
epan/dissectors/packet-igmp.c
epan/dissectors/packet-rgmp.c [new file with mode: 0644]
epan/dissectors/packet-rgmp.h [new file with mode: 0644]

index f4187b45d482a144a2e6ab2e10eb5ff8e70f4f3e..318f3a137e0c1557c548ec3ad118757f89926db5 100644 (file)
@@ -551,6 +551,7 @@ DISSECTOR_SRC =     \
        packet-rdt.c    \
        packet-redback.c \
        packet-retix-bpdu.c \
+       packet-rgmp.c   \
        packet-rip.c    \
        packet-ripng.c  \
        packet-rlogin.c \
@@ -911,6 +912,7 @@ DISSECTOR_INCLUDES =        \
        packet-ranap.h  \
        packet-raw.h    \
        packet-rdt.h    \
+       packet-rgmp.h   \
        packet-ripng.h  \
        packet-rmi.h    \
        packet-rmt-alc.h        \
index e16f94324decc19a3696f3ee5b80feb9226e2502..17bdb8b87af1b4182beaeadbfb8f9badda867e61 100644 (file)
@@ -19,7 +19,7 @@
  *
  * 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 /*
        IGMP is defined in the following RFCs
@@ -30,7 +30,7 @@
        RFC3376 Version 3
 
        Size in bytes for each packet
-       type    RFC988  RFC1054 RFC2236 RFC3376  DVMRP  MRDISC  MSNIP  IGAP
+       type    RFC988  RFC1054 RFC2236 RFC3376  DVMRP  MRDISC  MSNIP  IGAP  RGMP
                v0      v1      v2      v3       v1/v3
        0x01      20
        0x02      20
        0x40                                                           ??c
        0x41                                                           ??c
        0x42                                                           ??c
+       0xfc                                                                  8
+       0xfd                                                                  8
+       0xfe                                                                  8
+       0xff                                                                  8
 
    * Differs in second byte of protocol. Always 0 in V1
 
         IGAP : Internet Group membership Authentication Protocol
        draft-hayashi-igap-03.txt
 
+   d RGMP Protocol  see packet-rgmp.c
+
+       RGMP : Router-port Group Management Protocol
+       RFC3488
+       TTL == 1 and IP.DST==224.0.0.25 for all packets
+
 */
 
 #ifdef HAVE_CONFIG_H
 #include "packet-mrdisc.h"
 #include "packet-msnip.h"
 #include "packet-igap.h"
+#include "packet-rgmp.h"
 
 static int proto_igmp = -1;
 static int hf_type = -1;
@@ -164,6 +175,7 @@ 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
@@ -892,6 +904,16 @@ dissect_igmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
                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;
diff --git a/epan/dissectors/packet-rgmp.c b/epan/dissectors/packet-rgmp.c
new file mode 100644 (file)
index 0000000..a8b48cf
--- /dev/null
@@ -0,0 +1,142 @@
+/* packet-rgmp.c
+ * Routines for IGMP/RGMP packet disassembly
+ * Copyright 2006 Jaap Keuter
+ *
+ * $Id$
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/* 
+ 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.
+
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include <epan/packet.h>
+#include <epan/strutil.h>
+#include "packet-igmp.h"
+#include "packet-rgmp.h"
+
+
+static int proto_rgmp      = -1;
+static int hf_type         = -1;
+static int hf_checksum     = -1;
+static int hf_checksum_bad = -1;
+static int hf_maddr        = -1;
+
+static int ett_rgmp = -1;
+
+static const value_string rgmp_types[] = {
+    {IGMP_RGMP_LEAVE, "Leave"},
+    {IGMP_RGMP_JOIN,  "Join"},
+    {IGMP_RGMP_BYE,   "Bye"},
+    {IGMP_RGMP_HELLO, "Hello"},
+    {0, NULL}
+};
+
+/* This function is only called from the IGMP dissector */
+int
+dissect_rgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
+{
+    proto_tree *tree;
+    proto_item *item;
+    guint8 type;
+
+    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, FALSE);
+    tree = proto_item_add_subtree(item, ett_rgmp);
+
+    if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
+       col_set_str(pinfo->cinfo, COL_PROTOCOL, "RGMP");
+    }
+    if (check_col(pinfo->cinfo, COL_INFO)) {
+       col_clear(pinfo->cinfo, COL_INFO);
+    }
+
+    type = tvb_get_guint8(tvb, offset);
+    if (check_col(pinfo->cinfo, COL_INFO)) {
+       col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
+                    val_to_str(type, rgmp_types, "Unknown Type: 0x%02x"));
+    }
+    proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type);
+    offset += 1;
+
+    /* reserved */
+
+    offset += 1;
+
+    igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+    offset += 2;
+
+    proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, FALSE);
+    offset += 4;
+
+    return offset;
+}
+
+
+void
+proto_register_rgmp(void)
+{
+    static hf_register_info hf[] = {
+       { &hf_type,
+         { "Type", "rgmp.type", FT_UINT8, BASE_HEX,
+           VALS(rgmp_types), 0, "RGMP Packet Type", HFILL }
+       },
+
+       { &hf_checksum,
+         { "Checksum", "rgmp.checksum", FT_UINT16, BASE_HEX,
+           NULL, 0, "Checksum", HFILL }
+       },
+
+       { &hf_checksum_bad,
+         { "Bad Checksum", "rgmp.checksum_bad", FT_BOOLEAN, BASE_NONE,
+           NULL, 0, "Bad Checksum", HFILL }
+       },
+
+       { &hf_maddr,
+         { "Multicast group address", "rgmp.maddr", FT_IPv4, BASE_NONE,
+           NULL, 0, "Multicast group address", HFILL }
+       }
+    };
+
+    static gint *ett[] = {
+       &ett_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));
+}
diff --git a/epan/dissectors/packet-rgmp.h b/epan/dissectors/packet-rgmp.h
new file mode 100644 (file)
index 0000000..6e6afac
--- /dev/null
@@ -0,0 +1,36 @@
+/* packet-rgmp.h
+ * Declarations of routines for IGMP/RGMP packet disassembly
+ * Copyright 2006 Jaap Keuter
+ *
+ * $Id$
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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