summaryrefslogtreecommitdiff
path: root/plugins/ethercat
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 /plugins/ethercat
parent13964595ad09e5d1115f6c5cb604cded27f9f55d (diff)
downloadwireshark-f4b0abc7296bbb431e64e31f85b24c29196c2ae4.tar.gz
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 'plugins/ethercat')
-rw-r--r--plugins/ethercat/packet-ams.c7
-rw-r--r--plugins/ethercat/packet-ecatmb.c6
-rw-r--r--plugins/ethercat/packet-ethercat-frame.c7
3 files changed, 9 insertions, 11 deletions
diff --git a/plugins/ethercat/packet-ams.c b/plugins/ethercat/packet-ams.c
index 1b40275b08..f91c344aa6 100644
--- a/plugins/ethercat/packet-ams.c
+++ b/plugins/ethercat/packet-ams.c
@@ -127,6 +127,8 @@ static int hf_ams_adscycletime = -1;
/* static int hf_ams_adscmpmax = -1; */
/* static int hf_ams_adscmpmin = -1; */
+static dissector_handle_t ams_handle;
+
static const value_string TransMode[] =
{
{ 0, "NO TRANS"},
@@ -1227,16 +1229,15 @@ void proto_register_ams(void)
proto_register_field_array(proto_ams, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- register_dissector("ams", dissect_ams, proto_ams);
+ ams_handle = register_dissector("ams", dissect_ams, proto_ams);
}
/* The registration hand-off routing */
void proto_reg_handoff_ams(void)
{
- dissector_handle_t ams_handle, amstcp_handle;
+ dissector_handle_t amstcp_handle;
- ams_handle = find_dissector("ams");
amstcp_handle = create_dissector_handle( dissect_amstcp, proto_ams );
dissector_add_uint_with_preference("tcp.port", AMS_TCP_PORT, amstcp_handle);
dissector_add_uint("ecatf.type", 2, ams_handle);
diff --git a/plugins/ethercat/packet-ecatmb.c b/plugins/ethercat/packet-ecatmb.c
index e43cc0f403..0f34931852 100644
--- a/plugins/ethercat/packet-ecatmb.c
+++ b/plugins/ethercat/packet-ecatmb.c
@@ -41,6 +41,7 @@ void proto_reg_handoff_ecat_mailbox(void);
static dissector_handle_t eth_handle;
static dissector_handle_t ams_handle;
+static dissector_handle_t ecat_mailbox_handle;
/* Define the EtherCAT mailbox proto */
int proto_ecat_mailbox = -1;
@@ -1972,15 +1973,12 @@ void proto_register_ecat_mailbox(void)
proto_register_field_array(proto_ecat_mailbox, hf,array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- register_dissector("ecat_mailbox", dissect_ecat_mailbox, proto_ecat_mailbox);
+ ecat_mailbox_handle = register_dissector("ecat_mailbox", dissect_ecat_mailbox, proto_ecat_mailbox);
}
void proto_reg_handoff_ecat_mailbox(void)
{
- dissector_handle_t ecat_mailbox_handle;
-
/* Register this dissector as a sub dissector to E88A4 based on ether type. */
- ecat_mailbox_handle = find_dissector("ecat_mailbox");
dissector_add_uint("ecatf.type", 5, ecat_mailbox_handle);
eth_handle = find_dissector_add_dependency("eth_withoutfcs", proto_ecat_mailbox);
diff --git a/plugins/ethercat/packet-ethercat-frame.c b/plugins/ethercat/packet-ethercat-frame.c
index 53b60b7112..bf59d6ca45 100644
--- a/plugins/ethercat/packet-ethercat-frame.c
+++ b/plugins/ethercat/packet-ethercat-frame.c
@@ -39,6 +39,8 @@ static int proto_ethercat_frame = -1;
static dissector_table_t ethercat_frame_dissector_table;
+static dissector_handle_t ethercat_frame_handle;
+
/* Define the tree for the EtherCAT frame */
static int ett_ethercat_frame = -1;
static int hf_ethercat_frame_length = -1;
@@ -133,7 +135,7 @@ void proto_register_ethercat_frame(void)
proto_register_field_array(proto_ethercat_frame,hf,array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- register_dissector("ecatf", dissect_ethercat_frame, proto_ethercat_frame);
+ ethercat_frame_handle = register_dissector("ecatf", dissect_ethercat_frame, proto_ethercat_frame);
/* Define a handle (ecatf.type) for sub dissectors that want to dissect
the Ethercat frame ether type (E88A4) payload. */
@@ -143,9 +145,6 @@ void proto_register_ethercat_frame(void)
void proto_reg_handoff_ethercat_frame(void)
{
- dissector_handle_t ethercat_frame_handle;
-
- ethercat_frame_handle = find_dissector("ecatf");
dissector_add_uint("ethertype", ETHERTYPE_ECATF, ethercat_frame_handle);
dissector_add_uint_with_preference("udp.port", ETHERTYPE_ECATF, ethercat_frame_handle);
dissector_add_uint_with_preference("tcp.port", ETHERTYPE_ECATF, ethercat_frame_handle);