---
name: "pcap_open_dead"
section: "3pcap"
platform: "macos"
package: "libpcap"
version: "146"
release: "macOS 26.5"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/pcap_open_dead/3pcap"
---

# pcap\_open\_dead(3pcap)

open a fake pcap\_t for compiling filters or opening a capture for output

## NAME

pcap\_open\_dead, pcap\_open\_dead\_with\_tstamp\_precision - open a fake pcap\_t for compiling filters or opening a capture for output

## SYNOPSIS

```
#include <pcap/pcap.h>
```

**pcap\_t \*pcap\_open\_dead(int linktype, int snaplen);** **pcap\_t \*pcap\_open\_dead\_with\_tstamp\_precision(int linktype, int snaplen,**\
     **u\_int precision);**

## DESCRIPTION

**pcap\_open\_dead**() and **pcap\_open\_dead\_with\_tstamp\_precision**() are used for creating a **pcap\_t** structure to use when calling the other functions in libpcap.  It is typically used when just using libpcap for compiling BPF code; it can also be used if using **pcap\_dump\_open**(3PCAP), **pcap\_dump**(3PCAP), and **pcap\_dump\_close**(3PCAP) to write a savefile if there is no **pcap\_t** that supplies the packets to be written.

*linktype* specifies the link-layer type for the **pcap\_t**.

*snaplen* specifies the snapshot length for the **pcap\_t**.

When **pcap\_open\_dead\_with\_tstamp\_precision**(), is used to create a **pcap\_t** for use with **pcap\_dump\_open**(), *precision* specifies the time stamp precision for packets; **PCAP\_TSTAMP\_PRECISION\_MICRO** should be specified if the packets to be written have time stamps in seconds and microseconds, and **PCAP\_TSTAMP\_PRECISION\_NANO** should be specified if the packets to be written have time stamps in seconds and nanoseconds.  Its value does not affect **pcap\_compile**(3PCAP).

## BACKWARD COMPATIBILITY

The **pcap\_open\_dead\_with\_tstamp\_precision**() function became available in libpcap release 1.5.1.  In previous releases, there was no mechanism to open a savefile for writing with time stamps given in seconds and nanoseconds.

## SEE ALSO

**pcap**(3PCAP), [**pcap-linktype**(7)](/pcap-linktype/7.md)
