Browse Source

Propogate server's leap indicator flags to clients; ok henning@

OPENBSD_3_8
dtucker 19 years ago
parent
commit
f31cfdaa27
4 changed files with 17 additions and 11 deletions
  1. +2
    -2
      src/usr.sbin/ntpd/client.c
  2. +7
    -6
      src/usr.sbin/ntpd/ntp.c
  3. +2
    -1
      src/usr.sbin/ntpd/ntpd.h
  4. +6
    -2
      src/usr.sbin/ntpd/server.c

+ 2
- 2
src/usr.sbin/ntpd/client.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: client.c,v 1.64 2005/07/11 08:04:28 dtucker Exp $ */
/* $OpenBSD: client.c,v 1.65 2005/08/10 13:48:36 dtucker Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -246,7 +246,7 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
p->reply[p->shift].rcvd = time(NULL);
p->reply[p->shift].good = 1;
p->reply[p->shift].status.leap = (msg.status & LIMASK) >> 6;
p->reply[p->shift].status.leap = (msg.status & LIMASK);
p->reply[p->shift].status.precision = msg.precision;
p->reply[p->shift].status.rootdelay = sfp_to_d(msg.rootdelay);
p->reply[p->shift].status.rootdispersion = sfp_to_d(msg.dispersion);


+ 7
- 6
src/usr.sbin/ntpd/ntp.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntp.c,v 1.66 2005/08/08 14:42:32 henning Exp $ */
/* $OpenBSD: ntp.c,v 1.67 2005/08/10 13:48:36 dtucker Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -138,7 +138,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
client_peer_init(p);
bzero(&conf->status, sizeof(conf->status));
conf->status.leap = LI_ALARM;
conf->status.synced = 0;
clock_getres(CLOCK_REALTIME, &tp);
b = 1000000000 / tp.tv_nsec; /* convert to Hz */
for (a = 0; b > 1; a--, b >>= 1)
@ -308,12 +308,12 @@ ntp_dispatch_imsg(void)
switch (imsg.hdr.type) {
case IMSG_ADJTIME:
memcpy(&n, imsg.data, sizeof(n));
if (n == 1 && conf->status.leap == LI_ALARM) {
if (n == 1 && !conf->status.synced) {
log_info("clock is now synced");
conf->status.leap = LI_NOWARNING;
} else if (n == 0 && conf->status.leap != LI_ALARM) {
conf->status.synced = 1;
} else if (n == 0 && conf->status.synced) {
log_info("clock is now unsynced");
conf->status.leap = LI_ALARM;
conf->status.synced = 0;
}
break;
case IMSG_HOST_DNS:
@ -433,6 +433,7 @@ priv_adjtime(void)
conf->status.stratum =
peers[offset_cnt / 2]->update.status.stratum;
}
conf->status.leap = peers[offset_cnt / 2]->update.status.leap;
imsg_compose(ibuf_main, IMSG_ADJTIME, 0, 0,
&offset_median, sizeof(offset_median));


+ 2
- 1
src/usr.sbin/ntpd/ntpd.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.59 2005/07/15 03:37:15 henning Exp $ */
/* $OpenBSD: ntpd.h,v 1.60 2005/08/10 13:48:36 dtucker Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -90,6 +90,7 @@ struct ntp_status {
double reftime;
u_int32_t refid;
u_int32_t refid4;
u_int8_t synced;
u_int8_t leap;
int8_t precision;
u_int8_t poll;


+ 6
- 2
src/usr.sbin/ntpd/server.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: server.c,v 1.24 2005/07/22 08:58:56 dtucker Exp $ */
/* $OpenBSD: server.c,v 1.25 2005/08/10 13:48:36 dtucker Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -131,7 +131,11 @@ server_dispatch(int fd, struct ntpd_conf *conf)
version = (query.status & VERSIONMASK) >> 3;
bzero(&reply, sizeof(reply));
reply.status = conf->status.leap | (query.status & VERSIONMASK);
if (conf->status.synced)
reply.status = conf->status.leap;
else
reply.status = LI_ALARM;
reply.status |= (query.status & VERSIONMASK);
if ((query.status & MODEMASK) == MODE_CLIENT)
reply.status |= MODE_SERVER;
else


Loading…
Cancel
Save