diff options
author | AndersBroman <anders.broman@ericsson.com> | 2017-03-28 17:07:33 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-03-29 05:09:54 +0000 |
commit | 572b80d2835f9296e87c0d099f133d55149c44f1 (patch) | |
tree | fb3f68226770333f115a14b95848203dddd6baf6 /epan/proto.c | |
parent | 79ba8c397653d99b4c52a5bbfa2f4d554067c6a4 (diff) |
Add ENC_TIME_MSEC_NTP and use it in packet-gtpv2.c
While at it fix expert info a typo and an calculation.
Change-Id: I071a36edb7eed5f58708b98aebcb24bc6c34f2a8
Reviewed-on: https://code.wireshark.org/review/20766
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/proto.c')
-rw-r--r-- | epan/proto.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/epan/proto.c b/epan/proto.c index fcc4ab0bd8..89fc19cacc 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1922,7 +1922,7 @@ get_time_value(proto_tree *tree, tvbuff_t *tvb, const gint start, msecs = get_uint64_value(tree, tvb, start, length, encoding); time_stamp->secs = (time_t)(msecs / 1000); - time_stamp->nsecs = (int)(msecs % 1000); + time_stamp->nsecs = (int)(msecs % 1000)*1000000; } else report_type_length_mismatch(tree, "a time-in-milliseconds time stamp", length, TRUE); break; @@ -2032,7 +2032,23 @@ get_time_value(proto_tree *tree, tvbuff_t *tvb, const gint start, } else report_type_length_mismatch(tree, "an NTP seconds-only time stamp", length, TRUE); break; + case ENC_TIME_MSEC_NTP | ENC_BIG_ENDIAN: + /* + * Milliseconds, 1 to 8 bytes. + * For absolute times, it's milliseconds since the + * NTP epoch. + */ + if (length >= 1 && length <= 8) { + guint64 msecs; + msecs = get_uint64_value(tree, tvb, start, length, encoding); + tmpsecs = (guint32)(msecs / 1000); + time_stamp->secs = (time_t)(tmpsecs - (guint32)NTP_BASETIME); + time_stamp->nsecs = (int)(msecs % 1000)*1000000; + } + else + report_type_length_mismatch(tree, "a time-in-milliseconds NTP time stamp", length, TRUE); + break; default: DISSECTOR_ASSERT_NOT_REACHED(); break; @@ -2441,7 +2457,7 @@ proto_tree_new_item(field_info *new_fi, proto_tree *tree, if (encoding == TRUE) encoding = ENC_TIME_TIMESPEC|ENC_LITTLE_ENDIAN; - if (length != 8 && length != 4) { + if (length > 8 || length < 4) { length_error = length < 4 ? TRUE : FALSE; report_type_length_mismatch(tree, "an absolute time value", length, length_error); } @@ -3004,9 +3020,9 @@ proto_tree_add_time_item(proto_tree *tree, int hfindex, tvbuff_t *tvb, } else { const gboolean is_relative = (hfinfo->type == FT_RELATIVE_TIME) ? TRUE : FALSE; + const gboolean length_error = length < 4 ? TRUE : FALSE; - if (length != 8 && length != 4) { - const gboolean length_error = length < 4 ? TRUE : FALSE; + if (length > 8 || length < 4) { if (is_relative) report_type_length_mismatch(tree, "a relative time value", length, length_error); else |