Use "proto_tree_add_item()" whenever possible; this fixes some bugs
[obnox/wireshark/wip.git] / packet-fddi.c
index ee1adea5406e3c9b1760bd92f84eb308f4b7cb23..1c5a970972f43c9455fbc980332e63b360debe99 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Laurent Deniel <deniel@worldnet.fr>
  *
- * $Id: packet-fddi.c,v 1.51 2001/07/03 04:56:45 guy Exp $
+ * $Id: packet-fddi.c,v 1.55 2001/12/10 00:25:27 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -126,6 +126,7 @@ static const value_string mac_subtype_vals[] = {
 #define FDDI_P_SHOST           7
 
 static dissector_handle_t llc_handle;
+static dissector_handle_t data_handle;
 
 static void
 swap_mac_addr(u_char *swapped_addr, const u_char *orig_addr)
@@ -139,11 +140,11 @@ swap_mac_addr(u_char *swapped_addr, const u_char *orig_addr)
 
 
 void
-capture_fddi(const u_char *pd, packet_counts *ld)
+capture_fddi(const u_char *pd, int len, packet_counts *ld)
 {
   int        offset = 0, fc;
 
-  if (!BYTES_ARE_IN_FRAME(0, FDDI_HEADER_SIZE)) {
+  if (!BYTES_ARE_IN_FRAME(0, len, FDDI_HEADER_SIZE)) {
     ld->other++;
     return;
   }
@@ -171,7 +172,7 @@ capture_fddi(const u_char *pd, packet_counts *ld)
     case FDDI_FC_LLC_ASYNC + 13 :
     case FDDI_FC_LLC_ASYNC + 14 :
     case FDDI_FC_LLC_ASYNC + 15 :
-      capture_llc(pd, offset, ld);
+      capture_llc(pd, offset, len, ld);
       return;
     default :
       ld->other++;
@@ -266,14 +267,14 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
   u_char     src_swapped[6], dst_swapped[6];
   tvbuff_t   *next_tvb;
 
-  if (check_col(pinfo->fd, COL_PROTOCOL))
-    col_set_str(pinfo->fd, COL_PROTOCOL, "FDDI");
+  if (check_col(pinfo->cinfo, COL_PROTOCOL))
+    col_set_str(pinfo->cinfo, COL_PROTOCOL, "FDDI");
 
   fc = (int) tvb_get_guint8(tvb, FDDI_P_FC);
   fc_str = fddifc_to_str(fc);
 
-  if (check_col(pinfo->fd, COL_INFO))
-    col_add_str(pinfo->fd, COL_INFO, fc_str);
+  if (check_col(pinfo->cinfo, COL_INFO))
+    col_add_str(pinfo->cinfo, COL_INFO, fc_str);
 
   if (tree) {
     ti = proto_tree_add_protocol_format(tree, proto_fddi, tvb, 0, FDDI_HEADER_SIZE,
@@ -369,7 +370,7 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
       return;
       
     default :
-      dissect_data(next_tvb, 0, pinfo, tree);
+      call_dissector(data_handle,next_tvb, pinfo, tree);
       return;
 
   } /* fc */
@@ -451,13 +452,18 @@ proto_register_fddi(void)
 void
 proto_reg_handoff_fddi(void)
 {
+       dissector_handle_t fddi_handle, fddi_bitswapped_handle;
+
        /*
         * Get a handle for the LLC dissector.
         */
        llc_handle = find_dissector("llc");
+       data_handle = find_dissector("data");
 
-       dissector_add("wtap_encap", WTAP_ENCAP_FDDI,
-           dissect_fddi_not_bitswapped, proto_fddi);
+       fddi_handle = find_dissector("fddi");
+       dissector_add("wtap_encap", WTAP_ENCAP_FDDI, fddi_handle);
+       fddi_bitswapped_handle =
+           create_dissector_handle(dissect_fddi_bitswapped, proto_fddi);
        dissector_add("wtap_encap", WTAP_ENCAP_FDDI_BITSWAPPED,
-           dissect_fddi_bitswapped, proto_fddi);
+           fddi_bitswapped_handle);
 }