diff options
author | Michael Mann <mmann78@netscape.net> | 2016-09-03 22:22:50 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-09-16 14:58:24 +0000 |
commit | 3120536012bc85361e2e5cd204bd4aa91fb67ff6 (patch) | |
tree | 40a44f24258a339540591cfdcd95f7d2b8237c95 /epan/dissectors/packet-tpkt.c | |
parent | d67c1db3f2b16185d7cff250e098f48d94883f0e (diff) |
Have TPKT support a TCP port range preference instead of having "subdissectors?" register their own.
There are a number of dissectors who are subdissectors of TPKT (and OSITP) that are
not called by TCP dissector directly, yet can possibly register a TCP port "on the
behalf" of TPKT. Just allow TPKT to support a range of ports to possibly include
these protocols.
Remove the preferences from these dissectors, but add backwards compatibility for
the preferences by hooking into set_prefs and have the preferences just hook into
Decode As functionality directly.
Change-Id: Ic1b4959d39607f2b6b20fa6508da8d87d04cf098
Reviewed-on: https://code.wireshark.org/review/17476
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-tpkt.c')
-rw-r--r-- | epan/dissectors/packet-tpkt.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/epan/dissectors/packet-tpkt.c b/epan/dissectors/packet-tpkt.c index 080340d9f1..964ed7263d 100644 --- a/epan/dissectors/packet-tpkt.c +++ b/epan/dissectors/packet-tpkt.c @@ -53,11 +53,12 @@ static gint ett_tpkt = -1; /* desegmentation of OSI over TPKT over TCP */ static gboolean tpkt_desegment = TRUE; -#define TCP_PORT_TPKT 102 - /* find the dissector for OSI TP (aka COTP) */ static dissector_handle_t osi_tp_handle; +#define DEFAULT_TPKT_PORT_RANGE "102" +static range_t *tpkt_tcp_port_range; + /* * Check whether this could be a TPKT-encapsulated PDU. * Returns -1 if it's not, and the PDU length from the TPKT header @@ -648,22 +649,42 @@ proto_register_tpkt(void) proto_register_subtree_array(ett, array_length(ett)); register_dissector("tpkt", dissect_tpkt, proto_tpkt); - tpkt_module = prefs_register_protocol(proto_tpkt, NULL); + tpkt_module = prefs_register_protocol(proto_tpkt, proto_reg_handoff_tpkt); prefs_register_bool_preference(tpkt_module, "desegment", "Reassemble TPKT messages spanning multiple TCP segments", "Whether the TPKT dissector should reassemble messages spanning multiple TCP segments. " "To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &tpkt_desegment); + + range_convert_str(&tpkt_tcp_port_range, DEFAULT_TPKT_PORT_RANGE, MAX_TCP_PORT); + + prefs_register_range_preference(tpkt_module, "tcp.ports", "TPKT TCP ports", + "TCP ports to be decoded as TPKT (default: " + DEFAULT_TPKT_PORT_RANGE ")", + &tpkt_tcp_port_range, MAX_TCP_PORT); } void proto_reg_handoff_tpkt(void) { - dissector_handle_t tpkt_handle; + static dissector_handle_t tpkt_handle; + static range_t *port_range; + static gboolean initialized = FALSE; + + if (!initialized) + { + osi_tp_handle = find_dissector("ositp"); + tpkt_handle = find_dissector("tpkt"); + initialized = TRUE; + } + else + { + dissector_delete_uint_range("tcp.port", port_range, tpkt_handle); + g_free(port_range); + } - osi_tp_handle = find_dissector("ositp"); - tpkt_handle = find_dissector("tpkt"); - dissector_add_uint("tcp.port", TCP_PORT_TPKT, tpkt_handle); + port_range = range_copy(tpkt_tcp_port_range); + dissector_add_uint_range("tcp.port", port_range, tpkt_handle); /* tpkt_ascii_handle = create_dissector_handle(dissect_ascii_tpkt, proto_tpkt); |