PCAP_SET_TSTAMP_PRECISION(3PCAP)

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

πŸ’– NAME πŸ’–

okay bestie, this is PCAP_SET_TSTAMP_PRECISION(3PCAP) β€” yep, the 3PCAP manual β€” and the actual name is pcap_set_tstamp_precision: it sets the time stamp precision returned in captures. She’s specific, she’s useful, she slays. πŸ’…

✨ SYNOPSIS ✨

#include <pcap/pcap.h>

int pcap_set_tstamp_precision(pcap_t *p, int tstamp_precision);

🌸 DESCRIPTION 🌸

So pcap_set_tstamp_precision() sets the precision of the time stamp you want for packets captured on the pcap descriptor, using the type you pass in tstamp_precision. Iconic behavior. πŸŽ€

🚨 important vibe check: it must be called on a pcap descriptor created by pcap_create(3PCAP) that has not yet been activated by pcap_activate(3PCAP). No activating it first, bestie β€” that’s not the move. 😭

There are two time stamp precisions supported, microseconds and nanoseconds. You can use the options:

  • PCAP_TSTAMP_PRECISION_MICRO β€” request microsecond precision.
  • PCAP_TSTAMP_PRECISION_NANO β€” request nanosecond precision.

By default, time stamps are in microseconds. Periodt. ⭐

πŸ’… RETURN VALUE πŸ’…

pcap_set_tstamp_precision() returns:

  • 0 on success, if the specified time stamp precision is expected to be supported by the capture device β€” we love a supportive device 🫢
  • PCAP_ERROR_TSTAMP_PRECISION_NOTSUP if the capture device does not support the requested time stamp precision β€” the device said no πŸ’€
  • PCAP_ERROR_ACTIVATED if called on a capture handle that has been activated β€” you activated it first, bestie, and the function noticed πŸ™ˆ

πŸ¦‹ BACKWARD COMPATIBILITY πŸ¦‹

This function became available in libpcap release 1.5.1 🌈. In previous releases, time stamps from a capture device or savefile are always given in seconds and microseconds. So if you’re time-traveling in old libpcap, that’s the deal. πŸ•°οΈ

πŸ”₯ SEE ALSO πŸ”₯


xoxo, the PCAP_SET_TSTAMP_PRECISION(3PCAP) page from libpcap πŸ’– β€” dated 23 August 2018 πŸŽ€

πŸ“¦ where this page comes from