Add Decode As capabilities to MoldUDP64 dissector.
This is used by the NASDAQ-ITCH dissector to dissect a MoldUDP64 payload. From: https://ask.wireshark.org/questions/46882/help-decoding-moldudp64-payload-as-nasdaq-itch Change-Id: I78c706e12685604e2fc2176b5c4a89de73bd7e56 Reviewed-on: https://code.wireshark.org/review/11235 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
75c7a3d5c4
commit
25de4422c6
|
@ -28,6 +28,7 @@
|
|||
#include <epan/packet.h>
|
||||
#include <epan/prefs.h>
|
||||
#include <epan/expert.h>
|
||||
#include <epan/decode_as.h>
|
||||
|
||||
void proto_register_moldudp64(void);
|
||||
void proto_reg_handoff_moldudp64(void);
|
||||
|
@ -62,6 +63,18 @@ static expert_field ei_moldudp64_end_of_session_extra = EI_INIT;
|
|||
static expert_field ei_moldudp64_count_invalid = EI_INIT;
|
||||
static expert_field ei_moldudp64_request = EI_INIT;
|
||||
|
||||
static dissector_table_t moldudp64_payload_table;
|
||||
|
||||
static void moldudp64_prompt(packet_info *pinfo _U_, gchar* result)
|
||||
{
|
||||
g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Payload as");
|
||||
}
|
||||
|
||||
static gpointer moldudp64_value(packet_info *pinfo _U_)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Code to dissect a message block */
|
||||
static guint
|
||||
dissect_moldudp64_msgblk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
||||
|
@ -71,6 +84,7 @@ dissect_moldudp64_msgblk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
proto_tree *blk_tree;
|
||||
guint16 msglen, real_msglen, whole_len;
|
||||
gint remaining;
|
||||
tvbuff_t* next_tvb;
|
||||
|
||||
if (tvb_captured_length_remaining(tvb, offset) < MOLDUDP64_MSGLEN_LEN)
|
||||
return 0;
|
||||
|
@ -109,8 +123,13 @@ dissect_moldudp64_msgblk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
|
||||
offset += MOLDUDP64_MSGLEN_LEN;
|
||||
|
||||
proto_tree_add_item(blk_tree, hf_moldudp64_msgdata,
|
||||
tvb, offset, real_msglen, ENC_NA);
|
||||
/* Functionality for choosing subdissector is controlled through Decode As as CAN doesn't
|
||||
have a unique identifier to determine subdissector */
|
||||
next_tvb = tvb_new_subset_length(tvb, offset, real_msglen);
|
||||
if (!dissector_try_uint_new(moldudp64_payload_table, 0, next_tvb, pinfo, tree, FALSE, NULL))
|
||||
{
|
||||
proto_tree_add_item(blk_tree, hf_moldudp64_msgdata, tvb, offset, real_msglen, ENC_NA);
|
||||
}
|
||||
|
||||
return whole_len;
|
||||
}
|
||||
|
@ -250,10 +269,18 @@ proto_register_moldudp64(void)
|
|||
|
||||
expert_module_t* expert_moldudp64;
|
||||
|
||||
/* Decode As handling */
|
||||
static build_valid_func moldudp64_da_build_value[1] = {moldudp64_value};
|
||||
static decode_as_value_t moldudp64_da_values = {moldudp64_prompt, 1, moldudp64_da_build_value};
|
||||
static decode_as_t moldudp64_da = {"moldudp64", "MoldUDP64 Payload", "moldudp64.payload", 1, 0, &moldudp64_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_moldudp64 = proto_register_protocol("MoldUDP64",
|
||||
"MoldUDP64", "moldudp64");
|
||||
|
||||
moldudp64_payload_table = register_dissector_table("moldudp64.payload", "MoldUDP64 Payload", FT_UINT32, BASE_DEC);
|
||||
|
||||
/* Required function calls to register the header fields and subtrees used */
|
||||
proto_register_field_array(proto_moldudp64, hf, array_length(hf));
|
||||
proto_register_subtree_array(ett, array_length(ett));
|
||||
|
@ -268,6 +295,8 @@ proto_register_moldudp64(void)
|
|||
prefs_register_uint_preference(moldudp64_module, "udp.port", "MoldUDP64 UDP Port",
|
||||
"MoldUDP64 UDP port to dissect on.",
|
||||
10, &pf_moldudp64_port);
|
||||
|
||||
register_decode_as(&moldudp64_da);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
#include <epan/prefs.h>
|
||||
#include <wsutil/type_util.h>
|
||||
|
||||
void proto_register_nasdaq_itch(void);
|
||||
void proto_reg_handoff_nasdaq_itch(void);
|
||||
|
||||
/* Chi-X version */
|
||||
static gboolean nasdaq_itch_chi_x = TRUE;
|
||||
|
||||
|
@ -432,9 +435,6 @@ dissect_nasdaq_itch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
}
|
||||
|
||||
/* Register the protocol with Wireshark */
|
||||
|
||||
void proto_register_nasdaq_itch(void);
|
||||
|
||||
void
|
||||
proto_register_nasdaq_itch(void)
|
||||
{
|
||||
|
@ -589,6 +589,15 @@ proto_register_nasdaq_itch(void)
|
|||
register_dissector("nasdaq-itch", dissect_nasdaq_itch, proto_nasdaq_itch);
|
||||
}
|
||||
|
||||
void
|
||||
proto_reg_handoff_nasdaq_itch(void)
|
||||
{
|
||||
dissector_handle_t nasdaq_itch_handle;
|
||||
|
||||
nasdaq_itch_handle = create_dissector_handle( dissect_nasdaq_itch, proto_nasdaq_itch );
|
||||
dissector_add_for_decode_as("moldudp64.payload", nasdaq_itch_handle );
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue