diff options
author | David Perry <boolean263@protonmail.com> | 2023-09-19 14:12:28 -0400 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2023-09-19 19:06:51 +0000 |
commit | fb9d01556dbc28a507778f66cbaca234a55e6305 (patch) | |
tree | 6bd4e8351e33d1519492b96ae9baf69eef6ee678 /epan/dissectors/packet-simulcrypt.c | |
parent | d4f47c60b7eb12a84348d5c0228f6b5afd013660 (diff) |
Use `register_dissector()` for more protocols
Changes several calls of `create_dissector_handle()` to instead call
`register_dissector()` with a name for the dissector.
This should handle all dissectors in `epan/` from `packet-p*` to
`packet-v*`.
This change allows affected dissectors to be findable by calls to
`find_dissector()`. In turn, this opens up more command-line use for
these protocols, including fuzzshark and rawshark, as well as lua use
via `Dissector.get()`.
Where needed, move the call from the protocol handoff function to the
protocol register function, save the result in a static variable,
and use that variable in the handoff function.
There were some calls to `create_dissector_handle()` or
`register_dissector()` which passed `-1` as the protocol argument. When
I saw those I corrected them to pass the actual `proto_foo` identifier
instead.
Partially addresses #5612
Diffstat (limited to 'epan/dissectors/packet-simulcrypt.c')
-rw-r--r-- | epan/dissectors/packet-simulcrypt.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/epan/dissectors/packet-simulcrypt.c b/epan/dissectors/packet-simulcrypt.c index 5e35504a65..5fac3a135c 100644 --- a/epan/dissectors/packet-simulcrypt.c +++ b/epan/dissectors/packet-simulcrypt.c @@ -60,6 +60,9 @@ static void dissect_simulcrypt_data(proto_tree *simulcrypt_tree, proto_item *sim /* Wireshark ID of the SIMULCRYPT protocol */ static guint proto_simulcrypt = -1; +/* Dissector handle for SIMULCRYPT protocol */ +static dissector_handle_t simulcrypt_handle; + /* Preferences (with default values) */ static int ca_system_id_mikey = CA_SYSTEM_ID_MIKEY; /* MIKEY ECM CA_system_ID */ @@ -1803,6 +1806,8 @@ proto_register_simulcrypt (void) register_init_routine(simulcrypt_init); + simulcrypt_handle = register_dissector("simulcrypt", dissect_simulcrypt, proto_simulcrypt); + /* Register our configuration options for Simulcrypt, particularly our port. */ /* This registers our preferences; function proto_reg_handoff_simulcrypt is */ /* called when preferences are applied. */ @@ -1817,11 +1822,9 @@ void proto_reg_handoff_simulcrypt(void) { static gboolean initialized=FALSE; - dissector_handle_t simulcrypt_handle; guint i; if (!initialized) { - simulcrypt_handle = create_dissector_handle(dissect_simulcrypt, proto_simulcrypt); for(i=0;i<ECM_INTERPRETATION_SIZE;i++) { tab_ecm_inter[i].protocol_handle = find_dissector(tab_ecm_inter[i].protocol_name); |