---
name: "pcap_list_datalinks"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/pcap_free_datalinks"
---

# pcap\_list\_datalinks(3)

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

Part of [pcap\_free\_datalinks(3)](/pcap_free_datalinks/3.md).

## 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**(3)](/pcap_create/3.md) that has not yet been activated by [**pcap\_activate**(3)](/pcap_activate/3.md).

## 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**(3)](/pcap_geterr/3.md) or [**pcap\_perror**(3)](/pcap_perror/3.md) may be called with *p* as an argument to fetch or display the error text.

## SEE ALSO

[**pcap**(3)](/pcap/3.md), [**pcap\_datalink\_val\_to\_name**(3)](/pcap_datalink_val_to_name/3.md), [**pcap-linktype**(7)](/pcap-linktype/7.md)
