aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-08-24 21:31:56 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-08-24 21:31:56 +0000
commit6f43fbb2f088438dae20d4007df830863391b1c6 (patch)
tree7be99a00405385c14e1606c31906463d60107655 /wiretap
parentef81f7d060f39b43cc8eadf86c8e965a3e820225 (diff)
EVERYTHING IN THE BUILDBOT IS GOING TO BE RED!!! Sorry!
I've done more than a day to change the timestamp resolution from microseconds to nanoseconds. As I really don't want to loose those changes, I'm going to check in the changes I've done so far. Hopefully someone else will give me a helping hand with the things left ... What's done: I've changed the timestamp resolution from usec to nsec in almost any place in the sources. I've changed parts of the implementation in nstime.s/.h and a lot of places elsewhere. As I don't understand the editcap source (well, I'm maybe just too tired right now), hopefully someone else might be able to fix this soon. Doing all those changes, we get native nanosecond timestamp resolution in Ethereal. After fixing all the remaining issues, I'll take a look how to display this in a convenient way... As I've also changed the wiretap timestamp resolution from usec to nsec we might want to change the wiretap version number... svn path=/trunk/; revision=15520
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/5views.c8
-rw-r--r--wiretap/airopeek9.c4
-rw-r--r--wiretap/ascend.c4
-rw-r--r--wiretap/cosine.c4
-rw-r--r--wiretap/csids.c4
-rw-r--r--wiretap/dbs-etherwatch.c5
-rw-r--r--wiretap/erf.c10
-rw-r--r--wiretap/etherpeek.c10
-rw-r--r--wiretap/eyesdn.c4
-rw-r--r--wiretap/file_access.c1
-rw-r--r--wiretap/hcidump.c4
-rw-r--r--wiretap/i4btrace.c4
-rw-r--r--wiretap/iptrace.c8
-rw-r--r--wiretap/k12.c6
-rw-r--r--wiretap/lanalyzer.c14
-rw-r--r--wiretap/libpcap.c16
-rw-r--r--wiretap/netmon.c16
-rw-r--r--wiretap/nettl.c20
-rw-r--r--wiretap/network_instruments.c14
-rw-r--r--wiretap/netxray.c32
-rw-r--r--wiretap/ngsniffer.c12
-rw-r--r--wiretap/pppdump.c4
-rw-r--r--wiretap/radcom.c4
-rw-r--r--wiretap/snoop.c8
-rw-r--r--wiretap/toshiba.c4
-rw-r--r--wiretap/visual.c10
-rw-r--r--wiretap/vms.c5
-rw-r--r--wiretap/wtap-int.h6
-rw-r--r--wiretap/wtap.c6
-rw-r--r--wiretap/wtap.def1
-rw-r--r--wiretap/wtap.h14
31 files changed, 145 insertions, 117 deletions
diff --git a/wiretap/5views.c b/wiretap/5views.c
index c17101449d..38fc251ef9 100644
--- a/wiretap/5views.c
+++ b/wiretap/5views.c
@@ -251,8 +251,8 @@ _5views_read(wtap *wth, int *err, gchar **err_info _U_, long *data_offset)
TimeStamped_Header.Utc = pletohl(&TimeStamped_Header.Utc);
TimeStamped_Header.NanoSecondes =
pletohl(&TimeStamped_Header.NanoSecondes);
- wth->phdr.ts.tv_sec = TimeStamped_Header.Utc;
- wth->phdr.ts.tv_usec = TimeStamped_Header.NanoSecondes/1000;
+ wth->phdr.ts.secs = TimeStamped_Header.Utc;
+ wth->phdr.ts.nsecs = TimeStamped_Header.NanoSecondes;
wth->phdr.caplen = packet_size;
wth->phdr.len = orig_size;
@@ -414,8 +414,8 @@ static gboolean _5views_dump(wtap_dumper *wdh,
HeaderFrame.RecNb = htolel(1);
/* record-dependant fields */
- HeaderFrame.Utc = htolel(phdr->ts.tv_sec);
- HeaderFrame.NanoSecondes = htolel(phdr->ts.tv_usec*1000);
+ HeaderFrame.Utc = htolel(phdr->ts.secs);
+ HeaderFrame.NanoSecondes = htolel(phdr->ts.nsecs);
HeaderFrame.RecSize = htolel(phdr->len);
HeaderFrame.RecInfo = htolel(0);
diff --git a/wiretap/airopeek9.c b/wiretap/airopeek9.c
index 8cc276f54a..2eee7f5f76 100644
--- a/wiretap/airopeek9.c
+++ b/wiretap/airopeek9.c
@@ -509,8 +509,8 @@ static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info,
t *= 1.0e-9;
t -= TIME_FIXUP_CONSTANT;
- wth->phdr.ts.tv_sec = (time_t) t;
- wth->phdr.ts.tv_usec = (guint32) ((t - wth->phdr.ts.tv_sec)*1000000);
+ wth->phdr.ts.secs = (time_t) t;
+ wth->phdr.ts.nsecs = (guint32) ((t - wth->phdr.ts.secs)*1000000000);
switch (wth->file_encap) {
diff --git a/wiretap/ascend.c b/wiretap/ascend.c
index 5c57279905..0145aec796 100644
--- a/wiretap/ascend.c
+++ b/wiretap/ascend.c
@@ -298,8 +298,8 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
if (wth->capture.ascend->inittime > header.secs)
wth->capture.ascend->inittime -= header.secs;
}
- wth->phdr.ts.tv_sec = header.secs + wth->capture.ascend->inittime;
- wth->phdr.ts.tv_usec = header.usecs;
+ wth->phdr.ts.secs = header.secs + wth->capture.ascend->inittime;
+ wth->phdr.ts.nsecs = header.usecs * 1000;
wth->phdr.caplen = header.caplen;
wth->phdr.len = header.len;
wth->data_offset = offset;
diff --git a/wiretap/cosine.c b/wiretap/cosine.c
index 2b8138910c..e185ea9f7f 100644
--- a/wiretap/cosine.c
+++ b/wiretap/cosine.c
@@ -418,8 +418,8 @@ parse_cosine_rec_hdr(wtap *wth, const char *line,
tm.tm_min = min;
tm.tm_sec = sec;
tm.tm_isdst = -1;
- wth->phdr.ts.tv_sec = mktime(&tm);
- wth->phdr.ts.tv_usec = csec * 10000;
+ wth->phdr.ts.secs = mktime(&tm);
+ wth->phdr.ts.nsecs = csec * 10000000;
wth->phdr.len = pkt_len;
}
/* XXX need to handle other encapsulations like Cisco HDLC,
diff --git a/wiretap/csids.c b/wiretap/csids.c
index 4312c3a4fa..ff7c55c687 100644
--- a/wiretap/csids.c
+++ b/wiretap/csids.c
@@ -180,8 +180,8 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
wth->phdr.len = hdr.caplen;
wth->phdr.caplen = hdr.caplen;
- wth->phdr.ts.tv_sec = hdr.seconds;
- wth->phdr.ts.tv_usec = 0;
+ wth->phdr.ts.secs = hdr.seconds;
+ wth->phdr.ts.nsecs = 0;
if( wth->capture.csids->byteswapped == TRUE ) {
guint16* swap = (guint16*)buf;
diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c
index 7cd7ebc8e3..7331b694c1 100644
--- a/wiretap/dbs-etherwatch.c
+++ b/wiretap/dbs-etherwatch.c
@@ -474,9 +474,8 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err,
tm.tm_year -= 1900;
tm.tm_isdst = -1;
- wth->phdr.ts.tv_sec = mktime(&tm);
-
- wth->phdr.ts.tv_usec = csec * 10000;
+ wth->phdr.ts.secs = mktime(&tm);
+ wth->phdr.ts.nsecs = csec * 10000000;
wth->phdr.caplen = eth_hdr_len + pkt_len;
wth->phdr.len = eth_hdr_len + pkt_len;
}
diff --git a/wiretap/erf.c b/wiretap/erf.c
index cbde26704a..0937e9004b 100644
--- a/wiretap/erf.c
+++ b/wiretap/erf.c
@@ -330,13 +330,13 @@ static int erf_read_header(
#ifdef G_HAVE_GINT64
guint64 ts = pletohll(&erf_header->ts);
- phdr->ts.tv_sec = (long) (ts >> 32);
+ phdr->ts.secs = (long) (ts >> 32);
ts = ((ts & 0xffffffff) * 1000 * 1000);
ts += (ts & 0x80000000) << 1; /* rounding */
- phdr->ts.tv_usec = (long) (ts >> 32);
- if (phdr->ts.tv_usec >= 1000000) {
- phdr->ts.tv_usec -= 1000000;
- phdr->ts.tv_sec += 1;
+ phdr->ts.nsecs = ((long) (ts >> 32)) * 1000;
+ if (phdr->ts.nsecs >= 1000000000) {
+ phdr->ts.nsecs -= 1000000000;
+ phdr->ts.secs += 1;
}
#else
phdr->ts.tv_sec = pletohl(&erf_header->ts[1]);
diff --git a/wiretap/etherpeek.c b/wiretap/etherpeek.c
index 7967df2f90..afa8044f90 100644
--- a/wiretap/etherpeek.c
+++ b/wiretap/etherpeek.c
@@ -449,9 +449,9 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
t = (double) timestamp.lower +
(double) timestamp.upper * 4294967296.0;
t -= (double) mac2unix * 1000000.0;
- wth->phdr.ts.tv_sec = (time_t) (t/1000000.0);
- wth->phdr.ts.tv_usec = (guint32) (t - (double) wth->phdr.ts.tv_sec *
- 1000000.0);
+ wth->phdr.ts.secs = (time_t) (t/1000000.0);
+ wth->phdr.ts.nsecs = (guint32) (t - (double) wth->phdr.ts.secs *
+ 1000000000.0);
if (wth->file_encap == WTAP_ENCAP_IEEE_802_11_WITH_RADIO) {
/*
@@ -596,9 +596,9 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_,
wth->phdr.len = length;
wth->phdr.caplen = sliceLength;
/* timestamp is in milliseconds since reference_time */
- wth->phdr.ts.tv_sec = wth->capture.etherpeek->reference_time.tv_sec
+ wth->phdr.ts.secs = wth->capture.etherpeek->reference_time.tv_sec
+ (timestamp / 1000);
- wth->phdr.ts.tv_usec = 1000 * (timestamp % 1000);
+ wth->phdr.ts.nsecs = 1000 * (timestamp % 1000) * 1000;
wth->phdr.pkt_encap = WTAP_ENCAP_UNKNOWN;
for (i=0; i<NUM_ETHERPEEK_ENCAPS; i++) {
diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c
index 73a964d374..277a4684ec 100644
--- a/wiretap/eyesdn.c
+++ b/wiretap/eyesdn.c
@@ -280,8 +280,8 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
}
if (wth) {
- wth->phdr.ts.tv_sec = secs;
- wth->phdr.ts.tv_usec = usecs;
+ wth->phdr.ts.secs = secs;
+ wth->phdr.ts.nsecs = usecs * 1000;
wth->phdr.caplen = pkt_len;
wth->phdr.len = pkt_len;
}
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 1e9cf016d3..1881fc248a 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -279,6 +279,7 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
wth->data_offset = 0;
wth->subtype_sequential_close = NULL;
wth->subtype_close = NULL;
+ wth->tsprecision = WTAP_FILE_TSPREC_USEC;
/* Try all file types */
for (i = 0; i < N_FILE_TYPES; i++) {
diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c
index d9c5718999..ccca83ce8f 100644
--- a/wiretap/hcidump.c
+++ b/wiretap/hcidump.c
@@ -80,8 +80,8 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
}
wth->data_offset += packet_size;
- wth->phdr.ts.tv_sec = GUINT32_FROM_LE(dh.ts_sec);
- wth->phdr.ts.tv_usec = GUINT32_FROM_LE(dh.ts_usec);
+ wth->phdr.ts.secs = GUINT32_FROM_LE(dh.ts_sec);
+ wth->phdr.ts.nsecs = GUINT32_FROM_LE(dh.ts_usec) * 1000;
wth->phdr.caplen = packet_size;
wth->phdr.len = packet_size;
diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c
index 892e5fdb2b..11dc2cc2fd 100644
--- a/wiretap/i4btrace.c
+++ b/wiretap/i4btrace.c
@@ -142,8 +142,8 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
wth->phdr.len = length;
wth->phdr.caplen = length;
- wth->phdr.ts.tv_sec = hdr.ts_sec;
- wth->phdr.ts.tv_usec = hdr.ts_usec;
+ wth->phdr.ts.secs = hdr.ts_sec;
+ wth->phdr.ts.nsecs = hdr.ts_usec * 1000;
/*
* Read the packet data.
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index f427cff95b..9281b6b80c 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -179,8 +179,8 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info _U_,
wth->phdr.len = packet_size;
wth->phdr.caplen = packet_size;
- wth->phdr.ts.tv_sec = pntohl(&header[4]);
- wth->phdr.ts.tv_usec = 0;
+ wth->phdr.ts.secs = pntohl(&header[4]);
+ wth->phdr.ts.nsecs = 0;
if (wth->phdr.pkt_encap == WTAP_ENCAP_UNKNOWN) {
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
@@ -362,8 +362,8 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info _U_,
wth->phdr.len = packet_size;
wth->phdr.caplen = packet_size;
- wth->phdr.ts.tv_sec = pntohl(&header[32]);
- wth->phdr.ts.tv_usec = pntohl(&header[36]) / 1000;
+ wth->phdr.ts.secs = pntohl(&header[32]);
+ wth->phdr.ts.nsecs = pntohl(&header[36]);
if (wth->phdr.pkt_encap == WTAP_ENCAP_UNKNOWN) {
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
diff --git a/wiretap/k12.c b/wiretap/k12.c
index 42e90f7205..ecd9b75185 100644
--- a/wiretap/k12.c
+++ b/wiretap/k12.c
@@ -212,8 +212,8 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, long *data_o
ts = pntohll(buffer + K12_PACKET_TIMESTAMP);
- wth->phdr.ts.tv_usec = (guint32) ( (ts % 2000000) / 2);
- wth->phdr.ts.tv_sec = (guint32) ((ts / 2000000) + 631152000);
+ wth->phdr.ts.secs = (guint32) ( (ts % 2000000) / 2);
+ wth->phdr.ts.nsecs = (guint32) ((ts / 2000000) + 631152000) * 1000;
wth->phdr.len = wth->phdr.caplen = pntohl(buffer + K12_RECORD_FRAME_LEN) & 0x00001FFF;
@@ -597,7 +597,7 @@ static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
obj.record.frame_len = g_htonl(phdr->len);
obj.record.input = g_htonl(pseudo_header->k12.input);
- obj.record.ts = GUINT64_TO_BE((((guint64)phdr->ts.tv_sec - 631152000) * 2000000) + (phdr->ts.tv_usec * 2));
+ obj.record.ts = GUINT64_TO_BE((((guint64)phdr->ts.secs - 631152000) * 2000000) + (phdr->ts.nsecs / 1000 * 2));
memcpy(obj.record.frame,pd,phdr->len);
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index 00679a94fb..a6553ecc60 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -370,9 +370,9 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
t = t/1000000.0 * 0.5; /* t = # of secs */
t += wth->capture.lanalyzer->start;
- wth->phdr.ts.tv_sec = (long)t;
- wth->phdr.ts.tv_usec = (unsigned long)((t-(double)(wth->phdr.ts.tv_sec))
- *1.0e6);
+ wth->phdr.ts.secs = (long)t;
+ wth->phdr.ts.nsecs = (unsigned long)((t-(double)(wth->phdr.ts.secs))
+ *1.0e9);
if (true_size - 4 >= packet_size) {
/*
@@ -556,6 +556,7 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh,
double x;
int i;
int len;
+ struct timeval tv;
LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->dump.opaque);
struct timeval td;
@@ -576,19 +577,22 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh,
if (*err)
return FALSE;
+ tv.tv_sec = phdr->ts.secs;
+ tv.tv_usec = phdr->ts.nsecs / 1000;
if (!itmp->init) {
/* collect some information for the
* finally written header
*/
- itmp->start = phdr->ts;
+ /* XXX - this conversion could probably improved, if the start uses ns */
+ itmp->start = tv;
itmp->pkts = 0;
itmp->init = TRUE;
itmp->encap = wdh->encap;
itmp->lastlen = 0;
}
- my_timersub(&(phdr->ts),&(itmp->start),&td);
+ my_timersub(&(tv),&(itmp->start),&td);
x = (double) td.tv_usec;
x += (double) td.tv_sec * 1000000;
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index a7738c4af2..86bf798a6f 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -601,6 +601,10 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
gboolean aix;
int file_encap;
+
+ /* XXX - this must be done depending on the magic number */
+ /*wth->tsrecision = WTAP_FILE_TSPREC_NSEC;*/
+
/* Read in the number that should be at the start of a "libpcap" file */
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&magic, 1, sizeof magic, wth->fh);
@@ -1267,8 +1271,8 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
return FALSE; /* Read error */
wth->data_offset += packet_size;
- wth->phdr.ts.tv_sec = hdr.hdr.ts_sec;
- wth->phdr.ts.tv_usec = hdr.hdr.ts_usec;
+ wth->phdr.ts.secs = hdr.hdr.ts_sec;
+ wth->phdr.ts.nsecs = hdr.hdr.ts_usec * 1000;
wth->phdr.caplen = packet_size;
wth->phdr.len = orig_size;
@@ -1819,8 +1823,8 @@ wtap_process_pcap_packet(gint linktype, const struct pcap_pkthdr *phdr,
be a "struct bpf_timeval", with member sizes wired to 32
bits - and we may go that way ourselves in the future, so
copy the members individually. */
- whdr->ts.tv_sec = phdr->ts.tv_sec;
- whdr->ts.tv_usec = phdr->ts.tv_usec;
+ whdr->ts.secs = phdr->ts.tv_sec;
+ whdr->ts.nsecs = phdr->ts.tv_usec * 1000;
whdr->caplen = phdr->caplen;
whdr->len = phdr->len;
whdr->pkt_encap = linktype;
@@ -2017,8 +2021,8 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
else
hdrsize = 0;
- rec_hdr.hdr.ts_sec = phdr->ts.tv_sec;
- rec_hdr.hdr.ts_usec = phdr->ts.tv_usec;
+ rec_hdr.hdr.ts_sec = phdr->ts.secs;
+ rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000;
rec_hdr.hdr.incl_len = phdr->caplen + hdrsize;
rec_hdr.hdr.orig_len = phdr->len + hdrsize;
switch (wdh->file_type) {
diff --git a/wiretap/netmon.c b/wiretap/netmon.c
index bc10056510..c3c552d2d0 100644
--- a/wiretap/netmon.c
+++ b/wiretap/netmon.c
@@ -452,8 +452,8 @@ static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
}
secs = (time_t)(t/1000000);
usecs = (guint32)(t - (double)secs*1000000);
- wth->phdr.ts.tv_sec = netmon->start_secs + secs;
- wth->phdr.ts.tv_usec = usecs;
+ wth->phdr.ts.secs = netmon->start_secs + secs;
+ wth->phdr.ts.nsecs = usecs * 1000;
wth->phdr.caplen = packet_size;
wth->phdr.len = orig_size;
@@ -681,8 +681,8 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
case WTAP_FILE_NETMON_1_x:
rec_1_x_hdr.ts_delta = htolel(
- (phdr->ts.tv_sec - netmon->first_record_time.tv_sec)*1000
- + (phdr->ts.tv_usec - netmon->first_record_time.tv_usec + 500)/1000);
+ (phdr->ts.secs - netmon->first_record_time.secs)*1000
+ + (phdr->ts.nsecs - netmon->first_record_time.nsecs + 500000)/1000000);
rec_1_x_hdr.orig_len = htoles(phdr->len + atm_hdrsize);
rec_1_x_hdr.incl_len = htoles(phdr->caplen + atm_hdrsize);
hdrp = (char *)&rec_1_x_hdr;
@@ -696,8 +696,8 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
* (even on 32-bit processors), so we do it in floating
* point.
*/
- t = (phdr->ts.tv_sec - netmon->first_record_time.tv_sec)*1000000.0
- + (phdr->ts.tv_usec - netmon->first_record_time.tv_usec);
+ t = (phdr->ts.secs - netmon->first_record_time.secs)*1000000.0
+ + (phdr->ts.nsecs - netmon->first_record_time.nsecs) / 1000;
time_high = (guint32) (t/4294967296.0);
time_low = (guint32) (t - (time_high*4294967296.0));
rec_2_x_hdr.ts_delta_lo = htolel(time_low);
@@ -848,7 +848,7 @@ static gboolean netmon_dump_close(wtap_dumper *wdh, int *err)
}
file_hdr.network = htoles(wtap_encap[wdh->encap]);
- tm = localtime(&netmon->first_record_time.tv_sec);
+ tm = localtime(&netmon->first_record_time.secs);
if (tm != NULL) {
file_hdr.ts_year = htoles(1900 + tm->tm_year);
file_hdr.ts_month = htoles(tm->tm_mon + 1);
@@ -866,7 +866,7 @@ static gboolean netmon_dump_close(wtap_dumper *wdh, int *err)
file_hdr.ts_min = htoles(0);
file_hdr.ts_sec = htoles(0);
}
- file_hdr.ts_msec = htoles(netmon->first_record_time.tv_usec/1000);
+ file_hdr.ts_msec = htoles(netmon->first_record_time.nsecs/1000000);
/* XXX - what about rounding? */
file_hdr.frametableoffset = htolel(netmon->frame_table_offset);
file_hdr.frametablelength =
diff --git a/wiretap/nettl.c b/wiretap/nettl.c
index 22d54d5148..75ffb9e1ca 100644
--- a/wiretap/nettl.c
+++ b/wiretap/nettl.c
@@ -501,8 +501,8 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
phdr->caplen = pntohl(&ip_hdr.caplen);
}
- phdr->ts.tv_sec = pntohl(&ip_hdr.sec);
- phdr->ts.tv_usec = pntohl(&ip_hdr.usec);
+ phdr->ts.secs = pntohl(&ip_hdr.sec);
+ phdr->ts.nsecs = pntohl(&ip_hdr.usec) * 1000;
break;
case NETTL_SUBSYS_NS_LS_DRIVER :
@@ -546,8 +546,8 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
phdr->len = length;
phdr->caplen = pntohs(&drv_eth_hdr.caplen);
- phdr->ts.tv_sec = pntohl(&ip_hdr.sec);
- phdr->ts.tv_usec = pntohl(&ip_hdr.usec);
+ phdr->ts.secs = pntohl(&ip_hdr.sec);
+ phdr->ts.nsecs = pntohl(&ip_hdr.usec) * 1000;
break;
case NETTL_SUBSYS_SX25L2:
@@ -567,8 +567,8 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
if (length <= 0) return 0;
phdr->len = length - 24;
phdr->caplen = pntohl(&ip_hdr.caplen) - 24;
- phdr->ts.tv_sec = pntohl(&ip_hdr.sec);
- phdr->ts.tv_usec = pntohl(&ip_hdr.usec);
+ phdr->ts.secs = pntohl(&ip_hdr.sec);
+ phdr->ts.nsecs = pntohl(&ip_hdr.usec) * 1000;
if (wth->capture.nettl->is_hpux_11)
padlen = 28;
else
@@ -596,8 +596,8 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
if (length <= 0) return 0;
phdr->len = length;
phdr->caplen = pntohl(&ip_hdr.caplen);
- phdr->ts.tv_sec = pntohl(&ip_hdr.sec);
- phdr->ts.tv_usec = pntohl(&ip_hdr.usec);
+ phdr->ts.secs = pntohl(&ip_hdr.sec);
+ phdr->ts.nsecs = pntohl(&ip_hdr.usec) * 1000;
if (wth->capture.nettl->is_hpux_11) {
if (file_seek(fh, 4, SEEK_CUR, err) == -1) return -1;
offset += 4;
@@ -737,8 +737,8 @@ static gboolean nettl_dump(wtap_dumper *wdh,
memset(&rec_hdr,0,sizeof(rec_hdr));
rec_hdr.hdr_len = g_htons(sizeof(rec_hdr));
rec_hdr.hdr.kind = g_htonl(NETTL_HDR_PDUIN);
- rec_hdr.hdr.sec = g_htonl(phdr->ts.tv_sec);
- rec_hdr.hdr.usec = g_htonl(phdr->ts.tv_usec);
+ rec_hdr.hdr.sec = g_htonl(phdr->ts.secs);
+ rec_hdr.hdr.usec = g_htonl(phdr->ts.nsecs/1000);
rec_hdr.hdr.caplen = g_htonl(phdr->caplen);
rec_hdr.hdr.length = g_htonl(phdr->len);
rec_hdr.hdr.devid = -1;
diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c
index b5d7416e14..0e226e6e48 100644
--- a/wiretap/network_instruments.c
+++ b/wiretap/network_instruments.c
@@ -240,8 +240,8 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
wth->phdr.pkt_encap = observer_encap[packet_header.network_type];
wth->phdr.len = packet_header.network_size-4; /* neglect frame markers for wiretap */
wth->phdr.caplen = MIN(packet_header.captured_size, wth->phdr.len);
- wth->phdr.ts.tv_sec = seconds;
- wth->phdr.ts.tv_usec = useconds;
+ wth->phdr.ts.secs = seconds;
+ wth->phdr.ts.nsecs = useconds * 1000;
/* get to the frame data */
packet_header.offset_to_frame =
@@ -430,14 +430,14 @@ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
size_t nwritten;
guint64 capture_nanoseconds = 0;
- if(phdr->ts.tv_sec<(long)seconds1970to2000) {
- if(phdr->ts.tv_sec<0)
+ if(phdr->ts.secs<(long)seconds1970to2000) {
+ if(phdr->ts.secs<0)
capture_nanoseconds = 0;
else
- capture_nanoseconds = phdr->ts.tv_sec;
+ capture_nanoseconds = phdr->ts.secs;
} else
- capture_nanoseconds = phdr->ts.tv_sec - seconds1970to2000;
- capture_nanoseconds = ((capture_nanoseconds*1000000) + (guint64)phdr->ts.tv_usec)*1000;
+ capture_nanoseconds = phdr->ts.secs - seconds1970to2000;
+ capture_nanoseconds = ((capture_nanoseconds*1000000) + (guint64)phdr->ts.nsecs);
memset(&packet_header, 0x00, sizeof(packet_entry_header));
packet_header.packet_magic = GUINT32_TO_LE(observer_packet_magic);
diff --git a/wiretap/netxray.c b/wiretap/netxray.c
index 93a5ef9bca..f5164a0615 100644
--- a/wiretap/netxray.c
+++ b/wiretap/netxray.c
@@ -808,9 +808,9 @@ reread:
+ (double)pletohl(&hdr.old_hdr.timehi)*4294967296.0;
t /= wth->capture.netxray->timeunit;
t -= wth->capture.netxray->start_timestamp;
- wth->phdr.ts.tv_sec = wth->capture.netxray->start_time + (long)t;
- wth->phdr.ts.tv_usec = (unsigned long)((t-(double)(unsigned long)(t))
- *1.0e6);
+ wth->phdr.ts.secs = wth->capture.netxray->start_time + (long)t;
+ wth->phdr.ts.nsecs = (unsigned long)((t-(double)(unsigned long)(t))
+ *1.0e9);
/*
* We subtract the padding from the packet size, so our caller
* doesn't see it.
@@ -822,9 +822,9 @@ reread:
+ (double)pletohl(&hdr.hdr_1_x.timehi)*4294967296.0;
t /= wth->capture.netxray->timeunit;
t -= wth->capture.netxray->start_timestamp;
- wth->phdr.ts.tv_sec = wth->capture.netxray->start_time + (long)t;
- wth->phdr.ts.tv_usec = (unsigned long)((t-(double)(unsigned long)(t))
- *1.0e6);
+ wth->phdr.ts.secs = wth->capture.netxray->start_time + (long)t;
+ wth->phdr.ts.nsecs = (unsigned long)((t-(double)(unsigned long)(t))
+ *1.0e9);
/*
* We subtract the padding from the packet size, so our caller
* doesn't see it.
@@ -1302,8 +1302,8 @@ gboolean netxray_dump_open_1_1(wtap_dumper *wdh, gboolean cant_seek, int *err)
wdh->dump.netxray = g_malloc(sizeof(netxray_dump_t));
wdh->dump.netxray->first_frame = TRUE;
- wdh->dump.netxray->start.tv_sec = 0;
- wdh->dump.netxray->start.tv_usec = 0;
+ wdh->dump.netxray->start.secs = 0;
+ wdh->dump.netxray->start.nsecs = 0;
wdh->dump.netxray->nframes = 0;
return TRUE;
@@ -1338,8 +1338,8 @@ static gboolean netxray_dump_1_1(wtap_dumper *wdh,
/* build the header for each packet */
memset(&rec_hdr, '\0', sizeof(rec_hdr));
- timestamp = (phdr->ts.tv_sec - netxray->start.tv_sec)*1000000 +
- phdr->ts.tv_usec;
+ timestamp = (phdr->ts.secs - netxray->start.secs)*1000000 +
+ phdr->ts.nsecs / 1000;
rec_hdr.timelo = htolel(timestamp);
rec_hdr.timehi = htolel(0);
rec_hdr.orig_len = htoles(phdr->len);
@@ -1399,7 +1399,7 @@ static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err)
/* "sniffer" version ? */
memset(&file_hdr, '\0', sizeof file_hdr);
memcpy(file_hdr.version, vers_1_1, sizeof vers_1_1);
- file_hdr.start_time = htolel(netxray->start.tv_sec);
+ file_hdr.start_time = htolel(netxray->start.secs);
file_hdr.nframes = htolel(netxray->nframes);
file_hdr.start_offset = htolel(CAPTUREFILE_HEADER_SIZE);
file_hdr.end_offset = htolel(filelen);
@@ -1491,8 +1491,8 @@ gboolean netxray_dump_open_2_0(wtap_dumper *wdh, gboolean cant_seek, int *err)
wdh->dump.netxray = g_malloc(sizeof(netxray_dump_t));
wdh->dump.netxray->first_frame = TRUE;
- wdh->dump.netxray->start.tv_sec = 0;
- wdh->dump.netxray->start.tv_usec = 0;
+ wdh->dump.netxray->start.secs = 0;
+ wdh->dump.netxray->start.nsecs = 0;
wdh->dump.netxray->nframes = 0;
return TRUE;
@@ -1527,8 +1527,8 @@ static gboolean netxray_dump_2_0(wtap_dumper *wdh,
/* build the header for each packet */
memset(&rec_hdr, '\0', sizeof(rec_hdr));
- timestamp = (phdr->ts.tv_sec - netxray->start.tv_sec)*1000000 +
- phdr->ts.tv_usec;
+ timestamp = (phdr->ts.secs - netxray->start.secs)*1000000 +
+ phdr->ts.nsecs/1000;
rec_hdr.timelo = htolel(timestamp);
rec_hdr.timehi = htolel(0);
rec_hdr.orig_len = htoles(phdr->len);
@@ -1606,7 +1606,7 @@ static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err)
/* "sniffer" version ? */
memset(&file_hdr, '\0', sizeof file_hdr);
memcpy(file_hdr.version, vers_2_001, sizeof vers_2_001);
- file_hdr.start_time = htolel(netxray->start.tv_sec);
+ file_hdr.start_time = htolel(netxray->start.secs);
file_hdr.nframes = htolel(netxray->nframes);
file_hdr.start_offset = htolel(CAPTUREFILE_HEADER_SIZE);
file_hdr.end_offset = htolel(filelen);
diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c
index 1d7768250d..04bcb78e89 100644
--- a/wiretap/ngsniffer.c
+++ b/wiretap/ngsniffer.c
@@ -1073,9 +1073,9 @@ found:
t = t/1000000.0 * wth->capture.ngsniffer->timeunit; /* t = # of secs */
t += wth->capture.ngsniffer->start;
- wth->phdr.ts.tv_sec = (long)t;
- wth->phdr.ts.tv_usec = (unsigned long)((t-(double)(wth->phdr.ts.tv_sec))
- *1.0e6);
+ wth->phdr.ts.secs = (long)t;
+ wth->phdr.ts.nsecs = (unsigned long)((t-(double)(wth->phdr.ts.secs))
+ *1.0e9);
return TRUE;
}
@@ -1917,13 +1917,13 @@ static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
date. */
if (priv->first_frame) {
priv->first_frame=FALSE;
- tm = localtime(&phdr->ts.tv_sec);
+ tm = localtime(&phdr->ts.secs);
if (tm != NULL) {
start_date = (tm->tm_year - (1980 - 1900)) << 9;
start_date |= (tm->tm_mon + 1) << 5;
start_date |= tm->tm_mday;
/* record the start date, not the start time */
- priv->start = phdr->ts.tv_sec - (3600*tm->tm_hour + 60*tm->tm_min + tm->tm_sec);
+ priv->start = phdr->ts.secs - (3600*tm->tm_hour + 60*tm->tm_min + tm->tm_sec);
} else {
start_date = 0;
priv->start = 0;
@@ -1968,7 +1968,7 @@ static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
*err = WTAP_ERR_SHORT_WRITE;
return FALSE;
}
- t = (double)phdr->ts.tv_sec + (double)phdr->ts.tv_usec/1.0e6; /* # of secs */
+ t = (double)phdr->ts.secs + (double)phdr->ts.nsecs/1.0e9; /* # of secs */
t = (t - priv->start)*1.0e6 / Usec[1]; /* timeunit = 1 */
t_low = (guint16)(t-(double)((guint32)(t/65536.0))*65536.0);
t_med = (guint16)((guint32)(t/65536.0) % 65536);
diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c
index 72061bdcd9..8913cd8c4a 100644
--- a/wiretap/pppdump.c
+++ b/wiretap/pppdump.c
@@ -355,8 +355,8 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, long *data_offset)
wth->phdr.len = num_bytes;
wth->phdr.caplen = num_bytes;
- wth->phdr.ts.tv_sec = state->timestamp;
- wth->phdr.ts.tv_usec = state->tenths * 100000;
+ wth->phdr.ts.secs = state->timestamp;
+ wth->phdr.ts.nsecs = state->tenths * 100000000;
wth->phdr.pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR;
wth->pseudo_header.p2p.sent = (direction == DIRECTION_SENT ? TRUE : FALSE);
diff --git a/wiretap/radcom.c b/wiretap/radcom.c
index 08524b23a3..9c3934504a 100644
--- a/wiretap/radcom.c
+++ b/wiretap/radcom.c
@@ -314,8 +314,8 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_,
tm.tm_min = (sec%3600)/60;
tm.tm_sec = sec%60;
tm.tm_isdst = -1;
- wth->phdr.ts.tv_sec = mktime(&tm);
- wth->phdr.ts.tv_usec = pletohl(&hdr.date.usec);
+ wth->phdr.ts.secs = mktime(&tm);
+ wth->phdr.ts.nsecs = pletohl(&hdr.date.usec) * 1000;
switch (wth->file_encap) {
diff --git a/wiretap/snoop.c b/wiretap/snoop.c
index a19e4cd532..5dc0c2a27d 100644
--- a/wiretap/snoop.c
+++ b/wiretap/snoop.c
@@ -501,8 +501,8 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
return FALSE; /* Read error */
wth->data_offset += packet_size;
- wth->phdr.ts.tv_sec = g_ntohl(hdr.ts_sec);
- wth->phdr.ts.tv_usec = g_ntohl(hdr.ts_usec);
+ wth->phdr.ts.secs = g_ntohl(hdr.ts_sec);
+ wth->phdr.ts.nsecs = g_ntohl(hdr.ts_usec) * 1000;
wth->phdr.caplen = packet_size;
wth->phdr.len = orig_size;
@@ -808,8 +808,8 @@ static gboolean snoop_dump(wtap_dumper *wdh,
rec_hdr.incl_len = g_htonl(phdr->caplen + atm_hdrsize);
rec_hdr.rec_len = g_htonl(reclen);
rec_hdr.cum_drops = 0;
- rec_hdr.ts_sec = g_htonl(phdr->ts.tv_sec);
- rec_hdr.ts_usec = g_htonl(phdr->ts.tv_usec);
+ rec_hdr.ts_sec = g_htonl(phdr->ts.secs);
+ rec_hdr.ts_usec = g_htonl(phdr->ts.nsecs) / 1000;
nwritten = fwrite(&rec_hdr, 1, sizeof rec_hdr, wdh->fh);
if (nwritten != sizeof rec_hdr) {
if (nwritten == 0 && ferror(wdh->fh))
diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c
index 086ed50be8..a9cc44d503 100644
--- a/wiretap/toshiba.c
+++ b/wiretap/toshiba.c
@@ -353,8 +353,8 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
}
if (wth) {
- wth->phdr.ts.tv_sec = hr * 3600 + min * 60 + sec;
- wth->phdr.ts.tv_usec = csec * 10000;
+ wth->phdr.ts.secs = hr * 3600 + min * 60 + sec;
+ wth->phdr.ts.nsecs = csec * 10000000;
wth->phdr.caplen = pkt_len;
wth->phdr.len = pkt_len;
}
diff --git a/wiretap/visual.c b/wiretap/visual.c
index 5725aa9375..b270d508fa 100644
--- a/wiretap/visual.c
+++ b/wiretap/visual.c
@@ -298,8 +298,8 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
t += ((double)pletohl(&vpkt_hdr.ts_delta))*1000;
secs = (time_t)(t/1000000);
usecs = (guint32)(t - secs*1000000);
- wth->phdr.ts.tv_sec = secs;
- wth->phdr.ts.tv_usec = usecs;
+ wth->phdr.ts.secs = secs;
+ wth->phdr.ts.nsecs = usecs * 1000;
wth->phdr.caplen = packet_size;
wth->phdr.len = pletohs(&vpkt_hdr.orig_len);
@@ -489,7 +489,7 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
if (visual->index_table_index == 0)
{
/* This is the first packet. Save its start time as the file time. */
- visual->start_time = phdr->ts.tv_sec;
+ visual->start_time = phdr->ts.secs;
/* Initialize the index table */
visual->index_table = g_malloc(1024 * sizeof *visual->index_table);
@@ -497,8 +497,8 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
}
/* Calculate milliseconds since capture start. */
- delta_msec = phdr->ts.tv_usec / 1000;
- delta_msec += (phdr->ts.tv_sec - visual->start_time) * 1000;
+ delta_msec = phdr->ts.nsecs / 1000000;
+ delta_msec += (phdr->ts.secs - visual->start_time) * 1000;
vpkt_hdr.ts_delta = htolel(delta_msec);
/* Fill in the length fields. */
diff --git a/wiretap/vms.c b/wiretap/vms.c
index fccd4b1c13..02d0e6cc8a 100644
--- a/wiretap/vms.c
+++ b/wiretap/vms.c
@@ -439,9 +439,8 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info)
tm.tm_year -= 1900;
tm.tm_isdst = -1;
- wth->phdr.ts.tv_sec = mktime(&tm);
-
- wth->phdr.ts.tv_usec = csec * 10000;
+ wth->phdr.ts.secs = mktime(&tm);
+ wth->phdr.ts.nsecs = csec * 10000000;
wth->phdr.caplen = pkt_len;
wth->phdr.len = pkt_len;
}
diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h
index fbbe89ef12..91a7456a84 100644
--- a/wiretap/wtap-int.h
+++ b/wiretap/wtap-int.h
@@ -176,6 +176,8 @@ struct wtap {
file formats that have
per-file encapsulation
types */
+ int tsprecision; /* timestamp precision of the lower 32bits
+ * 6 is microseconds, 9 is nanoseconds */
};
struct wtap_dumper;
@@ -192,13 +194,13 @@ typedef struct {
typedef struct {
gboolean first_frame;
- struct timeval start;
+ struct wtap_nstime start;
guint32 nframes;
} netxray_dump_t;
typedef struct {
gboolean got_first_record_time;
- struct timeval first_record_time;
+ struct wtap_nstime first_record_time;
guint32 frame_table_offset;
guint32 *frame_table;
guint frame_table_index;
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index b1e981b1d1..cb12f65ba9 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -84,6 +84,12 @@ wtap_file_encap(wtap *wth)
return wth->file_encap;
}
+int
+wtap_file_tsprecision(wtap *wth)
+{
+ return wth->tsprecision;
+}
+
/* Table of the encapsulation types we know about. */
static const struct encap_type_info {
const char *name;
diff --git a/wiretap/wtap.def b/wiretap/wtap.def
index 1e314db475..74d11b8cb1 100644
--- a/wiretap/wtap.def
+++ b/wiretap/wtap.def
@@ -12,6 +12,7 @@ wtap_encap_short_string
wtap_encap_string
wtap_file_encap
wtap_file_size
+wtap_file_tsprecision
wtap_file_type
wtap_file_type_short_string
wtap_file_type_string
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index b828a7e4b6..44da7e5c6a 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -33,6 +33,7 @@
#include <glib.h>
#include <stdio.h>
+#include <time.h>
/* Encapsulation types. Choose names that truly reflect
* what is contained in the packet trace file.
@@ -223,6 +224,10 @@
/* last WTAP_FILE_ value + 1 */
#define WTAP_NUM_FILE_TYPES 41
+/* timestamp accuracy (currently only these values are supported) */
+#define WTAP_FILE_TSPREC_USEC 6
+#define WTAP_FILE_TSPREC_NSEC 9
+
/*
* Maximum packet size we'll support.
* It must be at least 65535.
@@ -492,8 +497,14 @@ union wtap_pseudo_header {
struct k12_phdr k12;
};
+struct wtap_nstime {
+ time_t secs;
+ int nsecs;
+};
+
+
struct wtap_pkthdr {
- struct timeval ts;
+ struct wtap_nstime ts;
guint32 caplen;
guint32 len;
int pkt_encap;
@@ -537,6 +548,7 @@ gint64 wtap_file_size(wtap *wth, int *err);
int wtap_snapshot_length(wtap *wth); /* per file */
int wtap_file_type(wtap *wth);
int wtap_file_encap(wtap *wth);
+int wtap_file_tsprecision(wtap *wth);
const char *wtap_file_type_string(int filetype);
const char *wtap_file_type_short_string(int filetype);