diff options
author | Michael Mann <mmann78@netscape.net> | 2016-10-07 16:25:01 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-10-08 02:44:53 +0000 |
commit | 268841f3e00b7cf0f16c81dd2b3b952172130b8b (patch) | |
tree | 359e01cf5eba83308760531888713fe0ff0bc10b /epan/dissectors/packet-forces.c | |
parent | 11d3224142c0531879fb8e415daf9639a4eace66 (diff) |
Combine Decode As and port preferences for tcp.port dissector table.
This patch introduces new APIs to allow dissectors to have a preference for
a (TCP) port, but the underlying data is actually part of Decode As functionality.
For now the APIs are intentionally separate from the regular APIs that register a
dissector within a dissector table. It may be possible to eventually combine the
two so that all dissectors that register with a dissector table have an opportunity
to "automatically" have a preference to adjust the "table value" through the
preferences dialog.
The tcp.port dissector table was used as the guinea pig. This will eventually be
expanded to other dissector tables as well (most notably UDP ports). Some
dissectors that "shared" a TCP/UDP port preference were also converted. It also
removed the need for some preference callback functions (mostly when the callback
function was the proto_reg_handoff function) so there is cleanup around that.
Dissectors that has a port preference whose default was 0 were switched to using
the dissector_add_for_decode_as_with_preference API rather than dissector_add_uint_with_preference
Also added comments for TCP ports used that aren't IANA registered.
Change-Id: I99604f95d426ad345f4b494598d94178b886eb67
Reviewed-on: https://code.wireshark.org/review/17724
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-forces.c')
-rw-r--r-- | epan/dissectors/packet-forces.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/epan/dissectors/packet-forces.c b/epan/dissectors/packet-forces.c index e9f129050a..fcadd6a0f5 100644 --- a/epan/dissectors/packet-forces.c +++ b/epan/dissectors/packet-forces.c @@ -145,7 +145,6 @@ static int hf_forces_unknown_tlv = -1; #define TCP_UDP_TML_FOCES_MESSAGE_OFFSET_TCP 2 /*TCP+UDP TML*/ -static guint forces_alternate_tcp_port = 0; static guint forces_alternate_udp_port = 0; /*SCTP TML*/ static guint forces_alternate_sctp_high_prio_channel_port = 0; @@ -833,11 +832,6 @@ proto_register_forces(void) forces_module = prefs_register_protocol(proto_forces,proto_reg_handoff_forces); - prefs_register_uint_preference(forces_module, "tcp_alternate_port", - "TCP port", - "Decode packets on this TCP port as ForCES", - 10, &forces_alternate_tcp_port); - prefs_register_uint_preference(forces_module, "udp_alternate_port", "UDP port", "Decode packets on this UDP port as ForCES", @@ -864,7 +858,6 @@ proto_reg_handoff_forces(void) { static gboolean inited = FALSE; - static guint alternate_tcp_port = 0; /* 3000 */ static guint alternate_udp_port = 0; static guint alternate_sctp_high_prio_channel_port = 0; /* 6700 */ static guint alternate_sctp_med_prio_channel_port = 0; @@ -876,15 +869,12 @@ proto_reg_handoff_forces(void) forces_handle_tcp = create_dissector_handle(dissect_forces_tcp, proto_forces); forces_handle = create_dissector_handle(dissect_forces_not_tcp, proto_forces); ip_handle = find_dissector_add_dependency("ip", proto_forces); + /* Register TCP port for dissection */ + dissector_add_for_decode_as_with_preference("tcp.port", forces_handle_tcp); + inited = TRUE; } - /* Register TCP port for dissection */ - if ((alternate_tcp_port != 0) && (alternate_tcp_port != forces_alternate_tcp_port)) - dissector_delete_uint("tcp.port", alternate_tcp_port, forces_handle_tcp); - if ((forces_alternate_tcp_port != 0) && (alternate_tcp_port != forces_alternate_tcp_port)) - dissector_add_uint("tcp.port", forces_alternate_tcp_port, forces_handle_tcp); - alternate_tcp_port = forces_alternate_tcp_port; /* Register UDP port for dissection */ if ((alternate_udp_port != 0) && (alternate_udp_port != forces_alternate_udp_port)) |