From 61a85aecd076a99c847a2f8fa0eeb9cc4cf98b6f Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Sat, 18 Jul 2015 11:48:33 +0200 Subject: [PATCH] [sedhcpv6a] Receiving timestamp fixed as well. --- src/lib/util/ntp_utils.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/util/ntp_utils.cc b/src/lib/util/ntp_utils.cc index fa910fdeb3..922cb43554 100644 --- a/src/lib/util/ntp_utils.cc +++ b/src/lib/util/ntp_utils.cc @@ -99,6 +99,8 @@ Ntp::Ntp(double secs, time_t base) bool Ntp::from_binary(const std::vector binary) { + // This format is defined in RFC5905, Section 6, Fig. 3 + // (see 64bit timestamp format) if (binary.size() != 8) { return (false); } @@ -109,11 +111,11 @@ bool Ntp::from_binary(const std::vector binary) ntp_sec_ |= binary[2]; ntp_sec_ <<= 8; ntp_sec_ |= binary[3]; - ntp_sec_ <<= 8; - ntp_sec_ |= binary[4]; - ntp_sec_ <<= 8; - ntp_sec_ |= binary[5]; - ntp_fraction_ = binary[6]; + ntp_fraction_ = binary[4]; + ntp_fraction_ <<= 8; + ntp_fraction_ |= binary[5]; + ntp_fraction_ <<= 8; + ntp_fraction_ |= binary[6]; ntp_fraction_ <<= 8; ntp_fraction_ |= binary[7]; return (true); @@ -121,6 +123,8 @@ bool Ntp::from_binary(const std::vector binary) std::vector Ntp::to_binary() const { + // This format is defined in RFC5905, Section 6, Fig. 3 + // (see 64bit timestamp format) std::vector ret(8); ret[0] = static_cast((ntp_sec_ >> 24) & 0xff); ret[1] = static_cast((ntp_sec_ >> 16) & 0xff); -- 2.47.2