summaryrefslogtreecommitdiff
path: root/plugins/irda
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/irda
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/irda')
-rw-r--r--plugins/irda/packet-ircomm.c10
-rw-r--r--plugins/irda/packet-irda.c7
-rw-r--r--plugins/irda/packet-sir.c5
3 files changed, 8 insertions, 14 deletions
diff --git a/plugins/irda/packet-ircomm.c b/plugins/irda/packet-ircomm.c
index e9d79c122c..df5d017c01 100644
--- a/plugins/irda/packet-ircomm.c
+++ b/plugins/irda/packet-ircomm.c
@@ -400,8 +400,8 @@ void proto_register_ircomm(void)
/* Register protocol names and descriptions */
proto_ircomm = proto_register_protocol("IrCOMM Protocol", "IrCOMM", "ircomm");
- register_dissector("ircomm_raw", dissect_raw_ircomm, proto_ircomm);
- register_dissector("ircomm_cooked", dissect_cooked_ircomm, proto_ircomm);
+ ircomm_raw_handle = register_dissector("ircomm_raw", dissect_raw_ircomm, proto_ircomm);
+ ircomm_cooked_handle = register_dissector("ircomm_cooked", dissect_cooked_ircomm, proto_ircomm);
/* Required function calls to register the header fields */
proto_register_field_array(proto_ircomm, hf_ircomm, array_length(hf_ircomm));
@@ -416,12 +416,6 @@ void proto_register_ircomm(void)
proto_register_subtree_array(ett_p, MAX_IAP_ENTRIES * MAX_PARAMETERS);
}
-void
-proto_reg_handoff_ircomm(void) {
- ircomm_raw_handle = find_dissector("ircomm_raw");
- ircomm_cooked_handle = find_dissector("ircomm_cooked");
-}
-
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
diff --git a/plugins/irda/packet-irda.c b/plugins/irda/packet-irda.c
index af19f3f3c0..52b28812df 100644
--- a/plugins/irda/packet-irda.c
+++ b/plugins/irda/packet-irda.c
@@ -241,6 +241,8 @@ static gint ett_iap_entry[MAX_IAP_ENTRIES];
static int irda_address_type = -1;
+static dissector_handle_t irda_handle;
+
static const xdlc_cf_items irlap_cf_items = {
&hf_lap_c_nr,
&hf_lap_c_ns,
@@ -2206,7 +2208,7 @@ void proto_register_irda(void)
proto_ttp = proto_register_protocol("Tiny Transport Protocol", "TTP", "ttp");
/* Register the dissector */
- register_dissector("irda", dissect_irda, proto_irlap);
+ irda_handle = register_dissector("irda", dissect_irda, proto_irlap);
/* Required function calls to register the header fields */
proto_register_field_array(proto_irlap, hf_lap, array_length(hf_lap));
@@ -2241,9 +2243,6 @@ void proto_register_irda(void)
void proto_reg_handoff_irda(void)
{
- dissector_handle_t irda_handle;
-
- irda_handle = find_dissector("irda");
dissector_add_uint("wtap_encap", WTAP_ENCAP_IRDA, irda_handle);
dissector_add_uint("sll.ltype", LINUX_SLL_P_IRDA_LAP, irda_handle);
}
diff --git a/plugins/irda/packet-sir.c b/plugins/irda/packet-sir.c
index 57bdbc9da8..9060e42ece 100644
--- a/plugins/irda/packet-sir.c
+++ b/plugins/irda/packet-sir.c
@@ -49,6 +49,7 @@ void proto_register_irsir(void);
/** Protocol handles. */
static dissector_handle_t irda_handle;
+static dissector_handle_t sir_handle;
/** Protocol fields. */
static int proto_sir = -1;
@@ -174,7 +175,7 @@ dissect_sir(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root, void* data _U_)
void
proto_reg_handoff_irsir(void)
{
- dissector_add_uint_with_preference("tcp.port", TCP_PORT_SIR, find_dissector("sir"));
+ dissector_add_uint_with_preference("tcp.port", TCP_PORT_SIR, sir_handle);
irda_handle = find_dissector("irda");
}
@@ -226,7 +227,7 @@ proto_register_irsir(void)
expert_module_t* expert_sir;
proto_sir = proto_register_protocol("Serial Infrared", "SIR", "sir");
- register_dissector("sir", dissect_sir, proto_sir);
+ sir_handle = register_dissector("sir", dissect_sir, proto_sir);
proto_register_subtree_array(ett, array_length(ett));
proto_register_field_array( proto_sir, hf_sir, array_length(hf_sir));
expert_sir = expert_register_protocol(proto_sir);