PCAP_LIST_DATALINKS(3)
πΈ PCAP_LIST_DATALINKS(3) β pcap_list_datalinks & pcap_free_datalinks, the datalink lineup era β¨π
π NAME π
pcap_list_datalinks, pcap_free_datalinks β get a list of link-layer header types supported by a capture device, and free that list. That's the whole assignment, bestie π«Ά.
π¦ SYNOPSIS π¦
#include <pcap/pcap.h>
int pcap_list_datalinks(pcap_t *p, int **dlt_buf);
void pcap_free_datalinks(int *dlt_list);
β¨ DESCRIPTION β¨
okay so pcap_list_datalinks() is the main character: it gets the list of supported link-layer header types of the interface associated with the pcap descriptor. It allocates an array to hold the list and sets *dlt_buf to point to that array. Very demure, very mindful, very allocated π
.
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. Basically: you got the list, now clean up your room. No leaving memory lying around like yesterday's boba cup ππ§.
π¨ important vibe check: it must not be called on a pcap descriptor created bypcap_create(3)that has not yet been activated bypcap_activate(3). Like, the handle has to be activated first, or it's a no from the library, bestie π.
π RETURN VALUE π
pcap_list_datalinks() returns the number of link-layer header types in the array on success. Slay. Count 'em, queen π.
- It returns
PCAP_ERROR_NOT_ACTIVATEDif called on a capture handle that has been created but not activated. - It returns
PCAP_ERRORon other errors.
If PCAP_ERROR is returned, pcap_geterr(3) or pcap_perror(3) may be called with p as an argument to fetch or display the error text. So yeah, you can get the error tea ββ¨.
π SEE ALSO π
xoxo bestie π this little icon is from the Library Functions Manual and is dated 25 July 2018 β PCAP_LIST_DATALINKS(3) signing off ππ¦
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1994, 1996, 1997 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms