diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-04-20 18:27:41 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-04-21 01:28:15 +0000 |
commit | 8b720910d2ae04aab24709cf30363e9f064e2c63 (patch) | |
tree | 62da61102824a5a03f02a73c6fdfe34777c3d32e /wiretap/peektagged.c | |
parent | c35f2ccb4433718416551cc7a85afb0860529d57 (diff) |
Calculate *Peek tagged timestamps in fixed-point.
Add a variant of filetime_to_nstime() that takes a value that's like a
FILETIME but in units of nanoseconds rather than tenths of a
microsecond, and use that. (It looks as if they might just get FILETIME
values from the OS and multiply them by 100, as the nanosecond-FILETIME
values appear to be multiples of 100 in the captures I've seen, but they
might have chosen nanosecond resolution in case they need to support a
higher-resolution time stamp source, so we don't assume that the values
will always be a multiple of 100.)
Change-Id: If6a1cb2cb673688b042eb113b79cfd267f5454a5
Reviewed-on: https://code.wireshark.org/review/8150
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/peektagged.c')
-rw-r--r-- | wiretap/peektagged.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/wiretap/peektagged.c b/wiretap/peektagged.c index 8d9806899e..51bd43af62 100644 --- a/wiretap/peektagged.c +++ b/wiretap/peektagged.c @@ -462,16 +462,6 @@ wtap_open_return_val peektagged_open(wtap *wth, int *err, gchar **err_info) } /* - * Time stamps appear to be in nanoseconds since the Windows epoch - * as used in FILETIMEs, i.e. midnight, January 1, 1601. - * - * This magic number came from "nt_time_to_nstime()" in "packet-smb.c". - * 1970-1601 is 369; I'm not sure what the extra 3 days and 6 hours are - * that are being subtracted. - */ -#define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60)) - -/* * Read the packet. * * XXX - we should supply the additional radio information; @@ -499,7 +489,7 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, guint32 data_rate_or_mcs_index = 0; struct ieee_802_11_phdr ieee_802_11; int skip_len = 0; - double t; + guint64 t; timestamp.upper = 0; timestamp.lower = 0; @@ -678,12 +668,12 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, phdr->caplen = sliceLength; /* calculate and fill in packet time stamp */ - t = (double) timestamp.lower + - (double) timestamp.upper * 4294967296.0; - t *= 1.0e-9; - t -= TIME_FIXUP_CONSTANT; - phdr->ts.secs = (time_t) t; - phdr->ts.nsecs = (guint32) ((t - phdr->ts.secs)*1000000000); + t = (((guint64) timestamp.upper) << 32) + timestamp.lower; + if (!nsfiletime_to_nstime(&phdr->ts, t)) { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup_printf("peektagged: time stamp outside supported range"); + return -1; + } switch (wth->file_encap) { |