summaryrefslogtreecommitdiff
path: root/src/ntp.c
diff options
context:
space:
mode:
authorGrant Erickson <marathon96@gmail.com>2012-07-16 09:48:04 -0700
committerDaniel Wagner <daniel.wagner@bmw-carit.de>2012-07-17 10:13:43 +0200
commit6f0080f148b1f5555e1be9db7536bdbad2f48642 (patch)
tree1b49dd1048d7fc8c7f69809a07ef984f363e0f30 /src/ntp.c
parentd00cbbd3b0aa78b2464153681ae37f10a9acaa48 (diff)
downloadconnman-6f0080f148b1f5555e1be9db7536bdbad2f48642.tar.gz
connman-6f0080f148b1f5555e1be9db7536bdbad2f48642.tar.bz2
connman-6f0080f148b1f5555e1be9db7536bdbad2f48642.zip
ntp: Use mnemonic when specifying the request precision
This patch uses a mnemonic to specify the request precision and also adds a comment how a future implementation might pass along the actual system wall clock precision.
Diffstat (limited to 'src/ntp.c')
-rw-r--r--src/ntp.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ntp.c b/src/ntp.c
index 3e907416..e15bd083 100644
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -120,10 +120,17 @@ static void send_packet(int fd, const char *server)
struct sockaddr_in addr;
ssize_t len;
+ /*
+ * At some point, we could specify the actual system precision with:
+ *
+ * clock_getres(CLOCK_REALTIME, &ts);
+ * msg.precision = (int)log2(ts.tv_sec + (ts.tv_nsec * 1.0e-9));
+ */
memset(&msg, 0, sizeof(msg));
msg.flags = NTP_FLAGS_ENCODE(NTP_FLAG_LI_NOTINSYNC, 4, NTP_FLAG_MD_CLIENT);
msg.poll = 4; // min
msg.poll = 10; // max
+ msg.precision = NTP_PRECISION_S;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;