Bye bye xntpd.

This commit is contained in:
roberto 1999-12-22 15:24:45 +00:00
parent 38a2392e70
commit ea759355ea
360 changed files with 0 additions and 93367 deletions

View File

@ -1,62 +0,0 @@
/******************************************************************************
* *
* Copyright (c) David L. Mills 1992, 1993, 1994 *
* *
* 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. *
* *
******************************************************************************/
/*
* For all files included in this distribution and not specifically marked
* otherwise, the above copyright information applies.
*
* Authors
*
* Dennis Ferguson <dennis@mrbill.canet.ca> (foundation code for NTP
* Version 2 as specified in RFC-1119)
* Lars H. Mathiesen <thorinn@diku.dk> (adaptation of foundation code for
* Version 3 as specified in RFC-1305)
* Louis A. Mamakos <louie@ni.umd.edu> (support for md5-based
* authentication)
* Craig Leres <leres@ee.lbl.gov> (port to 4.4BSD operating system,
* ppsclock, Maganavox GPS clock driver)
* Nick Sayer <mrapple@quack.kfu.com> (SunOS streams modules)
* Frank Kardel <Frank.Kardel@informatik.uni-erlangen.de>(PARSE (GENERIC)
* driver, STREAMS module for PARSE, support scripts, reference clock
* configuration scripts, Makefile cleanup)
* Rainer Pruy <Rainer.Pruy@informatik.uni-erlangen.de> (monitoring/trap
* scripts, statistics file handling)
* Glenn Hollinger <glenn@herald.usask.ca> (GOES clock driver)
* Kenneth Stone <ken@sdd.hp.com> (port to HPUX operating system)
* Dave Katz <dkatz@cisco.com> (port to RS/6000 AIX operating system)
* William L. Jones <jones@hermes.chpc.utexas.edu> (RS/6000 AIX
* modifications, HPUX modifications)
* John A. Dundas III <dundas@salt.jpl.nasa.gov> (Apple A/UX port)
* David L. Mills <mills@udel.edu> (Spectractom WWVB, Austron GPS,
* Heath, ATOM, ACTS, KSI/Odetics IRIG-B clock drivers; pps support)
* Jeffrey Mogul <mogul@pa.dec.com> (ntptrace utility)
* Steve Clift (clift@ml.csiro.au) OMEGA clock driver)
* Mike Iglesias (iglesias@uci.edu) (DEC Alpha changes)
* Mark Andrews <marka@syd.dms.csiro.au> (Leitch atomic clock controller)
* George Lindholm <lindholm@ucs.ubc.ca> (port to SunOS 5.1 operating system)
* Jeff Johnson <jbj@chatham.usdesign.com> (massive prototyping overhaul)
* Tom Moore <tmoore@fievel.daytonoh.ncr.com> (port to i386 svr4)
* Piete Brooks <Piete.Brooks@cl.cam.ac.uk> (MSF clock driver, Trimble PARSE
* support)
* Karl Berry <karl@owl.HQ.ileaf.com> (syslog to file option)
* Torsten Duwe <duwe@immd4.informatik.uni-erlangen.de> (Linux Port)
* Paul A Vixie <vixie@vix.com> (TrueTime GPS driver)
* Jim Jagielski <jim@jagubox.gsfc.nasa.gov> (A/UX port)
* Ray Schnitzler <schnitz@unipress.com> (First pass at a Unixware1 port.)
* Ajit Thyagarajan <ajit@ee.udel.edu> (IP multicast support)
* Jeff Steinman <jss@pebbles.jpl.nasa.gov> (Datum PTS clock driver)
* Tomoaki TSURUOKA <tsuruoka@nc.fukuoka-u.ac.jp> (TRAK clock driver)
*/

View File

@ -1,7 +0,0 @@
#
# Makefile for xntpd.
# $FreeBSD$
#
SUBDIR= lib parse xntpd xntpdc ntpq ntpdate ntptrace authstuff
.include <bsd.subdir.mk>

View File

@ -1,21 +0,0 @@
# $FreeBSD$
DEFS_LOCAL=-DREFCLOCK -DPARSE -DUDP_WILDCARD_DELIVERY
NTPDEFS= -DSYS_FREEBSD -DSYS_44BSD
AUTHDEFS= -DMD5
CLOCKDEFS= -DLOCAL_CLOCK -DPST -DWWVB -DAS2201 -DGOES -DGPSTM -DOMEGA \
-DLEITCH -DTRAK -DACTS -DATOM -DDATUM -DHEATH -DMSFEES \
-DMX4200 -DNMEA -DBOEDER
CFLAGS+= ${NTPDEFS} ${DEFS_LOCAL} ${AUTHDEFS} ${CLOCKDEFS} ${COPTS}
.if exists(${.OBJDIR}/../lib)
LIBNTP= ${.OBJDIR}/../lib/libntp.a
.else
LIBNTP= ${.CURDIR}/../lib/libntp.a
.endif
.if !defined(NOCRYPT) && exists(${.CURDIR}/../../../secure/usr.sbin/xntpd/lib)
AUTHDEFS+= -DDES
.endif
.include "../Makefile.inc"

View File

@ -1,37 +0,0 @@
These are the rules so that older bsd systems and the POSIX standard
system can coexist togather.
1) If you use select then include "ntp_select.h"
select is not standard, since it is very system depenedent as to where
select is defined. The logic to include the right system dependent
include file is in "ntp_select.h".
2) Always use POSIX defintion of strings. Inlcude "ntp_string.h" instaed
of <string.h>.
3) Always include "ntp_malloc.h" if you use malloc.
4) Always include "ntp_io.h" instead of <sys/file.h> or <fnctl.h> to
get O_* flags.
5) Always include "ntp_if.h" instead of <net/if.h>.
6) Always include "ntp_stdlib.h" instead of <stdlib.h>.
7) Always define a system identifier for any new system added to the
machines directory. The identifier should always start with SYS_!
8) Define any special defines needed for a system in
./include/ntp_machine.h based on system identifier. This file is
included by the "ntp_types.h" file and should always be placed
first after the <> defines.
9) Define any special library prototypes left over from the system
library and include files in the "l_stdlib.h" file. This file is
included by the "ntp_stdlib.h" file and should ordinarily be
placed last in the includes list.
10) Don't define a include file by the same name as a system include file.
"l_stdlib.h" can contain any extra definitions that are needed so that
gcc will shut up. They should be controlled by a system identifier and
there should be a seperate section for each system. Really this will
make it easier to maintain.
See include/ntp_machines.h for the verious compile time options.
Good luck.
Bill Jones, with amendments by Dave Mills

View File

@ -1,156 +0,0 @@
The xntp3 Distribution
This directory and its subdirectories contain the Network Time Protocol
Version 3 (NTP) distribution for Unix systems. It contains source code
for the daemon, together with related auxiliary programs, documentation
and strange stuff. You are welcome to the lot, with due consideration of
the COPYRIGHT files stashed in the distributions. You are also invited
to contribute bugfixes and drivers for new and exotic radios, telephones
and sundials. This distribution is normally available by anonymous ftp
as the compressed tar archive xntp-<version>.tar.Z in the pub/ntp directory
on louie.udel.edu.
The base directory contains the distributions and related stuff. The files
marked with a "*" are not distributed, but generated. Most of
the subdirectories contain README files describing their contents. The
base directory ./ includes:
COPYRIGHT file specifying copyright conditions, together with a
list of major authors and electric addresses.
Config * configuration file built by the configuration script
"make makeconfig" and used to build the makefiles in the
various subdirectories. Do not edit.
Config.local * Unless you have a reference clock (besides the local
computer clock) or want to change the default installation
directory (/usr/local/bin) not action is needed. For
configuring a reference clock a "make refconf" should
suffice. Diehards can still use an editor on this file.
Config.local.dist file used to generate a plausible Config.local by commands
such as "make Config.local.green".
Config.sed * sed script used to build makefiles from the
configuration file. Do not edit.
Makefile this is the root of the makefile tree. Do not edit.
(Contents under pressure - qualified personel only 8-)
PORTING contains useful information for porting to unexplored
new systems.
RELNOTES instructions for compiling and installing the daemon and
supporting programs.
README this file.
TODO our current problems where we could need help.
adjtime directory containing the sources for the adjtime daemon
for HP/UX systems.
authstuff directory containing sources for miscellaneous programs
to test, calibrate and certify the cryptographic
mechanisms for DES and MD5 based authentication. These
programs do not include the cryptographic routines
themselves, so are free of U.S. export restrictions.
clockstuff directory containing sources for miscellaneous programs
to test certain auxilliary programs used with some
kernel configurations, together with a program to
calculate propagation delays for use with radio clocks
and national time dissemination services such as
WWV/WWVH, WWVB and CHU.
compilers directory containing configuration scripts for various
compilers and operating systems.
conf directory containing a motley collection of
configuration files for various systems. For example
only.
doc directory containing miscellaneous man pages and memos
useful for installation and subnet management.
gadget directory containing instructions and construction data
for a mysterious little box used as a CHU radio
demodulator and/or a level converter-pulse generator for
a precision 1-pps signal.
include directory containing include header files used by most
programs in the distribution.
hints directory containing files with hints on particular
topics like installation on specific OS variants or
general information.
kernel directory containing sources for kernel programs such as
line disciplines and STREAMS modules used with the CHU
decoder and precision 1-pps signals.
lib directory containing sources for the library programs
used by most programs in the distribution.
machines directory containing configuration scripts for various
operating systems.
ntpdate directory containing sources for a program to set the
local machine time from one or more remote machines
running NTP. Operates like rdate, but much more
accurate.
ntpq directory containing sources for a utility program to
query local and remote NTP peers for state variables and
related timekeeping information. This program conforms
to Appendix A of the NTP Version 3 Specification RFC
1305.
ntptrace directory containing sources for a utility program that
can be used to reveal the chain of NTP peers from a
designated peer to the primary server at the root of the
timekeeping subnet.
parse directory containing file belonging to the generic parse
reference clock driver. For reasonably simple clocks it
is possible to get away with about 3-4Kb of code.
additionally the SunOS 4.x streams module for parse is
residing here.
parse/util some goodies for testing parse processing of DCF77 information.
(primarily for use on Suns, although others may work
also - possibly with a little porting.)
one little gem is dcfd.c - DCF77 decoder with ntp loopfilter
code for standalone DCF77 synchronisation without the full
works of NTP.
Dcfd.c has been ported to FreeBSD for the Boeder DCF77 receiver
by Vincenzo Capuano.
ppsclock directory containing sources for modifications to the
kernel asynchronous serial driver plus a STREAMS module
to capture a precision 1-pps signal. Useful on SunOS
4.1.X systems only.
refclocks directory containing reference clock configuration support
scripts directory containing scripts to build the configuration
file "config" in this directory and then the makefiles
used in various dependent directories.
the subdirectories monitoring and support hold various
perl and shell scripts for visualising synchronisation
and daemon startup.
util directory containing sources for various utility and
testing programs.
xntpd directory containing sources for the NTP Version 3 daemon.
xntpdc directory containing sources for a utility program to
query local and remote NTP peers for state variables and
related timekeeping information. This program is
specific to this implmentation of NTP Version 3 and does
not conform to Appendix A of the NTP Version 3
Specification RFC 1305.
xntpres directory containing sources for a name-resolution
program used in some configurations of NTP Version 3.

View File

@ -1,15 +0,0 @@
$FreeBSD$
This version of NTP was converted to the BSD-style Makefile system by
Garrett Wollman (wollman@FreeBSD.org); it is based on version
3.4e (beta) from the University of Delaware.
Besides the Makefile changes, the DES code has been completely removed
in order to make this code exportable. If you have a legal copy of
`authdes.c', you can just add it to the lib/ directory and add `-DDES'
to the AUTHDEFS in Makefile.inc.
You can change CLOCKDEFS in the same file to add other reference clocks.
This port should work under either FreeBSD 1.1 or FreeBSD 2.0. For
1.1, change the `-DSYS_44BSD' in Makefile.inc to `-DSYS_386BSD'.

View File

@ -1,216 +0,0 @@
For special hints on setup/compilation/installation and other general
topics you may persue the files in the hints directory.
This file contains the usual instructions to compile and install the programs in
this distribution. To make these programs:
(0) Make sure that you have all necessary tools for building executables.
These tools include cc/gcc, make, awk, sed, tr, sh, grep, egrep and
a few others. Not all of these tools exist in the standard distribution
of todays UNIX versions (compilers are likely to be an extra product).
For a successful build all of these tools should be accessible via the
current path.
(1) By default, if there is no Config.local, the system will generate one
to support a local ref clock (i.e. run off the system clock).
Greenhorns can skip on to (2).
HACKers can create a Config.local and choose the compilation options,
install destination directory and clock drivers.
A template for Config.local can be found in Config.local.dist.
There are two Configurations that can be auto-generated:
make Config.local.local # network configuration plus local
# reference clock (the default)
make Config.local.NO.clock # network only configuration
To set up for a radio clock, type "make refconf" and answer the questions
about PLL, PPS and radio clock type.
If this is the first use of the ref clock, don't forget to make suitable
files in /dev/.
For custom tailored configuration copying Config.local.dist to Config.local
and editing Config.local to suit the local needs is neccessary (at most
3 lines to change), or use one of the make's above and then tweak it.
Config.local can also be used to override common settings from the
machines/* files like the AUTHDEFS= to select very specific configurations.
Please use this feature with care and don't be disappointed if it doesn't
work the way you expect.
(2) Type "make" to compile everything of general interest. Expect few or
no warnings using cc and a moderate level of warnings using gcc.
Note: On some Unix platforms the use of gcc can result in quite a few
complaints about system header files and type problems within xntp
code. This is usually the case when the OS header files are not up
up to ANSI standards or GCCISMs. (There may, however, be still some
inconsistencies in the code)
Other known problems stem from bugs/features/... in utility programs
of some vendors.
See section "build problems" for known problems and possible work-
arounds.
Each time you change the configuration a script that pokes your hard- and
software will be run to build the actual configuration files.
If the script fails, it will give you a list of machines it knows about.
You can override the automatic choice by cd to the ../machines directory
and typing "make makeconfig OS=<machine>", where <machine> is one of the
file names in the ../machine directory.
The shell script will attempt to find the gcc compiler and, if
found, will use it instead of the cc compiler. You can override
this automatic choice by cd to the ../machines directory and typing
"make makeconfig COMP=<compiler>", where <compiler> is one of the file
names in the ../compilers directory. This can be combined with
the OS argument above.
The configuration step can be separatly invoked by "make makeconfig".
Note that any reconfiguration will result in cleaning the old
program and object files.
(3) Assuming you have write permission on the install destination directory,
type "make install" to install the binaries in the destination directory.
At the time of writing this includes
the programs xntpd (the daemon), xntpdc (an xntpd-dependent query
program), ntpq (a standard query program), ntpdate (an rdate
replacement for boot time date setting and sloppy time keeping)
and xntpres (a program which provides name resolver support for
some xntpd configurations).
(4) You are now ready to configure the daemon and start it. At this
point it might be useful to format and print the file doc/notes.me
and read a little bit. The sections on configuration and on the
tickadj program will be immediately useful.
Additional "make" target you might find useful are:
clean cleans out object files, programs and temporary files
dist makes a new distribution file (also cleans current binaries)
All usual scratch and backup files (*.rej, *.orig, *.o, *~
core, lint*.errs, executables, tags, Makefile.bak, make.log)
will be removed. The distribution is created in a tar file
(file name: <prefix><version>.tar.<compression suffix> - with
the prefix usually being ../xntp- and a compression suffix
of .Z (compress))
Note: the file Config.local will never be included in the
distribution tar file. For configuration hints to propagate
in in distribution changes must be made to Config.local.dist.
depend possible maker of hazardous waste
refconf a target to interactively configure reference clock support.
This should work for you, but has not yet been tested on
the more exotic Unix ports (mostly the supercomputer ones).
Bug reports of a general nature can be sent to David Mills (mills@udel.edu).
Reports concerning specific hardware or software systems mentioned in the
COPYRIGHT file should be sent to the author, with copy to David Mills for
archive.
The distribution has been compiled and run on at least the following
machines, operating systems and compilers. In all known cases, if
the gcc compiler eats it with some success, the cc compiler also enjoys
the meal. The converse is not always true. See the conf directory for
test suites known to compile with various radio clocks; however, not all
the combinations that compile have been tested.
VAX-11/785 4.3 tahoe cc no REFCLOCK (dm 93/11/20)
Sun3 SunOS 4.1.1 gcc no REFCLOCK (pb 93/10/25)
Sun4 SunOS 4.1.1 gcc all REFCLOCK drivers (dm 93/10/25)
Sun4 SunOS 4.1.3 gcc all REFLCOCK drivers
Sun4 SunOS 5.1 gcc no REFCLOCK (pb 93/10/25)
Sun4 SunOS 5.2 gcc no REFCLOCK (dm 93/11/20)
Sun4 SunOS 5.2 gcc PARSE REFCLOCK (kd 93/11/10)
Sun4 SunOS 5.3 gcc local (pb 93/11/10)
HP700 HPUX 9.0 cc no REFCLOCK
hp7xx HPUX 9.01 cc local + PARSE (kd 93/10/26)
HP3xx HPUX 9.01 cc no REFCLOCK (pb 93/10/25)
HP3xx HPUX 8.0 cc no REFCLOCK (pb 93/10/25)
MIPS Ultrix 4.3a gcc WWVB clock (dm 93/11/20)
MIPS Ultrix 3a gcc green (pb 93/10/26)
ALPHA OSF 1.2a gcc no REFCLOCK (dm 93/11/20)
ALPHA OSF 1.3 gcc no REFCLOCK (pb 93/10/25)
ALPHA OSF1 1.3 gcc green (pb 93/10/26)
Convex Convex OS 10.1 ? ?
SGI IRIX 4.0.5F gcc no REFCLOCK (pb 93/11/10)
AIX 3.2 ? ?
A/UX 2.0.1, 3.x.x gcc LOCAL_CLOCK (jmj (94/01/26 see hints)
RS6000 AIX 3.2 gcc no REFCLOCK
MX500 Sinix-m V5.40 cc PARSE REFCLOCK
S2000 Sequent PTX 1.4 cc LOCAL_CLOCK (kd 93/11/10)
S2000 Sequent PTX 1.4 gcc LOCAL_CLOCK (kd 93/11/10)
PC FreeBSD gcc LOCAL_CLOCK see "build problems"
PC NetBSD? gcc LOCAL_CLOCK possibly see "build problems"
PC BSD/386 1.0 gcc LOCAL_CLOCK possibly see "build problems"
PC Linux (pl14) gcc LOCAL_CLOCK (dw 93/10/30)
PC Dell SVR4 v2.2 gcc ? (tl 93/12/30)
PC Unixware1/SVR4 cc no tickadj, ? (ras 93/04/11)
NCR3445 NCR SVR4 cc LOCAL_CLOCK (tm 93/11/29)
pb: Piete Brooks
kd: Frank Kardel
dw: Torsten Duwe (duwe@informatik.uni-erlangen.de)
dm: David Mills (mills@udel.edu)
tl: Tony Lill <ajlill@tlill.hookup.net>
tm: Tom Moore <Tom.Moore@DaytonOH.NCR.COM>
jmj: Jim Jagielski <jim@jagubox.gsfc.nasa.gov>
ras: Ray Schnitzler <schnitz@unipress.com>
Build Problems (and workaround):
During testing/porting we have found some
of "make" and "sh" and "awk" features in different implementations.
If you have problems other tha the one listed below please check for
usualy things like the latest sh compatible pd shell in your own
environment. Things like this are known to hinder compilation if
they are not fully compatible with sh or are buggy.
Current build problem on (Mac) NetBSD, possibly BSDI and 386BSD:
pmake (e. g. NetBSD on MAC, possible other BNR2+pmake systems)
Following Makefile construction fails for no
apparent reason (at least to me)
doit:
$(MAKE) MAKE=\"$(MAKE)\" all
all:
@echo all done.
for the "make MAKE=make" call but not for "make" or
"make -e MAKE=make". Use the last form if you suffer
from that kind of make problems. (Easily detected
by failure to build with the message:
"don't know how to make make".
On BSD/386 the solution is to get GNU make and run build as:
% gnumake MAKE=gnumake
Note that BSD/386 1.0's "sed" goes into an infinite loop if
you try to make the "refconf" target -- so edit Config.local
by hand if you have a reference clock. (BSD/386 1.1 will fix
this "sed" bug.)
The NetBSD people claim that this problem goes away
when you compile make with POSIX compilation options.
The known sh and some make pecularities have already been taken care of.
Usually the vendor should fix these bugs in vital utilities.
We try to circumvent these bugs in a hopefully portable way.
If you can reproduce these bugs on your system please bug your
vendor/developer group to fix them. We are not trying anything fancy
in here (except for starting sub-makes) and we are shocked that even
the most common tools fail so miserably. By the time you get this
code the above utilities may already have been fixed. Hopefully one
day we do not have to cope with this kind of broken utilities.
Frank Kardel
William L. Jones <jones@chpc.utexas.edu>
Dennis Ferguson (Advanced Network Systems) <dennis@ans.net>
Lars Mathiesen (University of Copenhagen) <thorinn@diku.dk>
David Mills <mills@udel.edu>
Frank Kardel <Frank.Kardel@informatik.uni-erlangen.de>
Piete Brooks <Piete.Brooks@cl.cam.ac.uk>
-- and a cast of thousands -- see the COPYRIGHT file
16 November 1993

View File

@ -1,26 +0,0 @@
#
# TODO,v 3.5 1994/01/25 19:03:55 kardel Exp
#
This file contains problems known to the authors that still need to be done.
We would appreciate if you could spare some of your time to look through
these topics and help us with some open questions. Most of the topics
pertain to specific architectures where we have no direct access or not
the time or expertise to currently track down the problem further.
If you don't know what we are talking about in the topics don't bother
with finding out - somebody else will probably solve that problem.
Before you try to send a solution to mills@udel.edu please check whether
this problem still exists in the distribution on louie.udel.edu.
Thank you for your help !
Dave Mills
Frank Kardel
Piete Brooks
Open issues:
Apollo:
- terminal affiliation
Check whether thing are still correct in respect to breaking
terminal affiliation - horrible stories are told in the code.
File affected: xntpd/ntpd.c

View File

@ -1 +0,0 @@
version=3.4e (beta multicast)

View File

@ -1,20 +0,0 @@
#
# $FreeBSD$
#
# Most of the programs in this directory are completely useless for the
# NTP configuration that we provide by default.
# We provide the `md5' program as a public service.
CFLAGS+= -I${.CURDIR}/../include
DPADD= ${LIBNTP}
LDADD= ${LIBNTP}
PROG= md5
SRCS= md5driver.c
NOMAN=
install:
.include <bsd.prog.mk>

View File

@ -1,13 +0,0 @@
README file for directory ./authstuff of the NTP Version 3 distribution
This directory contains the sources for miscellaneous programs to test,
validate and calibreate cryptographic routines used by NTP. These include
authcert.c used to certify the DES and MD5 message digest algorithms
work properly. See the source for directions for use.
authspeed.c used to determing the running time for DES and MD5
messge digest algorithms. See the source for directions
for use.
For other programs, see the source files.

View File

@ -1,44 +0,0 @@
#
# Sample key file, also used for testing.
#
# Note that there are three formats for keys. Standard format is a
# hex format with the low order bit of each byte being a parity
# bit, a la the NBS standard. NTP format is also hex, but uses the
# high order bit of each byte for parity. Ascii format simply encodes
# a 1-8 character ascii string as a key. Note that because of the
# simple tokenizing routine, the characters ' ', '#', '\t', '\n' and
# '\0' can't be used in an ascii key. Everything else is fair game, though.
#
1 S 0101010101010101 # odd parity 0 key
2 N 8080808080808080 # and again
3 A ugosnod
4 A BigbOObs
5 S f1f1f1f1f1f1f1f1
6 N f8f8f8f8f8f8f8f8 # same as key 5
7 S f8f8f8f8f8f8f8f8 # not same as key 6
8 A a # short ascii keys are zero padded
9 A &^%$@!*(
10 S 01020407080bf1f1
11 N 4040404040404040
12 A more
13 A random
14 A keys
15 A password # 15 used as password by runtime configuration
#
16 M password # MD5 key
17 M secret
18 M key1
19 M key2
20 M foobar
21 M tick
22 M tock
23 M key23
24 M key24
25 M key25
26 M a
27 M few
28 M more
29 M random
30 M md5
31 M keys!

View File

@ -1,33 +0,0 @@
Authentication delays (us) DES MD5
-------------------------------------------
IBM RS6000/990 10 28
IBM RS6000/590 10 29
HP 9000/735 hpux9.03 snavely 10 33
DEC 3000/400 OSF/1 bunnylou 14 35
HP 9000/730 hpux8.07(+OV) 16 55
SGI Indigo R4000 19 48
HP 9000/720 hpux8.07 21 66
IBM RS6000/250 20 39
IBM RS6000/370 21 43
IBM RS6000/580 22 43
SGI 4/35 38 110
DECstation 5000/240 cowbird 39 81
IBM RS6000/530H 40 83
Sun4c/75 SS2 43 96
Sun4c/50 IPX malarky 47 94
DECstation 5000/33 sundeck 49 106
IBM RS6000/530 51 107
SGI Indigo 54 115
DECstation 5000/125 herald 63 136
IBM RS6000/320 69 139
Sun4c/65 SS1+ pogo 72 159
Sun4c/40 IPC grundoon 73 163
Sun4c/60 SS1 albert 95 199
Sun4c/20 SLC 95 203
DECstation 3100 sheol 98 214
DECstation 2100 circus 126 278
VAX 780 985 ?
Updated 26 April 1994
David L. Mills

View File

@ -1,95 +0,0 @@
/*
* This file, and the certdata file, shamelessly stolen
* from Phil Karn's DES implementation.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define DES
#include "ntp_stdlib.h"
u_char ekeys[128];
u_char dkeys[128];
static void get8 P((U_LONG *));
static void put8 P((U_LONG *));
void
main()
{
U_LONG key[2], plain[2], cipher[2], answer[2], temp;
int i;
int test;
int fail;
for(test = 0; !feof(stdin); test++){
get8(key);
DESauth_subkeys(key, ekeys, dkeys);
printf(" K: "); put8(key);
get8(plain);
printf(" P: "); put8(plain);
get8(answer);
printf(" C: "); put8(answer);
for (i = 0; i < 2; i++)
cipher[i] = htonl(plain[i]);
DESauth_des(cipher, ekeys);
for (i = 0; i < 2; i++) {
temp = ntohl(cipher[i]);
if (temp != answer[i])
break;
}
fail = 0;
if (i != 2) {
printf(" Encrypt FAIL");
fail++;
}
DESauth_des(cipher, dkeys);
for (i = 0; i < 2; i++) {
temp = ntohl(cipher[i]);
if (temp != plain[i])
break;
}
if (i != 2) {
printf(" Decrypt FAIL");
fail++;
}
if (fail == 0)
printf(" OK");
printf("\n");
}
}
static void
get8(lp)
U_LONG *lp;
{
int t;
U_LONG l[2];
int i;
l[0] = l[1] = 0;
for (i = 0; i < 8; i++) {
scanf("%2x", &t);
if (feof(stdin))
exit(0);
l[i / 4] <<= 8;
l[i / 4] |= (U_LONG)(t & 0xff);
}
*lp = l[0];
*(lp + 1) = l[1];
}
static void
put8(lp)
U_LONG *lp;
{
int i;
for(i = 0; i < 2; i++)
printf("%08lx", (u_long)(*lp++));
}

View File

@ -1,315 +0,0 @@
/*
* authspeed - figure out how long it takes to do an NTP encryption
*/
#if defined(SYS_HPUX) || defined(SYS_AUX3) || defined(SYS_AUX2) || defined(SOLARIS) || defined(SYS_SVR4) || defined(SYS_PTX) || defined(SYS_UNIXWARE1)
#define FAKE_RUSAGE
#endif
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#ifdef FAKE_RUSAGE
#include <sys/param.h>
#include <sys/times.h>
#endif
#include "ntp_fp.h"
#include "ntp_stdlib.h"
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
#define DEFLOOPS -1
#define DEFDELAYLOOPS 20000
#define DEFCOSTLOOPS 2000
char *progname;
int debug;
struct timeval tstart, tend;
#ifdef FAKE_RUSAGE
struct tms rstart, rend;
#define getrusage(foo, t) times(t)
#define RUSAGE_SELF 0
#else
struct rusage rstart, rend;
#endif
l_fp dummy1, dummy2;
u_long dummy3;
U_LONG pkt[15];
int totalcost = 0;
double rtime;
double vtime;
int domd5 = 0;
static void dodelay P((int));
static void docheap P((int));
static void docost P((int));
static void subtime P((struct timeval *, struct timeval *, double *));
/*
* main - parse arguments and handle options
*/
void
main(argc, argv)
int argc;
char *argv[];
{
int c;
int loops;
int i;
int errflg = 0;
extern int ntp_optind;
extern char *ntp_optarg;
progname = argv[0];
loops = DEFLOOPS;
while ((c = ntp_getopt(argc, argv, "cdmn:")) != EOF)
switch (c) {
case 'c':
totalcost++;
break;
case 'd':
++debug;
break;
case 'm':
domd5 = 16; /* offset into list of keys */
break;
case 'n':
loops = atoi(ntp_optarg);
if (loops <= 0) {
(void) fprintf(stderr,
"%s: %s is unlikely to be a useful number of loops\n",
progname, ntp_optarg);
errflg++;
}
break;
default:
errflg++;
break;
}
if (errflg || ntp_optind == argc) {
(void) fprintf(stderr,
"usage: %s [-d] [-n loops] [ -c ] auth.samplekeys\n",
progname);
exit(2);
}
printf("Compute timing for ");
if (domd5)
printf("MD5");
else
printf("DES");
printf(" based authentication.\n");
init_auth();
authreadkeys(argv[ntp_optind]);
for (i = 0; i < 16; i++) {
if (!auth_havekey(i + domd5)) {
errflg++;
(void) fprintf(stderr, "%s: key %d missing\n",
progname, i + domd5);
}
}
if (errflg) {
(void) fprintf(stderr,
"%s: check syslog for errors, or use file with complete set of keys\n",
progname);
exit(1);
}
if (loops == DEFLOOPS) {
if (totalcost)
loops = DEFCOSTLOOPS;
else
loops = DEFDELAYLOOPS;
}
dummy1.l_ui = 0x80808080;
dummy1.l_uf = 0xffffff00;
dummy3 = 0x0aaaaaaa;
for (i = 0; i < 12; i++)
pkt[i] = i * 0x22222;
if (totalcost) {
if (totalcost > 1)
docheap(loops);
else
docost(loops);
} else {
dodelay(loops);
}
printf("total real time: %.3f\n", rtime);
printf("total CPU time: %.3f\n", vtime);
if (totalcost) {
printf("real cost (in seconds): %.6f\n",
rtime/(double)loops);
printf("CPU cost (in seconds): %.6f\n",
vtime/(double)loops);
printf("\nThis includes the cost of a decryption plus the\n");
printf("the cost of an encryption, i.e. the cost to process\n");
printf("a single authenticated packet.\n");
} else {
printf("authdelay in the configuration file\n");
printf("real authentication delay: %.6f\n",
rtime/(double)loops);
printf("authentication delay in CPU time: %.6f\n",
vtime/(double)loops);
printf("\nThe CPU delay is probably the best bet for\n");
printf("authdelay in the configuration file\n");
}
exit(0);
}
/*
* dodelay - do the delay measurement
*/
static void
dodelay(loops)
int loops;
{
double vtime1, rtime1, vtime2, rtime2;
register int loopcount;
/*
* If we're attempting to compute the cost of an auth2crypt()
* for first compute the total cost, then compute the
* cost of only doing the first step, auth1crypt(). What
* remains is the cost of auth2crypt.
*/
loopcount = loops;
(void) gettimeofday(&tstart, (struct timezone *)0);
(void) getrusage(RUSAGE_SELF, &rstart);
while (loopcount-- > 0) {
auth1crypt((loops & 0xf) + domd5, pkt, 48);
L_ADDUF(&dummy1, dummy3);
auth2crypt((loops & 0xf) + domd5, pkt, 48);
}
(void) getrusage(RUSAGE_SELF, &rend);
(void) gettimeofday(&tend, (struct timezone *)0);
subtime(&tstart, &tend, &rtime1);
#ifdef FAKE_RUSAGE
vtime1 = (rend.tms_utime - rstart.tms_utime) * 1.0 / HZ;
#else
subtime(&rstart.ru_utime, &rend.ru_utime, &vtime1);
#endif
printf("Time for full encryptions is %f rusage %f real\n", vtime1, rtime1);
loopcount = loops;
(void) gettimeofday(&tstart, (struct timezone *)0);
(void) getrusage(RUSAGE_SELF, &rstart);
while (loopcount-- > 0) {
auth1crypt((loops & 0xf) + domd5, pkt, 48);
}
(void) getrusage(RUSAGE_SELF, &rend);
(void) gettimeofday(&tend, (struct timezone *)0);
subtime(&tstart, &tend, &rtime2);
#ifdef FAKE_RUSAGE
vtime2 = (rend.tms_utime - rstart.tms_utime) * 1.0 / HZ;
#else
subtime(&rstart.ru_utime, &rend.ru_utime, &vtime2);
#endif
printf("Time for auth1crypt is %f rusage %f real\n", vtime2, rtime2);
vtime = vtime1 - vtime2;
rtime = rtime1 - rtime2;
}
/*
* docheap - do the cost measurement the cheap way
*/
static void
docheap(loops)
register int loops;
{
(void) authhavekey(3 + domd5);
(void) gettimeofday(&tstart, (struct timezone *)0);
(void) getrusage(RUSAGE_SELF, &rstart);
while (loops-- > 0) {
auth1crypt(3 + domd5, pkt, 48);
L_ADDUF(&dummy1, dummy3);
auth2crypt(3 + domd5, pkt, 48);
(void) authdecrypt(3 + domd5, pkt, 48);
}
(void) getrusage(RUSAGE_SELF, &rend);
(void) gettimeofday(&tend, (struct timezone *)0);
subtime(&tstart, &tend, &rtime);
#ifdef FAKE_RUSAGE
vtime = (rend.tms_utime - rstart.tms_utime) * 1.0 / HZ;
#else
subtime(&rstart.ru_utime, &rend.ru_utime, &vtime);
#endif
}
/*
* docost - do the cost measurement
*/
static void
docost(loops)
register int loops;
{
(void) gettimeofday(&tstart, (struct timezone *)0);
(void) getrusage(RUSAGE_SELF, &rstart);
while (loops-- > 0) {
auth1crypt((loops & 0xf) + domd5, pkt, 48);
L_ADDUF(&dummy1, dummy3);
auth2crypt((loops & 0xf) + domd5, pkt, 48);
(void) authdecrypt(((loops+1) & 0xf) + domd5, pkt, 48);
}
(void) getrusage(RUSAGE_SELF, &rend);
(void) gettimeofday(&tend, (struct timezone *)0);
subtime(&tstart, &tend, &rtime);
#ifdef FAKE_RUSAGE
vtime = (rend.tms_utime - rstart.tms_utime) * 1.0 / HZ;
#else
subtime(&rstart.ru_utime, &rend.ru_utime, &vtime);
#endif
}
/*
* subtime - subtract two struct timevals, return double result
*/
static void
subtime(tvs, tve, res)
struct timeval *tvs, *tve;
double *res;
{
long sec;
long usec;
sec = tve->tv_sec - tvs->tv_sec;
usec = tve->tv_usec - tvs->tv_usec;
if (usec < 0) {
usec += 1000000;
sec--;
}
*res = (double)sec + (double)usec/1000000.;
return;
}

View File

@ -1,34 +0,0 @@
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
0131D9619DC1376E 5CD54CA83DEF57DA 7A389D10354BD271
07A1133E4A0B2686 0248D43806F67172 868EBB51CAB4599A
3849674C2602319E 51454B582DDF440A 7178876E01F19B2A
04B915BA43FEB5B6 42FD443059577FA2 AF37FB421F8C4095
0113B970FD34F2CE 059B5E0851CF143A 86A560F10EC6D85B
0170F175468FB5E6 0756D8E0774761D2 0CD3DA020021DC09
43297FAD38E373FE 762514B829BF486A EA676B2CB7DB2B7A
07A7137045DA2A16 3BDD119049372802 DFD64A815CAF1A0F
04689104C2FD3B2F 26955F6835AF609A 5C513C9C4886C088
37D06BB516CB7546 164D5E404F275232 0A2AEEAE3FF4AB77
1F08260D1AC2465E 6B056E18759F5CCA EF1BF03E5DFA575A
584023641ABA6176 004BD6EF09176062 88BF0DB6D70DEE56
025816164629B007 480D39006EE762F2 A1F9915541020B56
49793EBC79B3258F 437540C8698F3CFA 6FBF1CAFCFFD0556
4FB05E1515AB73A7 072D43A077075292 2F22E49BAB7CA1AC
49E95D6D4CA229BF 02FE55778117F12A 5A6B612CC26CCE4A
018310DC409B26D6 1D9D5C5018F728C2 5F4C038ED12B2E41
1C587F1C13924FEF 305532286D6F295A 63FAC0D034D9F793
0101010101010101 0123456789ABCDEF 617B3A0CE8F07100
1F1F1F1F0E0E0E0E 0123456789ABCDEF DB958605F8C8C606
E0FEE0FEF1FEF1FE 0123456789ABCDEF EDBFD1C66C29CCC7
0000000000000000 FFFFFFFFFFFFFFFF 355550B2150E2451
FFFFFFFFFFFFFFFF 0000000000000000 CAAAAF4DEAF1DBAE
0123456789ABCDEF 0000000000000000 D5D44FF720683D0D
FEDCBA9876543210 FFFFFFFFFFFFFFFF 2A2BB008DF97C2F2

View File

@ -1,279 +0,0 @@
/*
* keyparity - add parity bits to key and/or change an ascii key to binary
*/
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
#include "ntp_string.h"
#include "ntp_stdlib.h"
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
/*
* 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
#define STD_PARITY_BITS 0x01010101
char *progname;
int debug;
int ntpflag = 0;
int stdflag = 0;
int asciiflag = 0;
int ntpoutflag = 0;
int gotoopt = 0;
static int parity P((u_long *));
static int decodekey P((int, char *, u_long *));
static void output P((u_long *, int));
/*
* main - parse arguments and handle options
*/
void
main(argc, argv)
int argc;
char *argv[];
{
int c;
int errflg = 0;
int keytype;
u_long key[2];
extern int ntp_optind;
extern char *ntp_optarg;
progname = argv[0];
while ((c = ntp_getopt(argc, argv, "adno:s")) != EOF)
switch (c) {
case 'a':
asciiflag = 1;
break;
case 'd':
++debug;
break;
case 'n':
ntpflag = 1;
break;
case 's':
stdflag = 1;
break;
case 'o':
if (*ntp_optarg == 'n') {
ntpoutflag = 1;
gotoopt = 1;
} else if (*ntp_optarg == 's') {
ntpoutflag = 0;
gotoopt = 1;
} else {
(void) fprintf(stderr,
"%s: output format must be `n' or `s'\n",
progname);
errflg++;
}
break;
default:
errflg++;
break;
}
if (errflg || ntp_optind == argc) {
(void) fprintf(stderr,
"usage: %s -n|-s [-a] [-o n|s] key [...]\n",
progname);
exit(2);
}
if (!ntpflag && !stdflag) {
(void) fprintf(stderr,
"%s: one of either the -n or -s flags must be specified\n",
progname);
exit(2);
}
if (ntpflag && stdflag) {
(void) fprintf(stderr,
"%s: only one of the -n and -s flags may be specified\n",
progname);
exit(2);
}
if (!gotoopt) {
if (ntpflag)
ntpoutflag = 1;
}
if (asciiflag)
keytype = KEY_TYPE_ASCII;
else if (ntpflag)
keytype = KEY_TYPE_NTP;
else
keytype = KEY_TYPE_STD;
for (; ntp_optind < argc; ntp_optind++) {
if (!decodekey(keytype, argv[ntp_optind], key)) {
(void) fprintf(stderr,
"%s: format of key %s invalid\n",
progname, argv[ntp_optind]);
exit(1);
}
(void) parity(key);
output(key, ntpoutflag);
}
exit(0);
}
/*
* parity - set parity on a key/check for odd parity
*/
static int
parity(key)
u_long *key;
{
u_long 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);
}
static int
decodekey(keytype, str, key)
int keytype;
char *str;
u_long *key;
{
u_char keybytes[8];
char *cp;
char *xdigit;
int len;
int i;
static char *hex = "0123456789abcdef";
cp = str;
len = strlen(cp);
if (len == 0)
return 0;
switch(keytype) {
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_long)(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);
}
break;
case KEY_TYPE_ASCII:
/*
* Make up key from ascii representation
*/
memset(keybytes, 0, sizeof(keybytes));
for (i = 0; i < 8 && i < len; i++)
keybytes[i] = *cp++ << 1;
key[0] = keybytes[0] << 24 | keybytes[1] << 16
| keybytes[2] << 8 | keybytes[3];
key[1] = keybytes[4] << 24 | keybytes[5] << 16
| keybytes[6] << 8 | keybytes[7];
break;
default:
/* Oh, well */
return 0;
}
return 1;
}
/*
* output - print a hex key on the standard output
*/
static void
output(key, ntpformat)
u_long *key;
int ntpformat;
{
int i;
if (ntpformat) {
for (i = 0; i < 2; i++)
key[i] = ((key[i] & ~STD_PARITY_BITS) >> 1)
| ((key[i] & STD_PARITY_BITS) << 7);
}
(void) printf("%08x%08x\n", key[0], key[1]);
}

View File

@ -1,345 +0,0 @@
/*
* makeIPFP - make fast DES IP and FP tables
*/
#include <stdio.h>
#include <sys/types.h>
#include "ntp_stdlib.h"
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
u_long IPL[256];
u_long FPL[256];
char *progname;
int debug;
static void perm P((u_char *, u_char *, u_long *, u_long *));
static void doit P((void));
/*
* main - parse arguments and handle options
*/
void
main(argc, argv)
int argc;
char *argv[];
{
int c;
int errflg = 0;
extern int ntp_optind;
extern char *ntp_optarg;
progname = argv[0];
while ((c = ntp_getopt(argc, argv, "d")) != EOF)
switch (c) {
case 'd':
++debug;
break;
default:
errflg++;
break;
}
if (errflg) {
(void) fprintf(stderr, "usage: %s [-d]\n", progname);
exit(2);
}
doit();
exit(0);
}
/*
* Initial permutation table
*/
u_char IP[64] = {
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6,
64, 56, 48, 40, 32, 24, 16, 8,
57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
61, 53, 45, 37, 29, 21, 13, 5,
63, 55, 47, 39, 31, 23, 15, 7
};
/*
* Inverse initial permutation table
*/
u_char FP[64] = {
40, 8, 48, 16, 56, 24, 64, 32,
39, 7, 47, 15, 55, 23, 63, 31,
38, 6, 46, 14, 54, 22, 62, 30,
37, 5, 45, 13, 53, 21, 61, 29,
36, 4, 44, 12, 52, 20, 60, 28,
35, 3, 43, 11, 51, 19, 59, 27,
34, 2, 42, 10, 50, 18, 58, 26,
33, 1, 41, 9, 49, 17, 57, 25
};
/*
* Bit order after the operation
*
* ((left & 0x55555555) << 1) | (right & 0x55555555)
*/
u_char IPLbits[32] = {
2, 34, 4, 36, 6, 38, 8, 40,
10, 42, 12, 44, 14, 46, 16, 48,
18, 50, 20, 52, 22, 54, 24, 56,
26, 58, 28, 60, 30, 62, 32, 64
};
/*
* Bit order after the operation
*
* (left & 0xaaaaaaaa) | ((right & 0xaaaaaaaa) >> 1)
*/
u_char IPRbits[32] = {
1, 33, 3, 35, 5, 37, 7, 39,
9, 41, 11, 43, 13, 45, 15, 47,
17, 49, 19, 51, 21, 53, 23, 55,
25, 57, 27, 59, 29, 61, 31, 63
};
/*
* Bit order after the operation
*
* ((left & 0x0f0f0f0f) << 4) | (right & 0x0f0f0f0f)
*/
u_char FPLbits[32] = {
5, 6, 7, 8, 37, 38, 39, 40,
13, 14, 15, 16, 45, 46, 47, 48,
21, 22, 23, 24, 53, 54, 55, 56,
29, 30, 31, 32, 61, 62, 63, 64
};
/*
* Bit order after the operation
*
* (left & 0xf0f0f0f0) | ((right & 0xf0f0f0f0) >> 4)
*/
u_char FPRbits[32] = {
1, 2, 3, 4, 33, 34, 35, 36,
9, 10, 11, 12, 41, 42, 43, 44,
17, 18, 19, 20, 49, 50, 51, 52,
25, 26, 27, 28, 57, 58, 59, 60
};
/*
* perm - do a permutation with the given table
*/
static void
perm(databits, permtab, leftp, rightp)
u_char *databits;
u_char *permtab;
u_long *leftp;
u_long *rightp;
{
register u_long left;
register u_long right;
register u_char *PT;
register u_char *bits;
register int i;
left = right = 0;
PT = permtab;
bits = databits;
for (i = 0; i < 32; i++) {
left <<= 1;
if (bits[PT[i]-1])
left |= 1;
}
for (i = 32; i < 64; i++) {
right <<= 1;
if (bits[PT[i]-1])
right |= 1;
}
*leftp = left;
*rightp = right;
}
/*
* doit - make up the tables
*/
static void
doit()
{
u_char bits[64];
u_long left;
u_long right;
int tabno;
int i;
int ind0, ind1, ind2, ind3;
int ind4, ind5, ind6, ind7;
int octbits;
memset((char *)bits, 0, sizeof bits);
/*
* Do the rounds for the IP table. We save the results of
* this as well as printing them. Note that this is the
* left-half table, the right half table will be identical.
*/
printf("static u_long IP[256] = {");
for (tabno = 0; tabno < 4; tabno++) {
i = tabno * 8;
ind7 = IPLbits[i] - 1;
ind6 = IPLbits[i+1] - 1;
ind5 = IPLbits[i+2] - 1;
ind4 = IPLbits[i+3] - 1;
ind3 = IPLbits[i+4] - 1;
ind2 = IPLbits[i+5] - 1;
ind1 = IPLbits[i+6] - 1;
ind0 = IPLbits[i+7] - 1;
for (octbits = 0; octbits < 256; octbits++) {
if (octbits & (1 << 7))
bits[ind7] = 1;
if (octbits & (1 << 6))
bits[ind6] = 1;
if (octbits & (1 << 5))
bits[ind5] = 1;
if (octbits & (1 << 4))
bits[ind4] = 1;
if (octbits & (1 << 3))
bits[ind3] = 1;
if (octbits & (1 << 2))
bits[ind2] = 1;
if (octbits & (1 << 1))
bits[ind1] = 1;
if (octbits & 1)
bits[ind0] = 1;
perm(bits, IP, &left, &right);
bits[ind7] = 0;
bits[ind6] = 0;
bits[ind5] = 0;
bits[ind4] = 0;
bits[ind3] = 0;
bits[ind2] = 0;
bits[ind1] = 0;
bits[ind0] = 0;
if (right != 0) {
fprintf(stderr,
"IP tabno %d oct %d right not zero\n",
tabno, octbits);
exit(1);
}
if (tabno > 0) {
if ((IPL[octbits] << tabno) != left) {
fprintf(stderr,
"IP tabno %d oct %d IP %d left %d, IP != left\n",
tabno, octbits, IPL[octbits], left);
exit (1);
}
} else {
IPL[octbits] = left;
if (octbits == 255) {
printf(" 0x%08x", left);
} else if (octbits & 0x3) {
printf(" 0x%08x,", left);
} else {
printf("\n\t0x%08x,", left);
}
}
}
if (tabno == 0)
printf("\n};\n\n");
}
/*
* Next is the FP table, in big endian order
*/
printf("#if BYTE_ORDER == LITTLE_ENDIAN\nstatic u_long FP[256] = {");
for (tabno = 3; tabno >= 0; tabno--) {
i = tabno * 8;
ind7 = FPLbits[i] - 1;
ind6 = FPLbits[i+1] - 1;
ind5 = FPLbits[i+2] - 1;
ind4 = FPLbits[i+3] - 1;
ind3 = FPLbits[i+4] - 1;
ind2 = FPLbits[i+5] - 1;
ind1 = FPLbits[i+6] - 1;
ind0 = FPLbits[i+7] - 1;
for (octbits = 0; octbits < 256; octbits++) {
if (octbits & (1 << 7))
bits[ind7] = 1;
if (octbits & (1 << 6))
bits[ind6] = 1;
if (octbits & (1 << 5))
bits[ind5] = 1;
if (octbits & (1 << 4))
bits[ind4] = 1;
if (octbits & (1 << 3))
bits[ind3] = 1;
if (octbits & (1 << 2))
bits[ind2] = 1;
if (octbits & (1 << 1))
bits[ind1] = 1;
if (octbits & 1)
bits[ind0] = 1;
perm(bits, FP, &left, &right);
bits[ind7] = 0;
bits[ind6] = 0;
bits[ind5] = 0;
bits[ind4] = 0;
bits[ind3] = 0;
bits[ind2] = 0;
bits[ind1] = 0;
bits[ind0] = 0;
if (right != 0) {
fprintf(stderr,
"FP tabno %d oct %d right not zero\n",
tabno, octbits);
exit(1);
}
if (tabno != 3) {
if ((FPL[octbits] << ((3-tabno)<<1)) != left) {
fprintf(stderr,
"FP tabno %d oct %d FP %x left %x, FP != left\n",
tabno, octbits, FPL[octbits], left);
exit (1);
}
} else {
FPL[octbits] = left;
if (octbits == 255) {
printf(" 0x%08x", left);
} else if (octbits & 0x3) {
printf(" 0x%08x,", left);
} else {
printf("\n\t0x%08x,", left);
}
}
}
if (tabno == 3)
printf("\n};\n");
}
/*
* Now reouput the FP table in order appropriate for little
* endian machines
*/
printf("#else\nstatic u_long FP[256] = {");
for (octbits = 0; octbits < 256; octbits++) {
left = ((FPL[octbits] >> 24) & 0x000000ff)
| ((FPL[octbits] >> 8) & 0x0000ff00)
| ((FPL[octbits] << 8) & 0x00ff0000)
| ((FPL[octbits] << 24) & 0xff000000);
if (octbits == 255) {
printf(" 0x%08x", left);
} else if (octbits & 0x3) {
printf(" 0x%08x,", left);
} else {
printf("\n\t0x%08x,", left);
}
}
printf("\n};\n#endif\n");
}

View File

@ -1,286 +0,0 @@
/*
* makePC1 - build custom permutted choice 1 tables
*/
#include <stdio.h>
#include <sys/types.h>
#include "ntp_stdlib.h"
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
char *progname;
int debug;
static void permute P((u_char *, u_long *, u_long *));
static void doit P((void));
/*
* main - parse arguments and handle options
*/
void
main(argc, argv)
int argc;
char *argv[];
{
int c;
int errflg = 0;
extern int ntp_optind;
extern char *ntp_optarg;
progname = argv[0];
while ((c = ntp_getopt(argc, argv, "d")) != EOF)
switch (c) {
case 'd':
++debug;
break;
default:
errflg++;
break;
}
if (errflg) {
(void) fprintf(stderr, "usage: %s [-d]\n", progname);
exit(2);
}
doit();
exit(0);
}
/*
* Permuted choice 1 table, to produce the initial C. This table
* has had 1 subtracted from it to give it a zero base.
*/
static u_char PC1_C[28] = {
56, 48, 40, 32, 24, 16, 8,
0, 57, 49, 41, 33, 25, 17,
9, 1, 58, 50, 42, 34, 26,
18, 10, 2, 59, 51, 43, 35
};
/*
* Permuted choice 1 table, to produce the initial D. Again, 1 has
* been subtracted to match C language zero base arrays.
*/
static u_char PC1_D[28] = {
62, 54, 46, 38, 30, 22, 14,
6, 61, 53, 45, 37, 29, 21,
13, 5, 60, 52, 44, 36, 28,
20, 12, 4, 27, 19, 11, 3
};
/*
* permute - produce c and d for the given bits
*/
static void
permute(bits, cp, dp)
u_char *bits;
u_long *cp;
u_long *dp;
{
register int i;
register u_long mask;
u_char c[28];
u_char d[28];
memset((char *)c, 0, sizeof c);
memset((char *)d, 0, sizeof d);
for (i = 0; i < 28; i++) {
c[i] = bits[PC1_C[i]];
d[i] = bits[PC1_D[i]];
}
mask = 0x10000000;
*cp = *dp = 0;
for (i = 0; i < 28; i++) {
mask >>= 1;
if (c[i])
*cp |= mask;
if (d[i])
*dp |= mask;
}
}
/*
* bits from the left part of the key used to form the C subkey
*/
static int lc3[4] = { 0, 8, 16, 24 };
/*
* bits from the left part of the key used to form the D subkey
*/
static int ld4[4] = { 3, 11, 19, 27 };
/*
* bits from the right part of the key used to form the C subkey
*/
static int rc4[4] = { 32, 40, 48, 56 };
/*
* bits from the right part of the key used to form the D subkey
*/
static int rd3[4] = { 36, 44, 52, 60 };
static u_long PC_CL[8];
static u_long PC_DL[16];
static u_long PC_CR[16];
static u_long PC_DR[8];
/*
* doit - compute and print the four PC1 tables
*/
static void
doit()
{
int i;
int comb;
u_long c;
u_long d;
u_char bits[64];
memset((char *)bits, 0, sizeof bits);
printf("static u_long PC1_CL[8] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 8; comb++) {
if (comb & 0x4)
bits[lc3[i]] = 1;
if (comb & 0x2)
bits[lc3[i]+1] = 1;
if (comb & 0x1)
bits[lc3[i]+2] = 1;
permute(bits, &c, &d);
bits[lc3[i]] = 0;
bits[lc3[i]+1] = 0;
bits[lc3[i]+2] = 0;
if (d != 0) {
(void) fprintf(stderr,
"Error PC_CL i %d comb %d\n", i, comb);
}
if (i == 0) {
PC_CL[comb] = c;
if ((comb & 0x3) == 0)
printf("\n\t0x%08x,", c);
else if (comb == 7)
printf(" 0x%08x\n};\n\n", c);
else
printf(" 0x%08x,", c);
} else {
if (c != PC_CL[comb] << i)
(void) fprintf(stderr,
"Error PC_CL 0x%08x c 0x%08x\n",
PC_CL[comb], c);
}
}
}
printf("static u_long PC1_DL[16] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 16; comb++) {
if (comb & 0x8)
bits[ld4[i]] = 1;
if (comb & 0x4)
bits[ld4[i]+1] = 1;
if (comb & 0x2)
bits[ld4[i]+2] = 1;
if (comb & 0x1)
bits[ld4[i]+3] = 1;
permute(bits, &c, &d);
bits[ld4[i]] = 0;
bits[ld4[i]+1] = 0;
bits[ld4[i]+2] = 0;
bits[ld4[i]+3] = 0;
if (c != 0) {
(void) fprintf(stderr,
"Error PC_DL i %d comb %d\n", i, comb);
}
if (i == 0) {
PC_DL[comb] = d;
if ((comb & 0x3) == 0)
printf("\n\t0x%08x,", d);
else if (comb == 15)
printf(" 0x%08x\n};\n\n", d);
else
printf(" 0x%08x,", d);
} else {
if (d != PC_DL[comb] << i)
(void) fprintf(stderr,
"Error PC_DL 0x%08x c 0x%08x\n",
PC_DL[comb], d);
}
}
}
printf("static u_long PC1_CR[16] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 16; comb++) {
if (comb & 0x8)
bits[rc4[i]] = 1;
if (comb & 0x4)
bits[rc4[i]+1] = 1;
if (comb & 0x2)
bits[rc4[i]+2] = 1;
if (comb & 0x1)
bits[rc4[i]+3] = 1;
permute(bits, &c, &d);
bits[rc4[i]] = 0;
bits[rc4[i]+1] = 0;
bits[rc4[i]+2] = 0;
bits[rc4[i]+3] = 0;
if (d != 0) {
(void) fprintf(stderr,
"Error PC_CR i %d comb %d\n", i, comb);
}
if (i == 0) {
PC_CR[comb] = c;
if ((comb & 0x3) == 0)
printf("\n\t0x%08x,", c);
else if (comb == 15)
printf(" 0x%08x\n};\n\n", c);
else
printf(" 0x%08x,", c);
} else {
if (c != PC_CR[comb] << i)
(void) fprintf(stderr,
"Error PC_CR 0x%08x c 0x%08x\n",
PC_CR[comb], c);
}
}
}
printf("static u_long PC1_DR[8] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 8; comb++) {
if (comb & 0x4)
bits[rd3[i]] = 1;
if (comb & 0x2)
bits[rd3[i]+1] = 1;
if (comb & 0x1)
bits[rd3[i]+2] = 1;
permute(bits, &c, &d);
bits[rd3[i]] = 0;
bits[rd3[i]+1] = 0;
bits[rd3[i]+2] = 0;
if (c != 0) {
(void) fprintf(stderr,
"Error PC_DR i %d comb %d\n", i, comb);
}
if (i == 0) {
PC_DR[comb] = d;
if ((comb & 0x3) == 0)
printf("\n\t0x%08x,", d);
else if (comb == 7)
printf(" 0x%08x\n};\n\n", d);
else
printf(" 0x%08x,", d);
} else {
if (d != PC_DR[comb] << i)
(void) fprintf(stderr,
"Error PC_DR 0x%08x c 0x%08x\n",
PC_DR[comb], d);
}
}
}
}

View File

@ -1,238 +0,0 @@
/*
* makePC2 - build custom permutted choice 2 tables
*/
#include <stdio.h>
#include <sys/types.h>
#include "ntp_stdlib.h"
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
char *progname;
int debug;
static void permc P((u_char *, u_long *));
static void permd P((u_char *, u_long *));
static void doit P((void));
/*
* main - parse arguments and handle options
*/
void
main(argc, argv)
int argc;
char *argv[];
{
int c;
int errflg = 0;
extern int ntp_optind;
extern char *ntp_optarg;
progname = argv[0];
while ((c = ntp_getopt(argc, argv, "d")) != EOF)
switch (c) {
case 'd':
++debug;
break;
default:
errflg++;
break;
}
if (errflg) {
(void) fprintf(stderr, "usage: %s [-d]\n", progname);
exit(2);
}
doit();
exit(0);
}
/*
* Permuted choice 2 table. This actually produces the low order 24
* bits of the subkey Ki from the 28 bit value of Ci. This has had
* 1 subtracted from it to give a zero base.
*/
static u_char PC2_C[24] = {
13, 16, 10, 23, 0, 4,
2, 27, 14, 5, 20, 9,
22, 18, 11, 3, 25, 7,
15, 6, 26, 19, 12, 1
};
/*
* Permuted choice 2 table, operating on the 28 Di bits to produce the
* high order 24 bits of subkey Ki. This has had 29 subtracted from
* it to give it a zero base into our D bit array.
*/
static u_char PC2_D[24] = {
12, 23, 2, 8, 18, 26,
1, 11, 22, 16, 4, 19,
15, 20, 10, 27, 5, 24,
17, 13, 21, 7, 0, 3
};
u_long masks[4] = { 0x40000000, 0x400000, 0x4000, 0x40 };
/*
* permc - permute C, producing a four byte result
*/
static void
permc(bits, resp)
u_char *bits;
u_long *resp;
{
register int part;
register int i;
register u_long mask;
u_char res[24];
memset((char *)res, 0, sizeof res);
for (i = 0; i < 24; i++) {
res[i] = bits[PC2_C[i]];
}
*resp = 0;
for (part = 0; part < 4; part++) {
mask = masks[part];
for (i = part*6; i < (part+1)*6; i++) {
mask >>= 1;
if (res[i])
*resp |= mask;
}
}
}
/*
* permd - permute D, producing a four byte result
*/
static void
permd(bits, resp)
u_char *bits;
u_long *resp;
{
register int part;
register int i;
register u_long mask;
u_char res[24];
memset((char *)res, 0, sizeof res);
for (i = 0; i < 24; i++) {
res[i] = bits[PC2_D[i]];
}
*resp = 0;
for (part = 0; part < 4; part++) {
mask = masks[part];
for (i = part*6; i < (part+1)*6; i++) {
mask >>= 1;
if (res[i])
*resp |= mask;
}
}
}
/*
* bits used for each round in C
*/
static int cbits[4][6] = {
0, 1, 2, 3, 4, 5,
6, 7, 9, 10, 11, 12,
13, 14, 15, 16, 22, 23,
18, 19, 20, 25, 26, 27
};
/*
* bits used for each round in D
*/
static int dbits[4][6] = {
0, 1, 2, 3, 4, 5,
7, 8, 10, 11, 12, 13,
15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 26, 27
};
/*
* doit - compute and print the four PC1 tables
*/
static void
doit()
{
int i;
int comb;
u_long res;
u_char bits[28];
memset((char *)bits, 0, sizeof bits);
printf("static u_long PC2_C[4][64] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 64; comb++) {
if (comb & 0x20)
bits[cbits[i][0]] = 1;
if (comb & 0x10)
bits[cbits[i][1]] = 1;
if (comb & 0x8)
bits[cbits[i][2]] = 1;
if (comb & 0x4)
bits[cbits[i][3]] = 1;
if (comb & 0x2)
bits[cbits[i][4]] = 1;
if (comb & 0x1)
bits[cbits[i][5]] = 1;
permc(bits, &res);
bits[cbits[i][0]] = 0;
bits[cbits[i][1]] = 0;
bits[cbits[i][2]] = 0;
bits[cbits[i][3]] = 0;
bits[cbits[i][4]] = 0;
bits[cbits[i][5]] = 0;
if ((comb & 0x3) == 0)
printf("\n\t0x%08x,", res);
else if (comb == 63 && i == 3)
printf(" 0x%08x\n};\n\n", res);
else if (comb == 63)
printf(" 0x%08x,\n", res);
else
printf(" 0x%08x,", res);
}
}
printf("static u_long PC2_D[4][64] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 64; comb++) {
if (comb & 0x20)
bits[dbits[i][0]] = 1;
if (comb & 0x10)
bits[dbits[i][1]] = 1;
if (comb & 0x8)
bits[dbits[i][2]] = 1;
if (comb & 0x4)
bits[dbits[i][3]] = 1;
if (comb & 0x2)
bits[dbits[i][4]] = 1;
if (comb & 0x1)
bits[dbits[i][5]] = 1;
permd(bits, &res);
bits[dbits[i][0]] = 0;
bits[dbits[i][1]] = 0;
bits[dbits[i][2]] = 0;
bits[dbits[i][3]] = 0;
bits[dbits[i][4]] = 0;
bits[dbits[i][5]] = 0;
if ((comb & 0x3) == 0)
printf("\n\t0x%08x,", res);
else if (comb == 63 && i == 3)
printf(" 0x%08x\n};\n\n", res);
else if (comb == 63)
printf(" 0x%08x,\n", res);
else
printf(" 0x%08x,", res);
}
}
}

View File

@ -1,183 +0,0 @@
/*
* makeSP - build combination S and P tables for quick DES computation
*/
#include <stdio.h>
#include <sys/types.h>
#include "ntp_stdlib.h"
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
char *progname;
int debug;
static void selperm P((int, int, u_long *));
static void doit P((void));
/*
* main - parse arguments and handle options
*/
void
main(argc, argv)
int argc;
char *argv[];
{
int c;
int errflg = 0;
extern int ntp_optind;
extern char *ntp_optarg;
progname = argv[0];
while ((c = ntp_getopt(argc, argv, "d")) != EOF)
switch (c) {
case 'd':
++debug;
break;
default:
errflg++;
break;
}
if (errflg) {
(void) fprintf(stderr, "usage: %s [-d]\n", progname);
exit(2);
}
doit();
exit(0);
}
/*
* The cipher selection function tables. These turn 6 bit data back
* into 4 bit data.
*/
u_char S[8][64] = {
14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13,
15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9,
10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12,
7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14,
2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3,
12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13,
4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12,
13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11
};
/*
* Cipher function permutation table
*/
u_char PT[32] = {
16, 7, 20, 21,
29, 12, 28, 17,
1, 15, 23, 26,
5, 18, 31, 10,
2, 8, 24, 14,
32, 27, 3, 9,
19, 13, 30, 6,
22, 11, 4, 25
};
/*
* Bits array. We keep this zeroed.
*/
u_char bits[32];
/*
* selperm - run six bit data through the given selection table, then
* through the PT table to produce a long output.
*/
static void
selperm(selnumber, sixbits, resp)
int selnumber;
int sixbits;
u_long *resp;
{
register u_long res;
register int selno;
register int i;
register int ind;
selno = selnumber;
i = sixbits;
ind = (i & 0x20) | ((i >> 1) & 0xf) | ((i & 0x1) << 4);
i = S[selno][ind];
for (ind = 0; ind < 4; ind++) {
if (i & 0x8)
bits[4*selno + ind] = 1;
i <<= 1;
}
res = 0;
for (i = 0; i < 32; i++) {
res <<= 1;
if (bits[PT[i]-1])
res |= 1;
}
*resp = res;
bits[4*selno] = 0;
bits[4*selno + 1] = 0;
bits[4*selno + 2] = 0;
bits[4*selno + 3] = 0;
}
/*
* doit - compute and print the 8 SP tables
*/
static void
doit()
{
int selno;
u_long result;
int sixbits;
memset((char *)bits, 0, sizeof bits);
printf("static u_long SP[8][64] = {");
for (selno = 0; selno < 8; selno++) {
for (sixbits = 0; sixbits < 64; sixbits++) {
selperm(selno, sixbits, &result);
if ((sixbits & 0x3) == 0)
printf("\n\t0x%08x,", result);
else if (sixbits == 63 && selno == 7)
printf(" 0x%08x\n};\n", result);
else if (sixbits == 63)
printf(" 0x%08x,\n", result);
else
printf(" 0x%08x,", result);
}
}
}

View File

@ -1,8 +0,0 @@
MD5 test suite results:
d41d8cd98f00b204e9800998ecf8427e ""
0cc175b9c0f1b6a831c399e269772661 "a"
900150983cd24fb0d6963f7d28e17f72 "abc"
f96b697d7cb7938d525a2f31aaf161d0 "message digest"
c3fcd3d76192e4007dfb496cca67e13b "abcdefghijklmnopqrstuvwxyz"
d174ab98d277d9f5a5611c2c9f419d9f "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
57edf4a22be3c955ac49da2e2107b67a "12345678901234567890123456789012345678901234567890123456789012345678901234567890"

View File

@ -1,213 +0,0 @@
/*
***********************************************************************
** md5driver.c -- sample test routines **
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
** Created: 2/16/90 RLR **
** Updated: 1/91 SRD **
** Updated: 7/91 SRD Removed file "foo" from test suite **
***********************************************************************
*/
/*
***********************************************************************
** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
** **
** RSA Data Security, Inc. makes no representations concerning **
** either the merchantability of this software or the suitability **
** of this software for any particular purpose. It is provided "as **
** is" without express or implied warranty of any kind. **
** **
** These notices must be retained in any copies of any part of this **
** documentation and/or software. **
***********************************************************************
*/
/* $FreeBSD$ */
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
#if defined(SYS_BSDI) || defined(SYS_44BSD)
#include <sys/time.h>
#endif /* SYS_BSDI */
#include "md5.h"
#ifndef MD5
#define MD5
#endif
#include "ntp_string.h"
#include "ntp_stdlib.h"
/* Prints message digest buffer in mdContext as 32 hexadecimal digits.
Order is from low-order byte to high-order byte of digest.
Each byte is printed with high-order hexadecimal digit first.
*/
static void
MDPrint (mdContext)
MD5_CTX *mdContext;
{
int i;
for (i = 0; i < 16; i++)
printf ("%02x", mdContext->digest[i]);
}
/* size of test block */
#define TEST_BLOCK_SIZE 1000
/* number of blocks to process */
#define TEST_BLOCKS 10000
/* number of test bytes = TEST_BLOCK_SIZE * TEST_BLOCKS */
static long TEST_BYTES = (long)TEST_BLOCK_SIZE * (long)TEST_BLOCKS;
/* A time trial routine, to measure the speed of MD5.
Measures wall time required to digest TEST_BLOCKS * TEST_BLOCK_SIZE
characters.
*/
static void
MDTimeTrial ()
{
MD5_CTX mdContext;
time_t endTime, startTime;
unsigned char data[TEST_BLOCK_SIZE];
unsigned int i;
/* initialize test data */
for (i = 0; i < TEST_BLOCK_SIZE; i++)
data[i] = (unsigned char)(i & 0xFF);
/* start timer */
printf ("MD5 time trial. Processing %ld characters...\n", (long)TEST_BYTES);
time (&startTime);
/* digest data in TEST_BLOCK_SIZE byte blocks */
MD5Init (&mdContext);
for (i = TEST_BLOCKS; i > 0; i--)
MD5Update (&mdContext, data, TEST_BLOCK_SIZE);
MD5Final (&mdContext);
/* stop timer, get time difference */
time (&endTime);
MDPrint (&mdContext);
printf (" is digest of test input.\n");
printf
("Seconds to process test input: %ld\n", (long)endTime-startTime);
printf
("Characters processed per second: %ld\n",
(long)(TEST_BYTES/(endTime-startTime)));
}
/* Computes the message digest for string inString.
Prints out message digest, a space, the string (in quotes) and a
carriage return.
*/
static void
MDString (inString)
char *inString;
{
MD5_CTX mdContext;
unsigned int len = strlen (inString);
MD5Init (&mdContext);
MD5Update (&mdContext, inString, len);
MD5Final (&mdContext);
MDPrint (&mdContext);
printf (" \"%s\"\n", inString);
}
/* Computes the message digest for a specified file.
Prints out message digest, a space, the file name, and a carriage
return.
*/
static void
MDFile (filename)
char *filename;
{
FILE *inFile = fopen (filename, "rb");
MD5_CTX mdContext;
int bytes;
unsigned char data[1024];
if (inFile == NULL) {
printf ("%s can't be opened.\n", filename);
return;
}
MD5Init (&mdContext);
while ((bytes = fread (data, 1, 1024, inFile)) != 0)
MD5Update (&mdContext, data, bytes);
MD5Final (&mdContext);
MDPrint (&mdContext);
printf (" %s\n", filename);
fclose (inFile);
}
/* Writes the message digest of the data from stdin onto stdout,
followed by a carriage return.
*/
static void
MDFilter ()
{
MD5_CTX mdContext;
int bytes;
unsigned char data[16];
MD5Init (&mdContext);
while ((bytes = fread (data, 1, 16, stdin)) != 0)
MD5Update (&mdContext, data, bytes);
MD5Final (&mdContext);
MDPrint (&mdContext);
printf ("\n");
}
/* Runs a standard suite of test data.
*/
static void
MDTestSuite ()
{
printf ("MD5 test suite results:\n");
MDString ("");
MDString ("a");
MDString ("abc");
MDString ("message digest");
MDString ("abcdefghijklmnopqrstuvwxyz");
MDString
("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
MDString
("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
}
int
main (argc, argv)
int argc;
char *argv[];
{
int i;
/* For each command line argument in turn:
** filename -- prints message digest and name of file
** -sstring -- prints message digest and contents of string
** -t -- prints time trial statistics for 10M
characters
** -x -- execute a standard suite of test data
** (no args) -- writes messages digest of stdin onto stdout
*/
if (argc == 1)
MDFilter ();
else
for (i = 1; i < argc; i++)
if (argv[i][0] == '-' && argv[i][1] == 's')
MDString (argv[i] + 2);
else if (strcmp (argv[i], "-t") == 0)
MDTimeTrial ();
else if (strcmp (argv[i], "-x") == 0)
MDTestSuite ();
else MDFile (argv[i]);
}
/*
***********************************************************************
** End of md5driver.c **
******************************** (cut) ********************************
*/

View File

@ -1,167 +0,0 @@
/*
* mkrandkeys - make a key file for xntpd with some quite random keys
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "ntp_stdlib.h"
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
char *progname;
int debug;
u_long keydata[2];
int std = 1; /* DES standard key format */
u_char dokey[16] = { 0 };
static void rand_data P((u_long *));
/*
* main - parse arguments and handle options
*/
void
main(argc, argv)
int argc;
char *argv[];
{
int c;
int i;
int j;
int errflg = 0;
int numkeys;
u_long tmp;
char *passwd;
extern int ntp_optind;
extern char *ntp_optarg;
extern char *getpass();
numkeys = 0;
progname = argv[0];
passwd = NULL;
while ((c = ntp_getopt(argc, argv, "dnp:s")) != EOF)
switch (c) {
case 'd':
++debug;
break;
case 'n':
std = 0;
break;
case 'p':
passwd = ntp_optarg;
break;
case 's':
std = 1;
break;
default:
errflg++;
break;
}
numkeys = 0;
for (; !errflg && ntp_optind < argc; ntp_optind++) {
c = atoi(argv[ntp_optind]);
if (c <= 0 || c > 15) {
(void) fprintf(stderr, "%s: invalid key number `%s'\n",
progname, argv[ntp_optind]);
exit(2);
}
dokey[c] = 1;
numkeys++;
}
if (errflg || numkeys == 0) {
(void) fprintf(stderr,
"usage: %s [-ns] [-p seed] key# [key# ...]\n",
progname);
exit(2);
}
while (passwd == 0 || *passwd == '\0') {
passwd = getpass("Seed: ");
if (*passwd == '\0') {
(void) fprintf(stderr,
"better use a better seed than that\n");
}
}
keydata[0] = keydata[1] = 0;
for (i = 0; i < 8 && *passwd != '\0'; i++) {
keydata[i/4] |= ((((u_long)(*passwd))&0xff)<<(1+((3-(i%4))*8)));
passwd++;
}
for (i = 1; i <= 15; i++) {
if (dokey[i]) {
for (c = 0, tmp = 0; c < 32; c += 4)
tmp |= (i << c);
keydata[0] ^= tmp;
keydata[1] ^= tmp;
rand_data(keydata);
DESauth_parity(keydata);
if (std) {
(void)printf("%-2d S\t%08x%08x\n",
i, keydata[0], keydata[1]);
} else {
for (j = 0; j < 2; j++) {
keydata[j]
= ((keydata[j] & 0xfefefefe) >> 1)
| ((keydata[j] & 0x01010101) << 7);
}
(void)printf("%-2d N\t%08x%08x\n",
i, keydata[0], keydata[1]);
}
}
}
exit(0);
}
char *volatile_file[] = {
"/bin/echo",
"/bin/sh",
"/bin/cat",
"/bin/ls",
"/bin/stty",
"/bin/date",
"/bin/cat",
"/bin/cc",
"/etc/motd",
"/etc/utmp",
"/dev/kmem",
"/dev/null",
"",
};
#define NEXT(X) (0x1e1f2f2d*(X) + 0x361962e9)
static void
rand_data(data)
u_long *data;
{
register i;
struct stat buf;
extern long time();
char ekeys[128], dkeys[128];
*data ^= 0x9662f394;
*(data+1) ^= 0x9f17c55f;
DESauth_subkeys(data, ekeys, dkeys);
*data ^= NEXT(getpid() + (getuid() << 16));
*(data+1) ^= NEXT(time((long *)0));
DESauth_des(data, ekeys);
for (i = 0; strlen(volatile_file[i]); i++) {
if (stat(volatile_file[i], &buf) == -1)
continue;
if (i & 1) {
*data ^= NEXT(buf.st_atime);
*(data+1) ^= NEXT(buf.st_mtime);
} else {
*data ^= NEXT(buf.st_mtime);
*(data+1) ^= NEXT(buf.st_atime);
}
DESauth_des(data, ekeys);
}
}

View File

@ -1,361 +0,0 @@
/*
* makeIPFP - make fast DES IP and FP tables
*
* This is an older version which generated tables half the size of
* the current version, but which took about double the CPU time to
* compute permutations from these tables. Since the CPU spent on the
* permutations is small compared to the CPU spent in the cipher code,
* I may go back to the smaller tables to save the space some day.
*/
#include <stdio.h>
#include <sys/types.h>
#include "ntp_stdlib.h"
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
u_long IPL[8][16];
u_long FPL[8][16];
char *progname;
int debug;
static void perm P((u_char *, u_char *, u_long *, u_long *));
static void doit P((void));
/*
* main - parse arguments and handle options
*/
void
main(argc, argv)
int argc;
char *argv[];
{
int c;
int errflg = 0;
extern int ntp_optind;
extern char *ntp_optarg;
progname = argv[0];
while ((c = ntp_getopt(argc, argv, "d")) != EOF)
switch (c) {
case 'd':
++debug;
break;
default:
errflg++;
break;
}
if (errflg) {
(void) fprintf(stderr, "usage: %s [-d]\n", progname);
exit(2);
}
doit();
exit(0);
}
/*
* Initial permutation table
*/
u_char IP[64] = {
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6,
64, 56, 48, 40, 32, 24, 16, 8,
57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
61, 53, 45, 37, 29, 21, 13, 5,
63, 55, 47, 39, 31, 23, 15, 7
};
/*
* Inverse initial permutation table
*/
u_char FP[64] = {
40, 8, 48, 16, 56, 24, 64, 32,
39, 7, 47, 15, 55, 23, 63, 31,
38, 6, 46, 14, 54, 22, 62, 30,
37, 5, 45, 13, 53, 21, 61, 29,
36, 4, 44, 12, 52, 20, 60, 28,
35, 3, 43, 11, 51, 19, 59, 27,
34, 2, 42, 10, 50, 18, 58, 26,
33, 1, 41, 9, 49, 17, 57, 25
};
/*
* Bit order after the operation
*
* ((left & 0x55555555) << 1) | (right & 0x55555555)
*/
u_char IPLbits[32] = {
2, 34, 4, 36, 6, 38, 8, 40,
10, 42, 12, 44, 14, 46, 16, 48,
18, 50, 20, 52, 22, 54, 24, 56,
26, 58, 28, 60, 30, 62, 32, 64
};
/*
* Bit order after the operation
*
* (left & 0xaaaaaaaa) | ((right & 0xaaaaaaaa) >> 1)
*/
u_char IPRbits[32] = {
1, 33, 3, 35, 5, 37, 7, 39,
9, 41, 11, 43, 13, 45, 15, 47,
17, 49, 19, 51, 21, 53, 23, 55,
25, 57, 27, 59, 29, 61, 31, 63
};
/*
* Bit order after the operation
*
* ((left & 0x0f0f0f0f) << 4) | (right & 0x0f0f0f0f)
*/
u_char FPLbits[32] = {
5, 6, 7, 8, 37, 38, 39, 40,
13, 14, 15, 16, 45, 46, 47, 48,
21, 22, 23, 24, 53, 54, 55, 56,
29, 30, 31, 32, 61, 62, 63, 64
};
/*
* Bit order after the operation
*
* (left & 0xf0f0f0f0) | ((right & 0xf0f0f0f0) >> 4)
*/
u_char FPRbits[32] = {
1, 2, 3, 4, 33, 34, 35, 36,
9, 10, 11, 12, 41, 42, 43, 44,
17, 18, 19, 20, 49, 50, 51, 52,
25, 26, 27, 28, 57, 58, 59, 60
};
/*
* perm - do a permutation with the given table
*/
static void
perm(databits, permtab, leftp, rightp)
u_char *databits;
u_char *permtab;
u_long *leftp;
u_long *rightp;
{
register u_long left;
register u_long right;
register u_char *PT;
register u_char *bits;
register int i;
left = right = 0;
PT = permtab;
bits = databits;
for (i = 0; i < 32; i++) {
left <<= 1;
if (bits[PT[i]-1])
left |= 1;
}
for (i = 32; i < 64; i++) {
right <<= 1;
if (bits[PT[i]-1])
right |= 1;
}
*leftp = left;
*rightp = right;
}
/*
* doit - make up the tables
*/
static void
doit()
{
u_char bits[64];
u_long left;
u_long right;
int tabno;
int i;
int ind0, ind1, ind2, ind3;
int quadbits;
memset((char *)bits, 0, sizeof bits);
/*
* Do the rounds for the IPL table. We save the results of
* this as well as printing them. Note that this is the
* left-half table.
*/
printf("static u_long IP[8][16] = {");
for (tabno = 0; tabno < 8; tabno++) {
i = tabno * 4;
ind3 = IPLbits[i] - 1;
ind2 = IPLbits[i+1] - 1;
ind1 = IPLbits[i+2] - 1;
ind0 = IPLbits[i+3] - 1;
for (quadbits = 0; quadbits < 16; quadbits++) {
if (quadbits & (1 << 3))
bits[ind3] = 1;
if (quadbits & (1 << 2))
bits[ind2] = 1;
if (quadbits & (1 << 1))
bits[ind1] = 1;
if (quadbits & 1)
bits[ind0] = 1;
perm(bits, IP, &left, &right);
bits[ind3] = 0;
bits[ind2] = 0;
bits[ind1] = 0;
bits[ind0] = 0;
if (right != 0) {
fprintf(stderr,
"IPL tabno %d quad %d right not zero\n",
tabno, quadbits);
exit(1);
}
IPL[tabno][quadbits] = left;
if (quadbits == 15 && tabno == 7) {
printf(" 0x%08x", left);
} else if (quadbits & 0x3) {
printf(" 0x%08x,", left);
} else {
printf("\n\t0x%08x,", left);
}
}
if (tabno == 7)
printf("\n};\n");
printf("\n");
}
/*
* Compute the right half of the same table. I noticed this table
* was the same as the previous one, just by luck, so we don't
* actually have to do this. Do it anyway just for a check.
*/
for (tabno = 0; tabno < 8; tabno++) {
i = tabno * 4;
ind3 = IPRbits[i] - 1;
ind2 = IPRbits[i+1] - 1;
ind1 = IPRbits[i+2] - 1;
ind0 = IPRbits[i+3] - 1;
for (quadbits = 0; quadbits < 16; quadbits++) {
if (quadbits & (1 << 3))
bits[ind3] = 1;
if (quadbits & (1 << 2))
bits[ind2] = 1;
if (quadbits & (1 << 1))
bits[ind1] = 1;
if (quadbits & 1)
bits[ind0] = 1;
perm(bits, IP, &left, &right);
bits[ind3] = 0;
bits[ind2] = 0;
bits[ind1] = 0;
bits[ind0] = 0;
if (left != 0) {
fprintf(stderr,
"IPR tabno %d quad %d left not zero\n",
tabno, quadbits);
exit(1);
}
if (right != IPL[tabno][quadbits]) {
fprintf(stderr,
"IPR tabno %d quad %d: 0x%08x not same as 0x%08x\n",
tabno, quadbits, right,IPL[tabno][quadbits]);
exit(1);
}
}
}
/*
* Next are the FP tables
*/
printf("static u_long FP[8][16] = {");
for (tabno = 0; tabno < 8; tabno++) {
i = tabno * 4;
ind3 = FPLbits[i] - 1;
ind2 = FPLbits[i+1] - 1;
ind1 = FPLbits[i+2] - 1;
ind0 = FPLbits[i+3] - 1;
for (quadbits = 0; quadbits < 16; quadbits++) {
if (quadbits & (1 << 3))
bits[ind3] = 1;
if (quadbits & (1 << 2))
bits[ind2] = 1;
if (quadbits & (1 << 1))
bits[ind1] = 1;
if (quadbits & 1)
bits[ind0] = 1;
perm(bits, FP, &left, &right);
bits[ind3] = 0;
bits[ind2] = 0;
bits[ind1] = 0;
bits[ind0] = 0;
if (right != 0) {
fprintf(stderr,
"FPL tabno %d quad %d right not zero\n",
tabno, quadbits);
exit(1);
}
FPL[tabno][quadbits] = left;
if (quadbits == 15 && tabno == 7) {
printf(" 0x%08x", left);
} else if (quadbits & 0x3) {
printf(" 0x%08x,", left);
} else {
printf("\n\t0x%08x,", left);
}
}
if (tabno == 7)
printf("\n};");
printf("\n");
}
/*
* Right half of same set of tables. This was symmetric too.
* Amazing!
*/
for (tabno = 0; tabno < 8; tabno++) {
i = tabno * 4;
ind3 = FPRbits[i] - 1;
ind2 = FPRbits[i+1] - 1;
ind1 = FPRbits[i+2] - 1;
ind0 = FPRbits[i+3] - 1;
for (quadbits = 0; quadbits < 16; quadbits++) {
if (quadbits & (1 << 3))
bits[ind3] = 1;
if (quadbits & (1 << 2))
bits[ind2] = 1;
if (quadbits & (1 << 1))
bits[ind1] = 1;
if (quadbits & 1)
bits[ind0] = 1;
perm(bits, FP, &left, &right);
bits[ind3] = 0;
bits[ind2] = 0;
bits[ind1] = 0;
bits[ind0] = 0;
if (left != 0) {
fprintf(stderr,
"FPR tabno %d quad %d left not zero\n",
tabno, quadbits);
exit(1);
}
if (right != FPL[tabno][quadbits]) {
fprintf(stderr,
"FPR tabno %d quad %d: 0x%08x not same as 0x%08x\n",
tabno, quadbits, right,FPL[tabno][quadbits]);
exit(1);
}
}
}
}

View File

@ -1,2 +0,0 @@
odin/1000000: 0.000145
idavolde/1000000: 0.000451

View File

@ -1,156 +0,0 @@
/*
* This file, and the certdata file, shamelessly stolen
* from Phil Karn's DES implementation.
*
* This version uses the standard Unix setkey() and encrypt()
* routines to do the encryption.
*/
#include <stdio.h>
#include <sys/types.h>
#include "ntp_stdlib.h"
static void get8 P((U_LONG *));
static void put8 P((U_LONG *));
static void do_setkey P((U_LONG *));
static void do_crypt P((U_LONG *, int));
void
main()
{
U_LONG key[2], plain[2], cipher[2], answer[2];
int i;
int test;
int fail;
for(test=0;!feof(stdin);test++){
get8(key);
do_setkey(key);
printf(" K: "); put8(key);
get8(plain);
printf(" P: "); put8(plain);
get8(answer);
printf(" C: "); put8(answer);
for(i=0;i<2;i++)
cipher[i] = plain[i];
do_crypt(cipher, 0);
for(i=0;i<2;i++)
if(cipher[i] != answer[i])
break;
fail = 0;
if(i != 2){
printf(" Encrypt FAIL");
fail++;
}
do_crypt(cipher, 1);
for(i=0;i<2;i++)
if(cipher[i] != plain[i])
break;
if(i != 2){
printf(" Decrypt FAIL");
fail++;
}
if(fail == 0)
printf(" OK");
printf("\n");
}
}
static void
get8(lp)
U_LONG *lp;
{
int t;
U_LONG l[2];
int i;
l[0] = l[1] = 0L;
for(i=0;i<8;i++){
scanf("%2x",&t);
if(feof(stdin))
exit(0);
l[i/4] <<= 8;
l[i/4] |= (U_LONG)(t & 0xff);
}
*lp = l[0];
*(lp+1) = l[1];
}
static void
put8(lp)
U_LONG *lp;
{
int i;
for(i=0;i<2;i++){
printf("%08x",*lp++);
}
}
static void
do_setkey(key)
U_LONG *key;
{
int j;
register int i;
register char *kb;
register U_LONG *kp;
char keybits[64];
kb = keybits;
kp = key;
for (j = 0; j < 2; j++) {
for (i = 0; i < 32; i++) {
if (*kp & (1<<(31-i)))
*kb++ = 1;
else
*kb++ = 0;
}
kp++;
}
setkey(keybits);
}
static void
do_crypt(data, edflag)
U_LONG *data;
int edflag;
{
int j;
register int i;
register char *bp;
register U_LONG *dp;
char block[64];
bp = block;
dp = data;
for (j = 0; j < 2; j++) {
for (i = 0; i < 32; i++) {
if (*dp & (1<<(31-i)))
*bp++ = 1;
else
*bp++ = 0;
}
dp++;
}
encrypt(block, edflag);
bp = block;
dp = data;
for (j = 0; j < 2; j++) {
*dp = 0;
for (i = 0; i < 32; i++) {
if (*bp++)
*dp |= 1<<(31-i);
}
dp++;
}
}

View File

@ -1,16 +0,0 @@
#
# $FreeBSD$
#
PROG= propdelay
DPADD= ${LIBNTP} ${LIBM}
LDADD= ${LIBNTP} -lm
SRCS= propdelay.c
NOMAN=
install:
CLEANFILES+= chutest clktest chutest.o clktest.o
.include <bsd.prog.mk>

View File

@ -1,31 +0,0 @@
README file for directory ./clockstuff of the NTP Version 3 distribution
This directory contains the sources for utility programs designed to
support radio clocks. The chutest.c and clktest.c are desgined to
test the chu_clk and tty_clk line disciplines and STREAMS modules in
the ../kernel directory.
These files have been modified to work with either the line disciplines
or the STREAMS modules. Be sure to define -DSTREAM if appropriate.
These are random bits of things written to help with clocks. You can
make things in here by typing one or more of:
make propdelay (or `make')
make chutest
make clktest
Propdelay computes high frequency propagation delays, given the
longitude and latitude of the transmitter and receiver. Use
this for WWV/H and CHU. Don't use it for WWVB (the computation
is easier for that).
Chutest can be used to input and process data from a CHU modem
attached to a serial port. It will use the CHU line discipline
(if installed), or raw mode otherwise. This was used to test
out the initial reduction algorithms, and may not be up to date.
Clktest can be used to test the clock line discipline (CLKLDISC,
it must be available), and to take a look at radio clocks attached to a
serial port.

View File

@ -1,798 +0,0 @@
/* chutest.c,v 3.1 1993/07/06 01:05:21 jbj Exp
* chutest - test the CHU clock
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/file.h>
#include <sgtty.h>
#include "../include/ntp_fp.h"
#include "../include/ntp.h"
#include "../include/ntp_unixtime.h"
#ifdef STREAM
#include <sys/chudefs.h>
#include <stropts.h>
#endif
#ifdef CHULDISC
#include <sys/chudefs.h>
#endif
#ifndef CHULDISC
#ifndef STREAM
#define NCHUCHARS (10)
struct chucode {
u_char codechars[NCHUCHARS]; /* code characters */
u_char ncodechars; /* number of code characters */
u_char chustatus; /* not used currently */
struct timeval codetimes[NCHUCHARS]; /* arrival times */
};
#endif
#endif
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
char *progname;
int debug;
int dofilter = 0; /* set to 1 when we should run filter algorithm */
int showtimes = 0; /* set to 1 when we should show char arrival times */
int doprocess = 0; /* set to 1 when we do processing analogous to driver */
#ifdef CHULDISC
int usechuldisc = 0; /* set to 1 when CHU line discipline should be used */
#endif
#ifdef STREAM
int usechuldisc = 0; /* set to 1 when CHU line discipline should be used */
#endif
struct timeval lasttv;
struct chucode chudata;
extern u_long ustotslo[];
extern u_long ustotsmid[];
extern u_long ustotshi[];
/*
* main - parse arguments and handle options
*/
main(argc, argv)
int argc;
char *argv[];
{
int c;
int errflg = 0;
extern int ntp_optind;
extern char *ntp_optarg;
void init_chu();
progname = argv[0];
while ((c = ntp_getopt(argc, argv, "cdfpt")) != EOF)
switch (c) {
case 'c':
#ifdef STREAM
usechuldisc = 1;
break;
#endif
#ifdef CHULDISC
usechuldisc = 1;
break;
#endif
#ifndef STREAM
#ifndef CHULDISC
(void) fprintf(stderr,
"%s: CHU line discipline not available on this machine\n",
progname);
exit(2);
#endif
#endif
case 'd':
++debug;
break;
case 'f':
dofilter = 1;
break;
case 'p':
doprocess = 1;
case 't':
showtimes = 1;
break;
default:
errflg++;
break;
}
if (errflg || ntp_optind+1 != argc) {
#ifdef STREAM
(void) fprintf(stderr, "usage: %s [-dft] tty_device\n",
progname);
#endif
#ifdef CHULDISC
(void) fprintf(stderr, "usage: %s [-dft] tty_device\n",
progname);
#endif
#ifndef STREAM
#ifndef CHULDISC
(void) fprintf(stderr, "usage: %s [-cdft] tty_device\n",
progname);
#endif
#endif
exit(2);
}
(void) gettimeofday(&lasttv, (struct timezone *)0);
c = openterm(argv[ntp_optind]);
init_chu();
#ifdef STREAM
if (usechuldisc)
process_ldisc(c);
else
#endif
#ifdef CHULDISC
if (usechuldisc)
process_ldisc(c);
else
#endif
process_raw(c);
/*NOTREACHED*/
}
/*
* openterm - open a port to the CHU clock
*/
int
openterm(dev)
char *dev;
{
int s;
struct sgttyb ttyb;
if (debug)
(void) fprintf(stderr, "Doing open...");
if ((s = open(dev, O_RDONLY, 0777)) < 0)
error("open(%s)", dev, "");
if (debug)
(void) fprintf(stderr, "open okay\n");
if (debug)
(void) fprintf(stderr, "Setting exclusive use...");
if (ioctl(s, TIOCEXCL, (char *)0) < 0)
error("ioctl(TIOCEXCL)", "", "");
if (debug)
(void) fprintf(stderr, "done\n");
ttyb.sg_ispeed = ttyb.sg_ospeed = B300;
ttyb.sg_erase = ttyb.sg_kill = 0;
ttyb.sg_flags = EVENP|ODDP|RAW;
if (debug)
(void) fprintf(stderr, "Setting baud rate et al...");
if (ioctl(s, TIOCSETP, (char *)&ttyb) < 0)
error("ioctl(TIOCSETP, raw)", "", "");
if (debug)
(void) fprintf(stderr, "done\n");
#ifdef CHULDISC
if (usechuldisc) {
int ldisc;
if (debug)
(void) fprintf(stderr, "Switching to CHU ldisc...");
ldisc = CHULDISC;
if (ioctl(s, TIOCSETD, (char *)&ldisc) < 0)
error("ioctl(TIOCSETD, CHULDISC)", "", "");
if (debug)
(void) fprintf(stderr, "okay\n");
}
#endif
#ifdef STREAM
if (usechuldisc) {
if (debug)
(void) fprintf(stderr, "Poping off streams...");
while (ioctl(s, I_POP, 0) >=0) ;
if (debug)
(void) fprintf(stderr, "okay\n");
if (debug)
(void) fprintf(stderr, "Pushing CHU stream...");
if (ioctl(s, I_PUSH, "chu") < 0)
error("ioctl(I_PUSH, \"chu\")", "", "");
if (debug)
(void) fprintf(stderr, "okay\n");
}
#endif
return s;
}
/*
* process_raw - process characters in raw mode
*/
process_raw(s)
int s;
{
u_char c;
int n;
struct timeval tv;
struct timeval difftv;
while ((n = read(s, &c, sizeof(char))) > 0) {
(void) gettimeofday(&tv, (struct timezone *)0);
if (dofilter)
raw_filter((unsigned int)c, &tv);
else {
difftv.tv_sec = tv.tv_sec - lasttv.tv_sec;
difftv.tv_usec = tv.tv_usec - lasttv.tv_usec;
if (difftv.tv_usec < 0) {
difftv.tv_sec--;
difftv.tv_usec += 1000000;
}
(void) printf("%02x\t%lu.%06lu\t%lu.%06lu\n",
c, tv.tv_sec, tv.tv_usec, difftv.tv_sec,
difftv.tv_usec);
lasttv = tv;
}
}
if (n == 0) {
(void) fprintf(stderr, "%s: zero returned on read\n", progname);
exit(1);
} else
error("read()", "", "");
}
/*
* raw_filter - run the line discipline filter over raw data
*/
raw_filter(c, tv)
unsigned int c;
struct timeval *tv;
{
static struct timeval diffs[10] = { 0 };
struct timeval diff;
l_fp ts;
void chufilter();
if ((c & 0xf) > 9 || ((c>>4)&0xf) > 9) {
if (debug)
(void) fprintf(stderr,
"character %02x failed BCD test\n");
chudata.ncodechars = 0;
return;
}
if (chudata.ncodechars > 0) {
diff.tv_sec = tv->tv_sec
- chudata.codetimes[chudata.ncodechars].tv_sec;
diff.tv_usec = tv->tv_usec
- chudata.codetimes[chudata.ncodechars].tv_usec;
if (diff.tv_usec < 0) {
diff.tv_sec--;
diff.tv_usec += 1000000;
} /*
if (diff.tv_sec != 0 || diff.tv_usec > 900000) {
if (debug)
(void) fprintf(stderr,
"character %02x failed time test\n");
chudata.ncodechars = 0;
return;
} */
}
chudata.codechars[chudata.ncodechars] = c;
chudata.codetimes[chudata.ncodechars] = *tv;
if (chudata.ncodechars > 0)
diffs[chudata.ncodechars] = diff;
if (++chudata.ncodechars == 10) {
if (doprocess) {
TVTOTS(&chudata.codetimes[NCHUCHARS-1], &ts);
ts.l_ui += JAN_1970;
chufilter(&chudata, &chudata.codetimes[NCHUCHARS-1]);
} else {
register int i;
for (i = 0; i < chudata.ncodechars; i++) {
(void) printf("%x%x\t%lu.%06lu\t%lu.%06lu\n",
chudata.codechars[i] & 0xf,
(chudata.codechars[i] >>4 ) & 0xf,
chudata.codetimes[i].tv_sec,
chudata.codetimes[i].tv_usec,
diffs[i].tv_sec, diffs[i].tv_usec);
}
}
chudata.ncodechars = 0;
}
}
/* #ifdef CHULDISC*/
/*
* process_ldisc - process line discipline
*/
process_ldisc(s)
int s;
{
struct chucode chu;
int n;
register int i;
struct timeval diff;
l_fp ts;
void chufilter();
while ((n = read(s, (char *)&chu, sizeof chu)) > 0) {
if (n != sizeof chu) {
(void) fprintf(stderr, "Expected %d, got %d\n",
sizeof chu, n);
continue;
}
if (doprocess) {
TVTOTS(&chu.codetimes[NCHUCHARS-1], &ts);
ts.l_ui += JAN_1970;
chufilter(&chu, &ts);
} else {
for (i = 0; i < NCHUCHARS; i++) {
if (i == 0)
diff.tv_sec = diff.tv_usec = 0;
else {
diff.tv_sec = chu.codetimes[i].tv_sec
- chu.codetimes[i-1].tv_sec;
diff.tv_usec = chu.codetimes[i].tv_usec
- chu.codetimes[i-1].tv_usec;
if (diff.tv_usec < 0) {
diff.tv_sec--;
diff.tv_usec += 1000000;
}
}
(void) printf("%x%x\t%lu.%06lu\t%lu.%06lu\n",
chu.codechars[i] & 0xf, (chu.codechars[i]>>4)&0xf,
chu.codetimes[i].tv_sec, chu.codetimes[i].tv_usec,
diff.tv_sec, diff.tv_usec);
}
}
}
if (n == 0) {
(void) fprintf(stderr, "%s: zero returned on read\n", progname);
exit(1);
} else
error("read()", "", "");
}
/*#endif*/
/*
* error - print an error message
*/
error(fmt, s1, s2)
char *fmt;
char *s1;
char *s2;
{
(void) fprintf(stderr, "%s: ", progname);
(void) fprintf(stderr, fmt, s1, s2);
(void) fprintf(stderr, ": ");
perror("");
exit(1);
}
/*
* Definitions
*/
#define MAXUNITS 4 /* maximum number of CHU units permitted */
#define CHUDEV "/dev/chu%d" /* device we open. %d is unit number */
#define NCHUCODES 9 /* expect 9 CHU codes per minute */
/*
* When CHU is operating optimally we want the primary clock distance
* to come out at 300 ms. Thus, peer.distance in the CHU peer structure
* is set to 290 ms and we compute delays which are at least 10 ms long.
* The following are 290 ms and 10 ms expressed in u_fp format
*/
#define CHUDISTANCE 0x00004a3d
#define CHUBASEDELAY 0x0000028f
/*
* To compute a quality for the estimate (a pseudo delay) we add a
* fixed 10 ms for each missing code in the minute and add to this
* the sum of the differences between the remaining offsets and the
* estimated sample offset.
*/
#define CHUDELAYPENALTY 0x0000028f
/*
* Other constant stuff
*/
#define CHUPRECISION (-9) /* what the heck */
#define CHUREFID "CHU\0"
/*
* Default fudge factors
*/
#define DEFPROPDELAY 0x00624dd3 /* 0.0015 seconds, 1.5 ms */
#define DEFFILTFUDGE 0x000d1b71 /* 0.0002 seconds, 200 us */
/*
* 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))
/*
* Constants for use when multiplying by 0.1. ZEROPTONE is 0.1
* as an l_fp fraction, NZPOBITS is the number of significant bits
* in ZEROPTONE.
*/
#define ZEROPTONE 0x1999999a
#define NZPOBITS 29
/*
* The CHU table. This gives the expected time of arrival of each
* character after the on-time second and is computed as follows:
* The CHU time code is sent at 300 bps. Your average UART will
* synchronize at the edge of the start bit and will consider the
* character complete at the center of the first stop bit, i.e.
* 0.031667 ms later. Thus the expected time of each interrupt
* is the start bit time plus 0.031667 seconds. These times are
* in chutable[]. To this we add such things as propagation delay
* and delay fudge factor.
*/
#define CHARDELAY 0x081b4e80
static u_long chutable[NCHUCHARS] = {
0x2147ae14 + CHARDELAY, /* 0.130 (exactly) */
0x2ac08312 + CHARDELAY, /* 0.167 (exactly) */
0x34395810 + CHARDELAY, /* 0.204 (exactly) */
0x3db22d0e + CHARDELAY, /* 0.241 (exactly) */
0x472b020c + CHARDELAY, /* 0.278 (exactly) */
0x50a3d70a + CHARDELAY, /* 0.315 (exactly) */
0x5a1cac08 + CHARDELAY, /* 0.352 (exactly) */
0x63958106 + CHARDELAY, /* 0.389 (exactly) */
0x6d0e5604 + CHARDELAY, /* 0.426 (exactly) */
0x76872b02 + CHARDELAY, /* 0.463 (exactly) */
};
/*
* Keep the fudge factors separately so they can be set even
* when no clock is configured.
*/
static l_fp propagation_delay;
static l_fp fudgefactor;
static l_fp offset_fudge;
/*
* We keep track of the start of the year, watching for changes.
* We also keep track of whether the year is a leap year or not.
* All because stupid CHU doesn't include the year in the time code.
*/
static u_long yearstart;
/*
* Imported from the timer module
*/
extern u_long current_time;
extern struct event timerqueue[];
/*
* Time conversion tables imported from the library
*/
extern u_long ustotslo[];
extern u_long ustotsmid[];
extern u_long ustotshi[];
/*
* init_chu - initialize internal chu driver data
*/
void
init_chu()
{
/*
* Initialize fudge factors to default.
*/
propagation_delay.l_ui = 0;
propagation_delay.l_uf = DEFPROPDELAY;
fudgefactor.l_ui = 0;
fudgefactor.l_uf = DEFFILTFUDGE;
offset_fudge = propagation_delay;
L_ADD(&offset_fudge, &fudgefactor);
yearstart = 0;
}
void
chufilter(chuc, rtime)
struct chucode *chuc;
l_fp *rtime;
{
register int i;
register u_long date_ui;
register u_long tmp;
register u_char *code;
int isneg;
int imin;
int imax;
u_long reftime;
l_fp off[NCHUCHARS];
l_fp ts;
int day, hour, minute, second;
static u_char lastcode[NCHUCHARS];
extern u_long calyearstart();
extern char *mfptoa();
void chu_process();
extern char *prettydate();
/*
* We'll skip the checks made in the kernel, but assume they've
* been done. This means that all characters are BCD and
* the intercharacter spacing isn't unreasonable.
*/
/*
* print the code
*/
for (i = 0; i < NCHUCHARS; i++)
printf("%c%c", (chuc->codechars[i] & 0xf) + '0',
((chuc->codechars[i]>>4) & 0xf) + '0');
printf("\n");
/*
* Format check. Make sure the two halves match.
*/
for (i = 0; i < NCHUCHARS/2; i++)
if (chuc->codechars[i] != chuc->codechars[i+(NCHUCHARS/2)]) {
(void) printf("Bad format, halves don't match\n");
return;
}
/*
* Break out the code into the BCD nibbles. Only need to fiddle
* with the first half since both are identical. Note the first
* BCD character is the low order nibble, the second the high order.
*/
code = lastcode;
for (i = 0; i < NCHUCHARS/2; i++) {
*code++ = chuc->codechars[i] & 0xf;
*code++ = (chuc->codechars[i] >> 4) & 0xf;
}
/*
* If the first nibble isn't a 6, we're up the creek
*/
code = lastcode;
if (*code++ != 6) {
(void) printf("Bad format, no 6 at start\n");
return;
}
/*
* Collect the day, the hour, the minute and the second.
*/
day = *code++;
day = MULBY10(day) + *code++;
day = MULBY10(day) + *code++;
hour = *code++;
hour = MULBY10(hour) + *code++;
minute = *code++;
minute = MULBY10(minute) + *code++;
second = *code++;
second = MULBY10(second) + *code++;
/*
* Sanity check the day and time. Note that this
* only occurs on the 31st through the 39th second
* of the minute.
*/
if (day < 1 || day > 366
|| hour > 23 || minute > 59
|| second < 31 || second > 39) {
(void) printf("Failed date sanity check: %d %d %d %d\n",
day, hour, minute, second);
return;
}
/*
* Compute seconds into the year.
*/
tmp = (u_long)(MULBY24((day-1)) + hour); /* hours */
tmp = MULBY60(tmp) + (u_long)minute; /* minutes */
tmp = MULBY60(tmp) + (u_long)second; /* seconds */
/*
* Now the fun begins. We demand that the received time code
* be within CLOCK_WAYTOOBIG 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_ui = tmp + yearstart;
if (date_ui < (rtime->l_ui + CLOCK_WAYTOOBIG)
&& date_ui > (rtime->l_ui - CLOCK_WAYTOOBIG))
goto codeokay; /* looks good */
/*
* Trouble. Next check is to see if the year rolled over and, if
* so, try again with the new year's start.
*/
date_ui = calyearstart(rtime->l_ui);
if (date_ui != yearstart) {
yearstart = date_ui;
date_ui += tmp;
(void) printf("time %u, code %u, difference %d\n",
date_ui, rtime->l_ui, (long)date_ui-(long)rtime->l_ui);
if (date_ui < (rtime->l_ui + CLOCK_WAYTOOBIG)
&& date_ui > (rtime->l_ui - CLOCK_WAYTOOBIG))
goto codeokay; /* okay this time */
}
ts.l_uf = 0;
ts.l_ui = yearstart;
printf("yearstart %s\n", prettydate(&ts));
printf("received %s\n", prettydate(rtime));
ts.l_ui = date_ui;
printf("date_ui %s\n", prettydate(&ts));
/*
* 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 CLOCK_WAYTOOBIG seconds into the new year.
*/
if ((rtime->l_ui - yearstart) < CLOCK_WAYTOOBIG) {
date_ui = tmp + calyearstart(yearstart - CLOCK_WAYTOOBIG);
if ((rtime->l_ui - date_ui) < CLOCK_WAYTOOBIG)
goto codeokay;
}
/*
* 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.
*/
date_ui = tmp + calyearstart(yearstart + (400*24*60*60)); /* 400 days */
if ((date_ui - rtime->l_ui) >= CLOCK_WAYTOOBIG) {
printf("Date hopelessly off\n");
return; /* hopeless, let it sync to other peers */
}
codeokay:
reftime = date_ui;
/*
* We've now got the integral seconds part of the time code (we hope).
* The fractional part comes from the table. We next compute
* the offsets for each character.
*/
for (i = 0; i < NCHUCHARS; i++) {
register u_long tmp2;
off[i].l_ui = date_ui;
off[i].l_uf = chutable[i];
tmp = chuc->codetimes[i].tv_sec + JAN_1970;
TVUTOTSF(chuc->codetimes[i].tv_usec, tmp2);
M_SUB(off[i].l_ui, off[i].l_uf, tmp, tmp2);
}
/*
* Here is a *big* problem. What one would normally
* do here on a machine with lots of clock bits (say
* a Vax or the gizmo board) is pick the most positive
* offset and the estimate, since this is the one that
* is most likely suffered the smallest interrupt delay.
* The trouble is that the low order clock bit on an IBM
* RT, which is the machine I had in mind when doing this,
* ticks at just under the millisecond mark. This isn't
* precise enough. What we can do to improve this is to
* average all 10 samples and rely on the second level
* filtering to pick the least delayed estimate. Trouble
* is, this means we have to divide a 64 bit fixed point
* number by 10, a procedure which really sucks. Oh, well.
* First compute the sum.
*/
date_ui = 0;
tmp = 0;
for (i = 0; i < NCHUCHARS; i++)
M_ADD(date_ui, tmp, off[i].l_ui, off[i].l_uf);
if (M_ISNEG(date_ui, tmp))
isneg = 1;
else
isneg = 0;
/*
* Here is a multiply-by-0.1 optimization that should apply
* just about everywhere. If the magnitude of the sum
* is less than 9 we don't have to worry about overflow
* out of a 64 bit product, even after rounding.
*/
if (date_ui < 9 || date_ui > 0xfffffff7) {
register u_long prod_ui;
register u_long prod_uf;
prod_ui = prod_uf = 0;
/*
* This code knows the low order bit in 0.1 is zero
*/
for (i = 1; i < NZPOBITS; i++) {
M_LSHIFT(date_ui, tmp);
if (ZEROPTONE & (1<<i))
M_ADD(prod_ui, prod_uf, date_ui, tmp);
}
/*
* Done, round it correctly. Prod_ui contains the
* fraction.
*/
if (prod_uf & 0x80000000)
prod_ui++;
if (isneg)
date_ui = 0xffffffff;
else
date_ui = 0;
tmp = prod_ui;
/*
* date_ui is integral part, tmp is fraction.
*/
} else {
register u_long prod_ovr;
register u_long prod_ui;
register u_long prod_uf;
register u_long highbits;
prod_ovr = prod_ui = prod_uf = 0;
if (isneg)
highbits = 0xffffffff; /* sign extend */
else
highbits = 0;
/*
* This code knows the low order bit in 0.1 is zero
*/
for (i = 1; i < NZPOBITS; i++) {
M_LSHIFT3(highbits, date_ui, tmp);
if (ZEROPTONE & (1<<i))
M_ADD3(prod_ovr, prod_uf, prod_ui,
highbits, date_ui, tmp);
}
if (prod_uf & 0x80000000)
M_ADDUF(prod_ovr, prod_ui, (u_long)1);
date_ui = prod_ovr;
tmp = prod_ui;
}
/*
* At this point we have the mean offset, with the integral
* part in date_ui and the fractional part in tmp. Store
* it in the structure.
*/
/*
* Add in fudge factor.
*/
M_ADD(date_ui, tmp, offset_fudge.l_ui, offset_fudge.l_uf);
/*
* Find the minimun and maximum offset
*/
imin = imax = 0;
for (i = 1; i < NCHUCHARS; i++) {
if (L_ISGEQ(&off[i], &off[imax])) {
imax = i;
} else if (L_ISGEQ(&off[imin], &off[i])) {
imin = i;
}
}
L_ADD(&off[imin], &offset_fudge);
if (imin != imax)
L_ADD(&off[imax], &offset_fudge);
(void) printf("mean %s, min %s, max %s\n",
mfptoa(date_ui, tmp, 8), lfptoa(&off[imin], 8),
lfptoa(&off[imax], 8));
}

View File

@ -1,511 +0,0 @@
/* clktest.c,v 3.1 1993/07/06 01:05:23 jbj Exp
* clktest - test the clock line discipline
*
* usage: clktest -b bps -f -t timeo -s cmd -c char1 -a char2 /dev/whatever
*/
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <signal.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/file.h>
#include <sgtty.h>
#include "../include/ntp_fp.h"
#include "../include/ntp.h"
#include "../include/ntp_unixtime.h"
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
#if defined(ULT_2_0_SUCKS)
#ifndef sigmask
#define sigmask(m) (1<<(m))
#endif
#endif
#ifndef STREAM
#ifndef CLKLDISC
CLOCK_LINE_DISCIPLINE_NEEDED_BY_THIS_PROGRAM;
#endif
#endif
/*
* Mask for blocking SIGIO and SIGALRM
*/
#define BLOCKSIGMASK (sigmask(SIGIO)|sigmask(SIGALRM))
/*
* speed table
*/
struct speeds {
int bps;
int rate;
} speedtab[] = {
{ 300, B300 },
{ 1200, B1200 },
{ 2400, B2400 },
{ 4800, B4800 },
{ 9600, B9600 },
{ 19200, EXTA },
{ 38400, EXTB },
{ 0, 0 }
};
char *progname;
int debug;
#ifdef CLKLDISC
#define DEFMAGIC '\r'
#endif
#ifdef STREAM
#include <stropts.h>
#include <sys/clkdefs.h>
#define DEFMAGIC "\r"
#endif
struct timeval timeout = { 0 };
char *cmd = NULL;
int cmdlen;
int docmd = 0;
#ifdef CLKLDISC
u_long magic1 = DEFMAGIC;
u_long magic2 = DEFMAGIC;
#endif
#ifdef STREAM
char magic[32];
#endif
int speed = B9600;
int ttflags = RAW|EVENP|ODDP;
int wasalarmed;
int iosig;
struct timeval lasttv;
extern u_long ustotslo[];
extern u_long ustotsmid[];
extern u_long ustotshi[];
/*
* main - parse arguments and handle options
*/
main(argc, argv)
int argc;
char *argv[];
{
int c;
int errflg = 0;
struct speeds *spd;
u_long tmp;
int fd;
struct sgttyb ttyb;
struct itimerval itimer;
extern int ntp_optind;
extern char *ntp_optarg;
int alarming();
int ioready();
progname = argv[0];
#ifdef STREAM
magic[0] = 0;
#endif
while ((c = ntp_getopt(argc, argv, "a:b:c:dfs:t:")) != EOF)
switch (c) {
#ifdef CLKLDISC
case 'a':
#endif
case 'c':
if (!atouint(ntp_optarg, &tmp)) {
(void) fprintf(stderr,
"%s: argument for -%c must be integer\n",
progname, c);
errflg++;
break;
}
#ifdef CLKLDISC
if (c == 'c')
magic1 = tmp;
else
magic2 = tmp;
#endif
#ifdef STREAM
magic[strlen(magic)+1] = '\0';
magic[strlen(magic)] = tmp;
#endif
break;
case 'b':
if (!atouint(ntp_optarg, &tmp)) {
errflg++;
break;
}
spd = speedtab;
while (spd->bps != 0)
if ((int)tmp == spd->bps)
break;
if (spd->bps == 0) {
(void) fprintf(stderr,
"%s: speed %lu is unsupported\n",
progname, tmp);
errflg++;
} else {
speed = spd->rate;
}
break;
case 'd':
++debug;
break;
case 'f':
ttflags |= CRMOD;
break;
case 's':
cmdlen = strlen(ntp_optarg);
if (cmdlen == 0)
errflg++;
else
cmd = ntp_optarg;
break;
case 't':
if (!atouint(ntp_optarg, &tmp))
errflg++;
else {
timeout.tv_sec = (long)tmp;
docmd = 1;
}
break;
default:
errflg++;
break;
}
if (errflg || ntp_optind+1 != argc) {
(void) fprintf(stderr,
#ifdef CLKLDISC
"usage: %s [-b bps] [-c magic1] [-a magic2] [-f] [-s cmd] [-t timeo] tty_device\n",
#endif
#ifdef STREAM
"usage: %s [-b bps] [-c magic1] [-c magic2]... [-f] [-s cmd] [-t timeo] tty_device\n",
#endif
progname);
exit(2);
}
#ifdef STREAM
if (!strlen(magic))
strcpy(magic,DEFMAGIC);
#endif
if (docmd)
fd = open(argv[ntp_optind], O_RDWR, 0777);
else
fd = open(argv[ntp_optind], O_RDONLY, 0777);
if (fd == -1) {
(void) fprintf(stderr, "%s: open(%s): ", progname,
argv[ntp_optind]);
perror("");
exit(1);
}
if (ioctl(fd, TIOCEXCL, (char *)0) < 0) {
(void) fprintf(stderr, "%s: ioctl(TIOCEXCL): ", progname);
perror("");
exit(1);
}
/*
* If we have the clock discipline, set the port to raw. Otherwise
* we run cooked.
*/
ttyb.sg_ispeed = ttyb.sg_ospeed = speed;
#ifdef CLKLDISC
ttyb.sg_erase = (char)magic1;
ttyb.sg_kill = (char)magic2;
#endif
ttyb.sg_flags = (short)ttflags;
if (ioctl(fd, TIOCSETP, (char *)&ttyb) < 0) {
(void) fprintf(stderr, "%s: ioctl(TIOCSETP): ", progname);
perror("");
exit(1);
}
if (fcntl(fd, F_SETOWN, getpid()) == -1) {
(void) fprintf(stderr, "%s: fcntl(F_SETOWN): ", progname);
perror("");
exit(1);
}
#ifdef CLKLDISC
{
int ldisc;
ldisc = CLKLDISC;
if (ioctl(fd, TIOCSETD, (char *)&ldisc) < 0) {
(void) fprintf(stderr, "%s: ioctl(TIOCSETD): ", progname);
perror("");
exit(1);
}
}
#endif
#ifdef STREAM
if (ioctl(fd, I_POP, 0) >=0 ) ;
if (ioctl(fd, I_PUSH, "clk") < 0) {
(void) fprintf(stderr, "%s: ioctl(I_PUSH): ", progname);
perror("");
exit(1);
}
if (ioctl(fd, CLK_SETSTR, magic) < 0) {
(void) fprintf(stderr, "%s: ioctl(CLK_SETSTR): ", progname);
perror("");
exit(1);
}
#endif
(void) gettimeofday(&lasttv, (struct timezone *)0);
if (docmd) {
/*
* set non-blocking, async I/O on the descriptor
*/
iosig = 0;
(void) signal(SIGIO, ioready);
if (fcntl(fd, F_SETFL, FNDELAY|FASYNC) < 0) {
(void) fprintf(stderr, "%s: fcntl(F_SETFL): ",
progname);
perror("");
exit(1);
}
/*
* Set up the alarm interrupt.
*/
wasalarmed = 0;
(void) signal(SIGALRM, alarming);
itimer.it_interval = itimer.it_value = timeout;
setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
doboth(fd);
}
doioonly(fd);
}
/*
* doboth - handle both I/O and alarms via SIGIO
*/
doboth(fd)
int fd;
{
int n;
int sawalarm;
int sawiosig;
int omask;
fd_set fds;
struct timeval tvzero;
sawalarm = 0;
sawiosig = 0;
FD_ZERO(&fds);
for (;;) {
omask = sigblock(BLOCKSIGMASK);
if (wasalarmed) { /* alarmed? */
sawalarm = 1;
wasalarmed = 0;
}
if (iosig) {
sawiosig = 1;
iosig = 0;
}
if (!sawalarm && !sawiosig) {
/*
* Nothing to do. Wait for something.
*/
sigpause(omask);
if (wasalarmed) { /* alarmed? */
sawalarm = 1;
wasalarmed = 0;
}
if (iosig) {
sawiosig = 1;
iosig = 0;
}
}
(void)sigsetmask(omask);
if (sawiosig) {
do {
tvzero.tv_sec = tvzero.tv_usec = 0;
FD_SET(fd, &fds);
n = select(fd+1, &fds, (fd_set *)0,
(fd_set *)0, &tvzero);
if (n > 0)
doio(fd);
} while (n > 0);
if (n == -1) {
(void) fprintf(stderr, "%s: select: ",
progname);
perror("");
exit(1);
}
sawiosig = 0;
}
if (sawalarm) {
doalarm(fd);
sawalarm = 0;
}
}
}
/*
* doioonly - do I/O. This avoids the use of signals
*/
doioonly(fd)
int fd;
{
int n;
fd_set fds;
FD_ZERO(&fds);
for (;;) {
FD_SET(fd, &fds);
n = select(fd+1, &fds, (fd_set *)0, (fd_set *)0,
(struct timeval *)0);
if (n > 0)
doio(fd);
}
}
/*
* doio - read a buffer full of stuff and print it out
*/
doio(fd)
int fd;
{
register char *rp, *rpend;
register char *cp;
register int i;
char raw[512];
struct timeval tv, tvd;
int rlen;
int ind;
char cooked[2049];
static char *digits = "0123456789abcdef";
rlen = read(fd, raw, sizeof(raw));
if (rlen < 0) {
(void) fprintf(stderr, "%s: read(): ", progname);
perror("");
return;
}
if (rlen == 0) {
(void) printf("Zero length read\n");
return;
}
cp = cooked;
rp = raw;
rpend = &raw[rlen];
ind = 0;
while (rp < rpend) {
ind = 1;
if (isprint(*rp))
*cp++ = *rp;
else {
*cp++ = '<';
*cp++ = digits[((*rp)>>4) & 0xf];
*cp++ = digits[*rp & 0xf];
*cp++ = '>';
}
#ifdef CLKLDISC
if (*rp == (char)magic1 || *rp == (char)magic2) {
#else
if ( strchr( magic, *rp) != NULL ) {
#endif
rp++;
ind = 0;
*cp = '\0';
if ((rpend - rp) < sizeof(struct timeval)) {
(void)printf(
"Too little data (%d): %s\n",
rpend-rp, cooked);
return;
}
tv.tv_sec = 0;
for (i = 0; i < 4; i++) {
tv.tv_sec <<= 8;
tv.tv_sec |= ((long)*rp++) & 0xff;
}
tv.tv_usec = 0;
for (i = 0; i < 4; i++) {
tv.tv_usec <<= 8;
tv.tv_usec |= ((long)*rp++) & 0xff;
}
tvd.tv_sec = tv.tv_sec - lasttv.tv_sec;
tvd.tv_usec = tv.tv_usec - lasttv.tv_usec;
if (tvd.tv_usec < 0) {
tvd.tv_usec += 1000000;
tvd.tv_sec--;
}
(void)printf("%lu.%06lu %lu.%06lu %s\n",
tv.tv_sec, tv.tv_usec, tvd.tv_sec, tvd.tv_usec,
cooked);
lasttv = tv;
} else {
rp++;
}
}
if (ind) {
*cp = '\0';
(void)printf("Incomplete data: %s\n", cooked);
}
}
/*
* doalarm - send a string out the port, if we have one.
*/
doalarm(fd)
int fd;
{
int n;
if (cmd == NULL || cmdlen <= 0)
return;
n = write(fd, cmd, cmdlen);
if (n < 0) {
(void) fprintf(stderr, "%s: write(): ", progname);
perror("");
} else if (n < cmdlen) {
(void) printf("Short write (%d bytes, should be %d)\n",
n, cmdlen);
}
}
/*
* alarming - receive alarm interupt
*/
alarming()
{
wasalarmed = 1;
}
/*
* ioready - handle SIGIO interrupt
*/
ioready()
{
iosig = 1;
}

View File

@ -1,536 +0,0 @@
/* propdelay.c,v 3.1 1993/07/06 01:05:24 jbj Exp
* propdelay - compute propagation delays
*
* cc -o propdelay propdelay.c -lm
*
* "Time and Frequency Users' Manual", NBS Technical Note 695 (1977).
*/
/*
* This can be used to get a rough idea of the HF propagation delay
* between two points (usually between you and the radio station).
* The usage is
*
* propdelay latitudeA longitudeA latitudeB longitudeB
*
* where points A and B are the locations in question. You obviously
* need to know the latitude and longitude of each of the places.
* The program expects the latitude to be preceded by an 'n' or 's'
* and the longitude to be preceded by an 'e' or 'w'. It understands
* either decimal degrees or degrees:minutes:seconds. Thus to compute
* the delay between the WWVH (21:59:26N, 159:46:00W) and WWV (40:40:49N,
* 105:02:27W) you could use:
*
* propdelay n21:59:26 w159:46 n40:40:49 w105:02:27
*
* By default it prints out a summer (F2 average virtual height 350 km) and
* winter (F2 average virtual height 250 km) number. The results will be
* quite approximate but are about as good as you can do with HF time anyway.
* You might pick a number between the values to use, or use the summer
* value in the summer and switch to the winter value when the static
* above 10 MHz starts to drop off in the fall. You can also use the
* -h switch if you want to specify your own virtual height.
*
* You can also do a
*
* propdelay -W n45:17:47 w75:45:22
*
* to find the propagation delays to WWV and WWVH (from CHU in this
* case), a
*
* propdelay -C n40:40:49 w105:02:27
*
* to find the delays to CHU, and a
*
* propdelay -G n52:03:17 w98:34:18
*
* to find delays to GOES via each of the three satellites.
*/
#include <stdio.h>
#include <string.h>
#include "ntp_stdlib.h"
extern double sin P((double));
extern double cos P((double));
extern double acos P((double));
extern double tan P((double));
extern double atan P((double));
extern double sqrt P((double));
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
/*
* Program constants
*/
#define EARTHRADIUS (6370.0) /* raduis of earth (km) */
#define LIGHTSPEED (299800.0) /* speed of light, km/s */
#define PI (3.1415926536)
#define RADPERDEG (PI/180.0) /* radians per degree */
#define MILE (1.609344) /* km in a mile */
#define SUMMERHEIGHT (350.0) /* summer height in km */
#define WINTERHEIGHT (250.0) /* winter height in km */
#define SATHEIGHT (6.6110 * 6378.0) /* geosync satellite height in km
from centre of earth */
#define WWVLAT "n40:40:49"
#define WWVLONG "w105:02:27"
#define WWVHLAT "n21:59:26"
#define WWVHLONG "w159:46:00"
#define CHULAT "n45:17:47"
#define CHULONG "w75:45:22"
#define GOES_UP_LAT "n37:52:00"
#define GOES_UP_LONG "w75:27:00"
#define GOES_EAST_LONG "w75:00:00"
#define GOES_STBY_LONG "w105:00:00"
#define GOES_WEST_LONG "w135:00:00"
#define GOES_SAT_LAT "n00:00:00"
char *wwvlat = WWVLAT;
char *wwvlong = WWVLONG;
char *wwvhlat = WWVHLAT;
char *wwvhlong = WWVHLONG;
char *chulat = CHULAT;
char *chulong = CHULONG;
char *goes_up_lat = GOES_UP_LAT;
char *goes_up_long = GOES_UP_LONG;
char *goes_east_long = GOES_EAST_LONG;
char *goes_stby_long = GOES_STBY_LONG;
char *goes_west_long = GOES_WEST_LONG;
char *goes_sat_lat = GOES_SAT_LAT;
int hflag = 0;
int Wflag = 0;
int Cflag = 0;
int Gflag = 0;
int height;
char *progname;
int debug;
static void doit P((double, double, double, double, double, char *));
static double latlong P((char *, int));
static double greatcircle P((double, double, double, double));
static double waveangle P((double, double, int));
static double propdelay P((double, double, int));
static int finddelay P((double, double, double, double, double, double *));
static void satdoit P((double, double, double, double, double, double, char *));
static void satfinddelay P((double, double, double, double, double *));
static double satpropdelay P((double));
/*
* main - parse arguments and handle options
*/
void
main(argc, argv)
int argc;
char *argv[];
{
int c;
int errflg = 0;
double lat1, long1;
double lat2, long2;
double lat3, long3;
extern int ntp_optind;
extern char *ntp_optarg;
progname = argv[0];
while ((c = ntp_getopt(argc, argv, "dh:CWG")) != EOF)
switch (c) {
case 'd':
++debug;
break;
case 'h':
hflag++;
height = atof(ntp_optarg);
if (height <= 0.0) {
(void) fprintf(stderr, "height %s unlikely\n",
ntp_optarg);
errflg++;
}
break;
case 'C':
Cflag++;
break;
case 'W':
Wflag++;
break;
case 'G':
Gflag++;
break;
default:
errflg++;
break;
}
if (errflg || (!(Cflag || Wflag || Gflag) && ntp_optind+4 != argc) ||
((Cflag || Wflag || Gflag) && ntp_optind+2 != argc)) {
(void) fprintf(stderr,
"usage: %s [-d] [-h height] lat1 long1 lat2 long2\n",
progname);
(void) fprintf(stderr," - or -\n");
(void) fprintf(stderr,
"usage: %s -CWG [-d] lat long\n",
progname);
exit(2);
}
if (!(Cflag || Wflag || Gflag)) {
lat1 = latlong(argv[ntp_optind], 1);
long1 = latlong(argv[ntp_optind + 1], 0);
lat2 = latlong(argv[ntp_optind + 2], 1);
long2 = latlong(argv[ntp_optind + 3], 0);
if (hflag) {
doit(lat1, long1, lat2, long2, height, "");
} else {
doit(lat1, long1, lat2, long2, (double)SUMMERHEIGHT,
"summer propagation, ");
doit(lat1, long1, lat2, long2, (double)WINTERHEIGHT,
"winter propagation, ");
}
} else if (Wflag) {
/*
* Compute delay from WWV
*/
lat1 = latlong(argv[ntp_optind], 1);
long1 = latlong(argv[ntp_optind + 1], 0);
lat2 = latlong(wwvlat, 1);
long2 = latlong(wwvlong, 0);
if (hflag) {
doit(lat1, long1, lat2, long2, height, "WWV ");
} else {
doit(lat1, long1, lat2, long2, (double)SUMMERHEIGHT,
"WWV summer propagation, ");
doit(lat1, long1, lat2, long2, (double)WINTERHEIGHT,
"WWV winter propagation, ");
}
/*
* Compute delay from WWVH
*/
lat2 = latlong(wwvhlat, 1);
long2 = latlong(wwvhlong, 0);
if (hflag) {
doit(lat1, long1, lat2, long2, height, "WWVH ");
} else {
doit(lat1, long1, lat2, long2, (double)SUMMERHEIGHT,
"WWVH summer propagation, ");
doit(lat1, long1, lat2, long2, (double)WINTERHEIGHT,
"WWVH winter propagation, ");
}
} else if (Cflag) {
lat1 = latlong(argv[ntp_optind], 1);
long1 = latlong(argv[ntp_optind + 1], 0);
lat2 = latlong(chulat, 1);
long2 = latlong(chulong, 0);
if (hflag) {
doit(lat1, long1, lat2, long2, height, "CHU ");
} else {
doit(lat1, long1, lat2, long2, (double)SUMMERHEIGHT,
"CHU summer propagation, ");
doit(lat1, long1, lat2, long2, (double)WINTERHEIGHT,
"CHU winter propagation, ");
}
} else if (Gflag) {
lat1 = latlong(goes_up_lat, 1);
long1 = latlong(goes_up_long, 0);
lat3 = latlong(argv[ntp_optind], 1);
long3 = latlong(argv[ntp_optind + 1], 0);
lat2 = latlong(goes_sat_lat, 1);
long2 = latlong(goes_west_long, 0);
satdoit(lat1, long1, lat2, long2, lat3, long3,
"GOES Delay via WEST");
long2 = latlong(goes_stby_long, 0);
satdoit(lat1, long1, lat2, long2, lat3, long3,
"GOES Delay via STBY");
long2 = latlong(goes_east_long, 0);
satdoit(lat1, long1, lat2, long2, lat3, long3,
"GOES Delay via EAST");
}
exit(0);
}
/*
* doit - compute a delay and print it
*/
static void
doit(lat1, long1, lat2, long2, h, str)
double lat1;
double long1;
double lat2;
double long2;
double h;
char *str;
{
int hops;
double delay;
hops = finddelay(lat1, long1, lat2, long2, h, &delay);
printf("%sheight %g km, hops %d, delay %g seconds\n",
str, h, hops, delay);
}
/*
* latlong - decode a latitude/longitude value
*/
static double
latlong(str, islat)
char *str;
int islat;
{
register char *cp;
register char *bp;
double arg;
double div;
int isneg;
char buf[32];
char *colon;
if (islat) {
/*
* Must be north or south
*/
if (*str == 'N' || *str == 'n')
isneg = 0;
else if (*str == 'S' || *str == 's')
isneg = 1;
else
isneg = -1;
} else {
/*
* East is positive, west is negative
*/
if (*str == 'E' || *str == 'e')
isneg = 0;
else if (*str == 'W' || *str == 'w')
isneg = 1;
else
isneg = -1;
}
if (isneg >= 0)
str++;
colon = strchr(str, ':');
if (colon != NULL) {
/*
* in hhh:mm:ss form
*/
cp = str;
bp = buf;
while (cp < colon)
*bp++ = *cp++;
*bp = '\0';
cp++;
arg = atof(buf);
div = 60.0;
colon = strchr(cp, ':');
if (colon != NULL) {
bp = buf;
while (cp < colon)
*bp++ = *cp++;
*bp = '\0';
cp++;
arg += atof(buf) / div;
div = 3600.0;
}
if (*cp != '\0')
arg += atof(cp) / div;
} else {
arg = atof(str);
}
if (isneg == 1)
arg = -arg;
if (debug > 2)
(void) printf("latitude/longitude %s = %g\n", str, arg);
return arg;
}
/*
* greatcircle - compute the great circle distance in kilometers
*/
static double
greatcircle(lat1, long1, lat2, long2)
double lat1;
double long1;
double lat2;
double long2;
{
double dg;
double l1r, l2r;
l1r = lat1 * RADPERDEG;
l2r = lat2 * RADPERDEG;
dg = EARTHRADIUS * acos(
(cos(l1r) * cos(l2r) * cos((long2-long1)*RADPERDEG))
+ (sin(l1r) * sin(l2r)));
if (debug >= 2)
printf(
"greatcircle lat1 %g long1 %g lat2 %g long2 %g dist %g\n",
lat1, long1, lat2, long2, dg);
return dg;
}
/*
* waveangle - compute the wave angle for the given distance, virtual
* height and number of hops.
*/
static double
waveangle(dg, h, n)
double dg;
double h;
int n;
{
double theta;
double delta;
theta = dg / (EARTHRADIUS * (double)(2 * n));
delta = atan((h / (EARTHRADIUS * sin(theta))) + tan(theta/2)) - theta;
if (debug >= 2)
printf("waveangle dist %g height %g hops %d angle %g\n",
dg, h, n, delta / RADPERDEG);
return delta;
}
/*
* propdelay - compute the propagation delay
*/
static double
propdelay(dg, h, n)
double dg;
double h;
int n;
{
double phi;
double theta;
double td;
theta = dg / (EARTHRADIUS * (double)(2 * n));
phi = (PI/2.0) - atan((h / (EARTHRADIUS * sin(theta))) + tan(theta/2));
td = dg / (LIGHTSPEED * sin(phi));
if (debug >= 2)
printf("propdelay dist %g height %g hops %d time %g\n",
dg, h, n, td);
return td;
}
/*
* finddelay - find the propagation delay
*/
static int
finddelay(lat1, long1, lat2, long2, h, delay)
double lat1;
double long1;
double lat2;
double long2;
double h;
double *delay;
{
double dg; /* great circle distance */
double delta; /* wave angle */
int n; /* number of hops */
dg = greatcircle(lat1, long1, lat2, long2);
if (debug)
printf("great circle distance %g km %g miles\n", dg, dg/MILE);
n = 1;
while ((delta = waveangle(dg, h, n)) < 0.0) {
if (debug)
printf("tried %d hop%s, no good\n", n, n>1?"s":"");
n++;
}
if (debug)
printf("%d hop%s okay, wave angle is %g\n", n, n>1?"s":"",
delta / RADPERDEG);
*delay = propdelay(dg, h, n);
return n;
}
/*
* satdoit - compute a delay and print it
*/
static void
satdoit(lat1, long1, lat2, long2, lat3, long3, str)
double lat1;
double long1;
double lat2;
double long2;
double lat3;
double long3;
char *str;
{
double up_delay,down_delay;
satfinddelay(lat1, long1, lat2, long2, &up_delay);
satfinddelay(lat3, long3, lat2, long2, &down_delay);
printf("%s, delay %g seconds\n", str, up_delay + down_delay);
}
/*
* satfinddelay - calculate the one-way delay time between a ground station
* and a satellite
*/
static void
satfinddelay(lat1, long1, lat2, long2, delay)
double lat1;
double long1;
double lat2;
double long2;
double *delay;
{
double dg; /* great circle distance */
dg = greatcircle(lat1, long1, lat2, long2);
*delay = satpropdelay(dg);
}
/*
* satpropdelay - calculate the one-way delay time between a ground station
* and a satellite
*/
static double
satpropdelay(dg)
double dg;
{
double k1, k2, dist;
double theta;
double td;
theta = dg / (EARTHRADIUS);
k1 = EARTHRADIUS * sin(theta);
k2 = SATHEIGHT - (EARTHRADIUS * cos(theta));
if (debug >= 2)
printf("Theta %g k1 %g k2 %g\n", theta, k1, k2);
dist = sqrt(k1*k1 + k2*k2);
td = dist / LIGHTSPEED;
if (debug >= 2)
printf("propdelay dist %g height %g time %g\n", dg, dist, td);
return td;
}

View File

@ -1,211 +0,0 @@
# Edit this file to reflect information specific to your installation.
# Then run 'make makeconfig' to propagate the information to all the makefiles,
# Config.CHATHAM,v 3.1 1993/07/06 01:03:42 jbj Exp
#
# Definitions for the library:
#
# You must define one of -DXNTP_BIG_ENDIAN, -DXNTP_LITTLE_ENDIAN
# or -DXNTP_AUTO_ENDIAN depending on which way your machine's
# bytes go for the benefit of the DES routine. Most things
# sold by DEC, the NS32x32 and the 80386 deserve a
# -DXNTP_LITTLE_ENDIAN. Most of the rest of the world does
# it the other way. If in doubt, pick one, compile
# everything and run authstuff/authcert < authstuff/certdata.
# If everything fails, do it the other way.
#
# Under BSD, you may define -DXNTP_NETINET_ENDIAN to use
# netinet/in.h to determine which of -DXNTP_BIG_ENDIAN and
# XNTP_LITTLE_ENDIAN should be used.
#
LIBDEFS= -DWORDS_BIGENDIAN
#
# Library loading:
#
# If you don't want your library ranlib'ed, chose the second line
#
RANLIB= ranlib
#RANLIB= : # ar does the work of ranlib under System V
#
# Definitions for programs:
#
# If your compiler doesn't understand the declaration `signed char',
# add -DNO_SIGNED_CHAR_DECL. Your `char' data type had better be
# signed. If you don't know what the compiler knows, try it
# without the flag. If you get a syntax error on line 13 of
# ntp.h, add it. Note that `signed char' is an ANSIism. Most
# older, pcc-derived compilers will need this flag.
#
# If your library already has 's_char' defined, add -DS_CHAR_DEFINED.
#
# For SunOS 3.x, add -DSUN_3_3_STINKS (otherwise it will complain
# about broadaddr and will hang if you run without a -d flag
# on the command line. I actually can't believe the latter
# bug. If it hangs on your system with the flag defined, peruse
# xntpd/ntp_io.c for some rude comments about SunOS 3.5 and try it
# the other way). This flag affects xntpd only.
#
# For Ultrix 2.0, add -DULT_2_0_SUCKS. This OS has the same hanging
# bug as SunOS 3.5 (is this an original 4.2 bug?) and in addition
# has some strangeness concerning signal masks. Ultrix 2.3 doesn't
# have these problems. If you're running something in between
# you're on your own. This flag affects xntpd only.
#
# For SunOS 4.x, add -DDOSYNCTODR_SUCKS to include the code in ntp_util.c
# that sets the battery clock at the same time that it updates
# the driftfile. It does this by revving up the niceness, then
# sets the time of day to the current time of day. Ordinarily,
# you would need this only on non-networked machines.
#
# For some machines, settimeofday does not set the sub-second component
# of the time correctly. For these machines add -DSETTIMEOFDAY_BROKEN.
# If xntpd keeps STEPPING the clock by small amounts, then it is
# possible that you are suffering from this problem.
#
# There are three ways to pry loose the kernel variables tick and tickadj
# needed by ntp_unixclock.c. One reads kmem and and is enabled
# with -DREADKMEM. One uses Sun's libkvm and is enabled with
# -DUSELIBKVM. The last one uses builtin defaults and is enabled
# with -DNOKMEM. Therefore, one of -DUSELIBKVM, -DREADKMEM or
# -DNOKMEM must be defined. Suns and recent BSD should use
# -DUSELIBKVM; others should use -DREADKMEM. If -DUSELIBKVM, use
# the DAEMONLIBS below to get the kernel routines.
#
# If your gethostbyname() routine isn't based on the DNS resolver (and,
# in particular, h_errno doesn't exist) add a -DNODNS. There
# doesn't seem to be a good way to detect this automatically which
# works in all cases. This flag affects xntpres only.
#
# Adding -DLOCK_PROCESS to the compilation flags will prevent
# xntpd from being swapped out on systems where the plock(3) call
# is available.
#
# The flag -DDEBUG includes some debugging code.
#
# The flag -DREFCLOCK causes the basic reference clock support to be
# compiled into the daemon. If you set this you will also want
# to configure the particular clock drivers you want in the
# CLOCKDEFS= line below. This flag affects xntpd only.
#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
# Under HP-UX, you must use either -Dhpux70 or -Dhpux80 as,
# well as -DNOKMEM
#
# If your library doesn't include the vsprintf() routine, define
# NEED_VSPRINTF.
#
# There are three ways to utilize external 1-pps signals. Define -DPPS to
# include just the pps routine, such as used by the DCF77 reference clock
# driver. Define -DPPSDEV ito include a serial device driver. This
# requires a serial port and either a line discipline or STREAMS module.
# Define -DPPSCD to include the driver and a special kernal hack
# (for SunOS 4.1.1) that intercepts carrier-detect transitions
# generated by the pps signal. Only one of these flags should be defined.
#
DEFS= -DUSELIBKVM -DDEBUG -DSTREAM -DREFCLOCK -DNO_SIGNED_CHAR_DECL -DPPS -DPPSDEV -DXNTP_RETROFIT_STDLIB -DNTP_POSIX_SOURCE
#
# Authentication types supported. Choose from DES and MD5. If you
# have a 680x0 type CPU and GNU-C, also choose -DFASTMD5
#
AUTHDEFS=-DDES -DMD5
#
# Clock support definitions (these only make sense if -DREFCLOCK used):
#
# Define -DLOCAL_CLOCK to include local pseudo-clock support
#
# Define -DPST to include support for the PST 1020 WWV/H receiver.
#
# Define -DWWVB to include support for the Spectracom 8170 WWVB receiver.
# Define -DWWVBPPS for PPS support via the WWVB receiver; also,
# define -DPPSCD in the DEFS above. This requires the ppsclock
# streams module under SunOS 4.2.
#
# Define -DCHU to include support for a driver to receive the CHU
# timecode. Note that to compile in CHU support you must
# previously have installed the CHU serial line discipline in
# the kernel of the machine you are doing the compile on.
#
# Define -DDCF to include support for the DCF77 receiver. This code
# requires a special STREAMS module found in the kernel directory.
# Define -DDCFPPS for PPS support via the DCF77 receiver; also,
# devine -DPPS in the DEFS above.
#
# Define -DMX4200 to support a Magnavox 4200 GPS receiver. Define -DPPSCD
# in the DEFS above for PPS support via this receiver. This requires
# the ppsclock streams module under SunOS 4.2.
#
# Define -DAS2201 to include support for the Austron 2201 GPS Timing
# Receiver. Define -DPPSCD in the DEFS above for PPS support via this
# receiver. This requires the ppsclock streams module under SunOS 4.2.
#
# Define -DGOES to support a Kinemetrics TrueTime 468-DC GOES receiver. This
# driver may work with other True-Time products as well.
#
# Define -DOMEGA to support a Kinemetrics TrueTime OM-DC OMEGA receiver.
#
# Define -DTPRO to support a KSI/Odetics TPRO-S IRIG-B timecode reader. This
# requires the Sun interface driver available from KSI.
#
# Define -DLEITCH to support a Leitch CSD 5300 Master Clock System Driver
# for the HP 5061B Cesium Clock.
#
CLOCKDEFS= -DLOCAL_CLOCK -DPST -DWWVB -DWWVBPPS -DCHU -DDCF -DMX4200 -DAS2201 -DGOES -DOMEGA -DTPRO -DLEITCH -DIRIG
#
# For MIPS 4.3BSD or RISCos 4.0, include a -lmld to get the nlist() routine.
# If USELIBKVM is defined above, include a -lkvm to get the kernel
# routines.
#
#DAEMONLIBS= -lmld
DAEMONLIBS= -lkvm
#DAEMONLIBS=
#
# Name resolver library. Included when loading xntpres, which calls
# gethostbyname(). Define this if you would rather use a different
# version of the routine than the one in libc.a
#
#RESLIB= -lresolv
RESLIB=
#
# Option flags for the C compiler. A -g if you are uncomfortable
#
COPTS= -O
#
# C compiler to use. gcc will work, but avoid the -fstrength-reduce option
# if the version is 1.35 or earlier (using this option caused incorrect
# code to be generated in the DES key permutation code, and perhaps
# elsewhere).
#
COMPILER= gcc -pipe -Wall -g -O2 -finline-functions -fdelayed-branch -fomit-frame-pointer
#COMPILER= cc -pipe
#
# Directory into which binaries should be installed
#
BINDIR= /usr/local/bin
#
# Special library for adjtime emulation. Used under HP-UX
# (remember to run make in the adjtime directory)
#
#ADJLIB= ../adjtime/libadjtime.a
ADJLIB=
#
# BSD emulation library. In theory, this fixes signal semantics under
# HP-UX, but it doesn't work with 8.0 on a 9000s340, so there is now
# a work-around in the code (compiled when hpux80 is defined). In other
# words, use this for HP-UX prior to 8.0.
#
#COMPAT= -lBSD
COMPAT=

View File

@ -1,7 +0,0 @@
#
# Test suite for HPUX 9 (no multicast, kernel mods, disciplines, modem control)
#
DEFS_OPT=-DDEBUG
DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK
CLOCKDEFS= -DATOM -DAS2201 -DCHU -DGOES -DGPSTM -DIRIG -DLEITCH -DLOCAL_CLOCK -DMSFEES -DMX4200 -DNMEA -DOMEGA -DPST -DTPRO -DTRAK -DWWVB
BINDIR= /usr/local/bin

View File

@ -1,186 +0,0 @@
# Edit this file to reflect information specific to your installation.
# Then run 'make makeconfig' to propagate the information to all the makefiles,
# Config.MONOMOY,v 3.1 1993/07/06 01:03:43 jbj Exp
# Config.bsdi by Bdale Garbee, N3EUA, bdale@gag.com
#
# Tested with the BSDI BSD/386 0.9.3 "gamma 4" revision. It should
# work fine with this or later revs of BSD/386.
#
# Definitions for the library:
#
# You must define one of -DXNTP_BIG_ENDIAN, -DXNTP_LITTLE_ENDIAN
# or -DXNTP_AUTO_ENDIAN depending on which way your machine's
# bytes go for the benefit of the DES routine. Most things
# sold by DEC, the NS32x32 and the 80386 deserve a
# -DXNTP_LITTLE_ENDIAN. Most of the rest of the world does
# it the other way. If in doubt, pick one, compile
# everything and run authstuff/authcert < authstuff/certdata.
# If everything fails, do it the other way.
#
# Under BSD, you may define -DXNTP_NETINET_ENDIAN to use
# netinet/in.h to determine which of -DXNTP_BIG_ENDIAN and
# XNTP_LITTLE_ENDIAN should be used.
#
LIBDEFS= -DXNTP_LITTLE_ENDIAN
#
# Library loading:
#
# If you don't want your library ranlib'ed, chose the second line
#
RANLIB= ranlib
#RANLIB= : # ar does the work of ranlib under System V
#
# Definitions for programs:
#
# If your compiler doesn't understand the declaration `signed char',
# add -DNO_SIGNED_CHAR_DECL. Your `char' data type had better be
# signed. If you don't know what the compiler knows, try it
# without the flag. If you get a syntax error on line 13 of
# ntp.h, add it. Note that `signed char' is an ANSIism. Most
# older, pcc-derived compilers will need this flag.
#
# If your library already has 's_char' defined, add -DS_CHAR_DEFINED.
#
# For SunOS 3.x, add -DSUN_3_3_STINKS (otherwise it will complain
# about broadaddr and will hang if you run without a -d flag
# on the command line. I actually can't believe the latter
# bug. If it hangs on your system with the flag defined, peruse
# xntpd/ntp_io.c for some rude comments about SunOS 3.5 and try it
# the other way). This flag affects xntpd only.
#
# For Ultrix 2.0, add -DULT_2_0_SUCKS. This OS has the same hanging
# bug as SunOS 3.5 (is this an original 4.2 bug?) and in addition
# has some strangeness concerning signal masks. Ultrix 2.3 doesn't
# have these problems. If you're running something in between
# you're on your own. This flag affects xntpd only.
#
# For SunOS 4.x, add -DDOSYNCTODR_SUCKS to include the code in ntp_util.c
# that sets the battery clock at the same time that it updates
# the driftfile. It does this by revving up the niceness, then
# sets the time of day to the current time of day. Ordinarily,
# you would need this only on non-networked machines.
#
# There are three ways to pry loose the kernel variables tick and tickadj
# needed by ntp_unixclock.c. One reads kmem and and is enabled
# with -DREADKMEM. One uses Sun's libkvm and is enabled with
# -DUSELIBKVM. The last one uses builtin defaults and is enabled
# with -DNOKMEM. Therefore, one of -DUSELIBKVM, -DREADKMEM or
# -DNOKMEM must be defined. Suns and recent BSD should use
# -DUSELIBKVM; others should use -DREADKMEM. If -DUSELIBKVM, use
# the DAEMONLIBS below to get the kernel routines.
#
# If your gethostbyname() routine isn't based on the DNS resolver (and,
# in particular, h_errno doesn't exist) add a -DNODNS. There
# doesn't seem to be a good way to detect this automatically which
# works in all cases. This flag affects xntpres only.
#
# The flag -DDEBUG includes some debugging code.
#
# The flag -DREFCLOCK causes the basic reference clock support to be
# compiled into the daemon. If you set this you will also want
# to configure the particular clock drivers you want in the
# CLOCKDEFS= line below. This flag affects xntpd only.
#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
# Under HP-UX, you must use either -Dhpux70 or -Dhpux80 as,
# well as -DNOKMEM
#
# If your library doesn't include the vsprintf() routine, define
# NEED_VSPRINTF.
#
# Define -DPPS to include support for a 1-pps signal. Define -DPPSDEV
# to include a device driver for it. The latter requires a
# serial port and either a line discipline or STREAMS module.
# The PPS signal may also be generated via a reference clock
# module like DCF77. In that case a special define is required for
# the reference clock module (only one source of PPS signal should
# be used)
#
DEFS= -DBSDI -DUSELIBKVM -DDEBUG -DREFCLOCK -DPPS -DCONFIG_FILE=\\"/usr/local/etc/xntp.conf\\" -DNTP_POSIX_SOURCE
#
# Authentication types supported. Choose from DES and MD5. If you
# have a 680x0 type CPU and GNU-C, also choose -DFASTMD5
#
AUTHDEFS=-DDES -DMD5
#
# Clock support definitions (these only make sense if -DREFCLOCK used):
#
# Define -DLOCAL_CLOCK to include local pseudo-clock support
#
# Define -DPST to include support for the PST 1020 WWV/H receiver.
#
# Define -DWWVB to include support for the Spectracom 8170 WWVB receiver.
#
# Define -DCHU to include support for a driver to receive the CHU
# timecode. Note that to compile in CHU support you must
# previously have installed the CHU serial line discipline in
# the kernel of the machine you are doing the compile on.
#
# Define -DDCF to include support for the DCF77 receiver. This code
# requires a special STREAMS module found in the kernel directory.
# Define -DDCFPPS for PPS support via the DCF77 receiver
# (see also: -DPPS)
#
# Define -DGOES to support a Kinemetrics TrueTime 468-DC GOES receiver.
#
CLOCKDEFS= -DLOCAL_CLOCK -DPST -DWWVB -DCHU -DGOES # -DMX4200 -DAS2201
#
# For MIPS 4.3BSD or RISCos 4.0, include a -lmld to get the nlist() routine.
# If USELIBKVM is defined above, include a -lkvm to get the kernel
# routines.
#
#DAEMONLIBS= -lmld
DAEMONLIBS= -lkvm
#DAEMONLIBS=
#
# Name resolver library. Included when loading xntpres, which calls
# gethostbyname(). Define this if you would rather use a different
# version of the routine than the one in libc.a
#
#RESLIB= -lresolv
RESLIB=
#
# Option flags for the C compiler. A -g if you are uncomfortable
#
COPTS= -O
#
# C compiler to use. gcc will work, but avoid the -fstrength-reduce option
# if the version is 1.35 or earlier (using this option caused incorrect
# code to be generated in the DES key permutation code, and perhaps
# elsewhere).
#
COMPILER= gcc -pipe -Wall -g -O -finline-functions -fdelayed-branch -fomit-frame-pointer
#COMPILER= cc -pipe -g
#
# Directory into which binaries should be installed
#
BINDIR= /usr/local/bin
#
# Special library for adjtime emulation. Used under HP-UX
# (remember to run make in the adjtime directory)
#
#ADJLIB= ../adjtime/libadjtime.a
ADJLIB=
#
# BSD emulation library. In theory, this fixes signal semantics under
# HP-UX, but it doesn't work with 8.0 on a 9000s340, so there is now
# a work-around in the code (compiled when hpux80 is defined). In other
# words, use this for HP-UX prior to 8.0.
#
#COMPAT= -lBSD
COMPAT=

View File

@ -1,7 +0,0 @@
#
# Test suite for DEC OSF/1 V1.x (no disciplines)
#
DEFS_OPT=-DDEBUG
DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DKERNEL_PLL -DMCAST
CLOCKDEFS= -DACTS -DATOM -DAS2201 -DCHU -DDATUM -DGOES -DGPSTM -DHEATH -DIRIG -DLEITCH -DLOCAL_CLOCK -DMSFEES -DMX4200 -DNMEA -DOMEGA -DPST -DTPRO -DTRAK -DWWVB
BINDIR= /usr/local/bin

View File

@ -1,7 +0,0 @@
#
# Test suite for SunOS 4.1.x (kitchen sink)
#
DEFS_OPT=-DDEBUG
DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DMCAST -DKERNEL_PLL -DCLK -DCHU -DPPS
CLOCKDEFS= -DACTS -DATOM -DAS2201 -DCHU -DDATUM -DGOES -DGPSTM -DHEATH -DIRIG -DLEITCH -DLOCAL_CLOCK -DMSFEES -DMX4200 -DNMEA -DOMEGA -DPST -DTPRO -DTRAK -DWWVB
BINDIR= /usr/local/bin

View File

@ -1,182 +0,0 @@
# Edit this file to reflect information specific to your installation.
# Then run 'make makeconfig' to propagate the information to all the makefiles,
# Config.TIGER,v 3.1 1993/07/06 01:03:45 jbj Exp
#
# Definitions for the library:
#
# You must define one of -DXNTP_BIG_ENDIAN, -DXNTP_LITTLE_ENDIAN
# or -DXNTP_AUTO_ENDIAN depending on which way your machine's
# bytes go for the benefit of the DES routine. Most things
# sold by DEC, the NS32x32 and the 80386 deserve a
# -DXNTP_LITTLE_ENDIAN. Most of the rest of the world does
# it the other way. If in doubt, pick one, compile
# everything and run authstuff/authcert < authstuff/certdata.
# If everything fails, do it the other way.
#
# Under BSD, you may define -DXNTP_NETINET_ENDIAN to use
# netinet/in.h to determine which of -DXNTP_BIG_ENDIAN and
# XNTP_LITTLE_ENDIAN should be used.
#
LIBDEFS= -DXNTP_LITTLE_ENDIAN
#
# Library loading:
#
# If you don't want your library ranlib'ed, chose the second line
#
RANLIB= ranlib
#RANLIB= : # ar does the work of ranlib under System V
#
# Definitions for programs:
#
# If your compiler doesn't understand the declaration `signed char',
# add -DNO_SIGNED_CHAR_DECL. Your `char' data type had better be
# signed. If you don't know what the compiler knows, try it
# without the flag. If you get a syntax error on line 13 of
# ntp.h, add it. Note that `signed char' is an ANSIism. Most
# older, pcc-derived compilers will need this flag.
#
# If your library already has 's_char' defined, add -DS_CHAR_DEFINED.
#
# For SunOS 3.x, add -DSUN_3_3_STINKS (otherwise it will complain
# about broadaddr and will hang if you run without a -d flag
# on the command line. I actually can't believe the latter
# bug. If it hangs on your system with the flag defined, peruse
# xntpd/ntp_io.c for some rude comments about SunOS 3.5 and try it
# the other way). This flag affects xntpd only.
#
# For Ultrix 2.0, add -DULT_2_0_SUCKS. This OS has the same hanging
# bug as SunOS 3.5 (is this an original 4.2 bug?) and in addition
# has some strangeness concerning signal masks. Ultrix 2.3 doesn't
# have these problems. If you're running something in between
# you're on your own. This flag affects xntpd only.
#
# For SunOS 4.x, add -DDOSYNCTODR_SUCKS to include the code in ntp_util.c
# that sets the battery clock at the same time that it updates
# the driftfile. It does this by revving up the niceness, then
# sets the time of day to the current time of day. Ordinarily,
# you would need this only on non-networked machines.
#
# There are three ways to pry loose the kernel variables tick and tickadj
# needed by ntp_unixclock.c. One reads kmem and and is enabled
# with -DREADKMEM. One uses Sun's libkvm and is enabled with
# -DUSELIBKVM. The last one uses builtin defaults and is enabled
# with -DNOKMEM. Therefore, one of -DUSELIBKVM, -DREADKMEM or
# -DNOKMEM must be defined. Suns and recent BSD should use
# -DUSELIBKVM; others should use -DREADKMEM. If -DUSELIBKVM, use
# the DAEMONLIBS below to get the kernel routines.
#
# If your gethostbyname() routine isn't based on the DNS resolver (and,
# in particular, h_errno doesn't exist) add a -DNODNS. There
# doesn't seem to be a good way to detect this automatically which
# works in all cases. This flag affects xntpres only.
#
# The flag -DDEBUG includes some debugging code.
#
# The flag -DREFCLOCK causes the basic reference clock support to be
# compiled into the daemon. If you set this you will also want
# to configure the particular clock drivers you want in the
# CLOCKDEFS= line below. This flag affects xntpd only.
#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
# Under HP-UX, you must use either -Dhpux70 or -Dhpux80 as,
# well as -DNOKMEM
#
# If your library doesn't include the vsprintf() routine, define
# NEED_VSPRINTF.
#
# Define -DPPS to include support for a 1-pps signal. Define -DPPSDEV
# to include a device driver for it. The latter requires a
# serial port and either a line discipline or STREAMS module.
# The PPS signal may also be generated via a reference clock
# module like DCF77. In that case a special define is required for
# the reference clock module (only one source of PPS signal should
# be used)
#
DEFS= -DREFCLOCK -DS_CHAR_DEFINED -DREADKMEM -DDEBUG -DPLL -DXNTP_RETROFIT_STDLIB -DNTP_POSIX_SOURCE
#
# Authentication types supported. Choose from DES and MD5. If you
# have a 680x0 type CPU and GNU-C, also choose -DFASTMD5
#
AUTHDEFS=-DDES -DMD5
#
# Clock support definitions (these only make sense if -DREFCLOCK used):
#
# Define -DLOCAL_CLOCK to include local pseudo-clock support
#
# Define -DPST to include support for the PST 1020 WWV/H receiver.
#
# Define -DWWVB to include support for the Spectracom 8170 WWVB receiver.
#
# Define -DCHU to include support for a driver to receive the CHU
# timecode. Note that to compile in CHU support you must
# previously have installed the CHU serial line discipline in
# the kernel of the machine you are doing the compile on.
#
# Define -DDCF to include support for the DCF77 receiver. This code
# requires a special STREAMS module found in the kernel directory.
# Define -DDCFPPS for PPS support via the DCF77 receiver
# (see also: -DPPS)
#
# Define -DGOES to support a Kinemetrics TrueTime 468-DC GOES receiver.
#
CLOCKDEFS= -DLOCAL_CLOCK -DPST -DWWVB -DGOES -DCHU
#
# For MIPS 4.3BSD or RISCos 4.0, include a -lmld to get the nlist() routine.
# If USELIBKVM is defined above, include a -lkvm to get the kernel
# routines.
#
#DAEMONLIBS= -lmld
#DAEMONLIBS= -lkvm
DAEMONLIBS=
#
# Name resolver library. Included when loading xntpres, which calls
# gethostbyname(). Define this if you would rather use a different
# version of the routine than the one in libc.a
#
#RESLIB= -lresolv
RESLIB=
#
# Option flags for the C compiler. A -g if you are uncomfortable
#
COPTS= -O
#
# C compiler to use. gcc will work, but avoid the -fstrength-reduce option
# if the version is 1.35 or earlier (using this option caused incorrect
# code to be generated in the DES key permutation code, and perhaps
# elsewhere).
#
COMPILER= gcc -Wall -g -O2 -finline-functions -fdelayed-branch -fomit-frame-pointer
#COMPILER= cc
#
# Directory into which binaries should be installed
#
BINDIR= /usr/local/bin
#
# Special library for adjtime emulation. Used under HP-UX
# (remember to run make in the adjtime directory)
#
#ADJLIB= ../adjtime/libadjtime.a
ADJLIB=
#
# BSD emulation library. In theory, this fixes signal semantics under
# HP-UX, but it doesn't work with 8.0 on a 9000s340, so there is now
# a work-around in the code (compiled when hpux80 is defined). In other
# words, use this for HP-UX prior to 8.0.
#
#COMPAT= -lBSD
COMPAT=

View File

@ -1,202 +0,0 @@
# Edit this file to reflect information specific to your installation.
# Then run 'make makeconfig' to propagate the information to all the makefiles,
# Config.TRURO,v 3.1 1993/07/06 01:03:46 jbj Exp
#
# Definitions for the library:
#
# You must define one of -DXNTP_BIG_ENDIAN, -DXNTP_LITTLE_ENDIAN
# or -DXNTP_AUTO_ENDIAN depending on which way your machine's
# bytes go for the benefit of the DES routine. Most things
# sold by DEC, the NS32x32 and the 80386 deserve a
# -DXNTP_LITTLE_ENDIAN. Most of the rest of the world does
# it the other way. If in doubt, pick one, compile
# everything and run authstuff/authcert < authstuff/certdata.
# If everything fails, do it the other way.
#
# Under BSD, you may define -DXNTP_NETINET_ENDIAN to use
# netinet/in.h to determine which of -DXNTP_BIG_ENDIAN and
# XNTP_LITTLE_ENDIAN should be used.
#
LIBDEFS= -DWORDS_BIGENDIAN
#
# Library loading:
#
# If you don't want your library ranlib'ed, chose the second line
#
RANLIB= : # ar does the work of ranlib under System V
#
# Definitions for programs:
#
# If your compiler doesn't understand the declaration `signed char',
# add -DNO_SIGNED_CHAR_DECL. Your `char' data type had better be
# signed. If you don't know what the compiler knows, try it
# without the flag. If you get a syntax error on line 13 of
# ntp.h, add it. Note that `signed char' is an ANSIism. Most
# older, pcc-derived compilers will need this flag.
#
# If your library already has 's_char' defined, add -DS_CHAR_DEFINED.
#
# For SunOS 3.x, add -DSUN_3_3_STINKS (otherwise it will complain
# about broadaddr and will hang if you run without a -d flag
# on the command line. I actually can't believe the latter
# bug. If it hangs on your system with the flag defined, peruse
# xntpd/ntp_io.c for some rude comments about SunOS 3.5 and try it
# the other way). This flag affects xntpd only.
#
# For Ultrix 2.0, add -DULT_2_0_SUCKS. This OS has the same hanging
# bug as SunOS 3.5 (is this an original 4.2 bug?) and in addition
# has some strangeness concerning signal masks. Ultrix 2.3 doesn't
# have these problems. If you're running something in between
# you're on your own. This flag affects xntpd only.
#
# For SunOS 4.x, add -DDOSYNCTODR_SUCKS to include the code in ntp_util.c
# that sets the battery clock at the same time that it updates
# the driftfile. It does this by revving up the niceness, then
# sets the time of day to the current time of day. Ordinarily,
# you would need this only on non-networked machines.
#
# For some machines, settimeofday does not set the sub-second component
# of the time correctly. For these machines add -DSETTIMEOFDAY_BROKEN.
# If xntpd keeps STEPPING the clock by small amounts, then it is
# possible that you are suffering from this problem.
#
# There are four ways to pry loose the kernel variables tick and tickadj
# needed by ntp_unixclock.c. One reads kmem and and is enabled
# with -DREADKMEM. One uses Sun's libkvm and is enabled with
# -DUSELIBKVM. The last one uses builtin defaults and is enabled
# with -DNOKMEM. Therefore, one of -DUSELIBKVM, -DREADKMEM or
# -DNOKMEM must be defined. Suns, if they are not running Solaris,
# and recent BSD should use -DUSELIBKVM; others should use
# -DREADKMEM. Soalris 2.1 should use -DSOLARIS.
# If -DUSELIBKVM, use the DAEMONLIBS below to get the
# kernel routines.
#
# If your gethostbyname() routine isn't based on the DNS resolver (and,
# in particular, h_errno doesn't exist) add a -DNODNS. There
# doesn't seem to be a good way to detect this automatically which
# works in all cases. This flag affects xntpres only.
#
# The flag -DDEBUG includes some debugging code.
#
# The flag -DREFCLOCK causes the basic reference clock support to be
# compiled into the daemon. If you set this you will also want
# to configure the particular clock drivers you want in the
# CLOCKDEFS= line below. This flag affects xntpd only.
#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
# Under HP-UX, you must use either -Dhpux70 or -Dhpux80 as,
# well as -DNOKMEM
#
# Under Solaris 2.1, you must use -DSOLARIS and -DSLEWALWAYS.
# Don't define USELIBKVM, NOKMEM or READKMEM.
#
# If your library doesn't include the vsprintf() routine, define
# NEED_VSPRINTF.
#
# There are three ways to utilize external 1-pps signals. Define -DPPS to
# include just the pps routine, such as used by the DCF77 reference clock
# driver. Define -DPPSDEV ito include a serial device driver. This
# requires a serial port and either a line discipline or STREAMS module.
# Define -DPPSCD to include the driver and a special kernal hack
# (for SunOS 4.1.1) that intercepts carrier-detect transitions
# generated by the pps signal. Only one of these flags should be defined.
#
DEFS= -DDEBUG -DSTREAM -DREFCLOCK -DNO_SIGNED_CHAR_DECL -DSLEWALWAYS -DSOLARIS -DPPS -DSTUPID_SIGNAL -DXNTP_RETROFIT_STDLIB -DNTP_POSIX_SOURCE
#
# Authentication types supported. Choose from DES and MD5. If you
# have a 680x0 type CPU and GNU-C, also choose -DFASTMD5
#
AUTHDEFS=-DDES -DMD5
#
# Clock support definitions (these only make sense if -DREFCLOCK used):
#
# Define -DLOCAL_CLOCK to include local pseudo-clock support
#
# Define -DPST to include support for the PST 1020 WWV/H receiver.
#
# Define -DWWVB to include support for the Spectracom 8170 WWVB receiver.
# Define -DWWVBPPS for PPS support via the WWVB receiver; also,
# define -DPPSCD in the DEFS above. This requires the ppsclock
# streams module under SunOS 4.2.
#
# Define -DCHU to include support for a driver to receive the CHU
# timecode. Note that to compile in CHU support you must
# previously have installed the CHU serial line discipline in
# the kernel of the machine you are doing the compile on.
#
# Define -DDCF to include support for the DCF77 receiver. This code
# requires a special STREAMS module found in the kernel directory.
# Define -DDCFPPS for PPS support via the DCF77 receiver; also,
# devine -DPPS in the DEFS above.
#
# Define -DMX4200 to support a Magnavox 4200 GPS receiver. Define -DPPSCD
# in the DEFS above for PPS support via this receiver. This requires
# the ppsclock streams module under SunOS 4.2.
#
# Define -DAS2201 to include support for the Austron 2201 GPS Timing
# Receiver. Define -DPPSCD in the DEFS above for PPS support via this
# receiver. This requires the ppsclock streams module under SunOS 4.2.
#
# Define -DGOES to support a Kinemetrics TrueTime 468-DC GOES receiver. This
# driver may work with other True-Time products as well.
#
CLOCKDEFS= -DLOCAL_CLOCK -DPST -DWWVB -DWWVBPPS -DGOES -DCHU -DMX4200 -DAS2201 -DOMEGA -DTPRO -DLEITCH -DIRIG
#
# For MIPS 4.3BSD or RISCos 4.0, include a -lmld to get the nlist() routine.
# If USELIBKVM is defined above, include a -lkvm to get the kernel
# routines.
#
#DAEMONLIBS= -lmld
DAEMONLIBS=
#
# Name resolver library. Included when loading xntpres, which calls
# gethostbyname(). Define this if you would rather use a different
# version of the routine than the one in libc.a
#
#RESLIB= -lresolv
RESLIB= -lsocket -lnsl -lelf
#
# Option flags for the C compiler. A -g if you are uncomfortable
#
COPTS= -O
#
# C compiler to use. gcc will work, but avoid the -fstrength-reduce option
# if the version is 1.35 or earlier (using this option caused incorrect
# code to be generated in the DES key permutation code, and perhaps
# elsewhere).
#
#COMPILER= gcc -traditional
COMPILER= gcc -pipe -Wall -g -O2 -finline-functions -fdelayed-branch -fomit-frame-pointer
#
# Directory into which binaries should be installed
#
BINDIR= /usr/local/bin
#
# Special library for adjtime emulation. Used under HP-UX
# (remember to run make in the adjtime directory)
#
#ADJLIB= ../adjtime/libadjtime.a
ADJLIB=
#
# BSD emulation library. In theory, this fixes signal semantics under
# HP-UX, but it doesn't work with 8.0 on a 9000s340, so there is now
# a work-around in the code (compiled when hpux80 is defined). In other
# words, use this for HP-UX prior to 8.0.
#
#COMPAT= -lBSD
COMPAT=

View File

@ -1,7 +0,0 @@
#
# Test suite for Ultrix 4.x (no disciplines)
#
DEFS_OPT=-DDEBUG
DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DKERNEL_PLL -DMCAST
CLOCKDEFS= -DACTS -DATOM -DAS2201 -DCHU -DDATUM -DGOES -DGPSTM -DHEATH -DIRIG -DLEITCH -DLOCAL_CLOCK -DMSFEES -DMX4200 -DNMEA -DOMEGA -DPST -DTPRO -DTRAK -DWWVB
BINDIR= /usr/local/bin

View File

@ -1,7 +0,0 @@
#
# Test suite for 4.3bsd VAX tahoe (no multicast, kernel mods, disciplines)
#
DEFS_OPT=-DDEBUG
DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK
CLOCKDEFS= -DACTS -DATOM -DAS2201 -DCHU -DDATUM -DGOES -DGPSTM -DHEATH -DIRIG -DLEITCH -DLOCAL_CLOCK -DMSFEES -DMX4200 -DNMEA -DOMEGA -DPST -DTPRO -DTRAK -DWWVB
BINDIR= /usr/local/bin

View File

@ -1,187 +0,0 @@
# This is the local configure file (distribution version).
# You must modify it to fit your particular configuration
# and name it Config.local
# The following configuratiions can be auto-generated:
#
# make Config.local.green
# make a Config.local that supports a local clock
# (i.e. allow fallback to use of the CPU's own clock)
# make Config.local.NO.clock
# make a Config.local that supports no clocks
#
#
# NOTE TO GREENHORNS
#
# For plug-'n-play and no radios or other complicated gadgetry,
# use "make Config.local.green" or "make Config.local.local" as above.
#
# Following defines can be set in the DEFS_OPT= define:
#
# The flag -DDEBUG includes some debugging code. To use this, include
# the define and start the daemon with one or more -d flags, depending
# on your calibration of pearannoya. The daemon will not detach your
# terminal in this case. Judicious use of grep will reduce the speaker
# volume to bearable levels.
#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
# The -DSYSLOG_FILE defines allows logging messages that are normally
# reported via syslof() in a file. The file name can be configured using
# the configuration line "logfile <filename>" in CONFIG_FILE.
#
# There are three serial port system software interfaces, each of
# which is peculiar to one or more Unix versions. Define
# -DHAVE_SYSV_TTYS for basic System V compatibility; define -DSTREAM
# for POSIX compatibility including System V Streams, and
# HAVE_BSD_TTYS for 4.3bsd compatibility. Only one of these three
# should be defined. If none are defined, HAVE_BSD_TTYS is assumed.
# Usually these defines are already set correctly.
#
DEFS_OPT=-DDEBUG
#
# The DEFS_LOCAL define picks up all flags from DEFS_OPT (do not delete that)
# and one of the following:
#
# The flag -DREFCLOCK causes the basic reference clock support to be
# compiled into the daemon. If you set this you may also want to
# configure the particular clock drivers you want in the CLOCKDEFS= line
# below. This flag affects xntpd only. This define is included by
# default when using the "make makeconfig" script.
#
# The next two sets of defines are meaningful only when radio clock
# drivers or special 1-pps signals are to be used. For systems without
# these features, these delicious complexities can be avoided. Ordinarily,
# the "make makeconfig" script figures out which ones to use, but your
# mileage may vary.
#
# There are three ways to utilize external 1-pps signals. Define
# -DPPS to include just the pps routine, such as used by the DCF77(PARSE)
# clock driver. Define -DPPSCLK to include a serial device driver
# which avoids much of the jitter due to upper level port
# processing. This requires a dedicated serial port and either the
# tty_clock line discipline or tty_clk_streams module, both of
# which are in the ./kernel directory. Define -DPPSCD to include a
# special driver which intercepts carrier-detect transitions
# generated by the pps signal. This requires a nondedicated serial
# port and the ppsclock streams module in the ./kernel directory.
# Only one of these three flags should be defined.
#
# The flag KERNEL_PLL causes code to be compiled for a special feature of
# the kernel that (a) implements the phase-lock loop and (b) provides
# a user interface to learn time, maximum error and estimated error.
# See the file README.kern in the doc directory for further info.
# This code is activated only if the relevant kernel features have
# been configured; it does not affect operation of unmodified kernels.
# To compile it, however, requires a few header files from the
# special distribution.
#
# Note: following line must always start with DEFS_LOCAL= $(DEFS_OPT)
DEFS_LOCAL= $(DEFS_OPT) -DPPSPPS -DREFCLOCK -DKERNEL_PLL
#
# Radio clock support definitions (these only make sense if -DREFCLOCK
# used), which is normally the case. Note that a configuration can include
# no clocks, more than one type of clock and even multiple clocks of the
# same type.
#
# For most radio clocks operating with serial ports, accuracy can
# be considerably improved through use of the tty_clk line
# discipline or tty_clk_STREAMS streams module found in the
# ./kernel directory. These gizmos capture a timestamp upon
# occurrence of an intercept character and stuff it in the data
# stream for the clock driver to munch. To select this mode,
# postfix the driver name with the string CLK; that is, WWVB
# becomes WWVBCLK. If more than one clock is in use, the CLK
# postfix can be used with any or all of them.
#
# Alternatively, for the best accuracy, use the ppsclock streams
# module in the ./ppsclock directory to steal the carrier-detect
# transition and capture a precision timestamp. At present this
# works only with SunOS 4.1.1 or later. To select this mode,
# postfix the driver name with the string PPS; that is, AS2201
# becomes AS2201PPS. If more than one clock is in use, the PPS
# postfix should be used with only one of them. If any PPS
# postfix is defined, the -DPPSPPS define should be used on the
# DEFS above.
#
# Define -DLOCAL_CLOCK for a local pseudo-clock to masquerade as a
# reference clock for those subnets without access to the real thing.
# Works in all systems and requires no hardware support. This is defined
# by default when using the "make makeconfig" script and greenhorn
# configuraiton.
#
# Define -DPST for a PST/Traconex 1020 WWV/H receiver. The driver
# supports both the CLK and PPS modes. It should work in all systems
# with a serial port.
#
# Define -DWWVB for a Spectracom 8170 or Netclock/2 WWVB receiver. It
# should work in all systems with a serial port. The driver supports
# both the CLK and PPS modes if the requisite kernel support is installed.
#
# Define -DCHU for a special CHU receiver using an ordinary shortwave
# radio. This requires the chu_clk line discipline or chu_clk_STREAMS
# module in the ./kernel directory. At present, this driver works only
# on SunOS4.1.x; operation in other systems has not been confirmed.
# Construction details for a suitable modem can be found in the ./gadget
# directory. The driver supports # neither the CLK nor PPS modes.
#
# Define -DPARSE for a DCF77/GPS(GENERIC) receiver. For best performance
# this requires a special parsestreams STREAMS (SunOS 4.x) module in the
# ./parse directory. Define -DPARSEPPS for PPS support via the
# DCF77/GPS (GENERIC) receiver; also, define -DPPS in the DEFS above.
# Define: -DCLOCK_MEINBERG for Meinberg clocks
# -DCLOCK_SCHMID for Schmid receivers
# -DCLOCK_DCF7000 for ELV DCF7000
# -DCLOCK_RAWDCF for simple receivers (100/200ms pulses on Rx)
# -DCLOCK_TRIMSV6 for Trimble SV6 GPS receiver
#
# Define -DMX4200PPS for a Magnavox 4200 GPS receiver. At present, this
# driver works only on SunOS4.1.x with CPU serial ports only. The PPS
# mode is required.
#
# Define -DAS2201 for an Austron 2200A or 2201A GPS receiver. It should
# work in all systems with a serial port. The driver does not support the
# CLK mode, but does support the PPS mode. If the radio is connected to
# more than one machine, the PPS mode is required.
#
# Define -DGOES for a Kinemetrics/TrueTime 468-DC GOES receiver. This
# driver is known to work with some other TrueTime products as well,
# including the GPS-DC GPS receiver. It should work in all systems with
# a serial port. The driver does not support the CLK mode, but does
# support the PPS mode.
#
# Define -DOMEGA for a Kinemetrics/TrueTime OM-DC OMEGA receiver. It
# should work in all systems with a serial port. The driver does not
# support the CLK mode, but does support the PPS mode.
#
# Define -DTPRO for a KSI/Odetics TPRO-S IRIG-B timecode reader. This
# requires the SunOS interface driver available from KSI. The driver
# supports neither the CLK nor PPS modes.
#
# Define -DLEITCH for a Leitch CSD 5300 Master Clock System Driver for
# the HP 5061B Cesium Clock. It should work in all systems with a serial
# port. The driver does not support the CLK mode, but does support the
# PPS mode.
#
# Define -DMSFEESPPS for an EES M201 MSF receiver. It currently only works
# under SunOS 4.x with the PPSCD (ppsclock) STREAMS module, but the RCS
# files on cl.cam.ac.uk still has support for CLK and CBREAK modes.
#
# Define -DIRIG for a IRIG-B timecode timecode using the audio codec of
# the Sun SPARCstations. This requires a modified BSD audio driver and
# exclusive access to the audio port. A memo describing how it works and
# how to install the driver is in the README.irig file in the ./doc
# directory.
#
# Note: The following defines result in compilation of all the above radio
# clocks. This works on a Sun 4.1.x system which has tty_clk, chu_clk and
# ppsclock STREAMS modules installed. If the trailing CLK and PPS suffixes
# are removed and the IRIG, PARSE* and CLOCK* deleted, all of the rest compile
# under Ultrix 4.2a/3. If the MX4200 is removed, all the rest compile on a DEC
# OSF/1 Alpha.
#
CLOCKDEFS=-DAS2201PPS -DCHU -DGOES -DIRIG -DLEITCH -DLOCAL_CLOCK -DMX4200PPS -DOMEGA -DPSTCLK -DTPRO -DWWVBCLK
#
# Directory into which binaries should be installed (default /usr/local)
#
BINDIR= /usr/local/bin

View File

@ -1,190 +0,0 @@
# This is the local configure file (distribution version).
# You must modify it to fit your particular configuration
# and name it Config.local
# The following configuratiions can be auto-generated:
#
# make Config.local.green
# make a Config.local that supports a local clock
# (i.e. allow fallback to use of the CPU's own clock)
# make Config.local.NO.clock
# make a Config.local that supports no clocks
#
#
# NOTE TO GREENHORNS
#
# For plug-'n-play and no radios or other complicated gadgetry,
# use "make Config.local.green" as above.
#
# Following defines can be set in the DEFS_OPT= define:
#
# The flag -DDEBUG includes some debugging code. To use this, include
# the define and start the daemon with one or more -d flags, depending
# on your calibration of pearannoya. The daemon will not detach your
# terminal in this case. Judicious use of grep will reduce the speaker
# volume to bearable levels.
#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
# The -DSYSLOG_FILE defines allows logging messages that are normally
# reported via syslof() in a file. The file name can be configured using
# the configuration line "logfile <filename>" in CONFIG_FILE.
#
# There are three serial port system software interfaces, each of
# which is peculiar to one or more Unix versions. Define
# -DHAVE_SYSV_TTYS for basic System V compatibility; define -DSTREAM
# for POSIX compatibility including System V Streams, and
# HAVE_BSD_TTYS for 4.3bsd compatibility. Only one of these three
# should be defined. If none are defined, HAVE_BSD_TTYS is assumed.
# Usually these defines are already set correctly.
#
DEFS_OPT=-DDEBUG
#
# The DEFS_LOCAL define picks up all flags from DEFS_OPT (do not delete that)
# and one of the following:
#
# The flag -DREFCLOCK causes the basic reference clock support to be
# compiled into the daemon. If you set this you may also want to
# configure the particular clock drivers you want in the CLOCKDEFS= line
# below. This flag affects xntpd only. This define is included by
# default when using the "make makeconfig" script.
#
# The next two sets of defines are meaningful only when radio clock
# drivers or special 1-pps signals are to be used. For systems without
# these features, these delicious complexities can be avoided. Ordinarily,
# the "make makeconfig" script figures out which ones to use, but your
# mileage may vary.
#
# There are three ways to utilize external 1-pps signals. Define
# -DPPS to include just the pps routine, such as used by the DCF77(PARSE)
# clock driver. Define -DPPSCLK to include a serial device driver
# which avoids much of the jitter due to upper level port
# processing. This requires a dedicated serial port and either the
# tty_clock line discipline or tty_clk_streams module, both of
# which are in the ./kernel directory. Define -DPPSCD to include a
# special driver which intercepts carrier-detect transitions
# generated by the pps signal. This requires a nondedicated serial
# port and the ppsclock streams module in the ./kernel directory.
# Only one of these three flags should be defined.
#
# The flag KERNEL_PLL causes code to be compiled for a special feature of
# the kernel that (a) implements the phase-lock loop and (b) provides
# a user interface to learn time, maximum error and estimated error.
# See the file README.kern in the doc directory for further info.
# This code is activated only if the relevant kernel features have
# been configured; it does not affect operation of unmodified kernels.
# To compile it, however, requires a few header files from the
# special distribution.
#
# Note: following line must always start with DEFS_LOCAL= $(DEFS_OPT)
DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DKERNEL_PLL -DMCAST
#
# Radio clock support definitions (these only make sense if -DREFCLOCK
# used), which is normally the case. Note that a configuration can include
# no clocks, more than one type of clock and even multiple clocks of the
# same type.
#
# For most radio clocks operating with serial ports, accuracy can
# be considerably improved through use of the tty_clk line
# discipline or tty_clk_STREAMS streams module found in the
# ./kernel directory. These gizmos capture a timestamp upon
# occurrence of an intercept character and stuff it in the data
# stream for the clock driver to munch. To select this mode,
# postfix the driver name with the string CLK; that is, WWVB
# becomes WWVBCLK. If more than one clock is in use, the CLK
# postfix can be used with any or all of them.
#
# Alternatively, for the best accuracy, use the ppsclock streams
# module in the ./ppsclock directory to steal the carrier-detect
# transition and capture a precision timestamp. At present this
# works only with SunOS 4.1.1 or later. To select this mode,
# postfix the driver name with the string PPS; that is, AS2201
# becomes AS2201PPS. If more than one clock is in use, the PPS
# postfix should be used with only one of them. If any PPS
# postfix is defined, the -DPPSPPS define should be used on the
# DEFS above.
#
# Define -DLOCAL_CLOCK for a local pseudo-clock to masquerade as a
# reference clock for those subnets without access to the real thing.
# Works in all systems and requires no hardware support. This is defined
# by default when using the "make makeconfig" script and greenhorn
# configuraiton.
#
# Define -DPST for a PST/Traconex 1020 WWV/H receiver. The driver
# supports both the CLK and PPS modes. It should work in all systems
# with a serial port.
#
# Define -DWWVB for a Spectracom 8170 or Netclock/2 WWVB receiver. It
# should work in all systems with a serial port. The driver supports
# both the CLK and PPS modes if the requisite kernel support is installed.
#
# Define -DCHU for a special CHU receiver using an ordinary shortwave
# radio. This requires the chu_clk line discipline or chu_clk_STREAMS
# module in the ./kernel directory. At present, this driver works only
# on SunOS4.1.x; operation in other systems has not been confirmed.
# Construction details for a suitable modem can be found in the ./gadget
# directory. The driver supports # neither the CLK nor PPS modes.
#
# Define -DPARSE for a DCF77/GPS(GENERIC) receiver. For best performance
# this requires a special parsestreams STREAMS (SunOS 4.x) module in the
# ./parse directory. Define -DPARSEPPS for PPS support via the
# DCF77/GPS (GENERIC) receiver; also, define -DPPS in the DEFS above.
# Define: -DCLOCK_MEINBERG for Meinberg clocks
# -DCLOCK_SCHMID for Schmid receivers
# -DCLOCK_DCF7000 for ELV DCF7000
# -DCLOCK_RAWDCF for simple receivers (100/200ms pulses on Rx)
# -DCLOCK_TRIMSV6 for Trimble SV6 GPS receiver
#
# Define -DMX4200PPS for a Magnavox 4200 GPS receiver. At present, this
# driver works only on SunOS4.1.x with CPU serial ports only. The PPS
# mode is required.
#
# Define -DAS2201 for an Austron 2200A or 2201A GPS receiver. It should
# work in all systems with a serial port. The driver does not support the
# CLK mode, but does support the PPS mode. If the radio is connected to
# more than one machine, the PPS mode is required.
#
# Define -DGOES for a Kinemetrics/TrueTime 468-DC GOES receiver. This
# driver is known to work with some other TrueTime products as well,
# including the GPS-DC GPS receiver. It should work in all systems with
# a serial port. The driver does not support the CLK mode, but does
# support the PPS mode.
#
# Define -DOMEGA for a Kinemetrics/TrueTime OM-DC OMEGA receiver. It
# should work in all systems with a serial port. The driver does not
# support the CLK mode, but does support the PPS mode.
#
# Define -DTPRO for a KSI/Odetics TPRO-S IRIG-B timecode reader. This
# requires the SunOS interface driver available from KSI. The driver
# supports neither the CLK nor PPS modes.
#
# Define -DLEITCH for a Leitch CSD 5300 Master Clock System Driver for
# the HP 5061B Cesium Clock. It should work in all systems with a serial
# port. The driver does not support the CLK mode, but does support the
# PPS mode.
#
# Define -DMSFEESPPS for an EES M201 MSF receiver. It currently only works
# under SunOS 4.x with the PPSCD (ppsclock) STREAMS module, but the RCS
# files on cl.cam.ac.uk still has support for CLK and CBREAK modes.
#
# Define -DIRIG for a IRIG-B timecode timecode using the audio codec of
# the Sun SPARCstations. This requires a modified BSD audio driver and
# exclusive access to the audio port. A memo describing how it works and
# how to install the driver is in the README.irig file in the ./doc
# directory.
#
# Note: The following defines result in compilation of all the above radio
# clocks. This works on a Sun 4.1.x system which has tty_clk, chu_clk and
# ppsclock STREAMS modules installed. If the trailing CLK and PPS suffixes
# are removed and the IRIG, PARSE* and CLOCK* deleted, all of the rest compile
# under Ultrix 4.2a/3. If the MX4200 is removed, all the rest compile on a DEC
# OSF/1 Alpha.
#
CLOCKDEFS= -DLOCAL_CLOCK -DAS2201PPS -DCHUPPS -DGOES -DIRIG -DMX4200PPS -DOMEGA -DPSTCLK -DTPRO -DWWVBCLK -DLEITCH
#
# Directory into which binaries should be installed (default /usr/local)
#
BINDIR= /usr/local/bin

View File

@ -1,190 +0,0 @@
# This is the local configure file (distribution version).
# You must modify it to fit your particular configuration
# and name it Config.local
# The following configuratiions can be auto-generated:
#
# make Config.local.green
# make a Config.local that supports a local clock
# (i.e. allow fallback to use of the CPU's own clock)
# make Config.local.NO.clock
# make a Config.local that supports no clocks
#
#
# NOTE TO GREENHORNS
#
# For plug-'n-play and no radios or other complicated gadgetry,
# use "make Config.local.green" as above.
#
# Following defines can be set in the DEFS_OPT= define:
#
# The flag -DDEBUG includes some debugging code. To use this, include
# the define and start the daemon with one or more -d flags, depending
# on your calibration of pearannoya. The daemon will not detach your
# terminal in this case. Judicious use of grep will reduce the speaker
# volume to bearable levels.
#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
# The -DSYSLOG_FILE defines allows logging messages that are normally
# reported via syslof() in a file. The file name can be configured using
# the configuration line "logfile <filename>" in CONFIG_FILE.
#
# There are three serial port system software interfaces, each of
# which is peculiar to one or more Unix versions. Define
# -DHAVE_SYSV_TTYS for basic System V compatibility; define -DSTREAM
# for POSIX compatibility including System V Streams, and
# HAVE_BSD_TTYS for 4.3bsd compatibility. Only one of these three
# should be defined. If none are defined, HAVE_BSD_TTYS is assumed.
# Usually these defines are already set correctly.
#
DEFS_OPT=-DDEBUG
#
# The DEFS_LOCAL define picks up all flags from DEFS_OPT (do not delete that)
# and one of the following:
#
# The flag -DREFCLOCK causes the basic reference clock support to be
# compiled into the daemon. If you set this you may also want to
# configure the particular clock drivers you want in the CLOCKDEFS= line
# below. This flag affects xntpd only. This define is included by
# default when using the "make makeconfig" script.
#
# The next two sets of defines are meaningful only when radio clock
# drivers or special 1-pps signals are to be used. For systems without
# these features, these delicious complexities can be avoided. Ordinarily,
# the "make makeconfig" script figures out which ones to use, but your
# mileage may vary.
#
# There are three ways to utilize external 1-pps signals. Define
# -DPPS to include just the pps routine, such as used by the DCF77(PARSE)
# clock driver. Define -DPPSCLK to include a serial device driver
# which avoids much of the jitter due to upper level port
# processing. This requires a dedicated serial port and either the
# tty_clock line discipline or tty_clk_streams module, both of
# which are in the ./kernel directory. Define -DPPSCD to include a
# special driver which intercepts carrier-detect transitions
# generated by the pps signal. This requires a nondedicated serial
# port and the ppsclock streams module in the ./kernel directory.
# Only one of these three flags should be defined.
#
# The flag KERNEL_PLL causes code to be compiled for a special feature of
# the kernel that (a) implements the phase-lock loop and (b) provides
# a user interface to learn time, maximum error and estimated error.
# See the file README.kern in the doc directory for further info.
# This code is activated only if the relevant kernel features have
# been configured; it does not affect operation of unmodified kernels.
# To compile it, however, requires a few header files from the
# special distribution.
#
# Note: following line must always start with DEFS_LOCAL= $(DEFS_OPT)
DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DKERNEL_PLL -DMCAST
#
# Radio clock support definitions (these only make sense if -DREFCLOCK
# used), which is normally the case. Note that a configuration can include
# no clocks, more than one type of clock and even multiple clocks of the
# same type.
#
# For most radio clocks operating with serial ports, accuracy can
# be considerably improved through use of the tty_clk line
# discipline or tty_clk_STREAMS streams module found in the
# ./kernel directory. These gizmos capture a timestamp upon
# occurrence of an intercept character and stuff it in the data
# stream for the clock driver to munch. To select this mode,
# postfix the driver name with the string CLK; that is, WWVB
# becomes WWVBCLK. If more than one clock is in use, the CLK
# postfix can be used with any or all of them.
#
# Alternatively, for the best accuracy, use the ppsclock streams
# module in the ./ppsclock directory to steal the carrier-detect
# transition and capture a precision timestamp. At present this
# works only with SunOS 4.1.1 or later. To select this mode,
# postfix the driver name with the string PPS; that is, AS2201
# becomes AS2201PPS. If more than one clock is in use, the PPS
# postfix should be used with only one of them. If any PPS
# postfix is defined, the -DPPSPPS define should be used on the
# DEFS above.
#
# Define -DLOCAL_CLOCK for a local pseudo-clock to masquerade as a
# reference clock for those subnets without access to the real thing.
# Works in all systems and requires no hardware support. This is defined
# by default when using the "make makeconfig" script and greenhorn
# configuraiton.
#
# Define -DPST for a PST/Traconex 1020 WWV/H receiver. The driver
# supports both the CLK and PPS modes. It should work in all systems
# with a serial port.
#
# Define -DWWVB for a Spectracom 8170 or Netclock/2 WWVB receiver. It
# should work in all systems with a serial port. The driver supports
# both the CLK and PPS modes if the requisite kernel support is installed.
#
# Define -DCHU for a special CHU receiver using an ordinary shortwave
# radio. This requires the chu_clk line discipline or chu_clk_STREAMS
# module in the ./kernel directory. At present, this driver works only
# on SunOS4.1.x; operation in other systems has not been confirmed.
# Construction details for a suitable modem can be found in the ./gadget
# directory. The driver supports # neither the CLK nor PPS modes.
#
# Define -DPARSE for a DCF77/GPS(GENERIC) receiver. For best performance
# this requires a special parsestreams STREAMS (SunOS 4.x) module in the
# ./parse directory. Define -DPARSEPPS for PPS support via the
# DCF77/GPS (GENERIC) receiver; also, define -DPPS in the DEFS above.
# Define: -DCLOCK_MEINBERG for Meinberg clocks
# -DCLOCK_SCHMID for Schmid receivers
# -DCLOCK_DCF7000 for ELV DCF7000
# -DCLOCK_RAWDCF for simple receivers (100/200ms pulses on Rx)
# -DCLOCK_TRIMSV6 for Trimble SV6 GPS receiver
#
# Define -DMX4200PPS for a Magnavox 4200 GPS receiver. At present, this
# driver works only on SunOS4.1.x with CPU serial ports only. The PPS
# mode is required.
#
# Define -DAS2201 for an Austron 2200A or 2201A GPS receiver. It should
# work in all systems with a serial port. The driver does not support the
# CLK mode, but does support the PPS mode. If the radio is connected to
# more than one machine, the PPS mode is required.
#
# Define -DGOES for a Kinemetrics/TrueTime 468-DC GOES receiver. This
# driver is known to work with some other TrueTime products as well,
# including the GPS-DC GPS receiver. It should work in all systems with
# a serial port. The driver does not support the CLK mode, but does
# support the PPS mode.
#
# Define -DOMEGA for a Kinemetrics/TrueTime OM-DC OMEGA receiver. It
# should work in all systems with a serial port. The driver does not
# support the CLK mode, but does support the PPS mode.
#
# Define -DTPRO for a KSI/Odetics TPRO-S IRIG-B timecode reader. This
# requires the SunOS interface driver available from KSI. The driver
# supports neither the CLK nor PPS modes.
#
# Define -DLEITCH for a Leitch CSD 5300 Master Clock System Driver for
# the HP 5061B Cesium Clock. It should work in all systems with a serial
# port. The driver does not support the CLK mode, but does support the
# PPS mode.
#
# Define -DMSFEESPPS for an EES M201 MSF receiver. It currently only works
# under SunOS 4.x with the PPSCD (ppsclock) STREAMS module, but the RCS
# files on cl.cam.ac.uk still has support for CLK and CBREAK modes.
#
# Define -DIRIG for a IRIG-B timecode timecode using the audio codec of
# the Sun SPARCstations. This requires a modified BSD audio driver and
# exclusive access to the audio port. A memo describing how it works and
# how to install the driver is in the README.irig file in the ./doc
# directory.
#
# Note: The following defines result in compilation of all the above radio
# clocks. This works on a Sun 4.1.x system which has tty_clk, chu_clk and
# ppsclock STREAMS modules installed. If the trailing CLK and PPS suffixes
# are removed and the IRIG, PARSE* and CLOCK* deleted, all of the rest compile
# under Ultrix 4.2a/3. If the MX4200 is removed, all the rest compile on a DEC
# OSF/1 Alpha.
#
CLOCKDEFS= -DLOCAL_CLOCK -DCHU -DGOES -DOMEGA -DPST -DWWVB -DLEITCH
#
# Directory into which binaries should be installed (default /usr/local)
#
BINDIR= /usr/local/bin

View File

@ -1,7 +0,0 @@
#
# Test suite for SunOS 5.x (no kernel mods, disciplines)
#
DEFS_OPT=-DDEBUG
DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DMCAST
CLOCKDEFS= -DACTS -DATOM -DAS2201 -DCHU -DDATUM -DGOES -DGPSTM -DHEATH -DIRIG -DLEITCH -DLOCAL_CLOCK -DMSFEES -DMX4200 -DNMEA -DOMEGA -DPST -DTPRO -DTRAK -DWWVB
BINDIR= /usr/local/bin

View File

@ -1,167 +0,0 @@
#
# This is the local configure file. Modify it to fit your particular
# configuration.
#
# NOTE TO GREENHORNS
#
# For plug-'n-play and no radios or other complicated gadgetry, set the
# alternate defines as shown.
#
# The flag -DDEBUG includes some debugging code. To use this, include
# the define and start the daemon with one or more -d flags, depending
# on your calibration of pearannoya. The daemon will not detach your
# terminal in this case. Judicious use of grep will reduce the speaker
# volume to bearable levels.
#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
# The flag -DREFCLOCK causes the basic reference clock support to be
# compiled into the daemon. If you set this you may also want to
# configure the particular clock drivers you want in the CLOCKDEFS= line
# below. This flag affects xntpd only. This define is included by
# default when using the "make makeconfig" script.
#
# The next two sets of defines are meaningful only when radio clock
# drivers or special 1-pps signals are to be used. For systems without
# these features, these delicious complexities can be avoided. Ordinarily,
# the "make makeconfig" script figures out which ones to use, but your
# mileage may vary.
#
# There are three ways to utilize external 1-pps signals. Define
# -DPPS to include just the pps routine, such as used by the DCF77
# clock driver. Define -DPPSCLK to include a serial device driver
# which avoids much of the jitter due to upper level port
# processing. This requires a dedicated serial port and either the
# tty_clock line discipline or tty_clk_streams module, both of
# which are in the ./kernel directory. Define -DPPSCD to include a
# special driver which intercepts carrier-detect transitions
# generated by the pps signal. This requires a nondedicated serial
# port and the ppsclock streams module in the ./kernel directory.
# Only one of these three flags should be defined.
#
# There are three serial port system software interfaces, each of
# which is peculiar to one or more Unix versions. Define
# -DHAVE_SYSV_TTYS for basic System V compatibility; define -DSTREAM
# for POSIX compatibility including System V Streams, and
# HAVE_BSD_TTYS for 4.3bsd compatibility. Only one of these three
# should be defined. If none are defined, HAVE_BSD_TTYS is assumed.
# Ordinarily, the correct define is sniffed by the "make makeconfig"
# script and automatically included.
#
# The flag KERNEL_PLL is a temporary hack to use when the phase-lock loop
# is implmented in the kernel. Do not use unless you have modified
# kernel routines (see doc/README.kern).
#
#DEFS_LOCAL= -DDEBUG -DPPSPPS -DKERNEL_PLL
DEFS_LOCAL= -DDEBUG
#DEFS_LOCAL= # for greenhorns
#
# Radio clock support definitions (these only make sense if -DREFCLOCK
# used), which is normally the case. Note that a configuration can include
# no clocks, more than one type of clock and even multiple clocks of the
# same type.
#
# For most radio clocks operating with serial ports, accuracy can
# be considerably improved through use of the tty_clk line
# discipline or tty_clk_STREAMS streams module found in the
# ./kernel directory. These gizmos capture a timestamp upon
# occurrence of an intercept character and stuff it in the data
# stream for the clock driver to munch. To select this mode,
# postfix the driver name with the string CLK; that is, WWVB
# becomes WWVBCLK. If more than one clock is in use, the CLK
# postfix can be used with any or all of them.
#
# Alternatively, for the best accuracy, use the ppsclock streams
# module in the ./ppsclock directory to steal the carrier-detect
# transition and capture a precision timestamp. At present this
# works only with SunOS 4.1.1 or later. To select this mode,
# postfix the driver name with the string PPS; that is, AS2201
# becomes AS2201PPS. If more than one clock is in use, the PPS
# postfix should be used with only one of them. If any PPS
# postfix is defined, the -DPPSPPS define should be used on the
# DEFS above.
#
# Define -DLOCAL_CLOCK for a local pseudo-clock to masquerade as a
# reference clock for those subnets without access to the real thing.
# Works in all systems and requires no hardware support. This is defined
# by default when using the "make makeconfig" script.
#
# Define -DPST for a PST/Traconex 1020 WWV/H receiver. The driver
# supports both the CLK and PPS modes. It should work in all systems
# with a serial port.
#
# Define -DWWVB for a Spectracom 8170 or Netclock/2 WWVB receiver. It
# should work in all systems with a serial port. The driver supports
# both the CLK and PPS modes if the requisite kernel support is installed.
#
# Define -DCHU for a special CHU receiver using an ordinary shortwave
# radio. This requires the chu_clk line discipline or chu_clk_STREAMS
# module in the ./kernel directory. At present, this driver works only
# on SunOS4.1.x; operation in other systems has not been confirmed.
# Construction details for a suitable modem can be found in the ./gadget
# directory. The driver supports # neither the CLK nor PPS modes.
#
# Define -DPARSE for a DCF77/GPS(GENERIC) receiver. For best performance
# this requires a special parsestreams STREAMS (SunOS 4.x) module in the
# ./kernel directory. Define -DPARSEPPS for PPS support via the
# DCF77/GPS (GENERIC) receiver; also, define -DPPS in the DEFS above.
# Define PARSESTREAM for utilising the STREAMS module for improved
# precision (currently only SunOS4.x)
#
# Define: -DCLOCK_MEINBERG for Meinberg clocks
# -DCLOCK_SCHMID for Schmid receivers
# -DCLOCK_DCF7000 for ELV DCF7000
# -DCLOCK_RAWDCF for simple receivers (100/200ms pulses on Rx)
#
# Define -DMX4200PPS for a Magnavox 4200 GPS receiver. At present, this
# driver works only on SunOS4.1.x with CPU serial ports only. The PPS
# mode is required.
#
# Define -DAS2201 for an Austron 2200A or 2201A GPS receiver. It should
# work in all systems with a serial port. The driver does not support the
# CLK mode, but does support the PPS mode. If the radio is connected to
# more than one machine, the PPS mode is required.
#
# Define -DGOES for a Kinemetrics/TrueTime 468-DC GOES receiver. This
# driver is known to work with some other TrueTime products as well,
# including the GPS-DC GPS receiver. It should work in all systems with
# a serial port. The driver does not support the CLK mode, but does
# support the PPS mode.
#
# Define -DOMEGA for a Kinemetrics/TrueTime OM-DC OMEGA receiver. It
# should work in all systems with a serial port. The driver does not
# support the CLK mode, but does support the PPS mode.
#
# Define -DTPRO for a KSI/Odetics TPRO-S IRIG-B timecode reader. This
# requires the SunOS interface driver available from KSI. The driver
# supports neither the CLK nor PPS modes.
#
# Define -DLEITCH for a Leitch CSD 5300 Master Clock System Driver for
# the HP 5061B Cesium Clock. It should work in all systems with a serial
# port. The driver does not support the CLK mode, but does support the
# PPS mode.
#
# Define -DMSF for a EES M201 MSF receiver. It should work in all systems
# with a serial port. The driver does not support the CLK mode, but does
# support the # PPS mode.
#
# Define -DIRIG for a IRIG-B timecode timecode using the audio codec of
# the Sun SPARCstations. This requires a modified BSD audio driver and
# exclusive access to the audio port. A memo describing how it works and
# how to install the driver is in the README.irig file in the ./doc
# directory.
#
# Note: The following defines result in compilation of all the above radio
# clocks. This works on a Sun 4.1.x system which has tty_clk, chu_clk and
# ppsclock STREAMS modules installed. If the trailing CLK and PPS suffixes
# are removed and the IRIG deleted, all of the rest compile under
# Ultrix 4.2a/3. If the MX4200 is removed, all the rest compile on a DEC
# OSF/1 Alpha.
#
#CLOCKDEFS= -DAS2201PPS -DCHU -DGOES -DIRIG -DMX4200PPS -DOMEGA -DPST -DPSTCLK -DTPRO -DWWVBCLK
CLOCKDEFS= # for greenhorns
#
# Directory into which binaries should be installed
#
BINDIR= /usr/etc

View File

@ -1,11 +0,0 @@
README file for directory ./conf of the NTP Version 3 distribution
This directory contains example run-time configuration files for the
NTP Version 3 daemon xntpd. These files illustrate some of the more
obtuse configurations you may run into. They are not likely to do
anything good if run on machines other than their native spot, so don't
just blindly copy something and put it up. Additional information can
be found in the ./doc directory of the base directory.
See the Config.local.dist file in the base directory for an explanation
of the defines used.

View File

@ -1,40 +0,0 @@
#
# NTP configuration file (ntp.conf)
# baldwin.udel.edu (128.4.1.24)
#
# This illustrates the use of an external clock with the local clock
# driver, as well as a multicast server. The prefer keyword on the
# local clock driver declares an external clock and that the time of
# this server should not be wiggled by an NTP peer, unless the
# external clock comes unstuck. Note the use of the multicast group
# ID assigned to NTP, 224.0.1.1, which identifies this as a multicast
# server rather than a broadcast one. The other NTP peers are known
# stratum-1 chimes intended as backup should the external clock croak.
#
peer 127.127.1.0 prefer # KSI/Odetics TPRO IRIG interface
fudge 127.127.1.0 stratum 0 refid GPS
broadcast 224.0.1.1 key 6 ttl 127
peer 128.4.1.1 # rackety.udel.edu (Sun4c/40 IPC)
peer 128.4.1.4 # barnstable.udel.edu (Sun4c/65 SS1+)
peer 128.4.1.2 # mizbeaver.udel.edu (Bancomm bc700LAN)
peer 128.4.1.20 # pogo.udel.edu (Sun4c/65 SS1+)
#
# Miscellaneous stuff
#
enable auth monitor # enable the good stuff
driftfile /etc/ntp.drift # path for drift file
statsdir /baldwin/ntpstats/ # directory for statistics files
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
filegen clockstats file clockstats type day enable
#
# Authentication stuff
#
keys /usr/local/bin/ntp.keys # path for keys file
trustedkey 3 4 5 6 14 15 # define trusted keys
requestkey 15 # key (7) for accessing server variables
controlkey 15 # key (6) for accessing server variables
authdelay 0.000163 # authentication delay (SPARC4c/40 IPC MD5)

View File

@ -1,46 +0,0 @@
#
# NTP configuration file (ntp.conf)
#
# Generic configuration file for UDel NTP stratum-2 time servers. Don't
# forget each server should have a /etc/ntp.drift and /etc/ntp.keys file.
#
# Stratum-1 peers. Each server should chime two different stratum-1
# servers from the following list. Each stratum-1 server should be used
# only once.
#
#peer 128.8.10.1 # umd1.umd.edu
#peer 18.72.0.3 version 2 # bitsy.mit.edu
peer 132.249.16.1 # fuzz.sdsc.edu
peer 128.118.46.3 version 2 # otc1.psu.edu
#peer 128.9.2.129 # wwvb.isi.edu
#peer 130.43.2.2 version 2 # apple.com
#peer 16.1.0.22 # clepsydra.dec.com
#peer 130.105.1.156 version 2 # clock.osf.orga
#peer 128.96.60.5 version 2 # pi.bellcore.com
#peer 128.4.1.1 # rackety.udel.edu
#peer 129.116.3.5 # shorty.chpc.utexas.edu
#
# Stratum-2 peers. Each server should chime all of the others in this
# list except itself.
#
peer 128.175.1.1 # huey.udel.edu (VAX)
#peer 128.175.1.2 # dewey.udel.edu (VAX)
peer 128.175.1.3 # louie.udel.edu (SPARC)
peer 128.175.2.15 # snow-white.ee.udel.edu (SPARC)
peer 128.175.7.4 # sol.cis.udel.edu (SPARC)
#
# Miscellaneous stuff
#
enable auth monitor # enable the good stuff
driftfile /etc/ntp.drift # path for drift file
#
# Authentication stuff. Note the different authentication delay on
# VAX and SPARC.
#
authenticate yes # enable authentication
keys /etc/ntp.keys # path for key file
trustedkey 1 2 15 # define trusted keys
requestkey 15 # key (7) for accessing server variables
controlkey 15 # key (6) for accessing server variables
authdelay 0.001501 # authentication delay (VAX)
#authdelay 0.000073 # authentication delay (SPARC)

View File

@ -1,157 +0,0 @@
#
# NTP configuration file (ntp.conf)
# grundoon.udel.edu (128.4.2.7)
#
# This machine can best be described as the kitchen sink. It has, in
# addition to the baseboard tty ports ttya and ttyb, an 8-line
# Serial/Parallel Interface (SPIF) with ports ttyz00 through ttyz07. The
# configuration includes the following drivers, clock addresses and Unix
# device names.
#
# Local Clock 127.127.1.0 /dev/audio
# PST 1020 WWV/WWVH Receiver 127.127.3.1 /dev/pst1
# Spectracom 8170 WWVB Receiver 127.127.4.1 /dev/wwvb1
# IRIG Audio Decoder 127.127.6.0 /dev/audio
# Scratchbuilt CHU Receiver 127.127.7.1 /dev/chu1
# NIST ACTS modem 127.127.18.1 /dev/acts1
# Heath GC-1000 WWV Receiver 127.127.19.1 /dev/pst1
# PPS Clock 127.127.22.1 none
#
# This machine has the kernel modifications described in the README.kern
# file, as well as the tty_clk, tty_chu and ppsclock streams modules.
#
# Spectracom 8170/Netclock-2 WWVB receiver. This receiver is equipped
# with a 1-pps and IRIG outputs. The 1-pps signal is connected via the
# ppsclock streams module and the carrier detect line of the CHU
# receiver below (ttyb). The IRIG signal is connected via an attenuator
# to the audio port (/dev/audio). The propagation delay computed from
# geographical coordinates is 8.8 ms, while the receiver delay
# calibrated at the factory is 17.3 ms, for a total delay of 26.1 ms.
# This is confirmed within 0.1 ms at the 1-pps signal output using a
# portable cesium clock. We add a fudge time1 of 3.5 ms so the driver
# time agrees with the 1-pps signal to within 1 ms. The fudge flag4 is
# set to cause the receiver to dump the quality table once each day to
# the clockstats file.
#
#server 127.127.4.1 # /dev/wwvb1 -> /dev/ttyz03
#fudge 127.127.4.1 time1 0.0035 flag4 1
#
# IRIG Audio Decoder. The IRGI signal of the Spectracom WWVB receiver is
# connected to the audio codec via a resistor attenuator. We add a fudge
# time1 of 3.5 ms so the driver agrees with the calibrated 1-pps signal
# to within 0.1 ms. We also specify a reference ID of WWVB to indicate
# the signal origin. Note the prefer keyword in the server line, which
# favors this driver over all others that survive the clock selection
# algorithm. See README.refclock for further insight on this feature.
#
server 127.127.6.0 prefer # /dev/audio
fudge 127.127.6.0 time1 0.0005 refid WWVB
#
# PST/Traconex 1020 WWV/WWVH Receier. The internal DIPswitches are set
# as near as possible to the delays to WWV (8.8 ms) and WWVH (28.1 ms),
# as computed from geographical coordinates. We add a fudge time1 of 5.9
# ms so the driver time agrees with the 1-pps signal to within 1 ms for
# WWV. We also set the stratum to 1, so this receiver will not normally
# be selected, unless the primary WWVB receiver comes unstuck.
#
server 127.127.3.1 # /dev/pst1 -> ttyz05
fudge 127.127.3.1 time1 0.0059 stratum 1
#
# Scratchbuilt CHU Receiver. The audio signal from a computer controlled
# CHU receiver is connected to a gadget box, which contains a 103A modem
# chip and level converter operating at 300 bps. The propagation delay
# computed from geographical coordinates is 3.0 ms, which is the value
# of the fudge time1 parameter. We add a fudge time2 of 9.9 ms so that
# the driver time agrees with the 1-pps signal to within a few ms,
# ordinarily the best possible with this receiver. The fudge flag3 is
# set because the 1-pps signal happens to be connected vit the carrier
# detect line on this port (ttyb). We also set the stratum to 1, so this
# receiver will not normally be selected, unless the primary WWVB
# receiver comes unstuck.
#
server 127.127.7.1 # /dev/chu1 -> /dev/ttyb
fudge 127.127.7.1 time1 0.0030 time2 0.0099 flag3 1 stratum 1
#
# NIST Automated Computer Time Service. This driver calls a special
# telephone number in Boulder, CO, to fetch the time directly from the
# NIST cesium farm. The details of the complicated calling program are
# in the README.refclock file. The Practical Peripherals 9600SA modem
# does not work correctly with the ACTS echo-delay scheme for
# automatically calculating the propagation delay, so the fudge flag2 is
# set to disable the feature. Instead, we add a fudge time1 of 65.0 ms
# so that the driver time agrees with th e1-pps signal to within 1 ms.
# The phone command specifies three alternate telephone numbers,
# including AT modem command prefix, which will be tried one after the
# other at each measurement attempt. In this case, a cron job is used to
# set fudge flag1, causing a measurement attempt, every six hours.
#
server 127.127.18.1 # /dev/acts1 -> /dev/ttyz00
fudge 127.127.18.1 time1 0.0650 flag2 1
phone atdt13034944774 atdt13034944785 atdt13034944774
#
# Heath GC-1000 Most Accurate Clock. This is a WWV receiver with a
# claimed accuracy better than 100 ms under "hi spec" conditions, but
# such conditions are not frequent. The propagation delay DIPswitchs are
# set to 9 ms, as close as possible to the 8.8 ms computed from
# geographical coordinates. We add a fudge time2 of 40.0 ms so that the
# driver time agrees with the 1-pps signal to within 50 ms, ordinarily
# the best possible with this receiver. We also set the stratum to 1, so
# this receiver will not normally be selected, unless the primary WWVB
# receiver comes unstuck.
#
server 127.127.19.1 # /dev/heath1 -> ttyz07
fudge 127.127.19.1 time1 0.040 stratum 1
#
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available. The
# default stratum is usually 3, but in this case we elect to use stratum
# 0. Since the server line does not have the prefer keyword, this driver
# is never used for synchronization, unless no other other
# synchronization source is available. In case the local host is
# controlled by some external source, such as an external oscillator or
# another protocol, the prefer keyword would cause the local host to
# disregard all other synchronization sources, unless the kernel
# modifications are in use and declare an unsynchronized condition.
#
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 0
#
# PPS Clock. This driver is used to capture a 1-pps signal when the PPS
# kernel modifications are not in use. It can be configured for the
# tty_clk or ppsclock streams module or no module at all, assuming the
# RS232 connector is properly wired. Normally, the 1-pps signal is
# generated by a radio clock, in this cast the Spectracom clock
# 127.127.4.1 also configured for this host. When used this way, the
# associated radio clock normally has the prefer keyword in the serve
# command line. The PPS driver then will be selected only if the prefer
# peer is operating within nominal error bounds. See the README.refclock
# file for further details.
#
#server 127.127.22.1 # pps clock
#
# Miscellaneous stuff. We enable authentication in order to prevent
#
enable auth monitor # enable the good stuff
driftfile /etc/ntp.drift # path for drift file
statsdir /grundoon/ntpstats/ # directory for statistics files
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
filegen clockstats file clockstats type day enable
#
# Authentication stuff
#
keys /usr/local/ntp.keys # path for keys file
trustedkey 1 2 3 4 5 6 14 15 # define trusted keys
requestkey 15 # key (7) for accessing server variables
controlkey 15 # key (6) for accessing server variables
authdelay 0.000163 # authentication delay (SPARC4c/40 IPC MD5)

View File

@ -1,33 +0,0 @@
#
# NTP configuration file (ntp.conf)
#
# This illustrates a multicast client. All that is really needed
# here is the multicastclient command and the authentication stuff.
# If the monitoring option and filgen statistics were not needed,
# this could be done without a configuration file by including the
# following snip in the rc.local startup file or equivalent:
#
#if [ -f /usr/local/bin/xntpd ]; then
# /usr/local/bin/xntpd -m -a -k/usr/local/bin/ntp.keys -t3
#fi
#
multicastclient # listen on default 224.0.1.1
#
# Miscellaneous stuff
#
enable auth monitor # enable the good stuff
driftfile /etc/ntp.drift # path for drift file
statsdir /malarky/ntpstats/ # directory for statistics files
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
filegen clockstats file clockstats type day enable
#
# Authentication stuff
#
keys /usr/local/bin/ntp.keys # path for key file
trustedkey 3 4 5 6 14 15 # define trusted keys
requestkey 15 # key (7) for accessing server variables
controlkey 15 # key (6) for accessing server variables
authdelay 0.000094 # authentication delay (Sun4c/50 IPX MD5)

View File

@ -1,27 +0,0 @@
#
# NTP configuration file (ntp.conf)
#
# This is for a broadcast/multicast client. Except for the statistics
# stuff, this can be done with only a commmand line of the form
#
# /usr/local/bin/xntpd -a -k /usr/local/bin/ntp.keys -m -t 3
#
multicastclient # listen on default 224.0.1.1
#
# Miscellaneous stuff
#
enable auth monitor # enable the good stuff
driftfile /etc/ntp.drift # path for drift file
statsdir /malarky/ntpstats/ # directory for statistics files
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
filegen clockstats file clockstats type day enable
#
# Authentication stuff
#
keys /usr/local/bin/ntp.keys # path for key file
trustedkey 3 4 5 6 14 # define trusted keys
requestkey 14 # key (7) for accessing server variables
controlkey 14 # key (6) for accessing server variables
authdelay 0.000094 # authentication delay (Sun4c/50 IPX MD5)

View File

@ -1,19 +0,0 @@
#
# XNTP configuration file (/etc/ntp.conf)
#
#
# Server is a Boeder DCF77 receiver
#
# Use:
# 127.127.8.40 for /dev/refclock-0 (/dev/ttyd0)
# 127.127.8.41 for /dev/refclock-1 (/dev/ttyd1)
# 127.127.8.42 for /dev/refclock-2 (/dev/ttyd2)
# 127.127.8.43 for /dev/refclock-3 (/dev/ttyd3)
#
server 127.127.8.40
#
# drift file
#
driftfile /etc/ntp.drift

View File

@ -1,34 +0,0 @@
#
# peers for gw.ccie.utoronto.ca (128.100.63.2, 128.100.49.104, 128.100.224.224)
#
peer 128.4.0.1 key 1 # dcn1.udel.edu
peer 128.8.10.1 key 2 # umd1.umd.edu
peer 128.116.64.3 key 3 # ncarfuzz.ucar.edu
peer 128.9.2.129 key 4 # wwvb.isi.edu
#peer 128.4.0.6 key 1 # dcn6.udel.edu
#
# Don't configure associations with the other secondaries. This is
# the only one in a machine room and will hold itself pretty stable
# when all else fails
#
monitor yes # keep track of traffic
#
# drift file
#
driftfile /etc/ntp.drift
#
# authentication stuff. We're running authenticated, tell it
# where the keys are and which to trust.
#
authenticate yes
authdelay 0.000323 # seconds, about right for an RT model 125
trustedkey 1 2 3 4 21 22 23 24
keys /etc/ntp.keys
#
# allow run time reconfiguration using key 65535
#
requestkey 65535
controlkey 65535

View File

@ -1,32 +0,0 @@
#
# peers for ipl.utcs.utoronto.ca (128.100.102.7)
#
peer 128.4.0.5 key 1 # dcn5.udel.edu
peer 128.8.10.1 key 2 # umd1.umd.edu
peer 192.12.207.1 key 3 # fuzz.sdsc.edu
peer 128.9.2.129 key 4 # wwvb.isi.edu
peer 128.100.63.2 key 21 # gw.ccie
peer 128.100.49.105 key 22 # suzuki.ccie
peer 128.100.102.4 key 23 # shiningtree.utcs
#
monitor yes # keep track of traffic
#
# drift file
#
driftfile /etc/ntp.drift
#
# authentication stuff. We're running authenticated, tell it
# where the keys are and which to trust.
#
authenticate yes
authdelay 0.000323 # seconds, about right for an RT model 125
trustedkey 1 2 3 4 21 22 23
keys /etc/ntp.keys
#
# allow run time reconfiguration using key 65535
#
requestkey 65535
controlkey 65535

View File

@ -1,156 +0,0 @@
#
# Maybe an alternate xntpd configuration for NSS#17
#
#
# precision is supported, but you don't really need it. The code
# will determine a precision from the kernel's value of _hz which
# is fine. Note you shouldn't claim too good a precision on a
# Unix machine even if the clock carries a lot of bits, since
# precision also depends on things like I/O delays and scheduling
# latencies, which Unix machines control poorly. If you claim better
# than -6 or -7 it will make the anti-hop aperture tighter than is
# reasonable for a Unix machine.
#
#precision -7
#
# peers are ncarfuzz.ucar.edu umd1.umd.edu dcn5.udel.edu fuzz.sdsc.edu
# syntax is peer addr [ key 1-15 ] [ version 1_or_2 ]
#
peer 128.116.64.3 # ncarfuzz.ucar.edu
peer 128.8.10.1 # umd1.umd.edu
peer 128.4.0.5 # dcn5.udel.edu
peer 192.12.207.1 # fuzz.sdsc.edu
#
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
# This is a nice feature. Once you've got the drift computed it hardly
# ever takes more than an hour or so to resync after a restart.
#
driftfile /etc/ntp.drift
#
# The server statement causes polling to be done in client mode rather
# than symmetric active. It is an alternative to the peer command
# above. Which you use depends on what you want to achieve. Usually
# it doesn't matter. Syntax is:
#
#server 128.100.49.1 key 4 version 1
#
# The broadcast statement tells it to start broadcasting time out one
# of its interfaces. Syntax is
#
#broadcast 128.100.49.255 # [ key n ] [ version n ]
#
# broadcastclient tells the daemon whether it should attempt to sync
# to broadcasts or not. Defaults to `no'.
#
#broadcastclient yes # or no
#
# broadcastdelay configures in a default round-trip delay to use for
# broadcast time. It may poll to improve this estimate.
#
#broadcastdelay 0.0095 # in seconds
#
# authenticate configures us into strict authentication mode (or not).
#
#authenticate yes # or no. Default is no
#
# authdelay is the time it takes to do an NTP encryption on this host.
# The current routine is pretty fast.
#
#authdelay 0.000340 # in seconds
#
# trustedkey are used when authenticate is on. We only trust (and sync to)
# peers who know these keys.
#
#trustedkey 1 3 4 8
#
# monitor turns on the monitoring facility. See xntpdc's monlist command.
# This shows a lot of neat stuff, but I'm not fussy about the implementation.
# Uses up to 20Kb of memory at run time. You could try this.
#
#monitor yes # or no. Default is no
#
# keys points at the file which holds the authentication keys.
#
#keys /etc/ntp.keys
#
# requestkey indicates which key is to be used for validating
# runtime reconfiguration requests. If this isn't defined, or the
# key isn't in the keys file, you can't do runtime reconfiguration.
# controlkey indicates which key is to be used for validating
# mode 6 write variables commands. If this isn't defined you can't
# do it. The only thing the latter is used for is to set leap second
# warnings on machines with radio clocks.
#
#requestkey 65535
#controlkey 65534
#
# restrict places restrictions on the punters. This is implemented as
# a sorted address-and-mask list, with each entry including a set of
# flags which define what a host matching the entry *can't* do (the sort
# also saves CPU time searching the table since it needn't be searched
# to the end). The last match in the table defines what the host does.
# The default entry, which everyone matches, is first, most specific
# matches are later in the table. The flags are:
#
# ignore - ignore all traffic from host
# noserve - don't give host any time (but let him make queries?)
# notrust - give host time, let him make queries, but don't sync to him
# noquery - host can have time, but not make queries
# nomodify - allow the host to make queries except those which are
# actually run-time configuration commands.
# notrap - don't allow matching hosts to set traps. If noquery is
# set this isn't needed
# lowpriotrap - if this guy sets a trap make it easy to delete
# ntpport - a different kind of flag. Makes matches for this entry
# possible only if the source port is 123.
#
# To understand this better, take a look at xntpdc's reslist command when the
# server is running. This usually prints in the sorted order.
#
# This should match the NSS 17 stuff. Default mask is all ones.
restrict default ignore # ignore almost everyone
#
# These guys can be served time and make non-modifying queries
#
restrict 129.140.0.0 mask 255.255.0.0 notrust nomodify
restrict 35.1.1.42 notrust nomodify
#
# Rest of 35.1.1 gets to look but not touch
#
restrict 35.1.1.0 mask 255.255.255.0 noserve nomodify
#
# modifications can be made from local NSS only
#
restrict 129.140.17.0 mask 255.255.255.0 notrust
restrict 127.0.0.1 notrust
#
# take time from the following peers, but don't let them peek or modify
#
restrict 128.116.64.3 noquery
restrict 128.8.10.1 noquery
restrict 128.4.0.5 noquery
restrict 192.12.207.1 noquery

View File

@ -1,32 +0,0 @@
#
# peers for shiningtree.utcs.utoronto.ca (128.100.102.4)
#
peer 128.4.0.1 key 1 # dcn1.udel.edu
peer 130.126.174.40 key 2 # truechimer.cso.uiuc.edu
peer 192.12.207.1 key 3 # fuzz.sdsc.edu
peer 128.116.64.3 key 4 # ncarfuzz.ucar.edu
peer 128.100.63.2 key 21 # gw.ccie
peer 128.100.49.105 key 22 # suzuki.ccie
peer 128.100.102.7 key 23 # ipl.utcs
#
monitor yes # keep track of traffic
#
# drift file
#
driftfile /etc/ntp.drift
#
# authentication stuff. We're running authenticated, tell it
# where the keys are and which to trust.
#
authenticate yes
authdelay 0.000323 # seconds, about right for an RT model 125
trustedkey 1 2 3 4 21 22 23
keys /etc/ntp.keys
#
# allow run time reconfiguration using key 65535
#
requestkey 65535
controlkey 65535

View File

@ -1,43 +0,0 @@
#
# peers for suzuki.ccie.utoronto.ca (128.100.49.105, 128.100.224.225)
#
#
# the reference clock, /dev/chu1
#
server 127.127.7.1 key 4
# Propagation delay 2.5 ms, sloppy clock flag on
fudge 127.127.7.1 time1 0.0025 flag1 1
peer 128.4.0.5 key 1 # dcn5.udel.edu
peer 128.8.10.1 key 2 # umd1.umd.edu
peer 128.116.64.34 key 3 # ncarfuzz.ucar.edu
peer 130.126.174.40 key 4 # truechimer.cso.uiuc.edu
peer 128.100.49.104 key 24 # gw.ccie
peer 128.100.102.4 key 22 # shiningtree.utcs
peer 128.100.102.7 key 22 # ipl.utcs
peer 128.4.0.6 key 1 # dcn6.udel.edu
#
monitor yes # keep track of traffic
#
# drift file
#
driftfile /etc/ntp.drift
#
# authentication stuff. We're running authenticated, tell it
# where the keys are and which to trust.
#
authenticate yes
authdelay 0.000323 # seconds, about right for an RT model 125
trustedkey 1 2 3 4 21 22 23 24
keys /etc/ntp.keys
#
# allow run time reconfiguration using key 65535
#
requestkey 65535
controlkey 65535

View File

@ -1,34 +0,0 @@
#
# NTP configuration file (ntp.conf)
# pogo.udel.edu (128.4.1.20)
#
server 127.127.10.1 prefer # austron 2201A gps receiver
peer 128.4.1.1 # rackety.udel.edu (Sun4c/40 IPC)
peer 128.4.1.2 # mizbeaver.udel.edu (Bancomm bc700LAN)
peer 128.4.1.4 # barnstable.udel.edu (Sun4c/65 SS1+)
peer 128.4.1.5 maxpoll 8 # churchy.udel.edu (cisco IGS router)
peer 132.163.135.130 maxpoll 8 # time_A.timefreq.bldrdoc.gov (Cesium)
peer 131.188.1.40 maxpoll 8 # ntps1-0.uni-erlangen.de (DCF77)
peer 129.132.2.21 maxpoll 8 # swisstime.ethz.ch (DCF77)
peer 130.155.98.13 maxpoll 8 # terss.ml.csiro.au (Cesium)
peer 192.36.143.150 maxpoll 8 # Time1.Stupi.SE (Cesium)
#
# Miscellaneous stuff
#
enable auth monitor # enable the good stuff
precision -18 # clock reading precision (usec)
driftfile /etc/ntp.drift # path for drift file
statsdir /pogo/ntpstats/ # directory for statistics files
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
filegen clockstats file clockstats type day enable
#
# Authentication stuff
#
keys /usr/local/bin/ntp.keys # path for keys file
trustedkey 3 4 5 6 14 # define trusted keys
requestkey 15 # key (7) for accessing server variables
controlkey 15 # key (6) for accessing server variables
authdelay 0.000159 # authentication delay (SPARC4c/65 SS1+ MD5)

View File

@ -1,69 +0,0 @@
#
# NTP configuration file (ntp.conf)
# rackety (128.4.1.1)
#
server 127.127.10.1 prefer # austron 2201A gps receiver
fudge 127.127.10.1 flag4 1 # enable statistics
server 127.127.4.1 # spectracom 8170/netclock-2 wwvb receiver
# propagation delay: wwvb 0.0088, receiver delay 0.0173, os delay .0035
fudge 127.127.4.1 time1 0.0035 stratum 1 flag4 1
#
# ee vaxen
#
peer 128.175.1.1 # huey.udel.edu
peer 128.175.1.2 # louie.udel.edu
peer 128.175.1.3 # dewey.udel.edu
#
# munchkins (stratum-1 only)
#
broadcast 224.0.1.1 key 5 ttl 127 # multicast
broadcast 128.4.1.0 key 3 # local broadcast
peer 128.4.1.2 # mizbeaver.udel.edu
peer 128.4.1.4 # barnstable.udel.edu
peer 128.4.1.20 # pogo.udel.edu
#
# dartnet
#
peer 140.173.112.2 # ames.dart.net
peer 140.173.128.1 # la.dart.net
peer 140.173.64.1 # dc.dart.net
peer 140.173.144.2 # parc.dart.net
peer 140.173.80.1 # sri.dart.net
peer 140.173.96.1 # lbl.dart.net
peer 140.173.128.2 # isi.dart.net
peer 140.173.16.1 # udel.dart.net
peer 140.173.32.1 # bbn.dart.net
peer 140.173.48.2 # mit.dart.net
#
# nsfnet t3 backbone
#
server 140.222.134.1 version 2 # enss134 (cambridge - mit)
server 140.222.135.1 version 2 # enss135 (san diego - sdsc)
peer 140.222.136.1 version 2 # enss136 (college park - sura)
server 140.222.141.1 version 2 # enss141 (boulder - ncar)
server 140.222.144.1 version 2 # enss144 (sunnyvale - nasa ames)
#
# Miscellaneous stuff
#
enable auth monitor # enable the good stuff
precision -18 # clock reading precision (usec)
driftfile /etc/ntp.drift # path for drift file
statsdir /rackety/ntpstats/ # directory for statistics files
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
filegen clockstats file clockstats type day enable
#
# Authentication stuff
#
keys /usr/local/bin/ntp.keys # path for keys file
trustedkey 3 4 5 6 14 # define trusted keys
requestkey 14 # key (7) for accessing server variables
controlkey 14 # key (6) for accessing server variables
authdelay 0.000163 # authentication delay (SPARC4c/40 IPC MD5)

View File

@ -1,33 +0,0 @@
#
# NTP configuration file (ntp.conf)
# snow-white.udel.edu (128.175.2.15)
#
# Stratum-2 peers
#
peer 128.175.1.1 # huey.udel.edu
peer 128.175.1.2 # dewey.udel.edu
#peer 128.175.1.3 # louie.udel.edu
peer 128.175.2.33 # louie.udel.edu
#peer 128.175.7.39 # louie.udel.edu
#
# Stratum-3 peers
#
peer 128.175.7.4 # sol.cis.udel.edu
peer 128.175.7.18 # ra.cis.udel.edu
#peer 128.175.2.15 # snow-white.ee.udel.edu
peer 128.175.2.21 # opus.ee.udel.edu
#
# Miscellaneous stuff
#
monitor yes # enable monitoring
precision -18 # clock reading precision (1 usec)
driftfile /etc/ntp.drift # path for drift file
#
# Authentication stuff
#
authenticate yes # enable authentication
keys /etc/ntp.keys # path for key file
trustedkey 1 2 15 # define trusted keys
requestkey 15 # key (7) for accessing server variables
controlkey 15 # key (6) for accessing server variables
authdelay 0.000077 # authentication delay (SPARC IPC)

View File

@ -1,306 +0,0 @@
Audio IRIG Receiver for Precision Timekeeping
Revised 20 September 1993
Note: This information file is included in both the BSD audio driver
distribution (bsd_audio.tar.Z) and NTP Version 3 distribution
(xntp3.tar.Z) as the file README.irig. Both distributions can be
obtained via anonymous ftp from louie.udel.edu in the directory pub/ntp.
1. Introduction
This software distribution includes modifications to the BSD audio
driver for the Sun SPARCstation written by Van Jacobson and
collaborators at Lawrence Berkeley National Laboratory. The
modifications provide for the connection of a standard Inter-Range
Instrumentation Group (IRIG) timecode signal generator and the decoding
of the signal to produce data sufficient to synchronize a host clock to
the IRIG signal. There are several timing receivers now on the market
that can produce IRIG signals, including those made by Austron,
TrueTime, Odetics and Spectracom, among others. These data can be used
to precisely synchronize the host computer clock to within a few
microseconds without requiring level converters or pulse generators
necessary with the one-pulse-per-second signals also produced by these
receivers. The current implementation of the Network Time Protocol
Version 3 supports the modified BSD driver when installed in the SunOS
4.1.x kernel.
The specific IRIG signal format supported by the driver is designated
IRIG-B. It consists of an amplitude-modulated 1000-Hz sinewave, where
each symbol is encoded as ten full carrier cycles, or 10 ms in duration.
The symbols are distinguished using a pulse-width code, where 2 ms
corresponds to logic zero, 5 ms to logic one and 8 ms to a position
identifier used for symbol synchronization. The complete IRIG-B message
consists of a frame of ten fields, each field consisting of a nine
information symbols followed by a position identifier for a total frame
duration of one second. The first symbol in the frame is also a position
identifier to facilitate frame synchronization.
The IRIG-B signal encodes the day of year and time of day in binary-
coded decimal (BCD) format, together with a set of control functions,
which are not used by the driver, but included in the raw binary
timecode. Either the BCD timecode or the combined raw timecode and BCD
timecode can be returned in response to a read() system call. The BCD
timecode is in handy ASCII format: "ddd hh:mm:ss*" for convenience in
client programs. In this format the "*" status character is " " when the
driver is operating normally and "?" when errors may be present (see
below). In order to reduce residual errors to the greatest extent
possible, the driver computes a timestamp based on the value of the
kernel clock at the on-time epoch of the IRIG-B signal. In addition, the
driver automatically adjusts for slowly varying amplitude levels of the
IRIG-B signal and suppresses noise transients.
In operation the IRIG driver interprets the IRIG-B signal in real time,
synchronizes to the signal, demodulates the data bits and prepares the
data to be read later. At the on-time epoch a timestamp is captured from
the kernel clock and adjusted for the phase of the IRIG carrier signal
relative to the 8-kHz codec sample clock. When a client program issues a
read() request, the most recent timecode data, including a status byte
and the corrected timestamp, are stored in a structure and returned to
the caller. Depending on the frequency with which the driver is called,
this may result in old data or duplicate data or even invalid data,
should the driver be called before it has computed its first timestamp.
In practice, the resulting ambiguity causes few problems. The caller
converts the ASCII timecode returned by a read() system call to Unix
timeval format and subtracts it from the kernel timestamp provided by
the driver. The result is an adjustment that can be subtracted from the
kernel time, as returned in a gettimeofday() call, for example, to
correct for the deviation between IRIG time and kernel time. The result
can always be relied on to within plus/minus 128 microseconds, the audio
codec sampling interval, and ordinarily to within a few microseconds, as
determined by the interpolation algorithm.
2. Programming Interface
The IRIG driver modifications are integrated in the BSD audio driver
bsd_audio.c without affecting its usual functions in transmitting and
receiving ordinary speech, except when enabled by specific ioctl()
system calls. However, the driver cannot be used for both speech and
IRIG signals at the same time. Once activated by a designated ioctl()
call, the driver remains active until it is explicitly deactivated by
another ioctl() call. This allows applications to configure the audio
device and pass the pre-configured driver to other applications. Since
the driver is currently only a receiver, it does not affect the
operation of the BSD audio output driver.
Data are read using the standard read() system call. Since the output
formats have constant lengths, the application receives the data into a
fixed-length buffer or structure. The read() call never blocks; it
simply returns the most recent IRIG data received during the last
second. It may happen that, due to unavoidable race conditions in the
kernel, data for other than the most recent second are returned. The
driver's internal data structure is updated as an atomic unit; thus, the
entire structure is valid, even if it contains old data. This should
cause no problems, since in the intended application the driver is
called at regular intervals by a time-synchronization daemon such as
NTP. The daemon can determine the validity of the time indication by
checking the timecode or status byte returned with the data.
The header file bsd_audioirig.h defines the irig_time structure and
ioctl() codes used by the driver. Following are those codes specific to
the IRIG function of the driver. Unless indicated otherwise, the (third)
argument of the ioctl() system call points to an integer or string.
AUDIO_IRIG_OPEN
This command activates the IRIG receiver. The audio driver must be
opened with this command before other commands can be issued. The
argument is ignored. When the IRIG receiver is initialized, all
internal data are purged and any buffered data are lost.
AUDIO_IRIG_CLOSE
This command deactivates the IRIG receiver. The argument is
ignored. The buffers are purged and any buffered time data are
lost. The original BSD audio driver functions are enabled and it
resumes operating normally.
AUDIO_IRIG_SETFORMAT
The argument is a pointer to an integer designating the output
format for the IRIG data. There are currently two formats defined,
0 (default) and 1. If an invalid format is selected, the default
format is used.
The data returned by a read() system call in format 0 is a character
string in the format "ddd hh:mm:ss*\n", which consists of 13 ASCII
characters followed by a newline terminator for a total of 14
characters. The "*" status character is an ASCII space " " if the status
byte determined by the driver is zero and "?" if not. This format is
intended to be used with simple user programs that care only about the
time to the nearest second.
The data returned by a read() system call in format 1 is a structure
defined in the bsd_audioirig.h header file:
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 */
};
The irig-time.stamp is a pair of 32-bit longwords in Unix timeval
format, as defined in the sys/time.h header file. The first word is the
number of seconds since 1 January 1970, while the second is the number
of microseconds in the current second. The timestamp is captured at the
most recent on-time instant of the IRIG timecode and applies to all
other values returned in the irig_time structure.
The irig_time.bits[13] is a vector of 13 bytes to hold the 100-bit,
zero-padded raw binary timecode, packed 8 symbols per byte. The symbol
encoding maps IRIG one to 1 and both IRIG zero and IRIG position
identifier to 0. The order of encoding is illustrated by the following
diagram (the padding bits are represented by xxxx, which are set to
zero):
IRIG symbol number 00000000001111111111 . . . 8888889999999999xxxx
01234567890123456789 . . . 4567890123456789xxxx
-----------------------------------------------
bits byte number <--00--><--01--><---- ----><--11--><--12-->
bits bit in byte 01234567012345670123 . . . 45670123456701234567
The irig_time.status is a single byte with bits defined in the
bsd_audioirig.h header file. In ordinary operation all bits of the
status byte are zero and the " " status character is set in the ASCII
timecode. If any of these bits are nonzero, the "?" status character is
set in the ASCII timecode.
AUDIO_IRIG_BADSIGNAL
The signal amplitude is outside tolerance limits, either in
amplitude or modulation depth. The indicated time may or may not be
in error. If the signal is too high, it may be clipped by the
codec, so that the pulse width cannot be reliably determined. If
too low, it may be obscured by noise. The nominal expectation is
that the peak amplitude of the signal be maintained by the codec
AGC at about 10 dB below the clipping level and that the modulation
index be at least 0.5 (6 dB).
AUDIO_IRIG_BADDATA
An invalid hex code (A through F) has been found where BCD data is
expected. The ASCII representation of the invalid code is set to
"?". Errors of this type are most likely due to noise on the IRIG
signal due to ground loops, coupling to other noise sources, etc.
AUDIO_IRIG_BADSYNC
A code element has been found where a position identifier should be
or a position identifier has been found where a code element should
be. The time is meaningless and should be disregarded. Errors of
this type can be due to severe noise on the IRIG signal due to
ground loops, coupling to other noise sources, etc., or during
initial acquisition of the signal.
AUDIO_IRIG_BADCLOCK
Some IRIG timecode generators can indicate whether or not the
generator is operating correctly or synchronized to its source of
standard time using a designated field in the raw binary timecode.
Where such information is available and the IRIG decoder can detect
it, this bit is set when the generator reports anything except
normal operating conditions.
AUDIO_IRIG_OLDDATA
The IRIG time has not changed since the last time it was returned
in a read() call. This is not normally considered an error, unless
it persists for longer than a few seconds, in which case it
probably indicates a hardware problem.
The irig_time.time[14] vector is a character string in the format "ddd
hh:mm:ss*\0", which consists of 13 ASCII characters followed by a zero
terminator. The "*" status character is an ASCII space " " if the status
byte is zero and "?" if not. This format is identical to format 0,
except that in format 1 the time string is null-terminated.
2.1. Programming Example
The following pseudo-code demonstrates how the IRIG receiver may be used
by a simple user program. Of course, real code should include error
checking after each call to ensure the driver is communicating properly.
It should also verify that the correct fields in the structure are being
filled by the read() call.
include "bsd_audioirig.h"
int format = 1;
struct irig_time it;
Audio_fd = open("/dev/audio", O_RDONLY);
ioctl(Audio_fd, AUDIO_IRIG_OPEN, NULL);
ioctl(Audio_fd, AUDIO_IRIG_SETFORMAT,&format);
while (condition)
read(Audio_fd, &it, sizeof(it);
printf("%s\n", it.time);
ioctl(Audio_fd, AUDIO_IRIG_CLOSE, NULL);
close(Audio_fd);
3. Implementation and Configuration Notes
The signal level produced by most IRIG-equipped radios is on the order
of a few volts peak-peak, which is far larger than the audio codec can
accept; therefore, an attenuator in the form of a voltage divider is
needed. The codec can handle IRIG signals at the microphone input from
4.2mV to 230mV peak-peak. A suitable attenuator conists of a series-
connected 100K-Ohm resistor at the input and a parallel-connected 1K-Ohm
resistor at the output, both contained along with suitable connectors in
a small aluminum box. The exact values of these resistors are not
critical, since the IRIG driver includes an automatic level-adjustment
capability.
For the most accurate time using the IRIG signal and a particular radio,
it may be necessary to adjust the time1 parameter of the fudge command
to compensate for the codec delay and any additional delay due to IRIG
processing in the radio itself. Since the codec samples at an 8-kHz
rate, the average delay is about 62 usec; however, the delays due to the
radios and IRIG signals themselves can vary. For instance, in the
Austron recievers the IRIG delay is essentially zero, while in the
Spectracom receivers the delay is about 240 usec relative to the 1-pps
signal. In addition, the poll interval can be reduced from the usual 64
seconds to 16 seconds to reduce wander of the local hardware clock.
Finally, the prefer parameter can be used to bias the clock-selection
algorithm to favor the IRIG time, which is ordinarily the best time
available. For example, the following two lines in the NTP configuration
file ntp.conf are appropriate for the Spectracom Netclock/1 WWVB
Synchronized Clock with IRIG Option:
server 127.127.6.0 prefer minpoll 4 maxpoll 4 # irig audio decoder
fudge 127.127.6.0 time1 0.0005
The time1 value of .0005 s (500 usec) was determined by actual
measurement. Since the IRIG delay in Austron receivers is essentially
zero, the fudge command is not necessary with these receivers. The
correct value in case of other radios may have to be determined by
actual measurement. A convenient way of doing this is to configure the
PPSPPS feature in the NTP Version 3 distribution and adjust time1 until
the 1-pps signal and IRIG signal both show the same offset.
The modified BSD driver includes both the modified driver itself
bsd_audio.c and the IRIG header file bsd_audioirig.h, as well as
modified header files bsd_audiovar.h and bsd_audioio.h. The driver is
installed in the same way as described in the BSD driver documentation,
with the addition of the following define in the kernel configuration
file:
options AUDIO_IRIG # IRIG driver
This causes the IRIG code to be included in the BSD driver, as well as a
C-coded codec interrupt routine which replaces the assembly-coded
routine and provides the IRIG functionality. While the C-coded routine
is somewhat slower than the assembly-coded routine, the extra overhead
is not expected to be significant. Note that the IRIG driver calls the
kernel routine microtime() as included in the ppsclock directory of the
NTP Version 3 distribution xntp3. It is highly recommended that this
routine be installed in the kernel configuration as well. The
instructions for doing this are contained in the ppsclock directory of
the xntp3 distribution.
Roy LeCates <lecates@udel.edu> and David Mills <mills@udel.edu>
Electrical Engineering Department
University of Delaware
Newark, DE 19716
302 831 8247 fax 302 831 4316
24 August 1993

File diff suppressed because it is too large Load Diff

View File

@ -1,346 +0,0 @@
Magic Tricks for Precision Timekeeping
Revised 19 September 1993
Note: This information file is included in the NTP Version 3
distribution (xntp3.tar.Z) as the file README.magic. This distribution
can be obtained via anonymous ftp from louie.udel.edu in the directory
pub/ntp.
1. Introduction
It most cases it is possible using NTP to synchronize a number of hosts
on an Ethernet or moderately loaded T1 network to a radio clock within a
few tens of milliseconds with no particular care in selecting the radio
clock or configuring the servers on the network. This may be adequate
for the majority of applications; however, modern workstations and high
speed networks can do much better than that, generally to within some
fraction of a millisecond, by using special care in the design of the
hardware and software interfaces.
The timekeeping accuracy of a NTP-synchronized host depends on two
quantities: the delay due to hardware and software processing and the
accumulated jitter due to such things as clock reading precision and
varying latencies in hardware and software queuing. Processing delays
directly affect the timekeeping accuracy, unless minimized by systematic
analysis and adjustment. Jitter, on the other hand, can be essentially
removed, as long as the statistical properties are unbiased, by the low-
pass filtering of the phase-lock loop incorporated in the NTP local
clock model.
This note discusses issues in the connection of external time sources
such as radio clocks and related timing signals to a primary (stratum-1)
NTP time server. Of principal concern are various techniques that can be
utilized to improve the accuracy and precision of the time accuracy and
frequency stability. Radio clocks are most often connected to a time
server using a serial asynchronous port. Much of the discussion in this
memorandum has to do with ways in which the delay incurred in this type
of connection can be controlled and ways in which the jitter due to
various causes can be minimized.
However, there are ways other than serial ports to connect a radio
clock, including special purpose hardware devices for some
architectures, and even unusual applications of existing interface
devices, such as the audio codec provided in some systems. Many of these
methods can yield accuracies as good as any attainable with a serial
port. For those radio clocks equipped with an IRIG-B signal output, for
example, a hardware device is available for the Sun SPARCstation; see
the xntpd.8 manual page in the doc directory of the NTP Version 3
distribution for further information. In addition, it is possible to
decode the IRIG-B signal using the audio codec included in the Sun
SPARCstation and a special kernel driver described in the irig.txt file
in the doc directory of the NTP Version 3 distribution. These devices
will not be discussed further in this memorandum.
2. Connection via Serial Port
Most radio clocks produce an ASCII timecode with a precision only to the
millisecond. This results in a maximum peak-to-peak (p-p) jitter in the
clock readings of one millisecond. However, assuming the read requests
are statistically independent of the clock update times, the reading
error is uniformly distributed over the millisecond, so that the average
over a large number of readings will make the clock appear 0.5 ms late.
To compensate for this, it is only necessary to add 0.5 ms to its
reading before further processing by the NTP algorithms.
Radio clocks are usually connected to the host computer using a serial
port operating at a typical speed of 9600 baud. The on-time reference
epoch for the timecode is usually the start bit of a designated
character, usually <CR>, which is part of the timecode. The UART chip
implementing the serial port most often has a sample clock of eight to
16 times the basic baud rate. Assuming the sample clock starts midway in
the start bit and continues to midway in the first stop bit, this
creates a processing delay of 10.5 baud times, or about 1.1 ms, relative
to the start bit of the character. The jitter contribution is usually no
more than a couple of sample-clock periods, or about 26 usec p-p. This
is small compared to the clock reading jitter and can be ignored. Thus,
the UART delay can be considered constant, so the hardware contribution
to the total mean delay budget is 0.5 + 1.1 = 1.6 ms.
In some kernel serial port drivers, in particular, the Sun zs driver,
an intentional delay is introduce in input character processing when the
first character is received after an idle period. A batch of characters
is passed to the calling program when either (a) a timeout in the
neighborhood of 10 ms expires or (b) an input buffer fills up. The
intent in this design is to reduce the interrupt load on the processor
by batching the characters where possible. Obviously, this can cause
severe problems for precision timekeeping. It is possible to patch the
zs driver to eliminate the jitter due to this cause; contact the author
for further details. However, there is a better solution which will be
described later in this note. The problem does not appear to be present
in the Serial/Parallel Controller (SPC) for the SBus, which contains
eight serial asynchronous ports along with a parallel port. The
measurements referred to below were made using this controller.
Good timekeeping depends strongly on the means available to capture an
accurate sample of the local clock or timestamp at the instant the stop
bit of the on-time character is found; therefore, the code path delay
between the character interrupt routine and the first place a timestamp
can be captured is very important, since on some systems such as Sun
SPARCstations, this path can be astonishingly long. The Sun scheduling
mechanisms involve both a hardware interrupt queue and a software
interrupt queue. Entries are made on the hardware queue as the interrupt
is signalled and generally with the lowest latency, estimated at 20-30
microseconds (usec) for a SPARC 4/65 IPC. Then, after minimal
processing, an entry is made on the software queue for later processing
in order of software interrupt priority. Finally, the software interrupt
unblocks the NTP daemon which calculates the current local clock offset
and introduces corrections as required.
Opportunities exist to capture timestamps at the hardware interrupt
time, software interrupt time and at the time the NTP daemon is
activated, but these involve various degrees of kernel trespass and
hardware gimmicks. To gain some idea of the severity of the errors
introduced at each of these stages, measurements were made using a Sun
4/65 IPC and a test setup that results in an error between the host
clock and a precision time source (calibrated cesium clock) no greater
than 0.1 ms. The total delay from the on-time epoch to when the NTP
daemon is activated was measured at 8.3 ms in an otherwise idle system,
but increased on rare occasion to over 25 ms under load, even when the
NTP daemon was operated at the highest available software priority
level. Since 1.6 ms of the total delay is due to the hardware, the
remaining 6.7 ms represents the total code path delay accounting for all
software processing from the hardware interrupt to the NTP daemon.
It is commonly observed that the latency variations (jitter) in typical
real-time applications scale as the processing delay. In the case above,
the ratio of the maximum observed delay (25 ms) to the baseline code
path delay (8.3 ms) is about three. It is natural to expect that this
ratio remain the same or less as the code path between the hardware
interrupt and where the timestamp is captured is reduced. However, in
general this requires trespass on kernel facilities and/or making use of
features not common to all or even most Unix implementations. In order
to assess the cost and benefits of increasingly more aggressive insult
to the hardware and software of the system, it is useful to construct a
budget of the code path delay at each of the timestamp opportunity
times. For instance, on Unix systems which include support for the SIGIO
facility, it is possible to intervene at the time the software interrupt
is serviced. The NTP daemon code uses this facility, when available, to
capture a timestamp and save it along with the data in a buffer for
later processing. This reduces the total code path delay from 6.7 ms to
3.5 ms on an otherwise idle system. This reduction applies to all input
processing, including network interfaces and serial ports.
3. The CLK Mode
By far the best place to capture the timestamp is right in the kernel
interrupt routine, but this gerally requires intruding in the code
itself, which can be intricate and architecture dependent. The next best
place is in some routine close to the interrupt routine on the code
path. There are two ways to do this, depending on the ancestry of the
Unix operating system variant. Older systems based primarily on the
original Unix 4.3bsd support what is called a line discipline module,
which is a hunk of code with more-or-less well defined interface
specifications that can get in the way, so to speak, of the code path
between the interrupt routine and the remainder of the serial port
processing. Newer systems based on System V STREAMS can do the same
thing using what is called a streams module. Both approaches are
supported in the NTP Version 3 distribution, as described in the README
files in the kernel directory of the distribution. In either case,
header and source files have to be copied to the kernel build tree and
certain tables in the kernel have to be modified. In neither case,
however, are kernel sources required. In order to take advantage of
this, the clock driver must include code to activate the feature and
extract the timestamp. At present, this support is included in the clock
drivers for the Spectracom WWVB clock (WWVB define), the PSTI/Traconex
WWV/WWVH clock (PST define) and a special one-pulse-per-second (pps)
signal (PPSCLK define) described later. If justified, support can be
easily added to most other clock drivers as well. For future reference,
these modules operating with supported drivers will be called the CLK
support.
The CLK line discipline and STREAMS modules operate in the same way.
They look for a designated character, usually <CR>, and stuff a Unix
timestamp in the data stream following that character whenever it is
found. Eventually, the data arrive at the particular clock driver
configured in the NTP Version 3 distribution. The driver then uses the
timestamp as a precise reference epoch, subject to the earlier
processing delays and jitter budget, for future reference. In order to
gain some insight as to the effectiveness of this approach, measurements
were made using the same test setup described above. The total delay
from the on-time epoch to the instant when the timestamp is captured was
measured at 3.5 ms. Thus, the code path delay is this value less the
hardware delay 3.5 - 1.6 = 1.9 ms.
While the improvement in accuracy in the baseline case is significant,
there is another factor, at least in Sun systems, that makes it even
more worthwhile. When processing the code path up to the CLK module, the
priority is apparently higher than for processing beyond it. In case of
heavy CPU activity, this can lead to relatively long tails in the
processing delays for the driver, which of course are avoided by
capturing the timestamp early in the code path.
4. The PPSCLK Mode
Many timing receivers can produce a 1-pps signal of considerably better
precision than the ASCII timecode. Using this signal, it is possible to
avoid the 1-ms p-p jitter and 1.6 ms hardware timecode adjustment
entirely. However, a device is required to interface this signal to the
hardware and operating system. In general, this requires some sort of
level converter and pulse generator that can turn the 1-pps signal on-
time transition into a valid character. An example of such a device is
described in the gadget directory of the NTP Version 3 distribution.
Although many different circuit designs could be used as well, this
particular device generates a single 26-usec start bit for each 1-pps
signal on-time transition. This appears to the UART operating at 38.4K
baud as an ASCII DEL (hex FF).
Now, assuming a serial port can be dedicated to this purpose, a source
of 1-pps character interrupts is available and can be used to provide a
precision reference. The NTP Version 3 daemon can be configured to
utilize this feature by specifying the PPSCLK define, which requires the
CLK module and gadget box described above. The character resulting from
each 1-pps signal on-time transition is intercepted by the CLK module
and a timestamp is inserted in the data stream. An interrupt is created
for the device driver, which reads the timestamp and discards the DEL
character. Since the timestamp is captured at the on-time transition,
the seconds-fraction portion is the offset between the local clock and
the on-time epoch less the UART delay of 273 usec at 38.4K baud. If the
local clock is within +-0.5 second of this epoch, as determined by other
means, the local clock correction is taken as the offset itself, if
between zero and 0.5 s, and the offset minus one second, if between 0.5
and 1.0 s. In the NTP daemon the resulting correction is first processed
by a multi-stage median/trimmed mean filter to remove residual jitter
and then processed by the usual NTP algorithms.
The baseline delay between the on-time transition and the timestamp
capture was measured at 400+-10 usec on an otherwise idle test system.
As the UART delay at 38.4K baud is about 270 usec, the difference, 130
usec, must be due to the hardware interrupt latency plus the time to
call the microtime() routine which actually reads the system clock and
microsecond counter. For these measurements the assembly-coded version
of this routine described in the ppsclock directory of the NTP Version 3
distribution was used. This routine reduces the time to read the system
clock from 42-85 usec with the native Sun C-coded routine to about 3
usec using the microtime() assembly-coded routine and can be ignored.
Thus, the 130 usec must be accounted for in interrupt service, register
window, context switching, streams operations and measurement
uncertainty, which is probably not unreasonable. The reason for the
difference between the this figure and the previously calculated value
of 1.9 ms for the CLK module and serial ASCII timecode is probably due
to the fact that all STREAMS modules other than the CLK module were
removed, since the serial port is not used for ordinary ASCII data.
An interesting feature of this approach is that the 1-pps signal is not
necessarily associated with any particular radio clock and, indeed,
there may be no such clock at all. Some precision timekeeping equipment,
such as cesium clocks, VLF receivers and LORAN-C timing receivers
produce only a precision 1-pps signal and rely on other mechanisms to
resolve the second of the day and day of the year. It is possible for an
NTP-synchronized host to derive the latter information using other NTP
peers, presumably properly synchronized within +-0.5 second, and to
remove residual jitter using the 1-pps signal. This makes it quite
practical to deliver precision time to local clients when the subnet
paths to remote primary servers are heavily congested. In extreme cases
like this, it has been found useful to increase the tracking aperture
from +-128 ms to as high as +-512 ms.
In the current implementation the radio timecode and 1-pps signal are
separately processed. The timecode capture and CLK support, if provided
by the radio driver, operate the same way whether or not the PPSCLK
support is enabled. If the local clock is reliably synchronized within
+-0.5 s and the 1-pps signal has been valid for some number of seconds,
its offset rather than whatever synchronization source has been selected
is used instead. However, while a this procedure delivers a new offset
estimate every second, the local clock is updated only as each valid
update is computed for the peer selected as the source of
synchronization.
However, there is a hazard to the use of the 1-pps signal in this way if
the radio generating the 1-pps signal misbehaves or loses
synchronization with its transmitter. In such a case the radio might
indicate the error, but the system has no way to associate the error
with the 1-pps signal. To deal with this problem the prefer parameter
described in the xntpd.8 man page in the doc directory of the NTP
Version 3 distribution can be used both to cause the clock selection
algorithm to choose a preferred peer, all other things being equal, as
well as associate the error indications in such a way that the 1-pps
signal will be disregarded if the peer stops providing valid updates,
such as would occur in an error condition. The prefer parameter can be
used in other situations as well when preference is to be given a
particular source of synchronization.
5. The PPS Mode
For the ultimate accuracy and lowest jitter, it would be best to
eliminate the UART and capture the 1-pps on-time transition directly
using an appropriate interface. This is in fact possible using a
modified serial port driver and data lead in the serial port interface
cable. In this scheme, described in detail in the ppsclock directory of
the NTP Version 3 distribution, the 1-pps source is connected via the
previously described gadget box to the carrier-detect lead of a serial
port. Happily, this can be the same port used for a radio clock, for
example, or another unrelated serial device. The scheme, referred to
subsequently as the PPS mode, is specific to the SunOS 4.1.x kernel and
requires a special STREAMS module. Instructions on how to build the
kernel are also included in that directory.
Except for special-purpose interface modules, such as the KSI/Odetics
TPRO IRIG-B decoder and the modified audio driver for the IRIG-B signal
mentioned previously, the PPS mode provides the most accurate and
precise timestamp available. There is essentially no latency and the
timestamp is captured within 20-30 usec of the on-time epoch.
The PPS mode requires the PPSPPS define and one of the radio clock
serial ports to be selected as the PPS interface. This is the port which
handles the 1-pps signal; however, the signal path has nothing to do
with the ordinary serial data path; the two signals are not related,
other than by the need to activate the PPS mode and pass the file
descriptor to a common processing routine. Thus, for the port to be
selected for the PPS function, the define for the associated radio clock
needs to have a PPS suffix. In case of multiple radio clocks on a single
time server, the PPS suffix is necessary on only one of them; more than
one PPS suffix would be an error.
The PPS mode works just like the CLK mode in the treatment of the prefer
parameter and indicated peer errors. As in the CLK mode, only the offset
within the second is used and only when the offset is less than +-0.5 s.
However, the precision of the clock adjustments is usually so fine that
the error budget is dominated by the inherent short-term stability of
typical computer local clock oscillators. Therefore, it is advisable to
reduce the poll interval for the preferred peer from the default 64 s to
something less, like 16 s. This is done using the minpoll and maxpoll
parameters of the peer or server command associated with the clock.
These parameters take as arguments a power of 2, in seconds, which
becomes the poll interval and, indirectly, affects the bandwidth of the
tracking loop.
6. Results and Conclusions
It is clear from the above that substantial improvements in timekeeping
accuracy are possible with varying degrees of hardware and software
intrusion. While the ultimate accuracy depends on the jitter and wander
characteristics of the computer local oscillator, it is possible to
reduce jitter to a negligible degree simply by processing with the NTP
phase-lock loop and local clock algorithms. The residual jitter using
the PPS mode on a Sun4 IPC is typically in the 40-100 usec range, while
the wander is rarely more than twice that under typical environmental
room conditions.
David L. Mills <mills@udel.edu>
Electrical Engineering Department
University of Delaware
Newark, DE 19716
302 831 8247 fax 302 831 4316
25 August 1993

File diff suppressed because it is too large Load Diff

View File

@ -1,146 +0,0 @@
This file is the original README, and is a little out of date. It
is also very specific to UofT, since there was a time when the daemon
was only run here.
To run this:
(1) Fix your kernel's value of tickadj. Tickadj sets both the
precision with which time slews can be performed and the amount
of slew you can do in a given interval. Xntpd operates by making
a bunch of little adjustments. Make tickadj too large (the default
value almost always is) and xntpd will perform poorly since the
slews will disappear in the roundoff. Make tickadj too small
and large slews won't complete before the next adjustment is
ready.
To determine a good value of tickadj to use, first determine your
kernel's value of hz (50 on a Sun 3, 100 on Sun 4's and vaxes).
Divide that number into 500 (i.e. compute 500/hz) and use an
integer near there as tickadj (say, 10 on Sun 3's, 5 on Sun 4's
and vaxes). Then adb your kernel and write the new value. You
should probably do both the running kernel and the disk image.
If your machine doesn't come with adb, or if the kernel is of a
non-Berkeley flavour, take a look at the util directory, particularly
util/tickadj.
(2) Edit the Config file in this directory. You *must* tell it whether
your machine uses big endian or little endian byte order. Also,
Suns running SunOS 3.x require special consideration, as well as Vaxes
running Ultrix 2.0 and compilers which don't understand `signed char'
declarations. When you've got all this worked out, type `make makefiles'
to distribute configuration information to Makefiles for individual
programs, followed by `make' to compile everything.
(2a) Note that, among other things, two programs were made in the authstuff
directory, authcert and authspeed. The last two are utilities for
checking the authentication code. Type `authcert < certdata'. If
this provokes a massive failure you probably got the byte order wrong
in the Config file. Type `authspeed -n 10000 auth.samplekeys', or
something, a couple of times to get a value of authdelay to stick in
the configuration file. The numbers for machines I've tried look like:
uVax II 0.001450
Sun 3/180 0.000620
uVax III 0.000515
Sun 3/60 0.000455
IBM RT Mdl 125 0.000323
Sun 3/280 0.000302
Sun 4/280 0.000110
MIPS M/1000 0.000100
(3) Typing `make install' will nstall xntpd, xntpdc, ntpdate and ntpq. Watch
the install location in the Config file.
(4) If you will be running xntpd (see 4a below for the alternative),
configure it (configuration is necessary for all machines now, though
this restriction will go away when I get broadcast time fully tested).
xntpd reads its configuration from /etc/ntp.conf (by default) and
you must tell it which machines it is to get its time from in
here.
Note that NTP operates in a hierarchy. Machines with radio clocks
(which are stratum 1 servers) are at the top of the heap, in that
all time originates with them. The situation with servers locally
is in a state of flux. We currently have one semi-reliable stratum 1
server on campus (suzuki.ccie), and maintain three other stratum 2
servers which (gently) access other people's off-campus stratum 1
servers. All of these machines are lightly loaded and have good
quality clocks, and so will probably do until we get some more stratum 1
weight.
Thus you are probably faced with choosing whether your hosts should
be stratum 2 or stratum 3 (or stratum 3 or 4 when suzuki's clock is down).
The rule of thumb is to make your best clocks and/or your file servers
stratum 2 (or 3) by peering them with the four campus servers, and make
lesser clocks and clients stratum 3 (or 4) by peering them with near
by servers which are synchonized to the campus servers. The second rule
of thumb is that more servers are better. It is quite possible to
synchronize with just a single server, but if you do your xtnpd daemon
won't have any cross checks to tell it when the server has gone
wonky. 3 or 4 lower stratum peers is about right. Note that while
you can also peer with same-stratum peers, you shouldn't do this
unless the same-stratum peer is exchanging time with a lower stratum
peer you don't talk to directly.
Anyway, for your stratum 2 servers you can probably use ntp.conf
from the conf directory directly. You will have to handcraft the
peer assocations for your stratum 3 servers.
Oh, and a note about the drift file (see ntp.conf). One of the
things xntpd does is accumulate a correction for the frequency of
the crystal in your computer. It usually takes a day or so of
running to figure this out, after which the value will usually remain
pretty stable, especially if the computer is in a machine room. The
value is printed in your syslog file (once a minute, currently, though
this will change), and can be obtained from the daemon using xntpdc.
To avoid having to wait a day after restarts before the computer
synchronizes really well, xntpd will optionally write its current
value of the frequency correction into a file, once an hour. When
it is killed and restarted, xntpd reinitializes itself to this
value on start up. This is an advantageous feature, so a driftfile
line should always be included in the configuration file.
(4a) Xntpd is a daemon. It will keep your time exquisitely precise under
normal conditions (it is quite capable of keeping a good clock within
a millisecond of a good server. Our servers aren't normally this
good, yet, but may become so when we get a few more stable local
stratum 1 peers). Even when cut off entirely from its servers xntpd
will prevent your clock from drifting seriously by continuing to apply
its accumulated frequency correction. The cost of this is that xntpd
will permanently consume memory while it is running, and real memory
at that since xntpd is unlikely to ever swap out. This cost is
currently over 100 kb.
If you aren't too worried about millisecond timing and feel religious
about keeping memory consumption at a minimum (perhaps on memory-poor
workstations), a passable alternative might be to run ntpdate instead.
Ntpdate is the NTP equivalent of rdate, a one shot date setting
program, and implements the same multiple sample/multiple server
filter algorithms as xntpd. Ntpdate was explicitly designed to be
run repeatly from cron, though it also makes a good boot time date
setter. Running ntpdate from cron on an hourly basis will keep all
but seriously broken clocks within 100 ms of on-time, and for most
clocks will probably do better than 50 ms. If this is an attractive
alternative see the manual page. You should choose ntpdate's servers
as you would the peer associations for a stratum 3 xntpd server.
(5) Once everything is configured, start the daemon(s). ntpq can be
used to see what xntpd is doing. It runs both interactive and from
the command line, type ? to see the interactive commands and ? command
to see what a command does. The `peers' command is a good one. ntpq
can also be used to see what other peoples' servers are doing, in
particular the fuzzball primary servers.
(6) If you want to use the authentication facility (this might be useful
if, for example, you were running Kerberos since this prevents people
from setting your time back and doing replay attacks on the server),
you might find a couple of useful programs in the auth_stuff directory.
mkrandkeys will generate some very random keys to use. keyparity
generates odd parity bits for keys (needed for the key file) and will
convert between key formats.
All bug reports gratefully received.
Dennis

View File

@ -1,878 +0,0 @@
/*
* refclock_acts - clock driver for the NIST Automated Computer Time
* Service aka Amalgamated Containerized Trash Service (ACTS)
*/
#if defined(REFCLOCK) && defined(ACTS)
#include <stdio.h>
#include <ctype.h>
#include <sys/time.h>
#include "ntpd.h"
#include "ntp_io.h"
#include "ntp_unixtime.h"
#include "ntp_refclock.h"
#include "ntp_stdlib.h"
/*
* 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 is
* designed primarily for use as a backup 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.
*
* The ACTS is located at NIST Boulder, CO, telephone 303 494 4774. A
* toll call from a residence telephone in Newark, DE, costs between 14
* and 27 cents, depending on time of day, and from a campus telephone
* between 3 and 4 cents, although it is not clear what carrier and time
* of day discounts apply in this case. 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.
*
* 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.
*
* 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.
*
* 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 modem setup string is hard-coded in
* the driver and may require changes for nonstandard modems or special
* circumstances.
*
* Further information can be found in the README.refclock file in the
* xntp3 distribution.
*
* Fudge Factors
*
* Ordinarily, the propagation time correction is computed automatically
* by ACTS and the driver. When this is not possible or erratic due to
* individual modem characteristics, the fudge flag2 switch should be
* set to disable the ACTS echo-delay scheme. In any case, the fudge
* time1 parameter can be used to adjust the propagation delay as
* required.
*
* The ACTS call interval is determined in one of three ways. In MANUAL
* mode a call is initiated by setting fudge flag1 using xntpdc, either
* manually or via a cron job. In AUTO mode this flag is set by the peer
* timer, which is controlled by the sys_poll variable in response to
* measured errors. In BACKUP mode the driver is ordinarily asleep, but
* awakes (in AUTO mode) if all other synchronization sources are lost.
* In either AUTO or BACKUP modes, the call interval increases as long
* as the measured errors do not exceed the value of the fudge time2
* parameter.
*
* When the fudge flag1 is set, the ACTS calling program is activated.
* This program dials each number listed in the phones command of the
* configuration file in turn. If a call attempt fails, the next number
* in the list is dialed. The fudge flag1 and counter are reset and the
* calling program terminated if (a) a valid clock update has been
* determined, (b) no more numbers remain in the list, (c) a device
* fault or timeout occurs or (d) fudge flag1 is reset manually using
* xntpdc.
*/
/*
* DESCRIPTION OF THE AUTOMATED COMPUTER TELEPHONE SERVICE (ACTS)
* (reformatted from ACTS on-line computer help information)
*
* The following is transmitted (at 1200 baud) following completion of
* the telephone connection.
*
* National Institute of Standards and Technology
* Telephone Time Service, Generator 3B
* Enter question mark "?" for HELP
* D L D
* MJD YR MO DA H M S ST S UT1 msADV <OTM>
* 47999 90-04-18 21:39:15 50 0 +.1 045.0 UTC(NIST) *
* 47999 90-04-18 21:39:16 50 0 +.1 045.0 UTC(NIST) *
* 47999 90-04-18 21:39:17 50 0 +.1 045.0 UTC(NIST) *
* 47999 90-04-18 21:39:18 50 0 +.1 045.0 UTC(NIST) *
* 47999 90-04-18 21:39:19 50 0 +.1 037.6 UTC(NIST) #
* 47999 90-04-18 21:39:20 50 0 +.1 037.6 UTC(NIST) #
* etc..etc...etc.......
*
* UTC = Universal Time Coordinated, the official world time referred to
* the zero meridian.
*
* DST Daylight savings time characters, valid for the continental
* U.S., are set as follows:
*
* 00 We are on standard time (ST).
* 01-49 Now on DST, go to ST when your local time is 2:00 am and
* the count is 01. The count is decremented daily at 00
* (UTC).
* 50 We are on DST.
* 51-99 Now on ST, go to DST when your local time is 2:00 am and
* the count is 51. The count is decremented daily at 00
* (UTC).
*
* The two DST characters provide up to 48 days advance notice of a
* change in time. The count remains at 00 or 50 at other times.
*
* LS Leap second flag is set to "1" to indicate that a leap second is
* to be added as 23:59:60 (UTC) on the last day of the current UTC
* month. The LS flag will be reset to "0" starting with 23:59:60
* (UTC). The flag will remain on for the entire month before the
* second is added. Leap seconds are added as needed at the end of
* any month. Usually June and/or December are chosen.
*
* The leap second flag will be set to a "2" to indicate that a
* leap second is to be deleted at 23:59:58--00:00:00 on the last
* day of the current month. (This latter provision is included per
* international recommendation, however it is not likely to be
* required in the near future.)
*
* DUT1 Approximate difference between earth rotation time (UT1) and
* UTC, in steps of 0.1 second: DUT1 = UT1 - UTC.
*
* MJD Modified Julian Date, often used to tag certain scientific data.
*
* The full time format is sent at 1200 baud, 8 bit, 1 stop, no parity.
* The format at 300 Baud is also 8 bit, 1 stop, no parity. At 300 Baud
* the MJD and DUT1 values are deleted and the time is transmitted only
* on even seconds.
*
* Maximum on line time will be 56 seconds. If all lines are busy at any
* time, the oldest call will be terminated if it has been on line more
* than 28 seconds, otherwise, the call that first reaches 28 seconds
* will be terminated.
*
* Current time is valid at the "on-time" marker (OTM), either "*" or
* "#". The nominal on-time marker (*) will be transmitted 45 ms early
* to account for the 8 ms required to send 1 character at 1200 Baud,
* plus an additional 7 ms for delay from NIST to the user, and
* approximately 30 ms "scrambler" delay inherent in 1200 Baud modems.
* If the caller echoes all characters, NIST will measure the round trip
* delay and advance the on-time marker so that the midpoint of the stop
* bit arrives at the user on time. The amount of msADV will reflect the
* actual required advance in milliseconds and the OTM will be a "#".
*
* (The NIST system requires 4 or 5 consecutive delay measurements which
* are consistent before switching from "*" to "#". If the user has a
* 1200 Baud modem with the same internal delay as that used by NIST,
* then the "#" OTM should arrive at the user within +-2 ms of the
* correct time.
*
* However, NIST has studied different brands of 1200 Baud modems and
* found internal delays from 24 ms to 40 ms and offsets of the "#" OTM
* of +-10 ms. For many computer users, +-10 ms accuracy should be more
* than adequate since many computer internal clocks can only be set
* with granularity of 20 to 50 ms. In any case, the repeatability of
* the offset for the "#" OTM should be within +-2 ms, if the dial-up
* path is reciprocal and the user doesn't change the brand or model of
* modem used.
*
* This should be true even if the dial-up path on one day is a land-
* line of less than 40 ms (one way) and on the next day is a satellite
* link of 260 to 300 ms. In the rare event that the path is one way by
* satellite and the other way by land line with a round trip
* measurement in the range of 90 to 260 ms, the OTM will remain a "*"
* indicating 45 ms advance.
*
* For user comments write:
* NIST-ACTS
* Time and Frequency Division
* Mail Stop 847
* 325 Broadway
* Boulder, CO 80303
*
* Software for setting (PC)DOS compatable machines is available on a
* 360-kbyte diskette for $35.00 from: NIST Office of Standard Reference
* Materials B311-Chemistry Bldg, NIST, Gaithersburg, MD, 20899, (301)
* 975-6776
*/
/*
* Interface definitions
*/
#define DEVICE "/dev/acts%d" /* device name and unit */
#define SPEED232 B1200 /* uart speed (1200 cowardly baud) */
#define PRECISION (-10) /* precision assumed (about 1 ms) */
#define REFID "ACTS" /* reference ID */
#define DESCRIPTION "NIST Automated Computer Time Service" /* WRU */
#define MODE_AUTO 0 /* automatic mode */
#define MODE_BACKUP 1 /* backup mode */
#define MODE_MANUAL 2 /* manual mode */
#define NSAMPLES 3 /* stages of median filter */
#define MSGCNT 10 /* we need this many ACTS messages */
#define SMAX 80 /* max token string length */
#define LENCODE 50 /* length of valid timecode string */
#define ACTS_MINPOLL 10 /* log2 min poll interval (1024 s) */
#define ACTS_MAXPOLL 14 /* log2 max poll interval (16384 s) */
#define MAXOUTAGE 3600 /* max outage before ACTS kicks in (s) */
/*
* Modem control strings. These may have to be changed for some modems.
*
* AT command prefix
* B1 initiate call negotiation using Bell 212A
* &C1 enable carrier detect
* &D2 hang up and return to command mode on DTR transition
* E0 modem command echo disabled
* l1 set modem speaker volume to low level
* M1 speaker enabled untill carrier detect
* Q0 return result codes
* V1 return result codes as English words
*/
#define MODEM_SETUP "ATB1&C1&D2E0L1M1Q0V1" /* modem setup */
#define MODEM_HANGUP "ATH" /* modem disconnect */
/*
* Timeouts
*/
#define IDLE 60 /* idle timeout (s) */
#define WAIT 2 /* wait timeout (s) */
#define ANSWER 30 /* answer timeout (s) */
#define CONNECT 10 /* connect timeout (s) */
#define TIMECODE 15 /* timecode timeout (s) */
/*
* Imported from ntp_timer module
*/
extern u_long current_time; /* current time (s) */
extern u_long last_time; /* last clock update time (s) */
extern struct event timerqueue[]; /* inner space */
/*
* Imported from ntpd module
*/
extern int debug; /* global debug flag */
/*
* Imported from ntp_config module
*/
extern char sys_phone[][MAXDIAL]; /* modem dial strings */
/*
* Imported from ntp_proto module
*/
extern struct peer *sys_peer; /* who is running the show */
extern u_char sys_poll; /* log2 of system poll interval */
extern struct peer *sys_peer; /* system peer structure pointer */
/*
* Tables to compute the ddd of year form icky dd/mm timecode. Viva la
* leap.
*/
static day1tab[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
static day2tab[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
/*
* Unit control structure
*/
struct actsunit {
struct event timer; /* timeout timer */
int pollcnt; /* poll message counter */
int state; /* the first one was Delaware */
int run; /* call program run switch */
int msgcnt; /* count of ACTS messages received */
long redial; /* interval to next automatic call */
double msADV; /* millisecond advance of last message */
};
/*
* Function prototypes
*/
static int acts_start P((int, struct peer *));
static void acts_shutdown P((int, struct peer *));
static void acts_receive P((struct recvbuf *));
static void acts_poll P((int, struct peer *));
static void acts_timeout P((struct peer *));
static void acts_disc P((struct peer *));
static int acts_write P((struct peer *, char *));
/*
* Transfer vector
*/
struct refclock refclock_acts = {
acts_start, /* start up driver */
acts_shutdown, /* shut down driver */
acts_poll, /* transmit poll message */
noentry, /* not used (old acts_control) */
noentry, /* not used (old acts_init) */
noentry, /* not used (old acts_buginfo) */
NOFLAGS /* not used */
};
/*
* acts_start - open the devices and initialize data for processing
*/
static int
acts_start(unit, peer)
int unit;
struct peer *peer;
{
register struct actsunit *up;
struct refclockproc *pp;
int fd;
char device[20];
int dtr = TIOCM_DTR;
/*
* Open serial port. Use ACTS line discipline, if available. It
* pumps a timestamp into the data stream at every on-time
* character '*' found. Note: the port must have modem control
* or deep pockets for the phone bill. HP-UX 9.03 users should
* have very deep pockets.
*/
(void)sprintf(device, DEVICE, unit);
if (!(fd = refclock_open(device, SPEED232, LDISC_ACTS)))
return (0);
if (ioctl(fd, TIOCMBIC, (char *)&dtr) < 0) {
syslog(LOG_ERR, "clock %s ACTS no modem control",
ntoa(&peer->srcadr));
return (0);
}
/*
* Allocate and initialize unit structure
*/
if (!(up = (struct actsunit *)
emalloc(sizeof(struct actsunit)))) {
(void) close(fd);
return (0);
}
memset((char *)up, 0, sizeof(struct actsunit));
pp = peer->procptr;
pp->io.clock_recv = acts_receive;
pp->io.srcclock = (caddr_t)peer;
pp->io.datalen = 0;
pp->io.fd = fd;
if (!io_addclock(&pp->io)) {
(void) close(fd);
free(up);
return (0);
}
pp->unitptr = (caddr_t)up;
/*
* Initialize miscellaneous variables
*/
peer->precision = PRECISION;
pp->clockdesc = DESCRIPTION;
memcpy((char *)&pp->refid, REFID, 4);
peer->minpoll = ACTS_MINPOLL;
peer->maxpoll = ACTS_MAXPOLL;
/*
* Initialize modem and kill DTR. We skedaddle if this comes
* bum.
*/
if (!acts_write(peer, MODEM_SETUP)) {
(void) close(fd);
free(up);
return (0);
}
/*
* Set up the driver timeout
*/
up->timer.peer = (struct peer *)peer;
up->timer.event_handler = acts_timeout;
up->timer.event_time = current_time + WAIT;
TIMER_INSERT(timerqueue, &up->timer);
return (1);
}
/*
* acts_shutdown - shut down the clock
*/
static void
acts_shutdown(unit, peer)
int unit;
struct peer *peer;
{
register struct actsunit *up;
struct refclockproc *pp;
pp = peer->procptr;
up = (struct actsunit *)pp->unitptr;
TIMER_DEQUEUE(&up->timer);
io_closeclock(&pp->io);
free(up);
}
/*
* acts_receive - receive data from the serial interface
*/
static void
acts_receive(rbufp)
struct recvbuf *rbufp;
{
register struct actsunit *up;
struct refclockproc *pp;
struct peer *peer;
char str[SMAX];
int i;
l_fp tstmp;
u_fp disp;
char hangup = '%'; /* ACTS hangup */
int day; /* day of the month */
int month; /* month of the year */
u_long mjd; /* Modified Julian Day */
u_int dst; /* daylight/standard time indicator */
u_int leap; /* leap-second indicator */
double dut1; /* DUT adjustment */
double msADV; /* ACTS transmit advance (ms) */
char utc[10]; /* this is NIST and you're not */
char flag; /* calibration flag */
/*
* Initialize pointers and read the timecode and timestamp. If
* the OK modem status code, leave it where folks can find it.
*/
peer = (struct peer *)rbufp->recv_srcclock;
pp = peer->procptr;
up = (struct actsunit *)pp->unitptr;
pp->lencode = refclock_gtlin(rbufp, pp->lastcode, BMAX,
&pp->lastrec);
if (pp->lencode == 0) {
if (strcmp(pp->lastcode, "OK") == 0)
pp->lencode = 2;
return;
}
#ifdef DEBUG
if (debug)
printf("acts: timecode %d %s\n", pp->lencode,
pp->lastcode);
#endif
switch (up->state) {
case 0:
/*
* State 0. We are not expecting anything. Probably
* modem disconnect noise. Go back to sleep.
*/
return;
case 1:
/*
* State 1. We are waiting for the call to be answered.
* All we care about here is CONNECT as the first token
* in the string. If the modem signals BUSY, ERROR, NO
* ANSWER, NO CARRIER or NO DIALTONE, we immediately
* hang up the phone. If CONNECT doesn't happen after
* ANSWER seconds, hang up the phone. If everything is
* okay, start the connect timeout and slide into state
* 2.
*/
(void)strncpy(str, strtok(pp->lastcode, " "), SMAX);
if (strcmp(str, "BUSY") == 0 || strcmp(str, "ERROR") ==
0 || strcmp(str, "NO") == 0) {
TIMER_DEQUEUE(&up->timer);
syslog(LOG_NOTICE,
"clock %s ACTS modem status %s",
ntoa(&peer->srcadr), pp->lastcode);
acts_disc(peer);
} else if (strcmp(str, "CONNECT") == 0) {
TIMER_DEQUEUE(&up->timer);
up->timer.event_time = current_time + CONNECT;
TIMER_INSERT(timerqueue, &up->timer);
up->msgcnt = 0;
up->state++;
}
return;
case 2:
/*
* State 2. The call has been answered and we are
* waiting for the first ACTS message. If this doesn't
* happen within the timecode timeout, hang up the
* phone. We probably got a wrong number or ACTS is
* down.
*/
TIMER_DEQUEUE(&up->timer);
up->timer.event_time = current_time + TIMECODE;
TIMER_INSERT(timerqueue, &up->timer);
up->state++;
}
/*
* Real yucky things here. Ignore everything except timecode
* messages, as determined by the message length. We told the
* terminal routines to end the line with '*' and the line
* discipline to strike a timestamp on that character. However,
* when the ACTS echo-delay scheme works, the '*' eventually
* becomes a '#'. In this case the message is ended by the <CR>
* that comes about 200 ms after the '#' and the '#' cannot be
* echoed at the proper time. But, this may not be a lose, since
* we already have good data from prior messages and only need
* the millisecond advance calculated by ACTS. So, if the
* message is long enough and has an on-time character at the
* right place, we consider the message (but not neccesarily the
* timestmap) to be valid.
*/
if (pp->lencode != LENCODE)
return;
/*
* We apparently have a valid timecode message, so dismember it
* with sscan(). This routine does a good job in spotting syntax
* errors without becoming overly pedantic.
*
* D L D
* MJD YR MO DA H M S ST S UT1 msADV OTM
* 47222 88-03-02 21:39:15 83 0 +.3 045.0 UTC(NBS) *
*/
if (sscanf(pp->lastcode,
"%5ld %2d-%2d-%2d %2d:%2d:%2d %2d %1d %3lf %5lf %s %c",
&mjd, &pp->year, &month, &day, &pp->hour, &pp->minute,
&pp->second, &dst, &leap, &dut1, &msADV, utc, &flag) != 13) {
refclock_report(peer, CEVNT_BADREPLY);
return;
}
/*
* Some modems can't be trusted (the Practical Peripherals
* 9600SA comes to mind) and, even if they manage to unstick
* ACTS, the millisecond advance is wrong, so we use CLK_FLAG2
* to disable echoes, if neccessary.
*/
if ((flag == '*' || flag == '#') && !(pp->sloppyclockflag &
CLK_FLAG2))
(void)write(pp->io.fd, &flag, 1);
/*
* Yes, I know this code incorrectly thinks that 2000 is a leap
* year. The ACTS timecode format croaks then anyway. Life is
* short. Would only the timecode mavens resist the urge to
* express months of the year and days of the month in favor of
* days of the year.
*/
if (month < 1 || month > 12 || day < 1) {
refclock_report(peer, CEVNT_BADTIME);
return;
}
if (pp->year % 4) {
if (day > day1tab[month - 1]) {
refclock_report(peer, CEVNT_BADTIME);
return;
}
for (i = 0; i < month - 1; i++)
day += day1tab[i];
} else {
if (day > day2tab[month - 1]) {
refclock_report(peer, CEVNT_BADTIME);
return;
}
for (i = 0; i < month - 1; i++)
day += day2tab[i];
}
pp->day = day;
if (leap == 1)
pp->leap = LEAP_ADDSECOND;
else if (pp->leap == 2)
pp->leap = LEAP_DELSECOND;
else
pp->leap = 0;
pp->lasttime = current_time;
/*
* Colossal hack here. We process each sample in a trimmed-mean
* filter and determine the reference clock offset and
* dispersion. The fudge time1 value is added to each sample as
* received. If we collect MSGCNT samples before the '#' on-time
* character, we use the results of the filter as is. If the '#'
* is found before that, the adjusted msADV is used to correct
* the propagation delay.
*/
up->msgcnt++;
if (flag == '#') {
L_CLR(&tstmp);
TVUTOTSF((long)((msADV - up->msADV) * 1000.),
tstmp.l_uf);
L_ADD(&pp->offset, &tstmp);
} else {
up->msADV = msADV;
if (!refclock_process(pp, up->msgcnt, up->msgcnt -
up->msgcnt / 3)) {
refclock_report(peer, CEVNT_BADTIME);
return;
} else if (up->msgcnt < MSGCNT)
return;
}
/*
* We have a filtered sample offset ready for peer processing.
* We use lastrec as both the reference time and receive time in
* order to avoid being cute, like setting the reference time
* later than the receive time, which may cause a paranoid
* protocol module to chuck out the data. Finaly, we unhook the
* timeout, arm for the next call, fold the tent and go home.
* The little dance with the '%' character is an undocumented
* ACTS feature that hangs up the phone real quick without
* waiting for carrier loss or long-space disconnect, but we do
* these clumsy things anyway.
*/
disp = LFPTOFP(&pp->fudgetime2);
record_clock_stats(&peer->srcadr, pp->lastcode);
refclock_receive(peer, &pp->offset, 0, pp->dispersion +
(u_fp)disp, &pp->lastrec, &pp->lastrec, pp->leap);
pp->sloppyclockflag &= ~CLK_FLAG1;
up->pollcnt = 0;
TIMER_DEQUEUE(&up->timer);
(void)write(pp->io.fd, &hangup, 1);
up->state = 0;
acts_disc(peer);
}
/*
* acts_poll - called by the transmit routine
*/
static void
acts_poll(unit, peer)
int unit;
struct peer *peer;
{
register struct actsunit *up;
struct refclockproc *pp;
/*
* If the driver is running, we set the enable flag (fudge
* flag1), which causes the driver timeout routine to initiate a
* call to ACTS. If not, the enable flag can be set using
* xntpdc. If this is the sustem peer, then follow the system
* poll interval.
*/
pp = peer->procptr;
up = (struct actsunit *)pp->unitptr;
if (up->run) {
pp->sloppyclockflag |= CLK_FLAG1;
if (peer == sys_peer)
peer->hpoll = sys_poll;
else
peer->hpoll = peer->minpoll;
}
}
/*
* acts_timeout - called by the timer interrupt
*/
static void
acts_timeout(peer)
struct peer *peer;
{
register struct actsunit *up;
struct refclockproc *pp;
int dtr = TIOCM_DTR;
/*
* If a timeout occurs in other than state 0, the call has
* failed. If in state 0, we just see if there is other work to
* do.
*/
pp = peer->procptr;
up = (struct actsunit *)pp->unitptr;
if (up->state) {
acts_disc(peer);
return;
}
switch (peer->ttl) {
/*
* In manual mode the ACTS calling program is activated
* by the xntpdc program using the enable flag (fudge
* flag1), either manually or by a cron job.
*/
case MODE_MANUAL:
up->run = 0;
break;
/*
* In automatic mode the ACTS calling program runs
* continuously at intervals determined by the sys_poll
* variable.
*/
case MODE_AUTO:
if (!up->run)
pp->sloppyclockflag |= CLK_FLAG1;
up->run = 1;
break;
/*
* In backup mode the ACTS calling program is disabled,
* unless no system peer has been selected for MAXOUTAGE
* (3600 s). Once enabled, it runs until some other NTP
* peer shows up.
*/
case MODE_BACKUP:
if (!up->run && sys_peer == 0) {
if (current_time - last_time > MAXOUTAGE) {
up->run = 1;
peer->hpoll = peer->minpoll;
syslog(LOG_NOTICE,
"clock %s ACTS backup started ",
ntoa(&peer->srcadr));
}
} else if (up->run && sys_peer->refclktype !=
REFCLK_NIST_ACTS) {
peer->hpoll = peer->minpoll;
up->run = 0;
syslog(LOG_NOTICE,
"clock %s ACTS backup stopped",
ntoa(&peer->srcadr));
}
break;
default:
syslog(LOG_NOTICE,
"clock %s ACTS invalid mode", ntoa(&peer->srcadr));
}
/*
* The fudge flag1 is used as an enable/disable; if set either
* by the code or via xntpdc, the ACTS calling program is
* started; if reset, the phones stop ringing.
*/
if (!(pp->sloppyclockflag & CLK_FLAG1)) {
up->pollcnt = 0;
up->timer.event_time = current_time + IDLE;
TIMER_INSERT(timerqueue, &up->timer);
return;
}
/*
* Initiate a call to the ACTS service. If we wind up here in
* other than state 0, a successful call could not be completed
* within minpoll seconds. We advance to the next modem dial
* string. If none are left, we log a notice and clear the
* enable flag. For future enhancement: call the site RP and
* leave an obscene message in his voicemail.
*/
if (sys_phone[up->pollcnt][0] == '\0') {
refclock_report(peer, CEVNT_TIMEOUT);
syslog(LOG_NOTICE,
"clock %s ACTS calling program terminated",
ntoa(&peer->srcadr));
pp->sloppyclockflag &= ~CLK_FLAG1;
#ifdef DEBUG
if (debug)
printf("acts: calling program terminated\n");
#endif
up->pollcnt = 0;
up->timer.event_time = current_time + IDLE;
TIMER_INSERT(timerqueue, &up->timer);
return;
}
/*
* Raise DTR, call ACTS and start the answer timeout. We think
* it strange if the OK status has not been received from the
* modem, but plow ahead anyway.
*/
if (strcmp(pp->lastcode, "OK") != 0)
syslog(LOG_NOTICE, "clock %s ACTS no modem status",
ntoa(&peer->srcadr));
(void)ioctl(pp->io.fd, TIOCMBIS, (char *)&dtr);
(void)acts_write(peer, sys_phone[up->pollcnt]);
syslog(LOG_NOTICE, "clock %s ACTS calling %s\n",
ntoa(&peer->srcadr), sys_phone[up->pollcnt]);
up->state = 1;
up->pollcnt++;
pp->polls++;
up->timer.event_time = current_time + ANSWER;
TIMER_INSERT(timerqueue, &up->timer);
}
/*
* acts_disc - disconnect the call and wait for the ruckus to cool
*/
static void
acts_disc(peer)
struct peer *peer;
{
register struct actsunit *up;
struct refclockproc *pp;
int dtr = TIOCM_DTR;
/*
* We should never get here other than in state 0, unless a call
* has timed out. We drop DTR, which will reliably get the modem
* off the air, even while ACTS is hammering away full tilt.
*/
pp = peer->procptr;
up = (struct actsunit *)pp->unitptr;
(void)ioctl(pp->io.fd, TIOCMBIC, (char *)&dtr);
if (up->state > 0) {
up->state = 0;
syslog(LOG_NOTICE, "clock %s ACTS call failed %d",
ntoa(&peer->srcadr), up->state);
#ifdef DEBUG
if (debug)
printf("acts: call failed %d\n", up->state);
#endif
}
up->timer.event_time = current_time + WAIT;
TIMER_INSERT(timerqueue, &up->timer);
}
/*
* acts_write - write a message to the serial port
*/
int
acts_write(peer, str)
struct peer *peer;
char *str;
{
register struct actsunit *up;
struct refclockproc *pp;
int len;
int code;
char cr = '\r';
/*
* Not much to do here, other than send the message, handle
* debug and report faults.
*/
pp = peer->procptr;
up = (struct actsunit *)pp->unitptr;
len = strlen(str);
#ifdef DEBUG
if (debug)
printf("acts: state %d send %d %s\n", up->state, len,
str);
#endif
code = write(pp->io.fd, str, len) == len;
code |= write(pp->io.fd, &cr, 1) == 1;
if (!code)
refclock_report(peer, CEVNT_FAULT);
return (code);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,147 +0,0 @@
.\"
.\" $FreeBSD$
.\"
.Dd December 21, 1993
.Dt NTPDATE 8
.Os
.Sh NAME
.Nm ntpdate
.Nd set the date and time via NTP
.Sh SYNOPSIS
.Nm
.Op Fl bdqsv
.Op Fl o Ar version
.Op Fl a Ar key#
.Op Fl e Ar authdelay
.Op Fl k Ar keyfile
.Op Fl p Ar samples
.Op Fl t Ar timeout
.Ar server ...
.Sh DESCRIPTION
.Nm Ntpdate
sets the local date and time by polling the Network Time Protocol
server(s) on the host(s) given as arguments to determine
the correct time. It must be run as root on the local host. A number
of samples are obtained from each of the servers specified and the
standard NTP clock filter and selection algorithms are applied to select
the best of these. Typically,
.Nm
can be inserted in the
.Pa /etc/rc.local
startup up script to set the time of day at boot time and/or can be run
from time\-to\-time via
.Xr cron 8 .
Note that
.Nm Ns 's
reliability and precision will improve dramatically with greater numbers
of servers. While a single server may be used, better performance and
greater resistance to insanity on the part of any one server
will be obtained by providing at least three or four servers, if not more.
.Pp
Time adjustments are made by
.Nm
in one of two ways. If
.Nm
determines your clock is off by more than 0.5 seconds it will simply
step the time by calling
.Xr settimeofday 2 .
If the error is less than 0.5 seconds, however, it will by default slew
the clock's time via a call to
.Xr adjtime 2
with the offset. The latter technique is less disruptive and more
accurate when the offset is small, and works quite well when
.Nm
is run by
.Xr cron 8
every hour or two. The adjustment made in the latter
case is actually 50% larger than the measured offset since this will
tend to keep a badly drifting clock more accurate (at some expense to
stability, though this tradeoff is usually advantageous). At boot time,
however, it is usually better to always step the time. This can be forced
in all cases by specifying the
.Fl b
switch on the command line. The
.Fl s
switch tells
.Nm
to log its actions via the
.Xr syslog 3
facility rather than to the standard output, a useful option when
running the program from
.Xr cron 8 .
.Pp
The
.Fl d
flag may be used to determine what
.Nm
will do without it actually doing it. Information useful for general
debugging will also be printed. The
.Fl q
flag is used to perform a simple query without binding a priviledged
UPD port. The
.Fl v
enables a few diagnostic messages. By default
.Nm
claims to be an NTP version 3 implementation in its outgoing packets. As
some older software will decline to respond to version 3 queries, the
.Fl o Ar version
switch can be used to force the program to poll as a version 2 or 1
implementation instead.
.Pp
The number of samples
.Nm
acquires from each server can be set to between 1 and 8 inclusive
using the
.Fl p
switch. The default is 4. The time it will spend waiting for a
response can be set using the
.Fl t
switch, and will be rounded to a multiple of 0.2 seconds. The default
is 1 second, a value suitable for polling across a LAN.
.Pp
.Nm Ntpdate
will authenticate its transactions if need be. The
.Fl a
switch specifies that all packets should be authenticated using the
key number indicated. The
.Fl k
switch allows the name of the file from which the keys may be read
to be modified from the default of
.Pa /etc/ntp.keys .
This file should be in the format described in
.Xr xntpd 8 .
The
.Fl e
option allows the specification of an authentication processing delay,
in seconds (see
.Xr xntpd 8
for details). This number is usually small enough to be negligible for
.Nm Ns 's
purposes, though specifying a value may improve timekeeping on very slow
CPU's.
.Pp
.Nm Ntpdate
will decline to set the date if an NTP server daemon (e.g.
.Xr xntpd 8 )
is running on the same host. When running
.Nm
on a regular basis from
.Xr cron 8
as an alternative to running a daemon, doing so once every hour or two
will result in precise enough timekeeping to avoid stepping the clock.
.Sh FILES
.Bl -tag -width /etc/ntp.keys -compact
.It Pa /etc/ntp.keys
contains the encryption keys used by
.Nm Ns .
.El
.Sh SEE ALSO
.Xr xntpd 8
.Sh HISTORY
Written by
.An Dennis Ferguson
at the University of Toronto
.Sh BUGS
The technique used for improving accuracy by compensating for clock
oscillator errors sucks, but doing better would require the program
to save state from previous runs.

View File

@ -1,480 +0,0 @@
.\"
.\" $FreeBSD$
.\"
.Dd December 21, 1993
.Dt NTPQ 8
.Os
.Sh NAME
.Nm ntpq
.Nd standard Network Time Protocol query program
.Sh SYNOPSIS
.Nm
.Op Fl inp
.Op Fl c Ar command
.Op Ar host ...
.Sh DESCRIPTION
.Nm Ntpq
is used to query NTP servers which implement the recommended NTP mode 6
control message format about current state and to request changes in
that state. The program may be run either in interactive mode or
controlled using command line arguments. Requests to read and write
arbitrary variables can be assembled, with raw and pretty\-printed
output options being available.
.Nm Ntpq
can also obtain and print a list of peers in a common format by sending
multiple queries to the server.
.Pp
If one or more request options is included on the command line when
.Nm
is executed, each of the requests will be sent to the NTP servers
running on each of the hosts given as command line arguments, or on
.Ar localhost
by default. If no request options are given,
.Nm
will attempt to read commands from the standard input and execute these
on the NTP server running on the first host given on the command line,
again
defaulting to
.Ar localhost
when no other host is specified.
.Nm Ntpq
will prompt for commands if the standard input is a terminal device.
.Pp
.Nm Ntpq
uses NTP mode 6 packets to communicate with the NTP server, and hence
can be used to query any compatible server on the network which permits
it. Note that since NTP is a UDP protocol this communication will be
somewhat unreliable, especially over large distances in terms of network
topology.
.Nm Ntpq
makes one attempt to retransmit requests, and will time requests out if
the remote host is not heard from within a suitable time out time.
.Pp
Command line options are described following. Specifying a command line
option other than
.Fl i
or
.Fl n
will cause the specified query (queries) to be sent to the indicated
host(s) immediately. Otherwise,
.Nm
will attempt to read interactive format commands from the standard
input.
The following options are available:
.Bl -tag -width indent
.It Fl c Ar command
The following argument is interpreted as an interactive format
.Ar command
and is added to the list of commands to be executed on the specified
host(s). Multiple
.Fl c
options may be given.
.It Fl i
Force
.Nm
to operate in interactive mode. Prompts will be written to the standard
output and commands read from the standard input.
.It Fl n
Output all host addresses in dotted\-quad numeric format rather than
converting to the canonical host names.
.It Fl p
Print a list of the peers known to the server as well as a summary of
their state. This is equivalent to the
.Em peers
interactive command.
.El
.Sh INTERNAL COMMANDS
.Pp
Interactive format commands consist of a keyword followed by zero to
four arguments. Only enough characters of the full keyword to uniquely
identify the command need be typed. The output of a command is normally
sent to the standard output, but optionally the output of individual
commands may be sent to a file by appending a
.Qq > ,
followed by a file name, to the command line.
.Pp
A number of interactive format commands are executed entirely within the
.Nm
program itself and do not result in NTP mode 6 requests being sent to a
server. These are described following.
.Pp
.Bl -tag -width indent
.It ? Op Ar command_keyword
A
.Qq ?
by itself will print a list of all the command keywords
known to this incarnation of
.Nm Ns .
A
.Qq ?
followed by a command keyword will print function and
usage information about the command. This command is probably a better
source of information about
.Nm
than this manual page.
.It timeout Ar milliseconds
Specify a time out period for responses to server queries. The default
is about 5000 milliseconds. Note that since
.Nm
retries each query once after a time out the total waiting time for a
time out will be twice the time out value set.
.It delay Ar milliseconds
Specify a time interval to be added to timestamps included in requests
which require authentication. This is used to enable (unreliable) server
reconfiguration over long delay network paths or between machines whose
clocks are unsynchronized. Actually the server does not now require time
stamps in authenticated requests, so this command may be obsolete.
.It host Ar hostname
Set the host to which future queries will be sent.
.Ar Hostname
may be either a host name or a numeric
address.
.It Xo poll
.Op Ar #
.Op Ar verbose
.Xc
Poll the current server in client mode. The first argument is the number
of times to poll (default is 1) while the second argument may be given
to obtain a more detailed output of the results. This command is
currently just wishful thinking.
.It keyid Ar #
This command allows the specification of a key number to be used to
authenticate configuration requests. This must correspond to a key
number the server has been configured to use for this purpose.
.It passwd
This command prompts you to type in a password (which will not be
echoed) which will be used to authenticate configuration requests. The
password must correspond to the key configured for use by the NTP server
for this purpose if such requests are to be successful.
.It hostnames Ar yes | Ar no
If
.Ar yes
is specified, host names are printed in information
displays. If
.Ar no
is given, numeric addresses are printed
instead. The default is
.Ar yes
unless modified using the command line
.Fl n
switch.
.It raw
Cause all output from query commands is printed as received from the
remote server. The only formating/intepretation done on the data is to
transform non-ASCII data into a printable (but barely understandable)
form.
.It cooked
Cause output from query commands to be
.Qq cooked Ns .
Variables
which are recognized by the server will have their values reformatted
for human consumption. Variables which
.Nm
thinks should have a decodeable value but didn't are marked with a
trailing
.Qq ? Ns .
.It ntpversion Ar 1 | Ar 2 | Ar 3
Set the NTP version number which
.Nm
claims in packets. Defaults to 3, Note that mode 6 control messages (and
modes, for that matter) didn't exist in NTP version 1. There appear to
be no servers left which demand version 1.
.It authenticate Ar yes | Ar no
Normally
.Nm
does not authenticate requests unless they are write requests. The
command
.Em authenticate yes
causes
.Nm
to send authentication with all requests it makes. Authenticated
requests causes some servers to handle requests slightly differently,
and can occasionally melt the CPU in fuzzballs if you turn
authentication on before doing a peer display.
.It Xo addvars
.Aq variable_name Ns
.Op = Ns Aq value Ns
.Op ,...
.Xc
.It Xo rmvars
.Aq variable_name Ns
.Op ,...
.Xc
.It clearvars
The data carried by NTP mode 6 messages consists of a list of items of
the form
.Xo Aq variable_name Ns
.Pf = Aq value
.Xc
where the
.Qq = Ns Aq value
is ignored, and can be omitted, in requests
to the server to read variables.
.Nm Ntpq
maintains an internal list in which data to be included in control
messages can be assembled, and sent using the
.Em readlist
and
.Em writelist
commands described below. The
.Em addvars
command allows variables and their optional values to be added to the
list. If more than one variable is to be added, the list should be
comma\-separated and not contain white space. The
.Em rmvars
command can be used to remove individual variables from the list, while
the
.Em clearlist
command removes all variables from the list.
.It debug Ar more | Ar less | Ar off
Turn internal query program debugging on and off.
.It quit
Exit
.Nm Ns .
.El
.Sh CONTROL MESSAGE COMMANDS
Each peer known to an NTP server has a 16 bit integer
.Em association identifier
assigned to it. NTP control messages which carry peer variables must
identify the peer the values correspond to by including its association
ID. An association ID of 0 is special, and indicates the variables are
system variables, whose names are drawn from a separate name space.
.Pp
Control message commands result in one or more NTP mode 6 messages being
sent to the server, and cause the data returned to be printed in some
format. Most commands currently implemented send a single message and
expect a single response. The current exceptions are the
.Em peers
command, which will send a preprogrammed series of messages to obtain
the data it needs, and the
.Em mreadlist
and
.Em mreadvar
commands, which will iterate over a range of associations.
.Bl -tag -width indent
.It associations
Obtain and print a list of association identifiers and peer statuses
for in\-spec peers of the server being queried. The list is printed in
columns. The first of these is an index numbering the associations from
1 for internal use, the second the actual association identifier
returned by the server and the third the status word for the peer. This
is followed by a number of columns containing data decoded from the
status word. Note that the data returned by the \*(L"associations\*(R"
command is cached internally in
.Nm Ns .
The index is then of use when dealing with stupid servers which use
association identifiers which are hard for humans to type, in that for
any subsequent commands which require an association identifier as an
argument, the form
.Em &index
may be used as an alternative.
.It lassocations
Obtain and print a list of association identifiers and peer statuses
for all associations for which the server is maintaining state. This
command differs from the
.Em associations
command only for servers
which retain state for out\-of\-spec client associations (i.e.
fuzzballs). Such associations are normally omitted from the display when
the
.Em associations
command is used, but are included in the
output of
.Em lassociations Ns .
.It passociations
Print association data concerning in\-spec peers from the internally
cached list of associations. This command performs identically to the
.Em associations
except that it displays the internally stored
data rather than making a new query.
.It lpassociations
Print data for all associations, including out\-of\-spec client
associations, from the internally cached list of associations. This
command differs from
.Em passociations
only when dealing with fuzzballs.
.It pstatus Ar assocID
Send a read status request to the server for the given association. The
names and values of the peer variables returned will be printed. Note
that the status word from the header is displayed preceding the
variables, both in hexadecimal and in pidgin English.
.It Xo readvar
.Op Ar assocID Ns
.Pf [ Aq variable_name Ns
.Op = Ns Aq value Ns
.Op ,...]
.Xc
Request that the values of the specified variables be returned by the
server by sending a read variables request. If the association ID is
omitted or is given as zero the variables are system variables,
otherwise they are peer variables and the values returned will be those
of the corresponding peer. Omitting the variable list will send a
request with no data which should induce the server to return a default
display.
.It Xo rv
.Op Ar assocID Ns
.Pf [ Aq variable_name Ns
.Op = Ns Aq value Ns
.Op ,...]
.Xc
An easy\-to\-type short form for the
.Em readvar
command.
.It Xo writevar
.Ar assocID
.Aq variable_name Ns
.Pf = Ns Aq value Ns
.Op ,...
.Xc
Like the
.Em readvar
request, except the specified variables are written instead of read.
.It readlist Op Ar assocID
Request that the values of the variables in the internal variable list
be returned by the server. If the association ID is omitted or is 0 the
variables are assumed to be system variables. Otherwise they are treated
as peer variables. If the internal variable list is empty a request is
sent without data, which should induce the remote server to return a
default display.
.It rl Op Ar assocID
An easy\-to\-type short form of the
.Em readlist
command.
.It writelist Op Ar assocID
Like the
.Em readlist
request, except the internal list variables are written instead of read.
.It Xo mreadvar
.Ar assocID assocID [
.Aq variable_name Ns
.Op = Ns Aq value Ns
.Op ,...]
.Xc
Like the
.Em readvar
command except the query is done for each of a range of (nonzero)
association IDs. This range is determined from the association list
cached by the most recent
.Em associations
command.
.It Xo mrv
.Ar assocID assocID [
.Aq variable_name Ns
.Op = Ns Aq value Ns
.Op ,...]
.Xc
An easy\-to\-type short form of the
.Em mreadvar
command.
.It mreadlist Ar assocID assocID
Like the
.Em readlist
command except the query is done for each of a range of (nonzero)
association IDs. This range is determined from the association list
cached by the most recent
.Em associations
command.
.It mrl Ar assocID assocID
An easy\-to\-type short form of the
.Em mreadlist
command.
.It Xo clockvar
.Op Ar assocID Ns
.Pf [ Aq variable_name Ns
.Op = Ns Aq value Ns
.Op ,...]
.Xc
Request that a list of the server's clock variables be sent. Servers
which have a radio clock or other external synchronization will respond
positively to this. If the association identifier is omitted or zero the
request is for the variables of the
.Qq system clock
and will
generally get a positive response from all servers with a clock. If the
server treats clocks as pseudo\-peers, and hence can possibly have more
than one clock connected at once, referencing the appropriate peer
association ID will show the variables of a particular clock. Omitting
the variable list will cause the server to return a default variable
display.
.It Xo cv
.Op Ar assocID Ns
.Pf [ Aq variable_name Ns
.Op = Ns Aq value Ns
.Op ,...]
.Xc
An easy\-to\-type short form of the
.Em clockvar
command.
.It peers
Obtain a list of in\-spec peers of the server, along with a summary of
each peer's state. Summary information includes the address of the
remote peer, the reference ID (0.0.0.0 if the refID is unknown), the
stratum of the remote peer, the type of the peer (local, unicast,
multicast or broadcast), when the last packet was received, the polling
interval, in seconds, the reachability register, in octal, and the
current estimated delay, offset and dispersion of the peer, all in
seconds.
.Pp
The character in the left margin indicates the fate of this peer in the
clock selection process. The codes mean: <sp> discarded due to high
stratum and/or failed sanity checks;
.Qq x
designated falsticker
by the intersection algorithm;
.Qq \&.
culled from the end of the
candidate list;
.Qq -
discarded by the clustering algorithm;
.Qq +
included in the final selection set;
.Qq #
selected
for synchronization but distance exceeds maximum;
.Qq *
selected
for synchronization; and
.Qq o
selected for synchronization, pps
signal in use.
.Pp
Note that since the
.Em peers
command depends on the ability to parse the values in the responses it
gets it may fail to work from time to time with servers which poorly
control the data formats.
.Pp
The contents of the host field may be one of four forms. It may be a
host name, an IP address, a reference clock implementation name with its
parameter or
.Qq REFCLK(<implementation number>, <parameter>) .
On
.Qq hostnames no
only IP\-addresses will be displayed.
.It lpeers
Like
.Em peers ,
except a summary of all associations for which the server is maintaining
state is printed. This can produce a much longer list of peers from
fuzzball servers.
.It opeers
An old form of the
.Em peers
command with the reference ID
replaced by the local interface address.
.El
.Sh HISTORY
Written by
.An Dennis Ferguson
at the University of Toronto.
.Sh BUGS
The
.Em peers
command is non\-atomic and may occasionally result in spurious error
messages about invalid associations occurring and terminating the
command.
.Pp
The timeout time is a fixed constant, which means you wait a long time
for time outs since it assumes sort of a worst case. The program should
improve the time out estimate as it sends queries to a particular host,
but doesn't.

View File

@ -1,65 +0,0 @@
.\"
.\" $FreeBSD$
.\"
.Dd December 21, 1993
.Dt NTPTRACE 8
.Os
.Sh NAME
.Nm ntptrace
.Nd "trace a chain of NTP hosts back to their master time source"
.Sh SYNOPSIS
.Nm ntptrace
.Op Fl vdn
.Op Fl r Ar retries
.Op Fl t Ar timeout
.Op Ar server
.Sh DESCRIPTION
.Nm Ntptrace
determines where a given Network Time Protocol (NTP) server gets
its time from, and follows the chain of NTP servers back to their
master time source.
If given no arguments, it starts with
.Dq localhost .
.Pp
Here is an example of the output from
.Nm Ns :
.Bd -literal
% ntptrace
localhost: stratum 4, offset 0.0019529, synch distance 0.144135
server2.bozo.com: stratum 2, offset 0.0124263, synch distance 0.115784
h.edu: stratum 1, offset 0.0019298, synch distance 0.011993, refid 'WWVB'
.Ed
.Pp
On each line, the fields are (left to right): the host name, the
host's stratum,
the time offset between that host and the local host
(as measured by
.Nm Ns ;
this is why it is not always zero for
.Dq localhost ) ,
the host's
.Dq synchronization distance ,
and (only for stratum-1 servers) the reference clock ID. All times
are given in seconds. (Synchronization distance is a measure of the
goodness of the clock's time.)
.Sh OPTIONS
The following options are available:
.Bl -tag -width indent
.It Fl d
Turn on some debugging output.
.It Fl n
Turn off the printing of host names; instead, host IP addresses
are given. This may be necessary if a nameserver is down.
.It Fl r Ar retries
Set the number of retransmission attempts for each host; the default is 5.
.It Fl t Ar timeout
Set the retransmission timeout (in seconds); the default is 2.
.It Fl v
Print verbose information about the NTP servers.
.El
.Sh SEE ALSO
.Xr xntpd 8 ,
.Xr xntpdc 8
.Sh BUGS
This program makes no attempt to improve accuracy by doing multiple
samples.

View File

@ -1,124 +0,0 @@
.\" $FreeBSD$
.\"
.Dd December 21, 1993
.Dt TICKADJ 8
.Os
.Sh NAME
.Nm tickadj
.Nd fiddle time\-related variables in the kernel
.Sh SYNOPSIS
.Nm tickadj
.Op Fl Adkpqs
.Op Fl a Ar new_tickadj
.Op Fl t Ar new_tick
.Sh DESCRIPTION
The
.Nm
program reads, and optionally modifies, several time\-keeping\-related
variables in the running kernel, via
.Pa /dev/kmem .
The particular variables it is concerned with are
.Em tick ,
which is the number of microseconds added to the system time during a
clock interrupt,
.Em tickadj ,
which sets the slew rate and resolution used by the
.Xr adjtime 2
system call, and
.Em dosynctodr ,
which indicates to the kernels on some machines whether they should internally
adjust the system clock to keep it in line with time\-of\-day clock
or not.
.Pp
By default, with no arguments,
.Nm
reads the variables of interest in the kernel and prints them. At the
same time it determines an
.Qq optimal
value for the value of the
.Em tickadj
variable if the intent is to run the
.Xr xntpd 8
Network Time Protocol daemon, and prints this as well. Since the operation
of
.Nm
when reading the kernel mimics the operation of similar parts of the
.Xr xntpd 8
program fairly closely, this is useful for doing debugging of problems
with
.Xr xntpd 8 Ns .
.Pp
Various flags may be specified to change the variables of interest in
the running kernel:
.Bl -tag -width indent
.It Fl a Ar new_tickadj
Allow one to set the variable
.Em tickadj
to the value specified as an argument.
.It Fl A
Cause
.Em tickadj
to be modified, but instead will set it to the internally computed
.Qq optimal
value.
.It Fl d
Add debugging information.
.It Fl k
Use
.Pa /dev/kmem
instead of
.Pa /kernel .
This is the default.
.It Fl p
Tell
.Nm
to set the value of the variable
.Em noprintf
to one.
.It Fl q
Tell
.Nm
to shut up about everything except errors. Normally
.Nm
is quite verbose about what it is doing.
.It Fl s
Tell
.Nm
to set the value of the variable
.Em dosynctodr
to zero, a prerequisite for running the
.Xr xntpd 8
daemon under SunOS 4.0.
.It Fl t Ar new_tick
May be used to reset the kernel's value of
.Em tick ,
a capability which is useful on machines with very broken clocks.
.El
.Pp
Note that
.Nm
should be run with some caution when being used for the first time on
different types of machines. The operations which
.Nm
trys to perform are not guaranteed to work on all Unix machines.
.Sh FILES
.Bl -tag -width /dev/kmem -compact
.It Pa /kernel
.It Pa /dev/kmem
.El
.Sh SEE ALSO
.Xr xntpd 8
.Sh HISTORY
Written by
.An Dennis Ferguson
at the University of Toronto.
.Sh BUGS
Fiddling with kernel variables at run time as a part of ordinary
operations is a hideous practice which is only necessary to make
up for deficiencies in the implementation of
.Xr adjtime 2
in many kernels and/or brokenness of the system clock in some
vendors' kernels. It would be much better if the kernels were fixed
and the
.Nm
program went away.

File diff suppressed because it is too large Load Diff

View File

@ -1,674 +0,0 @@
.\"
.\" $FreeBSD$
.\"
.Dd December 21, 1993
.Dt XNTPDC 8
.Os
.Sh NAME
.Nm xntpdc
.Nd query/control program for the Network Time Protocol daemon
.Sh SYNOPSIS
.Nm xntpdc
.Op Fl ilnps
.Op Fl c Ar command
.Op Ar host ...
.Sh DESCRIPTION
.Nm Xntpdc
is used to query the
.Xr xntpd 8
daemon about its current state and to request changes in that state. The
program may be run either in interactive mode or controlled using
command line arguments. Extensive state and statistics information is
available through the
.Nm
interface. In addition, nearly all the configuration options which can
be specified at start up using
.Nm xntpd Ns 's
configuration file may also be specified at run time using
.Nm Ns .
.Pp
If one or more request options is included on the command line when
.Nm
is executed, each of the requests will be sent to the
.Tn NTP
servers
running on each of the hosts given as command line arguments, or on
.Ar localhost
by default. If no request options are given,
.Nm
will attempt to read commands from the standard input and execute these
on the
.Tn NTP
server running on the first host given on the command line,
again defaulting to
.Ar localhost
when no other host is specified.
.Nm Xntpdc
will prompt for commands if the standard input is a terminal device.
.Pp
.Nm Xntpdc
uses
.Tn NTP
mode 7 packets to communicate with the
.Tn NTP
server, and hence
can be used to query any compatible server on the network which permits
it. Note that since
.Tn NTP
is a UDP protocol this communication will be
somewhat unreliable, especially over large distances in terms of network
topology.
.Nm Xntpdc
makes no attempt to retransmit requests, and will time requests out if
the remote host is not heard from within a suitable time out time.
.Pp
Command line options are described following. Specifying a command line
option other than
.Fl i
or
.Fl n
will cause the specified query (queries) to be sent to the indicated
host(s) immediately. Otherwise,
.Nm
will attempt to read interactive format commands from the standard
input.
.Bl -tag -width indent
.It Fl c
The following argument is interpreted as an interactive format command
and is added to the list of commands to be executed on the specified
host(s). Multiple
.Fl c
options may be given.
.It Fl i
Force
.Nm
to operate in interactive mode. Prompts will be written to the standard
output and commands read from the standard input.
.It Fl l
Obtain a list of peers which are known to the server(s). This switch is
equivalent to
.Qq -c listpeers .
.It Fl n
Output all host addresses in dotted\-quad numeric format rather than
converting to the canonical host names.
.It Fl p
Print a list of the peers known to the server as well as a summary of
their state. This is equivalent to
.Qq -c peers .
.It Fl s
Print a list of the peers known to the server as well as a summary of
their state, but in a slightly different format than the
.Fl p
switch. This is equivalent to
.Qq -c dmpeers .
.El
.Sh INTERNAL COMMANDS
Interactive format commands consist of a keyword followed by zero to
four arguments. Only enough characters of the full keyword to uniquely
identify the command need be typed. The output of a command is normally
sent to the standard output, but optionally the output of individual
commands may be sent to a file by appending a
.Qq > ,
followed by a
file name, to the command line.
.Pp
A number of interactive format commands are executed entirely within the
.Nm
program itself and do not result in
.Tn NTP
mode 7 requests being sent to a
server. These are described following:
.Pp
.Bl -tag -width indent
.It Xo ?
.Op Ar command_keyword
.Xc
A
.Em ?
by itself will print a list of all the command keywords
known to this incarnation of
.Nm Ns .
A
.Em ?
followed by a command keyword will print function and
usage information about the command. This command is probably a better
source of information about
.Nm
than this manual page.
.It help Ar command_keyword
A synonym for the
.Em ?
command.
.It timeout Ar millseconds
Specify a time out period for responses to server queries. The default
is about 8000 milliseconds.
.It delay Ar milliseconds
Specify a time interval to be added to timestamps included in requests
which require authentication. This is used to enable (unreliable) server
reconfiguration over long delay network paths or between machines whose
clocks are unsynchronized.
.It host Ar hostname
Set the host to which future queries will be sent.
.Ar Hostname
may be either a host name or a numeric (dotted quad) dmaddress.
.It keyid Ar #
This command allows the specification of a key number to be used to
authenticate configuration requests. This must correspond to the key
number the server has been configured to use for this purpose.
.It passwd
This command prompts you to type in a password (which will not be
echoed) which will be used to authenticate configuration requests. The
password must correspond to the key configured for use by the
.Tn NTP
server for this purpose if such requests are to be successful.
.It hostnames Ar yes|no
If
.Ar yes
is specified, host names are printed in information
displays. If
.Ar no
is given, numeric addresses are printed
instead. The default is
.Ar yes
unless modified using the command line
.Fl n
switch.
.It quit
Exit
.Nm Ns .
.El
.Sh QUERY COMMANDS
Query commands result in
.Tn NTP
mode 7 packets containing requests for
information being sent to the server. These are
.Qq read\-only
commands in that they make no modification of the server configuration
state.
.Bl -tag -width indent
.It listpeers
Obtain and print a brief list of the peers for which the server is
maintaining state. These should include all configured peer associations
as well as those peers whose stratum is such that they are considered by
the server to be possible future synchronization candidates.
.It peers
Obtain a list of peers for which the server is maintaining state, along
with a summary of that state. Summary information includes the address
of the remote peer, the local interface address (0.0.0.0 if a local
address has yet to be determined), the stratum of the remote peer (a
stratum of 16 indicates the remote peer is unsynchronized), the polling
interval, in seconds, the reachability register, in octal, and the
current estimated delay, offset and dispersion of the peer, all in
seconds. In addition, the character in the left margin indicates the
mode this peer entry is operating in. A
.Qq +
denotes symmetric
active, a
.Qq -
indicates symmetric passive, a
.Qq =
means
the remote server is being polled in client mode, a
.Qq ^
indicates that the server is broadcasting to this address, a
.Qq ~
denotes that the remote peer is sending broadcasts and a
.Qq *
marks the peer the server is currently synchronizing to.
.Pp
The contents of the host field may be one of four forms. It may be a
host name, an IP address, a reference clock implementation name with its
parameter or
.Qq REFCLK(<implementation number>, <parameter>) .
On
.Qq hostnames no
only IP\-addresses will be displayed.
.It dmpeers
A slightly different peer summary list. Identical to the output of the
.Em peers
command except for the character in the leftmost column. Characters only
appear beside peers which were included in the final stage of the clock
selection algorithm. A
.Qq \&.
indicates that this peer was cast off
in the falseticker detection, while a
.Qq +
indicates that the
peer made it through. A
.Qq *
denotes the peer the server is
currently synchronizing with.
.It Xo showpeer
.Ar peer_address
.Op Ar addr2
.Op Ar addr3
.Op Ar addr4
.Xc
Show a detailed display of the current peer variables for one or more
peers. Most of these values are described in the
.Tn NTP
Version 2 specification.
.It Xo pstats
.Ar peer_address
.Op Ar addr2
.Op Ar addr3
.Op Ar addr4
.Xc
Show per\-peer statistic counters associated with the specified peer(s).
.It Xo clockinfo
.Ar clock_peer_address
.Op Ar addr2
.Op Ar addr3
.Op Ar addr4
.Xc
Obtain and print information concerning a peer clock. The values
obtained provide information on the setting of fudge factors and other
clock performance information.
.It kerninfo
Obtain and print kernel phase-lock loop operating parameters. This
information is available only if the kernel has been specially modified
for a precision timekeeping function.
.It loopinfo Op Ar oneline|multiline
Print the values of selected loop filter variables. The loop filter is
the part of
.Tn NTP
which deals with adjusting the local system clock. The
.Qq offset
is the last offset given to the loop filter by the
packet processing code. The
.Qq frequency
is the frequency error
of the local clock in parts-per-million (ppm). The
.Qq time_const
controls the
.Qq stiffness
of the phase-lock loop and thus the speed at
which it can adapt to oscillator drift. The
.Qq watchdog timer
value is the number of seconds which have elapsed since the last sample
offset was given to the loop filter. The
.Ar oneline
and
.Ar multiline
options specify the format in which this information
is to be printed, with
.Ar multiline
as the default.
.It sysinfo
Print a variety of system state variables, i.e. state related to the
local server. All except the last four lines are described in the
.Tn NTP
Version 3 specification, RFC 1305. The
.Qq system flags
show various system flags, some of which can be set and cleared by the
.Qq enable
and
.Qq disable
configuration commands,
respectively. The
.Qq stability
is the residual frequency error
remaining after the system frequency correction is applied and is
intended for maintenance and debugging. In most architectures, this
value will initially decrease from as high as 500 ppm to a nominal value
in the range .01 to 0.1 ppm. If it remains high for some time after
starting the daemon, something may be wrong with the local clock, or the
value of the kernel variable
.Qq tick
may be incorrect. The
.Qq broadcastdelay
shows the default broadcast delay, as set by
the
.Qq broadcastdelay
configuration command, while the
.Qq authdelay
shows the default authentication delay, as set by
the
.Qq authdelay
configuration command.
.It sysstats
Print statistics counters maintained in the protocol module.
.It memstats
Print statistics counters related to memory allocation
code.
.It iostats
Print statistics counters maintained in the input\-output module.
.It timerstats
Print statistics counters maintained in the timer/event queue support
code.
.It reslist
Obtain and print the server's restriction list. This list is (usually)
printed in sorted order and may help to understand how the restrictions
are applied.
.It monlist Op Ar version
Obtain and print traffic counts collected and maintained by the monitor
facility. The version number should not normally need to be specified.
.It Xo clkbug
.Ar clock_peer_address
.Op Ar addr2
.Op Ar addr3
.Op Ar addr4
.Xc
Obtain debugging information for a reference clock driver. This
information is provided only by some clock drivers and is mostly
undecodable without a copy of the driver source in hand.
.El
.Sh RUNTIME CONFIGURATION REQUESTS
All requests which cause state changes in the server are authenticated
by the server using a configured
.Tn NTP
key (the facility can also be
disabled by the server by not configuring a key). The key number and the
corresponding key must also be made known to
.Nm Ns .
This can be done using the
.Em keyid
and
.Em passwd
commands, the latter of which will prompt at the terminal for a password
to use as the encryption key. You will also be prompted automatically
for both the key number and password the first time a command which
would result in an authenticated request to the server is given.
Authentication not only provides verification that the requester has
permission to make such changes, but also gives an extra degree of
protection again transmission errors.
.Pp
Authenticated requests always include a timestamp in the packet data,
which is included in the computation of the authentication code. This
timestamp is compared by the server to its receive time stamp. If they
differ by more than a small amount the request is rejected. This is done
for two reasons. First, it makes simple replay attacks on the server, by
someone who might be able to overhear traffic on your LAN, much more
difficult. Second, it makes it more difficult to request configuration
changes to your server from topologically remote hosts. While the
reconfiguration facility will work well with a server on the local host,
and may work adequately between time\-synchronized hosts on the same
LAN, it will work very poorly for more distant hosts. As such, if
reasonable passwords are chosen, care is taken in the distribution and
protection of keys and appropriate source address restrictions are
applied, the run time reconfiguration facility should provide an
adequate level of security.
.Pp
The following commands all make authenticated requests:
.Bl -tag -width indent
.It Xo addpeer
.Ar peer_address
.Op Ar keyid
.Op Ar version#
.Op Ar prefer
.Xc
Add a configured peer association at the given address and operating in
symmetric active mode. Note that an existing association with the same
peer may be deleted when this command is executed, or may simply be
converted to conform to the new configuration, as appropriate. If the
optional
.Ar keyid
is a nonzero integer, all outgoing packets to
the remote server will have an authentication field attached encrypted
with this key. If the value is 0 (or not given) no authentication will
be done. The
.Ar version#
can be 1, 2 or 3 and defaults to 3. The
.Ar prefer
keyword indicates a preferred peer (and thus will be
used primarily for clock synchronisation if possible). The preferred
peer also determines the validity of the PPS signal - if the preferred
peer is suitable for synchronisation so is the PPS signal.
.It Xo addserver
.Ar peer_address
.Op Ar keyid
.Op Ar version#
.Op Ar prefer
.Xc
Identical to the
.Em addpeer
command, except that the operating mode is client.
.It Xo broadcast
.Ar peer_address
.Op Ar keyid
.Op Ar version#
.Xc
Identical to the
.Em addpeer
command, except that the operating mode is broadcast. In this case a
valid key identifier and key are required. The
.Ar peer_address
parameter can be the broadcast address of the local network or a
multicast group address assigned to
.Tn NTP .
If a multicast address, a
multicast-capable kernel is required.
.It Xo unconfig
.Ar peer_address
.Op Ar addr2
.Op Ar addr3
.Op Ar addr4
.Xc
This command causes the configured bit to be removed from the specified
peer(s). In many cases this will cause the peer association to be
deleted. When appropriate, however, the association may persist in an
unconfigured mode if the remote peer is willing to continue on in this
fashion.
.It Xo fudge
.Ar peer_address
.Op Ar time1
.Op Ar time2
.Op Ar stratum
.Op Ar refid
.Xc
This command provides a way to set certain data for a reference clock.
See the source listing for further information.
.It Xo enable
.Ar auth|bclient|pll|monitor|stats
.Op Ar ...
.Xc
Provide a way to enable various server options. Flags not mentioned are
unaffected. The
.Ar auth
flag causes 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 disable (off). The
.Ar bclient
flag causes the server
to listen for a message from a broadcast or multicast server, following
which an association is automatically instantiated for that server. The
default for this flag is disable (off). The
.Ar pll
flag enables
the server to adjust its local clock, with default enable (on). If not
set, 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
.Tn NTP
is used only to provide
synchronization to other clients. The
.Ar monitor
flag enables the
monitoring facility (see elsewhere), with default disable (off). The
.Ar stats
flag enables statistics facility filegen (see
description elsewhere.), with default enable (on).
.It Xo disable
.Ar auth|bclient|pll|monitor|stats
.Op Ar ...
.Xc
Provide a way to disable various server options. Flags not mentioned
are unaffected. The flags presently available are described under the
enable command.
.It Xo restrict
.Ar address
.Ar mask
.Ar flag
.Op Ar flag
.Xc
Cause flag(s) to be added to an existing restrict list entry, or adds a
new entry to the list with the specified flag(s). The possible choices
for the flags arguments are given in the following list:
.Bl -tag -width indent
.It ignore
Ignore all packets from hosts which match this entry. If this flag is
specified neither queries nor time server polls will be responded to.
.It noquery
Ignore all
.Tn NTP
mode 7 packets (i.e. information queries and
configuration requests) from the source. Time service is not affected.
.It nomodify
Ignore all
.Tn NTP
mode 7 packets which attempt to modify the state of the
server (i.e. run time reconfiguration). Queries which return information
are permitted.
.It notrap
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.
.It lowpriotrap
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.
.It noserve
Ignore
.Tn NTP
packets whose mode is other than 7. In effect, time service
is denied, though queries may still be permitted.
.It nopeer
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.
.It notrust
Treat these hosts normally in other respects, but never use them as
synchronization sources.
.It limited
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
.Qq client_limit
hosts that have
shown up at the server and that have been active during the last
.Qq client_limit_period
seconds are accepted. Requests from other
clients from the same net are rejected. Only time request packets are
taken into account.
.Qq Private ,
.Qq control ,
and
.Qq broadcast
packets are not subject to client limitation and
therefore are not contributing to client count. History of clients is
kept using the monitoring capability of
.Xr xntpd 8 .
Thus, monitoring is active as long as there is a restriction entry with
the
.Ar limited
flag. The default value for
.Qq client_limit
is 3. The default value for
.Qq client_limit_period
is 3600
seconds. Currently both variables are not runtime configurable.
.It ntpport
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
.Tn NTP
UDP port (123). Both
.Em ntpport
and
.Pf non\- Em ntpport
may be specified. The
.Em ntpport
is considered more specific and is sorted later in the list.
.El
.It Xo unrestrict
.Ar address
.Ar mask
.Ar flag
.Op Ar flag
.Xc
Remove the specified flag(s) from the restrict list entry indicated
by the
.Ar address
and
.Ar mask
arguments.
.It Xo delrestrict
.Ar address
.Ar mask
.Op Ar ntpport
.Xc
Delete the matching entry from the restrict list.
.It monitor Ar yes|no
Enable or disable the monitoring facility. Note that a
.Em monitor Ar no
command followed by a
.Em monitor Ar yes
command is a good way of resetting the packet counts.
.It readkeys
Cause the current set of authentication keys to be purged and a new set
to be obtained by rereading the keys file (which must have been
specified in the
.Nm xntpd
configuration file). This allows encryption keys to be changed without
restarting the server.
.It Xo trustkey
.Ar keyid
.Op Ar keyid
.Op Ar keyid
.Op Ar keyid
.Xc
Add one or more keys to the trusted key list. When authentication is
enabled, peers whose time is to be trusted must be authenticated using a
trusted key.
.It Xo untrustkey
.Ar keyid
.Op Ar keyid
.Op Ar keyid
.Op Ar keyid
.Xc
Remove one or more keys from the trusted key list.
.It authinfo
Return information concerning the authentication module, including
known keys and counts of encryptions and decryptions which have been
done.
.It setprecision Ar precision_value
Set the precision which the server advertises to the specified value.
This should be a negative integer in the range -4 through -20.
.It traps
Display the traps set in the server. See the source listing for further
information.
.It Xo addtrap
.Ar address
.Op Ar port
.Op Ar interface
.Xc
Set a trap for asynchronous messages. See the source listing for further
information.
.It Xo clrtrap
.Ar address
.Op Ar port
.Op Ar interface
.Xc
Clear a trap for asynchronous messages. See the source listing for
further information.
.It reset Ar ...
Clear the statistics counters in various modules of the server. See the
source listing for further information.
.El
.Sh SEE ALSO
.Xr xntpd 8
.Sh HISTORY
Written by
.An Dennis Ferguson
at the University of Toronto.
.Sh BUGS
.Nm Xntpdc
is a crude hack. Much of the information it shows is deadly boring and
could only be loved by its implementer. The program was designed so that
new (and temporary) features were easy to hack in, at great expense to
the program's ease of use. Despite this, the program is occasionally
useful.

View File

@ -1,21 +0,0 @@
README file for directory ./include of the NTP Version 3 distribution
This directory contains the include files used by most programs in this
distribution. The ./sys directory in this directory contains system
header files used by the clock discipline and STREAMS modules in the
../kernel directory.
Note that multicast support (MCAST define) requires the header file
/usr/include/netinet/in.h for the particular architecture to be in place.
This file is constructed during the installation process in older systems;
it is already in place for those machines that support multicast ex box.
The file in.h included in this distribution is for Suns; the files for
other systems can be found in the multicast distribtutions for each
architecture separately.
If the precision-time kernel (KERNEL_PLL define) is configured, the
installation process requires the header file /usr/include/sys/timex.h
for the particular architecture to be in place. The file timex.h included
in this distribution is for Suns; the files for other systems can be
found in the kernel distributions available from the manufacturer's
representatives.

View File

@ -1,256 +0,0 @@
/* @(#)in.h 1.19 90/07/27 SMI; from UCB 7.5 2/22/88 */
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
/*
* Constants and structures defined by the internet system,
* Per RFC 790, September 1981.
*/
#ifndef _netinet_in_h
#define _netinet_in_h
/*
* Protocols
*/
#define IPPROTO_IP 0 /* dummy for IP */
#define IPPROTO_ICMP 1 /* control message protocol */
#define IPPROTO_IGMP 2 /* group control protocol */
#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
#define IPPROTO_ST 5 /* st */
#define IPPROTO_TCP 6 /* tcp */
#define IPPROTO_EGP 8 /* exterior gateway protocol */
#define IPPROTO_PUP 12 /* pup */
#define IPPROTO_UDP 17 /* user datagram protocol */
#define IPPROTO_IDP 22 /* xns idp */
#define IPPROTO_HELLO 63 /* "hello" routing protocol */
#define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
#define IPPROTO_OSPF 89 /* Open SPF IGP */
#define IPPROTO_RAW 255 /* raw IP packet */
#define IPPROTO_MAX 256
/*
* Port/socket numbers: network standard functions
*/
#define IPPORT_ECHO 7
#define IPPORT_DISCARD 9
#define IPPORT_SYSTAT 11
#define IPPORT_DAYTIME 13
#define IPPORT_NETSTAT 15
#define IPPORT_FTP 21
#define IPPORT_TELNET 23
#define IPPORT_SMTP 25
#define IPPORT_TIMESERVER 37
#define IPPORT_NAMESERVER 42
#define IPPORT_WHOIS 43
#define IPPORT_MTP 57
/*
* Port/socket numbers: host specific functions
*/
#define IPPORT_TFTP 69
#define IPPORT_RJE 77
#define IPPORT_FINGER 79
#define IPPORT_TTYLINK 87
#define IPPORT_SUPDUP 95
/*
* UNIX TCP sockets
*/
#define IPPORT_EXECSERVER 512
#define IPPORT_LOGINSERVER 513
#define IPPORT_CMDSERVER 514
#define IPPORT_EFSSERVER 520
/*
* UNIX UDP sockets
*/
#define IPPORT_BIFFUDP 512
#define IPPORT_WHOSERVER 513
#define IPPORT_ROUTESERVER 520 /* 520+1 also used */
/*
* Ports < IPPORT_RESERVED are reserved for
* privileged processes (e.g. root).
* Ports > IPPORT_USERRESERVED are reserved
* for servers, not necessarily privileged.
*/
#define IPPORT_RESERVED 1024
#define IPPORT_USERRESERVED 5000
/*
* Link numbers
*/
#define IMPLINK_IP 155
#define IMPLINK_LOWEXPER 156
#define IMPLINK_HIGHEXPER 158
/*
* Internet address
* This definition contains obsolete fields for compatibility
* with SunOS 3.x and 4.2bsd. The presence of subnets renders
* divisions into fixed fields misleading at best. New code
* should use only the s_addr field.
*/
struct in_addr {
union {
struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
struct { u_short s_w1,s_w2; } S_un_w;
u_long S_addr;
} S_un;
#define s_addr S_un.S_addr /* should be used for all code */
#define s_host S_un.S_un_b.s_b2 /* OBSOLETE: host on imp */
#define s_net S_un.S_un_b.s_b1 /* OBSOLETE: network */
#define s_imp S_un.S_un_w.s_w2 /* OBSOLETE: imp */
#define s_impno S_un.S_un_b.s_b4 /* OBSOLETE: imp # */
#define s_lh S_un.S_un_b.s_b3 /* OBSOLETE: logical host */
};
/*
* Definitions of bits in internet address integers.
* On subnets, the decomposition of addresses to host and net parts
* is done according to subnet mask, not the masks here.
*/
#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
#define IN_CLASSA_NET 0xff000000
#define IN_CLASSA_NSHIFT 24
#define IN_CLASSA_HOST 0x00ffffff
#define IN_CLASSA_MAX 128
#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
#define IN_CLASSB_NET 0xffff0000
#define IN_CLASSB_NSHIFT 16
#define IN_CLASSB_HOST 0x0000ffff
#define IN_CLASSB_MAX 65536
#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
#define IN_CLASSC_NET 0xffffff00
#define IN_CLASSC_NSHIFT 8
#define IN_CLASSC_HOST 0x000000ff
#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
#define IN_MULTICAST(i) IN_CLASSD(i)
#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
#define INADDR_ANY (u_long)0x00000000
#define INADDR_LOOPBACK (u_long)0x7F000001
#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
#define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */
#define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */
#define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */
#define IN_LOOPBACKNET 127 /* official! */
/*
* Define a macro to stuff the loopback address into an Internet address
*/
#define IN_SET_LOOPBACK_ADDR(a) {(a)->sin_addr.s_addr = htonl(INADDR_LOOPBACK); \
(a)->sin_family = AF_INET;}
/*
* Socket address, internet style.
*/
struct sockaddr_in {
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
/*
* Options for use with [gs]etsockopt at the IP level.
*/
#define IP_OPTIONS 1 /* set/get IP per-packet options */
#define IP_MULTICAST_IF 2 /* set/get IP multicast interface */
#define IP_MULTICAST_TTL 3 /* set/get IP multicast timetolive */
#define IP_MULTICAST_LOOP 4 /* set/get IP multicast loopback */
#define IP_ADD_MEMBERSHIP 5 /* add an IP group membership */
#define IP_DROP_MEMBERSHIP 6 /* drop an IP group membership */
#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
#define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */
/*
* Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
*/
struct ip_mreq {
struct in_addr imr_multiaddr; /* IP multicast address of group */
struct in_addr imr_interface; /* local IP address of interface */
};
#if !defined(vax) && !defined(ntohl) && !defined(i386)
/*
* Macros for number representation conversion.
*/
#define ntohl(x) (x)
#define ntohs(x) (x)
#define htonl(x) (x)
#define htons(x) (x)
#endif
#if !defined(ntohl) && (defined(vax) || defined(i386))
u_short ntohs(), htons();
u_long ntohl(), htonl();
#endif
#ifdef KERNEL
extern struct domain inetdomain;
extern struct protosw inetsw[];
struct in_addr in_makeaddr();
u_long in_netof(), in_lnaof();
#endif
#ifndef BYTE_ORDER
/*
* Definitions for byte order,
* according to byte significance from low address to high.
*/
#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */
#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */
#if defined(vax) || defined(i386)
#define BYTE_ORDER LITTLE_ENDIAN
#else
#define BYTE_ORDER BIG_ENDIAN /* mc68000, tahoe, most others */
#endif
#endif BYTE_ORDER
/*
* Macros for number representation conversion.
*/
#if BYTE_ORDER==LITTLE_ENDIAN
#define NTOHL(d) ((d) = ntohl((d)))
#define NTOHS(d) ((d) = ntohs((d)))
#define HTONL(d) ((d) = htonl((d)))
#define HTONS(d) ((d) = htons((d)))
#else
#define ntohl(x) (x)
#define ntohs(x) (x)
#define htonl(x) (x)
#define htons(x) (x)
#define NTOHL(d)
#define NTOHS(d)
#define HTONL(d)
#define HTONS(d)
#endif
#endif /*!_netinet_in_h*/

View File

@ -1,284 +0,0 @@
/*
* Proto types for machines that are not ANSI and POSIX compliant.
* This is optionaly
*/
#ifndef _l_stdlib_h
#define _l_stdlib_h
#if defined(NTP_POSIX_SOURCE)
#include <stdlib.h>
#endif
#ifndef P
#if defined(__STDC__) || defined(USE_PROTOTYPES)
#define P(x) x
#else
#define P(x) ()
#if !defined(const)
#define const
#endif
#endif
#endif
/*
* Unprottyped library functions for SunOS 4.x.x
*/
#ifdef SYS_SUNOS4
extern void closelog P((void));
extern void openlog P((char *, int, int));
extern void syslog P((int, char *, ...));
extern int setlogmask P((int));
extern char * getpass P((char *));
extern int setpriority P((int ,int ,int));
extern long strtol P((char *, char **, int));
#if !defined(NTP_POSIX_SOURCE)
extern int atoi P((char *));
extern int dup2 P((int, int));
extern int execve P((char *, char **,char **));
extern int fork P((void));
extern int getdtablesize P((void));
extern int qsort P((void *, int , int,
int (*compar)(void *, void *)));
extern int rand P((void));
extern int setpgrp P((int, int));
extern void srand P((unsigned int));
extern void bcopy P((char *, char *, int));
#endif
#ifndef bzero /* XXX macro prototyping clash */
extern void bzero P((char *, int));
extern int bcmp P((char *, char *, int));
extern void bcopy P((char *, char *, int));
#endif
extern char *mktemp P((char *));
extern int tolower P((int));
extern int isatty P((int));
extern unsigned sleep P((unsigned ));
extern unsigned int alarm P((unsigned int));
extern int pause P((void));
extern int getpid P((void));
extern int getppid P((void));
extern int close P((int));
extern int ioctl P((int, int, char *));
extern int read P((int, void *, unsigned));
extern int rename P((char *, char *));
extern int write P((int, const void *, unsigned));
extern int unlink P((const char *));
extern int link P((const char *, const char *));
#ifdef FILE
extern int fclose P((FILE *));
extern int fflush P((FILE *));
extern int fprintf P((FILE *, char *, ...));
extern int fscanf P((FILE *, char *, ...));
extern int fputs P((char *, FILE *));
extern int fputc P((char, FILE *));
extern int fread P((char *, int, int, FILE *));
extern int printf P((char *, ...));
extern int setbuf P((FILE *, char *));
extern int setvbuf P((FILE *, char *, int, int));
extern int scanf P((char *, ...));
extern int sscanf P((char *, char *, ...));
extern int vsprintf P((char *, char *, ...));
extern int _flsbuf P((int, FILE *));
extern int _filbuf P((FILE *));
extern void perror P((char *));
#ifndef NTP_POSIX_SOURCE
extern int setlinebuf P((FILE *));
#endif
#endif
#ifdef _ntp_string_h
#ifdef NTP_POSIX_SOURCE /* these are builtins */
#ifndef NTP_NEED_BOPS /* but may be emulated by bops */
extern char *memcpy();
extern char *memset();
extern int memcmp();
#endif
#endif
#endif
#ifdef _sys_socket_h
extern int bind P((int, struct sockaddr *, int));
extern int connect P((int, struct sockaddr *, int));
extern int sendto P((int, char *, int, int, struct sockaddr *, int));
extern int setsockopt P((int, int, int, char *, int));
extern int socket P((int, int, int));
extern int recvfrom P((int, char *, int, int, struct sockaddr *, int *));
#endif /* _sys_socket_h */
#ifdef _ntp_select_h
extern int select P((int, fd_set *, fd_set *, fd_set *, struct timeval *));
#endif
#ifdef _sys_time_h
extern int adjtime P((struct timeval *, struct timeval *));
extern int setitimer P((int , struct itimerval *, struct itimerval *));
#ifdef SYSV_TIMEOFDAY
extern int gettimeofday P((struct timeval *));
extern int settimeofday P((struct timeval *));
#else /* ! SYSV_TIMEOFDAY */
extern int gettimeofday P((struct timeval *, struct timezone *));
extern int settimeofday P((struct timeval *, struct timezone *));
#endif /* SYSV_TIMEOFDAY */
#endif /* _sys_time_h */
#ifdef __time_h
extern time_t time P((time_t *));
#endif
#ifdef __setjmp_h
extern int setjmp P((jmp_buf));
extern void longjmp P((jmp_buf, int));
#endif
#ifdef _sys_resource_h
extern int getrusage P((int, struct rusage *));
#endif
#ifdef _nlist_h
extern int nlist P((char *, struct nlist *));
#endif
#endif /* SYS_SUNOS4 */
/*
* Unprototyped library functions for DEC OSF/1
*/
#ifdef SYS_DECOSF1
#ifndef _MACHINE_ENDIAN_H_
#define _MACHINE_ENDIAN_H_
extern u_short htons P((u_short));
extern u_short ntohs P((u_short));
extern U_LONG htonl P((U_LONG));
extern U_LONG ntohl P((U_LONG));
#endif /* _MACHINE_ENDIAN_H_ */
/*
extern char * getpass P((char *));
*/
extern char * mktemp P((char *));
#ifndef SYS_IX86OSF1
extern int ioctl P((int, u_long, char *));
extern void bzero P((char *, int));
#endif
#ifdef SOCK_DGRAM
extern int bind P((int, const struct sockaddr *, int));
extern int connect P((int, const struct sockaddr *, int));
extern int socket P((int, int, int));
extern int sendto P((int, const void *, int, int, const struct sockaddr *, int));
extern int setsockopt P((int, int, int, const void *, int));
extern int recvfrom P((int, void *, int, int, struct sockaddr *, int *));
#endif /* SOCK_STREAM */
#ifdef _ntp_select_h
extern int select P((int, fd_set *, fd_set *, fd_set *, struct timeval *));
#endif
#endif /* DECOSF1 */
/*
* Unprototyped library functions for Ultrix
*/
#ifdef SYS_ULTRIX
extern int close P((int));
extern char * getpass P((char *));
extern int getpid P((void));
extern int ioctl P((int, int, char *));
extern char *mktemp P((char *));
extern int unlink P((const char *));
extern int link P((const char *, const char *));
extern void closelog P((void));
extern void syslog P((int, char *, ...));
#ifndef LOG_DAEMON
extern void openlog P((char *, int));
#else
extern void openlog P((char *, int, int));
#endif
extern int setpriority P((int ,int ,int ));
#ifdef SOCK_DGRAM
extern int bind P((int, struct sockaddr *, int));
extern int connect P((int, struct sockaddr *, int));
extern int socket P((int, int, int));
extern int sendto P((int, char *, int, int, struct sockaddr *, int));
extern int setsockopt P((int, int, int, char *, int));
extern int recvfrom P((int, char *, int, int, struct sockaddr *, int *));
#endif /* SOCK_STREAM */
#ifdef _TIME_H_
extern int gettimeofday P((struct timeval *, struct timezone *));
extern int settimeofday P((struct timeval *, struct timezone *));
extern int adjtime P((struct timeval *, struct timeval *));
extern int select P((int, fd_set *, fd_set *, fd_set *, struct timeval *));
extern int setitimer P((int , struct itimerval *, struct itimerval *));
#endif /* _TIME_H_ */
#ifdef N_UNDF
extern int nlist P((char *, struct nlist *));
#endif
#ifndef bzero /* XXX macro prototyping clash */
extern void bzero P((char *, int));
extern int bcmp P((char *, char *, int));
extern void bcopy P((char *, char *, int));
#endif
#ifndef NTP_POSIX_SOURCE
extern int atoi P((char *));
extern void bzero P((char *, int));
extern int bcmp P((char *, char *, int));
extern void bcopy P((char *, char *, int));
extern int execve P((char *, char **,char **));
extern int fork P((void));
extern int getdtablesize P((void));
extern int ran P((void));
extern int rand P((void));
extern void srand P((unsigned int));
#ifdef _TIME_H_
extern int gettimeofday P((struct timeval *, struct timezone *));
extern int settimeofday P((struct timeval *, struct timezone *));
#endif
#endif
#ifdef _RESOURCE_H_
extern int getrusage P((int, struct rusage *));
#endif
#endif /* SYS_ULTRIX */
#if defined(__convex__)
extern char * getpass P((char *));
#endif
#ifdef SYS_IRIX4
extern char * getpass P((char *));
#endif /* IRIX4 */
#ifdef SYS_VAX
extern char * getpass P((char *));
#endif /* VAX */
#ifdef SYS_DOMAINOS
extern char * getpass P((char *));
#endif /* SYS_DOMAINOS */
#ifdef SYS_BSD
#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
#endif
#endif /* l_stdlib_h */

View File

@ -1,56 +0,0 @@
/*
***********************************************************************
** md5.h -- header file for implementation of MD5 **
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
** Created: 2/17/90 RLR **
** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
** Revised (for MD5): RLR 4/27/91 **
***********************************************************************
*/
/*
***********************************************************************
** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
** **
** License to copy and use this software is granted provided that **
** it is identified as the "RSA Data Security, Inc. MD5 Message- **
** Digest Algorithm" in all material mentioning or referencing this **
** software or this function. **
** **
** License is also granted to make and use derivative works **
** provided that such works are identified as "derived from the RSA **
** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
** material mentioning or referencing the derived work. **
** **
** RSA Data Security, Inc. makes no representations concerning **
** either the merchantability of this software or the suitability **
** of this software for any particular purpose. It is provided "as **
** is" without express or implied warranty of any kind. **
** **
** These notices must be retained in any copies of any part of this **
** documentation and/or software. **
***********************************************************************
*/
#include "ntp_types.h"
/* typedef a 32-bit type */
typedef unsigned LONG UINT4;
/* Data structure for MD5 (Message-Digest) computation */
typedef struct {
UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
UINT4 buf[4]; /* scratch buffer */
unsigned char in[64]; /* input buffer */
unsigned char digest[16]; /* actual digest after MD5Final call */
} MD5_CTX;
void MD5Init ();
void MD5Update ();
void MD5Final ();
/*
***********************************************************************
** End of md5.h **
******************************** (cut) ********************************
*/

View File

@ -1,40 +0,0 @@
/* records transmitted from extern CDU to MX 4200 */
#define PMVXG_S_INITMODEA 0 /* initialization/mode part A */
#define PMVXG_S_INITMODEB 1 /* initialization/mode part B*/
#define PMVXG_S_SATHEALTH 2 /* satellite health control */
#define PMVXG_S_DIFFNAV 3 /* differential navigation control */
#define PMVXG_S_PORTCONF 7 /* control port configuration */
#define PMVXG_S_GETSELFTEST 3 /* self test (request results) */
#define PMVXG_S_RTCMCONF 16 /* RTCM port configuration */
#define PMVXG_S_PASSTHRU 17 /* equipment port pass-thru config */
#define PMVXG_S_RESTART 18 /* restart control */
#define PMVXG_S_OSCPARAM 19 /* oscillator parameter */
#define PMVXG_S_DOSELFTEST 20 /* self test (activate a test) */
#define PMVXG_S_TRECOVCONF 23 /* time recovery configuration */
#define PMVXG_S_RAWDATASEL 24 /* raw data port data selection */
#define PMVXG_S_EQUIPCONF 26 /* equipment port configuration */
#define PMVXG_S_RAWDATACONF 27 /* raw data port configuration */
/* records transmitted from MX 4200 to external CDU */
#define PMVXG_D_STATUS 0 /* status */
#define PMVXG_D_POSITION 1 /* position */
#define PMVXG_D_OPDOPS 3 /* (optimum) DOPs */
#define PMVXG_D_MODEDATA 4 /* mode data */
#define PMVXG_D_SATPRED 5 /* satellite predictions */
#define PMVXG_D_SATHEALTH 6 /* satellite health status */
#define PMVXG_D_UNRECOG 7 /* unrecognized request response */
#define PMVXG_D_SIGSTRLOC 8 /* sig strength & location (sats 1-4) */
#define PMVXG_D_SPEEDHEAD 11 /* speed/heading data */
#define PMVXG_D_OSELFTEST 12 /* (old) self-test results */
#define PMVXG_D_SIGSTRLOC2 18 /* sig strength & location (sats 5-8) */
#define PMVXG_D_OSCPARAM 19 /* oscillator parameter */
#define PMVXG_D_SELFTEST 20 /* self test results */
#define PMVXG_D_PHV 21 /* position, height & velocity */
#define PMVXG_D_DOPS 22 /* DOPs */
#define PMVXG_D_SOFTCONF 30 /* software configuration */
#define PMVXG_D_DIFFGPSMODE 503 /* differential gps moding */
#define PMVXG_D_TRECOVUSEAGE 523 /* time recovery usage */
#define PMVXG_D_RAWDATAOUT 524 /* raw data port data output */
#define PMVXG_D_TRECOVRESULT 828 /* time recovery results */
#define PMVXG_D_TRECOVOUT 830 /* time recovery output message */

View File

@ -1,706 +0,0 @@
/*
* ntp.h - NTP definitions for the masses
*/
#include "ntp_types.h"
/*
* How to get signed characters. On machines where signed char works,
* use it. On machines where signed char doesn't work, char had better
* be signed.
*/
#if !defined(S_CHAR_DEFINED)
#if defined(NO_SIGNED_CHAR_DECL)
typedef char s_char;
#else
typedef signed char s_char;
#endif
#ifdef sequent
#undef SO_RCVBUF
#undef SO_SNDBUF
#endif
#endif
/*
* NTP protocol parameters. See section 3.2.6 of the specification.
*/
#define NTP_VERSION ((u_char)3) /* current version number */
#define NTP_OLDVERSION ((u_char)1) /* oldest credible version */
#define NTP_PORT 123 /* included for sake of non-unix machines */
#define NTP_MAXSTRATUM ((u_char)15) /* max stratum, infinity a la Bellman-Ford */
#define NTP_MAXAGE 86400 /* one day in seconds */
#define NTP_MAXSKEW 1 /* 1 sec, skew after NTP_MAXAGE w/o updates */
#define NTP_SKEWINC 49170 /* skew increment for clock updates (l_f) */
#define NTP_SKEWFACTOR 16 /* approximation of factor for peer calcs */
#define NTP_MAXDISTANCE (1 * FP_SECOND) /* max. rootdelay for synchr. */
#define NTP_MINDPOLL 6 /* log2 default min poll interval (64 s) */
#define NTP_MAXDPOLL 10 /* log2 default max poll interval (~17 m) */
#define NTP_MINPOLL 4 /* log2 min poll interval (16 s) */
#define NTP_MAXPOLL 14 /* log2 max poll interval (~4.5 h) */
#define NTP_MINCLOCK 3 /* minimum for outlyer detection */
#define NTP_MAXCLOCK 10 /* maximum select list size */
#define NTP_MINDISPERSE (FP_SECOND / 100) /* min dispersion (u_fp 10 ms) */
#define NTP_MAXDISPERSE (FP_SECOND * 16) /* max dispersion (u_fp 16 s) */
#define NTP_DISPFACTOR 20 /* MAXDISPERSE as a shift (u_fp 16 s) */
#define NTP_WINDOW 8 /* reachability register size */
#define NTP_SHIFT 8 /* 8 suitable for crystal time base */
#define NTP_MAXKEY 65535 /* maximum authentication key number */
#define NTP_MAXD 3 /* log2 estimated error averaging factor */
/*
* Loop filter parameters. See section 5.1 of the specification.
*
* Note that these are appropriate for a crystal time base. If your
* system clock is line frequency controlled you should read the
* specification for appropriate modifications. Note that the
* loop filter code will have to change if you change CLOCK_MAX
* to be greater than or equal to 500 ms.
*
* Note these parameters have been rescaled for a time constant range from
* 0 through 10, with 2 corresoponding to the old time constant of 0.
*/
#define CLOCK_MINSTEP 900 /* step timeout (sec) */
#define CLOCK_ADJ 0 /* log2 adjustment interval (1 sec) */
#define CLOCK_DSCALE 20 /* skew reg. scale: unit is 2**-20 ~= 1 ppm */
#define CLOCK_FREQ 16 /* log2 frequency weight (65536) */
#define CLOCK_PHASE 6 /* log2 phase weight (64) */
#define CLOCK_LIMIT 30 /* time constant adjust threshold */
#define CLOCK_G 2 /* log2 frequency averaging factor */
#define CLOCK_MAXSEC 800 /* max update interval for pll */
#define CLOCK_MAX_FP 0x000020c5 /* max clock offset (s_fp 128 ms) */
#define CLOCK_MAX_F 0x20c49ba6 /* max clock offset (l_fp 128 ms) */
#define CLOCK_MAX_I 0x00000000 /* both fractional and integral parts */
#define CLOCK_WAYTOOBIG 1000 /* if clock 1000 sec off, forget it */
/*
* Event timers are actually implemented as a sorted queue of expiry
* times. The queue is slotted, with each slot holding timers which
* expire in a 2**(NTP_MINPOLL-1) (8) second period. The timers in
* each slot are sorted by increasing expiry time. The number of
* slots is 2**(NTP_MAXPOLL-(NTP_MINPOLL-1)), or 512, to cover a time
* period of 2**NTP_MAXPOLL (16384) seconds into the future before
* wrapping.
*/
#define EVENT_TIMEOUT CLOCK_ADJ
struct event {
struct event *next; /* next in chain */
struct event *prev; /* previous in chain */
struct peer *peer; /* peer this counter belongs to */
void (*event_handler)(); /* routine to call to handle event */
u_long event_time; /* expiry time of counter */
};
#define TIMER_SLOTTIME (1<<(NTP_MINPOLL-1))
#define TIMER_NSLOTS (1<<(NTP_MAXPOLL-(NTP_MINPOLL-1)))
#define TIMER_SLOT(t) (((t) >> (NTP_MINPOLL-1)) & (TIMER_NSLOTS-1))
/*
* TIMER_ENQUEUE() puts stuff on the timer queue. It takes as
* arguments (ea), an array of event slots, and (iev), the event
* to be inserted. This one searches the hash bucket from the
* end, and is about optimum for the timing requirements of
* NTP peers.
*/
#define TIMER_ENQUEUE(ea, iev) \
do { \
register struct event *ev; \
\
ev = (ea)[TIMER_SLOT((iev)->event_time)].prev; \
while (ev->event_time > (iev)->event_time) \
ev = ev->prev; \
(iev)->prev = ev; \
(iev)->next = ev->next; \
(ev)->next->prev = (iev); \
(ev)->next = (iev); \
} while(0)
/*
* TIMER_INSERT() also puts stuff on the timer queue, but searches the
* bucket from the top. This is better for things that do very short
* time outs, like clock support.
*/
#define TIMER_INSERT(ea, iev) \
do { \
register struct event *ev; \
\
ev = (ea)[TIMER_SLOT((iev)->event_time)].next; \
while (ev->event_time != 0 && \
ev->event_time < (iev)->event_time) \
ev = ev->next; \
(iev)->next = ev; \
(iev)->prev = ev->prev; \
(ev)->prev->next = (iev); \
(ev)->prev = (iev); \
} while(0)
/*
* Remove an event from the queue.
*/
#define TIMER_DEQUEUE(ev) \
do { \
if ((ev)->next != 0) { \
(ev)->next->prev = (ev)->prev; \
(ev)->prev->next = (ev)->next; \
(ev)->next = (ev)->prev = 0; \
} \
} while (0)
/*
* The interface structure is used to hold the addresses and socket
* numbers of each of the interfaces we are using.
*/
struct interface {
int fd; /* socket this is opened on */
int bfd; /* socket for receiving broadcasts */
struct sockaddr_in sin; /* interface address */
struct sockaddr_in bcast; /* broadcast address */
struct sockaddr_in mask; /* interface mask */
char name[8]; /* name of interface */
int flags; /* interface flags */
int last_ttl; /* last TTL specified */
long received; /* number of incoming packets */
long sent; /* number of outgoing packets */
long notsent; /* number of send failures */
};
/*
* Flags for interfaces
*/
#define INT_BROADCAST 1 /* can broadcast out this interface */
#define INT_BCASTOPEN 2 /* broadcast socket is open */
#define INT_LOOPBACK 4 /* the loopback interface */
#define INT_MULTICAST 8 /* multicasting enabled */
/*
* Define flasher bits (tests 1 through 8 in packet procedure)
* These reveal the state at the last grumble from the peer and are
* most handy for diagnosing problems, even if not strictly a state
* variable in the spec. These are recorded in the peer structure.
*/
#define TEST1 0x01 /* duplicate packet received */
#define TEST2 0x02 /* bogus packet received */
#define TEST3 0x04 /* protocol unsynchronized */
#define TEST4 0x08 /* peer delay/dispersion bounds check */
#define TEST5 0x10 /* peer authentication failed */
#define TEST6 0x20 /* peer clock unsynchronized */
#define TEST7 0x40 /* peer stratum out of bounds */
#define TEST8 0x80 /* root delay/dispersion bounds check */
/*
* The peer structure. Holds state information relating to the guys
* we are peering with. Most of this stuff is from section 3.2 of the
* spec.
*/
struct peer {
struct peer *next;
struct peer *ass_next; /* link pointer in associd hash */
struct sockaddr_in srcadr; /* address of remote host */
struct interface *dstadr; /* pointer to address on local host */
struct refclockproc *procptr; /* pointer to reference clock sutuff */
u_char leap; /* leap indicator */
u_char hmode; /* association mode with this peer */
u_char pmode; /* peer's association mode */
u_char stratum; /* stratum of remote peer */
s_char precision; /* peer's clock precision */
u_char ppoll; /* peer poll interval */
u_char hpoll; /* local host poll interval */
u_char minpoll; /* min local host poll interval */
u_char maxpoll; /* max local host poll interval */
u_char version; /* version number */
u_char flags; /* peer flags */
u_char cast_flags; /* flags MDF_?CAST */
u_char flash; /* peer flashers (for maint) */
u_char refclktype; /* reference clock type */
u_char refclkunit; /* reference clock unit number */
u_char sstclktype; /* clock type for system status word */
s_fp rootdelay; /* distance from primary clock */
u_fp rootdispersion; /* peer clock dispersion */
U_LONG refid; /* peer reference ID */
l_fp reftime; /* time of peer's last update */
struct event event_timer; /* event queue entry */
U_LONG keyid; /* encription key ID */
U_LONG pkeyid; /* keyid used to encrypt last message */
u_short associd; /* association ID, a unique integer */
u_char ttl; /* time to live (multicast) */
/* **Start of clear-to-zero area.*** */
/* Everything that is cleared to zero goes below here */
u_char valid; /* valid counter */
#define clear_to_zero valid
u_char reach; /* reachability, NTP_WINDOW bits */
u_char unreach; /* unreachable count */
u_short filter_nextpt; /* index into filter shift register */
s_fp filter_delay[NTP_SHIFT]; /* delay part of shift register */
l_fp filter_offset[NTP_SHIFT]; /* offset part of shift register */
s_fp filter_soffset[NTP_SHIFT]; /* offset in s_fp format, for disp */
l_fp org; /* originate time stamp */
l_fp rec; /* receive time stamp */
l_fp xmt; /* transmit time stamp */
/* ***End of clear-to-zero area.*** */
/* Everything that is cleared to zero goes above here */
u_char filter_order[NTP_SHIFT]; /* we keep the filter sorted here */
#define end_clear_to_zero filter_order[0]
u_fp filter_error[NTP_SHIFT]; /* error part of shift register */
long update; /* base sys_clock for skew calc.s */
s_fp delay; /* filter estimated delay */
u_fp dispersion; /* filter estimated dispersion */
l_fp offset; /* filter estimated clock offset */
s_fp soffset; /* fp version of above */
s_fp synch; /* synch distance from above */
u_fp selectdisp; /* select dispersion */
s_fp estbdelay; /* broadcast offset */
/*
* statistic counters
*/
u_long timereset; /* time stat counters were reset */
u_long sent; /* number of updates sent */
u_long received; /* number of frames received */
u_long timereceived; /* last time a frame received */
u_long timereachable; /* last reachable/unreachable event */
u_long processed; /* processed by the protocol */
u_long badauth; /* bad credentials detected */
u_long bogusorg; /* rejected due to bogus origin */
u_long oldpkt; /* rejected as duplicate packet */
u_long seldisptoolarge; /* too much dispersion for selection */
u_long selbroken; /* broken NTP detected in selection */
u_long seltooold; /* too long since sync in selection */
u_char candidate; /* position after candidate selection */
u_char select; /* position at end of falseticker sel */
u_char was_sane; /* set to 1 if it passed sanity check */
u_char correct; /* set to 1 if it passed correctness check */
u_char last_event; /* set to code for last peer error */
u_char num_events; /* num. of events which have occurred */
};
/*
* Values for peer.leap, sys_leap
*/
#define LEAP_NOWARNING 0x0 /* normal, no leap second warning */
#define LEAP_ADDSECOND 0x1 /* last minute of day has 61 seconds */
#define LEAP_DELSECOND 0x2 /* last minute of day has 59 seconds */
#define LEAP_NOTINSYNC 0x3 /* overload, clock is free running */
/*
* Values for peer.mode
*/
#define MODE_UNSPEC 0 /* unspecified (probably old NTP version) */
#define MODE_ACTIVE 1 /* symmetric active */
#define MODE_PASSIVE 2 /* symmetric passive */
#define MODE_CLIENT 3 /* client mode */
#define MODE_SERVER 4 /* server mode */
#define MODE_BROADCAST 5 /* broadcast mode */
#define MODE_CONTROL 6 /* control mode packet */
#define MODE_PRIVATE 7 /* implementation defined function */
#define MODE_BCLIENT 8 /* a pseudo mode, used internally */
#define MODE_MCLIENT 9 /* multicast mode, used internally */
/*
* Values for peer.stratum, sys_stratum
*/
#define STRATUM_REFCLOCK ((u_char)0) /* stratum claimed by primary clock */
#define STRATUM_PRIMARY ((u_char)1) /* host has a primary clock */
#define STRATUM_INFIN ((u_char)NTP_MAXSTRATUM) /* infinity a la Bellman-Ford */
/* A stratum of 0 in the packet is mapped to 16 internally */
#define STRATUM_PKT_UNSPEC ((u_char)0) /* unspecified in packet */
#define STRATUM_UNSPEC ((u_char)(NTP_MAXSTRATUM+(u_char)1)) /* unspecified */
/*
* Values for peer.flags
*/
#define FLAG_CONFIG 0x1 /* association was configured */
#define FLAG_AUTHENABLE 0x2 /* this guy needs authentication */
#define FLAG_MCAST1 0x4 /* multicast client/server mode */
#define FLAG_MCAST2 0x8 /* multicast client mode */
#define FLAG_AUTHENTIC 0x10 /* last message was authentic */
#define FLAG_REFCLOCK 0x20 /* this is actually a reference clock */
#define FLAG_SYSPEER 0x40 /* this is one of the selected peers */
#define FLAG_PREFER 0x80 /* this is the preferred peer */
/*
* Definitions for the clear() routine. We use memset() to clear
* the parts of the peer structure which go to zero. These are
* used to calculate the start address and length of the area.
*/
#define CLEAR_TO_ZERO(p) ((char *)&((p)->clear_to_zero))
#define END_CLEAR_TO_ZERO(p) ((char *)&((p)->end_clear_to_zero))
#define LEN_CLEAR_TO_ZERO (END_CLEAR_TO_ZERO((struct peer *)0) \
- CLEAR_TO_ZERO((struct peer *)0))
/*
* Reference clock identifiers (for pps signal)
*/
#define PPSREFID (U_LONG)"PPS " /* used when pps controls stratum > 1 */
/*
* Reference clock types. Added as necessary.
*/
#define REFCLK_NONE 0 /* unknown or missing */
#define REFCLK_LOCALCLOCK 1 /* external (e.g., lockclock) */
#define REFCLK_GPS_TRAK 2 /* TRAK 8810 GPS Receiver */
#define REFCLK_WWV_PST 3 /* PST/Traconex 1020 WWV/H */
#define REFCLK_WWVB_SPECTRACOM 4 /* Spectracom 8170/Netclock WWVB */
#define REFCLK_GOES_TRUETIME 5 /* TrueTime 468-DC GOES */
#define REFCLK_IRIG_AUDIO 6 /* IRIG-B audio decoder */
#define REFCLK_CHU 7 /* scratchbuilt CHU (Canada) */
#define REFCLK_PARSE 8 /* generic driver (usually DCF77,GPS) */
#define REFCLK_GPS_MX4200 9 /* Magnavox MX4200 GPS */
#define REFCLK_GPS_AS2201 10 /* Austron 2201A GPS */
#define REFCLK_OMEGA_TRUETIME 11 /* TrueTime OM-DC OMEGA */
#define REFCLK_IRIG_TPRO 12 /* KSI/Odetics TPRO-S IRIG */
#define REFCLK_ATOM_LEITCH 13 /* Leitch CSD 5300 Master Clock */
#define REFCLK_MSF_EES 14 /* EES M201 MSF Receiver */
#define REFCLK_GPSTM_TRUETIME 15 /* TrueTime GPS/TM-TMD Receiver */
#define REFCLK_IRIG_BANCOMM 16 /* Bancomm GPS/IRIG Interface */
#define REFCLK_GPS_DATUM 17 /* Datum Programmable Time System */
#define REFCLK_NIST_ACTS 18 /* NIST Auto Computer Time Service */
#define REFCLK_WWV_HEATH 19 /* Heath GC1000 WWV/WWVH Receiver */
#define REFCLK_GPS_NMEA 20 /* NMEA based GPS clock */
#define REFCLK_GPS_MOTO 21 /* Motorola GPS clock */
#define REFCLK_ATOM_PPS 22 /* 1-PPS Clock Discipline */
#define REFCLK_MAX 24 /* maximum index (room to expand) */
/*
* We tell reference clocks from real peers by giving the reference
* clocks an address of the form 127.127.t.u, where t is the type and
* u is the unit number. We define some of this here since we will need
* some sanity checks to make sure this address isn't interpretted as
* that of a normal peer.
*/
#define REFCLOCK_ADDR 0x7f7f0000 /* 127.127.0.0 */
#define REFCLOCK_MASK 0xffff0000 /* 255.255.0.0 */
#define ISREFCLOCKADR(srcadr) ((SRCADR(srcadr) & REFCLOCK_MASK) \
== REFCLOCK_ADDR)
/*
* Macro for checking for invalid addresses. This is really, really
* gross, but is needed so no one configures a host on net 127 now that
* we're encouraging it the the configuration file.
*/
#define LOOPBACKADR 0x7f000001
#define LOOPNETMASK 0xff000000
#define ISBADADR(srcadr) (((SRCADR(srcadr) & LOOPNETMASK) \
== (LOOPBACKADR & LOOPNETMASK)) \
&& (SRCADR(srcadr) != LOOPBACKADR))
/*
* Utilities for manipulating addresses and port numbers
*/
#define NSRCADR(src) ((src)->sin_addr.s_addr) /* address in net byte order */
#define NSRCPORT(src) ((src)->sin_port) /* port in net byte order */
#define SRCADR(src) (ntohl(NSRCADR((src)))) /* address in host byte order */
#define SRCPORT(src) (ntohs(NSRCPORT((src)))) /* host port */
/*
* NTP packet format. The mac field is optional. It isn't really
* an l_fp either, but for now declaring it that way is convenient.
* See Appendix A in the specification.
*
* Note that all u_fp and l_fp values arrive in network byte order
* and must be converted (except the mac, which isn't, really).
*/
struct pkt {
u_char li_vn_mode; /* contains leap indicator, version and mode */
u_char stratum; /* peer's stratum */
u_char ppoll; /* the peer polling interval */
s_char precision; /* peer clock precision */
s_fp rootdelay; /* distance to primary clock */
u_fp rootdispersion; /* clock dispersion */
U_LONG refid; /* reference clock ID */
l_fp reftime; /* time peer clock was last updated */
l_fp org; /* originate time stamp */
l_fp rec; /* receive time stamp */
l_fp xmt; /* transmit time stamp */
#define MIN_MAC_LEN (sizeof(U_LONG) + 8) /* DES */
#define MAX_MAC_LEN (sizeof(U_LONG) + 16) /* MD5 */
U_LONG keyid; /* key identification */
u_char mac[MAX_MAC_LEN-sizeof(U_LONG)];/* message-authentication code */
/*l_fp mac;*/
};
/*
* Packets can come in two flavours, one with a mac and one without.
*/
#define LEN_PKT_NOMAC (sizeof(struct pkt) - MAX_MAC_LEN)
/*
* Minimum size of packet with a MAC: has to include at least a key number.
*/
#define LEN_PKT_MAC (LEN_PKT_NOMAC + sizeof(U_LONG))
/*
* Stuff for extracting things from li_vn_mode
*/
#define PKT_MODE(li_vn_mode) ((u_char)((li_vn_mode) & 0x7))
#define PKT_VERSION(li_vn_mode) ((u_char)(((li_vn_mode) >> 3) & 0x7))
#define PKT_LEAP(li_vn_mode) ((u_char)(((li_vn_mode) >> 6) & 0x3))
/*
* Stuff for putting things back into li_vn_mode
*/
#define PKT_LI_VN_MODE(li, vn, md) \
((u_char)((((li) << 6) & 0xc0) | (((vn) << 3) & 0x38) | ((md) & 0x7)))
/*
* Dealing with stratum. 0 gets mapped to 16 incoming, and back to 0
* on output.
*/
#define PKT_TO_STRATUM(s) ((u_char)(((s) == (STRATUM_PKT_UNSPEC)) ?\
(STRATUM_UNSPEC) : (s)))
#define STRATUM_TO_PKT(s) ((u_char)(((s) == (STRATUM_UNSPEC)) ?\
(STRATUM_PKT_UNSPEC) : (s)))
/*
* Format of a recvbuf. These are used by the asynchronous receive
* routine to store incoming packets and related information.
*/
/*
* the maximum length NTP packet is a full length NTP control message with
* the maximum length message authenticator. I hate to hard-code 468 and 12,
* but only a few modules include ntp_control.h...
*/
#define RX_BUFF_SIZE (468+12+MAX_MAC_LEN)
struct recvbuf {
struct recvbuf *next; /* next buffer in chain */
union {
struct sockaddr_in X_recv_srcadr;
caddr_t X_recv_srcclock;
} X_from_where;
#define recv_srcadr X_from_where.X_recv_srcadr
#define recv_srcclock X_from_where.X_recv_srcclock
struct sockaddr_in srcadr; /* where packet came from */
struct interface *dstadr; /* interface datagram arrived thru */
int fd; /* fd on which it was received */
l_fp recv_time; /* time of arrival */
void (*receiver)(); /* routine to receive buffer */
int recv_length; /* number of octets received */
union {
struct pkt X_recv_pkt;
char X_recv_buffer[RX_BUFF_SIZE];
} recv_space;
#define recv_pkt recv_space.X_recv_pkt
#define recv_buffer recv_space.X_recv_buffer
};
/*
* Event codes. Used for reporting errors/events to the control module
*/
#define PEER_EVENT 0x80 /* this is a peer event */
#define EVNT_UNSPEC 0
#define EVNT_SYSRESTART 1
#define EVNT_SYSFAULT 2
#define EVNT_SYNCCHG 3
#define EVNT_PEERSTCHG 4
#define EVNT_CLOCKRESET 5
#define EVNT_BADDATETIM 6
#define EVNT_CLOCKEXCPT 7
#define EVNT_PEERIPERR (1|PEER_EVENT)
#define EVNT_PEERAUTH (2|PEER_EVENT)
#define EVNT_UNREACH (3|PEER_EVENT)
#define EVNT_REACH (4|PEER_EVENT)
#define EVNT_PEERCLOCK (5|PEER_EVENT)
/*
* Clock event codes
*/
#define CEVNT_NOMINAL 0
#define CEVNT_TIMEOUT 1
#define CEVNT_BADREPLY 2
#define CEVNT_FAULT 3
#define CEVNT_PROP 4
#define CEVNT_BADDATE 5
#define CEVNT_BADTIME 6
#define CEVNT_MAX CEVNT_BADTIME
/*
* Very misplaced value. Default port through which we send traps.
*/
#define TRAPPORT 18447
/*
* To speed lookups, peers are hashed by the low order bits of the remote
* IP address. These definitions relate to that.
*/
#define HASH_SIZE 32
#define HASH_MASK (HASH_SIZE-1)
#define HASH_ADDR(src) ((SRCADR((src))^(SRCADR((src))>>8)) & HASH_MASK)
/*
* The poll update procedure takes an extra argument which controls
* how a random perturbation is applied to peer.timer. The choice is
* to not randomize at all, to randomize only if we're going to update
* peer.timer, and to randomize no matter what (almost, the algorithm
* is that we apply the random value if it is less than the current
* timer count).
*/
#define POLL_NOTRANDOM 0 /* don't randomize */
#define POLL_RANDOMCHANGE 1 /* if you change, change randomly */
#define POLL_MAKERANDOM 2 /* randomize next interval */
/*
* How we randomize polls. The poll interval is a power of two.
* We chose a random value which is between 1/4 and 3/4 of the
* poll interval we would normally use and which is an even multiple
* of the EVENT_TIMEOUT. The random number routine, given an argument
* spread value of n, returns an integer between 0 and (1<<n)-1. This
* is shifted by EVENT_TIMEOUT and added to the base value.
*/
#define RANDOM_SPREAD(poll) ((poll) - (EVENT_TIMEOUT+1))
#define RANDOM_POLL(poll, rval) ((((rval)+1)<<EVENT_TIMEOUT) + (1<<((poll)-2)))
/*
* min, min3 and max. Makes it easier to transliterate the spec without
* thinking about it.
*/
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min3(a,b,c) min(min((a),(b)), (c))
/*
* Configuration items. These are for the protocol module (proto_config())
*/
#define PROTO_BROADCLIENT 1
#define PROTO_PRECISION 2
#define PROTO_AUTHENTICATE 3
#define PROTO_BROADDELAY 4
#define PROTO_AUTHDELAY 5
#define PROTO_MULTICAST_ADD 6
#define PROTO_MULTICAST_DEL 7
#define PROTO_PLL 8
#define PROTO_PPS 9
#define PROTO_MONITOR 10
#define PROTO_FILEGEN 11
/*
* Configuration items for the loop filter
*/
#define LOOP_DRIFTCOMP 1 /* set frequency offset */
#define LOOP_PPSDELAY 2 /* set pps delay */
#define LOOP_PPSBAUD 3 /* set pps baud rate */
/*
* Configuration items for the stats printer
*/
#define STATS_FREQ_FILE 1 /* configure drift file */
#define STATS_STATSDIR 2 /* directory prefix for stats files */
#define STATS_PID_FILE 3 /* configure xntpd PID file */
#define MJD_1970 40587 /* MJD for 1 Jan 1970 */
/*
* Default parameters. We use these in the absense of something better.
*/
#define DEFPRECISION (-7) /* default precision (~10 ms) */
#define DEFBROADDELAY 0x00000100 /* default broadcast offset */
/* (~4 ms as s_fp) */
#define DEFAUTHDELAY 0x00080000 /* default authentcation delay */
/* (~100 us as l_fp.u_f) */
#define INADDR_NTP 0xe0000101 /* NTP multicast address 224.0.1.1 */
/*
* Structure used optionally for monitoring when this is turned on.
*/
struct mon_data {
struct mon_data *hash_next; /* next structure in hash list */
struct mon_data *mru_next; /* next structure in MRU list */
struct mon_data *mru_prev; /* previous structure in MRU list */
struct mon_data *fifo_next; /* next structure in FIFO list */
struct mon_data *fifo_prev; /* previous structure in FIFO list */
u_long lastdrop; /* last time dropped due to RES_LIMIT*/
u_long lasttime; /* last time data updated */
u_long firsttime; /* time structure initialized */
u_long count; /* count we have seen */
U_LONG rmtadr; /* address of remote host */
struct interface *interface; /* interface on which this arrived */
u_short rmtport; /* remote port last came from */
u_char mode; /* mode of incoming packet */
u_char version; /* version of incoming packet */
u_char cast_flags; /* flags MDF_?CAST */
};
#define MDF_UCAST 1 /* unicast packet */
#define MDF_MCAST 2 /* multicast packet */
#define MDF_BCAST 4 /* broadcast packet */
#define MDF_LCAST 8 /* local packet */
/*
* Values used with mon_enabled to indicate reason for enabling monitoring
*/
#define MON_OFF 0x00 /* no monitoring */
#define MON_ON 0x01 /* monitoring explicitly enabled */
#define MON_RES 0x02 /* implicit monitoring for RES_LIMITED */
/*
* Structure used for restrictlist entries
*/
struct restrictlist {
struct restrictlist *next; /* link to next entry */
U_LONG addr; /* host address (host byte order) */
U_LONG mask; /* mask for address (host byte order) */
u_long count; /* number of packets matched */
u_short flags; /* accesslist flags */
u_short mflags; /* match flags */
};
/*
* Access flags
*/
#define RES_IGNORE 0x1 /* ignore if matched */
#define RES_DONTSERVE 0x2 /* don't give him any time */
#define RES_DONTTRUST 0x4 /* don't trust if matched */
#define RES_NOQUERY 0x8 /* don't allow queries if matched */
#define RES_NOMODIFY 0x10 /* don't allow him to modify server */
#define RES_NOPEER 0x20 /* don't allocate memory resources */
#define RES_NOTRAP 0x40 /* don't allow him to set traps */
#define RES_LPTRAP 0x80 /* traps set by him are low priority */
#define RES_LIMITED 0x100 /* limit per net number of clients */
#define RES_ALLFLAGS \
(RES_IGNORE|RES_DONTSERVE|RES_DONTTRUST|RES_NOQUERY\
|RES_NOMODIFY|RES_NOPEER|RES_NOTRAP|RES_LPTRAP|RES_LIMITED)
/*
* Match flags
*/
#define RESM_INTERFACE 0x1 /* this is an interface */
#define RESM_NTPONLY 0x2 /* match ntp port only */
/*
* Restriction configuration ops
*/
#define RESTRICT_FLAGS 1 /* add flags to restrict entry */
#define RESTRICT_UNFLAG 2 /* remove flags from restrict entry */
#define RESTRICT_REMOVE 3 /* remove a restrict entry */
/*
* Experimental alternate selection algorithm identifiers
*/
#define SELECT_1 1
#define SELECT_2 2
#define SELECT_3 3
#define SELECT_4 4
#define SELECT_5 5
/*
* Endpoint structure for the select algorithm
*/
struct endpoint {
s_fp val; /* offset of endpoint */
int type; /* interval entry/exit */
};

View File

@ -1,80 +0,0 @@
/*
* ntp_calendar.h - definitions for the calendar time-of-day routine
*/
#include "ntp_types.h"
struct calendar {
u_short year; /* year (A.D.) */
u_short yearday; /* day of year, 1 = January 1 */
u_char month; /* month, 1 = January */
u_char monthday; /* day of month */
u_char hour; /* hour of day, midnight = 0 */
u_char minute; /* minute of hour */
u_char second; /* second of minute */
};
/*
* Days in each month. 30 days hath September...
*/
#define JAN 31
#define FEB 28
#define FEBLEAP 29
#define MAR 31
#define APR 30
#define MAY 31
#define JUN 30
#define JUL 31
#define AUG 31
#define SEP 30
#define OCT 31
#define NOV 30
#define DEC 31
/*
* We deal in a 4 year cycle starting at March 1, 1900. We assume
* we will only want to deal with dates since then, and not to exceed
* the rollover day in 2036.
*/
#define SECSPERMIN (60) /* seconds per minute */
#define MINSPERHR (60) /* minutes per hour */
#define HRSPERDAY (24) /* hours per day */
#define DAYSPERYEAR (365) /* days per year */
#define SECSPERDAY (SECSPERMIN*MINSPERHR*HRSPERDAY)
#define SECSPERYEAR (365 * SECSPERDAY) /* regular year */
#define SECSPERLEAPYEAR (366 * SECSPERDAY) /* leap year */
#define MAR1900 ((JAN+FEB) * SECSPERDAY) /* no leap year in 1900 */
#define DAYSPERCYCLE (365+365+365+366) /* 3 normal years plus leap */
#define SECSPERCYCLE (DAYSPERCYCLE*SECSPERDAY)
#define YEARSPERCYCLE 4
/*
* Gross hacks. I have illicit knowlege that there won't be overflows
* here, the compiler often can't tell this.
*/
#define TIMES60(val) ((((val)<<4) - (val))<<2) /* *(16 - 1) * 4 */
#define TIMES24(val) (((val)<<4) + ((val)<<3)) /* *16 + *8 */
#define TIMES7(val) (((val)<<3) - (val)) /* *8 - *1 */
#define TIMESDPERC(val) (((val)<<10) + ((val)<<8) \
+ ((val)<<7) + ((val)<<5) \
+ ((val)<<4) + ((val)<<2) + (val)) /* *big* hack */
/*
* Another big hack. Cycle 22 started on March 1, 1988. This is
* STARTCYCLE22 seconds after the start of cycle 0.
*/
#define CYCLE22 (22)
#define STARTCYCLE22 (u_long)(0xa586b500) /* 2777068800 */
#define MAR1988 (u_long)(STARTCYCLE22 + (u_long)MAR1900)
/*
* The length of January + February in leap and non-leap years.
*/
#define JANFEBNOLEAP ((JAN+FEB) * SECSPERDAY)
#define JANFEBLEAP ((JAN+FEBLEAP) * SECSPERDAY)
extern void caljulian P((u_long, struct calendar *));
extern u_long caltontp P((const struct calendar *));

View File

@ -1,253 +0,0 @@
/*
* ntp_control.h - definitions related to NTP mode 6 control messages
*/
#include "ntp_types.h"
struct ntp_control {
u_char li_vn_mode; /* leap, version, mode */
u_char r_m_e_op; /* response, more, error, opcode */
u_short sequence; /* sequence number of request */
u_short status; /* status word for association */
u_short associd; /* association ID */
u_short offset; /* offset of this batch of data */
u_short count; /* count of data in this packet */
u_char data[(480 + MAX_MAC_LEN)]; /* data + auth */
};
/*
* Length of the control header, in octets
*/
#define CTL_HEADER_LEN 12
#define CTL_MAX_DATA_LEN 468
/*
* Limits and things
*/
#define CTL_MAXTRAPS 3 /* maximum number of traps we allow */
#define CTL_TRAPTIME (60*60) /* time out traps in 1 hour */
#define CTL_MAXAUTHSIZE 64 /* maximum size of an authen'ed req */
/*
* Decoding for the r_m_e_op field
*/
#define CTL_RESPONSE 0x80
#define CTL_ERROR 0x40
#define CTL_MORE 0x20
#define CTL_OP_MASK 0x1f
#define CTL_ISRESPONSE(r_m_e_op) (((r_m_e_op) & 0x80) != 0)
#define CTL_ISMORE(r_m_e_op) (((r_m_e_op) & 0x20) != 0)
#define CTL_ISERROR(r_m_e_op) (((r_m_e_op) & 0x40) != 0)
#define CTL_OP(r_m_e_op) ((r_m_e_op) & CTL_OP_MASK)
/*
* Opcodes
*/
#define CTL_OP_UNSPEC 0
#define CTL_OP_READSTAT 1
#define CTL_OP_READVAR 2
#define CTL_OP_WRITEVAR 3
#define CTL_OP_READCLOCK 4
#define CTL_OP_WRITECLOCK 5
#define CTL_OP_SETTRAP 6
#define CTL_OP_ASYNCMSG 7
#define CTL_OP_UNSETTRAP 31
/*
* {En,De}coding of the system status word
*/
#define CTL_SST_TS_UNSPEC 0 /* time source unspecified */
#define CTL_SST_TS_ATOM 1 /* time source calibrated atomic */
#define CTL_SST_TS_LF 2 /* time source VLF or LF radio */
#define CTL_SST_TS_HF 3 /* time source HF radio */
#define CTL_SST_TS_UHF 4 /* time source UHF radio */
#define CTL_SST_TS_LOCAL 5 /* time source LOCAL */
#define CTL_SST_TS_NTP 6 /* time source NTP */
#define CTL_SST_TS_UDPTIME 7 /* time source UDP/TIME */
#define CTL_SST_TS_WRSTWTCH 8 /* time source is wristwatch */
#define CTL_SST_TS_TELEPHONE 9 /* time source is telephone modem */
#define CTL_SST_TS_PPS 0x20 /* time source is PPS signal */
#define CTL_SYS_MAXEVENTS 15
#define CTL_SYS_STATUS(li, source, nevnt, evnt) \
(((((unsigned short)(li))<< 14)&0xc000) | \
(((source)<<8)&0x3f00) | \
(((nevnt)<<4)&0x00f0) | \
((evnt)&0x000f))
#define CTL_SYS_LI(status) (((status)>>14) & 0x3)
#define CTL_SYS_SOURCE(status) (((status)>>8) & 0x3f)
#define CTL_SYS_NEVNT(status) (((status)>>4) & 0xf)
#define CTL_SYS_EVENT(status) ((status) & 0xf)
/*
* {En,De}coding of the peer status word
*/
#define CTL_PST_CONFIG 0x80
#define CTL_PST_AUTHENABLE 0x40
#define CTL_PST_AUTHENTIC 0x20
#define CTL_PST_REACH 0x10
#define CTL_PST_UNSPEC 0x08
#define CTL_PST_SEL_REJECT 0 /* rejected */
#define CTL_PST_SEL_SANE 1 /* passed sanity checks */
#define CTL_PST_SEL_CORRECT 2 /* passed correctness checks */
#define CTL_PST_SEL_SELCAND 3 /* passed candidate checks */
#define CTL_PST_SEL_SYNCCAND 4 /* passed outlyer checks */
#define CTL_PST_SEL_DISTSYSPEER 5 /* selected, distance exceeded */
#define CTL_PST_SEL_SYSPEER 6 /* selected */
#define CTL_PST_SEL_PPS 7 /* selected, pps signal override */
#define CTL_PEER_MAXEVENTS 15
#define CTL_PEER_STATUS(status, nevnt, evnt) \
((((status)<<8) & 0xff00) | \
(((nevnt)<<4) & 0x00f0) | \
((evnt) & 0x000f))
#define CTL_PEER_STATVAL(status)(((status)>>8) & 0xff)
#define CTL_PEER_NEVNT(status) (((status)>>4) & 0xf)
#define CTL_PEER_EVENT(status) ((status) & 0xf)
/*
* {En,De}coding of the clock status word
*/
#define CTL_CLK_OKAY 0
#define CTL_CLK_NOREPLY 1
#define CTL_CLK_BADFORMAT 2
#define CTL_CLK_FAULT 3
#define CTL_CLK_PROPAGATION 4
#define CTL_CLK_BADDATE 5
#define CTL_CLK_BADTIME 6
#define CTL_CLK_STATUS(status, event) \
((((status)<<8) & 0xff00) | \
((event) & 0x00ff))
/*
* Error code responses returned when the E bit is set.
*/
#define CERR_UNSPEC 0
#define CERR_PERMISSION 1
#define CERR_BADFMT 2
#define CERR_BADOP 3
#define CERR_BADASSOC 4
#define CERR_UNKNOWNVAR 5
#define CERR_BADVALUE 6
#define CERR_RESTRICT 7
#define CERR_NORESOURCE CERR_PERMISSION /* wish there was a different code */
/*
* System variables we understand
*/
#define CS_LEAP 1
#define CS_STRATUM 2
#define CS_PRECISION 3
#define CS_ROOTDELAY 4
#define CS_ROOTDISPERSION 5
#define CS_REFID 6
#define CS_REFTIME 7
#define CS_POLL 8
#define CS_PEERID 9
#define CS_OFFSET 10
#define CS_DRIFT 11
#define CS_COMPLIANCE 12
#define CS_CLOCK 13
#define CS_LEAPIND 14
#define CS_LEAPWARNING 15
#define CS_PROCESSOR 16
#define CS_SYSTEM 17
#define CS_KEYID 18
#define CS_REFSKEW 19
#define CS_VARLIST 20
#define CS_MAXCODE CS_VARLIST
/*
* Peer variables we understand
*/
#define CP_CONFIG 1
#define CP_AUTHENABLE 2
#define CP_AUTHENTIC 3
#define CP_SRCADR 4
#define CP_SRCPORT 5
#define CP_DSTADR 6
#define CP_DSTPORT 7
#define CP_LEAP 8
#define CP_HMODE 9
#define CP_STRATUM 10
#define CP_PPOLL 11
#define CP_HPOLL 12
#define CP_PRECISION 13
#define CP_ROOTDELAY 14
#define CP_ROOTDISPERSION 15
#define CP_REFID 16
#define CP_REFTIME 17
#define CP_ORG 18
#define CP_REC 19
#define CP_XMT 20
#define CP_REACH 21
#define CP_VALID 22
#define CP_TIMER 23
#define CP_DELAY 24
#define CP_OFFSET 25
#define CP_DISPERSION 26
#define CP_KEYID 27
#define CP_FILTDELAY 28
#define CP_FILTOFFSET 29
#define CP_PMODE 30
#define CP_RECEIVED 31
#define CP_SENT 32
#define CP_FILTERROR 33
#define CP_FLASH 34
#define CP_DISP 35
#define CP_VARLIST 36
#define CP_MAXCODE CP_VARLIST
/*
* Clock variables we understand
*/
#define CC_TYPE 1
#define CC_TIMECODE 2
#define CC_POLL 3
#define CC_NOREPLY 4
#define CC_BADFORMAT 5
#define CC_BADDATA 6
#define CC_FUDGETIME1 7
#define CC_FUDGETIME2 8
#define CC_FUDGEVAL1 9
#define CC_FUDGEVAL2 10
#define CC_FLAGS 11
#define CC_DEVICE 12
#define CC_VARLIST 13
#define CC_MAXCODE CC_VARLIST
/*
* Definition of the structure used internally to hold trap information.
* ntp_request.c wants to see this.
*/
struct ctl_trap {
struct sockaddr_in tr_addr; /* address of trap recipient */
struct interface *tr_localaddr; /* interface to send this through */
u_long tr_settime; /* time trap was set */
u_long tr_count; /* async messages sent to this guy */
u_long tr_origtime; /* time trap was originally set */
u_long tr_resets; /* count of resets for this trap */
u_short tr_sequence; /* trap sequence id */
u_char tr_flags; /* trap flags */
u_char tr_version; /* version number of trapper */
};
/*
* Flag bits
*/
#define TRAP_INUSE 0x1 /* this trap is active */
#define TRAP_NONPRIO 0x2 /* this trap is non-priority */
#define TRAP_CONFIGURED 0x4 /* this trap was configured */

View File

@ -1,30 +0,0 @@
struct btfp_time /* Structure for reading 5 time words */
/* in one ioctl(2) operation. */
{
unsigned short btfp_time[5]; /* Time words 0,1,2,3, and 4. (16bit)*/
};
/***** Simple ioctl commands *****/
#define RUNLOCK _IO('X',19) /* Release Capture Lockout */
#define RCR0 _IOR('X',22,unsigned int) /* Read control register */
#define WCR0 _IOW('X',23,unsigned int) /* Write control register */
/***** Compound ioctl commands *****/
/* Read all 5 time words in one call. */
#define READTIME _IOR('X',32,struct btfp_time)
#define VMEFD "/dev/btfp0"
struct vmedate { /* structure returned by get_vmetime.c */
unsigned short year;
unsigned short doy;
unsigned short hr;
unsigned short mn;
unsigned short sec;
unsigned long frac;
unsigned short status;
};
#define PRIO 120 /* set the realtime priority */
#define NREGS 7 /* number of registers we will use */

View File

@ -1,51 +0,0 @@
/*
* ntp_filegen.h,v 3.8 1994/05/30 09:48:53 kardel Exp
*
* definitions for NTP file generations support
*
*
* Copyright (c) 1992
* Rainer Pruy Friedrich-Alexander Unuiversitaet Erlangen-Nuernberg
*
* This code may be modified and used freely
* provided the credits remain intact.
*/
#include "ntp_types.h"
/*
* supported file generation types
*/
#define FILEGEN_NONE 255 /* no generations - use plain file name */
#define FILEGEN_PID 1 /* one filegen per process incarnation */
#define FILEGEN_DAY 2 /* one filegen per day */
#define FILEGEN_WEEK 3 /* one filegen per week */
#define FILEGEN_MONTH 4 /* one filegen per month */
#define FILEGEN_YEAR 5 /* one filegen per year */
#define FILEGEN_AGE 6 /* change filegen each FG_AGE_SECS */
/*
* supported file generation flags
*/
#define FGEN_FLAG_LINK 0x01 /* make a link to base name */
#define FGEN_FLAG_ENABLED 0x80 /* set this to really create files */
/* without this, open is suppressed */
typedef struct FILEGEN
{
FILE *fp; /* file referring to current generation */
char *prefix; /* filename prefix and basename to be used*/
char *basename; /* for constructing filename of generation file */
/* WARNING: must be malloced !!! will be fed to free()*/
u_long id; /* id of current generation */
u_char type; /* type of file generation */
u_char flag; /* flags modifying processing of file generation */
} FILEGEN;
extern void filegen_setup P((FILEGEN *, u_long));
extern void filegen_config P((FILEGEN *, char *, u_int, u_int));
extern FILEGEN *filegen_get P((char *));
extern void filegen_register P((char *, FILEGEN *));

View File

@ -1,316 +0,0 @@
/*
* ntp_fp.h - definitions for NTP fixed point arithmetic
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "ntp_types.h"
/*
* NTP uses two fixed point formats. The first (l_fp) is the "long" format
* and is 64 bits long with the decimal between bits 31 and 32. This
* is used for time stamps in the NTP packet header (in network byte
* order) and for internal computations of offsets (in local host byte
* order). We use the same structure for both signed and unsigned values,
* which is a big hack but saves rewriting all the operators twice. Just
* to confuse this, we also sometimes just carry the fractional part in
* calculations, in both signed and unsigned forms. Anyway, an l_fp looks
* like:
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Integral Part |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Fractional Part |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
typedef struct {
union {
U_LONG Xl_ui;
LONG Xl_i;
} Ul_i;
union {
U_LONG Xl_uf;
LONG Xl_f;
} Ul_f;
} l_fp;
#define l_ui Ul_i.Xl_ui /* unsigned integral part */
#define l_i Ul_i.Xl_i /* signed integral part */
#define l_uf Ul_f.Xl_uf /* unsigned fractional part */
#define l_f Ul_f.Xl_f /* signed fractional part */
/*
* Fractional precision (of an l_fp) is actually the number of
* bits in a long.
*/
#define FRACTION_PREC (32)
/*
* The second fixed point format is 32 bits, with the decimal between
* bits 15 and 16. There is a signed version (s_fp) and an unsigned
* version (u_fp). This is used to represent synchronizing distance
* and synchronizing dispersion in the NTP packet header (again, in
* network byte order) and internally to hold both distance and
* dispersion values (in local byte order). In network byte order
* it looks like:
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Integer Part | Fraction Part |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
typedef LONG s_fp;
typedef U_LONG u_fp;
/*
* A unit second in fp format. Actually 2**(half_the_bits_in_a_long)
*/
#define FP_SECOND (0x10000)
/*
* Byte order conversions
*/
#define HTONS_FP(x) (htonl(x))
#define HTONL_FP(h, n) do { (n)->l_ui = htonl((h)->l_ui); \
(n)->l_uf = htonl((h)->l_uf); } while (0)
#define NTOHS_FP(x) (ntohl(x))
#define NTOHL_FP(n, h) do { (h)->l_ui = ntohl((n)->l_ui); \
(h)->l_uf = ntohl((n)->l_uf); } while (0)
#define NTOHL_MFP(ni, nf, hi, hf) \
do { (hi) = ntohl(ni); (hf) = ntohl(nf); } while (0)
#define HTONL_MFP(hi, hf, ni, nf) \
do { (ni) = ntohl(hi); (nf) = ntohl(hf); } while (0)
/* funny ones. Converts ts fractions to net order ts */
#define HTONL_UF(uf, nts) \
do { (nts)->l_ui = 0; (nts)->l_uf = htonl(uf); } while (0)
#define HTONL_F(f, nts) do { (nts)->l_uf = htonl(f); \
if ((f) & 0x80000000) \
(nts)->l_i = -1; \
else \
(nts)->l_i = 0; \
} while (0)
/*
* Conversions between the two fixed point types
*/
#define MFPTOFP(x_i, x_f) (((x_i)<<16) | (((x_f)>>16)&0xffff))
#define LFPTOFP(v) MFPTOFP((v)->l_i, (v)->l_f)
#define UFPTOLFP(x, v) ((v)->l_ui = (u_fp)(x)>>16, (v)->l_uf = (x)<<16)
#define FPTOLFP(x, v) (UFPTOLFP((x), (v)), (x) < 0 ? (v)->l_ui -= 0x10000 : 0)
/*
* Primitive operations on long fixed point values. If these are
* reminiscent of assembler op codes it's only because some may
* be replaced by inline assembler for particular machines someday.
* These are the (kind of inefficient) run-anywhere versions.
*/
#define M_NEG(v_i, v_f) /* v = -v */ \
do { \
if ((v_f) == 0) \
(v_i) = -(v_i); \
else { \
(v_f) = -(v_f); \
(v_i) = ~(v_i); \
} \
} while(0)
#define M_NEGM(r_i, r_f, a_i, a_f) /* r = -a */ \
do { \
if ((a_f) == 0) { \
(r_f) = 0; \
(r_i) = -(a_i); \
} else { \
(r_f) = -(a_f); \
(r_i) = ~(a_i); \
} \
} while(0)
#define M_ADD(r_i, r_f, a_i, a_f) /* r += a */ \
do { \
register U_LONG lo_tmp; \
register U_LONG hi_tmp; \
\
lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \
hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \
if (lo_tmp & 0x10000) \
hi_tmp++; \
(r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
\
(r_i) += (a_i); \
if (hi_tmp & 0x10000) \
(r_i)++; \
} while (0)
#define M_ADD3(r_ovr, r_i, r_f, a_ovr, a_i, a_f) /* r += a, three word */ \
do { \
register U_LONG lo_tmp; \
register U_LONG hi_tmp; \
\
lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \
hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \
if (lo_tmp & 0x10000) \
hi_tmp++; \
(r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
\
lo_tmp = ((r_i) & 0xffff) + ((a_i) & 0xffff); \
if (hi_tmp & 0x10000) \
lo_tmp++; \
hi_tmp = (((r_i) >> 16) & 0xffff) + (((a_i) >> 16) & 0xffff); \
if (lo_tmp & 0x10000) \
hi_tmp++; \
(r_i) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
\
(r_ovr) += (a_ovr); \
if (hi_tmp & 0x10000) \
(r_ovr)++; \
} while (0)
#define M_SUB(r_i, r_f, a_i, a_f) /* r -= a */ \
do { \
register U_LONG lo_tmp; \
register U_LONG hi_tmp; \
\
if ((a_f) == 0) { \
(r_i) -= (a_i); \
} else { \
lo_tmp = ((r_f) & 0xffff) + ((-(a_f)) & 0xffff); \
hi_tmp = (((r_f) >> 16) & 0xffff) \
+ (((-(a_f)) >> 16) & 0xffff); \
if (lo_tmp & 0x10000) \
hi_tmp++; \
(r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
\
(r_i) += ~(a_i); \
if (hi_tmp & 0x10000) \
(r_i)++; \
} \
} while (0)
#define M_RSHIFTU(v_i, v_f) /* v >>= 1, v is unsigned */ \
do { \
(v_f) = (U_LONG)(v_f) >> 1; \
if ((v_i) & 01) \
(v_f) |= 0x80000000; \
(v_i) = (U_LONG)(v_i) >> 1; \
} while (0)
#define M_RSHIFT(v_i, v_f) /* v >>= 1, v is signed */ \
do { \
(v_f) = (U_LONG)(v_f) >> 1; \
if ((v_i) & 01) \
(v_f) |= 0x80000000; \
if ((v_i) & 0x80000000) \
(v_i) = ((v_i) >> 1) | 0x80000000; \
else \
(v_i) = (v_i) >> 1; \
} while (0)
#define M_LSHIFT(v_i, v_f) /* v <<= 1 */ \
do { \
(v_i) <<= 1; \
if ((v_f) & 0x80000000) \
(v_i) |= 0x1; \
(v_f) <<= 1; \
} while (0)
#define M_LSHIFT3(v_ovr, v_i, v_f) /* v <<= 1, with overflow */ \
do { \
(v_ovr) <<= 1; \
if ((v_i) & 0x80000000) \
(v_ovr) |= 0x1; \
(v_i) <<= 1; \
if ((v_f) & 0x80000000) \
(v_i) |= 0x1; \
(v_f) <<= 1; \
} while (0)
#define M_ADDUF(r_i, r_f, uf) /* r += uf, uf is U_LONG fraction */ \
M_ADD((r_i), (r_f), 0, (uf)) /* let optimizer worry about it */
#define M_SUBUF(r_i, r_f, uf) /* r -= uf, uf is U_LONG fraction */ \
M_SUB((r_i), (r_f), 0, (uf)) /* let optimizer worry about it */
#define M_ADDF(r_i, r_f, f) /* r += f, f is a LONG fraction */ \
do { \
if ((f) > 0) \
M_ADD((r_i), (r_f), 0, (f)); \
else if ((f) < 0) \
M_ADD((r_i), (r_f), (-1), (f));\
} while(0)
#define M_ISNEG(v_i, v_f) /* v < 0 */ \
(((v_i) & 0x80000000) != 0)
#define M_ISHIS(a_i, a_f, b_i, b_f) /* a >= b unsigned */ \
(((U_LONG)(a_i)) > ((U_LONG)(b_i)) || \
((a_i) == (b_i) && ((U_LONG)(a_f)) >= ((U_LONG)(b_f))))
#define M_ISGEQ(a_i, a_f, b_i, b_f) /* a >= b signed */ \
(((LONG)(a_i)) > ((LONG)(b_i)) || \
((a_i) == (b_i) && ((U_LONG)(a_f)) >= ((U_LONG)(b_f))))
#define M_ISEQU(a_i, a_f, b_i, b_f) /* a == b unsigned */ \
((a_i) == (b_i) && (a_f) == (b_f))
/*
* Operations on the long fp format
*/
#define L_ADD(r, a) M_ADD((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
#define L_SUB(r, a) M_SUB((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
#define L_NEG(v) M_NEG((v)->l_ui, (v)->l_uf)
#define L_ADDUF(r, uf) M_ADDUF((r)->l_ui, (r)->l_uf, (uf))
#define L_SUBUF(r, uf) M_SUBUF((r)->l_ui, (r)->l_uf, (uf))
#define L_ADDF(r, f) M_ADDF((r)->l_ui, (r)->l_uf, (f))
#define L_RSHIFT(v) M_RSHIFT((v)->l_i, (v)->l_uf)
#define L_RSHIFTU(v) M_RSHIFT((v)->l_ui, (v)->l_uf)
#define L_LSHIFT(v) M_LSHIFT((v)->l_ui, (v)->l_uf)
#define L_CLR(v) ((v)->l_ui = (v)->l_uf = 0)
#define L_ISNEG(v) (((v)->l_ui & 0x80000000) != 0)
#define L_ISZERO(v) ((v)->l_ui == 0 && (v)->l_uf == 0)
#define L_ISHIS(a, b) ((a)->l_ui > (b)->l_ui || \
((a)->l_ui == (b)->l_ui && (a)->l_uf >= (b)->l_uf))
#define L_ISGEQ(a, b) ((a)->l_i > (b)->l_i || \
((a)->l_i == (b)->l_i && (a)->l_uf >= (b)->l_uf))
#define L_ISEQU(a, b) M_ISEQU((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
extern char * dofptoa P((u_fp, int, int, int));
extern char * dolfptoa P((u_long, u_long, int, int, int));
extern int atolfp P((const char *, l_fp *));
extern int buftvtots P((const char *, l_fp *));
extern void gettstamp P((l_fp *));
extern char * fptoa P((s_fp, int));
extern char * fptoms P((s_fp, int));
extern char * fptoms P((s_fp, int));
extern int hextolfp P((const char *, l_fp *));
extern int mstolfp P((const char *, l_fp *));
extern char * prettydate P((l_fp *));
extern char * uglydate P((l_fp *));
extern void get_systime P((l_fp *));
extern int step_systime P((l_fp *));
extern int step_systime_real P((l_fp *));
extern int adj_systime P((l_fp *));
#define lfptoa(_fpv, _ndec) mfptoa((_fpv)->l_ui, (_fpv)->l_uf, (_ndec))
#define lfptoms(_fpv, _ndec) mfptoms((_fpv)->l_ui, (_fpv)->l_uf, (_ndec))
#define ntoa(_sin) numtoa((_sin)->sin_addr.s_addr)
#define ntohost(_sin) numtohost((_sin)->sin_addr.s_addr)
#define ufptoa(_fpv, _ndec) dofptoa((_fpv), 0, (_ndec), 0)
#define ufptoms(_fpv, _ndec) dofptoa((_fpv), 0, (_ndec), 1)
#define ulfptoa(_fpv, _ndec) dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 0)
#define ulfptoms(_fpv, _ndec) dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 1)
#define umfptoa(_fpi, _fpf, _ndec) dolfptoa((_fpi), (_fpf), 0, (_ndec), 0)

View File

@ -1,51 +0,0 @@
/*
* Sockets are not standard.
* So hide uglyness in include file.
*/
#if defined(SYS_CONVEXOS9)
#include "/sys/sync/queue.h"
#include "/sys/sync/sema.h"
#endif
#if defined(SYS_AIX)
#include <sys/time.h>
#include <time.h>
#endif
#if (defined(SOLARIS) && !defined(bsd)) || defined(SYS_SUNOS4)
#include <sys/sockio.h>
#endif
#if defined(SYS_UNIXWARE1)
#include <sys/sockio.h>
#endif
#if defined(SYS_PTX) || defined(SYS_SINIXM)
#include <sys/stream.h>
#include <sys/stropts.h>
#endif
#if defined(SYS_SVR4)
#if !defined(USE_STREAMS_DEVICE_FOR_IF_CONFIG)
#include <sys/sockio.h>
#else /* USE_STREAMS_DEVICE_FOR_IF_CONFIG */
#include <netinet/ip.h>
#undef SIOCGIFCONF
#undef SIOCGIFFLAGS
#undef SIOCGIFADDR
#undef SIOCGIFBRDADDR
#undef SIOCGIFNETMASK
#define SIOCGIFCONF IPIOC_GETIFCONF
#define SIOCGIFFLAGS IPIOC_GETIFFLAGS
#define SIOCGIFADDR IPIOC_GETIFADDR
#define SIOCGIFBRDADDR IPIOC_GETIFBRDADDR
#define SIOCGIFNETMASK IPIOC_GETIFNETMASK
#endif /* USE_STREAMS_DEVICE_FOR_IF_CONFIG */
#endif /* SYS_SVR4 */
#if defined(SYS_FREEBSD)
#include <sys/time.h>
#endif
#include <net/if.h>

View File

@ -1,259 +0,0 @@
/* @(#)in.h 1.19 90/07/27 SMI; from UCB 7.5 2/22/88 */
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
/*
* Constants and structures defined by the internet system,
* Per RFC 790, September 1981.
*/
#ifndef _netinet_in_h
#define _netinet_in_h
#define _NETINET_IN_H_
#define _SYS_IN_INCLUDED
#define __IN_HEADER
/*
* Protocols
*/
#define IPPROTO_IP 0 /* dummy for IP */
#define IPPROTO_ICMP 1 /* control message protocol */
#define IPPROTO_IGMP 2 /* group control protocol */
#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
#define IPPROTO_ST 5 /* st */
#define IPPROTO_TCP 6 /* tcp */
#define IPPROTO_EGP 8 /* exterior gateway protocol */
#define IPPROTO_PUP 12 /* pup */
#define IPPROTO_UDP 17 /* user datagram protocol */
#define IPPROTO_IDP 22 /* xns idp */
#define IPPROTO_HELLO 63 /* "hello" routing protocol */
#define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
#define IPPROTO_OSPF 89 /* Open SPF IGP */
#define IPPROTO_RAW 255 /* raw IP packet */
#define IPPROTO_MAX 256
/*
* Port/socket numbers: network standard functions
*/
#define IPPORT_ECHO 7
#define IPPORT_DISCARD 9
#define IPPORT_SYSTAT 11
#define IPPORT_DAYTIME 13
#define IPPORT_NETSTAT 15
#define IPPORT_FTP 21
#define IPPORT_TELNET 23
#define IPPORT_SMTP 25
#define IPPORT_TIMESERVER 37
#define IPPORT_NAMESERVER 42
#define IPPORT_WHOIS 43
#define IPPORT_MTP 57
/*
* Port/socket numbers: host specific functions
*/
#define IPPORT_TFTP 69
#define IPPORT_RJE 77
#define IPPORT_FINGER 79
#define IPPORT_TTYLINK 87
#define IPPORT_SUPDUP 95
/*
* UNIX TCP sockets
*/
#define IPPORT_EXECSERVER 512
#define IPPORT_LOGINSERVER 513
#define IPPORT_CMDSERVER 514
#define IPPORT_EFSSERVER 520
/*
* UNIX UDP sockets
*/
#define IPPORT_BIFFUDP 512
#define IPPORT_WHOSERVER 513
#define IPPORT_ROUTESERVER 520 /* 520+1 also used */
/*
* Ports < IPPORT_RESERVED are reserved for
* privileged processes (e.g. root).
* Ports > IPPORT_USERRESERVED are reserved
* for servers, not necessarily privileged.
*/
#define IPPORT_RESERVED 1024
#define IPPORT_USERRESERVED 5000
/*
* Link numbers
*/
#define IMPLINK_IP 155
#define IMPLINK_LOWEXPER 156
#define IMPLINK_HIGHEXPER 158
/*
* Internet address
* This definition contains obsolete fields for compatibility
* with SunOS 3.x and 4.2bsd. The presence of subnets renders
* divisions into fixed fields misleading at best. New code
* should use only the s_addr field.
*/
struct in_addr {
union {
struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
struct { u_short s_w1,s_w2; } S_un_w;
u_long S_addr;
} S_un;
#define s_addr S_un.S_addr /* should be used for all code */
#define s_host S_un.S_un_b.s_b2 /* OBSOLETE: host on imp */
#define s_net S_un.S_un_b.s_b1 /* OBSOLETE: network */
#define s_imp S_un.S_un_w.s_w2 /* OBSOLETE: imp */
#define s_impno S_un.S_un_b.s_b4 /* OBSOLETE: imp # */
#define s_lh S_un.S_un_b.s_b3 /* OBSOLETE: logical host */
};
/*
* Definitions of bits in internet address integers.
* On subnets, the decomposition of addresses to host and net parts
* is done according to subnet mask, not the masks here.
*/
#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
#define IN_CLASSA_NET 0xff000000
#define IN_CLASSA_NSHIFT 24
#define IN_CLASSA_HOST 0x00ffffff
#define IN_CLASSA_MAX 128
#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
#define IN_CLASSB_NET 0xffff0000
#define IN_CLASSB_NSHIFT 16
#define IN_CLASSB_HOST 0x0000ffff
#define IN_CLASSB_MAX 65536
#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
#define IN_CLASSC_NET 0xffffff00
#define IN_CLASSC_NSHIFT 8
#define IN_CLASSC_HOST 0x000000ff
#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
#define IN_MULTICAST(i) IN_CLASSD(i)
#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
#define INADDR_ANY (u_long)0x00000000
#define INADDR_LOOPBACK (u_long)0x7F000001
#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
#define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */
#define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */
#define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */
#define IN_LOOPBACKNET 127 /* official! */
/*
* Define a macro to stuff the loopback address into an Internet address
*/
#define IN_SET_LOOPBACK_ADDR(a) {(a)->sin_addr.s_addr = htonl(INADDR_LOOPBACK); \
(a)->sin_family = AF_INET;}
/*
* Socket address, internet style.
*/
struct sockaddr_in {
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
/*
* Options for use with [gs]etsockopt at the IP level.
*/
#define IP_OPTIONS 1 /* set/get IP per-packet options */
#define IP_MULTICAST_IF 2 /* set/get IP multicast interface */
#define IP_MULTICAST_TTL 3 /* set/get IP multicast timetolive */
#define IP_MULTICAST_LOOP 4 /* set/get IP multicast loopback */
#define IP_ADD_MEMBERSHIP 5 /* add an IP group membership */
#define IP_DROP_MEMBERSHIP 6 /* drop an IP group membership */
#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
#define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */
/*
* Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
*/
struct ip_mreq {
struct in_addr imr_multiaddr; /* IP multicast address of group */
struct in_addr imr_interface; /* local IP address of interface */
};
#if !defined(vax) && !defined(ntohl) && !defined(i386)
/*
* Macros for number representation conversion.
*/
#define ntohl(x) (x)
#define ntohs(x) (x)
#define htonl(x) (x)
#define htons(x) (x)
#endif
#if !defined(ntohl) && (defined(vax) || defined(i386))
u_short ntohs(), htons();
u_long ntohl(), htonl();
#endif
#ifdef KERNEL
extern struct domain inetdomain;
extern struct protosw inetsw[];
struct in_addr in_makeaddr();
u_long in_netof(), in_lnaof();
#endif
#ifndef BYTE_ORDER
/*
* Definitions for byte order,
* according to byte significance from low address to high.
*/
#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */
#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */
#if defined(vax) || defined(i386)
#define BYTE_ORDER LITTLE_ENDIAN
#else
#define BYTE_ORDER BIG_ENDIAN /* mc68000, tahoe, most others */
#endif
#endif BYTE_ORDER
/*
* Macros for number representation conversion.
*/
#if BYTE_ORDER==LITTLE_ENDIAN
#define NTOHL(d) ((d) = ntohl((d)))
#define NTOHS(d) ((d) = ntohs((d)))
#define HTONL(d) ((d) = htonl((d)))
#define HTONS(d) ((d) = htons((d)))
#else
#define ntohl(x) (x)
#define ntohs(x) (x)
#define htonl(x) (x)
#define htons(x) (x)
#define NTOHL(d)
#define NTOHS(d)
#define HTONL(d)
#define HTONS(d)
#endif
#endif /*!_netinet_in_h*/

View File

@ -1,25 +0,0 @@
/*
* POSIX says use <fnct.h> to get O_* symbols and
* SEEK_SET symbol form <untisd.h>.
*/
#if defined(NTP_POSIX_SOURCE)
/*
* POSIX way
*/
#include <stdio.h>
#if defined(HAVE_SIGNALED_IO) && (defined(SYS_AUX2) || defined(SYS_AUX3) || defined(SYS_PTX))
#include <sys/file.h>
#endif
#include <unistd.h>
#include <fcntl.h>
#else
/*
* BSD way
*/
#include <sys/file.h>
#include <fcntl.h>
#if !defined(SEEK_SET) && defined(L_SET)
#define SEEK_SET L_SET
#endif
#endif

View File

@ -1,742 +0,0 @@
/*
* Collect all machine dependent idiosyncrasies in one place.
*/
#ifndef __ntp_machine
#define __ntp_machine
/*
Various options.
They can defined with the DEFS directive in the Config file if they
are not defined here.
WHICH NICE
HAVE_ATT_NICE - Use att nice(priority_change)
HAVE_BSD_NICE - Use bsd setprioirty(which, who, priority)
HAVE_NO_NICE - Don't have (or use) either
KERNEL MUCKING - If you porting to a new system see xntpd/ntp_unixclock.c and
util/tickadj.c to see what these do. This is very system
dependent stuff!!!
HAVE_LIBKVM - Use libkvm to read kernal memory
HAVE_READKMEM - Use read to read kernal memory
NOKMEM - Don't read kmem
HAVE_N_UN - Have u_nn nlist struct.
WHICH SETPGRP TO USE - Not needed if NTP_POSIX_SOURCE is defined since you
better of setsid!
HAVE_ATT_SETPGRP - setpgrp(void) instead of setpgrp(int, int)
Signaled IO - Signled IO defines.
HAVE_SIGNALED_IO - Enable signaled io. Assumes you are going to use SIGIO
for tty and udp io.
USE_UDP_SIGPOLL - Use SIGPOLL on socket io. This assumes that the
sockets routines are defined on top of streams.
USE_TTY_SIGPOLL - Use SIGPOLL on tty io. This assumes streams.
UDP_BACKWARDS_SETOWN - SunOS 3.5 or Ultirx 2.0 system.
WHICH TERMINAL MODEL TO USE - I would assume HAVE_TERMIOS if
NTP_POSIX_SOURCE was set but can't. The
posix tty driver is too restrictive on most systems.
It is defined if you define STREAMS.
We do not put these defines in the ntp_machine.h as some systems
offer multiple interfaces and refclock configuration likes to
peek into the configuration defines for tty model restrictions.
Thus all tty definitions should be in the files in the machines directory.
HAVE_TERMIOS - Use POSIX termios.h
HAVE_SYSV_TTYS - Use SYSV termio.h
HAVE_BSD_TTYS - Use BSD stty.h
THIS MAKES PORTS TO NEW SYSTEMS EASY - You only have to wory about
kernel mucking.
NTP_POSIX_SOURCE - Use POSIX functions over bsd functions and att functions.
This is NOT the same as _POSIX_SOURCE.
It is much weaker!
STEP SLEW OR TWO STEP - The Default is to step.
SLEWALWAYS - setttimeofday can not be used to set the time of day at
all.
STEP_SLEW - setttimeofday can not set the seconds part of time
time use setttimeofday to set the seconds part of the
time and the slew the seconds.
FORCE_NTPDATE_STEP - even if SLEWALWAYS is defined, force a step of
of the systemtime (via settimeofday()). Only takes
affect if STEP_SLEW isn't defined.
WHICH TIMEOFDAY()
SYSV_TIMEOFDAY - [sg]ettimeofday(struct timeval *) as opposed to BSD
[sg]ettimeofday(struct timeval *, struct timezone *)
INFO ON NEW KERNEL PLL SYS CALLS
NTP_SYSCALLS_STD - use the "normal" ones
NTP_SYSCALL_GET - SYS_ntp_gettime id
NTP_SYSCALL_ADJ - SYS_ntp_adjtime id
NTP_SYSCALLS_LIBC - ntp_adjtime() and ntp_gettime() are in libc.
HOW TO GET IP INTERFACE INFORMATION
Some UNIX V.4 machines implement a sockets library on top of
streams. For these systems, you must use send the SIOCGIFCONF down
the stream in an I_STR ioctl. This ususally also implies
USE_STREAMS_DEVICE FOR IF_CONFIG. Dell UNIX is a notable exception.
STREAMS_TLI - use ioctl(I_STR) to implement ioctl(SIOCGIFCONF)
WHAT DOES IOCTL(SIOCGIFCONF) RETURN IN THE BUFFER
UNIX V.4 machines implement a sockets library on top of streams.
When requesting the IP interface configuration with an ioctl(2) calll,
an array of ifreq structures are placed in the provided buffer. Some
implementations also place the length of the buffer information in
the first integer position of the buffer.
SIZE_RETURNED_IN_BUFFER - size integer is in the buffer
WILL IOCTL(SIOCGIFCONF) WORK ON A SOCKET
Some UNIX V.4 machines do not appear to support ioctl() requests for the
IP interface configuration on a socket. They appear to require the use
of the streams device instead.
USE_STREAMS_DEVICE_FOR_IF_CONFIG - use the /dev/ip device for configuration
MISC
USE_PROTOTYPES - Prototype functions
DOSYNCTODR - Resync TODR clock every hour.
RETSIGTYPE - Define signal function type.
NO_SIGNED_CHAR_DECL - No "signed char" see include/ntp.h
LOCK_PROCESS - Have plock.
UDP_WILDCARD_DELIVERY
- these systems deliver broadcast packets to the wildcard
port instead to a port bound to the interface bound
to the correct broadcast address - are these
implementations broken or did the spec change ?
DEFINITIONS FOR SYSTEM && PROCESSOR
STR_SYSTEM - value of system variable
STR_PROCESSOR - value of processor variable
You could just put the defines on the DEFS line in machines/<os> file.
I don't since there are lots of different types of compilers that a system might
have, some that can do proto typing and others that cannot on the same system.
I get a chance to twiddle some of the configuration parameters at compile
time based on compiler/machine combinations by using this include file.
See convex, aix and sun configurations see how complex it get.
Note that it _is_ considered reasonable to add some system-specific defines
to the machine/<os> file if it would be too inconvenient to puzzle them out
in this file.
*/
/*
* RS6000 running AIX.
*/
#if defined(SYS_AIX)
#define HAVE_SIGNALED_IO
#ifndef _BSD
#define NTP_STDC
#define NTP_POSIX_SOURCE
/*
* Keep USE_PROTOTYPES and _NO_PROTO in step.
*/
#if defined(_NO_PROTO) && defined(USE_PROTOTYPES)
#undef USE_PROTOTYPES
#endif
#if !defined(_NO_PROTO) && !defined(USE_PROTOTYPES)
#define USE_PROTOTYPES
#endif
#endif /*_BSD */
#define HAVE_BSD_NICE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/AIX"
#endif
#endif /* RS6000 */
/*
* SunOS 4.X.X
* Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO
*/
#if defined(SYS_SUNOS4)
#define NTP_NEED_BOPS
#define NO_SIGNED_CHAR_DECL
#define HAVE_LIBKVM
#define HAVE_MALLOC_H
#define HAVE_BSD_NICE
#define RETSIGTYPE void
#define NTP_SYSCALL_GET 132
#define NTP_SYSCALL_ADJ 147
#define HAVE_MODEM_CONTROL
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/SunOS 4.x"
#endif
#endif
/*
* Sinix-M
*/
#if defined(SYS_SINIXM)
#undef HAVE_SIGNALED_IO
#undef USE_TTY_SIGPOLL
#undef USE_UDP_SIGPOLL
#define STREAMS_TLI
#define NO_SIGNED_CHAR_DECL
#define STEP_SLEW /* TWO step */
#define RETSIGTYPE void
#define NTP_POSIX_SOURCE
#define HAVE_ATT_SETPGRP
#define HAVE_ATT_NICE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/SINIX-M"
#endif
#endif
/*
* SunOS 5.1 or SunOS 5.2 or Solaris 2.1 or Solaris 2.2
*/
#if defined(SYS_SOLARIS)
#define HAVE_SIGNALED_IO
#define USE_TTY_SIGPOLL
#define USE_UDP_SIGPOLL
#define NO_SIGNED_CHAR_DECL
#define STEP_SLEW /* TWO step */
#define RETSIGTYPE void
#define NTP_POSIX_SOURCE
#define HAVE_ATT_SETPGRP
#define HAVE_ATT_NICE
#define UDP_WILDCARD_DELIVERY
#define HAVE_MODEM_CONTROL
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/Solaris 2.x"
#endif
#endif
/*
* Convex
*/
#if defined(SYS_CONVEXOS10) || defined(SYS_CONVEXOS9)
#define HAVE_SIGNALED_IO
#define HAVE_N_UN
#define HAVE_READKMEM
#define HAVE_BSD_NICE
#if defined(convex)
#define RETSIGTYPE int
#define NO_SIGNED_CHAR_DECL
#else
#if defined(__stdc__) && !defined(USE_PROTOTYPES)
#define USE_PROTOTYPES
#endif
#if !defined(__stdc__) && defined(USE_PROTOTYPES)
#undef USE_PROTOTYPES
#endif
#define NTP_POSIX_SOURCE
#define HAVE_ATT_SETPGRP
#endif
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/ConvexOS"
#endif
#endif
/*
* IRIX 4.X and IRIX 5.x
*/
#if defined(SYS_IRIX4)||defined(SYS_IRIX5)
#define HAVE_SIGNALED_IO
#define USE_TTY_SIGPOLL
#define ADJTIME_IS_ACCURATE
#define LOCK_PROCESS
#define USE_PROTOTYPES
#define HAVE_ATT_SETPGRP
#define HAVE_BSD_NICE
#define NTP_POSIX_SOURCE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/IRIX"
#endif
#endif
/*
* Ultrix
* Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO
*/
#if defined(SYS_ULTRIX)
#define S_CHAR_DEFINED
#define HAVE_READKMEM
#define HAVE_BSD_NICE
#define RETSIGTYPE void
#define NTP_SYSCALLS_STD
#define HAVE_MODEM_CONTROL
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/Ultrix"
#endif
#endif
/*
* AUX
*/
#if defined(SYS_AUX2) || defined(SYS_AUX3)
#define NO_SIGNED_CHAR_DECL
#define HAVE_READKMEM
#define HAVE_ATT_NICE
#define LOCK_PROCESS
#define NTP_POSIX_SOURCE
/*
* This requires that _POSIX_SOURCE be forced on the
* compiler command flag. We can't do it here since this
* file is included _after_ the system header files and we
* need to let _them_ know we're POSIX. We do this in
* compilers/aux3.gcc...
*/
#define SLEWALWAYS
#define FORCE_NTPDATE_STEP
#define RETSIGTYPE void
#define HAVE_ATT_SETPGRP
#define LOG_NTP LOG_LOCAL1
#define HAVE_SIGNALED_IO
#define NTP_NEED_BOPS
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/AUX"
#endif
#endif
/*
* Next
*/
#if defined(SYS_NEXT)
#define RETSIGTYPE void
#define DOSYNCTODR
#define HAVE_READKMEM
#define HAVE_BSD_NICE
#define HAVE_N_UN
#undef NTP_POSIX_SOURCE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/Next"
#endif
#endif
/*
* HPUX
*/
#if defined(SYS_HPUX)
#define NTP_POSIX_SOURCE
#define HAVE_SIGNALED_IO
#define getdtablesize() sysconf(_SC_OPEN_MAX)
#define setlinebuf(f) setvbuf(f, NULL, _IOLBF, 0)
#define NO_SIGNED_CHAR_DECL
#define LOCK_PROCESS
#define RETSIGTYPE void
#if (SYS_HPUX < 9)
#define HAVE_NO_NICE /* HPUX uses rtprio instead */
#else
#define HAVE_BSD_NICE /* new at 9.X */
#endif
#if (SYS_HPUX < 10)
#define NOKMEM
#else
#define HAVE_READKMEM
#endif
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/HPUX"
#endif
#endif
/*
* bsdi
*/
#if defined(SYS_BSDI)
#define HAVE_SIGNALED_IO
#define HAVE_LIBKVM
#define NTP_POSIX_SOURCE
#define HAVE_BSD_NICE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/BSDI"
#endif
#endif
/*
* 4.4 bsd
*/
#if defined(SYS_44BSD)
#define HAVE_SIGNALED_IO
#define HAVE_LIBKVM
#define HAVE_SYSCTL
#define NTP_POSIX_SOURCE
#define HAVE_BSD_NICE
#define USE_PROTOTYPES
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/4.4BSD"
#endif
#define MCAST
#ifdef SYS_FREEBSD
#ifdef HAVE_SIGNALED_IO
#undef HAVE_SIGNALED_IO
#endif
#define HAVE_TERMIOS
#define HAVE_UNAME
#define HAVE_SYS_TIMEX_H
#define HAVE_GETBOOTFILE
#define NTP_SYSCALLS_LIBC
#define KERNEL_PLL
#endif
#endif
/*
* Linux
*/
#if defined(SYS_LINUX)
#undef HAVE_SIGNALED_IO
#define RETSIGTYPE void
#define NTP_POSIX_SOURCE
#define ADJTIME_IS_ACCURATE
#define HAVE_SYS_TIMEX_H
/* hope there will be a standard interface
* along with a standard name one day ! */
#define ntp_adjtime __adjtimex
#define HAVE_BSD_NICE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/Linux"
#endif
#endif
/*
* 386BSD and any variants 8-) - should really have only ONE define
* for this bunch.
*/
#if defined(SYS_386BSD) || defined(SYS_NETBSD)
#define HAVE_SIGNALED_IO
#define HAVE_READKMEM
#define NTP_POSIX_SOURCE
#define HAVE_BSD_NICE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/\052BSD"
#endif
#ifdef SYS_FREEBSD
#define HAVE_TERMIOS
#define HAVE_UNAME
#define HAVE_SYS_TIMEX_H
#define NTP_SYSCALLS_LIBC
#define KERNEL_PLL
#endif
#endif
/*
* DEC AXP OSF/1
*/
#if defined(SYS_DECOSF1)
#define HAVE_SIGNALED_IO
#define HAVE_READKMEM
#define NTP_POSIX_SOURCE
#define NTP_SYSCALLS_STD
#define HAVE_BSD_NICE
#define HAVE_MODEM_CONTROL
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/DECOSF1"
#endif
#endif
/*
* Intel x86 OSF/1
*/
#if defined(SYS_IX86OSF1)
#define HAVE_SIGNALED_IO
#define HAVE_READKMEM
#define NTP_POSIX_SOURCE
#define NTP_SYSCALLS_STD
#define HAVE_BSD_NICE
#define HAVE_MODEM_CONTROL
#define SYS_DECOSF1
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/IX86OSF1"
#endif
#endif
/*
* ISI
*/
#if defined(SYS_BSD)
#define NO_SIGNED_CHAR_DECL
#define HAVE_BSD_NICE
#define HAVE_BSD_TTYS
#define HAVE_READKMEM
#define HAVE_SIGNALED_IO
#define NEED_VSPRINTF
#undef NTP_POSIX_SOURCE
#endif
/*
* I386
* XXX - what OS?
*/
#if defined(SYS_I386)
#define HAVE_READKMEM
#define S_CHAR_DEFINED
#define HAVE_BSD_NICE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/I386"
#endif
#endif
/*
* Mips
*/
#if defined(SYS_MIPS)
#define NOKMEM
#define HAVE_BSD_NICE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/Mips"
#endif
#endif
/*
* SEQUENT
*/
#if defined(SYS_SEQUENT)
#define HAVE_BSD_NICE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/Sequent Dynix 3"
#endif
#endif
/*
* PTX
*/
#if defined(SYS_PTX)
#define NO_SIGNED_CHAR_DECL
#define STREAMS_TLI
#define HAVE_ATT_SETPGRP
#define HAVE_SIGNALED_IO
#define USE_UDP_SIGPOLL
#define USE_TTY_SIGPOLL
#undef ADJTIME_IS_ACCURATE /* not checked yet */
#define LOCK_PROCESS
#define HAVE_ATT_SETPGRP
#define HAVE_ATT_NICE
#define STEP_SLEW /* TWO step */
#define SYSV_GETTIMEOFDAY
#define HAVE_READKMEM
#define UDP_WILDCARD_DELIVERY
#define NTP_POSIX_SOURCE
#define memmove(x, y, z) memcpy(x, y, z)
struct timezone { int __0; }; /* unused placebo */
/*
* no comment !@!
*/
typedef unsigned int u_int;
#ifndef _NETINET_IN_SYSTM_INCLUDED /* i am about to comment... */
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned long u_long;
#endif
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/Sequent PTX"
#endif
#endif
/*
* Sony NEWS
*/
#if defined(SYS_SONY)
#define NO_SIGNED_CHAR_DECL
#define HAVE_READKMEM
#define HAVE_BSD_NICE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/Sony"
#endif
#endif
/*
* VAX
* XXX - VMS?
*/
#if defined(SYS_VAX)
#define NO_SIGNED_CHAR_DECL
#define HAVE_READKMEM
#define HAVE_BSD_NICE
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/VAX"
#endif
#endif
/*
* UNIX V.4 on and NCR 3000
*/
#if defined(SYS_SVR4)
#define HAVE_ATT_SETPGRP
#define USE_PROTOTYPES
#define NTP_POSIX_SOURCE
#define HAVE_ATT_NICE
#define HAVE_READKMEM
#define USE_TTY_SIGPOLL
#define USE_UDP_SIGPOLL
#define STREAM
#define STEP_SLEW /* TWO step */
#define LOCK_PROCESS
#define SYSV_TIMEOFDAY
#define SIZE_RETURNED_IN_BUFFER
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/SysVR4"
#endif
#endif
/*
* (Univel/Novell) Unixware1 SVR4 on intel x86 processor
*/
#if defined(SYS_UNIXWARE1)
/* #define _POSIX_SOURCE */
#undef HAVE_ATT_SETPGRP
#define USE_PROTOTYPES
#define NTP_POSIX_SOURCE
#define HAVE_ATT_NICE
#define HAVE_READKMEM
#define USE_TTY_SIGPOLL
#define USE_UDP_SIGPOLL
#define UDP_WILDCARD_DELIVERY
#undef HAVE_SIGNALED_IO
#define STREAM
#define STREAMS
#ifndef STREAMS_TLI
/*#define STREAMS_TLI*/
#endif
/* #define USE_STREAMS_DEVICE_FOR_IF_CONFIG */
#undef STEP_SLEW /* TWO step */
#define LOCK_PROCESS
#define NO_SIGNED_CHAR_DECL
#undef SYSV_TIMEOFDAY
#define SIZE_RETURNED_IN_BUFFER
#define RETSIGTYPE void
#include <sys/sockio.h>
#include <sys/types.h>
#include <netinet/in_systm.h>
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/Unixware1"
#endif
#endif
/*
* DomainOS
*/
#if defined(SYS_DOMAINOS)
#define HAVE_BSD_NICE
#define NOKMEM
#define HAVE_SIGNALED_IO
#define NTP_SYSCALLS_STD
#define USE_PROTOTYPES
#define UDP_WILDCARD_DELIVERY
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/DOMAINOS"
#endif
#endif
#ifdef STREAM /* STREAM implies TERMIOS */
#ifndef HAVE_TERMIOS
#define HAVE_TERMIOS
#endif
#endif
#ifndef RETSIGTYPE
#if defined(NTP_POSIX_SOURCE)
#define RETSIGTYPE void
#else
#define RETSIGTYPE int
#endif
#endif
#ifdef NTP_SYSCALLS_STD
#ifndef NTP_SYSCALL_GET
#define NTP_SYSCALL_GET 235
#endif
#ifndef NTP_SYSCALL_ADJ
#define NTP_SYSCALL_ADJ 236
#endif
#endif /* NTP_SYSCALLS_STD */
#if !defined(HAVE_ATT_NICE) \
&& !defined(HAVE_BSD_NICE) \
&& !defined(HAVE_NO_NICE)
ERROR You_must_define_one_of_the_HAVE_xx_NICE_defines
#endif
/*
* use only one tty model - no use in initialising
* a tty in three ways
* HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
*/
#ifdef HAVE_TERMIOS
#undef HAVE_BSD_TTYS
#undef HAVE_SYSV_TTYS
#endif
#ifdef HAVE_SYSV_TTYS
#undef HAVE_BSD_TTYS
#endif
#if !defined(HAVE_SYSV_TTYS) \
&& !defined(HAVE_BSD_TTYS) \
&& !defined(HAVE_TERMIOS)
ERROR no_tty_type_defined
#endif
#if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
# if defined(XNTP_AUTO_ENDIAN)
# include <netinet/in.h>
# if BYTE_ORDER == BIG_ENDIAN
# define XNTP_BIG_ENDIAN
# endif
# if BYTE_ORDER == LITTLE_ENDIAN
# define XNTP_LITTLE_ENDIAN
# endif
# else /* AUTO */
# ifdef WORDS_BIGENDIAN
# define XNTP_BIG_ENDIAN 1
# else
# define XNTP_LITTLE_ENDIAN 1
# endif
# endif /* AUTO */
#endif /* !BIG && !LITTLE */
/*
* Byte order woes. The DES code is sensitive to byte order. This
* used to be resolved by calling ntohl() and htonl() to swap things
* around, but this turned out to be quite costly on Vaxes where those
* things are actual functions. The code now straightens out byte
* order troubles on its own, with no performance penalty for little
* end first machines, but at great expense to cleanliness.
*/
#if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
/*
* Pick one or the other.
*/
BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
#endif
#if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN)
/*
* Pick one or the other.
*/
BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
#endif
#endif /* __ntp_machine */

View File

@ -1,15 +0,0 @@
/*
* Define malloc and friends.
*/
#ifndef _ntp_malloc_h
#define _ntp_malloc_h
#ifdef NTP_POSIX_SOURCE
#include <stdlib.h>
#else /* NTP_POSIX_SOURCE */
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#endif /* NTP_POSIX_SOURCE */
#endif /* _ntp_malloc_h */

View File

@ -1,224 +0,0 @@
/*
* ntp_refclock.h - definitions for reference clock support
*/
#include "ntp_types.h"
#if defined(HAVE_BSD_TTYS)
#include <sgtty.h>
#endif /* HAVE_BSD_TTYS */
#if defined(HAVE_SYSV_TTYS)
#include <termio.h>
#endif /* HAVE_SYSV_TTYS */
#if defined(HAVE_TERMIOS)
#include <termios.h>
#endif
#if defined(STREAM)
#include <stropts.h>
#if defined(CLK)
#include <sys/clkdefs.h>
#endif /* CLK */
#endif /* STREAM */
#if !defined(SYSV_TTYS) && !defined(STREAM) & !defined(BSD_TTYS)
#define BSD_TTYS
#endif /* SYSV_TTYS STREAM BSD_TTYS */
/*
* Macros to determine the clock type and unit numbers from a
* 127.127.t.u address
*/
#define REFCLOCKTYPE(srcadr) ((SRCADR(srcadr) >> 8) & 0xff)
#define REFCLOCKUNIT(srcadr) (SRCADR(srcadr) & 0xff)
/*
* List of reference clock names and descriptions. These must agree with
* lib/clocktypes.c and xntpd/refclock_conf.c.
*/
struct clktype {
int code; /* driver "major" number */
char *clocktype; /* long description */
char *abbrev; /* short description */
};
/*
* Configuration flag values
*/
#define CLK_HAVETIME1 0x1
#define CLK_HAVETIME2 0x2
#define CLK_HAVEVAL1 0x4
#define CLK_HAVEVAL2 0x8
#define CLK_FLAG1 0x1
#define CLK_FLAG2 0x2
#define CLK_FLAG3 0x4
#define CLK_FLAG4 0x8
#define CLK_HAVEFLAG1 0x10
#define CLK_HAVEFLAG2 0x20
#define CLK_HAVEFLAG3 0x40
#define CLK_HAVEFLAG4 0x80
/*
* Structure for returning clock status
*/
struct refclockstat {
u_char type; /* clock type */
u_char flags; /* clock flags */
u_char haveflags; /* bit array of valid flags */
u_char lencode; /* length of last timecode */
char *lastcode; /* last timecode received */
U_LONG polls; /* transmit polls */
U_LONG noresponse; /* no response to poll */
U_LONG badformat; /* bad format timecode received */
U_LONG baddata; /* invalid data timecode received */
U_LONG timereset; /* driver resets */
char *clockdesc; /* ASCII description */
l_fp fudgetime1; /* configure fudge time1 */
l_fp fudgetime2; /* configure fudge time2 */
LONG fudgeval1; /* configure fudge value1 */
LONG fudgeval2; /* configure fudge value2 */
u_char currentstatus; /* clock status */
u_char lastevent; /* last exception event */
u_char unused; /* spare */
struct ctl_var *kv_list; /* additional variables */
};
/*
* Reference clock I/O structure. Used to provide an interface between
* the reference clock drivers and the I/O module.
*/
struct refclockio {
struct refclockio *next; /* link to next structure */
void (*clock_recv)();/* completion routine */
caddr_t srcclock; /* pointer to clock structure */
int datalen; /* lenth of data */
int fd; /* file descriptor */
u_long recvcount; /* count of receive completions */
};
/*
* Structure for returning debugging info
*/
#define NCLKBUGVALUES 16
#define NCLKBUGTIMES 32
struct refclockbug {
u_char nvalues; /* values following */
u_char ntimes; /* times following */
u_short svalues; /* values format sign array */
U_LONG stimes; /* times format sign array */
U_LONG values[NCLKBUGVALUES]; /* real values */
l_fp times[NCLKBUGTIMES]; /* real times */
};
/*
* Structure interface between the reference clock support
* ntp_refclock.c and the driver utility routines
*/
#define MAXSTAGE 64 /* max stages in shift register */
#define BMAX 128 /* max timecode length */
#define GMT 0 /* I hope nobody sees this */
#define MAXDIAL 20 /* max length of modem dial strings */
/*
* Line discipline flags. These require line discipline or streams
* modules to be installed/loaded in the kernel. If specified, but not
* installed, the code runs as if unspecified.
*/
#define LDISC_STD 0x0 /* standard */
#define LDISC_CLK 0x1 /* tty_clk \n intercept */
#define LDISC_CLKPPS 0x2 /* tty_clk \377 intercept */
#define LDISC_ACTS 0x4 /* tty_clk #* intercept */
#define LDISC_CHU 0x8 /* tty_chu */
#define LDISC_PPS 0x10 /* ppsclock */
struct refclockproc {
struct refclockio io; /* I/O handler structure */
caddr_t unitptr; /* pointer to unit structure */
u_long lasttime; /* last clock update time */
u_char leap; /* leap/synchronization code */
u_char currentstatus; /* clock status */
u_char lastevent; /* last exception event */
u_char type; /* clock type */
char *clockdesc; /* clock description */
char lastcode[BMAX]; /* last timecode received */
u_char lencode; /* length of last timecode */
u_int year; /* year of eternity */
u_int day; /* day of year */
u_int hour; /* hour of day */
u_int minute; /* minute of hour */
u_int second; /* second of minute */
u_int msec; /* millisecond of second */
u_long usec; /* microsecond of second (alt) */
u_int nstages; /* median filter stages */
u_long yearstart; /* beginning of year */
u_long coderecv; /* sample counter */
l_fp lastref; /* last reference timestamp */
l_fp lastrec; /* last local timestamp */
l_fp offset; /* median offset */
u_fp dispersion; /* sample dispersion */
l_fp filter[MAXSTAGE]; /* median filter */
/*
* Configuration data
*/
l_fp fudgetime1; /* fudge time1 */
l_fp fudgetime2; /* fudge time2 */
u_long refid; /* reference identifier */
u_long sloppyclockflag; /* fudge flags */
/*
* Status tallies
*/
u_long timestarted; /* time we started this */
u_long polls; /* polls sent */
u_long noreply; /* no replies to polls */
u_long badformat; /* bad format reply */
u_long baddata; /* bad data reply */
};
/*
* Structure interface between the reference clock support
* ntp_refclock.c and particular clock drivers. This must agree with the
* structure defined in the driver.
*/
#define noentry 0 /* flag for null routine */
#define NOFLAGS 0 /* flag for null flags */
struct refclock {
int (*clock_start) P((int, struct peer *));
void (*clock_shutdown) P((int, struct peer *));
void (*clock_poll) P((int, struct peer *));
void (*clock_control) P((int, struct refclockstat *,
struct refclockstat *));
void (*clock_init) P((void));
void (*clock_buginfo) P((int, struct refclockbug *));
u_long clock_flags;
};
/*
* Function prototypes
*/
extern int io_addclock_simple P((struct refclockio *));
extern int io_addclock P((struct refclockio *));
extern void io_closeclock P((struct refclockio *));
#ifdef REFCLOCK
extern void refclock_buginfo P((struct sockaddr_in *,
struct refclockbug *));
extern void refclock_control P((struct sockaddr_in *,
struct refclockstat *,
struct refclockstat *));
extern int refclock_open P((char *, int, int));
extern void refclock_transmit P((struct peer *));
extern int refclock_ioctl P((int, int));
extern int refclock_process P((struct refclockproc *, int, int));
extern void refclock_report P((struct peer *, u_char));
extern int refclock_gtlin P((struct recvbuf *, char *, int,
l_fp *));
#endif /* REFCLOCK */

View File

@ -1,808 +0,0 @@
/*
* ntp_request.h - definitions for the xntpd remote query facility
*/
#include "ntp_types.h"
/*
* A mode 7 packet is used exchanging data between an NTP server
* and a client for purposes other than time synchronization, e.g.
* monitoring, statistics gathering and configuration. A mode 7
* packet has the following format:
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |R|M| VN | Mode|A| Sequence | Implementation| Req Code |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Err | Number of data items | MBZ | Size of data item |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | |
* | Data (Minimum 0 octets, maximum 500 octets) |
* | |
* [...]
* | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encryption Keyid (when A bit set) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | |
* | Message Authentication Code (when A bit set) |
* | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* where the fields are (note that the client sends requests, the server
* responses):
*
* Response Bit: This packet is a response (if clear, packet is a request).
*
* More Bit: Set for all packets but the last in a response which
* requires more than one packet.
*
* Version Number: 2 for current version
*
* Mode: Always 7
*
* Authenticated bit: If set, this packet is authenticated.
*
* Sequence number: For a multipacket response, contains the sequence
* number of this packet. 0 is the first in the sequence,
* 127 (or less) is the last. The More Bit must be set in
* all packets but the last.
*
* Implementation number: The number of the implementation this request code
* is defined by. An implementation number of zero is used
* for requst codes/data formats which all implementations
* agree on. Implementation number 255 is reserved (for
* extensions, in case we run out).
*
* Request code: An implementation-specific code which specifies the
* operation to be (which has been) performed and/or the
* format and semantics of the data included in the packet.
*
* Err: Must be 0 for a request. For a response, holds an error
* code relating to the request. If nonzero, the operation
* requested wasn't performed.
*
* 0 - no error
* 1 - incompatable implementation number
* 2 - unimplemented request code
* 3 - format error (wrong data items, data size, packet size etc.)
* 4 - no data available (e.g. request for details on unknown peer)
* 5-6 I don't know
* 7 - authentication failure (i.e. permission denied)
*
* Number of data items: number of data items in packet. 0 to 500
*
* MBZ: A reserved data field, must be zero in requests and responses.
*
* Size of data item: size of each data item in packet. 0 to 500
*
* Data: Variable sized area containing request/response data. For
* requests and responses the size in octets must be greater
* than or equal to the product of the number of data items
* and the size of a data item. For requests the data area
* must be exactly 40 octets in length. For responses the
* data area may be any length between 0 and 500 octets
* inclusive.
*
* Message Authentication Code: Same as NTP spec, in definition and function.
* May optionally be included in requests which require
* authentication, is never included in responses.
*
* The version number, mode and keyid have the same function and are
* in the same location as a standard NTP packet. The request packet
* is the same size as a standard NTP packet to ease receive buffer
* management, and to allow the same encryption procedure to be used
* both on mode 7 and standard NTP packets. The mac is included when
* it is required that a request be authenticated, the keyid should be
* zero in requests in which the mac is not included.
*
* The data format depends on the implementation number/request code pair
* and whether the packet is a request or a response. The only requirement
* is that data items start in the octet immediately following the size
* word and that data items be concatenated without padding between (i.e.
* if the data area is larger than data_items*size, all padding is at
* the end). Padding is ignored, other than for encryption purposes.
* Implementations using encryption might want to include a time stamp
* or other data in the request packet padding. The key used for requests
* is implementation defined, but key 15 is suggested as a default.
*/
/*
* A request packet. These are almost a fixed length.
*/
struct req_pkt {
u_char rm_vn_mode; /* response, more, version, mode */
u_char auth_seq; /* key, sequence number */
u_char implementation; /* implementation number */
u_char request; /* request number */
u_short err_nitems; /* error code/number of data items */
u_short mbz_itemsize; /* item size */
char data[32]; /* data area */
l_fp tstamp; /* time stamp, for authentication */
U_LONG keyid; /* encryption key */
char mac[MAX_MAC_LEN-sizeof(U_LONG)]; /* (optional) 8 byte auth code */
};
/*
* Input packet lengths. One with the mac, one without.
*/
#define REQ_LEN_MAC (sizeof(struct req_pkt))
#define REQ_LEN_NOMAC (sizeof(struct req_pkt) - MAX_MAC_LEN)
/*
* A response packet. The length here is variable, this is a
* maximally sized one. Note that this implementation doesn't
* authenticate responses.
*/
#define RESP_HEADER_SIZE (8)
#define RESP_DATA_SIZE (500)
struct resp_pkt {
u_char rm_vn_mode; /* response, more, version, mode */
u_char auth_seq; /* key, sequence number */
u_char implementation; /* implementation number */
u_char request; /* request number */
u_short err_nitems; /* error code/number of data items */
u_short mbz_itemsize; /* item size */
char data[RESP_DATA_SIZE]; /* data area */
};
/*
* Information error codes
*/
#define INFO_OKAY 0
#define INFO_ERR_IMPL 1 /* incompatable implementation */
#define INFO_ERR_REQ 2 /* unknown request code */
#define INFO_ERR_FMT 3 /* format error */
#define INFO_ERR_NODATA 4 /* no data for this request */
#define INFO_ERR_AUTH 7 /* authentication failure */
/*
* Maximum sequence number.
*/
#define MAXSEQ 127
/*
* Bit setting macros for multifield items.
*/
#define RESP_BIT 0x80
#define MORE_BIT 0x40
#define ISRESPONSE(rm_vn_mode) (((rm_vn_mode)&RESP_BIT)!=0)
#define ISMORE(rm_vn_mode) (((rm_vn_mode)&MORE_BIT)!=0)
#define INFO_VERSION(rm_vn_mode) ((u_char)(((rm_vn_mode)>>3)&0x7))
#define INFO_MODE(rm_vn_mode) ((rm_vn_mode)&0x7)
#define RM_VN_MODE(resp, more) ((u_char)(((resp)?RESP_BIT:0)\
|((more)?MORE_BIT:0)\
|((NTP_VERSION)<<3)\
|(MODE_PRIVATE)))
#define INFO_IS_AUTH(auth_seq) (((auth_seq) & 0x80) != 0)
#define INFO_SEQ(auth_seq) ((auth_seq)&0x7f)
#define AUTH_SEQ(auth, seq) ((u_char)((((auth)!=0)?0x80:0)|((seq)&0x7f)))
#define INFO_ERR(err_nitems) ((u_short)((ntohs(err_nitems)>>12)&0xf))
#define INFO_NITEMS(err_nitems) ((u_short)(ntohs(err_nitems)&0xfff))
#define ERR_NITEMS(err, nitems) (htons((((u_short)(err)<<12)&0xf000)\
|((u_short)(nitems)&0xfff)))
#define INFO_MBZ(mbz_itemsize) ((ntohs(mbz_itemsize)>>12)&0xf)
#define INFO_ITEMSIZE(mbz_itemsize) (ntohs(mbz_itemsize)&0xfff)
#define MBZ_ITEMSIZE(itemsize) (htons((u_short)(itemsize)))
/*
* Implementation numbers. One for universal use and one for xntpd.
*/
#define IMPL_UNIV 0
#define IMPL_XNTPD 2
/*
* Some limits related to authentication. Frames which are
* authenticated must include a time stamp which differs from
* the receive time stamp by no more than 10 seconds.
*/
#define INFO_TS_MAXSKEW_UI 10
/*
* Universal request codes go here. There aren't any.
*/
/*
* XNTPD request codes go here.
*/
#define REQ_PEER_LIST 0 /* return list of peers */
#define REQ_PEER_LIST_SUM 1 /* return summary info for all peers */
#define REQ_PEER_INFO 2 /* get standard information on peer */
#define REQ_PEER_STATS 3 /* get statistics for peer */
#define REQ_SYS_INFO 4 /* get system information */
#define REQ_SYS_STATS 5 /* get system stats */
#define REQ_IO_STATS 6 /* get I/O stats */
#define REQ_MEM_STATS 7 /* stats related to peer list maint */
#define REQ_LOOP_INFO 8 /* info from the loop filter */
#define REQ_TIMER_STATS 9 /* get timer stats */
#define REQ_CONFIG 10 /* configure a new peer */
#define REQ_UNCONFIG 11 /* unconfigure an existing peer */
#define REQ_SET_SYS_FLAG 12 /* set system flags */
#define REQ_CLR_SYS_FLAG 13 /* clear system flags */
#define REQ_MONITOR 14 /* monitor clients */
#define REQ_NOMONITOR 15 /* stop monitoring clients */
#define REQ_GET_RESTRICT 16 /* return restrict list */
#define REQ_RESADDFLAGS 17 /* add flags to restrict list */
#define REQ_RESSUBFLAGS 18 /* remove flags from restrict list */
#define REQ_UNRESTRICT 19 /* remove entry from restrict list */
#define REQ_MON_GETLIST 20 /* return data collected by monitor */
#define REQ_RESET_STATS 21 /* reset stat counters */
#define REQ_RESET_PEER 22 /* reset peer stat counters */
#define REQ_REREAD_KEYS 23 /* reread the encryption key file */
#define REQ_DO_DIRTY_HACK 24 /* historical interest */
#define REQ_DONT_DIRTY_HACK 25 /* Ibid. */
#define REQ_TRUSTKEY 26 /* add a trusted key */
#define REQ_UNTRUSTKEY 27 /* remove a trusted key */
#define REQ_AUTHINFO 28 /* return authentication info */
#define REQ_TRAPS 29 /* return currently set traps */
#define REQ_ADD_TRAP 30 /* add a trap */
#define REQ_CLR_TRAP 31 /* clear a trap */
#define REQ_REQUEST_KEY 32 /* define a new request keyid */
#define REQ_CONTROL_KEY 33 /* define a new control keyid */
#define REQ_GET_CTLSTATS 34 /* get stats from the control module */
#define REQ_GET_LEAPINFO 35 /* get leap information */
#define REQ_GET_CLOCKINFO 36 /* get clock information */
#define REQ_SET_CLKFUDGE 37 /* set clock fudge factors */
#define REQ_GET_KERNEL 38 /* get kernel pll/pps information */
#define REQ_GET_CLKBUGINFO 39 /* get clock debugging info */
#define REQ_SET_PRECISION 41 /* set clock precision */
#define REQ_MON_GETLIST_1 42 /* return data collected by monitor v1*/
/*
* Flags in the peer information returns
*/
#define INFO_FLAG_CONFIG 0x1
#define INFO_FLAG_SYSPEER 0x2
#define INFO_FLAG_UNUSED 0x4
#define INFO_FLAG_REFCLOCK 0x8
#define INFO_FLAG_PREFER 0x10
#define INFO_FLAG_AUTHENABLE 0x20
#define INFO_FLAG_SEL_CANDIDATE 0x40
#define INFO_FLAG_SHORTLIST 0x80
/*
* Flags in the system information returns
*/
#define INFO_FLAG_BCLIENT 0x1
#define INFO_FLAG_AUTHENTICATE 0x2
#define INFO_FLAG_PLL 0x4
#define INFO_FLAG_PPS 0x8 /* unused */
#define INFO_FLAG_PLL_SYNC 0x10
#define INFO_FLAG_PPS_SYNC 0x20
#define INFO_FLAG_MONITOR 0x40
#define INFO_FLAG_FILEGEN 0x80
/*
* Peer list structure. Used to return raw lists of peers. It goes
* without saying that everything returned is in network byte order.
*/
struct info_peer_list {
U_LONG address; /* address of peer */
u_short port; /* port number of peer */
u_char hmode; /* mode for this peer */
u_char flags; /* flags (from above) */
};
/*
* Peer summary structure. Sort of the info that ntpdc returns by default.
*/
struct info_peer_summary {
U_LONG dstadr; /* local address (zero for undetermined) */
U_LONG srcadr; /* source address */
u_short srcport; /* source port */
u_char stratum; /* stratum of peer */
s_char hpoll; /* host polling interval */
s_char ppoll; /* peer polling interval */
u_char reach; /* reachability register */
u_char flags; /* flags, from above */
u_char hmode; /* peer mode */
s_fp delay; /* peer.estdelay */
l_fp offset; /* peer.estoffset */
u_fp dispersion; /* peer.estdisp */
};
/*
* Peer information structure.
*/
struct info_peer {
U_LONG dstadr; /* local address */
U_LONG srcadr; /* remote address */
u_short srcport; /* remote port */
u_char flags; /* peer flags */
u_char leap; /* peer.leap */
u_char hmode; /* peer.hmode */
u_char pmode; /* peer.pmode */
u_char stratum; /* peer.stratum */
u_char ppoll; /* peer.ppoll */
u_char hpoll; /* peer.hpoll */
s_char precision; /* peer.precision */
u_char version; /* peer.version */
u_char valid; /* peer.valid */
u_char reach; /* peer.reach */
u_char unreach; /* peer.unreach */
u_char flash; /* peer.flash */
u_char ttl; /* peer.ttl */
u_char unused8; /* (obsolete) */
u_char unused9;
u_short associd; /* association ID */
U_LONG keyid; /* auth key in use */
U_LONG pkeyid; /* peer.pkeyid */
U_LONG refid; /* peer.refid */
U_LONG timer; /* peer.timer */
s_fp rootdelay; /* peer.distance */
u_fp rootdispersion; /* peer.dispersion */
l_fp reftime; /* peer.reftime */
l_fp org; /* peer.org */
l_fp rec; /* peer.rec */
l_fp xmt; /* peer.xmt */
s_fp filtdelay[NTP_SHIFT]; /* delay shift register */
l_fp filtoffset[NTP_SHIFT]; /* offset shift register */
u_char order[NTP_SHIFT]; /* order of peers from last filter */
s_fp delay; /* peer.estdelay */
u_fp dispersion; /* peer.estdisp */
l_fp offset; /* peer.estoffset */
u_fp selectdisp; /* peer select dispersion */
LONG unused1; /* (obsolete) */
LONG unused2;
LONG unused3;
LONG unused4;
LONG unused5;
LONG unused6;
LONG unused7;
s_fp estbdelay; /* broadcast offset */
};
/*
* Peer statistics structure
*/
struct info_peer_stats {
U_LONG dstadr; /* local address */
U_LONG srcadr; /* remote address */
u_short srcport; /* remote port */
u_short flags; /* peer flags */
U_LONG timereset; /* time counters were reset */
U_LONG timereceived; /* time since a packet received */
U_LONG timetosend; /* time until a packet sent */
U_LONG timereachable; /* time peer has been reachable */
U_LONG sent; /* number sent */
U_LONG unused1; /* (unused) */
U_LONG processed; /* number processed */
U_LONG unused2; /* (unused) */
U_LONG badauth; /* bad authentication */
U_LONG bogusorg; /* bogus origin */
U_LONG oldpkt; /* duplicate */
U_LONG unused3; /* (unused) */
U_LONG unused4; /* (unused) */
U_LONG seldisp; /* bad dispersion */
U_LONG selbroken; /* bad reference time */
U_LONG unused5; /* (unused) */
u_char candidate; /* select order */
u_char unused6; /* (unused) */
u_char unused7; /* (unused) */
u_char unused8; /* (unused) */
};
/*
* Loop filter variables
*/
struct info_loop {
l_fp last_offset;
l_fp drift_comp;
U_LONG compliance;
U_LONG watchdog_timer;
};
/*
* System info. Mostly the sys.* variables, plus a few unique to
* the implementation.
*/
struct info_sys {
U_LONG peer; /* system peer address */
u_char peer_mode; /* mode we are syncing to peer in */
u_char leap; /* system leap bits */
u_char stratum; /* our stratum */
s_char precision; /* local clock precision */
s_fp rootdelay; /* distance from sync source */
u_fp rootdispersion; /* dispersion from sync source */
U_LONG refid; /* reference ID of sync source */
l_fp reftime; /* system reference time */
U_LONG poll; /* system poll interval */
u_char flags; /* system flags */
u_char unused1; /* unused */
u_char unused2; /* unused */
u_char unused3; /* unused */
s_fp bdelay; /* default broadcast offset */
s_fp frequency; /* frequency residual (scaled ppm) */
l_fp authdelay; /* default authentication delay */
u_fp stability; /* clock stability (scaled ppm) */
};
/*
* System stats. These are collected in the protocol module
*/
struct info_sys_stats {
U_LONG timeup; /* time we have been up and running */
U_LONG timereset; /* time since these were last cleared */
U_LONG badstratum; /* packets claiming an invalid stratum */
U_LONG oldversionpkt; /* old version packets received */
U_LONG newversionpkt; /* new version packets received */
U_LONG unknownversion; /* don't know version packets */
U_LONG badlength; /* packets with bad length */
U_LONG processed; /* packets processed */
U_LONG badauth; /* packets dropped because of authorization */
U_LONG wanderhold; /* (obsolete) */
U_LONG limitrejected; /* rejected because of client limitation */
};
/*
* System stats - old version
*/
struct old_info_sys_stats {
U_LONG timeup; /* time we have been up and running */
U_LONG timereset; /* time since these were last cleared */
U_LONG badstratum; /* packets claiming an invalid stratum */
U_LONG oldversionpkt; /* old version packets received */
U_LONG newversionpkt; /* new version packets received */
U_LONG unknownversion; /* don't know version packets */
U_LONG badlength; /* packets with bad length */
U_LONG processed; /* packets processed */
U_LONG badauth; /* packets dropped because of authorization */
U_LONG wanderhold;
};
/*
* Peer memory statistics. Collected in the peer module.
*/
struct info_mem_stats {
U_LONG timereset; /* time since reset */
u_short totalpeermem;
u_short freepeermem;
U_LONG findpeer_calls;
U_LONG allocations;
U_LONG demobilizations;
u_char hashcount[HASH_SIZE];
};
/*
* I/O statistics. Collected in the I/O module
*/
struct info_io_stats {
U_LONG timereset; /* time since reset */
u_short totalrecvbufs; /* total receive bufs */
u_short freerecvbufs; /* free buffers */
u_short fullrecvbufs; /* full buffers */
u_short lowwater; /* number of times we've added buffers */
U_LONG dropped; /* dropped packets */
U_LONG ignored; /* ignored packets */
U_LONG received; /* received packets */
U_LONG sent; /* packets sent */
U_LONG notsent; /* packets not sent */
U_LONG interrupts; /* interrupts we've handled */
U_LONG int_received; /* received by interrupt handler */
};
/*
* Timer stats. Guess where from.
*/
struct info_timer_stats {
U_LONG timereset; /* time since reset */
U_LONG alarms; /* alarms we've handled */
U_LONG overflows; /* timer overflows */
U_LONG xmtcalls; /* calls to xmit */
};
/*
* Structure for passing peer configuration information
*/
struct conf_peer {
U_LONG peeraddr; /* address to poll */
u_char hmode; /* mode, either broadcast, active or client */
u_char version; /* version number to poll with */
u_char minpoll; /* min host poll interval */
u_char maxpoll; /* max host poll interval */
u_char flags; /* flags for this request */
u_char ttl; /* time to live (multicast) */
u_short unused; /* unused */
U_LONG keyid; /* key to use for this association */
};
#define CONF_FLAG_AUTHENABLE 0x1
#define CONF_FLAG_PREFER 0x2
/*
* Structure for passing peer deletion information. Currently
* we only pass the address and delete all configured peers with
* this addess.
*/
struct conf_unpeer {
U_LONG peeraddr; /* address of peer */
};
/*
* Structure for carrying system flags.
*/
struct conf_sys_flags {
U_LONG flags;
};
/*
* System flags we can set/clear
*/
#define SYS_FLAG_BCLIENT 0x1
#define SYS_FLAG_AUTHENTICATE 0x2
#define SYS_FLAG_PLL 0x4
#define SYS_FLAG_PPS 0x8
#define SYS_FLAG_MONITOR 0x10
#define SYS_FLAG_FILEGEN 0x20
/*
* Structure used for returning restrict entries
*/
struct info_restrict {
U_LONG addr; /* match address */
U_LONG mask; /* match mask */
U_LONG count; /* number of packets matched */
u_short flags; /* restrict flags */
u_short mflags; /* match flags */
};
/*
* Structure used for specifying restrict entries
*/
struct conf_restrict {
U_LONG addr; /* match address */
U_LONG mask; /* match mask */
u_short flags; /* restrict flags */
u_short mflags; /* match flags */
};
/*
* Structure used for returning monitor data
*/
struct info_monitor_1 {
U_LONG lasttime; /* last packet from this host */
U_LONG firsttime; /* first time we received a packet */
U_LONG lastdrop; /* last time we rejected a packet due to client limitation policy */
U_LONG count; /* count of packets received */
U_LONG addr; /* host address */
U_LONG daddr; /* destination host address */
U_LONG flags; /* flags about destination */
u_short port; /* port number of last reception */
u_char mode; /* mode of last packet */
u_char version; /* version number of last packet */
};
/*
* Structure used for returning monitor data
*/
struct info_monitor {
U_LONG lasttime; /* last packet from this host */
U_LONG firsttime; /* first time we received a packet */
U_LONG lastdrop; /* last time we rejected a packet due to client limitation policy */
U_LONG count; /* count of packets received */
U_LONG addr; /* host address */
u_short port; /* port number of last reception */
u_char mode; /* mode of last packet */
u_char version; /* version number of last packet */
};
/*
* Structure used for returning monitor data (old format
*/
struct old_info_monitor {
U_LONG lasttime; /* last packet from this host */
U_LONG firsttime; /* first time we received a packet */
U_LONG count; /* count of packets received */
U_LONG addr; /* host address */
u_short port; /* port number of last reception */
u_char mode; /* mode of last packet */
u_char version; /* version number of last packet */
};
/*
* Structure used for passing indication of flags to clear
*/
struct reset_flags {
U_LONG flags;
};
#define RESET_FLAG_ALLPEERS 0x01
#define RESET_FLAG_IO 0x02
#define RESET_FLAG_SYS 0x04
#define RESET_FLAG_MEM 0x08
#define RESET_FLAG_TIMER 0x10
#define RESET_FLAG_AUTH 0x20
#define RESET_FLAG_CTL 0x40
#define RESET_ALLFLAGS \
(RESET_FLAG_ALLPEERS|RESET_FLAG_IO|RESET_FLAG_SYS \
|RESET_FLAG_MEM|RESET_FLAG_TIMER|RESET_FLAG_AUTH|RESET_FLAG_CTL)
/*
* Structure used to return information concerning the authentication
* module.
*/
struct info_auth {
U_LONG timereset; /* time counters were reset */
U_LONG numkeys; /* number of keys we know */
U_LONG numfreekeys; /* number of free keys */
U_LONG keylookups; /* calls to authhavekey() */
U_LONG keynotfound; /* requested key unknown */
U_LONG encryptions; /* number of encryptions */
U_LONG decryptions; /* number of decryptions */
U_LONG unused; /* (unused) */
U_LONG keyuncached; /* calls to encrypt/decrypt with uncached key */
};
/*
* Structure used to pass trap information to the client
*/
struct info_trap {
U_LONG local_address; /* local interface address */
U_LONG trap_address; /* remote client's address */
u_short trap_port; /* remote port number */
u_short sequence; /* sequence number */
U_LONG settime; /* time trap last set */
U_LONG origtime; /* time trap originally set */
U_LONG resets; /* number of resets on this trap */
U_LONG flags; /* trap flags, as defined in ntp_control.h */
};
/*
* Structure used to pass add/clear trap information to the client
*/
struct conf_trap {
U_LONG local_address; /* local interface address */
U_LONG trap_address; /* remote client's address */
u_short trap_port; /* remote client's port */
u_short unused;
};
/*
* Structure used to return statistics from the control module
*/
struct info_control {
U_LONG ctltimereset;
U_LONG numctlreq; /* number of requests we've received */
U_LONG numctlbadpkts; /* number of bad control packets */
U_LONG numctlresponses; /* # resp packets sent */
U_LONG numctlfrags; /* # of fragments sent */
U_LONG numctlerrors; /* number of error responses sent */
U_LONG numctltooshort; /* number of too short input packets */
U_LONG numctlinputresp; /* number of responses on input */
U_LONG numctlinputfrag; /* number of fragments on input */
U_LONG numctlinputerr; /* # input pkts with err bit set */
U_LONG numctlbadoffset; /* # input pkts with nonzero offset */
U_LONG numctlbadversion; /* # input pkts with unknown version */
U_LONG numctldatatooshort; /* data too short for count */
U_LONG numctlbadop; /* bad op code found in packet */
U_LONG numasyncmsgs; /* # async messages we've sent */
};
/*
* Structure used to return leap information.
*/
struct info_leap {
u_char sys_leap; /* current sys_leap */
u_char leap_indicator; /* current leap indicator */
u_char leap_warning; /* current leap warning */
u_char leap_bits; /* leap flags */
U_LONG leap_timer; /* seconds to next interrupt */
U_LONG leap_processcalls; /* calls to the leap process */
U_LONG leap_notclose; /* found leap was not close */
U_LONG leap_monthofleap; /* in month of leap */
U_LONG leap_dayofleap; /* in day of leap */
U_LONG leap_hoursfromleap; /* leap within two hours */
U_LONG leap_happened; /* leap second happened */
};
#define INFO_LEAP_MASK 0x3 /* flag for leap_bits */
#define INFO_LEAP_SEENSTRATUM1 0x4 /* server has seen stratum 1 */
#define INFO_LEAP_OVERRIDE 0x8 /* server will override the leap information */
/*
* Structure used to return clock information
*/
struct info_clock {
U_LONG clockadr;
u_char type;
u_char flags;
u_char lastevent;
u_char currentstatus;
U_LONG polls;
U_LONG noresponse;
U_LONG badformat;
U_LONG baddata;
U_LONG timestarted;
l_fp fudgetime1;
l_fp fudgetime2;
LONG fudgeval1;
LONG fudgeval2;
};
/*
* Structure used for setting clock fudge factors
*/
struct conf_fudge {
U_LONG clockadr;
U_LONG which;
l_fp fudgetime;
LONG fudgeval_flags;
};
#define FUDGE_TIME1 1
#define FUDGE_TIME2 2
#define FUDGE_VAL1 3
#define FUDGE_VAL2 4
#define FUDGE_FLAGS 5
/*
* Structure used for returning clock debugging info
*/
#define NUMCBUGVALUES 16
#define NUMCBUGTIMES 32
struct info_clkbug {
U_LONG clockadr;
u_char nvalues;
u_char ntimes;
u_short svalues;
U_LONG stimes;
U_LONG values[NUMCBUGVALUES];
l_fp times[NUMCBUGTIMES];
};
/*
* Structure used for returning kernel pll/PPS information
*/
struct info_kernel {
LONG offset;
LONG freq;
LONG maxerror;
LONG esterror;
u_short status;
u_short shift;
LONG constant;
LONG precision;
LONG tolerance;
/*
* Variables used only if PPS signal discipline is implemented
*/
LONG ppsfreq;
LONG jitter;
LONG stabil;
LONG jitcnt;
LONG calcnt;
LONG errcnt;
LONG stbcnt;
};

View File

@ -1,20 +0,0 @@
/*
* Not all machines define FD_SET in sys/types.h
*/
#ifndef _ntp_select_h
#define _ntp_select_h
#if (defined(RS6000)||defined(SYS_PTX))&&!defined(_BSD)
#include <sys/select.h>
#endif
#ifndef FD_SET
#define NFDBITS 32
#define FD_SETSIZE 32
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
#define FD_ZERO(p) memset((char *)(p), 0, sizeof(*(p)))
#endif
#endif /* _ntp_select_h */

View File

@ -1,93 +0,0 @@
/*
* ntp_stdlib.h - Prototypes for XNTP lib.
*/
#include <sys/types.h>
#include "ntp_types.h"
#include "ntp_string.h"
#include "l_stdlib.h"
#ifndef P
#if defined(__STDC__) || defined(USE_PROTOTYPES)
#define P(x) x
#else
#define P(x) ()
#if !defined(const)
#define const
#endif
#endif
#endif
#if defined(__STDC__)
extern void msyslog P((int, char *, ...));
#else
extern void msyslog P(());
#endif
extern void auth_des P((u_long *, u_char *));
extern void auth_delkeys P((void));
extern int auth_havekey P((u_long));
extern int auth_parity P((u_long *));
extern void auth_setkey P((u_long, u_long *));
extern void auth_subkeys P((u_long *, u_char *, u_char *));
extern int authistrusted P((u_long));
extern int authusekey P((u_long, int, const char *));
extern void auth_delkeys P((void));
extern void auth1crypt P((u_long, U_LONG *, int));
extern int auth2crypt P((u_long, U_LONG *, int));
extern int authdecrypt P((u_long, U_LONG *, int));
extern int authencrypt P((u_long, U_LONG *, int));
extern int authhavekey P((u_long));
extern int authreadkeys P((const char *));
extern void authtrust P((u_long, int));
extern void calleapwhen P((u_long, u_long *, u_long *));
extern u_long calyearstart P((u_long));
extern const char *clockname P((int));
extern int clocktime P((int, int, int, int, int, u_long, u_long *, U_LONG *));
extern char * emalloc P((u_int));
extern int ntp_getopt P((int, char **, char *));
extern void init_auth P((void));
extern void init_lib P((void));
extern void init_random P((void));
#ifdef DES
extern void DESauth1crypt P((u_long, U_LONG *, int));
extern int DESauth2crypt P((u_long, U_LONG *, int));
extern int DESauthdecrypt P((u_long, const U_LONG *, int));
extern int DESauthencrypt P((u_long, U_LONG *, int));
extern void DESauth_setkey P((u_long, const U_LONG *));
extern void DESauth_subkeys P((const U_LONG *, u_char *, u_char *));
extern void DESauth_des P((U_LONG *, u_char *));
extern int DESauth_parity P((U_LONG *));
#endif /* DES */
#ifdef MD5
extern void MD5auth1crypt P((u_long, U_LONG *, int));
extern int MD5auth2crypt P((u_long, U_LONG *, int));
extern int MD5authdecrypt P((u_long, const U_LONG *, int));
extern int MD5authencrypt P((u_long, U_LONG *, int));
extern void MD5auth_setkey P((u_long, const U_LONG *));
#endif /* MD5 */
extern int atoint P((const char *, long *));
extern int atouint P((const char *, u_long *));
extern int hextoint P((const char *, u_long *));
extern char * humandate P((u_long));
extern char * inttoa P((long));
extern char * mfptoa P((u_long, u_long, int));
extern char * mfptoms P((u_long, u_long, int));
extern char * modetoa P((int));
extern u_int32_t netof P((u_int32_t));
extern char * numtoa P((u_int32_t));
extern char * numtohost P((u_int32_t));
extern int octtoint P((const char *, u_long *));
extern u_long ranp2 P((int));
extern char * refnumtoa P((u_long));
extern int tsftomsu P((u_long, int));
extern char * uinttoa P((u_long));
extern int decodenetnum P((const char *, u_long *));
extern RETSIGTYPE signal_no_reset P((int, RETSIGTYPE (*func)()));

View File

@ -1,35 +0,0 @@
/*
* Define string ops: strchr strrchr memcmp memmove memset
*/
#ifndef _ntp_string_h
#define _ntp_string_h
#if defined(NTP_POSIX_SOURCE)
# if defined(HAVE_MEMORY_H)
# include <memory.h>
# endif
# include <string.h>
#else
# include <strings.h>
# define strchr(s,c) index(s,c)
# define strrchr(s,c) rindex(s,c)
# ifndef NTP_NEED_BOPS
# define NTP_NEED_BOPS
# endif
#endif /* NTP_POSIX_SOURCE */
#ifdef NTP_NEED_BOPS
# define memcmp(a,b,c) bcmp(a,b,c)
# define memmove(t,f,c) bcopy(f,t,c)
# define memset(a,x,c) if (x == 0x00) bzero(a,c); else ntp_memset((char*)a,x,c)
void ntp_memset P((char *, int, int));
#endif /* NTP_NEED_BOPS */
#endif /* _ntp_string_h */

View File

@ -1,15 +0,0 @@
/*
* A hack for platforms which require specially built syslog facilities
*/
#ifdef GIZMO
#include "gizmo_syslog.h"
#else /* !GIZMO */
#include <syslog.h>
#ifdef SYSLOG_FILE
#include <stdio.h>
#endif
#endif /* GIZMO */
#ifdef SYSLOG_FILE
extern FILE *syslog_file;
#define syslog msyslog
#endif

View File

@ -1,273 +0,0 @@
/******************************************************************************
* *
* Copyright (c) David L. Mills 1993, 1994 *
* *
* 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. *
* *
******************************************************************************/
/*
* Modification history timex.h
*
* 19 Mar 94 David L. Mills
* Moved defines from kernel routines to header file and added new
* defines for PPS phase-lock loop.
*
* 20 Feb 94 David L. Mills
* Revised status codes and structures for external clock and PPS
* signal discipline.
*
* 28 Nov 93 David L. Mills
* Adjusted parameters to improve stability and increase poll
* interval.
*
* 17 Sep 93 David L. Mills
* Created file
*/
/*
* This header file defines the Network Time Protocol (NTP) interfaces
* for user and daemon application programs. These are implemented using
* private syscalls and data structures and require specific kernel
* support.
*
* NAME
* ntp_gettime - NTP user application interface
*
* SYNOPSIS
* #include <sys/timex.h>
*
* int syscall(SYS_ntp_gettime, tptr)
*
* int SYS_ntp_gettime defined in syscall.h header file
* struct ntptimeval *tptr pointer to ntptimeval structure
*
* NAME
* ntp_adjtime - NTP daemon application interface
*
* SYNOPSIS
* #include <sys/timex.h>
*
* int syscall(SYS_ntp_adjtime, mode, tptr)
*
* int SYS_ntp_adjtime defined in syscall.h header file
* struct timex *tptr pointer to timex structure
*
*/
#ifndef MSDOS /* Microsoft specific */
#include <sys/syscall.h>
#endif /* MSDOS */
/*
* The following defines establish the engineering parameters of the
* phase-lock loop (PLL) model used in the kernel implementation. These
* parameters have been carefully chosen by analysis for good stability
* and wide dynamic range.
*
* The hz variable is defined in the kernel build environment. It
* establishes the timer interrupt frequency, 100 Hz for the SunOS
* kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the OSF/1
* kernel. SHIFT_HZ expresses the same value as the nearest power of two
* in order to avoid hardware multiply operations.
*
* SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
* for a slightly underdamped convergence characteristic.
*
* MAXTC establishes the maximum time constant of the PLL. With the
* SHIFT_KG and SHIFT_KF values given and a time constant range from
* zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
* respectively.
*/
#define SHIFT_HZ 7 /* log2(hz) */
#define SHIFT_KG 6 /* phase factor (shift) */
#define SHIFT_KF 16 /* frequency factor (shift) */
#define MAXTC 6 /* maximum time constant (shift) */
/*
* The following defines establish the scaling of the various variables
* used by the PLL. They are chosen to allow the greatest precision
* possible without overflow of a 32-bit word.
*
* SHIFT_SCALE defines the scaling (shift) of the time_phase variable,
* which serves as a an extension to the low-order bits of the system
* clock variable time.tv_usec.
*
* SHIFT_UPDATE defines the scaling (shift) of the time_offset variable,
* which represents the current time offset with respect to standard
* time.
*
* SHIFT_USEC defines the scaling (shift) of the time_freq and
* time_tolerance variables, which represent the current frequency
* offset and maximum frequency tolerance.
*
* FINEUSEC is 1 us in SHIFT_UPDATE units of the time_phase variable.
*/
#define SHIFT_SCALE 23 /* phase scale (shift) */
#define SHIFT_UPDATE (SHIFT_KG + MAXTC) /* time offset scale (shift) */
#define SHIFT_USEC 16 /* frequency offset scale (shift) */
#define FINEUSEC (1L << SHIFT_SCALE) /* 1 us in phase units */
/*
* The following defines establish the performance envelope of the PLL.
* They insure it operates within predefined limits, in order to satisfy
* correctness assertions. An excursion which exceeds these bounds is
* clamped to the bound and operation proceeds accordingly. In practice,
* this can occur only if something has failed or is operating out of
* tolerance, but otherwise the PLL continues to operate in a stable
* mode.
*
* MAXPHASE must be set greater than or equal to CLOCK.MAX (128 ms), as
* defined in the NTP specification. CLOCK.MAX establishes the maximum
* time offset allowed before the system time is reset, rather than
* incrementally adjusted. Here, the maximum offset is clamped to
* MAXPHASE only in order to prevent overflow errors due to defective
* protocol implementations.
*
* MAXFREQ is the maximum frequency tolerance of the CPU clock
* oscillator plus the maximum slew rate allowed by the protocol. It
* should be set to at least the frequency tolerance of the oscillator
* plus 100 ppm for vernier frequency adjustments. If the kernel
* PPS discipline code is configured (PPS_SYNC), the oscillator time and
* frequency are disciplined to an external source, presumably with
* negligible time and frequency error relative to UTC, and MAXFREQ can
* be reduced.
*
* MAXTIME is the maximum jitter tolerance of the PPS signal if the
* kernel PPS discipline code is configured (PPS_SYNC).
*
* MINSEC and MAXSEC define the lower and upper bounds on the interval
* between protocol updates.
*/
#define MAXPHASE 128000L /* max phase error (us) */
#ifdef PPS_SYNC
#define MAXFREQ (100L << SHIFT_USEC) /* max freq error (100 ppm) */
#define MAXTIME (200L << PPS_AVG) /* max PPS error (jitter) (200 us) */
#else
#define MAXFREQ (200L << SHIFT_USEC) /* max freq error (200 ppm) */
#endif /* PPS_SYNC */
#define MINSEC 16L /* min interval between updates (s) */
#define MAXSEC 1200L /* max interval between updates (s) */
#ifdef PPS_SYNC
/*
* The following defines are used only if a pulse-per-second (PPS)
* signal is available and connected via a modem control lead, such as
* produced by the optional ppsclock feature incorporated in the Sun
* asynch driver. They establish the design parameters of the frequency-
* lock loop used to discipline the CPU clock oscillator to the PPS
* signal.
*
* PPS_AVG is the averaging factor for the frequency loop, as well as
* the time and frequency dispersion.
*
* PPS_SHIFT and PPS_SHIFTMAX specify the minimum and maximum
* calibration intervals, respectively, in seconds as a power of two.
*
* PPS_VALID is the maximum interval before the PPS signal is considered
* invalid and protocol updates used directly instead.
*
* MAXGLITCH is the maximum interval before a time offset of more than
* MAXTIME is believed.
*/
#define PPS_AVG 2 /* pps averaging constant (shift) */
#define PPS_SHIFT 2 /* min interval duration (s) (shift) */
#define PPS_SHIFTMAX 8 /* max interval duration (s) (shift) */
#define PPS_VALID 120 /* pps signal watchdog max (s) */
#define MAXGLITCH 30 /* pps signal glitch max (s) */
#endif /* PPS_SYNC */
/*
* The following defines and structures define the user interface for
* the ntp_gettime() and ntp_adjtime() system calls.
*
* Control mode codes (timex.modes)
*/
#define MOD_OFFSET 0x0001 /* set time offset */
#define MOD_FREQUENCY 0x0002 /* set frequency offset */
#define MOD_MAXERROR 0x0004 /* set maximum time error */
#define MOD_ESTERROR 0x0008 /* set estimated time error */
#define MOD_STATUS 0x0010 /* set clock status bits */
#define MOD_TIMECONST 0x0020 /* set pll time constant */
#define MOD_CLKB 0x4000 /* set clock B */
#define MOD_CLKA 0x8000 /* set clock A */
/*
* Status codes (timex.status)
*/
#define STA_PLL 0x0001 /* enable PLL updates (rw) */
#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
#define STA_INS 0x0010 /* insert leap (rw) */
#define STA_DEL 0x0020 /* delete leap (rw) */
#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
STA_PPSERROR | STA_CLOCKERR) /* read-only bits */
/*
* Clock states (time_state)
*/
#define TIME_OK 0 /* no leap second warning */
#define TIME_INS 1 /* insert leap second warning */
#define TIME_DEL 2 /* delete leap second warning */
#define TIME_OOP 3 /* leap second in progress */
#define TIME_WAIT 4 /* leap second has occured */
#define TIME_ERROR 5 /* clock not synchronized */
/*
* NTP user interface (ntp_gettime()) - used to read kernel clock values
*
* Note: maximum error = NTP synch distance = dispersion + delay / 2;
* estimated error = NTP dispersion.
*/
struct ntptimeval {
struct timeval time; /* current time (ro) */
LONG maxerror; /* maximum error (us) (ro) */
LONG esterror; /* estimated error (us) (ro) */
};
/*
* NTP daemon interface - (ntp_adjtime()) used to discipline CPU clock
* oscillator
*/
struct timex {
unsigned int modes; /* clock mode bits (wo) */
LONG offset; /* time offset (us) (rw) */
LONG freq; /* frequency offset (scaled ppm) (rw) */
LONG maxerror; /* maximum error (us) (rw) */
LONG esterror; /* estimated error (us) (rw) */
int status; /* clock status bits (rw) */
LONG constant; /* pll time constant (rw) */
LONG precision; /* clock precision (us) (ro) */
LONG tolerance; /* clock frequency tolerance (scaled
* ppm) (ro) */
/*
* The following read-only structure members are implemented
* only if the PPS signal discipline is configured in the
* kernel.
*/
LONG ppsfreq; /* pps frequency (scaled ppm) (ro) */
LONG jitter; /* pps jitter (us) (ro) */
int shift; /* interval duration (s) (shift) (ro) */
LONG stabil; /* pps stability (scaled ppm) (ro) */
LONG jitcnt; /* jitter limit exceeded (ro) */
LONG calcnt; /* calibration intervals (ro) */
LONG errcnt; /* calibration errors (ro) */
LONG stbcnt; /* stability limit exceeded (ro) */
};

View File

@ -1,60 +0,0 @@
/*
* ntp_types.h - defines how LONG and U_LONG are treated. For 64 bit systems
* like the DEC Alpha, they has to be defined as int and u_int. for 32 bit
* systems, define them as long and u_long
*/
#include "ntp_machine.h"
#ifndef _NTP_TYPES_
#define _NTP_TYPES_
/*
* This is another naming conflict.
* On NetBSD for MAC the macro "mac" is defined as 1
* this is fun for a as a paket structure contains an
* optional "mac" member - severe confusion results 8-)
* As we hopefully do not have to rely on that macro we
* just undefine that.
*/
#ifdef mac
#undef mac
#endif
/*
* Set up for prototyping
*/
#ifndef P
#if defined(__STDC__) || defined(USE_PROTOTYPES)
#define P(x) x
#else /* __STDC__ USE_PROTOTYPES */
#define P(x) ()
#if !defined(const)
#define const
#endif /* const */
#endif /* __STDC__ USE_PROTOTYPES */
#endif /* P */
/*
* DEC Alpha systems need LONG and U_LONG defined as int and u_int
*/
#ifdef __alpha
#ifndef LONG
#define LONG int
#endif /* LONG */
#ifndef U_LONG
#define U_LONG u_int
#endif /* U_LONG */
/*
* All other systems fall into this part
*/
#else /* __alpha */
#ifndef LONG
#define LONG long
#endif /* LONG */
#ifndef U_LONG
#define U_LONG u_long
#endif /* U_LONG */
#endif /* __ alplha */
#endif /* _NTP_TYPES_ */

View File

@ -1,119 +0,0 @@
/*
* ntp_unixtime.h - contains constants and macros for converting between
* NTP time stamps (l_fp) and Unix times (struct timeval)
*/
#include "ntp_types.h"
#include <sys/time.h>
/* gettimeofday() takes two args in BSD and only one in SYSV */
#ifdef SYSV_TIMEOFDAY
# define GETTIMEOFDAY(a, b) (gettimeofday(a))
# define SETTIMEOFDAY(a, b) (settimeofday(a))
#else /* ! SYSV_TIMEOFDAY */
# define GETTIMEOFDAY(a, b) (gettimeofday(a, b))
# define SETTIMEOFDAY(a, b) (settimeofday(a, b))
#endif /* SYSV_TIMEOFDAY */
/*
* Time of day conversion constant. Ntp's time scale starts in 1900,
* Unix in 1970.
*/
#define JAN_1970 0x83aa7e80 /* 2208988800 1970 - 1900 in seconds */
/*
* These constants are used to round the time stamps computed from
* a struct timeval to the microsecond (more or less). This keeps
* things neat.
*/
#define TS_MASK 0xfffff000 /* mask to usec, for time stamps */
#define TS_ROUNDBIT 0x00000800 /* round at this bit */
/*
* Convert usec to a time stamp fraction. If you use this the program
* must include the following declarations:
*/
extern u_long ustotslo[];
extern u_long ustotsmid[];
extern u_long ustotshi[];
#define TVUTOTSF(tvu, tsf) \
(tsf) = ustotslo[(tvu) & 0xff] \
+ ustotsmid[((tvu) >> 8) & 0xff] \
+ ustotshi[((tvu) >> 16) & 0xf]
/*
* Convert a struct timeval to a time stamp.
*/
#define TVTOTS(tv, ts) \
do { \
(ts)->l_ui = (u_long)(tv)->tv_sec; \
TVUTOTSF((tv)->tv_usec, (ts)->l_uf); \
} while(0)
#define sTVTOTS(tv, ts) \
do { \
int isneg = 0; \
long usec; \
(ts)->l_ui = (tv)->tv_sec; \
usec = (tv)->tv_usec; \
if (((tv)->tv_sec < 0) || ((tv)->tv_usec < 0)) { \
usec = -usec; \
(ts)->l_ui = -(ts)->l_ui; \
isneg = 1; \
} \
TVUTOTSF(usec, (ts)->l_uf); \
if (isneg) { \
L_NEG((ts)); \
} \
} while(0)
/*
* TV_SHIFT is used to turn the table result into a usec value. To round,
* add in TV_ROUNDBIT before shifting
*/
#define TV_SHIFT 3
#define TV_ROUNDBIT 0x4
/*
* Convert a time stamp fraction to microseconds. The time stamp
* fraction is assumed to be unsigned. To use this in a program, declare:
*/
extern long tstouslo[];
extern long tstousmid[];
extern long tstoushi[];
#define TSFTOTVU(tsf, tvu) \
(tvu) = (tstoushi[((tsf) >> 24) & 0xff] \
+ tstousmid[((tsf) >> 16) & 0xff] \
+ tstouslo[((tsf) >> 9) & 0x7f] \
+ TV_ROUNDBIT) >> TV_SHIFT
/*
* Convert a time stamp to a struct timeval. The time stamp
* has to be positive.
*/
#define TSTOTV(ts, tv) \
do { \
(tv)->tv_sec = (ts)->l_ui; \
TSFTOTVU((ts)->l_uf, (tv)->tv_usec); \
if ((tv)->tv_usec == 1000000) { \
(tv)->tv_sec++; \
(tv)->tv_usec = 0; \
} \
} while (0)
/*
* Convert milliseconds to a time stamp fraction. This shouldn't be
* here, but it is convenient since the guys who use the definition will
* often be including this file anyway.
*/
extern u_long msutotsflo[];
extern u_long msutotsfhi[];
#define MSUTOTSF(msu, tsf) \
(tsf) = msutotsfhi[((msu) >> 5) & 0x1f] + msutotsflo[(msu) & 0x1f]
extern char * tvtoa P((const struct timeval *));
extern char * utvtoa P((const struct timeval *));

View File

@ -1,175 +0,0 @@
/*
* ntpd.h - Prototypes for xntpd.
*/
#include "ntp_syslog.h"
#include "ntp_fp.h"
#include "ntp.h"
#include "ntp_malloc.h"
/* ntp_config.c */
extern void getstartup P((int, char **));
extern void getconfig P((int, char **));
/* ntp_config.c */
extern void ctl_clr_stats P((void));
extern int ctlclrtrap P((struct sockaddr_in *, struct interface *, int));
extern u_short ctlpeerstatus P((struct peer *));
extern int ctlsettrap P((struct sockaddr_in *, struct interface *, int, int));
extern u_short ctlsysstatus P((void));
extern void init_control P((void));
extern void process_control P((struct recvbuf *, int));
extern void report_event P((int, struct peer *));
/* ntp_control.c */
/*
* Structure for translation tables between internal system
* variable indices and text format.
*/
struct ctl_var {
u_short code;
u_short flags;
char *text;
};
/*
* Flag values
*/
#define CAN_READ 0x01
#define CAN_WRITE 0x02
#define DEF 0x20
#define PADDING 0x40
#define EOV 0x80
#define RO (CAN_READ)
#define WO (CAN_WRITE)
#define RW (CAN_READ|CAN_WRITE)
extern char * add_var P((struct ctl_var **, unsigned long, int));
extern void free_varlist P((struct ctl_var *));
extern void set_var P((struct ctl_var **, char *, unsigned long, int));
extern void set_sys_var P((char *, unsigned long, int));
/* ntp_intres.c */
extern void ntp_intres P((void));
/* ntp_io.c */
extern struct interface *findbcastinter P((struct sockaddr_in *));
extern struct interface *findinterface P((struct sockaddr_in *));
extern void freerecvbuf P((struct recvbuf *));
extern struct recvbuf *getrecvbufs P((void));
extern void init_io P((void));
extern void input_handler P((l_fp *));
extern void io_clr_stats P((void));
extern void io_setbclient P((void));
extern void io_unsetbclient P((void));
extern void io_multicast_add P((u_long));
extern void io_multicast_del P((u_long));
extern void sendpkt P((struct sockaddr_in *, struct interface *, int, struct pkt *, int));
#ifdef HAVE_SIGNALED_IO
extern void wait_for_signal P((void));
extern void unblock_io_and_alarm P((void));
extern void block_io_and_alarm P((void));
#endif
/* ntp_leap.c */
extern void init_leap P((void));
extern void leap_process P((void));
extern int leap_setleap P((int, int));
/*
* there seems to be a bug in the IRIX 4 compiler which prevents
* u_char from beeing used in prototyped functions.
* This is also true AIX compiler.
* So give up and define it to be int. WLJ
*/
extern int leap_actual P((int));
/* ntp_loopfilter.c */
extern void init_loopfilter P((void));
extern int local_clock P((l_fp *, struct peer *));
extern void adj_frequency P((s_fp));
extern void adj_host_clock P((void));
extern void loop_config P((int, l_fp *, int));
#if defined(PPS) || defined(PPSPPS) || defined(PPSCD)
extern int pps_sample P((l_fp *));
#endif /* PPS || PPSDEV || PPSCD */
/* ntp_monitor.c */
extern void init_mon P((void));
extern void mon_start P((int));
extern void mon_stop P((int));
extern void monitor P((struct recvbuf *));
/* ntp_peer.c */
extern void init_peer P((void));
extern struct peer *findexistingpeer P((struct sockaddr_in *, struct peer *));
extern struct peer *findpeer P((struct sockaddr_in *, struct interface *, int));
extern struct peer *findpeerbyassoc P((int));
extern struct peer *newpeer P((struct sockaddr_in *, struct interface *, int, int, int, int, int, u_long));
extern void peer_all_reset P((void));
extern void peer_clr_stats P((void));
extern struct peer *peer_config P((struct sockaddr_in *, struct interface *, int, int, int, int, int, int, u_long));
extern void peer_reset P((struct peer *));
extern int peer_unconfig P((struct sockaddr_in *, struct interface *));
extern void unpeer P((struct peer *));
/* ntp_proto.c */
extern void transmit P((struct peer *));
extern void receive P((struct recvbuf *));
extern void peer_clear P((struct peer *));
extern int process_packet P((struct peer *, struct pkt *, l_fp *, int, int));
extern void clock_update P((struct peer *));
/*
* there seems to be a bug in the IRIX 4 compiler which prevents
* u_char from beeing used in prototyped functions.
* This is also true AIX compiler.
* So give up and define it to be int. WLJ
*/
extern void poll_update P((struct peer *, unsigned int, int));
extern void clear P((struct peer *));
extern void clock_filter P((struct peer *, l_fp *, s_fp, u_fp));
extern void clock_select P((void));
extern void clock_combine P((struct peer **, int));
extern void fast_xmit P((struct recvbuf *, int, int));
extern void init_proto P((void));
extern void proto_config P((int, u_long));
extern void proto_clr_stats P((void));
#ifdef REFCLOCK
/* ntp_refclock.c */
extern int refclock_newpeer P((struct peer *));
extern void refclock_unpeer P((struct peer *));
extern void refclock_receive P((struct peer *, l_fp *, s_fp, u_fp, l_fp *, l_fp *, int));
extern void refclock_leap P((void));
extern void init_refclock P((void));
#endif /* REFCLOCK */
/* ntp_request.c */
extern void init_request P((void));
extern void process_private P((struct recvbuf *, int));
/* ntp_restrict.c */
extern void init_restrict P((void));
extern int restrictions P((struct sockaddr_in *));
extern void restrict P((int, struct sockaddr_in *, struct sockaddr_in *, int, int));
/* ntp_timer.c */
extern void init_timer P((void));
extern void timer P((void));
extern void timer_clr_stats P((void));
/* ntp_unixclock.c */
extern void init_systime P((void));
/* ntp_util.c */
extern void init_util P((void));
extern void hourly_stats P((void));
extern void stats_config P((int, char *));
extern void record_peer_stats P((struct sockaddr_in *, int, l_fp *, s_fp, u_fp));
extern void record_loop_stats P((l_fp *, s_fp, int));
extern void record_clock_stats P((struct sockaddr_in *, char *));
extern void getauthkeys P((char *));
extern void rereadkeys P((void));

Some files were not shown because too many files have changed in this diff Show More