QUIC: Update IETF draft URL (draft-08)
[metze/wireshark/wip.git] / epan / print.h
1 /* print.h
2  * Definitions for printing packet analysis trees.
3  *
4  * Gilbert Ramirez <gram@alumni.rice.edu>
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #ifndef __PRINT_H__
26 #define __PRINT_H__
27
28 #include <stdio.h>
29
30 #include <epan/epan.h>
31 #include <epan/packet.h>
32
33 #include <epan/print_stream.h>
34
35 #include "ws_symbol_export.h"
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
40
41 /* print output format */
42 typedef enum {
43   PR_FMT_TEXT,    /* plain text */
44   PR_FMT_PS       /* postscript */
45 } print_format_e;
46
47 /* print_dissections, enum how the dissections should be printed */
48 typedef enum {
49   print_dissections_none,         /* no dissections at all */
50   print_dissections_collapsed,    /* no dissection details */
51   print_dissections_as_displayed, /* details as displayed */
52   print_dissections_expanded      /* all dissection details */
53 } print_dissections_e;
54
55
56 typedef enum {
57   FORMAT_CSV,     /* CSV */
58   FORMAT_JSON,    /* JSON */
59   FORMAT_EK,      /* JSON bulk insert to Elasticsearch */
60   FORMAT_XML      /* PDML output */
61 } fields_format;
62
63 typedef enum {
64   PF_NONE = 0x00,
65   PF_INCLUDE_CHILDREN = 0x01
66 } pf_flags;
67
68 /*
69  * Print user selected list of fields
70  */
71 struct _output_fields;
72 typedef struct _output_fields output_fields_t;
73
74 typedef GSList* (*proto_node_children_grouper_func)(proto_node *node);
75
76 WS_DLL_PUBLIC output_fields_t* output_fields_new(void);
77 WS_DLL_PUBLIC void output_fields_free(output_fields_t* info);
78 WS_DLL_PUBLIC void output_fields_add(output_fields_t* info, const gchar* field);
79 WS_DLL_PUBLIC GSList * output_fields_valid(output_fields_t* info);
80 WS_DLL_PUBLIC gsize output_fields_num_fields(output_fields_t* info);
81 WS_DLL_PUBLIC gboolean output_fields_set_option(output_fields_t* info, gchar* option);
82 WS_DLL_PUBLIC void output_fields_list_options(FILE *fh);
83 WS_DLL_PUBLIC gboolean output_fields_has_cols(output_fields_t* info);
84
85 /*
86  * Higher-level packet-printing code.
87  */
88
89 WS_DLL_PUBLIC gboolean proto_tree_print(print_dissections_e print_dissections,
90                                         gboolean print_hex_data,
91                                         epan_dissect_t *edt,
92                                         GHashTable *output_only_tables,
93                                         print_stream_t *stream);
94 WS_DLL_PUBLIC gboolean print_hex_data(print_stream_t *stream, epan_dissect_t *edt);
95
96 WS_DLL_PUBLIC void write_pdml_preamble(FILE *fh, const gchar* filename);
97 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);
98 WS_DLL_PUBLIC void write_pdml_finale(FILE *fh);
99
100 // Implementations of proto_node_children_grouper_func
101 // Groups each child separately
102 WS_DLL_PUBLIC GSList *proto_node_group_children_by_unique(proto_node *node);
103 // Groups children by json key (children with the same json key get put in the same group
104 WS_DLL_PUBLIC GSList *proto_node_group_children_by_json_key(proto_node *node);
105
106 WS_DLL_PUBLIC void write_json_preamble(FILE *fh);
107 WS_DLL_PUBLIC void write_json_proto_tree(output_fields_t* fields,
108                                          print_dissections_e print_dissections,
109                                          gboolean print_hex_data,
110                                          gchar **protocolfilter,
111                                          pf_flags protocolfilter_flags,
112                                          epan_dissect_t *edt,
113                                          column_info *cinfo,
114                                          proto_node_children_grouper_func node_children_grouper,
115                                          FILE *fh);
116 WS_DLL_PUBLIC void write_json_finale(FILE *fh);
117
118 WS_DLL_PUBLIC void write_ek_proto_tree(output_fields_t* fields,
119                                        gboolean print_summary,
120                                        gboolean print_hex_data,
121                                        gchar **protocolfilter,
122                                        pf_flags protocolfilter_flags,
123                                        epan_dissect_t *edt,
124                                        column_info *cinfo, FILE *fh);
125
126 WS_DLL_PUBLIC void write_psml_preamble(column_info *cinfo, FILE *fh);
127 WS_DLL_PUBLIC void write_psml_columns(epan_dissect_t *edt, FILE *fh, gboolean use_color);
128 WS_DLL_PUBLIC void write_psml_finale(FILE *fh);
129
130 WS_DLL_PUBLIC void write_csv_column_titles(column_info *cinfo, FILE *fh);
131 WS_DLL_PUBLIC void write_csv_columns(epan_dissect_t *edt, FILE *fh);
132
133 WS_DLL_PUBLIC void write_carrays_hex_data(guint32 num, FILE *fh, epan_dissect_t *edt);
134
135 WS_DLL_PUBLIC void write_fields_preamble(output_fields_t* fields, FILE *fh);
136 WS_DLL_PUBLIC void write_fields_proto_tree(output_fields_t* fields, epan_dissect_t *edt, column_info *cinfo, FILE *fh);
137 WS_DLL_PUBLIC void write_fields_finale(output_fields_t* fields, FILE *fh);
138
139 WS_DLL_PUBLIC gchar* get_node_field_value(field_info* fi, epan_dissect_t* edt);
140
141 extern void print_cache_field_handles(void);
142
143 #ifdef __cplusplus
144 }
145 #endif /* __cplusplus */
146
147 #endif /* print.h */