| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
Classes | Enumerations | Functions
text_import.h File Reference
`#include <stdio.h>`
`#include <wireshark.h>`
`#include <wiretap/wtap.h>`

Go to the source code of this file.

## Classes
struct | text_import_info_t
| Complete configuration and runtime state for a text-to-pcap import operation. More...

## Enumerations
enum | offset_type { OFFSET_NONE = 0 , OFFSET_HEX , OFFSET_OCT , OFFSET_DEC }
| Numeric base used to render byte offsets in a hex dump import. More...
enum | data_encoding { ENCODING_PLAIN_HEX , ENCODING_PLAIN_OCT , ENCODING_PLAIN_BIN , ENCODING_BASE64 }
| Encoding used to represent raw byte data in a regex-mode text import. More...
enum | dummy_header_type { HEADER_NONE , HEADER_ETH , HEADER_IPV4 , HEADER_UDP , HEADER_TCP , HEADER_SCTP , HEADER_SCTP_DATA , HEADER_EXPORT_PDU }
| Selects the synthetic protocol header prepended to each imported frame. More...
enum | text_import_mode { TEXT_IMPORT_HEXDUMP , TEXT_IMPORT_REGEX }
| Selects the parsing mode used to extract packet data from the input text file. More...

## Functions
int | text_import (text_import_info_t *const info)
| Import a text file.
int | text_import_pre_open (wtap_dump_params *const params, int file_type_subtype, const char *const input_filename, const char *const interface_name)
| Prepares the wtap_dump_params with necessary headers before opening the wtap dump file.

## Detailed Description

text_import.h State machine for text import November 2010, Jaap Keuter jaap..nosp@m.keut.nosp@m.er@xs.nosp@m.4all.nosp@m..nl Modified February 2021, Paul Weiß

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs

Based on text2pcap.h by Ashok Narayanan ashok.nosp@m.n@ci.nosp@m.sco.c.nosp@m.om

SPDX-License-Identifier: GPL-2.0-or-later*

## Enumeration Type Documentation

## ◆ data_encoding

enum data_encoding

Encoding used to represent raw byte data in a regex-mode text import.

Enumerator
ENCODING_PLAIN_HEX | Bytes encoded as plain hexadecimal digit pairs
ENCODING_PLAIN_OCT | Bytes encoded as plain octal digit groups
ENCODING_PLAIN_BIN | Bytes encoded as plain binary digit groups
ENCODING_BASE64 | Bytes encoded as Base64

## ◆ dummy_header_type

enum dummy_header_type

Selects the synthetic protocol header prepended to each imported frame.

Enumerator
HEADER_NONE | No dummy header; raw payload only
HEADER_ETH | Prepend a dummy Ethernet II header
HEADER_IPV4 | Prepend a dummy IPv4 header
HEADER_UDP | Prepend dummy IPv4 and UDP headers
HEADER_TCP | Prepend dummy IPv4 and TCP headers
HEADER_SCTP | Prepend dummy IPv4 and SCTP headers
HEADER_SCTP_DATA | Prepend dummy IPv4, SCTP, and SCTP DATA chunk headers
HEADER_EXPORT_PDU | Prepend a Wireshark Export PDU header

## ◆ offset_type

enum offset_type

Numeric base used to render byte offsets in a hex dump import.

Enumerator
OFFSET_NONE | No offset column present in the input
OFFSET_HEX | Offsets are written in hexadecimal
OFFSET_OCT | Offsets are written in octal
OFFSET_DEC | Offsets are written in decimal

## ◆ text_import_mode

enum text_import_mode

Selects the parsing mode used to extract packet data from the input text file.

Enumerator
TEXT_IMPORT_HEXDUMP | Parse input as a hex dump with optional offset and ASCII columns
TEXT_IMPORT_REGEX | Parse input by matching lines against a user-supplied regular expression

## Function Documentation

## ◆ text_import()

int text_import | ( | text_import_info_t *const | info | ) |

Import a text file.

This function imports a text file and writes the SHB and IDB to the wtap_dump_params before opening the wtap dump file. It initializes various parameters for packet processing, including timestamps and direction.

Parameters

  info | Pointer to the text import information structure.

Returns
  Return status of the import operation.

## ◆ text_import_pre_open()

int text_import_pre_open | ( | wtap_dump_params *const | params,
|  | int | file_type_subtype,
|  | const char *const | input_filename,
|  | const char *const | interface_name )

Prepares the wtap_dump_params with necessary headers before opening the wtap dump file.

Write the SHB and IDB to the wtap_dump_params before opening the wtap dump file. While dummy headers can be written automatically, this writes out some extra information including an optional interface name.

NOTE: The caller will be responsible for freeing params->idb_inf after finished with the wtap_dumper to avoid a memory leak. wtap_dump_close does not free it.

Parameters

  params | Pointer to the wtap_dump_params structure.
  file_type_subtype | The type of the file to be opened.
  input_filename | The name of the input file.
  interface_name | The name of the interface.

Returns
  Return status of the preparation operation.