From Bingyao Du:
authorjake <jake@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 27 Apr 2007 06:34:31 +0000 (06:34 +0000)
committerjake <jake@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 27 Apr 2007 06:34:31 +0000 (06:34 +0000)
Attachment is a patch for adding a new Juniper NSRP dissector. In this patch, OICQ author email address
<dubingyao@gmail.com> has also been updated to <secfire@gmail.com>.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@21599 f5534014-38df-0310-8fa8-9805f1628bb7

AUTHORS
epan/dissectors/Makefile.common
epan/dissectors/packet-ethertype.c
epan/dissectors/packet-nsrp.c [new file with mode: 0644]
epan/etypes.h

diff --git a/AUTHORS b/AUTHORS
index 3b41f789c5247f0c61b7fbbe9d798212872345b9..6260ca640833079698187daf8458ac8eb0976151 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -2467,8 +2467,9 @@ Eric Wedel              <ewedel [AT] bluearc.com> {
        KPASSWD over TCP support
 }
 
-Du Bingyao             <dubingyao[AT]gmail.com> {
+Secfire                <secfire[AT]gmail.com> {
        OICQ
+       Juniper NSRP
 }
 
 Eric Hultin            <Eric.Hultin[AT]arrisi.com> {
index 9084fe8b7a1ee5af6aa48929393ecc815d1412f4..596939ab8206d1d57474d2f6718b98b6231c6d55 100644 (file)
@@ -543,6 +543,7 @@ CLEAN_DISSECTOR_SRC = \
        packet-nlsp.c           \
        packet-nntp.c           \
        packet-nsip.c           \
+       packet-nsrp.c           \
        packet-nt-oui.c         \
        packet-nt-sonmp.c       \
        packet-nt-tpcp.c        \
index ff7fa29f0c3aff3c70bdceb9f02b959ccd1f2b1d..0a4b1ecf5867f1ec7c8f90c8444cda7e75a29b73 100644 (file)
@@ -110,6 +110,7 @@ const value_string etype_vals[] = {
     {ETHERTYPE_3GPP2,                           "CDMA2000 A10 3GPP2 Packet" },
     {ETHERTYPE_LLTD,                   "Link Layer Topology Discovery (LLTD)" },
     {ETHERTYPE_COBRANET,               "Cirrus Cobranet Packet" },
+    {ETHERTYPE_NSRP,                   "Juniper Netscreen Redundant Protocol" },
     /*
      * NDISWAN on Windows translates Ethernet frames from higher-level
      * protocols into PPP frames to hand to the PPP driver, and translates
diff --git a/epan/dissectors/packet-nsrp.c b/epan/dissectors/packet-nsrp.c
new file mode 100644 (file)
index 0000000..d5a546b
--- /dev/null
@@ -0,0 +1,520 @@
+/* packet-nsrp.c
+ * Routines for the Juniper Netscreen Redundant Protocol (NSRP)
+ *
+ * Secfire <secfire@gmail.com>
+ *
+ * $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.
+ */
+
+/* 
+ *
+ * NSRP update information can be found at www.juniper.net
+ *
+ *
+ *           
+ *    NSRP Packet Header is defined as follow:
+ *                  
+ *       1         2       3        4        5         6       7        8 
+ *   +--------+--------+--------+--------+--------+--------+--------+--------+
+ *   |Version | Type   |Clust ID|MSG Flag|     Length      |HA Port |Not Used|
+ *   +--------+--------+--------+--------+--------+--------+--------+--------+
+ *   |          Destination Unit         |             Source Unit           |
+ *   +--------+--------+--------+--------+--------+--------+--------+--------+
+ *
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+
+#include <epan/packet.h>
+#include <epan/etypes.h>
+
+#define NSRP_MIN_LEN    32
+
+/* Initialize the protocol and registered fields */
+static int proto_nsrp       = -1;
+
+static int hf_nsrp_version       = -1;
+static int hf_nsrp_msg_type      = -1;
+static int hf_nsrp_clust_id      = -1;
+static int hf_nsrp_msg_flag      = -1;
+static int hf_nsrp_len           = -1;
+static int hf_nsrp_ha_port       = -1;
+static int hf_nsrp_not_used      = -1;
+static int hf_nsrp_dst_unit      = -1;
+static int hf_nsrp_src_unit      = -1;
+static int hf_nsrp_msgtype       = -1;
+static int hf_nsrp_wst_group     = -1;
+static int hf_nsrp_hst_group     = -1;
+static int hf_nsrp_msgflag     = -1;
+static int hf_nsrp_authflag      = -1;
+static int hf_nsrp_priority      = -1;
+static int hf_nsrp_dummy         = -1;
+static int hf_nsrp_authchecksum  = -1;
+static int hf_nsrp_ifnum         = -1;
+
+
+/* Dada defined for HA Message */
+static int hf_nsrp_msglen      = -1;
+static int hf_nsrp_encflag      = -1;
+static int hf_nsrp_notused = -1;
+
+static int hf_nsrp_total_size = -1;
+
+static int hf_nsrp_ns = -1;
+static int hf_nsrp_nr = -1;
+
+static int hf_nsrp_no_used = -1;
+static int hf_nsrp_checksum = -1;
+
+static int hf_nsrp_data = -1;
+
+
+static const value_string nsrp_msg_type_vals[] = {
+       { 0x01, "HA MESSAGE" },
+       { 0x02, "MNG MESSAGE" },
+       { 0x03, "DADA MESSAGE" },
+       { 0,                    NULL }
+};
+
+static const value_string nsrp_msgtype_vals[] = {
+       { 0x01, "CREATE SESSION" },
+       { 0x02, "CLOSE SESSION" },
+       { 0x03, "CHANG SESSION" },
+       { 0x04, "CREATE SP SESSION" },
+       { 0x05, "SYS CONFIG" },
+       { 0x06, "FILE SYS" },
+       { 0x07, "CMD WEB" },
+       { 0x08, "SAVE SLAVE" },
+       { 0x09, "VPN SPI" },
+       { 0x0a, "ARP" },
+       { 0x0b, "HEALTH CHECK" },
+       { 0x0c, "EMW DATA" },
+       { 0x0d, "INVITE SYNC" },
+       { 0x0e, "DOWNLOAD CONFIG" },
+       { 0x0f, "L2TP TUNL CREATE" },
+       { 0x10, "L2TP TUNL DELETE" },
+       { 0x11, "L2TP CALL CREATE" },
+       { 0x12, "L2TP CALL DELETE" },
+       { 0x13, "PKI SYNC" },
+       { 0x14, "VPN SEQ" },
+       { 0x15, "MAX" },
+       { 0,                    NULL }
+};
+
+static const value_string nsrp_flag_vals[] = {
+       { 0x80, "ENCRPT MESSAGE" },
+       { 0x40, "CLOSE SESSION" },
+       { 0x20, "CHANG SESSION" },
+       { 0x10, "CREATE SP SESSION" },
+       { 0x08, "SYS CONFIG" },
+       { 0x04, "FILE SYS" },
+       { 0x02, "CMD WEB" },
+       { 0,                    NULL }
+};
+
+static const value_string nsrp_encflag_vals[] = {
+       { 0xf0, "ENCRYPT METHOD MASK" },
+       { 0x0f, "ENCRYPT PAD BIT MASK" },
+       { 0,                    NULL }
+};
+
+
+/* Initialize the subtree pointers */
+static gint ett_nsrp = -1;
+
+/* Code to actually dissect the packets */
+static void
+dissect_nsrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+    proto_item  *ti;
+    proto_tree  *nsrp_tree = NULL;
+    gint        offset = 0;
+    guint8      msgtype = 0;
+
+    if (check_col(pinfo->cinfo, COL_PROTOCOL))
+                       col_set_str(pinfo->cinfo, COL_PROTOCOL, "NSRP");
+
+    if (check_col(pinfo->cinfo, COL_INFO))
+    {
+                       col_clear(pinfo->cinfo, COL_INFO);
+                       col_set_str(pinfo->cinfo, COL_INFO, "NSRP Protocol");
+               }
+
+    if (tree) {
+                       ti = proto_tree_add_item(tree, proto_nsrp, tvb, 0, -1, FALSE);
+                       nsrp_tree = proto_item_add_subtree(ti, ett_nsrp);
+                       
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_version, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       msgtype = tvb_get_guint8(tvb, offset);
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_msg_type, tvb, offset, 1, FALSE);
+                       offset += 1;
+               
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_clust_id, tvb, offset, 1, FALSE);
+                       offset += 1;
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_msg_flag, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_len, tvb, offset, 2, FALSE);
+                       offset += 2;
+               
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_ha_port, tvb, offset, 1, FALSE);
+                       offset += 1;
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_dst_unit, tvb, offset, 4, FALSE);
+                       offset += 4;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_src_unit, tvb, offset, 4, FALSE);
+                       offset += 4;
+               }
+               
+/*
+ *
+ *
+ *    NSRP HA Packet is defined as follow:
+ * 
+ *       1         2       3        4        5         6       7        8 
+ *   +--------+--------+--------+--------+--------+--------+--------+--------+
+ *   | Type   |WstGroup|HstGroup|MSG Flag|     Length      |Enc Flag|Not Used|
+ *   +--------+--------+--------+--------+--------+--------+--------+--------+
+ *   |            Total Size             |        NS       |        NR       |
+ *   +--------+--------+--------+--------+--------+--------+--------+--------+
+ *   |     No Used     |    Checksum     |              Data                 |
+ *   +--------+--------+--------+--------+-----------------------------------+
+ *
+ *
+ */
+
+               if ( msgtype == 0x00 ) {
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, FALSE);
+                       offset += 1;
+               
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, FALSE);
+                       offset += 2;
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_encflag, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_total_size, tvb, offset, 4, FALSE);
+                       offset += 4;
+               
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_ns, tvb, offset, 2, FALSE);
+                       offset += 2;
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_nr, tvb, offset, 2, FALSE);
+                       offset += 2;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_no_used, tvb, offset, 2, FALSE);
+                       offset += 2;
+               
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_checksum, tvb, offset, 2, FALSE);
+                       offset += 2;
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, FALSE);
+                       
+    }
+    
+/*
+ *  
+ *    NSRP MNG Packet is defined as follow:
+ * 
+ *       1         2       3        4        5         6       7        8 
+ *   +--------+--------+--------+--------+--------+--------+--------+--------+
+ *   | Type   |WstGroup|HstGroup|MSG Flag|     Length      |AuthFlag|Not Used|
+ *   +--------+--------+--------+--------+--------+--------+--------+--------+
+ *   |Priority+ Dummy  +   Auth CheckSum +                Data               |
+ *   +--------+--------+--------+--------+-----------------------------------+
+ *  
+ *
+ */
+
+               if ( msgtype == 0x02 ) {
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, FALSE);
+                       offset += 1;
+               
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, FALSE);
+                       offset += 2;
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_authflag, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_priority, tvb, offset, 1, FALSE);
+                       offset += 1;
+               
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_dummy, tvb, offset, 1, FALSE);
+                       offset += 1;
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_authchecksum, tvb, offset, 2, FALSE);
+                       offset += 2;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, FALSE);
+                       
+    }
+    
+        
+    
+    
+/*   
+ *    NSRP DATA Packet is defined as follow:
+ * 
+ *       1         2       3        4        5         6       7        8 
+ *   +--------+--------+--------+--------+--------+--------+--------+--------+
+ *   | Type   |WstGroup|HstGroup|MSG Flag|     Length      | Ifnum  |Not Used|
+ *   +--------+--------+--------+--------+--------+--------+--------+--------+
+ *   |            Total Size             |                Data               |
+ *   +--------+--------+--------+--------+-----------------------------------+
+ *
+ *
+ */
+   if ( msgtype == 0x03 ) {
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, FALSE);
+                       offset += 1;
+               
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, FALSE);
+                       offset += 2;
+                       
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_ifnum, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, FALSE);
+                       offset += 1;
+
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_total_size, tvb, offset, 4, FALSE);
+                       offset += 4;
+               
+                       proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, FALSE);
+                       
+    }
+
+}
+
+
+void
+proto_register_nsrp(void)
+{
+
+    static hf_register_info hf[] = {
+       { &hf_nsrp_version,
+         { "Version", "nsrp.version",
+           FT_UINT8, BASE_DEC, NULL, 0,
+           "NSRP Version", HFILL }
+       },
+               { &hf_nsrp_msg_type,
+         { "Type", "nsrp.type",
+           FT_UINT8, BASE_DEC, nsrp_msg_type_vals, 0,
+           "NSRP Message Type", HFILL }
+       },
+               { &hf_nsrp_clust_id,
+         { "Clust ID", "nsrp.clustid",
+           FT_UINT8, BASE_DEC, NULL, 0,
+           "NSRP CLUST ID", HFILL }
+       },
+               { &hf_nsrp_msg_flag,
+         { "Flag", "nsrp.flag",
+           FT_UINT8, BASE_DEC, NULL, 0,
+           "NSRP FLAG", HFILL }
+       },
+       { &hf_nsrp_len,
+         { "Length", "nsrp.length",
+           FT_UINT16, BASE_DEC, NULL, 0,
+           "NSRP Length", HFILL }
+       },
+               { &hf_nsrp_ha_port,
+         { "Port", "nsrp.haport",
+           FT_UINT8, BASE_DEC, NULL, 0,
+           "NSRP HA Port", HFILL }
+       },
+               { &hf_nsrp_not_used,
+         { "Not used", "nsrp.notused",
+           FT_UINT8, BASE_DEC, NULL, 0,
+           "NOT USED", HFILL }
+       },
+               { &hf_nsrp_dst_unit,
+         { "Destination", "nsrp.dst",
+           FT_UINT32, BASE_DEC, NULL, 0,
+           "DESTINATION UNIT INFORMATION", HFILL }
+       },
+       { &hf_nsrp_src_unit,
+         { "Source", "nsrp.src",
+           FT_UINT32, BASE_DEC, NULL, 0,
+           "SOURCE UNIT INFORMATION", HFILL }
+       },
+               { &hf_nsrp_msgtype,
+         { "MsgType", "nsrp.msgtype",
+           FT_UINT8, BASE_DEC, VALS(nsrp_msgtype_vals), 0,
+           "Message Type", HFILL }
+       },
+               { &hf_nsrp_wst_group,
+         { "Wst group", "nsrp.wst",
+           FT_UINT8, BASE_DEC, NULL, 0,
+           "NSRP WST GROUP", HFILL }
+       },
+               { &hf_nsrp_hst_group,
+         { "Hst group", "nsrp.hst",
+           FT_UINT8, BASE_DEC, NULL, 0,
+           "NSRP HST GROUP", HFILL }
+       },
+       { &hf_nsrp_msgflag,
+         { "Msgflag", "nsrp.msgflag",
+           FT_UINT8, BASE_DEC, VALS(nsrp_flag_vals), 0,
+           "NSRP MSG FLAG", HFILL }
+       },
+       { &hf_nsrp_msglen,
+         { "Msg Length", "nsrp.msglen",
+           FT_UINT16, BASE_DEC, NULL, 0,
+           "NSRP MESSAGE LENGTH", HFILL }
+       },
+               
+       { &hf_nsrp_encflag,
+         { "Enc Flag", "nsrp.encflag",
+           FT_UINT8, BASE_DEC, VALS(nsrp_encflag_vals), 0,
+           "NSRP ENCRYPT FLAG", HFILL }
+       },
+               { &hf_nsrp_notused,
+         { "Not Used", "nsrp.notused",
+           FT_UINT8, BASE_DEC, NULL, 0,
+           "NOT USED", HFILL }
+       },
+               { &hf_nsrp_total_size,
+         { "Total Size", "nsrp.totalsize",
+           FT_UINT32, BASE_DEC, NULL, 0,
+           "NSRP MSG TOTAL MESSAGE", HFILL }
+       },
+               { &hf_nsrp_ns,
+         { "Ns", "nsrp.ns",
+           FT_UINT16, BASE_DEC, NULL, 0,
+           "Ns", HFILL }
+       },
+               { &hf_nsrp_nr,
+         { "Nr", "nsrp.nr",
+           FT_UINT16, BASE_DEC, NULL, 0,
+           "Nr", HFILL }
+       },
+               { &hf_nsrp_no_used,
+         { "Reserved", "nsrp.reserved",
+           FT_UINT16, BASE_DEC, NULL, 0,
+           "RESERVED", HFILL }
+       },
+               { &hf_nsrp_checksum,
+         { "Checksum", "nsrp.checksum",
+           FT_UINT16, BASE_HEX, NULL, 0,
+           "NSRP PACKET CHECKSUM", HFILL }
+       },
+               { &hf_nsrp_authflag,
+         { "AuthFlag", "nsrp.authflag",
+           FT_UINT8, BASE_HEX, NULL, 0,
+           "NSRP Auth Flag", HFILL }
+       },
+                       { &hf_nsrp_priority,
+         { "Priority", "nsrp.priority",
+           FT_UINT8, BASE_HEX, NULL, 0,
+           "NSRP Priority", HFILL }
+       },
+                       { &hf_nsrp_dummy,
+         { "Dummy", "nsrp.dummy",
+           FT_UINT8, BASE_HEX, NULL, 0,
+           "NSRP Dummy", HFILL }
+       },
+               { &hf_nsrp_authchecksum,
+         { "Checksum", "nsrp.authchecksum",
+           FT_UINT16, BASE_HEX, NULL, 0,
+           "NSRP AUTH CHECKSUM", HFILL }
+       },
+               { &hf_nsrp_ifnum,
+         { "Ifnum", "nsrp.ifnum",
+           FT_UINT16, BASE_HEX, NULL, 0,
+           "NSRP IfNum", HFILL }
+       },
+       { &hf_nsrp_data,
+         { "Data", "nsrp.data",
+           FT_STRING, 0, NULL, 0,
+           "PADING", HFILL }
+       }
+    };
+
+    static gint *ett[] = {
+       &ett_nsrp
+    };
+
+    proto_nsrp = proto_register_protocol("Juniper Netscreen Redundant Protocol",
+       "NSRP", "nsrp");
+    proto_register_field_array(proto_nsrp, hf, array_length(hf));
+    proto_register_subtree_array(ett, array_length(ett));
+}
+
+
+void
+proto_reg_handoff_nsrp(void)
+{
+    dissector_handle_t nsrp_handle;
+
+    nsrp_handle = create_dissector_handle(dissect_nsrp, proto_nsrp);
+    dissector_add("ethertype", ETHERTYPE_NSRP, nsrp_handle);
+}
index 58fe7ae88c72f54c6c6b3f372732d2f4f0b88f0b..ce7358b8b859c7f12e41063a6476ed8bcd19a3d6 100644 (file)
 #define ETHERTYPE_VLAN         0x8100  /* 802.1Q Virtual LAN */
 #endif
 
+#ifndef ETHERTYPE_NSRP
+#define ETHERTYPE_NSRP         0x8133
+#endif
+
 #ifndef ETHERTYPE_IPX
 #define ETHERTYPE_IPX          0x8137
 #endif