aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-moldudp.c
diff options
context:
space:
mode:
authorJustin Helgesen <justinhelgesen@gmail.com>2017-01-29 15:06:49 -0600
committerMichael Mann <mmann78@netscape.net>2017-01-31 21:12:32 +0000
commit6ab483ffe33d1fc13e1da0ebd2880736d4afda4c (patch)
treebda0c2cc209705dbef59caf81afc8551606fe7b6 /epan/dissectors/packet-moldudp.c
parent4a1150acdd9fca7eded7ddf06443c3f18f03c6f8 (diff)
Add Decode As capabilities to MoldUDP dissector
Per the Nasdaq TotalView-ITCH v2/3 protocol specifications the NASDAQ-ITCH dissector needs be able to dissect a MoldUDP payload. Change-Id: Id5194930025a9abdfb1663234233fd51e525a34b Reviewed-on: https://code.wireshark.org/review/19847 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-moldudp.c')
-rw-r--r--epan/dissectors/packet-moldudp.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/epan/dissectors/packet-moldudp.c b/epan/dissectors/packet-moldudp.c
index 7d697ed8f1..9bcb6c4f79 100644
--- a/epan/dissectors/packet-moldudp.c
+++ b/epan/dissectors/packet-moldudp.c
@@ -27,6 +27,7 @@
#include <epan/packet.h>
#include <epan/expert.h>
+#include <epan/decode_as.h>
void proto_register_moldudp(void);
void proto_reg_handoff_moldudp(void);
@@ -55,6 +56,18 @@ static gint ett_moldudp_msgblk = -1;
static expert_field ei_moldudp_msglen_invalid = EI_INIT;
static expert_field ei_moldudp_count_invalid = EI_INIT;
+static dissector_table_t moldudp_payload_table;
+
+static void moldudp_prompt(packet_info *pinfo _U_, gchar* result)
+{
+ g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Payload as");
+}
+
+static gpointer moldudp_value(packet_info *pinfo _U_)
+{
+ return 0;
+}
+
/* Code to dissect a message block */
static guint
dissect_moldudp_msgblk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
@@ -64,6 +77,7 @@ dissect_moldudp_msgblk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree *blk_tree;
guint16 msglen, real_msglen, whole_len;
guint remaining;
+ tvbuff_t* next_tvb;
if (tvb_reported_length(tvb) - offset < MOLDUDP_MSGLEN_LEN)
return 0;
@@ -105,8 +119,15 @@ dissect_moldudp_msgblk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
offset += MOLDUDP_MSGLEN_LEN;
- proto_tree_add_item(blk_tree, hf_moldudp_msgdata,
- tvb, offset, real_msglen, ENC_NA);
+
+ /* Functionality for choosing subdissector is controlled through Decode As as MoldUDP doesn't
+ have a unique identifier to determine subdissector */
+ next_tvb = tvb_new_subset_length(tvb, offset, real_msglen);
+ if (!dissector_try_uint_new(moldudp_payload_table, 0, next_tvb, pinfo, tree, FALSE, NULL))
+ {
+ proto_tree_add_item(blk_tree, hf_moldudp_msgdata,
+ tvb, offset, real_msglen, ENC_NA);
+ }
return whole_len;
}
@@ -228,14 +249,24 @@ proto_register_moldudp(void)
expert_module_t* expert_moldudp;
+ /* Decode As handling */
+ static build_valid_func moldudp_da_build_value[1] = {moldudp_value};
+ static decode_as_value_t moldudp_da_values = {moldudp_prompt, 1, moldudp_da_build_value};
+ static decode_as_t moldudp_da = {"moldudp", "MoldUDP Payload", "moldudp.payload", 1, 0, &moldudp_da_values, NULL, NULL,
+ decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
+
/* Register the protocol name and description */
proto_moldudp = proto_register_protocol("MoldUDP", "MoldUDP", "moldudp");
+ moldudp_payload_table = register_dissector_table("moldudp.payload", "MoldUDP Payload", proto_moldudp, FT_UINT32, BASE_DEC);
+
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_moldudp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_moldudp = expert_register_protocol(proto_moldudp);
expert_register_field_array(expert_moldudp, ei, array_length(ei));
+
+ register_decode_as(&moldudp_da);
}