Include <string.h> to get "strcmp()" declared.
[obnox/wireshark/wip.git] / packet-gmrp.c
index d4794fc2b70e371782bbbbc9d62b8aa0ed4a97fe..0354eeb329fe506b95c35c7ae9b599777b2a0f32 100644 (file)
@@ -5,6 +5,8 @@
  * Based on the code from packet-gvrp.c (GVRP) from
  * Kevin Shi <techishi@ms22.hinet.net> Copyright 2000
  *
+ * $Id: packet-gmrp.c,v 1.10 2002/08/28 21:00:13 jmayer Exp $
+ *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
  * 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 <stdlib.h>
 #include <string.h>
 
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-
 #include <glib.h>
 
-#ifdef NEED_SNPRINTF_H
-# include "snprintf.h"
-#endif
-
-#include "packet.h"
+#include <epan/packet.h>
 #include "llcsaps.h"
 
 /* Initialize the protocol and registered fields */
@@ -129,12 +119,12 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     guint8        octet;
     guint8               attribute_type;
     int           msg_index, attr_index, offset = 0, length = tvb_reported_length(tvb);
-    
-    if (check_col(pinfo->fd, COL_PROTOCOL)) 
-       col_set_str(pinfo->fd, COL_PROTOCOL, "GMRP");
-    
-    if (check_col(pinfo->fd, COL_INFO)) 
-       col_set_str(pinfo->fd, COL_INFO, "GMRP");
+
+    if (check_col(pinfo->cinfo, COL_PROTOCOL))
+       col_set_str(pinfo->cinfo, COL_PROTOCOL, "GMRP");
+
+    if (check_col(pinfo->cinfo, COL_INFO))
+       col_set_str(pinfo->cinfo, COL_INFO, "GMRP");
 
     if (tree)
     {
@@ -144,22 +134,24 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
        /* Read in GARP protocol ID */
        protocol_id = tvb_get_ntohs(tvb, GARP_PROTOCOL_ID);
-    
+
        proto_tree_add_uint_format(gmrp_tree, hf_gmrp_proto_id, tvb,
-                                  GARP_PROTOCOL_ID, sizeof(guint16), 
+                                  GARP_PROTOCOL_ID, sizeof(guint16),
                                   protocol_id,
-                                  "Protocol Identifier: 0x%04x (%s)", 
+                                  "Protocol Identifier: 0x%04x (%s)",
                                   protocol_id,
-                                  protocol_id == GARP_DEFAULT_PROTOCOL_ID ? 
+                                  protocol_id == GARP_DEFAULT_PROTOCOL_ID ?
                                     "GARP Multicast Registration Protocol" :
                                     "Unknown Protocol");
 
        /* Currently only one protocol ID is supported */
        if (protocol_id != GARP_DEFAULT_PROTOCOL_ID)
        {
-           proto_tree_add_text(gmrp_tree, tvb, GARP_PROTOCOL_ID, sizeof(guint16), 
+           proto_tree_add_text(gmrp_tree, tvb, GARP_PROTOCOL_ID, sizeof(guint16),
  "   (Warning: this version of Ethereal only knows about protocol id = 1)");
-           call_dissector(data_handle,tvb_new_subset(tvb, GARP_PROTOCOL_ID + sizeof(guint16), -1,tvb_reported_length_remaining(tvb,GARP_PROTOCOL_ID + sizeof(guint16))),pinfo, tree);
+           call_dissector(data_handle,
+               tvb_new_subset(tvb, GARP_PROTOCOL_ID + sizeof(guint16), -1, -1),
+               pinfo, tree);
            return;
        }
 
@@ -189,7 +181,9 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                }
                                else
                                {
-                                       call_dissector(data_handle,tvb_new_subset(tvb, offset,-1,tvb_reported_length_remaining(tvb,offset)), pinfo, tree);
+                                       call_dissector(data_handle,
+                                           tvb_new_subset(tvb, offset, -1, -1),
+                                           pinfo, tree);
                                        return;
                                }
                        }
@@ -197,7 +191,7 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        offset += sizeof(guint8);
                        length -= sizeof(guint8);
 
