summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-mpls.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2013-11-20 19:17:08 +0000
committerMichael Mann <mmann78@netscape.net>2013-11-20 19:17:08 +0000
commit76ab93ea94787605d4c829620b51ff4dee105cb1 (patch)
tree88b6c8e46ab562da0ad5a57c2869046845dabda5 /epan/dissectors/packet-mpls.c
parent91b972ae5ef1dbd437778d942901c6d820f399e2 (diff)
downloadwireshark-76ab93ea94787605d4c829620b51ff4dee105cb1.tar.gz
Provide "Decode As" functionality through dissectors themselves instead of the GUI. Bug 9450 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9450)
The basic idea behind this design is to have dissectors register with a "decode as list" with their name and dissector table. When "Decode As" dialog is launched, any "registered" dissector found in the packet will cause a tab to be created in the dialog. This patch includes just the dissector portion of the functionality (minus packet-dcerpc.[ch] because it has hooks to the current GUI) svn path=/trunk/; revision=53445
Diffstat (limited to 'epan/dissectors/packet-mpls.c')
-rw-r--r--epan/dissectors/packet-mpls.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/epan/dissectors/packet-mpls.c b/epan/dissectors/packet-mpls.c
index 0542add032..b4f9c05d6a 100644
--- a/epan/dissectors/packet-mpls.c
+++ b/epan/dissectors/packet-mpls.c
@@ -59,6 +59,7 @@
#include <epan/prefs.h>
#include <epan/ipproto.h>
#include <epan/addr_resolv.h>
+#include <epan/decode_as.h>
#include "packet-ppp.h"
#include "packet-mpls.h"
@@ -316,6 +317,16 @@ static value_string_ext mpls_pwac_types_ext = VALUE_STRING_EXT_INIT(mpls_pwac_ty
static dissector_table_t mpls_subdissector_table;
+static void mpls_prompt(packet_info *pinfo, gchar* result)
+{
+ g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Data after label %u as", pinfo->mpls_label);
+}
+
+static gpointer mpls_value(packet_info *pinfo)
+{
+ return GUINT_TO_POINTER(pinfo->mpls_label);
+}
+
/*
* Given a 4-byte MPLS label starting at offset "offset", in tvbuff "tvb",
* decode it.
@@ -759,6 +770,13 @@ proto_register_mpls(void)
&ett_mpls_pw_ach,
&ett_mpls_pw_mcw,
};
+
+ /* Decode As handling */
+ static build_valid_func mpls_da_build_value[1] = {mpls_value};
+ static decode_as_value_t mpls_da_values = {mpls_prompt, 1, mpls_da_build_value};
+ static decode_as_t mpls_da = {"mpls", "MPLS", "mpls.label", 1, 0, &mpls_da_values, NULL, NULL,
+ decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
+
module_t * module_mpls;
/* FF: mpls subdissector table is indexed by label */
@@ -793,7 +811,9 @@ proto_register_mpls(void)
"Assume bottom of stack label as Flow label",
"Lowest label is used to segregate flows inside a pseudowire",
&mpls_bos_flowlabel);
- }
+
+ register_decode_as(&mpls_da);
+}
void
proto_reg_handoff_mpls(void)