From 9b3c8d4515c9a1a307c141c25fa59694391efe3a Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Sat, 8 Jul 2017 21:48:36 -0400 Subject: [PATCH] Expand register_decode_as_next_proto to include prompt string. Many dissectors don't have an identifier to pass to a dissector table. When using Decode As they all have a "value" function that returns 0 just so something is returned. A first step to a cleaner refactor of the functionality is to allow dissectors to provide a "prompt" function when registering Decode As with register_decode_as_next_proto() so that the text exposed in the GUI can vary, but the function that returns 0 (nothing) can be consolidated under decode as registration functionality. This casts a wider net for register_decode_as_next_proto() use. Change-Id: I2995b3c251dae70f5f529b672473d25c6288ed5c Reviewed-on: https://code.wireshark.org/review/22562 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/decode_as.c | 14 ++++++++++++-- epan/decode_as.h | 16 +++++++++++----- epan/dissectors/packet-aruba-erm.c | 22 +--------------------- epan/dissectors/packet-bthci_cmd.c | 13 +------------ epan/dissectors/packet-bthci_evt.c | 14 +------------- epan/dissectors/packet-enip.c | 14 +------------- epan/dissectors/packet-flexray.c | 20 +++----------------- epan/dissectors/packet-flip.c | 13 +------------ epan/dissectors/packet-i2c.c | 13 +------------ epan/dissectors/packet-infiniband.c | 13 +------------ epan/dissectors/packet-iso15765.c | 23 ++--------------------- epan/dissectors/packet-moldudp.c | 13 +------------ epan/dissectors/packet-moldudp64.c | 13 +------------ epan/dissectors/packet-nfs.c | 13 +------------ epan/dissectors/packet-pcli.c | 20 +------------------- epan/dissectors/packet-rtacser.c | 13 +------------ epan/dissectors/packet-socketcan.c | 18 +----------------- epan/dissectors/packet-usb-ccid.c | 3 +-- 18 files changed, 42 insertions(+), 226 deletions(-) diff --git a/epan/decode_as.c b/epan/decode_as.c index f7a08577ad..3222f9fb6e 100644 --- a/epan/decode_as.c +++ b/epan/decode_as.c @@ -70,7 +70,7 @@ static decode_as_value_t next_proto_da_values = { next_proto_prompt, 1, next_proto_values }; void register_decode_as_next_proto( - const char *name, const gchar *title, const gchar *table_name) + const char *name, const gchar *title, const gchar *table_name, build_label_func* label_func) { decode_as_t *da; dissector_table_t dt; @@ -83,7 +83,17 @@ void register_decode_as_next_proto( da->title = wmem_strdup(wmem_epan_scope(), title); da->table_name = wmem_strdup(wmem_epan_scope(), table_name); da->num_items = 1; - da->values = &next_proto_da_values; + if (label_func == NULL) + { + da->values = &next_proto_da_values; + } + else + { + da->values = wmem_new(wmem_epan_scope(), decode_as_value_t); + da->values->label_func = *label_func; + da->values->num_values = 1; + da->values->build_values = next_proto_values; + } da->populate_list = decode_as_default_populate_list; da->reset_value = decode_as_default_reset; da->change_value = decode_as_default_change; diff --git a/epan/decode_as.h b/epan/decode_as.h index 63398efdf4..99383e0436 100644 --- a/epan/decode_as.h +++ b/epan/decode_as.h @@ -86,12 +86,18 @@ typedef struct decode_as_s { WS_DLL_PUBLIC void register_decode_as(decode_as_t* reg); /** Register a "Decode As" entry for the special case where there is no - indication for the next protocol (such as port number etc.). - For now, this will use a uint32 dissector table internally and - assign all registered protocols to 0. The framework to do this can - be kept internal to epan. */ + * indication for the next protocol (such as port number etc.). + * For now, this will use a uint32 dissector table internally and + * assign all registered protocols to 0. The framework to do this can + * be kept internal to epan. + * + * @param name The table name in which this dissector is found. + * @param title The table name in which this dissector is found. + * @param table_name The table name in which this dissector is found. + * @param label_func Optional prompt text for dissector. If NULL, "Next level protocol as" is used. +*/ WS_DLL_PUBLIC void register_decode_as_next_proto( - const char *name, const gchar *title, const gchar *table_name); + const char *name, const gchar *title, const gchar *table_name, build_label_func* label_func); /* Walk though the dissector table and provide dissector_handle_t for each item in the table */ WS_DLL_PUBLIC void decode_as_default_populate_list(const gchar *table_name, decode_as_add_to_list_func add_to_list, gpointer ui_element); diff --git a/epan/dissectors/packet-aruba-erm.c b/epan/dissectors/packet-aruba-erm.c index 73b912c97d..d27bd87cc6 100644 --- a/epan/dissectors/packet-aruba-erm.c +++ b/epan/dissectors/packet-aruba-erm.c @@ -353,13 +353,6 @@ aruba_erm_prompt(packet_info *pinfo _U_, gchar* result) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Aruba ERM payload as"); } -static gpointer -aruba_erm_value(packet_info *pinfo _U_) -{ - return NULL; -} - - void proto_register_aruba_erm(void) { @@ -412,18 +405,6 @@ proto_register_aruba_erm(void) module_t *aruba_erm_module; - /* Decode As handling */ - static build_valid_func aruba_erm_payload_da_build_value[1] = {aruba_erm_value}; - static decode_as_value_t aruba_erm_payload_da_values = {aruba_erm_prompt, 1, aruba_erm_payload_da_build_value}; - static decode_as_t aruba_erm_payload_da = { - "aruba_erm", "Aruba ERM Type", "aruba_erm.type", 1, 0, - &aruba_erm_payload_da_values, NULL, NULL, - decode_as_default_populate_list, - decode_as_default_reset, - decode_as_default_change, - NULL, - }; - expert_module_t* expert_aruba_erm; proto_aruba_erm = proto_register_protocol(PROTO_LONG_NAME, "ARUBA_ERM" , "aruba_erm"); @@ -455,8 +436,7 @@ proto_register_aruba_erm(void) "aruba_erm.type", "Aruba ERM Type", proto_aruba_erm, FT_UINT32, BASE_DEC); - register_decode_as(&aruba_erm_payload_da); - + register_decode_as_next_proto("aruba_erm", "Aruba ERM Type", "aruba_erm.type", (build_label_func*)&aruba_erm_prompt); } void diff --git a/epan/dissectors/packet-bthci_cmd.c b/epan/dissectors/packet-bthci_cmd.c index efdd41623b..de6b47c1b2 100644 --- a/epan/dissectors/packet-bthci_cmd.c +++ b/epan/dissectors/packet-bthci_cmd.c @@ -2105,11 +2105,6 @@ static void bthci_cmd_vendor_prompt(packet_info *pinfo _U_, gchar* result) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Vendor as"); } -static gpointer bthci_cmd_vendor_value(packet_info *pinfo _U_) -{ - return NULL; -} - static gint dissect_coding_format(proto_tree *tree, int hf_x, tvbuff_t *tvb, gint offset, gint ett_x) { proto_item *sub_item; @@ -7114,12 +7109,6 @@ proto_register_bthci_cmd(void) &ett_pattern }; - /* Decode As handling */ - static build_valid_func bthci_cmd_vendor_da_build_value[1] = {bthci_cmd_vendor_value}; - static decode_as_value_t bthci_cmd_vendor_da_values = {bthci_cmd_vendor_prompt, 1, bthci_cmd_vendor_da_build_value}; - static decode_as_t bthci_cmd_vendor_da = {"bthci_evt", "Vendor", "bthci_cmd.vendor", 1, 0, &bthci_cmd_vendor_da_values, NULL, NULL, - decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; - proto_bthci_cmd = proto_register_protocol("Bluetooth HCI Command", "HCI_CMD", "bthci_cmd"); bthci_cmd_handle = register_dissector("bthci_cmd", dissect_bthci_cmd, proto_bthci_cmd); @@ -7139,7 +7128,7 @@ proto_register_bthci_cmd(void) "Bluetooth HCI version: 4.0 (Core)", "Version of protocol supported by this dissector."); - register_decode_as(&bthci_cmd_vendor_da); + register_decode_as_next_proto("bthci_evt", "Vendor", "bthci_cmd.vendor", (build_label_func*)&bthci_cmd_vendor_prompt); } diff --git a/epan/dissectors/packet-bthci_evt.c b/epan/dissectors/packet-bthci_evt.c index f86d062a10..db736c2e42 100644 --- a/epan/dissectors/packet-bthci_evt.c +++ b/epan/dissectors/packet-bthci_evt.c @@ -918,11 +918,6 @@ static void bthci_evt_vendor_prompt(packet_info *pinfo _U_, gchar* result) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Vendor as"); } -static gpointer bthci_evt_vendor_value(packet_info *pinfo _U_) -{ - return NULL; -} - static void add_opcode(wmem_list_t *opcode_list, guint16 opcode, enum command_status command_status) { opcode_list_data_t *opcode_list_data; @@ -7975,13 +7970,6 @@ proto_register_bthci_evt(void) &ett_expert }; - /* Decode As handling */ - static build_valid_func bthci_evt_vendor_da_build_value[1] = {bthci_evt_vendor_value}; - static decode_as_value_t bthci_evt_vendor_da_values = {bthci_evt_vendor_prompt, 1, bthci_evt_vendor_da_build_value}; - static decode_as_t bthci_evt_vendor_da = {"bthci_cmd", "Vendor", "bthci_cmd.vendor", 1, 0, &bthci_evt_vendor_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_bthci_evt = proto_register_protocol("Bluetooth HCI Event", "HCI_EVT", "bthci_evt"); @@ -7999,7 +7987,7 @@ proto_register_bthci_evt(void) "Bluetooth HCI version: 4.0 (Core) + Addendum 4", "Version of protocol supported by this dissector."); - register_decode_as(&bthci_evt_vendor_da); + register_decode_as_next_proto("bthci_cmd", "Vendor", "bthci_cmd.vendor", (build_label_func*)&bthci_evt_vendor_prompt); } diff --git a/epan/dissectors/packet-enip.c b/epan/dissectors/packet-enip.c index 677dc6fe1c..4ef8b0b4c1 100644 --- a/epan/dissectors/packet-enip.c +++ b/epan/dissectors/packet-enip.c @@ -724,11 +724,6 @@ static void enip_prompt(packet_info *pinfo _U_, gchar* result) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Dissect unidentified I/O traffic as"); } -static gpointer enip_value(packet_info *pinfo _U_) -{ - return 0; -} - static wmem_map_t *enip_request_hashtable = NULL; /* Return codes of function classifying packets as query/response */ @@ -4330,12 +4325,6 @@ proto_register_enip(void) module_t *enip_module; expert_module_t* expert_enip; - /* Decode As handling */ - static build_valid_func enip_da_build_value[1] = {enip_value}; - static decode_as_value_t enip_da_values = {enip_prompt, 1, enip_da_build_value}; - static decode_as_t enip_da = {"enip", "ENIP I/O", "enip.io", 1, 0, &enip_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_enip = proto_register_protocol("EtherNet/IP (Industrial Protocol)", "ENIP", "enip"); proto_enipio = proto_register_protocol("EtherNet/IP I/O", "ENIP I/O", "enip_io"); @@ -4389,8 +4378,7 @@ proto_register_enip(void) register_conversation_filter("enip", "ENIP IO", enip_io_conv_valid, enip_io_conv_filter); register_conversation_filter("enip", "ENIP Explicit", enip_exp_conv_valid, enip_exp_conv_filter); - register_decode_as(&enip_da); - + register_decode_as_next_proto("enip", "ENIP I/O", "enip.io", (build_label_func*)&enip_prompt); } /* end of proto_register_enip() */ diff --git a/epan/dissectors/packet-flexray.c b/epan/dissectors/packet-flexray.c index 2be2ce2d18..db4a5a7397 100644 --- a/epan/dissectors/packet-flexray.c +++ b/epan/dissectors/packet-flexray.c @@ -115,16 +115,6 @@ static const true_false_string flexray_nfi = { "True" }; -static void flexray_prompt(packet_info *pinfo _U_, gchar* result) -{ - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Next level protocol as"); -} - -static gpointer flexray_value(packet_info *pinfo _U_) -{ - return 0; -} - static int dissect_flexray(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { @@ -438,12 +428,6 @@ proto_register_flexray(void) } }; - /* Decode As handling */ - static build_valid_func flexray_da_build_value[1] = { flexray_value }; - static decode_as_value_t flexray_da_values = { flexray_prompt, 1, flexray_da_build_value }; - static decode_as_t flexray_da = { "flexray", "Network", "flexray.subdissector", 1, 0, &flexray_da_values, NULL, NULL, - decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL }; - proto_flexray = proto_register_protocol( "FlexRay Protocol", "FLEXRAY", @@ -457,10 +441,12 @@ proto_register_flexray(void) expert_register_field_array(expert_flexray, ei, array_length(ei)); register_dissector("flexray", dissect_flexray, proto_flexray); - register_decode_as(&flexray_da); subdissector_table = register_dissector_table("flexray.subdissector", "FLEXRAY next level dissector", proto_flexray, FT_UINT32, BASE_HEX); + + register_decode_as_next_proto("flexray", "Network", "flexray.subdissector", NULL); + } void diff --git a/epan/dissectors/packet-flip.c b/epan/dissectors/packet-flip.c index ca195fdbce..914625b746 100644 --- a/epan/dissectors/packet-flip.c +++ b/epan/dissectors/packet-flip.c @@ -96,11 +96,6 @@ static void flip_prompt(packet_info *pinfo _U_, gchar* result) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Decode FLIP payload protocol as"); } -static gpointer flip_value(packet_info *pinfo _U_) -{ - return 0; -} - /* Dissect the checksum extension header. */ static int dissect_flip_chksum_hdr(tvbuff_t *tvb, @@ -451,12 +446,6 @@ proto_register_flip(void) module_t *flip_module; - /* Decode As handling */ - static build_valid_func flip_da_build_value[1] = {flip_value}; - static decode_as_value_t flip_da_values = {flip_prompt, 1, flip_da_build_value}; - static decode_as_t flip_da = {"flip", "FLIP Payload", "flip.payload", 1, 0, &flip_da_values, NULL, NULL, - decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; - proto_flip = proto_register_protocol( "NSN FLIP", /* name */ "FLIP", /* short name */ @@ -478,7 +467,7 @@ proto_register_flip(void) prefs_register_obsolete_preference(flip_module, "forced_protocol"); prefs_register_obsolete_preference(flip_module, "forced_decode"); - register_decode_as(&flip_da); + register_decode_as_next_proto("flip", "FLIP Payload", "flip.payload", (build_label_func*)&flip_prompt); } /* proto_register_flip() */ diff --git a/epan/dissectors/packet-i2c.c b/epan/dissectors/packet-i2c.c index 5af77db8cc..9e5e952dd5 100644 --- a/epan/dissectors/packet-i2c.c +++ b/epan/dissectors/packet-i2c.c @@ -81,11 +81,6 @@ static void i2c_prompt(packet_info *pinfo _U_, gchar* result) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Interpret I2C messages as"); } -static gpointer i2c_value(packet_info *pinfo _U_) -{ - return 0; -} - static gboolean capture_i2c(const guchar *pd _U_, int offset _U_, int len _U_, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header) { @@ -241,12 +236,6 @@ proto_register_i2c(void) }; module_t *m; - /* Decode As handling */ - static build_valid_func i2c_da_build_value[1] = {i2c_value}; - static decode_as_value_t i2c_da_values = {i2c_prompt, 1, i2c_da_build_value}; - static decode_as_t i2c_da = {"i2c", "I2C Message", "i2c.message", 1, 0, &i2c_da_values, NULL, NULL, - decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; - proto_i2c = proto_register_protocol("Inter-Integrated Circuit", "I2C", "i2c"); proto_register_field_array(proto_i2c, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -260,7 +249,7 @@ proto_register_i2c(void) m = prefs_register_protocol(proto_i2c, NULL); prefs_register_obsolete_preference(m, "type"); - register_decode_as(&i2c_da); + register_decode_as_next_proto("i2c", "I2C Message", "i2c.message", (build_label_func*)&i2c_prompt); } void diff --git a/epan/dissectors/packet-infiniband.c b/epan/dissectors/packet-infiniband.c index 770ca04d21..da57f318b7 100644 --- a/epan/dissectors/packet-infiniband.c +++ b/epan/dissectors/packet-infiniband.c @@ -1537,11 +1537,6 @@ static void infiniband_payload_prompt(packet_info *pinfo _U_, gchar* result) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Dissect Infiniband payload as"); } -static gpointer infiniband_payload_value(packet_info *pinfo _U_) -{ - return 0; -} - static void table_destroy_notify(gpointer data) { g_free(data); } @@ -7962,12 +7957,6 @@ void proto_register_infiniband(void) &ett_eoib }; - /* Decode As handling */ - static build_valid_func infiniband_payload_da_build_value[1] = {infiniband_payload_value}; - static decode_as_value_t infiniband_payload_da_values = {infiniband_payload_prompt, 1, infiniband_payload_da_build_value}; - static decode_as_t infiniband_payload_da = {"infiniband", "Network", "infiniband", 1, 0, &infiniband_payload_da_values, NULL, NULL, - decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; - proto_infiniband = proto_register_protocol("InfiniBand", "IB", "infiniband"); ib_handle = register_dissector("infiniband", dissect_infiniband, proto_infiniband); @@ -8006,7 +7995,7 @@ void proto_register_infiniband(void) CM_context_table = g_hash_table_new_full(g_int64_hash, g_int64_equal, table_destroy_notify, table_destroy_notify); - register_decode_as(&infiniband_payload_da); + register_decode_as_next_proto("infiniband", "Network", "infiniband", (build_label_func*)&infiniband_payload_prompt); register_shutdown_routine(infiniband_shutdown); } diff --git a/epan/dissectors/packet-iso15765.c b/epan/dissectors/packet-iso15765.c index 16335f5035..668702f0df 100644 --- a/epan/dissectors/packet-iso15765.c +++ b/epan/dissectors/packet-iso15765.c @@ -157,18 +157,6 @@ static const fragment_items iso15765_frag_items = { "ISO15765 fragments" }; -static void -iso15765_prompt(packet_info *pinfo _U_, gchar* result) -{ - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Next level protocol as"); -} - -static gpointer -iso15765_value(packet_info *pinfo _U_) -{ - return 0; -} - static guint8 masked_guint8_value(const guint8 value, const guint8 mask) { @@ -559,13 +547,6 @@ proto_register_iso15765(void) module_t *iso15765_module; expert_module_t* expert_iso15765; - /* Decode As handling */ - static build_valid_func iso15765_da_build_value[1] = {iso15765_value}; - static decode_as_value_t iso15765_da_values = {iso15765_prompt, 1, iso15765_da_build_value}; - static decode_as_t can_iso15765 = {"iso15765", "Transport", "iso15765.subdissector", 1, 0, &iso15765_da_values, - NULL, NULL, decode_as_default_populate_list, decode_as_default_reset, - decode_as_default_change, NULL}; - proto_iso15765 = proto_register_protocol ( "ISO15765 Protocol", /* name */ "ISO 15765", /* short name */ @@ -596,12 +577,12 @@ proto_register_iso15765(void) "Window of ISO 15765 fragments", 10, &window); - register_decode_as(&can_iso15765); - iso15765_frame_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal); reassembly_table_register(&iso15765_reassembly_table, &addresses_reassembly_table_functions); + + register_decode_as_next_proto("iso15765", "Transport", "iso15765.subdissector", NULL); } void diff --git a/epan/dissectors/packet-moldudp.c b/epan/dissectors/packet-moldudp.c index 9bcb6c4f79..0106d24cba 100644 --- a/epan/dissectors/packet-moldudp.c +++ b/epan/dissectors/packet-moldudp.c @@ -63,11 +63,6 @@ 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, @@ -249,12 +244,6 @@ 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"); @@ -266,7 +255,7 @@ proto_register_moldudp(void) expert_moldudp = expert_register_protocol(proto_moldudp); expert_register_field_array(expert_moldudp, ei, array_length(ei)); - register_decode_as(&moldudp_da); + register_decode_as_next_proto("moldudp", "MoldUDP Payload", "moldudp.payload", (build_label_func*)&moldudp_prompt); } diff --git a/epan/dissectors/packet-moldudp64.c b/epan/dissectors/packet-moldudp64.c index efa85af34b..49ea590fa2 100644 --- a/epan/dissectors/packet-moldudp64.c +++ b/epan/dissectors/packet-moldudp64.c @@ -66,11 +66,6 @@ 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, @@ -263,12 +258,6 @@ 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"); @@ -281,7 +270,7 @@ proto_register_moldudp64(void) expert_moldudp64 = expert_register_protocol(proto_moldudp64); expert_register_field_array(expert_moldudp64, ei, array_length(ei)); - register_decode_as(&moldudp64_da); + register_decode_as_next_proto("moldudp64", "MoldUDP64 Payload", "moldudp64.payload", (build_label_func*)&moldudp64_prompt); } diff --git a/epan/dissectors/packet-nfs.c b/epan/dissectors/packet-nfs.c index 5f2ce42125..6f76b6e9e5 100644 --- a/epan/dissectors/packet-nfs.c +++ b/epan/dissectors/packet-nfs.c @@ -946,11 +946,6 @@ static void nfs_prompt(packet_info *pinfo _U_, gchar* result) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Decode NFS file handles as"); } -static gpointer nfs_value(packet_info *pinfo _U_) -{ - return 0; -} - /* This function will store one nfs filehandle in our global tree of * filehandles. * We store all filehandles we see in this tree so that every unique @@ -14038,12 +14033,6 @@ proto_register_nfs(void) module_t *nfs_module; expert_module_t* expert_nfs; - /* Decode As handling */ - static build_valid_func nfs_da_build_value[1] = {nfs_value}; - static decode_as_value_t nfs_da_values = {nfs_prompt, 1, nfs_da_build_value}; - static decode_as_t nfs_da = {"nfs", "NFS File Handle", "nfs_fhandle.type", 1, 0, &nfs_da_values, NULL, NULL, - decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; - proto_nfs = proto_register_protocol("Network File System", "NFS", "nfs"); /* "protocols" registered just for Decode As */ @@ -14108,7 +14097,7 @@ proto_register_nfs(void) register_init_routine(nfs_name_snoop_init); register_cleanup_routine(nfs_name_snoop_cleanup); - register_decode_as(&nfs_da); + register_decode_as_next_proto("nfs", "NFS File Handle", "nfs_fhandle.type", (build_label_func*)&nfs_prompt); } diff --git a/epan/dissectors/packet-pcli.c b/epan/dissectors/packet-pcli.c index 8dc4213329..3e35dcd1ea 100644 --- a/epan/dissectors/packet-pcli.c +++ b/epan/dissectors/packet-pcli.c @@ -208,12 +208,6 @@ pcli_prompt(packet_info *pinfo _U_, gchar* result) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "PCLI payload as"); } -static gpointer -pcli_value(packet_info *pinfo _U_) -{ - return NULL; -} - void proto_register_pcli(void) { @@ -238,18 +232,6 @@ proto_register_pcli(void) module_t *pcli_module; - /* Decode As handling */ - static build_valid_func pcli_payload_da_build_value[1] = {pcli_value}; - static decode_as_value_t pcli_payload_da_values = {pcli_prompt, 1, pcli_payload_da_build_value}; - static decode_as_t pcli_payload_da = { - "pcli", "PCLI payload", "pcli.payload", 1, 0, - &pcli_payload_da_values, NULL, NULL, - decode_as_default_populate_list, - decode_as_default_reset, - decode_as_default_change, - NULL, - }; - proto_pcli = proto_register_protocol("Packet Cable Lawful Intercept", "PCLI", "pcli"); /* Create "placeholders" to remove confusion with Decode As" */ proto_pcli8 = proto_register_protocol_in_name_only("Packet Cable Lawful Intercept (8 byte CCCID)", "PCLI8 (8 byte CCCID)", "pcli8", proto_pcli, FT_PROTOCOL); @@ -271,7 +253,7 @@ proto_register_pcli(void) "pcli.payload", "PCLI payload dissector", proto_pcli, FT_UINT32, BASE_DEC); - register_decode_as(&pcli_payload_da); + register_decode_as_next_proto("pcli", "PCLI payload", "pcli.payload", (build_label_func*)&pcli_prompt); } /* The registration hand-off routing */ diff --git a/epan/dissectors/packet-rtacser.c b/epan/dissectors/packet-rtacser.c index 7030f0fff9..87867ac7fe 100644 --- a/epan/dissectors/packet-rtacser.c +++ b/epan/dissectors/packet-rtacser.c @@ -120,12 +120,6 @@ rtacser_ppi_prompt(packet_info *pinfo _U_, gchar* result) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Payload as"); } -static gpointer -rtacser_ppi_value(packet_info *pinfo _U_) -{ - return 0; -} - /******************************************************************************************************/ /* Code to dissect RTAC Serial-Line Protocol packets */ /******************************************************************************************************/ @@ -280,11 +274,6 @@ proto_register_rtacser(void) &ett_rtacser_cl, }; - static build_valid_func rtacser_da_ppi_build_value[1] = {rtacser_ppi_value}; - static decode_as_value_t rtacser_da_ppi_values[1] = {{rtacser_ppi_prompt, 1, rtacser_da_ppi_build_value}}; - static decode_as_t rtacser_da_ppi = {"rtacser", "RTAC Serial", "rtacser.data", 1, 0, rtacser_da_ppi_values, "RTAC Serial", NULL, - decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; - module_t *rtacser_module; /* Register the protocol name and description */ @@ -305,7 +294,7 @@ proto_register_rtacser(void) /* RTAC Serial Preference - Payload Protocol in use */ prefs_register_obsolete_preference(rtacser_module, "rtacserial_payload_proto"); - register_decode_as(&rtacser_da_ppi); + register_decode_as_next_proto("rtacser", "RTAC Serial", "rtacser.data", (build_label_func*)&rtacser_ppi_prompt); } /******************************************************************************************************/ diff --git a/epan/dissectors/packet-socketcan.c b/epan/dissectors/packet-socketcan.c index ca62cca0a8..c7df1bc4ed 100644 --- a/epan/dissectors/packet-socketcan.c +++ b/epan/dissectors/packet-socketcan.c @@ -95,16 +95,6 @@ static const value_string frame_type_vals[] = { 0, NULL } }; -static void can_prompt(packet_info *pinfo _U_, gchar* result) -{ - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Next level protocol as"); -} - -static gpointer can_value(packet_info *pinfo _U_) -{ - return 0; -} - static int dissect_socketcan_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint encoding) @@ -388,12 +378,6 @@ proto_register_socketcan(void) module_t *can_module; - /* Decode As handling */ - static build_valid_func can_da_build_value[1] = {can_value}; - static decode_as_value_t can_da_values = {can_prompt, 1, can_da_build_value}; - static decode_as_t can_da = {"can", "Network", "can.subdissector", 1, 0, &can_da_values, NULL, NULL, - decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; - proto_can = proto_register_protocol("Controller Area Network", "CAN", "can"); socketcan_bigendian_handle = register_dissector("can-bigendian", dissect_socketcan_bigendian, proto_can); socketcan_hostendian_handle = register_dissector("can-hostendian", dissect_socketcan_hostendian, proto_can); @@ -415,7 +399,7 @@ proto_register_socketcan(void) "Whether the CAN ID/flags field should be byte-swapped", &byte_swap); - register_decode_as(&can_da); + register_decode_as_next_proto("can", "Network", "can.subdissector", NULL); } void diff --git a/epan/dissectors/packet-usb-ccid.c b/epan/dissectors/packet-usb-ccid.c index 1a029afeb3..c7096424ec 100644 --- a/epan/dissectors/packet-usb-ccid.c +++ b/epan/dissectors/packet-usb-ccid.c @@ -882,8 +882,7 @@ proto_register_ccid(void) subdissector_table = register_dissector_table( "usbccid.subdissector", "USB CCID payload", proto_ccid, FT_UINT32, BASE_HEX); - register_decode_as_next_proto( - "USB CCID", "Transport", "usbccid.subdissector"); + register_decode_as_next_proto("USB CCID", "Transport", "usbccid.subdissector", NULL); } /* Handler registration */