aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ip.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-ip.c
parent91b972ae5ef1dbd437778d942901c6d820f399e2 (diff)
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-ip.c')
-rw-r--r--epan/dissectors/packet-ip.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c
index abe4156611..a2a69664d4 100644
--- a/epan/dissectors/packet-ip.c
+++ b/epan/dissectors/packet-ip.c
@@ -50,6 +50,7 @@
#include <epan/ax25_pids.h>
#include <epan/tap.h>
#include <epan/wmem/wmem.h>
+#include <epan/decode_as.h>
#include "packet-ip.h"
#include "packet-ipsec.h"
@@ -462,6 +463,17 @@ static dissector_handle_t data_handle;
#define is_a_multicast_addr(addr) \
((addr & 0xf0000000) == 0xe0000000)
+static void ip_prompt(packet_info *pinfo, gchar* result)
+{
+ g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "IP protocol %u as", pinfo->ipproto);
+}
+
+static gpointer ip_value(packet_info *pinfo)
+{
+ return GUINT_TO_POINTER(pinfo->ipproto);
+}
+
+
/*
* defragmentation of IPv4
*/
@@ -2972,6 +2984,12 @@ proto_register_ip(void)
{ &ei_ip_ttl_too_small, { "ip.ttl.too_small", PI_SEQUENCE, PI_NOTE, "Time To Live", EXPFILL }},
};
+ /* Decode As handling */
+ static build_valid_func ip_da_build_value[1] = {ip_value};
+ static decode_as_value_t ip_da_values = {ip_prompt, 1, ip_da_build_value};
+ static decode_as_t ip_da = {"ip", "Network", "ip.proto", 1, 0, &ip_da_values, NULL, NULL,
+ decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
+
module_t *ip_module;
expert_module_t* expert_ip;
@@ -3024,6 +3042,8 @@ proto_register_ip(void)
register_dissector("ip", dissect_ip, proto_ip);
register_init_routine(ip_defragment_init);
ip_tap = register_tap("ip");
+
+ register_decode_as(&ip_da);
}
void