diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2017-06-16 15:19:18 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-06-22 19:31:01 +0000 |
commit | 07f576ffeb2bfabecaefbe24088a2858f47d4642 (patch) | |
tree | ee51b1043b254b4b86b8422c5e86d643c81d8cf8 /epan/print.h | |
parent | 2954a69d7d5627bf330eb9bb05eb5a1274e01f3a (diff) | |
download | wireshark-07f576ffeb2bfabecaefbe24088a2858f47d4642.tar.gz |
Add --no-duplicate-keys tshark option.
Adds the --no-duplicate-keys option to tshark. If -T json is specified,
this option can be specified in order to transform the duplicate keys
produced by -T json into single keys with as value a json array of all
separate values.
Specifying --no-duplicate-keys changes the function which groups node
children that is passed to write_json_proto_tree. Instead of a function
that puts each node in a separate group (proto_node_group_children_by_unique)
a function is passed that groups children that have the same json key
together (proto_node_group_children_by_json_key). This will lead to
some groups having multiple values. Groups with multiple values are
written to the output as a json array. This includes normal json keys
but also keys with the "_raw" and "_tree" suffix.
If --no-duplicate-keys is specified with an option other than "-T json"
or "-T jsonraw" or without -T an error is shown and tshark will exit.
"Export Packet Dissections -> As JSON" in the GUI is hardcoded to use
the duplicated keys format.
Fixes one regression in the output where a filtered json key (-j) with
both a value and children would not have the "_tree" suffix added to the
json key containing the children.
Includes a little code cleanup (removes one instance of code
duplication and simplifies a while loop).
Fixes a memory leak (I thought this fix was already included in the
previous refactor patch but something must have gone wrong when updating
the patch so I'm including it again in this patch).
Bug: 12958
Change-Id: I401f8fc877b5c590686567c3c44cdb832e9e7dfe
Reviewed-on: https://code.wireshark.org/review/22166
Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/print.h')
-rw-r--r-- | epan/print.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/epan/print.h b/epan/print.h index bfa2ab482a..c47e83272b 100644 --- a/epan/print.h +++ b/epan/print.h @@ -71,6 +71,8 @@ typedef enum { struct _output_fields; typedef struct _output_fields output_fields_t; +typedef GSList* (*proto_node_children_grouper_func)(proto_node *node); + 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); @@ -95,13 +97,21 @@ 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_finale(FILE *fh); +// Implementations of proto_node_children_grouper_func +// Groups each child separately +WS_DLL_PUBLIC GSList *proto_node_group_children_by_unique(proto_node *node); +// Groups children by json key (children with the same json key get put in the same group +WS_DLL_PUBLIC GSList *proto_node_group_children_by_json_key(proto_node *node); + WS_DLL_PUBLIC void write_json_preamble(FILE *fh); WS_DLL_PUBLIC void write_json_proto_tree(output_fields_t* fields, print_dissections_e print_dissections, gboolean print_hex_data, gchar **protocolfilter, pf_flags protocolfilter_flags, - epan_dissect_t *edt, FILE *fh); + epan_dissect_t *edt, + proto_node_children_grouper_func node_children_grouper, + FILE *fh); WS_DLL_PUBLIC void write_json_finale(FILE *fh); WS_DLL_PUBLIC void write_ek_proto_tree(output_fields_t* fields, |