PCAP\_SET\_DATALINK(3PCAP) PCAP\_SET\_DATALINK(3PCAP)

# [NAME](#NAME)

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

# [SYNOPSIS](#SYNOPSIS)

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

```
int pcap_set_datalink(pcap_t *p, int dlt);
```

# [DESCRIPTION](#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](#RETURN_VALUE)

**pcap\_set\_datalink**() returns **0** on success, **PCAP\_ERROR\_NOT\_ACTIVATED** if called on a capture handle that has been created but not activated, or **PCAP\_ERROR** on other errors. If **PCAP\_ERROR** is returned, [**pcap\_geterr**(3PCAP)](/man/os/libpcap/pcap_geterr.3PCAP) or [**pcap\_perror**(3PCAP)](/man/os/libpcap/pcap_perror.3PCAP) may be called with *p* as an argument to fetch or display the error text.

# [SEE ALSO](#SEE_ALSO)

[**pcap**(3PCAP)](/man/os/libpcap/pcap.3PCAP), [**pcap\_datalink**(3PCAP)](/man/os/libpcap/pcap_datalink.3PCAP), [**pcap\_list\_datalinks**(3PCAP)](/man/os/libpcap/pcap_list_datalinks.3PCAP), [**pcap\_datalink\_name\_to\_val**(3PCAP)](/man/os/libpcap/pcap_datalink_name_to_val.3PCAP)

5 March 2022

---

Document: pcap_set_datalink(3pcap) from libpcap 1.11.0-r0 (Chainguard OS)
Source: https://github.com/the-tcpdump-group/libpcap.git
