Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
text_import.h
Go to the documentation of this file.
1
18#ifndef __TEXT_IMPORT_H__
19#define __TEXT_IMPORT_H__
20
21#include <stdio.h>
22#include <wireshark.h>
23
24#include <wiretap/wtap.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif /* __cplusplus */
29
30/* The parameter interface */
31
32enum offset_type
33{
34 OFFSET_NONE = 0,
35 OFFSET_HEX,
36 OFFSET_OCT,
37 OFFSET_DEC
38};
39
40enum data_encoding {
41 ENCODING_PLAIN_HEX,
42 ENCODING_PLAIN_OCT,
43 ENCODING_PLAIN_BIN,
44 ENCODING_BASE64
45};
46
47enum dummy_header_type
48{
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
57};
58
59enum text_import_mode {
60 TEXT_IMPORT_HEXDUMP,
61 TEXT_IMPORT_REGEX
62};
63
64typedef struct
65{
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;
72
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;
87
88 /* Import info */
89 /* Wiretap encapsulation type; see wiretap/wtap.h for details */
90 unsigned encapsulation;
91 wtap_dumper* wdh;
92
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;
111
112 unsigned max_frame_length;
113
114 /* Output info */
115 unsigned num_packets_read;
116 unsigned num_packets_written;
118
119int text_import(text_import_info_t * const info);
120
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.
124 *
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.
128 */
129int
130text_import_pre_open(wtap_dump_params * const params, int file_type_subtype, const char* const input_filename, const char* const interface_name);
131
132#ifdef __cplusplus
133}
134#endif /* __cplusplus */
135
136#endif /* __TEXT_IMPORT_H__ */
Definition inet_addr.h:21
Definition file-pcapng.h:57
Definition text_import.h:65
Definition wtap.h:1537
Definition wtap-int.h:98