PCAP_LIST_DATALINKS(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’– 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 by pcap_create(3) that has not yet been activated by pcap_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_ACTIVATED if called on a capture handle that has been created but not activated.
  • It returns PCAP_ERROR on 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