forked from osmocom/wireshark
Recompile dfilter for all tap listeners when fields changed
When fields have changed the compiled display filter may be invalid or need a recompile to be valid. Filters which are not valid after a recompile is set to a filter matching no packets (frame.number == 0) to indicate that this does no longer match anything. We should probably have a better filter matching no packet for this purpose. Change-Id: Id27efa9f46e77e20df50d7366f26d5cada186f93 Reviewed-on: https://code.wireshark.org/review/10123 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
parent
b755a6687b
commit
fa40025a7e
30
epan/tap.c
30
epan/tap.c
|
@ -93,6 +93,7 @@ typedef struct _tap_listener_t {
|
||||||
int tap_id;
|
int tap_id;
|
||||||
gboolean needs_redraw;
|
gboolean needs_redraw;
|
||||||
guint flags;
|
guint flags;
|
||||||
|
gchar *fstring;
|
||||||
dfilter_t *code;
|
dfilter_t *code;
|
||||||
void *tapdata;
|
void *tapdata;
|
||||||
tap_reset_cb reset;
|
tap_reset_cb reset;
|
||||||
|
@ -529,6 +530,7 @@ register_tap_listener(const char *tapname, void *tapdata, const char *fstring,
|
||||||
return error_string;
|
return error_string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tl->fstring=g_strdup(fstring);
|
||||||
|
|
||||||
tl->tap_id=tap_id;
|
tl->tap_id=tap_id;
|
||||||
tl->tapdata=tapdata;
|
tl->tapdata=tapdata;
|
||||||
|
@ -573,8 +575,10 @@ set_tap_dfilter(void *tapdata, const char *fstring)
|
||||||
tl->code=NULL;
|
tl->code=NULL;
|
||||||
}
|
}
|
||||||
tl->needs_redraw=TRUE;
|
tl->needs_redraw=TRUE;
|
||||||
|
g_free(tl->fstring);
|
||||||
if(fstring){
|
if(fstring){
|
||||||
if(!dfilter_compile(fstring, &tl->code, &err_msg)){
|
if(!dfilter_compile(fstring, &tl->code, &err_msg)){
|
||||||
|
tl->fstring=NULL;
|
||||||
error_string = g_string_new("");
|
error_string = g_string_new("");
|
||||||
g_string_printf(error_string,
|
g_string_printf(error_string,
|
||||||
"Filter \"%s\" is invalid - %s",
|
"Filter \"%s\" is invalid - %s",
|
||||||
|
@ -583,11 +587,36 @@ set_tap_dfilter(void *tapdata, const char *fstring)
|
||||||
return error_string;
|
return error_string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tl->fstring=g_strdup(fstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* this function recompiles dfilter for all registered tap listeners
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
tap_listeners_dfilter_recompile(void)
|
||||||
|
{
|
||||||
|
tap_listener_t *tl;
|
||||||
|
gchar *err_msg;
|
||||||
|
|
||||||
|
for(tl=(tap_listener_t *)tap_listener_queue;tl;tl=tl->next){
|
||||||
|
if(tl->code){
|
||||||
|
dfilter_free(tl->code);
|
||||||
|
tl->code=NULL;
|
||||||
|
}
|
||||||
|
tl->needs_redraw=TRUE;
|
||||||
|
if(tl->fstring){
|
||||||
|
if(!dfilter_compile(tl->fstring, &tl->code, &err_msg)){
|
||||||
|
g_free(err_msg);
|
||||||
|
/* Not valid, make a dfilter matching no packets */
|
||||||
|
dfilter_compile("frame.number == 0", &tl->code, &err_msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* this function removes a tap listener
|
/* this function removes a tap listener
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
|
@ -617,6 +646,7 @@ remove_tap_listener(void *tapdata)
|
||||||
if(tl->code){
|
if(tl->code){
|
||||||
dfilter_free(tl->code);
|
dfilter_free(tl->code);
|
||||||
}
|
}
|
||||||
|
g_free(tl->fstring);
|
||||||
g_free(tl);
|
g_free(tl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,9 @@ WS_DLL_PUBLIC GString *register_tap_listener(const char *tapname, void *tapdata,
|
||||||
/** This function sets a new dfilter to a tap listener */
|
/** This function sets a new dfilter to a tap listener */
|
||||||
WS_DLL_PUBLIC GString *set_tap_dfilter(void *tapdata, const char *fstring);
|
WS_DLL_PUBLIC GString *set_tap_dfilter(void *tapdata, const char *fstring);
|
||||||
|
|
||||||
|
/** This function recompiles dfilter for all registered tap listeners */
|
||||||
|
WS_DLL_PUBLIC void tap_listeners_dfilter_recompile(void);
|
||||||
|
|
||||||
/** this function removes a tap listener */
|
/** this function removes a tap listener */
|
||||||
WS_DLL_PUBLIC void remove_tap_listener(void *tapdata);
|
WS_DLL_PUBLIC void remove_tap_listener(void *tapdata);
|
||||||
|
|
||||||
|
|
|
@ -1308,6 +1308,7 @@ void MainWindow::redissectPackets()
|
||||||
void MainWindow::fieldsChanged()
|
void MainWindow::fieldsChanged()
|
||||||
{
|
{
|
||||||
color_filters_reload();
|
color_filters_reload();
|
||||||
|
tap_listeners_dfilter_recompile();
|
||||||
|
|
||||||
if (!df_combo_box_->checkDisplayFilter()) {
|
if (!df_combo_box_->checkDisplayFilter()) {
|
||||||
g_free(CaptureFile::globalCapFile()->dfilter);
|
g_free(CaptureFile::globalCapFile()->dfilter);
|
||||||
|
|
Loading…
Reference in New Issue