1PCAP_DUMP_OPEN(3PCAP) PCAP_DUMP_OPEN(3PCAP)
2
3
4
6 pcap_dump_open, pcap_dump_fopen - open a file to which to write packets
7
9 #include <pcap/pcap.h>
10
11 pcap_dumper_t *pcap_dump_open(pcap_t *p, const char *fname);
12 pcap_dumper_t *pcap_dump_open_append(pcap_t *p, const char *fname);
13 pcap_dumper_t *pcap_dump_fopen(pcap_t *p, FILE *fp);
14
16 pcap_dump_open() is called to open a ``savefile'' for writing. fname
17 specifies the name of the file to open. The file will have the same
18 format as those used by tcpdump(1) and tcpslice(1). The name "-" is a
19 synonym for stdout.
20
21 pcap_dump_fopen() is called to write data to an existing open stream
22 fp; this stream will be closed by a subsequent call to
23 pcap_dump_close(). Note that on Windows, that stream should be opened
24 in binary mode.
25
26 p is a capture or ``savefile'' handle returned by an earlier call to
27 pcap_create() and activated by an earlier call to pcap_activate(), or
28 returned by an earlier call to pcap_open_offline(), pcap_open_live(),
29 or pcap_open_dead(). The time stamp precision, link-layer type, and
30 snapshot length from p are used as the link-layer type and snapshot
31 length of the output file.
32
33 pcap_dump_open_append() is like pcap_dump_open but does not create the
34 file if it does not exist and, if it does already exist, and is a pcap
35 file with the same byte order as the host opening the file, and has the
36 same time stamp precision, link-layer header type, and snapshot length
37 as p, it will write new packets at the end of the file.
38
40 A pointer to a pcap_dumper_t structure to use in subsequent pcap_dump()
41 and pcap_dump_close() calls is returned on success. NULL is returned
42 on failure. If NULL is returned, pcap_geterr(p) can be used to get the
43 error text.
44
46 pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP),
47 pcap_open_offline(3PCAP), pcap_open_live(3PCAP), pcap_open_dead(3PCAP),
48 pcap_dump(3PCAP), pcap_dump_close(3PCAP), pcap_geterr(3PCAP),
49 pcap-savefile(5)
50
51
52
53 22 June 2018 PCAP_DUMP_OPEN(3PCAP)