diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-04-17 17:17:01 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-04-18 00:18:34 +0000 |
commit | ce6430e35e137b981cb18e286e546eae3c1f6b3c (patch) | |
tree | 491d35c11120199b01092ce8f3d45e7c0fa20517 /wiretap/libpcap.c | |
parent | c9bb6b8282eb5c829bc4cb07f4bc2e53f409c0c5 (diff) | |
download | wireshark-ce6430e35e137b981cb18e286e546eae3c1f6b3c.tar.gz |
Eliminate an unneded member of a wtap_dumper.
The only place the time stamp precision is used is in the libpcap code,
where it determines whether to write out microsecond-precision or
nanosecond-precision time stamps; we can determine that by looking at
the type/subtype field, which is also part of that structure, so do
that.
We weren't setting it consistently - we were only setting it in libpcap
and a few other capture file writers, and not in other capture file
writers - and none of the writers other than libpcap used it.
Change-Id: If53779cf4823ca936b8bf3e8a7dbcfea5850e652
Reviewed-on: https://code.wireshark.org/review/21171
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/libpcap.c')
-rw-r--r-- | wiretap/libpcap.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index e0133e2dc9..3d98ff0cbb 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -838,18 +838,15 @@ gboolean libpcap_dump_open(wtap_dumper *wdh, int *err) case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990417: /* modified, but with the old magic, sigh */ case WTAP_FILE_TYPE_SUBTYPE_PCAP_NOKIA: /* Nokia libpcap of some sort */ magic = PCAP_MAGIC; - wdh->tsprecision = WTAP_TSPREC_USEC; break; case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990915: /* new magic, extra crap */ case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS991029: magic = PCAP_MODIFIED_MAGIC; - wdh->tsprecision = WTAP_TSPREC_USEC; break; case WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC: /* same as WTAP_FILE_TYPE_SUBTYPE_PCAP, but nsec precision */ magic = PCAP_NSEC_MAGIC; - wdh->tsprecision = WTAP_TSPREC_NSEC; break; default: @@ -914,12 +911,6 @@ static gboolean libpcap_dump(wtap_dumper *wdh, return FALSE; } - rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; - if(wdh->tsprecision == WTAP_TSPREC_NSEC) { - rec_hdr.hdr.ts_usec = phdr->ts.nsecs; - } else { - rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000; - } rec_hdr.hdr.incl_len = phdr->caplen + phdrsize; rec_hdr.hdr.orig_len = phdr->len + phdrsize; @@ -931,12 +922,21 @@ static gboolean libpcap_dump(wtap_dumper *wdh, switch (wdh->file_type_subtype) { case WTAP_FILE_TYPE_SUBTYPE_PCAP: + rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; + rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000; + hdr_size = sizeof (struct pcaprec_hdr); + break; + case WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC: + rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; + rec_hdr.hdr.ts_usec = phdr->ts.nsecs; hdr_size = sizeof (struct pcaprec_hdr); break; case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990417: /* modified, but with the old magic, sigh */ case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS991029: + rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; + rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000; /* XXX - what should we supply here? Alexey's "libpcap" looks up the interface in the system's @@ -963,6 +963,8 @@ static gboolean libpcap_dump(wtap_dumper *wdh, break; case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990915: /* new magic, extra crap at the end */ + rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; + rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000; rec_hdr.ifindex = 0; rec_hdr.protocol = 0; rec_hdr.pkt_type = 0; @@ -972,6 +974,8 @@ static gboolean libpcap_dump(wtap_dumper *wdh, break; case WTAP_FILE_TYPE_SUBTYPE_PCAP_NOKIA: /* old magic, extra crap at the end */ + rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; + rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000; /* restore the "mysterious stuff" that came with the packet */ memcpy(&rec_hdr.ifindex, pseudo_header->nokia.stuff, 4); /* not written */ |