aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-mpls-psc.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-mpls-psc.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-mpls-psc.c')
-rw-r--r--epan/dissectors/packet-mpls-psc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/epan/dissectors/packet-mpls-psc.c b/epan/dissectors/packet-mpls-psc.c
index 71f25c62cc..bd05a1b4d4 100644
--- a/epan/dissectors/packet-mpls-psc.c
+++ b/epan/dissectors/packet-mpls-psc.c
@@ -22,6 +22,8 @@
void proto_register_mpls_psc(void);
void proto_reg_handoff_mpls_psc(void);
+static dissector_handle_t mpls_psc_handle;
+
static gint proto_mpls_psc = -1;
static gint ett_mpls_psc = -1;
@@ -222,14 +224,13 @@ proto_register_mpls_psc(void)
proto_register_field_array(proto_mpls_psc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+
+ mpls_psc_handle = register_dissector("mpls_psc", dissect_mpls_psc, proto_mpls_psc);
}
void
proto_reg_handoff_mpls_psc(void)
{
- dissector_handle_t mpls_psc_handle;
-
- mpls_psc_handle = create_dissector_handle( dissect_mpls_psc, proto_mpls_psc );
dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_PSC, mpls_psc_handle);
}