---
name: "pcap_list_datalinks"
section: "3pcap"
platform: "linux"
package: "libpcap"
version: "1.11.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/pcap_list_datalinks/3pcap"
---

# pcap\_list\_datalinks(3pcap)

get a list of link-layer header types supported by a capture device, and free that list

## 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

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

**int pcap\_list\_datalinks(pcap\_t \*p, int \*\*dlt\_buf);** **void pcap\_free\_datalinks(int \*dlt\_list);**

## 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) that has not yet been activated by **pcap\_activate**(3PCAP).

## 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) 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\_val\_to\_name**(3PCAP), **pcap\_datalink**(3PCAP), **pcap\_set\_datalink**(3PCAP), [**pcap-linktype**(7)](/pcap-linktype/7.md)
