forked from osmocom/wireshark
Display the name of the invalid field when tshark is run with -T fields
-e invalidfield Change-Id: Iaf8733096d9e1d15510a38363397b1dcd972ff59 Reviewed-on: https://code.wireshark.org/review/10504 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
722174359e
commit
68dd2c823a
16
epan/print.c
16
epan/print.c
|
@ -1075,30 +1075,28 @@ static void
|
|||
output_field_check(void *data, void *user_data)
|
||||
{
|
||||
gchar *field = (gchar *)data;
|
||||
gboolean *all_valid = (gboolean *)user_data;
|
||||
GSList **invalid_fields = (GSList **)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;
|
||||
*invalid_fields = g_slist_prepend(*invalid_fields, field);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gboolean
|
||||
GSList *
|
||||
output_fields_valid(output_fields_t *fields)
|
||||
{
|
||||
gboolean all_valid = TRUE;
|
||||
|
||||
GSList *invalid_fields = NULL;
|
||||
if (fields->fields == NULL) {
|
||||
return TRUE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_ptr_array_foreach(fields->fields, output_field_check, &all_valid);
|
||||
g_ptr_array_foreach(fields->fields, output_field_check, &invalid_fields);
|
||||
|
||||
return all_valid;
|
||||
return invalid_fields;
|
||||
}
|
||||
|
||||
gboolean output_fields_set_option(output_fields_t *info, gchar *option)
|
||||
|
|
|
@ -88,7 +88,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 GSList * 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);
|
||||
|
|
16
tshark.c
16
tshark.c
|
@ -2030,11 +2030,19 @@ DIAG_ON(cast-qual)
|
|||
/* 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;
|
||||
}
|
||||
{
|
||||
GSList* it = NULL;
|
||||
GSList *invalid_fields = output_fields_valid(output_fields);
|
||||
if (invalid_fields != NULL) {
|
||||
|
||||
cmdarg_err("Some fields aren't valid:");
|
||||
for (it=invalid_fields; it != NULL; it = g_slist_next(it)) {
|
||||
cmdarg_err_cont("\t%s", (gchar *)it->data);
|
||||
}
|
||||
g_slist_free(invalid_fields);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_LIBPCAP
|
||||
/* We currently don't support taps, or printing dissected packets,
|
||||
if we're writing to a pipe. */
|
||||
|
|
Loading…
Reference in New Issue