summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epan/libwireshark.def1
-rw-r--r--epan/proto.c32
-rw-r--r--epan/proto.h15
-rw-r--r--gtk/expert_comp_table.c4
-rw-r--r--gtk/main.c5
-rw-r--r--gtk/menu.c8
-rw-r--r--print.c5
-rw-r--r--tap-protocolinfo.c3
8 files changed, 55 insertions, 18 deletions
diff --git a/epan/libwireshark.def b/epan/libwireshark.def
index 9b94071463..9f8664210e 100644
--- a/epan/libwireshark.def
+++ b/epan/libwireshark.def
@@ -483,6 +483,7 @@ process_reassembled_data
process_stat_cmd_arg
protocols_module DATA
proto_all_finfos
+proto_can_match_selected
proto_can_toggle_protocol
proto_construct_match_selected_string
proto_data DATA
diff --git a/epan/proto.c b/epan/proto.c
index 9746c5476f..ffc4227cbd 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -5078,8 +5078,8 @@ hfinfo_numeric_format(header_field_info *hfinfo)
* You do not need to [g_]free() this string since it will be automatically
* freed once the next packet is dissected.
*/
-gboolean
-proto_construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
+static gboolean
+construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
char **filter)
{
header_field_info *hfinfo;
@@ -5282,3 +5282,31 @@ proto_construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
return TRUE;
}
+
+/*
+ * Returns TRUE if we can do a "match selected" on the field, FALSE
+ * otherwise.
+ */
+gboolean
+proto_can_match_selected(field_info *finfo, epan_dissect_t *edt)
+{
+ return construct_match_selected_string(finfo, edt, NULL);
+}
+
+/* This function attempts to construct a "match selected" display filter
+ * string for the specified field; if it can do so, it returns a pointer
+ * to the string, otherwise it returns NULL.
+ *
+ * The string is allocated with packet lifetime scope.
+ * You do not need to [g_]free() this string since it will be automatically
+ * freed once the next packet is dissected.
+ */
+char*
+proto_construct_match_selected_string(field_info *finfo, epan_dissect_t *edt)
+{
+ char *filter;
+
+ if (!construct_match_selected_string(finfo, edt, &filter))
+ return NULL;
+ return filter;
+}
diff --git a/epan/proto.h b/epan/proto.h
index 78c1096843..361d5ecd01 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -1532,16 +1532,19 @@ hfinfo_bitwidth(header_field_info *hfinfo);
#include "epan.h"
-/** Check whether we can do a "match selected" on this field and, if
- requested to, return the filter that does so.
+/** Can we do a "match selected" on this field.
@param finfo field_info
@param edt epan dissecting
- @param filter if non-null, the display filter string is constructed and
- *filter is set to point to it
@return TRUE if we can do a "match selected" on the field, FALSE otherwise. */
extern gboolean
-proto_construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
- char **filter);
+proto_can_match_selected(field_info *finfo, epan_dissect_t *edt);
+
+/** Construct a "match selected" display filter string.
+ @param finfo field_info
+ @param edt epan dissecting
+ @return the display filter string */
+extern char*
+proto_construct_match_selected_string(field_info *finfo, epan_dissect_t *edt);
/** Find field from offset in tvb.
@param tree
diff --git a/gtk/expert_comp_table.c b/gtk/expert_comp_table.c
index 607baa7a38..24a9a826d6 100644
--- a/gtk/expert_comp_table.c
+++ b/gtk/expert_comp_table.c
@@ -750,7 +750,9 @@ init_error_table_row(error_equiv_table *err, const expert_info_t *expert_data)
/* If an expert item was passed then build the filter string */
if (expert_data->pitem) {
char *filter;
- if (proto_construct_match_selected_string(expert_data->pitem->finfo, NULL, &filter))
+
+ filter = proto_construct_match_selected_string(expert_data->pitem->finfo, NULL);
+ if (filter != NULL)
err->procedures[row].fvalue_value = g_strdup(filter);
}
/* Store the updated count of events */
diff --git a/gtk/main.c b/gtk/main.c
index e4d37fa9d4..d64fcf348f 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -309,8 +309,9 @@ match_selected_ptree_cb(GtkWidget *w, gpointer data, MATCH_SELECTED_E action)
char *filter;
if (cfile.finfo_selected) {
- if (proto_construct_match_selected_string(cfile.finfo_selected,
- cfile.edt, &filter))
+ filter = proto_construct_match_selected_string(cfile.finfo_selected,
+ cfile.edt);
+ if (filter != NULL)
match_selected_cb_do((data ? data : w), action, filter);
}
}
diff --git a/gtk/menu.c b/gtk/menu.c
index aa04707140..86e0e5a2b6 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -2430,13 +2430,13 @@ set_menus_for_selected_tree_row(capture_file *cf)
set_menu_sensitivity(tree_view_menu_factory,
"/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM);
set_menu_sensitivity(main_menu_factory, "/Analyze/Apply as Filter",
- proto_construct_match_selected_string(cf->finfo_selected, cf->edt, NULL));
+ proto_can_match_selected(cf->finfo_selected, cf->edt));
set_menu_sensitivity(tree_view_menu_factory, "/Apply as Filter",
- proto_construct_match_selected_string(cf->finfo_selected, cf->edt, NULL));
+ proto_can_match_selected(cf->finfo_selected, cf->edt));
set_menu_sensitivity(main_menu_factory, "/Analyze/Prepare a Filter",
- proto_construct_match_selected_string(cf->finfo_selected, cf->edt, NULL));
+ proto_can_match_selected(cf->finfo_selected, cf->edt));
set_menu_sensitivity(tree_view_menu_factory, "/Prepare a Filter",
- proto_construct_match_selected_string(cf->finfo_selected, cf->edt, NULL));
+ proto_can_match_selected(cf->finfo_selected, cf->edt));
set_menu_sensitivity(tree_view_menu_factory, "/Protocol Preferences...",
properties);
set_menu_sensitivity(main_menu_factory, "/View/Expand Subtrees", cf->finfo_selected->tree_type != -1);
diff --git a/print.c b/print.c
index ed5a3ba74d..7297c10daf 100644
--- a/print.c
+++ b/print.c
@@ -343,8 +343,9 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
default:
/* XXX - this is a hack until we can just call
* fvalue_to_string_repr() for *all* FT_* types. */
- if (proto_construct_match_selected_string(fi,
- pdata->edt, &dfilter_string)) {
+ dfilter_string = proto_construct_match_selected_string(fi,
+ pdata->edt);
+ if (dfilter_string != NULL) {
chop_len = strlen(fi->hfinfo->abbrev) + 4; /* for " == " */
/* XXX - Remove double-quotes. Again, once we
diff --git a/tap-protocolinfo.c b/tap-protocolinfo.c
index 0c9f8fbfc4..dfaea88099 100644
--- a/tap-protocolinfo.c
+++ b/tap-protocolinfo.c
@@ -76,7 +76,8 @@ protocolinfo_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt, const vo
}
for(i=0;i<gp->len;i++){
- if(proto_construct_match_selected_string(gp->pdata[i], NULL, &str)){
+ str=proto_construct_match_selected_string(gp->pdata[i], NULL);
+ if(str){
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",str);
}
}