aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/print.c26
-rw-r--r--epan/print.h1
-rw-r--r--tshark.c8
3 files changed, 35 insertions, 0 deletions
diff --git a/epan/print.c b/epan/print.c
index 3789443134..f4eb8818e0 100644
--- a/epan/print.c
+++ b/epan/print.c
@@ -1429,6 +1429,32 @@ void output_fields_add(output_fields_t *fields, const gchar *field)
}
+static void
+output_field_check(void *data, void *user_data)
+{
+ gchar *field = (gchar *)data;
+ gboolean *all_valid = (gboolean *)user_data;
+
+ if (!strncmp(field, COLUMN_FIELD_FILTER, strlen(COLUMN_FIELD_FILTER)))
+ return;
+
+ if (!proto_registrar_get_byname(field)) {
+ g_warning("'%s' isn't a valid field!", field);
+ *all_valid = FALSE;
+ }
+
+}
+
+gboolean
+output_fields_valid(output_fields_t *fields)
+{
+ gboolean all_valid = TRUE;
+
+ g_ptr_array_foreach(fields->fields, output_field_check, &all_valid);
+
+ return all_valid;
+}
+
gboolean output_fields_set_option(output_fields_t *info, gchar *option)
{
const gchar *option_name;
diff --git a/epan/print.h b/epan/print.h
index be739f248b..9832d575a4 100644
--- a/epan/print.h
+++ b/epan/print.h
@@ -119,6 +119,7 @@ typedef struct _output_fields output_fields_t;
WS_DLL_PUBLIC output_fields_t* output_fields_new(void);
WS_DLL_PUBLIC void output_fields_free(output_fields_t* info);
WS_DLL_PUBLIC void output_fields_add(output_fields_t* info, const gchar* field);
+WS_DLL_PUBLIC gboolean output_fields_valid(output_fields_t* info);
WS_DLL_PUBLIC gsize output_fields_num_fields(output_fields_t* info);
WS_DLL_PUBLIC gboolean output_fields_set_option(output_fields_t* info, gchar* option);
WS_DLL_PUBLIC void output_fields_list_options(FILE *fh);
diff --git a/tshark.c b/tshark.c
index bdb8046ee1..8d27037772 100644
--- a/tshark.c
+++ b/tshark.c
@@ -1922,6 +1922,14 @@ main(int argc, char *argv[])
of the filter. We can now process all the "-z" arguments. */
start_requested_stats();
+ /* At this point MATE will have registered its field array so we can
+ check if the fields specified by the user are all good.
+ */
+ if (!output_fields_valid(output_fields)) {
+ cmdarg_err("Some fields aren't valid");
+ return 1;
+ }
+
#ifdef HAVE_LIBPCAP
/* We currently don't support taps, or printing dissected packets,
if we're writing to a pipe. */