Update a URL.
[obnox/wireshark/wip.git] / packet-isl.c
index 468174dc450411f97b4b9e3138b42bd3c454b9fc..72d6b97bc250700f4698f887dcba99e0d6eccd8e 100644 (file)
@@ -1,23 +1,22 @@
 /* packet-isl.c
  * Routines for Cisco ISL Ethernet header disassembly
  *
- * $Id: packet-isl.c,v 1.18 2000/12/28 09:49:09 guy Exp $
+ * $Id: packet-isl.c,v 1.33 2003/08/08 17:57:44 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * 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.
 # include "config.h"
 #endif
 
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-
 #include <glib.h>
-#include "packet.h"
+#include <epan/packet.h>
 #include "packet-isl.h"
 #include "packet-eth.h"
 #include "packet-tr.h"
@@ -45,7 +36,7 @@
 /*
  * See
  *
- *     http://www.cisco.com/warp/public/741/4.html
+ *     http://www.cisco.com/warp/public/473/741_4.html
  *
  * and
  *
@@ -82,12 +73,16 @@ static gint ett_isl = -1;
 #define        TYPE_FDDI       0x2
 #define        TYPE_ATM        0x3
 
+static dissector_handle_t eth_handle;
+static dissector_handle_t tr_handle;
+static dissector_handle_t data_handle;
+
 void
-capture_isl(const u_char *pd, int offset, packet_counts *ld)
+capture_isl(const guchar *pd, int offset, int len, packet_counts *ld)
 {
   guint8 type;
 
-  if (!BYTES_ARE_IN_FRAME(offset, ISL_HEADER_SIZE)) {
+  if (!BYTES_ARE_IN_FRAME(offset, len, ISL_HEADER_SIZE)) {
     ld->other++;
     return;
   }
@@ -98,12 +93,12 @@ capture_isl(const u_char *pd, int offset, packet_counts *ld)
 
   case TYPE_ETHER:
     offset += 14+12;   /* skip the header */
-    capture_eth(pd, offset, ld);
+    capture_eth(pd, offset, len, ld);
     break;
 
   case TYPE_TR:
     offset += 14+17;   /* skip the header */
-    capture_tr(pd, offset, ld);
+    capture_tr(pd, offset, len, ld);
     break;
 
   default:
@@ -149,14 +144,10 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   gint captured_length;
   tvbuff_t *next_tvb;
 
-  CHECK_DISPLAY_AS_DATA(proto_isl, tvb, pinfo, tree);
-
-  pinfo->current_proto = "ISL";
-  
-  if (check_col(pinfo->fd, COL_PROTOCOL))
-    col_set_str(pinfo->fd, COL_PROTOCOL, "ISL");
-  if (check_col(pinfo->fd, COL_INFO))
-    col_clear(pinfo->fd, COL_INFO);
+  if (check_col(pinfo->cinfo, COL_PROTOCOL))
+    col_set_str(pinfo->cinfo, COL_PROTOCOL, "ISL");
+  if (check_col(pinfo->cinfo, COL_INFO))
+    col_clear(pinfo->cinfo, COL_INFO);
 
   type = (tvb_get_guint8(tvb, 5) >> 4)&0x0F;
 
@@ -195,8 +186,8 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        field (which is, admittedly, an OUI). */
     proto_tree_add_item(fh_tree, hf_isl_hsa, tvb, 17, 3, FALSE);
   }
-  if (check_col(pinfo->fd, COL_INFO))
-    col_add_fstr(pinfo->fd, COL_INFO, "VLAN ID: 0x%04X",
+  if (check_col(pinfo->cinfo, COL_INFO))
+    col_add_fstr(pinfo->cinfo, COL_INFO, "VLAN ID: 0x%04X",
                 tvb_get_ntohs(tvb, 20) >> 1);
   if (tree) {
     proto_tree_add_item(fh_tree, hf_isl_vlan_id, tvb, 20, 2, FALSE);
@@ -233,13 +224,15 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
       captured_length = tvb_length_remaining(tvb, ISL_HEADER_SIZE);
       if (captured_length > 4) {
         /* Subtract the encapsulated frame CRC. */
-       captured_length -= 4;
+        captured_length -= 4;
 
         /* Make sure it's not bigger than the actual length. */
-       if (captured_length > length)
-         captured_length = length;
+        if (captured_length > length)
+          captured_length = length;
+
         next_tvb = tvb_new_subset(tvb, ISL_HEADER_SIZE, captured_length, length);
-        dissect_eth(next_tvb, pinfo, tree);
+
+        call_dissector(eth_handle, next_tvb, pinfo, tree);
       }
     }
     break;
@@ -254,84 +247,95 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
       proto_tree_add_item(fh_tree, hf_isl_esize, tvb, 30, 1, FALSE);
     }
     next_tvb = tvb_new_subset(tvb, 31, -1, -1);
-    dissect_tr(next_tvb, pinfo, tree);
+    call_dissector(tr_handle, next_tvb, pinfo, tree);
     break;
 
   default:
     next_tvb = tvb_new_subset(tvb, ISL_HEADER_SIZE, -1, -1);
-    dissect_data(next_tvb, 0, pinfo, tree);
+    call_dissector(data_handle,next_tvb, pinfo, tree);
     break;
   }
 }
