summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd/ntp.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-10-13 12:22:40 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-10-13 12:22:40 +0000
commit395a6c5650b3167080dfae83dec6dca056c9ae9c (patch)
tree3e9e4bce482eaaf29cfa6561650f3574848cedda /usr.sbin/ntpd/ntp.c
parente177c1335c78f9589154ae123c2de4f55e5d899c (diff)
correctly set refid in replies with NTP protocol versions < 4.
code path for NTP4 remains unchanged, we already set refid correctly there. NTP3 and older uses an IPv4 address as refid. use the IP of the server we last synced to if it was a IPv4 one. sometimes we use the average offset between two, in that case just pick one for the IP. this scheme naturally fails when we query IPv6 servers and have to reply to IPv4 NTP3 (or even older NTP versions) clients - refid stays at 0 then. this is a protocol limitation, nothing we can do about it.
Diffstat (limited to 'usr.sbin/ntpd/ntp.c')
-rw-r--r--usr.sbin/ntpd/ntp.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index 53a0382c4c9..6c5e5a4e7d0 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.35 2004/10/13 09:20:41 henning Exp $ */
+/* $OpenBSD: ntp.c,v 1.36 2004/10/13 12:22:39 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -385,6 +385,10 @@ ntp_adjtime(void)
conf->status.reftime = gettime();
conf->status.leap = LI_NOWARNING; /* XXX */
+
+ if (peers[offset_cnt / 2]->addr->ss.ss_family == AF_INET)
+ conf->status.refid = ((struct sockaddr_in *)
+ &peers[offset_cnt / 2]->addr->ss)->sin_addr.s_addr;
}
free(peers);