Use "proto_tree_add_item()" whenever possible; this fixes some bugs
[obnox/wireshark/wip.git] / packet-cdp.c
index 6e516566bc4dd97dafdd0c29373eaba9e855c270..51e1e4de6c1b9d79ae734400069831bb57f89617 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for the disassembly of the "Cisco Discovery Protocol"
  * (c) Copyright Hannes R. Boehm <hannes@boehm.org>
  *
- * $Id: packet-cdp.c,v 1.39 2001/08/28 08:28:14 guy Exp $
+ * $Id: packet-cdp.c,v 1.42 2001/12/10 00:25:26 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -61,6 +61,8 @@ static gint ett_cdp_tlv = -1;
 static gint ett_cdp_address = -1;
 static gint ett_cdp_capabilities = -1;
 
+static dissector_handle_t data_handle;
+
 static int
 dissect_address_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree);
 static void
@@ -109,10 +111,10 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     guint32 naddresses;
     int addr_length;
 
-    if (check_col(pinfo->fd, COL_PROTOCOL))
-        col_set_str(pinfo->fd, COL_PROTOCOL, "CDP");
-    if (check_col(pinfo->fd, COL_INFO))
-        col_set_str(pinfo->fd, COL_INFO, "Cisco Discovery Protocol"); 
+    if (check_col(pinfo->cinfo, COL_PROTOCOL))
+        col_set_str(pinfo->cinfo, COL_PROTOCOL, "CDP");
+    if (check_col(pinfo->cinfo, COL_INFO))
+        col_set_str(pinfo->cinfo, COL_INFO, "Cisco Discovery Protocol"); 
 
     if (tree){
         ti = proto_tree_add_item(tree, proto_cdp, tvb, offset,
@@ -355,7 +357,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                offset += length;
            }
        }
-       dissect_data(tvb, offset, pinfo, cdp_tree);
+       call_dissector(data_handle,tvb_new_subset(tvb, offset,-1,tvb_reported_length_remaining(tvb,offset)), pinfo, cdp_tree);
     }
 }
 
@@ -578,6 +580,10 @@ proto_register_cdp(void)
 void
 proto_reg_handoff_cdp(void)
 {
-    dissector_add("llc.cisco_pid", 0x2000, dissect_cdp, proto_cdp);
-    dissector_add("chdlctype", 0x2000, dissect_cdp, proto_cdp);
+    dissector_handle_t cdp_handle;
+
+    data_handle = find_dissector("data");
+    cdp_handle = create_dissector_handle(dissect_cdp, proto_cdp);
+    dissector_add("llc.cisco_pid", 0x2000, cdp_handle);
+    dissector_add("chdlctype", 0x2000, cdp_handle);
 }