LATER... ei_kerberos_kdc_session_key ...
[wireshark-sm.git] / ui / text_import.h
blobb845075409d3c5734445c3749592b182f9aa9d64
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 bool little_endian;
79 } hexdump;
80 struct {
81 GMappedFile* import_text_GMappedFile;
82 /* const */ GRegex* format;
83 enum data_encoding encoding;
84 /* const */ char* in_indication;
85 /* const */ char* out_indication;
86 } regex;
87 const char* timestamp_format;
89 /* Import info */
90 /* Wiretap encapsulation type; see wiretap/wtap.h for details */
91 unsigned encapsulation;
92 wtap_dumper* wdh;
94 /* Dummy header info (if encapsulation == 1) */
95 enum dummy_header_type dummy_header_type;
96 unsigned pid;
97 bool ipv6;
98 union {
99 ws_in4_addr ipv4;
100 ws_in6_addr ipv6;
101 } ip_src_addr;
102 union {
103 ws_in4_addr ipv4;
104 ws_in6_addr ipv6;
105 } ip_dest_addr;
106 unsigned protocol;
107 unsigned src_port;
108 unsigned dst_port;
109 unsigned tag;
110 unsigned ppi;
111 /* const */ char* payload;
113 unsigned max_frame_length;
115 /* Output info */
116 unsigned num_packets_read;
117 unsigned num_packets_written;
118 } text_import_info_t;
120 int text_import(text_import_info_t * const info);
122 /* Write the SHB and IDB to the wtap_dump_params before opening the wtap dump
123 * file. While dummy headers can be written automatically, this writes out
124 * some extra information including an optional interface name.
126 * NOTE: The caller will be responsible for freeing params->idb_inf after
127 * finished with the wtap_dumper to avoid a memory leak. wtap_dump_close
128 * does not free it.
131 text_import_pre_open(wtap_dump_params * const params, int file_type_subtype, const char* const input_filename, const char* const interface_name);
133 #ifdef __cplusplus
135 #endif /* __cplusplus */
137 #endif /* __TEXT_IMPORT_H__ */