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

# pcap\_set\_datalink(3pcap)

set the link-layer header type to be used by a capture device

## NAME

pcap\_set\_datalink - set the link-layer header type to be used by a capture device

## SYNOPSIS

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

**int pcap\_set\_datalink(pcap\_t \*p, int dlt);**

## DESCRIPTION

**pcap\_set\_datalink**() is used to set the current link-layer header type of the pcap descriptor to the type specified by *dlt*.

## RETURN VALUE

**pcap\_set\_datalink**() returns **0** on success and **PCAP\_ERROR** on failure. If **PCAP\_ERROR** is returned, **pcap\_geterr**(3PCAP) or **pcap\_perror**(3PCAP) may be called with *p* as an argument to fetch or display the error text.

## SEE ALSO

**pcap**(3PCAP), **pcap\_datalink\_name\_to\_val**(3PCAP)
