aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-06-23 12:45:32 -0700
committerGuy Harris <guy@alum.mit.edu>2016-06-23 19:45:51 +0000
commita5e9e7e7aed75cfec58ff33fc488baf6236c92c6 (patch)
tree243b50849b0800c4ba5e055c1ddf4fc23f7611ad /epan
parentdd5f3c96c300688cb996e52c163fb3f5a614706c (diff)
Fix "disable this protocol by default".
Allow a dissector to mark its protocol as "disabled by default", which means that the "enable all protocols" routine won't enable it. This is necessary in order to allow the disabling of protocols not to be unintentionally changed due to profile changes; see bug 9826. Change-Id: I3947f794c21350b70a8de06899cfc7715b77f90f Ping-Bug: 9826 Reviewed-on: https://code.wireshark.org/review/16109 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-prp.c2
-rw-r--r--epan/proto.c31
-rw-r--r--epan/proto.h4
3 files changed, 28 insertions, 9 deletions
diff --git a/epan/dissectors/packet-prp.c b/epan/dissectors/packet-prp.c
index a804e06909..c0781269a8 100644
--- a/epan/dissectors/packet-prp.c
+++ b/epan/dissectors/packet-prp.c
@@ -272,6 +272,8 @@ void proto_reg_handoff_prp(void)
prefs_initialized = TRUE;
}
+ if (!prp_enable_dissector)
+ proto_disable_by_default(proto_prp);
proto_set_decoding(proto_prp, prp_enable_dissector);
}
diff --git a/epan/proto.c b/epan/proto.c
index de5924ef8d..07c8288f43 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -300,14 +300,15 @@ int hf_text_only = -1;
/* Structure for information about a protocol */
struct _protocol {
- const char *name; /* long description */
- const char *short_name; /* short description */
- const char *filter_name; /* name of this protocol in filters */
- GPtrArray *fields; /* fields for this protocol */
- int proto_id; /* field ID for this protocol */
- gboolean is_enabled; /* TRUE if protocol is enabled */
- gboolean can_toggle; /* TRUE if is_enabled can be changed */
- GList *heur_list; /* Heuristic dissectors associated with this protocol */
+ const char *name; /* long description */
+ const char *short_name; /* short description */
+ const char *filter_name; /* name of this protocol in filters */
+ GPtrArray *fields; /* fields for this protocol */
+ int proto_id; /* field ID for this protocol */
+ gboolean is_enabled; /* TRUE if protocol is enabled */
+ gboolean enabled_by_default; /* TRUE if protocol is enabled by default */
+ gboolean can_toggle; /* TRUE if is_enabled can be changed */
+ GList *heur_list; /* Heuristic dissectors associated with this protocol */
};
/* List of all protocols */
@@ -5700,6 +5701,7 @@ proto_register_protocol(const char *name, const char *short_name,
protocol->filter_name = filter_name;
protocol->fields = g_ptr_array_new();
protocol->is_enabled = TRUE; /* protocol is enabled by default */
+ protocol->enabled_by_default = TRUE; /* see previous comment */
protocol->can_toggle = TRUE;
protocol->heur_list = NULL;
/* list will be sorted later by name, when all protocols completed registering */
@@ -6045,6 +6047,17 @@ proto_can_toggle_protocol(const int proto_id)
}
void
+proto_disable_by_default(const int proto_id)
+{
+ protocol_t *protocol;
+
+ protocol = find_protocol_by_id(proto_id);
+ DISSECTOR_ASSERT(protocol->can_toggle);
+ protocol->is_enabled = FALSE;
+ protocol->enabled_by_default = FALSE;
+}
+
+void
proto_set_decoding(const int proto_id, const gboolean enabled)
{
protocol_t *protocol;
@@ -6065,7 +6078,7 @@ proto_enable_all(void)
while (list_item) {
protocol = (protocol_t *)list_item->data;
- if (protocol->can_toggle)
+ if (protocol->can_toggle && protocol->enabled_by_default)
protocol->is_enabled = TRUE;
list_item = g_list_next(list_item);
}
diff --git a/epan/proto.h b/epan/proto.h
index 56f78350c1..b48ecadeb7 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -2285,6 +2285,10 @@ WS_DLL_PUBLIC void proto_get_frame_protocols(const wmem_list_t *layers,
*/
WS_DLL_PUBLIC gboolean proto_is_frame_protocol(const wmem_list_t *layers, const char* proto_name);
+/** Mark protocol with the given item number as disabled by default.
+ @param proto_id protocol id (0-indexed) */
+WS_DLL_PUBLIC void proto_disable_by_default(const int proto_id);
+
/** Enable / Disable protocol of the given item number.
@param proto_id protocol id (0-indexed)
@param enabled enable / disable the protocol */