summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd/client.c
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2008-06-10 03:51:54 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2008-06-10 03:51:54 +0000
commit7b97c806c9204d0dcddc4c0483e909fe16d513ce (patch)
tree738eb1d02f5ec247f57a8f29b4aacab2aabd39bc /usr.sbin/ntpd/client.c
parent2cfc51272e42f900535e789491b04ac34dd5125f (diff)
For IPv6 addresses, return the first 32 bits of the MD5 hash of the
address as ref ID (RFC4330). ok henning@
Diffstat (limited to 'usr.sbin/ntpd/client.c')
-rw-r--r--usr.sbin/ntpd/client.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c
index 92a5199d5a2..bf374510bea 100644
--- a/usr.sbin/ntpd/client.c
+++ b/usr.sbin/ntpd/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.80 2008/06/10 03:46:09 naddy Exp $ */
+/* $OpenBSD: client.c,v 1.81 2008/06/10 03:51:53 naddy Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -19,6 +19,7 @@
#include <sys/param.h>
#include <errno.h>
+#include <md5.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -267,10 +268,20 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
p->reply[p->shift].status.poll = msg.ppoll;
p->reply[p->shift].status.stratum = msg.stratum;
- if (p->addr->ss.ss_family == AF_INET)
+ if (p->addr->ss.ss_family == AF_INET) {
p->reply[p->shift].status.send_refid =
((struct sockaddr_in *)&p->addr->ss)->sin_addr.s_addr;
- else
+ } else if (p->addr->ss.ss_family == AF_INET6) {
+ MD5_CTX context;
+ u_int8_t digest[MD5_DIGEST_LENGTH];
+
+ MD5Init(&context);
+ MD5Update(&context, ((struct sockaddr_in6 *)&p->addr->ss)->
+ sin6_addr.s6_addr, sizeof(struct in6_addr));
+ MD5Final(digest, &context);
+ memcpy((char *)&p->reply[p->shift].status.send_refid, digest,
+ sizeof(u_int32_t));
+ } else
p->reply[p->shift].status.send_refid = msg.xmttime.fractionl;
if (p->trustlevel < TRUSTLEVEL_PATHETIC)