diff --git a/epan/column-utils.c b/epan/column-utils.c index f27e4702c4..8721dbfb19 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -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; diff --git a/epan/column.c b/epan/column.c index 4d23d9e5bc..8544f84b21 100644 --- a/epan/column.c +++ b/epan/column.c @@ -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: diff --git a/epan/frame_data.c b/epan/frame_data.c index bf403684f1..bfce771779 100644 --- a/epan/frame_data.c +++ b/epan/frame_data.c @@ -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; diff --git a/epan/frame_data.h b/epan/frame_data.h index 58256357f4..996f4e1321 100644 --- a/epan/frame_data.h +++ b/epan/frame_data.h @@ -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 */ diff --git a/epan/timestamp.c b/epan/timestamp.c index bf0feabb0a..1feda0d8e1 100644 --- a/epan/timestamp.c +++ b/epan/timestamp.c @@ -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; diff --git a/epan/timestamp.h b/epan/timestamp.h index bbda35e64c..25a048ab90 100644 --- a/epan/timestamp.h +++ b/epan/timestamp.h @@ -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 { diff --git a/epan/wslua/wslua_file.c b/epan/wslua/wslua_file.c index f83eb29d20..81347aaae0 100644 --- a/epan/wslua/wslua_file.c +++ b/epan/wslua/wslua_file.c @@ -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); } diff --git a/file.c b/file.c index f343028240..e948a48a83 100644 --- a/file.c +++ b/file.c @@ -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++) { diff --git a/rawshark.c b/rawshark.c index 50589f8b0e..a1eb7fa027 100644 --- a/rawshark.c +++ b/rawshark.c @@ -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); diff --git a/tshark.c b/tshark.c index 88ccb9489f..48679fd229 100644 --- a/tshark.c +++ b/tshark.c @@ -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 diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index fa6cab1bc4..986bf600ac 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -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); } diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index efbadac64f..dce301c8f2 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -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 diff --git a/wiretap/5views.c b/wiretap/5views.c index 4db2d69d59..8576c726d8 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -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; } diff --git a/wiretap/aethra.c b/wiretap/aethra.c index 2a91970fad..6eb37202b9 100644 --- a/wiretap/aethra.c +++ b/wiretap/aethra.c @@ -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; } diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c index 1e6f4fbbf8..008afd678f 100644 --- a/wiretap/ascendtext.c +++ b/wiretap/ascendtext.c @@ -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(); diff --git a/wiretap/ber.c b/wiretap/ber.c index 4d015097ba..cb1829bda3 100644 --- a/wiretap/ber.c +++ b/wiretap/ber.c @@ -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; } diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c index 6d3e75a2c6..fa0075b847 100644 --- a/wiretap/btsnoop.c +++ b/wiretap/btsnoop.c @@ -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: diff --git a/wiretap/camins.c b/wiretap/camins.c index faa516aeaa..d5aafe9fcc 100644 --- a/wiretap/camins.c +++ b/wiretap/camins.c @@ -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; diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c index a0555ddd1f..2b5ef4e51c 100644 --- a/wiretap/catapult_dct2000.c +++ b/wiretap/catapult_dct2000.c @@ -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; /***************************************************************/ diff --git a/wiretap/commview.c b/wiretap/commview.c index 5a5f881a77..e0c24326d1 100644 --- a/wiretap/commview.c +++ b/wiretap/commview.c @@ -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 */ } diff --git a/wiretap/cosine.c b/wiretap/cosine.c index fbf1c13842..d007c90820 100644 --- a/wiretap/cosine.c +++ b/wiretap/cosine.c @@ -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; } diff --git a/wiretap/csids.c b/wiretap/csids.c index 99dff7f2bb..e99e47b788 100644 --- a/wiretap/csids.c +++ b/wiretap/csids.c @@ -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; } diff --git a/wiretap/daintree-sna.c b/wiretap/daintree-sna.c index 0b5ab67f85..672393dc95 100644 --- a/wiretap/daintree-sna.c +++ b/wiretap/daintree-sna.c @@ -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 */ diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c index fd6ca4a088..9e76a5da36 100644 --- a/wiretap/dbs-etherwatch.c +++ b/wiretap/dbs-etherwatch.c @@ -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; } diff --git a/wiretap/dct3trace.c b/wiretap/dct3trace.c index 5baaa69971..7ce51242ac 100644 --- a/wiretap/dct3trace.c +++ b/wiretap/dct3trace.c @@ -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; } diff --git a/wiretap/erf.c b/wiretap/erf.c index 0d47ee0f56..ede93d5a5b 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -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; diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c index ccf165c1fc..724400a1c8 100644 --- a/wiretap/eyesdn.c +++ b/wiretap/eyesdn.c @@ -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; } diff --git a/wiretap/file_access.c b/wiretap/file_access.c index e7db8941c1..33640df1d1 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -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; diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c index f2353be970..1a508968d9 100644 --- a/wiretap/hcidump.c +++ b/wiretap/hcidump.c @@ -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; } diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c index f4fea01fb0..d7fe2c7067 100644 --- a/wiretap/i4btrace.c +++ b/wiretap/i4btrace.c @@ -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; } diff --git a/wiretap/ipfix.c b/wiretap/ipfix.c index 70b700d092..00466bea86 100644 --- a/wiretap/ipfix.c +++ b/wiretap/ipfix.c @@ -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; diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c index 3bd06f24ce..71ea09a0ee 100644 --- a/wiretap/iptrace.c +++ b/wiretap/iptrace.c @@ -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; diff --git a/wiretap/iseries.c b/wiretap/iseries.c index ba1dd628ec..09c4f6c30e 100644 --- a/wiretap/iseries.c +++ b/wiretap/iseries.c @@ -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) { diff --git a/wiretap/k12.c b/wiretap/k12.c index 068c968c76..79d62eac72 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -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; } diff --git a/wiretap/k12text.l b/wiretap/k12text.l index 13f8d42439..b281dfe15f 100644 --- a/wiretap/k12text.l +++ b/wiretap/k12text.l @@ -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; } diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index 9fea6b34ea..5db1d2030c 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -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) { 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; diff --git a/wiretap/logcat.c b/wiretap/logcat.c index f50b118fe3..d8c603cfdd 100644 --- a/wiretap/logcat.c +++ b/wiretap/logcat.c @@ -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: diff --git a/wiretap/logcat_text.c b/wiretap/logcat_text.c index 89ca100d76..546fd1c5a5 100644 --- a/wiretap/logcat_text.c +++ b/wiretap/logcat_text.c @@ -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; } diff --git a/wiretap/mime_file.c b/wiretap/mime_file.c index e89f16dea6..7b67dbe830 100644 --- a/wiretap/mime_file.c +++ b/wiretap/mime_file.c @@ -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; diff --git a/wiretap/mp2t.c b/wiretap/mp2t.c index 3b3dc81a9e..faf6b93598 100644 --- a/wiretap/mp2t.c +++ b/wiretap/mp2t.c @@ -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; diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c index 92cdc80b20..05ac414260 100644 --- a/wiretap/mpeg.c +++ b/wiretap/mpeg.c @@ -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; diff --git a/wiretap/netmon.c b/wiretap/netmon.c index bb974a931a..f2e7e5a5c5 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -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; diff --git a/wiretap/netscaler.c b/wiretap/netscaler.c index 00cfd1f5cd..f6e4346e76 100644 --- a/wiretap/netscaler.c +++ b/wiretap/netscaler.c @@ -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; diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c index c1fb1ece96..61b32834ee 100644 --- a/wiretap/netscreen.c +++ b/wiretap/netscreen.c @@ -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; } diff --git a/wiretap/nettl.c b/wiretap/nettl.c index 9fa6462fb7..14863848b3 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -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; } diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index 6b941aaff7..d803c76e77 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -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 */ diff --git a/wiretap/netxray.c b/wiretap/netxray.c index d8704d9fa0..5bb9732bde 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -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: diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index 085e403ee3..e9d7595488 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -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; } diff --git a/wiretap/packetlogger.c b/wiretap/packetlogger.c index 51954f87ee..065ad4aaed 100644 --- a/wiretap/packetlogger.c +++ b/wiretap/packetlogger.c @@ -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 */ } diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index db8fe49118..39738805cc 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -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).", diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c index 2167cbd645..48454addf6 100644 --- a/wiretap/peekclassic.c +++ b/wiretap/peekclassic.c @@ -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; } diff --git a/wiretap/peektagged.c b/wiretap/peektagged.c index 3084ebf353..c7a695e14b 100644 --- a/wiretap/peektagged.c +++ b/wiretap/peektagged.c @@ -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; diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 173a97adef..0ca9201ff5 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -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); diff --git a/wiretap/radcom.c b/wiretap/radcom.c index 024b62c598..9b0072c1ff 100644 --- a/wiretap/radcom.c +++ b/wiretap/radcom.c @@ -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; diff --git a/wiretap/snoop.c b/wiretap/snoop.c index b023c327bf..0318a07257 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -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; } diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c index c3703cc7ff..bdf458fe35 100644 --- a/wiretap/stanag4607.c +++ b/wiretap/stanag4607.c @@ -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; } diff --git a/wiretap/tnef.c b/wiretap/tnef.c index aada2b9c0f..2e8b565485 100644 --- a/wiretap/tnef.c +++ b/wiretap/tnef.c @@ -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; } diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index 1cbff935dc..a6e36057c0 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -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; } diff --git a/wiretap/visual.c b/wiretap/visual.c index 23c76e59ca..aab7e4a9c4 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -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)); diff --git a/wiretap/vms.c b/wiretap/vms.c index e05ca8fffd..61a3fc1d32 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -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; } diff --git a/wiretap/vwr.c b/wiretap/vwr.c index 7593f72672..64ab7d32c9 100644 --- a/wiretap/vwr.c +++ b/wiretap/vwr.c @@ -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) diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index dfa3441835..fa95119dfe 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -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; diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 0ac1c655d4..a4fb756059 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -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)) { /* diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 0a97189abd..e58134a2f0 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -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