PCAP\_LIST\_DATALINKS(3PCAP) PCAP\_LIST\_DATALINKS(3PCAP)

# [NAME](#NAME)

pcap\_list\_datalinks, pcap\_free\_datalinks - get a list of link-layer header types supported by a capture device, and free that list

# [SYNOPSIS](#SYNOPSIS)

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

```
int pcap_list_datalinks(pcap_t *p, int **dlt_buf);
void pcap_free_datalinks(int *dlt_list);
```

# [DESCRIPTION](#DESCRIPTION)

**pcap\_list\_datalinks**() is used to get a list of the supported link-layer header types of the interface associated with the pcap descriptor. **pcap\_list\_datalinks**() allocates an array to hold the list and sets *\*dlt\_buf* to point to that array.

The caller is responsible for freeing the array with **pcap\_free\_datalinks**(), which frees the list of link-layer header types pointed to by *dlt\_list*.

It must not be called on a pcap descriptor created by [**pcap\_create**(3PCAP)](/man/os/libpcap/pcap_create.3PCAP) that has not yet been activated by [**pcap\_activate**(3PCAP)](/man/os/libpcap/pcap_activate.3PCAP).

# [RETURN VALUE](#RETURN_VALUE)

**pcap\_list\_datalinks**() returns the number of link-layer header types in the array on success, **PCAP\_ERROR\_NOT\_ACTIVATED** if called on a capture handle that has been created but not activated, and **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\_val\_to\_name**(3PCAP)](/man/os/libpcap/pcap_datalink_val_to_name.3PCAP), [**pcap\_datalink**(3PCAP)](/man/os/libpcap/pcap_datalink.3PCAP), [**pcap\_set\_datalink**(3PCAP)](/man/os/libpcap/pcap_set_datalink.3PCAP), [**pcap-linktype**(7)](/man/os/libpcap/pcap-linktype.7)

25 July 2018

---

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