This sets the ntp request packet transmit time to the current system
time to reflect behavior implemented by ntpdate and ntpd in one-shot
mode.
---
 src/ntp.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/ntp.c b/src/ntp.c
index c7224a8..1916a72 100644
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -117,8 +117,6 @@ static void send_packet(int fd, const char *server)
        msg.flags = NTP_FLAGS_ENCODE(NTP_FLAG_LI_NOWARNING, 4, 
NTP_FLAG_MD_CLIENT);
        msg.poll = 4;   // min
        msg.poll = 10;  // max
-       msg.xmttime.seconds = random();
-       msg.xmttime.fraction = random();
 
        memset(&addr, 0, sizeof(addr));
        addr.sin_family = AF_INET;
@@ -127,6 +125,9 @@ static void send_packet(int fd, const char *server)
 
        gettimeofday(&transmit_timeval, NULL);
 
+       msg.xmttime.seconds = htonl(transmit_timeval.tv_sec + OFFSET_1900_1970);
+       msg.xmttime.fraction = htonl(transmit_timeval.tv_usec * 1000);
+
        len = sendto(fd, &msg, sizeof(msg), MSG_DONTWAIT,
                                                &addr, sizeof(addr));
        if (len < 0) {
-- 
1.7.10

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to