PCAP_LIST_TSTAMP_TYPES(3PCAP)

πŸ“¦
version 1.10.7 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, centos-stream 10, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

okay so bestie, welcome to PCAP_LIST_TSTAMP_TYPES(3PCAP) β€” the manual page that’s literally giving β€œwhich time stamp types can my capture device serve, and how do I free that list after?” energy. ✨

πŸŽ€ NAME πŸŽ€

  • pcap_list_tstamp_types, pcap_free_tstamp_types β€” get a list of time stamp types supported by a capture device, and free that list. πŸ’…

✨ SYNOPSIS ✨

#include <pcap/pcap.h>

int pcap_list_tstamp_types(pcap_t *p, int **tstamp_typesp);
void pcap_free_tstamp_types(int *tstamp_types);

πŸ’– DESCRIPTION πŸ’–

pcap_list_tstamp_types() is used to get a list of the supported time stamp types of the interface associated with the pcap descriptor. It allocates an array to hold the list and sets *tstamp_typesp to point to the array. See pcap-tstamp(7) for a list of all the time stamp types. πŸ‘‘

The caller is responsible for freeing the array with pcap_free_tstamp_types(), which frees the list pointed to by tstamp_types. So yeah, cleanup is your main character moment, not libpcap’s. 🫢

πŸ”₯ RETURN VALUE πŸ”₯

pcap_list_tstamp_types() returns the number of time stamp types in the array on success and PCAP_ERROR on failure.

  • Return value 1? That means the only time stamp type supported is the one in the list, which is the capture device’s default time stamp type. Slay, singular. πŸ’…
  • Return value 0? That means the only time stamp type supported is PCAP_TSTAMP_HOST, which is the capture device’s default time stamp type. (Only older versions of libpcap will return that; newer versions will always return one or more types.) Iconic legacy behavior, ngl. πŸ•°οΈ

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. So you can get the tea on what went wrong. 😭

🌈 BACKWARD COMPATIBILITY 🌈

These functions became available in libpcap release 1.2.1. In previous releases, the time stamp type cannot be set; only the default time stamp type offered by a capture source is available. So if you’re time-traveling to older libpcap, adjust your expectations, bestie. ⏳

πŸ’œ SEE ALSO πŸ’œ


mwah πŸ’‹ β€” source/version: PCAP_LIST_TSTAMP_TYPES(3PCAP), dated 8 September 2019.

πŸ“¦ where this page comes from