aboutsummaryrefslogtreecommitdiffstats
path: root/epan/proto.c
diff options
context:
space:
mode:
authorJuanjo Martin <juanjo@rti.com>2015-10-20 17:05:42 +0200
committerMichael Mann <mmann78@netscape.net>2015-11-02 03:48:47 +0000
commite52931bab0553d3e51b1b10e70838a34c603b019 (patch)
tree1d1e7216213ef6ab4ddf13b302b926121d5a9994 /epan/proto.c
parentf015c85317a8fc134902addab48ec3a1eeceab3e (diff)
RTPS: added new encoding to proto.c and used it in the rtps dissector
RTPS uses NTP encoding with a BASETIME equal to 0. Also, changed "magic" by "Magic" Change-Id: I2512176f2018396edaa6b2a1478facd26118cb13 Reviewed-on: https://code.wireshark.org/review/11184 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/epan/proto.c b/epan/proto.c
index 0cf1079747..bf21b74d98 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -1609,6 +1609,56 @@ get_time_value(tvbuff_t *tvb, const gint start, const gint length, const guint e
time_stamp->nsecs = 0;
}
break;
+ case ENC_TIME_NTP_BASE_ZERO|ENC_BIG_ENDIAN:
+ /*
+ * DDS NTP time stamp, big-endian.
+ */
+
+#define NTP_BASETIME_ZERO G_GUINT64_CONSTANT(0)
+
+ tmpsecs = tvb_get_ntohl(tvb, start);
+ if (tmpsecs)
+ time_stamp->secs = (time_t)(tmpsecs - (guint32)NTP_BASETIME_ZERO);
+ else
+ time_stamp->secs = tmpsecs; /* 0 */
+
+ if (length == 8) {
+ /*
+ * We're using nanoseconds here (and we will
+ * display nanoseconds), but NTP's timestamps
+ * have a precision in microseconds or greater.
+ * Round to 1 microsecond.
+ */
+ time_stamp->nsecs = (int)(1000000*(tvb_get_ntohl(tvb, start+4)/4294967296.0));
+ time_stamp->nsecs *= 1000;
+ } else {
+ time_stamp->nsecs = 0;
+ }
+ break;
+
+ case ENC_TIME_NTP_BASE_ZERO|ENC_LITTLE_ENDIAN:
+ /*
+ * NTP time stamp, big-endian.
+ */
+ tmpsecs = tvb_get_letohl(tvb, start);
+ if (tmpsecs)
+ time_stamp->secs = (time_t)(tmpsecs - (guint32)NTP_BASETIME_ZERO);
+ else
+ time_stamp->secs = tmpsecs; /* 0 */
+ time_stamp->secs = (time_t)tvb_get_letohl(tvb, start);
+ if (length == 8) {
+ /*
+ * We're using nanoseconds here (and we will
+ * display nanoseconds), but NTP's timestamps
+ * have a precision in microseconds or greater.
+ * Round to 1 microsecond.
+ */
+ time_stamp->nsecs = (int)(1000000*(tvb_get_letohl(tvb, start+4)/4294967296.0));
+ time_stamp->nsecs *= 1000;
+ } else {
+ time_stamp->nsecs = 0;
+ }
+ break;
default:
DISSECTOR_ASSERT_NOT_REACHED();