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>
This commit is contained in:
Guy Harris 2014-09-28 11:37:06 -07:00
parent efea8ce1c6
commit 54b733ce9a
65 changed files with 390 additions and 344 deletions

View File

@ -757,6 +757,7 @@ set_abs_ymd_time(const frame_data *fd, gchar *buf, gboolean local)
{
struct tm *tmp;
time_t then;
int tsprecision;
if (fd->flags.has_ts) {
then = fd->abs_ts.secs;
@ -769,7 +770,31 @@ set_abs_ymd_time(const frame_data *fd, gchar *buf, gboolean local)
if (tmp != NULL) {
switch (timestamp_get_precision()) {
case TS_PREC_FIXED_SEC:
case TS_PREC_AUTO_SEC:
tsprecision = WTAP_TSPREC_SEC;
break;
case TS_PREC_FIXED_DSEC:
tsprecision = WTAP_TSPREC_DSEC;
break;
case TS_PREC_FIXED_CSEC:
tsprecision = WTAP_TSPREC_CSEC;
break;
case TS_PREC_FIXED_MSEC:
tsprecision = WTAP_TSPREC_MSEC;
break;
case TS_PREC_FIXED_USEC:
tsprecision = WTAP_TSPREC_USEC;
break;
case TS_PREC_FIXED_NSEC:
tsprecision = WTAP_TSPREC_NSEC;
break;
case TS_PREC_AUTO:
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
@ -778,8 +803,7 @@ set_abs_ymd_time(const frame_data *fd, gchar *buf, gboolean local)
tmp->tm_min,
tmp->tm_sec);
break;
case TS_PREC_FIXED_DSEC:
case TS_PREC_AUTO_DSEC:
case WTAP_TSPREC_DSEC:
g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%01d",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
@ -789,8 +813,7 @@ set_abs_ymd_time(const frame_data *fd, gchar *buf, gboolean local)
tmp->tm_sec,
fd->abs_ts.nsecs / 100000000);
break;
case TS_PREC_FIXED_CSEC:
case TS_PREC_AUTO_CSEC:
case WTAP_TSPREC_CSEC:
g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%02d",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
@ -800,8 +823,7 @@ set_abs_ymd_time(const frame_data *fd, gchar *buf, gboolean local)
tmp->tm_sec,
fd->abs_ts.nsecs / 10000000);
break;
case TS_PREC_FIXED_MSEC:
case TS_PREC_AUTO_MSEC:
case WTAP_TSPREC_MSEC:
g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%03d",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
@ -811,8 +833,7 @@ set_abs_ymd_time(const frame_data *fd, gchar *buf, gboolean local)
tmp->tm_sec,
fd->abs_ts.nsecs / 1000000);
break;
case TS_PREC_FIXED_USEC:
case TS_PREC_AUTO_USEC:
case WTAP_TSPREC_USEC:
g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%06d",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
@ -822,8 +843,7 @@ set_abs_ymd_time(const frame_data *fd, gchar *buf, gboolean local)
tmp->tm_sec,
fd->abs_ts.nsecs / 1000);
break;
case TS_PREC_FIXED_NSEC:
case TS_PREC_AUTO_NSEC:
case WTAP_TSPREC_NSEC:
g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%09d",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
@ -866,6 +886,7 @@ set_abs_ydoy_time(const frame_data *fd, gchar *buf, gboolean local)
{
struct tm *tmp;
time_t then;
int tsprecision;
if (fd->flags.has_ts) {
then = fd->abs_ts.secs;
@ -878,7 +899,31 @@ set_abs_ydoy_time(const frame_data *fd, gchar *buf, gboolean local)
if (tmp != NULL) {
switch (timestamp_get_precision()) {
case TS_PREC_FIXED_SEC:
case TS_PREC_AUTO_SEC:
tsprecision = WTAP_TSPREC_SEC;
break;
case TS_PREC_FIXED_DSEC:
tsprecision = WTAP_TSPREC_DSEC;
break;
case TS_PREC_FIXED_CSEC:
tsprecision = WTAP_TSPREC_CSEC;
break;
case TS_PREC_FIXED_MSEC:
tsprecision = WTAP_TSPREC_MSEC;
break;
case TS_PREC_FIXED_USEC:
tsprecision = WTAP_TSPREC_USEC;
break;
case TS_PREC_FIXED_NSEC:
tsprecision = WTAP_TSPREC_NSEC;
break;
case TS_PREC_AUTO:
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
g_snprintf(buf, COL_MAX_LEN,"%04d/%03d %02d:%02d:%02d",
tmp->tm_year + 1900,
tmp->tm_yday + 1,
@ -886,8 +931,7 @@ set_abs_ydoy_time(const frame_data *fd, gchar *buf, gboolean local)
tmp->tm_min,
tmp->tm_sec);
break;
case TS_PREC_FIXED_DSEC:
case TS_PREC_AUTO_DSEC:
case WTAP_TSPREC_DSEC:
g_snprintf(buf, COL_MAX_LEN,"%04d/%03d %02d:%02d:%02d.%01d",
tmp->tm_year + 1900,
tmp->tm_yday + 1,
@ -896,8 +940,7 @@ set_abs_ydoy_time(const frame_data *fd, gchar *buf, gboolean local)
tmp->tm_sec,
fd->abs_ts.nsecs / 100000000);
break;
case TS_PREC_FIXED_CSEC:
case TS_PREC_AUTO_CSEC:
case WTAP_TSPREC_CSEC:
g_snprintf(buf, COL_MAX_LEN,"%04d/%03d %02d:%02d:%02d.%02d",
tmp->tm_year + 1900,
tmp->tm_yday + 1,
@ -906,8 +949,7 @@ set_abs_ydoy_time(const frame_data *fd, gchar *buf, gboolean local)
tmp->tm_sec,
fd->abs_ts.nsecs / 10000000);
break;
case TS_PREC_FIXED_MSEC:
case TS_PREC_AUTO_MSEC:
case WTAP_TSPREC_MSEC:
g_snprintf(buf, COL_MAX_LEN, "%04d/%03d %02d:%02d:%02d.%03d",
tmp->tm_year + 1900,
tmp->tm_yday + 1,
@ -916,8 +958,7 @@ set_abs_ydoy_time(const frame_data *fd, gchar *buf, gboolean local)
tmp->tm_sec,
fd->abs_ts.nsecs / 1000000);
break;
case TS_PREC_FIXED_USEC:
case TS_PREC_AUTO_USEC:
case WTAP_TSPREC_USEC:
g_snprintf(buf, COL_MAX_LEN, "%04d/%03d %02d:%02d:%02d.%06d",
tmp->tm_year + 1900,
tmp->tm_yday + 1,
@ -926,8 +967,7 @@ set_abs_ydoy_time(const frame_data *fd, gchar *buf, gboolean local)
tmp->tm_sec,
fd->abs_ts.nsecs / 1000);
break;
case TS_PREC_FIXED_NSEC:
case TS_PREC_AUTO_NSEC:
case WTAP_TSPREC_NSEC:
g_snprintf(buf, COL_MAX_LEN, "%04d/%03d %02d:%02d:%02d.%09d",
tmp->tm_year + 1900,
tmp->tm_yday + 1,
@ -965,36 +1005,57 @@ col_set_utc_ydoy_time(const frame_data *fd, column_info *cinfo, const int col)
}
static void
set_time_seconds(const nstime_t *ts, gchar *buf)
set_time_seconds(const frame_data *fd, const nstime_t *ts, gchar *buf)
{
int tsprecision;
switch (timestamp_get_precision()) {
case TS_PREC_FIXED_SEC:
case TS_PREC_AUTO_SEC:
tsprecision = WTAP_TSPREC_SEC;
break;
case TS_PREC_FIXED_DSEC:
tsprecision = WTAP_TSPREC_DSEC;
break;
case TS_PREC_FIXED_CSEC:
tsprecision = WTAP_TSPREC_CSEC;
break;
case TS_PREC_FIXED_MSEC:
tsprecision = WTAP_TSPREC_MSEC;
break;
case TS_PREC_FIXED_USEC:
tsprecision = WTAP_TSPREC_USEC;
break;
case TS_PREC_FIXED_NSEC:
tsprecision = WTAP_TSPREC_NSEC;
break;
case TS_PREC_AUTO:
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
display_signed_time(buf, COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
break;
case TS_PREC_FIXED_DSEC:
case TS_PREC_AUTO_DSEC:
case WTAP_TSPREC_DSEC:
display_signed_time(buf, COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
break;
case TS_PREC_FIXED_CSEC:
case TS_PREC_AUTO_CSEC:
case WTAP_TSPREC_CSEC:
display_signed_time(buf, COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
break;
case TS_PREC_FIXED_MSEC:
case TS_PREC_AUTO_MSEC:
case WTAP_TSPREC_MSEC:
display_signed_time(buf, COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
break;
case TS_PREC_FIXED_USEC:
case TS_PREC_AUTO_USEC:
case WTAP_TSPREC_USEC:
display_signed_time(buf, COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs / 1000, TO_STR_TIME_RES_T_USECS);
break;
case TS_PREC_FIXED_NSEC:
case TS_PREC_AUTO_NSEC:
case WTAP_TSPREC_NSEC:
display_signed_time(buf, COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
break;
@ -1004,11 +1065,12 @@ set_time_seconds(const nstime_t *ts, gchar *buf)
}
static void
set_time_hour_min_sec(const nstime_t *ts, gchar *buf)
set_time_hour_min_sec(const frame_data *fd, const nstime_t *ts, gchar *buf)
{
time_t secs = ts->secs;
long nsecs = (long) ts->nsecs;
gboolean negative = FALSE;
int tsprecision;
if (secs < 0) {
secs = -secs;
@ -1021,7 +1083,31 @@ set_time_hour_min_sec(const nstime_t *ts, gchar *buf)
switch (timestamp_get_precision()) {
case TS_PREC_FIXED_SEC:
case TS_PREC_AUTO_SEC:
tsprecision = WTAP_TSPREC_SEC;
break;
case TS_PREC_FIXED_DSEC:
tsprecision = WTAP_TSPREC_DSEC;
break;
case TS_PREC_FIXED_CSEC:
tsprecision = WTAP_TSPREC_CSEC;
break;
case TS_PREC_FIXED_MSEC:
tsprecision = WTAP_TSPREC_MSEC;
break;
case TS_PREC_FIXED_USEC:
tsprecision = WTAP_TSPREC_USEC;
break;
case TS_PREC_FIXED_NSEC:
tsprecision = WTAP_TSPREC_NSEC;
break;
case TS_PREC_AUTO:
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
if (secs >= (60*60)) {
g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2ds",
negative ? "- " : "",
@ -1039,8 +1125,7 @@ set_time_hour_min_sec(const nstime_t *ts, gchar *buf)
(gint32) secs);
}
break;
case TS_PREC_FIXED_DSEC:
case TS_PREC_AUTO_DSEC:
case WTAP_TSPREC_DSEC:
if (secs >= (60*60)) {
g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%01lds",
negative ? "- " : "",
@ -1061,8 +1146,7 @@ set_time_hour_min_sec(const nstime_t *ts, gchar *buf)
nsecs / 100000000);
}
break;
case TS_PREC_FIXED_CSEC:
case TS_PREC_AUTO_CSEC:
case WTAP_TSPREC_CSEC:
if (secs >= (60*60)) {
g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%02lds",
negative ? "- " : "",
@ -1083,8 +1167,7 @@ set_time_hour_min_sec(const nstime_t *ts, gchar *buf)
nsecs / 10000000);
}
break;
case TS_PREC_FIXED_MSEC:
case TS_PREC_AUTO_MSEC:
case WTAP_TSPREC_MSEC:
if (secs >= (60*60)) {
g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%03lds",
negative ? "- " : "",
@ -1105,8 +1188,7 @@ set_time_hour_min_sec(const nstime_t *ts, gchar *buf)
nsecs / 1000000);
}
break;
case TS_PREC_FIXED_USEC:
case TS_PREC_AUTO_USEC:
case WTAP_TSPREC_USEC:
if (secs >= (60*60)) {
g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%06lds",
negative ? "- " : "",
@ -1127,8 +1209,7 @@ set_time_hour_min_sec(const nstime_t *ts, gchar *buf)
nsecs / 1000);
}
break;
case TS_PREC_FIXED_NSEC:
case TS_PREC_AUTO_NSEC:
case WTAP_TSPREC_NSEC:
if (secs >= (60*60)) {
g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%09lds",
negative ? "- " : "",
@ -1168,14 +1249,14 @@ col_set_rel_time(const frame_data *fd, column_info *cinfo, const int col)
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
set_time_seconds(&del_rel_ts, cinfo->col_buf[col]);
set_time_seconds(fd, &del_rel_ts, cinfo->col_buf[col]);
cinfo->col_expr.col_expr[col] = "frame.time_relative";
g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
break;
case TS_SECONDS_HOUR_MIN_SEC:
set_time_hour_min_sec(&del_rel_ts, cinfo->col_buf[col]);
set_time_hour_min_sec(fd, &del_rel_ts, cinfo->col_buf[col]);
cinfo->col_expr.col_expr[col] = "frame.time_relative";
set_time_seconds(&del_rel_ts, cinfo->col_expr.col_expr_val[col]);
set_time_seconds(fd, &del_rel_ts, cinfo->col_expr.col_expr_val[col]);
break;
default:
g_assert_not_reached();
@ -1192,14 +1273,14 @@ col_set_delta_time(const frame_data *fd, column_info *cinfo, const int col)
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
set_time_seconds(&del_cap_ts, cinfo->col_buf[col]);
set_time_seconds(fd, &del_cap_ts, cinfo->col_buf[col]);
cinfo->col_expr.col_expr[col] = "frame.time_delta";
g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
break;
case TS_SECONDS_HOUR_MIN_SEC:
set_time_hour_min_sec(&del_cap_ts, cinfo->col_buf[col]);
set_time_hour_min_sec(fd, &del_cap_ts, cinfo->col_buf[col]);
cinfo->col_expr.col_expr[col] = "frame.time_delta";
set_time_seconds(&del_cap_ts, cinfo->col_expr.col_expr_val[col]);
set_time_seconds(fd, &del_cap_ts, cinfo->col_expr.col_expr_val[col]);
break;
default:
g_assert_not_reached();
@ -1222,14 +1303,14 @@ col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col)
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
set_time_seconds(&del_dis_ts, cinfo->col_buf[col]);
set_time_seconds(fd, &del_dis_ts, cinfo->col_buf[col]);
cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
break;
case TS_SECONDS_HOUR_MIN_SEC:
set_time_hour_min_sec(&del_dis_ts, cinfo->col_buf[col]);
set_time_hour_min_sec(fd, &del_dis_ts, cinfo->col_buf[col]);
cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
set_time_seconds(&del_dis_ts, cinfo->col_expr.col_expr_val[col]);
set_time_seconds(fd, &del_dis_ts, cinfo->col_expr.col_expr_val[col]);
break;
default:
g_assert_not_reached();
@ -1243,6 +1324,7 @@ set_abs_time(const frame_data *fd, gchar *buf, gboolean local)
{
struct tm *tmp;
time_t then;
int tsprecision;
if (fd->flags.has_ts) {
then = fd->abs_ts.secs;
@ -1255,46 +1337,65 @@ set_abs_time(const frame_data *fd, gchar *buf, gboolean local)
if (tmp != NULL) {
switch (timestamp_get_precision()) {
case TS_PREC_FIXED_SEC:
case TS_PREC_AUTO_SEC:
tsprecision = WTAP_TSPREC_SEC;
break;
case TS_PREC_FIXED_DSEC:
tsprecision = WTAP_TSPREC_DSEC;
break;
case TS_PREC_FIXED_CSEC:
tsprecision = WTAP_TSPREC_CSEC;
break;
case TS_PREC_FIXED_MSEC:
tsprecision = WTAP_TSPREC_MSEC;
break;
case TS_PREC_FIXED_USEC:
tsprecision = WTAP_TSPREC_USEC;
break;
case TS_PREC_FIXED_NSEC:
tsprecision = WTAP_TSPREC_NSEC;
break;
case TS_PREC_AUTO:
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d",
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec);
break;
case TS_PREC_FIXED_DSEC:
case TS_PREC_AUTO_DSEC:
case WTAP_TSPREC_DSEC:
g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%01d",
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
fd->abs_ts.nsecs / 100000000);
break;
case TS_PREC_FIXED_CSEC:
case TS_PREC_AUTO_CSEC:
case WTAP_TSPREC_CSEC:
g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%02d",
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
fd->abs_ts.nsecs / 10000000);
break;
case TS_PREC_FIXED_MSEC:
case TS_PREC_AUTO_MSEC:
case WTAP_TSPREC_MSEC:
g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%03d",
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
fd->abs_ts.nsecs / 1000000);
break;
case TS_PREC_FIXED_USEC:
case TS_PREC_AUTO_USEC:
case WTAP_TSPREC_USEC:
g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%06d",
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
fd->abs_ts.nsecs / 1000);
break;
case TS_PREC_FIXED_NSEC:
case TS_PREC_AUTO_NSEC:
case WTAP_TSPREC_NSEC:
g_snprintf(buf, COL_MAX_LEN, "%02d:%02d:%02d.%09d",
tmp->tm_hour,
tmp->tm_min,
@ -1333,38 +1434,59 @@ col_set_utc_time(const frame_data *fd, column_info *cinfo, const int col)
static gboolean
set_epoch_time(const frame_data *fd, gchar *buf)
{
int tsprecision;
if (!fd->flags.has_ts) {
buf[0] = '\0';
return FALSE;
}
switch (timestamp_get_precision()) {
case TS_PREC_FIXED_SEC:
case TS_PREC_AUTO_SEC:
tsprecision = WTAP_TSPREC_SEC;
break;
case TS_PREC_FIXED_DSEC:
tsprecision = WTAP_TSPREC_DSEC;
break;
case TS_PREC_FIXED_CSEC:
tsprecision = WTAP_TSPREC_CSEC;
break;
case TS_PREC_FIXED_MSEC:
tsprecision = WTAP_TSPREC_MSEC;
break;
case TS_PREC_FIXED_USEC:
tsprecision = WTAP_TSPREC_USEC;
break;
case TS_PREC_FIXED_NSEC:
tsprecision = WTAP_TSPREC_NSEC;
break;
case TS_PREC_AUTO:
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
display_epoch_time(buf, COL_MAX_LEN,
fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
break;
case TS_PREC_FIXED_DSEC:
case TS_PREC_AUTO_DSEC:
case WTAP_TSPREC_DSEC:
display_epoch_time(buf, COL_MAX_LEN,
fd->abs_ts.secs, fd->abs_ts.nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
break;
case TS_PREC_FIXED_CSEC:
case TS_PREC_AUTO_CSEC:
case WTAP_TSPREC_CSEC:
display_epoch_time(buf, COL_MAX_LEN,
fd->abs_ts.secs, fd->abs_ts.nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
break;
case TS_PREC_FIXED_MSEC:
case TS_PREC_AUTO_MSEC:
case WTAP_TSPREC_MSEC:
display_epoch_time(buf, COL_MAX_LEN,
fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
break;
case TS_PREC_FIXED_USEC:
case TS_PREC_AUTO_USEC:
case WTAP_TSPREC_USEC:
display_epoch_time(buf, COL_MAX_LEN,
fd->abs_ts.secs, fd->abs_ts.nsecs / 1000, TO_STR_TIME_RES_T_USECS);
break;
case TS_PREC_FIXED_NSEC:
case TS_PREC_AUTO_NSEC:
case WTAP_TSPREC_NSEC:
display_epoch_time(buf, COL_MAX_LEN,
fd->abs_ts.secs, fd->abs_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
break;
@ -1409,10 +1531,10 @@ set_fd_time(const epan_t *epan, frame_data *fd, gchar *buf)
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
set_time_seconds(&del_rel_ts, buf);
set_time_seconds(fd, &del_rel_ts, buf);
break;
case TS_SECONDS_HOUR_MIN_SEC:
set_time_seconds(&del_rel_ts, buf);
set_time_seconds(fd, &del_rel_ts, buf);
break;
default:
g_assert_not_reached();
@ -1430,10 +1552,10 @@ set_fd_time(const epan_t *epan, frame_data *fd, gchar *buf)
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
set_time_seconds(&del_cap_ts, buf);
set_time_seconds(fd, &del_cap_ts, buf);
break;
case TS_SECONDS_HOUR_MIN_SEC:
set_time_hour_min_sec(&del_cap_ts, buf);
set_time_hour_min_sec(fd, &del_cap_ts, buf);
break;
default:
g_assert_not_reached();
@ -1451,10 +1573,10 @@ set_fd_time(const epan_t *epan, frame_data *fd, gchar *buf)
switch (timestamp_get_seconds_type()) {
case TS_SECONDS_DEFAULT:
set_time_seconds(&del_dis_ts, buf);
set_time_seconds(fd, &del_dis_ts, buf);
break;
case TS_SECONDS_HOUR_MIN_SEC:
set_time_hour_min_sec(&del_dis_ts, buf);
set_time_hour_min_sec(fd, &del_dis_ts, buf);
break;
default:
g_assert_not_reached();
@ -1619,32 +1741,27 @@ col_set_time(column_info *cinfo, const gint el, const nstime_t *ts, const char *
if (cinfo->fmt_matx[col][el]) {
switch (timestamp_get_precision()) {
case TS_PREC_FIXED_SEC:
case TS_PREC_AUTO_SEC:
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
break;
case TS_PREC_FIXED_DSEC:
case TS_PREC_AUTO_DSEC:
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
break;
case TS_PREC_FIXED_CSEC:
case TS_PREC_AUTO_CSEC:
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
break;
case TS_PREC_FIXED_MSEC:
case TS_PREC_AUTO_MSEC:
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
break;
case TS_PREC_FIXED_USEC:
case TS_PREC_AUTO_USEC:
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs / 1000, TO_STR_TIME_RES_T_USECS);
break;
case TS_PREC_FIXED_NSEC:
case TS_PREC_AUTO_NSEC:
case TS_PREC_AUTO: /* default to maximum */
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
(gint32) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
break;

View File

@ -286,28 +286,23 @@ get_timestamp_column_longest_string(const gint type, const gint precision)
case(TS_ABSOLUTE_WITH_YMD):
case(TS_UTC_WITH_YMD):
switch(precision) {
case(TS_PREC_AUTO_SEC):
case(TS_PREC_FIXED_SEC):
return "0000-00-00 00:00:00";
break;
case(TS_PREC_AUTO_DSEC):
case(TS_PREC_FIXED_DSEC):
return "0000-00-00 00:00:00.0";
break;
case(TS_PREC_AUTO_CSEC):
case(TS_PREC_FIXED_CSEC):
return "0000-00-00 00:00:00.00";
break;
case(TS_PREC_AUTO_MSEC):
case(TS_PREC_FIXED_MSEC):
return "0000-00-00 00:00:00.000";
break;
case(TS_PREC_AUTO_USEC):
case(TS_PREC_FIXED_USEC):
return "0000-00-00 00:00:00.000000";
break;
case(TS_PREC_AUTO_NSEC):
case(TS_PREC_FIXED_NSEC):
case(TS_PREC_AUTO): /* Leave enough room for the maximum */
return "0000-00-00 00:00:00.000000000";
break;
default:
@ -317,28 +312,23 @@ get_timestamp_column_longest_string(const gint type, const gint precision)
case(TS_ABSOLUTE_WITH_YDOY):
case(TS_UTC_WITH_YDOY):
switch(precision) {
case(TS_PREC_AUTO_SEC):
case(TS_PREC_FIXED_SEC):
return "0000/000 00:00:00";
break;
case(TS_PREC_AUTO_DSEC):
case(TS_PREC_FIXED_DSEC):
return "0000/000 00:00:00.0";
break;
case(TS_PREC_AUTO_CSEC):
case(TS_PREC_FIXED_CSEC):
return "0000/000 00:00:00.00";
break;
case(TS_PREC_AUTO_MSEC):
case(TS_PREC_FIXED_MSEC):
return "0000/000 00:00:00.000";
break;
case(TS_PREC_AUTO_USEC):
case(TS_PREC_FIXED_USEC):
return "0000/000 00:00:00.000000";
break;
case(TS_PREC_AUTO_NSEC):
case(TS_PREC_FIXED_NSEC):
case(TS_PREC_AUTO): /* Leave enough room for the maximum */
return "0000/000 00:00:00.000000000";
break;
default:
@ -348,28 +338,23 @@ get_timestamp_column_longest_string(const gint type, const gint precision)
case(TS_ABSOLUTE):
case(TS_UTC):
switch(precision) {
case(TS_PREC_AUTO_SEC):
case(TS_PREC_FIXED_SEC):
return "00:00:00";
break;
case(TS_PREC_AUTO_DSEC):
case(TS_PREC_FIXED_DSEC):
return "00:00:00.0";
break;
case(TS_PREC_AUTO_CSEC):
case(TS_PREC_FIXED_CSEC):
return "00:00:00.00";
break;
case(TS_PREC_AUTO_MSEC):
case(TS_PREC_FIXED_MSEC):
return "00:00:00.000";
break;
case(TS_PREC_AUTO_USEC):
case(TS_PREC_FIXED_USEC):
return "00:00:00.000000";
break;
case(TS_PREC_AUTO_NSEC):
case(TS_PREC_FIXED_NSEC):
case(TS_PREC_AUTO): /* Leave enough room for the maximum */
return "00:00:00.000000000";
break;
default:
@ -380,28 +365,23 @@ get_timestamp_column_longest_string(const gint type, const gint precision)
case(TS_DELTA):
case(TS_DELTA_DIS):
switch(precision) {
case(TS_PREC_AUTO_SEC):
case(TS_PREC_FIXED_SEC):
return "0000";
break;
case(TS_PREC_AUTO_DSEC):
case(TS_PREC_FIXED_DSEC):
return "0000.0";
break;
case(TS_PREC_AUTO_CSEC):
case(TS_PREC_FIXED_CSEC):
return "0000.00";
break;
case(TS_PREC_AUTO_MSEC):
case(TS_PREC_FIXED_MSEC):
return "0000.000";
break;
case(TS_PREC_AUTO_USEC):
case(TS_PREC_FIXED_USEC):
return "0000.000000";
break;
case(TS_PREC_AUTO_NSEC):
case(TS_PREC_FIXED_NSEC):
case(TS_PREC_AUTO): /* Leave enough room for the maximum */
return "0000.000000000";
break;
default:
@ -411,28 +391,23 @@ get_timestamp_column_longest_string(const gint type, const gint precision)
case(TS_EPOCH):
/* This is enough to represent 2^63 (signed 64-bit integer) + fractions */
switch(precision) {
case(TS_PREC_AUTO_SEC):
case(TS_PREC_FIXED_SEC):
return "0000000000000000000";
break;
case(TS_PREC_AUTO_DSEC):
case(TS_PREC_FIXED_DSEC):
return "0000000000000000000.0";
break;
case(TS_PREC_AUTO_CSEC):
case(TS_PREC_FIXED_CSEC):
return "0000000000000000000.00";
break;
case(TS_PREC_AUTO_MSEC):
case(TS_PREC_FIXED_MSEC):
return "0000000000000000000.000";
break;
case(TS_PREC_AUTO_USEC):
case(TS_PREC_FIXED_USEC):
return "0000000000000000000.000000";
break;
case(TS_PREC_AUTO_NSEC):
case(TS_PREC_FIXED_NSEC):
case(TS_PREC_AUTO): /* Leave enough room for the maximum */
return "0000000000000000000.000000000";
break;
default:

View File

@ -311,6 +311,7 @@ frame_data_init(frame_data *fdata, guint32 num,
fdata->flags.has_ts = (phdr->presence_flags & WTAP_HAS_TS) ? 1 : 0;
fdata->flags.has_phdr_comment = (phdr->opt_comment != NULL);
fdata->flags.has_user_comment = 0;
fdata->tsprec = (gint16)phdr->pkt_tsprec;
fdata->color_filter = NULL;
fdata->abs_ts.secs = phdr->ts.secs;
fdata->abs_ts.nsecs = phdr->ts.nsecs;

View File

@ -77,6 +77,7 @@ typedef struct _frame_data {
unsigned int has_phdr_comment : 1; /** 1 = there's comment for this packet */
unsigned int has_user_comment : 1; /** 1 = user set (also deleted) comment for this packet */
} flags;
gint16 tsprec; /**< Time stamp precision */
const void *color_filter; /**< Per-packet matching color_filter_t object */

View File

@ -28,7 +28,7 @@
* and distinguish it from a command line value */
static ts_type timestamp_type = TS_NOT_SET;
static int timestamp_precision = TS_PREC_AUTO_USEC;
static int timestamp_precision = TS_PREC_AUTO;
static ts_seconds_type timestamp_seconds_type = TS_SECONDS_NOT_SET;

View File

@ -52,19 +52,13 @@ typedef enum {
} ts_type;
typedef enum {
TS_PREC_AUTO, /* recent */
TS_PREC_FIXED_SEC, /* recent and internal */
TS_PREC_FIXED_DSEC, /* recent and internal */
TS_PREC_FIXED_CSEC, /* recent and internal */
TS_PREC_FIXED_MSEC, /* recent and internal */
TS_PREC_FIXED_USEC, /* recent and internal */
TS_PREC_FIXED_NSEC, /* recent and internal */
TS_PREC_AUTO_SEC, /* internal */
TS_PREC_AUTO_DSEC, /* internal */
TS_PREC_AUTO_CSEC, /* internal */
TS_PREC_AUTO_MSEC, /* internal */
TS_PREC_AUTO_USEC, /* internal */
TS_PREC_AUTO_NSEC /* internal */
TS_PREC_AUTO,
TS_PREC_FIXED_SEC,
TS_PREC_FIXED_DSEC,
TS_PREC_FIXED_CSEC,
TS_PREC_FIXED_MSEC,
TS_PREC_FIXED_USEC,
TS_PREC_FIXED_NSEC
} ts_precision;
typedef enum {

View File

@ -705,7 +705,7 @@ static CaptureInfo* push_CaptureInfo(lua_State* L, wtap *wth, const gboolean fir
if (first_time) {
/* XXX: need to do this? */
wth->file_encap = WTAP_ENCAP_UNKNOWN;
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
wth->file_tsprec = WTAP_TSPREC_UNKNOWN;
wth->snapshot_length = 0;
}
@ -720,8 +720,8 @@ WSLUA_METAMETHOD CaptureInfo__tostring(lua_State* L) {
lua_pushstring(L,"CaptureInfo pointer is NULL!");
} else {
wtap *wth = fi->wth;
lua_pushfstring(L, "CaptureInfo: file_type_subtype=%d, snapshot_length=%d, pkt_encap=%d, tsprecision='%s'",
wth->file_type_subtype, wth->snapshot_length, wth->phdr.pkt_encap, wth->tsprecision);
lua_pushfstring(L, "CaptureInfo: file_type_subtype=%d, snapshot_length=%d, pkt_encap=%d, file_tsprec='%s'",
wth->file_type_subtype, wth->snapshot_length, wth->phdr.pkt_encap, wth->file_tsprec);
}
WSLUA_RETURN(1); /* String of debug information. */
@ -747,8 +747,8 @@ WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,encap,wth->file_encap,int);
See `wtap_file_tsprec` in `init.lua` for available precisions.
*/
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,time_precision,wth->tsprecision);
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,time_precision,wth->tsprecision,int);
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,time_precision,wth->file_tsprec);
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,time_precision,wth->file_tsprec,int);
/* WSLUA_ATTRIBUTE CaptureInfo_snapshot_length RW The maximum packet length that could be recorded.
@ -979,7 +979,7 @@ WSLUA_METAMETHOD CaptureInfoConst__tostring(lua_State* L) {
lua_pushstring(L,"CaptureInfoConst pointer is NULL!");
} else {
wtap_dumper *wdh = fi->wdh;
lua_pushfstring(L, "CaptureInfoConst: file_type_subtype=%d, snaplen=%d, encap=%d, compressed=%d, tsprecision='%s'",
lua_pushfstring(L, "CaptureInfoConst: file_type_subtype=%d, snaplen=%d, encap=%d, compressed=%d, file_tsprec='%s'",
wdh->file_type_subtype, wdh->snaplen, wdh->encap, wdh->compressed, wdh->tsprecision);
}

34
file.c
View File

@ -217,46 +217,12 @@ void
cf_timestamp_auto_precision(capture_file *cf)
{
int i;
int prec = timestamp_get_precision();
/* don't try to get the file's precision if none is opened */
if (cf->state == FILE_CLOSED) {
return;
}
/* if we are in auto mode, set precision of current file */
if (prec == TS_PREC_AUTO ||
prec == TS_PREC_AUTO_SEC ||
prec == TS_PREC_AUTO_DSEC ||
prec == TS_PREC_AUTO_CSEC ||
prec == TS_PREC_AUTO_MSEC ||
prec == TS_PREC_AUTO_USEC ||
prec == TS_PREC_AUTO_NSEC)
{
switch(wtap_file_tsprecision(cf->wth)) {
case(WTAP_FILE_TSPREC_SEC):
timestamp_set_precision(TS_PREC_AUTO_SEC);
break;
case(WTAP_FILE_TSPREC_DSEC):
timestamp_set_precision(TS_PREC_AUTO_DSEC);
break;
case(WTAP_FILE_TSPREC_CSEC):
timestamp_set_precision(TS_PREC_AUTO_CSEC);
break;
case(WTAP_FILE_TSPREC_MSEC):
timestamp_set_precision(TS_PREC_AUTO_MSEC);
break;
case(WTAP_FILE_TSPREC_USEC):
timestamp_set_precision(TS_PREC_AUTO_USEC);
break;
case(WTAP_FILE_TSPREC_NSEC):
timestamp_set_precision(TS_PREC_AUTO_NSEC);
break;
default:
g_assert_not_reached();
}
}
/* Set the column widths of those columns that show the time in
"command-line-specified" format. */
for (i = 0; i < cf->cinfo.num_cols; i++) {

View File

@ -873,35 +873,6 @@ main(int argc, char *argv[])
}
}
/* Set timestamp precision; there should arguably be a command-line
option to let the user set this. */
#if 0
switch(wtap_file_tsprecision(cfile.wth)) {
case(WTAP_FILE_TSPREC_SEC):
timestamp_set_precision(TS_PREC_AUTO_SEC);
break;
case(WTAP_FILE_TSPREC_DSEC):
timestamp_set_precision(TS_PREC_AUTO_DSEC);
break;
case(WTAP_FILE_TSPREC_CSEC):
timestamp_set_precision(TS_PREC_AUTO_CSEC);
break;
case(WTAP_FILE_TSPREC_MSEC):
timestamp_set_precision(TS_PREC_AUTO_MSEC);
break;
case(WTAP_FILE_TSPREC_USEC):
timestamp_set_precision(TS_PREC_AUTO_USEC);
break;
case(WTAP_FILE_TSPREC_NSEC):
timestamp_set_precision(TS_PREC_AUTO_NSEC);
break;
default:
g_assert_not_reached();
}
#else
timestamp_set_precision(TS_PREC_AUTO_USEC);
#endif
/* Process the packets in the file */
if (!load_cap_file(&cfile)) {
epan_free(cfile.epan);

View File

@ -2082,31 +2082,6 @@ main(int argc, char *argv[])
return 2;
}
/* Set timestamp precision; there should arguably be a command-line
option to let the user set this. */
switch(wtap_file_tsprecision(cfile.wth)) {
case(WTAP_FILE_TSPREC_SEC):
timestamp_set_precision(TS_PREC_AUTO_SEC);
break;
case(WTAP_FILE_TSPREC_DSEC):
timestamp_set_precision(TS_PREC_AUTO_DSEC);
break;
case(WTAP_FILE_TSPREC_CSEC):
timestamp_set_precision(TS_PREC_AUTO_CSEC);
break;
case(WTAP_FILE_TSPREC_MSEC):
timestamp_set_precision(TS_PREC_AUTO_MSEC);
break;
case(WTAP_FILE_TSPREC_USEC):
timestamp_set_precision(TS_PREC_AUTO_USEC);
break;
case(WTAP_FILE_TSPREC_NSEC):
timestamp_set_precision(TS_PREC_AUTO_NSEC);
break;
default:
g_assert_not_reached();
}
/* Process the packets in the file */
TRY {
#ifdef HAVE_LIBPCAP
@ -2209,9 +2184,6 @@ main(int argc, char *argv[])
}
}
/* For now, assume libpcap gives microsecond precision. */
timestamp_set_precision(TS_PREC_AUTO_USEC);
/*
* XXX - this returns FALSE if an error occurred, but it also
* returns FALSE if the capture stops because a time limit

View File

@ -638,11 +638,7 @@ timestamp_precision_new_cb (GtkRadioAction *action, GtkRadioAction *current _U_,
value = gtk_radio_action_get_current_value (action);
if (recent.gui_time_precision != value) {
/* the actual precision will be set in packet_list_queue_draw() below */
if (value == TS_PREC_AUTO) {
timestamp_set_precision(TS_PREC_AUTO_SEC);
} else {
timestamp_set_precision(value);
}
timestamp_set_precision(value);
recent.gui_time_precision = value;
/* This call adjusts column width */
cf_timestamp_auto_precision(&cfile);
@ -1804,7 +1800,7 @@ static const GtkRadioActionEntry main_menu_bar_radio_view_time_entries [] =
static const GtkRadioActionEntry main_menu_bar_radio_view_time_fileformat_prec_entries [] =
{
/* name, stock id, label, accel, tooltip, value */
{ "/View/TimeDisplayFormat/FileFormatPrecision-Automatic", NULL, "Automatic (File Format Precision)", NULL, NULL, TS_PREC_AUTO },
{ "/View/TimeDisplayFormat/FileFormatPrecision-Automatic", NULL, "Automatic (use precision indicated in the file)", NULL, NULL, TS_PREC_AUTO },
{ "/View/TimeDisplayFormat/FileFormatPrecision-Seconds", NULL, "Seconds: 0", NULL, NULL, TS_PREC_FIXED_SEC },
{ "/View/TimeDisplayFormat/FileFormatPrecision-Deciseconds", NULL, "Deciseconds: 0.1", NULL, NULL, TS_PREC_FIXED_DSEC },
{ "/View/TimeDisplayFormat/FileFormatPrecision-Centiseconds", NULL, "Centiseconds: 0.12", NULL, NULL, TS_PREC_FIXED_CSEC },
@ -4773,8 +4769,8 @@ menu_recent_read_finished(void)
cf_timestamp_auto_precision(&cfile);
packet_list_queue_draw();
/* the actual precision will be set in packet_list_queue_draw() below */
if (recent.gui_time_precision == TS_PREC_AUTO) {
timestamp_set_precision(TS_PREC_AUTO_SEC);
if (recent.gui_time_precision > TS_PREC_FIXED_NSEC) {
timestamp_set_precision(TS_PREC_AUTO);
} else {
timestamp_set_precision(recent.gui_time_precision);
}

View File

@ -1133,7 +1133,7 @@ int main(int argc, char *argv[])
g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: timestamp types should be set elsewhere");
timestamp_set_type(TS_RELATIVE);
timestamp_set_precision(TS_PREC_AUTO_USEC);
timestamp_set_precision(TS_PREC_AUTO);
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
#ifdef HAVE_LIBPCAP

View File

@ -185,7 +185,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = _5views_seek_read;
wth->file_encap = encap;
wth->snapshot_length = 0; /* not available in header */
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
return 1;
}

View File

@ -173,7 +173,7 @@ int aethra_open(wtap *wth, int *err, gchar **err_info)
*/
wth->file_encap = WTAP_ENCAP_ISDN;
wth->snapshot_length = 0; /* not available in header */
wth->tsprecision = WTAP_FILE_TSPREC_MSEC;
wth->file_tsprec = WTAP_TSPREC_MSEC;
return 1;
}

View File

@ -217,7 +217,7 @@ int ascend_open(wtap *wth, int *err, gchar **err_info)
}
ascend->inittime = statbuf.st_ctime;
ascend->adjusted = FALSE;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
init_parse_ascend();

View File

@ -181,7 +181,7 @@ int ber_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_read = ber_read;
wth->subtype_seek_read = ber_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
wth->file_tsprec = WTAP_TSPREC_SEC;
return 1;
}

View File

@ -155,7 +155,7 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = btsnoop_seek_read;
wth->file_encap = file_encap;
wth->snapshot_length = 0; /* not available in header */
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_BTSNOOP;
return 1;
}
@ -420,7 +420,7 @@ gboolean btsnoop_dump_open_h1(wtap_dumper *wdh, int *err)
switch (wdh->file_type_subtype) {
case WTAP_FILE_TYPE_SUBTYPE_BTSNOOP:
wdh->tsprecision = WTAP_FILE_TSPREC_USEC;
wdh->tsprecision = WTAP_TSPREC_USEC;
break;
default:
@ -462,7 +462,7 @@ gboolean btsnoop_dump_open_h4(wtap_dumper *wdh, int *err)
switch (wdh->file_type_subtype) {
case WTAP_FILE_TYPE_SUBTYPE_BTSNOOP:
wdh->tsprecision = WTAP_FILE_TSPREC_USEC;
wdh->tsprecision = WTAP_TSPREC_USEC;
break;
default:

View File

@ -348,7 +348,7 @@ int camins_open(wtap *wth, int *err, gchar **err_info _U_)
wth->file_encap = WTAP_ENCAP_DVBCI;
wth->snapshot_length = 0;
wth->tsprecision = WTAP_FILE_TSPREC_MSEC;
wth->file_tsprec = WTAP_TSPREC_MSEC;
wth->priv = NULL;

View File

@ -261,7 +261,7 @@ catapult_dct2000_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_close = catapult_dct2000_close;
/* Choose microseconds (have 4 decimal places...) */
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
/***************************************************************/

View File

@ -123,7 +123,7 @@ int commview_open(wtap *wth, int *err, gchar **err_info)
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_COMMVIEW;
wth->file_encap = WTAP_ENCAP_PER_PACKET;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
return 1; /* Our kind of file */
}

View File

@ -280,7 +280,7 @@ int cosine_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not known */
wth->subtype_read = cosine_read;
wth->subtype_seek_read = cosine_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_CSEC;
wth->file_tsprec = WTAP_TSPREC_CSEC;
return 1;
}

View File

@ -138,7 +138,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not known */
wth->subtype_read = csids_read;
wth->subtype_seek_read = csids_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
wth->file_tsprec = WTAP_TSPREC_SEC;
return 1;
}

View File

@ -126,7 +126,7 @@ int daintree_sna_open(wtap *wth, int *err, gchar **err_info)
/* set up for file type */
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_DAINTREE_SNA;
wth->file_encap = WTAP_ENCAP_IEEE802_15_4_NOFCS;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
wth->snapshot_length = 0; /* not available in header */
return 1; /* it's a Daintree file */

View File

@ -190,7 +190,7 @@ int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not known */
wth->subtype_read = dbs_etherwatch_read;
wth->subtype_seek_read = dbs_etherwatch_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_CSEC;
wth->file_tsprec = WTAP_TSPREC_CSEC;
return 1;
}

View File

@ -181,7 +181,7 @@ int dct3trace_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not known */
wth->subtype_read = dct3trace_read;
wth->subtype_seek_read = dct3trace_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
wth->file_tsprec = WTAP_TSPREC_SEC;
return 1;
}

View File

@ -272,7 +272,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_read = erf_read;
wth->subtype_seek_read = erf_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
erf_populate_interfaces(wth);
@ -714,7 +714,7 @@ int erf_dump_open(wtap_dumper *wdh, int *err)
switch(wdh->file_type_subtype){
case WTAP_FILE_TYPE_SUBTYPE_ERF:
wdh->tsprecision = WTAP_FILE_TSPREC_NSEC;
wdh->tsprecision = WTAP_TSPREC_NSEC;
break;
default:
*err = WTAP_ERR_UNSUPPORTED_FILE_TYPE;

View File

@ -143,7 +143,7 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not known */
wth->subtype_read = eyesdn_read;
wth->subtype_seek_read = eyesdn_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
return 1;
}

View File

@ -824,7 +824,7 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
wth->file_encap = WTAP_ENCAP_UNKNOWN;
wth->subtype_sequential_close = NULL;
wth->subtype_close = NULL;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
wth->priv = NULL;
wth->wslua_data = NULL;

View File

@ -128,7 +128,7 @@ int hcidump_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_read = hcidump_read;
wth->subtype_seek_read = hcidump_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
return 1;
}

View File

@ -104,7 +104,7 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info)
i4btrace->byte_swapped = byte_swapped;
wth->file_encap = WTAP_ENCAP_ISDN;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
return 1;
}

View File

@ -278,7 +278,7 @@ ipfix_open(wtap *wth, int *err, gchar **err_info)
/* all's good, this is a IPFIX file */
wth->file_encap = WTAP_ENCAP_RAW_IPFIX;
wth->snapshot_length = 0;
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
wth->file_tsprec = WTAP_TSPREC_SEC;
wth->subtype_read = ipfix_read;
wth->subtype_seek_read = ipfix_seek_read;
wth->subtype_close = ipfix_close;

View File

@ -68,13 +68,13 @@ int iptrace_open(wtap *wth, int *err, gchar **err_info)
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_IPTRACE_1_0;
wth->subtype_read = iptrace_read_1_0;
wth->subtype_seek_read = iptrace_seek_read_1_0;
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
wth->file_tsprec = WTAP_TSPREC_SEC;
}
else if (strcmp(name, "iptrace 2.0") == 0) {
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_IPTRACE_2_0;
wth->subtype_read = iptrace_read_2_0;
wth->subtype_seek_read = iptrace_seek_read_2_0;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
}
else {
return 0;

View File

@ -248,7 +248,7 @@ iseries_open (wtap * wth, int *err, gchar ** err_info)
wth->snapshot_length = 0;
wth->subtype_read = iseries_read;
wth->subtype_seek_read = iseries_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
{
@ -288,7 +288,7 @@ iseries_open (wtap * wth, int *err, gchar ** err_info)
wth->snapshot_length = 0;
wth->subtype_read = iseries_read;
wth->subtype_seek_read = iseries_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
{

View File

@ -1001,7 +1001,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
wth->subtype_seek_read = k12_seek_read;
wth->subtype_close = k12_close;
wth->priv = (void *)file_data;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
return 1;
}

View File

@ -343,7 +343,7 @@ k12text_open(wtap *wth, int *err, gchar **err_info _U_)
wth->snapshot_length = 0;
wth->subtype_read = k12text_read;
wth->subtype_seek_read = k12text_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
return 1;
}

View File

@ -345,7 +345,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_read = lanalyzer_read;
wth->subtype_seek_read = lanalyzer_seek_read;
wth->snapshot_length = 0;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
/* Read records until we find the start of packets */
while (1) {

View File

@ -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;

View File

@ -277,7 +277,7 @@ int logcat_open(wtap *wth, int *err, gchar **err_info _U_)
wth->subtype_read = logcat_read;
wth->subtype_seek_read = logcat_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
return 1;
}
@ -332,7 +332,7 @@ gboolean logcat_binary_dump_open(wtap_dumper *wdh, int *err)
switch (wdh->encap) {
case WTAP_ENCAP_LOGCAT:
case WTAP_ENCAP_WIRESHARK_UPPER_PDU:
wdh->tsprecision = WTAP_FILE_TSPREC_USEC;
wdh->tsprecision = WTAP_TSPREC_USEC;
break;
default:

View File

@ -310,7 +310,7 @@ int logcat_text_open(wtap *wth, int *err, gchar **err_info _U_) {
wth->subtype_read = logcat_text_read;
wth->subtype_seek_read = logcat_text_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
return 1;
}

View File

@ -204,7 +204,7 @@ mime_file_open(wtap *wth, int *err, gchar **err_info)
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MIME;
wth->file_encap = WTAP_ENCAP_MIME;
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
wth->file_tsprec = WTAP_TSPREC_SEC;
wth->subtype_read = mime_read;
wth->subtype_seek_read = mime_seek_read;
wth->snapshot_length = 0;

View File

@ -231,7 +231,7 @@ mp2t_open(wtap *wth, int *err, gchar **err_info)
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MPEG_2_TS;
wth->file_encap = WTAP_ENCAP_MPEG_2_TS;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
wth->subtype_read = mp2t_read;
wth->subtype_seek_read = mp2t_seek_read;
wth->snapshot_length = 0;

View File

@ -290,7 +290,7 @@ good_magic:
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MPEG;
wth->file_encap = WTAP_ENCAP_MPEG;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
wth->subtype_read = mpeg_read;
wth->subtype_seek_read = mpeg_seek_read;
wth->snapshot_length = 0;

View File

@ -395,7 +395,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
* Version 1.x of the file format supports
* millisecond precision.
*/
wth->tsprecision = WTAP_FILE_TSPREC_MSEC;
wth->file_tsprec = WTAP_TSPREC_MSEC;
break;
case 2:
@ -405,7 +405,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
* currently support that, so say
* "nanosecond precision" for now.
*/
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
break;
}
return 1;

View File

@ -781,7 +781,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
nstrace->nstrace_buf_offset = 0;
}
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
wth->phdr.ts.secs = nstrace->nspm_curtime;
wth->phdr.ts.nsecs = 0;

View File

@ -184,7 +184,7 @@ int netscreen_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not known */
wth->subtype_read = netscreen_read;
wth->subtype_seek_read = netscreen_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_DSEC;
wth->file_tsprec = WTAP_TSPREC_DSEC;
return 1;
}

View File

@ -282,7 +282,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info)
if (file_seek(wth->fh, FILE_HDR_SIZE, SEEK_SET, err) == -1) {
return -1;
}
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
return 1;
}

View File

@ -245,7 +245,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_close = NULL;
wth->subtype_sequential_close = NULL;
wth->snapshot_length = 0; /* not available in header */
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NETWORK_INSTRUMENTS;
/* reset the pointer to the first packet */

View File

@ -576,12 +576,12 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
case WTAP_FILE_TYPE_SUBTYPE_NETXRAY_OLD:
ticks_per_sec = 1000.0;
wth->tsprecision = WTAP_FILE_TSPREC_MSEC;
wth->file_tsprec = WTAP_TSPREC_MSEC;
break;
case WTAP_FILE_TYPE_SUBTYPE_NETXRAY_1_0:
ticks_per_sec = 1000.0;
wth->tsprecision = WTAP_FILE_TSPREC_MSEC;
wth->file_tsprec = WTAP_TSPREC_MSEC;
break;
case WTAP_FILE_TYPE_SUBTYPE_NETXRAY_1_1:
@ -592,7 +592,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
* and older versions of Windows Sniffer.
*/
ticks_per_sec = 1000000.0;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
break;
case WTAP_FILE_TYPE_SUBTYPE_NETXRAY_2_00x:
@ -749,9 +749,9 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
* XXX - Seems reasonable to use nanosecs only if TPS >= 10M
*/
if (ticks_per_sec >= 1e7)
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
else
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
break;
default:

View File

@ -789,7 +789,7 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
* isn't stored in the capture file.
*/
wth->tsprecision = WTAP_FILE_TSPREC_NSEC; /* XXX */
wth->file_tsprec = WTAP_TSPREC_NSEC; /* XXX */
return 1;
}

View File

@ -88,7 +88,7 @@ int packetlogger_open(wtap *wth, int *err, gchar **err_info)
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PACKETLOGGER;
wth->file_encap = WTAP_ENCAP_PACKETLOGGER;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
return 1; /* Our kind of file */
}

View File

@ -353,7 +353,6 @@ typedef struct wtapng_block_s {
*/
struct wtap_pkthdr *packet_header;
Buffer *frame_buffer;
int *file_encap;
} wtapng_block_t;
/* Interface data in private struct */
@ -361,6 +360,7 @@ typedef struct interface_info_s {
int wtap_encap;
guint32 snap_len;
guint64 time_units_per_second;
int tsprecision;
} interface_info_t;
typedef struct {
@ -711,10 +711,12 @@ pcapng_read_section_header_block(FILE_T fh, gboolean first_block,
/* "Interface Description Block" */
static int
pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
wtapng_block_t *wblock, int *err, gchar **err_info)
pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh,
pcapng_t *pn, wtapng_block_t *wblock, int *err,
gchar **err_info)
{
guint64 time_units_per_second = 1000000; /* default */
guint64 time_units_per_second = 1000000; /* default = 10^6 */
int tsprecision = WTAP_TSPREC_USEC;
int bytes_read;
guint block_read;
guint to_read, opt_cont_buf_len;
@ -773,6 +775,7 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
wblock->data.if_descr.wtap_encap = wtap_pcap_encap_to_wtap_encap(wblock->data.if_descr.link_type);
wblock->data.if_descr.time_units_per_second = time_units_per_second;
wblock->data.if_descr.tsprecision = tsprecision;
pcapng_debug3("pcapng_read_if_descr_block: IDB link_type %u (%s), snap %u",
wblock->data.if_descr.link_type,
@ -908,7 +911,20 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
}
wblock->data.if_descr.time_units_per_second = time_units_per_second;
wblock->data.if_descr.if_tsresol = if_tsresol;
pcapng_debug2("pcapng_read_if_descr_block: if_tsresol %u, units/s %" G_GINT64_MODIFIER "u", wblock->data.if_descr.if_tsresol, wblock->data.if_descr.time_units_per_second);
if (time_units_per_second >= 1000000000)
tsprecision = WTAP_TSPREC_NSEC;
else if (time_units_per_second >= 1000000)
tsprecision = WTAP_TSPREC_USEC;
else if (time_units_per_second >= 1000)
tsprecision = WTAP_TSPREC_MSEC;
else if (time_units_per_second >= 100)
tsprecision = WTAP_TSPREC_CSEC;
else if (time_units_per_second >= 10)
tsprecision = WTAP_TSPREC_DSEC;
else
tsprecision = WTAP_TSPREC_SEC;
wblock->data.if_descr.tsprecision = tsprecision;
pcapng_debug3("pcapng_read_if_descr_block: if_tsresol %u, units/s %" G_GINT64_MODIFIER "u, tsprecision %d", wblock->data.if_descr.if_tsresol, wblock->data.if_descr.time_units_per_second, tsprecision);
} else {
pcapng_debug1("pcapng_read_if_descr_block: if_tsresol length %u not 1 as expected", oh.option_length);
}
@ -970,11 +986,32 @@ pcapng_read_if_descr_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn,
g_free(option_content);
if (*wblock->file_encap == WTAP_ENCAP_UNKNOWN) {
*wblock->file_encap = wblock->data.if_descr.wtap_encap;
/*
* If the per-file encapsulation isn't known, set it to this
* interface's encapsulation.
*
* If it *is* known, and it isn't this interface's encapsulation,
* set it to WTAP_ENCAP_PER_PACKET, as this file doesn't
* have a single encapsulation for all interfaces in the file,
* so it probably doesn't have a single encapsulation for all
* packets in the file.
*/
if (wth->file_encap == WTAP_ENCAP_UNKNOWN) {
wth->file_encap = wblock->data.if_descr.wtap_encap;
} else {
if (*wblock->file_encap != wblock->data.if_descr.wtap_encap) {
*wblock->file_encap = WTAP_ENCAP_PER_PACKET;
if (wth->file_encap != wblock->data.if_descr.wtap_encap) {
wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
}
/*
* The same applies to the per-file time stamp resolution.
*/
if (wth->file_tsprec == WTAP_TSPREC_UNKNOWN) {
wth->file_tsprec = wblock->data.if_descr.tsprecision;
} else {
if (wth->file_tsprec != wblock->data.if_descr.tsprecision) {
wth->file_tsprec = WTAP_TSPREC_PER_PACKET;
}
}
@ -1172,6 +1209,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
pcap_get_phdr_size(iface_info.wtap_encap, &wblock->packet_header->pseudo_header));
wblock->packet_header->interface_id = packet.interface_id;
wblock->packet_header->pkt_encap = iface_info.wtap_encap;
wblock->packet_header->pkt_tsprec = iface_info.tsprecision;
memset((void *)&wblock->packet_header->pseudo_header, 0, sizeof(union wtap_pseudo_header));
pseudo_header_len = pcap_process_pseudo_header(fh,
@ -1444,6 +1482,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
wblock->packet_header->presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID;
wblock->packet_header->interface_id = 0;
wblock->packet_header->pkt_encap = iface_info.wtap_encap;
wblock->packet_header->pkt_tsprec = iface_info.tsprecision;
wblock->packet_header->ts.secs = 0;
wblock->packet_header->ts.nsecs = 0;
wblock->packet_header->interface_id = 0;
@ -2056,7 +2095,7 @@ pcapng_read_unknown_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn _U_
static int
pcapng_read_block(FILE_T fh, gboolean first_block, pcapng_t *pn, wtapng_block_t *wblock, int *err, gchar **err_info)
pcapng_read_block(wtap *wth, FILE_T fh, gboolean first_block, pcapng_t *pn, wtapng_block_t *wblock, int *err, gchar **err_info)
{
int block_read;
int bytes_read;
@ -2112,7 +2151,7 @@ pcapng_read_block(FILE_T fh, gboolean first_block, pcapng_t *pn, wtapng_block_t
bytes_read = pcapng_read_section_header_block(fh, first_block, &bh, pn, wblock, err, err_info);
break;
case(BLOCK_TYPE_IDB):
bytes_read = pcapng_read_if_descr_block(fh, &bh, pn, wblock, err, err_info);
bytes_read = pcapng_read_if_descr_block(wth, fh, &bh, pn, wblock, err, err_info);
break;
case(BLOCK_TYPE_PB):
bytes_read = pcapng_read_packet_block(fh, &bh, pn, wblock, err, err_info, FALSE);
@ -2202,6 +2241,7 @@ pcapng_process_idb(wtap *wth, pcapng_t *pcapng, wtapng_block_t *wblock)
iface_info.wtap_encap = wblock->data.if_descr.wtap_encap;
iface_info.snap_len = wblock->data.if_descr.snap_len;
iface_info.time_units_per_second = wblock->data.if_descr.time_units_per_second;
iface_info.tsprecision = wblock->data.if_descr.tsprecision;
g_array_append_val(pcapng->interfaces, iface_info);
}
@ -2229,11 +2269,10 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
/* we don't expect any packet blocks yet */
wblock.frame_buffer = NULL;
wblock.packet_header = NULL;
wblock.file_encap = &wth->file_encap;
pcapng_debug0("pcapng_open: opening file");
/* read first block */
bytes_read = pcapng_read_block(wth->fh, TRUE, &pn, &wblock, err, err_info);
bytes_read = pcapng_read_block(wth, wth->fh, TRUE, &pn, &wblock, err, err_info);
if (bytes_read <= 0) {
pcapng_free_wtapng_block_data(&wblock);
if (bytes_read == -2) {
@ -2272,7 +2311,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = WTAP_ENCAP_UNKNOWN;
wth->snapshot_length = 0;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_UNKNOWN;
pcapng = (pcapng_t *)g_malloc(sizeof(pcapng_t));
wth->priv = (void *)pcapng;
*pcapng = pn;
@ -2313,7 +2352,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
if (bh.block_type != BLOCK_TYPE_IDB) {
break; /* No more IDB:s */
}
bytes_read = pcapng_read_block(wth->fh, FALSE, &pn, &wblock, err, err_info);
bytes_read = pcapng_read_block(wth, wth->fh, FALSE, &pn, &wblock, err, err_info);
if (bytes_read == 0) {
pcapng_debug0("No more IDBs available...");
pcapng_free_wtapng_block_data(&wblock);
@ -2349,14 +2388,13 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
wblock.frame_buffer = wth->frame_buffer;
wblock.packet_header = &wth->phdr;
wblock.file_encap = &wth->file_encap;
pcapng->add_new_ipv4 = wth->add_new_ipv4;
pcapng->add_new_ipv6 = wth->add_new_ipv6;
/* read next block */
while (1) {
bytes_read = pcapng_read_block(wth->fh, FALSE, pcapng, &wblock, err, err_info);
bytes_read = pcapng_read_block(wth, wth->fh, FALSE, pcapng, &wblock, err, err_info);
if (bytes_read <= 0) {
pcapng_debug1("pcapng_read: data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset);
pcapng_debug0("pcapng_read: couldn't read packet block");
@ -2368,6 +2406,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
case(BLOCK_TYPE_SHB):
/* We don't currently support multi-section files. */
wth->phdr.pkt_encap = WTAP_ENCAP_UNKNOWN;
wth->phdr.pkt_tsprec = WTAP_TSPREC_UNKNOWN;
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("pcapng: multi-section files not currently supported");
return FALSE;
@ -2462,10 +2501,9 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
wblock.frame_buffer = buf;
wblock.packet_header = phdr;
wblock.file_encap = &wth->file_encap;
/* read the block */
bytes_read = pcapng_read_block(wth->random_fh, FALSE, pcapng, &wblock, err, err_info);
bytes_read = pcapng_read_block(wth, wth->random_fh, FALSE, pcapng, &wblock, err, err_info);
pcapng_free_wtapng_block_data(&wblock);
if (bytes_read <= 0) {
pcapng_debug3("pcapng_seek_read: couldn't read packet block (err=%d, errno=%d, bytes_read=%d).",

View File

@ -353,7 +353,7 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
}
wth->snapshot_length = 0; /* not available in header */
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
return 1;
}

View File

@ -345,7 +345,7 @@ int peektagged_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = file_encap;
wth->subtype_read = peektagged_read;
wth->subtype_seek_read = peektagged_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->file_tsprec = WTAP_TSPREC_NSEC;
peektagged = (peektagged_t *)g_malloc(sizeof(peektagged_t));
wth->priv = (void *)peektagged;

View File

@ -298,7 +298,7 @@ pppdump_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_read = pppdump_read;
wth->subtype_seek_read = pppdump_seek_read;
wth->subtype_close = pppdump_close;
wth->tsprecision = WTAP_FILE_TSPREC_DSEC;
wth->file_tsprec = WTAP_TSPREC_DSEC;
state->seek_state = g_new(pppdump_t,1);

View File

@ -164,7 +164,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_read = radcom_read;
wth->subtype_seek_read = radcom_seek_read;
wth->snapshot_length = 0; /* not available in header, only in frame */
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
#if 0
tm.tm_year = pletoh16(&start_date.year)-1900;

View File

@ -427,7 +427,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = snoop_seek_read;
wth->file_encap = file_encap;
wth->snapshot_length = 0; /* not available in header */
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
return 1;
}

View File

@ -197,7 +197,7 @@ int stanag4607_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_read = stanag4607_read;
wth->subtype_seek_read = stanag4607_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_MSEC;
wth->file_tsprec = WTAP_TSPREC_MSEC;
return 1;
}

View File

@ -121,7 +121,7 @@ int tnef_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_read = tnef_read;
wth->subtype_seek_read = tnef_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
wth->file_tsprec = WTAP_TSPREC_SEC;
return 1;
}

View File

@ -208,7 +208,7 @@ int toshiba_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not known */
wth->subtype_read = toshiba_read;
wth->subtype_seek_read = toshiba_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_CSEC;
wth->file_tsprec = WTAP_TSPREC_CSEC;
return 1;
}

View File

@ -264,7 +264,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
/* Set up the pointers to the handlers for this file type */
wth->subtype_read = visual_read;
wth->subtype_seek_read = visual_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
/* Add Visual-specific information to the wiretap struct for later use. */
visual = (struct visual_read_info *)g_malloc(sizeof(struct visual_read_info));

View File

@ -249,7 +249,7 @@ int vms_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not known */
wth->subtype_read = vms_read;
wth->subtype_seek_read = vms_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_CSEC;
wth->file_tsprec = WTAP_TSPREC_CSEC;
return 1;
}

View File

@ -551,7 +551,7 @@ int vwr_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0;
wth->subtype_read = vwr_read;
wth->subtype_seek_read = vwr_seek_read;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
wth->file_tsprec = WTAP_TSPREC_USEC;
wth->file_encap = WTAP_ENCAP_IXVERIWAVE;
if (fpgaVer == S2_W_FPGA || fpgaVer == S1_W_FPGA || fpgaVer == S3_W_FPGA)

View File

@ -68,10 +68,18 @@ struct wtap {
int file_encap; /* per-file, for those
* file formats that have
* per-file encapsulation
* types
* types rather than per-packet
* encapsulation types
*/
int tsprecision; /* timestamp precision of the lower 32bits
* e.g. WTAP_FILE_TSPREC_USEC
int file_tsprec; /* per-file timestamp precision
* of the fractional part of
* the time stamp, for those
* file formats that have
* per-file timestamp
* precision rather than
* per-packet timestamp
* precision
* e.g. WTAP_TSPREC_USEC
*/
wtap_new_ipv4_callback_t add_new_ipv4;
wtap_new_ipv6_callback_t add_new_ipv6;
@ -105,7 +113,7 @@ struct wtap_dumper {
subtype_close_func subtype_close;
int tsprecision; /**< timestamp precision of the lower 32bits
* e.g. WTAP_FILE_TSPREC_USEC
* e.g. WTAP_TSPREC_USEC
*/
addrinfo_lists_t *addrinfo_lists; /**< Struct containing lists of resolved addresses */
struct wtapng_section_s *shb_hdr;

View File

@ -162,9 +162,9 @@ wtap_file_encap(wtap *wth)
}
int
wtap_file_tsprecision(wtap *wth)
wtap_file_tsprec(wtap *wth)
{
return wth->tsprecision;
return wth->file_tsprec;
}
wtapng_section_t *
@ -996,8 +996,11 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
* capture file type doesn't have to set it), and if it
* *is* WTAP_ENCAP_PER_PACKET, the caller needs to set it
* anyway.
*
* Do the same for the packet time stamp resolution.
*/
wth->phdr.pkt_encap = wth->file_encap;
wth->phdr.pkt_tsprec = wth->file_tsprec;
if (!wth->subtype_read(wth, err, err_info, data_offset)) {
/*

View File

@ -353,12 +353,14 @@ extern "C" {
#define WTAP_NUM_FILE_TYPES_SUBTYPES wtap_get_num_file_types_subtypes()
/* timestamp precision (currently only these values are supported) */
#define WTAP_FILE_TSPREC_SEC 0
#define WTAP_FILE_TSPREC_DSEC 1
#define WTAP_FILE_TSPREC_CSEC 2
#define WTAP_FILE_TSPREC_MSEC 3
#define WTAP_FILE_TSPREC_USEC 6
#define WTAP_FILE_TSPREC_NSEC 9
#define WTAP_TSPREC_UNKNOWN -2
#define WTAP_TSPREC_PER_PACKET -1 /* as a per-file value, means per-packet */
#define WTAP_TSPREC_SEC 0
#define WTAP_TSPREC_DSEC 1
#define WTAP_TSPREC_CSEC 2
#define WTAP_TSPREC_MSEC 3
#define WTAP_TSPREC_USEC 6
#define WTAP_TSPREC_NSEC 9
/*
* Maximum packet size we'll support.
@ -969,7 +971,8 @@ struct wtap_pkthdr {
nstime_t ts;
guint32 caplen; /* data length in the file */
guint32 len; /* data length on the wire */
int pkt_encap;
int pkt_encap; /* WTAP_ENCAP_ value for this packet */
int pkt_tsprec; /* WTAP_TSPREC_ value for this packet */
/* pcapng variables */
guint32 interface_id; /* identifier of the interface. */
/* options */
@ -1112,6 +1115,7 @@ typedef struct wtapng_iface_descriptions_s {
typedef struct wtapng_if_descr_s {
int wtap_encap; /**< link_type translated to wtap_encap */
guint64 time_units_per_second;
int tsprecision; /**< WTAP_TSPREC_ value for this interface */
/* mandatory */
guint16 link_type;
@ -1431,7 +1435,7 @@ int wtap_file_type_subtype(wtap *wth);
WS_DLL_PUBLIC
int wtap_file_encap(wtap *wth);
WS_DLL_PUBLIC
int wtap_file_tsprecision(wtap *wth);
int wtap_file_tsprec(wtap *wth);
WS_DLL_PUBLIC
wtapng_section_t* wtap_file_get_shb_info(wtap *wth);
WS_DLL_PUBLIC