Patches to prevent problems under Windows when time formats are negative.
[obnox/wireshark/wip.git] / packet-mpls.c
index 028d4b7ac8a8d300571d11f02bdb8074a61ee6e1..1ff12427145ba65b02cd7b3d9c1aabb6484d6a5f 100644 (file)
@@ -3,7 +3,7 @@
  * 
  * (c) Copyright Ashok Narayanan <ashokn@cisco.com>
  *
- * $Id: packet-mpls.c,v 1.3 2000/03/20 22:52:44 gram Exp $
+ * $Id: packet-mpls.c,v 1.12 2000/12/14 08:20:29 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
 #endif
 
 #include <glib.h>
+#include "etypes.h"
 #include "packet.h"
-#include "packet-mpls.h"
 #include "packet-ip.h"
+#include "ppptypes.h"
+#include "packet-ppp.h"
 
 static gint proto_mpls = -1;
 
@@ -108,6 +110,8 @@ static hf_register_info mplsf_info[] = {
       "" }},
 };
 
+static dissector_handle_t ip_handle;
+
 /*
  * Given a 4-byte MPLS label starting at "start", decode this.
  * Return the label in "label", EXP bits in "exp",
@@ -123,7 +127,7 @@ void decode_mpls_label(const unsigned char *start,
     *ttl = start[3];
 }
 
-void
+static void
 dissect_mpls(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) 
 {
     guint32 label;
@@ -134,8 +138,10 @@ dissect_mpls(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
     proto_tree  *mpls_tree;
     proto_item  *ti;
 
+    OLD_CHECK_DISPLAY_AS_DATA(proto_mpls, pd, offset, fd, tree);
+
     if (check_col(fd, COL_PROTOCOL)) {
-       col_add_str(fd,COL_PROTOCOL, "MPLS");
+       col_set_str(fd,COL_PROTOCOL, "MPLS");
     }
     
     if (check_col(fd,COL_INFO)) {
@@ -145,7 +151,7 @@ dissect_mpls(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
     /* Start Decoding Here. */
     while (1) {
        if (!BYTES_ARE_IN_FRAME(offset, 4)) {
-           dissect_data(pd, offset, fd, tree);
+           old_dissect_data(pd, offset, fd, tree);
            return;
        }
 
@@ -153,29 +159,29 @@ dissect_mpls(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
 
        if (tree) {
 
-           ti = proto_tree_add_item(tree, proto_mpls, offset, 4, NULL);
+           ti = proto_tree_add_item(tree, proto_mpls, NullTVB, offset, 4, FALSE);
            mpls_tree = proto_item_add_subtree(ti, ett_mpls);
 
            if (label <= MAX_RESERVED)
-               proto_tree_add_uint_format(mpls_tree, mpls_filter[MPLSF_LABEL],
+               proto_tree_add_uint_format(mpls_tree, mpls_filter[MPLSF_LABEL], NullTVB,
                                    offset, 3, label, "Label: %d (%s)", 
                                    label, val_to_str(label, special_labels, 
                                                      "Reserved - Unknown"));
            else
-               proto_tree_add_item(mpls_tree, mpls_filter[MPLSF_LABEL],
+               proto_tree_add_uint(mpls_tree, mpls_filter[MPLSF_LABEL], NullTVB,
                                    offset, 3, label);
 
-           proto_tree_add_item(mpls_tree,mpls_filter[MPLSF_EXP]
+           proto_tree_add_uint(mpls_tree,mpls_filter[MPLSF_EXP], NullTVB
                                offset+2,1, exp);
-           proto_tree_add_item(mpls_tree,mpls_filter[MPLSF_BOTTOM_OF_STACK]
+           proto_tree_add_uint(mpls_tree,mpls_filter[MPLSF_BOTTOM_OF_STACK], NullTVB
                                offset+2,1, bos);
-           proto_tree_add_item(mpls_tree,mpls_filter[MPLSF_TTL]
+           proto_tree_add_uint(mpls_tree,mpls_filter[MPLSF_TTL], NullTVB
                                offset+3,1, ttl);
        }
        offset += 4;
        if (bos) break;
     }
-    dissect_ip(pd, offset, fd, tree);
+    old_call_dissector(ip_handle, pd, offset, fd, tree);
 }
 
 void
@@ -190,3 +196,14 @@ proto_register_mpls(void)
        proto_register_subtree_array(ett, array_length(ett));
 }
 
+void
+proto_reg_handoff_mpls(void)
+{
+       old_dissector_add("ethertype", ETHERTYPE_MPLS, dissect_mpls);
+       old_dissector_add("ppp.protocol", PPP_MPLS_UNI, dissect_mpls);
+
+       /*
+        * Get a handle for the IP dissector.
+        */
+       ip_handle = find_dissector("ip");
+}