aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2020-07-28 13:25:38 -0700
committerAnders Broman <a.broman58@gmail.com>2020-07-29 13:49:09 +0000
commitc68d36b173b3bafd007e2d14461dfb0f194e0bde (patch)
treefd2c674da5d5e2ad67ad906eaf2c6e7efcc2fa00 /wiretap
parentf8efccc3cc1e8d604a4fd085ab9a0f0174e9b25f (diff)
wiretap: have the file's time stamp resolution be a dump parameter.
Add a tsprec value to the wtap_dump_params structure, giving the per-file time stamp precision. In wtap_dump_init_dumper(), when constructing a dummy IDB for files that don't have one, fill in the tsprecision and time_units_per_second values based on the tsprec value in the wtap_dump_params structure. Change-Id: I3708b144d4d0ac0dfbe32bd1c16768a75c942141 Reviewed-on: https://code.wireshark.org/review/37979 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/file_access.c32
-rw-r--r--wiretap/wtap.c1
-rw-r--r--wiretap/wtap.h1
3 files changed, 33 insertions, 1 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 3875ffbd2b..b39ad9a8c8 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -2328,7 +2328,37 @@ wtap_dump_init_dumper(int file_type_subtype, wtap_compression_type compression_t
descr = wtap_block_create(WTAP_BLOCK_IF_DESCR);
descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(descr);
descr_mand->wtap_encap = params->encap;
- descr_mand->time_units_per_second = 1000000; /* default microsecond resolution */
+ descr_mand->tsprecision = params->tsprec;
+ switch (params->tsprec) {
+
+ case WTAP_TSPREC_SEC:
+ descr_mand->time_units_per_second = 1;
+ break;
+
+ case WTAP_TSPREC_DSEC:
+ descr_mand->time_units_per_second = 10;
+ break;
+
+ case WTAP_TSPREC_CSEC:
+ descr_mand->time_units_per_second = 100;
+ break;
+
+ case WTAP_TSPREC_MSEC:
+ descr_mand->time_units_per_second = 1000;
+ break;
+
+ case WTAP_TSPREC_USEC:
+ descr_mand->time_units_per_second = 1000000;
+ break;
+
+ case WTAP_TSPREC_NSEC:
+ descr_mand->time_units_per_second = 1000000000;
+ break;
+
+ default:
+ descr_mand->time_units_per_second = 1000000; /* default microsecond resolution */
+ break;
+ }
snaplen = params->snaplen;
if (snaplen == 0) {
/*
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 84d26064b6..804b027ca5 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -420,6 +420,7 @@ wtap_dump_params_init(wtap_dump_params *params, wtap *wth)
params->encap = wtap_file_encap(wth);
params->snaplen = wtap_snapshot_length(wth);
+ params->tsprec = wtap_file_tsprec(wth);
params->shb_hdrs = wtap_file_get_shb_for_new_file(wth);
params->idb_inf = wtap_file_get_idb_info(wth);
params->nrb_hdrs = wtap_file_get_nrb_for_new_file(wth);
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 186f1a31a8..52ed51a563 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1565,6 +1565,7 @@ typedef struct addrinfo_lists {
typedef struct wtap_dump_params {
int encap; /**< Per-file packet encapsulation, or WTAP_ENCAP_PER_PACKET */
int snaplen; /**< Per-file snapshot length (what if it's per-interface?) */
+ int tsprec; /**< Per-file time stamp precision */
GArray *shb_hdrs; /**< The section header block(s) information, or NULL. */
wtapng_iface_descriptions_t *idb_inf; /**< The interface description information, or NULL. */
GArray *nrb_hdrs; /**< The name resolution blocks(s) comment/custom_opts information, or NULL. */