more decompress
[wireshark-sm.git] / epan / print.h
blobee9a0ec173c2a2652f27682ffd707ce136f9839b
1 /** @file
2 * Definitions for printing packet analysis trees.
4 * Gilbert Ramirez <gram@alumni.rice.edu>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #ifndef __PRINT_H__
14 #define __PRINT_H__
16 #include <stdio.h>
18 #include <epan/epan.h>
19 #include <epan/packet.h>
20 #include <epan/print_stream.h>
22 #include <wsutil/json_dumper.h>
24 #include "ws_symbol_export.h"
26 #ifdef __cplusplus
27 extern "C" {
28 #endif /* __cplusplus */
30 /* print output format */
31 typedef enum {
32 PR_FMT_TEXT, /* plain text */
33 PR_FMT_PS /* postscript */
34 } print_format_e;
36 /* print_dissections, enum how the dissections should be printed */
37 typedef enum {
38 print_dissections_none, /* no dissections at all */
39 print_dissections_collapsed, /* no dissection details */
40 print_dissections_as_displayed, /* details as displayed */
41 print_dissections_expanded /* all dissection details */
42 } print_dissections_e;
45 typedef enum {
46 FORMAT_CSV, /* CSV */
47 FORMAT_JSON, /* JSON */
48 FORMAT_EK, /* JSON bulk insert to Elasticsearch */
49 FORMAT_XML /* PDML output */
50 } fields_format;
52 typedef enum {
53 PF_NONE = 0x00,
54 PF_INCLUDE_CHILDREN = 0x01
55 } pf_flags;
58 * Print user selected list of fields
60 struct _output_fields;
61 typedef struct _output_fields output_fields_t;
63 typedef GSList* (*proto_node_children_grouper_func)(proto_node *node);
65 WS_DLL_PUBLIC output_fields_t* output_fields_new(void);
66 WS_DLL_PUBLIC void output_fields_free(output_fields_t* info);
67 WS_DLL_PUBLIC void output_fields_add(output_fields_t* info, const char* field);
68 WS_DLL_PUBLIC GSList * output_fields_valid(output_fields_t* info);
69 WS_DLL_PUBLIC size_t output_fields_num_fields(output_fields_t* info);
70 WS_DLL_PUBLIC bool output_fields_set_option(output_fields_t* info, char* option);
71 WS_DLL_PUBLIC void output_fields_list_options(FILE *fh);
72 WS_DLL_PUBLIC bool output_fields_add_protocolfilter(output_fields_t* info, const char* field, pf_flags filter_flags);
73 WS_DLL_PUBLIC bool output_fields_has_cols(output_fields_t* info);
74 WS_DLL_PUBLIC void output_fields_prime_edt(struct epan_dissect *edt, output_fields_t* info);
77 * Higher-level packet-printing code.
80 WS_DLL_PUBLIC bool proto_tree_print(print_dissections_e print_dissections,
81 bool print_hex_data,
82 epan_dissect_t *edt,
83 GHashTable *output_only_tables,
84 print_stream_t *stream);
87 * Hexdump option for displaying data sources:
90 #define HEXDUMP_SOURCE_MASK (0x0004U)
91 #define HEXDUMP_SOURCE_OPTION(option) ((option) & HEXDUMP_SOURCE_MASK)
93 #define HEXDUMP_SOURCE_MULTI (0x0000U) /* create hexdumps for all data sources assigned to a frame (legacy tshark behaviour) */
94 #define HEXDUMP_SOURCE_PRIMARY (0x0004U) /* create hexdumps for only the frame data */
96 WS_DLL_PUBLIC bool print_hex_data(print_stream_t *stream, epan_dissect_t *edt, unsigned hexdump_options);
98 WS_DLL_PUBLIC void write_pdml_preamble(FILE *fh, const char* filename);
99 WS_DLL_PUBLIC void write_pdml_proto_tree(output_fields_t* fields, epan_dissect_t *edt, column_info *cinfo, FILE *fh, bool use_color);
100 WS_DLL_PUBLIC void write_pdml_finale(FILE *fh);
102 // Implementations of proto_node_children_grouper_func
103 // Groups each child separately
104 WS_DLL_PUBLIC GSList *proto_node_group_children_by_unique(proto_node *node);
105 // Groups children by json key (children with the same json key get put in the same group
106 WS_DLL_PUBLIC GSList *proto_node_group_children_by_json_key(proto_node *node);
108 WS_DLL_PUBLIC json_dumper write_json_preamble(FILE *fh);
109 WS_DLL_PUBLIC void write_json_proto_tree(output_fields_t* fields,
110 print_dissections_e print_dissections,
111 bool print_hex_data,
112 epan_dissect_t *edt,
113 column_info *cinfo,
114 proto_node_children_grouper_func node_children_grouper,
115 json_dumper *dumper);
116 WS_DLL_PUBLIC void write_json_finale(json_dumper *dumper);
118 WS_DLL_PUBLIC void write_ek_proto_tree(output_fields_t* fields,
119 bool print_summary,
120 bool print_hex_data,
121 epan_dissect_t *edt,
122 column_info *cinfo, FILE *fh);
124 WS_DLL_PUBLIC void write_psml_preamble(column_info *cinfo, FILE *fh);
125 WS_DLL_PUBLIC void write_psml_columns(epan_dissect_t *edt, FILE *fh, bool use_color);
126 WS_DLL_PUBLIC void write_psml_finale(FILE *fh);
128 WS_DLL_PUBLIC void write_csv_column_titles(column_info *cinfo, FILE *fh);
129 WS_DLL_PUBLIC void write_csv_columns(epan_dissect_t *edt, FILE *fh);
131 WS_DLL_PUBLIC void write_carrays_hex_data(uint32_t num, FILE *fh, epan_dissect_t *edt);
133 WS_DLL_PUBLIC void write_fields_preamble(output_fields_t* fields, FILE *fh);
134 WS_DLL_PUBLIC void write_fields_proto_tree(output_fields_t* fields, epan_dissect_t *edt, column_info *cinfo, FILE *fh);
135 WS_DLL_PUBLIC void write_fields_finale(output_fields_t* fields, FILE *fh);
137 WS_DLL_PUBLIC char* get_node_field_value(field_info* fi, epan_dissect_t* edt);
139 extern void print_cache_field_handles(void);
141 #ifdef __cplusplus
143 #endif /* __cplusplus */
145 #endif /* print.h */