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 #include +#ifdef HAVE_LUA +#include +#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,