aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-dcm.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-10-07 16:25:01 -0400
committerMichael Mann <mmann78@netscape.net>2016-10-08 02:44:53 +0000
commit268841f3e00b7cf0f16c81dd2b3b952172130b8b (patch)
tree359e01cf5eba83308760531888713fe0ff0bc10b /epan/dissectors/packet-dcm.c
parent11d3224142c0531879fb8e415daf9639a4eace66 (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-dcm.c')
-rw-r--r--epan/dissectors/packet-dcm.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/epan/dissectors/packet-dcm.c b/epan/dissectors/packet-dcm.c
index 587d36e9c3..d38ebe11e1 100644
--- a/epan/dissectors/packet-dcm.c
+++ b/epan/dissectors/packet-dcm.c
@@ -239,9 +239,6 @@ void proto_reg_handoff_dcm(void);
#define MAX_BUF_LEN 1024 /* Used for string allocations */
-static range_t *global_dcm_tcp_range = NULL;
-static range_t *global_dcm_tcp_range_backup = NULL; /* needed to deregister */
-
static gboolean global_dcm_export_header = TRUE;
static guint global_dcm_export_minsize = 4096; /* Filter small objects in export */
@@ -7071,25 +7068,6 @@ dissect_dcm_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 off
return offset; /* return the number of processed bytes */
}
-static void
-dcm_apply_settings(void)
-{
- /* deregister first */
- dissector_delete_uint_range("tcp.port", global_dcm_tcp_range_backup, dcm_handle);
- g_free(global_dcm_tcp_range_backup);
-
- /* Register 'static' tcp port range specified in properties
- Statically defined ports take precedence over a heuristic one,
- I.e., if an foreign protocol claims a port, where dicom is running on
- We would never be called, by just having the heuristic registration
- */
-
- dissector_add_uint_range("tcp.port", global_dcm_tcp_range, dcm_handle);
-
- /* remember settings for next time */
- global_dcm_tcp_range_backup = range_copy(global_dcm_tcp_range);
-}
-
/* Register the protocol with Wireshark */
void
@@ -7295,12 +7273,7 @@ proto_register_dcm(void)
/* Allow other dissectors to find this one by name. */
dcm_handle = register_dissector("dicom", dissect_dcm_static, proto_dcm);
- dcm_module = prefs_register_protocol(proto_dcm, dcm_apply_settings);
-
- range_convert_str(&global_dcm_tcp_range, DICOM_DEFAULT_RANGE, 65535);
- global_dcm_tcp_range_backup = range_empty();
- prefs_register_range_preference(dcm_module, "tcp.port",
- "DICOM Ports", "DICOM Ports range", &global_dcm_tcp_range, 65535);
+ dcm_module = prefs_register_protocol(proto_dcm, NULL);
prefs_register_obsolete_preference(dcm_module, "heuristic");
@@ -7352,8 +7325,12 @@ proto_register_dcm(void)
void
proto_reg_handoff_dcm(void)
{
-
- dcm_apply_settings(); /* Register static ports */
+ /* Register 'static' tcp port range specified in properties
+ Statically defined ports take precedence over a heuristic one,
+ I.e., if an foreign protocol claims a port, where dicom is running on
+ We would never be called, by just having the heuristic registration
+ */
+ dissector_add_uint_range_with_preference("tcp.port", DICOM_DEFAULT_RANGE, dcm_handle);
heur_dissector_add("tcp", dissect_dcm_heuristic, "DICOM over TCP", "dicom_tcp", proto_dcm, HEURISTIC_DISABLE);
}