PCAP_SET_TSTAMP_PRECISION(3)

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

🌸 NAME 🌸

pcap_set_tstamp_precision β€” set the time stamp precision returned in captures. That’s the whole assignment, bestie: you’re telling libpcap what time-stamp precision you want for captured packets, no cap.

This page lives in the Library Functions Manual, and it’s giving very specific β€œconfigure your capture handle before you activate it” energy. πŸ’…


✨ SYNOPSIS ✨

#include <pcap/pcap.h>

int pcap_set_tstamp_precision(pcap_t *p, int tstamp_precision);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so pcap_set_tstamp_precision() sets the precision of the time stamp desired for packets captured on the pcap descriptor to the type specified by tstamp_precision.

The way that this works is: it must be called on a pcap descriptor created by pcap_create(3) that has not yet been activated by pcap_activate(3). Like, do not try to sneak this in after activation β€” that’s not the vibe. πŸ™ˆ

Two time stamp precisions are supported, bestie:

  • microseconds
  • nanoseconds

You can use these options to request the precision you want:

  • PCAP_TSTAMP_PRECISION_MICRO
  • PCAP_TSTAMP_PRECISION_NANO

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. Slay. ✨

It can also return:

  • PCAP_ERROR_TSTAMP_PRECISION_NOTSUP β€” if the capture device does not support the requested time stamp precision.
  • PCAP_ERROR_ACTIVATED β€” if called on a capture handle that has been activated.
Like, read the room: if the handle is already activated, PCAP_ERROR_ACTIVATED is the energy you get. πŸ’€

πŸŽ€ 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 through old libpcap versions, that’s the situation. πŸ•°οΈ


🌈 SEE ALSO 🌈


Mwah πŸ’‹ β€” signing off from the Library Functions Manual, page PCAP_SET_T...P_PRECISION(3), dated 23 August 2018. Stay precise, bestie. 🫢✨

πŸ“¦ where this page comes from