-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathpcapio.h
112 lines (102 loc) · 5.35 KB
/
pcapio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* pcapio.h
* Declarations of our own routines for writing libpcap files.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Derived from code in the Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* Writing pcap files */
/** Write the file header to a dump file.
Returns TRUE on success, FALSE on failure.
Sets "*err" to an error code, or 0 for a short write, on failure*/
extern u_int8_t
libpcap_write_file_header(FILE* pfile, int linktype, int snaplen,
u_int8_t ts_nsecs, u_int64_t *bytes_written, int *err);
/** Write a record for a packet to a dump file.
Returns TRUE on success, FALSE on failure. */
extern u_int8_t
libpcap_write_packet(FILE* pfile,
time_t sec, u_int32_t usec,
u_int32_t caplen, u_int32_t len,
const u_int8_t *pd,
u_int64_t *bytes_written, int *err);
/* Writing pcapng files */
/* Write a pre-formatted pcapng block */
extern u_int8_t
pcapng_write_block(FILE* pfile,
const u_int8_t *data,
u_int32_t block_total_length,
u_int64_t *bytes_written,
int *err);
/** Write a section header block (SHB)
*
*/
extern u_int8_t
pcapng_write_section_header_block(FILE* pfile, /**< Write information */
const char *comment, /**< Comment on the section, Optinon 1 opt_comment
* A UTF-8 string containing a comment that is associated to the current block.
*/
const char *hw, /**< HW, Optinon 2 shb_hardware
* An UTF-8 string containing the description of the hardware used to create this section.
*/
const char *os, /**< Operating system name, Optinon 3 shb_os
* An UTF-8 string containing the name of the operating system used to create this section.
*/
const char *appname, /**< Application name, Optinon 4 shb_userappl
* An UTF-8 string containing the name of the application used to create this section.
*/
u_int64_t section_length, /**< Length of section */
u_int64_t *bytes_written, /**< Number of written bytes */
int *err /**< Error type */
);
extern u_int8_t
pcapng_write_interface_description_block(FILE* pfile,
const char *comment, /* OPT_COMMENT 1 */
const char *name, /* IDB_NAME 2 */
const char *descr, /* IDB_DESCRIPTION 3 */
const char *filter, /* IDB_FILTER 11 */
const char *os, /* IDB_OS 12 */
int link_type,
int snap_len,
u_int64_t *bytes_written,
u_int64_t if_speed, /* IDB_IF_SPEED 8 */
u_int8_t tsresol, /* IDB_TSRESOL 9 */
int *err);
extern u_int8_t
pcapng_write_interface_statistics_block(FILE* pfile,
u_int32_t interface_id,
u_int64_t *bytes_written,
const char *comment, /* OPT_COMMENT 1 */
u_int64_t isb_starttime, /* ISB_STARTTIME 2 */
u_int64_t isb_endtime, /* ISB_ENDTIME 3 */
u_int64_t isb_ifrecv, /* ISB_IFRECV 4 */
u_int64_t isb_ifdrop, /* ISB_IFDROP 5 */
int *err);
extern u_int8_t
pcapng_write_enhanced_packet_block(FILE* pfile,
const char *comment,
time_t sec, u_int32_t usec,
u_int32_t caplen, u_int32_t len,
u_int32_t interface_id,
u_int32_t ts_mul,
const u_int8_t *pd,
u_int32_t flags,
u_int64_t *bytes_written,
int *err);
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/