aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-opensafety.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-12-16 20:06:11 -0500
committerAnders Broman <a.broman58@gmail.com>2016-12-31 07:31:42 +0000
commitf4b0abc7296bbb431e64e31f85b24c29196c2ae4 (patch)
tree68394f5fdfa1987900f0b079d0ecfd34003e8a5a /epan/dissectors/packet-opensafety.c
parent13964595ad09e5d1115f6c5cb604cded27f9f55d (diff)
Dissectors don't need a journey of self discovery.
They already know who they are when they register themselves. Saving the handle then to avoid finding it later. Not sure if this will increase unnecessary register_dissector functions (instead of using create_dissector_handle in proto_reg_handoff function) when other dissectors copy/paste, but it should make startup time a few microseconds better. Change-Id: I3839be791b32b84887ac51a6a65fb5733e9f1f43 Reviewed-on: https://code.wireshark.org/review/19481 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-opensafety.c')
-rw-r--r--epan/dissectors/packet-opensafety.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/epan/dissectors/packet-opensafety.c b/epan/dissectors/packet-opensafety.c
index 36a293ae5e..d3162cdc8b 100644
--- a/epan/dissectors/packet-opensafety.c
+++ b/epan/dissectors/packet-opensafety.c
@@ -256,6 +256,9 @@ static const fragment_items oss_frag_items = {
static const char *global_scm_udid = "00:00:00:00:00:00";
static dissector_handle_t data_dissector = NULL;
+static dissector_handle_t opensafety_udpdata_handle = NULL;
+static dissector_handle_t opensafety_mbtcp_handle = NULL;
+static dissector_handle_t opensafety_pnio_handle = NULL;
static gboolean global_display_intergap_data = FALSE;
static gboolean global_scm_udid_autoset = TRUE;
@@ -2403,23 +2406,18 @@ dissect_opensafety_udpdata(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree
static void
apply_prefs ( void )
{
- static dissector_handle_t opensafety_udpdata_handle = NULL;
static guint opensafety_udp_port_number;
static guint opensafety_udp_siii_port_number;
static gboolean opensafety_init = FALSE;
/* It only should delete dissectors, if run for any time except the first */
- if ( !opensafety_init )
- {
- opensafety_udpdata_handle = find_dissector("opensafety_udpdata");
- opensafety_init = TRUE;
- }
- else
+ if ( opensafety_init )
{
/* Delete dissectors in preparation of a changed config setting */
dissector_delete_uint ("udp.port", opensafety_udp_port_number, opensafety_udpdata_handle);
dissector_delete_uint ("udp.port", opensafety_udp_siii_port_number, opensafety_udpdata_handle);
}
+ opensafety_init = TRUE;
/* Storing the port numbers locally, to being able to delete the old associations */
opensafety_udp_port_number = global_network_udp_port;
@@ -2854,9 +2852,9 @@ proto_register_opensafety(void)
&global_classify_transport);
/* Registering default and ModBus/TCP dissector */
- register_dissector("opensafety_udpdata", dissect_opensafety_udpdata, proto_opensafety );
- register_dissector("opensafety_mbtcp", dissect_opensafety_mbtcp, proto_opensafety );
- register_dissector("opensafety_pnio", dissect_opensafety_pn_io, proto_opensafety);
+ opensafety_udpdata_handle = register_dissector("opensafety_udpdata", dissect_opensafety_udpdata, proto_opensafety );
+ opensafety_mbtcp_handle = register_dissector("opensafety_mbtcp", dissect_opensafety_mbtcp, proto_opensafety );
+ opensafety_pnio_handle = register_dissector("opensafety_pnio", dissect_opensafety_pn_io, proto_opensafety);
}
void
@@ -2875,7 +2873,7 @@ proto_reg_handoff_opensafety(void)
heur_dissector_add("opensafety_udp", dissect_opensafety_udpdata, "openSAFETY over UDP", "opensafety_udp", proto_opensafety, HEURISTIC_ENABLE);
/* Modbus TCP dissector registration */
- dissector_add_string("modbus.data", "data", find_dissector("opensafety_mbtcp"));
+ dissector_add_string("modbus.data", "data", opensafety_mbtcp_handle);
/* For Profinet we have to register as a heuristic dissector, as Profinet
* is implemented as a plugin, and therefore the heuristic dissector is not
@@ -2891,7 +2889,7 @@ proto_reg_handoff_opensafety(void)
* the ethernet subdissector list. No PNIO specific data will be dissected
* and a warning will be displayed, recognizing the missing dissector plugin.
*/
- dissector_add_uint("ethertype", ETHERTYPE_PROFINET, find_dissector("opensafety_pnio"));
+ dissector_add_uint("ethertype", ETHERTYPE_PROFINET, opensafety_pnio_handle);
}
apply_prefs();