-                       msg_item = proto_tree_add_text(gmrp_tree, tvb, msg_start, 0,
+                       msg_item = proto_tree_add_text(gmrp_tree, tvb, msg_start, -1,
                                                   "Message %d", msg_index + 1);
 
                        proto_tree_add_uint(gmrp_tree, hf_gmrp_attribute_type, tvb,
@@ -206,7 +200,9 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        /* GMRP supports Group Membership and Service Requirement as attribute types */
                        if ( (octet != GMRP_ATTRIBUTE_TYPE_GROUP_MEMBERSHIP) && (octet != GMRP_ATTRIBUTE_TYPE_SERVICE_REQUIREMENT) )
                        {
-                               call_dissector(data_handle,tvb_new_subset(tvb, offset,-1,tvb_reported_length_remaining(tvb,offset)), pinfo, tree);
+                               call_dissector(data_handle,
+                                   tvb_new_subset(tvb, offset, -1, -1), pinfo,
+                                   tree);
                                return;
                        }
 
@@ -223,7 +219,7 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                /* Check for end of mark */
                                if (octet == GARP_END_OF_MARK)
                                {
-                                       /* If at least one message has been already read, 
+                                       /* If at least one message has been already read,
                                         * check for another end of mark.
                                         */
                                        if (attr_index)
@@ -239,7 +235,9 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                        }
                                        else
                                        {
-                                               call_dissector(data_handle,tvb_new_subset(tvb, offset,-1,tvb_reported_length_remaining(tvb,offset)), pinfo, tree);
+                                               call_dissector(data_handle,
+                                                   tvb_new_subset(tvb, offset, -1, -1),
+                                                   pinfo, tree);
                                                return;
                                        }
                                }
@@ -251,7 +249,7 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                        length -= sizeof(guint8);
 
                                        attr_item = proto_tree_add_text(gmrp_tree, tvb,
-                                        attr_start, 0, "  Attribute %d", attr_index + 1);
+                                        attr_start, -1, "  Attribute %d", attr_index + 1);
 
                                        proto_tree_add_uint(gmrp_tree, hf_gmrp_attribute_length,
                                         tvb, attr_start, sizeof(guint8), octet);
@@ -270,7 +268,9 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                        case GMRP_EVENT_LEAVEALL:
                                                if (octet != GMRP_LENGTH_LEAVEALL)
                                                {
-                                                       call_dissector(data_handle,tvb_new_subset(tvb, offset,-1,tvb_reported_length_remaining(tvb,offset)), pinfo, tree);
+                                                       call_dissector(data_handle,
+                                                           tvb_new_subset(tvb, offset, -1, -1),
+                                                           pinfo, tree);
                                                        return;
                                                }
                                                break;
@@ -282,7 +282,9 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                         case GMRP_EVENT_EMPTY:
                                                if ( (octet != GMRP_GROUP_MEMBERSHIP_NON_LEAVEALL) && (octet != GMRP_SERVICE_REQUIREMENT_NON_LEAVEALL) )
                                                {
-                                                       call_dissector(data_handle,tvb_new_subset(tvb, offset, -1,tvb_reported_length_remaining(tvb,offset)),pinfo, tree);
+                                                       call_dissector(data_handle,
+                                                           tvb_new_subset(tvb, offset, -1, -1),
+                                                           pinfo, tree);
                                                        return;
                                                }
 
@@ -303,20 +305,24 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                                /* Service Requirement */
                                                proto_tree_add_item(gmrp_tree, hf_gmrp_attribute_value_service_requirement,
                                                        tvb, offset, sizeof(guint8), FALSE);
-                                                       
+
                                                offset += sizeof(guint8);
                                                length -= sizeof(guint8);
                                        }
                                        else
                                        {
-                                               call_dissector(data_handle,tvb_new_subset(tvb, offset,-1,tvb_reported_length_remaining(tvb,offset)), pinfo, tree);
+                                               call_dissector(data_handle,
+                                                   tvb_new_subset(tvb, offset, -1, -1),
+                                                   pinfo, tree);
                                                return;
                                        }
 
                                        break;
 
                                         default:
-                                       call_dissector(data_handle,tvb_new_subset(tvb, offset,-1,tvb_reported_length_remaining(tvb,offset)), pinfo, tree);
+                                       call_dissector(data_handle,
+                                           tvb_new_subset(tvb, offset, -1, -1),
+                                           pinfo, tree);
                                        return;
                                        }
                                }
@@ -336,7 +342,7 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 /* Register the protocol with Ethereal */
 void
 proto_register_gmrp(void)
-{               
+{
     static hf_register_info hf[] = {
        { &hf_gmrp_proto_id,
            { "Protocol ID", "garp.protocol_id",
@@ -368,7 +374,7 @@ proto_register_gmrp(void)
            FT_UINT8,        BASE_HEX,      NULL,  0x0,
            "" , HFILL }
        }
-       
+
     };
 
     static gint *ett[] = {
@@ -382,9 +388,9 @@ proto_register_gmrp(void)
      * used by GMRP */
     proto_register_field_array(proto_gmrp, hf, array_length(hf));
     proto_register_subtree_array(ett, array_length(ett));
-    
+
     register_dissector("gmrp", dissect_gmrp, proto_gmrp);
-    
+
 }
 
 void