From fb9d01556dbc28a507778f66cbaca234a55e6305 Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 19 Sep 2023 14:12:28 -0400 Subject: 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 --- epan/dissectors/packet-rmt-norm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'epan/dissectors/packet-rmt-norm.c') diff --git a/epan/dissectors/packet-rmt-norm.c b/epan/dissectors/packet-rmt-norm.c index a965462ed4..98889896e6 100644 --- a/epan/dissectors/packet-rmt-norm.c +++ b/epan/dissectors/packet-rmt-norm.c @@ -38,6 +38,8 @@ void proto_register_norm(void); void proto_reg_handoff_norm(void); +static dissector_handle_t norm_handle; + /* String tables */ #define NORM_INFO 1 @@ -954,6 +956,8 @@ void proto_register_norm(void) expert_rmt_norm = expert_register_protocol(proto_rmt_norm); expert_register_field_array(expert_rmt_norm, ei, array_length(ei)); + /* Register the subdissector handle */ + norm_handle = register_dissector("norm", dissect_norm, proto_rmt_norm); /* Register preferences */ module = prefs_register_protocol(proto_rmt_norm, NULL); @@ -962,10 +966,7 @@ void proto_register_norm(void) void proto_reg_handoff_norm(void) { - static dissector_handle_t handle; - - handle = create_dissector_handle(dissect_norm, proto_rmt_norm); - dissector_add_for_decode_as_with_preference("udp.port", handle); + dissector_add_for_decode_as_with_preference("udp.port", norm_handle); heur_dissector_add("udp", dissect_norm_heur, "NORM over UDP", "rmt_norm_udp", proto_rmt_norm, HEURISTIC_DISABLE); rmt_fec_handle = find_dissector_add_dependency("rmt-fec", proto_rmt_norm); -- cgit v1.2.3