blob: 3c59372fe1ab714da5d17786067340cd4ddde92f [file] [log] [blame]
Elliott Hughes965a4b52017-05-15 10:37:39 -07001.\" Copyright (c) 1994, 1996, 1997
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that: (1) source code distributions
6.\" retain the above copyright notice and this paragraph in its entirety, (2)
7.\" distributions including binary code include the above copyright notice and
8.\" this paragraph in its entirety in the documentation or other materials
9.\" provided with the distribution, and (3) all advertising materials mentioning
10.\" features or use of this software display the following acknowledgement:
11.\" ``This product includes software developed by the University of California,
12.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
13.\" the University nor the names of its contributors may be used to endorse
14.\" or promote products derived from this software without specific prior
15.\" written permission.
16.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
17.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19.\"
Haibo Huang165065a2018-07-23 17:26:52 -070020.TH PCAP_OPEN_OFFLINE 3PCAP "8 January 2018 "
Elliott Hughes965a4b52017-05-15 10:37:39 -070021.SH NAME
22pcap_open_offline, pcap_open_offline_with_tstamp_precision,
23pcap_fopen_offline, pcap_fopen_offline_with_tstamp_precision \- open a saved capture file for reading
24.SH SYNOPSIS
25.nf
26.ft B
27#include <pcap/pcap.h>
28.ft
29.LP
30.nf
31.ft B
32char errbuf[PCAP_ERRBUF_SIZE];
33.ft
34.LP
35.ft B
36pcap_t *pcap_open_offline(const char *fname, char *errbuf);
37pcap_t *pcap_open_offline_with_tstamp_precision(const char *fname,
38 u_int precision, char *errbuf);
39pcap_t *pcap_fopen_offline(FILE *fp, char *errbuf);
40pcap_t *pcap_fopen_offline_with_tstamp_precision(FILE *fp,
41 u_int precision, char *errbuf);
42.ft
43.fi
44.SH DESCRIPTION
45.B pcap_open_offline()
46and
47.B pcap_open_offline_with_tstamp_precision()
48are called to open a ``savefile'' for reading.
49.PP
50.I fname
51specifies the name of the file to open. The file can have the pcap file
52format as described in
53.BR pcap-savefile (5),
54which is the file format used by, among other programs,
55.BR tcpdump (1)
56and
57.BR tcpslice (1),
Haibo Huang165065a2018-07-23 17:26:52 -070058or can have the pcapng file format, although not all pcapng files can
Elliott Hughes965a4b52017-05-15 10:37:39 -070059be read.
60The name "-" is a synonym for
61.BR stdin .
62.PP
63.B pcap_open_offline_with_tstamp_precision()
64takes an additional
65.I precision
66argument specifying the time stamp precision desired;
67if
68.B PCAP_TSTAMP_PRECISION_MICRO
69is specified, packet time stamps will be supplied in seconds and
70microseconds,
71and if
72.B PCAP_TSTAMP_PRECISION_NANO
73is specified, packet time stamps will be supplied in seconds and
74nanoseconds. If the time stamps in the file do not have the same
75precision as the requested precision, they will be scaled up or down as
76necessary before being supplied.
77.PP
78Alternatively, you may call
79.B pcap_fopen_offline()
80or
81.B pcap_fopen_offline_with_tstamp_precision()
82to read dumped data from an existing open stream
83.IR fp .
84.B pcap_fopen_offline_with_tstamp_precision() takes an additional
85.I precision
86argument as described above.
87Note that on Windows, that stream should be opened in binary mode.
88.SH RETURN VALUE
89.BR pcap_open_offline() ,
90.BR pcap_open_offline_with_tstamp_precision() ,
91.BR pcap_fopen_offline() ,
92and
93.B pcap_fopen_offline_with_tstamp_precision()
94return a
95.I pcap_t *
96on success and
97.B NULL
98on failure.
99If
100.B NULL
101is returned,
102.I errbuf
103is filled in with an appropriate error message.
104.I errbuf
105is assumed to be able to hold at least
106.B PCAP_ERRBUF_SIZE
107chars.
108.SH SEE ALSO
109pcap(3PCAP), pcap-savefile(5)