diff options
-rw-r--r-- | epan/dissectors/packet-gsmtap_log.c | 2 | ||||
-rw-r--r-- | epan/proto.c | 61 | ||||
-rw-r--r-- | epan/proto.h | 38 |
3 files changed, 74 insertions, 27 deletions
diff --git a/epan/dissectors/packet-gsmtap_log.c b/epan/dissectors/packet-gsmtap_log.c index 3f851cac32..6b0b6e2250 100644 --- a/epan/dissectors/packet-gsmtap_log.c +++ b/epan/dissectors/packet-gsmtap_log.c @@ -68,7 +68,7 @@ dissect_gsmtap_log(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * d ti = proto_tree_add_item(tree, proto_gsmtap_log, tvb, 0, -1, ENC_NA); log_tree = proto_item_add_subtree(ti, ett_gsmtap_log); - proto_tree_add_item(log_tree, hf_log_ts, tvb, offset, 8, ENC_TIME_NTP_BASE_ZERO|ENC_BIG_ENDIAN); + proto_tree_add_item(log_tree, hf_log_ts, tvb, offset, 8, ENC_TIME_TIMEVAL|ENC_BIG_ENDIAN); offset += 8; proto_tree_add_item_ret_string(log_tree, hf_log_ident, tvb, offset, 16, ENC_NA, wmem_packet_scope(), &log_ident); offset += 16; diff --git a/epan/proto.c b/epan/proto.c index 5c420416c9..c19ab27bd8 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1726,27 +1726,6 @@ get_time_value(tvbuff_t *tvb, const gint start, const gint length, const guint e time_stamp->nsecs = 0; break; - case ENC_TIME_TOD|ENC_BIG_ENDIAN: - /* - * TOD time stamp, big-endian. - */ -/* XXX - where should this go? */ -#define TOD_BASETIME G_GUINT64_CONSTANT(2208988800) - - todsecs = tvb_get_ntoh64(tvb, start) >> 12; - time_stamp->secs = (time_t)((todsecs / 1000000) - TOD_BASETIME); - time_stamp->nsecs = (int)((todsecs % 1000000) * 1000); - break; - - case ENC_TIME_TOD|ENC_LITTLE_ENDIAN: - /* - * TOD time stamp, big-endian. - */ - todsecs = tvb_get_letoh64(tvb, start) >> 12 ; - time_stamp->secs = (time_t)((todsecs / 1000000) - TOD_BASETIME); - time_stamp->nsecs = (int)((todsecs % 1000000) * 1000); - break; - case ENC_TIME_NTP|ENC_BIG_ENDIAN: /* * NTP time stamp, big-endian. @@ -1802,6 +1781,28 @@ get_time_value(tvbuff_t *tvb, const gint start, const gint length, const guint e time_stamp->nsecs = 0; } break; + + case ENC_TIME_TOD|ENC_BIG_ENDIAN: + /* + * TOD time stamp, big-endian. + */ +/* XXX - where should this go? */ +#define TOD_BASETIME G_GUINT64_CONSTANT(2208988800) + + todsecs = tvb_get_ntoh64(tvb, start) >> 12; + time_stamp->secs = (time_t)((todsecs / 1000000) - TOD_BASETIME); + time_stamp->nsecs = (int)((todsecs % 1000000) * 1000); + break; + + case ENC_TIME_TOD|ENC_LITTLE_ENDIAN: + /* + * TOD time stamp, big-endian. + */ + todsecs = tvb_get_letoh64(tvb, start) >> 12 ; + time_stamp->secs = (time_t)((todsecs / 1000000) - TOD_BASETIME); + time_stamp->nsecs = (int)((todsecs % 1000000) * 1000); + break; + case ENC_TIME_NTP_BASE_ZERO|ENC_BIG_ENDIAN: /* * DDS NTP time stamp, big-endian. @@ -1845,6 +1846,24 @@ get_time_value(tvbuff_t *tvb, const gint start, const gint length, const guint e } break; + case ENC_TIME_TIMEVAL|ENC_BIG_ENDIAN: + /* + * 4-byte UNIX epoch, followed by 4-byte fractional + * time in microseconds, both big-endian. + */ + time_stamp->secs = (time_t)tvb_get_ntohl(tvb, start); + time_stamp->nsecs = tvb_get_ntohl(tvb, start+4)*1000; + break; + + case ENC_TIME_TIMEVAL|ENC_LITTLE_ENDIAN: + /* + * 4-byte UNIX epoch, followed by 4-byte fractional + * time in microseconds, both little-endian. + */ + time_stamp->secs = (time_t)tvb_get_letohl(tvb, start); + time_stamp->nsecs = tvb_get_letohl(tvb, start+4)*1000; + break; + default: DISSECTOR_ASSERT_NOT_REACHED(); break; diff --git a/epan/proto.h b/epan/proto.h index 6c41fc8663..155f99f51e 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -362,18 +362,46 @@ WS_DLL_PUBLIC WS_NORETURN void proto_report_dissector_bug(const char *message); #define ENC_HOST_ENDIAN ENC_BIG_ENDIAN #endif - /* * Historically FT_TIMEs were only timespecs; the only question was whether * they were stored in big- or little-endian format. * * For backwards compatibility, we interpret an encoding of 1 as meaning * "little-endian timespec", so that passing TRUE is interpreted as that. + * + * We now support: + * + * ENC_TIME_TIMESPEC - 4 or 8 bytes; the first 4 bytes are seconds since + * the UN*X epoch (1970-01-01 00:00:00 UTC), and, if there are 8 bytes, + * the next 4 bytes are nanoseconds since that second. (I.e., a UN*X + * struct timespec with a 4-byte time_t.) + * + * ENC_TIME_NTP - 4 or 8 bytes; the first 4 bytes are seconds since + * the NTP epoch (1901-01-01 00:00:00 GMT), and, if there are 8 bytes, + * the next 4 bytes are 1/2^32's of a second since that second. (I.e., + * a 64-bit count of 1/2^32's of a second since the NTP epoch, with + * the upper 32 bits first and the lower 32 bits second, even when + * little-endian.) + * + * ENC_TIME_TOD - 8 bytes, as a count of microseconds since the System/3x0 + * and z/Architecture epoch (1900-01-01 00:00:00 GMT). + * + * ENC_TIME_NTP_BASE_ZERO - 4 or 8 bytes; the first 4 bytes are seconds + * since the UN*X epoch, and, if there are 8 bytes, the next 4 bytes are + * are 1/2^32's of a second since that second. (I.e., it's the offspring + * of a mating between UN*X time and NTP time.) + * + * ENC_TIME_TIMEVAL - 8 bytes; the first 4 bytes are seconds since + * the UN*X epoch (1970-01-01 00:00:00 UTC), and, if there are 8 bytes, + * the next 4 bytes are microseconds since that second. (I.e., a UN*X + * struct timeval with a 4-byte time_t.) */ -#define ENC_TIME_TIMESPEC 0x00000000 /* "struct timespec" */ -#define ENC_TIME_NTP 0x00000002 /* NTP times */ -#define ENC_TIME_TOD 0x00000004 /* System/3xx and z/Architecture time-of-day clock */ -#define ENC_TIME_NTP_BASE_ZERO 0x00000008 /* NTP times with different BASETIME */ +#define ENC_TIME_TIMESPEC 0x00000000 +#define ENC_TIME_NTP 0x00000002 +#define ENC_TIME_TOD 0x00000004 +#define ENC_TIME_NTP_BASE_ZERO 0x00000008 +#define ENC_TIME_TIMEVAL 0x00000010 + /* * Historically, the only place the representation mattered for strings * was with FT_UINT_STRINGs, where we had FALSE for the string length |