*
* (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;
"" }},
};
+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",
*ttl = start[3];
}
-void
+static void
dissect_mpls(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
guint32 label;
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)) {
/* 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;
}
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
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");
+}