aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-pdc.c
diff options
context:
space:
mode:
authorDavid Perry <boolean263@protonmail.com>2023-09-19 14:12:28 -0400
committerAndersBroman <a.broman58@gmail.com>2023-09-19 19:06:51 +0000
commitfb9d01556dbc28a507778f66cbaca234a55e6305 (patch)
tree6bd4e8351e33d1519492b96ae9baf69eef6ee678 /epan/dissectors/packet-pdc.c
parentd4f47c60b7eb12a84348d5c0228f6b5afd013660 (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-pdc.c')
-rw-r--r--epan/dissectors/packet-pdc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/epan/dissectors/packet-pdc.c b/epan/dissectors/packet-pdc.c
index 9dc0c28dc0..1bc4a5f272 100644
--- a/epan/dissectors/packet-pdc.c
+++ b/epan/dissectors/packet-pdc.c
@@ -40,6 +40,9 @@ void proto_reg_handoff_pdc(void);
#define PDC_MSG_SIZE_FIELD_LENGTH 2 /* minimum amount of data to find out how big the split packet should be when recombined */
#define FRAME_HEADER_LEN 8
+/* global handle for our dissector */
+static dissector_handle_t pdc_tcp_handle;
+
/* global handle for calling asterix decoder if required */
static dissector_handle_t asterix_handle;
@@ -563,16 +566,15 @@ void proto_register_pdc(void)
/*Required Function Calls to register the header fields and subtrees used*/
proto_register_field_array(proto_pdc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+
+ /* Register our dissector handle */
+ pdc_tcp_handle = register_dissector("pdc", tcp_dissect_pdc, proto_pdc);
}
/* Function to add pdc dissector to tcp.port dissector table and to get handle for asterix dissector */
void proto_reg_handoff_pdc(void)
{
- dissector_handle_t pdc_tcp_handle;
-
asterix_handle = find_dissector_add_dependency("asterix", proto_pdc);
- pdc_tcp_handle = create_dissector_handle(tcp_dissect_pdc, proto_pdc);
-
dissector_add_for_decode_as_with_preference("tcp.port", pdc_tcp_handle);
}