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-autosar-nm.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-autosar-nm.c')
-rw-r--r-- | epan/dissectors/packet-autosar-nm.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/epan/dissectors/packet-autosar-nm.c b/epan/dissectors/packet-autosar-nm.c index 631b36086a..dc8dc9b4a8 100644 --- a/epan/dissectors/packet-autosar-nm.c +++ b/epan/dissectors/packet-autosar-nm.c @@ -727,6 +727,9 @@ void proto_register_autosar_nm(void) prefs_register_range_preference(autosar_nm_module, "ipdum.pdu.id", "AUTOSAR I-PduM PDU IDs", "I-PDU Multiplexer PDU IDs.", &g_autosar_nm_ipdum_pdus, 0xffffffff); + + nm_handle = register_dissector("autosar-nm", dissect_autosar_nm, proto_autosar_nm); + nm_handle_can = register_dissector("autosar-nm.can", dissect_autosar_nm_can, proto_autosar_nm); } void proto_reg_handoff_autosar_nm(void) @@ -734,10 +737,8 @@ void proto_reg_handoff_autosar_nm(void) static gboolean initialized = FALSE; if (!initialized) { - nm_handle = create_dissector_handle(dissect_autosar_nm, proto_autosar_nm); dissector_add_for_decode_as_with_preference("udp.port", nm_handle); - nm_handle_can = create_dissector_handle(dissect_autosar_nm_can, proto_autosar_nm); dissector_add_for_decode_as("can.subdissector", nm_handle_can); /* heuristics default on since they do nothing without IDs being configured */ |