summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2016-02-03 23:10:40 +0100
committerAnders Broman <a.broman58@gmail.com>2016-02-05 05:35:02 +0000
commitcc679ca5ce9af9fb0dc9afe360d12654f6b4027a (patch)
treee68fdf9627cfbfbb4a827721d7a2db0d1f2cf421
parent4c144c5d8c4c3f289a8b89a19bb9843cf9584d0e (diff)
downloadwireshark-cc679ca5ce9af9fb0dc9afe360d12654f6b4027a.tar.gz
Qt: Add check for field extractors
The proto tree is needed in several cases when using Lua field extractors, because they fetch values from the tree. Without a valid field extractor a Lua plugin may misbehave and display wrong column info. This fixes column issues when: - Calling resetColumns() in Qt. This involves adding a display filter, change time display format, change name resolution and other changes in UI which requires column updates. - Print summary lines. - Export as CSV and PSML. Change-Id: Ieed6f8578cdf2759f1f836cd8413a4529b7bbd80 Reviewed-on: https://code.wireshark.org/review/13708 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--debian/libwireshark0.symbols1
-rw-r--r--epan/column-utils.c14
-rw-r--r--epan/column-utils.h5
-rw-r--r--epan/dfilter/dfilter.c6
-rw-r--r--epan/dfilter/dfilter.h4
-rw-r--r--epan/wslua/wslua.h1
-rw-r--r--epan/wslua/wslua_field.c5
-rw-r--r--file.c10
-rw-r--r--ui/qt/packet_list_record.cpp5
9 files changed, 44 insertions, 7 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols
index 6b3803f161..3f482aef29 100644
--- a/debian/libwireshark0.symbols
+++ b/debian/libwireshark0.symbols
@@ -768,6 +768,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
has_heur_dissector_list@Base 1.12.0~rc1
have_custom_cols@Base 1.9.1
have_filtering_tap_listeners@Base 1.9.1
+ have_field_extractors@Base 2.0.2
have_tap_listener@Base 1.12.0~rc1
heur_dissector_add@Base 1.9.1
heur_dissector_delete@Base 1.9.1
diff --git a/epan/column-utils.c b/epan/column-utils.c
index ea932034b9..846c177c6b 100644
--- a/epan/column-utils.c
+++ b/epan/column-utils.c
@@ -43,6 +43,10 @@
#include <epan/dfilter/dfilter.h>
#include <wsutil/utf8_entities.h>
+#ifdef HAVE_LUA
+#include <epan/wslua/wslua.h>
+#endif
+
/* Allocate all the data structures for constructing column data, given
the number of columns. */
void
@@ -292,6 +296,16 @@ have_custom_cols(column_info *cinfo)
return HAVE_CUSTOM_COLS(cinfo);
}
+gboolean
+have_field_extractors(void)
+{
+#ifdef HAVE_LUA
+ return wslua_has_field_extractors();
+#else
+ return FALSE;
+#endif
+}
+
/* search in edt tree custom fields */
void col_custom_set_edt(epan_dissect_t *edt, column_info *cinfo)
{
diff --git a/epan/column-utils.h b/epan/column-utils.h
index 9e2bf3cbc2..c51397a008 100644
--- a/epan/column-utils.h
+++ b/epan/column-utils.h
@@ -241,6 +241,11 @@ void col_custom_prime_edt(struct epan_dissect *edt, column_info *cinfo);
/** For internal Wireshark use only. Not to be called from dissectors. */
WS_DLL_PUBLIC
gboolean have_custom_cols(column_info *cinfo);
+
+/** For internal Wireshark use only. Not to be called from dissectors. */
+WS_DLL_PUBLIC
+gboolean have_field_extractors(void);
+
/** For internal Wireshark use only. Not to be called from dissectors. */
WS_DLL_PUBLIC
gboolean col_has_time_fmt(column_info *cinfo, const gint col);
diff --git a/epan/dfilter/dfilter.c b/epan/dfilter/dfilter.c
index a843bbe936..df24b1ced7 100644
--- a/epan/dfilter/dfilter.c
+++ b/epan/dfilter/dfilter.c
@@ -415,6 +415,12 @@ dfilter_prime_proto_tree(const dfilter_t *df, proto_tree *tree)
}
}
+gboolean
+dfilter_has_interesting_fields(const dfilter_t *df)
+{
+ return (df->num_interesting_fields > 0);
+}
+
GPtrArray *
dfilter_deprecated_tokens(dfilter_t *df) {
if (df->deprecated && df->deprecated->len > 0) {
diff --git a/epan/dfilter/dfilter.h b/epan/dfilter/dfilter.h
index 1bbf907ec4..0b24b3d62b 100644
--- a/epan/dfilter/dfilter.h
+++ b/epan/dfilter/dfilter.h
@@ -80,6 +80,10 @@ dfilter_apply(dfilter_t *df, proto_tree *tree);
void
dfilter_prime_proto_tree(const dfilter_t *df, proto_tree *tree);
+/* Check if dfilter has interesting fields */
+gboolean
+dfilter_has_interesting_fields(const dfilter_t *df);
+
WS_DLL_PUBLIC
GPtrArray *
dfilter_deprecated_tokens(dfilter_t *df);
diff --git a/epan/wslua/wslua.h b/epan/wslua/wslua.h
index 8d2c882375..75b67967ed 100644
--- a/epan/wslua/wslua.h
+++ b/epan/wslua/wslua.h
@@ -710,6 +710,7 @@ extern void wslua_prefs_changed(void);
extern void proto_register_lua(void);
extern GString* lua_register_all_taps(void);
extern void wslua_prime_dfilter(epan_dissect_t *edt);
+extern gboolean wslua_has_field_extractors(void);
extern void lua_prime_all_fields(proto_tree* tree);
extern int Proto_commit(lua_State* L);
diff --git a/epan/wslua/wslua_field.c b/epan/wslua/wslua_field.c
index 5847ba97aa..fc1a46f62a 100644
--- a/epan/wslua/wslua_field.c
+++ b/epan/wslua/wslua_field.c
@@ -551,6 +551,11 @@ void wslua_prime_dfilter(epan_dissect_t *edt) {
}
}
+/* Check if we have any registered field extractors. */
+gboolean wslua_has_field_extractors(void) {
+ return (wslua_dfilter && dfilter_has_interesting_fields(wslua_dfilter));
+}
+
/*
* field extractor registration is tricky, In order to allow
* the user to define them in the body of the script we will
diff --git a/file.c b/file.c
index db1f7194cc..cda78b19ed 100644
--- a/file.c
+++ b/file.c
@@ -2469,7 +2469,7 @@ cf_print_packets(capture_file *cf, print_args_t *print_args)
proto_tree_needed =
callback_args.print_args->print_dissections != print_dissections_none ||
callback_args.print_args->print_hex ||
- have_custom_cols(&cf->cinfo);
+ have_custom_cols(&cf->cinfo) || have_field_extractors();
epan_dissect_init(&callback_args.edt, cf->epan, proto_tree_needed, proto_tree_needed);
/* Iterate through the list of packets, printing the packets we were
@@ -2641,8 +2641,8 @@ cf_write_psml_packets(capture_file *cf, print_args_t *print_args)
callback_args.fh = fh;
/* Fill in the column information, only create the protocol tree
- if having custom columns. */
- proto_tree_needed = have_custom_cols(&cf->cinfo);
+ if having custom columns or field extractors. */
+ proto_tree_needed = have_custom_cols(&cf->cinfo) || have_field_extractors();
epan_dissect_init(&callback_args.edt, cf->epan, proto_tree_needed, proto_tree_needed);
/* Iterate through the list of packets, printing the packets we were
@@ -2721,8 +2721,8 @@ cf_write_csv_packets(capture_file *cf, print_args_t *print_args)
callback_args.fh = fh;
- /* only create the protocol tree if having custom columns. */
- proto_tree_needed = have_custom_cols(&cf->cinfo);
+ /* only create the protocol tree if having custom columns or field extractors. */
+ proto_tree_needed = have_custom_cols(&cf->cinfo) || have_field_extractors();
epan_dissect_init(&callback_args.edt, cf->epan, proto_tree_needed, proto_tree_needed);
/* Iterate through the list of packets, printing the packets we were
diff --git a/ui/qt/packet_list_record.cpp b/ui/qt/packet_list_record.cpp
index 8fab6f03f9..7317b9bae9 100644
--- a/ui/qt/packet_list_record.cpp
+++ b/ui/qt/packet_list_record.cpp
@@ -133,8 +133,9 @@ void PacketListRecord::dissect(capture_file *cap_file, bool dissect_color)
return; /* error reading the record */
}
- create_proto_tree = (dissect_color && color_filters_used()) ||
- (dissect_columns && have_custom_cols(cinfo));
+ create_proto_tree = ((dissect_color && color_filters_used()) ||
+ (dissect_columns && (have_custom_cols(cinfo) ||
+ have_field_extractors())));
epan_dissect_init(&edt, cap_file->epan,
create_proto_tree,