diff options
author | David Perry <boolean263@protonmail.com> | 2023-05-09 15:19:23 -0400 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2023-05-16 08:18:10 +0000 |
commit | 5468611d57cb0302d4f0f359f79c0bedc66ee888 (patch) | |
tree | 7ade10f42525ed5a80b68a1f2849b08ae0094b3a /epan/dissectors/packet-dis.c | |
parent | 40fdd6766467007fcae26d4edb6c32c1bbc3dea6 (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-a*` to
`packet-d*`.
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, and use `find_dissector()` 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-dis.c')
-rw-r--r-- | epan/dissectors/packet-dis.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/epan/dissectors/packet-dis.c b/epan/dissectors/packet-dis.c index acc2f72e3e..0a7be792df 100644 --- a/epan/dissectors/packet-dis.c +++ b/epan/dissectors/packet-dis.c @@ -8257,6 +8257,8 @@ static gint parseField_VariableRecord(tvbuff_t *tvb, proto_tree *tree, gint offs void proto_register_dis(void); +static dissector_handle_t dis_dissector_handle; + static const true_false_string dis_modulation_spread_spectrum = { "Spread Spectrum modulation in use", "Spread Spectrum modulation not in use" @@ -11057,6 +11059,8 @@ void proto_register_dis(void) proto_dis = proto_register_protocol("Distributed Interactive Simulation", "DIS", "dis"); proto_register_field_array(proto_dis, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + + dis_dissector_handle = register_dissector("dis", dissect_dis, proto_dis); } /* Register handoff routine for DIS dissector. This will be invoked initially @@ -11065,9 +11069,6 @@ void proto_register_dis(void) */ void proto_reg_handoff_dis(void) { - dissector_handle_t dis_dissector_handle; - - dis_dissector_handle = create_dissector_handle(dissect_dis, proto_dis); dissector_add_uint_with_preference("udp.port", DEFAULT_DIS_UDP_PORT, dis_dissector_handle); link16_handle = find_dissector_add_dependency("link16", proto_dis); |