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__
22 #include <wireshark.h>
24 #include <wiretap/wtap.h>
28 #endif /* __cplusplus */
30 /* The parameter interface */
47 enum dummy_header_type
59 enum text_import_mode
{
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
;
74 FILE *import_text_FILE
;
75 enum offset_type offset_type
;
80 GMappedFile
* import_text_GMappedFile
;
81 /* const */ GRegex
* format
;
82 enum data_encoding encoding
;
83 /* const */ char* in_indication
;
84 /* const */ char* out_indication
;
86 const char* timestamp_format
;
89 /* Wiretap encapsulation type; see wiretap/wtap.h for details */
90 unsigned encapsulation
;
93 /* Dummy header info (if encapsulation == 1) */
94 enum dummy_header_type dummy_header_type
;
110 /* const */ char* payload
;
112 unsigned max_frame_length
;
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
130 text_import_pre_open(wtap_dump_params
* const params
, int file_type_subtype
, const char* const input_filename
, const char* const interface_name
);
134 #endif /* __cplusplus */
136 #endif /* __TEXT_IMPORT_H__ */