summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/packet-rtps.c5
-rw-r--r--epan/proto.c50
-rw-r--r--epan/proto.h8
3 files changed, 57 insertions, 6 deletions
diff --git a/epan/dissectors/packet-rtps.c b/epan/dissectors/packet-rtps.c
index 3e4f7bbed6..73946c7a8c 100644
--- a/epan/dissectors/packet-rtps.c
+++ b/epan/dissectors/packet-rtps.c
@@ -1723,8 +1723,9 @@ void rtps_util_add_ntp_time(proto_tree *tree,
gboolean little_endian,
int hf_time) {
+ /* ENC_TIME_NTP_BASE_ZERO applies the BASETIME specified by the standard (zero)*/
proto_tree_add_item(tree, hf_time, tvb, offset, 8,
- ENC_TIME_NTP|(little_endian ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN));
+ ENC_TIME_NTP_BASE_ZERO|(little_endian ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN));
}
@@ -7642,7 +7643,7 @@ void proto_register_rtps(void) {
static hf_register_info hf[] = {
{ &hf_rtps_magic, {
- "magic",
+ "Magic",
"rtps.magic",
FT_STRING,
BASE_NONE,
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();
diff --git a/epan/proto.h b/epan/proto.h
index 46e7683e37..2e8f30c24e 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -368,10 +368,10 @@ WS_DLL_PUBLIC WS_MSVC_NORETURN void proto_report_dissector_bug(const char *messa
* For backwards compatibility, we interpret an encoding of 1 as meaning
* "little-endian timespec", so that passing TRUE is interpreted as that.
*/
-#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_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 */
/*
* Historically, the only place the representation mattered for strings
* was with FT_UINT_STRINGs, where we had FALSE for the string length