- merge the update code in one function
- support wtmpx - kill local decls of logwtmp; use util.h
This commit is contained in:
parent
b772b1e89b
commit
7bc0bdf604
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.11 2007/01/25 23:25:20 cbiere Exp $
|
||||
# $NetBSD: Makefile,v 1.12 2007/01/25 23:51:11 christos Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
#
|
||||
# optional flags are: MEASURE TESTING DEBUG
|
||||
|
@ -8,8 +8,7 @@ SRCS= acksend.c candidate.c correct.c master.c networkdelta.c readmsg.c \
|
|||
slave.c timed.c byteorder.c measure.c cksum.c tspname.c
|
||||
DPADD= ${LIBUTIL}
|
||||
LDADD= -lutil
|
||||
CPPFLAGS+=-DSUPPORT_UTMP -DSUPPORT_UTMPX
|
||||
MAN= timed.8
|
||||
|
||||
WARNS= 2
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: master.c,v 1.16 2007/01/25 23:25:20 cbiere Exp $ */
|
||||
/* $NetBSD: master.c,v 1.17 2007/01/25 23:51:11 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1985, 1993 The Regents of the University of California.
|
||||
|
@ -34,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)master.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: master.c,v 1.16 2007/01/25 23:25:20 cbiere Exp $");
|
||||
__RCSID("$NetBSD: master.c,v 1.17 2007/01/25 23:51:11 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -56,8 +56,6 @@ static int slvcount; /* slaves listening to our clock */
|
|||
|
||||
static void mchgdate(struct tsp*);
|
||||
|
||||
extern void logwtmp(char *, char *, char *);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
@ -372,16 +370,12 @@ mchgdate(struct tsp *msg)
|
|||
dictate = 3;
|
||||
synch(tvtomsround(ntime));
|
||||
} else {
|
||||
logwtmp("|", "date", "");
|
||||
tmptv.tv_sec = msg->tsp_time.tv_sec;
|
||||
tmptv.tv_usec = msg->tsp_time.tv_usec;
|
||||
(void)settimeofday(&tmptv, 0);
|
||||
logwtmp("}", "date", "");
|
||||
update_time(&tmptv, msg);
|
||||
spreadtime();
|
||||
}
|
||||
|
||||
syslog(LOG_NOTICE, "date changed by %s from %s",
|
||||
tname, olddate);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: measure.c,v 1.14 2007/01/25 23:25:20 cbiere Exp $ */
|
||||
/* $NetBSD: measure.c,v 1.15 2007/01/25 23:51:11 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1985, 1993 The Regents of the University of California.
|
||||
|
@ -34,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)measure.c 8.2 (Berkeley) 3/26/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: measure.c,v 1.14 2007/01/25 23:25:20 cbiere Exp $");
|
||||
__RCSID("$NetBSD: measure.c,v 1.15 2007/01/25 23:51:11 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -42,6 +42,7 @@ __RCSID("$NetBSD: measure.c,v 1.14 2007/01/25 23:25:20 cbiere Exp $");
|
|||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip_icmp.h>
|
||||
#include <util.h>
|
||||
|
||||
#define MSEC_DAY (SECDAY*1000)
|
||||
|
||||
|
@ -322,3 +323,23 @@ mstotvround(struct timeval *res, long x)
|
|||
res->tv_sec--;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
update_time(struct timeval *tv, const struct tsp *msg)
|
||||
{
|
||||
#ifdef SUPPORT_UTMP
|
||||
logwtmp("|", "date", "");
|
||||
#endif
|
||||
#ifdef SUPPORT_UTMPX
|
||||
logwtmpx("|", "date", "", 0, OLD_TIME);
|
||||
#endif
|
||||
tv->tv_sec = msg->tsp_time.tv_sec;
|
||||
tv->tv_usec = msg->tsp_time.tv_usec;
|
||||
(void)settimeofday(tv, 0);
|
||||
#ifdef SUPPORT_UTMP
|
||||
logwtmp("}", "date", "");
|
||||
#endif
|
||||
#ifdef SUPPORT_UTMPX
|
||||
logwtmpx("}", "date", "", 0, NEW_TIME);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: slave.c,v 1.16 2007/01/25 23:25:20 cbiere Exp $ */
|
||||
/* $NetBSD: slave.c,v 1.17 2007/01/25 23:51:11 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1985, 1993 The Regents of the University of California.
|
||||
|
@ -34,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)slave.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: slave.c,v 1.16 2007/01/25 23:25:20 cbiere Exp $");
|
||||
__RCSID("$NetBSD: slave.c,v 1.17 2007/01/25 23:51:11 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -56,9 +56,6 @@ static void schgdate(struct tsp *, char *);
|
|||
static void setmaster(struct tsp *);
|
||||
static void answerdelay(void);
|
||||
|
||||
extern void logwtmp(char *, char *, char *);
|
||||
|
||||
|
||||
int
|
||||
slave(void)
|
||||
{
|
||||
|
@ -278,12 +275,7 @@ loop:
|
|||
*/
|
||||
synch(tvtomsround(ntime));
|
||||
} else {
|
||||
logwtmp("|", "date", "");
|
||||
tmptv.tv_sec = msg->tsp_time.tv_sec;
|
||||
tmptv.tv_usec = msg->tsp_time.tv_usec;
|
||||
(void)settimeofday(&tmptv, 0);
|
||||
logwtmp("}", "date", "");
|
||||
|
||||
update_time(&tmptv, msg);
|
||||
syslog(LOG_NOTICE,
|
||||
"date changed by %s from %s",
|
||||
msg->tsp_name, olddate);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: timed-extern.h,v 1.6 2007/01/25 23:25:20 cbiere Exp $ */
|
||||
/* $NetBSD: timed-extern.h,v 1.7 2007/01/25 23:51:11 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993 The Regents of the University of California.
|
||||
|
@ -82,6 +82,6 @@ void synch(long);
|
|||
void traceoff(const char *);
|
||||
void traceon(void);
|
||||
void xmit(int, u_short, struct sockaddr_in *);
|
||||
void set_tsp_name(struct tsp *tsp, const char *name);
|
||||
void get_tsp_name(const struct tsp *tsp, char *name, size_t size);
|
||||
|
||||
void set_tsp_name(struct tsp *, const char *);
|
||||
void get_tsp_name(const struct tsp *tsp, char *, size_t);
|
||||
void update_time(struct timeval *, const struct tsp *);
|
||||
|
|
Loading…
Reference in New Issue