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 | |
parent | c9bb6b8282eb5c829bc4cb07f4bc2e53f409c0c5 (diff) |
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')
-rw-r--r-- | wiretap/btsnoop.c | 26 | ||||
-rw-r--r-- | wiretap/erf.c | 12 | ||||
-rw-r--r-- | wiretap/libpcap.c | 22 | ||||
-rw-r--r-- | wiretap/logcat.c | 13 | ||||
-rw-r--r-- | wiretap/wtap-int.h | 3 |
5 files changed, 15 insertions, 61 deletions
diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c index ac48c3b5f3..998c9589b8 100644 --- a/wiretap/btsnoop.c +++ b/wiretap/btsnoop.c @@ -402,19 +402,6 @@ gboolean btsnoop_dump_open_h1(wtap_dumper *wdh, int *err) wdh->subtype_write = btsnoop_dump_h1; /* Write the file header. */ - switch (wdh->file_type_subtype) { - - case WTAP_FILE_TYPE_SUBTYPE_BTSNOOP: - wdh->tsprecision = WTAP_TSPREC_USEC; - break; - - default: - /* We should never get here - our open routine - should only get called for the types above. */ - *err = WTAP_ERR_UNWRITABLE_FILE_TYPE; - return FALSE; - } - if (!wtap_dump_file_write(wdh, btsnoop_magic, sizeof btsnoop_magic, err)) return FALSE; @@ -443,19 +430,6 @@ gboolean btsnoop_dump_open_h4(wtap_dumper *wdh, int *err) wdh->subtype_write = btsnoop_dump_h4; /* Write the file header. */ - switch (wdh->file_type_subtype) { - - case WTAP_FILE_TYPE_SUBTYPE_BTSNOOP: - wdh->tsprecision = WTAP_TSPREC_USEC; - break; - - default: - /* We should never get here - our open routine - should only get called for the types above. */ - *err = WTAP_ERR_UNWRITABLE_FILE_TYPE; - return FALSE; - } - if (!wtap_dump_file_write(wdh, btsnoop_magic, sizeof btsnoop_magic, err)) return FALSE; diff --git a/wiretap/erf.c b/wiretap/erf.c index 6cafda9042..21951d596b 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -924,20 +924,10 @@ int erf_dump_can_write_encap(int encap) return 0; } -int erf_dump_open(wtap_dumper *wdh, int *err) +int erf_dump_open(wtap_dumper *wdh, int *err _U_) { wdh->subtype_write = erf_dump; - switch(wdh->file_type_subtype){ - case WTAP_FILE_TYPE_SUBTYPE_ERF: - wdh->tsprecision = WTAP_TSPREC_NSEC; - break; - default: - *err = WTAP_ERR_UNWRITABLE_FILE_TYPE; - return FALSE; - break; - } - return TRUE; } 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 */ diff --git a/wiretap/logcat.c b/wiretap/logcat.c index 719cf6e531..f37eda988b 100644 --- a/wiretap/logcat.c +++ b/wiretap/logcat.c @@ -347,21 +347,10 @@ static gboolean logcat_binary_dump(wtap_dumper *wdh, return TRUE; } -gboolean logcat_binary_dump_open(wtap_dumper *wdh, int *err) +gboolean logcat_binary_dump_open(wtap_dumper *wdh, int *err _U_) { wdh->subtype_write = logcat_binary_dump; - switch (wdh->encap) { - case WTAP_ENCAP_LOGCAT: - case WTAP_ENCAP_WIRESHARK_UPPER_PDU: - wdh->tsprecision = WTAP_TSPREC_USEC; - break; - - default: - *err = WTAP_ERR_UNWRITABLE_FILE_TYPE; - return FALSE; - } - return TRUE; } diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index 0897e9db00..decfdcd975 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -109,9 +109,6 @@ struct wtap_dumper { subtype_write_func subtype_write; /* write out a record */ subtype_finish_func subtype_finish; /* write out information to finish writing file */ - int tsprecision; /**< timestamp precision of the lower 32bits - * e.g. WTAP_TSPREC_USEC - */ addrinfo_lists_t *addrinfo_lists; /**< Struct containing lists of resolved addresses */ GArray *shb_hdrs; GArray *nrb_hdrs; /**< name resolution comment/custom_opt, or NULL */ |