Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
print.h
Go to the documentation of this file.
1
13#ifndef __PRINT_H__
14#define __PRINT_H__
15
16#include <stdio.h>
17
18#include <epan/epan.h>
19#include <epan/packet.h>
20#include <epan/print_stream.h>
21
22#include <wsutil/json_dumper.h>
23
24#include "ws_symbol_export.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif /* __cplusplus */
29
30/* print output format */
31typedef enum {
32 PR_FMT_TEXT, /* plain text */
33 PR_FMT_PS /* postscript */
34} print_format_e;
35
36/* print_dissections, enum how the dissections should be printed */
37typedef 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;
43
44
45typedef 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;
51
52typedef enum {
53 PF_NONE = 0x00,
54 PF_INCLUDE_CHILDREN = 0x01
55} pf_flags;
56
57/*
58 * Print user selected list of fields
59 */
60struct _output_fields;
61typedef struct _output_fields output_fields_t;
62
63typedef GSList* (*proto_node_children_grouper_func)(proto_node *node);
64
65WS_DLL_PUBLIC output_fields_t* output_fields_new(void);
66WS_DLL_PUBLIC void output_fields_free(output_fields_t* info);
67WS_DLL_PUBLIC void output_fields_add(output_fields_t* info, const char* field);
68WS_DLL_PUBLIC GSList * output_fields_valid(output_fields_t* info);
69WS_DLL_PUBLIC size_t output_fields_num_fields(output_fields_t* info);
70WS_DLL_PUBLIC bool output_fields_set_option(output_fields_t* info, char* option);
71WS_DLL_PUBLIC void output_fields_list_options(FILE *fh);
72WS_DLL_PUBLIC bool output_fields_add_protocolfilter(output_fields_t* info, const char* field, pf_flags filter_flags);
73WS_DLL_PUBLIC bool output_fields_has_cols(output_fields_t* info);
74WS_DLL_PUBLIC void output_fields_prime_edt(struct epan_dissect *edt, output_fields_t* info);
75
76/*
77 * Higher-level packet-printing code.
78 */
79
80WS_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,
85
86/*
87 * Hexdump option for displaying data sources:
88 */
89
90#define HEXDUMP_SOURCE_MASK (0x0004U)
91#define HEXDUMP_SOURCE_OPTION(option) ((option) & HEXDUMP_SOURCE_MASK)
92
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 */
95
96WS_DLL_PUBLIC bool print_hex_data(print_stream_t *stream, epan_dissect_t *edt, unsigned hexdump_options);
97
98WS_DLL_PUBLIC void write_pdml_preamble(FILE *fh, const char* filename);
99WS_DLL_PUBLIC void write_pdml_proto_tree(output_fields_t* fields, epan_dissect_t *edt, column_info *cinfo, FILE *fh, bool use_color);
100WS_DLL_PUBLIC void write_pdml_finale(FILE *fh);
101
102// Implementations of proto_node_children_grouper_func
103// Groups each child separately
104WS_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
106WS_DLL_PUBLIC GSList *proto_node_group_children_by_json_key(proto_node *node);
107
108WS_DLL_PUBLIC json_dumper write_json_preamble(FILE *fh);
109WS_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);
116WS_DLL_PUBLIC void write_json_finale(json_dumper *dumper);
117
118WS_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);
123
124WS_DLL_PUBLIC void write_psml_preamble(column_info *cinfo, FILE *fh);
125WS_DLL_PUBLIC void write_psml_columns(epan_dissect_t *edt, FILE *fh, bool use_color);
126WS_DLL_PUBLIC void write_psml_finale(FILE *fh);
127
128WS_DLL_PUBLIC void write_csv_column_titles(column_info *cinfo, FILE *fh);
129WS_DLL_PUBLIC void write_csv_columns(epan_dissect_t *edt, FILE *fh);
130
131WS_DLL_PUBLIC void write_carrays_hex_data(uint32_t num, FILE *fh, epan_dissect_t *edt);
132
133WS_DLL_PUBLIC void write_fields_preamble(output_fields_t* fields, FILE *fh);
134WS_DLL_PUBLIC void write_fields_proto_tree(output_fields_t* fields, epan_dissect_t *edt, column_info *cinfo, FILE *fh);
135WS_DLL_PUBLIC void write_fields_finale(output_fields_t* fields, FILE *fh);
136
137WS_DLL_PUBLIC char* get_node_field_value(field_info* fi, epan_dissect_t* edt);
138
139extern void print_cache_field_handles(void);
140
141#ifdef __cplusplus
142}
143#endif /* __cplusplus */
144
145#endif /* print.h */
WS_DLL_PUBLIC GSList * proto_node_group_children_by_json_key(proto_node *node)
Definition print.c:1091
WS_DLL_PUBLIC GSList * proto_node_group_children_by_unique(proto_node *node)
Definition print.c:1073
Definition print.c:73
Definition proto.h:901
Definition column-info.h:62
Definition epan_dissect.h:28
Definition proto.h:813
Definition file-pcapng.h:57
Definition json_dumper.h:57
Definition print_stream.h:43
Definition stream.c:41