-    
+
 void
 proto_register_isl(void)
 {
   static hf_register_info hf[] = {
        { &hf_isl_dst,
        { "Destination",        "isl.dst", FT_ETHER, BASE_NONE, NULL, 0x0,
-               "Destination Address" }},
+               "Destination Address", HFILL }},
        { &hf_isl_type,
-       { "Type",               "isl.type", FT_UINT8, BASE_NONE,
-               VALS(type_vals), 0xF0, "Type" }},
+       { "Type",               "isl.type", FT_UINT8, BASE_DEC,
+               VALS(type_vals), 0xF0, "Type", HFILL }},
        { &hf_isl_user_eth,
-       { "User",               "isl.user_eth", FT_UINT8, BASE_NONE,
-               VALS(ether_user_vals), 0x0F, "Priority (for Ethernet)" }},
+       { "User",               "isl.user_eth", FT_UINT8, BASE_DEC,
+               VALS(ether_user_vals), 0x0F, "Priority (for Ethernet)", HFILL }},
        { &hf_isl_user,
        { "User",               "isl.user", FT_UINT8, BASE_HEX, NULL, 0x0F,
-               "User-defined bits" }},
+               "User-defined bits", HFILL }},
        { &hf_isl_src,
        { "Source",             "isl.src", FT_ETHER, BASE_NONE, NULL, 0x0,
-               "Source Hardware Address" }},
+               "Source Hardware Address", HFILL }},
        { &hf_isl_addr,
        { "Source or Destination Address", "isl.addr", FT_ETHER, BASE_NONE, NULL, 0x0,
-               "Source or Destination Hardware Address" }},
+               "Source or Destination Hardware Address", HFILL }},
        { &hf_isl_len,
        { "Length",             "isl.len", FT_UINT16, BASE_DEC, NULL, 0x0,
-               "" }},
+               "", HFILL }},
        { &hf_isl_hsa,
        { "HSA",                "isl.hsa", FT_UINT24, BASE_HEX, NULL, 0x0,
-               "High bits of source address" }},
+               "High bits of source address", HFILL }},
        { &hf_isl_vlan_id,
        { "VLAN ID",            "isl.vlan_id", FT_UINT16, BASE_HEX, NULL,
-               0xFFFE, "Virtual LAN ID" }},
+               0xFFFE, "Virtual LAN ID", HFILL }},
        { &hf_isl_bpdu,
        { "BPDU",               "isl.bpdu", FT_BOOLEAN, 16,
-               TFS(&bpdu_tfs), 0x0001, "BPDU indicator" }},
+               TFS(&bpdu_tfs), 0x0001, "BPDU indicator", HFILL }},
        { &hf_isl_index,
        { "Index",              "isl.index", FT_UINT16, BASE_DEC, NULL, 0x0,
-               "Port index of packet source" }},
+               "Port index of packet source", HFILL }},
        { &hf_isl_crc,
        { "CRC",                "isl.crc", FT_UINT32, BASE_HEX, NULL, 0x0,
-               "CRC field of encapsulated frame" }},
+               "CRC field of encapsulated frame", HFILL }},
        { &hf_isl_src_vlan_id,
        { "Source VLAN ID",     "isl.src_vlan_id", FT_UINT16, BASE_HEX, NULL,
-               0xFFFE, "Source Virtual LAN ID" }},
+               0xFFFE, "Source Virtual LAN ID", HFILL }},
        { &hf_isl_explorer,
        { "Explorer",           "isl.explorer", FT_BOOLEAN, 16,
-               TFS(&explorer_tfs), 0x0001, "Explorer" }},
+               TFS(&explorer_tfs), 0x0001, "Explorer", HFILL }},
        { &hf_isl_dst_route_descriptor,
        { "Destination route descriptor",       "isl.dst_route_desc",
                FT_UINT16, BASE_HEX, NULL, 0x0,
-               "Route descriptor to be used for forwarding" }},
+               "Route descriptor to be used for forwarding", HFILL }},
        { &hf_isl_src_route_descriptor,
        { "Source-route descriptor",    "isl.src_route_desc",
                FT_UINT16, BASE_HEX, NULL, 0x0,
-               "Route descriptor to be used for source learning" }},
+               "Route descriptor to be used for source learning", HFILL }},
        { &hf_isl_fcs_not_incl,
        { "FCS Not Included",   "isl.fcs_not_incl", FT_BOOLEAN, 9,
-               NULL, 0x40, "FCS not included" }},
+               NULL, 0x40, "FCS not included", HFILL }},
        { &hf_isl_esize,
        { "Esize",      "isl.esize", FT_UINT8, BASE_DEC, NULL,
-               0x3F, "Frame size for frames less than 64 bytes" }},
+               0x3F, "Frame size for frames less than 64 bytes", HFILL }},
   };
   static gint *ett[] = {
        &ett_isl,
   };
 
-  proto_isl = proto_register_protocol("Cisco ISL", "isl");
+  proto_isl = proto_register_protocol("Cisco ISL", "ISL", "isl");
   proto_register_field_array(proto_isl, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
 
-  register_dissector("isl", dissect_isl);
+  register_dissector("isl", dissect_isl, proto_isl);
+}
+
+void
+proto_reg_handoff_isl(void)
+{
+  /*
+   * Get handles for the Ethernet and Token Ring dissectors.
+   */
+  eth_handle = find_dissector("eth");
+  tr_handle = find_dissector("tr");
+  data_handle = find_dissector("data");
 }