Remove xntp3 sources.
This commit is contained in:
parent
44e419a369
commit
6e1372a422
@ -1,127 +0,0 @@
|
||||
<!-- $NetBSD: COPYRIGHT,v 1.6 1999/07/03 12:30:27 simonb Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Copyright Notice
|
||||
</title></head><body><h3>
|
||||
Copyright Notice
|
||||
</h3><hr>
|
||||
|
||||
<p>The following copyright notice applies to all files collectively
|
||||
called the Network Time Protocol Version 4 Distribution. Unless
|
||||
specifically declared otherwise in an individual file, this notice
|
||||
applies as if the text was explicitly included in the file.
|
||||
|
||||
<pre>
|
||||
|
||||
/***********************************************************************
|
||||
* *
|
||||
* Copyright (c) David L. Mills 1992, 1993, 1994, 1995, 1996 *
|
||||
* *
|
||||
* Permission to use, copy, modify, and distribute this software and *
|
||||
* its documentation for any purpose and without fee is hereby *
|
||||
* granted, provided that the above copyright notice appears in all *
|
||||
* copies and that both the copyright notice and this permission *
|
||||
* notice appear in supporting documentation, and that the name *
|
||||
* University of Delaware not be used in advertising or publicity *
|
||||
* pertaining to distribution of the software without specific, *
|
||||
* written prior permission. The University of Delaware makes no *
|
||||
* representations about the suitability this software for any *
|
||||
* purpose. It is provided "as is" without express or implied *
|
||||
* warranty. *
|
||||
**********************************************************************/
|
||||
|
||||
</pre><p>
|
||||
|
||||
The following individuals contributed in part to the Network Time
|
||||
Protocol Distribution Version 4 and are acknowledged as authors of this
|
||||
work.
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mark Andrews (marka@syd.dms.csiro.au) Leitch atomic clock
|
||||
controller
|
||||
|
||||
<br><li>Viraj Bais (vbais@mailman1.intel.com), Clayton Kirkwood
|
||||
(kirkwood@striderfm.intel.com), and Greg Schueman (schueman@acm.org)
|
||||
port to WindowsNT 3.51
|
||||
|
||||
<br><li>Karl Berry (karl@owl.HQ.ileaf.com) syslog to file option
|
||||
|
||||
<br><li>Piete Brooks (Piete.Brooks@cl.cam.ac.uk) MSF clock driver,
|
||||
Trimble PARSE support
|
||||
|
||||
<br><li>Steve Clift (clift@ml.csiro.au): OMEGA clock driver
|
||||
|
||||
<br><li><a href="http://www.ee.uct.ac.za/~casey"> Casey Crellin </a>
|
||||
<a href="mailto:casey@csc.co.za"> (casey@csc.co.za) </a>
|
||||
vxWorks (Tornado) port and help with target configuration
|
||||
|
||||
<br><li>Torsten Duwe (duwe@immd4.informatik.uni-erlangen.de) Linux Port
|
||||
|
||||
<br><li>John A. Dundas III (dundas@salt.jpl.nasa.gov) Apple A/UX port
|
||||
|
||||
<br><li>Dennis Ferguson (dennis@mrbill.canet.ca) foundation code for NTP
|
||||
Version 2 as specified in RFC-1119
|
||||
|
||||
<br><li>Glenn Hollinger (glenn@herald.usask.ca) GOES clock driver
|
||||
|
||||
<br><li>Mike Iglesias (iglesias@uci.edu): DEC Alpha port
|
||||
|
||||
<br><li>Jim Jagielski (jim@jagubox.gsfc.nasa.gov) A/UX port
|
||||
|
||||
<br><li>Jeff Johnson (jbj@chatham.usdesign.com) massive prototyping
|
||||
overhaul
|
||||
<br><li>William L. Jones (jones@hermes.chpc.utexas.edu) RS/6000 AIX
|
||||
modifications, HPUX modifications
|
||||
|
||||
<br><li>Dave Katz (dkatz@cisco.com) RS/6000 AIX port
|
||||
|
||||
<br><li>Craig Leres (leres@ee.lbl.gov) 4.4BSD port, ppsclock, Maganavox
|
||||
GPS clock driver
|
||||
|
||||
<br><li>George Lindholm (lindholm@ucs.ubc.ca) SunOS 5.1 port
|
||||
|
||||
<br><li>Louis A. Mamakos (louie@ni.umd.edu) MD5-based authentication
|
||||
|
||||
<br><li>Lars H. Mathiesen (thorinn@diku.dk) adaptation of foundation
|
||||
code for Version 3 as specified in RFC-1305
|
||||
|
||||
<br><li><a href="http://www.eecis.udel.edu/~mills">David L. Mills
|
||||
(mills@udel.edu)</a> Spectractom WWVB, Austron GPS, Heath, ATOM, ACTS,
|
||||
KSI/Odetics IRIG-B clock drivers; PPS support
|
||||
|
||||
<br><li>Wolfgang Moeller (moeller@gwdgv1.dnet.gwdg.de) VMS port
|
||||
|
||||
<br><li>Jeffrey Mogul (mogul@pa.dec.com) ntptrace utility
|
||||
|
||||
<br><li>Tom Moore (tmoore@fievel.daytonoh.ncr.com) i386 svr4 port
|
||||
|
||||
<br><li>Rainer Pruy (Rainer.Pruy@informatik.uni-erlangen.de)
|
||||
monitoring/trap scripts, statistics file handling
|
||||
|
||||
<br><li>Nick Sayer (mrapple@quack.kfu.com) SunOS streams modules
|
||||
|
||||
<br><li><a href="http://www4.informatik.uni-erlangen.de/~kardel">Frank Kardel</a>
|
||||
<a href="mailto: Frank.Kardel@informatik.uni-erlangen.de"> <Frank.Kardel@informatik.uni-erlangen.de></a>
|
||||
PARSE <GENERIC> driver (14 reference clocks), STREAMS modules for PARSE, support
|
||||
scripts, syslog cleanup
|
||||
|
||||
<br><li>Ray Schnitzler (schnitz@unipress.com) Unixware1 port
|
||||
|
||||
<br><li>Michael Shields (shields@tembel.org) USNO clock driver
|
||||
|
||||
<br><li>Jeff Steinman (jss@pebbles.jpl.nasa.gov) Datum PTS clock driver
|
||||
|
||||
<br><li>Kenneth Stone (ken@sdd.hp.com) HP-UX port
|
||||
|
||||
<br><li><a href="http://www.eecis.udel.edu/~ajit">Ajit Thyagarajan
|
||||
(ajit@ee.udel.edu)</a> IP multicast support
|
||||
|
||||
<br><li>Tomoaki TSURUOKA (tsuruoka@nc.fukuoka-u.ac.jp) TRAK clock driver
|
||||
|
||||
<br><li>Paul A Vixie (vixie@vix.com) TrueTime GPS driver, generic
|
||||
TrueTime clock driver
|
||||
|
||||
</ol>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,26 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.10 1999/07/20 10:53:05 mrg Exp $
|
||||
|
||||
SRCTOP= ../..
|
||||
.include <bsd.crypto.mk>
|
||||
|
||||
LIB= ntp
|
||||
SRCS= utvtoa.c uinttoa.c uglydate.c tvtots.c tvtoa.c tstotv.c \
|
||||
tsftomsu.c systime.c syssignal.c statestr.c refnumtoa.c ranny.c \
|
||||
prettydate.c octtoint.c numtohost.c numtoa.c netof.c msyslog.c \
|
||||
msutotsf.c mstolfp.c modetoa.c mfptoms.c mfptoa.c mexit.c \
|
||||
memmove.c machines.c lib_strbuf.h lib_strbuf.c inttoa.c humandate.c \
|
||||
hextolfp.c hextoint.c getopt.c fptoms.c fptoa.c findconfig.c \
|
||||
emalloc.c dolfptoa.c dofptoa.c decodenetnum.c clocktypes.c clocktime.c \
|
||||
calyearstart.c caltontp.c calleapwhen.c caljulian.c buftvtots.c authusekey.c \
|
||||
authreadkeys.c authparity.c authkeys.c authencrypt.c authdes.c authdecrypt.c \
|
||||
auth12crypt.c atouint.c atolfp.c atoint.c adjtime.c a_md5encrypt.c \
|
||||
a_md5decrypt.c a_md512crypt.c
|
||||
SRCS += version.c
|
||||
|
||||
CPPFLAGS+=-DHAVE_CONFIG_H -I${.CURDIR}/../../usr.sbin/xntp/include
|
||||
|
||||
.if defined(CRYPTOPATH)
|
||||
.sinclude "${CRYPTOPATH}/lib/libntp/Makefile.frag"
|
||||
.endif
|
||||
|
||||
.include <bsd.lib.mk>
|
@ -1,103 +0,0 @@
|
||||
/* $NetBSD: a_md512crypt.c,v 1.6 1999/07/03 12:30:28 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* md5crypt - MD5 based authentication routines
|
||||
*/
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_string.h"
|
||||
#include "md5.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
extern u_int32 cache_keyid;
|
||||
extern char *cache_key;
|
||||
extern int cache_keylen;
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
extern void *memmove P((void *, const void *, size_t));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Stat counters, imported from data base module
|
||||
*/
|
||||
extern u_int32 authencryptions;
|
||||
extern u_int32 authdecryptions;
|
||||
extern u_int32 authkeyuncached;
|
||||
extern u_int32 authnokey;
|
||||
|
||||
/*
|
||||
* For our purposes an NTP packet looks like:
|
||||
*
|
||||
* a variable amount of encrypted data, multiple of 8 bytes, followed by:
|
||||
* NOCRYPT_OCTETS worth of unencrypted data, followed by:
|
||||
* BLOCK_OCTETS worth of ciphered checksum.
|
||||
*/
|
||||
#define NOCRYPT_OCTETS 4
|
||||
#define BLOCK_OCTETS 16
|
||||
|
||||
#define NOCRYPT_int32S ((NOCRYPT_OCTETS)/sizeof(u_int32))
|
||||
#define BLOCK_int32S ((BLOCK_OCTETS)/sizeof(u_int32))
|
||||
|
||||
static MD5_CTX ctx;
|
||||
|
||||
/*
|
||||
* Do first stage of a two stage authenticator generation.
|
||||
*/
|
||||
|
||||
void
|
||||
MD5auth1crypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
u_int32 *pkt;
|
||||
int length; /* length of all encrypted data */
|
||||
{
|
||||
|
||||
authencryptions++;
|
||||
|
||||
if (keyno != cache_keyid) {
|
||||
authkeyuncached++;
|
||||
if (!authhavekey(keyno)) {
|
||||
authnokey++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MD5Init(&ctx);
|
||||
MD5Update(&ctx, (unsigned const char *)cache_key, cache_keylen);
|
||||
MD5Update(&ctx, (unsigned const char *)pkt, length - 8);
|
||||
/* just leave the partially computed value in the static MD5_CTX */
|
||||
}
|
||||
|
||||
/*
|
||||
* Do second state of a two stage authenticator generation.
|
||||
*/
|
||||
int
|
||||
MD5auth2crypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
u_int32 *pkt;
|
||||
int length; /* total length of encrypted area */
|
||||
{
|
||||
#ifdef __NetBSD__
|
||||
unsigned char hash[16];
|
||||
#endif
|
||||
/*
|
||||
* Don't bother checking the keys. The first stage would have
|
||||
* handled that. Finish up the generation by also including the
|
||||
* last 8 bytes of the data area.
|
||||
*/
|
||||
|
||||
MD5Update(&ctx, (unsigned const char *)(pkt) + length - 8, 8);
|
||||
#ifdef __NetBSD__
|
||||
MD5Final(hash, &ctx);
|
||||
#else
|
||||
MD5Final(&ctx);
|
||||
#endif
|
||||
|
||||
memmove((char *) &pkt[NOCRYPT_int32S + length/sizeof(u_int32)],
|
||||
#ifdef __NetBSD__
|
||||
(char *) hash,
|
||||
#else
|
||||
(char *) ctx.digest,
|
||||
#endif
|
||||
BLOCK_OCTETS);
|
||||
return (4 + BLOCK_OCTETS);
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/* $NetBSD: a_md5decrypt.c,v 1.6 1999/07/03 12:30:28 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* md5crypt - MD5 based authentication routines
|
||||
*/
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_string.h"
|
||||
#include "md5.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
extern u_int32 cache_keyid;
|
||||
extern char *cache_key;
|
||||
extern int cache_keylen;
|
||||
|
||||
/*
|
||||
* Stat counters, imported from data base module
|
||||
*/
|
||||
extern u_int32 authencryptions;
|
||||
extern u_int32 authdecryptions;
|
||||
extern u_int32 authkeyuncached;
|
||||
extern u_int32 authnokey;
|
||||
|
||||
/*
|
||||
* For our purposes an NTP packet looks like:
|
||||
*
|
||||
* a variable amount of encrypted data, multiple of 8 bytes, followed by:
|
||||
* NOCRYPT_OCTETS worth of unencrypted data, followed by:
|
||||
* BLOCK_OCTETS worth of ciphered checksum.
|
||||
*/
|
||||
#define NOCRYPT_OCTETS 4
|
||||
#define BLOCK_OCTETS 16
|
||||
|
||||
#define NOCRYPT_int32S ((NOCRYPT_OCTETS)/sizeof(u_int32))
|
||||
#define BLOCK_int32S ((BLOCK_OCTETS)/sizeof(u_int32))
|
||||
|
||||
int
|
||||
MD5authdecrypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
const u_int32 *pkt;
|
||||
int length; /* length of variable data in octets */
|
||||
{
|
||||
MD5_CTX ctx;
|
||||
#ifdef __NetBSD__
|
||||
unsigned char hash[16];
|
||||
#endif
|
||||
|
||||
authdecryptions++;
|
||||
|
||||
if (keyno != cache_keyid) {
|
||||
authkeyuncached++;
|
||||
if (!authhavekey(keyno))
|
||||
return 0;
|
||||
}
|
||||
|
||||
MD5Init(&ctx);
|
||||
MD5Update(&ctx, (unsigned const char *)cache_key, cache_keylen);
|
||||
MD5Update(&ctx, (unsigned const char *)pkt, length);
|
||||
#ifdef __NetBSD__
|
||||
MD5Final(hash, &ctx);
|
||||
#else
|
||||
MD5Final(&ctx);
|
||||
#endif
|
||||
|
||||
return (!memcmp(
|
||||
#ifdef __NetBSD__
|
||||
(const char *) hash,
|
||||
#else
|
||||
(const char *) ctx.digest,
|
||||
#endif
|
||||
(const char *)pkt + length + 4,
|
||||
BLOCK_OCTETS));
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/* $NetBSD: a_md5encrypt.c,v 1.6 1999/07/03 12:30:28 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* md5crypt - MD5 based authentication routines
|
||||
*/
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_string.h"
|
||||
#include "md5.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
extern u_int32 cache_keyid;
|
||||
extern char *cache_key;
|
||||
extern int cache_keylen;
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
extern void *memmove P((void *, const void *, size_t));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Stat counters, imported from data base module
|
||||
*/
|
||||
extern u_int32 authencryptions;
|
||||
extern u_int32 authdecryptions;
|
||||
extern u_int32 authkeyuncached;
|
||||
extern u_int32 authnokey;
|
||||
|
||||
/*
|
||||
* For our purposes an NTP packet looks like:
|
||||
*
|
||||
* a variable amount of encrypted data, multiple of 8 bytes, followed by:
|
||||
* NOCRYPT_OCTETS worth of unencrypted data, followed by:
|
||||
* BLOCK_OCTETS worth of ciphered checksum.
|
||||
*/
|
||||
#define NOCRYPT_OCTETS 4
|
||||
#define BLOCK_OCTETS 16
|
||||
|
||||
#define NOCRYPT_int32S ((NOCRYPT_OCTETS)/sizeof(u_int32))
|
||||
#define BLOCK_int32S ((BLOCK_OCTETS)/sizeof(u_int32))
|
||||
|
||||
|
||||
int
|
||||
MD5authencrypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
u_int32 *pkt;
|
||||
int length; /* length of encrypted portion of packet */
|
||||
{
|
||||
MD5_CTX ctx;
|
||||
int len; /* in 4 byte quantities */
|
||||
#ifdef __NetBSD__
|
||||
unsigned char hash[16];
|
||||
#endif
|
||||
|
||||
authencryptions++;
|
||||
|
||||
if (keyno != cache_keyid) {
|
||||
authkeyuncached++;
|
||||
if (!authhavekey(keyno)) {
|
||||
authnokey++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
len = length / sizeof(u_int32);
|
||||
|
||||
/*
|
||||
* Generate the authenticator.
|
||||
*/
|
||||
MD5Init(&ctx);
|
||||
MD5Update(&ctx, (unsigned const char *)cache_key, cache_keylen);
|
||||
MD5Update(&ctx, (unsigned const char *)pkt, length);
|
||||
#ifdef __NetBSD__
|
||||
MD5Final(hash, &ctx);
|
||||
#else
|
||||
MD5Final(&ctx);
|
||||
#endif
|
||||
|
||||
memmove((char *)&pkt[NOCRYPT_int32S + len],
|
||||
#ifdef __NetBSD__
|
||||
(char *) hash,
|
||||
#else
|
||||
(char *) ctx.digest,
|
||||
#endif
|
||||
BLOCK_OCTETS);
|
||||
return (4 + BLOCK_OCTETS); /* return size of key and MAC */
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
/* $NetBSD: adjtime.c,v 1.2 1998/01/09 03:15:49 perry Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef NEED_HPUX_ADJTIME
|
||||
/*************************************************************************/
|
||||
/* (c) Copyright Tai Jin, 1988. All Rights Reserved. */
|
||||
/* Hewlett-Packard Laboratories. */
|
||||
/* */
|
||||
/* Permission is hereby granted for unlimited modification, use, and */
|
||||
/* distribution. This software is made available with no warranty of */
|
||||
/* any kind, express or implied. This copyright notice must remain */
|
||||
/* intact in all versions of this software. */
|
||||
/* */
|
||||
/* The author would appreciate it if any bug fixes and enhancements were */
|
||||
/* to be sent back to him for incorporation into future versions of this */
|
||||
/* software. Please send changes to tai@iag.hp.com or ken@sdd.hp.com. */
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Revision history
|
||||
*
|
||||
* 9 Jul 94 David L. Mills, Unibergity of Delabunch
|
||||
* Implemented variable threshold to limit age of
|
||||
* corrections; reformatted code for readability.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char RCSid[] = "adjtime.c,v 3.1 1993/07/06 01:04:42 jbj Exp";
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include "adjtime.h"
|
||||
|
||||
#define abs(x) ((x) < 0 ? -(x) : (x))
|
||||
|
||||
/*
|
||||
* The following paramters are appropriate for an NTP adjustment
|
||||
* interval of one second.
|
||||
*/
|
||||
#define ADJ_THRESH 200 /* initial threshold */
|
||||
#define ADJ_DELTA 4 /* threshold decrement */
|
||||
|
||||
static long adjthresh; /* adjustment threshold */
|
||||
static long saveup; /* corrections accumulator */
|
||||
|
||||
/*
|
||||
* clear_adjtime - reset accumulator and threshold variables
|
||||
*/
|
||||
void
|
||||
_clear_adjtime()
|
||||
{
|
||||
saveup = 0;
|
||||
adjthresh = ADJ_THRESH;
|
||||
}
|
||||
|
||||
/*
|
||||
* adjtime - hp-ux copout of the standard Unix adjtime() system call
|
||||
*/
|
||||
int
|
||||
adjtime(delta, olddelta)
|
||||
register struct timeval *delta;
|
||||
register struct timeval *olddelta;
|
||||
{
|
||||
struct timeval newdelta;
|
||||
|
||||
/*
|
||||
* Corrections greater than one second are done immediately.
|
||||
*/
|
||||
if (delta->tv_sec) {
|
||||
adjthresh = ADJ_THRESH;
|
||||
saveup = 0;
|
||||
return(_adjtime(delta, olddelta));
|
||||
}
|
||||
|
||||
/*
|
||||
* Corrections less than one second are accumulated until
|
||||
* tripping a threshold, which is initially set at ADJ_THESH and
|
||||
* reduced in ADJ_DELTA steps to zero. The idea here is to
|
||||
* introduce large corrections quickly, while making sure that
|
||||
* small corrections are introduced without excessive delay. The
|
||||
* idea comes from the ARPAnet routing update algorithm.
|
||||
*/
|
||||
saveup += delta->tv_usec;
|
||||
if (abs(saveup) >= adjthresh) {
|
||||
adjthresh = ADJ_THRESH;
|
||||
newdelta.tv_sec = 0;
|
||||
newdelta.tv_usec = saveup;
|
||||
saveup = 0;
|
||||
return(_adjtime(&newdelta, olddelta));
|
||||
} else {
|
||||
adjthresh -= ADJ_DELTA;
|
||||
}
|
||||
|
||||
/*
|
||||
* While nobody uses it, return the residual before correction,
|
||||
* as per Unix convention.
|
||||
*/
|
||||
if (olddelta)
|
||||
olddelta->tv_sec = olddelta->tv_usec = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* _adjtime - does the actual work
|
||||
*/
|
||||
int
|
||||
_adjtime(delta, olddelta)
|
||||
register struct timeval *delta;
|
||||
register struct timeval *olddelta;
|
||||
{
|
||||
register int mqid;
|
||||
MsgBuf msg;
|
||||
register MsgBuf *msgp = &msg;
|
||||
|
||||
/*
|
||||
* Get the key to the adjtime message queue (note that we must
|
||||
* get it every time because the queue might have been removed
|
||||
* and recreated)
|
||||
*/
|
||||
if ((mqid = msgget(KEY, 0)) == -1)
|
||||
return (-1);
|
||||
msgp->msgb.mtype = CLIENT;
|
||||
msgp->msgb.tv = *delta;
|
||||
if (olddelta)
|
||||
msgp->msgb.code = DELTA2;
|
||||
else
|
||||
msgp->msgb.code = DELTA1;
|
||||
|
||||
/*
|
||||
* Tickle adjtimed and snatch residual, if indicated. Lots of
|
||||
* fanatic error checking here.
|
||||
*/
|
||||
if (msgsnd(mqid, &msgp->msgp, MSGSIZE, 0) == -1)
|
||||
return (-1);
|
||||
if (olddelta) {
|
||||
if (msgrcv(mqid, &msgp->msgp, MSGSIZE, SERVER, 0) == -1)
|
||||
return (-1);
|
||||
*olddelta = msgp->msgb.tv;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
#else /* not NEED_HPUX_ADJTIME */
|
||||
int adjtime_bs;
|
||||
#endif /* not NEED_HPUX_ADJTIME */
|
@ -1,51 +0,0 @@
|
||||
/* $NetBSD: atoint.c,v 1.4 1999/07/03 12:30:28 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* atoint - convert an ascii string to a signed long, with error checking
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
int
|
||||
atoint(str, ival)
|
||||
const char *str;
|
||||
long *ival;
|
||||
{
|
||||
register long u;
|
||||
register const char *cp;
|
||||
register int isneg;
|
||||
register int oflow_digit;
|
||||
|
||||
cp = str;
|
||||
|
||||
if (*cp == '-') {
|
||||
cp++;
|
||||
isneg = 1;
|
||||
oflow_digit = '8';
|
||||
} else {
|
||||
isneg = 0;
|
||||
oflow_digit = '7';
|
||||
}
|
||||
|
||||
if (*cp == '\0')
|
||||
return 0;
|
||||
|
||||
u = 0;
|
||||
while (*cp != '\0') {
|
||||
if (!isdigit(*cp))
|
||||
return 0;
|
||||
if (u > 214748364 || (u == 214748364 && *cp > oflow_digit))
|
||||
return 0; /* overflow */
|
||||
u = (u << 3) + (u << 1);
|
||||
u += *cp++ - '0'; /* ascii dependent */
|
||||
}
|
||||
|
||||
if (isneg)
|
||||
*ival = -u;
|
||||
else
|
||||
*ival = u;
|
||||
return 1;
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
/* $NetBSD: atolfp.c,v 1.5 1999/07/03 12:30:28 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* atolfp - convert an ascii string to an l_fp number
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_string.h"
|
||||
|
||||
/*
|
||||
* Powers of 10
|
||||
*/
|
||||
static u_long ten_to_the_n[10] = {
|
||||
0,
|
||||
10,
|
||||
100,
|
||||
1000,
|
||||
10000,
|
||||
100000,
|
||||
1000000,
|
||||
10000000,
|
||||
100000000,
|
||||
1000000000,
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
atolfp(str, lfp)
|
||||
const char *str;
|
||||
l_fp *lfp;
|
||||
{
|
||||
register const char *cp;
|
||||
register u_long dec_i;
|
||||
register u_long dec_f;
|
||||
char *ind;
|
||||
int ndec;
|
||||
int isneg;
|
||||
static const char *digits = "0123456789";
|
||||
|
||||
isneg = 0;
|
||||
dec_i = dec_f = 0;
|
||||
ndec = 0;
|
||||
cp = str;
|
||||
|
||||
/*
|
||||
* We understand numbers of the form:
|
||||
*
|
||||
* [spaces][-|+][digits][.][digits][spaces|\n|\0]
|
||||
*/
|
||||
while (isspace(*cp))
|
||||
cp++;
|
||||
|
||||
if (*cp == '-') {
|
||||
cp++;
|
||||
isneg = 1;
|
||||
}
|
||||
|
||||
if (*cp == '+')
|
||||
cp++;
|
||||
|
||||
if (*cp != '.' && !isdigit(*cp))
|
||||
return 0;
|
||||
|
||||
while (*cp != '\0' && (ind = strchr(digits, *cp)) != NULL) {
|
||||
dec_i = (dec_i << 3) + (dec_i << 1); /* multiply by 10 */
|
||||
dec_i += (ind - digits);
|
||||
cp++;
|
||||
}
|
||||
|
||||
if (*cp != '\0' && !isspace(*cp)) {
|
||||
if (*cp++ != '.')
|
||||
return 0;
|
||||
|
||||
while (ndec < 9 && *cp != '\0'
|
||||
&& (ind = strchr(digits, *cp)) != NULL) {
|
||||
ndec++;
|
||||
dec_f = (dec_f << 3) + (dec_f << 1); /* *10 */
|
||||
dec_f += (ind - digits);
|
||||
cp++;
|
||||
}
|
||||
|
||||
while (isdigit(*cp))
|
||||
cp++;
|
||||
|
||||
if (*cp != '\0' && !isspace(*cp))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ndec > 0) {
|
||||
register u_long tmp;
|
||||
register u_long bit;
|
||||
register u_long ten_fact;
|
||||
|
||||
ten_fact = ten_to_the_n[ndec];
|
||||
|
||||
tmp = 0;
|
||||
bit = 0x80000000;
|
||||
while (bit != 0) {
|
||||
dec_f <<= 1;
|
||||
if (dec_f >= ten_fact) {
|
||||
tmp |= bit;
|
||||
dec_f -= ten_fact;
|
||||
}
|
||||
bit >>= 1;
|
||||
}
|
||||
if ((dec_f << 1) > ten_fact)
|
||||
tmp++;
|
||||
dec_f = tmp;
|
||||
}
|
||||
|
||||
if (isneg)
|
||||
M_NEG(dec_i, dec_f);
|
||||
|
||||
lfp->l_ui = dec_i;
|
||||
lfp->l_uf = dec_f;
|
||||
return 1;
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
/* $NetBSD: atouint.c,v 1.2 1998/01/09 03:15:52 perry Exp $ */
|
||||
|
||||
/*
|
||||
* atouint - convert an ascii string to an unsigned long, with error checking
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
int
|
||||
atouint(str, uval)
|
||||
const char *str;
|
||||
u_long *uval;
|
||||
{
|
||||
register u_long u;
|
||||
register const char *cp;
|
||||
|
||||
cp = str;
|
||||
if (*cp == '\0')
|
||||
return 0;
|
||||
|
||||
u = 0;
|
||||
while (*cp != '\0') {
|
||||
if (!isdigit(*cp))
|
||||
return 0;
|
||||
if (u > 429496729 || (u == 429496729 && *cp >= '6'))
|
||||
return 0; /* overflow */
|
||||
u = (u << 3) + (u << 1);
|
||||
u += *cp++ - '0'; /* ascii dependent */
|
||||
}
|
||||
|
||||
*uval = u;
|
||||
return 1;
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
/* $NetBSD: auth12crypt.c,v 1.5 1999/07/03 12:30:28 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* auth12crypt.c - routines to support two stage NTP encryption
|
||||
*/
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
/*
|
||||
* For our purposes an NTP packet looks like:
|
||||
*
|
||||
* a variable amount of encrypted data, multiple of 8 bytes, which
|
||||
* is encrypted in pass 1, followed by:
|
||||
* an 8 byte chunk of data which is encrypted in pass 2
|
||||
* NOCRYPT_OCTETS worth of unencrypted data, followed by:
|
||||
* BLOCK_OCTETS worth of ciphered checksum.
|
||||
*/
|
||||
#define NOCRYPT_OCTETS 4
|
||||
#define BLOCK_OCTETS 8
|
||||
|
||||
#define NOCRYPT_int32S ((NOCRYPT_OCTETS)/sizeof(u_int32))
|
||||
#define BLOCK_int32S ((BLOCK_OCTETS)/sizeof(u_int32))
|
||||
|
||||
/*
|
||||
* Imported from the key data base module
|
||||
*/
|
||||
extern u_int32 cache_keyid; /* cached key ID */
|
||||
extern u_int32 DEScache_ekeys[]; /* cached decryption keys */
|
||||
extern u_int32 DESzeroekeys[]; /* zero key decryption keys */
|
||||
|
||||
/*
|
||||
* Stat counters, from the database module
|
||||
*/
|
||||
extern u_int32 authencryptions;
|
||||
extern u_int32 authkeyuncached;
|
||||
extern u_int32 authnokey;
|
||||
|
||||
|
||||
/*
|
||||
* auth1crypt - do the first stage of a two stage encryption
|
||||
*/
|
||||
void
|
||||
DESauth1crypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
u_int32 *pkt;
|
||||
int length; /* length of all encrypted data */
|
||||
{
|
||||
register u_int32 *pd;
|
||||
register int i;
|
||||
register u_char *keys;
|
||||
u_int32 work[2];
|
||||
|
||||
authencryptions++;
|
||||
|
||||
if (keyno == 0) {
|
||||
keys = (u_char *)DESzeroekeys;
|
||||
} else {
|
||||
if (keyno != cache_keyid) {
|
||||
authkeyuncached++;
|
||||
if (!authhavekey(keyno)) {
|
||||
authnokey++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
keys = (u_char *)DEScache_ekeys;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do the first five encryptions. Stick the intermediate result
|
||||
* in the mac field. The sixth encryption must wait until the
|
||||
* caller freezes a transmit time stamp, and will be done in stage 2.
|
||||
*/
|
||||
pd = pkt;
|
||||
work[0] = work[1] = 0;
|
||||
|
||||
for (i = (length/BLOCK_OCTETS - 1); i > 0; i--) {
|
||||
work[0] ^= *pd++;
|
||||
work[1] ^= *pd++;
|
||||
DESauth_des(work, keys);
|
||||
}
|
||||
|
||||
/*
|
||||
* Space to the end of the packet and stick the intermediate
|
||||
* result in the mac field.
|
||||
*/
|
||||
pd += BLOCK_int32S + NOCRYPT_int32S;
|
||||
*pd++ = work[0];
|
||||
*pd = work[1];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* auth2crypt - do the second stage of a two stage encryption
|
||||
*/
|
||||
int
|
||||
DESauth2crypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
u_int32 *pkt;
|
||||
int length; /* total length of encrypted area */
|
||||
{
|
||||
register u_int32 *pd;
|
||||
register u_char *keys;
|
||||
|
||||
/*
|
||||
* Skip the key check. The call to the first stage should
|
||||
* have got it.
|
||||
*/
|
||||
if (keyno == 0)
|
||||
keys = (u_char *)DESzeroekeys;
|
||||
else
|
||||
keys = (u_char *)DEScache_ekeys;
|
||||
|
||||
/*
|
||||
* The mac currently should hold the results of the first `n'
|
||||
* encryptions. We xor in the last block in data section and
|
||||
* do the final encryption in place.
|
||||
*
|
||||
* Get a pointer to the MAC block. XOR in the last two words of
|
||||
* the data area. Call the encryption routine.
|
||||
*/
|
||||
pd = pkt + (length/sizeof(u_int32)) + NOCRYPT_int32S;
|
||||
|
||||
*pd ^= *(pd - NOCRYPT_int32S - 2);
|
||||
*(pd + 1) ^= *(pd - NOCRYPT_int32S - 1);
|
||||
DESauth_des(pd, keys);
|
||||
|
||||
return 4 + 8; /* return size of key number and MAC */
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
/* $NetBSD: authdecrypt.c,v 1.5 1999/07/03 12:30:28 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* authdecrypt - routine to decrypt a packet to see if this guy knows our key.
|
||||
*/
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
/*
|
||||
* For our purposes an NTP packet looks like:
|
||||
*
|
||||
* a variable amount of unencrypted data, multiple of 8 bytes, followed by:
|
||||
* NOCRYPT_OCTETS worth of unencrypted data, followed by:
|
||||
* BLOCK_OCTETS worth of ciphered checksum.
|
||||
*/
|
||||
#define NOCRYPT_OCTETS 4
|
||||
#define BLOCK_OCTETS 8
|
||||
|
||||
#define NOCRYPT_int32S ((NOCRYPT_OCTETS)/sizeof(u_int32))
|
||||
#define BLOCK_int32S ((BLOCK_OCTETS)/sizeof(u_int32))
|
||||
|
||||
/*
|
||||
* Imported from the key data base module
|
||||
*/
|
||||
extern u_int32 cache_keyid; /* cached key ID */
|
||||
extern u_int32 DEScache_dkeys[]; /* cached decryption keys */
|
||||
extern u_int32 DESzerodkeys[]; /* zero key decryption keys */
|
||||
|
||||
/*
|
||||
* Stat counters, imported from data base module
|
||||
*/
|
||||
extern u_int32 authdecryptions;
|
||||
extern u_int32 authkeyuncached;
|
||||
|
||||
int
|
||||
DESauthdecrypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
const u_int32 *pkt;
|
||||
int length; /* length of variable data in octets */
|
||||
{
|
||||
register const u_int32 *pd;
|
||||
register int i;
|
||||
register u_char *keys;
|
||||
register int longlen;
|
||||
u_int32 work[2];
|
||||
|
||||
authdecryptions++;
|
||||
|
||||
if (keyno == 0)
|
||||
keys = (u_char *)DESzerodkeys;
|
||||
else {
|
||||
if (keyno != cache_keyid) {
|
||||
authkeyuncached++;
|
||||
if (!authhavekey(keyno))
|
||||
return 0;
|
||||
}
|
||||
keys = (u_char *)DEScache_dkeys;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get encryption block data in host byte order and decrypt it.
|
||||
*/
|
||||
longlen = length / sizeof(u_int32);
|
||||
pd = pkt + longlen; /* points at NOCRYPT area */
|
||||
work[0] = *(pd + NOCRYPT_int32S);
|
||||
work[1] = *(pd + NOCRYPT_int32S + 1);
|
||||
|
||||
if (longlen & 0x1) {
|
||||
DESauth_des(work, keys);
|
||||
work[0] ^= *(--pd);
|
||||
}
|
||||
|
||||
for (i = longlen/2; i > 0; i--) {
|
||||
DESauth_des(work, keys);
|
||||
work[1] ^= *(--pd);
|
||||
work[0] ^= *(--pd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Success if the encryption data is zero
|
||||
*/
|
||||
if ((work[0] == 0) && (work[1] == 0))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/* $NetBSD: authdes.c,v 1.4 1999/07/03 12:30:29 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* authdes.c - dummy encryption routines for destinations outside the USA.
|
||||
*
|
||||
* Sorry, folks; I hate this, too. Send me your e-mail address in an
|
||||
* envelope bearing a US postmark and I'll send you the decryption key
|
||||
* for the des program normally distributed with Unix in the USA. Outside
|
||||
* the USA you are on your own; however, you should be able quickly to
|
||||
* obtain the source from lots of places, homegrown or otherwise.
|
||||
*
|
||||
* to decrypt the des routine, mumble the following:
|
||||
*
|
||||
* des -d -k key authdes.c.des authdes.c
|
||||
*
|
||||
* , where key is as above, and rebuild. To restore the distribution
|
||||
* to its exportable state, copy this file to authdes.c .
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
/*
|
||||
* This routine is normally called to compute the key schedule.
|
||||
*/
|
||||
void
|
||||
DESauth_subkeys(key, encryptkeys, decryptkeys)
|
||||
const u_int32 *key;
|
||||
u_char *encryptkeys;
|
||||
u_char *decryptkeys;
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine is normally called to encrypt and decrypt the data. This
|
||||
* is done in-place using the Digital Encryption Standard (DES) Cipher-
|
||||
* Block Chaining (CBC) method as described in the NTP specification.
|
||||
*/
|
||||
void
|
||||
DESauth_des(data, subkeys)
|
||||
u_int32 *data;
|
||||
u_char *subkeys;
|
||||
{
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
/* $NetBSD: authencrypt.c,v 1.5 1999/07/03 12:30:29 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* authencrypt - compute and encrypt the mac field in an NTP packet
|
||||
*/
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
/*
|
||||
* For our purposes an NTP packet looks like:
|
||||
*
|
||||
* a variable amount of encrypted data, multiple of 8 bytes, followed by:
|
||||
* NOCRYPT_OCTETS worth of unencrypted data, followed by:
|
||||
* BLOCK_OCTETS worth of ciphered checksum.
|
||||
*/
|
||||
#define NOCRYPT_OCTETS 4
|
||||
#define BLOCK_OCTETS 8
|
||||
|
||||
#define NOCRYPT_int32S ((NOCRYPT_OCTETS)/sizeof(u_int32))
|
||||
#define BLOCK_int32S ((BLOCK_OCTETS)/sizeof(u_int32))
|
||||
|
||||
/*
|
||||
* Imported from the key data base module
|
||||
*/
|
||||
extern u_int32 cache_keyid; /* cached key ID */
|
||||
extern u_int32 DEScache_ekeys[]; /* cached decryption keys */
|
||||
extern u_int32 DESzeroekeys[]; /* zero key decryption keys */
|
||||
|
||||
/*
|
||||
* Stat counters from the database module
|
||||
*/
|
||||
extern u_int32 authencryptions;
|
||||
extern u_int32 authkeyuncached;
|
||||
extern u_int32 authnokey;
|
||||
|
||||
int
|
||||
DESauthencrypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
u_int32 *pkt;
|
||||
int length; /* length of encrypted portion of packet */
|
||||
{
|
||||
register u_int32 *pd;
|
||||
register int i;
|
||||
register u_char *keys;
|
||||
register int len;
|
||||
u_int32 work[2];
|
||||
|
||||
authencryptions++;
|
||||
|
||||
if (keyno == 0) {
|
||||
keys = (u_char *)DESzeroekeys;
|
||||
} else {
|
||||
if (keyno != cache_keyid) {
|
||||
authkeyuncached++;
|
||||
if (!authhavekey(keyno)) {
|
||||
authnokey++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
keys = (u_char *)DEScache_ekeys;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do the encryption. Work our way forward in the packet, eight
|
||||
* bytes at a time, encrypting as we go. Note that the byte order
|
||||
* issues are handled by the DES routine itself
|
||||
*/
|
||||
pd = pkt;
|
||||
work[0] = work[1] = 0;
|
||||
len = length / sizeof(u_int32);
|
||||
|
||||
for (i = (len/2); i > 0; i--) {
|
||||
work[0] ^= *pd++;
|
||||
work[1] ^= *pd++;
|
||||
DESauth_des(work, keys);
|
||||
}
|
||||
|
||||
if (len & 0x1) {
|
||||
work[0] ^= *pd++;
|
||||
DESauth_des(work, keys);
|
||||
}
|
||||
|
||||
/*
|
||||
* Space past the keyid and stick the result back in the mac field
|
||||
*/
|
||||
pd += NOCRYPT_int32S;
|
||||
*pd++ = work[0];
|
||||
*pd = work[1];
|
||||
|
||||
return 4 + BLOCK_OCTETS; /* return size of key and MAC */
|
||||
}
|
@ -1,613 +0,0 @@
|
||||
/* $NetBSD: authkeys.c,v 1.6 1999/07/03 12:30:29 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* authkeys.c - routines to manage the storage of authentication keys
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_string.h"
|
||||
#include "ntp_malloc.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
/*
|
||||
* Structure to store keys in in the hash table.
|
||||
*/
|
||||
struct savekey {
|
||||
struct savekey *next;
|
||||
union {
|
||||
long bogon; /* Make sure union isn't empty... */
|
||||
#ifdef DES
|
||||
u_int32 DES_key[2];
|
||||
#endif
|
||||
#ifdef MD5
|
||||
char MD5_key[32];
|
||||
#endif
|
||||
} k;
|
||||
u_int32 keyid;
|
||||
u_short flags;
|
||||
#ifdef MD5
|
||||
int keylen;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define KEY_TRUSTED 0x1 /* this key is trusted */
|
||||
#define KEY_KNOWN 0x2 /* this key is known */
|
||||
|
||||
#ifdef DES
|
||||
#define KEY_DES 0x100 /* this is a DES type key */
|
||||
#endif
|
||||
|
||||
#ifdef MD5
|
||||
#define KEY_MD5 0x200 /* this is a MD5 type key */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The hash table. This is indexed by the low order bits of the
|
||||
* keyid. We make this fairly big for potentially busy servers.
|
||||
*/
|
||||
#define HASHSIZE 64
|
||||
#define HASHMASK ((HASHSIZE)-1)
|
||||
#define KEYHASH(keyid) ((keyid) & HASHMASK)
|
||||
|
||||
struct savekey *key_hash[HASHSIZE];
|
||||
|
||||
u_int32 authkeynotfound;
|
||||
u_int32 authkeylookups;
|
||||
u_int32 authnumkeys;
|
||||
u_int32 authuncached;
|
||||
u_int32 authkeyuncached;
|
||||
u_int32 authnokey; /* calls to encrypt with no key */
|
||||
u_int32 authencryptions;
|
||||
u_int32 authdecryptions;
|
||||
|
||||
/*
|
||||
* Storage for free key structures. We malloc() such things but
|
||||
* never free them.
|
||||
*/
|
||||
struct savekey *authfreekeys;
|
||||
int authnumfreekeys;
|
||||
|
||||
#define MEMINC 12 /* number of new free ones to get at once */
|
||||
|
||||
|
||||
#ifdef DES
|
||||
/*
|
||||
* Size of the key schedule (in u_int32s for fast DES)
|
||||
*/
|
||||
#define KEY_SCHED_SIZE ((128+sizeof(u_int32)-1)/sizeof(u_int32))
|
||||
|
||||
/*
|
||||
* The zero key, which we always have. Store the permutted key
|
||||
* zero in here.
|
||||
*/
|
||||
#define ZEROKEY_L 0x01010101 /* odd parity zero key */
|
||||
#define ZEROKEY_R 0x01010101 /* right half of same */
|
||||
/*
|
||||
* fast DES code expects base address aligned to u_long
|
||||
*/
|
||||
u_int32 DESzeroekeys[KEY_SCHED_SIZE];
|
||||
u_int32 DESzerodkeys[KEY_SCHED_SIZE];
|
||||
u_int32 DEScache_ekeys[KEY_SCHED_SIZE];
|
||||
u_int32 DEScache_dkeys[KEY_SCHED_SIZE];
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The key cache. We cache the last key we looked at here.
|
||||
*/
|
||||
u_int32 cache_keyid;
|
||||
u_short cache_flags;
|
||||
|
||||
#ifdef MD5
|
||||
int cache_keylen;
|
||||
char *cache_key;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* init_auth - initialize internal data
|
||||
*/
|
||||
void
|
||||
init_auth()
|
||||
{
|
||||
#ifdef DES
|
||||
u_int32 zerokey[2];
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initialize hash table and free list
|
||||
*/
|
||||
memset((char *)key_hash, 0, sizeof key_hash);
|
||||
cache_keyid = 0;
|
||||
cache_flags = 0;
|
||||
|
||||
authnumfreekeys = authkeynotfound = authkeylookups = 0;
|
||||
authnumkeys = authuncached = authkeyuncached = authnokey = 0;
|
||||
authencryptions = authdecryptions = 0;
|
||||
|
||||
#ifdef DES
|
||||
/*
|
||||
* Initialize the zero key
|
||||
*/
|
||||
zerokey[0] = ZEROKEY_L;
|
||||
zerokey[1] = ZEROKEY_R;
|
||||
/* could just zero all */
|
||||
DESauth_subkeys(zerokey, (u_char *)DESzeroekeys, (u_char *)DESzerodkeys);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* auth_findkey - find a key in the hash table
|
||||
*/
|
||||
struct savekey *
|
||||
auth_findkey(keyno)
|
||||
u_int32 keyno;
|
||||
{
|
||||
register struct savekey *sk;
|
||||
|
||||
sk = key_hash[KEYHASH(keyno)];
|
||||
while (sk != 0) {
|
||||
if (keyno == sk->keyid)
|
||||
return sk;
|
||||
sk = sk->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* auth_havekey - return whether a key is known
|
||||
*/
|
||||
int
|
||||
auth_havekey(keyno)
|
||||
u_int32 keyno;
|
||||
{
|
||||
register struct savekey *sk;
|
||||
|
||||
if (keyno == 0 || (keyno == cache_keyid))
|
||||
return 1;
|
||||
|
||||
sk = key_hash[KEYHASH(keyno)];
|
||||
while (sk != 0) {
|
||||
if (keyno == sk->keyid) {
|
||||
if (sk->flags & KEY_KNOWN)
|
||||
return 1;
|
||||
else {
|
||||
authkeynotfound++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
sk = sk->next;
|
||||
}
|
||||
authkeynotfound++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* authhavekey - return whether a key is known. Permute and cache
|
||||
* the key as a side effect.
|
||||
*/
|
||||
int
|
||||
authhavekey(keyno)
|
||||
u_int32 keyno;
|
||||
{
|
||||
register struct savekey *sk;
|
||||
|
||||
authkeylookups++;
|
||||
if (keyno == 0 || keyno == cache_keyid)
|
||||
return 1;
|
||||
|
||||
sk = key_hash[KEYHASH(keyno)];
|
||||
while (sk != 0) {
|
||||
if (keyno == sk->keyid)
|
||||
break;
|
||||
sk = sk->next;
|
||||
}
|
||||
|
||||
if (sk == 0 || !(sk->flags & KEY_KNOWN)) {
|
||||
authkeynotfound++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
cache_keyid = sk->keyid;
|
||||
cache_flags = sk->flags;
|
||||
#ifdef MD5
|
||||
if (sk->flags & KEY_MD5) {
|
||||
cache_keylen = sk->keylen;
|
||||
cache_key = (char *) sk->k.MD5_key; /* XXX */
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DES
|
||||
if (sk->flags & KEY_DES) {
|
||||
DESauth_subkeys(sk->k.DES_key, (u_char *)DEScache_ekeys, (u_char *)DEScache_dkeys);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* auth_moremem - get some more free key structures
|
||||
*/
|
||||
int
|
||||
auth_moremem()
|
||||
{
|
||||
register struct savekey *sk;
|
||||
register int i;
|
||||
|
||||
sk = (struct savekey *)malloc(MEMINC * sizeof(struct savekey));
|
||||
if (sk == 0)
|
||||
return 0;
|
||||
|
||||
for (i = MEMINC; i > 0; i--) {
|
||||
sk->next = authfreekeys;
|
||||
authfreekeys = sk++;
|
||||
}
|
||||
authnumfreekeys += MEMINC;
|
||||
return authnumfreekeys;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* authtrust - declare a key to be trusted/untrusted
|
||||
*/
|
||||
void
|
||||
authtrust(keyno, trust)
|
||||
u_int32 keyno;
|
||||
int trust;
|
||||
{
|
||||
register struct savekey *sk;
|
||||
|
||||
sk = key_hash[KEYHASH(keyno)];
|
||||
while (sk != 0) {
|
||||
if (keyno == sk->keyid)
|
||||
break;
|
||||
sk = sk->next;
|
||||
}
|
||||
|
||||
if (sk == 0 && !trust)
|
||||
return;
|
||||
|
||||
if (sk != 0) {
|
||||
if (cache_keyid == keyno) {
|
||||
cache_flags = 0;
|
||||
cache_keyid = 0;
|
||||
}
|
||||
|
||||
if (trust) {
|
||||
sk->flags |= KEY_TRUSTED;
|
||||
return;
|
||||
}
|
||||
|
||||
sk->flags &= ~KEY_TRUSTED;
|
||||
if (!(sk->flags & KEY_KNOWN)) {
|
||||
register struct savekey *skp;
|
||||
|
||||
skp = key_hash[KEYHASH(keyno)];
|
||||
if (skp == sk) {
|
||||
key_hash[KEYHASH(keyno)] = sk->next;
|
||||
} else {
|
||||
while (skp->next != sk)
|
||||
skp = skp->next;
|
||||
skp->next = sk->next;
|
||||
}
|
||||
authnumkeys--;
|
||||
|
||||
sk->next = authfreekeys;
|
||||
authfreekeys = sk;
|
||||
authnumfreekeys++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (authnumfreekeys == 0)
|
||||
if (auth_moremem() == 0)
|
||||
return;
|
||||
|
||||
sk = authfreekeys;
|
||||
authfreekeys = sk->next;
|
||||
authnumfreekeys--;
|
||||
|
||||
sk->keyid = keyno;
|
||||
sk->flags = KEY_TRUSTED;
|
||||
sk->next = key_hash[KEYHASH(keyno)];
|
||||
key_hash[KEYHASH(keyno)] = sk;
|
||||
authnumkeys++;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* authistrusted - determine whether a key is trusted
|
||||
*/
|
||||
int
|
||||
authistrusted(keyno)
|
||||
u_int32 keyno;
|
||||
{
|
||||
register struct savekey *sk;
|
||||
|
||||
if (keyno == cache_keyid)
|
||||
return ((cache_flags & KEY_TRUSTED) != 0);
|
||||
|
||||
authkeyuncached++;
|
||||
|
||||
sk = key_hash[KEYHASH(keyno)];
|
||||
while (sk != 0) {
|
||||
if (keyno == sk->keyid)
|
||||
break;
|
||||
sk = sk->next;
|
||||
}
|
||||
|
||||
if (sk == 0 || !(sk->flags & KEY_TRUSTED))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef DES
|
||||
/*
|
||||
* DESauth_setkey - set a key into the key array
|
||||
*/
|
||||
void
|
||||
DESauth_setkey(keyno, key)
|
||||
u_int32 keyno;
|
||||
const u_int32 *key;
|
||||
{
|
||||
register struct savekey *sk;
|
||||
|
||||
/*
|
||||
* See if we already have the key. If so just stick in the
|
||||
* new value.
|
||||
*/
|
||||
sk = key_hash[KEYHASH(keyno)];
|
||||
while (sk != 0) {
|
||||
if (keyno == sk->keyid) {
|
||||
sk->k.DES_key[0] = key[0];
|
||||
sk->k.DES_key[1] = key[1];
|
||||
sk->flags |= KEY_KNOWN | KEY_DES;
|
||||
if (cache_keyid == keyno)
|
||||
cache_flags = 0;
|
||||
cache_keyid = 0;
|
||||
return;
|
||||
}
|
||||
sk = sk->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* Need to allocate new structure. Do it.
|
||||
*/
|
||||
if (authnumfreekeys == 0) {
|
||||
if (auth_moremem() == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
sk = authfreekeys;
|
||||
authfreekeys = sk->next;
|
||||
authnumfreekeys--;
|
||||
|
||||
sk->k.DES_key[0] = key[0];
|
||||
sk->k.DES_key[1] = key[1];
|
||||
sk->keyid = keyno;
|
||||
sk->flags = KEY_KNOWN | KEY_DES;
|
||||
sk->next = key_hash[KEYHASH(keyno)];
|
||||
key_hash[KEYHASH(keyno)] = sk;
|
||||
authnumkeys++;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MD5
|
||||
void
|
||||
MD5auth_setkey(keyno, key)
|
||||
u_int32 keyno;
|
||||
const u_int32 *key;
|
||||
{
|
||||
register struct savekey *sk;
|
||||
|
||||
/*
|
||||
* See if we already have the key. If so just stick in the
|
||||
* new value.
|
||||
*/
|
||||
sk = key_hash[KEYHASH(keyno)];
|
||||
while (sk != 0) {
|
||||
if (keyno == sk->keyid) {
|
||||
strncpy(sk->k.MD5_key, (const char *)key, sizeof(sk->k.MD5_key));
|
||||
if ((sk->keylen = strlen((const char *)key)) >
|
||||
sizeof(sk->k.MD5_key))
|
||||
sk->keylen = sizeof(sk->k.MD5_key);
|
||||
|
||||
sk->flags |= KEY_KNOWN | KEY_MD5;
|
||||
if (cache_keyid == keyno) {
|
||||
cache_flags = 0;
|
||||
cache_keyid = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
sk = sk->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* Need to allocate new structure. Do it.
|
||||
*/
|
||||
if (authnumfreekeys == 0) {
|
||||
if (auth_moremem() == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
sk = authfreekeys;
|
||||
authfreekeys = sk->next;
|
||||
authnumfreekeys--;
|
||||
|
||||
strncpy(sk->k.MD5_key, (const char *)key, sizeof(sk->k.MD5_key));
|
||||
if ((sk->keylen = strlen((const char *)key)) > sizeof(sk->k.MD5_key))
|
||||
sk->keylen = sizeof(sk->k.MD5_key);
|
||||
|
||||
sk->keyid = keyno;
|
||||
sk->flags = KEY_KNOWN | KEY_MD5;
|
||||
sk->next = key_hash[KEYHASH(keyno)];
|
||||
key_hash[KEYHASH(keyno)] = sk;
|
||||
authnumkeys++;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* auth_delkeys - delete all known keys, in preparation for rereading
|
||||
* the keys file (presumably)
|
||||
*/
|
||||
void
|
||||
auth_delkeys()
|
||||
{
|
||||
register struct savekey *sk;
|
||||
register struct savekey **skp;
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < HASHSIZE; i++) {
|
||||
skp = &(key_hash[i]);
|
||||
sk = key_hash[i];
|
||||
while (sk != 0) {
|
||||
sk->flags &= ~(KEY_KNOWN
|
||||
#ifdef MD5
|
||||
| KEY_MD5
|
||||
#endif
|
||||
#ifdef DES
|
||||
| KEY_DES
|
||||
#endif
|
||||
);
|
||||
if (sk->flags == 0) {
|
||||
*skp = sk->next;
|
||||
authnumkeys--;
|
||||
sk->next = authfreekeys;
|
||||
authfreekeys = sk;
|
||||
authnumfreekeys++;
|
||||
sk = *skp;
|
||||
} else {
|
||||
skp = &(sk->next);
|
||||
sk = sk->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* auth1crypt - support for two stage encryption, part 1.
|
||||
*/
|
||||
void
|
||||
auth1crypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
u_int32 *pkt;
|
||||
int length; /* length of all encrypted data */
|
||||
{
|
||||
if (keyno && keyno != cache_keyid) {
|
||||
authkeyuncached++;
|
||||
if (!authhavekey(keyno)) {
|
||||
authnokey++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DES
|
||||
if (!keyno || (cache_flags & KEY_DES)) {
|
||||
DESauth1crypt(keyno, pkt, length);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MD5
|
||||
if (cache_flags & KEY_MD5) {
|
||||
MD5auth1crypt(keyno, pkt, length);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* auth2crypt - support for two stage encryption, part 2.
|
||||
*/
|
||||
int
|
||||
auth2crypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
u_int32 *pkt;
|
||||
int length; /* total length of encrypted area */
|
||||
{
|
||||
if (keyno && keyno != cache_keyid) {
|
||||
authkeyuncached++;
|
||||
if (!authhavekey(keyno)) {
|
||||
authnokey++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DES
|
||||
if (!keyno || (cache_flags & KEY_DES))
|
||||
return DESauth2crypt(keyno, pkt, length);
|
||||
#endif
|
||||
|
||||
#ifdef MD5
|
||||
if (cache_flags & KEY_MD5)
|
||||
return MD5auth2crypt(keyno, pkt, length);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
authencrypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
u_int32 *pkt;
|
||||
int length; /* length of encrypted portion of packet */
|
||||
{
|
||||
if (keyno && keyno != cache_keyid) {
|
||||
authkeyuncached++;
|
||||
if (!authhavekey(keyno)) {
|
||||
authnokey++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DES
|
||||
if (!keyno || (cache_flags & KEY_DES))
|
||||
return DESauthencrypt(keyno, pkt, length);
|
||||
#endif
|
||||
|
||||
#ifdef MD5
|
||||
if (cache_flags & KEY_MD5)
|
||||
return MD5authencrypt(keyno, pkt, length);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
authdecrypt(keyno, pkt, length)
|
||||
u_int32 keyno;
|
||||
u_int32 *pkt;
|
||||
int length; /* length of variable data in octets */
|
||||
{
|
||||
if (keyno && (keyno != cache_keyid)) {
|
||||
authkeyuncached++;
|
||||
if (!authhavekey(keyno)) {
|
||||
authnokey++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DES
|
||||
if (!keyno || (cache_flags & KEY_DES))
|
||||
return DESauthdecrypt(keyno, pkt, length);
|
||||
#endif
|
||||
|
||||
#ifdef MD5
|
||||
if (cache_flags & KEY_MD5)
|
||||
return MD5authdecrypt(keyno, pkt, length);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/* $NetBSD: authparity.c,v 1.2 1998/01/09 03:15:57 perry Exp $ */
|
||||
|
||||
/*
|
||||
* auth_parity - set parity on a key/check for odd parity
|
||||
*/
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
int
|
||||
DESauth_parity(key)
|
||||
u_int32 *key;
|
||||
{
|
||||
u_int32 mask;
|
||||
int parity_err;
|
||||
int bitcount;
|
||||
int half;
|
||||
int byte;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Go through counting bits in each byte. Check to see if
|
||||
* each parity bit was set correctly. If not, note the error
|
||||
* and set it right.
|
||||
*/
|
||||
parity_err = 0;
|
||||
for (half = 0; half < 2; half++) { /* two halves of key */
|
||||
mask = 0x80000000;
|
||||
for (byte = 0; byte < 4; byte++) { /* 4 bytes per half */
|
||||
bitcount = 0;
|
||||
for (i = 0; i < 7; i++) { /* 7 data bits / byte */
|
||||
if (key[half] & mask)
|
||||
bitcount++;
|
||||
mask >>= 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* If bitcount is even, parity must be set. If
|
||||
* bitcount is odd, parity must be clear.
|
||||
*/
|
||||
if ((bitcount & 0x1) == 0) {
|
||||
if (!(key[half] & mask)) {
|
||||
parity_err++;
|
||||
key[half] |= mask;
|
||||
}
|
||||
} else {
|
||||
if (key[half] & mask) {
|
||||
parity_err++;
|
||||
key[half] &= ~mask;
|
||||
}
|
||||
}
|
||||
mask >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the result of the parity check.
|
||||
*/
|
||||
return (parity_err == 0);
|
||||
}
|
||||
|
||||
|
@ -1,198 +0,0 @@
|
||||
/* $NetBSD: authreadkeys.c,v 1.5 1999/07/03 12:30:29 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* authreadkeys.c - routines to support the reading of the key file
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ntp_stdlib.h"
|
||||
#include "ntp_syslog.h"
|
||||
|
||||
#ifdef DES
|
||||
/*
|
||||
* Types of ascii representations for keys. "Standard" means a 64 bit
|
||||
* hex number in NBS format, i.e. with the low order bit of each byte
|
||||
* a parity bit. "NTP" means a 64 bit key in NTP format, with the
|
||||
* high order bit of each byte a parity bit. "Ascii" means a 1-to-8
|
||||
* character string whose ascii representation is used as the key.
|
||||
*/
|
||||
#define KEY_TYPE_STD 1
|
||||
#define KEY_TYPE_NTP 2
|
||||
#define KEY_TYPE_ASCII 3
|
||||
#endif
|
||||
|
||||
#ifdef MD5
|
||||
/*
|
||||
* Arbitrary long string of ASCII characters.
|
||||
*/
|
||||
#define KEY_TYPE_MD5 4
|
||||
#endif
|
||||
|
||||
/* Forwards */
|
||||
static char *nexttok P((char **));
|
||||
|
||||
/*
|
||||
* nexttok - basic internal tokenizing routine
|
||||
*/
|
||||
static char *
|
||||
nexttok(str)
|
||||
char **str;
|
||||
{
|
||||
register char *cp;
|
||||
char *starttok;
|
||||
|
||||
cp = *str;
|
||||
|
||||
/*
|
||||
* Space past white space
|
||||
*/
|
||||
while (*cp == ' ' || *cp == '\t')
|
||||
cp++;
|
||||
|
||||
/*
|
||||
* Save this and space to end of token
|
||||
*/
|
||||
starttok = cp;
|
||||
while (*cp != '\0' && *cp != '\n' && *cp != ' '
|
||||
&& *cp != '\t' && *cp != '#')
|
||||
cp++;
|
||||
|
||||
/*
|
||||
* If token length is zero return an error, else set end of
|
||||
* token to zero and return start.
|
||||
*/
|
||||
if (starttok == cp)
|
||||
return 0;
|
||||
|
||||
if (*cp == ' ' || *cp == '\t')
|
||||
*cp++ = '\0';
|
||||
else
|
||||
*cp = '\0';
|
||||
|
||||
*str = cp;
|
||||
return starttok;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* authreadkeys - (re)read keys from a file.
|
||||
*/
|
||||
int
|
||||
authreadkeys(file)
|
||||
const char *file;
|
||||
{
|
||||
FILE *fp;
|
||||
char *line;
|
||||
char *token;
|
||||
u_int32 keyno;
|
||||
int keytype;
|
||||
char buf[512]; /* lots of room for line? */
|
||||
#if !defined(VMS) /* wjm - what are these lines doing here? */
|
||||
extern FILE * fopen P((const char *filename, const char *type));
|
||||
extern int fclose P((FILE *stream));
|
||||
#endif /* !VMS */
|
||||
|
||||
/*
|
||||
* Open file. Complain and return if it can't be opened.
|
||||
*/
|
||||
fp = fopen(file, "r");
|
||||
if (fp == NULL) {
|
||||
msyslog(LOG_ERR, "can't open key file %s: %m", file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove all existing keys
|
||||
*/
|
||||
auth_delkeys();
|
||||
|
||||
/*
|
||||
* Now read lines from the file, looking for key entries
|
||||
*/
|
||||
while ((line = fgets(buf, sizeof buf, fp)) != NULL) {
|
||||
token = nexttok(&line);
|
||||
if (token == 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* First is key number. See if it is okay.
|
||||
*/
|
||||
keyno = atoi(token);
|
||||
if (keyno == 0) {
|
||||
msyslog(LOG_ERR,
|
||||
"cannot change keyid 0, key entry `%s' ignored",
|
||||
token);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Next is keytype. See if that is all right.
|
||||
*/
|
||||
token = nexttok(&line);
|
||||
if (token == 0) {
|
||||
msyslog(LOG_ERR,
|
||||
"no key type for key number %ld, entry ignored",
|
||||
keyno);
|
||||
continue;
|
||||
}
|
||||
switch (*token) {
|
||||
#ifdef DES
|
||||
case 'S':
|
||||
case 's':
|
||||
keytype = KEY_TYPE_STD; break;
|
||||
|
||||
case 'N':
|
||||
case 'n':
|
||||
keytype = KEY_TYPE_NTP; break;
|
||||
|
||||
case 'A':
|
||||
case 'a':
|
||||
keytype = KEY_TYPE_ASCII; break;
|
||||
#endif
|
||||
#ifdef MD5
|
||||
case 'M':
|
||||
case 'm':
|
||||
keytype = KEY_TYPE_MD5; break;
|
||||
#endif
|
||||
default:
|
||||
msyslog(LOG_ERR,
|
||||
"invalid key type for key number %ld, entry ignored",
|
||||
keyno);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Finally, get key and insert it
|
||||
*/
|
||||
token = nexttok(&line);
|
||||
if (token == 0) {
|
||||
msyslog(LOG_ERR,
|
||||
"no key for number %ld entry, entry ignored",
|
||||
keyno);
|
||||
} else {
|
||||
switch(keytype) {
|
||||
#ifdef DES
|
||||
case KEY_TYPE_STD:
|
||||
case KEY_TYPE_NTP:
|
||||
case KEY_TYPE_ASCII:
|
||||
if (!authusekey(keyno, keytype, token))
|
||||
msyslog(LOG_ERR,
|
||||
"format/parity error for DES key %ld, not used",
|
||||
keyno);
|
||||
break;
|
||||
#endif
|
||||
#ifdef MD5
|
||||
case KEY_TYPE_MD5:
|
||||
if (!authusekey(keyno, keytype, token))
|
||||
msyslog(LOG_ERR,
|
||||
"format/parity error for MD5 key %ld, not used",
|
||||
keyno);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
(void) fclose(fp);
|
||||
return 1;
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
/* $NetBSD: authusekey.c,v 1.5 1999/07/03 12:30:29 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* authusekey - decode a key from ascii and use it
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_string.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
/*
|
||||
* Types of ascii representations for keys. "Standard" means a 64 bit
|
||||
* hex number in NBS format, i.e. with the low order bit of each byte
|
||||
* a parity bit. "NTP" means a 64 bit key in NTP format, with the
|
||||
* high order bit of each byte a parity bit. "Ascii" means a 1-to-8
|
||||
* character string whose ascii representation is used as the key.
|
||||
*/
|
||||
#ifdef DES
|
||||
#define KEY_TYPE_STD 1
|
||||
#define KEY_TYPE_NTP 2
|
||||
#define KEY_TYPE_ASCII 3
|
||||
|
||||
#define STD_PARITY_BITS 0x01010101
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MD5
|
||||
#define KEY_TYPE_MD5 4
|
||||
#endif
|
||||
|
||||
int
|
||||
authusekey(keyno, keytype, str)
|
||||
u_int32 keyno;
|
||||
int keytype;
|
||||
const char *str;
|
||||
{
|
||||
#ifdef DES
|
||||
u_int32 key[2];
|
||||
u_char keybytes[8];
|
||||
char *xdigit;
|
||||
int i;
|
||||
static const char *hex = "0123456789abcdef";
|
||||
#endif
|
||||
const char *cp;
|
||||
int len;
|
||||
|
||||
cp = str;
|
||||
len = strlen(cp);
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
switch(keytype) {
|
||||
#ifdef DES
|
||||
case KEY_TYPE_STD:
|
||||
case KEY_TYPE_NTP:
|
||||
if (len != 16) /* Lazy. Should define constant */
|
||||
return 0;
|
||||
/*
|
||||
* Decode hex key.
|
||||
*/
|
||||
key[0] = 0;
|
||||
key[1] = 0;
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (!isascii(*cp))
|
||||
return 0;
|
||||
xdigit = strchr(hex, isupper(*cp) ? tolower(*cp) : *cp);
|
||||
cp++;
|
||||
if (xdigit == 0)
|
||||
return 0;
|
||||
key[i>>3] <<= 4;
|
||||
key[i>>3] |= (u_int32)(xdigit - hex) & 0xf;
|
||||
}
|
||||
|
||||
/*
|
||||
* If this is an NTP format key, put it into NBS format
|
||||
*/
|
||||
if (keytype == KEY_TYPE_NTP) {
|
||||
for (i = 0; i < 2; i++)
|
||||
key[i] = ((key[i] << 1) & ~STD_PARITY_BITS)
|
||||
| ((key[i] >> 7) & STD_PARITY_BITS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the parity, reject the key if the check fails
|
||||
*/
|
||||
if (!DESauth_parity(key)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* We can't find a good reason not to use this key.
|
||||
* So use it.
|
||||
*/
|
||||
DESauth_setkey(keyno, key);
|
||||
break;
|
||||
|
||||
case KEY_TYPE_ASCII:
|
||||
/*
|
||||
* Make up key from ascii representation
|
||||
*/
|
||||
memset((char *) keybytes, 0, sizeof(keybytes));
|
||||
for (i = 0; i < 8 && i < len; i++)
|
||||
keybytes[i] = *cp++ << 1;
|
||||
key[0] = (u_int32)keybytes[0] << 24 | (u_int32)keybytes[1] << 16
|
||||
| (u_int32)keybytes[2] << 8 | (u_int32)keybytes[3];
|
||||
key[1] = (u_int32)keybytes[4] << 24 | (u_int32)keybytes[5] << 16
|
||||
| (u_int32)keybytes[6] << 8 | (u_int32)keybytes[7];
|
||||
|
||||
/*
|
||||
* Set parity on key
|
||||
*/
|
||||
(void)DESauth_parity(key);
|
||||
|
||||
/*
|
||||
* Now set key in.
|
||||
*/
|
||||
DESauth_setkey(keyno, key);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef MD5
|
||||
case KEY_TYPE_MD5:
|
||||
/* XXX FIXME: MD5auth_setkey() casts arg2 back to (char *) */
|
||||
MD5auth_setkey(keyno, (u_int32 *)str);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/* Oh, well */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/* $NetBSD: buftvtots.c,v 1.3 1998/03/06 18:17:14 christos Exp $ */
|
||||
|
||||
/*
|
||||
* buftvtots - pull a Unix-format (struct timeval) time stamp out of
|
||||
* an octet stream and convert it to a l_fp time stamp.
|
||||
* This is useful when using the clock line discipline.
|
||||
*/
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_unixtime.h"
|
||||
|
||||
int
|
||||
buftvtots(bufp, ts)
|
||||
const char *bufp;
|
||||
l_fp *ts;
|
||||
{
|
||||
register const u_char *bp;
|
||||
register u_long sec;
|
||||
register u_long usec;
|
||||
|
||||
#ifdef XNTP_BIG_ENDIAN
|
||||
bp = (const u_char *)bufp;
|
||||
|
||||
sec = (u_long)*bp++ & 0xff;
|
||||
sec <<= 8;
|
||||
sec += (u_long)*bp++ & 0xff;
|
||||
sec <<= 8;
|
||||
sec += (u_long)*bp++ & 0xff;
|
||||
sec <<= 8;
|
||||
sec += (u_long)*bp++ & 0xff;
|
||||
|
||||
usec = (u_long)*bp++ & 0xff;
|
||||
usec <<= 8;
|
||||
usec += (u_long)*bp++ & 0xff;
|
||||
usec <<= 8;
|
||||
usec += (u_long)*bp++ & 0xff;
|
||||
usec <<= 8;
|
||||
usec += (u_long)*bp & 0xff;
|
||||
#else
|
||||
bp = (u_char *)bufp + 7;
|
||||
|
||||
usec = (u_long)*bp-- & 0xff;
|
||||
usec <<= 8;
|
||||
usec += (u_long)*bp-- & 0xff;
|
||||
usec <<= 8;
|
||||
usec += (u_long)*bp-- & 0xff;
|
||||
usec <<= 8;
|
||||
usec += (u_long)*bp-- & 0xff;
|
||||
|
||||
sec = (u_long)*bp-- & 0xff;
|
||||
sec <<= 8;
|
||||
sec += (u_long)*bp-- & 0xff;
|
||||
sec <<= 8;
|
||||
sec += (u_long)*bp-- & 0xff;
|
||||
sec <<= 8;
|
||||
sec += (u_long)*bp & 0xff;
|
||||
#endif
|
||||
if (usec > 999999)
|
||||
return 0;
|
||||
|
||||
ts->l_ui = sec + (u_long)JAN_1970;
|
||||
TVUTOTSF(usec, ts->l_uf);
|
||||
return 1;
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/* $NetBSD: caljulian.c,v 1.5 1999/07/03 12:30:29 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* caljulian - determine the Julian date from an NTP time.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_calendar.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
/*
|
||||
* calmonthtab - days-in-the-month table
|
||||
*/
|
||||
static u_short calmonthtab[11] = {
|
||||
JAN,
|
||||
FEB,
|
||||
MAR,
|
||||
APR,
|
||||
MAY,
|
||||
JUN,
|
||||
JUL,
|
||||
AUG,
|
||||
SEP,
|
||||
OCT,
|
||||
NOV
|
||||
};
|
||||
|
||||
void
|
||||
caljulian(ntptime, jt)
|
||||
u_long ntptime;
|
||||
register struct calendar *jt;
|
||||
{
|
||||
u_long ntp_day;
|
||||
u_long minutes;
|
||||
/*
|
||||
* Absolute, zero-adjusted Christian era day, starting from the
|
||||
* mythical day 12/1/1 BC
|
||||
*/
|
||||
u_long acez_day;
|
||||
|
||||
u_long d400; /* Days into a Gregorian cycle */
|
||||
u_long d100; /* Days into a normal century */
|
||||
u_long d4; /* Days into a 4-year cycle */
|
||||
u_long n400; /* # of Gregorian cycles */
|
||||
u_long n100; /* # of normal centuries */
|
||||
u_long n4; /* # of 4-year cycles */
|
||||
u_long n1; /* # of years into a leap year */
|
||||
/* cycle */
|
||||
|
||||
/*
|
||||
* Do the easy stuff first: take care of hh:mm:ss, ignoring leap
|
||||
* seconds
|
||||
*/
|
||||
jt->second = ntptime % SECSPERMIN;
|
||||
minutes = ntptime / SECSPERMIN;
|
||||
jt->minute = minutes % MINSPERHR;
|
||||
jt->hour = (minutes / MINSPERHR) % HRSPERDAY;
|
||||
|
||||
/*
|
||||
* Find the day past 1900/01/01 00:00 UTC
|
||||
*/
|
||||
ntp_day = ntptime / SECSPERDAY;
|
||||
acez_day = DAY_NTP_STARTS + ntp_day - 1;
|
||||
n400 = acez_day/GREGORIAN_CYCLE_DAYS;
|
||||
d400 = acez_day%GREGORIAN_CYCLE_DAYS;
|
||||
n100 = d400 / GREGORIAN_NORMAL_CENTURY_DAYS;
|
||||
d100 = d400 % GREGORIAN_NORMAL_CENTURY_DAYS;
|
||||
n4 = d100 / GREGORIAN_NORMAL_LEAP_CYCLE_DAYS;
|
||||
d4 = d100 % GREGORIAN_NORMAL_LEAP_CYCLE_DAYS;
|
||||
n1 = d4 / DAYSPERYEAR;
|
||||
|
||||
/*
|
||||
* Calculate the year and year-of-day
|
||||
*/
|
||||
jt->yearday = 1 + d4%DAYSPERYEAR;
|
||||
jt->year = 400*n400 + 100*n100 + n4*4 + n1;
|
||||
|
||||
if (n100 == 4 || n1 == 4)
|
||||
{
|
||||
/*
|
||||
* If the cycle year ever comes out to 4, it must be December 31st
|
||||
* of a leap year.
|
||||
*/
|
||||
jt->month = 12;
|
||||
jt->monthday = 31;
|
||||
jt->yearday = 366;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Else, search forwards through the months to get the right month
|
||||
* and date.
|
||||
*/
|
||||
int monthday;
|
||||
|
||||
jt->year++;
|
||||
monthday = jt->yearday;
|
||||
|
||||
for (jt->month=0;jt->month<11; jt->month++)
|
||||
{
|
||||
int t;
|
||||
|
||||
t = monthday - calmonthtab[jt->month];
|
||||
if (jt->month == 1 && is_leapyear(jt->year))
|
||||
t--;
|
||||
|
||||
if (t > 0)
|
||||
monthday = t;
|
||||
else
|
||||
break;
|
||||
}
|
||||
jt->month++;
|
||||
jt->monthday = monthday;
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/* $NetBSD: calleapwhen.c,v 1.4 1999/07/03 12:30:29 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* calleapwhen - determine the number of seconds to the next possible
|
||||
* leap occurance and the last one.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_calendar.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
/*
|
||||
* calleaptab - leaps occur at the end of December and June
|
||||
*/
|
||||
long calleaptab[10] = {
|
||||
-(JAN+FEBLEAP)*SECSPERDAY, /* leap previous to cycle */
|
||||
(MAR+APR+MAY+JUN)*SECSPERDAY, /* end of June */
|
||||
(MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV+DEC)*SECSPERDAY, /* end of Dec */
|
||||
(MAR+APR+MAY+JUN)*SECSPERDAY + SECSPERYEAR,
|
||||
(MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV+DEC)*SECSPERDAY + SECSPERYEAR,
|
||||
(MAR+APR+MAY+JUN)*SECSPERDAY + 2*SECSPERYEAR,
|
||||
(MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV+DEC)*SECSPERDAY + 2*SECSPERYEAR,
|
||||
(MAR+APR+MAY+JUN)*SECSPERDAY + 3*SECSPERYEAR,
|
||||
(MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV+DEC)*SECSPERDAY + 3*SECSPERYEAR,
|
||||
(MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV+DEC+JAN+FEBLEAP+MAR+APR+MAY+JUN)
|
||||
*SECSPERDAY + 3*SECSPERYEAR, /* next after current cycle */
|
||||
};
|
||||
|
||||
void
|
||||
calleapwhen(ntpdate, leaplast, leapnext)
|
||||
u_long ntpdate;
|
||||
u_long *leaplast;
|
||||
u_long *leapnext;
|
||||
{
|
||||
register u_long dateincycle;
|
||||
register int i;
|
||||
|
||||
/*
|
||||
* Find the offset from the start of the cycle
|
||||
*/
|
||||
dateincycle = ntpdate;
|
||||
if (dateincycle >= MAR1988)
|
||||
dateincycle -= MAR1988;
|
||||
else
|
||||
dateincycle -= MAR1900;
|
||||
|
||||
while (dateincycle >= SECSPERCYCLE)
|
||||
dateincycle -= SECSPERCYCLE;
|
||||
|
||||
/*
|
||||
* Find where we are with respect to the leap events.
|
||||
*/
|
||||
for (i = 1; i < 9; i++)
|
||||
if (dateincycle < (u_long)calleaptab[i])
|
||||
break;
|
||||
|
||||
/*
|
||||
* i points at the next leap. Compute the last and the next.
|
||||
*/
|
||||
*leaplast = (u_long)((long)dateincycle - calleaptab[i-1]);
|
||||
*leapnext = (u_long)(calleaptab[i] - (long)dateincycle);
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/* $NetBSD: caltontp.c,v 1.5 1999/07/03 12:30:29 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* caltontp - convert a date to an NTP time
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_calendar.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
u_long
|
||||
caltontp(jt)
|
||||
register const struct calendar *jt;
|
||||
{
|
||||
u_long ace_days; /* absolute Christian Era days */
|
||||
u_long ntp_days;
|
||||
int prior_years;
|
||||
u_long ntp_time;
|
||||
|
||||
/*
|
||||
* First convert today's date to absolute days past 12/1/1 BC
|
||||
*/
|
||||
prior_years = jt->year-1;
|
||||
ace_days = jt->yearday /* days this year */
|
||||
+(DAYSPERYEAR*prior_years) /* plus days in previous years */
|
||||
+(prior_years/4) /* plus prior years's leap days */
|
||||
-(prior_years/100) /* minus leapless century years */
|
||||
+(prior_years/400); /* plus leapful Gregorian yrs */
|
||||
|
||||
/*
|
||||
* Subtract out 1/1/1900, the beginning of the NTP epoch
|
||||
*/
|
||||
ntp_days = ace_days - DAY_NTP_STARTS;
|
||||
|
||||
/*
|
||||
* Do the obvious:
|
||||
*/
|
||||
ntp_time =
|
||||
ntp_days*SECSPERDAY+SECSPERMIN*(MINSPERHR*jt->hour + jt->minute);
|
||||
|
||||
return ntp_time;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/* $NetBSD: calyearstart.c,v 1.4 1999/07/03 12:30:29 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* calyearstart - determine the NTP time at midnight of January 1 in
|
||||
* the year of the given date.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_calendar.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
/*
|
||||
* calyeartab - year start offsets from the beginning of a cycle
|
||||
*/
|
||||
u_long calyeartab[YEARSPERCYCLE] = {
|
||||
(SECSPERLEAPYEAR-JANFEBLEAP),
|
||||
(SECSPERLEAPYEAR-JANFEBLEAP) + SECSPERYEAR,
|
||||
(SECSPERLEAPYEAR-JANFEBLEAP) + 2*SECSPERYEAR,
|
||||
(SECSPERLEAPYEAR-JANFEBLEAP) + 3*SECSPERYEAR
|
||||
};
|
||||
|
||||
u_long
|
||||
calyearstart(dateinyear)
|
||||
register u_long dateinyear;
|
||||
{
|
||||
register u_long cyclestart;
|
||||
register u_long nextyear, lastyear;
|
||||
register int i;
|
||||
|
||||
/*
|
||||
* Find the start of the cycle this is in.
|
||||
*/
|
||||
if (dateinyear >= MAR1988)
|
||||
cyclestart = MAR1988;
|
||||
else
|
||||
cyclestart = MAR1900;
|
||||
while ((cyclestart + SECSPERCYCLE) <= dateinyear)
|
||||
cyclestart += SECSPERCYCLE;
|
||||
|
||||
/*
|
||||
* If we're in the first year of the cycle, January 1 is
|
||||
* two months back from the cyclestart and the year is
|
||||
* a leap year.
|
||||
*/
|
||||
lastyear = cyclestart + calyeartab[0];
|
||||
if (dateinyear < lastyear)
|
||||
return (cyclestart - JANFEBLEAP);
|
||||
|
||||
/*
|
||||
* Look for an intermediate year
|
||||
*/
|
||||
for (i = 1; i < YEARSPERCYCLE; i++) {
|
||||
nextyear = cyclestart + calyeartab[i];
|
||||
if (dateinyear < nextyear)
|
||||
return lastyear;
|
||||
lastyear = nextyear;
|
||||
}
|
||||
|
||||
/*
|
||||
* Not found, must be in last two months of cycle
|
||||
*/
|
||||
return nextyear;
|
||||
}
|
@ -1,133 +0,0 @@
|
||||
/* $NetBSD: clocktime.c,v 1.2 1998/01/09 03:16:04 perry Exp $ */
|
||||
|
||||
/*
|
||||
* clocktime - compute the NTP date from a day of year, hour, minute
|
||||
* and second.
|
||||
*/
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_unixtime.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
/*
|
||||
* Hacks to avoid excercising the multiplier. I have no pride.
|
||||
*/
|
||||
#define MULBY10(x) (((x)<<3) + ((x)<<1))
|
||||
#define MULBY60(x) (((x)<<6) - ((x)<<2)) /* watch overflow */
|
||||
#define MULBY24(x) (((x)<<4) + ((x)<<3))
|
||||
|
||||
/*
|
||||
* Two days, in seconds.
|
||||
*/
|
||||
#define TWODAYS (2*24*60*60)
|
||||
|
||||
/*
|
||||
* We demand that the time be within CLOSETIME seconds of the receive
|
||||
* time stamp. This is about 4 hours, which hopefully should be
|
||||
* wide enough to collect most data, while close enough to keep things
|
||||
* from getting confused.
|
||||
*/
|
||||
#define CLOSETIME (4*60*60)
|
||||
|
||||
|
||||
int
|
||||
clocktime(yday, hour, minute, second, tzoff, rec_ui, yearstart, ts_ui)
|
||||
int yday;
|
||||
int hour;
|
||||
int minute;
|
||||
int second;
|
||||
int tzoff;
|
||||
u_long rec_ui;
|
||||
u_long *yearstart;
|
||||
u_int32 *ts_ui;
|
||||
{
|
||||
register long tmp;
|
||||
register u_long date;
|
||||
register u_long yst;
|
||||
|
||||
/*
|
||||
* Compute the offset into the year in seconds. Note that
|
||||
* this could come out to be a negative number.
|
||||
*/
|
||||
tmp = (long)(MULBY24((yday-1)) + hour + tzoff);
|
||||
tmp = MULBY60(tmp) + (long)minute;
|
||||
tmp = MULBY60(tmp) + (long)second;
|
||||
|
||||
/*
|
||||
* Initialize yearstart, if necessary.
|
||||
*/
|
||||
yst = *yearstart;
|
||||
if (yst == 0) {
|
||||
yst = calyearstart(rec_ui);
|
||||
*yearstart = yst;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now the fun begins. We demand that the received clock time
|
||||
* be within CLOSETIME of the receive timestamp, but
|
||||
* there is uncertainty about the year the timestamp is in.
|
||||
* Use the current year start for the first check, this should
|
||||
* work most of the time.
|
||||
*/
|
||||
date = (u_long)(tmp + (long)yst);
|
||||
if (date < (rec_ui + CLOSETIME) &&
|
||||
date > (rec_ui - CLOSETIME)) {
|
||||
*ts_ui = date;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Trouble. Next check is to see if the year rolled over and, if
|
||||
* so, try again with the new year's start.
|
||||
*/
|
||||
yst = calyearstart(rec_ui);
|
||||
if (yst != *yearstart) {
|
||||
date = (u_long)((long)yst + tmp);
|
||||
*ts_ui = date;
|
||||
if (date < (rec_ui + CLOSETIME) &&
|
||||
date > (rec_ui - CLOSETIME)) {
|
||||
*yearstart = yst;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Here we know the year start matches the current system
|
||||
* time. One remaining possibility is that the time code
|
||||
* is in the year previous to that of the system time. This
|
||||
* is only worth checking if the receive timestamp is less
|
||||
* than a couple of days into the new year.
|
||||
*/
|
||||
if ((rec_ui - yst) < TWODAYS) {
|
||||
yst = calyearstart(yst - TWODAYS);
|
||||
if (yst != *yearstart) {
|
||||
date = (u_long)(tmp + (long)yst);
|
||||
if (date < (rec_ui + CLOSETIME) &&
|
||||
date > (rec_ui - CLOSETIME)) {
|
||||
*yearstart = yst;
|
||||
*ts_ui = date;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* One last possibility is that the time stamp is in the year
|
||||
* following the year the system is in. Try this one before
|
||||
* giving up.
|
||||
*/
|
||||
yst = calyearstart(rec_ui + TWODAYS);
|
||||
if (yst != *yearstart) {
|
||||
date = (u_long)((long)yst + tmp);
|
||||
if (date < (rec_ui + CLOSETIME) &&
|
||||
date > (rec_ui - CLOSETIME)) {
|
||||
*yearstart = yst;
|
||||
*ts_ui = date;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Give it up.
|
||||
*/
|
||||
return 0;
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
/* $NetBSD: clocktypes.c,v 1.6 1999/07/03 12:30:30 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* Data for pretty printing clock types
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp.h"
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_refclock.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
struct clktype clktypes[] = {
|
||||
{ REFCLK_NONE, "unspecified type (0)",
|
||||
"UNKNOWN" },
|
||||
{ REFCLK_LOCALCLOCK, "Undisciplined local clock (1)",
|
||||
"LOCAL" },
|
||||
{ REFCLK_GPS_TRAK, "TRAK 8810 GPS Receiver (2)",
|
||||
"GPS_TRAK" },
|
||||
{ REFCLK_WWV_PST, "PSTI/Traconex WWV/WWVH Receiver (3)",
|
||||
"WWV_PST" },
|
||||
{ REFCLK_WWVB_SPECTRACOM, "Spectracom WWVB Receiver (4)",
|
||||
"WWVB_SPEC" },
|
||||
{ REFCLK_TRUETIME, "TrueTime (generic) Receivers (5)",
|
||||
"TRUETIME" },
|
||||
{ REFCLK_IRIG_AUDIO, "IRIG Audio Decoder (6)",
|
||||
"IRIG_AUDIO" },
|
||||
{ REFCLK_CHU, "Scratchbuilt CHU Receiver (7)",
|
||||
"CHU" },
|
||||
{ REFCLK_PARSE, "Generic reference clock driver (8)",
|
||||
"GENERIC" },
|
||||
{ REFCLK_GPS_MX4200, "Magnavox MX4200 GPS Receiver (9)",
|
||||
"GPS_MX4200" },
|
||||
{ REFCLK_GPS_AS2201, "Austron 2201A GPS Receiver (10)",
|
||||
"GPS_AS2201" },
|
||||
{ REFCLK_GPS_ARBITER, "Arbiter 1088A/B GPS Receiver (11)",
|
||||
"GPS_ARBITER" },
|
||||
{ REFCLK_IRIG_TPRO, "KSI/Odetics TPRO/S IRIG Interface (12)",
|
||||
"IRIG_TPRO" },
|
||||
{ REFCLK_ATOM_LEITCH, "Leitch CSD 5300 Master Clock Controller (13)",
|
||||
"ATOM_LEITCH" },
|
||||
{ REFCLK_MSF_EES, "EES M201 MSF Receiver (14)",
|
||||
"MSF_EES" },
|
||||
{ REFCLK_GPSTM_TRUE, "TrueTime (old GPSTM driver) Receiver (15)",
|
||||
"GPSTM_TRUE" },
|
||||
{ REFCLK_IRIG_BANCOMM, "Bancomm GPS/IRIG Receiver (16)",
|
||||
"GPS_BANC" },
|
||||
{ REFCLK_GPS_DATUM, "Datum Precision Time System (17)",
|
||||
"GPS_DATUM" },
|
||||
{ REFCLK_NIST_ACTS, "NIST Automated Computer Time Service (18)",
|
||||
"NIST_ACTS" },
|
||||
{ REFCLK_WWV_HEATH, "Heath WWV/WWVH Receiver (19)",
|
||||
"WWV_HEATH" },
|
||||
{ REFCLK_GPS_NMEA, "Generic NMEA GPS Receiver (20)",
|
||||
"GPS_NMEA" },
|
||||
{ REFCLK_GPS_VME, "TrueTime GPS-VME Interface (21)",
|
||||
"GPS_VME" },
|
||||
{ REFCLK_ATOM_PPS, "PPS Clock Discipline (22)",
|
||||
"ATOM_PPS" },
|
||||
{ REFCLK_PTB_ACTS, "PTB Automated Computer Time Service (23)",
|
||||
"PTB_ACTS" },
|
||||
{ REFCLK_USNO, "Naval Observatory dialup (24)",
|
||||
"USNO" },
|
||||
{ REFCLK_TRUETIME, "TrueTime (generic) Receivers (25)",
|
||||
"TRUETIME" },
|
||||
{ REFCLK_GPS_HP, "HP 58503A GPS Time & Frequency Receiver (26)",
|
||||
"GPS_HP" },
|
||||
{ REFCLK_ARCRON_MSF, "ARCRON MSF (and DCF77) Receiver (27)",
|
||||
"ARCRON_MSF" },
|
||||
{ REFCLK_SHM, "Clock attached thru shared Memory (28)",
|
||||
"SHM" },
|
||||
{ REFCLK_PALISADE, "Trimble Navigation Palisade GPS (29)",
|
||||
"PALISADE" },
|
||||
{ REFCLK_ONCORE, "Motorola UT Oncore GPS (30)",
|
||||
"ONCORE" },
|
||||
{ REFCLK_GPS_JUPITER, "Rockwell Jupiter GPS Receiver (31)",
|
||||
"GPS_JUPITER" },
|
||||
{ -1, "", "" }
|
||||
};
|
||||
|
||||
const char *
|
||||
clockname(num)
|
||||
int num;
|
||||
{
|
||||
register struct clktype *clk;
|
||||
|
||||
for (clk = clktypes; clk->code != -1; clk++) {
|
||||
if (num == clk->code)
|
||||
return (clk->abbrev);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/* $NetBSD: decodenetnum.c,v 1.4 1999/07/03 12:30:30 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* decodenetnum - return a net number (this is crude, but careful)
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
int
|
||||
decodenetnum(num, netnum)
|
||||
const char *num;
|
||||
u_int32 *netnum;
|
||||
{
|
||||
register const char *cp;
|
||||
register char *bp;
|
||||
register int i;
|
||||
register int temp;
|
||||
register int eos;
|
||||
char buf[80]; /* will core dump on really stupid stuff */
|
||||
|
||||
cp = num;
|
||||
*netnum = 0;
|
||||
|
||||
if (*cp == '[') {
|
||||
eos = ']';
|
||||
cp++;
|
||||
} else {
|
||||
eos = '\0';
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
bp = buf;
|
||||
while (isdigit(*cp))
|
||||
*bp++ = *cp++;
|
||||
if (bp == buf)
|
||||
break;
|
||||
|
||||
if (i < 3) {
|
||||
if (*cp++ != '.')
|
||||
break;
|
||||
} else if (*cp != eos)
|
||||
break;
|
||||
|
||||
*bp = '\0';
|
||||
temp = atoi(buf);
|
||||
if (temp > 255)
|
||||
break;
|
||||
*netnum <<= 8;
|
||||
*netnum += temp;
|
||||
}
|
||||
|
||||
if (i < 4)
|
||||
return 0;
|
||||
*netnum = htonl(*netnum);
|
||||
return 1;
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
/* $NetBSD: dofptoa.c,v 1.4 1999/07/03 12:30:30 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* dofptoa - do the grunge work to convert an fp number to ascii
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_string.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
char *
|
||||
dofptoa(fpv, neg, ndec, msec)
|
||||
u_fp fpv;
|
||||
int neg;
|
||||
int ndec;
|
||||
int msec;
|
||||
{
|
||||
register u_char *cp, *cpend;
|
||||
register u_long val;
|
||||
register short dec;
|
||||
u_char cbuf[12];
|
||||
u_char *cpdec;
|
||||
char *buf;
|
||||
char *bp;
|
||||
|
||||
/*
|
||||
* Get a string buffer before starting
|
||||
*/
|
||||
LIB_GETBUF(buf);
|
||||
|
||||
/*
|
||||
* Zero out the buffer
|
||||
*/
|
||||
memset((char *)cbuf, 0, sizeof cbuf);
|
||||
|
||||
/*
|
||||
* Set the pointers to point at the first
|
||||
* decimal place. Get a local copy of the value.
|
||||
*/
|
||||
cp = cpend = &cbuf[5];
|
||||
val = fpv;
|
||||
|
||||
/*
|
||||
* If we have to, decode the integral part
|
||||
*/
|
||||
if (!(val & 0xffff0000))
|
||||
cp--;
|
||||
else {
|
||||
register u_short sv = (u_short)(val >> 16);
|
||||
register u_short tmp;
|
||||
register u_short ten = 10;
|
||||
|
||||
do {
|
||||
tmp = sv;
|
||||
sv /= ten;
|
||||
*(--cp) = tmp - ((sv<<3) + (sv<<1));
|
||||
} while (sv != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Figure out how much of the fraction to do
|
||||
*/
|
||||
if (msec) {
|
||||
dec = ndec + 3;
|
||||
if (dec < 3)
|
||||
dec = 3;
|
||||
cpdec = &cbuf[8];
|
||||
} else {
|
||||
dec = ndec;
|
||||
cpdec = cpend;
|
||||
}
|
||||
|
||||
if (dec > 6)
|
||||
dec = 6;
|
||||
|
||||
if (dec > 0) {
|
||||
do {
|
||||
val &= 0xffff;
|
||||
val = (val << 3) + (val << 1);
|
||||
*cpend++ = (u_char)(val >> 16);
|
||||
} while (--dec > 0);
|
||||
}
|
||||
|
||||
if (val & 0x8000) {
|
||||
register u_char *tp;
|
||||
/*
|
||||
* Round it. Ick.
|
||||
*/
|
||||
tp = cpend;
|
||||
*(--tp) += 1;
|
||||
while (*tp >= 10) {
|
||||
*tp = 0;
|
||||
*(--tp) += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove leading zeroes if necessary
|
||||
*/
|
||||
while (cp < (cpdec -1) && *cp == 0)
|
||||
cp++;
|
||||
|
||||
/*
|
||||
* Copy it into the buffer, asciizing as we go.
|
||||
*/
|
||||
bp = buf;
|
||||
if (neg)
|
||||
*bp++ = '-';
|
||||
|
||||
while (cp < cpend) {
|
||||
if (cp == cpdec)
|
||||
*bp++ = '.';
|
||||
*bp++ = (char)(*cp++ + '0');
|
||||
}
|
||||
*bp = '\0';
|
||||
return buf;
|
||||
}
|
@ -1,163 +0,0 @@
|
||||
/* $NetBSD: dolfptoa.c,v 1.4 1999/07/03 12:30:30 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* dolfptoa - do the grunge work of converting an l_fp number to decimal
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_string.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
char *
|
||||
dolfptoa(fpi, fpv, neg, ndec, msec)
|
||||
u_long fpi;
|
||||
u_long fpv;
|
||||
int neg;
|
||||
int ndec;
|
||||
int msec;
|
||||
{
|
||||
register u_char *cp, *cpend;
|
||||
register u_long lwork;
|
||||
register int dec;
|
||||
u_char cbuf[24];
|
||||
u_char *cpdec;
|
||||
char *buf;
|
||||
char *bp;
|
||||
|
||||
/*
|
||||
* Get a string buffer before starting
|
||||
*/
|
||||
LIB_GETBUF(buf);
|
||||
|
||||
/*
|
||||
* Zero the character buffer
|
||||
*/
|
||||
memset((char *) cbuf, 0, sizeof(cbuf));
|
||||
|
||||
/*
|
||||
* Work on the integral part. This is biased by what I know
|
||||
* compiles fairly well for a 68000.
|
||||
*/
|
||||
cp = cpend = &cbuf[10];
|
||||
lwork = fpi;
|
||||
if (lwork & 0xffff0000) {
|
||||
register u_long lten = 10;
|
||||
register u_long ltmp;
|
||||
|
||||
do {
|
||||
ltmp = lwork;
|
||||
lwork /= lten;
|
||||
ltmp -= (lwork << 3) + (lwork << 1);
|
||||
*--cp = (u_char)ltmp;
|
||||
} while (lwork & 0xffff0000);
|
||||
}
|
||||
if (lwork != 0) {
|
||||
register u_short sten = 10;
|
||||
register u_short stmp;
|
||||
register u_short swork = (u_short)lwork;
|
||||
|
||||
do {
|
||||
stmp = swork;
|
||||
swork /= sten;
|
||||
stmp -= (swork<<3) + (swork<<1);
|
||||
*--cp = (u_char)stmp;
|
||||
} while (swork != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Done that, now deal with the problem of the fraction. First
|
||||
* determine the number of decimal places.
|
||||
*/
|
||||
if (msec) {
|
||||
dec = ndec + 3;
|
||||
if (dec < 3)
|
||||
dec = 3;
|
||||
cpdec = &cbuf[13];
|
||||
} else {
|
||||
dec = ndec;
|
||||
if (dec < 0)
|
||||
dec = 0;
|
||||
cpdec = &cbuf[10];
|
||||
}
|
||||
if (dec > 12)
|
||||
dec = 12;
|
||||
|
||||
/*
|
||||
* If there's a fraction to deal with, do so.
|
||||
*/
|
||||
if (fpv != 0) {
|
||||
l_fp work;
|
||||
|
||||
work.l_ui = 0;
|
||||
work.l_uf = fpv;
|
||||
while (dec > 0) {
|
||||
l_fp ftmp;
|
||||
|
||||
dec--;
|
||||
/*
|
||||
* The scheme here is to multiply the
|
||||
* fraction (0.1234...) by ten. This moves
|
||||
* a junk of BCD into the units part.
|
||||
* record that and iterate.
|
||||
*/
|
||||
work.l_ui = 0;
|
||||
L_LSHIFT(&work);
|
||||
ftmp = work;
|
||||
L_LSHIFT(&work);
|
||||
L_LSHIFT(&work);
|
||||
L_ADD(&work, &ftmp);
|
||||
*cpend++ = (u_char)work.l_ui;
|
||||
if (work.l_uf == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Rounding is rotten
|
||||
*/
|
||||
if (work.l_uf & 0x80000000) {
|
||||
register u_char *tp = cpend;
|
||||
|
||||
*(--tp) += 1;
|
||||
while (*tp >= 10) {
|
||||
*tp = 0;
|
||||
*(--tp) += 1;
|
||||
};
|
||||
if (tp < cp)
|
||||
cp = tp;
|
||||
}
|
||||
}
|
||||
cpend += dec;
|
||||
|
||||
|
||||
/*
|
||||
* We've now got the fraction in cbuf[], with cp pointing at
|
||||
* the first character, cpend pointing past the last, and
|
||||
* cpdec pointing at the first character past the decimal.
|
||||
* Remove leading zeros, then format the number into the
|
||||
* buffer.
|
||||
*/
|
||||
while (cp < cpdec) {
|
||||
if (*cp != 0)
|
||||
break;
|
||||
cp++;
|
||||
}
|
||||
if (cp == cpdec)
|
||||
--cp;
|
||||
|
||||
bp = buf;
|
||||
if (neg)
|
||||
*bp++ = '-';
|
||||
while (cp < cpend) {
|
||||
if (cp == cpdec)
|
||||
*bp++ = '.';
|
||||
*bp++ = (char)(*cp++ + '0'); /* ascii dependent? */
|
||||
}
|
||||
*bp = '\0';
|
||||
|
||||
/*
|
||||
* Done!
|
||||
*/
|
||||
return buf;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/* $NetBSD: emalloc.c,v 1.2 1998/01/09 03:16:08 perry Exp $ */
|
||||
|
||||
/*
|
||||
* emalloc - return new memory obtained from the system. Belch if none.
|
||||
*/
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_malloc.h"
|
||||
#include "ntp_stdlib.h"
|
||||
#include "ntp_syslog.h"
|
||||
|
||||
char *
|
||||
emalloc(size)
|
||||
u_int size;
|
||||
{
|
||||
char *mem;
|
||||
|
||||
if ((mem = (char *)malloc(size)) == 0) {
|
||||
msyslog(LOG_ERR, "No more memory!");
|
||||
exit(1);
|
||||
}
|
||||
return mem;
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/* $NetBSD: findconfig.c,v 1.6 1999/07/03 12:30:30 simonb Exp $ */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef NEED_HPUX_FINDCONFIG
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
|
||||
char *
|
||||
FindConfig(base)
|
||||
char *base;
|
||||
{
|
||||
static char result[BUFSIZ];
|
||||
char hostname[MAXHOSTNAMELEN + 1], *cp;
|
||||
struct stat sbuf;
|
||||
struct utsname unamebuf;
|
||||
|
||||
/* All keyed by initial target being a directory */
|
||||
(void) strcpy(result, base);
|
||||
if (stat(result, &sbuf) == 0) {
|
||||
if (S_ISDIR(sbuf.st_mode)) {
|
||||
|
||||
/* First choice is my hostname */
|
||||
if (gethostname(hostname, BUFSIZ) >= 0) {
|
||||
hostname[sizeof(hostname) - 1] = '\0';
|
||||
(void) sprintf(result, "%s/%s", base, hostname);
|
||||
if (stat(result, &sbuf) == 0) {
|
||||
goto outahere;
|
||||
} else {
|
||||
|
||||
/* Second choice is of form default.835 */
|
||||
(void) uname(&unamebuf);
|
||||
if (strncmp(unamebuf.machine, "9000/", 5) == 0)
|
||||
cp = unamebuf.machine + 5;
|
||||
else
|
||||
cp = unamebuf.machine;
|
||||
(void) sprintf(result, "%s/default.%s", base, cp);
|
||||
if (stat(result, &sbuf) == 0) {
|
||||
goto outahere;
|
||||
} else {
|
||||
|
||||
/* Last choice is just default */
|
||||
(void) sprintf(result, "%s/default", base);
|
||||
if (stat(result, &sbuf) == 0) {
|
||||
goto outahere;
|
||||
} else {
|
||||
(void) strcpy(result, "/not/found");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
outahere:
|
||||
return(result);
|
||||
}
|
||||
#else
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
char *
|
||||
FindConfig(base)
|
||||
char *base;
|
||||
{
|
||||
return base;
|
||||
}
|
||||
#endif
|
@ -1,26 +0,0 @@
|
||||
/* $NetBSD: fptoa.c,v 1.2 1998/01/09 03:16:10 perry Exp $ */
|
||||
|
||||
/*
|
||||
* fptoa - return an asciized representation of an s_fp number
|
||||
*/
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
char *
|
||||
fptoa(fpv, ndec)
|
||||
s_fp fpv;
|
||||
int ndec;
|
||||
{
|
||||
u_fp plusfp;
|
||||
int neg;
|
||||
|
||||
if (fpv < 0) {
|
||||
plusfp = (u_fp)(-fpv);
|
||||
neg = 1;
|
||||
} else {
|
||||
plusfp = (u_fp)fpv;
|
||||
neg = 0;
|
||||
}
|
||||
|
||||
return dofptoa(plusfp, neg, ndec, 0);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/* $NetBSD: fptoms.c,v 1.2 1998/01/09 03:16:11 perry Exp $ */
|
||||
|
||||
/*
|
||||
* fptoms - return an asciized s_fp number in milliseconds
|
||||
*/
|
||||
#include "ntp_fp.h"
|
||||
|
||||
char *
|
||||
fptoms(fpv, ndec)
|
||||
s_fp fpv;
|
||||
int ndec;
|
||||
{
|
||||
u_fp plusfp;
|
||||
int neg;
|
||||
|
||||
if (fpv < 0) {
|
||||
plusfp = (u_fp)(-fpv);
|
||||
neg = 1;
|
||||
} else {
|
||||
plusfp = (u_fp)fpv;
|
||||
neg = 0;
|
||||
}
|
||||
|
||||
return dofptoa(plusfp, neg, ndec, 1);
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
/* $NetBSD: getopt.c,v 1.9 1999/07/03 12:30:30 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* getopt - get option letter from argv
|
||||
*
|
||||
* This is a version of the public domain getopt() implementation by
|
||||
* Henry Spencer, changed for 4.3BSD compatibility (in addition to System V).
|
||||
* It allows rescanning of an option list by setting optind to 0 before
|
||||
* calling, which is why we use it even if the system has its own (in fact,
|
||||
* this one has a unique name so as not to conflict with the system's).
|
||||
* Thanks to Dennis Ferguson for the appropriate modifications.
|
||||
*
|
||||
* This file is in the Public Domain.
|
||||
*/
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
#ifdef lint
|
||||
#undef putc
|
||||
#define putc fputc
|
||||
#endif /* lint */
|
||||
|
||||
char *ntp_optarg; /* Global argument pointer. */
|
||||
int ntp_optind = 0; /* Global argv index. */
|
||||
int ntp_opterr = 1; /* for compatibility, should error be printed? */
|
||||
int ntp_optopt; /* for compatibility, option character checked */
|
||||
|
||||
static char *scan = NULL; /* Private scan pointer. */
|
||||
static const char *prog = "amnesia";
|
||||
|
||||
static int badopt P((char *, int));
|
||||
|
||||
/*
|
||||
* Print message about a bad option.
|
||||
*/
|
||||
static int
|
||||
badopt(mess, ch)
|
||||
char *mess;
|
||||
int ch;
|
||||
{
|
||||
if (ntp_opterr) {
|
||||
fputs(prog, stderr);
|
||||
fputs(mess, stderr);
|
||||
(void) putc(ch, stderr);
|
||||
(void) putc('\n', stderr);
|
||||
}
|
||||
return ('?');
|
||||
}
|
||||
|
||||
int
|
||||
ntp_getopt(argc, argv, optstring)
|
||||
int argc;
|
||||
char *argv[];
|
||||
const char *optstring;
|
||||
{
|
||||
register char c;
|
||||
register const char *place;
|
||||
|
||||
prog = argv[0];
|
||||
ntp_optarg = NULL;
|
||||
|
||||
if (ntp_optind == 0) {
|
||||
scan = NULL;
|
||||
ntp_optind++;
|
||||
}
|
||||
|
||||
if (scan == NULL || *scan == '\0') {
|
||||
if (ntp_optind >= argc
|
||||
|| argv[ntp_optind][0] != '-'
|
||||
|| argv[ntp_optind][1] == '\0') {
|
||||
return (-1);
|
||||
}
|
||||
if (argv[ntp_optind][1] == '-'
|
||||
&& argv[ntp_optind][2] == '\0') {
|
||||
ntp_optind++;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
scan = argv[ntp_optind++]+1;
|
||||
}
|
||||
|
||||
c = *scan++;
|
||||
ntp_optopt = c & 0377;
|
||||
for (place = optstring; place != NULL && *place != '\0'; ++place)
|
||||
if (*place == c)
|
||||
break;
|
||||
|
||||
if (place == NULL || *place == '\0' || c == ':' || c == '?') {
|
||||
return (badopt(": unknown option -", c));
|
||||
}
|
||||
|
||||
place++;
|
||||
if (*place == ':') {
|
||||
if (*scan != '\0') {
|
||||
ntp_optarg = scan;
|
||||
scan = NULL;
|
||||
} else if (ntp_optind >= argc) {
|
||||
return (badopt(": option requires argument -", c));
|
||||
} else {
|
||||
ntp_optarg = argv[ntp_optind++];
|
||||
}
|
||||
}
|
||||
|
||||
return (c & 0377);
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/* $NetBSD: hextoint.c,v 1.2 1998/01/09 03:16:14 perry Exp $ */
|
||||
|
||||
/*
|
||||
* hextoint - convert an ascii string in hex to an unsigned
|
||||
* long, with error checking
|
||||
*/
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
int
|
||||
hextoint(str, ival)
|
||||
const char *str;
|
||||
u_long *ival;
|
||||
{
|
||||
register u_long u;
|
||||
register const char *cp;
|
||||
|
||||
cp = str;
|
||||
|
||||
if (*cp == '\0')
|
||||
return 0;
|
||||
|
||||
u = 0;
|
||||
while (*cp != '\0') {
|
||||
if (!isxdigit(*cp))
|
||||
return 0;
|
||||
if (u >= 0x10000000)
|
||||
return 0; /* overflow */
|
||||
u <<= 4;
|
||||
if (*cp <= '9') /* very ascii dependent */
|
||||
u += *cp++ - '0';
|
||||
else if (*cp >= 'a')
|
||||
u += *cp++ - 'a' + 10;
|
||||
else
|
||||
u += *cp++ - 'A' + 10;
|
||||
}
|
||||
*ival = u;
|
||||
return 1;
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
/* $NetBSD: hextolfp.c,v 1.5 1999/07/03 12:30:30 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* hextolfp - convert an ascii hex string to an l_fp number
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_string.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
int
|
||||
hextolfp(str, lfp)
|
||||
const char *str;
|
||||
l_fp *lfp;
|
||||
{
|
||||
register const char *cp;
|
||||
register const char *cpstart;
|
||||
register u_long dec_i;
|
||||
register u_long dec_f;
|
||||
char *ind = NULL;
|
||||
static const char *digits = "0123456789abcdefABCDEF";
|
||||
|
||||
dec_i = dec_f = 0;
|
||||
cp = str;
|
||||
|
||||
/*
|
||||
* We understand numbers of the form:
|
||||
*
|
||||
* [spaces]8_hex_digits[.]8_hex_digits[spaces|\n|\0]
|
||||
*/
|
||||
while (isspace(*cp))
|
||||
cp++;
|
||||
|
||||
cpstart = cp;
|
||||
while (*cp != '\0' && (cp - cpstart) < 8 &&
|
||||
(ind = strchr(digits, *cp)) != NULL) {
|
||||
dec_i = dec_i << 4; /* multiply by 16 */
|
||||
dec_i += ((ind - digits) > 15) ? (ind - digits) - 6
|
||||
: (ind - digits);
|
||||
cp++;
|
||||
}
|
||||
|
||||
if ((cp - cpstart) < 8 || ind == NULL)
|
||||
return 0;
|
||||
if (*cp == '.')
|
||||
cp++;
|
||||
|
||||
cpstart = cp;
|
||||
while (*cp != '\0' && (cp - cpstart) < 8 &&
|
||||
(ind = strchr(digits, *cp)) != NULL) {
|
||||
dec_f = dec_f << 4; /* multiply by 16 */
|
||||
dec_f += ((ind - digits) > 15) ? (ind - digits) - 6
|
||||
: (ind - digits);
|
||||
cp++;
|
||||
}
|
||||
|
||||
if ((cp - cpstart) < 8 || ind == NULL)
|
||||
return 0;
|
||||
|
||||
if (*cp != '\0' && !isspace(*cp))
|
||||
return 0;
|
||||
|
||||
lfp->l_ui = dec_i;
|
||||
lfp->l_uf = dec_f;
|
||||
return 1;
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/* $NetBSD: humandate.c,v 1.8 1999/07/03 12:30:30 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* humandate - convert an NTP (or the current) time to something readable
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "time.h"
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_unixtime.h" /* includes <sys/time.h> */
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
char *humanlogtime __P((void));
|
||||
|
||||
static const char *months[] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
static const char *days[] = {
|
||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
||||
};
|
||||
|
||||
char *humanlogtime P((void));
|
||||
|
||||
char *
|
||||
humandate(ntptime)
|
||||
u_long ntptime;
|
||||
{
|
||||
char *bp;
|
||||
struct tm *tm;
|
||||
time_t sec;
|
||||
|
||||
LIB_GETBUF(bp);
|
||||
|
||||
sec = ntptime - JAN_1970;
|
||||
tm = localtime(&sec);
|
||||
|
||||
(void) sprintf(bp, "%s, %s %2d %4d %2d:%02d:%02d",
|
||||
days[tm->tm_wday], months[tm->tm_mon], tm->tm_mday,
|
||||
1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
|
||||
return bp;
|
||||
}
|
||||
|
||||
|
||||
/* This is used in msyslog.c; we don't want to clutter up the log with
|
||||
the year and day of the week, etc.; just the minimal date and time. */
|
||||
|
||||
char *
|
||||
humanlogtime()
|
||||
{
|
||||
char *bp;
|
||||
time_t cursec = time((time_t *) 0);
|
||||
struct tm *tm = localtime(&cursec);
|
||||
|
||||
LIB_GETBUF(bp);
|
||||
|
||||
(void) sprintf(bp, "%2d %s %02d:%02d:%02d",
|
||||
tm->tm_mday, months[tm->tm_mon],
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
|
||||
return bp;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/* $NetBSD: inttoa.c,v 1.2 1998/01/09 03:16:16 perry Exp $ */
|
||||
|
||||
/*
|
||||
* inttoa - return an asciized signed integer
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
char *
|
||||
inttoa(ival)
|
||||
long ival;
|
||||
{
|
||||
register char *buf;
|
||||
|
||||
LIB_GETBUF(buf);
|
||||
|
||||
(void) sprintf(buf, "%ld", (long)ival);
|
||||
return buf;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/* $NetBSD: lib_strbuf.c,v 1.3 1998/01/09 03:16:16 perry Exp $ */
|
||||
|
||||
/*
|
||||
* lib_strbuf - library string storage
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include "lib_strbuf.h"
|
||||
|
||||
/*
|
||||
* Storage declarations
|
||||
*/
|
||||
char lib_stringbuf[LIB_NUMBUFS][LIB_BUFLENGTH];
|
||||
int lib_nextbuf;
|
||||
int lib_inited = 0;
|
||||
|
||||
void init_lib __P((void));
|
||||
|
||||
/*
|
||||
* initialization routine. Might be needed if the code is ROMized.
|
||||
*/
|
||||
void
|
||||
init_lib()
|
||||
{
|
||||
lib_nextbuf = 0;
|
||||
lib_inited = 1;
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
/* $NetBSD: lib_strbuf.h,v 1.3 1998/08/12 14:11:49 christos Exp $ */
|
||||
|
||||
/*
|
||||
* lib_strbuf.h - definitions for routines which use the common string buffers
|
||||
*/
|
||||
|
||||
#include <ntp_types.h>
|
||||
|
||||
/*
|
||||
* Sizes of things
|
||||
*/
|
||||
#define LIB_NUMBUFS 20
|
||||
#define LIB_BUFLENGTH 80
|
||||
|
||||
/*
|
||||
* Macro to get a pointer to the next buffer
|
||||
*/
|
||||
#define LIB_GETBUF(buf) \
|
||||
do { \
|
||||
if (!lib_inited) \
|
||||
init_lib(); \
|
||||
buf = &lib_stringbuf[lib_nextbuf][0]; \
|
||||
if (++lib_nextbuf >= LIB_NUMBUFS) \
|
||||
lib_nextbuf = 0; \
|
||||
} while (0)
|
||||
|
||||
extern char lib_stringbuf[LIB_NUMBUFS][LIB_BUFLENGTH];
|
||||
extern int lib_nextbuf;
|
||||
extern int lib_inited;
|
||||
|
||||
void init_lib P((void));
|
@ -1,256 +0,0 @@
|
||||
/* $NetBSD: machines.c,v 1.6 1999/07/03 12:30:31 simonb Exp $ */
|
||||
|
||||
/* machines.c - provide special support for peculiar architectures
|
||||
*
|
||||
* Real bummers unite !
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
|
||||
#ifndef SYS_WINNT
|
||||
|
||||
#ifdef SYS_VXWORKS
|
||||
#include "taskLib.h"
|
||||
#include "sysLib.h"
|
||||
#include "time.h"
|
||||
#include "ntp_syslog.h"
|
||||
|
||||
/* some translations to the world of vxWorkings -casey */
|
||||
/* first some netdb type things */
|
||||
#include "ioLib.h"
|
||||
#include <socket.h>
|
||||
int h_errno;
|
||||
|
||||
struct hostent *gethostbyname(char *name)
|
||||
{
|
||||
struct hostent *host1;
|
||||
h_errno = 0; /* we are always successful!!! */
|
||||
host1 = (struct hostent *) malloc (sizeof(struct hostent));
|
||||
host1->h_name = name;
|
||||
host1->h_addrtype = AF_INET;
|
||||
host1->h_aliases = name;
|
||||
host1->h_length = 4;
|
||||
host1->h_addr_list[0] = (char *)hostGetByName (name);
|
||||
host1->h_addr_list[1] = NULL;
|
||||
return host1;
|
||||
}
|
||||
|
||||
struct hostent *gethostbyaddr(char *name, int size, int addr_type)
|
||||
{
|
||||
struct hostent *host1;
|
||||
h_errno = 0; /* we are always successful!!! */
|
||||
host1 = (struct hostent *) malloc (sizeof(struct hostent));
|
||||
host1->h_name = name;
|
||||
host1->h_addrtype = AF_INET;
|
||||
host1->h_aliases = name;
|
||||
host1->h_length = 4;
|
||||
host1->h_addr_list = NULL;
|
||||
return host1;
|
||||
}
|
||||
|
||||
struct servent *getservbyname (char *name, char *type)
|
||||
{
|
||||
struct servent *serv1;
|
||||
serv1 = (struct servent *) malloc (sizeof(struct servent));
|
||||
serv1->s_name = "ntp"; /* official service name */
|
||||
serv1->s_aliases = NULL; /* alias list */
|
||||
serv1->s_port = 123; /* port # */
|
||||
serv1->s_proto = "udp"; /* protocol to use */
|
||||
return serv1;
|
||||
}
|
||||
|
||||
/* second
|
||||
* vxworks thinks it has insomnia
|
||||
* we have to sleep for number of seconds
|
||||
*/
|
||||
|
||||
#define CLKRATE sysClkRateGet()
|
||||
|
||||
/* I am not sure how valid the granularity is - it is from G. Eger's port */
|
||||
#define CLK_GRANULARITY 1 /* Granularity of system clock in usec */
|
||||
/* Used to round down # usecs/tick */
|
||||
/* On a VCOM-100, PIT gets 8 MHz clk, */
|
||||
/* & it prescales by 32, thus 4 usec */
|
||||
/* on mv167, granularity is 1usec anyway*/
|
||||
/* To defeat rounding, set to 1 */
|
||||
#define USECS_PER_SEC 1000000L /* Microseconds per second */
|
||||
#define TICK (((USECS_PER_SEC / CLKRATE) / CLK_GRANULARITY) * CLK_GRANULARITY)
|
||||
|
||||
/* emulate unix sleep
|
||||
* casey
|
||||
*/
|
||||
void sleep(int seconds)
|
||||
{
|
||||
taskDelay(seconds*TICK);
|
||||
}
|
||||
/* emulate unix alarm
|
||||
* that pauses and calls SIGALRM after the seconds are up...
|
||||
* so ... taskDelay() fudged for seconds should amount to the same thing.
|
||||
* casey
|
||||
*/
|
||||
void alarm (int seconds)
|
||||
{
|
||||
sleep(seconds);
|
||||
}
|
||||
|
||||
#endif /* SYS_VXWORKS */
|
||||
|
||||
#ifdef SYS_PTX /* Does PTX still need this? */
|
||||
/*#include <sys/types.h> */
|
||||
#include <sys/procstats.h>
|
||||
|
||||
int
|
||||
gettimeofday(tvp)
|
||||
struct timeval *tvp;
|
||||
{
|
||||
/*
|
||||
* hi, this is Sequents sneak path to get to a clock
|
||||
* this is also the most logical syscall for such a function
|
||||
*/
|
||||
return (get_process_stats(tvp, PS_SELF, (struct procstats *) 0,
|
||||
(struct procstats *) 0));
|
||||
}
|
||||
#endif /* SYS_PTX */
|
||||
|
||||
#if defined(HAVE_CLOCK_SETTIME) && defined(CLOCK_REALTIME)
|
||||
const char *set_tod_using = "clock_settime";
|
||||
|
||||
/*#include <time.h> */
|
||||
|
||||
int
|
||||
settimeofday(tvp, tzp)
|
||||
struct timeval *tvp;
|
||||
void *tzp;
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
/* Convert timeval to timespec */
|
||||
ts.tv_sec = tvp->tv_sec;
|
||||
ts.tv_nsec = 1000 * tvp->tv_usec;
|
||||
|
||||
return clock_settime(CLOCK_REALTIME, &ts);
|
||||
}
|
||||
|
||||
#else /* not HAVE_CLOCK_SETTIME || not CLOCK_REALTIME */
|
||||
# ifdef HAVE_SETTIMEOFDAY
|
||||
const char *set_tod_using = "settimeofday";
|
||||
# else /* not (HAVE_SETTIMEOFDAY || HAVE_CLOCK_SETTIME) */
|
||||
# ifdef HAVE_STIME
|
||||
char *set_tod_using = "stime";
|
||||
|
||||
int
|
||||
settimeofday(tvp, tzp)
|
||||
struct timeval *tvp;
|
||||
void *tzp;
|
||||
{
|
||||
return (stime(&tvp->tv_sec)); /* lie as bad as SysVR4 */
|
||||
}
|
||||
|
||||
# else
|
||||
# include <Bletch: How do we set the time here?>
|
||||
# endif /* HAVE_STIME */
|
||||
# endif /* not (HAVE_SETTIMEOFDAY || HAVE_CLOCK_SETTIME) */
|
||||
#endif /* not HAVE_CLOCK_SETTIME */
|
||||
|
||||
|
||||
#else /* SYS_WINNT */
|
||||
|
||||
|
||||
#include <time.h>
|
||||
#include <sys\timeb.h>
|
||||
#include <conio.h>
|
||||
#include "ntp_syslog.h"
|
||||
|
||||
char * set_tod_using = "SetSystemTime";
|
||||
|
||||
/* Windows NT versions of gettimeofday and settimeofday
|
||||
*
|
||||
* ftime() has internal DayLightSavings related BUGS
|
||||
* therefore switched to GetSystemTimeAsFileTime()
|
||||
*/
|
||||
|
||||
/* 100ns intervals between 1/1/1601 and 1/1/1970 as reported by
|
||||
* SystemTimeToFileTime()
|
||||
*/
|
||||
|
||||
#define FILETIME_1970 0x019db1ded53e8000
|
||||
const BYTE DWLEN = sizeof(DWORD) * 8; /* number of bits in DWORD */
|
||||
|
||||
int
|
||||
gettimeofday(tv)
|
||||
struct timeval *tv;
|
||||
{
|
||||
FILETIME ft;
|
||||
__int64 msec;
|
||||
|
||||
GetSystemTimeAsFileTime(&ft); /* 100ns intervals since 1/1/1601 */
|
||||
msec = (__int64) ft.dwHighDateTime << DWLEN | ft.dwLowDateTime;
|
||||
msec = (msec - FILETIME_1970) / 10;
|
||||
tv->tv_sec = (long) (msec / 1000000);
|
||||
tv->tv_usec = (long) (msec % 1000000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
settimeofday(tv)
|
||||
struct timeval *tv;
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
struct tm *gmtm;
|
||||
long x = tv->tv_sec;
|
||||
long y = tv->tv_usec;
|
||||
|
||||
gmtm = gmtime((const time_t *) &x);
|
||||
st.wSecond = (WORD) gmtm->tm_sec;
|
||||
st.wMinute = (WORD) gmtm->tm_min;
|
||||
st.wHour = (WORD) gmtm->tm_hour;
|
||||
st.wDay = (WORD) gmtm->tm_mday;
|
||||
st.wMonth = (WORD) (gmtm->tm_mon + 1);
|
||||
st.wYear = (WORD) (gmtm->tm_year + 1900);
|
||||
st.wDayOfWeek = (WORD) gmtm->tm_wday;
|
||||
st.wMilliseconds = (WORD) (y / 1000);
|
||||
|
||||
if (!SetSystemTime(&st)) {
|
||||
msyslog(LOG_ERR, "SetSystemTime failed: %m\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SYS_WINNT */
|
||||
|
||||
#if defined (SYS_WINNT) || defined (SYS_VXWORKS)
|
||||
/* getpass is used in ntpq.c and ntpdc.c */
|
||||
|
||||
char *
|
||||
getpass(const char * prompt)
|
||||
{
|
||||
int c, i;
|
||||
static char password[32];
|
||||
|
||||
fprintf(stderr, "%s", prompt);
|
||||
fflush(stderr);
|
||||
for (i=0; i<sizeof(password)-1 && ((c=_getch())!='\n'); i++) {
|
||||
password[i] = c;
|
||||
}
|
||||
password[i] = '\0';
|
||||
|
||||
return password;
|
||||
}
|
||||
|
||||
#endif /* SYS_WINNT */
|
||||
|
||||
#if !defined(HAVE_MEMSET) || defined(NTP_NEED_BOPS)
|
||||
void
|
||||
ntp_memset(a, x, c)
|
||||
char *a;
|
||||
int x, c;
|
||||
{
|
||||
while (c-- > 0)
|
||||
*a++ = x;
|
||||
}
|
||||
#endif /*POSIX*/
|
@ -1,137 +0,0 @@
|
||||
/* $NetBSD: memmove.c,v 1.2 1998/01/09 03:16:19 perry Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Chris Torek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* sizeof(word) MUST BE A POWER OF TWO
|
||||
* SO THAT wmask BELOW IS ALL ONES
|
||||
*/
|
||||
typedef int word; /* "word" used for optimal copy speed */
|
||||
|
||||
#define wsize sizeof(word)
|
||||
#define wmask (wsize - 1)
|
||||
|
||||
/*
|
||||
* Copy a block of memory, handling overlap.
|
||||
* This is the routine that actually implements
|
||||
* (the portable versions of) bcopy, memcpy, and memmove.
|
||||
*/
|
||||
void *
|
||||
memmove(dst0, src0, length)
|
||||
void *dst0;
|
||||
const void *src0;
|
||||
register size_t length;
|
||||
{
|
||||
register char *dst = dst0;
|
||||
register const char *src = src0;
|
||||
register size_t t;
|
||||
|
||||
if (length == 0 || dst == src) /* nothing to do */
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* Macros: loop-t-times; and loop-t-times, t>0
|
||||
*/
|
||||
#define TLOOP(s) if (t) TLOOP1(s)
|
||||
#define TLOOP1(s) do { s; } while (--t)
|
||||
|
||||
if ((unsigned long)dst < (unsigned long)src) {
|
||||
/*
|
||||
* Copy forward.
|
||||
*/
|
||||
t = (int)src; /* only need low bits */
|
||||
if ((t | (int)dst) & wmask) {
|
||||
/*
|
||||
* Try to align operands. This cannot be done
|
||||
* unless the low bits match.
|
||||
*/
|
||||
if ((t ^ (int)dst) & wmask || length < wsize)
|
||||
t = length;
|
||||
else
|
||||
t = wsize - (t & wmask);
|
||||
length -= t;
|
||||
TLOOP1(*dst++ = *src++);
|
||||
}
|
||||
/*
|
||||
* Copy whole words, then mop up any trailing bytes.
|
||||
*/
|
||||
t = length / wsize;
|
||||
TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
|
||||
t = length & wmask;
|
||||
TLOOP(*dst++ = *src++);
|
||||
} else {
|
||||
/*
|
||||
* Copy backwards. Otherwise essentially the same.
|
||||
* Alignment works as before, except that it takes
|
||||
* (t&wmask) bytes to align, not wsize-(t&wmask).
|
||||
*/
|
||||
src += length;
|
||||
dst += length;
|
||||
t = (int)src;
|
||||
if ((t | (int)dst) & wmask) {
|
||||
if ((t ^ (int)dst) & wmask || length <= wsize)
|
||||
t = length;
|
||||
else
|
||||
t &= wmask;
|
||||
length -= t;
|
||||
TLOOP1(*--dst = *--src);
|
||||
}
|
||||
t = length / wsize;
|
||||
TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src);
|
||||
t = length & wmask;
|
||||
TLOOP(*--dst = *--src);
|
||||
}
|
||||
done:
|
||||
return (dst0);
|
||||
}
|
||||
#else
|
||||
int memmove_bs;
|
||||
#endif
|
@ -1,35 +0,0 @@
|
||||
/* $NetBSD: mexit.c,v 1.4 1999/07/03 12:30:31 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* mexit - Used to exit the XNTPD daemon
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef SYS_WINNT
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
HANDLE hServDoneEvent = NULL;
|
||||
|
||||
void
|
||||
service_exit(status)
|
||||
int status;
|
||||
{
|
||||
extern int debug;
|
||||
|
||||
if (debug) /* did not become a service, simply exit */
|
||||
ExitThread((DWORD)status);
|
||||
else {
|
||||
/* service mode, need to have the service_main routine
|
||||
* register with the service control manager that the
|
||||
* service has stopped running, before exiting
|
||||
*/
|
||||
if ((status > 0) && (hServDoneEvent != NULL))
|
||||
SetEvent(hServDoneEvent);
|
||||
ExitThread((DWORD)status);
|
||||
}
|
||||
}
|
||||
|
||||
#else /* not SYS_WINNT */
|
||||
int mexit_bs;
|
||||
#endif /* not SYS_WINNT */
|
@ -1,24 +0,0 @@
|
||||
/* $NetBSD: mfptoa.c,v 1.2 1998/01/09 03:16:20 perry Exp $ */
|
||||
|
||||
/*
|
||||
* mfptoa - Return an asciized representation of a signed long fp number
|
||||
*/
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
char *
|
||||
mfptoa(fpi, fpf, ndec)
|
||||
u_long fpi;
|
||||
u_long fpf;
|
||||
int ndec;
|
||||
{
|
||||
int isneg;
|
||||
|
||||
if (M_ISNEG(fpi, fpf)) {
|
||||
isneg = 1;
|
||||
M_NEG(fpi, fpf);
|
||||
} else
|
||||
isneg = 0;
|
||||
|
||||
return dolfptoa(fpi, fpf, isneg, ndec, 0);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/* $NetBSD: mfptoms.c,v 1.2 1998/01/09 03:16:22 perry Exp $ */
|
||||
|
||||
/*
|
||||
* mfptoms - Return an asciized signed long fp number in milliseconds
|
||||
*/
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
char *
|
||||
mfptoms(fpi, fpf, ndec)
|
||||
u_long fpi;
|
||||
u_long fpf;
|
||||
int ndec;
|
||||
{
|
||||
int isneg;
|
||||
|
||||
if (M_ISNEG(fpi, fpf)) {
|
||||
isneg = 1;
|
||||
M_NEG(fpi, fpf);
|
||||
} else
|
||||
isneg = 0;
|
||||
|
||||
return dolfptoa(fpi, fpf, isneg, ndec, 1);
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/* $NetBSD: modetoa.c,v 1.3 1998/03/06 18:17:15 christos Exp $ */
|
||||
|
||||
/*
|
||||
* modetoa - return an asciized mode
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
const char *
|
||||
modetoa(mode)
|
||||
int mode;
|
||||
{
|
||||
char *bp;
|
||||
static const char *modestrings[] = {
|
||||
"unspec",
|
||||
"sym_active",
|
||||
"sym_passive",
|
||||
"client",
|
||||
"server",
|
||||
"broadcast",
|
||||
"control",
|
||||
"private",
|
||||
"bclient",
|
||||
};
|
||||
|
||||
if (mode < 0 || mode >= (sizeof modestrings)/sizeof(char *)) {
|
||||
LIB_GETBUF(bp);
|
||||
(void)sprintf(bp, "mode#%d", mode);
|
||||
return bp;
|
||||
}
|
||||
|
||||
return modestrings[mode];
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/* $NetBSD: mstolfp.c,v 1.4 1999/07/03 12:30:31 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* mstolfp - convert an ascii string in milliseconds to an l_fp number
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
int
|
||||
mstolfp(str, lfp)
|
||||
const char *str;
|
||||
l_fp *lfp;
|
||||
{
|
||||
register const char *cp;
|
||||
register char *bp;
|
||||
register const char *cpdec;
|
||||
char buf[100];
|
||||
|
||||
/*
|
||||
* We understand numbers of the form:
|
||||
*
|
||||
* [spaces][-][digits][.][digits][spaces|\n|\0]
|
||||
*
|
||||
* This is one enormous hack. Since I didn't feel like
|
||||
* rewriting the decoding routine for milliseconds, what
|
||||
* is essentially done here is to make a copy of the string
|
||||
* with the decimal moved over three places so the seconds
|
||||
* decoding routine can be used.
|
||||
*/
|
||||
bp = buf;
|
||||
cp = str;
|
||||
while (isspace(*cp))
|
||||
cp++;
|
||||
|
||||
if (*cp == '-') {
|
||||
*bp++ = '-';
|
||||
cp++;
|
||||
}
|
||||
|
||||
if (*cp != '.' && !isdigit(*cp))
|
||||
return 0;
|
||||
|
||||
|
||||
/*
|
||||
* Search forward for the decimal point or the end of the string.
|
||||
*/
|
||||
cpdec = cp;
|
||||
while (isdigit(*cpdec))
|
||||
cpdec++;
|
||||
|
||||
/*
|
||||
* Found something. If we have more than three digits copy the
|
||||
* excess over, else insert a leading 0.
|
||||
*/
|
||||
if ((cpdec - cp) > 3) {
|
||||
do {
|
||||
*bp++ = (char)*cp++;
|
||||
} while ((cpdec - cp) > 3);
|
||||
} else {
|
||||
*bp++ = '0';
|
||||
}
|
||||
|
||||
/*
|
||||
* Stick the decimal in. If we've got less than three digits in
|
||||
* front of the millisecond decimal we insert the appropriate number
|
||||
* of zeros.
|
||||
*/
|
||||
*bp++ = '.';
|
||||
if ((cpdec - cp) < 3) {
|
||||
register int i = 3 - (cpdec - cp);
|
||||
|
||||
do {
|
||||
*bp++ = '0';
|
||||
} while (--i > 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the remainder up to the millisecond decimal. If cpdec
|
||||
* is pointing at a decimal point, copy in the trailing number too.
|
||||
*/
|
||||
while (cp < cpdec)
|
||||
*bp++ = (char)*cp++;
|
||||
|
||||
if (*cp == '.') {
|
||||
cp++;
|
||||
while (isdigit(*cp))
|
||||
*bp++ = (char)*cp++;
|
||||
}
|
||||
*bp = '\0';
|
||||
|
||||
/*
|
||||
* Check to make sure the string is properly terminated. If
|
||||
* so, give the buffer to the decoding routine.
|
||||
*/
|
||||
if (*cp != '\0' && !isspace(*cp))
|
||||
return 0;
|
||||
return atolfp(buf, lfp);
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/* $NetBSD: msutotsf.c,v 1.2 1998/01/09 03:16:24 perry Exp $ */
|
||||
|
||||
/*
|
||||
* msutotsf - tables for converting from a subsecond millisecond value
|
||||
* to a time stamp fraction.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "ntp_types.h"
|
||||
|
||||
/*
|
||||
* Index each of these tables with five bits of the (less than) 10
|
||||
* bit millisecond value. Note that the tables are rounded (not
|
||||
* truncated). The error in the result will thus be +-1 low order
|
||||
* bit in the time stamp fraction.
|
||||
*/
|
||||
u_long msutotsflo[32] = {
|
||||
0x00000000, 0x00418937, 0x0083126f, 0x00c49ba6,
|
||||
0x010624dd, 0x0147ae14, 0x0189374c, 0x01cac083,
|
||||
0x020c49ba, 0x024dd2f2, 0x028f5c29, 0x02d0e560,
|
||||
0x03126e98, 0x0353f7cf, 0x03958106, 0x03d70a3d,
|
||||
0x04189375, 0x045a1cac, 0x049ba5e3, 0x04dd2f1b,
|
||||
0x051eb852, 0x05604189, 0x05a1cac1, 0x05e353f8,
|
||||
0x0624dd2f, 0x06666666, 0x06a7ef9e, 0x06e978d5,
|
||||
0x072b020c, 0x076c8b44, 0x07ae147b, 0x07ef9db2
|
||||
};
|
||||
|
||||
u_long msutotsfhi[32] = {
|
||||
0x00000000, 0x083126e9, 0x10624dd3, 0x189374bc,
|
||||
0x20c49ba6, 0x28f5c28f, 0x3126e979, 0x39581062,
|
||||
0x4189374c, 0x49ba5e35, 0x51eb851f, 0x5a1cac08,
|
||||
0x624dd2f2, 0x6a7ef9db, 0x72b020c5, 0x7ae147ae,
|
||||
0x83126e98, 0x8b439581, 0x9374bc6a, 0x9ba5e354,
|
||||
0xa3d70a3d, 0xac083127, 0xb4395810, 0xbc6a7efa,
|
||||
0xc49ba5e3, 0xcccccccd, 0xd4fdf3b6, 0xdd2f1aa0,
|
||||
0xe5604189, 0xed916873, 0xf5c28f5c, 0xfdf3b646
|
||||
};
|
@ -1,192 +0,0 @@
|
||||
/* $NetBSD: msyslog.c,v 1.6 2000/01/21 17:08:34 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* msyslog - either send a message to the terminal or print it on
|
||||
* the standard output.
|
||||
*
|
||||
* Converted to use varargs, much better ... jks
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* alternative, as Solaris 2.x defines __STDC__ as 0 in a largely standard
|
||||
conforming environment
|
||||
#if __STDC__ || (defined(SYS_SOLARIS) && defined(__STDC__))
|
||||
*/
|
||||
#ifdef __STDC__
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include "ntp_types.h"
|
||||
#include "ntp_string.h"
|
||||
#include "ntp_stdlib.h"
|
||||
#include "ntp_syslog.h"
|
||||
|
||||
#ifdef SYS_WINNT
|
||||
# include "log.h"
|
||||
# include "messages.h"
|
||||
#endif
|
||||
|
||||
int syslogit = 1;
|
||||
|
||||
FILE *syslog_file = NULL;
|
||||
|
||||
u_long ntp_syslogmask = ~ (u_long) 0;
|
||||
|
||||
#ifdef SYS_WINNT
|
||||
HANDLE hEventSource;
|
||||
LPTSTR lpszStrings[1];
|
||||
static WORD event_type[] = {
|
||||
EVENTLOG_ERROR_TYPE, EVENTLOG_ERROR_TYPE, EVENTLOG_ERROR_TYPE, EVENTLOG_ERROR_TYPE,
|
||||
EVENTLOG_WARNING_TYPE,
|
||||
EVENTLOG_INFORMATION_TYPE, EVENTLOG_INFORMATION_TYPE, EVENTLOG_INFORMATION_TYPE,
|
||||
};
|
||||
#endif /* SYS_WINNT */
|
||||
extern char *progname;
|
||||
|
||||
#if defined(__STDC__)
|
||||
void msyslog(int level, const char *fmt, ...)
|
||||
#else
|
||||
/*VARARGS*/
|
||||
void msyslog(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifndef __STDC__
|
||||
int level;
|
||||
const char *fmt;
|
||||
#endif
|
||||
va_list ap;
|
||||
char buf[1025], nfmt[256];
|
||||
#if !defined(VMS)
|
||||
char xerr[50];
|
||||
#endif
|
||||
register int c;
|
||||
register char *n, *prog;
|
||||
register const char *f;
|
||||
#ifdef CHAR_SYS_ERRLIST
|
||||
extern int sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
#endif
|
||||
register int l;
|
||||
int olderrno;
|
||||
const char *err;
|
||||
|
||||
|
||||
#ifdef __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
|
||||
level = va_arg(ap, int);
|
||||
fmt = va_arg(ap, char *);
|
||||
#endif
|
||||
|
||||
olderrno = errno;
|
||||
n = nfmt;
|
||||
f = fmt;
|
||||
while ((c = *f++) != '\0' && c != '\n' && n < &nfmt[252]) {
|
||||
if (c != '%') {
|
||||
*n++ = c;
|
||||
continue;
|
||||
}
|
||||
if ((c = *f++) != 'm') {
|
||||
*n++ = '%';
|
||||
*n++ = c;
|
||||
continue;
|
||||
}
|
||||
err = 0;
|
||||
#if !defined(VMS) && !defined(SYS_WINNT) && !defined (SYS_VXWORKS)
|
||||
if ((unsigned)olderrno > sys_nerr)
|
||||
sprintf((char *)(err = xerr), "error %d", olderrno);
|
||||
else
|
||||
err = sys_errlist[olderrno];
|
||||
#elif defined(VMS) || defined (SYS_VXWORKS)
|
||||
err = strerror(olderrno);
|
||||
#else /* SYS_WINNT */
|
||||
err = xerr;
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
|
||||
(LPTSTR) err,
|
||||
sizeof(xerr),
|
||||
NULL);
|
||||
|
||||
#endif /* VMS && SYS_WINNT */
|
||||
if (n + (l = strlen(err)) < &nfmt[254]) {
|
||||
strcpy(n, err);
|
||||
n += strlen(err);
|
||||
}
|
||||
}
|
||||
#if !defined(VMS)
|
||||
if (!syslogit)
|
||||
#endif /* VMS */
|
||||
*n++ = '\n';
|
||||
*n = '\0';
|
||||
|
||||
vsprintf(buf, nfmt, ap);
|
||||
#if !defined(VMS) && !defined (SYS_VXWORKS)
|
||||
if (syslogit)
|
||||
#ifndef SYS_WINNT
|
||||
syslog(level, "%s", buf);
|
||||
#else
|
||||
{
|
||||
lpszStrings[0] = buf;
|
||||
|
||||
switch (event_type[level])
|
||||
{
|
||||
case EVENTLOG_ERROR_TYPE :
|
||||
{
|
||||
reportAnEEvent(NTP_ERROR,1,lpszStrings);
|
||||
break;
|
||||
}
|
||||
case EVENTLOG_INFORMATION_TYPE :
|
||||
{
|
||||
reportAnIEvent(NTP_INFO,1,lpszStrings);
|
||||
break;
|
||||
}
|
||||
case EVENTLOG_WARNING_TYPE :
|
||||
{
|
||||
reportAnWEvent(NTP_WARNING,1,lpszStrings);
|
||||
break;
|
||||
}
|
||||
} /* switch end */
|
||||
|
||||
}
|
||||
#endif /* SYS_WINNT */
|
||||
else {
|
||||
#else
|
||||
{
|
||||
#endif /* VMS && SYS_VXWORKS*/
|
||||
extern char * humanlogtime P((void));
|
||||
|
||||
FILE *out_file = syslog_file ? syslog_file
|
||||
: level <= LOG_ERR ? stderr : stdout;
|
||||
/* syslog() provides the timestamp, so if we're not using
|
||||
syslog, we must provide it. */
|
||||
prog = strrchr(progname, '/');
|
||||
if (prog == NULL)
|
||||
prog = progname;
|
||||
else
|
||||
prog++;
|
||||
(void) fprintf(out_file, "%s ", humanlogtime ());
|
||||
(void) fprintf(out_file, "%s[%d]: %s", prog, (int)getpid(), buf);
|
||||
fflush (out_file);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/* $NetBSD: netof.c,v 1.4 1999/07/03 12:30:31 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* netof - return the net address part of an ip address
|
||||
* (zero out host part)
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
u_int32
|
||||
netof(num)
|
||||
u_int32 num;
|
||||
{
|
||||
register u_int32 netnum;
|
||||
|
||||
netnum = num;
|
||||
if(IN_CLASSC(netnum))
|
||||
netnum &= IN_CLASSC_NET;
|
||||
else if (IN_CLASSB(netnum))
|
||||
netnum &= IN_CLASSB_NET;
|
||||
else /* treat all other like class A */
|
||||
netnum &= IN_CLASSA_NET;
|
||||
return netnum;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/* $NetBSD: numtoa.c,v 1.2 1998/01/09 03:16:26 perry Exp $ */
|
||||
|
||||
/*
|
||||
* numtoa - return asciized network numbers store in local array space
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
char *
|
||||
numtoa(num)
|
||||
u_int32 num;
|
||||
{
|
||||
register u_int32 netnum;
|
||||
register char *buf;
|
||||
|
||||
netnum = ntohl(num);
|
||||
LIB_GETBUF(buf);
|
||||
(void) sprintf(buf, "%lu.%lu.%lu.%lu", ((u_long)netnum >> 24) & 0xff,
|
||||
((u_long)netnum >> 16) & 0xff, ((u_long)netnum >> 8) & 0xff,
|
||||
(u_long)netnum & 0xff);
|
||||
return buf;
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/* $NetBSD: numtohost.c,v 1.4 1999/07/03 12:30:31 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* numtohost - convert network number to host name.
|
||||
*/
|
||||
#include <netdb.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_stdlib.h"
|
||||
#include "lib_strbuf.h"
|
||||
|
||||
#define LOOPBACKNET 0x7f000000
|
||||
#define LOOPBACKHOST 0x7f000001
|
||||
#define LOOPBACKNETMASK 0xff000000
|
||||
|
||||
char *
|
||||
numtohost(netnum)
|
||||
u_int32 netnum;
|
||||
{
|
||||
char *bp;
|
||||
struct hostent *hp;
|
||||
|
||||
/*
|
||||
* This is really gross, but saves lots of hanging looking for
|
||||
* hostnames for the radio clocks. Don't bother looking up
|
||||
* addresses on the loopback network except for the loopback
|
||||
* host itself.
|
||||
*/
|
||||
if ((((ntohl(netnum) & LOOPBACKNETMASK) == LOOPBACKNET)
|
||||
&& (ntohl(netnum) != LOOPBACKHOST))
|
||||
|| ((hp = gethostbyaddr((char *)&netnum, sizeof netnum, AF_INET))
|
||||
== 0))
|
||||
return numtoa(netnum);
|
||||
|
||||
LIB_GETBUF(bp);
|
||||
|
||||
bp[LIB_BUFLENGTH-1] = '\0';
|
||||
(void) strncpy(bp, hp->h_name, LIB_BUFLENGTH-1);
|
||||
return bp;
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
/* $NetBSD: octtoint.c,v 1.2 1998/01/09 03:16:28 perry Exp $ */
|
||||
|
||||
/*
|
||||
* octtoint - convert an ascii string in octal to an unsigned
|
||||
* long, with error checking
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
int
|
||||
octtoint(str, ival)
|
||||
const char *str;
|
||||
u_long *ival;
|
||||
{
|
||||
register u_long u;
|
||||
register const char *cp;
|
||||
|
||||
cp = str;
|
||||
|
||||
if (*cp == '\0')
|
||||
return 0;
|
||||
|
||||
u = 0;
|
||||
while (*cp != '\0') {
|
||||
if (!isdigit(*cp) || *cp == '8' || *cp == '9')
|
||||
return 0;
|
||||
if (u >= 0x20000000)
|
||||
return 0; /* overflow */
|
||||
u <<= 3;
|
||||
u += *cp++ - '0'; /* ascii dependent */
|
||||
}
|
||||
*ival = u;
|
||||
return 1;
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/* $NetBSD: prettydate.c,v 1.5 1999/07/03 12:30:31 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* prettydate - convert a time stamp to something readable
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_unixtime.h" /* includes <sys/time.h> */
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
#ifndef TM_IN_SYS_TIME
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
char *
|
||||
prettydate(ts)
|
||||
l_fp *ts;
|
||||
{
|
||||
char *bp;
|
||||
struct tm *tm;
|
||||
time_t sec;
|
||||
u_long msec;
|
||||
static const char *months[] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
static const char *days[] = {
|
||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
||||
};
|
||||
|
||||
LIB_GETBUF(bp);
|
||||
|
||||
sec = ts->l_ui - JAN_1970;
|
||||
msec = ts->l_uf / 4294967; /* fract / (2 ** 32 / 1000) */
|
||||
|
||||
tm = localtime(&sec);
|
||||
|
||||
(void) sprintf(bp, "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03lu",
|
||||
(u_long)ts->l_ui, (u_long)ts->l_uf, days[tm->tm_wday],
|
||||
months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year,
|
||||
tm->tm_hour,tm->tm_min, tm->tm_sec, msec);
|
||||
|
||||
return bp;
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/* $NetBSD: ranny.c,v 1.2 1998/01/09 03:16:29 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Random number generator is:
|
||||
*
|
||||
* Copyright 1988 by Rayan S. Zachariassen, all rights reserved.
|
||||
* This will be free software, but only when it is finished.
|
||||
*
|
||||
* Used in xntp by permission of the author. If copyright is
|
||||
* annoying to you, read no further. Instead, look up the reference,
|
||||
* write me an equivalent to this and send it back to me.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Random number generator; see Knuth Vol 2. 2nd ed. p.27 (section 3.2.2)
|
||||
*/
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
extern time_t time P((time_t *loc));
|
||||
|
||||
/*
|
||||
* 55 random numbers, not all even. Note we don't initialize ran_y
|
||||
* directly since I have had thoughts of putting this in an EPROM
|
||||
*/
|
||||
static time_t ran_y[55];
|
||||
|
||||
static time_t init_ran_y[55] = {
|
||||
1860909544, 231033423, 437666411, 1349655137, 2014584962,
|
||||
504613712, 656256107, 1246027206, 573713775, 643466871,
|
||||
540235388, 1630565153, 443649364, 729302839, 1933991552,
|
||||
944681982, 949111118, 406212522, 1065063137, 1712954727,
|
||||
73280612, 787623973, 1874130997, 801658492, 73395958,
|
||||
739165367, 596047144, 490055249, 1131094323, 662727104,
|
||||
483614097, 844520219, 893760527, 921280508, 46691708,
|
||||
760861842, 1425894220, 702947816, 2006889048, 1999607995,
|
||||
1346414687, 399640789, 1482689501, 1790064052, 1128943628,
|
||||
1269197405, 587262386, 2078054746, 1675409928, 1652325524,
|
||||
1643525825, 1748690540, 292465849, 1370173174, 402865384
|
||||
};
|
||||
|
||||
static int ran_j;
|
||||
static int ran_k;
|
||||
|
||||
|
||||
/*
|
||||
* ranp2 - return a random integer in the range 0 .. (1 << m) - 1
|
||||
*/
|
||||
u_long
|
||||
ranp2(m)
|
||||
int m;
|
||||
{
|
||||
time_t r;
|
||||
|
||||
ran_y[ran_k] += ran_y[ran_j]; /* overflow does a mod */
|
||||
r = ran_y[ran_k];
|
||||
if (ran_k-- == 0)
|
||||
ran_k = 54;
|
||||
if (ran_j-- == 0)
|
||||
ran_j = 54;
|
||||
return (u_long)(r & ((1 << m ) - 1));
|
||||
}
|
||||
|
||||
/*
|
||||
* init_random - do initialization of random number routine
|
||||
*/
|
||||
void
|
||||
init_random()
|
||||
{
|
||||
register int i;
|
||||
register time_t now;
|
||||
|
||||
ran_j = 23;
|
||||
ran_k = 54;
|
||||
|
||||
/*
|
||||
* Randomize the seed array some more. The time of day
|
||||
* should be initialized by now.
|
||||
*/
|
||||
now = time((time_t *)0) | 01;
|
||||
|
||||
for (i = 0; i < 55; ++i)
|
||||
ran_y[i] = now * init_ran_y[i]; /* overflow does a mod */
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/* $NetBSD: refnumtoa.c,v 1.4 1999/07/03 12:30:31 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* refnumtoa - return asciized refclock addresses stored in local array space
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
char *
|
||||
refnumtoa(num)
|
||||
u_int32 num;
|
||||
{
|
||||
register u_int32 netnum;
|
||||
register char *buf;
|
||||
register const char *rclock;
|
||||
|
||||
netnum = ntohl(num);
|
||||
|
||||
LIB_GETBUF(buf);
|
||||
|
||||
rclock = clockname((int)((u_long)netnum >> 8) & 0xff);
|
||||
|
||||
if (rclock != NULL)
|
||||
(void)sprintf(buf, "%s(%lu)", rclock, (u_long)netnum & 0xff);
|
||||
else
|
||||
(void)sprintf(buf, "REFCLK(%lu,%lu)",
|
||||
((u_long)netnum >> 8) & 0xff, (u_long)netnum & 0xff);
|
||||
return buf;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
# $NetBSD: shlib_version,v 1.3 1999/02/25 08:02:20 abs Exp $
|
||||
# Remember to update distrib/sets/lists/base/shl.* when changing
|
||||
#
|
||||
major=0
|
||||
minor=0
|
@ -1,262 +0,0 @@
|
||||
/* $NetBSD: statestr.c,v 1.6 1999/07/03 12:30:31 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* pretty printing of status information
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "ntp_stdlib.h"
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp.h"
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_refclock.h"
|
||||
#include "ntp_control.h"
|
||||
#include "ntp_string.h"
|
||||
|
||||
/*
|
||||
* Structure for turning various constants into a readable string.
|
||||
*/
|
||||
struct codestring {
|
||||
int code;
|
||||
const char *string;
|
||||
};
|
||||
|
||||
/*
|
||||
* Leap values
|
||||
*/
|
||||
static
|
||||
struct codestring leap_codes[] = {
|
||||
{ LEAP_NOWARNING, "leap_none" },
|
||||
{ LEAP_ADDSECOND, "leap_add_sec" },
|
||||
{ LEAP_DELSECOND, "leap_del_sec" },
|
||||
{ LEAP_NOTINSYNC, "sync_alarm" },
|
||||
{ -1, "leap" }
|
||||
};
|
||||
|
||||
/*
|
||||
* Clock source
|
||||
*/
|
||||
static
|
||||
struct codestring sync_codes[] = {
|
||||
{ CTL_SST_TS_UNSPEC, "sync_unspec" },
|
||||
{ CTL_SST_TS_ATOM, "sync_atomic" },
|
||||
{ CTL_SST_TS_LF, "sync_lf_clock" },
|
||||
{ CTL_SST_TS_HF, "sync_hf_clock" },
|
||||
{ CTL_SST_TS_UHF, "sync_uhf_clock" },
|
||||
{ CTL_SST_TS_LOCAL, "sync_local_proto" },
|
||||
{ CTL_SST_TS_NTP, "sync_ntp" },
|
||||
{ CTL_SST_TS_UDPTIME, "sync_udp/time" },
|
||||
{ CTL_SST_TS_WRSTWTCH, "sync_wristwatch" },
|
||||
{ CTL_SST_TS_TELEPHONE, "sync_telephone" },
|
||||
{ -1, "sync" }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Peer selection
|
||||
*/
|
||||
static
|
||||
struct codestring select_codes[] = {
|
||||
{ CTL_PST_SEL_REJECT, "sel_reject" },
|
||||
{ CTL_PST_SEL_SANE, "sel_sane" },
|
||||
{ CTL_PST_SEL_CORRECT, "sel_correct" },
|
||||
{ CTL_PST_SEL_SELCAND, "sel_candidate" },
|
||||
{ CTL_PST_SEL_SYNCCAND, "sel_sync" },
|
||||
{ CTL_PST_SEL_DISTSYSPEER, "sel_sys.peer, hi_dist" },
|
||||
{ CTL_PST_SEL_SYSPEER, "sel_sys.peer" },
|
||||
{ -1, "sel" }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Clock status
|
||||
*/
|
||||
static
|
||||
struct codestring clock_codes[] = {
|
||||
{ CTL_CLK_OKAY, "clk_okay" },
|
||||
{ CTL_CLK_NOREPLY, "clk_noreply" },
|
||||
{ CTL_CLK_BADFORMAT, "clk_badformat" },
|
||||
{ CTL_CLK_FAULT, "clk_fault" },
|
||||
{ CTL_CLK_PROPAGATION, "clk_propagation" },
|
||||
{ CTL_CLK_BADDATE, "clk_baddate" },
|
||||
{ CTL_CLK_BADTIME, "clk_badtime" },
|
||||
{ -1, "clk" }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* System Events
|
||||
*/
|
||||
static
|
||||
struct codestring sys_codes[] = {
|
||||
{ EVNT_UNSPEC, "event_unspec" },
|
||||
{ EVNT_SYSRESTART, "event_restart" },
|
||||
{ EVNT_SYSFAULT, "event_fault" },
|
||||
{ EVNT_SYNCCHG, "event_sync_chg" },
|
||||
{ EVNT_PEERSTCHG, "event_peer/strat_chg" },
|
||||
{ EVNT_CLOCKRESET, "event_clock_reset" },
|
||||
{ EVNT_BADDATETIM, "event_bad_date" },
|
||||
{ EVNT_CLOCKEXCPT, "event_clock_excptn" },
|
||||
{ -1, "event" }
|
||||
};
|
||||
|
||||
/*
|
||||
* Peer Events
|
||||
*/
|
||||
static
|
||||
struct codestring peer_codes[] = {
|
||||
{ EVNT_UNSPEC, "event_unspec" },
|
||||
{ EVNT_PEERIPERR & ~PEER_EVENT, "event_ip_err" },
|
||||
{ EVNT_PEERAUTH & ~PEER_EVENT, "event_authen" },
|
||||
{ EVNT_UNREACH & ~PEER_EVENT, "event_unreach" },
|
||||
{ EVNT_REACH & ~PEER_EVENT, "event_reach" },
|
||||
{ EVNT_PEERCLOCK & ~PEER_EVENT, "event_peer_clock" },
|
||||
#if 0
|
||||
{ EVNT_PEERSTRAT & ~PEER_EVENT, "event_stratum_chg" },
|
||||
#endif
|
||||
{ -1, "event" }
|
||||
};
|
||||
|
||||
/* Forwards */
|
||||
static const char *getcode P((int, struct codestring *));
|
||||
static char *getevents P((int));
|
||||
|
||||
/*
|
||||
* getcode - return string corresponding to code
|
||||
*/
|
||||
static const char *
|
||||
getcode(code, codetab)
|
||||
int code;
|
||||
struct codestring *codetab;
|
||||
{
|
||||
static char buf[30];
|
||||
|
||||
while (codetab->code != -1) {
|
||||
if (codetab->code == code)
|
||||
return (char *) codetab->string;
|
||||
codetab++;
|
||||
}
|
||||
(void) sprintf(buf, "%s_%d", codetab->string, code);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* getevents - return a descriptive string for the event count
|
||||
*/
|
||||
static char *
|
||||
getevents(cnt)
|
||||
int cnt;
|
||||
{
|
||||
static char buf[20];
|
||||
|
||||
if (cnt == 0)
|
||||
return "no events";
|
||||
(void) sprintf(buf, "%d event%s", cnt, (cnt==1) ? "" : "s");
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* statustoa - return a descriptive string for a peer status
|
||||
*/
|
||||
char *
|
||||
statustoa(type, st)
|
||||
int type;
|
||||
int st;
|
||||
{
|
||||
char *cb;
|
||||
u_char pst;
|
||||
|
||||
LIB_GETBUF(cb);
|
||||
|
||||
switch (type) {
|
||||
case TYPE_SYS:
|
||||
(void)strcpy(cb, getcode(CTL_SYS_LI(st), leap_codes));
|
||||
(void)strcat(cb, ", ");
|
||||
(void)strcat(cb, getcode(CTL_SYS_SOURCE(st) & ~CTL_SST_TS_PPS, sync_codes));
|
||||
if (CTL_SYS_SOURCE(st) & CTL_SST_TS_PPS)
|
||||
(void)strcat(cb, "/PPS");
|
||||
(void)strcat(cb, ", ");
|
||||
(void)strcat(cb, getevents(CTL_SYS_NEVNT(st)));
|
||||
(void)strcat(cb, ", ");
|
||||
(void)strcat(cb, getcode(CTL_SYS_EVENT(st), sys_codes));
|
||||
break;
|
||||
|
||||
case TYPE_PEER:
|
||||
/*
|
||||
* Handcraft the bits
|
||||
*/
|
||||
pst = CTL_PEER_STATVAL(st);
|
||||
if (!(pst & CTL_PST_REACH)) {
|
||||
(void)strcpy(cb, "unreach");
|
||||
} else {
|
||||
(void)strcpy(cb, "reach");
|
||||
|
||||
}
|
||||
if (pst & CTL_PST_CONFIG)
|
||||
(void)strcat(cb, ", conf");
|
||||
if (pst & CTL_PST_AUTHENABLE) {
|
||||
if (!(pst & CTL_PST_REACH) || (pst & CTL_PST_AUTHENTIC))
|
||||
(void)strcat(cb, ", auth");
|
||||
else
|
||||
(void)strcat(cb, ", unauth");
|
||||
}
|
||||
|
||||
/*
|
||||
* Now the codes
|
||||
*/
|
||||
if ((pst & 0x7) != CTL_PST_SEL_REJECT) {
|
||||
(void)strcat(cb, ", ");
|
||||
(void)strcat(cb, getcode(pst & 0x7, select_codes));
|
||||
}
|
||||
(void)strcat(cb, ", ");
|
||||
(void)strcat(cb, getevents(CTL_PEER_NEVNT(st)));
|
||||
if (CTL_PEER_EVENT(st) != EVNT_UNSPEC) {
|
||||
(void)strcat(cb, ", ");
|
||||
(void)strcat(cb, getcode(CTL_PEER_EVENT(st),
|
||||
peer_codes));
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_CLOCK:
|
||||
(void)strcpy(cb, getcode(((st)>>8) & 0xff, clock_codes));
|
||||
(void)strcat(cb, ", last_");
|
||||
(void)strcat(cb, getcode((st) & 0xff, clock_codes));
|
||||
break;
|
||||
}
|
||||
return cb;
|
||||
}
|
||||
|
||||
const char *
|
||||
eventstr(num)
|
||||
int num;
|
||||
{
|
||||
return getcode(num & ~PEER_EVENT, (num & PEER_EVENT) ? peer_codes : sys_codes);
|
||||
}
|
||||
|
||||
const char *
|
||||
ceventstr(num)
|
||||
int num;
|
||||
{
|
||||
return getcode(num, clock_codes);
|
||||
}
|
||||
|
||||
const char *
|
||||
sysstatstr(status)
|
||||
int status;
|
||||
{
|
||||
return statustoa(TYPE_SYS, status);
|
||||
}
|
||||
|
||||
const char *
|
||||
peerstatstr(status)
|
||||
int status;
|
||||
{
|
||||
return statustoa(TYPE_PEER, status);
|
||||
}
|
||||
|
||||
const char *
|
||||
clockstatstr(status)
|
||||
int status;
|
||||
{
|
||||
return statustoa(TYPE_CLOCK, status);
|
||||
}
|
||||
|
@ -1,102 +0,0 @@
|
||||
/* $NetBSD: syssignal.c,v 1.5 2000/01/21 17:08:34 mycroft Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "ntp_syslog.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
#ifdef HAVE_SIGACTION
|
||||
#include <errno.h>
|
||||
|
||||
void
|
||||
signal_no_reset(sig, func)
|
||||
int sig;
|
||||
void (*func) P((int));
|
||||
{
|
||||
int n;
|
||||
struct sigaction vec;
|
||||
|
||||
vec.sa_handler = func;
|
||||
sigemptyset(&vec.sa_mask);
|
||||
#if 0
|
||||
#ifdef SA_RESTART
|
||||
vec.sa_flags = SA_RESTART;
|
||||
#else
|
||||
vec.sa_flags = 0;
|
||||
#endif
|
||||
#else
|
||||
vec.sa_flags = 0;
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
struct sigaction ovec;
|
||||
|
||||
n = sigaction(sig, &vec, &ovec);
|
||||
if (n == -1 && errno == EINTR) continue;
|
||||
if (ovec.sa_flags)
|
||||
msyslog(LOG_DEBUG, "signal_no_reset: signal %d had flags %x",
|
||||
sig, ovec.sa_flags);
|
||||
break;
|
||||
}
|
||||
if (n == -1) {
|
||||
perror("sigaction");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#elif HAVE_SIGVEC
|
||||
|
||||
void
|
||||
signal_no_reset(sig, func)
|
||||
int sig;
|
||||
RETSIGTYPE (*func) P((int));
|
||||
{
|
||||
struct sigvec sv;
|
||||
int n;
|
||||
|
||||
bzero((char *) &sv, sizeof(sv));
|
||||
sv.sv_handler = func;
|
||||
n = sigvec(sig, &sv, (struct sigvec *)NULL);
|
||||
if (n == -1) {
|
||||
perror("sigvec");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#elif HAVE_SIGSET
|
||||
|
||||
void
|
||||
signal_no_reset(sig, func)
|
||||
int sig;
|
||||
RETSIGTYPE (*func) P((int));
|
||||
{
|
||||
int n;
|
||||
|
||||
n = sigset(sig, func);
|
||||
if (n == -1) {
|
||||
perror("sigset");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* Beware! This implementation resets the signal to SIG_DFL */
|
||||
void
|
||||
signal_no_reset(sig, func)
|
||||
int sig;
|
||||
RETSIGTYPE (*func) P((int));
|
||||
{
|
||||
int n;
|
||||
|
||||
n = signal(sig, func);
|
||||
if (n == -1) {
|
||||
perror("signal");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,580 +0,0 @@
|
||||
/* $NetBSD: systime.c,v 1.6 1999/10/09 19:42:46 sommerfeld Exp $ */
|
||||
|
||||
/*
|
||||
* systime -- routines to fiddle a UNIX clock.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
#ifdef HAVE_UTMP_H
|
||||
# include <utmp.h>
|
||||
#endif /* HAVE_UTMP_H */
|
||||
#ifdef HAVE_UTMPX_H
|
||||
# include <utmpx.h>
|
||||
#endif /* HAVE_UTMPX_H */
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_syslog.h"
|
||||
#include "ntp_unixtime.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
#if defined(GDT_SURVEYING)
|
||||
l_fp gdt_rsadj; /* running sum of adjustments to time */
|
||||
#endif
|
||||
|
||||
#if defined(STEP_SLEW)
|
||||
# define SLEWALWAYS
|
||||
#endif
|
||||
|
||||
extern int debug;
|
||||
int allow_set_backward;
|
||||
|
||||
/*
|
||||
* These routines (init_systime, get_systime, step_systime, adj_systime)
|
||||
* implement an interface between the (more or less) system independent
|
||||
* bits of NTP and the peculiarities of dealing with the Unix system
|
||||
* clock. These routines will run with good precision fairly independently
|
||||
* of your kernel's value of tickadj. I couldn't tell the difference
|
||||
* between tickadj==40 and tickadj==5 on a microvax, though I prefer
|
||||
* to set tickadj == 500/hz when in doubt. At your option you
|
||||
* may compile this so that your system's clock is always slewed to the
|
||||
* correct time even for large corrections. Of course, all of this takes
|
||||
* a lot of code which wouldn't be needed with a reasonable tickadj and
|
||||
* a willingness to let the clock be stepped occasionally. Oh well.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Clock variables. We round calls to adjtime() to adj_precision
|
||||
* microseconds, and limit the adjustment to tvu_maxslew microseconds
|
||||
* (tsf_maxslew fractional sec) in one adjustment interval. As we are
|
||||
* thus limited in the speed and precision with which we can adjust the
|
||||
* clock, we compensate by keeping the known "error" in the system time
|
||||
* in sys_clock_offset. This is added to timestamps returned by get_systime().
|
||||
* We also remember the clock precision we computed from the kernel in
|
||||
* case someone asks us.
|
||||
*/
|
||||
|
||||
long sys_clock;
|
||||
|
||||
long adj_precision; /* adj precision in usec (tickadj) */
|
||||
long tvu_maxslew; /* maximum adjust doable in 1 second */
|
||||
|
||||
u_long tsf_maxslew; /* same as above, as long format */
|
||||
|
||||
l_fp sys_clock_offset; /* correction for current system time */
|
||||
|
||||
#ifdef SYS_WINNT
|
||||
/*
|
||||
* number of 100 nanosecond units added to the clock at each tick
|
||||
* determined by GetSystemTimeAdjustment() in clock_parms()
|
||||
*/
|
||||
long units_per_tick;
|
||||
#endif /* SYS_WINNT */
|
||||
|
||||
/*
|
||||
* get_systime - return the system time in timestamp format
|
||||
* As a side effect, update sys_clock.
|
||||
*/
|
||||
void
|
||||
get_systime(now)
|
||||
l_fp *now;
|
||||
{
|
||||
struct timeval tv;
|
||||
#ifdef HAVE_GETCLOCK
|
||||
struct timespec ts;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get the time of day, convert to time stamp format
|
||||
* and add in the current time offset. Then round
|
||||
* appropriately.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_GETCLOCK
|
||||
(void) getclock(TIMEOFDAY, &ts);
|
||||
tv.tv_sec = ts.tv_sec;
|
||||
tv.tv_usec = ts.tv_nsec / 1000;
|
||||
#else /* not HAVE_GETCLOCK */
|
||||
(void) GETTIMEOFDAY(&tv, (struct timezone *)0);
|
||||
#endif /* not HAVE_GETCLOCK */
|
||||
|
||||
TVTOTS(&tv, now);
|
||||
L_ADD(now, &sys_clock_offset);
|
||||
if (now->l_uf & TS_ROUNDBIT)
|
||||
L_ADDUF(now, TS_ROUNDBIT);
|
||||
|
||||
now->l_ui += JAN_1970;
|
||||
now->l_uf &= TS_MASK;
|
||||
|
||||
sys_clock = now->l_ui;
|
||||
}
|
||||
|
||||
/*
|
||||
* step_systime - do a step adjustment in the system time (at least from
|
||||
* NTP's point of view.
|
||||
*/
|
||||
int
|
||||
step_systime(now)
|
||||
l_fp *now;
|
||||
{
|
||||
register u_long tmp_ui;
|
||||
register u_long tmp_uf;
|
||||
int isneg;
|
||||
#ifdef STEP_SLEW
|
||||
int n;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Take the absolute value of the offset
|
||||
*/
|
||||
tmp_ui = now->l_ui;
|
||||
tmp_uf = now->l_uf;
|
||||
if (M_ISNEG(tmp_ui, tmp_uf)) {
|
||||
M_NEG(tmp_ui, tmp_uf);
|
||||
isneg = 1;
|
||||
} else
|
||||
isneg = 0;
|
||||
#ifdef SLEWALWAYS
|
||||
#ifdef STEP_SLEW
|
||||
|
||||
if (tmp_ui >= 3) { /* Step it and slew we might win */
|
||||
n = step_systime_real(now);
|
||||
if (!n) return n;
|
||||
if (isneg)
|
||||
now->l_ui = ~0;
|
||||
else
|
||||
now->l_ui = ~0;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Just add adjustment into the current offset. The update
|
||||
* routine will take care of bringing the system clock into
|
||||
* line.
|
||||
*/
|
||||
L_ADD(&sys_clock_offset, now);
|
||||
#if defined(GDT_SURVEYING)
|
||||
L_ADD(&gdt_rsadj, now);
|
||||
#endif
|
||||
return 1;
|
||||
#else /* SLEWALWAYS */
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug > 2)
|
||||
printf ("allow_set_backward=%d\n",allow_set_backward);
|
||||
#endif
|
||||
if (isneg && !allow_set_backward) {
|
||||
L_ADD(&sys_clock_offset, now);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
if (debug > 2)
|
||||
printf ("calling step_systime_real from not slewalways\n");
|
||||
#endif
|
||||
return step_systime_real(now);
|
||||
}
|
||||
#endif /* SLEWALWAYS */
|
||||
}
|
||||
|
||||
int max_no_complete = 20;
|
||||
|
||||
/*
|
||||
* adj_systime - called once every second to make system time adjustments.
|
||||
*/
|
||||
int
|
||||
adj_systime(now)
|
||||
l_fp *now;
|
||||
{
|
||||
register u_int32 offset_i, offset_f;
|
||||
register long temp;
|
||||
register u_long residual;
|
||||
register int isneg = 0;
|
||||
struct timeval adjtv;
|
||||
#ifndef SYS_WINNT
|
||||
struct timeval oadjtv;
|
||||
l_fp oadjts;
|
||||
#endif
|
||||
long adj = now->l_f;
|
||||
int rval;
|
||||
|
||||
#ifdef SYS_WINNT
|
||||
DWORD dwTimeAdjustment;
|
||||
#endif /* SYS_WINNT */
|
||||
|
||||
#if defined(GDT_SURVEYING)
|
||||
/* add to record of increments */
|
||||
M_ADDF(gdt_rsadj.l_ui, gdt_rsadj.l_uf, adj);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug > 4)
|
||||
printf("systime: offset %s\n", lfptoa(now, 6));
|
||||
#endif
|
||||
/*
|
||||
* Move the current offset into the registers
|
||||
*/
|
||||
offset_i = sys_clock_offset.l_ui;
|
||||
offset_f = sys_clock_offset.l_uf;
|
||||
|
||||
/*
|
||||
* Add the new adjustment into the system offset. Adjust the
|
||||
* system clock to minimize this.
|
||||
*/
|
||||
M_ADDF(offset_i, offset_f, adj);
|
||||
if (M_ISNEG(offset_i, offset_f)) {
|
||||
isneg = 1;
|
||||
M_NEG(offset_i, offset_f);
|
||||
}
|
||||
adjtv.tv_sec = 0;
|
||||
if (offset_i > 0 || offset_f >= tsf_maxslew) {
|
||||
/*
|
||||
* Slew is bigger than we can complete in
|
||||
* the adjustment interval. Make a maximum
|
||||
* sized slew and reduce sys_clock_offset by this
|
||||
* much.
|
||||
*/
|
||||
M_SUBUF(offset_i, offset_f, tsf_maxslew);
|
||||
if (!isneg) {
|
||||
#ifndef SYS_WINNT
|
||||
adjtv.tv_usec = tvu_maxslew;
|
||||
#else
|
||||
dwTimeAdjustment = units_per_tick + tvu_maxslew / adj_precision;
|
||||
#endif /* SYS_WINNT */
|
||||
} else {
|
||||
#ifndef SYS_WINNT
|
||||
adjtv.tv_usec = -tvu_maxslew;
|
||||
#else
|
||||
dwTimeAdjustment = units_per_tick - tvu_maxslew / adj_precision;
|
||||
#endif /* SYS_WINNT */
|
||||
M_NEG(offset_i, offset_f);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug > 4)
|
||||
printf("systime: maximum slew: %s%s, remainder = %s\n",
|
||||
isneg?"-":"", umfptoa(0, tsf_maxslew, 9),
|
||||
mfptoa(offset_i, offset_f, 9));
|
||||
#endif
|
||||
} else {
|
||||
/*
|
||||
* We can do this slew in the time period. Do our
|
||||
* best approximation (rounded), save residual for
|
||||
* next adjustment.
|
||||
*
|
||||
* Note that offset_i is guaranteed to be 0 here.
|
||||
*/
|
||||
TSFTOTVU(offset_f, temp);
|
||||
#ifndef ADJTIME_IS_ACCURATE
|
||||
/*
|
||||
* Round value to be an even multiple of adj_precision
|
||||
*/
|
||||
residual = temp % adj_precision;
|
||||
temp -= residual;
|
||||
if ( (long) (residual << 1) >= adj_precision)
|
||||
temp += adj_precision;
|
||||
#endif /* ADJTIME_IS_ACCURATE */
|
||||
TVUTOTSF(temp, residual);
|
||||
M_SUBUF(offset_i, offset_f, residual);
|
||||
if (isneg) {
|
||||
#ifndef SYS_WINNT
|
||||
adjtv.tv_usec = -temp;
|
||||
#else
|
||||
dwTimeAdjustment = units_per_tick - temp / adj_precision;
|
||||
#endif /* SYS_WINNT */
|
||||
M_NEG(offset_i, offset_f);
|
||||
} else {
|
||||
#ifndef SYS_WINNT
|
||||
adjtv.tv_usec = temp;
|
||||
#else
|
||||
dwTimeAdjustment = units_per_tick + temp / adj_precision;
|
||||
#endif /* SYS_WINNT */
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (debug > 4)
|
||||
#ifndef SYS_WINNT
|
||||
printf(
|
||||
"systime: adjtv = %s sec, adjts = %s sec, sys_clock_offset = %s sec\n",
|
||||
tvtoa(&adjtv), umfptoa(0, residual, 6),
|
||||
mfptoa(offset_i, offset_f, 6));
|
||||
#else
|
||||
printf(
|
||||
"systime: dwTimeAdjustment = %d, sys_clock_offset = %s sec\n",
|
||||
dwTimeAdjustment, mfptoa(offset_i, offset_f, 6));
|
||||
#endif /* SYS_WINNT */
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
/*
|
||||
* Here we do the actual adjustment. If for some reason the adjtime()
|
||||
* call fails, like it is not implemented or something like that,
|
||||
* we honk to the log. If the previous adjustment did not complete,
|
||||
* we correct the residual offset and honk to the log, but only for
|
||||
* a little while.
|
||||
*/
|
||||
if (
|
||||
#ifndef SYS_WINNT
|
||||
/* casey - we need a posix type thang here */
|
||||
(adjtime(&adjtv, &oadjtv) < 0)
|
||||
#else
|
||||
(!SetSystemTimeAdjustment(dwTimeAdjustment, FALSE))
|
||||
#endif /* SYS_WINNT */
|
||||
) {
|
||||
msyslog(LOG_ERR, "Can't adjust time: %m");
|
||||
rval = 0;
|
||||
} else {
|
||||
sys_clock_offset.l_ui = offset_i;
|
||||
sys_clock_offset.l_uf = offset_f;
|
||||
rval = 1;
|
||||
#ifndef SYS_WINNT
|
||||
if (oadjtv.tv_sec != 0 || oadjtv.tv_usec != 0) {
|
||||
sTVTOTS(&oadjtv, &oadjts);
|
||||
L_ADD(&sys_clock_offset, &oadjts);
|
||||
#if defined(GDT_SURVEYING)
|
||||
L_ADD(&gdt_rsadj, &oadjts);
|
||||
#endif
|
||||
if (max_no_complete > 0) {
|
||||
max_no_complete--;
|
||||
NLOG(NLOG_SYSSTATUS|NLOG_SYNCSTATUS)
|
||||
msyslog(LOG_WARNING,
|
||||
"Previous time adjustment incomplete; residual %s sec\n",
|
||||
lfptoa(&oadjts, 6));
|
||||
}
|
||||
}
|
||||
#endif /* SYS_WINNT */
|
||||
}
|
||||
return(rval);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This is used by ntpdate even when xntpd does not use it! WLJ
|
||||
*/
|
||||
int
|
||||
step_systime_real(now)
|
||||
l_fp *now;
|
||||
{
|
||||
struct timeval timetv, adjtv, oldtimetv;
|
||||
int isneg = 0;
|
||||
#if defined(HAVE_GETCLOCK) || defined(HAVE_CLOCK_SETTIME)
|
||||
struct timespec ts;
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
if (debug)
|
||||
printf("step_systime: offset %s sys_offset %s\n",
|
||||
lfptoa(now, 6), lfptoa(&sys_clock_offset, 6));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We can afford to be sloppy here since if this is called
|
||||
* the time is really screwed and everything is being reset.
|
||||
*/
|
||||
L_ADD(&sys_clock_offset, now);
|
||||
#if defined(GDT_SURVEYING)
|
||||
L_ADD(&gdt_rsadj, now);
|
||||
#endif
|
||||
|
||||
if (L_ISNEG(&sys_clock_offset)) {
|
||||
isneg = 1;
|
||||
L_NEG(&sys_clock_offset);
|
||||
}
|
||||
TSTOTV(&sys_clock_offset, &adjtv);
|
||||
|
||||
#ifdef HAVE_GETCLOCK
|
||||
(void) getclock(TIMEOFDAY, &ts);
|
||||
timetv.tv_sec = ts.tv_sec;
|
||||
timetv.tv_usec = ts.tv_nsec / 1000;
|
||||
#else /* not HAVE_GETCLOCK */
|
||||
(void) GETTIMEOFDAY(&timetv, (struct timezone *)0);
|
||||
#endif /* not HAVE_GETCLOCK */
|
||||
|
||||
oldtimetv = timetv;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug)
|
||||
printf("step: %s sec, sys_clock_offset = %s sec, adjtv = %s sec, timetv = %s sec\n",
|
||||
lfptoa(now, 6), lfptoa(&sys_clock_offset, 6), tvtoa(&adjtv),
|
||||
utvtoa(&timetv));
|
||||
#endif
|
||||
if (isneg) {
|
||||
timetv.tv_sec -= adjtv.tv_sec;
|
||||
timetv.tv_usec -= adjtv.tv_usec;
|
||||
if (timetv.tv_usec < 0) {
|
||||
timetv.tv_sec--;
|
||||
timetv.tv_usec += 1000000;
|
||||
}
|
||||
} else {
|
||||
timetv.tv_sec += adjtv.tv_sec;
|
||||
timetv.tv_usec += adjtv.tv_usec;
|
||||
if (timetv.tv_usec >= 1000000) {
|
||||
timetv.tv_sec++;
|
||||
timetv.tv_usec -= 1000000;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (debug)
|
||||
printf("step: old timetv = %s sec\n", utvtoa(&timetv));
|
||||
#endif
|
||||
#if HAVE_CLOCK_SETTIME
|
||||
ts.tv_sec = timetv.tv_sec;
|
||||
ts.tv_nsec = timetv.tv_usec * 1000;
|
||||
#endif /* HAVE_CLOCK_SETTIME */
|
||||
if (
|
||||
#if HAVE_CLOCK_SETTIME
|
||||
(clock_settime(CLOCK_REALTIME, &ts) != 0)
|
||||
#else /* HAVE_CLOCK_SETTIME */
|
||||
(SETTIMEOFDAY(&timetv, (struct timezone *)0) != 0)
|
||||
#endif /* HAVE_CLOCK_SETTIME */
|
||||
) {
|
||||
msyslog(LOG_ERR, "Can't set time of day: %m");
|
||||
return (0);
|
||||
}
|
||||
#if DEBUG
|
||||
if (debug) {
|
||||
#ifdef HAVE_GETCLOCK
|
||||
(void) getclock(TIMEOFDAY, &ts);
|
||||
timetv.tv_sec = ts.tv_sec;
|
||||
timetv.tv_usec = ts.tv_nsec / 1000;
|
||||
#else /* not HAVE_GETCLOCK */
|
||||
(void) GETTIMEOFDAY(&timetv, (struct timezone *)0);
|
||||
#endif /* not HAVE_GETCLOCK */
|
||||
printf("step: new timetv = %s sec\n", utvtoa(&timetv));
|
||||
}
|
||||
#endif
|
||||
L_CLR(&sys_clock_offset);
|
||||
|
||||
#ifdef NEED_HPUX_ADJTIME
|
||||
/*
|
||||
* CHECKME: is this correct when called by ntpdate?????
|
||||
*/
|
||||
_clear_adjtime();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FreeBSD, for example, has:
|
||||
* struct utmp {
|
||||
* char ut_line[UT_LINESIZE];
|
||||
* char ut_name[UT_NAMESIZE];
|
||||
* char ut_host[UT_HOSTSIZE];
|
||||
* long ut_time;
|
||||
* };
|
||||
* and appends line="|", name="date", host="", time for the OLD
|
||||
* and appends line="{", name="date", host="", time for the NEW
|
||||
* to _PATH_WTMP .
|
||||
*
|
||||
* Some OSes have utmp, some have utmpx.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Write old and new time entries in utmp and wtmp if step adjustment
|
||||
* is greater than one second.
|
||||
*
|
||||
* This might become even Uglier...
|
||||
*/
|
||||
|
||||
if (oldtimetv.tv_sec != timetv.tv_sec)
|
||||
{
|
||||
#ifdef HAVE_UTMP_H
|
||||
struct utmp ut;
|
||||
#endif
|
||||
#ifdef HAVE_UTMPX_H
|
||||
struct utmpx utx;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UTMP_H
|
||||
memset((char *)&ut, 0, sizeof(ut));
|
||||
#endif
|
||||
#ifdef HAVE_UTMPX_H
|
||||
memset((char *)&utx, 0, sizeof(utx));
|
||||
#endif
|
||||
|
||||
/* UTMP */
|
||||
|
||||
#ifdef UPDATE_UTMP
|
||||
# ifdef HAVE_PUTUTLINE
|
||||
ut.ut_type = OLD_TIME;
|
||||
(void)strcpy(ut.ut_line, OTIME_MSG);
|
||||
ut.ut_time = oldtimetv.tv_sec;
|
||||
pututline(&ut);
|
||||
setutent();
|
||||
ut.ut_type = NEW_TIME;
|
||||
(void)strcpy(ut.ut_line, NTIME_MSG);
|
||||
ut.ut_time = timetv.tv_sec;
|
||||
pututline(&ut);
|
||||
endutent();
|
||||
# else /* not HAVE_PUTUTLINE */
|
||||
# endif /* not HAVE_PUTUTLINE */
|
||||
#endif /* UPDATE_UTMP */
|
||||
|
||||
/* UTMPX */
|
||||
|
||||
#ifdef UPDATE_UTMPX
|
||||
# ifdef HAVE_PUTUTXLINE
|
||||
utx.ut_type = OLD_TIME;
|
||||
(void)strcpy(utx.ut_line, OTIME_MSG);
|
||||
utx.ut_tv = oldtimetv;
|
||||
pututxline(&utx);
|
||||
setutxent();
|
||||
utx.ut_type = NEW_TIME;
|
||||
(void)strcpy(utx.ut_line, NTIME_MSG);
|
||||
utx.ut_tv = timetv;
|
||||
pututxline(&utx);
|
||||
endutxent();
|
||||
# else /* not HAVE_PUTUTXLINE */
|
||||
# endif /* not HAVE_PUTUTXLINE */
|
||||
#endif /* UPDATE_UTMPX */
|
||||
|
||||
/* WTMP */
|
||||
|
||||
#ifdef UPDATE_WTMP
|
||||
# ifdef HAVE_PUTUTLINE
|
||||
utmpname(WTMP_FILE);
|
||||
ut.ut_type = OLD_TIME;
|
||||
(void)strcpy(ut.ut_line, OTIME_MSG);
|
||||
ut.ut_time = oldtimetv.tv_sec;
|
||||
pututline(&ut);
|
||||
ut.ut_type = NEW_TIME;
|
||||
(void)strcpy(ut.ut_line, NTIME_MSG);
|
||||
ut.ut_time = timetv.tv_sec;
|
||||
pututline(&ut);
|
||||
endutent();
|
||||
# else /* not HAVE_PUTUTLINE */
|
||||
# endif /* not HAVE_PUTUTLINE */
|
||||
#endif /* UPDATE_WTMP */
|
||||
|
||||
/* WTMPX */
|
||||
|
||||
#ifdef UPDATE_WTMPX
|
||||
# ifdef HAVE_PUTUTXLINE
|
||||
utx.ut_type = OLD_TIME;
|
||||
utx.ut_tv = oldtimetv;
|
||||
(void)strcpy(utx.ut_line, OTIME_MSG);
|
||||
# ifdef HAVE_UPDWTMPX
|
||||
updwtmpx(WTMPX_FILE, &utx);
|
||||
# else /* not HAVE_UPDWTMPX */
|
||||
# endif /* not HAVE_UPDWTMPX */
|
||||
# else /* not HAVE_PUTUTXLINE */
|
||||
# endif /* not HAVE_PUTUTXLINE */
|
||||
# ifdef HAVE_PUTUTXLINE
|
||||
utx.ut_type = NEW_TIME;
|
||||
utx.ut_tv = timetv;
|
||||
(void)strcpy(utx.ut_line, NTIME_MSG);
|
||||
# ifdef HAVE_UPDWTMPX
|
||||
updwtmpx(WTMPX_FILE, &utx);
|
||||
# else /* not HAVE_UPDWTMPX */
|
||||
# endif /* not HAVE_UPDWTMPX */
|
||||
# else /* not HAVE_PUTUTXLINE */
|
||||
# endif /* not HAVE_PUTUTXLINE */
|
||||
#endif /* UPDATE_WTMPX */
|
||||
|
||||
}
|
||||
return (1);
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/* $NetBSD: tsftomsu.c,v 1.2 1998/01/09 03:16:33 perry Exp $ */
|
||||
|
||||
/*
|
||||
* tsftomsu - convert from a time stamp fraction to milliseconds
|
||||
*/
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
int
|
||||
tsftomsu(tsf, round)
|
||||
u_long tsf;
|
||||
int round;
|
||||
{
|
||||
register long val_ui, val_uf;
|
||||
register long tmp_ui, tmp_uf;
|
||||
register int i;
|
||||
|
||||
/*
|
||||
* Essentially, multiply by 10 three times in l_fp form.
|
||||
* The integral part is the milliseconds.
|
||||
*/
|
||||
val_ui = 0;
|
||||
val_uf = tsf;
|
||||
for (i = 3; i > 0; i--) {
|
||||
M_LSHIFT(val_ui, val_uf);
|
||||
tmp_ui = val_ui;
|
||||
tmp_uf = val_uf;
|
||||
M_LSHIFT(val_ui, val_uf);
|
||||
M_LSHIFT(val_ui, val_uf);
|
||||
M_ADD(val_ui, val_uf, tmp_ui, tmp_uf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Round the value if need be, then return it.
|
||||
*/
|
||||
if (round && (val_uf & 0x80000000))
|
||||
val_ui++;
|
||||
return (int)val_ui;
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
/* $NetBSD: tstotv.c,v 1.2 1998/01/09 03:16:34 perry Exp $ */
|
||||
|
||||
/*
|
||||
* tstotv - tables for converting from NTP time stamps to struct timeval
|
||||
*/
|
||||
|
||||
#include "ntp_types.h"
|
||||
|
||||
/*
|
||||
* Tables to convert from a time stamp fraction to usecs. Note that
|
||||
* the units of these tables are actually (usec<<3). We carry three
|
||||
* guard bits so that the result can be properly truncated (or rounded)
|
||||
* to be correct to the least significant bit.
|
||||
*
|
||||
* These tables are rounded.
|
||||
*/
|
||||
|
||||
long tstoushi[256] = {
|
||||
0x000000, 0x007a12, 0x00f424, 0x016e36,
|
||||
0x01e848, 0x02625a, 0x02dc6c, 0x03567e,
|
||||
0x03d090, 0x044aa2, 0x04c4b4, 0x053ec6,
|
||||
0x05b8d8, 0x0632ea, 0x06acfc, 0x07270e,
|
||||
0x07a120, 0x081b32, 0x089544, 0x090f56,
|
||||
0x098968, 0x0a037a, 0x0a7d8c, 0x0af79e,
|
||||
0x0b71b0, 0x0bebc2, 0x0c65d4, 0x0cdfe6,
|
||||
0x0d59f8, 0x0dd40a, 0x0e4e1c, 0x0ec82e,
|
||||
0x0f4240, 0x0fbc52, 0x103664, 0x10b076,
|
||||
0x112a88, 0x11a49a, 0x121eac, 0x1298be,
|
||||
0x1312d0, 0x138ce2, 0x1406f4, 0x148106,
|
||||
0x14fb18, 0x15752a, 0x15ef3c, 0x16694e,
|
||||
0x16e360, 0x175d72, 0x17d784, 0x185196,
|
||||
0x18cba8, 0x1945ba, 0x19bfcc, 0x1a39de,
|
||||
0x1ab3f0, 0x1b2e02, 0x1ba814, 0x1c2226,
|
||||
0x1c9c38, 0x1d164a, 0x1d905c, 0x1e0a6e,
|
||||
0x1e8480, 0x1efe92, 0x1f78a4, 0x1ff2b6,
|
||||
0x206cc8, 0x20e6da, 0x2160ec, 0x21dafe,
|
||||
0x225510, 0x22cf22, 0x234934, 0x23c346,
|
||||
0x243d58, 0x24b76a, 0x25317c, 0x25ab8e,
|
||||
0x2625a0, 0x269fb2, 0x2719c4, 0x2793d6,
|
||||
0x280de8, 0x2887fa, 0x29020c, 0x297c1e,
|
||||
0x29f630, 0x2a7042, 0x2aea54, 0x2b6466,
|
||||
0x2bde78, 0x2c588a, 0x2cd29c, 0x2d4cae,
|
||||
0x2dc6c0, 0x2e40d2, 0x2ebae4, 0x2f34f6,
|
||||
0x2faf08, 0x30291a, 0x30a32c, 0x311d3e,
|
||||
0x319750, 0x321162, 0x328b74, 0x330586,
|
||||
0x337f98, 0x33f9aa, 0x3473bc, 0x34edce,
|
||||
0x3567e0, 0x35e1f2, 0x365c04, 0x36d616,
|
||||
0x375028, 0x37ca3a, 0x38444c, 0x38be5e,
|
||||
0x393870, 0x39b282, 0x3a2c94, 0x3aa6a6,
|
||||
0x3b20b8, 0x3b9aca, 0x3c14dc, 0x3c8eee,
|
||||
0x3d0900, 0x3d8312, 0x3dfd24, 0x3e7736,
|
||||
0x3ef148, 0x3f6b5a, 0x3fe56c, 0x405f7e,
|
||||
0x40d990, 0x4153a2, 0x41cdb4, 0x4247c6,
|
||||
0x42c1d8, 0x433bea, 0x43b5fc, 0x44300e,
|
||||
0x44aa20, 0x452432, 0x459e44, 0x461856,
|
||||
0x469268, 0x470c7a, 0x47868c, 0x48009e,
|
||||
0x487ab0, 0x48f4c2, 0x496ed4, 0x49e8e6,
|
||||
0x4a62f8, 0x4add0a, 0x4b571c, 0x4bd12e,
|
||||
0x4c4b40, 0x4cc552, 0x4d3f64, 0x4db976,
|
||||
0x4e3388, 0x4ead9a, 0x4f27ac, 0x4fa1be,
|
||||
0x501bd0, 0x5095e2, 0x510ff4, 0x518a06,
|
||||
0x520418, 0x527e2a, 0x52f83c, 0x53724e,
|
||||
0x53ec60, 0x546672, 0x54e084, 0x555a96,
|
||||
0x55d4a8, 0x564eba, 0x56c8cc, 0x5742de,
|
||||
0x57bcf0, 0x583702, 0x58b114, 0x592b26,
|
||||
0x59a538, 0x5a1f4a, 0x5a995c, 0x5b136e,
|
||||
0x5b8d80, 0x5c0792, 0x5c81a4, 0x5cfbb6,
|
||||
0x5d75c8, 0x5defda, 0x5e69ec, 0x5ee3fe,
|
||||
0x5f5e10, 0x5fd822, 0x605234, 0x60cc46,
|
||||
0x614658, 0x61c06a, 0x623a7c, 0x62b48e,
|
||||
0x632ea0, 0x63a8b2, 0x6422c4, 0x649cd6,
|
||||
0x6516e8, 0x6590fa, 0x660b0c, 0x66851e,
|
||||
0x66ff30, 0x677942, 0x67f354, 0x686d66,
|
||||
0x68e778, 0x69618a, 0x69db9c, 0x6a55ae,
|
||||
0x6acfc0, 0x6b49d2, 0x6bc3e4, 0x6c3df6,
|
||||
0x6cb808, 0x6d321a, 0x6dac2c, 0x6e263e,
|
||||
0x6ea050, 0x6f1a62, 0x6f9474, 0x700e86,
|
||||
0x708898, 0x7102aa, 0x717cbc, 0x71f6ce,
|
||||
0x7270e0, 0x72eaf2, 0x736504, 0x73df16,
|
||||
0x745928, 0x74d33a, 0x754d4c, 0x75c75e,
|
||||
0x764170, 0x76bb82, 0x773594, 0x77afa6,
|
||||
0x7829b8, 0x78a3ca, 0x791ddc, 0x7997ee
|
||||
};
|
||||
|
||||
long tstousmid[256] = {
|
||||
0x0000, 0x007a, 0x00f4, 0x016e, 0x01e8, 0x0262, 0x02dc, 0x0356,
|
||||
0x03d1, 0x044b, 0x04c5, 0x053f, 0x05b9, 0x0633, 0x06ad, 0x0727,
|
||||
0x07a1, 0x081b, 0x0895, 0x090f, 0x0989, 0x0a03, 0x0a7e, 0x0af8,
|
||||
0x0b72, 0x0bec, 0x0c66, 0x0ce0, 0x0d5a, 0x0dd4, 0x0e4e, 0x0ec8,
|
||||
0x0f42, 0x0fbc, 0x1036, 0x10b0, 0x112b, 0x11a5, 0x121f, 0x1299,
|
||||
0x1313, 0x138d, 0x1407, 0x1481, 0x14fb, 0x1575, 0x15ef, 0x1669,
|
||||
0x16e3, 0x175d, 0x17d8, 0x1852, 0x18cc, 0x1946, 0x19c0, 0x1a3a,
|
||||
0x1ab4, 0x1b2e, 0x1ba8, 0x1c22, 0x1c9c, 0x1d16, 0x1d90, 0x1e0a,
|
||||
0x1e84, 0x1eff, 0x1f79, 0x1ff3, 0x206d, 0x20e7, 0x2161, 0x21db,
|
||||
0x2255, 0x22cf, 0x2349, 0x23c3, 0x243d, 0x24b7, 0x2531, 0x25ac,
|
||||
0x2626, 0x26a0, 0x271a, 0x2794, 0x280e, 0x2888, 0x2902, 0x297c,
|
||||
0x29f6, 0x2a70, 0x2aea, 0x2b64, 0x2bde, 0x2c59, 0x2cd3, 0x2d4d,
|
||||
0x2dc7, 0x2e41, 0x2ebb, 0x2f35, 0x2faf, 0x3029, 0x30a3, 0x311d,
|
||||
0x3197, 0x3211, 0x328b, 0x3306, 0x3380, 0x33fa, 0x3474, 0x34ee,
|
||||
0x3568, 0x35e2, 0x365c, 0x36d6, 0x3750, 0x37ca, 0x3844, 0x38be,
|
||||
0x3938, 0x39b3, 0x3a2d, 0x3aa7, 0x3b21, 0x3b9b, 0x3c15, 0x3c8f,
|
||||
0x3d09, 0x3d83, 0x3dfd, 0x3e77, 0x3ef1, 0x3f6b, 0x3fe5, 0x405f,
|
||||
0x40da, 0x4154, 0x41ce, 0x4248, 0x42c2, 0x433c, 0x43b6, 0x4430,
|
||||
0x44aa, 0x4524, 0x459e, 0x4618, 0x4692, 0x470c, 0x4787, 0x4801,
|
||||
0x487b, 0x48f5, 0x496f, 0x49e9, 0x4a63, 0x4add, 0x4b57, 0x4bd1,
|
||||
0x4c4b, 0x4cc5, 0x4d3f, 0x4db9, 0x4e34, 0x4eae, 0x4f28, 0x4fa2,
|
||||
0x501c, 0x5096, 0x5110, 0x518a, 0x5204, 0x527e, 0x52f8, 0x5372,
|
||||
0x53ec, 0x5466, 0x54e1, 0x555b, 0x55d5, 0x564f, 0x56c9, 0x5743,
|
||||
0x57bd, 0x5837, 0x58b1, 0x592b, 0x59a5, 0x5a1f, 0x5a99, 0x5b13,
|
||||
0x5b8d, 0x5c08, 0x5c82, 0x5cfc, 0x5d76, 0x5df0, 0x5e6a, 0x5ee4,
|
||||
0x5f5e, 0x5fd8, 0x6052, 0x60cc, 0x6146, 0x61c0, 0x623a, 0x62b5,
|
||||
0x632f, 0x63a9, 0x6423, 0x649d, 0x6517, 0x6591, 0x660b, 0x6685,
|
||||
0x66ff, 0x6779, 0x67f3, 0x686d, 0x68e7, 0x6962, 0x69dc, 0x6a56,
|
||||
0x6ad0, 0x6b4a, 0x6bc4, 0x6c3e, 0x6cb8, 0x6d32, 0x6dac, 0x6e26,
|
||||
0x6ea0, 0x6f1a, 0x6f94, 0x700f, 0x7089, 0x7103, 0x717d, 0x71f7,
|
||||
0x7271, 0x72eb, 0x7365, 0x73df, 0x7459, 0x74d3, 0x754d, 0x75c7,
|
||||
0x7641, 0x76bc, 0x7736, 0x77b0, 0x782a, 0x78a4, 0x791e, 0x7998
|
||||
};
|
||||
|
||||
long tstouslo[128] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
|
||||
0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
|
||||
0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e,
|
||||
0x1f, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
|
||||
0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
|
||||
0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x33, 0x34,
|
||||
0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c,
|
||||
0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44,
|
||||
0x45, 0x46, 0x47, 0x48, 0x48, 0x49, 0x4a, 0x4b,
|
||||
0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53,
|
||||
0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b,
|
||||
0x5c, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62,
|
||||
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
|
||||
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x71,
|
||||
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79
|
||||
};
|
@ -1,39 +0,0 @@
|
||||
/* $NetBSD: tvtoa.c,v 1.2 1998/01/09 03:16:35 perry Exp $ */
|
||||
|
||||
/*
|
||||
* tvtoa - return an asciized representation of a struct timeval
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "lib_strbuf.h"
|
||||
#if defined(VMS)
|
||||
#include "ntp_fp.h"
|
||||
#endif /* VMS */
|
||||
#include "ntp_stdlib.h"
|
||||
#include "ntp_unixtime.h"
|
||||
|
||||
char *
|
||||
tvtoa(tv)
|
||||
const struct timeval *tv;
|
||||
{
|
||||
register char *buf;
|
||||
register u_long sec;
|
||||
register u_long usec;
|
||||
register int isneg;
|
||||
|
||||
if (tv->tv_sec < 0 || tv->tv_usec < 0) {
|
||||
sec = -tv->tv_sec;
|
||||
usec = -tv->tv_usec;
|
||||
isneg = 1;
|
||||
} else {
|
||||
sec = tv->tv_sec;
|
||||
usec = tv->tv_usec;
|
||||
isneg = 0;
|
||||
}
|
||||
|
||||
LIB_GETBUF(buf);
|
||||
|
||||
(void) sprintf(buf, "%s%lu.%06lu", (isneg?"-":""), sec, usec);
|
||||
return buf;
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
/* $NetBSD: tvtots.c,v 1.2 1998/01/09 03:16:36 perry Exp $ */
|
||||
|
||||
/*
|
||||
* tvtots - tables for converting from Unix struct timeval's to
|
||||
* NTP time stamp format.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "ntp_types.h"
|
||||
|
||||
/*
|
||||
* Tables to calculate time stamp fractions from usecs. The entries
|
||||
* in these tables are offset into using each of the two low order
|
||||
* bytes plus the next 4 bits in a usec value (from a struct timeval).
|
||||
* These are summed to produce the time stamp fraction.
|
||||
*
|
||||
* Note that these tables are rounded (not truncated) to the nearest
|
||||
* low order bit in the fraction. The timestamp computed should be
|
||||
* +- 1.5 low order bits.
|
||||
*/
|
||||
|
||||
u_long ustotslo[256] = {
|
||||
0x00000000, 0x000010c7, 0x0000218e, 0x00003255,
|
||||
0x0000431c, 0x000053e3, 0x000064aa, 0x00007571,
|
||||
0x00008638, 0x000096ff, 0x0000a7c6, 0x0000b88d,
|
||||
0x0000c954, 0x0000da1b, 0x0000eae2, 0x0000fba9,
|
||||
0x00010c6f, 0x00011d36, 0x00012dfd, 0x00013ec4,
|
||||
0x00014f8b, 0x00016052, 0x00017119, 0x000181e0,
|
||||
0x000192a7, 0x0001a36e, 0x0001b435, 0x0001c4fc,
|
||||
0x0001d5c3, 0x0001e68a, 0x0001f751, 0x00020818,
|
||||
0x000218df, 0x000229a6, 0x00023a6d, 0x00024b34,
|
||||
0x00025bfb, 0x00026cc2, 0x00027d89, 0x00028e50,
|
||||
0x00029f17, 0x0002afde, 0x0002c0a5, 0x0002d16c,
|
||||
0x0002e233, 0x0002f2fa, 0x000303c0, 0x00031487,
|
||||
0x0003254e, 0x00033615, 0x000346dc, 0x000357a3,
|
||||
0x0003686a, 0x00037931, 0x000389f8, 0x00039abf,
|
||||
0x0003ab86, 0x0003bc4d, 0x0003cd14, 0x0003dddb,
|
||||
0x0003eea2, 0x0003ff69, 0x00041030, 0x000420f7,
|
||||
0x000431be, 0x00044285, 0x0004534c, 0x00046413,
|
||||
0x000474da, 0x000485a1, 0x00049668, 0x0004a72f,
|
||||
0x0004b7f6, 0x0004c8bd, 0x0004d984, 0x0004ea4b,
|
||||
0x0004fb12, 0x00050bd8, 0x00051c9f, 0x00052d66,
|
||||
0x00053e2d, 0x00054ef4, 0x00055fbb, 0x00057082,
|
||||
0x00058149, 0x00059210, 0x0005a2d7, 0x0005b39e,
|
||||
0x0005c465, 0x0005d52c, 0x0005e5f3, 0x0005f6ba,
|
||||
0x00060781, 0x00061848, 0x0006290f, 0x000639d6,
|
||||
0x00064a9d, 0x00065b64, 0x00066c2b, 0x00067cf2,
|
||||
0x00068db9, 0x00069e80, 0x0006af47, 0x0006c00e,
|
||||
0x0006d0d5, 0x0006e19c, 0x0006f263, 0x00070329,
|
||||
0x000713f0, 0x000724b7, 0x0007357e, 0x00074645,
|
||||
0x0007570c, 0x000767d3, 0x0007789a, 0x00078961,
|
||||
0x00079a28, 0x0007aaef, 0x0007bbb6, 0x0007cc7d,
|
||||
0x0007dd44, 0x0007ee0b, 0x0007fed2, 0x00080f99,
|
||||
0x00082060, 0x00083127, 0x000841ee, 0x000852b5,
|
||||
0x0008637c, 0x00087443, 0x0008850a, 0x000895d1,
|
||||
0x0008a698, 0x0008b75f, 0x0008c826, 0x0008d8ed,
|
||||
0x0008e9b4, 0x0008fa7b, 0x00090b41, 0x00091c08,
|
||||
0x00092ccf, 0x00093d96, 0x00094e5d, 0x00095f24,
|
||||
0x00096feb, 0x000980b2, 0x00099179, 0x0009a240,
|
||||
0x0009b307, 0x0009c3ce, 0x0009d495, 0x0009e55c,
|
||||
0x0009f623, 0x000a06ea, 0x000a17b1, 0x000a2878,
|
||||
0x000a393f, 0x000a4a06, 0x000a5acd, 0x000a6b94,
|
||||
0x000a7c5b, 0x000a8d22, 0x000a9de9, 0x000aaeb0,
|
||||
0x000abf77, 0x000ad03e, 0x000ae105, 0x000af1cc,
|
||||
0x000b0292, 0x000b1359, 0x000b2420, 0x000b34e7,
|
||||
0x000b45ae, 0x000b5675, 0x000b673c, 0x000b7803,
|
||||
0x000b88ca, 0x000b9991, 0x000baa58, 0x000bbb1f,
|
||||
0x000bcbe6, 0x000bdcad, 0x000bed74, 0x000bfe3b,
|
||||
0x000c0f02, 0x000c1fc9, 0x000c3090, 0x000c4157,
|
||||
0x000c521e, 0x000c62e5, 0x000c73ac, 0x000c8473,
|
||||
0x000c953a, 0x000ca601, 0x000cb6c8, 0x000cc78f,
|
||||
0x000cd856, 0x000ce91d, 0x000cf9e4, 0x000d0aaa,
|
||||
0x000d1b71, 0x000d2c38, 0x000d3cff, 0x000d4dc6,
|
||||
0x000d5e8d, 0x000d6f54, 0x000d801b, 0x000d90e2,
|
||||
0x000da1a9, 0x000db270, 0x000dc337, 0x000dd3fe,
|
||||
0x000de4c5, 0x000df58c, 0x000e0653, 0x000e171a,
|
||||
0x000e27e1, 0x000e38a8, 0x000e496f, 0x000e5a36,
|
||||
0x000e6afd, 0x000e7bc4, 0x000e8c8b, 0x000e9d52,
|
||||
0x000eae19, 0x000ebee0, 0x000ecfa7, 0x000ee06e,
|
||||
0x000ef135, 0x000f01fb, 0x000f12c2, 0x000f2389,
|
||||
0x000f3450, 0x000f4517, 0x000f55de, 0x000f66a5,
|
||||
0x000f776c, 0x000f8833, 0x000f98fa, 0x000fa9c1,
|
||||
0x000fba88, 0x000fcb4f, 0x000fdc16, 0x000fecdd,
|
||||
0x000ffda4, 0x00100e6b, 0x00101f32, 0x00102ff9,
|
||||
0x001040c0, 0x00105187, 0x0010624e, 0x00107315,
|
||||
0x001083dc, 0x001094a3, 0x0010a56a, 0x0010b631,
|
||||
};
|
||||
|
||||
u_long ustotsmid[256] = {
|
||||
0x00000000, 0x0010c6f8, 0x00218def, 0x003254e7,
|
||||
0x00431bde, 0x0053e2d6, 0x0064a9ce, 0x007570c5,
|
||||
0x008637bd, 0x0096feb4, 0x00a7c5ac, 0x00b88ca4,
|
||||
0x00c9539b, 0x00da1a93, 0x00eae18a, 0x00fba882,
|
||||
0x010c6f7a, 0x011d3671, 0x012dfd69, 0x013ec460,
|
||||
0x014f8b58, 0x01605250, 0x01711947, 0x0181e03f,
|
||||
0x0192a736, 0x01a36e2e, 0x01b43526, 0x01c4fc1d,
|
||||
0x01d5c315, 0x01e68a0c, 0x01f75104, 0x020817fc,
|
||||
0x0218def3, 0x0229a5eb, 0x023a6ce3, 0x024b33da,
|
||||
0x025bfad2, 0x026cc1c9, 0x027d88c1, 0x028e4fb9,
|
||||
0x029f16b0, 0x02afdda8, 0x02c0a49f, 0x02d16b97,
|
||||
0x02e2328f, 0x02f2f986, 0x0303c07e, 0x03148775,
|
||||
0x03254e6d, 0x03361565, 0x0346dc5c, 0x0357a354,
|
||||
0x03686a4b, 0x03793143, 0x0389f83b, 0x039abf32,
|
||||
0x03ab862a, 0x03bc4d21, 0x03cd1419, 0x03dddb11,
|
||||
0x03eea208, 0x03ff6900, 0x04102ff7, 0x0420f6ef,
|
||||
0x0431bde7, 0x044284de, 0x04534bd6, 0x046412cd,
|
||||
0x0474d9c5, 0x0485a0bd, 0x049667b4, 0x04a72eac,
|
||||
0x04b7f5a3, 0x04c8bc9b, 0x04d98393, 0x04ea4a8a,
|
||||
0x04fb1182, 0x050bd879, 0x051c9f71, 0x052d6669,
|
||||
0x053e2d60, 0x054ef458, 0x055fbb4f, 0x05708247,
|
||||
0x0581493f, 0x05921036, 0x05a2d72e, 0x05b39e25,
|
||||
0x05c4651d, 0x05d52c15, 0x05e5f30c, 0x05f6ba04,
|
||||
0x060780fb, 0x061847f3, 0x06290eeb, 0x0639d5e2,
|
||||
0x064a9cda, 0x065b63d2, 0x066c2ac9, 0x067cf1c1,
|
||||
0x068db8b8, 0x069e7fb0, 0x06af46a8, 0x06c00d9f,
|
||||
0x06d0d497, 0x06e19b8e, 0x06f26286, 0x0703297e,
|
||||
0x0713f075, 0x0724b76d, 0x07357e64, 0x0746455c,
|
||||
0x07570c54, 0x0767d34b, 0x07789a43, 0x0789613a,
|
||||
0x079a2832, 0x07aaef2a, 0x07bbb621, 0x07cc7d19,
|
||||
0x07dd4410, 0x07ee0b08, 0x07fed200, 0x080f98f7,
|
||||
0x08205fef, 0x083126e6, 0x0841edde, 0x0852b4d6,
|
||||
0x08637bcd, 0x087442c5, 0x088509bc, 0x0895d0b4,
|
||||
0x08a697ac, 0x08b75ea3, 0x08c8259b, 0x08d8ec92,
|
||||
0x08e9b38a, 0x08fa7a82, 0x090b4179, 0x091c0871,
|
||||
0x092ccf68, 0x093d9660, 0x094e5d58, 0x095f244f,
|
||||
0x096feb47, 0x0980b23e, 0x09917936, 0x09a2402e,
|
||||
0x09b30725, 0x09c3ce1d, 0x09d49514, 0x09e55c0c,
|
||||
0x09f62304, 0x0a06e9fb, 0x0a17b0f3, 0x0a2877ea,
|
||||
0x0a393ee2, 0x0a4a05da, 0x0a5accd1, 0x0a6b93c9,
|
||||
0x0a7c5ac1, 0x0a8d21b8, 0x0a9de8b0, 0x0aaeafa7,
|
||||
0x0abf769f, 0x0ad03d97, 0x0ae1048e, 0x0af1cb86,
|
||||
0x0b02927d, 0x0b135975, 0x0b24206d, 0x0b34e764,
|
||||
0x0b45ae5c, 0x0b567553, 0x0b673c4b, 0x0b780343,
|
||||
0x0b88ca3a, 0x0b999132, 0x0baa5829, 0x0bbb1f21,
|
||||
0x0bcbe619, 0x0bdcad10, 0x0bed7408, 0x0bfe3aff,
|
||||
0x0c0f01f7, 0x0c1fc8ef, 0x0c308fe6, 0x0c4156de,
|
||||
0x0c521dd5, 0x0c62e4cd, 0x0c73abc5, 0x0c8472bc,
|
||||
0x0c9539b4, 0x0ca600ab, 0x0cb6c7a3, 0x0cc78e9b,
|
||||
0x0cd85592, 0x0ce91c8a, 0x0cf9e381, 0x0d0aaa79,
|
||||
0x0d1b7171, 0x0d2c3868, 0x0d3cff60, 0x0d4dc657,
|
||||
0x0d5e8d4f, 0x0d6f5447, 0x0d801b3e, 0x0d90e236,
|
||||
0x0da1a92d, 0x0db27025, 0x0dc3371d, 0x0dd3fe14,
|
||||
0x0de4c50c, 0x0df58c03, 0x0e0652fb, 0x0e1719f3,
|
||||
0x0e27e0ea, 0x0e38a7e2, 0x0e496ed9, 0x0e5a35d1,
|
||||
0x0e6afcc9, 0x0e7bc3c0, 0x0e8c8ab8, 0x0e9d51b0,
|
||||
0x0eae18a7, 0x0ebedf9f, 0x0ecfa696, 0x0ee06d8e,
|
||||
0x0ef13486, 0x0f01fb7d, 0x0f12c275, 0x0f23896c,
|
||||
0x0f345064, 0x0f45175c, 0x0f55de53, 0x0f66a54b,
|
||||
0x0f776c42, 0x0f88333a, 0x0f98fa32, 0x0fa9c129,
|
||||
0x0fba8821, 0x0fcb4f18, 0x0fdc1610, 0x0fecdd08,
|
||||
0x0ffda3ff, 0x100e6af7, 0x101f31ee, 0x102ff8e6,
|
||||
0x1040bfde, 0x105186d5, 0x10624dcd, 0x107314c4,
|
||||
0x1083dbbc, 0x1094a2b4, 0x10a569ab, 0x10b630a3,
|
||||
};
|
||||
|
||||
u_long ustotshi[16] = {
|
||||
0x00000000, 0x10c6f79a, 0x218def35, 0x3254e6cf,
|
||||
0x431bde6a, 0x53e2d604, 0x64a9cd9f, 0x7570c539,
|
||||
0x8637bcd3, 0x96feb46e, 0xa7c5ac08, 0xb88ca3a3,
|
||||
0xc9539b3d, 0xda1a92d7, 0xeae18a72, 0xfba8820c,
|
||||
};
|
@ -1,51 +0,0 @@
|
||||
/* $NetBSD: uglydate.c,v 1.2 1998/01/09 03:16:36 perry Exp $ */
|
||||
|
||||
/*
|
||||
* uglydate - convert a time stamp to something barely readable
|
||||
* The string returned is 37 characters long.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_unixtime.h"
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_stdlib.h"
|
||||
#ifndef TM_IN_SYS_TIME
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
char *
|
||||
uglydate(ts)
|
||||
l_fp *ts;
|
||||
{
|
||||
char *bp;
|
||||
char *timep;
|
||||
struct tm *tm;
|
||||
time_t sec;
|
||||
long msec;
|
||||
int year;
|
||||
|
||||
timep = ulfptoa(ts, 6); /* returns max 17 characters */
|
||||
LIB_GETBUF(bp);
|
||||
sec = ts->l_ui - JAN_1970;
|
||||
msec = ts->l_uf / 4294967; /* fract / (2**32/1000) */
|
||||
tm = gmtime(&sec);
|
||||
if (ts->l_ui == 0) {
|
||||
/*
|
||||
* Probably not a real good thing to do. Oh, well.
|
||||
*/
|
||||
year = 0;
|
||||
tm->tm_yday = 0;
|
||||
tm->tm_hour = 0;
|
||||
tm->tm_min = 0;
|
||||
tm->tm_sec = 0;
|
||||
} else {
|
||||
year = tm->tm_year;
|
||||
while (year >= 100)
|
||||
year -= 100;
|
||||
}
|
||||
(void) sprintf(bp, "%17s %02d:%03d:%02d:%02d:%02d.%03ld",
|
||||
timep, year, tm->tm_yday, tm->tm_hour, tm->tm_min,
|
||||
tm->tm_sec, msec);
|
||||
return bp;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/* $NetBSD: uinttoa.c,v 1.2 1998/01/09 03:16:37 perry Exp $ */
|
||||
|
||||
/*
|
||||
* uinttoa - return an asciized unsigned integer
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib_strbuf.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
char *
|
||||
uinttoa(uval)
|
||||
u_long uval;
|
||||
{
|
||||
register char *buf;
|
||||
|
||||
LIB_GETBUF(buf);
|
||||
|
||||
(void) sprintf(buf, "%lu", (u_long)uval);
|
||||
return buf;
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/* $NetBSD: utvtoa.c,v 1.4 1999/07/03 12:30:32 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* utvtoa - return an asciized representation of an unsigned struct timeval
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "lib_strbuf.h"
|
||||
#if defined(VMS)
|
||||
#include "ntp_fp.h"
|
||||
#endif
|
||||
#include "ntp_stdlib.h"
|
||||
#include "ntp_unixtime.h"
|
||||
|
||||
char *
|
||||
utvtoa(tv)
|
||||
const struct timeval *tv;
|
||||
{
|
||||
register char *buf;
|
||||
|
||||
LIB_GETBUF(buf);
|
||||
|
||||
(void) sprintf(buf, "%lu.%06lu", (u_long)tv->tv_sec,
|
||||
(u_long)tv->tv_usec);
|
||||
return buf;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
/* $NetBSD: version.c,v 1.3 1998/08/12 14:11:50 christos Exp $ */
|
||||
|
||||
/*
|
||||
* version file for 5.93c
|
||||
*/
|
||||
char * Version = "5.93c 3-NetBSD Wed Aug 12 10:05:25 EDT 1998 (1)";
|
@ -1,127 +0,0 @@
|
||||
<!-- $NetBSD: COPYRIGHT,v 1.4 1998/08/12 14:11:50 christos Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Copyright Notice
|
||||
</title></head><body><h3>
|
||||
Copyright Notice
|
||||
</h3><hr>
|
||||
|
||||
<p>The following copyright notice applies to all files collectively
|
||||
called the Network Time Protocol Version 4 Distribution. Unless
|
||||
specifically declared otherwise in an individual file, this notice
|
||||
applies as if the text was explicitly included in the file.
|
||||
|
||||
<pre>
|
||||
|
||||
/***********************************************************************
|
||||
* *
|
||||
* Copyright (c) David L. Mills 1992, 1993, 1994, 1995, 1996 *
|
||||
* *
|
||||
* Permission to use, copy, modify, and distribute this software and *
|
||||
* its documentation for any purpose and without fee is hereby *
|
||||
* granted, provided that the above copyright notice appears in all *
|
||||
* copies and that both the copyright notice and this permission *
|
||||
* notice appear in supporting documentation, and that the name *
|
||||
* University of Delaware not be used in advertising or publicity *
|
||||
* pertaining to distribution of the software without specific, *
|
||||
* written prior permission. The University of Delaware makes no *
|
||||
* representations about the suitability this software for any *
|
||||
* purpose. It is provided "as is" without express or implied *
|
||||
* warranty. *
|
||||
**********************************************************************/
|
||||
|
||||
</pre><p>
|
||||
|
||||
The following individuals contributed in part to the Network Time
|
||||
Protocol Distribution Version 4 and are acknowledged as authors of this
|
||||
work.
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mark Andrews (marka@syd.dms.csiro.au) Leitch atomic clock
|
||||
controller
|
||||
|
||||
<br><li>Viraj Bais (vbais@mailman1.intel.com), Clayton Kirkwood
|
||||
(kirkwood@striderfm.intel.com), and Greg Schueman (schueman@acm.org)
|
||||
port to WindowsNT 3.51
|
||||
|
||||
<br><li>Karl Berry (karl@owl.HQ.ileaf.com) syslog to file option
|
||||
|
||||
<br><li>Piete Brooks (Piete.Brooks@cl.cam.ac.uk) MSF clock driver,
|
||||
Trimble PARSE support
|
||||
|
||||
<br><li>Steve Clift (clift@ml.csiro.au): OMEGA clock driver
|
||||
|
||||
<br><li><a href="http://www.ee.uct.ac.za/~casey"> Casey Crellin </a>
|
||||
<a href="mailto:casey@csc.co.za"> (casey@csc.co.za) </a>
|
||||
vxWorks (Tornado) port and help with target configuration
|
||||
|
||||
<br><li>Torsten Duwe (duwe@immd4.informatik.uni-erlangen.de) Linux Port
|
||||
|
||||
<br><li>John A. Dundas III (dundas@salt.jpl.nasa.gov) Apple A/UX port
|
||||
|
||||
<br><li>Dennis Ferguson (dennis@mrbill.canet.ca) foundation code for NTP
|
||||
Version 2 as specified in RFC-1119
|
||||
|
||||
<br><li>Glenn Hollinger (glenn@herald.usask.ca) GOES clock driver
|
||||
|
||||
<br><li>Mike Iglesias (iglesias@uci.edu): DEC Alpha port
|
||||
|
||||
<br><li>Jim Jagielski (jim@jagubox.gsfc.nasa.gov) A/UX port
|
||||
|
||||
<br><li>Jeff Johnson (jbj@chatham.usdesign.com) massive prototyping
|
||||
overhaul
|
||||
<br><li>William L. Jones (jones@hermes.chpc.utexas.edu) RS/6000 AIX
|
||||
modifications, HPUX modifications
|
||||
|
||||
<br><li>Dave Katz (dkatz@cisco.com) RS/6000 AIX port
|
||||
|
||||
<br><li>Craig Leres (leres@ee.lbl.gov) 4.4BSD port, ppsclock, Maganavox
|
||||
GPS clock driver
|
||||
|
||||
<br><li>George Lindholm (lindholm@ucs.ubc.ca) SunOS 5.1 port
|
||||
|
||||
<br><li>Louis A. Mamakos (louie@ni.umd.edu) MD5-based authentication
|
||||
|
||||
<br><li>Lars H. Mathiesen (thorinn@diku.dk) adaptation of foundation
|
||||
code for Version 3 as specified in RFC-1305
|
||||
|
||||
<br><li><a href="http://www.eecis.udel.edu/~mills">David L. Mills
|
||||
(mills@udel.edu)</a> Spectractom WWVB, Austron GPS, Heath, ATOM, ACTS,
|
||||
KSI/Odetics IRIG-B clock drivers; PPS support
|
||||
|
||||
<br><li>Wolfgang Moeller (moeller@gwdgv1.dnet.gwdg.de) VMS port
|
||||
|
||||
<br><li>Jeffrey Mogul (mogul@pa.dec.com) ntptrace utility
|
||||
|
||||
<br><li>Tom Moore (tmoore@fievel.daytonoh.ncr.com) i386 svr4 port
|
||||
|
||||
<br><li>Rainer Pruy (Rainer.Pruy@informatik.uni-erlangen.de)
|
||||
monitoring/trap scripts, statistics file handling
|
||||
|
||||
<br><li>Nick Sayer (mrapple@quack.kfu.com) SunOS streams modules
|
||||
|
||||
<br><li><a href="http://www4.informatik.uni-erlangen.de/~kardel">Frank Kardel</a>
|
||||
<a href="mailto: Frank.Kardel@informatik.uni-erlangen.de"> <Frank.Kardel@informatik.uni-erlangen.de></a>
|
||||
PARSE <GENERIC> driver (14 reference clocks), STREAMS modules for PARSE, support
|
||||
scripts, syslog cleanup
|
||||
|
||||
<br><li>Ray Schnitzler (schnitz@unipress.com) Unixware1 port
|
||||
|
||||
<br><li>Michael Shields (shields@tembel.org) USNO clock driver
|
||||
|
||||
<br><li>Jeff Steinman (jss@pebbles.jpl.nasa.gov) Datum PTS clock driver
|
||||
|
||||
<br><li>Kenneth Stone (ken@sdd.hp.com) HP-UX port
|
||||
|
||||
<br><li><a href="http://www.eecis.udel.edu/~ajit">Ajit Thyagarajan
|
||||
(ajit@ee.udel.edu)</a> IP multicast support
|
||||
|
||||
<br><li>Tomoaki TSURUOKA (tsuruoka@nc.fukuoka-u.ac.jp) TRAK clock driver
|
||||
|
||||
<br><li>Paul A Vixie (vixie@vix.com) TrueTime GPS driver, generic
|
||||
TrueTime clock driver
|
||||
|
||||
</ol>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,4 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.3 1998/03/06 18:17:16 christos Exp $
|
||||
SUBDIR= ntpdate ntpq ntptime ntptrace xntpd xntpdc
|
||||
|
||||
.include <bsd.subdir.mk>
|
@ -1,9 +0,0 @@
|
||||
# $NetBSD: Makefile.inc,v 1.11 1998/08/12 14:11:50 christos Exp $
|
||||
|
||||
CPPFLAGS += -I${.CURDIR}/../include -DHAVE_CONFIG_H
|
||||
LDADD += -lntp
|
||||
DPADD += ${LIBNTP}
|
||||
|
||||
.if exists(${.CURDIR}/../../Makefile.inc)
|
||||
.include "${.CURDIR}/../../Makefile.inc"
|
||||
.endif
|
File diff suppressed because it is too large
Load Diff
@ -1,23 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.2 1999/10/31 22:46:17 veego Exp $
|
||||
|
||||
HTML += HTMLPrimer.html accopt.html authcert.html authopt.html authspeed.html
|
||||
HTML+= biblio.html build.html clockopt.html config.html confopt.html
|
||||
HTML+= copyright.html debug.html driver1.html driver10.html driver11.html
|
||||
HTML+= driver12.html driver18.html driver19.html driver2.html driver20.html
|
||||
HTML+= driver22.html driver23.html driver24.html driver26.html driver27.html
|
||||
HTML+= driver28.html driver3.html driver4.html driver5.html driver6.html
|
||||
HTML+= driver7.html driver8.html driver9.html gadget.html hints.html
|
||||
HTML+= howto.html index.html irig.html kern.html kernpps.html ldisc.html
|
||||
HTML+= md5cert.html measure.html miscopt.html monopt.html notes.html
|
||||
HTML+= ntpdate.html ntpq.html ntptime.html ntptrace.html parsedata.html
|
||||
HTML+= parsenew.html patches.html porting.html pps.html prefer.html
|
||||
HTML+= rdebug.html refclock.html release.html tickadj.html vxworks.html
|
||||
HTML+= xntpd.html xntpdc.html
|
||||
|
||||
DIR=html/xntp
|
||||
FILES=${HTML}
|
||||
|
||||
docinstall::
|
||||
${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} ${DESTDIR}/${DOCDIR}/${DIR}
|
||||
|
||||
.include <bsd.doc.mk>
|
@ -1,141 +0,0 @@
|
||||
<!-- $NetBSD: accopt.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Access Control Options
|
||||
</title></head><body><h3>
|
||||
Access Control Options
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Access Control Support</h4>
|
||||
|
||||
<p><code>xntpd</code> implements a general purpose address-and-mask
|
||||
based restriction list. The list is sorted by address and by mask, and
|
||||
the list is searched in this order for matches, with the last match
|
||||
found defining the restriction flags associated with the incoming
|
||||
packets. The source address of incoming packets is used for the match,
|
||||
with the 32-bit address being and'ed with the mask associated with the
|
||||
restriction entry and then compared with the entry's address (which has
|
||||
also been and'ed with the mask) to look for a match. Additional
|
||||
information and examples can be found in the <a href = "notes.html">
|
||||
Notes on Configuring NTP and Setting up a NTP Subnet </a> page.
|
||||
|
||||
<p>The restriction facility was implemented in conformance with the
|
||||
access policies for the original NSFnet backbone time servers. While
|
||||
this facility may be otherwise useful for keeping unwanted or broken
|
||||
remote time servers from affecting your own, it should not be considered
|
||||
an alternative to the standard NTP authentication facility. Source
|
||||
address based restrictions are easily circumvented by a determined
|
||||
cracker.
|
||||
|
||||
<p><h4>Access Control Commands</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>restrict <i>numeric_address</i> [ mask <i>numeric_mask</i>
|
||||
] [ <i>flag</i> ] [ ... ]</code>
|
||||
<dd>The <code><i>numeric_address</i></code> argument, expressed in
|
||||
dotted-quad form, is the address of an host or network. The
|
||||
<code><i>mask</i></code> argument, also expressed in dotted-quad form,
|
||||
defaults to <code>255.255.255.255</code>, meaning that the
|
||||
<code><i>numeric_address</i></code> is treated as the address of an
|
||||
individual host. A default entry (address <code>0.0.0.0</code>, mask
|
||||
<code>0.0.0.0</code>) is always included and, given the sort algorithm,
|
||||
is always the first entry in the list. Note that, while
|
||||
<code><i>numeric_address</i></code> is normally given in dotted-quad
|
||||
format, the text string <code>default</code>, with no mask option, may
|
||||
be used to indicate the default entry.
|
||||
|
||||
<p><dd>In the current implementation, <code><i>flag</i></code> always
|
||||
restricts access, i.e., an entry with no flags indicates that free
|
||||
access to the server is to be given. The flags are not orthogonal, in
|
||||
that more restrictive flags will often make less restrictive ones
|
||||
redundant. The flags can generally be classed into two catagories, those
|
||||
which restrict time service and those which restrict informational
|
||||
queries and attempts to do run-time reconfiguration of the server. One
|
||||
or more of the following flags may be specified:
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>ignore</code>
|
||||
<dd>Ignore all packets from hosts which match this entry. If this flag
|
||||
is specified neither queries nor time server polls will be responded to.
|
||||
|
||||
<p><dt><code>noquery</code>
|
||||
<dd>Ignore all NTP mode 6 and 7 packets (i.e. information queries and
|
||||
configuration requests) from the source. Time service is not affected.
|
||||
|
||||
<p><dt><code>nomodify</code>
|
||||
<dd>Ignore all NTP mode 6 and 7 packets which attempt to modify the
|
||||
state of the server (i.e. run time reconfiguration). Queries which
|
||||
return information are permitted.
|
||||
|
||||
<p><dt><code>notrap</code>
|
||||
<dd>Decline to provide mode 6 control message trap service to matching
|
||||
hosts. The trap service is a subsystem of the mode 6 control message
|
||||
protocol which is intended for use by remote event logging programs.
|
||||
|
||||
<p><dt><code>lowpriotrap</code>
|
||||
<dd>Declare traps set by matching hosts to be low priority. The number
|
||||
of traps a server can maintain is limited (the current limit is 3).
|
||||
Traps are usually assigned on a first come, first served basis, with
|
||||
later trap requestors being denied service. This flag modifies the
|
||||
assignment algorithm by allowing low priority traps to be overridden by
|
||||
later requests for normal priority traps.
|
||||
|
||||
<p><dt><code>noserve</code>
|
||||
<dd>Ignore NTP packets whose mode is other than 6 or 7. In effect, time
|
||||
service is denied, though queries may still be permitted.
|
||||
|
||||
<p><dt><code>nopeer</code>
|
||||
<dd>Provide stateless time service to polling hosts, but do not allocate
|
||||
peer memory resources to these hosts even if they otherwise might be
|
||||
considered useful as future synchronization partners.
|
||||
|
||||
<p><dt><code>notrust</code>
|
||||
<dd>Treat these hosts normally in other respects, but never use them as
|
||||
synchronization sources.
|
||||
|
||||
<p><dt><code>limited</code>
|
||||
<dd>These hosts are subject to limitation of number of clients from the
|
||||
same net. Net in this context refers to the IP notion of net (class A,
|
||||
class B, class C, etc.). Only the first <code>client_limit</code> hosts
|
||||
that have shown up at the server and that have been active during the
|
||||
last <code>client_limit_period</code> seconds are accepted. Requests
|
||||
from other clients from the same net are rejected. Only time request
|
||||
packets are taken into account. Query packets sent by the
|
||||
<code>ntpq</code> and <code>xntpdc</code> programs are not subject to
|
||||
these limits. A history of clients is kept using the monitoring
|
||||
capability of <code>xntpd</code>. Thus, monitoring is always active as
|
||||
long as there is a restriction entry with the <code>limited</code> flag.
|
||||
|
||||
<p><dt><code>ntpport</code>
|
||||
<dd>This is actually a match algorithm modifier, rather than a
|
||||
restriction flag. Its presence causes the restriction entry to be
|
||||
matched only if the source port in the packet is the standard NTP UDP
|
||||
port (123). Both <code>ntpport</code> and <code>non-ntpport</code> may
|
||||
be specified. The <code>ntpport</code> is considered more specific and
|
||||
is sorted later in the list.
|
||||
|
||||
</dl>
|
||||
|
||||
<p><dd>Default restriction list entries, with the flags <code>ignore,
|
||||
ntpport</code>, for each of the local host's interface addresses are
|
||||
inserted into the table at startup to prevent the server from attempting
|
||||
to synchronize to its own time. A default entry is also always present,
|
||||
though if it is otherwise unconfigured; no flags are associated with the
|
||||
default entry (i.e., everything besides your own NTP server is
|
||||
unrestricted).
|
||||
|
||||
<p><dt><code>clientlimit <i>limit</i></code>
|
||||
<dd>Set the <code>client_limit</code> variable, which limits the number
|
||||
of simultaneous access-controlled clients. The default value for this
|
||||
variable is 3.
|
||||
<p><dt><code>clientperiod <i>period</i></code>
|
||||
<dd>Set the <code>client_limit_period</code> variable, which specifies
|
||||
the number of seconds after which a client is considered inactive and
|
||||
thus no longer is counted for client limit restriction. The default
|
||||
value for this variable is 3600 seconds.
|
||||
|
||||
</dl>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,51 +0,0 @@
|
||||
<!-- $NetBSD: authcert.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
authcert - DES validation program
|
||||
</title></head><body><h3>
|
||||
<code>authcert</code> - DES validation program
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p><code>authcert</code>
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This program verifies whether the DES encryption algorithm is
|
||||
operating correctly in the particular architecture. The program reads a
|
||||
line from the standard input containing a key, plaintext block and the
|
||||
corresponding encrypted ciphertext block, respectively, as in the
|
||||
following
|
||||
|
||||
<pre>
|
||||
0000000000000000 0000000000000000 8CA64DE9C1B123A7
|
||||
FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 7359B2163E4EDC58
|
||||
3000000000000000 1000000000000001 958E6E627A05557B
|
||||
1111111111111111 1111111111111111 F40379AB9E0EC533
|
||||
0123456789ABCDEF 1111111111111111 17668DFC7292532D
|
||||
1111111111111111 0123456789ABCDEF 8A5AE1F81AB8F2DD
|
||||
0000000000000000 0000000000000000 8CA64DE9C1B123A7
|
||||
FEDCBA9876543210 0123456789ABCDEF ED39D950FA74BCC4
|
||||
7CA110454A1A6E57 01A1D6D039776742 690F5B0D9A26939B
|
||||
</pre>
|
||||
|
||||
<p>and generates output as in the following
|
||||
|
||||
<pre>
|
||||
K: 0000000000000000 P: 0000000000000000 C: 8ca64de9c1b123a7 OK
|
||||
K: ffffffffffffffff P: ffffffffffffffff C: 7359b2163e4edc58 OK
|
||||
K: 3000000000000000 P: 1000000000000001 C: 958e6e627a05557b OK
|
||||
K: 1111111111111111 P: 1111111111111111 C: f40379ab9e0ec533 OK
|
||||
K: 0123456789abcdef P: 1111111111111111 C: 17668dfc7292532d OK
|
||||
K: 1111111111111111 P: 0123456789abcdef C: 8a5ae1f81ab8f2dd OK
|
||||
K: 0000000000000000 P: 0000000000000000 C: 8ca64de9c1b123a7 OK
|
||||
K: fedcba9876543210 P: 0123456789abcdef C: ed39d950fa74bcc4 OK
|
||||
K: 7ca110454a1a6e57 P: 01a1d6d039776742 C: 690f5b0d9a26939b OK
|
||||
</pre>
|
||||
|
||||
<p><h4>Files</h4>
|
||||
|
||||
<p><code>./authstuff/certdata</code> - a representative test file
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,130 +0,0 @@
|
||||
<!-- $NetBSD: authopt.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Authentication Options
|
||||
</title></head><body><h3>
|
||||
Authentication Options
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Authentication Support</h4>
|
||||
|
||||
<p>The NTP standard specifies an extension which provides cryptographic
|
||||
authentication of received NTP packets. This is implemented in
|
||||
<code>xntpd</code> using the DES or MD5 algorithms to compute a digital
|
||||
signature, or message digest. The specification allows any one of
|
||||
possibly 4 billion keys, numbered with 32-bit key identifiers, to be
|
||||
used to authenticate an association. The servers involved in an
|
||||
association must agree on the key and key identifier used to
|
||||
authenticate their messages.
|
||||
|
||||
<p>Keys and related information are specified in a key file, which
|
||||
should be exchanged and stored using secure procedures beyond the scope
|
||||
of the protocol. There are three classes of keys involved in the current
|
||||
implementation. One class is used for ordinary NTP associations, another
|
||||
for the <a href = "ntpq.html"> <code>ntpq</code></a> utility program and
|
||||
the third for the <a href = "xntpdc.html"> <code>xntpdc</code></a>
|
||||
utility program.
|
||||
|
||||
<p><h4>Authentication Commands</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>keys <i>keyfile</i></code>
|
||||
<dd>Specifies the file name containing the encryption keys and key
|
||||
identifiers used by <code>xntpd</code>, <code>ntpq</code> and
|
||||
<code>xntpdc</code> when operating in authenticated mode. The format of
|
||||
this file is described later in this document.
|
||||
|
||||
<p><dt><code>trustedkey <i>key</i> [ ... ]</code>
|
||||
<dd>Specifies the encryption key identifiers which are trusted for the
|
||||
purposes of authenticating peers suitable for synchronization. The
|
||||
authentication procedures require that both the local and remote servers
|
||||
share the same key and key identifier for this purpose, although
|
||||
different keys can be used with different servers. The
|
||||
<code><i>key</i></code> arguments are 32-bit unsigned integers. Note
|
||||
that NTP key 0 is fixed and globally known. If meaningful authentication
|
||||
is to be performed the 0 key should not be trusted.
|
||||
|
||||
<p><dt><code>requestkey <i>key</i></code>
|
||||
<dd>Specifies the key identifier to use with the <code>xntpdc</code>
|
||||
program, which uses a proprietary protocol specific to this
|
||||
implementation of <code>xntpd</code>. This program is useful to diagnose
|
||||
and repair problems that affect <code>xntpd</code> operation. The
|
||||
<code><i>key</i></code> argument to this command is a 32-bit unsigned
|
||||
integer. If no <code>requestkey</code> command is included in the
|
||||
configuration file, or if the keys don't match, such requests will be
|
||||
ignored.
|
||||
|
||||
<p><dt><code>controlkey <i>key</i></code>
|
||||
<dd>Specifies the key identifier to use with the <code>ntpq</code>
|
||||
program, which uses the standard protocol defined in RFC-1305. This
|
||||
program is useful to diagnose and repair problems that affect
|
||||
<code>xntpd</code> operation. The <code><i>key</i></code> argument to
|
||||
this command is a 32-bit unsigned integer. If no <code>requestkey</code>
|
||||
command is included in the configuration file, or if the keys don't
|
||||
match, such requests will be ignored.
|
||||
|
||||
</dl>
|
||||
<p><h4>Authentication Key File Format</h4>
|
||||
|
||||
<p>In the case of DES, the keys are 56 bits long with, depending on
|
||||
type, a parity check on each byte. In the case of MD5, the keys are 64
|
||||
bits (8 bytes). <code>xntpd</code> reads its keys from a file specified
|
||||
using the <code>-k</code> command line option or the <code>keys</code>
|
||||
statement in the configuration file. While key number 0 is fixed by the
|
||||
NTP standard (as 56 zero bits) and may not be changed, one or more of
|
||||
the keys numbered 1 through 15 may be arbitrarily set in the keys file.
|
||||
|
||||
<p>The key file uses the same comment conventions as the configuration
|
||||
file. Key entries use a fixed format of the form
|
||||
|
||||
<p><code><i>keyno type key</i></code>
|
||||
|
||||
<p>where <code><i>keyno</i></code> is a positive integer,
|
||||
<code><i>type</i></code> is a single character which defines the key
|
||||
format, and <code><i>key</i></code> is the key itself.
|
||||
|
||||
<p>The key may be given in one of three different formats, controlled by
|
||||
the <code><i>type</i></code> character. The three key types, and
|
||||
corresponding formats, are listed following.
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>S</code>
|
||||
<dd>The key is a 64-bit hexadecimal number in the format specified in
|
||||
the DES specification; that is, the high order seven bits of each octet
|
||||
are used to form the 56-bit key while the low order bit of each octet is
|
||||
given a value such that odd parity is maintained for the octet. Leading
|
||||
zeroes must be specified (i.e., the key must be exactly 16 hex digits
|
||||
long) and odd parity must be maintained. Hence a zero key, in standard
|
||||
format, would be given as <code>0101010101010101</code>.
|
||||
|
||||
<p><dt><code>N</code>
|
||||
<dd>The key is a 64-bit hexadecimal number in the format specified in
|
||||
the NTP standard. This is the same as the DES format, except the bits in
|
||||
each octet have been rotated one bit right so that the parity bit is now
|
||||
the high order bit of the octet. Leading zeroes must be specified and
|
||||
odd parity must be maintained. A zero key in NTP format would be
|
||||
specified as <code>8080808080808080</code>.
|
||||
|
||||
<p><dt><code>A</code>
|
||||
<dd>The key is a 1-to-8 character ASCII string. A key is formed from
|
||||
this by using the low order 7 bits of each ASCII character in the
|
||||
string, with zeroes added on the right when necessary to form a full
|
||||
width 56-bit key, in the same way that encryption keys are formed from
|
||||
Unix passwords.
|
||||
|
||||
<p><dt><code>M</code>
|
||||
<dd>The key is a 1-to-8 character ASCII string, using the MD5
|
||||
authentication scheme. Note that both the keys and the authentication
|
||||
schemes (DES or MD5) must be identical between a set of peers sharing
|
||||
the same key number.
|
||||
|
||||
</dl>
|
||||
|
||||
<p>Note that the keys used by the <code>ntpq</code> and
|
||||
<code>xntpdc</code> programs are checked against passwords requested by
|
||||
the programs and entered by hand, so it is generally appropriate to
|
||||
specify these keys in ASCII format.
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,46 +0,0 @@
|
||||
<!-- $NetBSD: authspeed.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
authspeed - determine authentication delays
|
||||
</title></head><body><h3>
|
||||
<code>authspeed</code> - determine authentication delays
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p><code>authspeed [ -cdm ] [ -n <i>loops</i> ] auth.samplekeys</code>
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This program encrypts a test file and determines the authentication
|
||||
delay to use in the NTP configuration file. There are two choices of
|
||||
encryption algorithm, DES Cipher-Block-Chaining (DES-CBC) and Message
|
||||
Digest 5 (MD5).
|
||||
|
||||
<p><h4>Options</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>-c</code>
|
||||
<dd>Select total cost of encryption. Default is value to use in the
|
||||
authdelay configuration command.
|
||||
|
||||
<p><dt><code>-d</code>
|
||||
<dd>Enable debug output. Default is no debug output.
|
||||
|
||||
<p><dt><code>-m</code>
|
||||
<dd>Enable MD5 algorithm. Default is DES-CBC algorithm.
|
||||
|
||||
<p><dt><code>-n <i>loops</i></code>
|
||||
<dd>Specify the number of program loops. Default is 20,000.
|
||||
|
||||
</dl>
|
||||
|
||||
<p><h4>Files</h4>
|
||||
|
||||
<p><code>./authstuff/auth.samplekeys</code> - a representative list of
|
||||
keys
|
||||
<p><code>./authstuff/auth.speed</code> - a listing of results for a
|
||||
representative set of architectures and compilers
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,230 +0,0 @@
|
||||
<!-- $NetBSD: biblio.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Further Information and Bibliography
|
||||
</title></head><body><h3>
|
||||
Further Information and Bibliography
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Conformance Statement</h4>
|
||||
|
||||
<p>The Network Time Protocol (NTP) is used to synchronize the time of a
|
||||
computer client or server to another server or reference time source,
|
||||
such as a radio or satellite receiver or modem. It provides accuracies
|
||||
typically within a millisecond on LANs up to a few tens of milliseconds
|
||||
on WANs relative to Coordinated Universal Time (UTC), as provided by a
|
||||
Global Positioning Service (GPS) receiver, for example. Typical NTP
|
||||
configurations utilize multiple redundant servers and diverse network
|
||||
paths, in order to achieve high accuracy and reliability. Some
|
||||
configurations include cryptographic authentication to prevent
|
||||
accidental or malicious protocol attacks. Information on the NTP
|
||||
architecture, protocol and algorithms can be found in the following
|
||||
articles and reports, which are available online
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mills, D.L. Internet time synchronization: the Network Time Protocol.
|
||||
<i>IEEE Trans. Communications COM-39, 10</i> (October 1991), 1482-1493.
|
||||
<a href = "ftp://ftp.udel.edu/pub/people/mills/papers/trans.ps">
|
||||
(PostScript)</a>. Also in: Yang, Z., and T.A. Marsland (Eds.). <i>Global
|
||||
States and Time in Distributed Systems</i>. IEEE Computer Society Press,
|
||||
Los Alamitos, CA, 1994, 91-102. Condensed from: <i>Ibid</i>. Network
|
||||
Working Group Report RFC-1129, University of Delaware, October 1989. <a
|
||||
href = "ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1129/rfc1129a.ps">
|
||||
(Abstract: PostScript)</a>, <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1129/rfc1129b.ps"> (Body:
|
||||
PostScript)</a>. Also published as: Electrical Engineering Department
|
||||
Report 89-9-1, University of Delaware, September 1989. <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/reports/nts/ntsa.ps"> (Abstract:
|
||||
PostScript)</a>, <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/reports/nts/ntsb.ps"> (Body:
|
||||
PostScript)</a>.
|
||||
|
||||
</ol>
|
||||
|
||||
<p>The NTP specification and implementation has evolved over the last
|
||||
fifteen years to the current Version 3 of the protocol. This version
|
||||
includes significant enhancements in accuracy and reliability, as
|
||||
determined by experience in an estimated total of well over 100,000
|
||||
clients and servers in the Internet, while retaining backward
|
||||
compatibility with previous versions. The formal specification of the NTP
|
||||
Version 3 protocol is contained in:
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mills, D.L. Network Time Protocol (Version 3) specification,
|
||||
implementation and analysis. Network Working Group Report RFC-1305,
|
||||
University of Delaware, March 1992, 113 pp. <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1305/rfc1305a.ps">
|
||||
(Abstract: PostScript)</a>, <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1305/rfc1305b.ps"> (Body:
|
||||
PostScript)</a>, <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1305/rfc1305c.ps">
|
||||
(Appendices: PostScript)</a>.
|
||||
|
||||
</ol>
|
||||
|
||||
<p>This software distribution contains a fully compliant implementation
|
||||
of the NTP Version 3 protocol, including an autonomous protocol daemon
|
||||
that disciplines the local host clock, as well as a set of supporting
|
||||
utility programs used to debug and manage one or more NTP servers in a
|
||||
network. It includes complete sources and documentation for well over
|
||||
two dozen Unix-based and Microsoft NT-based workstations and file
|
||||
servers. The implementation is fully compliant with RFC-1305 and, in
|
||||
addition, contains certain extensions compatible with, but not defined
|
||||
by, that document. These extensions include:
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Support for precision-time kernel modifications, as described in
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mills, D.L. Unix kernel modifications for precision time
|
||||
synchronization. Electrical Engineering Department Report 94-10-1,
|
||||
University of Delaware, October 1994, 24 pp. <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/reports/kern/kerna.ps"> (Abstract:
|
||||
PostScript)</a>, <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/reports/kern/kernb.ps"> (Body:
|
||||
PostScript)</a>. Major revision and update of: Network Working Group
|
||||
Report RFC-1589, University of Delaware, March 1994. 31 pp. <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1589.txt"> (ASCII)</a>.
|
||||
|
||||
</ol>
|
||||
|
||||
<p><li>Support for IP Multicasting, as described in
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mills, D.L, and A. Thyagarajan. Network time protocol version 4
|
||||
proposed changes. Electrical Engineering Department Report 94-10-2,
|
||||
University of Delaware, October 1994, 32 pp. <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/reports/acts/actsa.ps"> (Abstract:
|
||||
PostScript)</a>, <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/reports/acts/actsb.ps"> (Body:
|
||||
PostScript)</a>.
|
||||
|
||||
</ol>
|
||||
|
||||
<p><li>A new hybrid phase/frequency-lock clock discipline, which
|
||||
replaces the RFC-1305 local clock algorithm, as described in
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mills, D.L. Improved algorithms for synchronizing computer network
|
||||
clocks. <i>IEEE/ACM Trans. Networks</i> (June 1995), 245-254. <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/papers/tune2.ps"> (PostScript)</a>.
|
||||
</ol>
|
||||
|
||||
<p><li>Engineered refinements to radio clock drivers and interface code,
|
||||
as described in:
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mills, D.L. Precision synchronization of computer network clocks.
|
||||
<i>ACM Computer Communication Review 24, 2</i> (April 1994). 28-43. <a
|
||||
href = "ftp://ftp.udel.edu/pub/people/mills/papers/fine.ps">
|
||||
(PostScript)</a>.
|
||||
|
||||
</ol>
|
||||
|
||||
<p><li>Support for over two dozen reference clock drivers for all known
|
||||
national and international radio, satellite and modem standard time
|
||||
services known at this time. See the <a href = "refclock.html">
|
||||
Reference Clock Drivers </a> page.
|
||||
<p><li>Support for the MD5 cryptographic hash algorithm, in addition to
|
||||
the DES-CBC algorithm described in RFC-1305, as described in the <a
|
||||
href="xntpd.html"><code>xntpd</code> - Network Time Protocol (NTP)
|
||||
daemon </a> page.
|
||||
|
||||
<p><li>The prefer-peer scheme, as described in the <a href =
|
||||
"prefer.html">Mitigation Rules and the <code>prefer</code> Keyword </a>
|
||||
page.
|
||||
|
||||
</ol>
|
||||
|
||||
<p><h4>Selected Bibliography</h4>
|
||||
|
||||
<p>A number of articles and reports have been written on the analysis,
|
||||
design, implementation and performance of NTP. A representative sample
|
||||
is included here, along with a short description of each. Additional
|
||||
information on NTP can be found at the web sites for <a href =
|
||||
"http://www.eecis.udel.edu/~ntp"> NTP </a> and <a href =
|
||||
"http://www.eecis.udel.edu/~mills"> David L. Mills </a>
|
||||
|
||||
<ol>
|
||||
|
||||
<li>A subset of NTP has been defined suitable for use where some
|
||||
degradation in accuracy and reliability is acceptable, so that the
|
||||
entire suite of specified algorithms need not be implemented. This
|
||||
subset is defined in:
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mills, D.L. Simple Network Time Protocol (SNTP). Network Working
|
||||
Group Report RFC-1769, University of Delaware, March 1995, 14 pp. <a
|
||||
href = "ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1769.txt">
|
||||
(ASCII)</a>. Major revision and update of: <i>Ibid</i>. Network Working
|
||||
Group Report RFC-1361, University of Delaware, August 1992, 10 pp. <a
|
||||
href = "ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1361.txt">
|
||||
(ASCII)</a>.
|
||||
|
||||
</ol>
|
||||
|
||||
<p><li>An assessment of the expected accuracy of NTP operating in the
|
||||
Internet is contained in the following:
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mills, D.L. Measured performance of the Network Time Protocol in the
|
||||
Internet system. Network Working Group Report RFC-1128. University of
|
||||
Delaware, October 1989. <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1128/rfc1128a.ps">
|
||||
(Abstract: PostScript)</a>, <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1128/rfc1128b.ps"> (Body:
|
||||
PostScript)</a>. Also published as: Electrical Engineering Department
|
||||
Report 89-9-3, University of Delaware, September 1989. <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/reports/glory/glorya.ps">
|
||||
(Abstract: PostScript)</a>, <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/reports/glory/gloryb.ps"> (Body:
|
||||
PostScript)</a>.
|
||||
|
||||
<li>Mills, D.L. On the accuracy and stability of clocks synchronized by
|
||||
the Network Time Protocol in the Internet system. <i>ACM Computer
|
||||
Communication Review 20, 1</i> (January 1990), 65-75. <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/papers/ccr.ps"> (PostScript)</a>.
|
||||
|
||||
</ol>
|
||||
<p><li>The following publication explores issues involved in the
|
||||
development of the NTP specification, including the development of its
|
||||
timescale and the treatment of leap seconds:
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mills, D.L. On the chronology and metrology of computer network
|
||||
timescales and their application to the Network Time Protocol. <i>ACM
|
||||
Computer Communications Review 21, 5</i> (October 1991), 8-17. <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/papers/time.ps"> (PostScript)</a>.
|
||||
|
||||
</ol>
|
||||
|
||||
<p><li>A comprehensive analysis of the engineering model used in the NTP
|
||||
algorithms is given in the following report. This includes a performance
|
||||
analysis of the clock filter and selection algorithms, clock discipline
|
||||
feedback loop, and error budget.
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mills, D.L. Modelling and analysis of computer network clocks.
|
||||
Electrical Engineering Department Report 92-5-2, University of Delaware,
|
||||
May 1992, 29 pp. <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/reports/time/timea.ps"> (Abstract:
|
||||
PostScript)</a>, <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/reports/time/timeb.ps"> (Body:
|
||||
PostScript)</a>.
|
||||
|
||||
</ol>
|
||||
|
||||
</ol>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,149 +0,0 @@
|
||||
<!-- $NetBSD: build.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Building and Installing the Distribution
|
||||
</title></head><body><h3>
|
||||
Building and Installing the Distribution
|
||||
</h3><hr>
|
||||
|
||||
<p>Following are instructions to build and install the programs in this
|
||||
distribution.
|
||||
|
||||
<p>Note that the automatic build process inspects the machine
|
||||
environment and tests for the presence of system header files and the
|
||||
contents of these files to determine if certain features are available.
|
||||
When one or more of these features are present, the code is compiled to
|
||||
use them; if not, no special code is compiled. However, even if the code
|
||||
is compiled to use these features, the code does a special test at run
|
||||
time to see if one or more are actually present and avoids using them if
|
||||
not present. In such cases a warning message is sent to the system log,
|
||||
but the daemon should still work properly.
|
||||
|
||||
<p><h4>Building and Installing under Unix</h4>
|
||||
|
||||
<p>Make sure that you have all necessary tools for building executables.
|
||||
These tools include <code>cc/gcc, make, awk, sed, tr, sh, grep,
|
||||
egrep</code> and a few others. Not all of these tools exist in the
|
||||
standard distribution of modern Unix versions (compilers are likely to
|
||||
be an add-on product - consider using the <code>gnu</code> tools and
|
||||
<code>gcc</code> compiler in this case). For a successful build, all of
|
||||
these tools should be accessible via the current path.
|
||||
|
||||
<h5>Configuration</h5>
|
||||
|
||||
<p>Use the <code>configure</code> command to perform an automatic
|
||||
configuration procedure. This procedure normally includes the debugging
|
||||
code, which can be useful in diagnosing problems found in initial test,
|
||||
and all reference clock drivers known to work with each machine and
|
||||
operating system. Unless memory space is at a premium, this is a
|
||||
sensible strategy and saves lots of messy fiddling. If you need to
|
||||
delete either the debugging code or one or more or all reference clock
|
||||
drivers to save space, see the <a href="config.html">Configuration
|
||||
Options</a> page.
|
||||
|
||||
<p>If your site supports multiple architectures and uses NFS to share
|
||||
files, you can use a single source tree to compile executables for all
|
||||
architectures. While running on a target architecture machine and with
|
||||
the distribution base directory active, create a subdirectory using a
|
||||
command like <code>mkdir `config.guess`</code>, which will create an
|
||||
architecture-specific directory with name peculiar to the architecture
|
||||
and operating system. Then change to this directory and configure with
|
||||
the <code>../configure</code> command. The remaining steps are the same
|
||||
whether building in the base directory or in the subdirectory.
|
||||
|
||||
<h5>Compilation</h5>
|
||||
|
||||
<p>Use the <code>make</code> command to compile all source modules,
|
||||
construct the libraries and link the distribution. Expect few or no
|
||||
warnings using <code>cc</code> and a moderate level of warnings using
|
||||
<code>gcc</code>. Note: On some Unix platforms the use of
|
||||
<code>gcc</code> can result in quite a few complaints about system
|
||||
header files and type inconsistencies, especially about pointer
|
||||
variables. This is usually the case when the system header files are not
|
||||
up to ANSI standards or <code>gcc</code>-isms. While the autoconfigure
|
||||
process is quite thorough, the Unix programming cultures of the various
|
||||
workstation makers still remain idiosyncratic.
|
||||
|
||||
<h5>Installation</h5>
|
||||
<p>As root, use the <code>make install</code> command to install the
|
||||
binaries in the destination directory. You must of course have write
|
||||
permission on the install destination directory. This includes the
|
||||
programs <a href="xntpd.html"><code>xntpd</code></a> (the daemon), <a
|
||||
href="xntpdc.html"><code>xntpdc</code></a> (an <code>xntpd</code>-
|
||||
dependent query program), <a href="ntpq.html"><code>ntpq</code></a> (a
|
||||
standard query program), <a href="ntpdate.html"><code>ntpdate</code></a>
|
||||
(an <code>rdate</code> replacement for boot time date setting and sloppy
|
||||
time keeping) and <a href="ntptrace.html"><code>ntptrace</code></a> (a
|
||||
utility useful to find the primary (stratum-1) servers). In some
|
||||
systems, the <a href="tickadj.html"><code>tickadj</code></a> (a utility
|
||||
useful to adjust kernel variables) is installed. If the precision time
|
||||
kernel modifications are present, the <a
|
||||
href="ntptime.html"><code>ntptime</code></a> (a utility useful to debug
|
||||
kernel time functions) is installed.
|
||||
|
||||
<p>You are now ready to configure the daemon and start it. You will need
|
||||
to create a NTP configuration file <code>ntp.conf</code> and possibly a
|
||||
cryptographic key file <code>ntp.keys</code>. Directions for doing that
|
||||
are in the <a href="notes.html">Notes on Configuring NTP and Setting up
|
||||
a NTP Subnet</a>. A tutorial on debugging technique is in <a
|
||||
href="debug.html">NTP Debugging Technique</a>. If problems peculiar to
|
||||
the particular hardware and software environment are suspected, browse
|
||||
the <a href="http:hints.html">Hints and Kinks</a> page.
|
||||
|
||||
<p>Bug reports of a general nature can be sent to David Mills
|
||||
(mills@udel.edu). Bug reports of a specific nature on features
|
||||
implemented by the programmer corps mentioned in the <a
|
||||
href="copyright.html">Copyright</a> page should be sent directly to the
|
||||
implementor listed in that page, with copy to mills@udel.edu.
|
||||
|
||||
<p><strong>Please include the version of the source distribution (e.g.,
|
||||
xntp3-5.87) in your bug report.</strong>
|
||||
|
||||
<p><strong>Please include the output of <code>config.guess</code> in
|
||||
your bug report.</strong>
|
||||
|
||||
<p><strong>It will look something like:
|
||||
<code>pdp11-dec-fuzzos3.4</code></strong>
|
||||
|
||||
<p>Additional <code>make</code> commands
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>make clean</code>
|
||||
<dd>Cleans out object files, programs and temporary files.
|
||||
|
||||
<p><dt><code>make distclean</code>
|
||||
<dd>Does the work of <code>clean</code>, but cleans out all directories
|
||||
in preparation for a new distribution release.
|
||||
|
||||
<p><dt><code>make dist</code>
|
||||
<dd>Does the work of <code>make distclean</code>, but constructs
|
||||
compressed tar files for distribution. You must have GNU automake to
|
||||
perform this function.
|
||||
|
||||
</dl>
|
||||
|
||||
<p><h4>Building and Installing under Windows NT</h4>
|
||||
|
||||
<p>Under Windows NT, you will need <code>Visual C++ 4.0</code> or above,
|
||||
<code>InstallShield</code> SDK (comes with <code>VC++</code>),
|
||||
<code>Perl5</code> and some version of the archiving program
|
||||
<code>ZIP</code>.
|
||||
|
||||
<p>See the <code>./scripts/wininstall/readme.nt</code> file for
|
||||
directions to compile the sources, build the libraries and link the
|
||||
executables. Initiate the build by running either <code>bldrel.bat</code>
|
||||
or <code>blddbg.bat</code> to compile all of the source and create an
|
||||
<code>InstallShield</code> based graphical installation package.
|
||||
|
||||
<p>To install the executables, make sure that you are logged in as a
|
||||
system account, or one with administrator privileges such as the
|
||||
"administrator" account. As part of the build an
|
||||
<code>InstallShield</code> based graphical installer was created. Run
|
||||
<code>\xntp\scripts\wininstall\intel\disk1\setup.exe</code> to begin the
|
||||
installation. This installer will prompt for basic defaults, copy the
|
||||
binaries, install the service, and start it up. The other option is
|
||||
to run <code>\xntp\scripts\wininstall\distrib\install.bat</code> which
|
||||
will do the basic installation from the command line.
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,172 +0,0 @@
|
||||
<!-- $NetBSD: clockopt.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Reference Clock Options
|
||||
</title></head><body><h3>
|
||||
Reference Clock Options
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Reference Clock Support</h4>
|
||||
|
||||
<p>The NTP Version 3 daemon currently supports several different radio,
|
||||
satellite and modem reference clocks plus a special pseudo-clock used
|
||||
for backup or when no other clock source is available. Detailed
|
||||
descriptions of individual device drivers and options can be found in
|
||||
the <a href = "refclock.html"> Reference Clock Drivers </a> page.
|
||||
Additional information can be found in the pages referenced there,
|
||||
including the <a href="rdebug.html">Debugging Hints for Reference Clock
|
||||
Drivers</a> and <a href="howto.html">How To Write a Reference Clock
|
||||
Driver</a> pages. In many drivers, support for a PPS signal is available
|
||||
as described in <a href="pps.html">Pulse-per-second (PPS) Signal
|
||||
Interfacing</a> page. Many drivers support special line
|
||||
discipline/streams modules which can significantly improve the accuracy
|
||||
using the driver. These are described in the <a href="ldisc.html">Line
|
||||
Disciplines and Streams Drivers</a> page.
|
||||
|
||||
<p>A reference clock will generally (though not always) be a radio
|
||||
timecode receiver which is synchronized to a source of standard time
|
||||
such as the services offered by the NRC in Canada and NIST and USNO in
|
||||
the U.S. The interface between the computer and the timecode receiver is
|
||||
device dependent and will vary, but is often a serial port. A device
|
||||
driver specific to each clock must be selected and compiled in the
|
||||
distribution; however, most common radio, satellite and modem clocks
|
||||
are included by default. Note that an attempt to configure a reference
|
||||
clock when the driver has not been included or the hardware port has not
|
||||
been appropriately configured results in a scalding remark to the system
|
||||
log file, but is otherwise non hazardous.
|
||||
|
||||
<p>For the purposes of configuration, <code>xntpd</code> treats
|
||||
reference clocks in a manner analogous to normal NTP peers as much as
|
||||
possible. Reference clocks are identified by a syntactically correct but
|
||||
invalid IP address, in order to distinguish them from normal NTP peers.
|
||||
Reference clock addresses are of the form
|
||||
<code>127.127.<i>t.u</i></code>, where <code><i>t</i></code> is an
|
||||
integer denoting the clock type and <code><i>u</i></code> indicates the
|
||||
type-specific unit number.
|
||||
|
||||
The <code>server</code> command is used to configure a reference clock,
|
||||
where the <code><i>address</i></code> argument in that command is the
|
||||
clock address. The <code>key</code>, <code>version</code> and
|
||||
<code>ttl</code> options are not used for reference clock support. The
|
||||
<code>mode</code> option is added for reference clock support, as
|
||||
described below. The <code>prefer</code> option can be useful to
|
||||
persuade the server to cherish a reference clock with somewhat more
|
||||
enthusiasm than other reference clocks or peers. Further information on
|
||||
this option can be found in the <a href = "prefer.html"> Mitigation
|
||||
Rules and the <code>prefer</code> Keyword </a> page. The
|
||||
<code>minpoll</code> and <code>maxpoll</code> options have meaning only
|
||||
for selected clock drivers. See the individual clock driver document
|
||||
pages for additional information.
|
||||
|
||||
<p>The stratum of a reference clock is by default zero. Since the
|
||||
<code>xntpd</code> daemon adds one to the stratum of each peer, a
|
||||
primary server ordinarily displays stratum one. In order to provide
|
||||
engineered backups, it is often useful to specify the reference clock
|
||||
stratum as greater than zero. The <code>stratum</code> option is used
|
||||
for this purpose. Also, in cases involving both a reference clock and a
|
||||
pulse-per-second (PPS) discipline signal, it is useful to specify the
|
||||
reference clock identifier as other than the default, depending on the
|
||||
driver. The <code>refid</code> option is used for this purpose. Except
|
||||
where noted, these options apply to all clock drivers.
|
||||
|
||||
<p><h4>Reference Clock Commands</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>server 127.127.<i>t.u</i> [ prefer ] [ mode <i>int</i> ]</code>
|
||||
<dd>This command can be used to configure reference clocks in special
|
||||
ways. The options are interpreted as follows:
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>prefer</code>
|
||||
<dd>Marks the reference clock as preferred. All other things being
|
||||
equal, this host will be chosen for synchronization among a set of
|
||||
correctly operating hosts. See the <a href = "prefer.html"> Mitigation
|
||||
Rules and the <code>prefer</code> Keyword </a> page for further
|
||||
information.
|
||||
|
||||
<p><dt><code>mode <i>int</i></code>
|
||||
<dd>Specifies a mode number which is interpreted in a device-specific
|
||||
fashion. For instance, it selects a dialing protocol in the ACTS driver
|
||||
and a device subtype in the <code>parse</code> drivers.
|
||||
|
||||
<p><dt><code>minpoll <i>minpoll</i></code>
|
||||
<dd>This option specifies the minimum polling interval for NTP messages,
|
||||
in seconds to the power of two. The allowable range is 4 (16 s to 14
|
||||
(16384 s) inclusive. The default is 6 (64 s) for all except modem
|
||||
reference clocks, where the default is 10 (1024 s).
|
||||
|
||||
<p><dt><code>maxpoll <i>maxpoll</i></code>
|
||||
<dd>This option specifies the maximum polling interval for NTP messages,
|
||||
in seconds to the power of two. The allowable range is 4 (16 s to 14
|
||||
(16384 s) inclusive. The default is 6 (64 s) for all except modem
|
||||
reference clocks, where the default is 14 (16384 s).
|
||||
|
||||
</dl>
|
||||
|
||||
<dt><code>fudge 127.127.<i>t.u</i> [ time1 <i>secs</i> ] [ time2
|
||||
<i>secs</i> ] [ stratum <i>int</i> ] [ refid <i>string</i> ] [ mode
|
||||
<i>int</i> ] [ flag1 0 | 1 ] [ flag2 0 | 1 ] [ flag3 0 | 1] [ flag4 0 |
|
||||
1 ]</code>
|
||||
<dd>This command can be used to configure reference clocks in special
|
||||
ways. It must immediately follow the <code>server</code> command which
|
||||
configures the driver. Note that the same capability is possible at run
|
||||
time using the <a href = "xntpdc.html"> <code>xntpdc</code></a> program.
|
||||
The options are interpreted as follows:
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>secs</i></code>
|
||||
<dd>Specifies a constant to be added to the time offset produced by the
|
||||
driver, a fixed-point decimal number in seconds. This is used as a
|
||||
calibration constant to adjust the nominal time offset of a particular
|
||||
clock to agree with an external standard, such as a precision PPS
|
||||
signal. It also provides a way to correct a systematic error or bias due
|
||||
to serial port latencies, different cable lengths or receiver internal
|
||||
delay. The specified offset is in addition to the propagation delay
|
||||
provided by other means, such as internal DIPswitches. Where a
|
||||
calibration for an individual system and driver is available, an
|
||||
approximate correction is noted in the driver documentation pages.
|
||||
|
||||
<p><dt><code>time2 <i>secs</i></code>
|
||||
<dd>Specifies a fixed-point decimal number in seconds, which is
|
||||
interpreted in a driver-dependent way. See the descriptions of specific
|
||||
drivers in the <a href="refclock.html">reference clock drivers</a> page.
|
||||
|
||||
<p><dt><code>stratum <i>int</i></code>
|
||||
<dd>Specifies the stratum number assigned to the driver, an integer
|
||||
between 0 and 15. This number overrides the default stratum number
|
||||
ordinarily assigned by the driver itself, usually zero.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies an ASCII string of from one to four characters which
|
||||
defines the reference identifier used by the driver. This string
|
||||
overrides the default identifier ordinarily assigned by the driver
|
||||
itself.
|
||||
|
||||
<p><dt><code>mode <i>int</i></code>
|
||||
<dd>Specifies a mode number which is interpreted in a device-specific
|
||||
fashion. For instance, it selects a dialing protocol in the ACTS driver
|
||||
and a device subtype in the <code>parse</code> drivers.
|
||||
|
||||
<p><dt><code>flag1</code> <code>flag2</code> <code>flag3</code>
|
||||
<code>flag4</code>
|
||||
<dd>These four flags are used for customizing the clock driver. The
|
||||
interpretation of these values, and whether they are used at all, is a
|
||||
function of the particular clock driver. However, by convention, and
|
||||
unless indicated otherwise, <code>flag3</code> is used to attach the
|
||||
<code>ppsclock</code> streams module to the configured driver, while
|
||||
<code>flag4</code> is used to enable recording verbose monitoring data
|
||||
to the <code>clockstats</code> file configured with the
|
||||
<code>filegen</code> command. Further information on the
|
||||
<code>ppsclock</code> streams module can be found in the <a
|
||||
href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page.
|
||||
Further information on the <code>filegen</code> command can be found in
|
||||
the <a href="monopt.html"> Monitoring Options </a> page.
|
||||
|
||||
</dl>
|
||||
|
||||
</dl>
|
||||
|
||||
<p><hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,137 +0,0 @@
|
||||
<!-- $NetBSD: config.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Configuration Options
|
||||
</title></head><body><h3>
|
||||
Configuration Options
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Basic Configuration Options - the <code>configure</code>
|
||||
utility</h4>
|
||||
|
||||
<p>The following options are for compiling and installing a working
|
||||
version of the xntp3 distribution. In most cases, the build process is
|
||||
completely automatic. In some cases where memory space is at a premium,
|
||||
or the binaries are to be installed in a different place, it is possible
|
||||
to tailor the configuration to remove such features as reference clock
|
||||
driver support, debugging support, and so forth.
|
||||
|
||||
<p>Configuration options are specified as arguments to the
|
||||
<code>configure</code> script. Following is a summary of the current
|
||||
options:
|
||||
<p>
|
||||
Usage: configure [options] [host]<br>
|
||||
Options: [defaults in brackets after descriptions]
|
||||
|
||||
<p><pre>
|
||||
Configuration
|
||||
|
||||
--cache-file=FILE cache test results in FILE
|
||||
--help print this message
|
||||
--no-create do not create output files
|
||||
--quiet, --silent do not print `checking...' messages
|
||||
--version print the version of autoconf that created
|
||||
configure
|
||||
Directory and file names
|
||||
|
||||
--prefix=PREFIX install architecture-independent files in
|
||||
PREFIX [/usr/local]
|
||||
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
|
||||
[same as prefix]
|
||||
--bindir=DIR user executables in DIR [EPREFIX/bin]
|
||||
--sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
|
||||
--libexecdir=DIR program executables in DIR [EPREFIX/libexec]
|
||||
--datadir=DIR read-only architecture-independent data in DIR
|
||||
[PREFIX/share]
|
||||
--sysconfdir=DIR read-only single-machine data in DIR
|
||||
[PREFIX/etc]
|
||||
--sharedstatedir=DIR modifiable architecture-independent data in DIR
|
||||
[PREFIX/com]
|
||||
--localstatedir=DIR modifiable single-machine data in DIR
|
||||
[PREFIX/var]
|
||||
--libdir=DIR object code libraries in DIR [EPREFIX/lib]
|
||||
--includedir=DIR C header files in DIR [PREFIX/include]
|
||||
--oldincludedir=DIR C header files for non-gcc in DIR
|
||||
[/usr/include]
|
||||
--infodir=DIR info documentation in DIR [PREFIX/info]
|
||||
--mandir=DIR man documentation in DIR [PREFIX/man]
|
||||
--srcdir=DIR find the sources in DIR [configure dir or ..]
|
||||
--program-prefix=PREFIX prepend PREFIX to installed program names
|
||||
--program-suffix=SUFFIX append SUFFIX to installed program names
|
||||
--program-transform-name=PROGRAM run sed PROGRAM on installed program
|
||||
names
|
||||
Host type
|
||||
|
||||
--build=BUILD configure for building on BUILD [BUILD=HOST]
|
||||
--host=HOST configure for HOST [guessed]
|
||||
--target=TARGET configure for TARGET [TARGET=HOST]
|
||||
Features and packages
|
||||
|
||||
--disable-FEATURE do not include FEATURE (same as --enable-
|
||||
FEATURE=no)
|
||||
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
|
||||
--x-includes=DIR X include files are in DIR
|
||||
--x-libraries=DIR X library files are in DIR
|
||||
|
||||
--enable- and --disable- with options recognized
|
||||
|
||||
debugging Include debugging code [enable]
|
||||
gdt-surveying Include GDT survey code [disable]
|
||||
md5 Include support for MD5 keys [enable]
|
||||
des Include support for DES keys [enable]
|
||||
all-clocks Include drivers for all reference clocks
|
||||
[enable]
|
||||
|
||||
Radio Clocks (these are ordinarily enabled, if supported by the
|
||||
machine and operating system)
|
||||
|
||||
ACTS NIST dialup clock
|
||||
ARBITER Arbiter 1088A/B GPS receiver
|
||||
AS2201 Austron 2200A or 2201A GPS receiver
|
||||
ATOM ATOM clock
|
||||
BANCOMM BANCOMM clock
|
||||
CHU CHU clock
|
||||
DATUM Datum Programmable Time System
|
||||
DCF7000 ELV/DCF7000
|
||||
GPSVME GPS-VME Clock
|
||||
HEATH HeathKit GC-1000 Most Accurate Clock
|
||||
HOPF6021 HOPF6021 Radio Clock support
|
||||
HPGPS HP 58503A GPS Time & Frequency receiver
|
||||
IRIG IRIG (Audio) Clock
|
||||
LEITCH Leitch CSD 5300 Master Clock System Driver
|
||||
LOCAL-CLOCK Local Clock driver
|
||||
MEINBERG Meinberg clocks
|
||||
MSFEES MSFEES clock
|
||||
MOTO Motorola GPS clock
|
||||
MX4200 MX4200 clock
|
||||
NMEA NMEA GPS clock
|
||||
PARSE PARSE clock code
|
||||
PST PST/Traconex 1020 WWV/H receiver
|
||||
PTBACTS PTB dialup clock support
|
||||
RAWDCF use raw DCF77 time code
|
||||
RCC8000 RCC8000 Radio Clock support
|
||||
SCHMID SCHMID DCF77 clock support
|
||||
TRAK TRAK 8810 GPS station clock
|
||||
TPRO KSI/Odetics TPRO/S IRIG Interface
|
||||
TRIMTAIP Trimble GPS/TAIP Protocol
|
||||
TRIMTSIP Trimble GPS/TSIP Protocol
|
||||
TRUETIME Kinemetrics/TrueTime (generic) receiver
|
||||
WWVB Spectracom 8170 or Netclock/2 WWVB receiver
|
||||
USNO US Naval Observatory dialup clock
|
||||
|
||||
Miscellany
|
||||
|
||||
accurate-adjtime The adjtime() call is accurate
|
||||
kmem Read kmem
|
||||
tick=VALUE Force a value for 'tick'
|
||||
tickadj=VALUE Force a value for 'tickadj'
|
||||
udp-wildcard Use UDP wildcard delivery
|
||||
slew-always Always slew the time
|
||||
step-slew Step and slew the time
|
||||
ntpdate-step If ntpdate should step the time
|
||||
hourly-todr-sync If we should sync TODR hourly
|
||||
</pre><p>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,190 +0,0 @@
|
||||
<!-- $NetBSD: confopt.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Configuration Options
|
||||
</title></head><body><h3>
|
||||
Configuration Options
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Configuration Commands</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>peer <i>address</i> [ key <i>key</i> ] [ version
|
||||
<i>version</i> ] [ prefer ]</code> [ minpoll <i>minpoll</i> [ maxpoll
|
||||
<i>maxpoll</i> ]
|
||||
<br><code>server <i>address</i> [ key <i>key</i> ] [ version
|
||||
<i>version</i> ] [ prefer ] [ mode <i>mode</i> ]</code>
|
||||
<br><code>broadcast <i>address</i> [ key <i>key</i> ] [ version
|
||||
<i>version</i> ] [ ttl <i>ttl</i> ]</code>
|
||||
<dd>These three commands specify the time server name or address
|
||||
<i>address</i> to be used and the mode in which to operate. The
|
||||
<i>address</i> can be either a DNS name or a IP address in dotted-quad
|
||||
notation. The <code>peer</code> command specifies that the local server
|
||||
is to operate in symmetric active mode with the remote server. In this
|
||||
mode, the local server can be synchronized to the remote server and, in
|
||||
addition, the remote server can be synchronized by the local server.
|
||||
This is useful in a network of servers where, depending on various
|
||||
failure scenarios, either the local or remote server may be the better
|
||||
source of time.
|
||||
|
||||
<p><dd>The <code>server</code> command specifies that the local server
|
||||
is to operate in client mode with the specified remote server. In this
|
||||
mode, the local server can be synchronized to the remote server, but the
|
||||
remote server can never be synchronized to the local server.
|
||||
|
||||
<p><dd>The <code>broadcast</code> command specifies that the local
|
||||
server is to operate in broadcast mode, where the local server sends
|
||||
periodic broadcast messages to a client population at the
|
||||
broadcast/multicast <i>address</i> specified. Ordinarily, this
|
||||
specification applies only to the local server operating as a sender;
|
||||
for operation as a broadcast client, see the
|
||||
<code>broadcastclient</code> or <code>multicastclient</code> commands
|
||||
below. In this mode, <i>address</i> is usually the broadcast address on
|
||||
(one of) the local network(s) or a multicast address assigned to NTP.
|
||||
The Numbers Czar has assigned the address 224.0.1.1 to NTP; this is
|
||||
presently the only address that should be used. Note that the use of
|
||||
multicast features requires a multicast kernel, which is not yet
|
||||
ubiquitous in vendor products.
|
||||
|
||||
<p><dd>Options
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>key <i>key</i></code>
|
||||
<dd>All packets sent to the address are to include authentication fields
|
||||
encrypted using the specified <i>key</i> identifier, which is an
|
||||
unsigned 32 bit integer. The default is to not include an encryption
|
||||
field.
|
||||
|
||||
<p><dt><code>version <i>version</i></code>
|
||||
<dd>Specifies the version number to be used for outgoing NTP packets.
|
||||
Versions 1, 2, and 3 are the choices, with version 3 the default.
|
||||
|
||||
<p><dt><code>prefer</code>
|
||||
<dd>Marks the server as preferred. All other things being equal, this
|
||||
host will be chosen for synchronization among a set of correctly
|
||||
operating hosts. See the <a href = "prefer.html"> Mitigation Rules and
|
||||
the <code>prefer</code> Keyword </a> page for further information.
|
||||
<p><dt><code>ttl <i>ttl</i></code>
|
||||
<dd>This option is used only with broadcast mode. It specifies the time-
|
||||
to-live <i>ttl</i> to use on multicast packets. Selection of the proper
|
||||
value, which defaults to 127, is something of a black art and must be
|
||||
coordinated with the network administrator(s).
|
||||
|
||||
<p><dt><code>minpoll <i>minpoll</i></code>
|
||||
<dd>This option specifies the minimum polling interval for NTP messages,
|
||||
in seconds to the power of two. The allowable range is 4 (16 s to 14
|
||||
(16384 s) inclusive. The default is 6 (64 s) for all except reference
|
||||
clocks.
|
||||
|
||||
<p><dt><code>maxpoll <i>maxpoll</i></code>
|
||||
<dd>This option specifies the maximum polling interval for NTP messages,
|
||||
in seconds to the power of two. The allowable range is 4 (16 s to 14
|
||||
(16384 s) inclusive. The default is 10 (1024 s) for all except reference
|
||||
clocks.
|
||||
|
||||
</dl>
|
||||
|
||||
<p><dt><code>broadcastclient [ <i>address</i></code> ]
|
||||
<dd>This command directs the local server to listen for broadcast
|
||||
messages at the broadcast address <i>address</i> of the local network.
|
||||
The default address is the subnet address with the host field bits set
|
||||
to ones. Upon hearing a broadcast message for the first time, the local
|
||||
server measures the nominal network delay using a brief client/server
|
||||
exchange with the remote server, then enters the broadcastclient mode,
|
||||
in which it listens for and synchronizes to succeeding broadcast
|
||||
messages. Note that, in order to avoid accidental or malicious
|
||||
disruption in this mode, both the local and remote servers should
|
||||
operate using authentication and the same trusted key and key
|
||||
identifier.
|
||||
|
||||
<p><dt><code>multicastclient [ <i>address</i> ] [ ... ]</code>
|
||||
<dd>This command directs the local server to listen for multicast
|
||||
messages at the group <i>address</i>(es) of the global network. The
|
||||
default address is that assigned by the Numbers Czar to NTP (224.0.1.1).
|
||||
This command operates in the same way as the
|
||||
<code>broadcastclient</code> command, but uses IP multicasting. Support
|
||||
for this command requires a multicast kernel.
|
||||
|
||||
<p><dt><code>driftfile <i>driftfile</i></code>
|
||||
<dd>This command specifies the name of the file used to record the
|
||||
frequency offset of the local clock oscillator. If the file exists, it
|
||||
is read at startup in order to set the initial frequency offset and then
|
||||
updated once per hour with the current frequency offset computed by the
|
||||
daemon. If the file does not exist or this command is not given, the
|
||||
initial frequency offset is assumed zero. In this case, it may take some
|
||||
hours for the frequency to stabilize and the residual timing errors to
|
||||
subside.
|
||||
|
||||
<p><dd>The <code>ntp.drift</code> file format consists of a single line
|
||||
containing a single floating point number, which records the frequency
|
||||
offset measured in parts-per-million (PPM). That the file is updated
|
||||
once per hour by first writing the current drift value into a temporary
|
||||
file and then renaming this file to replace the old version. This
|
||||
implies that <code>xntpd</code> must have write permission for the
|
||||
directory the drift file is located in, and that file system links,
|
||||
symbolic or otherwise, should probably be avoided.
|
||||
|
||||
<p><dt><code>enable auth | bclient | monitor | pll | pps | stats</code>
|
||||
<br><code>disable auth | bclient | monitor | pll | pps | stats</code>
|
||||
<dd>Provides a way to enable or disable various server options. Flags
|
||||
not mentioned are unaffected. Note that all of these flags can be
|
||||
controlled remotely using the <a href =
|
||||
"xntpdc.html"><code>xntpdc</code></a> utility program.
|
||||
<dl>
|
||||
|
||||
<dt><code>auth</code>
|
||||
<dd>Enables the server to synchronize with unconfigured peers only if
|
||||
the peer has been correctly authenticated using a trusted key and key
|
||||
identifier. The default for this flag is enable.
|
||||
|
||||
<p><dt><code>bclient</code>
|
||||
<dd>Enables the server to listen for a message from a broadcast or
|
||||
multicast server, as in the <code>multicastclient</code> command with
|
||||
default address. The default for this flag is disable.
|
||||
|
||||
<p><dt><code>monitor</code>
|
||||
<dd>Enables the monitoring facility. See the <code>xntpdc</code> program
|
||||
and the <code>monlist</code> command or further information. The default
|
||||
for this flag is enable.
|
||||
|
||||
<p><dt><code>pll</code>
|
||||
<dd>Enables the server to adjust its local clock by means of NTP. If
|
||||
disabled, the local clock free-runs at its intrinsic time and frequency
|
||||
offset. This flag is useful in case the local clock is controlled by
|
||||
some other device or protocol and NTP is used only to provide
|
||||
synchronization to other clients. In this case, the local clock driver
|
||||
is used. See the <a href = "refclock.html">Reference Clock Drivers </a>
|
||||
page for further information. The default for this flag is enable.
|
||||
|
||||
<p><dt><code>pps</code>
|
||||
<dd>Enables the pulse-per-second (PPS) signal when frequency and time is
|
||||
disciplined by the precision time kernel modifications. See the <a href
|
||||
= "kern.html"> A Kernel Model for Precision Timekeeping </a> page for
|
||||
further information. The default for this flag is disable.
|
||||
|
||||
<p><dt><code>stats</code>
|
||||
<dd>Enables the statistics facility. See the <a href="monopt.html">
|
||||
Monitoring Options </a>
|
||||
page for further information. The default for this flag is enable.
|
||||
|
||||
</dl>
|
||||
|
||||
<p><dt><code>tick value</code>
|
||||
<dd>If no value for <code>tick</code> can be found from the kernel, use
|
||||
this value. This is the "normalized" value; if your system
|
||||
keeps <code>tick</code> in nanoseconds you must divide your
|
||||
value by 1000. The expected range of the value is between 900
|
||||
and 11,000 (don't use the comma in the config file).
|
||||
|
||||
<p><dt><code>tickadj value</code>
|
||||
<dd>If no value for <code>tickadj</code> can be found in the
|
||||
kernel, use this value. The value must be "normalized"; if
|
||||
your system keeps <code>tickadj</code> in nanoseconds you must
|
||||
divide your value by 1000. The expected range of the value is
|
||||
between 1 and 50.
|
||||
|
||||
</dl>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,143 +0,0 @@
|
||||
<!-- $NetBSD: copyright.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Copyright Notice
|
||||
</title></head><body><h3>
|
||||
Copyright Notice
|
||||
</h3><hr>
|
||||
|
||||
<p>The following copyright notice applies to all files collectively
|
||||
called the Network Time Protocol Version 3 Distribution. Unless
|
||||
specifically declared otherwise in an individual file, this notice
|
||||
applies as if the text was explicitly included in the file.
|
||||
|
||||
<pre>
|
||||
|
||||
/***********************************************************************
|
||||
* *
|
||||
* Copyright (c) David L. Mills 1992, 1993, 1994, 1995, 1996, 1997 *
|
||||
* *
|
||||
* Permission to use, copy, modify, and distribute this software and *
|
||||
* its documentation for any purpose and without fee is hereby *
|
||||
* granted, provided that the above copyright notice appears in all *
|
||||
* copies and that both the copyright notice and this permission *
|
||||
* notice appear in supporting documentation, and that the name *
|
||||
* University of Delaware not be used in advertising or publicity *
|
||||
* pertaining to distribution of the software without specific, *
|
||||
* written prior permission. The University of Delaware makes no *
|
||||
* representations about the suitability this software for any *
|
||||
* purpose. It is provided "as is" without express or implied *
|
||||
* warranty. *
|
||||
**********************************************************************/
|
||||
|
||||
</pre>
|
||||
|
||||
<p>The following individuals contributed in part to the Network Time
|
||||
Protocol Distribution Version 4 and are acknowledged as authors of this
|
||||
work.
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mark Andrews <marka@syd.dms.csiro.au> Leitch atomic clock
|
||||
controller
|
||||
|
||||
<br><li>Viraj Bais <vbais@mailman1.intel.com> and Clayton Kirkwood
|
||||
<kirkwood@striderfm.intel.com> port to WindowsNT 3.5
|
||||
|
||||
<br><li>Karl Berry <karl@owl.HQ.ileaf.com> syslog to file option
|
||||
|
||||
<br><li>Piete Brooks <Piete.Brooks@cl.cam.ac.uk> MSF clock driver,
|
||||
Trimble PARSE support
|
||||
|
||||
<br><li>Steve Clift <clift@ml.csiro.au>: OMEGA clock driver
|
||||
|
||||
<br><li><a href="http://www.ee.uct.ac.za/~casey"> Casey Crellin </a>
|
||||
<a href="mailto:casey@csc.co.za"> (casey@csc.co.za) </a>
|
||||
vxWorks (Tornado) port and help with target configuration
|
||||
|
||||
<br><li>Torsten Duwe <duwe@immd4.informatik.uni-erlangen.de> Linux
|
||||
Port
|
||||
|
||||
<br><li>John A. Dundas III <dundas@salt.jpl.nasa.gov> Apple A/UX
|
||||
port
|
||||
|
||||
<br><li>Dennis Ferguson <dennis@mrbill.canet.ca> foundation code
|
||||
for NTP Version 2 as specified in RFC-1119
|
||||
|
||||
<br><li>Glenn Hollinger <glenn@herald.usask.ca> GOES clock driver
|
||||
|
||||
<br><li>Mike Iglesias <iglesias@uci.edu>: DEC Alpha port
|
||||
|
||||
<br><li>Jim Jagielski <jim@jagubox.gsfc.nasa.gov> A/UX port
|
||||
<br><li>Jeff Johnson <jbj@chatham.usdesign.com> massive
|
||||
prototyping overhaul
|
||||
|
||||
<br><li>William L. Jones <jones@hermes.chpc.utexas.edu> RS/6000
|
||||
AIX modifications, HPUX modifications
|
||||
|
||||
<br><li>Dave Katz <dkatz@cisco.com> RS/6000 AIX port
|
||||
|
||||
<br><li>Craig Leres <leres@ee.lbl.gov> 4.4BSD port, ppsclock,
|
||||
Maganavox GPS clock driver
|
||||
|
||||
<br><li>George Lindholm <lindholm@ucs.ubc.ca> SunOS 5.1 port
|
||||
|
||||
<br><li>Louis A. Mamakos <louie@ni.umd.edu> MD5-based
|
||||
authentication
|
||||
|
||||
<br><li>Derek Mulcahy <derek@toybox.demon.co.uk> and Damon Hart-Davis
|
||||
<d@hd.org>: ARCRON MSF clock driver
|
||||
|
||||
<br><li>Lars H. Mathiesen <thorinn@diku.dk> adaptation of
|
||||
foundation code for Version 3 as specified in RFC-1305
|
||||
|
||||
<br><li><a href="http://www.eecis.udel.edu/~mills">David L. Mills
|
||||
<mills@udel.edu></a> Spectractom WWVB, Austron GPS, Arbiter GPS,
|
||||
Heath, ATOM, ACTS, KSI/Odetics IRIG-B clock drivers; PPS support
|
||||
|
||||
<br><li>Wolfgang Moeller <moeller@gwdgv1.dnet.gwdg.de> VMS port
|
||||
|
||||
<br><li>Jeffrey Mogul <mogul@pa.dec.com> ntptrace utility
|
||||
|
||||
<br><li>Tom Moore <tmoore@fievel.daytonoh.ncr.com> i386 svr4 port
|
||||
|
||||
<br><li>Rainer Pruy <Rainer.Pruy@informatik.uni-erlangen.de>
|
||||
monitoring/trap scripts, statistics file handling
|
||||
|
||||
<br><li>Dirce Richards <dirce@zk3.dec.com> Digital UNIX V4.0 port
|
||||
|
||||
<br><li>Nick Sayer <mrapple@quack.kfu.com> SunOS streams modules
|
||||
|
||||
<br><li><a href="http://www4.informatik.uni-erlangen.de/~kardel">Frank Kardel</a>
|
||||
<a href="mailto: Frank.Kardel@informatik.uni-erlangen.de"> <Frank.Kardel@informatik.uni-erlangen.de></a>
|
||||
PARSE <GENERIC> driver (14 reference clocks), STREAMS modules for PARSE, support
|
||||
scripts, syslog cleanup
|
||||
|
||||
<br><li>Ray Schnitzler <schnitz@unipress.com> Unixware1 port
|
||||
|
||||
<br><li>Michael Shields <shields@tembel.org> USNO clock driver
|
||||
|
||||
<br><li>Jeff Steinman <jss@pebbles.jpl.nasa.gov> Datum PTS clock
|
||||
driver
|
||||
|
||||
<br><li>Harlan Stenn <harlan@pfcs.com> GNU automake/autoconfigure
|
||||
makeover
|
||||
|
||||
<br><li>Kenneth Stone <ken@sdd.hp.com> HP-UX port
|
||||
|
||||
<br><li><a href="http://www.eecis.udel.edu/~ajit">Ajit Thyagarajan
|
||||
<ajit@ee.udel.edu></a> IP multicast support
|
||||
|
||||
<br><li>Tomoaki TSURUOKA <tsuruoka@nc.fukuoka-u.ac.jp> TRAK clock
|
||||
driver
|
||||
|
||||
<br><li>Paul A Vixie <vixie@vix.com> TrueTime GPS driver, generic
|
||||
TrueTime clock driver
|
||||
|
||||
<li>Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> Corrected and
|
||||
validated HTML documents according to the HTML DTD
|
||||
|
||||
</ol>
|
||||
|
||||
<hr><address>David L. Mills
|
||||
<mills@udel.edu></address></body></html>
|
@ -1,279 +0,0 @@
|
||||
<!-- $NetBSD: debug.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
NTP Debugging Techniques
|
||||
</title></head><body><h3>
|
||||
NTP Debugging Techniques
|
||||
</h3><hr>
|
||||
|
||||
<p>Once the NTP software distribution has been compiled and installed
|
||||
and the configuration file constructed, the next step is to verify
|
||||
correct operation and fix any bugs that may result. Usually, the command
|
||||
line that starts the daemon is included in the system startup file, so
|
||||
it is executed only at system boot time; however, the daemon can be
|
||||
stopped and restarted from root at any time. Usually, no command-line
|
||||
arguments are required, unless special actions described in the xntpd.8
|
||||
man page are required. Once started, the daemon will begin sending
|
||||
messages, as specified in the configuration file, and interpreting
|
||||
received messages.
|
||||
|
||||
<p>The best way to verify correct operation is using the <a href =
|
||||
"ntpq.html"><code>ntpq</code></a> and <a href = "xntpdc.html">
|
||||
<code>xntpdc</code></a> utility programs, either on the server itself
|
||||
or from another machine elsewhere in the network. The <code>ntpq</code>
|
||||
program implements the management functions specified in Appendix A of
|
||||
the NTP specification <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1305/rfc1305c.ps"> RFC-1305,
|
||||
Appendix A </a>. The <code>xntpdc</code> program implements additional
|
||||
functions not provided in the standard. Both programs can be used to
|
||||
inspect the state variables defined in the specification and, in the
|
||||
case of <code>xntpdc</code>, additional ones of interest. In addition,
|
||||
the <code>xntpdc</code> program can be used to selectively enable and
|
||||
disable some functions of the daemon while the daemon is running.
|
||||
|
||||
<p>In extreme cases with elusive bugs, the daemon can operate in two
|
||||
modes, depending on the presence of the <code>-d</code> command-line
|
||||
debug switch. If not present, the daemon detaches from the controlling
|
||||
terminal and proceeds autonomously. If one or more <code>-d</code>
|
||||
switches are present, the daemon does not detach and generates special
|
||||
output useful for debugging. In general, interpretation of this output
|
||||
requires reference to the sources.
|
||||
|
||||
<p>Some problems are immediately apparent when the daemon first starts
|
||||
running. The most common of these are the lack of a ntp (UDP port 123)
|
||||
in the host <code>/etc/services</code> file. Note that NTP does not use
|
||||
TCP in any form. Other problems are apparent in the system log file. The
|
||||
log file should show the startup banner, some cryptic initialization
|
||||
data, and the computed precision value. The next most common problem is
|
||||
incorrect DNS names. Check that each DNS name used in the configuration
|
||||
file responds to the Unix <code>ping</code> command.
|
||||
|
||||
<p>When first started, the daemon normally polls the servers listed in
|
||||
the configuration file at 64-second intervals. In order to allow a
|
||||
sufficient number of samples for the NTP algorithms to reliably
|
||||
discriminate between correctly operating servers and possible intruders,
|
||||
at least four valid messages from at least one server is required before
|
||||
the daemon can not set the local clock. However, if the current local
|
||||
time is greater than 1000 seconds in error from the server time, the
|
||||
daemon will not set the local clock; instead, it will plant a message in
|
||||
the system log and shut down. It is necessary to set the local clock to
|
||||
within 1000 seconds first, either by a time-of-year hardware clock, by
|
||||
first using the <a href = "ntpdate.html"> <code>ntpdate</code> </a>
|
||||
program or manually be eyeball and wristwatch.
|
||||
|
||||
<p>After starting the daemon, run the <code>ntpq</code> program using
|
||||
the <code>-n</code> switch, which will avoid possible distractions due
|
||||
to name resolution problems. Use the <code>pe</code> command to display
|
||||
a billboard showing the status of configured peers and possibly other
|
||||
clients poking the daemon. After operating for a few minutes, the
|
||||
display should be something like:
|
||||
|
||||
<pre>
|
||||
ntpq>pe
|
||||
remote refid st when poll reach delay offset disp
|
||||
========================================================================
|
||||
+128.4.2.6 132.249.16.1 2 131 256 373 9.89 16.28 23.25
|
||||
*128.4.1.20 .WWVB. 1 137 256 377 280.62 21.74 20.23
|
||||
-128.8.2.88 128.8.10.1 2 49 128 376 294.14 5.94 17.47
|
||||
+128.4.2.17 .WWVB. 1 173 256 377 279.95 20.56 16.40
|
||||
</pre>
|
||||
|
||||
<p>The host addresses shown in the <code>remote</code> column should
|
||||
agree with the DNS entries in the configuration file, plus any peers not
|
||||
mentioned in the file at the same or lower than your stratum that happen
|
||||
to be configured to peer with you. Be prepared for surprises in cases
|
||||
where the peer has multiple addresses or multiple names. The
|
||||
<code>refid</code> entry shows the current source of synchronization for
|
||||
each peer, while the <code>st</code> reveals its stratum and the
|
||||
<code>poll</code> entry the polling interval, in seconds. The
|
||||
<code>when</code> entry shows the time since the peer was last heard,
|
||||
normally in seconds, while the <code>reach</code> entry shows the status
|
||||
of the reachability register (see RFC-1305), which is in octal format.
|
||||
The remaining entries show the latest delay, offset and dispersion
|
||||
computed for the peer, in milliseconds.
|
||||
|
||||
<p>The tattletale character at the left margin displays the
|
||||
synchronization status of each peer. The currently selected peer is
|
||||
marked <code>*</code>, while additional peers designated acceptable for
|
||||
synchronization, but not currently selected, are marked <code>+</code>.
|
||||
Peers marked <code>*</code> and <code>+</code> are included in a
|
||||
weighted average computation to set the local clock; the data produced
|
||||
by peers marked with other symbols are discarded. See the
|
||||
<code>ntpq</code> documentation for the meaning of these symbols.
|
||||
|
||||
<p>Additional details for each peer separately can be determined by the
|
||||
following procedure. First, use the <code>as</code> command to display
|
||||
an index of association identifiers, such as
|
||||
|
||||
<pre>
|
||||
ntpq>as
|
||||
ind assID status conf reach auth condition last_event cnt
|
||||
===========================================================
|
||||
1 11670 7414 no yes ok synchr. reachable 1
|
||||
2 11673 7614 no yes ok sys.peer reachable 1
|
||||
3 11833 7314 no yes ok outlyer reachable 1
|
||||
4 11868 7414 no yes ok synchr. reachable 1
|
||||
</pre>
|
||||
|
||||
<p>Each line in this billboard is associated with the corresponding line
|
||||
the <code>pe</code> billboard above. Next, use the <code>rv</code>
|
||||
command and the respective identifier to display a detailed synopsis of
|
||||
the selected peer, such as
|
||||
|
||||
<pre>
|
||||
ntpq>rv 11670
|
||||
status=7414 reach, auth, sel_sync, 1 event, event_reach
|
||||
srcadr=128.4.2.6, srcport=123, dstadr=128.4.2.7, dstport=123, keyid=1,
|
||||
stratum=2, precision=-10, rootdelay=362.00, rootdispersion=21.99,
|
||||
refid=132.249.16.1,
|
||||
reftime=af00bb44.849b0000 Fri, Jan 15 1993 4:25:40.517,
|
||||
delay= 9.89, offset= 16.28, dispersion=23.25, reach=373, valid=8,
|
||||
hmode=2, pmode=1, hpoll=8, ppoll=10, leap=00, flash=0x0,
|
||||
org=af00bb48.31a90000 Fri, Jan 15 1993 4:25:44.193,
|
||||
rec=af00bb48.305e3000 Fri, Jan 15 1993 4:25:44.188,
|
||||
xmt=af00bb1e.16689000 Fri, Jan 15 1993 4:25:02.087,
|
||||
filtdelay= 16.40 9.89 140.08 9.63 9.72 9.22 10.79 122.99,
|
||||
filtoffset= 13.24 16.28 -49.19 16.04 16.83 16.49 16.95 -39.43,
|
||||
filterror= 16.27 20.17 27.98 31.89 35.80 39.70 43.61 47.52
|
||||
</pre>
|
||||
|
||||
<p>A detailed explanation of the fields in this billboard are beyond the
|
||||
scope of this discussion; however, most variables defined in the
|
||||
specification RFC-1305 can be found. The most useful portion for
|
||||
debugging is the last three lines, which give the roundtrip delay, clock
|
||||
offset and dispersion for each of the last eight measurement rounds, all
|
||||
in milliseconds. Note that the dispersion, which is an estimate of the
|
||||
error, increases as the age of the sample increases. From these data, it
|
||||
is usually possible to determine the incidence of severe packet loss,
|
||||
network congestion, and unstable local clock oscillators. There are no
|
||||
hard and fast rules here, since every case is unique; however, if one or
|
||||
more of the rounds show zeros, or if the clock offset changes
|
||||
dramatically in the same direction for each round, cause for alarm
|
||||
exists.
|
||||
|
||||
<p>Finally, the state of the local clock can be determined using the
|
||||
<code>rv</code> command (without the argument), such as
|
||||
|
||||
<pre>
|
||||
ntpq>rv
|
||||
status=0664 leap_none, sync_ntp, 6 events, event_peer/strat_chg
|
||||
system="UNIX", leap=00, stratum=2, rootdelay=280.62,
|
||||
rootdispersion=45.26, peer=11673, refid=128.4.1.20,
|
||||
reftime=af00bb42.56111000 Fri, Jan 15 1993 4:25:38.336, poll=8,
|
||||
clock=af00bbcd.8a5de000 Fri, Jan 15 1993 4:27:57.540, phase=21.147,
|
||||
freq=13319.46, compliance=2
|
||||
</pre>
|
||||
|
||||
<p>The most useful data in this billboard show when the clock was last
|
||||
adjusted <code>reftime</code>, together with its status and most recent
|
||||
exception event. An explanation of these data is in the specification
|
||||
RFC-1305.
|
||||
|
||||
<p>When nothing seems to happen in the <code>pe</code> billboard after
|
||||
some minutes, there may be a network problem. The most common network
|
||||
problem is an access controlled router on the path to the selected peer.
|
||||
No known public NTP time server selectively restricts access at this
|
||||
time, although this may change in future; however, many private networks
|
||||
do. It also may be the case that the server is down or running in
|
||||
unsynchronized mode due to a local problem. Use the <code>ntpq</code>
|
||||
program to spy on its own variables in the same way you can spy on your
|
||||
own.
|
||||
|
||||
<p>Once the daemon has set the local clock, it will continuously track
|
||||
the discrepancy between local time and NTP time and adjust the local
|
||||
clock accordingly. There are two components of this adjustment, time and
|
||||
frequency. These adjustments are automatically determined by the clock
|
||||
discipline algorithm, which functions as a hybrid phase/frequency
|
||||
feedback loop. The behavior of this algorithm is carefully controlled to
|
||||
minimize residual errors due to network jitter and frequency variations
|
||||
of the local clock hardware oscillator that normally occur in practice.
|
||||
However, when started for the first time, the algorithm may take some
|
||||
time to converge on the intrinsic frequency error of the host machine.
|
||||
|
||||
<p>It has sometimes been the experience that the local clock oscillator
|
||||
frequency error is too large for the NTP discipline algorithm, which can
|
||||
correct frequency errors as large as 30 seconds per day. There are two
|
||||
possibilities that may result in this problem. First, the hardware time-
|
||||
of-year clock chip must be disabled when using NTP, since this can
|
||||
destabilize the discipline process. This is usually done using the <a
|
||||
href = "tickadj.html"> <code>tickadj</code></a> program and the
|
||||
<code>-s</code> command line argument, but other means may be necessary.
|
||||
For instance, in the Sun Solaris kernel, this must be done using a
|
||||
command in the system startup file.
|
||||
|
||||
<p>Normally, the daemon will adjust the local clock in small steps in
|
||||
such a way that system and user programs are unaware of its operation.
|
||||
The adjustment process operates continuously as long as the apparent
|
||||
clock error exceeds 128 milliseconds, which for most Internet paths is a
|
||||
quite rare event. If the event is simply an outlyer due to an occasional
|
||||
network delay spike, the correction is simply discarded; however, if the
|
||||
apparent time error persists for an interval of about 20 minutes, the
|
||||
local clock is stepped to the new value (as an option, the daemon can be
|
||||
compiled to slew at an accelerated rate to the new value, rather than be
|
||||
stepped). This behavior is designed to resist errors due to severely
|
||||
congested network paths, as well as errors due to confused radio clocks
|
||||
upon the epoch of a leap second.
|
||||
|
||||
<p><h4>Debugging Checklist</h4>
|
||||
|
||||
<p>If the <code>ntpq</code> or <code>xntpdc</code> programs do not
|
||||
show that messages are being received by the daemon or that received
|
||||
messages do not result in correct synchronization, verify the following:
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Verify the <code>/etc/services</code> file host machine is
|
||||
configured to accept UDP packets on the NTP port 123. NTP is
|
||||
specifically designed to use UDP and does not respond to TCP.
|
||||
|
||||
<p><li>Check the system log for <code>xntpd</code> messages about
|
||||
configuration errors, name-lookup failures or initialization problems.
|
||||
|
||||
<p><li>Using the <code>xntpdc</code> program and <code>iostats</code>
|
||||
command, verify that the received packets and packets sent counters are
|
||||
incrementing. If the packets send counter does not increment and the
|
||||
configuration file includes designated servers, something may be wrong
|
||||
in the network configuration of the xntpd host. If this counter does
|
||||
increment and packets are actually being sent to the network, but the
|
||||
received packets counter does not increment, something may be wrong in
|
||||
the network or the server may not be responding.
|
||||
|
||||
<p><li>If both the packets sent counter and received packets
|
||||
counter do increment, but the <code>rec</code> timestamp in the
|
||||
<code>pe</code> billboard shows a date in 1972, received packets are
|
||||
probably being discarded for some reason. There is a handy, undocumented
|
||||
state variable <code>flash</code> visible in the
|
||||
<code>pe</code>billboard. The value is in hex and normally has the value
|
||||
zero (OK). However, if something is wrong, the bits of this variable,
|
||||
reading from the right, correspond to the sanity checks listed in
|
||||
Section 3.4.3 of the NTP specification <a href =
|
||||
"ftp://ftp.udel.edu/pub/people/mills/rfc/rfc1305/rfc1305b.ps">
|
||||
RFC-1305</a>. A bit other than zero indicates the associated sanity
|
||||
check failed.
|
||||
|
||||
<p><li>If the <code>org, rec</code> and <code>xmt</code>
|
||||
timestamps in the <code>pe</code> billboard appear current, but the
|
||||
local clock is not set, as indicated by a stratum number less than 16 in
|
||||
the <code>rv</code> command without arguments, verify that valid clock
|
||||
offset, roundtrip delay and dispersion are displayed for at least one
|
||||
peer. The clock offset should be less than 1000 seconds, the roundtrip
|
||||
delay less than one second and the dispersion less than one second.
|
||||
|
||||
<p><li>While the algorithm can tolerate a relatively large frequency
|
||||
error (over 350 parts per million or 30 seconds per day), various
|
||||
configuration errors (and in some cases kernel bugs) can exceed this
|
||||
tolerance, leading to erratic behavior. This can result in frequent loss
|
||||
of synchronization, together with wildly swinging offsets. Use the
|
||||
<code>xntpdc</code> program (or temporary configuration file) and
|
||||
<code>disable pll</code> command to prevent the <code>xntpd</code>
|
||||
daemon from setting the clock. Using the <code>ntpq</code> or
|
||||
<code>xntpdc</code> programs, watch the apparent offset as it varies
|
||||
over time to determine the intrinsic frequency error. If the error
|
||||
increases by more than 22 milliseconds per 64-second poll interval, the
|
||||
intrinsic frequency must be reduced by some means. The easiest way to do
|
||||
this is with the <a href="tickadj.html"><code>tickadj</code></a> program
|
||||
and the <code>-t</code> command line argument.
|
||||
|
||||
</ol>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,134 +0,0 @@
|
||||
<!-- $NetBSD: driver1.html,v 1.1 1998/12/30 20:20:33 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Undisciplined Local Clock
|
||||
</title></head><body><h3>
|
||||
Undisciplined Local Clock
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.1.<var>u</var>
|
||||
<br>Reference ID: LCL
|
||||
<br>Driver ID: LOCAL
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This is a hack to allow a machine to use its own system clock as a
|
||||
reference clock, i.e., to free-run using no outside clock discipline
|
||||
source. This is useful if NTP is to be used in an isolated environment
|
||||
with no radio clock or NIST modem available. Pick a machine that has a
|
||||
good clock oscillator (Digital machines are good, Sun machines are not)
|
||||
and configure it with this driver. Set the clock using the best means
|
||||
available, like eyeball-and-wristwatch. Then, point all the other
|
||||
machines at this one or use broadcast (not multicast) mode to distribute
|
||||
time.
|
||||
|
||||
<p>Another application for this driver is if a particular server clock
|
||||
is to be used as the clock of last resort when all other normal
|
||||
synchronization sources have gone away. This is especially useful if
|
||||
that server has an ovenized oscillator. For this you would configure
|
||||
this driver at a stratum greater than any other likely sources of time
|
||||
(say 3 or 4) to prevent the server taking over when legitimate sources
|
||||
are still available.
|
||||
|
||||
<p>A third application for this driver is when an external discipline
|
||||
source is available, such as the NIST <code>lockclock</code> program,
|
||||
which synchronizes the local clock via a telephone modem and the NIST
|
||||
Automated Computer Time Service (ACTS), or the Digital Time
|
||||
Synchronization Service (DTSS), which runs on DCE machines. In this case
|
||||
the stratum should be set at zero, indicating a bona fide stratum-1
|
||||
source. Exercise some caution with this, since there is no easy way to
|
||||
telegraph via NTP that something might be wrong in the discipline source
|
||||
itself. In the case of DTSS, the local clock can have a rather large
|
||||
jitter, depending on the interval between corrections and the intrinsic
|
||||
frequency error of the clock oscillator. In extreme cases, this can
|
||||
cause clients to exceed the 128-ms slew window and drop off the NTP
|
||||
subnet.
|
||||
|
||||
In the default mode the behavior of the clock selection algorithm is
|
||||
modified when this driver is in use. The algorithm is designed so that
|
||||
this driver will never be selected unless no other discipline source is
|
||||
available. This can be overridden with the <code>prefer</code> keyword
|
||||
of the <code>server</code> configuration command, in which case only
|
||||
this driver will be selected for synchronization and all other
|
||||
discipline sources will be ignored. This behavior is intended for use
|
||||
when an external discipline source controls the system clock. See the <a
|
||||
href = "prefer.html"> Mitigation Rules and the <code>prefer</code>
|
||||
Keyword </a> page for a detailed description of the finicky behavior.
|
||||
|
||||
<p>The stratum for this driver is set at 3 by default, but can be
|
||||
changed by the <code>fudge</code> configuration command and/or the
|
||||
<code>xntpdc</code> utility. The reference ID is <code>LCL</code> by
|
||||
default, but can be changed using the same mechanisms.
|
||||
<strong>*NEVER*</strong> configure this driver to operate at a stratum
|
||||
which might possibly disrupt a client with access to a bona fide primary
|
||||
server, unless the local clock oscillator is reliably disciplined by
|
||||
another source. <strong>*NEVER NEVER*</strong> configure a server which
|
||||
might devolve to an undisciplined local clock to use multicast mode.
|
||||
<p>This driver provides a mechanism to trim the local clock in both time
|
||||
and frequency, as well as a way to manipulate the leap bits. The
|
||||
<code>fudge time1</code> parameter adjusts the time (in seconds) and the
|
||||
<code>fudge time2</code> parameter adjusts the frequency (in parts per
|
||||
million). Both parameters are additive and operate only once; that is,
|
||||
each command (as from <code>xntpdc</code>) adds signed increments in
|
||||
time or frequency to the nominal local clock time and frequency. (Note:
|
||||
The frequency cannot be changed when the kernel modifications are in use
|
||||
- see the <a href="kern.html">A Kernel Model for Precision Timekeeping
|
||||
</a> page.) The <code>fudge flag1</code> and <code>fudge flag2</code>
|
||||
flags set the corresponding leap bits; for example, setting only
|
||||
<code>flag1</code> causes a leap second to be inserted at the end of the
|
||||
UTC day and setting only <code>flag2</code> causes a leap second to be
|
||||
deleted at the end of the UTC day. Setting both flags causes the local
|
||||
clock driver to appear unsynchronized, which may be a blessing if a
|
||||
server violates the above rules, since <code>xntpdc</code> can turn the
|
||||
bugger off. These bits are not reset automatically when the leap takes
|
||||
place; they must be turned off manually after the leap event and before
|
||||
the next UTC day.
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>No <code>filegen clockstats</code> monitor data are produced by this
|
||||
driver.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <var>time</var></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <var>time</var></code>
|
||||
<dd>Specifies the frequency offset calibration factor, in parts per
|
||||
million, with default 0.0.
|
||||
|
||||
<p><dt><code>stratum <var>number</var></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
3.
|
||||
|
||||
<p><dt><code>refid <var>string</var></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>LCL</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Specifies a leap second to be inserted at the end of the current UTC
|
||||
day.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Specifies a leap second to be deleted at the end of the current UTC
|
||||
day.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
</dl>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,89 +0,0 @@
|
||||
<!-- $NetBSD: driver10.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Austron 2200A/2201A GPS Receivers
|
||||
</title></head><body><h3>
|
||||
Austron 2200A/2201A GPS Receivers
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.10.<var>u</var>
|
||||
<br>Reference ID: GPS
|
||||
<br>Driver ID: GPS-AS2201
|
||||
<br>Serial Port: <code>/dev/gps<var>u</var></code>; 9600 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: <code>tty_clk</code>, <code>ppsclock</code> (required)
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports the Austron 2200A/2201A GPS/LORAN Synchronized
|
||||
Clock and Timing Receiver connected via a serial port. It supports
|
||||
several special features of the clock, including the Input Buffer
|
||||
Module, Output Buffer Module, IRIG-B Interface Module and LORAN Assist
|
||||
Module. It requires the RS232 Serial Interface module for communication
|
||||
with the driver. It requires the <code>ppsclock</code> streams module
|
||||
described in the <a href="ldisc.html">Line Disciplines and Streams
|
||||
Drivers</a> page. It also requires a gadget box and 1-PPS level
|
||||
converter, such as described in the <a href="pps.html">Pulse-per-second
|
||||
(PPS) Signal Interfacing</a> page.
|
||||
|
||||
<p>This receiver is capable of a comprehensive and large volume of
|
||||
statistics and operational data. The specific data collection commands
|
||||
and attributes are embedded in the driver source code; however, the
|
||||
collection process can be enabled or disabled using the flag4 flag. If
|
||||
set, collection is enabled; if not, which is the default, it is
|
||||
disabled. A comprehensive suite of data reduction and summary scripts is
|
||||
in the ./scripts/stats directory of the xntp3 distribution.
|
||||
|
||||
<p>To achieve the high accuracy this device provides, it is necessary to
|
||||
use the <code>ppsclock</code> feature of the xntp3 program distribution
|
||||
or, alternatively, to install the kernel modifications described in the
|
||||
README.kern. The clock can be wired to provide time to a single CPU or
|
||||
bussed in parallel to several CPUs, with one CPU controlling the
|
||||
receiver and the others just listening. Fair accuracy can be achieved in
|
||||
the single-CPU configuration without use of the 1-pps signal, but in
|
||||
multiple CPU configurations accuracy is severely degraded without it.
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>When enabled by the <code>flag4</code> fudge flag, every received
|
||||
timecode is written as-is to the <code>clockstats</code> file.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>GPS</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Enable <code>ppsclock</code> line discipline/streams module if set.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable <code>clockstats</code> recording if set.
|
||||
|
||||
</dl>
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,140 +0,0 @@
|
||||
<!-- $NetBSD: driver11.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Arbiter 1088A/B GPS Receiver
|
||||
</title></head><body><h3>
|
||||
Arbiter 1088A/B GPS Receiver
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.11.<var>u</var>
|
||||
<br>Reference ID: GPS
|
||||
<br>Driver ID: GPS_ARBITER
|
||||
<br>Serial Port: <code>/dev/gps<var>u</var></code>; 9600 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: <code>tty_clk</code>
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports the Arbiter 1088A/B Satellite Controlled Clock.
|
||||
The claimed accuracy of this clock is 100 ns relative to the PPS output
|
||||
when receiving four or more satellites.
|
||||
|
||||
<p>The receiver should be configured before starting the NTP daemon, in
|
||||
order to establish reliable position and operating conditions. It does
|
||||
not initiate surveying or hold mode. For use with NTP, the daylight
|
||||
savings time feature should be disables (<code>D0</code> command) and
|
||||
the broadcast mode set to operate in UTC (<code>BU</code> command).
|
||||
|
||||
<p>The timecode format supported by this driver is selected by the poll
|
||||
sequence <code>B5</code>, which initiates a line in the following format
|
||||
to be repeated once per second until turned off by the <code>B0</code>
|
||||
command.
|
||||
|
||||
<p>Format <code>B5</code> (24 ASCII printing characters):
|
||||
|
||||
<pre>
|
||||
<cr><lf>i yy ddd hh:mm:ss.000bbb
|
||||
|
||||
on-time = <cr>
|
||||
i = synchronization flag (' ' = locked, '?' = unlocked)
|
||||
yy = year of century
|
||||
ddd = day of year
|
||||
hh:mm:ss = hours, minutes, seconds
|
||||
.000 = fraction of second (not used)
|
||||
bbb = tailing spaces for fill
|
||||
</pre>
|
||||
|
||||
<p>The alarm condition is indicated by a '?' at i, which indicates the
|
||||
receiver is not synchronized. In normal operation, a line consisting of
|
||||
the timecode followed by the time quality character (TQ) followed by the
|
||||
receiver status string (SR) is written to the clockstats file.
|
||||
|
||||
<p>The time quality character is encoded in IEEE P1344 standard:
|
||||
|
||||
<p>Format <code>TQ</code> (IEEE P1344 estimated worst-case time quality)
|
||||
|
||||
<pre>
|
||||
0 clock locked, maximum accuracy
|
||||
F clock failure, time not reliable
|
||||
4 clock unlocked, accuracy < 1 us
|
||||
5 clock unlocked, accuracy < 10 us
|
||||
6 clock unlocked, accuracy < 100 us
|
||||
7 clock unlocked, accuracy < 1 ms
|
||||
8 clock unlocked, accuracy < 10 ms
|
||||
9 clock unlocked, accuracy < 100 ms
|
||||
A clock unlocked, accuracy < 1 s
|
||||
B clock unlocked, accuracy < 10 s
|
||||
</pre>
|
||||
|
||||
<p>The status string is encoded as follows:
|
||||
|
||||
<p>Format <code>SR</code> (25 ASCII printing characters)
|
||||
|
||||
<pre>
|
||||
V=vv S=ss T=t P=pdop E=ee
|
||||
|
||||
vv = satellites visible
|
||||
ss = relative signal strength
|
||||
t = satellites tracked
|
||||
pdop = position dilution of precision (meters)
|
||||
ee = hardware errors
|
||||
</pre>
|
||||
|
||||
<p>A three-stage median filter is used to reduce jitter and provide a
|
||||
dispersion measure. The driver makes no attempt to correct for the
|
||||
intrinsic jitter of the radio itself.
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>The driver writes each timecode as received to the
|
||||
<code>clockstats</code> file. When enabled by the <code>flag4</code>
|
||||
fudge flag, an additional line containing the latitude, longitude,
|
||||
elevation and optional deviation data is written to the
|
||||
<code>clockstats</code> file. The deviation data operates with an
|
||||
external pulse-per-second (PPS) input, such as a cesium oscillator or
|
||||
another radio clock. The PPS input should be connected to the B event
|
||||
channel and the radio initialized for deviation data on that channel.
|
||||
The deviation data consists of the mean offset and standard deviation of
|
||||
the external PPS signal relative the GPS signal, both in microseconds
|
||||
over the last 16 seconds.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0. For a calibrated Sun IPC, the correct value
|
||||
is about .0065.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>GPS</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Enable <code>ppsclock</code> line discipline/streams module if set.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable extended <code>clockstats</code> recording if set.
|
||||
</dl>
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,77 +0,0 @@
|
||||
<!-- $NetBSD: driver12.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
KSI/Odetics TPRO/S IRIG Interface
|
||||
</title></head><body><h3>
|
||||
KSI/Odetics TPRO/S IRIG Interface
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.12.<var>u</var>
|
||||
<br>Reference ID: IRIG
|
||||
<br>Driver ID: IRIG-TPRO
|
||||
<br>TPRO Device: <code>/dev/tpro<var>u</var></code>
|
||||
<br>Requires: KSI/Odetics device driver,
|
||||
<code>/usr/include/sys/tpro.h</code> header file
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports the KSI/Odetics TPRO and TPRO-SAT IRIG-B
|
||||
Decoder, which is a module connected directly to the SBus of a Sun
|
||||
workstation. The module works with the IRIG-B signal generated by
|
||||
several radio clocks, including those made by Arbiter, Austron, Odetics,
|
||||
Spectracom and TrueTime, among others, although it is generally an add-
|
||||
on option. In the case of the TPRO-SAT, the module is an integral part
|
||||
of a GPS receiver, which serves as the primary timing source.
|
||||
|
||||
<p>Using the TPRO interface as a NTP reference clock provides precision
|
||||
time only to xntpd and its clients. With suitable kernel modifications,
|
||||
it is possible to use the TPRO as the CPU system clock, avoiding errors
|
||||
introduced by the CPU clock oscillator wander. See the <a href =
|
||||
"kern.html"> A Kernel Model for Precision Timekeeping </a> page for
|
||||
further details.
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>The driver writes each timecode as received to the
|
||||
<code>clockstats</code> file.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0. For a calibrated Sun IPC, the correct value
|
||||
is about .00037.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>IRIG</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
</dl>
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,235 +0,0 @@
|
||||
<!-- $NetBSD: driver18.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
NIST Modem Time Service
|
||||
</title></head><body><h3>
|
||||
NIST Modem Time Service
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.18.<var>u</var>
|
||||
<br>Reference ID: ACTS
|
||||
<br>Driver ID: NIST_ACTS
|
||||
<br>Serial Port: <code>/dev/acts<var>u</var></code>; 1200 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: <code>tty_clk</code>
|
||||
<br>Requires: <code>/usr/include/sys/termios.h</code> header file with
|
||||
modem control
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports the NIST Automated Computer Time Service (ACTS).
|
||||
It periodically dials a prespecified telephone number, receives the NIST
|
||||
timecode data and calculates the local clock correction. It designed
|
||||
primarily for use when neither a radio clock nor connectivity to
|
||||
Internet time servers is available. For the best accuracy, the
|
||||
individual telephone line/modem delay needs to be calibrated using
|
||||
outside sources.
|
||||
|
||||
<p>The ACTS is located at NIST Boulder, CO, telephone 303 494 4774. A
|
||||
toll call from Newark, DE, costs between three and four cents, although
|
||||
it is not clear what carrier and time of day discounts apply. The modem
|
||||
dial string will differ depending on local telephone configuration,
|
||||
etc., and is specified by the phone command in the configuration file.
|
||||
The argument to this command is an AT command for a Hayes compatible
|
||||
modem.
|
||||
|
||||
<p>The driver can operate in either of two modes, as determined by the
|
||||
mode parameter in the server configuration command. In mode 0 the driver
|
||||
operates continuously at intervals determined by the fudge time1
|
||||
parameter, as described above. In mode 1 the driver is enabled only when
|
||||
no other sources of synchronization are available and when we have gone
|
||||
more than MAXOUTAGE (3600 s) since last synchronized by other sources of
|
||||
synchronization.
|
||||
|
||||
<p>The accuracy produced by this driver should be in the range of a
|
||||
millisecond or two, but may need correction due to the delay
|
||||
characteristics of the individual modem involved. For undetermined
|
||||
reasons, some modems work with the ACTS echo-delay measurement scheme
|
||||
and some don't. This driver tries to do the best it can with what it
|
||||
gets. Initial experiments with a Practical Peripherals 9600SA modem here
|
||||
in Delaware suggest an accuracy of a millisecond or two can be achieved
|
||||
without the scheme by using a fudge time1 value of 65.0 ms. In either
|
||||
case, the dispersion for a single call involving ten samples is about
|
||||
1.3 ms.
|
||||
|
||||
<p>For reliable call management, this driver requires a 1200-bps modem
|
||||
with a Hayes-compatible command set and control over the modem data
|
||||
terminal ready (DTR) control line. Present restrictions require the use
|
||||
of a POSIX-compatible programming interface, although other interfaces
|
||||
may work as well. The ACTS telephone number and modem setup string are
|
||||
hard-coded in the driver and may require changes for nonstandard modems
|
||||
or special circumstances.
|
||||
|
||||
<p>The fudge time1 parameter represents a propagation-delay correction
|
||||
factor which is added to the value computed by ACTS when the echo-delay
|
||||
scheme is used. This scheme does not work with all modems; for those
|
||||
that don't, fudge flag2 should be set to disable the feature. In this
|
||||
case the fudge time1 parameter represents the total propagation delay
|
||||
due to all causes and must be determined by external calibration.
|
||||
|
||||
<p>The ACTS call interval is determined by a counter initially set to
|
||||
the fudge time2 parameter. At each poll interval, minpoll (usually 64 s)
|
||||
is subtracted from the counter. When the counter is equal to or less
|
||||
than zero, the fudge flag1 is set, which causes up to three call
|
||||
attempts to be made to ACTS. The fudge flag1 is reset after a valid
|
||||
clock update has been determined or by a device fault, timeout or
|
||||
manually using <code>xntpdc</code>. After a valid clock update, the
|
||||
counter is reset for the next interval. Setting the <code>fudge
|
||||
time2</code> parameter to zero disables automatic call attempts. Manual
|
||||
call attempts can be made at any time by setting <code>fudge
|
||||
flag1</code> using xntpdc.
|
||||
|
||||
<p>The NIST timecode message is transmitted at 1200 bps in the following
|
||||
format:
|
||||
|
||||
<pre>
|
||||
|
||||
jjjjj yy-mm-dd hh:mm:ss tt l uuu mmmmm UTC(NIST) *
|
||||
|
||||
jjjjj = modified Julian day
|
||||
yy-mm-dd = year, month, day
|
||||
hh:mm:ss = hours, minutes, seconds
|
||||
tt = DST indicator (see driver listing)
|
||||
l = leap-second warning (see driver listing)
|
||||
uuu = DUT1 correction (see driver listing)
|
||||
mmmmm = modem calibration (see driver listing)
|
||||
on-time = '*'
|
||||
|
||||
</pre>
|
||||
|
||||
<p>The timecode message is transmitted continuously after a signon
|
||||
banner, which this driver ignores. The driver also ignores all but the
|
||||
yy-mm-dd, hh:mm:ss and on-time character '*' fields, although it checks
|
||||
the format of all fields of the message. A timestamp is captured at the
|
||||
'*' character, as required by the ACTS specification, and used as the
|
||||
reference time of the timecode. If a message with an on-time character
|
||||
of '#' is received, the driver updates the propagation delay. The driver
|
||||
disconnects when (a) ten valid messages have been received, (b) no
|
||||
message has been received for 15 s, (c) an on-time character of '#' is
|
||||
received. These messages are processed by a trimmed-mean filter to
|
||||
reduce timing noise and then by the usual NTP algorithms to develop the
|
||||
clock correction.
|
||||
|
||||
<p>Since the accumulated error grows with the interval between calls, it
|
||||
is important that the intrinsic frequency error be minimized. This can
|
||||
be done by observing difference in offsets between two calls placed some
|
||||
hours apart and calculating the uncorrected frequency error. This error,
|
||||
as a fixed-point value in parts-per-million, should be installed in the
|
||||
ntp.drift file before the daemon is started. Some experimentation may be
|
||||
necessary in order to reduce the intrinsic frequency error to the order
|
||||
of 1 ppm.
|
||||
|
||||
<p>The behavior of the clock selection algorithm is modified when this
|
||||
driver is in use. The algorithm is designed so that this driver will
|
||||
never be selected unless no other discipline source is available. This
|
||||
can be overridden with the prefer keyword of the server configuration
|
||||
command, in which case only this driver will be selected for
|
||||
synchronization and all other discipline sources will be ignored.
|
||||
|
||||
<p>Unlike other drivers, each ACTS call generates one clock correction
|
||||
and that correction is processed immediately. There is no wait to allow
|
||||
the clock filter to accumulate samples. In addition, the watchdog
|
||||
timeout of the local clock algorithm is disabled, so that a correction
|
||||
received from this driver that exceeds CLOCK_MAX (128 ms) causes an
|
||||
immediate step/slew.
|
||||
|
||||
<p>Since the interval between updates can be much longer than used with
|
||||
ordinary NTP peers, the local clock procedure has been modified to
|
||||
operate in either of two modes, depending on whether the interval
|
||||
between updates is less than or greater than CLOCK_MAXSEC (1200 s). If
|
||||
less than this value, the local clock procedure operates using the
|
||||
standard NTP phase-lock loop as with other NTP peers. If greater than
|
||||
this value, the procedure operates using a modified frequency-lock loop
|
||||
suggested by Judah Levine in his lockclock algorithm designed
|
||||
specifically for ACTS.
|
||||
|
||||
<p><h4>Call Management</h4>
|
||||
|
||||
<p>Since ACTS will be a toll call in most areas of the country, it is
|
||||
necessary to carefully manage the call frequency. This can be done in
|
||||
two ways, by specifying the interval between calls, or by setting a flag
|
||||
bit manually or via a cron job. The call interval is determined by a
|
||||
counter initially set to the fudge time2 parameter. At each poll
|
||||
interval, minpoll (usually 64 s) is subtracted from the counter. When
|
||||
the counter is equal to or less than zero, the fudge flag1 is set, which
|
||||
causes up to three call attempts to be made. The fudge flag1 is reset
|
||||
after ten offset samples have been determined in a single call or by a
|
||||
device fault, timeout or manually using xntpdc. Upon successful
|
||||
completion of a call, the eight samples have been shifted into the clock
|
||||
filter, the local clock updated and the counter reset for the next
|
||||
interval. Setting the fudge time2 parameter to zero disables automatic
|
||||
call attempts.
|
||||
|
||||
<p>Manual call attempts can be made at any time by setting fudge flag1
|
||||
using xntpdc. For example, the xntpdc command
|
||||
|
||||
<pre>
|
||||
|
||||
fudge 127.127.18.1 flags 1
|
||||
|
||||
</pre>
|
||||
|
||||
<p>will ask for a key identifier and password and, if authenticated by
|
||||
the server, will set flag1. There may be a short delay until the
|
||||
expiration of the current poll timeout.
|
||||
|
||||
<p>The flag1 can be set from a cron job in the following way. Construct
|
||||
a file with contents
|
||||
|
||||
<pre>keyid 11
|
||||
passwd dialup
|
||||
fudge 127.127.18.1 flags 1
|
||||
quit
|
||||
|
||||
</pre>
|
||||
|
||||
<p>Then, run the following program at specified times as required.
|
||||
|
||||
<pre>
|
||||
/usr/local/bin/xntpdc <file
|
||||
</pre>
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>When enabled by the <code>flag4</code> fudge flag, every received
|
||||
timecode is written as-is to the <code>clockstats</code> file.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>ACTS</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Enable <code>ppsclock</code> line discipline/streams module if set.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable <code>clockstats</code> recording if set.
|
||||
|
||||
</dl>
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,106 +0,0 @@
|
||||
<!-- $NetBSD: driver19.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Heath WWV/WWVH Receiver
|
||||
</title></head><body><h3>
|
||||
Heath WWV/WWVH Receiver
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.19.<var>u</var>
|
||||
<br>Reference ID: WWV
|
||||
<br>Driver ID: WWV_HEATH
|
||||
<br>Serial Port: <code>/dev/heath<var>u</var></code>; 1200 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: <code>tty_clk</code>
|
||||
<br>Requires: <code>/usr/include/sys/termios.h</code> header file with
|
||||
modem control
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports the Heath GC-1000 Most Accurate Clock, with
|
||||
RS232C Output Accessory. This is a WWV/WWVH receiver somewhat less
|
||||
robust than other supported receivers. Its claimed accuracy is 100 ms
|
||||
when actually synchronized to the broadcast signal, but this doesn't
|
||||
happen even most of the time, due to propagation conditions, ambient
|
||||
noise sources, etc. When not synchronized, the accuracy is at the whim
|
||||
of the internal clock oscillator, which can wander into the sunset
|
||||
without warning. Since the indicated precision is 100 ms, expect a host
|
||||
synchronized only to this thing to wander to and fro, occasionally being
|
||||
rudely stepped when the offset exceeds the default CLOCK_MAX of 128 ms.
|
||||
|
||||
<p>The internal DIPswitches should be set to operate at 1200 baud in
|
||||
MANUAL mode and the current year. The external DIPswitches should be set
|
||||
to GMT and 24-hour format. It is very important that the year be set
|
||||
correctly in the DIPswitches; otherwise, the day of year will be
|
||||
incorrect after 28 April of a normal or leap year.
|
||||
|
||||
<p>In MANUAL mode the clock responds to a rising edge of the request to
|
||||
send (RTS) modem control line by sending the timecode. Therefore, it is
|
||||
necessary that the operating system implement the <code>TIOCMBIC</code>
|
||||
and <code>TIOCMBIS</code> ioctl system calls and <code>TIOCM_RTS</code>
|
||||
control bit. Present restrictions require the use of a POSIX-compatible
|
||||
programming interface, although other interfaces may work as well.
|
||||
|
||||
<p>The clock message consists of 23 ASCII printing characters in the
|
||||
following format:
|
||||
|
||||
<pre>
|
||||
hh:mm:ss.f dd/mm/yr<cr>
|
||||
|
||||
hh:mm:ss.f = hours, minutes, seconds
|
||||
f = deciseconds ('?' when out of spec)
|
||||
dd/mm/yr = day, month, year
|
||||
</pre>
|
||||
|
||||
<p>The alarm condition is indicated by '?', rather than a digit, at A.
|
||||
Note that 0?:??:??.? is displayed before synchronization is first
|
||||
established and hh:mm:ss.? once synchronization is established and then
|
||||
lost again for about a day.
|
||||
|
||||
<p>A fudge time1 value of .07 s appears to center the clock offset
|
||||
residuals.
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>When enabled by the <code>flag4</code> fudge flag, every received
|
||||
timecode is written as-is to the <code>clockstats</code> file.
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>WWV</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Enable <code>ppsclock</code> line discipline/streams module if set.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable <code>clockstats</code> recording if set.
|
||||
|
||||
</dl>
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,116 +0,0 @@
|
||||
<!-- $NetBSD: driver2.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Trak 8820 GPS Receiver
|
||||
</title></head><body><h3>
|
||||
Trak 8820 GPS Receiver
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.2.<var>u</var>
|
||||
<br>Reference ID: GPS
|
||||
<br>Driver ID: GPS-TRAK
|
||||
<br>Serial Port: <code>/dev/trak<var>u</var></code>; 9600 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: <code>tty_clk, ppsclock</code>
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports the Trak 8820 GPS Station Clock. The claimed
|
||||
accuracy at the 1-PPS output is 200-300 ns relative to the broadcast
|
||||
signal; however, in most cases the actual accuracy is limited by the
|
||||
precision of the timecode and the latencies of the serial interface and
|
||||
operating system.
|
||||
|
||||
<p>For best accuracy, this radio requires the <code>tty_clk</code> line
|
||||
discipline, which captures a timestamp at the <code>*</code> on-time
|
||||
character of the timecode. Using this discipline the jitter is in the
|
||||
order of 1 ms and systematic error about 0.5 ms. If unavailable, the
|
||||
buffer timestamp is used, which is captured at the <code>\r</code>
|
||||
ending the timecode message. This introduces a systematic error of 23
|
||||
character times, or about 24 ms at 9600 bps, together with a jitter well
|
||||
over 8 ms on Sun IPC-class machines.
|
||||
|
||||
<p>Using the menus, the radio should be set for 9600 bps, one stop bit
|
||||
and no parity. It should be set to operate in computer (no echo) mode.
|
||||
The timecode format includes neither the year nor leap-second warning.
|
||||
|
||||
<p>In operation, this driver sends a <code>RQTS\r</code> request to the
|
||||
radio at initialization in order to put it in continuous time output
|
||||
mode. The radio then sends the following message once each second:
|
||||
|
||||
<pre>
|
||||
*RQTS U,ddd:hh:mm:ss.0,q<cr><lf>
|
||||
|
||||
on-time = '*'
|
||||
ddd = day of year
|
||||
hh:mm:ss = hours, minutes, seconds
|
||||
q = quality indicator (phase error), 0-6:
|
||||
0 > 20 us
|
||||
6 > 10 us
|
||||
5 > 1 us
|
||||
4 > 100 ns
|
||||
3 > 10 ns
|
||||
2 < 10 ns
|
||||
</pre>
|
||||
|
||||
<p>The alarm condition is indicated by <code>0</code> at <code>Q</code>,
|
||||
which means the radio has a phase error greater than 20 us relative to
|
||||
the broadcast time. The absence of year, DST and leap-second warning in
|
||||
this format is also alarmed.
|
||||
|
||||
<p>The continuous time mode is disabled using the <code>RQTX\r</code>
|
||||
request, following which the radio sends a <code>RQTX
|
||||
DONE<cr><lf></code> response. In the normal mode, other
|
||||
control and status requests are effective, including the leap-second
|
||||
status request <code>RQLS<cr></code>. The radio responds with
|
||||
<code>RQLS yy,mm,dd<cr><lf></code>, where
|
||||
<code>yy,mm,dd</code> are the year, month and day. Presumably, this
|
||||
gives the epoch of the next leap second, <code>RQLS 00,00,00</code> if
|
||||
none is specified in the GPS message. Specified in this form, the
|
||||
information is generally useless and is ignored by the driver.
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>When enabled by the <code>flag4</code> fudge flag, every received
|
||||
timecode is written as-is to the <code>clockstats</code> file.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <var>time</var></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <var>time</var></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <var>number</var></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <var>string</var></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>TRAK</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable <code>clockstats</code> recording if set.
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
</dl>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,107 +0,0 @@
|
||||
<!-- $NetBSD: driver20.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Generic NMEA GPS Receiver
|
||||
</title></head><body><h3>
|
||||
Generic NMEA GPS Receiver
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.20.<var>u</var>
|
||||
<br>Reference ID: GPS
|
||||
<br>Driver ID: GPS_NMEA
|
||||
<br>Serial Port: <code>/dev/gps<var>u</var></code>; 4800 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: <code>tty_clk</code>
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports GPS's with the $GPRMC NMEA output string. The
|
||||
driver expect the GPS to be set up to transmit a $GPRMC message every
|
||||
second.
|
||||
|
||||
<p>The accuracy depend on the GPS used. Inexpesive GPS models are
|
||||
available with a claimed PPS signal accuracy of 1us or better relative
|
||||
to the broadcast signal. However, in most cases the actual accuracy is
|
||||
limited by the precision of the timecode and the latencies of the
|
||||
serial interface and operating system.
|
||||
|
||||
<p>The $GPRMC message that the GPS transmits look like this:
|
||||
<pre>
|
||||
$GPRMC,POS_UTC,POS_STAT,LAT,LAT_REF,LON,LON_REF,SPD,HDG,DATE,MAG_VAR,MAG_REF*CC<cr><lf>
|
||||
|
||||
POS_UTC - UTC of position. Hours, minutes and seconds. (hhmmss)
|
||||
POS_STAT - Position status. (A = Data valid, V = Data invalid)
|
||||
LAT - Latitude (llll.ll)
|
||||
LAT_REF - Latitude direction. (N = North, S = South)
|
||||
LON - Longitude (yyyyy.yy)
|
||||
LON_REF - Longitude direction (E = East, W = West)
|
||||
SPD - Speed over ground. (knots) (x.x)
|
||||
HDG - Heading/track made good (degrees True) (x.x)
|
||||
DATE - Date (ddmmyy)
|
||||
MAG_VAR - Magnetic variation (degrees) (x.x)
|
||||
MAG_REF - Magnetic variation (E = East, W = West)
|
||||
CC - Checksum (optional)
|
||||
<cr><lf> - Sentence terminator.
|
||||
</pre>
|
||||
|
||||
<p>The driver will send a "$PMOTG,RMC,0000*1D<cr><lf>"
|
||||
message each time a $GPRMC string is needed. This is not needed on most
|
||||
GPS receivers because they automatically send the $GPRMC string every
|
||||
second and will only work on GPS receivers that understand the $PMOTG
|
||||
string. Others will just ignore it.
|
||||
|
||||
<p><h4>Setting up the Garmin GPS-25XL</h4>
|
||||
|
||||
<p>Switch off all output with by sending it the following string.
|
||||
<pre>"$PGRMO,,2<cr><lf>"</pre>
|
||||
Now switch only $GPRMC on by sending it the following string.
|
||||
<pre>"$PGRMO,GPRMC,1<cr><lf>"</pre>
|
||||
|
||||
<p>On some systems the PPS signal isn't switched on by default. It can
|
||||
be switched on by sending the following string.
|
||||
<pre>"$PGRMC,,,,,,,,,,,,2<cr><lf>"</pre>
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>The $GPRMC string that is used is written to the clockstats file.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <var>time</var></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <var>time</var></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <var>number</var></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <var>string</var></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>GPS</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
</dl>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,107 +0,0 @@
|
||||
<!-- $NetBSD: driver22.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
PPS Clock Discipline
|
||||
</title></head><body><h3>
|
||||
PPS Clock Discipline
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.22.<var>u</var>
|
||||
<br>Reference ID: ATOM
|
||||
<br>Driver ID: ATOM-PPS
|
||||
<br>Serial Port: <code>/dev/pps<var>u</var></code>; 9600 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: <code>tty_clk</code>, <code>ppsclock</code>
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver furnishes an interface for pulse-per-second (PPS) signals
|
||||
produced by a cesium clock, radio clock or related equipment. It can be
|
||||
used to remove accumulated jitter and retime a secondary server when
|
||||
synchronized to a primary server over a congested, wide-area network and
|
||||
before redistributing the time to local clients.
|
||||
|
||||
<p>In order for this driver to work, the local clock must be set to
|
||||
within +-500 ms by another means, such as a radio clock or NTP itself.
|
||||
The PPS signal is connected via a serial port and <a
|
||||
href="gadget.html">gadget box</a> consisting of a one-shot and RS232
|
||||
level converter. When operated at 38.4 kbps with a SPARCstation IPC,
|
||||
this arrangement has a worst-case jitter less than 26 us.
|
||||
|
||||
<p>There are three ways in which this driver can be used. The first way
|
||||
uses the <code>LDISC_CLKPPS</code> line discipline and works only for
|
||||
the baseboard serial ports of the Sun SPARCstation running SunOS 4.x. In
|
||||
order to use this option, the -DPPS flag must be included in the
|
||||
<code>DEFS_LOCAL</code> line of the distribution configuration file
|
||||
<code>./Config.local</code>. The PPS signal is connected via the gadget
|
||||
box to the carrier detect (DCD) line of a serial port. The signal is
|
||||
activated by a <code>fudge flag3 1</code> command following the
|
||||
<code>server</code> command in the configuration file. This causes the
|
||||
<code>ppsclock</code> streams module to be configured for that port and
|
||||
to capture a timestamp at the on-time transition of the PPS signal. This
|
||||
driver then reads the timestamp directly by a designated
|
||||
<code>ioctl()</code> system call. This provides the most accurate time
|
||||
and least jitter of any other scheme. There is no need to configure a
|
||||
dedicated device for this purpose, which ordinarily is the device used
|
||||
for the associated radio clock.
|
||||
|
||||
<p>The second way uses the <code>LDISC_CLKPPS</code> line discipline and
|
||||
works for any architecture supporting a serial port. In order to use
|
||||
this option, the -DCLK flag must be included in the
|
||||
<code>DEFS_LOCAL</code> line of the distribution configuration file
|
||||
<code>./Config.local</code>. If after a few seconds this driver finds no
|
||||
<code>ppsclock</code> module configured, it attempts to open a serial
|
||||
port device <code>/dev/pps%d</code>, where <code>%d</code> is the unit
|
||||
number, and assign the LDISC_CLKPPS line discipline to it. If the line
|
||||
discipline fails, no harm is done except the accuracy is reduced
|
||||
somewhat. The pulse generator in the gadget box must be adjusted to
|
||||
produce a start bit of length 26 usec at 38400 bps. Used with the
|
||||
<code>LDISC_CLKPPS</code> line discipline, this produces an ASCII DEL
|
||||
character ('\377') followed by a timestamp at the on-time transition of
|
||||
the PPS signal.
|
||||
|
||||
<p>The third way involves an auxiliary radio clock driver which calls
|
||||
the PPS driver with a timestamp captured by that driver. This use is
|
||||
documented in the source code for the driver(s) involved.
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0. This parameter can be used to compensate for
|
||||
the UART and OS delays. Allow about 247 us for UART delays at 38400 bps
|
||||
and about 1 ms for SunOS streams nonsense.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>ATOM</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Enable <code>ppsclock</code> line discipline/streams module if set.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
</dl>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,66 +0,0 @@
|
||||
<!-- $NetBSD: driver23.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
PTB Modem Time Service
|
||||
</title></head><body><h3>
|
||||
PTB Modem Time Service
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.23.<var>u</var>
|
||||
<br>Reference ID: TPTB
|
||||
<br>Driver ID: PTP-ACTS
|
||||
<br>Serial Port: <code>/dev/ptb<var>u</var></code>; 1200 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: none
|
||||
<br>Requires: <code>/usr/include/sys/termios.h</code> header file with
|
||||
modem control
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>No further information available.
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>When enabled by the <code>flag4</code> fudge flag, every received
|
||||
timecode is written as-is to the <code>clockstats</code> file.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>USNO</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Enable <code>ppsclock</code> line discipline/streams module if set.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable <code>clockstats</code> recording if set.
|
||||
|
||||
</dl>
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,62 +0,0 @@
|
||||
<!-- $NetBSD: driver24.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
USNO Modem Time Service
|
||||
</title></head><body><h3>
|
||||
USNO Modem Time Service
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.24.<var>u</var>
|
||||
<br>Reference ID: USNO
|
||||
<br>Driver ID: USNO
|
||||
<br>Serial Port: <code>/dev/cua<var>u</var></code>; 1200 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: none
|
||||
<br>Requires: <code>/usr/include/sys/termios.h</code> header file with
|
||||
modem control
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>No information available.
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>When enabled by the <code>flag4</code> fudge flag, every received
|
||||
timecode is written as-is to the <code>clockstats</code> file.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>USNO</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Enable <code>ppsclock</code> line discipline/streams module if set.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable <code>clockstats</code> recording if set.
|
||||
|
||||
</dl>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,100 +0,0 @@
|
||||
<!-- $NetBSD: driver26.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Hewlett Packard 58503A GPS Receiver
|
||||
</title></head><body><h3>
|
||||
Hewlett Packard 58503A GPS Receiver
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.26.<var>u</var>
|
||||
<br>Reference ID: GPS
|
||||
<br>Driver ID: GPS-HP
|
||||
<br>Serial Port: <code>/dev/hpgps<var>u</var></code>; 9600 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: none
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports the HP 58503A Time and Frequency Reference
|
||||
Receiver. It uses HP SmartClock (TM) to implement an Enhanced GPS
|
||||
receiver. The receiver accuracy when locked to GPS in normal operation
|
||||
is better than 1 usec. The accuracy when operating in holdover is
|
||||
typically better than 10 us per day. It receiver should be operated with
|
||||
factory default settings. Initial driver operation: expects the receiver
|
||||
to be already locked to GPS, configured and able to output timecode
|
||||
format 2 messages.
|
||||
|
||||
<p>The driver uses the poll sequence <code>:PTIME:TCODE?</code> to get a
|
||||
response from the receiver. The receiver responds with a timecode string
|
||||
of ASCII printing characters, followed by a <cr><lf>,
|
||||
followed by a prompt string issued by the receiver, in the following
|
||||
format:
|
||||
|
||||
<pre>
|
||||
T#yyyymmddhhmmssMFLRVcc<cr><lf>
|
||||
</pre>
|
||||
|
||||
<p>The driver processes the response at the <cr> and
|
||||
<lf><cr> and <lf>, so what the driver sees is the
|
||||
prompt from the previous poll, followed by this timecode. The prompt
|
||||
from the current poll is (usually) left unread until the next poll. So
|
||||
(except on the very first poll) the driver sees this:
|
||||
|
||||
<pre>
|
||||
T#yyyymmddhhmmssMFLRVcc<cr><lf>
|
||||
</pre>
|
||||
|
||||
<p>The T is the on-time character, at 980 msec. before the next 1PPS
|
||||
edge. The # is the timecode format type. We look for format 2. Without
|
||||
any of the CLK or PPS stuff, then, the receiver buffer timestamp at the
|
||||
<cr>y is 24 characters later, which is about 25 msec. at 9600
|
||||
bps, so the first approximation for fudge time1 is nominally -0.955
|
||||
seconds. This number probably needs adjusting for each machine / OS
|
||||
type, so far:
|
||||
|
||||
-0.955000 on an HP 9000 Model 712/80 HP-UX 9.05
|
||||
-0.953175 on an HP 9000 Model 370 HP-UX 9.10
|
||||
|
||||
<p>This receiver also provides a 1-PPS signal, but I haven't figured out
|
||||
how to deal with any of the CLK or PPS stuff yet. Stay tuned.
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>When enabled by the <code>flag4</code> fudge flag, every received
|
||||
timecode is written as-is to the <code>clockstats</code> file.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>GPS</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Enable <code>ppsclock</code> line discipline/streams module if set.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable <code>clockstats</code> recording if set.
|
||||
|
||||
</dl>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,426 +0,0 @@
|
||||
<!-- $NetBSD: driver27.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Arcron MSF Receiver
|
||||
</title></head><body><h3>
|
||||
Arcron MSF Receiver
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.27.<var>u</var>
|
||||
<br>Reference ID: MSF
|
||||
<br>Driver ID: ARCRON_MSF
|
||||
<br>Serial Port: <code>/dev/arc<var>u</var></code>; 300 baud, 8-bits, 2-stop,
|
||||
no parity
|
||||
<br>Features: <code>tty_clk</code>
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports the Arcron MSF receiver, and would probably
|
||||
also support the DCF77 variant of the same clock. The clock reports
|
||||
its ID as ``<code>MSFa</code>'' to indicate MSF as a source and the use
|
||||
of the ARCRON driver.
|
||||
|
||||
<p>This documentation describes version V1.1 (1997/06/23) of the source
|
||||
and has been tested (amongst others) against xntpd3-5.90 on Solaris-1 (SunOS 4.1.3_U1 on
|
||||
an SS1 serving as a router and firewall) and against xntpd3-5.90 on
|
||||
Solaris-2.5 (on a SS1+ and TurboSPARC 170MHz). This code will probably
|
||||
work, and show increased stability, reduced jitter and more efficiency
|
||||
(fewer context switches) with the <code>tty_clk</code>
|
||||
discipline/STREAMS module installed, but this has not been tested. For
|
||||
a to-do list see the comments at the start of the code.
|
||||
|
||||
<p>This code has been significantly slimmed down since the V1.0 version,
|
||||
roughly halving the memory footprint of its code and data.
|
||||
|
||||
<p>This driver is designed to allow the unit to run from batteries as
|
||||
designed, for something approaching the 2.5 years expected in the usual
|
||||
stand-alone mode, but no battery-life measurements have been taken.
|
||||
|
||||
<p>Much of this code is originally from the other refclock driver files
|
||||
with thanks. The code was originally made to work with the clock
|
||||
by <a href="mailto:derek@toybox.demon.co.uk">Derek Mulcahy</a>, with
|
||||
modifications by <a href="mailto:d@hd.org">Damon Hart-Davis</a>.
|
||||
Thanks also to <a href="mailto:lyndond@sentinet.co.uk">Lyndon David</a>
|
||||
for some of the specifications of the clock.
|
||||
|
||||
<p>There is support for a Tcl/Tk monitor written by Derek Mulcahy
|
||||
that examines the output stats; see the
|
||||
<a href="http://www2.exnet.com/NTP/ARC/ARC.html">ARC Rugby MSF Receiver</a>
|
||||
page for more details and the code.
|
||||
|
||||
<p>Look at the notes at the start of the code for further information;
|
||||
some of the more important details follow.
|
||||
|
||||
<p>The driver interrogates the clock at each poll (ie every 64s by
|
||||
default) for a timestamp. The clock responds at the start of the next
|
||||
second (with the start bit of the first byte being on-time). The time
|
||||
is in `local' format, including the daylight savings adjustment when it
|
||||
is in effect. The driver code converts the time back to UTC.
|
||||
|
||||
<p>The clock claims to be accurate to within about 20ms of the
|
||||
MSF-broadcast time, and given the low data transmission speed from
|
||||
clock to host, and the fact that the clock is not in continuous sync
|
||||
with MSF, it seems sensible to set the `precision' of this clock to -5
|
||||
or -4, -4 being used in this code, which builds in a reported
|
||||
dispersion of over 63ms (ie says ``This clock is not very good.'').
|
||||
You can improve the reported precision to -4 (and thus reduce the base
|
||||
dispersion to about 31ms) by setting the fudge <code>flag3</code> to
|
||||
<code>1</code>.
|
||||
|
||||
<p>Even a busy and slow IP link can yield lower dispersions than this
|
||||
from polls of primary time servers on the Internet, which reinforces
|
||||
the idea that this clock should be used as a backup in case of problems
|
||||
with such an IP link, or in the unfortunate event of failure of more
|
||||
accurate sources such as GPS.
|
||||
|
||||
<p>By default this clock reports itself to be at stratum 2 rather than
|
||||
the usual stratum 0 for a refclock, because it is not really suited to
|
||||
be used as other than a backup source. The stratum reported can be
|
||||
changed with the <code>fudge</code> directive to be whatever you like.
|
||||
After careful monitoring of your clock, and appropriate choice of the
|
||||
<code>time1</code> fudge factor to remove systematic errors in the
|
||||
clock's reported time, you might fudge the clock to stratum 1 to allow
|
||||
a stratum-2 secondary server to sync to it.
|
||||
|
||||
<p>The driver code arranges to resync the clock to MSF at intervals of
|
||||
a little less than an hour (deliberately avoiding the same time each
|
||||
hour to avoid any systematic problems with the signal or host). Whilst
|
||||
resyncing, the driver supplements the normal polls for time from the
|
||||
clock with polls for the reception signal quality reported by the
|
||||
clock. If the signal quality is too low (0--2 out of a range of 0--5),
|
||||
we chose not to trust the clock until the next resync (which we bring
|
||||
forward by about half an hour). If we don't catch the resync, and so
|
||||
don't know the signal quality, we do trust the clock (because this
|
||||
would generally be when the signal is very good and a resync happens
|
||||
quickly), but we still bring the next resync forward and reduce the
|
||||
reported precision (and thus increase reported dispersion).
|
||||
|
||||
<p>If we force resyncs to MSF too often we will needlessly exhaust the
|
||||
batteries the unit runs from. During clock resync this driver tries to
|
||||
take enough time samples to avoid <code>xntpd</code> losing sync in
|
||||
case this clock is the current peer. By default the clock would only
|
||||
resync to MSF about once per day, which would almost certainly not be
|
||||
acceptable for NTP purposes.
|
||||
|
||||
<p>The driver does not force an immediate resync of the clock to MSF
|
||||
when it starts up to avoid excessive battery drain in case
|
||||
<code>xntpd</code> is going to be repeatedly restarted for any reason,
|
||||
and also to allow enough samples of the clock to be taken for
|
||||
<code>xntpd</code> to sync immediately to this clock (and not remain
|
||||
unsynchronised or to sync briefly to another configured peer, only to
|
||||
hop back in a few poll times, causing unnecessary disturbance). This
|
||||
behaviour should not cause problems because the driver will not accept
|
||||
the timestamps from the clock if the status flag delivered with the
|
||||
time code indicates that the last resync attempt was unsuccessful, so
|
||||
the initial timestamps will be close to reality, even if with up to a
|
||||
day's clock drift in the worst case (the clock by default resyncs to
|
||||
MSF once per day).
|
||||
|
||||
<p>The clock has a peculiar RS232 arrangement where the transmit lines
|
||||
are powered from the receive lines, presumably to minimise battery
|
||||
drain. This arrangement has two consequences:
|
||||
<ul>
|
||||
<li>Your RS232 interface must drive both +ve and -ve
|
||||
<li>You must (in theory) wait for an echo and a further 10ms between
|
||||
characters
|
||||
</ul>
|
||||
This driver, running on standard Sun hardware, seems to work fine; note
|
||||
the use of the <code>send_slow()</code> routine to queue up command
|
||||
characters to be sent once every two seconds.
|
||||
|
||||
<p>Three commands are sent to the clock by this driver. Each command
|
||||
consists of a single letter (of which only the bottom four bits are
|
||||
significant), followed by a CR (ASCII 13). Each character sent to the
|
||||
clock should be followed by a delay to allow the unit to echo the
|
||||
character, and then by a further 10ms. Following the echo of the
|
||||
command string, there may be a response (ie in the cae of the
|
||||
<code>g</code> and <code>o</code> commands below), which in the case of
|
||||
the <code>o</code> command may be delayed by up to 1 second so as the
|
||||
start bit of the first byte of the response can arrive on time.
|
||||
|
||||
The commands and their responses are:
|
||||
<dl>
|
||||
|
||||
<dt><code>g</code> CR
|
||||
<dd>Request for signal quality. Answer only valid during (late part
|
||||
of) resync to MSF signal. The response consists of two characters as
|
||||
follows:
|
||||
<ol>
|
||||
<li><dl compact>
|
||||
<dt>bit 7</dt> <dd> parity
|
||||
<dt>bit 6</dt> <dd> always 0
|
||||
<dt>bit 5</dt> <dd> always 1
|
||||
<dt>bit 4</dt> <dd> always 1
|
||||
<dt>bit 3</dt> <dd> always 0
|
||||
<dt>bit 2</dt> <dd> always 0
|
||||
<dt>bit 1</dt> <dd> always 1
|
||||
<dt>bit 0</dt> <dd> = 0 if no reception attempt at the moment,
|
||||
= 1 if reception attempt (ie resync) in progress
|
||||
</dl>
|
||||
<li><dl compact>
|
||||
<dt>bit 7</dt> <dd> parity
|
||||
<dt>bit 6</dt> <dd> always 0
|
||||
<dt>bit 5</dt> <dd> always 1
|
||||
<dt>bit 4</dt> <dd> always 1
|
||||
<dt>bit 3</dt> <dd> always 0
|
||||
<dt>bit 2--0</dt> <dd> reception signal quality in the range 0--5
|
||||
(very poor to very good); if in the range 0--2 no
|
||||
successful reception is to be expected. The reported
|
||||
value drops to zero when not resyncing, ie when first
|
||||
returned byte is not `3'.
|
||||
</dl>
|
||||
</ol>
|
||||
|
||||
<dt><code>h</code> CR
|
||||
<dd>Request to resync to MSF. Can take up from about 30s to 360s.
|
||||
Drains batteries so should not be used excessively. After this the
|
||||
clock time and date should be correct and the phase within 20ms of time
|
||||
as transmitted from Rugby MSF (remember to allow for propagation
|
||||
time). By default the clock resyncs once per day shortly after 2am
|
||||
(presumably to catch transitions to/from daylight saving time
|
||||
quickly). With this driver code we resync at least once per hour to
|
||||
minimise clock wander.
|
||||
|
||||
<dt><code>o</code> CR
|
||||
<dd>Request timestamp. Start bit of first byte of response is on-time,
|
||||
so may be delayed up to 1 second. Note that when the BST mode is in
|
||||
effect the time is GMT/UTC +0100, ie an hour ahead of UTC to reflect
|
||||
local time in the UK. The response data is as follows:
|
||||
<ol>
|
||||
<li>hours tens (hours range from 00 to 23)
|
||||
<li>hours units
|
||||
<li>minutes tens (minutes range from 00 to 59)
|
||||
<li>minutes units
|
||||
<li>seconds tens (seconds presumed to range from 00 to 60 to allow for leap second)
|
||||
<li>seconds units
|
||||
<li>day of week 1 (Monday) to 7 (Sunday)
|
||||
<li>day of month tens (day ranges from 01 to 31)
|
||||
<li>day of month units
|
||||
<li>month tens (months range from 01 to 12)
|
||||
<li>month units
|
||||
<li>year tens (years range from 00 to 99)
|
||||
<li>year units
|
||||
<li>BST/UTC status <dl compact>
|
||||
<dt>bit 7</dt> <dd> parity
|
||||
<dt>bit 6</dt> <dd> always 0
|
||||
<dt>bit 5</dt> <dd> always 1
|
||||
<dt>bit 4</dt> <dd> always 1
|
||||
<dt>bit 3</dt> <dd> always 0
|
||||
<dt>bit 2</dt> <dd> = 1 if UTC is in effect (reverse of bit 1)
|
||||
<dt>bit 1</dt> <dd> = 1 if BST is in effect (reverse of bit 2)
|
||||
<dt>bit 0</dt> <dd> = 1 if BST/UTC change pending
|
||||
</dl>
|
||||
<li>clock status<dl compact>
|
||||
<dt>bit 7</dt> <dd> parity
|
||||
<dt>bit 6</dt> <dd> always 0
|
||||
<dt>bit 5</dt> <dd> always 1
|
||||
<dt>bit 4</dt> <dd> always 1
|
||||
<dt>bit 3</dt> <dd> = 1 if low battery is detected
|
||||
<dt>bit 2</dt> <dd> = 1 if last resync failed (though officially
|
||||
undefined for the MSF clock)
|
||||
<dt>bit 1</dt> <dd> = 1 if at least one reception attempt since
|
||||
0230 for the MSF clock was successful
|
||||
(0300 for the DCF77 clock)
|
||||
<dt>bit 0</dt> <dd> = 1 if the clock has valid time---reset to zero
|
||||
when clock is reset (eg at power-up), and
|
||||
set to 1 after first successful resync attempt.
|
||||
</dl>
|
||||
</ol>
|
||||
The driver only accepts time from the clock if the bottom three bits of
|
||||
the status byte are <code>011</code>. The leap-year logic for
|
||||
computing day-in-year is only valid until 2099, and the clock will
|
||||
ignore stamps from the clock that claim BST is in effect in the first
|
||||
hour of each year. If the UK parliament decides to move us to
|
||||
+0100/+0200 time as opposed to the current +0000/+0100 time, it is not
|
||||
clear what effect that will have on the time broadcast by MSF, and
|
||||
therefore on this driver's usefulness.
|
||||
|
||||
</dl>
|
||||
|
||||
A typical <code>ntp.conf</code> configuration file for this driver
|
||||
might be:
|
||||
<pre>
|
||||
# hostname(n) means we expect (n) to be the stratum at which hostname runs.
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# SYNCHRONISATION PARTNERS
|
||||
# ========================
|
||||
|
||||
# Our betters...
|
||||
server 127.127.27.0 # ARCRON MSF radio clock(1).
|
||||
# Fudge stratum and other features as required.
|
||||
# ADJUST time1 VALUE FOR YOUR HOST, CLOCK AND LOCATION!
|
||||
fudge 127.127.27.0 stratum 1 time1 0.016 flag3 1 flag4 1
|
||||
|
||||
peer 11.22.33.9 # tick(1--2).
|
||||
peer 11.22.33.4 # tock(3), boot/NFS server.
|
||||
|
||||
# This shouldn't get swept away unless left untouched for a long time.
|
||||
driftfile /var/tmp/ntp.drift
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# RESTRICTIONS
|
||||
# ============
|
||||
|
||||
# By default, don't trust and don't allow modifications. Ignore in fact.
|
||||
restrict default ignore notrust nomodify
|
||||
|
||||
# Allow others in our subnet to check us out...
|
||||
restrict 11.22.33.0 mask 255.255.255.0 nomodify notrust
|
||||
|
||||
# Trust our peers for time. Don't trust others in case they are insane.
|
||||
restrict 127.127.27.0 nomodify
|
||||
restrict 11.22.33.4 nomodify
|
||||
restrict 11.22.33.9 nomodify
|
||||
|
||||
# Allow anything from the local host.
|
||||
restrict 127.0.0.1
|
||||
</pre>
|
||||
|
||||
There are a few <code>#define</code>s in the code that you might wish
|
||||
to play with:
|
||||
<dl>
|
||||
<dt><code>ARCRON_KEEN</code></dt>
|
||||
<dd>With this defined, the code is relatively trusting of the clock,
|
||||
and assumes that you will have the clock as one of a few time sources,
|
||||
so will bend over backwards to use the time from the clock when
|
||||
available and avoid <code>xntpd</code> dropping sync from the clock
|
||||
where possible. You may wish to undefine this, especially if you have
|
||||
better sources of time or your reception is ropey. However, there are
|
||||
many checks built in even with this flag defined.
|
||||
|
||||
<dt><code>ARCRON_OWN_FILTER</code></dt>
|
||||
<dd>When defined, the code uses its own median-filter code rather than
|
||||
that available in <code>ntp_refclock.c</code> since the latter seems to
|
||||
have a minor bug, at least in version 3-5.90. If this bug goes away
|
||||
this flag should be turned off to avoid duplication of code. (The bug,
|
||||
if that's what it is, causes the last raw offset to be used rather than
|
||||
the median offset.)
|
||||
|
||||
<p>Without this defined (and without
|
||||
<code>ARCRON_MULTIPLE_SAMPLES</code> below) a typical set of offsets
|
||||
reported and used to drive the clock-filter algorithm is (oldest
|
||||
last):
|
||||
<pre>
|
||||
filtoffset= -4.32 -34.82 -0.78 0.89 2.76 4.58 -3.92 -2.17
|
||||
</pre>
|
||||
Look at that spike!
|
||||
|
||||
<p>With this defined a typical set of offsets is:
|
||||
<pre>
|
||||
filtoffset= -7.06 -7.06 -2.91 -2.91 -2.91 -1.27 -9.54 -6.70
|
||||
</pre>
|
||||
with the repeated values being some evidence of outlyers being discarded.
|
||||
|
||||
<dt><code>ARCRON_MULTIPLE_SAMPLES</code></dt>
|
||||
<dd>When is defined, we regard each character in the returned timecode
|
||||
as at a known delay from the start of the second, and use the smallest
|
||||
(most negative) offset implied by any such character, ie with the
|
||||
smallest kernel-induced display, and use that. This helps to reduce
|
||||
jitter and spikes.
|
||||
|
||||
<dt><code>ARCRON_LEAPSECOND_KEEN</code></dt>
|
||||
<dd>When is defined, we try to do a resync to MSF as soon as possible
|
||||
in the first hour of the morning of the first day of the first and
|
||||
seventh months, ie just after a leap-second insertion or deletion would
|
||||
happen if it is going to. This should help compensate for the fact
|
||||
that this clock does not continuously sample MSF, which compounds the
|
||||
fact that MSF itself gives no warning of an impending leap-second
|
||||
event. This code did not seem functional at the leap-second insertion
|
||||
of 30th June 1997 so is by default disabled.
|
||||
|
||||
<dt><code>PRECISION</code></dt>
|
||||
<dd>Currently set to <code>-4</code>, but you may wish to set it to
|
||||
<code>-5</code> if you are more conservative, or to <code>-6</code> if
|
||||
you have particularly good experience with the clock and you live on
|
||||
the edge. Note that the <code>flag3</code> fudge value will improve
|
||||
the reported dispersion one notch if clock signal quality is known
|
||||
good. So maybe just leave this alone. B^)
|
||||
|
||||
<dt><code>NSAMPLES</code></dt>
|
||||
<dd>Should be at least 3 to help smooth out sampling jitters. Can be
|
||||
more, but if made too long can make <code>xntpd</code> overshoot on
|
||||
clock corrections and can hold onto bad samples longer than you would
|
||||
like. With this set to 4 and <code>NKEEP</code> set to 3 this allows
|
||||
the occasional bad sample (in my experience less than 1 value in 10) to
|
||||
be dropped. (Note that there seems to be some sort of `beat' effect in
|
||||
the offset with a periodicity of about 7 samples as of this writing
|
||||
(1997/05/11) still under investigation; a filter of approximately this
|
||||
length should be able to almost completely suppress this effect.) Note
|
||||
that if the fudge-factor <code>flag3</code> is set to 1, a larger
|
||||
<code>NSAMPLES</code> is used.
|
||||
|
||||
</dl>
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>Each timecode is written to the <code>clockstats</code> file with a
|
||||
signal quality value appended (`0'--`5' as reported by the clock, or
|
||||
`6' for unknown).
|
||||
|
||||
<p>Each resync and result (plus gaining or losing MSF sync) is logged
|
||||
to the system log at level <code>LOG_NOTICE</code>; note that each
|
||||
resync drains the unit's batteries, so the syslog entry seems justified.
|
||||
|
||||
<p>Syslog entries are of the form:
|
||||
<pre>
|
||||
May 10 10:15:24 oolong xntpd[615]: ARCRON: unit 0: sending resync command
|
||||
May 10 10:17:32 oolong xntpd[615]: ARCRON: sync finished, signal quality 5: OK, will use clock
|
||||
May 10 11:13:01 oolong xntpd[615]: ARCRON: unit 0: sending resync command
|
||||
May 10 11:14:06 oolong xntpd[615]: ARCRON: sync finished, signal quality -1: UNKNOWN, will use clock anyway
|
||||
May 10 11:41:49 oolong xntpd[615]: ARCRON: unit 0: sending resync command
|
||||
May 10 11:43:57 oolong xntpd[615]: ARCRON: sync finished, signal quality 5: OK, will use clock
|
||||
May 10 12:39:26 oolong xntpd[615]: ARCRON: unit 0: sending resync command
|
||||
May 10 12:41:34 oolong xntpd[615]: ARCRON: sync finished, signal quality 3: OK, will use clock
|
||||
</pre>
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0. On a Sun SparcStation 1 running SunOS
|
||||
4.1.3_U1, with the receiver in London, a value of 0.020 (20ms)
|
||||
seems to be appropriate.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not currently used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0. It is suggested that the clock be fudged to stratum 1 so this
|
||||
it is used a backup time source rather than a primary when more
|
||||
accurate sources are available.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>MSFa</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not currently used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not currently used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>If set to 1, better precision is reported (and thus lower dispersion)
|
||||
while clock's received signal quality is known to be good.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>If set to 1, a longer-than-normal (8-stage rather than 4-stage)
|
||||
median filter is used, to provide some extra smoothing of clock
|
||||
output and reduction in jitter, at the cost of extra clock
|
||||
overshoot. Probably not advisable unless the server using this
|
||||
clock has other sources it can use to help mitigate the overshoot.
|
||||
|
||||
</dl>
|
||||
|
||||
<p><h4>Additional Information</h4>
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
<p><a href="http://www2.exnet.com/NTP/ARC/ARC.html">ARC Rugby MSF Receiver</a> page
|
||||
|
||||
<hr><address>Damon Hart-Davis (d@hd.org)</address></body></html>
|
@ -1,103 +0,0 @@
|
||||
<!-- $NetBSD: driver28.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Shared memoy Driver
|
||||
</title></head><body><h3>
|
||||
Shared memory Driver
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.28.<var>u</var>
|
||||
<br>Reference ID: SHM
|
||||
<br>Driver ID: SHM
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver receives its reference clock info from a shared memory-segment.
|
||||
The shared memory-segment is created with owner-only access
|
||||
for unit 0 and 1, and world access for unit 2 and 3
|
||||
|
||||
<p><h4>Structure of shared memory-segment</h4>
|
||||
<pre>
|
||||
struct shmTime {
|
||||
int mode; /* 0 - if valid set
|
||||
* use values,
|
||||
* clear valid
|
||||
* 1 - if valid set
|
||||
* if count before and after read of
|
||||
* values is equal,
|
||||
* use values
|
||||
* clear valid
|
||||
*/
|
||||
int count;
|
||||
time_t clockTimeStampSec; /* external clock */
|
||||
int clockTimeStampUSec; /* external clock */
|
||||
time_t receiveTimeStampSec; /* internal clock, when external value was received */
|
||||
int receiveTimeStampUSec; /* internal clock, when external value was received */
|
||||
int leap;
|
||||
int precision;
|
||||
int nsamples;
|
||||
int valid;
|
||||
int dummy[10];
|
||||
};
|
||||
</pre>
|
||||
<p><h4>Operation mode=0</h4>
|
||||
When the poll-method of the driver is called, the valid-flag of the
|
||||
shared memory-segment is checked:
|
||||
<p>If set, the values in the record
|
||||
(clockTimeStampSec, clockTimeStampUSec, receiveTimeStampSec,
|
||||
receiveTimeStampUSec, leap, precision) are passed to ntp, and the valid-flag
|
||||
is cleared.
|
||||
<p>If not set, a timeout is reported to ntp, nothing else happend
|
||||
|
||||
<p><h4>Operation mode=1</h4>
|
||||
When the poll-method of the driver is called, the valid-flag of the
|
||||
shared memory-segment is checked:
|
||||
<p>If set, the count-field of the record is remembered, and the values in
|
||||
the record (clockTimeStampSec, clockTimeStampUSec, receiveTimeStampSec,
|
||||
receiveTimeStampUSec, leap, precision) are read. Then, the remembered count
|
||||
is compared to the count now in the record. If both are equal, the values
|
||||
read from the record are passed to ntp. If they differ, another process
|
||||
has modified the record while it was read out (was not able to produce
|
||||
this case), and failure is reported to ntp. The valid flag is cleared.
|
||||
|
||||
<p>If not set, a timeout is reported to ntp, nothing else happend
|
||||
<p>
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <var>time</var></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <var>time</var></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <var>number</var></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <var>string</var></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>SHM</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
</dl>
|
@ -1,111 +0,0 @@
|
||||
<!-- $NetBSD: driver3.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
PSTI/Traconex 1020 WWV/WWVH Receiver
|
||||
</title></head><body><h3>
|
||||
PSTI/Traconex 1020 WWV/WWVH Receiver
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.3.<var>u</var>
|
||||
<br>Reference ID: WWV
|
||||
<br>Driver ID: WWV-PST
|
||||
<br>Serial Port: <code>/dev/wwv<var>u</var></code>; 9600 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: <code>tty_clk</code>
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports the PSTI 1010 and Traconex 1020 WWV/WWVH
|
||||
Receivers. No specific claim of accuracy is made for these receiver, but
|
||||
actual experience suggests that 10 ms would be a conservative
|
||||
assumption.
|
||||
|
||||
<p>The DIP-switches should be set for 9600 bps line speed, 24-hour day-
|
||||
of-year format and UTC time zone. Automatic correction for DST should be
|
||||
disabled. It is very important that the year be set correctly in the
|
||||
DIP-switches; otherwise, the day of year will be incorrect after 28 April
|
||||
of a normal or leap year. The propagation delay DIP-switches should be
|
||||
set according to the distance from the transmitter for both WWV and
|
||||
WWVH, as described in the instructions. While the delay can be set only
|
||||
to within 11 ms, the fudge time1 parameter can be used for vernier
|
||||
corrections.
|
||||
|
||||
<p>Using the poll sequence <code>QTQDQM</code>, the response timecode is
|
||||
in three sections totalling 50 ASCII printing characters, as
|
||||
concatenated by the driver, in the following format:
|
||||
|
||||
<pre>
|
||||
ahh:mm:ss.fffs<cr> yy/dd/mm/ddd<cr>
|
||||
frdzycchhSSFTttttuuxx<cr>
|
||||
|
||||
on-time = first <cr>
|
||||
hh:mm:ss.fff = hours, minutes, seconds, milliseconds
|
||||
a = AM/PM indicator (' ' for 24-hour mode)
|
||||
yy = year (from DIPswitches)
|
||||
dd/mm/ddd = day of month, month, day of year
|
||||
s = daylight-saving indicator (' ' for 24-hour mode)
|
||||
f = frequency enable (O = all frequencies enabled)
|
||||
r = baud rate (3 = 1200, 6 = 9600)
|
||||
d = features indicator (@ = month/day display enabled)
|
||||
z = time zone (0 = UTC)
|
||||
y = year (5 = 91)
|
||||
cc = WWV propagation delay (52 = 22 ms)
|
||||
hh = WWVH propagation delay (81 = 33 ms)
|
||||
SS = status (80 or 82 = operating correctly)
|
||||
F = current receive frequency (4 = 15 MHz)
|
||||
T = transmitter (C = WWV, H = WWVH)
|
||||
tttt = time since last update (0000 = minutes)
|
||||
uu = flush character (03 = ^c)
|
||||
xx = 94 (unknown)
|
||||
</pre>
|
||||
|
||||
<p>The alarm condition is indicated by other than <code>8</code> at
|
||||
<code>a</code>, which occurs during initial synchronization and when
|
||||
received signal is lost for an extended period; unlock condition is
|
||||
indicated by other than <code>0000</code> in the <code>tttt</code>
|
||||
subfield.
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>When enabled by the <code>flag4</code> fudge flag, every received
|
||||
timecode is written as-is to the <code>clockstats</code> file.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>WWV</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Enable <code>ppsclock</code> line discipline/streams module if set.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable <code>clockstats</code> recording if set.
|
||||
|
||||
</dl>
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,133 +0,0 @@
|
||||
<!-- $NetBSD: driver4.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
Spectracom 8170 and Netclock/2 WWVB Receivers
|
||||
</title></head><body><h3>
|
||||
Spectracom 8170 and Netclock/2 WWVB Receivers
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.4.<var>u</var>
|
||||
<br>Reference ID: WWVB
|
||||
<br>Driver ID: WWVB-SPEC
|
||||
<br>Serial Port: <code>/dev/wwvb<var>u</var></code>; 9600 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: <code>tty_clk</code>
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports the Spectracom Model 8170 and Netclock/2 WWVB
|
||||
Synchronized Clock. This clock has proven a reliable source of time,
|
||||
except in some cases of high ambient conductive RF interference. The
|
||||
claimed accuracy of the clock is 100 usec relative to the broadcast
|
||||
signal; however, in most cases the actual accuracy is limited by the
|
||||
precision of the timecode and the latencies of the serial interface and
|
||||
operating system.
|
||||
|
||||
<p>The DIPswitches on this clock should be set to 24-hour display, AUTO
|
||||
DST off, data format 0 or 2 (see below) and baud rate 9600.
|
||||
If this clock is to used as the source for the IRIG Audio Decoder
|
||||
(refclock_irig.c in this distribution), set the DIPswitches for AM IRIG
|
||||
output and IRIG format 1 (IRIG B with signature control).
|
||||
|
||||
<p>There are two timecode formats used by these clocks. Format 0, which
|
||||
is available with both the Netclock/2 and 8170, and format 2, which is
|
||||
available only with the Netclock/2 and specially modified 8170.
|
||||
|
||||
<p>Format 0 (22 ASCII printing characters):
|
||||
|
||||
<pre>
|
||||
<cr><lf>i ddd hh:mm:ss TZ=zz<cr><lf>
|
||||
|
||||
on-time = first <cr>
|
||||
i = synchronization flag (' ' = in synch, '?' = out synch)
|
||||
hh:mm:ss = hours, minutes, seconds
|
||||
</pre>
|
||||
|
||||
<p>The alarm condition is indicated by other than ' ' at <code>i</code>,
|
||||
which occurs during initial synchronization and when received signal is
|
||||
lost for about ten hours.
|
||||
|
||||
<p>Format 2 (24 ASCII printing characters):
|
||||
|
||||
<pre>
|
||||
<cr><lf>iqyy ddd hh:mm:ss.fff ld
|
||||
|
||||
on-time = <cr>
|
||||
i = synchronization flag (' ' = in synch, '?' = out synch)
|
||||
q = quality indicator (' ' = locked, 'A'...'D' = unlocked)
|
||||
yy = year (as broadcast)
|
||||
ddd = day of year
|
||||
hh:mm:ss.fff = hours, minutes, seconds, milliseconds
|
||||
</pre>
|
||||
|
||||
<p>The alarm condition is indicated by other than ' ' at <code>i</code>,
|
||||
which occurs during initial synchronization and when received signal is
|
||||
lost for about ten hours. The unlock condition is indicated by other
|
||||
than ' ' at <code>q</code>.
|
||||
<p>The <code>q</code> is normally ' ' when the time error is less than 1
|
||||
ms and a character in the set <code>A...D</code> when the time error is
|
||||
less than 10, 100, 500 and greater than 500 ms respectively. The
|
||||
<code>l</code> is normally ' ', but is set to <code>L</code> early in
|
||||
the month of an upcoming UTC leap second and reset to ' ' on the first
|
||||
day of the following month. The <code>d</code> is set to <code>S</code>
|
||||
for standard time <code>S</code>, <code>I</code> on the day preceding a
|
||||
switch to daylight time, <code>D</code> for daylight time and
|
||||
<code>O</code> on the day preceding a switch to standard time. The start
|
||||
bit of the first <cr> is synchronized to the indicated time as
|
||||
returned.
|
||||
|
||||
<p>This driver does not need to be told which format is in use - it
|
||||
figures out which one from the length of the message. A three-stage
|
||||
median filter is used to reduce jitter and provide a dispersion measure.
|
||||
The driver makes no attempt to correct for the intrinsic jitter of the
|
||||
radio itself, which is a known problem with the older radios.
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>The driver writes each timecode as received to the
|
||||
<code>clockstats</code> file. When enabled by the <code>flag4</code>
|
||||
fudge flag, a table of quality data maintained internally by the
|
||||
Netclock/2 is retrieved and written to the <code>clockstats</code> file
|
||||
when the first timecode message of a new day is received.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0. For a calibrated Sun IPC, the correct value
|
||||
is about .0048.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>WWVB</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Enable <code>ppsclock</code> line discipline/streams module if set.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable extended <code>clockstats</code> recording if set.
|
||||
|
||||
</dl>
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,138 +0,0 @@
|
||||
<!-- $NetBSD: driver5.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
TrueTime GPS/GOES/OMEGA Receivers
|
||||
</title></head><body><h3>
|
||||
TrueTime GPS/GOES/OMEGA Receivers
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.5.<var>u</var>
|
||||
<br>Reference ID: GPS, OMEGA, GOES
|
||||
<br>Driver ID: TRUETIME
|
||||
<br>Serial Port: <code>/dev/true<var>u</var></code>; 9600 baud, 8-bits,
|
||||
no parity
|
||||
<br>Features: <code>tty_clk</code>
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports several models models of Kinemetrics/TrueTime
|
||||
timing receivers, including 468-DC MK III GOES Synchronized Clock, GPS-
|
||||
DC MK III and GPS/TM-TMD GPS Synchronized Clock, XL-DC (a 151-602-210,
|
||||
reported by the driver as a GPS/TM-TMD), GPS-800 TCU (an 805-957 with
|
||||
the RS232 Talker/Listener module), OM-DC OMEGA Synchronized Clock, and
|
||||
very likely others in the same model family that use the same timecode
|
||||
formats.
|
||||
|
||||
<p>Most of this code is originally from refclock_wwvb.c with thanks. It
|
||||
has been so mangled that wwvb is not a recognizable ancestor.
|
||||
|
||||
<pre>
|
||||
Timcode format: ADDD:HH:MM:SSQCL
|
||||
|
||||
A - control A (this is stripped before we see it)
|
||||
Q - Quality indication (see below)
|
||||
C - Carriage return
|
||||
L - Line feed
|
||||
|
||||
Quality codes indicate possible error of
|
||||
|
||||
468-DC GOES Receiver:
|
||||
GPS-TM/TMD Receiver:
|
||||
? +/- 500 milliseconds # +/- 50 milliseconds
|
||||
* +/- 5 milliseconds . +/- 1 millisecond
|
||||
space less than 1 millisecond
|
||||
|
||||
OM-DC OMEGA Receiver:
|
||||
|
||||
> +/- 5 seconds
|
||||
|
||||
? +/- 500 milliseconds # +/- 50 milliseconds
|
||||
* +/- 5 milliseconds . +/- 1 millisecond
|
||||
|
||||
A-H less than 1 millisecond. Character indicates which
|
||||
station
|
||||
is being received as follows: A = Norway, B = Liberia,
|
||||
C = Hawaii, D = North Dakota, E = La Reunion, F =
|
||||
Argentina,
|
||||
G = Australia, H = Japan.
|
||||
</pre>
|
||||
|
||||
<p>The carriage return start bit begins on 0 seconds and extends to 1
|
||||
bit time.
|
||||
|
||||
<p>Notes on 468-DC and OMEGA receiver:
|
||||
<p>Send the clock a <code>R</code> or <code>C</code> and once per second
|
||||
a timestamp will appear. Send a <code>R</code> to get the satellite
|
||||
position once (GOES only).
|
||||
|
||||
<p>Notes on the 468-DC receiver:
|
||||
|
||||
<p>Since the old east/west satellite locations are only historical, you
|
||||
can't set your clock propagation delay settings correctly and still use
|
||||
automatic mode. The manual says to use a compromise when setting the
|
||||
switches. This results in significant errors. The solution; use fudge
|
||||
time1 and time2 to incorporate corrections. If your clock is set for 50
|
||||
and it should be 58 for using the west and 46 for using the east, use
|
||||
the line
|
||||
|
||||
<p><code>fudge 127.127.5.0 time1 +0.008 time2 -0.004</code>
|
||||
|
||||
<p>This corrects the 4 milliseconds advance and 8 milliseconds retard
|
||||
needed. The software will ask the clock which satellite it sees.
|
||||
|
||||
<p>The PCL720 from PC Labs has an Intel 8253 look-alike, as well as a
|
||||
bunch of TTL input and output pins, all brought out to the back panel.
|
||||
If you wire a PPS signal (such as the TTL PPS coming out of a GOES or
|
||||
other Kinemetrics/Truetime clock) to the 8253's GATE0, and then also
|
||||
wire the 8253's OUT0 to the PCL720's INPUT3.BIT0, then we can read CTR0
|
||||
to get the number of microseconds since the last PPS upward edge,
|
||||
mediated by reading OUT0 to find out if the counter has wrapped around
|
||||
(this happens if more than 65535us (65ms) elapses between the PPS event
|
||||
and our being called.)
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>When enabled by the <code>flag4</code> fudge flag, every received
|
||||
timecode is written as-is to the <code>clockstats</code> file.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, to be used for the West satellite, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>. Specifies the time offset calibration factor, in seconds and
|
||||
fraction, to be used for the East satellite, with default 0.0.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>TRUE</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Silence the clock side of xntpd, just reading the clock without
|
||||
trying to write to it.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Generate a debug file /tmp/true%d.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Enable <code>ppsclock</code> line discipline/streams module if set.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable <code>clockstats</code> recording if set.
|
||||
</dl>
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
@ -1,134 +0,0 @@
|
||||
<!-- $NetBSD: driver6.html,v 1.1 1998/12/30 20:20:34 mcr Exp $ -->
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
|
||||
<html><head><title>
|
||||
IRIG Audio Decoder
|
||||
</title></head><body><h3>
|
||||
IRIG Audio Decoder
|
||||
</h3><hr>
|
||||
|
||||
<p><h4>Synopsis</h4>
|
||||
|
||||
<p>Address: 127.127.6.<var>u</var>
|
||||
<br>Reference ID: IRIG
|
||||
<br>Driver ID: IRIG-AUDIO
|
||||
<br>Audio Device: <code>/dev/irig<var>u</var></code>
|
||||
<br>Requires: modified SunOS 4.1.3 BSD audio driver and
|
||||
<code>/usr/include/sys/bsd_audioirig.h</code> header file
|
||||
|
||||
<p><h4>Description</h4>
|
||||
|
||||
<p>This driver supports the Inter-Range Instrumentation Group standard
|
||||
time-distribution signal IRIG-B using the audio codec native to the Sun
|
||||
SPARCstation. This signal is generated by several radio clocks,
|
||||
including those made by Austron, TrueTime, Odetics and Spectracom, among
|
||||
others, although it is generally an add-on option. The signal is
|
||||
connected via an attenuator box and cable to the audio codec input on a
|
||||
Sun SPARCstation and requires a specially modified kernel audio driver
|
||||
described in the <a href="irig.html">IRIG Support Using Sun SPARC
|
||||
Audio</a> page.
|
||||
|
||||
<p>The driver requires a modified SunOS 4.1.3 BSD audio driver available
|
||||
from the archive host ftp.udel.edu as the compressed tar archive
|
||||
<code>pub/ntp/bsd_audio.tar.Z</code>. For ordinary audio applications,
|
||||
the audio driver is transparent; for use with the NTP driver, the audio
|
||||
driver decodes the IRIG audio signals and provides a timestamp, raw
|
||||
binary timecode, status byte and decoded ASCII timecode. The data are
|
||||
represented in the structure in the sys/bsd_audioirig.h header file:
|
||||
|
||||
<pre>
|
||||
struct irig_time {
|
||||
struct timeval stamp; /* timestamp */
|
||||
u_char bits[13]; /* 100 IRIG data bits */
|
||||
u_char status; /* status byte */
|
||||
char time[14]; /* time string (null terminated) */
|
||||
</pre>
|
||||
|
||||
<p>where stamp represents a timestamp at the zero crossing of the index
|
||||
marker at the second's epoch, bits is a 13-octet, zero-padded binary-
|
||||
coded string representing code elements 1 through 100 in the IRIG-B code
|
||||
format, and status is a status byte, The decoded timestamp is a 13-
|
||||
octet, null-terminated ASCII string <code>ddd hh:mm:ss*</code>, where
|
||||
ddd is the day of year, hh:mm:ss the time of day and <code>*</code> is a
|
||||
status indicator, with ' ' indicating valid time and '?' indicating
|
||||
something wrong.
|
||||
|
||||
<p>The timestamp is in Unix timeval format, consisting of two 32-bit
|
||||
words, the first of which is the seconds since 1970 and the second is
|
||||
the fraction of the second in microseconds. The status byte is zero if
|
||||
(a) the input signal is within amplitude tolerances, (b) the raw binary
|
||||
timecode contains only valid code elements, (c) 11 position identifiers
|
||||
have been found at the expected element positions, (d) the clock status
|
||||
byte contained in the timecode is valid, and (e) a time determination
|
||||
has been made since the last read() system call.
|
||||
|
||||
<p>The 100 elements of the IRIG-B timecode are numbered from 0 through
|
||||
99. Position identifiers occur at elements 0, 9, 19 and every ten
|
||||
thereafter to 99. The control function (CF) elements begin at element 50
|
||||
(CF 1) and extend to element 78 (CF 27). The straight-binary-seconds
|
||||
(SBS) field, which encodes the seconds of the UTC day, begins at element
|
||||
80 (CF 28) and extends to element 97 (CF 44). The encoding of elements
|
||||
50 (CF 1) through 78 (CF 27) is device dependent. This driver presently
|
||||
does not use the CF elements.
|
||||
|
||||
<p>Where feasible, the interface should be operated with signature
|
||||
control, so that, if the IRIG signal is lost or malformed, the interface
|
||||
produces an unmodulated signal, rather than possibly random digits. The
|
||||
driver will declare itself unsynchronized in this case.
|
||||
|
||||
<pre>
|
||||
Element CF Function
|
||||
-------------------------------------
|
||||
55 6 time sync status
|
||||
60-63 10-13 bcd year units
|
||||
65-68 15-18 bcd year tens
|
||||
</pre>
|
||||
|
||||
<p>Timing jitter using the decoder and a Sun IPC is in the order of a
|
||||
few microseconds, although the overall timing accuracy is limited by the
|
||||
wander of the CPU oscillator used for timing purposes to a few hundred
|
||||
microseconds. These figures are comparable with what can be achieved
|
||||
using the PPS discipline as describe elsewhere in this note.
|
||||
|
||||
<p><h4>Monitor Data</h4>
|
||||
|
||||
<p>The driver writes each timecode as received to the
|
||||
<code>clockstats</code> file.
|
||||
|
||||
<p><h4>Fudge Factors</h4>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>time1 <i>time</i></code>
|
||||
<dd>Specifies the time offset calibration factor, in seconds and
|
||||
fraction, with default 0.0.
|
||||
|
||||
<p><dt><code>time2 <i>time</i></code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>stratum <i>number</i></code>
|
||||
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default
|
||||
0.
|
||||
|
||||
<p><dt><code>refid <i>string</i></code>
|
||||
<dd>Specifies the driver reference identifier, an ASCII string from one
|
||||
to four characters, with default <code>IRIG</code>.
|
||||
|
||||
<p><dt><code>flag1 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag2 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag3 0 | 1</code>
|
||||
<dd>Not used by this driver.
|
||||
|
||||
<p><dt><code>flag4 0 | 1</code>
|
||||
<dd>Enable <code>clockstats</code> recording if set.
|
||||
|
||||
</dl>
|
||||
|
||||
<p>Additional Information
|
||||
|
||||
<p><a href="refclock.html"> Reference Clock Drivers</a>
|
||||
|
||||
<hr><address>David L. Mills (mills@udel.edu)</address></body></html>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user