NAME |SYNOPSIS |DESCRIPTION |RETURN VALUE |BACKWARD COMPATIBILITY |SEE ALSO |COLOPHON | |
PCAP_OPEN_OFFLINE(3PCAP)PCAP_OPEN_OFFLINE(3PCAP)pcap_open_offline, pcap_open_offline_with_tstamp_precision, pcap_fopen_offline, pcap_fopen_offline_with_tstamp_precision - open a saved capture file for reading
#include <pcap/pcap.h>char errbuf[PCAP_ERRBUF_SIZE];pcap_t *pcap_open_offline(const char *fname, char *errbuf);pcap_t *pcap_open_offline_with_tstamp_precision(const char *fname,u_int precision, char *errbuf);pcap_t *pcap_fopen_offline(FILE *fp, char *errbuf);pcap_t *pcap_fopen_offline_with_tstamp_precision(FILE *fp,u_int precision, char *errbuf);
pcap_open_offline() andpcap_open_offline_with_tstamp_precision() are called to open a ``savefile'' for reading.fname specifies the name of the file to open. The file can have the pcap file format as described inpcap-savefile(5), which is the file format used by, among other programs,tcpdump(1) andtcpslice(1), or can have the pcapng file format, although not all pcapng files can be read. The name "-" is a synonym forstdin.pcap_open_offline_with_tstamp_precision() takes an additionalprecision argument specifying the time stamp precision desired; ifPCAP_TSTAMP_PRECISION_MICROis specified, packet time stamps will be supplied in seconds and microseconds, and ifPCAP_TSTAMP_PRECISION_NANOis specified, packet time stamps will be supplied in seconds and nanoseconds. If the time stamps in the file do not have the same precision as the requested precision, they will be scaled up or down as necessary before being supplied. Alternatively, you may callpcap_fopen_offline() orpcap_fopen_offline_with_tstamp_precision() to read dumped data from an existing open streamfp; this stream will be closed by a subsequent call topcap_close(3PCAP) unless it isstdin.pcap_fopen_offline_with_tstamp_precision() takes an additionalprecision argument as described above. Note that on Windows, that stream should be opened in binary mode.errbuf is a buffer large enough to hold at leastPCAP_ERRBUF_SIZE chars.
pcap_open_offline(),pcap_open_offline_with_tstamp_precision(),pcap_fopen_offline(), andpcap_fopen_offline_with_tstamp_precision() return apcap_t *on success andNULLon failure. IfNULLis returned,errbuf is filled in with an appropriate error message.
pcap_open_offline_with_tstamp_precision() andpcap_fopen_offline_with_tstamp_precision() became available in libpcap release 1.5.1. In previous releases, time stamps from a savefile are always given in seconds and microseconds.
pcap(3PCAP),pcap-savefile(5)
This page is part of thelibpcap (packet capture library) project. Information about the project can be found at ⟨http://www.tcpdump.org/⟩. If you have a bug report for this manual page, see ⟨http://www.tcpdump.org/#patches⟩. This page was obtained from the project's upstream Git repository ⟨https://github.com/the-tcpdump-group/libpcap.git⟩ on 2025-08-11. (At that time, the date of the most recent commit that was found in the repository was 2025-08-10.) If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.org 12 October 2024PCAP_OPEN_OFFLINE(3PCAP)HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |