forked from osmocom/wireshark
Get rid of another global in the print code.
Pass the "output only these protocols" hash table as an argument, instead. Change-Id: Id8540943037e7b9bbfe377120c3f60dbe54fe0f1 Reviewed-on: https://code.wireshark.org/review/5440 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
c68e77b844
commit
741db4c751
10
epan/print.c
10
epan/print.c
|
@ -59,6 +59,7 @@ typedef struct {
|
|||
gboolean print_hex_for_data;
|
||||
packet_char_enc encoding;
|
||||
epan_dissect_t *edt;
|
||||
GHashTable *output_only_tables; /* output only these protocols */
|
||||
} print_data;
|
||||
|
||||
typedef struct {
|
||||
|
@ -85,8 +86,6 @@ struct _output_fields {
|
|||
gboolean includes_col_fields;
|
||||
};
|
||||
|
||||
GHashTable *output_only_tables = NULL;
|
||||
|
||||
static gchar *get_field_hex_value(GSList *src_list, field_info *fi);
|
||||
static void proto_tree_print_node(proto_node *node, gpointer data);
|
||||
static void proto_tree_write_node_pdml(proto_node *node, gpointer data);
|
||||
|
@ -102,7 +101,7 @@ static void proto_tree_get_node_field_values(proto_node *node, gpointer data);
|
|||
|
||||
gboolean
|
||||
proto_tree_print(print_args_t *print_args, epan_dissect_t *edt,
|
||||
print_stream_t *stream)
|
||||
GHashTable *output_only_tables, print_stream_t *stream)
|
||||
{
|
||||
print_data data;
|
||||
|
||||
|
@ -117,6 +116,7 @@ proto_tree_print(print_args_t *print_args, epan_dissect_t *edt,
|
|||
print uninterpreted data fields in hex as well. */
|
||||
data.print_hex_for_data = !print_args->print_hex;
|
||||
data.edt = edt;
|
||||
data.output_only_tables = output_only_tables;
|
||||
|
||||
proto_tree_children_foreach(edt->tree, proto_tree_print_node, &data);
|
||||
return data.success;
|
||||
|
@ -170,8 +170,8 @@ proto_tree_print_node(proto_node *node, gpointer data)
|
|||
* subitems whose abbreviation doesn't match the protocol--for example
|
||||
* text items (whose abbreviation is simply "text").
|
||||
*/
|
||||
if ((output_only_tables != NULL) && (pdata->level == 0)
|
||||
&& (g_hash_table_lookup(output_only_tables, fi->hfinfo->abbrev) == NULL)) {
|
||||
if ((pdata->output_only_tables != NULL) && (pdata->level == 0)
|
||||
&& (g_hash_table_lookup(pdata->output_only_tables, fi->hfinfo->abbrev) == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
11
epan/print.h
11
epan/print.h
|
@ -94,17 +94,14 @@ WS_DLL_PUBLIC gboolean output_fields_set_option(output_fields_t* info, gchar* op
|
|||
WS_DLL_PUBLIC void output_fields_list_options(FILE *fh);
|
||||
WS_DLL_PUBLIC gboolean output_fields_has_cols(output_fields_t* info);
|
||||
|
||||
/*
|
||||
* Output only these protocols
|
||||
*/
|
||||
WS_DLL_PUBLIC GHashTable *output_only_tables;
|
||||
|
||||
/*
|
||||
* Higher-level packet-printing code.
|
||||
*/
|
||||
|
||||
WS_DLL_PUBLIC gboolean proto_tree_print(print_args_t *print_args, epan_dissect_t *edt,
|
||||
print_stream_t *stream);
|
||||
WS_DLL_PUBLIC gboolean proto_tree_print(print_args_t *print_args,
|
||||
epan_dissect_t *edt,
|
||||
GHashTable *output_only_tables,
|
||||
print_stream_t *stream);
|
||||
WS_DLL_PUBLIC gboolean print_hex_data(print_stream_t *stream, epan_dissect_t *edt);
|
||||
|
||||
WS_DLL_PUBLIC void write_pdml_preamble(FILE *fh, const gchar* filename);
|
||||
|
|
2
file.c
2
file.c
|
@ -2495,7 +2495,7 @@ print_packet(capture_file *cf, frame_data *fdata,
|
|||
}
|
||||
|
||||
/* Print the information in that tree. */
|
||||
if (!proto_tree_print(args->print_args, &args->edt, args->print_args->stream))
|
||||
if (!proto_tree_print(args->print_args, &args->edt, NULL, args->print_args->stream))
|
||||
goto fail;
|
||||
|
||||
/* Print a blank line if we print anything after this (aka more than one packet). */
|
||||
|
|
|
@ -172,6 +172,8 @@ static void failure_message_cont(const char *msg_format, va_list ap);
|
|||
|
||||
capture_file cfile;
|
||||
|
||||
static GHashTable *output_only_tables = NULL;
|
||||
|
||||
#if 0
|
||||
struct string_elem {
|
||||
const char *sstr; /* The short string */
|
||||
|
@ -2476,7 +2478,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
|
|||
print_args.print_hex = print_hex;
|
||||
print_args.print_dissections = print_details ? print_dissections_expanded : print_dissections_none;
|
||||
|
||||
if (!proto_tree_print(&print_args, edt, print_stream))
|
||||
if (!proto_tree_print(&print_args, edt, output_only_tables, print_stream))
|
||||
return FALSE;
|
||||
if (!print_hex) {
|
||||
if (!print_line(print_stream, 0, separator))
|
||||
|
|
4
tshark.c
4
tshark.c
|
@ -225,6 +225,8 @@ static void failure_message_cont(const char *msg_format, va_list ap);
|
|||
|
||||
capture_file cfile;
|
||||
|
||||
static GHashTable *output_only_tables = NULL;
|
||||
|
||||
struct string_elem {
|
||||
const char *sstr; /* The short string */
|
||||
const char *lstr; /* The long string */
|
||||
|
@ -3926,7 +3928,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
|
|||
print_args.print_hex = print_hex;
|
||||
print_args.print_dissections = print_details ? print_dissections_expanded : print_dissections_none;
|
||||
|
||||
if (!proto_tree_print(&print_args, edt, print_stream))
|
||||
if (!proto_tree_print(&print_args, edt, output_only_tables, print_stream))
|
||||
return FALSE;
|
||||
if (!print_hex) {
|
||||
if (!print_line(print_stream, 0, separator))
|
||||
|
|
Loading…
Reference in New Issue