aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-j1939.c
diff options
context:
space:
mode:
authorDavid Perry <boolean263@protonmail.com>2023-06-20 13:59:45 -0400
committerAndersBroman <a.broman58@gmail.com>2023-06-21 15:09:54 +0000
commitfacff6706764da354e215a471960a065e85edf59 (patch)
tree85a36f40f2ef28f3e542500dfb9f12cd161bb2ee /epan/dissectors/packet-j1939.c
parent7e07c29b09ff7333241945a012d453779ca43963 (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-j*` to `packet-o*`. 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-j1939.c')
-rw-r--r--epan/dissectors/packet-j1939.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/epan/dissectors/packet-j1939.c b/epan/dissectors/packet-j1939.c
index d152782ba4..8e27dfe893 100644
--- a/epan/dissectors/packet-j1939.c
+++ b/epan/dissectors/packet-j1939.c
@@ -22,6 +22,8 @@
void proto_register_j1939(void);
void proto_reg_handoff_j1939(void);
+static dissector_handle_t j1939_handle;
+
static int proto_j1939 = -1;
static int hf_j1939_can_id = -1;
@@ -341,14 +343,13 @@ void proto_register_j1939(void)
subdissector_pgn_table = register_dissector_table("j1939.pgn", "PGN Handle", proto_j1939, FT_UINT32, BASE_DEC);
j1939_address_type = address_type_dissector_register("AT_J1939", "J1939 Address", J1939_addr_to_str, J1939_addr_str_len, NULL, J1939_col_filter_str, J1939_addr_len, NULL, NULL);
+
+ j1939_handle = register_dissector("j1939", dissect_j1939, proto_j1939 );
}
void
proto_reg_handoff_j1939(void)
{
- dissector_handle_t j1939_handle;
-
- j1939_handle = create_dissector_handle( dissect_j1939, proto_j1939 );
dissector_add_for_decode_as("can.subdissector", j1939_handle );
}