diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-03-25 21:37:29 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-03-26 04:38:11 +0000 |
commit | a6730565f8569b0b8dafc8aebad120c5b66cf3cb (patch) | |
tree | 2b0193184ad5f07549856cc1fc8aa1a893304185 /epan/proto.c | |
parent | 6c374a2a5c6c5125ab3ebacb922ca3978d9c0a9d (diff) |
Add ENC_TIME_TIMEVAL and use it for gsmtap.
From a look at the libosmocom code, time stamps in
GSMTAP_TYPE_OSMOCORE_LOG messages appear to be UN*X struct timevals with
a 4-byte tv_sec, not anything NTP-like with the fraction-of-a-second
part in units of 1/2^32s of a second.
Add ENC_TIME_TIMEVAL to handle time stamps like that, and use it rather
than ENC_TIME_NTP_BASE_ZERO.
Change-Id: Ia1511527ee292fb7725b2a64c0af16d23ff10a6d
Reviewed-on: https://code.wireshark.org/review/20710
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/proto.c')
-rw-r--r-- | epan/proto.c | 61 |
1 files changed, 40 insertions, 21 deletions
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; |