diff options
author | David Perry <boolean263@protonmail.com> | 2023-06-13 15:51:49 -0400 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2023-06-13 21:53:31 +0000 |
commit | f02f47dadfca0f79f62df6274f032d9841260e35 (patch) | |
tree | c4d13b7489df600ceb66c21a5a3b245668fb15bc /epan/dissectors/packet-evrc.c | |
parent | 274e67998e84ba12a55b3e9456e500e4c632ac21 (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-e*` to
`packet-f*`.
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-evrc.c')
-rw-r--r-- | epan/dissectors/packet-evrc.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/epan/dissectors/packet-evrc.c b/epan/dissectors/packet-evrc.c index af0b09acf0..982d7c9f14 100644 --- a/epan/dissectors/packet-evrc.c +++ b/epan/dissectors/packet-evrc.c @@ -37,6 +37,13 @@ void proto_register_evrc(void); void proto_reg_handoff_evrc(void); +static dissector_handle_t evrc_handle; +static dissector_handle_t evrcb_handle; +static dissector_handle_t evrcwb_handle; +static dissector_handle_t evrcnw_handle; +static dissector_handle_t evrcnw2k_handle; +static dissector_handle_t evrc_legacy_handle; + static const value_string evrc_frame_type_vals[] = { { 0, "Blank (0 bits)" }, { 1, "1/8 Rate (16 bits)" }, @@ -594,6 +601,13 @@ proto_register_evrc(void) proto_register_subtree_array(ett, array_length(ett)); + evrc_handle = register_dissector("evrc", dissect_evrc, proto_evrc); + evrcb_handle = register_dissector("evrcb", dissect_evrcb, proto_evrcb); + evrcwb_handle = register_dissector("evrcwb", dissect_evrcwb, proto_evrcwb); + evrcnw_handle = register_dissector("evrcnw", dissect_evrcnw, proto_evrcnw); + evrcnw2k_handle = register_dissector("evrcnw2k", dissect_evrcnw2k, proto_evrcnw2k); + evrc_legacy_handle = register_dissector("evrc_legacy", dissect_evrc_legacy, proto_evrc_legacy); + expert_evrc = expert_register_protocol(proto_evrc); expert_register_field_array(expert_evrc, ei, array_length(ei)); @@ -615,23 +629,9 @@ void proto_reg_handoff_evrc(void) { static gboolean evrc_prefs_initialized = FALSE; - static dissector_handle_t evrc_legacy_handle; if (!evrc_prefs_initialized) { - dissector_handle_t evrc_handle; - dissector_handle_t evrcb_handle; - dissector_handle_t evrcwb_handle; - dissector_handle_t evrcnw_handle; - dissector_handle_t evrcnw2k_handle; - - evrc_handle = create_dissector_handle(dissect_evrc, proto_evrc); - evrcb_handle = create_dissector_handle(dissect_evrcb, proto_evrcb); - evrcwb_handle = create_dissector_handle(dissect_evrcwb, proto_evrcwb); - evrcnw_handle = create_dissector_handle(dissect_evrcnw, proto_evrcnw); - evrcnw2k_handle = create_dissector_handle(dissect_evrcnw2k, proto_evrcnw2k); - evrc_legacy_handle = create_dissector_handle(dissect_evrc_legacy, proto_evrc_legacy); - /* header-full mime types */ dissector_add_string("rtp_dyn_payload_type", "EVRC", evrc_handle); dissector_add_string("rtp_dyn_payload_type", "EVRCB", evrcb_handle); |