diff options
-rw-r--r-- | usr.sbin/ntpd/client.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c index bf374510bea..0f9ca4b4620 100644 --- a/usr.sbin/ntpd/client.c +++ b/usr.sbin/ntpd/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.81 2008/06/10 03:51:53 naddy Exp $ */ +/* $OpenBSD: client.c,v 1.82 2009/03/04 18:46:44 stevesk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -20,6 +20,7 @@ #include <sys/param.h> #include <errno.h> #include <md5.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> @@ -218,10 +219,25 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime) if ((msg.status & LI_ALARM) == LI_ALARM || msg.stratum == 0 || msg.stratum > NTP_MAXSTRATUM) { + char s[16]; + + if ((msg.status & LI_ALARM) == LI_ALARM) { + strlcpy(s, "alarm", sizeof(s)); + } else if (msg.stratum == 0) { + /* Kiss-o'-Death (KoD) packet */ + if (msg.refid != 0) + snprintf(s, sizeof(s), "KoD %.4s", + (char *)&msg.refid); + else + strlcpy(s, "KoD", sizeof(s)); + } else if (msg.stratum > NTP_MAXSTRATUM) { + snprintf(s, sizeof(s), "stratum %d", msg.stratum); + } interval = error_interval(); set_next(p, interval); - log_info("reply from %s: not synced, next query %ds", - log_sockaddr((struct sockaddr *)&p->addr->ss), interval); + log_info("reply from %s: not synced (%s), next query %ds", + log_sockaddr((struct sockaddr *)&p->addr->ss), s, + interval); return (0); } |