aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/libpcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-09-28 11:37:06 -0700
committerGuy Harris <guy@alum.mit.edu>2014-09-28 18:38:18 +0000
commit54b733ce9a0d1cd4ab9b142479368a5e696360be (patch)
tree1c98ec83c70ba99b383105516048d0254168d855 /wiretap/libpcap.c
parentefea8ce1c6a4331bc2ff7090dd3dadd2a80f6d86 (diff)
Make the time stamp resolution per-packet.
Pcap-ng files don't have a per-file time stamp resolution, they have a per-interface time stamp resolution. Add new time stamp resolution types of "unknown" and "per-packet", add the time stamp resolution to struct wtap_pkthdr, have the libwiretap core initialize it to the per-file time stamp resolution, and have pcap-ng do the same thing with the resolution that it does with the packet encapsulation. Get rid of the TS_PREC_AUTO_XXX values; just have TS_PREC_AUTO, which means "use the packet's resolution to determine how many significant digits to display". Rename all the WTAP_FILE_TSPREC_XXX values to WTAP_TSPREC_XXX, as they're also used for per-packet values. Change-Id: If9fd8f799b19836a5104aaa0870a951498886c69 Reviewed-on: https://code.wireshark.org/review/4349 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/libpcap.c')
-rw-r--r--wiretap/libpcap.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index 75e52015fd..431c899516 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -122,7 +122,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
a program using either standard or ss990417 libpcap. */
byte_swapped = FALSE;
modified = FALSE;
- wth->tsprecision = WTAP_FILE_TSPREC_USEC;
+ wth->file_tsprec = WTAP_TSPREC_USEC;
break;
case PCAP_MODIFIED_MAGIC:
@@ -130,7 +130,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
a program using either ss990915 or ss991029 libpcap. */
byte_swapped = FALSE;
modified = TRUE;
- wth->tsprecision = WTAP_FILE_TSPREC_USEC;
+ wth->file_tsprec = WTAP_TSPREC_USEC;
break;
case PCAP_SWAPPED_MAGIC:
@@ -139,7 +139,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
ss990417 libpcap. */
byte_swapped = TRUE;
modified = FALSE;
- wth->tsprecision = WTAP_FILE_TSPREC_USEC;
+ wth->file_tsprec = WTAP_TSPREC_USEC;
break;
case PCAP_SWAPPED_MODIFIED_MAGIC:
@@ -148,7 +148,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
or ss991029 libpcap. */
byte_swapped = TRUE;
modified = TRUE;
- wth->tsprecision = WTAP_FILE_TSPREC_USEC;
+ wth->file_tsprec = WTAP_TSPREC_USEC;
break;
case PCAP_NSEC_MAGIC:
@@ -157,7 +157,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
except that the time stamps have nanosecond resolution. */
byte_swapped = FALSE;
modified = FALSE;
- wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
+ wth->file_tsprec = WTAP_TSPREC_NSEC;
break;
case PCAP_SWAPPED_NSEC_MAGIC:
@@ -167,7 +167,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
nanosecond resolution. */
byte_swapped = TRUE;
modified = FALSE;
- wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
+ wth->file_tsprec = WTAP_TSPREC_NSEC;
break;
default:
@@ -326,7 +326,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* precision to nanosecond precision.
*/
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_AIX;
- wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
+ wth->file_tsprec = WTAP_TSPREC_NSEC;
return 1;
}
@@ -371,7 +371,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
subtypes = subtypes_modified;
n_subtypes = N_SUBTYPES_MODIFIED;
} else {
- if (wth->tsprecision == WTAP_FILE_TSPREC_NSEC) {
+ if (wth->file_tsprec == WTAP_TSPREC_NSEC) {
/*
* We have nanosecond-format libpcap's magic
* number. Try the subtypes for that.
@@ -715,7 +715,7 @@ libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
/* Update the timestamp, if not already done */
if (wth->file_encap != WTAP_ENCAP_ERF) {
phdr->ts.secs = hdr.hdr.ts_sec;
- if (wth->tsprecision == WTAP_FILE_TSPREC_NSEC)
+ if (wth->file_tsprec == WTAP_TSPREC_NSEC)
phdr->ts.nsecs = hdr.hdr.ts_usec;
else
phdr->ts.nsecs = hdr.hdr.ts_usec * 1000;
@@ -851,18 +851,18 @@ 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_FILE_TSPREC_USEC;
+ 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_FILE_TSPREC_USEC;
+ 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_FILE_TSPREC_NSEC;
+ wdh->tsprecision = WTAP_TSPREC_NSEC;
break;
default:
@@ -928,7 +928,7 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
}
rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs;
- if(wdh->tsprecision == WTAP_FILE_TSPREC_NSEC) {
+ if(wdh->tsprecision == WTAP_TSPREC_NSEC) {
rec_hdr.hdr.ts_usec = phdr->ts.nsecs;
} else {
rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000;