Add columns (_ws.col) to output formats json, ek, pdml
Bug: 13020 Change-Id: Ia83797a4e390be7cc59a9718735edc1c7f9a5712 Reviewed-on: https://code.wireshark.org/review/24928 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
487eae3507
commit
af6dee3571
33
epan/print.c
33
epan/print.c
|
@ -310,7 +310,7 @@ static gboolean check_protocolfilter(gchar **protocolfilter, const char *str)
|
|||
}
|
||||
|
||||
void
|
||||
write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh, gboolean use_color)
|
||||
write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, column_info *cinfo, FILE *fh, gboolean use_color)
|
||||
{
|
||||
write_pdml_data data;
|
||||
const color_filter_t *cfp;
|
||||
|
@ -345,7 +345,7 @@ write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags
|
|||
&data);
|
||||
} else {
|
||||
/* Write out specified fields */
|
||||
write_specified_fields(FORMAT_XML, fields, edt, NULL, fh);
|
||||
write_specified_fields(FORMAT_XML, fields, edt, cinfo, fh);
|
||||
}
|
||||
|
||||
fprintf(fh, "</packet>\n\n");
|
||||
|
@ -356,6 +356,7 @@ write_ek_proto_tree(output_fields_t* fields,
|
|||
gboolean print_summary, gboolean print_hex,
|
||||
gchar **protocolfilter,
|
||||
pf_flags protocolfilter_flags, epan_dissect_t *edt,
|
||||
column_info *cinfo,
|
||||
FILE *fh)
|
||||
{
|
||||
write_json_data data;
|
||||
|
@ -395,7 +396,7 @@ write_ek_proto_tree(output_fields_t* fields,
|
|||
proto_tree_write_node_ek(edt->tree, &data);
|
||||
} else {
|
||||
/* Write out specified fields */
|
||||
write_specified_fields(FORMAT_EK, fields, edt, NULL, fh);
|
||||
write_specified_fields(FORMAT_EK, fields, edt, cinfo, fh);
|
||||
}
|
||||
|
||||
fputs("}", fh);
|
||||
|
@ -703,6 +704,7 @@ write_json_proto_tree(output_fields_t* fields,
|
|||
print_dissections_e print_dissections,
|
||||
gboolean print_hex, gchar **protocolfilter,
|
||||
pf_flags protocolfilter_flags, epan_dissect_t *edt,
|
||||
column_info *cinfo,
|
||||
proto_node_children_grouper_func node_children_grouper,
|
||||
FILE *fh)
|
||||
{
|
||||
|
@ -747,7 +749,7 @@ write_json_proto_tree(output_fields_t* fields,
|
|||
|
||||
write_json_proto_node_children(edt->tree, &data);
|
||||
} else {
|
||||
write_specified_fields(FORMAT_JSON, fields, edt, NULL, fh);
|
||||
write_specified_fields(FORMAT_JSON, fields, edt, cinfo, fh);
|
||||
}
|
||||
|
||||
fputs("\n", fh);
|
||||
|
@ -2437,21 +2439,22 @@ static void write_specified_fields(fields_format format, output_fields_t *fields
|
|||
proto_tree_children_foreach(edt->tree, proto_tree_get_node_field_values,
|
||||
&data);
|
||||
|
||||
switch (format) {
|
||||
case FORMAT_CSV:
|
||||
if (fields->includes_col_fields) {
|
||||
for (col = 0; col < cinfo->num_cols; col++) {
|
||||
/* Prepend COLUMN_FIELD_FILTER as the field name */
|
||||
col_name = g_strdup_printf("%s%s", COLUMN_FIELD_FILTER, cinfo->columns[col].col_title);
|
||||
field_index = g_hash_table_lookup(fields->field_indicies, col_name);
|
||||
g_free(col_name);
|
||||
/* Add columns to fields */
|
||||
if (fields->includes_col_fields) {
|
||||
for (col = 0; col < cinfo->num_cols; col++) {
|
||||
/* Prepend COLUMN_FIELD_FILTER as the field name */
|
||||
col_name = g_strdup_printf("%s%s", COLUMN_FIELD_FILTER, cinfo->columns[col].col_title);
|
||||
field_index = g_hash_table_lookup(fields->field_indicies, col_name);
|
||||
g_free(col_name);
|
||||
|
||||
if (NULL != field_index) {
|
||||
format_field_values(fields, field_index, g_strdup(cinfo->columns[col].col_data));
|
||||
}
|
||||
if (NULL != field_index) {
|
||||
format_field_values(fields, field_index, g_strdup(cinfo->columns[col].col_data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
case FORMAT_CSV:
|
||||
for(i = 0; i < fields->fields->len; ++i) {
|
||||
if (0 != i) {
|
||||
fputc(fields->separator, fh);
|
||||
|
|
|
@ -94,7 +94,7 @@ WS_DLL_PUBLIC gboolean proto_tree_print(print_dissections_e print_dissections,
|
|||
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);
|
||||
WS_DLL_PUBLIC void write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh, gboolean use_color);
|
||||
WS_DLL_PUBLIC void write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, column_info *cinfo, FILE *fh, gboolean use_color);
|
||||
WS_DLL_PUBLIC void write_pdml_finale(FILE *fh);
|
||||
|
||||
// Implementations of proto_node_children_grouper_func
|
||||
|
@ -110,6 +110,7 @@ WS_DLL_PUBLIC void write_json_proto_tree(output_fields_t* fields,
|
|||
gchar **protocolfilter,
|
||||
pf_flags protocolfilter_flags,
|
||||
epan_dissect_t *edt,
|
||||
column_info *cinfo,
|
||||
proto_node_children_grouper_func node_children_grouper,
|
||||
FILE *fh);
|
||||
WS_DLL_PUBLIC void write_json_finale(FILE *fh);
|
||||
|
@ -119,7 +120,8 @@ WS_DLL_PUBLIC void write_ek_proto_tree(output_fields_t* fields,
|
|||
gboolean print_hex_data,
|
||||
gchar **protocolfilter,
|
||||
pf_flags protocolfilter_flags,
|
||||
epan_dissect_t *edt, FILE *fh);
|
||||
epan_dissect_t *edt,
|
||||
column_info *cinfo, FILE *fh);
|
||||
|
||||
WS_DLL_PUBLIC void write_psml_preamble(column_info *cinfo, FILE *fh);
|
||||
WS_DLL_PUBLIC void write_psml_columns(epan_dissect_t *edt, FILE *fh, gboolean use_color);
|
||||
|
|
4
file.c
4
file.c
|
@ -2514,7 +2514,7 @@ write_pdml_packet(capture_file *cf, frame_data *fdata,
|
|||
frame_tvbuff_new(&cf->provider, fdata, pd), fdata, NULL);
|
||||
|
||||
/* Write out the information in that tree. */
|
||||
write_pdml_proto_tree(NULL, NULL, PF_NONE, &args->edt, args->fh, FALSE);
|
||||
write_pdml_proto_tree(NULL, NULL, PF_NONE, &args->edt, &cf->cinfo, args->fh, FALSE);
|
||||
|
||||
epan_dissect_reset(&args->edt);
|
||||
|
||||
|
@ -2816,7 +2816,7 @@ write_json_packet(capture_file *cf, frame_data *fdata,
|
|||
/* Write out the information in that tree. */
|
||||
write_json_proto_tree(NULL, args->print_args->print_dissections,
|
||||
args->print_args->print_hex, NULL, PF_NONE,
|
||||
&args->edt, proto_node_group_children_by_unique, args->fh);
|
||||
&args->edt, &cf->cinfo, proto_node_group_children_by_unique, args->fh);
|
||||
|
||||
epan_dissect_reset(&args->edt);
|
||||
|
||||
|
|
8
tshark.c
8
tshark.c
|
@ -3910,7 +3910,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
|
|||
return !ferror(stdout);
|
||||
}
|
||||
if (print_details) {
|
||||
write_pdml_proto_tree(output_fields, protocolfilter, protocolfilter_flags, edt, stdout, dissect_color);
|
||||
write_pdml_proto_tree(output_fields, protocolfilter, protocolfilter_flags, edt, &cf->cinfo, stdout, dissect_color);
|
||||
printf("\n");
|
||||
return !ferror(stdout);
|
||||
}
|
||||
|
@ -3934,7 +3934,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
|
|||
if (print_details) {
|
||||
write_json_proto_tree(output_fields, print_dissections_expanded,
|
||||
print_hex, protocolfilter, protocolfilter_flags,
|
||||
edt, node_children_grouper, stdout);
|
||||
edt, &cf->cinfo, node_children_grouper, stdout);
|
||||
return !ferror(stdout);
|
||||
}
|
||||
break;
|
||||
|
@ -3945,14 +3945,14 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
|
|||
if (print_details) {
|
||||
write_json_proto_tree(output_fields, print_dissections_none, TRUE,
|
||||
protocolfilter, protocolfilter_flags,
|
||||
edt, node_children_grouper, stdout);
|
||||
edt, &cf->cinfo, node_children_grouper, stdout);
|
||||
return !ferror(stdout);
|
||||
}
|
||||
break;
|
||||
|
||||
case WRITE_EK:
|
||||
write_ek_proto_tree(output_fields, print_summary, print_hex, protocolfilter,
|
||||
protocolfilter_flags, edt, stdout);
|
||||
protocolfilter_flags, edt, &cf->cinfo, stdout);
|
||||
return !ferror(stdout);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue