aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-12-24 21:00:36 -0500
committerMichael Mann <mmann78@netscape.net>2016-12-25 15:04:21 +0000
commit96d15102f56900acdac587b6407eb4c6545721de (patch)
treecf25c2b4518ad5e326f3b5a8d3e0e9fec4e0f7a9 /epan
parent4270b48b19439cfed0f480f9ce29a34003e45e97 (diff)
Remove individual post-dissect enable preferences.
Use Analyze -> Enabled Protocol dialog interface. Added support for backwards compatibility of preference. Change-Id: I32b3fce9d18083d9324197e3fd7ddc7eb888d1fb Reviewed-on: https://code.wireshark.org/review/19422 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-prp.c48
-rw-r--r--epan/dissectors/packet-snort.c21
-rw-r--r--epan/prefs.c2
3 files changed, 23 insertions, 48 deletions
diff --git a/epan/dissectors/packet-prp.c b/epan/dissectors/packet-prp.c
index 5cf0f9c3d5..5856fd0fc5 100644
--- a/epan/dissectors/packet-prp.c
+++ b/epan/dissectors/packet-prp.c
@@ -60,17 +60,6 @@ static int hf_prp_redundancy_control_trailer_version = -1;
static gint ett_prp_redundancy_control_trailer = -1;
-/* Post dissectors (such as the trailer dissector for this protocol)
- * get called for every single frame anyone loads into Wireshark.
- * Since this protocol is not of general interest we disable this
- * protocol by default.
- *
- * This is done separately from the disabled protocols list mainly so
- * we can disable it by default. XXX Maybe there's a better way.
- */
-static gboolean prp_enable_dissector = FALSE;
-
-
/* Code to actually dissect the packets */
static int
dissect_prp_redundancy_control_trailer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
@@ -250,38 +239,29 @@ void proto_register_prp(void)
};
module_t *prp_module;
+ dissector_handle_t prp_handle;
/* Register the protocol name and description */
- proto_prp = proto_register_protocol("Parallel Redundancy Protocol (IEC62439 Part 3)",
- "PRP", "prp");
- prp_module = prefs_register_protocol(proto_prp, proto_reg_handoff_prp);
+ proto_prp = proto_register_protocol("Parallel Redundancy Protocol (IEC62439 Part 3)", "PRP", "prp");
+
+ /* Post dissectors (such as the trailer dissector for this protocol)
+ * get called for every single frame anyone loads into Wireshark.
+ * Since this protocol is not of general interest we disable this
+ * protocol by default.
+ */
+ proto_disable_by_default(proto_prp);
+
+ prp_module = prefs_register_protocol(proto_prp, NULL);
- prefs_register_bool_preference(prp_module, "enable", "Enable dissector",
- "Enable this dissector (default is false)",
- &prp_enable_dissector);
+ prefs_register_obsolete_preference(prp_module, "enable");
/* Required function calls to register the header fields and subtree used */
proto_register_field_array(proto_prp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
-}
-
-void proto_reg_handoff_prp(void)
-{
- static gboolean prefs_initialized = FALSE;
-
- if (!prefs_initialized) {
- dissector_handle_t prp_redundancy_control_trailer_handle;
-
- prp_redundancy_control_trailer_handle = create_dissector_handle(dissect_prp_redundancy_control_trailer, proto_prp);
- register_postdissector(prp_redundancy_control_trailer_handle);
-
- prefs_initialized = TRUE;
- }
+ prp_handle = register_dissector("prp", dissect_prp_redundancy_control_trailer, proto_prp);
- if (!prp_enable_dissector)
- proto_disable_by_default(proto_prp);
- proto_set_decoding(proto_prp, prp_enable_dissector);
+ register_postdissector(prp_handle);
}
/*
diff --git a/epan/dissectors/packet-snort.c b/epan/dissectors/packet-snort.c
index 6a57169d2e..ee2713e0e0 100644
--- a/epan/dissectors/packet-snort.c
+++ b/epan/dissectors/packet-snort.c
@@ -112,9 +112,6 @@ static expert_field ei_snort_content_not_matched = EI_INIT;
/*****************************************/
/* Preferences */
-/* Use explicit preference as want to disable this dissector by default */
-static gboolean snort_enable_dissector = FALSE;
-
/* Where to look for alerts. */
enum alerts_source {
FromRunningSnort,
@@ -713,7 +710,7 @@ static void snort_show_alert(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo
}
/* Show Port vars */
for (n=0; n < rule->relevant_vars.num_port_vars; n++) {
- ti = proto_tree_add_none_format(rule_tree, hf_snort_rule_ip_var, tvb, 0, 0, "Port Var: ($%s -> %s)",
+ ti = proto_tree_add_none_format(rule_tree, hf_snort_rule_port_var, tvb, 0, 0, "Port Var: ($%s -> %s)",
rule->relevant_vars.port_vars[n].name,
rule->relevant_vars.port_vars[n].value);
PROTO_ITEM_SET_GENERATED(ti);
@@ -1082,9 +1079,8 @@ static void snort_start(void)
};
/* Nothing to do if not enabled, but registered init function gets called anyway */
- if (!snort_enable_dissector) {
+ if (!proto_is_protocol_enabled(find_protocol_by_id(proto_snort)))
return;
- }
/* Create tree mapping packet_number -> Alerts_t*. It will get recreated when packet list is reloaded */
current_session.alerts_tree = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
@@ -1199,9 +1195,6 @@ proto_reg_handoff_snort(void)
* work as a non-root user (couldn't read stdin)
* TODO: could run snort just to get the version number and check the config file is readable?
* TODO: could make snort config parsing less forgiving and use that as a test? */
-
- /* Our own preference for turning off completely. Don't want to run at all unless turned on */
- proto_set_decoding(proto_snort, snort_enable_dissector);
}
void
@@ -1312,6 +1305,9 @@ proto_register_snort(void)
proto_snort = proto_register_protocol("Snort Alerts", "Snort", "snort");
+ /* Disable snort by default */
+ proto_disable_by_default(proto_snort);
+
proto_register_field_array(proto_snort, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@@ -1319,12 +1315,9 @@ proto_register_snort(void)
expert_snort = expert_register_protocol(proto_snort);
expert_register_field_array(expert_snort, ei, array_length(ei));
- snort_module = prefs_register_protocol(proto_snort, proto_reg_handoff_snort);
+ snort_module = prefs_register_protocol(proto_snort, NULL);
- prefs_register_bool_preference(snort_module, "enable_snort_dissector",
- "Enable the snort dissector",
- "Whether or not the snort post-dissector should run.",
- &snort_enable_dissector);
+ prefs_register_obsolete_preference(snort_module, "enable_snort_dissector");
prefs_register_enum_preference(snort_module, "alerts_source",
"Source of Snort alerts",
diff --git a/epan/prefs.c b/epan/prefs.c
index 34fe245864..f0dd59bc7a 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -4132,6 +4132,8 @@ deprecated_enable_dissector_pref(gchar *pref_name, const gchar *value)
struct dissector_pref_name dissector_prefs[] = {
{"transum.tsumenabled", "TRANSUM"},
+ {"snort.enable_snort_dissector", "Snort"},
+ {"prp.enable", "PRP"},
};
unsigned int i;