diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-11-04 18:08:47 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-11-05 02:09:14 +0000 |
commit | cd93af0ed16dba3c4b2ad3f9e0874d0ddd8877dc (patch) | |
tree | ad29b33c79adfb2cfd3df0d57b8a6c7743095da0 /caputils/capture-pcap-util-unix.c | |
parent | 6f3fc0ee7e83660222ff709c59d61f910d73379f (diff) |
Oops, we also need to worry about pcap_get_tstamp_precision().
Change-Id: I60a1f671ba313c59ca1999ab703ee11370608758
Reviewed-on: https://code.wireshark.org/review/5123
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'caputils/capture-pcap-util-unix.c')
-rw-r--r-- | caputils/capture-pcap-util-unix.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/caputils/capture-pcap-util-unix.c b/caputils/capture-pcap-util-unix.c index fa1fc0901f..cdc55a04f0 100644 --- a/caputils/capture-pcap-util-unix.c +++ b/caputils/capture-pcap-util-unix.c @@ -385,6 +385,41 @@ request_high_resolution_timestamp(pcap_t *pcap_h) pcap_set_tstamp_precision(pcap_h, PCAP_TSTAMP_PRECISION_NANO); #endif /* __APPLE__ */ } + +/* + * Return TRUE if the pcap_t in question is set up for high-precision + * time stamps, FALSE otherwise. + */ +gboolean +have_high_resolution_timestamp(pcap_t *pcap_h) +{ +#ifdef __APPLE__ + /* + * See above. + */ + static gboolean initialized = FALSE; + static int (*p_pcap_get_tstamp_precision)(pcap_t *); + + if (!initialized) { + p_pcap_get_tstamp_precision = + (int (*)(pcap_t *)) + dlsym(RTLD_NEXT, "pcap_get_tstamp_precision"); + initialized = TRUE; + } + if (p_pcap_get_tstamp_precision != NULL) + return (*p_pcap_get_tstamp_precision)(pcap_h) == PCAP_TSTAMP_PRECISION_NANO; + else + return FALSE; /* Can't get implies couldn't set */ +#else /* __APPLE__ */ + /* + * On other UN*Xes we require that we be run on an OS version + * with a libpcap equal to or later than the version with which + * we were built. + */ + return pcap_get_tstamp_precision(pcap_h) == PCAP_TSTAMP_PRECISION_NANO; +#endif /* __APPLE__ */ +} + #endif /* HAVE_PCAP_SET_TSTAMP_PRECISION */ /* |