diff options
author | Juanjo Martin <juanjo@rti.com> | 2015-10-20 17:05:42 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2015-11-02 03:48:47 +0000 |
commit | e52931bab0553d3e51b1b10e70838a34c603b019 (patch) | |
tree | 1d1e7216213ef6ab4ddf13b302b926121d5a9994 /epan | |
parent | f015c85317a8fc134902addab48ec3a1eeceab3e (diff) | |
download | wireshark-e52931bab0553d3e51b1b10e70838a34c603b019.tar.gz |
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')
-rw-r--r-- | epan/dissectors/packet-rtps.c | 5 | ||||
-rw-r--r-- | epan/proto.c | 50 | ||||
-rw-r--r-- | epan/proto.h | 8 |
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 |