Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / ui / text_import.h
blob28c1cd2d0c299735010d78ced375a7a9595b12ec
1 /** @file
3 * text_import.h
4 * State machine for text import
5 * November 2010, Jaap Keuter <jaap.keuter@xs4all.nl>
6 * Modified February 2021, Paul Weiß
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * Based on text2pcap.h by Ashok Narayanan <ashokn@cisco.com>
14 * SPDX-License-Identifier: GPL-2.0-or-later*
15 *******************************************************************************/
18 #ifndef __TEXT_IMPORT_H__
19 #define __TEXT_IMPORT_H__
21 #include <stdio.h>
22 #include <wireshark.h>
24 #include <wiretap/wtap.h>
26 #ifdef __cplusplus
27 extern "C" {
28 #endif /* __cplusplus */
30 /* The parameter interface */
32 enum offset_type
34 OFFSET_NONE = 0,
35 OFFSET_HEX,
36 OFFSET_OCT,
37 OFFSET_DEC
40 enum data_encoding {
41 ENCODING_PLAIN_HEX,
42 ENCODING_PLAIN_OCT,
43 ENCODING_PLAIN_BIN,
44 ENCODING_BASE64
47 enum dummy_header_type
49 HEADER_NONE,
50 HEADER_ETH,
51 HEADER_IPV4,
52 HEADER_UDP,
53 HEADER_TCP,
54 HEADER_SCTP,
55 HEADER_SCTP_DATA,
56 HEADER_EXPORT_PDU
59 enum text_import_mode {
60 TEXT_IMPORT_HEXDUMP,
61 TEXT_IMPORT_REGEX
64 typedef struct
66 /* Input info */
67 // TODO: add const, as this way string constants can't be used
68 // BUT: the other way clang-check complains when you free them
69 /* const */ char *import_text_filename;
70 char *output_filename;
71 enum text_import_mode mode;
73 struct {
74 FILE *import_text_FILE;
75 enum offset_type offset_type;
76 bool has_direction;
77 bool identify_ascii;
78 } hexdump;
79 struct {
80 GMappedFile* import_text_GMappedFile;
81 /* const */ GRegex* format;
82 enum data_encoding encoding;
83 /* const */ char* in_indication;
84 /* const */ char* out_indication;
85 } regex;
86 const char* timestamp_format;
88 /* Import info */
89 /* Wiretap encapsulation type; see wiretap/wtap.h for details */
90 unsigned encapsulation;
91 wtap_dumper* wdh;
93 /* Dummy header info (if encapsulation == 1) */
94 enum dummy_header_type dummy_header_type;
95 unsigned pid;
96 bool ipv6;
97 union {
98 ws_in4_addr ipv4;
99 ws_in6_addr ipv6;
100 } ip_src_addr;
101 union {
102 ws_in4_addr ipv4;
103 ws_in6_addr ipv6;
104 } ip_dest_addr;
105 unsigned protocol;
106 unsigned src_port;
107 unsigned dst_port;
108 unsigned tag;
109 unsigned ppi;
110 /* const */ char* payload;
112 unsigned max_frame_length;
114 /* Output info */
115 unsigned num_packets_read;
116 unsigned num_packets_written;
117 } text_import_info_t;
119 int text_import(text_import_info_t * const info);
121 /* Write the SHB and IDB to the wtap_dump_params before opening the wtap dump
122 * file. While dummy headers can be written automatically, this writes out
123 * some extra information including an optional interface name.
125 * NOTE: The caller will be responsible for freeing params->idb_inf after
126 * finished with the wtap_dumper to avoid a memory leak. wtap_dump_close
127 * does not free it.
130 text_import_pre_open(wtap_dump_params * const params, int file_type_subtype, const char* const input_filename, const char* const interface_name);
132 #ifdef __cplusplus
134 #endif /* __cplusplus */
136 #endif /* __TEXT_IMPORT_H__ */