forked from osmocom/wireshark
Add the display filter macros dialog.
Add some missing functionality to UatDialog. Remove what appears to be unused dfilter macro code. Change-Id: I8a8d6358523f24d5ddfe953d7741fe9af25d98eb Reviewed-on: https://code.wireshark.org/review/10187 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
97014f6d6b
commit
ee80be6dac
|
@ -244,7 +244,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
dfilter_dump@Base 1.9.1
|
||||
dfilter_free@Base 1.9.1
|
||||
dfilter_macro_build_ftv_cache@Base 1.9.1
|
||||
dfilter_macro_foreach@Base 1.9.1
|
||||
dfilter_macro_get_uat@Base 1.9.1
|
||||
disable_name_resolution@Base 1.99.9
|
||||
display_epoch_time@Base 1.9.1
|
||||
|
|
|
@ -90,62 +90,6 @@ void dfilter_macro_build_ftv_cache(void* tree_root) {
|
|||
proto_tree_traverse_post_order((proto_tree *)tree_root, fvt_cache_cb, NULL);
|
||||
}
|
||||
|
||||
void dfilter_macro_foreach(dfilter_macro_cb_t cb, void* data) {
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < num_macros; i++) {
|
||||
cb(&(macros[i]),data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void macro_fprint(dfilter_macro_t* m, void* ud) {
|
||||
FILE* f = (FILE*)ud;
|
||||
|
||||
fprintf(f,"%s\t%s\n",m->name,m->text);
|
||||
}
|
||||
|
||||
void dfilter_macro_save(const gchar* filename, gchar** error) {
|
||||
FILE* f = ws_fopen(filename,"w");
|
||||
|
||||
if (!f) {
|
||||
if (error != NULL)
|
||||
*error = g_strdup_printf("Could not open file: '%s', error: %s\n", filename, g_strerror(errno) );
|
||||
return;
|
||||
}
|
||||
|
||||
dfilter_macro_foreach(macro_fprint, f);
|
||||
|
||||
fclose(f);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DUMP_MACROS
|
||||
static void macro_dump(dfilter_macro_t* m _U_, void* ud _U_) {
|
||||
gchar** part = m->parts;
|
||||
int* args_pos = m->args_pos;
|
||||
|
||||
printf("\n->%s\t%s\t%d [%d]\n\t'%s'\n",
|
||||
m->name, m->text, m->argc, m->usable, *(part++));
|
||||
|
||||
while (*part) {
|
||||
printf("\t$%d '%s'\n",*args_pos,*part);
|
||||
|
||||
args_pos++;
|
||||
part++;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define macro_dump(a,b)
|
||||
#endif
|
||||
|
||||
void dfilter_macro_dump(void) {
|
||||
#ifdef DUMP_MACROS
|
||||
dfilter_macro_foreach(macro_dump, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static gchar* dfilter_macro_resolve(gchar* name, gchar** args, gchar** error) {
|
||||
GString* text;
|
||||
int argc = 0;
|
||||
|
@ -488,8 +432,6 @@ done:
|
|||
|
||||
m->usable = TRUE;
|
||||
|
||||
macro_dump(m,NULL);
|
||||
|
||||
DUMP_MACRO(m);
|
||||
|
||||
return TRUE;
|
||||
|
@ -601,11 +543,11 @@ static gboolean macro_name_chk(void *mp, const char *in_name, guint name_len,
|
|||
* different name, check for uniqueness. NOTE: if a duplicate already
|
||||
* exists (because the user manually edited the file), then this will
|
||||
* not trigger a warning. */
|
||||
if (!m->name || !g_str_equal(m->name, in_name)) {
|
||||
if (!m->name || g_strcmp0(m->name, in_name)) {
|
||||
for (i = 0; i < num_macros; i++) {
|
||||
/* This a string field which is always NUL-terminated,
|
||||
* so no need to check name_len. */
|
||||
if (g_str_equal(in_name, macros[i].name)) {
|
||||
if (!g_strcmp0(in_name, macros[i].name)) {
|
||||
*error = g_strdup_printf("macro '%s' already exists",
|
||||
in_name);
|
||||
return FALSE;
|
||||
|
@ -646,8 +588,8 @@ void dfilter_macro_init(void) {
|
|||
fvt_cache = g_hash_table_new(g_str_hash,g_str_equal);
|
||||
}
|
||||
|
||||
void dfilter_macro_get_uat(void** p) {
|
||||
*p = dfilter_macro_uat;
|
||||
void dfilter_macro_get_uat(uat_t **dfmu_ptr_ptr) {
|
||||
*dfmu_ptr_ptr = dfilter_macro_uat;
|
||||
}
|
||||
|
||||
#ifdef DUMP_DFILTER_MACRO
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
|
||||
#define DFILTER_MACRO_FILENAME "dfilter_macros"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _dfilter_macro_t {
|
||||
gchar* name; /* the macro id */
|
||||
|
@ -38,26 +41,21 @@ typedef struct _dfilter_macro_t {
|
|||
void* priv; /* a copy of text that contains every c-string in parts */
|
||||
} dfilter_macro_t;
|
||||
|
||||
/* loop over the macros list */
|
||||
typedef void (*dfilter_macro_cb_t)(dfilter_macro_t*, void*);
|
||||
WS_DLL_PUBLIC
|
||||
void dfilter_macro_foreach(dfilter_macro_cb_t, void*);
|
||||
|
||||
/* save dfilter macros to a file */
|
||||
void dfilter_macro_save(const gchar*, gchar**);
|
||||
|
||||
/* dumps the macros in the list (debug info, not formated as in the macros file) */
|
||||
void dfilter_macro_dump(void);
|
||||
|
||||
/* applies all macros to the given text and returns the resulting string or NULL on failure */
|
||||
const gchar* dfilter_macro_apply(const gchar* text, gchar** error);
|
||||
|
||||
void dfilter_macro_init(void);
|
||||
|
||||
struct epan_uat;
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
void dfilter_macro_get_uat(void**);
|
||||
void dfilter_macro_get_uat(struct epan_uat **dfmu_ptr_ptr);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
void dfilter_macro_build_ftv_cache(void* tree_root);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _DFILTER_MACRO_H */
|
||||
|
|
|
@ -39,13 +39,13 @@ void macros_post_update(void) {
|
|||
}
|
||||
|
||||
void macros_init (void) {
|
||||
void* dfmuat;
|
||||
uat_t* dfmuat;
|
||||
dfilter_macro_get_uat(&dfmuat);
|
||||
((uat_t*)dfmuat)->post_update_cb = macros_post_update;
|
||||
dfmuat->post_update_cb = macros_post_update;
|
||||
}
|
||||
|
||||
void macros_dialog_cb(GtkWidget *w _U_, gpointer data _U_) {
|
||||
void* dfmuat;
|
||||
uat_t* dfmuat;
|
||||
dfilter_macro_get_uat(&dfmuat);
|
||||
uat_window_cb(NULL,dfmuat);
|
||||
}
|
||||
|
|
|
@ -403,6 +403,7 @@ private slots:
|
|||
void on_actionCaptureCaptureFilters_triggered();
|
||||
|
||||
void on_actionAnalyzeDisplayFilters_triggered();
|
||||
void on_actionAnalyzeDisplayFilterMacros_triggered();
|
||||
void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
|
||||
void on_actionAnalyzeCreateAColumn_triggered();
|
||||
void on_actionAnalyzeAAFSelected_triggered();
|
||||
|
|
|
@ -1284,9 +1284,6 @@
|
|||
</property>
|
||||
</action>
|
||||
<action name="actionAnalyzeDisplayFilterMacros">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Display Filter &Macros…</string>
|
||||
</property>
|
||||
|
|
|
@ -50,9 +50,11 @@
|
|||
#include "epan/addr_resolv.h"
|
||||
#include "epan/color_dissector_filters.h"
|
||||
#include "epan/column.h"
|
||||
#include "epan/dfilter/dfilter-macro.h"
|
||||
#include "epan/epan_dissect.h"
|
||||
#include "epan/filter_expressions.h"
|
||||
#include "epan/prefs.h"
|
||||
#include "epan/uat.h"
|
||||
#include "epan/value_string.h"
|
||||
|
||||
#ifdef HAVE_LUA
|
||||
|
@ -107,6 +109,7 @@
|
|||
#include "lbm_uimflow_dialog.h"
|
||||
#include "lbm_lbtrm_transport_dialog.h"
|
||||
#include "lbm_lbtru_transport_dialog.h"
|
||||
#include "multicast_statistics_dialog.h"
|
||||
#include "packet_comment_dialog.h"
|
||||
#include "packet_dialog.h"
|
||||
#include "packet_list.h"
|
||||
|
@ -128,7 +131,7 @@
|
|||
#include "tap_parameter_dialog.h"
|
||||
#include "tcp_stream_dialog.h"
|
||||
#include "time_shift_dialog.h"
|
||||
#include "multicast_statistics_dialog.h"
|
||||
#include "uat_dialog.h"
|
||||
#include "voip_calls_dialog.h"
|
||||
#include "wireshark_application.h"
|
||||
#include "wlan_statistics_dialog.h"
|
||||
|
@ -2354,6 +2357,16 @@ void MainWindow::on_actionAnalyzeDisplayFilters_triggered()
|
|||
display_filter_dlg_->activateWindow();
|
||||
}
|
||||
|
||||
struct epan_uat;
|
||||
void MainWindow::on_actionAnalyzeDisplayFilterMacros_triggered()
|
||||
{
|
||||
struct epan_uat* dfm_uat;
|
||||
dfilter_macro_get_uat(&dfm_uat);
|
||||
UatDialog uat_dlg(parentWidget(), dfm_uat);
|
||||
|
||||
uat_dlg.exec();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionAnalyzeCreateAColumn_triggered()
|
||||
{
|
||||
gint colnr = 0;
|
||||
|
|
|
@ -417,6 +417,13 @@ void UatDialog::stringPrefTextChanged(const QString &text)
|
|||
uat_update_record(uat_, rec, FALSE);
|
||||
}
|
||||
}
|
||||
if (uat_->update_cb) {
|
||||
gchar *err;
|
||||
if (!uat_->update_cb(rec, &err)) {
|
||||
g_free(err); // XXX Handle this.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ok_button_->setEnabled(enable_ok);
|
||||
cur_line_edit_->setSyntaxState(ss);
|
||||
|
|
Loading…
Reference in New Issue