diff options
author | Grant Erickson <marathon96@gmail.com> | 2012-07-16 09:48:00 -0700 |
---|---|---|
committer | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2012-07-17 10:13:16 +0200 |
commit | 123e093b1395afe8b8857f40af6b08d9f396f9d3 (patch) | |
tree | 53c6438f0245ae08de9c155b70f391ee0f0d1240 /src/ntp.c | |
parent | 19116c1505384f3ee47626474f73cd458008055f (diff) | |
download | connman-123e093b1395afe8b8857f40af6b08d9f396f9d3.tar.gz connman-123e093b1395afe8b8857f40af6b08d9f396f9d3.tar.bz2 connman-123e093b1395afe8b8857f40af6b08d9f396f9d3.zip |
ntp: Send a transmit time value that reflects current system time
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.
Diffstat (limited to 'src/ntp.c')
-rw-r--r-- | src/ntp.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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) { |