forked from osmocom/wireshark
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>
This commit is contained in:
parent
4c144c5d8c
commit
cc679ca5ce
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
10
file.c
10
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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue