aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>1994-09-29 23:04:24 +0000
committerGarrett Wollman <wollman@FreeBSD.org>1994-09-29 23:04:24 +0000
commitdaa35edbd086b27357d8f048ede7c84dcc520748 (patch)
tree8dd520f3dfb7df4f73618d886e20c1154f3e5e5f
parentd2d2eed18837c57f97405aa88134457f8d97640d (diff)
downloadsrc-daa35edbd086b27357d8f048ede7c84dcc520748.tar.gz
src-daa35edbd086b27357d8f048ede7c84dcc520748.zip
xntp 3.4e from Dave Mills @ UDel
Notes
Notes: svn path=/vendor/ntpd/dist/; revision=3215
-rw-r--r--usr.sbin/xntpd/COPYRIGHT10
-rw-r--r--usr.sbin/xntpd/Config.local96
-rw-r--r--usr.sbin/xntpd/Config.local.dist89
-rw-r--r--usr.sbin/xntpd/Makefile17
-rw-r--r--usr.sbin/xntpd/RELNOTES4
-rw-r--r--usr.sbin/xntpd/VERSION2
-rw-r--r--usr.sbin/xntpd/authstuff/Makefile.tmpl2
-rw-r--r--usr.sbin/xntpd/authstuff/auth.samplekeys1
-rw-r--r--usr.sbin/xntpd/authstuff/auth.speed33
-rw-r--r--usr.sbin/xntpd/authstuff/authcert.c55
-rw-r--r--usr.sbin/xntpd/authstuff/authspeed.c10
-rw-r--r--usr.sbin/xntpd/authstuff/keyparity.c20
-rw-r--r--usr.sbin/xntpd/authstuff/makeIPFP.c26
-rw-r--r--usr.sbin/xntpd/authstuff/makePC1.c30
-rw-r--r--usr.sbin/xntpd/authstuff/makePC2.c22
-rw-r--r--usr.sbin/xntpd/authstuff/makeSP.c14
-rw-r--r--usr.sbin/xntpd/authstuff/md5driver.c12
-rw-r--r--usr.sbin/xntpd/authstuff/mkrandkeys.c16
-rw-r--r--usr.sbin/xntpd/authstuff/omakeIPFP.c24
-rw-r--r--usr.sbin/xntpd/authstuff/unixcert.c2
-rw-r--r--usr.sbin/xntpd/conf/Config.HP-UX7
-rw-r--r--usr.sbin/xntpd/conf/Config.OSF17
-rw-r--r--usr.sbin/xntpd/conf/Config.SunOS7
-rw-r--r--usr.sbin/xntpd/conf/Config.ULTRIX7
-rw-r--r--usr.sbin/xntpd/conf/Config.VAX7
-rw-r--r--usr.sbin/xntpd/conf/Config.solaris7
-rw-r--r--usr.sbin/xntpd/conf/README3
-rw-r--r--usr.sbin/xntpd/conf/baldwin.conf40
-rw-r--r--usr.sbin/xntpd/conf/dewey.conf42
-rw-r--r--usr.sbin/xntpd/conf/grundoon.conf179
-rw-r--r--usr.sbin/xntpd/conf/maccarony.conf33
-rw-r--r--usr.sbin/xntpd/conf/malarky.conf35
-rw-r--r--usr.sbin/xntpd/conf/pogo.conf32
-rw-r--r--usr.sbin/xntpd/conf/rackety.conf30
-rw-r--r--usr.sbin/xntpd/doc/README.refclock1416
-rw-r--r--usr.sbin/xntpd/doc/acts.c878
-rw-r--r--usr.sbin/xntpd/doc/ntpq.8319
-rw-r--r--usr.sbin/xntpd/doc/xntpd.81622
-rw-r--r--usr.sbin/xntpd/doc/xntpdc.8557
-rw-r--r--usr.sbin/xntpd/include/README15
-rw-r--r--usr.sbin/xntpd/include/in.h256
-rw-r--r--usr.sbin/xntpd/include/l_stdlib.h66
-rw-r--r--usr.sbin/xntpd/include/md5.h2
-rw-r--r--usr.sbin/xntpd/include/mx4200.h2
-rw-r--r--usr.sbin/xntpd/include/ntp.h132
-rw-r--r--usr.sbin/xntpd/include/ntp_calendar.h10
-rw-r--r--usr.sbin/xntpd/include/ntp_control.h10
-rw-r--r--usr.sbin/xntpd/include/ntp_datum.h30
-rw-r--r--usr.sbin/xntpd/include/ntp_filegen.h6
-rw-r--r--usr.sbin/xntpd/include/ntp_fp.h13
-rw-r--r--usr.sbin/xntpd/include/ntp_if.h2
-rw-r--r--usr.sbin/xntpd/include/ntp_machine.h50
-rw-r--r--usr.sbin/xntpd/include/ntp_refclock.h226
-rw-r--r--usr.sbin/xntpd/include/ntp_request.h88
-rw-r--r--usr.sbin/xntpd/include/ntp_stdlib.h86
-rw-r--r--usr.sbin/xntpd/include/ntp_syslog.h2
-rw-r--r--usr.sbin/xntpd/include/ntp_types.h2
-rw-r--r--usr.sbin/xntpd/include/ntp_unixtime.h22
-rw-r--r--usr.sbin/xntpd/include/ntpd.h17
-rw-r--r--usr.sbin/xntpd/include/parse.h118
-rw-r--r--usr.sbin/xntpd/include/parse_conf.h8
-rw-r--r--usr.sbin/xntpd/include/sys/bsd_audioirig.h10
-rw-r--r--usr.sbin/xntpd/include/sys/chudefs.h2
-rw-r--r--usr.sbin/xntpd/include/sys/clkdefs.h15
-rw-r--r--usr.sbin/xntpd/include/sys/parsestreams.h8
-rw-r--r--usr.sbin/xntpd/include/sys/ppsclock.h1
-rw-r--r--usr.sbin/xntpd/include/sys/timex.h290
-rw-r--r--usr.sbin/xntpd/include/sys/tpro.h2
-rw-r--r--usr.sbin/xntpd/kernel/Makefile.tmpl25
-rw-r--r--usr.sbin/xntpd/kernel/chuinit.c76
-rw-r--r--usr.sbin/xntpd/kernel/clkinit.c76
-rw-r--r--usr.sbin/xntpd/kernel/tty_clk.c14
-rw-r--r--usr.sbin/xntpd/kernel/tty_clk_STREAMS.c1
-rw-r--r--usr.sbin/xntpd/lib/Makefile.tmpl2
-rw-r--r--usr.sbin/xntpd/lib/a_md512crypt.c9
-rw-r--r--usr.sbin/xntpd/lib/a_md5decrypt.c7
-rw-r--r--usr.sbin/xntpd/lib/a_md5encrypt.c7
-rw-r--r--usr.sbin/xntpd/lib/atoint.c10
-rw-r--r--usr.sbin/xntpd/lib/atolfp.c14
-rw-r--r--usr.sbin/xntpd/lib/atouint.c6
-rw-r--r--usr.sbin/xntpd/lib/auth12crypt.c8
-rw-r--r--usr.sbin/xntpd/lib/authdecrypt.c11
-rw-r--r--usr.sbin/xntpd/lib/authdes.c2
-rw-r--r--usr.sbin/xntpd/lib/authdes.c.export2
-rw-r--r--usr.sbin/xntpd/lib/authencrypt.c6
-rw-r--r--usr.sbin/xntpd/lib/authkeys.c31
-rw-r--r--usr.sbin/xntpd/lib/authparity.c2
-rw-r--r--usr.sbin/xntpd/lib/authreadkeys.c16
-rw-r--r--usr.sbin/xntpd/lib/authusekey.c4
-rw-r--r--usr.sbin/xntpd/lib/buftvtots.c40
-rw-r--r--usr.sbin/xntpd/lib/caljulian.c6
-rw-r--r--usr.sbin/xntpd/lib/calleapwhen.c18
-rw-r--r--usr.sbin/xntpd/lib/caltontp.c16
-rw-r--r--usr.sbin/xntpd/lib/calyearstart.c12
-rw-r--r--usr.sbin/xntpd/lib/clocktime.c26
-rw-r--r--usr.sbin/xntpd/lib/clocktypes.c80
-rw-r--r--usr.sbin/xntpd/lib/decodenetnum.c4
-rw-r--r--usr.sbin/xntpd/lib/dofptoa.c4
-rw-r--r--usr.sbin/xntpd/lib/dolfptoa.c55
-rw-r--r--usr.sbin/xntpd/lib/emalloc.c4
-rw-r--r--usr.sbin/xntpd/lib/fptoa.c2
-rw-r--r--usr.sbin/xntpd/lib/fptoms.c2
-rw-r--r--usr.sbin/xntpd/lib/getopt.c2
-rw-r--r--usr.sbin/xntpd/lib/gettstamp.c2
-rw-r--r--usr.sbin/xntpd/lib/hextoint.c6
-rw-r--r--usr.sbin/xntpd/lib/hextolfp.c6
-rw-r--r--usr.sbin/xntpd/lib/humandate.c8
-rw-r--r--usr.sbin/xntpd/lib/inttoa.c6
-rw-r--r--usr.sbin/xntpd/lib/lib_strbuf.c2
-rw-r--r--usr.sbin/xntpd/lib/lib_strbuf.h2
-rw-r--r--usr.sbin/xntpd/lib/machines.c18
-rw-r--r--usr.sbin/xntpd/lib/md5.c2
-rw-r--r--usr.sbin/xntpd/lib/mfptoa.c8
-rw-r--r--usr.sbin/xntpd/lib/mfptoms.c8
-rw-r--r--usr.sbin/xntpd/lib/modetoa.c2
-rw-r--r--usr.sbin/xntpd/lib/mstolfp.c2
-rw-r--r--usr.sbin/xntpd/lib/msutotsf.c6
-rw-r--r--usr.sbin/xntpd/lib/msyslog.c2
-rw-r--r--usr.sbin/xntpd/lib/netof.c9
-rw-r--r--usr.sbin/xntpd/lib/numtoa.c12
-rw-r--r--usr.sbin/xntpd/lib/numtohost.c2
-rw-r--r--usr.sbin/xntpd/lib/octtoint.c6
-rw-r--r--usr.sbin/xntpd/lib/prettydate.c18
-rw-r--r--usr.sbin/xntpd/lib/ranny.c40
-rw-r--r--usr.sbin/xntpd/lib/refnumtoa.c18
-rw-r--r--usr.sbin/xntpd/lib/systime.c36
-rw-r--r--usr.sbin/xntpd/lib/tsftomsu.c8
-rw-r--r--usr.sbin/xntpd/lib/tstotv.c8
-rw-r--r--usr.sbin/xntpd/lib/tvtoa.c6
-rw-r--r--usr.sbin/xntpd/lib/tvtots.c8
-rw-r--r--usr.sbin/xntpd/lib/uglydate.c14
-rw-r--r--usr.sbin/xntpd/lib/uinttoa.c6
-rw-r--r--usr.sbin/xntpd/lib/utvtoa.c6
-rw-r--r--usr.sbin/xntpd/ntpdate/Makefile.tmpl2
-rw-r--r--usr.sbin/xntpd/ntpdate/ntpdate.c118
-rw-r--r--usr.sbin/xntpd/ntpdate/ntpdate.h7
-rw-r--r--usr.sbin/xntpd/ntpq/Makefile.tmpl2
-rw-r--r--usr.sbin/xntpd/ntpq/ntpq.c154
-rw-r--r--usr.sbin/xntpd/ntpq/ntpq.h16
-rw-r--r--usr.sbin/xntpd/ntpq/ntpq_ops.c87
-rw-r--r--usr.sbin/xntpd/ntptrace/Makefile.tmpl2
-rw-r--r--usr.sbin/xntpd/ntptrace/ntptrace.c65
-rw-r--r--usr.sbin/xntpd/ntptrace/ntptrace.h2
-rw-r--r--usr.sbin/xntpd/parse/Makefile.kernel14
-rw-r--r--usr.sbin/xntpd/parse/Makefile.tmpl4
-rw-r--r--usr.sbin/xntpd/parse/README.new_clocks44
-rw-r--r--usr.sbin/xntpd/parse/clk_dcf7000.c19
-rw-r--r--usr.sbin/xntpd/parse/clk_meinberg.c29
-rw-r--r--usr.sbin/xntpd/parse/clk_rawdcf.c45
-rw-r--r--usr.sbin/xntpd/parse/clk_schmid.c30
-rw-r--r--usr.sbin/xntpd/parse/clk_trimtaip.c140
-rw-r--r--usr.sbin/xntpd/parse/clk_trimtsip.c471
-rw-r--r--usr.sbin/xntpd/parse/parse.c361
-rw-r--r--usr.sbin/xntpd/parse/parse_conf.c15
-rw-r--r--usr.sbin/xntpd/parse/parsesolaris.c61
-rw-r--r--usr.sbin/xntpd/parse/parsestreams.c61
-rw-r--r--usr.sbin/xntpd/parse/util/dcfd.c47
-rw-r--r--usr.sbin/xntpd/parse/util/parsetest.c34
-rw-r--r--usr.sbin/xntpd/parse/util/testdcf.c16
-rw-r--r--usr.sbin/xntpd/refclocks/rclk.DATUM22
-rw-r--r--usr.sbin/xntpd/refclocks/rclk.MOTO29
-rw-r--r--usr.sbin/xntpd/refclocks/rclk.NMEA23
-rw-r--r--usr.sbin/xntpd/refclocks/rclk.PARSE12
-rw-r--r--usr.sbin/xntpd/refclocks/rconfig15
-rwxr-xr-xusr.sbin/xntpd/scripts/Guess.sh8
-rwxr-xr-xusr.sbin/xntpd/scripts/install.sh2
-rw-r--r--usr.sbin/xntpd/util/Makefile.tmpl2
-rw-r--r--usr.sbin/xntpd/util/ntptime.c27
-rw-r--r--usr.sbin/xntpd/util/precision.c87
-rw-r--r--usr.sbin/xntpd/util/tickadj.c12
-rw-r--r--usr.sbin/xntpd/util/timetrim.c2
-rw-r--r--usr.sbin/xntpd/xntpd/Makefile.tmpl52
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_config.c882
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_control.c317
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_filegen.c32
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_intres.c21
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_io.c388
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_leap.c38
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_loopfilter.c1180
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_monitor.c130
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_peer.c68
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_proto.c1239
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_refclock.c1185
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_request.c400
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_restrict.c40
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_timer.c18
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_unixclock.c79
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_util.c149
-rw-r--r--usr.sbin/xntpd/xntpd/ntpd.c22
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_acts.c895
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_as2201.c986
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_atom.c499
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_chu.c777
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_conf.c95
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_datum.c871
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_goes.c1188
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_gpstm.c78
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_heath.c393
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_irig.c569
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_leitch.c64
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_local.c357
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_moto.c2
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_msfees.c135
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_mx4200.c72
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_new/refclock_datum.c593
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_new/refclock_gpstm.c999
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_new/refclock_leitch.c718
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_new/refclock_msfees.c1575
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_new/refclock_mx4200.c977
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_new/refclock_omega.c999
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_new/refclock_parse.c3617
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_nmea.c391
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_old/refclock_datum.c645
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_old/refclock_gpstm.c998
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_old/refclock_leitch.c709
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_old/refclock_msfees.c1575
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_old/refclock_mx4200.c1342
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_old/refclock_omega.c999
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_old/refclock_parse.c3605
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_omega.c70
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_parse.c344
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_pst.c1893
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_tpro.c501
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_trak.c1083
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_wwvb.c1121
-rw-r--r--usr.sbin/xntpd/xntpdc/Makefile.tmpl2
-rw-r--r--usr.sbin/xntpd/xntpdc/ntpdc.c98
-rw-r--r--usr.sbin/xntpd/xntpdc/ntpdc.h14
-rw-r--r--usr.sbin/xntpd/xntpdc/ntpdc_ops.c905
229 files changed, 35900 insertions, 13262 deletions
diff --git a/usr.sbin/xntpd/COPYRIGHT b/usr.sbin/xntpd/COPYRIGHT
index b9ce773f163a..b5d6282c2aa9 100644
--- a/usr.sbin/xntpd/COPYRIGHT
+++ b/usr.sbin/xntpd/COPYRIGHT
@@ -29,9 +29,9 @@
* 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)
+ * 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)
@@ -41,7 +41,7 @@
* 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,
- * and KSI/Odetics IRIG-B clock drivers; pps support)
+ * 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)
@@ -57,4 +57,6 @@
* 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)
*/
diff --git a/usr.sbin/xntpd/Config.local b/usr.sbin/xntpd/Config.local
index 22c12a36e90a..50bbe3a85f9e 100644
--- a/usr.sbin/xntpd/Config.local
+++ b/usr.sbin/xntpd/Config.local
@@ -27,15 +27,17 @@
# -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
+# reported via syslog() 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.
+# HAVE_BSD_TTYS for 4.3bsd compatibility.
+# Use HAVE_TERMIOS for POSIX (termios.h) without System V Streams.
+# 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
@@ -78,7 +80,7 @@ DEFS_OPT=-DDEBUG
# special distribution.
#
# Note: following line must always start with DEFS_LOCAL= $(DEFS_OPT)
-DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DKERNEL_PLL -DMCAST
+DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK #TEST -DPPSPPS -DKERNEL_PLL
#
# Radio clock support definitions (these only make sense if -DREFCLOCK
@@ -112,13 +114,10 @@ DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DKERNEL_PLL -DMCAST
# 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 -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 -DCHU for a special CHU receiver using an ordinary shortwave
# radio. This requires the chu_clk line discipline or chu_clk_STREAMS
@@ -127,62 +126,71 @@ DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DKERNEL_PLL -DMCAST
# 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 -DGPSTM for a Kinemetrics/TrueTime GPS-TM/TMD receiver. It
+# should work in all systems with a serial port.
#
-# 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 -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.
#
# 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 -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 -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.
+# 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 -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 -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 -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 -DTRAK for a 8810 GPS Receiver with Buffered RS-232-C Interface
+# Module. 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.
#
# 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.
+# under Ultrix 4.2a/3 and DEC # OSF/1 Alpha.
#
-CLOCKDEFS= -DLOCAL_CLOCK -DAS2201PPS -DCHUPPS -DGOES -DIRIG -DMX4200PPS -DOMEGA -DPSTCLK -DTPRO -DWWVBCLK -DLEITCH
+CLOCKDEFS= -DLOCAL_CLOCK #TEST -DAS2201PPS -DCHU -DATUM -DGOES -DGPSTM -DIRIG -DLEITCH -DMSFEES -DMX4200PPS -DOMEGA -DPST -DTPRO -TRAK -DWWVB -DPARSE -DPARSEPPS -DCLOCK_MEINBERG -DCLOCK_RAWDCF -DCLOCK_SCHMID -DCLOCK_DCF7000 -DCLOCK_TRIMSV6
#
# Directory into which binaries should be installed (default /usr/local)
diff --git a/usr.sbin/xntpd/Config.local.dist b/usr.sbin/xntpd/Config.local.dist
index 7e540a327b21..2f7386687d87 100644
--- a/usr.sbin/xntpd/Config.local.dist
+++ b/usr.sbin/xntpd/Config.local.dist
@@ -114,17 +114,10 @@ DEFS_LOCAL= $(DEFS_OPT) #GREEN -DREFCLOCK #TEST -DPPSPPS -DKERNEL_PLL
# by default when using the "make makeconfig" script and greenhorn
# configuraiton.
#
-# Define -DTRAK for a 8810 GPS Receiver with Buffered RS-232-C Interface
-# Module. The driver supports both the CLK and PPS modes. It should work
-# in all systems with a serial port.
-#
-# 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 -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 -DCHU for a special CHU receiver using an ordinary shortwave
# radio. This requires the chu_clk line discipline or chu_clk_STREAMS
@@ -133,25 +126,6 @@ DEFS_LOCAL= $(DEFS_OPT) #GREEN -DREFCLOCK #TEST -DPPSPPS -DKERNEL_PLL
# 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
@@ -161,37 +135,62 @@ DEFS_LOCAL= $(DEFS_OPT) #GREEN -DREFCLOCK #TEST -DPPSPPS -DKERNEL_PLL
# Define -DGPSTM for a Kinemetrics/TrueTime GPS-TM/TMD receiver. It
# should work in all systems with a serial port.
#
-# 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 -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.
#
# 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 -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 -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.
+# 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 -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 -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 -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 -DTRAK for a 8810 GPS Receiver with Buffered RS-232-C Interface
+# Module. 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.
#
# 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.
+# under Ultrix 4.2a/3 and DEC # OSF/1 Alpha.
#
-CLOCKDEFS= #GREEN -DLOCAL_CLOCK #TEST -DAS2201PPS -DCHU -DGOES -DIRIG -DMX4200PPS -DOMEGA -DPST -DPSTCLK -DTPRO -DWWVBCLK -DMSFEESPPS -DLEITCH -DPARSE -DPARSEPPS -DCLOCK_MEINBERG -DCLOCK_RAWDCF -DCLOCK_SCHMID -DCLOCK_DCF7000 -DCLOCK_TRIMSV6
+CLOCKDEFS= #GREEN -DLOCAL_CLOCK #TEST -DAS2201PPS -DCHU -DATUM -DGOES -DGPSTM -DIRIG -DLEITCH -DMSFEES -DMX4200PPS -DOMEGA -DPST -DTPRO -TRAK -DWWVB -DPARSE -DPARSEPPS -DCLOCK_MEINBERG -DCLOCK_RAWDCF -DCLOCK_SCHMID -DCLOCK_DCF7000 -DCLOCK_TRIMSV6
#
# Directory into which binaries should be installed (default /usr/local)
diff --git a/usr.sbin/xntpd/Makefile b/usr.sbin/xntpd/Makefile
index ba92f47bd4d2..b9b0e88f9d2d 100644
--- a/usr.sbin/xntpd/Makefile
+++ b/usr.sbin/xntpd/Makefile
@@ -62,7 +62,7 @@ CONF = Config
CONFL = $(CONF).local
CONFLD= $(CONFL).dist
TARGETS = xntpd/xntpd xntpdc/xntpdc ntpq/ntpq ntpdate/ntpdate \
- ntptrace/ntptrace xntpres/xntpres authstuff/authspeed util/tickadj
+ ntptrace/ntptrace authstuff/authspeed util/tickadj
OPTTARG = adjtime/adjtimed util/ntptime util/precision
REFCONF=
COMPRESSOR=compress
@@ -139,11 +139,6 @@ authstuff/authspeed: lib/libntp.a authstuff/Makefile FRC
@echo '###' creating AUTH utilities
@cd authstuff && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)"
-xntpres/xntpres: lib/libntp.a xntpres/Makefile FRC
- @echo
- @echo '###' creating XNTPRES utility
- @cd xntpres && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)"
-
util/tickadj: util/Makefile lib/libntp.a FRC
@echo
@echo '###' creating TICKADJ utility
@@ -216,8 +211,6 @@ clean: neat
@cd xntpd && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@
@echo '###' cleaning xntpdc
@cd xntpdc && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@
- @echo '###' cleaning xntpres
- @cd xntpres && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@
@echo '###' cleaning parse
@cd parse && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@
@@ -232,8 +225,6 @@ install: all
@cd ntptrace && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install
@echo installing from ntpdate
@cd ntpdate && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install
- @echo installing from xntpres
- @cd xntpres && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install
@echo installing from util
@cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install
@echo installing from parse
@@ -339,12 +330,6 @@ xntpdc/Makefile: xntpdc/Makefile.tmpl ${CONF}.sed
@sed -f ${CONF}.sed < $@.tmpl > $@
@echo '###' cleaning in xntpdc
@cd xntpdc && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean
-xntpres/Makefile: xntpres/Makefile.tmpl ${CONF}.sed
- @echo
- @echo '###' updating Makefile in xntpres
- @sed -f ${CONF}.sed < $@.tmpl > $@
- @echo '###' cleaning in xntpres
- @cd xntpres && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean
parse/util/Makefile: parse/util/Makefile.tmpl ${CONF}.sed
@echo
@echo '###' updating Makefile in parse/util
diff --git a/usr.sbin/xntpd/RELNOTES b/usr.sbin/xntpd/RELNOTES
index 411ef452195b..ab3aebe25bd1 100644
--- a/usr.sbin/xntpd/RELNOTES
+++ b/usr.sbin/xntpd/RELNOTES
@@ -112,7 +112,9 @@ 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.
+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)
diff --git a/usr.sbin/xntpd/VERSION b/usr.sbin/xntpd/VERSION
index c145b870451f..a51bf7747d66 100644
--- a/usr.sbin/xntpd/VERSION
+++ b/usr.sbin/xntpd/VERSION
@@ -1 +1 @@
-version=3.3s (beta multicast)
+version=3.4e (beta multicast)
diff --git a/usr.sbin/xntpd/authstuff/Makefile.tmpl b/usr.sbin/xntpd/authstuff/Makefile.tmpl
index 4c8ca57e2c0c..ccafc5b6b25f 100644
--- a/usr.sbin/xntpd/authstuff/Makefile.tmpl
+++ b/usr.sbin/xntpd/authstuff/Makefile.tmpl
@@ -1,5 +1,5 @@
#
-# Makefile.tmpl,v 3.1 1993/07/06 01:04:48 jbj Exp
+# Makefile.tmpl
#
PROGRAM= authcert authspeed md5
#
diff --git a/usr.sbin/xntpd/authstuff/auth.samplekeys b/usr.sbin/xntpd/authstuff/auth.samplekeys
index c46d283405f2..761c7c251a66 100644
--- a/usr.sbin/xntpd/authstuff/auth.samplekeys
+++ b/usr.sbin/xntpd/authstuff/auth.samplekeys
@@ -1,4 +1,3 @@
-# auth.samplekeys,v 3.1 1993/07/06 01:04:49 jbj Exp
#
# Sample key file, also used for testing.
#
diff --git a/usr.sbin/xntpd/authstuff/auth.speed b/usr.sbin/xntpd/authstuff/auth.speed
index b55f20cbd821..ccf89938e522 100644
--- a/usr.sbin/xntpd/authstuff/auth.speed
+++ b/usr.sbin/xntpd/authstuff/auth.speed
@@ -1,20 +1,33 @@
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
-HP9000/735 hpux9.0 na 30
-HP9000/730 hpux8.07(+OV) 16 55
-SGI Indigo R4000 19 48
-HP9000/720 hpux8.07 21 66
+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
+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
+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
-Sun4c/65 SS1+ pogo 72 159
+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 3100 sheol 98 214
DECstation 2100 circus 126 278
VAX 780 985 ?
+
+Updated 26 April 1994
+David L. Mills
+
diff --git a/usr.sbin/xntpd/authstuff/authcert.c b/usr.sbin/xntpd/authstuff/authcert.c
index 6f6e42c220c8..0f04d61b5f01 100644
--- a/usr.sbin/xntpd/authstuff/authcert.c
+++ b/usr.sbin/xntpd/authstuff/authcert.c
@@ -1,4 +1,4 @@
-/* authcert.c,v 3.1 1993/07/06 01:04:52 jbj Exp
+/*
* This file, and the certdata file, shamelessly stolen
* from Phil Karn's DES implementation.
*/
@@ -20,44 +20,44 @@ static void put8 P((U_LONG *));
void
main()
{
- U_LONG key[2], plain[2], cipher[2], answer[2];
+ U_LONG key[2], plain[2], cipher[2], answer[2], temp;
int i;
int test;
int fail;
- for(test=0;!feof(stdin);test++){
+ 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++)
+ for (i = 0; i < 2; i++)
cipher[i] = htonl(plain[i]);
DESauth_des(cipher, ekeys);
-
- for(i=0;i<2;i++)
- if(ntohl(cipher[i]) != answer[i])
+ for (i = 0; i < 2; i++) {
+ temp = ntohl(cipher[i]);
+ if (temp != answer[i])
break;
+ }
+
fail = 0;
- if(i != 2){
+ if (i != 2) {
printf(" Encrypt FAIL");
fail++;
}
DESauth_des(cipher, dkeys);
- for(i=0;i<2;i++)
- if(ntohl(cipher[i]) != plain[i])
+ for (i = 0; i < 2; i++) {
+ temp = ntohl(cipher[i]);
+ if (temp != plain[i])
break;
- if(i != 2){
+ }
+ if (i != 2) {
printf(" Decrypt FAIL");
fail++;
}
- if(fail == 0)
+ if (fail == 0)
printf(" OK");
printf("\n");
}
@@ -65,32 +65,31 @@ main()
static void
get8(lp)
-U_LONG *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))
+ 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);
+ l[i / 4] <<= 8;
+ l[i / 4] |= (U_LONG)(t & 0xff);
}
*lp = l[0];
- *(lp+1) = l[1];
+ *(lp + 1) = l[1];
}
static void
put8(lp)
-U_LONG *lp;
+ U_LONG *lp;
{
int i;
- for(i=0;i<2;i++){
- printf("%08x",*lp++);
- }
+ for(i = 0; i < 2; i++)
+ printf("%08lx", (u_long)(*lp++));
}
diff --git a/usr.sbin/xntpd/authstuff/authspeed.c b/usr.sbin/xntpd/authstuff/authspeed.c
index ecddbcd96ba1..a6362a85b768 100644
--- a/usr.sbin/xntpd/authstuff/authspeed.c
+++ b/usr.sbin/xntpd/authstuff/authspeed.c
@@ -1,5 +1,5 @@
-/* authspeed.c,v 3.1 1993/07/06 01:04:54 jbj Exp
- * authspeed - figure out how LONG it takes to do an NTP encryption
+/*
+ * 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)
@@ -38,7 +38,7 @@ struct rusage rstart, rend;
#endif
l_fp dummy1, dummy2;
-U_LONG dummy3;
+u_long dummy3;
U_LONG pkt[15];
@@ -299,8 +299,8 @@ subtime(tvs, tve, res)
struct timeval *tvs, *tve;
double *res;
{
- LONG sec;
- LONG usec;
+ long sec;
+ long usec;
sec = tve->tv_sec - tvs->tv_sec;
usec = tve->tv_usec - tvs->tv_usec;
diff --git a/usr.sbin/xntpd/authstuff/keyparity.c b/usr.sbin/xntpd/authstuff/keyparity.c
index 424fade71745..aed05d9c5ccb 100644
--- a/usr.sbin/xntpd/authstuff/keyparity.c
+++ b/usr.sbin/xntpd/authstuff/keyparity.c
@@ -1,4 +1,4 @@
-/* keyparity.c,v 3.1 1993/07/06 01:04:57 jbj Exp
+/*
* keyparity - add parity bits to key and/or change an ascii key to binary
*/
@@ -33,9 +33,9 @@ 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));
+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
@@ -48,7 +48,7 @@ char *argv[];
int c;
int errflg = 0;
int keytype;
- U_LONG key[2];
+ u_long key[2];
extern int ntp_optind;
extern char *ntp_optarg;
@@ -138,9 +138,9 @@ char *argv[];
*/
static int
parity(key)
- U_LONG *key;
+ u_long *key;
{
- U_LONG mask;
+ u_long mask;
int parity_err;
int bitcount;
int half;
@@ -193,7 +193,7 @@ static int
decodekey(keytype, str, key)
int keytype;
char *str;
- U_LONG *key;
+ u_long *key;
{
u_char keybytes[8];
char *cp;
@@ -225,7 +225,7 @@ decodekey(keytype, str, key)
if (xdigit == 0)
return 0;
key[i>>3] <<= 4;
- key[i>>3] |= (U_LONG)(xdigit - hex) & 0xf;
+ key[i>>3] |= (u_long)(xdigit - hex) & 0xf;
}
/*
@@ -265,7 +265,7 @@ decodekey(keytype, str, key)
*/
static void
output(key, ntpformat)
- U_LONG *key;
+ u_long *key;
int ntpformat;
{
int i;
diff --git a/usr.sbin/xntpd/authstuff/makeIPFP.c b/usr.sbin/xntpd/authstuff/makeIPFP.c
index 50b31f4f2513..8fabdb77de7c 100644
--- a/usr.sbin/xntpd/authstuff/makeIPFP.c
+++ b/usr.sbin/xntpd/authstuff/makeIPFP.c
@@ -1,4 +1,4 @@
-/* makeIPFP.c,v 3.1 1993/07/06 01:04:58 jbj Exp
+/*
* makeIPFP - make fast DES IP and FP tables
*/
@@ -9,13 +9,13 @@
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
-U_LONG IPL[256];
-U_LONG FPL[256];
+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 perm P((u_char *, u_char *, u_long *, u_long *));
static void doit P((void));
/*
@@ -138,11 +138,11 @@ static void
perm(databits, permtab, leftp, rightp)
u_char *databits;
u_char *permtab;
- U_LONG *leftp;
- U_LONG *rightp;
+ u_long *leftp;
+ u_long *rightp;
{
- register U_LONG left;
- register U_LONG right;
+ register u_long left;
+ register u_long right;
register u_char *PT;
register u_char *bits;
register int i;
@@ -175,8 +175,8 @@ static void
doit()
{
u_char bits[64];
- U_LONG left;
- U_LONG right;
+ u_long left;
+ u_long right;
int tabno;
int i;
int ind0, ind1, ind2, ind3;
@@ -190,7 +190,7 @@ doit()
* 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] = {");
+ printf("static u_long IP[256] = {");
for (tabno = 0; tabno < 4; tabno++) {
i = tabno * 8;
ind7 = IPLbits[i] - 1;
@@ -258,7 +258,7 @@ doit()
/*
* Next is the FP table, in big endian order
*/
- printf("#if BYTE_ORDER == LITTLE_ENDIAN\nstatic U_LONG FP[256] = {");
+ printf("#if BYTE_ORDER == LITTLE_ENDIAN\nstatic u_long FP[256] = {");
for (tabno = 3; tabno >= 0; tabno--) {
i = tabno * 8;
ind7 = FPLbits[i] - 1;
@@ -327,7 +327,7 @@ doit()
* Now reouput the FP table in order appropriate for little
* endian machines
*/
- printf("#else\nstatic U_LONG FP[256] = {");
+ printf("#else\nstatic u_long FP[256] = {");
for (octbits = 0; octbits < 256; octbits++) {
left = ((FPL[octbits] >> 24) & 0x000000ff)
| ((FPL[octbits] >> 8) & 0x0000ff00)
diff --git a/usr.sbin/xntpd/authstuff/makePC1.c b/usr.sbin/xntpd/authstuff/makePC1.c
index 337353c1516b..8a49ec902e94 100644
--- a/usr.sbin/xntpd/authstuff/makePC1.c
+++ b/usr.sbin/xntpd/authstuff/makePC1.c
@@ -1,4 +1,4 @@
-/* makePC1.c,v 3.1 1993/07/06 01:04:59 jbj Exp
+/*
* makePC1 - build custom permutted choice 1 tables
*/
@@ -12,7 +12,7 @@
char *progname;
int debug;
-static void permute P((u_char *, U_LONG *, U_LONG *));
+static void permute P((u_char *, u_long *, u_long *));
static void doit P((void));
/*
@@ -74,11 +74,11 @@ static u_char PC1_D[28] = {
static void
permute(bits, cp, dp)
u_char *bits;
- U_LONG *cp;
- U_LONG *dp;
+ u_long *cp;
+ u_long *dp;
{
register int i;
- register U_LONG mask;
+ register u_long mask;
u_char c[28];
u_char d[28];
@@ -122,10 +122,10 @@ static int rc4[4] = { 32, 40, 48, 56 };
*/
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];
+static u_long PC_CL[8];
+static u_long PC_DL[16];
+static u_long PC_CR[16];
+static u_long PC_DR[8];
/*
@@ -136,13 +136,13 @@ doit()
{
int i;
int comb;
- U_LONG c;
- U_LONG d;
+ u_long c;
+ u_long d;
u_char bits[64];
memset((char *)bits, 0, sizeof bits);
- printf("static U_LONG PC1_CL[8] = {");
+ printf("static u_long PC1_CL[8] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 8; comb++) {
if (comb & 0x4)
@@ -176,7 +176,7 @@ doit()
}
}
- printf("static U_LONG PC1_DL[16] = {");
+ printf("static u_long PC1_DL[16] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 16; comb++) {
if (comb & 0x8)
@@ -213,7 +213,7 @@ doit()
}
}
- printf("static U_LONG PC1_CR[16] = {");
+ printf("static u_long PC1_CR[16] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 16; comb++) {
if (comb & 0x8)
@@ -250,7 +250,7 @@ doit()
}
}
- printf("static U_LONG PC1_DR[8] = {");
+ printf("static u_long PC1_DR[8] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 8; comb++) {
if (comb & 0x4)
diff --git a/usr.sbin/xntpd/authstuff/makePC2.c b/usr.sbin/xntpd/authstuff/makePC2.c
index 9795b6215a20..e5121fd08364 100644
--- a/usr.sbin/xntpd/authstuff/makePC2.c
+++ b/usr.sbin/xntpd/authstuff/makePC2.c
@@ -1,4 +1,4 @@
-/* makePC2.c,v 3.1 1993/07/06 01:05:01 jbj Exp
+/*
* makePC2 - build custom permutted choice 2 tables
*/
@@ -12,8 +12,8 @@
char *progname;
int debug;
-static void permc P((u_char *, U_LONG *));
-static void permd P((u_char *, U_LONG *));
+static void permc P((u_char *, u_long *));
+static void permd P((u_char *, u_long *));
static void doit P((void));
/*
@@ -71,7 +71,7 @@ static u_char PC2_D[24] = {
17, 13, 21, 7, 0, 3
};
-U_LONG masks[4] = { 0x40000000, 0x400000, 0x4000, 0x40 };
+u_long masks[4] = { 0x40000000, 0x400000, 0x4000, 0x40 };
/*
@@ -80,11 +80,11 @@ U_LONG masks[4] = { 0x40000000, 0x400000, 0x4000, 0x40 };
static void
permc(bits, resp)
u_char *bits;
- U_LONG *resp;
+ u_long *resp;
{
register int part;
register int i;
- register U_LONG mask;
+ register u_long mask;
u_char res[24];
memset((char *)res, 0, sizeof res);
@@ -110,11 +110,11 @@ permc(bits, resp)
static void
permd(bits, resp)
u_char *bits;
- U_LONG *resp;
+ u_long *resp;
{
register int part;
register int i;
- register U_LONG mask;
+ register u_long mask;
u_char res[24];
memset((char *)res, 0, sizeof res);
@@ -165,12 +165,12 @@ doit()
{
int i;
int comb;
- U_LONG res;
+ u_long res;
u_char bits[28];
memset((char *)bits, 0, sizeof bits);
- printf("static U_LONG PC2_C[4][64] = {");
+ printf("static u_long PC2_C[4][64] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 64; comb++) {
if (comb & 0x20)
@@ -203,7 +203,7 @@ doit()
}
}
- printf("static U_LONG PC2_D[4][64] = {");
+ printf("static u_long PC2_D[4][64] = {");
for (i = 0; i < 4; i++) {
for (comb = 0; comb < 64; comb++) {
if (comb & 0x20)
diff --git a/usr.sbin/xntpd/authstuff/makeSP.c b/usr.sbin/xntpd/authstuff/makeSP.c
index 7bfd93e2cbd6..4fcd78c35e3a 100644
--- a/usr.sbin/xntpd/authstuff/makeSP.c
+++ b/usr.sbin/xntpd/authstuff/makeSP.c
@@ -1,4 +1,4 @@
-/* makeSP.c,v 3.1 1993/07/06 01:05:02 jbj Exp
+/*
* makeSP - build combination S and P tables for quick DES computation
*/
@@ -12,7 +12,7 @@
char *progname;
int debug;
-static void selperm P((int, int, U_LONG *));
+static void selperm P((int, int, u_long *));
static void doit P((void));
/*
@@ -116,15 +116,15 @@ u_char bits[32];
/*
* selperm - run six bit data through the given selection table, then
- * through the PT table to produce a LONG output.
+ * through the PT table to produce a long output.
*/
static void
selperm(selnumber, sixbits, resp)
int selnumber;
int sixbits;
- U_LONG *resp;
+ u_long *resp;
{
- register U_LONG res;
+ register u_long res;
register int selno;
register int i;
register int ind;
@@ -162,11 +162,11 @@ static void
doit()
{
int selno;
- U_LONG result;
+ u_long result;
int sixbits;
memset((char *)bits, 0, sizeof bits);
- printf("static U_LONG SP[8][64] = {");
+ printf("static u_long SP[8][64] = {");
for (selno = 0; selno < 8; selno++) {
for (sixbits = 0; sixbits < 64; sixbits++) {
selperm(selno, sixbits, &result);
diff --git a/usr.sbin/xntpd/authstuff/md5driver.c b/usr.sbin/xntpd/authstuff/md5driver.c
index a608add35f4a..0d7e13254f14 100644
--- a/usr.sbin/xntpd/authstuff/md5driver.c
+++ b/usr.sbin/xntpd/authstuff/md5driver.c
@@ -1,4 +1,4 @@
-/* md5driver.c,v 3.1 1993/07/06 01:05:07 jbj Exp
+/*
***********************************************************************
** md5driver.c -- sample test routines **
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
@@ -25,7 +25,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
-#ifdef SYS_BSDI
+#if defined(SYS_BSDI) || defined(SYS_44BSD)
#include <sys/time.h>
#endif /* SYS_BSDI */
#include "md5.h"
@@ -57,7 +57,7 @@ MD5_CTX *mdContext;
#define TEST_BLOCKS 10000
/* number of test bytes = TEST_BLOCK_SIZE * TEST_BLOCKS */
-static LONG TEST_BYTES = (LONG)TEST_BLOCK_SIZE * (LONG)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
@@ -76,7 +76,7 @@ MDTimeTrial ()
data[i] = (unsigned char)(i & 0xFF);
/* start timer */
- printf ("MD5 time trial. Processing %ld characters...\n", TEST_BYTES);
+ printf ("MD5 time trial. Processing %ld characters...\n", (long)TEST_BYTES);
time (&startTime);
/* digest data in TEST_BLOCK_SIZE byte blocks */
@@ -90,10 +90,10 @@ MDTimeTrial ()
MDPrint (&mdContext);
printf (" is digest of test input.\n");
printf
- ("Seconds to process test input: %ld\n", (LONG)(endTime-startTime));
+ ("Seconds to process test input: %ld\n", (long)endTime-startTime);
printf
("Characters processed per second: %ld\n",
- TEST_BYTES/(endTime-startTime));
+ (long)(TEST_BYTES/(endTime-startTime)));
}
/* Computes the message digest for string inString.
diff --git a/usr.sbin/xntpd/authstuff/mkrandkeys.c b/usr.sbin/xntpd/authstuff/mkrandkeys.c
index 454b3418bbb1..0edf733ac6a4 100644
--- a/usr.sbin/xntpd/authstuff/mkrandkeys.c
+++ b/usr.sbin/xntpd/authstuff/mkrandkeys.c
@@ -1,4 +1,4 @@
-/* mkrandkeys.c,v 3.1 1993/07/06 01:05:08 jbj Exp
+/*
* mkrandkeys - make a key file for xntpd with some quite random keys
*/
#include <stdio.h>
@@ -12,12 +12,12 @@
char *progname;
int debug;
-U_LONG keydata[2];
+u_long keydata[2];
int std = 1; /* DES standard key format */
u_char dokey[16] = { 0 };
-static void rand_data P((U_LONG *));
+static void rand_data P((u_long *));
/*
* main - parse arguments and handle options
@@ -32,7 +32,7 @@ char *argv[];
int j;
int errflg = 0;
int numkeys;
- U_LONG tmp;
+ u_long tmp;
char *passwd;
extern int ntp_optind;
extern char *ntp_optarg;
@@ -89,7 +89,7 @@ char *argv[];
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)));
+ keydata[i/4] |= ((((u_long)(*passwd))&0xff)<<(1+((3-(i%4))*8)));
passwd++;
}
@@ -139,18 +139,18 @@ char *volatile_file[] = {
static void
rand_data(data)
- U_LONG *data;
+ u_long *data;
{
register i;
struct stat buf;
- extern LONG time();
+ 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));
+ *(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)
diff --git a/usr.sbin/xntpd/authstuff/omakeIPFP.c b/usr.sbin/xntpd/authstuff/omakeIPFP.c
index 0751a5d96b9c..92d87be30ba0 100644
--- a/usr.sbin/xntpd/authstuff/omakeIPFP.c
+++ b/usr.sbin/xntpd/authstuff/omakeIPFP.c
@@ -1,4 +1,4 @@
-/* omakeIPFP.c,v 3.1 1993/07/06 01:05:10 jbj Exp
+/*
* makeIPFP - make fast DES IP and FP tables
*
* This is an older version which generated tables half the size of
@@ -15,13 +15,13 @@
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
-U_LONG IPL[8][16];
-U_LONG FPL[8][16];
+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 perm P((u_char *, u_char *, u_long *, u_long *));
static void doit P((void));
/*
@@ -144,11 +144,11 @@ static void
perm(databits, permtab, leftp, rightp)
u_char *databits;
u_char *permtab;
- U_LONG *leftp;
- U_LONG *rightp;
+ u_long *leftp;
+ u_long *rightp;
{
- register U_LONG left;
- register U_LONG right;
+ register u_long left;
+ register u_long right;
register u_char *PT;
register u_char *bits;
register int i;
@@ -181,8 +181,8 @@ static void
doit()
{
u_char bits[64];
- U_LONG left;
- U_LONG right;
+ u_long left;
+ u_long right;
int tabno;
int i;
int ind0, ind1, ind2, ind3;
@@ -195,7 +195,7 @@ doit()
* this as well as printing them. Note that this is the
* left-half table.
*/
- printf("static U_LONG IP[8][16] = {");
+ printf("static u_long IP[8][16] = {");
for (tabno = 0; tabno < 8; tabno++) {
i = tabno * 4;
ind3 = IPLbits[i] - 1;
@@ -279,7 +279,7 @@ doit()
/*
* Next are the FP tables
*/
- printf("static U_LONG FP[8][16] = {");
+ printf("static u_long FP[8][16] = {");
for (tabno = 0; tabno < 8; tabno++) {
i = tabno * 4;
ind3 = FPLbits[i] - 1;
diff --git a/usr.sbin/xntpd/authstuff/unixcert.c b/usr.sbin/xntpd/authstuff/unixcert.c
index 36234b13f55f..47c76f6fa93c 100644
--- a/usr.sbin/xntpd/authstuff/unixcert.c
+++ b/usr.sbin/xntpd/authstuff/unixcert.c
@@ -1,4 +1,4 @@
-/* unixcert.c,v 3.1 1993/07/06 01:05:14 jbj Exp
+/*
* This file, and the certdata file, shamelessly stolen
* from Phil Karn's DES implementation.
*
diff --git a/usr.sbin/xntpd/conf/Config.HP-UX b/usr.sbin/xntpd/conf/Config.HP-UX
new file mode 100644
index 000000000000..ef4fa302cb2c
--- /dev/null
+++ b/usr.sbin/xntpd/conf/Config.HP-UX
@@ -0,0 +1,7 @@
+#
+# 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
diff --git a/usr.sbin/xntpd/conf/Config.OSF1 b/usr.sbin/xntpd/conf/Config.OSF1
new file mode 100644
index 000000000000..f460e9f934a7
--- /dev/null
+++ b/usr.sbin/xntpd/conf/Config.OSF1
@@ -0,0 +1,7 @@
+#
+# 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
diff --git a/usr.sbin/xntpd/conf/Config.SunOS b/usr.sbin/xntpd/conf/Config.SunOS
new file mode 100644
index 000000000000..42fd1a5cee6f
--- /dev/null
+++ b/usr.sbin/xntpd/conf/Config.SunOS
@@ -0,0 +1,7 @@
+#
+# 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
diff --git a/usr.sbin/xntpd/conf/Config.ULTRIX b/usr.sbin/xntpd/conf/Config.ULTRIX
new file mode 100644
index 000000000000..4ead1be017a0
--- /dev/null
+++ b/usr.sbin/xntpd/conf/Config.ULTRIX
@@ -0,0 +1,7 @@
+#
+# 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
diff --git a/usr.sbin/xntpd/conf/Config.VAX b/usr.sbin/xntpd/conf/Config.VAX
new file mode 100644
index 000000000000..66b9f91007bd
--- /dev/null
+++ b/usr.sbin/xntpd/conf/Config.VAX
@@ -0,0 +1,7 @@
+#
+# 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
diff --git a/usr.sbin/xntpd/conf/Config.solaris b/usr.sbin/xntpd/conf/Config.solaris
new file mode 100644
index 000000000000..5db3cd0b050c
--- /dev/null
+++ b/usr.sbin/xntpd/conf/Config.solaris
@@ -0,0 +1,7 @@
+#
+# 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
diff --git a/usr.sbin/xntpd/conf/README b/usr.sbin/xntpd/conf/README
index 19dcb795f80c..8d075916daf8 100644
--- a/usr.sbin/xntpd/conf/README
+++ b/usr.sbin/xntpd/conf/README
@@ -6,3 +6,6 @@ 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.
diff --git a/usr.sbin/xntpd/conf/baldwin.conf b/usr.sbin/xntpd/conf/baldwin.conf
new file mode 100644
index 000000000000..baaac95437cd
--- /dev/null
+++ b/usr.sbin/xntpd/conf/baldwin.conf
@@ -0,0 +1,40 @@
+#
+# 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)
+
diff --git a/usr.sbin/xntpd/conf/dewey.conf b/usr.sbin/xntpd/conf/dewey.conf
index 523008fcdc82..2a7548c8151e 100644
--- a/usr.sbin/xntpd/conf/dewey.conf
+++ b/usr.sbin/xntpd/conf/dewey.conf
@@ -1,38 +1,46 @@
#
# NTP configuration file (ntp.conf)
-# dewey.udel.edu (128.175.1.2)
#
-# Stratum-1 peers
+# 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.4.1.5 # dcn5.udel.edu
#peer 128.8.10.1 # umd1.umd.edu
#peer 18.72.0.3 version 2 # bitsy.mit.edu
-peer 192.43.244.9 # ncar-fuzz.nsf.net
-peer 132.249.16.1 # sdsc-fuzz.nsf.net
+peer 132.249.16.1 # fuzz.sdsc.edu
peer 128.118.46.3 version 2 # otc1.psu.edu
-#peer 130.126.174.40 # truechimer.cso.uiuc.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
+# Stratum-2 peers. Each server should chime all of the others in this
+# list except itself.
#
-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
+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
#
-monitor yes # enable monitoring
-precision -7 # clock reading precision (10 msec)
-driftfile /etc/ntp.drift # path for drift file
+enable auth monitor # enable the good stuff
+driftfile /etc/ntp.drift # path for drift file
#
-# Authentication stuff
+# 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 11/780)
+authdelay 0.001501 # authentication delay (VAX)
+#authdelay 0.000073 # authentication delay (SPARC)
diff --git a/usr.sbin/xntpd/conf/grundoon.conf b/usr.sbin/xntpd/conf/grundoon.conf
index c5aef6eb88e3..16003d59237b 100644
--- a/usr.sbin/xntpd/conf/grundoon.conf
+++ b/usr.sbin/xntpd/conf/grundoon.conf
@@ -2,43 +2,144 @@
# NTP configuration file (ntp.conf)
# grundoon.udel.edu (128.4.2.7)
#
-server 127.127.6.0 prefer # irig audio decoder
-fudge 127.127.6.0 time1 0.0005
-#pps delay -0.0004 # pps correction for CLK streams module
-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 flag4 1
-server 127.127.3.1 # pst/traconex 1020 wwv/h receiver
-# propagation delay: wwv 0.0088 wwvh 0.0281; receiver+os delay 0.0035
-fudge 127.127.3.1 time1 0.0123 time2 0.0316
-server 127.127.7.1 # scratchbuilt chu receiver/demodulator
-# propagtion delay: chu 0.0030; receiver+os delay 0.0060
-fudge 127.127.7.1 time1 0.0030 time2 0.0060
-#server 127.127.10.1 # austron 2201 gps receiver
-
-server 127.127.1.2 # local clock
-#server 127.127.12.2 # ksi/odetics tpr0-s irig-b reader
-
-#broadcast 128.4.2.255
-
-peer 128.4.1.1 key 3 # rackety.udel.edu (Sun4c/40 IPC)
-peer 128.4.1.4 # barnstable.udel.edu (Sun4c/65 SS1+)
-#peer 128.4.1.5 # churchy.udel.edu (Bancomm bc700LAN)
-#peer 128.4.2.7 key 3 # grundoon.udel.edu (Sun4c/40 IPC)
-peer 128.4.1.8 # bridgeport.udel.edu (Sun4c/40 IPC)
-peer 128.4.1.20 key 3 # pogo.udel.edu (Sun4c/65 SS1+)
-peer 128.4.1.22 # malarky.udel.edu (Sun4c/50 IPX)
-peer 128.4.1.23 # beauregard.udel.edu (Sun4/40 IPC)
-peer 128.4.1.24 # baldwin.udel.edu (Sun4/40 IPC)
-peer 128.4.1.25 # albert.udel.edu (Sun4c/60 SS1)
-peer 128.4.1.27 # bunnylou.udel.edu (Sun4c/40 IPC)
-peer 128.4.1.28 # cowbird.udel.edu (DEC 5000/240)
-peer 128.4.1.29 # porkypine.udel.edu (DEC 5000/240)
-#
-# Miscellaneous stuff
-#
-monitor yes # enable monitoring
-precision -18 # clock reading precision (usec)
+# 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
@@ -48,11 +149,9 @@ filegen clockstats file clockstats type day enable
#
# Authentication stuff
#
-authenticate yes # enable authentication
keys /usr/local/ntp.keys # path for keys file
-trustedkey 1 2 3 4 14 15 # define trusted keys
+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.000073 # authentication delay (SPARC4c/40 IPC DES)
authdelay 0.000163 # authentication delay (SPARC4c/40 IPC MD5)
diff --git a/usr.sbin/xntpd/conf/maccarony.conf b/usr.sbin/xntpd/conf/maccarony.conf
new file mode 100644
index 000000000000..6bd25c73ec11
--- /dev/null
+++ b/usr.sbin/xntpd/conf/maccarony.conf
@@ -0,0 +1,33 @@
+#
+# 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)
+
diff --git a/usr.sbin/xntpd/conf/malarky.conf b/usr.sbin/xntpd/conf/malarky.conf
index f887f839d1bb..9b1d7b2317e1 100644
--- a/usr.sbin/xntpd/conf/malarky.conf
+++ b/usr.sbin/xntpd/conf/malarky.conf
@@ -1,26 +1,16 @@
#
# NTP configuration file (ntp.conf)
-# malarky.udel.edu (128.4.1.22)
-#
-peer 128.4.1.1 # rackety.udel.edu
-peer 128.4.1.4 # barnstable.udel.edu
-#peer 128.4.1.5 #churchy.udel.edu
-peer 128.4.2.7 # grundoon.udel.edu
-peer 128.4.1.8 # bridgeport.udel.edu
-peer 128.4.1.20 prefer # pogo.udel.edu
-#peer 128.4.1.22 # malarky.udel.edu
-peer 128.4.1.23 # beauregard.udel.edu
-peer 128.4.1.24 # baldwin.udel.edu
-peer 128.4.1.25 # albert.udel.edu
-peer 128.4.1.27 # bunnylou.udel.edu
-peer 128.4.1.28 # cowbird.udel.edu
-peer 128.4.1.29 # porkypine.udel.edu
-
+#
+# 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
#
-monitor yes # enable monitoring
-precision -18 # clock reading precision (usec)
+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
@@ -30,11 +20,8 @@ filegen clockstats file clockstats type day enable
#
# Authentication stuff
#
-authenticate yes # enable authentication
keys /usr/local/bin/ntp.keys # path for key file
-trustedkey 1 2 3 4 14 15 # define trusted keys
-requestkey 15 # key (7) for accessing server variables
-controlkey 15 # key (6) for accessing server variables
-#authdelay 0.000047 # authentication delay (Sun4c/50 IPX DES)
+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)
-
diff --git a/usr.sbin/xntpd/conf/pogo.conf b/usr.sbin/xntpd/conf/pogo.conf
index 94ac6c84ea28..e557e44740a5 100644
--- a/usr.sbin/xntpd/conf/pogo.conf
+++ b/usr.sbin/xntpd/conf/pogo.conf
@@ -2,34 +2,21 @@
# NTP configuration file (ntp.conf)
# pogo.udel.edu (128.4.1.20)
#
-server 127.127.10.1 prefer # austron 2201 gps receiver
-#server 127.127.4.1 # spectracom 8170/netclock-2 wwvb receiver
-# propagation delay: wwvb 0.0088; receiver delay 0.0017
-#fudge 127.127.4.1 time1 0.0017
-
-peer 128.4.1.1 key 3 # rackety.udel.edu (Sun4c/40 IPC)
-peer 128.4.1.2 # mizbeaver.udel.edu
+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 # churchy.udel.edu (Bancomm bc700LAN)
-peer 128.4.2.7 key 3 # grundoon.udel.edu (Sun4c/40 IPC)
peer 128.4.1.5 maxpoll 8 # churchy.udel.edu (cisco IGS router)
-#peer 128.4.1.8 # bridgeport.udel.edu (Sun4c/40 IPC)
-#peer 128.4.1.20 key 3 # pogo.udel.edu (Sun4c/65 SS1+)
-#peer 128.4.1.22 # malarky.udel.edu (Sun4c/50 IPX)
-#peer 128.4.1.23 # beauregard.udel.edu (Sun4/40 IPC)
-peer 128.4.1.24 # baldwin.udel.edu (Sun4/40 IPC)
-#peer 128.4.1.25 # albert.udel.edu (Sun4c/60 SS1)
-#peer 128.4.1.27 # maccarony.udel.edu (Sun4c/40 IPC)
-peer 128.4.1.29 # porkypine.udel.edu
-peer 132.163.135.130 maxpoll 8 # time_A.timefreq.bldrdoc.gov (ACTS)
+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 (OMEGA)
+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
#
-monitor yes # enable monitoring
+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
@@ -40,11 +27,8 @@ filegen clockstats file clockstats type day enable
#
# Authentication stuff
#
-authenticate yes # enable authentication
keys /usr/local/bin/ntp.keys # path for keys file
-trustedkey 1 2 3 4 14 15 # define trusted keys
+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.000072 # authentication delay (SPARC4c/65 SS1+ DES)
authdelay 0.000159 # authentication delay (SPARC4c/65 SS1+ MD5)
-
diff --git a/usr.sbin/xntpd/conf/rackety.conf b/usr.sbin/xntpd/conf/rackety.conf
index 1a5181cd4b5c..48389dcb4529 100644
--- a/usr.sbin/xntpd/conf/rackety.conf
+++ b/usr.sbin/xntpd/conf/rackety.conf
@@ -2,11 +2,11 @@
# NTP configuration file (ntp.conf)
# rackety (128.4.1.1)
#
-server 127.127.10.1 prefer # austron 2201 gps receiver
+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.0017
-fudge 127.127.4.1 time1 0.0017 value1 2
+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
@@ -18,10 +18,11 @@ 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.5 # churchy.udel.edu
-peer 128.4.2.7 key 3 # grundoon.udel.edu
-peer 128.4.1.20 key 3 # pogo.udel.edu
+peer 128.4.1.4 # barnstable.udel.edu
+peer 128.4.1.20 # pogo.udel.edu
#
# dartnet
@@ -47,14 +48,9 @@ server 140.222.141.1 version 2 # enss141 (boulder - ncar)
server 140.222.144.1 version 2 # enss144 (sunnyvale - nasa ames)
#
-# famous players
-#
-#peer 132.163.135.130 # time_A.timefreq.bldrdoc.gov
-
-#
# Miscellaneous stuff
#
-monitor yes # enable monitoring
+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
@@ -65,11 +61,9 @@ filegen clockstats file clockstats type day enable
#
# Authentication stuff
#
-authenticate yes # enable authentication
keys /usr/local/bin/ntp.keys # path for keys file
-trustedkey 1 2 3 4 14 15 # define trusted keys
-requestkey 15 # key (7) for accessing server variables
-controlkey 15 # key (6) for accessing server variables
-#authdelay 0.000073 # authentication delay (SPARC4c/40 IPC DES)
+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)
diff --git a/usr.sbin/xntpd/doc/README.refclock b/usr.sbin/xntpd/doc/README.refclock
new file mode 100644
index 000000000000..1b9a51034b6b
--- /dev/null
+++ b/usr.sbin/xntpd/doc/README.refclock
@@ -0,0 +1,1416 @@
+ Information on Reference Clock Drivers
+
+ Revised 5 August 1994
+
+Support for most of the commonly available radio clocks is included in
+the default configuration of xntpd. Individual clocks can be activated
+by configuration file commands, specifically the server and fudge
+commands described in the xntpd.8 man page. This file contains
+information useful in configuring and operating these clocks. Note that
+the man pages and documentation files mentioned in this note can be
+found in the ./doc directory of the xntp3 distribution.
+
+Radio clocks by convention have addresses in the form 127.127.t.u, where
+"t" is the clock type and "u" is a unit number in the range 0-3 used to
+distinguish multiple instances of clocks of the same type. Most of these
+clocks require support in the form of a serial port or special bus
+peripheral. The particular device is normally specified by adding a soft
+link /dev/device%d to the particular hardware device involved. The name
+"device" is compiled in the driver according to the table below. The
+table shows the type number, device name, short description used in some
+displays, and long description used in other displays.
+
+Type Device Name Description
+-------------------------------------------------------
+1 (none) LOCAL Undisciplined Local Clock
+2 trak GPS_TRAK TRAK 8820 GPS Receiver
+3 pst WWV_PST PSTI/Traconex WWV/WWVH Receiver
+4 wwvb WWVB_SPEC Spectracom WWVB Receiver
+5 goes GPS_GOES_TRUE TrueTime GPS/GOES Receivers
+6 irig IRIG_AUDIO IRIG Audio Decoder
+7 chu CHU Scratchbuilt CHU Receiver
+8 refclock- GENERIC Generic Reference Clock Driver
+9 gps GPS_MX4200 Magnavox MX4200 GPS Receiver
+10 gps GPS_AS2201 Austron 2201A GPS Receiver
+11 omega OMEGA_TRUE TrueTime OM-DC OMEGA Receiver
+12 tpro IRIG_TPRO KSI/Odetics TPRO/S IRIG Interface
+13 leitch ATOM_LEITCH Leitch CSD 5300 Master Clock Controller
+14 ees MSF_EES EES M201 MSF Receiver
+15 gpstm GPS_TRUE TrueTime GPS/TM-TMD Receiver
+16 * GPS_BANC Bancomm GPS/IRIG Receiver
+17 datum GPS_DATUM Datum Precision Time System
+18 acts NIST_ACTS NIST Automated Computer Time Service
+19 heath WWV_HEATH Heath WWV/WWVH Receiver
+20 nmea GPS_NMEA Generic NMEA GPS Receiver
+21 * GPS_MOTO Motorola Six Gun GPS Receiver
+22 pps ATOM_PPS PPS Clock Discipline
+
+* Not yet available.
+
+A radio clock is specified in the configuration using the server command
+
+ server 127.127.t.u [ prefer ] [ mode m ]
+
+where t is the type number above and u can be in the range 0-3,
+conventionally 1. Ordinarily, this is the only command necessary to
+configure a radio clock. The optional prefer keyword can be used to
+modify the clock selection algorithm as described in Appendix B. For
+those clock drivers that support multiple modes of operation, the
+optional mode parameter selects which one. This parameter affects the
+operation of each driver as described in Appendix A.
+
+In rare cases a fudge command is necessary to specify additional
+details. This command has the following syntax
+
+fudge 127.127.t.u [stratum s] [refid r] [time1 t1] [time2 t2] [flags]
+and must follow the corresponding server command in the configuration
+file. The optional fields following the clock address are interpreted as
+follows:
+
+stratum s The s, a decimal number in the range 0-15, overrides the
+ default stratum assigned by the driver.
+
+refid r The r, a 4-character, null-terminated ASCII string, overrides
+ the reference identifier assigned by the driver.
+
+time1 t1 The t1, a fixed-point decimal number in seconds, specifies a
+ constant to be added to the time offset produced by the
+ driver. This provides a way to correct a systematic error or
+ bias on the part of the particular clock.
+
+time2 t2 The t2, a fixed-point decimal number, is interpreted in a
+ driver-dependent way. See the descriptions of specific clock
+ drivers in Appendix A.
+
+There are four optional flags named flag1, flag2, flag3 and flag4. A
+flag is specified in the form <keyword> <value>, where <keyword> is one
+of the flag names and <value> is either 0 or 1, as appropriate. Two of
+the flags are generic and are interpreted by all applicable drivers, and
+two are driver dependent. The generic ones are as follows:
+
+flag4 This flag is used to enable detailed status monitoring and
+ event recording. The data collected are written to the
+ clockstats file maintained by the filegen utility (See the
+ xntpd.8 man page). This file is normally processed by a cron
+ job run once per day to produce summary statistics and
+ performance data. The ./scripts/stats directory contains a
+ number of shell and awk scripts for this, as well as S-
+ language programs that produce PostScript plots of performance
+ data.
+
+flag3 This flag is used with Sun SPARCstation baseboard serial ports
+ to assign the ppsclock streams driver for a 1-pps signal
+ produced by some radio clocks and timekeeping devices. See the
+ dscription of the PPS Clock Discipline Driver (type 22) in
+ Appendix A for further information.
+
+Note that the fudge factors above can be changed at run time using the
+xntpdc program (see the xntpdc.8 man page). This program does not have
+to be run on the server machine itself, since it communicates with the
+xntpd daemon using cryptographically authenticated messages.
+
+The PPS Signal
+
+Some radio clocks and related timekeeping gear have a pulse-per-second
+(PPS) signal that can be used to discipline the local clock oscillator
+to a high degree of precision, typically to the order less than 50 us in
+time and 0.1 ppm in frequency. The PPS signal can be connected in either
+of two ways, either via the data leads of a serial port or via the modem
+control leads. Either way requires conversion of the PPS signal, usually
+at TTL levels, to RS232 levels, which can be done using a circuit such
+as described in the ./gadget directory of the xntp3 distribution.
+
+The data leads interface requires regenerating the PPS pulse and
+converting to RS232 signal levels, so that the pulse looks like a
+legitimate ASCII character. The tty_clk module in the ./kernel directory
+inserts a timestamp following this character in the input data stream.
+The driver uses this timestamp to determine the time of arrival of the
+PPS pulse to within 26 us at 38.4 kbps while eliminating error due to
+operating system queues and service times. In order to use the tty_clk
+module, the xntp3 distribution must be compiled with CLK defined.
+The modem control leads interface requires converting to RS232 levels
+and connecting to the carrier detect (CD) lead of a serial port. The
+ppsclock streams module in the ./ppsclock directory is used to capture a
+timestamp upon transition of the PPS signal. The driver reads the latest
+timestamp with a designated ioctl() system call to determine the time of
+arrival of the PPS pulse to within a few tens of microseconds. In order
+to use the ppsclock module, the xntp3 distribution must be compiled with
+PPS defined.
+
+Both of these mechanisms are supported by the ATOM_PPS reference clock
+driver described in Appendix A. This driver is ordinarily used in
+conjunction with another clock driver that supports the radio clock that
+produces the PPS pulse. This driver furnishes the coarse timecode used
+to disambiguate the seconds numbering of the PPS pulse itself. The NTP
+daemon mitigates between the radio clock driver and ATOM_PPS driver as
+described in Appendix B in order to provide the most accurate time,
+while respecting the various types of equipment failures that could
+happen.
+
+For the utmost time quality, a number of Unix system kernel
+modifications can be made as described in the README.magic and
+README.kernel files. Specifically, the ppsclock module can be used to
+interface the PPS signal directly to the kernel for use as discipline
+sources for both time and frequency. These sources can be separately
+enabled and monitored using the ntp_adjtime() system call described in
+README.kernel and the ./include/sys/timex.h header file in the xntp3
+distribution. In order to use the kernel PPS signal, the xntp3
+distribution must be compiled with KERNEL_PLL defined.
+
+In some configurations may have multiple radio clocks, each with PPS
+outputs, as well as a kernel modified to use the PPS signal. In order to
+provide the highest degree of redundancy and survivability, the kernel
+PPS discipline, tty_clk module and ppsclock module may all be in use at
+the same time, each backing up the other. The sometimes complicated
+mitigation rules are described in Appendix B.
+
+Debugging Hints
+
+The ntpq and xntpdc utility programs can be used to debug reference
+clocks, either on the server itself or from another machine elsewhere in
+the network. The server is compiled, installed and started using the
+command-line switches described in the xntpd.8 man page. The first thing
+to look for are error messages on the system log. If none occur, the
+daemon has started, opened the devices specified and waiting for peers
+and radios to come up.
+
+The next step is to be sure the RS232 messages, if used, are getting to
+and from the clock. The most reliable way to do this is with an RS232
+tester and to look for data flashes as the driver polls the clock and/or
+as data arrive from the clock. Our experience is that the overwhelming
+fraction of problems occurring during installation are due to problems
+such as miswired connectors or improperly configured radio clocks at
+this stage.
+
+If RS232 messages are getting to and from the clock, the variables of
+interest can be inspected using the ntpq program and various commands
+described in the ntpq.8 man page. First, use the pe and as commands to
+display a pair of billboards showing the peer configuration and
+association IDs for all peers, including the radio clock peers. The
+assigned clock address should appear in the pe billboard and the
+association ID for it at the same relative line position in the as
+billboard. If things are operating correctly, after a minute or two
+samples should show up in the pe display line for the clock.
+
+Additional information is available with the rv and clockvar commands,
+which take as argument the association ID shown in the as billboard. The
+rv command with no argument shows the system variables, while the rv
+command with argument shows the peer variables for the clock, as well as
+any other peers of interest. The clockvar command with argument shows
+the peer variables specific to reference clock peers, including the
+clock status, device name, last received timecode (if relevant), and
+various event counters. In addition, a subset of the fudge parameters is
+included.
+
+The xntpdc utility program can be used for detailed inspection of the
+clock driver status. The most useful are the clockstat and clkbug
+commands described in the xntpdc.8 man page. While these commands permit
+getting quite personal with the particular driver involved, their use is
+seldom necessary, unless an implementation bug shows up.
+
+Most drivers write a message to the clockstats file as each timecode or
+surrogate is received from the radio clock. By convention, this is the
+last ASCII timecode (or ASCII gloss of a binary-coded one) received from
+the radio. This file is managed by the filegen facility described in the
+xntpd.8 man page and requires specific commands in the configuration
+file. This forms a highly useful record to discover anomalies during
+regular operation of the clock. The scripts included in the
+./scripts/stats directory can be run from a cron job to collect and
+summarize these data on a daily or weekly basis. The summary files have
+proven invaluable to detect infrequent misbehavior due to clock
+implementation bugs in some radios.
+
+Appendix A. Individual Driver Descriptions
+
+Following are detailed descriptions of the clock drivers, together with
+configuration data useful for special circumstances.
+
+Type 1: Undisciplined Local Clock
+
+ This is a hack to allow a machine to use its own system clock as a
+ reference clock, i.e., to free-run using no outside clock
+ discipline source. This is useful if you want to use NTP in an
+ isolated environment with no radio clock or NIST modem available.
+ Pick a machine that you figure has a good clock oscillator and
+ configure it with this driver. Set the clock using the best means
+ available, like eyeball-and-wristwatch. Then, point all the other
+ machines at this one or use broadcast (not multicast) mode to
+ distribute time.
+
+ Another application for this driver is if you want to use a
+ particular server's clock as the clock of last resort when all
+ other normal synchronization sources have gone away. This is
+ especially useful if that server has an ovenized oscillator. For
+ this you would configure this driver at a higher stratum (say 3 or
+ 4) to prevent the server's stratum from falling below that.
+
+ A third application for this driver is when an external discipline
+ source is available, such as the NIST "lockclock" program, which
+ synchronizes the local clock via a telephone modem and the NIST
+ Automated Computer Time Service (ACTS), or the Digital Time
+ Synchronization Service (DTSS), which runs on DCE machines. In this
+ case the stratum should be set at zero, indicating a bona fide
+ stratum-1 source. Exercise some caution with this, since there is
+ no easy way to telegraph via NTP that something might be wrong in
+ the discipline source itself. In the case of DTSS, the local clock
+ can have a rather large jitter, depending on the interval between
+ corrections and the intrinsic frequency error of the clock
+ oscillator. In extreme cases, this can cause clients to exceed the
+ 128-ms slew window and drop off the NTP subnet.
+
+ In the default mode the behavior of the clock selection algorithm
+ is modified when this driver is in use. The algorithm is designed
+ so that this driver will never be selected unless no other
+ discipline source is available. This can be overridden with the
+ prefer keyword of the server configuration command, in which case
+ only this driver will be selected for synchronization and all other
+ discipline sources will be ignored. This behavior is intended for
+ use when an external discipline source controls the system clock.
+
+ Fudge Factors
+
+ The stratum for this driver LCLSTRATUM is set at 3 by default, but
+ can be changed by the fudge command and/or the xntpdc utility. The
+ reference ID is "LCL" by default, but can be changed using the same
+ mechanisms. *NEVER* configure this driver to operate at a stratum
+ which might possibly disrupt a client with access to a bona fide
+ primary server, unless the local clock oscillator is reliably
+ disciplined by another source. *NEVER NEVER* configure a server
+ which might devolve to an undisciplined local clock to use
+ multicast mode.
+
+ This driver provides a mechanism to trim the local clock in both
+ time and frequency, as well as a way to manipulate the leap bits.
+ The fudge time1 parameter adjusts the time, in seconds, and the
+ fudge time2 parameter adjusts the frequency, in ppm. Both
+ parameters are additive; that is, they add increments in time or
+ frequency to the present values. (Note: The frequency cannot be
+ changed when the kernel modifications are in use - see the
+ README.kern file). The fudge flag1 and fudge flag2 bits set the
+ corresponding leap bits; for example, setting flag1 causes a leap
+ second to be added at the end of the UTC day. These bits are not
+ reset automatically when the leap takes place; they must be turned
+ off manually after the leap event.
+
+Type 2: TRAK 8820 GPS Receiver
+
+ This driver supports the TRAK 8820 GPS Station Clock. The claimed
+ accuracy at the 1-pps output is 200-300 ns relative to the
+ broadcast signal; however, in most cases the actual accuracy is
+ limited by the precision of the timecode and the latencies of the
+ serial interface and operating system.
+
+ For best accuracy, this radio requires the LDISC_ACTS line
+ discipline, which captures a timestamp at the '*' on-time character
+ of the timecode. Using this discipline the jitter is in the order
+ of 1 ms and systematic error about 0.5 ms. If unavailable, the
+ buffer timestamp is used, which is captured at the \r ending the
+ timecode message. This introduces a systematic error of 23
+ character times, or about 24 ms at 9600 bps, together with a jitter
+ well over 8 ms on Sun IPC-class machines.
+
+ Using the menus, the radio should be set for 9600 bps, one stop bit
+ and no parity. It should be set to operate in computer (no echo)
+ mode. The timecode format includes neither the year nor leap-second
+ warning. No provisions are included in this preliminary version of
+ the driver to read and record detailed internal radio status.
+
+ In operation, this driver sends a RQTS\r request to the radio at
+ initialization in order to put it in continuous time output mode.
+ The radio then sends the following message once each second:
+
+ *RQTS U,ddd:hh:mm:ss.0,q<cr><lf>
+
+ on-time = '*'
+ ddd = day of year
+ hh:mm:ss = hours, minutes, seconds
+ q = quality indicator (phase error), 0-6:
+ 0 > 20 us
+ 6 > 10 us
+ 5 > 1 us
+ 4 > 100 ns
+ 3 > 10 ns
+ 2 < 10 ns
+
+ The alarm condition is indicated by '0' at Q, which means the radio
+ has a phase error than 20 usec relative to the broadcast time. The
+ absence of year, DST and leap-second warning in this format is also
+ alarming.
+
+ The continuous time mode is disabled using the RQTX<cr> request,
+ following which the radio sends a RQTX DONE<cr><lf> response. In
+ the normal mode, other control and status requests are effective,
+ including the leap-second status request RQLS<cr>. The radio
+ responds with RQLS yy,mm,dd<cr><lf>, where yy,mm,dd are the year,
+ month and day. Presumably, this gives the epoch of the next leap
+ second, RQLS 00,00,00 if none is specified in the GPS message.
+ Specified in this form, the information is generally useless and is
+ ignored by the driver.
+
+ Fudge Factors
+
+ There are no special fudge factors other than the generic.
+
+Type 3: PSTI/Traconex WWV/WWVH Receiver
+
+ This driver supports the PSTI 1010 and Traconex 1020 WWV/WWVH
+ Receivers. No specific claim of accuracy is made for these
+ receiver, but actual experience suggests that 10 ms would be a
+ conservative assumption.
+
+ The DIPswitches should be set for 9600 bps line speed, 24-hour day-
+ of-year format and UTC time zone. Automatic correction for DST
+ should be disabled. It is very important that the year be set
+ correctly in the DIPswitches; otherwise, the day of year will be
+ incorrect after 28 April of a normal or leap year. The propagation
+ delay DIPswitches should be set according to the distance from the
+ transmitter for both WWV and WWVH, as described in the
+ instructions. While the delay can be set only to within 11 ms, the
+ fudge time1 parameter can be used for vernier corrections.
+
+ Using the poll sequence QTQDQM, the response timecode is in three
+ sections totalling 50 ASCII printing characters, as concatenated by
+ the driver, in the following format:
+
+ ahh:mm:ss.fffs<cr> yy/dd/mm/ddd<cr> frdzycchhSSFTttttuuxx<cr>
+
+ on-time = first <cr>
+ hh:mm:ss.fff = hours, minutes, seconds, milliseconds
+ a = AM/PM indicator (' ' for 24-hour mode)
+ yy = year (from DIPswitches)
+ dd/mm/ddd = day of month, month, day of year
+ s = daylight-saving indicator (' ' for 24-hour mode)
+ f = frequency enable (O = all frequencies enabled)
+ r = baud rate (3 = 1200, 6 = 9600)
+ d = features indicator (@ = month/day display enabled)
+ z = time zone (0 = UTC)
+ y = year (5 = 91)
+ cc = WWV propagation delay (52 = 22 ms)
+ hh = WWVH propagation delay (81 = 33 ms)
+ SS = status (80 or 82 = operating correctly)
+ F = current receive frequency (4 = 15 MHz)
+ T = transmitter (C = WWV, H = WWVH)
+ tttt = time since last update (0000 = minutes)
+ uu = flush character (03 = ^c)
+ xx = 94 (unknown)
+
+ The alarm condition is indicated by other than '8' at A, which
+ occurs during initial synchronization and when received signal is
+ lost for an extended period; unlock condition is indicated by other
+ than "0000" in the tttt subfield at Q.
+
+ Fudge Factors
+
+ There are no special fudge factors other than the generic.
+
+Type 4: Spectracom WWVB Receiver
+
+ This driver supports the Spectracom Model 8170 and Netclock/2 WWVB
+ Synchronized Clock. This clock has proven a reliable source of
+ time, except in some cases of high ambient conductive RF
+ interference. The claimed accuracy of the clock is 100 usec
+ relative to the broadcast signal; however, in most cases the actual
+ accuracy is limited by the precision of the timecode and the
+ latencies of the serial interface and operating system.
+
+ The DIPswitches on this clock should be set to 24-hour display,
+ AUTO DST off, time zone 0 (UTC), data format 0 or 2 (see below) and
+ baud rate 9600. If this clock is to used as the source for the IRIG
+ Audio Decoder (refclock_irig.c in this distribution), set the
+ DIPswitches for AM IRIG output and IRIG format 1 (IRIG B with
+ signature control).
+
+ There are two timecode formats used by these clocks. Format 0,
+ which is available with both the Netclock/2 and 8170, and format 2,
+ which is available only with the Netclock/2 and specially modified
+ 8170.
+
+ Format 0 (22 ASCII printing characters):
+
+ <cr><lf>i ddd hh:mm:ss TZ=zz<cr><lf>
+
+ on-time = first <cr>
+ hh:mm:ss = hours, minutes, seconds
+ i = synchronization flag (' ' = in synch, '?' = out synch)
+
+ The alarm condition is indicated by other than ' ' at A, which
+ occurs during initial synchronization and when received signal is
+ lost for about ten hours.
+
+ Format 2 (24 ASCII printing characters):
+
+ <cr><lf>iqyy ddd hh:mm:ss.fff ld
+
+ on-time = <cr>
+ i = synchronization flag (' ' = in synch, '?' = out synch)
+ q = quality indicator (' ' = locked, 'A'...'D' = unlocked)
+ yy = year (as broadcast)
+ ddd = day of year
+ hh:mm:ss.fff = hours, minutes, seconds, milliseconds
+
+ The alarm condition is indicated by other than ' ' at A, which
+ occurs during initial synchronization and when received signal is
+ lost for about ten hours. The unlock condition is indicated by
+ other than ' ' at Q.
+
+ The Q is normally ' ' when the time error is less than 1 ms and a
+ character in the set 'A'...'D' when the time error is less than 10,
+ 100, 500 and greater than 500 ms respectively. The L is normally '
+ ', but is set to 'L' early in the month of an upcoming UTC leap
+ second and reset to ' ' on the first day of the following month.
+ The D is set to 'S' for standard time 'I' on the day preceding a
+ switch to daylight time, 'D' for daylight time and 'O' on the day
+ preceding a switch to standard time. The start bit of the first
+ <cr> is synchronized to the indicated time as returned.
+
+ This driver does not need to be told which format is in use - it
+ figures out which one from the length of the message. A three-stage
+ median filter is used to reduce jitter and provide a dispersion
+ measure. The driver makes no attempt to correct for the intrinsic
+ jitter of the radio itself, which is a known problem with the older
+ radios.
+
+ Fudge Factors
+
+ This driver can retrieve a table of quality data maintained
+ internally by the Netclock/2 receiver. If flag4 of the fudge
+ configuration command is set to 1, the driver will retrieve this
+ table and write it to the clockstats file on when the first
+ timecode message of a new day is received.
+
+Type 5: TrueTime GPS/GOES Receivers
+
+ This driver supports at least two models of Kinemetrics/TrueTime
+ Timing Receivers, the 468-DC MK III GOES Synchronized Clock and
+ GPS-DC MK III GPS Synchronized Clock and very likely others in the
+ same model family that use the same timecode formats. The clocks
+ are connected via a serial port. Up to four units, with unit
+ numbers in the range 0 through 3, can be configured. The driver
+ assumes the serial port device name is /dev/goes%d (i.e., unit 1 at
+ 127.127.5.1 opens the clock at /dev/goes1) and that the clock is
+ configured for 9600-baud operation.
+
+Type 6: IRIG Audio Decoder
+
+ This driver supports the Inter-Range Instrumentation Group standard
+ time-distribution signal IRIG-B using the audio codec native to the
+ Sun SPARCstation. This signal is generated by several radio clocks,
+ including those made by Austron, TrueTime, Odetics and Spectracom,
+ among others, although it is generally an add-on option. The signal
+ is connected via an attenuator box and cable to the audio codec
+ input on a Sun SPARCstation and requires a specially modified
+ kernel audio driver. Details are in the README.irig file.
+
+ Timing jitter using the decoder and a Sun IPC is in the order of a
+ few microseconds, although the overall timing accuracy is limited
+ by the wander of the CPU oscillator used for timing purposes to a
+ few hundred microseconds. These figures are comparable with what
+ can be achieved using the 1-pps discipline as describe elsewhere in
+ this note.
+
+ Fudge Factors
+
+ There are no special fudge factors other than the generic. The
+ flag3 and flag4 flags are not applicable to this driver.
+
+Type 7: Scratchbuilt CHU Receiver
+
+ This driver supports a shortwave receiver and special modem
+ circuitry described in the ./gadget directory of the xntp3
+ distribution. It requires the chu-clk line discipline or chu_clk
+ STREAMS module described in the ./kernel directory of that
+ distribution. It is connected via a serial port operating at 300
+ baud.
+ Unlike the NIST time services, whose timecode requires quite
+ specialized hardware to interpret, the CHU timecode can be received
+ directly via a serial port after demodulation. While there are
+ currently no known commercial CHU receivers, the hardware required
+ to receive the CHU timecode is fairly simple to build. While it is
+ possible to configure several CHU units simultaneously, this is in
+ general not useful.
+
+ Fudge Factors
+
+ The time1 option can be used to set the CHU propagation delay,
+ compensate for inherent latencies in the serial port hardware and
+ operating system. The default value is 0.0025 seconds, which is
+ about right for Toronto. Values for other locations can be
+ calculated using the propdelay program in the util directory of the
+ xntp3 distribution or equivalent means.
+
+ The time2 option can be used to compensate for inherent latencies
+ in the serial port hardware and operating system. The value, which
+ defaults to zero, is in addition to the propagation delay provided
+ by the time1 option. The default value is 0.0002 seconds, which is
+ about right for typical telephone modem chips.
+
+ The flag1 option can be used to modify the averaging algorithm used
+ to smooth the clock indications. Ordinarily, the algorithm picks
+ the median of a set of samples, which is appropriate under
+ conditions of poor to fair radio propagation conditions. If the
+ clock is located relatively close to the WWV or WWVH transmitters,
+ setting this flag will cause the algorithm to average the set of
+ samples, which can reduce the residual jitter and improve accuracy.
+
+Type 8: Generic Reference Clock Driver
+
+ The timecode of these receivers is sampled via a STREAMS module in
+ the kernel (The STREAMS module has been designed for use with SUN
+ Systems under SunOS 4.1.x. It can be linked directly into the
+ kernel or loaded via the loadable driver mechanism). This STREAMS
+ module can be adapted to be able to convert different time code
+ formats. If the daemon is
+
+ compiled without the STREAM definition synchronization will work
+ without the Sun streams module, though accuracy is significantly
+ degraded.
+
+ The actual receiver status is mapped into various synchronization
+ states generally used by receivers. The STREAMS module is
+ configured to interpret the time codes of DCF U/A 31, PZF535,
+ GPS166, Trimble SV6 GPS, ELV DCF7000, Schmid and low cost receivers
+ (see list below).
+
+ The reference clock support in xntp contains the necessary
+ configuration tables for those receivers. In addition to supporting
+ up to 32 different clock types and 4 devices, the generation a a
+ PPS signal is also provided as an configuration option. The PPS
+ configuration option uses the receiver generated time stamps for
+ feeding the PPS loopfilter control for much finer clock
+ synchronization.
+
+ CAUTION: The PPS configuration option is different from the
+ hardware PPS signal, which is also supported (see below), as it
+ controls the way xntpd is synchronized to the reference clock,
+ while the hardware PPS signal controls the way time offsets are
+ determined.
+
+ The use of the PPS option requires receivers with an accuracy of
+ better than 1ms.
+ Fudge factors
+
+ Only two fudge factors are utilized. The time1 fudge factor defines
+ the phase offset of the synchronization character to the actual
+ time. On the availability of PPS information the time2 fudge factor
+ defines the skew between the PPS time stamp and the receiver
+ timestamp of the PPS signal. This parameter is usually zero, as
+ usually the PPS signal is believed in time and OS delays should be
+ corrected in the machine specific section of the kernel driver.
+ time2 needs only be set when the actual PPS signal is delayed for
+ some reason. The flag0 enables input filtering. This a median
+ filter with continuous sampling. The flag1 selects averaging of the
+ samples remaining after the filtering. Leap secondhandling is
+ controlled with the flag2. When set a leap second will be deleted
+ on receipt of a leap second indication from the receiver. Otherwise
+ the leap second will be added, (which is the default).
+
+ ntpq (8)
+
+ timecode variable
+
+ The ntpq program can read clock variables command list several
+ variables. These hold the following information: refclock_time is
+ the local time with the offset to UTC (format HHMM). The currently
+ active receiver flags are listed in refclock_status. Additional
+ feature flags of the receiver are optionally listed in parentheses.
+ The actual time code is listed in timecode. A qualification of the
+ decoded time code format is following in refclock_format. The last
+ piece of information is the overall running time and the
+ accumulated times for the clock event states in refclock_states.
+ When PPS information is present additional variable are available.
+ refclock_ppstime lists then the PPS timestamp and refclock_ppsskew
+ lists the difference between RS232 derived timestamp and the PPS
+ timestamp.
+
+ Unit encoding
+
+ The unit field <u> encodes the device, clock type and the PPS
+ generation option. There are 4 possible units, which are encoded in
+ the lower two bits of the <u> field. The devices are named
+ /dev/refclock-0 through /dev/refclock-3. Bits 2 thru 6 encode the
+ clock type. The fudge factors of the clock type are taken from a
+ table clockinfo in refclock_parse.c. The generation of PPS
+ information for disciplining the local NTP clock is encoded in bit
+ 7 of <u>.
+
+ Currently, nine clock types (devices /dev/refclock-0 -
+ /dev/refclock-3) are supported.
+
+ 127.127.8.0-3 16
+
+ Meinberg PZF535 receiver (FM demodulation/TCXO / 50us)
+
+ 127.127.8.4-7 16
+
+ Meinberg PZF535 receiver (FM demodulation/OCXO / 50us)
+
+ 127.127.8.8-11 16
+
+ Meinberg DCF U/A 31 receiver (AM demodulation / 4ms)
+
+ 127.127.8.12-15 16
+
+ ELV DCF7000 (sloppy AM demodulation / 50ms)
+
+ 127.127.8.16-19 16
+ Walter Schmid DCF receiver Kit (AM demodulation / 1ms)
+
+ 127.127.8.20-23 16
+
+ RAW DCF77 100/200ms pulses (Conrad DCF77 receiver module / 5ms)
+
+ 127.127.8.24-27 16
+
+ RAW DCF77 100/200ms pulses (TimeBrick DCF77 receiver module / 5ms)
+
+ 127.127.8.28-31 16
+
+ Meinberg GPS166 receiver (GPS / <<1us)
+
+ 127.127.8.32-35 16
+
+ Trimble SV6 GPS receiver (GPS / <<1us)
+
+ The reference clock support carefully monitors the state
+ transitions of the receiver. All state changes and exceptional
+ events such as loss of time code transmission are logged via the
+ syslog facility. Every hour a summary of the accumulated times for
+ the clock states is listed via syslog.
+
+ PPS support is only available when the receiver is completely
+ synchronized. The receiver is believed to deliver correct time for
+ an additional period of time after losing synchronizations, unless
+ a disruption in time code transmission is detected (possible power
+ loss). The trust period is dependent on the receiver oscillator and
+ thus a function of clock type. This is one of the parameters in the
+ clockinfo field of the reference clock implementation. This
+ parameter cannot be configured by xntpdc.
+
+ In addition to the PPS loopfilter control a true PPS hardware
+ signal can be applied on Sun Sparc stations via the CPU serial
+ ports on the CD pin. This signal is automatically detected and will
+ be used for offset calculation. The input signal must be the time
+ mark for the following time code. (The edge sensitivity can be
+ selected - look into the appropriate kernel/parsestreams.c for
+ details). Meinberg receivers can be connected by feeding the PPS
+ pulse of the receiver via a 1488 level converter to Pin 8 (CD) of a
+ Sun serial zs\-port.
+
+ There exists a special firmware release for the PZF535 Meinberg
+ receivers. This release (PZFUERL 4.6 (or higher - The UERL is
+ important)) is absolutely recommended for XNTP use, as it provides
+ LEAP warning, time code time zone information and alternate antenna
+ indication. Please check with Meinberg for this firmware release.
+ For the Meinberg GPS166 receiver is also a special firmware release
+ available (Uni-Erlangen). This release must be used for proper
+ operation.
+
+ The raw DCF77 pulses can be fed via a level converter directly into
+ Pin 3 (Rx) of the Sun. The telegrams will be decoded an used for
+ synchronization. AM DCF77 receivers are running as low as $25. The
+ accuracy is dependent on the receiver and is somewhere between 2ms
+ (expensive) to 10ms (cheap). Upon bad signal reception of DCF77
+ synchronizations will cease as no backup oscillator is available as
+ usually found in other reference clock receivers. So it is
+ important to have a good place for the DCF77 antenna. For
+ transmitter shutdowns you are out of luck unless you have other NTP
+ servers with alternate time sources available.
+
+Type 9: Magnavox MX4200 GPS Receiver
+
+ This driver supports the Magnavox MX4200 Navigation Receiver
+ adapted to precision timing applications. This requires an
+ interface box described in the ./ppsclock directory of the xntp3
+ distribution. It is connected via a serial port and requires the
+ ppsclock STREAMS module described in the same directory.
+
+ Fudge Factors
+
+ There are no special fudge factors other than the generic.
+
+Type 10: Austron 2201A GPS Receiver
+
+ This driver supports the Austron 2200A/2201A GPS/LORAN Synchronized
+ Clock and Timing Receiver connected via a serial port. It supports
+ several special features of the clock, including the Input Buffer
+ Module, Output Buffer Module, IRIG-B Interface Module and LORAN
+ Assist Module. It requires the RS232 Serial Interface module for
+ communication with the driver.
+
+ This receiver is capable of a comprehensive and large volume of
+ statistics and operational data. The specific data collection
+ commands and attributes are embedded in the driver source code;
+ however, the collection process can be enabled or disabled using
+ the flag4 flag. If set, collection is enabled; if not, which is the
+ default, it is disabled. A comprehensive suite of data reduction
+ and summary scripts is in the ./scripts/stats directory of the
+ xntp3 distribution.
+
+ To achieve the high accuracy this device provides, it is necessary
+ to use the ppsclock feature of the xntp3 program distribution or,
+ alternatively, to install the kernel modifications described in the
+ README.kern. The clock can be wired to provide time to a single CPU
+ or bussed in parallel to several CPUs, with one CPU controlling the
+ receiver and the others just listening. Fair accuracy can be
+ achieved in the single-CPU configuration without use of the 1-pps
+ signal, but in multiple CPU configurations accuracy is severely
+ degraded without it.
+
+ Fudge Factors
+
+ There are no special fudge factors other than the generic.
+
+Type 11: TrueTime OM-DC OMEGA Receiver
+
+ This driver supports the Kinemetrics/TrueTime OMEGA-DC OMEGA
+ Synchronized Clock connected via a serial port. This clock is
+ sufficiently different from other Kinemetrics/TrueTime models that
+ a separate driver is required. Up to four units, with unit numbers
+ in the range 0 through 3, can be configured. The driver assumes the
+ serial port device name is /dev/omega%d (i.e., unit 1 at
+ 127.127.11.1 opens the clock at /dev/omega1) and that the clock is
+ configured for 9600-baud operation.
+
+ Fudge Factors
+
+ There are no special fudge factors other than the generic.
+
+Type 12: KSI/Odetics TPRO/S IRIG Interface
+
+ This driver supports the KSI/Odetics TPRO and TPRO-SAT IRIG-B
+ Decoder, which is a module connected directly to the SBus of a Sun
+ workstation. The module works with the IRIG-B signal generated by
+ several radio clocks, including those made by Austron, TrueTime,
+ Odetics and Spectracom, among others, although it is generally an
+ add-on option. In the case of the TPRO-SAT, the module is an
+ integral part of a GPS receiver, which serves as the primary timing
+ source.
+
+ Using the TPRO interface as a NTP reference clock provides
+ precision time only to xntpd and its clients. With suitable kernel
+ modifications, it is possible to use the TPRO as the CPU system
+ clock, avoiding errors introduced by the CPU clock oscillator
+ wander. See the README.kernel and kern.c files for further details.
+
+Type 13: Leitch CSD 5300 Master Clock Controller
+
+ Information not available.
+
+Type 14: EES M201 MSF Receiver
+
+ This driver supports the EES M201 MSF receiver connected to a Sun
+ SPARCstation running SunOS 4.x with the "ppsclock" STREAMS module.
+
+ Fudge Factors
+
+ If flag1 is set, then the system clock is assumed to be sloppy
+ (e.g. Sun4 with 20ms clock), so samples are averaged. If flag2 is
+ set, then leaphold is set. If flag3 is set, then the sample
+ information is dumped. If flag4 is set, then the input data is
+ smoothed, and all data points are used.
+
+Type 15: TrueTime GPS/TM-TMD Receiver
+
+ Information not available.
+
+Type 16: Bancomm GPS/IRIG Receiver
+
+ Information not available.
+
+Type 17: Datum Precision Time System
+
+ Information not available.
+
+Type 18: NIST Automated Computer Time Service
+
+ This driver supports the NIST Automated Computer Time Service
+ (ACTS). It periodically dials a prespecified telephone number,
+ receives the NIST timecode data and calculates the local clock
+ correction. It designed primarily for use when neither a radio
+ clock nor connectivity to Internet time servers is available. For
+ the best accuracy, the individual telephone line/modem delay needs
+ to be calibrated using outside sources.
+
+ The ACTS is located at NIST Boulder, CO, telephone 303 494 4774. A
+ toll call from Newark, DE, costs between three and four cents,
+ although it is not clear what carrier and time of day discounts
+ apply. The modem dial string will differ depending on local
+ telephone configuration, etc., and is specified by the phone
+ command in the configuration file. The argument to this command is
+ an AT command for a Hayes compatible modem.
+
+ 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 three modes, as determined by
+ the mode parameter in the server configuration command. In mode 0
+ (automatic) the driver operates continuously at intervals depending
+ on the prediction error, as measured by the driver, usually in the
+ order of several hours. In mode 1 (backup) the driver is enabled in
+ automatic mode only when no other source of synchronization is
+ available and when more than MAXOUTAGE (3600 s) have elapsed since
+ last synchronized by other sources. In mode 2 (manual) the driver
+ operates only when enabled using a fudge flags switch, as described
+ below.
+
+ For reliable call management, this driver requires a 1200-bps modem
+ with a Hayes-compatible command set and control over the modem data
+ terminal ready (DTR) control line. Present restrictions require the
+ use of a POSIX-compatible programming interface, although other
+ interfaces may work as well. The ACTS telephone number and modem
+ setup string are hard-coded in the driver and may require changes
+ for nonstandard modems or special circumstances.
+
+ 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 automatic 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 automatic mode) if all other
+ synchronization sources are lost. In either automatic 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.
+
+ The NIST timecode message is transmitted at 1200 bps in the
+ following format (see the driver source for more information):
+
+ jjjjj yy-mm-dd hh:mm:ss tt l uuu mmmmm UTC(NIST) *
+
+ jjjjj = modified Julian day
+ yy-mm-dd = year, month, day
+ hh:mm:ss = hours, minutes, seconds
+ tt = DST indicator (see driver listing)
+ l = leap-second warning (see driver listing)
+ uuu = DUT1 correction (see driver listing)
+ mmmmm = modem calibration (see driver listing)
+ on-time = '*'
+
+ The timecode message is transmitted continuously after a signon
+ banner, which this driver ignores. The driver also ignores all but
+ the yy-mm-dd, hh:mm:ss and on-time character '*' fields, although
+ it checks the format of all fields of the message. A timestamp is
+ captured at the '*' character, as required by the ACTS
+ specification, and used as the reference time of the timecode. If a
+ message with an on-time character of '#' is received, the driver
+ updates the propagation delay. The driver disconnects when (a) ten
+ valid messages have been received, (b) no message has been received
+ for 15 s, (c) an on-time character of '#' is received. These
+ messages are processed by a trimmed-mean filter to reduce timing
+ noise and then by the usual NTP algorithms to develop the clock
+ correction.
+
+ The behavior of the clock selection algorithm is modified when this
+ driver is in use. The algorithm is designed so that this driver
+ will never be selected unless no other discipline source is
+ available. This can be overridden with the prefer keyword of the
+ server configuration command, in which case only this driver will
+ be selected for synchronization and all other discipline sources
+ will be ignored. Ordinarily, the prefer keyword would be used only
+ in automatic mode ehen primary time is to be obtained via ACTS and
+ backup NTP peers used only when ACTS fails.
+
+ Call Management
+
+ Since ACTS will be a toll call in most areas of the country, it is
+ necessary to carefully manage the calling interval. The ACTS call
+ program is initiated by setting fudge flag1. This flag can be set
+ manually using xntpdc, by a cron job that calls xntpdc, or
+ automatically by the driver itself. The fudge flag1 is reset when
+ the program terminates after a time determination is comlete or
+ when no more numbers remain in the alternate path list, a device
+ fault or timeout has occured, or the fudge flag1 has been reset
+ using xntpdc.
+
+ In automatic and backup modes, the driver determines the call
+ interval using a procedure depending on the measured prediction
+ error and the fudge time2 parameter. If the error exceeds time2 for
+ a number of times depending on the current interval, the interval
+ is decreased, but not less than about 1000 s. If the error is less
+ than time2 for some number of times, the interval is increased, but
+ not more than about 18 h. With the default value of zero for fudge
+ time2, the interval will increase from 1000 s to the 4000-8000-s
+ range, in which the expected accuracy should be in the 1-2-ms
+ range. Setting fudge time2 to a large value, like 0.1 s, may result
+ in errors of that order, but increase the call interval to the
+ maximum. The exact value for each configuration will depend on the
+ modem and operating system involved, so some experimentation may be
+ necessary.
+
+ Manual call attempts can be made at any time by setting fudge flag1
+ using xntpdc. For example, the xntpdc command
+
+ fudge 127.127.18.1 flags 1
+
+ will ask for a key identifier and password and, if authenticated by
+ the server, will set flag1. There may be a short delay until the
+ expiration of the current poll timeout.
+
+ The flag1 can be set from a cron job in the following way.
+ Construct a file with contents
+
+ keyid 11
+ passwd dialup
+ fudge 127.127.18.1 flags 1
+ quit
+
+ Then, run the following program at specified times as required.
+
+ /usr/local/bin/xntpdc <file
+
+Type 19: Heath WWV/WWVH Receiver
+
+ This driver supports the Heath GC-1000 Most Accurate Clock, with
+ RS232C Output Accessory. This is a WWV/WWVH receiver somewhat less
+ robust than other supported receivers. Its claimed accuracy is 100
+ ms when actually synchronized to the broadcast signal, but this
+ doesn't happen even most of the time, due to propagation
+ conditions, ambient noise sources, etc. When not synchronized, the
+ accuracy is at the whim of the internal clock oscillator, which can
+ wander into the sunset without warning. Since the indicated
+ precision is 100 ms, expect a host synchronized only to this thing
+ to wander to and fro, occasionally being rudely stepped when the
+ offset exceeds the default CLOCK_MAX of 128 ms.
+
+ The internal DIPswitches should be set to operate at 1200 baud in
+ MANUAL mode and the current year. The external DIPswitches should
+ be set to GMT and 24-hour format. It is very important that the
+ year be set correctly in the DIPswitches. Otherwise, the day of
+ year will be incorrect after 28 April of a normal or leap year.
+
+ In MANUAL mode the clock responds to a rising edge of the request
+ to send (RTS) modem control line by sending the timecode.
+ Therefore, it is necessary that the operating system implement the
+ TIOCMBIC and TIOCMBIS ioctl system calls and TIOCM_RTS control bit.
+ Present restrictions require the use of a POSIX-compatible
+ programming interface, although other interfaces may work as well.
+
+ The clock message consists of 23 ASCII printing characters in the
+ following format:
+
+ hh:mm:ss.f dd/mm/yr<cr>
+
+ hh:mm:ss.f = hours, minutes, seconds
+ f = deciseconds ('?' when out of spec)
+ dd/mm/yr = day, month, year
+
+ The alarm condition is indicated by '?', rather than a digit, at A.
+ Note that 0?:??:??.? is displayed before synchronization is first
+ established and hh:mm:ss.? once synchronization is established and
+ then lost again for about a day.
+
+ Fudge Factors
+
+ There are no special fudge factors other than the generic. A fudge
+ time1 value of .07 s appears to center the clock offset residuals.
+
+Type 20: Generic NMEA GPS Receiver
+
+ Information not available.
+
+Type 21: Motorola Six Gun GPS Receiver
+
+ Information not available.
+
+Type 22: PPS Clock Discipline
+
+ This driver furnishes an interface for pulse-per-second (PPS)
+ signals produced by a cesium clock, timing receiver or related
+ equipment. It can be used to remove accumulated jitter and retime a
+ secondary server when synchronized to a primary server over a
+ congested, wide-area network and before redistributing the time to
+ local clients. Note that this driver does not control the system
+ clock if the kernel modifications described in the README.kernel
+ file have been installed, but it can be useful as a monitoring
+ tool.
+
+ In order for this driver to work, the local clock must be set to
+ within +-500 ms by another means, such as a radio clock or NTP
+ itself. The 1-pps signal is connected via a serial port and gadget
+ box consisting of a one-shot and RS232 level converter. When
+ operated at 38.4 kbps with a SPARCstation IPC, this arrangement has
+ a worst-case jitter less than 26 us.
+
+ There are three ways in which this driver can be used. The first
+ way uses the LDISC_PPS line discipline and works only for the
+ baseboard serial ports of the Sun SPARCstation. The PPS signal is
+ connected via a gadget box to the carrier detect (CD) line of a
+ serial port and flag3 of the driver configured for that port is
+ set. This causes the ppsclock streams module to be configured for
+ that port and capture a timestamp at the on-time transition of the
+ PPS signal. This driver then reads the timestamp directly by a
+ designated ioctl() system call. This provides the most accurate
+ time and least jitter of any other scheme. There is no need to
+ configure a dedicated device for this purpose, which ordinarily is
+ the device used for the associated radio clock.
+
+ The second way uses the LDISC_CLKPPS line discipline and works for
+ any architecture supporting a serial port. If after a few seconds
+ this driver finds no ppsclock module configured, it attempts to
+ open a serial port device /dev/pps%d, where %d is the unit number,
+ and assign the LDISC_CLKPPS line discipline to it. If the line
+ discipline fails, no harm is done except the accuracy is reduced
+ somewhat. The pulse generator in the gadget box is adjusted to
+ produce a start bit of length 26 us at 38400 bps (or 104 us at 9600
+ bps). Used with the LDISC_CLKPPS line discipline, this produces an
+ ASCII DEL character ('\377') followed by a timestamp at each
+ seconds epoch.
+
+ The third way involves an auxiliary radio clock driver which calls
+ the PPS driver with a timestamp captured by that driver. This use
+ is documented in the source code for the driver(s) involved.
+
+ Fudge Factors
+
+ There are no special fudge factors other than the generic and those
+ explicitly defined above. The fudge time1 parameter can be used to
+ compensate for miscellaneous UART and OS delays. Allow about 247 us
+ for uart delays at 38400 bps and about 1 ms for SunOS streams
+ nonsense.
+
+Appendix B. Mitigation Rules
+
+In order to provide robust backup sources, stratum-1 peers are usually
+operated in a diversity configuration, in which the local server
+operates with a number of remote peers in addition with one or more
+radio clocks operating also as local peers. In these configurations the
+suite of algorithms used in NTP to refine the data from each peer
+separately and to select and weight the data from a number of peers can
+be used with the entire ensemble of remote peers and local radios.
+However, Because of small but significant systematic time offsets
+between the peers, it is in general not possible to achieve the lowest
+jitter and highest stability in these configurations. In addition, there
+are a number of special configurations involving auxiliary radio clock
+outputs, telephone backup services and other special cases, so that a
+set of mitigation rules becomes necessary.
+
+The mitigation rules are based on a set of special characteristics of
+the various reference clock drivers configured on the server. For
+instance, it is possible to designate a peer as "preferred," in which
+case, all other things being equal, this peer will be selected for
+synchronization over all other eligible candidates in the clock
+selection procedures. The precise characterization of the prefer peer is
+described below. In addition, when a pulse-per-second (PPS) signal is
+connected via the PPS Clock Discipline Driver (type 22), the
+corresponding peer is called the PPS peer. The manner in which this peer
+operates is described below. When the Undisciplined Local Clock Driver
+(type 1) is configured in the server, this becomes the local-clock peer.
+When the Automated Computer Time Service Driver (type 18) is configured
+in the server, this becomes the ACTS peer. Both the local-clock and ACTS
+peers operates in the manner described in Appendix A. Finally, where
+support is available, the PPS signal may be processed directly by the
+kernel. In the following this will be called the kernel discipline.
+
+The mitigation rules apply in the clock selection procedures following
+the sanity checks, intersection algorithm and clustering algorithm. The
+survivors at this point represent the subset of all peers which can
+provide the most accurate, stable time. In the general case, with no
+designated prefer peer, PPS peer or local-clock peer, the mitigation
+rules require all survivors be averaged according to a weight depending
+on the reciprocal of the dispersion, as provided in the NTP
+specification.
+
+The mitigation rules establish the choice of system peer, which
+determine the stratum, reference identifier and several other system
+variables which are visible to clients of the local server. In addition,
+they establish which source or combination of sources control the local
+clock. In detail, these rules operate as follows:
+
+1. If there is a prefer peer and it is the local-clock peer or the
+ ACTS peer; or, if there is a prefer peer and the kernel discipline
+ is active, choose the prefer peer as the system peer.
+
+2. If the above is not the case and there is a PPS peer, then choose
+ it as the system peer and its offset as the system clock offset.
+
+3. If the above is not the case and there is a prefer peer (not the
+ local-clock or ACTS peer in this case), then choose it as the
+ system peer and its offset as the system clock offset.
+
+4. If the above is not the case and the peer previously chosen as the
+ system peer is in the surviving population, then choose it as the
+ system peer and average its offset along with the other survivors
+ to determine the system clock offset. This behavior is designed to
+ avoid excess jitter due to "clockhopping," when switching the
+ system peer would not materially improve the time accuracy.
+
+5. If the above is not the case, then choose the first candidate in
+ the list of survivors ranked in order of synchronization distance
+ and average its offset along with the other survivors to determine
+ the system clock offset. This is the default case and the only case
+ considered in the current NTP specification.
+
+The specific interpretation of the prefer peer and PPS peer require some
+explanation, which is given in following sections.
+
+B.1. Using the prefer Keyword
+
+For the reasons stated previously, a scheme has been implemented in NTP
+to provide an intelligent mitigation between various classes of peers,
+one designed to provide the best quality time without compromising the
+normal operation of the NTP algorithms. This scheme in its present form
+is not an integral component of the NTP specification. but is likely to
+be included in future versions of the specification. The scheme is based
+on the "preferred peer," which is specified by including the prefer
+keyword with the associated server or peer command in the configuration
+file. This keyword can be used with any peer or server, but is most
+commonly used with a radio clock server.
+
+The prefer scheme works on the set of peers that have survived the
+sanity and intersection algorithms of the clock select procedures.
+Ordinarily, the members of this set can be considered truechimers and
+any one of them could in principle provide correct time; however, due to
+various error contributions, not all can provide the most stable time.
+The job of the clustering algorithm, which is invoked at this point, is
+to select the best subset of the survivors providing the least variance
+in the combined ensemble compared to the variance in each member of the
+subset. The detailed operation of the clustering algorithm, which are
+given in the specification, are not important here, other than to point
+out it operates in rounds, where a survivor, presumably the worst of the
+lot, is discarded in each round until one of several termination
+conditions is met.
+
+In the prefer scheme the clustering algorithm is modified so that the
+prefer peer is never discarded; on the contrary, its potential removal
+becomes a termination condition. If the original algorithm were about to
+toss out the prefer peer, the algorithm terminates right there. The
+prefer peer can still be discarded by the sanity and intersection
+algorithms, of course, but it will always survive the clustering
+algorithm. A preferred peer retains that designation as long as it
+survives the intersection algorithm. If for some reason the prefer peer
+fails to survive the intersection algorithm, either because it was
+declared a falseticker or became unreachable, it loses that designation
+and the clock selection remitigates as described above.
+
+Along with this behavior, the clock select procedures are modified so
+that the combining algorithm is not used when a prefer (or PPS) peer is
+present. Instead, the offset of the prefer (or PPS) peer is used
+exclusively as the synchronization source. In the usual case involving a
+radio clock and a flock of remote stratum-1 peers, and with the radio
+clock designated a prefer peer, the result is that the high quality
+radio time disciplines the server clock as long as the radio itself
+remains operational and with valid time, as determined from the remote
+peers, sanity algorithm and intersection algorithm.
+
+While the model does not forbid it, it does not seem useful to designate
+more than one peer as preferred, since the additional complexities to
+mitigate among them do not seem justified from on the air experience.
+Note that the prefer peer interacts with the PPS peer discussed in
+Appendix C. It also interacts with the Undisciplined Local Clock Driver
+(type 1), as described in Appendix A. See the main text for the
+mitigation rules applying to the general case.
+
+B.2. Using the Pulse-per-Second (PPS) Signal
+
+Most radio clocks are connected using a serial port operating at speeds
+of 9600 bps or lower. The accuracy using typical timecode formats, where
+the on-time epoch is indicated by a designated ASCII character, like
+carriage-return <cr>, is limited to a millisecond at best and a few
+milliseconds in typical cases. However, some radios produce a precision
+pulse-per-second (PPS) signal which can be used to improve the accuracy
+in typical workstation servers to the order of a few tens of
+microseconds. The details of how this can be accomplished are discussed
+in the README.magic file; the following discusses how this signal is
+implemented and configured in a typical working server.
+
+First, it should be pointed out that the PPS signal is inherently
+ambiguous, in that it provides a precise seconds epoch, but does not
+provide a way to number the seconds. In principle and most commonly,
+another source of synchronization, either the timecode from an
+associated radio clock, or even a set of remote peers, is available to
+perform that function. In all cases a specific, configured peer or
+server must be designated as associated with the PPS signal. This is
+done by including the prefer keyword with the associated server or peer
+command in the configuration file. This PPS signal can be associated in
+this way any peer or server, but is most commonly used with the radio
+clock generating the PPS signal.
+
+The PPS signal is processed by a special PPS Clock Discipline Driver
+(type 22) described in Appendix A. That description specifies the
+hardware configurations in which this signal can be connected to the
+server. This driver replaces the former scheme based on conditional
+compilation and the PPS, CLK and PPSCLK compile-time switches.
+Regardless of method, the driver, like all other drivers, is mitigated
+in the manner described for the prefer peer in Appendix B. However, in
+the case of the PPS peer, the behavior is slightly more complex.
+
+First, in order for the PPS peer to be considered at all, its associated
+prefer peer must have survived the sanity and intersection algorithms
+and have been designated the prefer peer. This insures that the radio
+clock hardware is operating correctly and that, presumably, the PPS
+signal is operating correctly as well. Second, the absolute time offset
+from that peer must be less than CLOCK_MAX, the gradual-adjustment
+range, which is ordinarily set at 128 ms, or well within the +-0.5-s
+unambiguous range of the PPS signal itself. Finally, the time offsets
+generated by the PPS peer are propagated via the clock filter to the
+clock selection procedures just like any other peer. Should these pass
+the sanity and intersection algorithms, they will show up along with the
+offsets of the prefer peer itself. Note that, unlike the prefer peer,
+the PPS peer samples are not protected from discard by the clustering
+algorithm. These complicated procedures insure that the PPS offsets
+developed in this way are the most accurate, reliable available for
+synchronization.
+
+A PPS peer retains that designation as long as it survives the
+intersection algorithm; however, like any other clock driver, it runs a
+reachability algortihm on the PPS signal itself. If for some reason the
+signal fails or displays gross errors, the PPS peer will either become
+unreachable or stray out of the survivor population. In this case the
+clock selection remitigates as described above.
+
+Finally, the mitigation procedures described above for the prefer peer
+are modified so that, if the PPS peer survives the clustering algorithm,
+its offset is mitigated over the prefer peer offset; in other words in
+case of ties, the PPS offset wins. See the main text for the mitigation
+rules applying to the general case.
+
+B.3. Using the Kernel Discipline
+
+Code to implement the kernel discipline is a special feature that can be
+incorporated in the kernel of some workstations as described in the
+README.kernel file. The discipline provides for the control of the local
+clock oscillator time and/or frequency by means of an external PPS
+signal interfaced via a modem control lead. As the PPS signal is derived
+from external equipment, cables, etc., which sometimes fail, a good deal
+of error checking is done in the kernel to detect signal failure and
+excessive noise.
+
+In order to operate, the kernel discipline must be enabled and the
+signal must be present and within nominal jitter and wander error
+tolerances. In the NTP daemon the kernel is enabled only when the prefer
+peer is among the survivors of the clustering algorithm, as described
+above. Then, the PPS peer is designated the prefer peer as long as the
+PPS signal is present and operating within tolerances. Under these
+conditions the kernel disregards updates produced by the NTP daemon and
+uses its internal PPS source instead. The kernel maintains a watchdog
+timer for the PPS signal; if the signal has not been heard or is out of
+tolerance for more than some interval, currently two minutes, the kernel
+discipline is declared inoperable and operation continues as if it were
+not present.
+Appendix C. NTP Local Clock Discipline
+
+Implementation of the ACTS driver caused somewhat of a shakeup in the
+NTP local clock model and implementation. The model described in the
+specification RFC-1305 is based on a phase-lock loop (PLL) design, which
+is optimum or near optimum for the update intervals used for NTP peers
+and radio clocks, ordinarily in the range 64-1024 s. However, the ACTS
+driver must operate with update intervals in the range well above 1024
+s, where the performance of the PLL model deteriorates. As suggested by
+Judah Levine of NIST and used in his "lockclock" algorithm, a hybrid
+frequency-lock loop (FLL) gives better performance at the longer update
+intervals up to a maximum depending on the acceptable error bound.
+
+In a series of experiments and simulations, it was verified that the PLL
+model provides better performance in the regime less than about 1000 s,
+while the FLL model provides better performance above that. The
+parameters of each model were optimized by simulation for the lowest
+time and frequency error using data collected on an undisciplined
+computer clock oscillator over a period of about two weeks. The PLL/FLL
+hybrid loop has been implemented in NTP, along with certain other
+refinements described below. While it was designed primarily with ACTS
+in mind, it can be used with any NTP peer or radio clock, should that
+prove useful.
+
+To take advantage of this feature for other than the ACTS driver, where
+it is automatic, note that the default minimum poll interval is 64 s and
+default maximum poll interval 1024 s (for the ACTS driver the default
+minimum is 1024 s and default maximum 16384 s). However, using the
+minpoll and/or maxpoll parameters of the server or peer commands in the
+configuration file, it is possible to set the minimum poll interval as
+low as 16 s and the maximum poll interval as high as 16384 s. Poll
+intervals less than 64 s are useful if an exceptionally quick lock is
+required, like in real-time or portable systems. Poll intervals above
+1024 s, other than ACTS, may be useful to reduce traffic in some
+situations, such as when charges are made on a per-packet basis.
+
+Another modification to the stock NTP local clock discipline is to avoid
+errors due to old data. From a study of the stability characteristics of
+typical computer clock oscillators using both experiment and simulation,
+it was determined that data used to discipline the PLL are not generally
+useful if older than about 1000 s. This corresponds roughly to the knee
+in the Allan variance characteristic measured for a typical workstation
+oscillator. The NTP clock filter algorithm was modified to adjust the
+effective length of the shift register so that samples older than about
+1000 s are not used to determine the filtered offset, delay and
+dispersion values. This design has the useful byproduct that the time to
+acquire lock when first coming up and to declare unreachability is
+independent of the poll interval.
+
+A problem which has recurred on every occasion a leap second has been
+inserted in the UTC timescale is that not all radio clocks detect and
+implement the leap event. As a result, some radios sail right through
+the leap, become confused for periods up to 15 minutes, then reacquire
+lock. In order to cope with this, as well as other occasions where
+atypically large offsets occur, the NTP clock discipline has been
+modified to disregard offsets over 128 ms, unless (a) first coming up,
+(b) first returning to service after a period when unsynchronized, or
+(c) an interval of about 15 minutes has elapsed since the last update
+less than 128 ms was received. In addition, the discipline has been
+modified so that, if the first offset received after coming up is less
+than 128 ms, the local clock is immediately reset to that offset without
+affecting the PLL variables.
+
+It has been the experience of some users that, when first installed in a
+system, the NTP clock discipline fails to reliably lock to other peers
+and servers as configured. The indications are that the daemon locks for
+some period of time, but is unable to stabilize the frequency estimate.
+As the result, the time offsets eventually climb above 128 ms and the
+discipline unlocks again. After the 15-minute timeout, the daemon locks
+again and the cycle repeats. The problem here is that the intrinsic
+frequency error of the local clock exceeds the design capture range of
+the PLL, 100 ppm. This particular limit was selected as a compromise
+between useful maximum error indications and the tolerances found in
+typical computer clock oscillators.
+
+In spite of the tolerance assumed in the NTP specification of 100 ppm,
+the NTP daemon for Unix can operate with an intrinsic frequency error of
+over 380 ppm, depending on the values of tick and tickadj selected by
+the tickadj program. However, with errors that large, the PLL will not
+reliably lock, and the behavior noted above can occur. Formerly, the
+only remedial in cases where this happens waas a somewhat painful manual
+process where the nominal oscillator frequency is measured by some other
+means, such as eyeball-and-wristwatch, and a specific drift file
+(ntp.drift) crafted.
+
+In order to avoid the above problem, the NTP clock discipline has been
+modified to measure the frequency during periods when not locked to
+another server or radio clock. Such periods occur when the time offset
+wanders through and beyond the 128-ms window as described above. When
+synchronization is reestablished, the working frequency used by NTP is
+initialized with the measured value. Since a precise frequency
+determination is not always possible under these chaotic conditions, it
+may take more than one cycle of this type to get the residual error
+below 100 ppm and reliable lock established.
+
+David L. Mills <mills@udel.edu>
+Electrical Engineering Department
+University of Delaware
+Newark, DE 19716
+302 831 8247 fax 302 831 4316
+
+3 July 1994
diff --git a/usr.sbin/xntpd/doc/acts.c b/usr.sbin/xntpd/doc/acts.c
new file mode 100644
index 000000000000..7d3733b477d1
--- /dev/null
+++ b/usr.sbin/xntpd/doc/acts.c
@@ -0,0 +1,878 @@
+/*
+ * 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
diff --git a/usr.sbin/xntpd/doc/ntpq.8 b/usr.sbin/xntpd/doc/ntpq.8
index 1ddb829aba25..b323c73bb8d8 100644
--- a/usr.sbin/xntpd/doc/ntpq.8
+++ b/usr.sbin/xntpd/doc/ntpq.8
@@ -1,5 +1,5 @@
''' $Header
-'''
+'''
.de Sh
.br
.ne 5
@@ -48,7 +48,7 @@ ntpq - standard Network Time Protocol query program
[
.B -inp
] [
-.B -c
+.B -c
.I command
] [
.I host
@@ -57,26 +57,26 @@ ntpq - standard Network Time Protocol query program
]
.SH DESCRIPTION
.I 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.
+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.
.I Ntpq
-can also obtain and print a list of peers in a common format
-by sending multiple queries to the server.
+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
.I ntpq
-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
+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
.I localhost
-by default. If no request options are given,
+by default. If no request options are given,
.I ntpq
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
+on the NTP server running on the first host given on the command line,
+again
defaulting to
.I localhost
when no other host is specified.
@@ -86,53 +86,54 @@ will prompt for commands if the standard input is a terminal device.
.I Ntpq
uses NTP mode 6 packets to communicate with the NTP server, and hence
can be used to query any compatable server on the network which permits
-it. Note that since NTP is a UDP protocol this communication will be
+it. Note that since NTP is a UDP protocol this communication will be
somewhat unreliable, especially over large distances in terms of network
topology.
.I 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
+Command line options are described following. Specifying a command line
+option other than
.B -i
or
.B -n
will cause the specified query (queries) to be sent to the indicated
-host(s) immediately. Otherwise,
+host(s) immediately. Otherwise,
.I ntpq
-will attempt to read interactive format commands from the standard input.
+will attempt to read interactive format commands from the standard
+input.
.Ip -c 8
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
+host(s). Multiple
.B -c
options may be given.
.Ip -i 8
Force
.I ntpq
-to operate in interactive mode. Prompts will be written to the
-standard output and commands read from the standard input.
+to operate in interactive mode. Prompts will be written to the standard
+output and commands read from the standard input.
.Ip -n 8
Output all host addresses in dotted\-quad numeric format rather than
converting to the canonical host names.
.Ip -p 8
-Print a list of the peers known to the server as well as a summary
-of their state. This is equivalent to the \*(L"peers\*(R" interactive
+Print a list of the peers known to the server as well as a summary of
+their state. This is equivalent to the \*(L"peers\*(R" interactive
command.
.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 \*(L">\*(R",
-followed by a file name, to the command line.
+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 \*(L">\*(R", followed by a
+file name, to the command line.
.PP
A number of interactive format commands are executed entirely within the
.I ntpq
-program itself and do not result in NTP mode 6 requests being sent
-to a server. These are described following.
+program itself and do not result in NTP mode 6 requests being sent to a
+server. These are described following.
.PP
.B ?
[
@@ -143,7 +144,7 @@ A \*(L"?\*(R" by itself will print a list of all the command keywords
known to this incarnation of
.IR ntpq .
A \*(L"?\*(R" followed by a command keyword will print funcation and
-usage information about the command. This command is probably a better
+usage information about the command. This command is probably a better
source of information about
.I ntpq
than this manual page.
@@ -151,8 +152,8 @@ than this manual page.
.B timeout
.I millseconds
.PP
-Specify a time out period for responses to server queries. The default
-is about 5000 milliseconds. Note that since
+Specify a time out period for responses to server queries. The default
+is about 5000 milliseconds. Note that since
.I ntpq
retries each query once after a time out the total waiting time for a
time out will be twice the time out value set.
@@ -161,10 +162,10 @@ time out will be twice the time out value set.
.I milliseconds
.PP
Specify a time interval to be added to timestamps included in requests
-which require authentication. This is used to enable (unreliable) server
+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.
+clocks are unsynchronized. Actually the server does not now require time
+stamps in authenticated requests, so this command may be obsolete.
.PP
.B host
.I hostname
@@ -181,30 +182,30 @@ address.
.B verbose
]
.PP
-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.
+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.
.PP
.B keyid
.I #
.PP
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.
+authenticate configuration requests. This must correspond to a key
+number the server has been configured to use for this purpose.
.PP
.B passwd
.PP
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.
+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.
.PP
.B "hostnames yes|no"
.PP
If \*(L"yes\*(R" is specified, host names are printed in information
-displays. If \*(L"no\*(R" is given, numeric addresses are printed
-instead. The default is \*(L"yes\*(R" unless modified using the command
+displays. If \*(L"no\*(R" is given, numeric addresses are printed
+instead. The default is \*(L"yes\*(R" unless modified using the command
line
.B -n
switch.
@@ -212,15 +213,15 @@ switch.
.B raw
.PP
Causes all output from query commands is printed as received from the
-remote server. The only formating/intepretation done on the data is
-to transform nonascii data into a printable (but barely understandable)
+remote server. The only formating/intepretation done on the data is to
+transform nonascii data into a printable (but barely understandable)
form.
.PP
.B cooked
.PP
-Causes output from query commands to be \*(L"cooked\*(R". Variables
+Causes output from query commands to be \*(L"cooked\*(R". Variables
which are recognized by the server will have their values reformatted
-for human consumption. Variables which
+for human consumption. Variables which
.I ntpq
thinks should have a decodeable value but didn't are marked with a
trailing \*(L"?\*(R".
@@ -230,23 +231,24 @@ trailing \*(L"?\*(R".
.PP
Sets the NTP version number which
.I ntpq
-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.
+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.
.PP
.B authenticate
.B yes|no
.PP
Normally
.I ntpq
-does not authenticate requests unless they are write requests. The command
+does not authenticate requests unless they are write requests. The
+command
.B authenticate yes
causes
.I ntpq
-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.
+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.
.PP
.B addvars
.IR <variable_name>[=<value>] [,...]
@@ -254,25 +256,24 @@ doing a peer display.
.IR <variable_name> [,...]
.B clearvars
.PP
-The data carried by NTP mode 6 messages consists of a list of items
-of the form
+The data carried by NTP mode 6 messages consists of a list of items of
+the form
.IP "" 8
<variable_name>=<value>
.PP
where the \*(L"=<value>\*(R" is ignored, and can be omitted, in requests
to the server to read variables.
.I Ntpq
-maintains an internal list in which data to be included in control messages
-can be assembled, and sent using
-the
+maintains an internal list in which data to be included in control
+messages can be assembled, and sent using the
.B readlist
and
.B writelist
-commands described below. The
+commands described below. The
.B 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
+list. If more than one variable is to be added, the list should be
+comma\-separated and not contain white space. The
.B rmvars
command can be used to remove individual variables from the list, while
the
@@ -293,16 +294,15 @@ Exit
Each peer known to an NTP server has a 16 bit integer
.I association
.I 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
+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
.B peers
command, which will send a preprogrammed series of messages to obtain
the data it needs, and the
@@ -313,57 +313,53 @@ commands, which will iterate over a range of associations.
.PP
.B associations
.PP
-Obtains and prints 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
+Obtains and prints 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
+status word. Note that the data returned by the \*(L"associations\*(R"
+command is cached internally in
.IR ntpq .
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
+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
.I &index
may be used as an alternative.
.PP
.B lassocations
.PP
Obtains and prints a list of association identifiers and peer statuses
-for all associations for which the server is maintaining state. This
-command differs from the
-\*(L"associations\*(R"
-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
-\*(L"associations\*(R"
-command is used, but are included in the output of
-\*(L"lassociations\*(R".
+for all associations for which the server is maintaining state. This
+command differs from the \*(L"associations\*(R" 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 \*(L"associations\*(R" command is used, but are included in the
+output of \*(L"lassociations\*(R".
.PP
.B passociations
.PP
-Prints association data concerning in\-spec peers from the internally cached
-list of associations. This command performs
-identically to the \*(L"associations\*(R" except that it displays the
-internally stored data rather than making a new query.
+Prints association data concerning in\-spec peers from the internally
+cached list of associations. This command performs identically to the
+\*(L"associations\*(R" except that it displays the internally stored
+data rather than making a new query.
.PP
.B lpassociations
.PP
Print data for all associations, including out\-of\-spec client
-associations, from the internally cached list of associations. This command
-differs from \*(L"passociations\*(R" only when dealing with fuzzballs.
+associations, from the internally cached list of associations. This
+command differs from \*(L"passociations\*(R" only when dealing with
+fuzzballs.
.PP
.B pstatus
.I assocID
.PP
-Sends 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 hexidecimal and in pidgeon English.
+Sends 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 hexidecimal and in pidgeon English.
.PP
.B readvar
[
@@ -373,13 +369,12 @@ both in hexidecimal and in pidgeon English.
]
.PP
Requests 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.
+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.
.PP
.B rv
[
@@ -405,12 +400,12 @@ request, except the specified variables are written instead of read.
.I assocID
]
.PP
-Requests 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.
+Requests 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.
.PP
.B rl
[
@@ -428,8 +423,7 @@ command.
.PP
Like the
.B readlist
-request, except the internal list variables are written instead of
-read.
+request, except the internal list variables are written instead of read.
.PP
.B mreadvar
.I assocID
@@ -441,7 +435,7 @@ read.
Like the
.B readvar
command except the query is done for each of a range of (nonzero)
-association IDs. This range is determined from the association list
+association IDs. This range is determined from the association list
cached by the most recent
.B associations
command.
@@ -464,7 +458,7 @@ command.
Like the
.B readlist
command except the query is done for each of a range of (nonzero)
-association IDs. This range is determined from the association list
+association IDs. This range is determined from the association list
cached by the most recent
.B associations
command.
@@ -485,15 +479,16 @@ command.
.IR <variable_name>[=<value>] [,...]
]
.PP
-Requests that a list of the server's clock variables be sent. Servers
+Requests 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 \*(L"system clock\*(R" 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.
+positively to this. If the association identifier is omitted or zero the
+request is for the variables of the \*(L"system clock\*(R" 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.
.PP
.B cv
[
@@ -509,40 +504,42 @@ command.
.PP
.B peers
.PP
-Obtains 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 polling interval,
-in seconds, the reachability
-register, in octal, and the current estimated delay, offset and dispersion
-of the peer, all in seconds.
+Obtains 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; \*(L"x\*(R" designated falsticker by the
-intersection algorithm; \*(L".\*(R" culled from the end of the candidate
-list; \*(L"-\*(R" discarded by the clustering algorithmi; \*(L"+\*(R"
-included in the final selection set; \*(L"#\*(R" selected for synchronizatio;n
-but distance exceeds maximum; \*(L"*\*(R" selected for synchronization; and
-\*(L"o\*(R" selected for synchronization, pps signal in use.
+clock selection process. The codes mean: <sp> discarded due to high
+stratum and/or failed sanity checks; \*(L"x\*(R" designated falsticker
+by the intersection algorithm; \*(L".\*(R" culled from the end of the
+candidate list; \*(L"-\*(R" discarded by the clustering algorithmi;
+\*(L"+\*(R" included in the final selection set; \*(L"#\*(R" selected
+for synchronizatio;n but distance exceeds maximum; \*(L"*\*(R" selected
+for synchronization; and \*(L"o\*(R" selected for synchronization, pps
+signal in use.
.PP
Note that since the
.B 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.
+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
-\*(L"REFCLK(<implementation number>, <parameter>)\*(R". On \*(L"hostnames no\*(R"
-only IP\-addresses will be displayed.
+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 \*(L"REFCLK(<implementation number>, <parameter>)\*(R". On
+\*(L"hostnames no\*(R" only IP\-addresses will be displayed.
.PP
.B lpeers
.PP
Like
.BR 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
+state is printed. This can produce a much longer list of peers from
fuzzball servers.
.PP
.B opeers
@@ -561,6 +558,6 @@ messages about invalid associations occuring 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.
+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.
diff --git a/usr.sbin/xntpd/doc/xntpd.8 b/usr.sbin/xntpd/doc/xntpd.8
index 84b785bd54f0..77f64f93cb09 100644
--- a/usr.sbin/xntpd/doc/xntpd.8
+++ b/usr.sbin/xntpd/doc/xntpd.8
@@ -1,5 +1,5 @@
''' $Header
-'''
+'''
.de Sh
.br
.ne 5
@@ -46,9 +46,9 @@ xntpd - Network Time Protocol daemon
.SH SYNOPSIS
.B xntpd
[
-.B -ab
+.B -abdm
] [
-.B -c
+.B -c
.I conffile
] [
.B -e
@@ -60,14 +60,11 @@ xntpd - Network Time Protocol daemon
.B -k
.I keyfile
] [
-.B -l
-.I loopfile
-] [
.B -p
.I pidfile
] [
.B -r
-.I broaddelay
+.I broadcastdelay
] [
.B -s
.I statsdir
@@ -82,42 +79,52 @@ xntpd - Network Time Protocol daemon
.I variable
]
.SH DESCRIPTION
-.I Xntpd
-is a daemon which maintains a Unix system's time\-of\-day in agreement
-with Internet standard time servers.
-.I Xntpd
+.I xntpd
+is a daemon which sets and maintains a Unix system time\-of\-day in
+agreement with Internet standard time servers.
+.I xntpd
is a complete implementation of the Network Time Protocol (NTP) version
-3 standard as defined by RFC 1305 and also retains
-compatability with version 1 and 2 servers as defined
-by RFC 1059 and RFC 1119, respectively.
-.I Xntpd
-does all computations in fixed point arithmetic and is entirely free of
-floating point code. The computations done in the protocol and clock
-adjustment code are carried out with high precision and with attention
-to the details which might introduce systematic bias into the integrations,
-to try to maintain an accuracy suitable for synchronizing with even the
+3 standard, as defined by RFC 1305, but also retains compatability with
+version 1 and 2 servers as defined by RFC 1059 and RFC 1119,
+respectively.
+.I xntpd
+does all computations in fixed point arithmetic and requires no floating
+point code. The computations done in the protocol and clock adjustment
+code are carried out with high precision and with attention to the
+details which might introduce systematic bias into the computations, to
+try to maintain an accuracy suitable for synchronizing with even the
most precise external time source.
.PP
Ordinarily,
.I xntpd
-reads its configuration from a file at startup time. The default configuration
-file is
-.I /etc/ntp.conf,
-though this may be overridden from the command line. It is also possible to
-specify a working, though limited,
+reads its configuration from a configuration file at startup time. The
+default configuration file name is
+.IR /etc/ntp.conf,
+although this may be overridden from the command line. It is also
+possible to specify a working, although limited,
.I xntpd
configuration entirely on the command line, obviating the need for a
-configuration file. This may be particularly appropriate when xntpd is
-to be configured as a broadcast client, with all peers being determined
-by listening to broadcasts at run time. Various internal
+configuration file. This may be particularly appropriate when
+.I xntpd
+is to be configured as a broadcast or multicast client, with all peers
+being determined by listening to broadcasts at run time. Various
+internal
.I xntpd
-variables can be displayed, and configuration options altered, while the
+variables can be displayed and configuration options altered while the
daemon is running through use of the
.IR ntpq (8)
and
.IR xntpdc (8)
programs.
.PP
+The daemon can operate in any of several modes, including symmetric
+active/passive, client/server and broadcast/multicast. A
+broadcast/multicast client can automatically discover remote servers,
+compute one-way delay correction factors and comfigure itself
+automatically. This makes it possible to deploy a fleet of workstations
+without specifying a configuration file or configuration details
+specific to its environment.
+.PP
The following command line arguments are understood by
.I xntpd
(see the configuration file description for a more complete functional
@@ -129,42 +136,46 @@ listen for broadcast NTP and sync to this if available
.Ip -c 8
specify an alternate configuration file
.Ip -d 8
-specify debugging options
+specify debugging mode. This flag may occur multiple times, with each
+occurance indicating greater detail of display.
.Ip -e 8
-specify the time (in seconds) it takes to compute the NTP encryption field
-on this computer
-.Ip -f 8
+specify the time (in seconds) it takes to compute the NTP encryption
+field on this computer
+.Ip -f driftfile 8
specify the location of the drift file
.Ip -k 8
-specify the location of the file which contains the NTP authentication keys
+specify the location of the file which contains the NTP authentication
+keys
.Ip -m 8
-listen for multicast NTP and sync to this if available (requires multicast
-kernel)
+listen for multicast messages and synchronize to them if available
+(requires multicast kernel)
.Ip -p 8
specify the name of the file to record the daemon's process id
.Ip -r 8
-specify the default round trip delay (in seconds)
-to be used when synchronizing to broadcasts
+ordinarily, the daemon automatically compensates for the network delay
+between the broadcast/multicast server and the client; if the
+calibration procedure fails, use the specified the default delay (in
+seconds)
.Ip -s 8
-specify a directory to be used for creating statistics files
-.Ip -t 8
+specify the directory to be used for creating statistics files
+.Ip -t trustedkey 8
add a key number to the trusted key list
.Ip -v 8
add a system variable
.Ip -V 8
add a system variable listed by default
-.SH "CONFIGURATION FILE OPTIONS"
-.IR Xntpd 's
-configuration file is relatively free format. Comments, which may be
-freely inserted, begin with a \*(L"#\*(R" character
-and extend to the end of the line. Blank lines are ignored. Configuration
-statements include an initial keyword followed by white space separated
-arguments, some of which may be optional. Configuration statements
-may not be continued over multiple lines. Arguments may be network
-numbers (which must be written in numeric, dotted\-quad form), integers,
-floating point numbers (when specifying times in seconds) and text
-strings. Optional arguments are delimited by \*(L"[]\*(R" in the following
-descriptions, while alternatives are separated by \*(L"|\*(R".
+.SH "CONFIGURATION OPTIONS"
+.I xntpd 's
+configuration file format is similar to other Unix configuration files.
+Comments begin with a \*(L"#\*(R" character and extend to the end of the
+line. Blank lines are ignored. Configuration commands consist of an
+initial keyword followed by a list of arguments, some of which may be
+optional, separated by whitespace. These commands may not be continued
+over multiple lines. Arguments may be host names, host addresses written
+in numeric, dotted\-quad form, integers, floating point numbers (when
+specifying times in seconds) and text strings. Optional arguments are
+delimited by \*(L"[]\*(R" in the following descriptions, while
+alternatives are separated by \*(L"|\*(R".
.PP
.B peer
.I host_address
@@ -199,163 +210,150 @@ descriptions, while alternatives are separated by \*(L"|\*(R".
.B version
.I #
] [
-.B prefer
+.B ttl
+.I #
]
.PP
-These three statements specify various time servers to be used and/or
-time services to be provided. The
+These three commands specify various time servers to be used and/or time
+services to be provided. The
.B peer
-statement specifies that the given host is to be polled in
-\*(L"symmetric active\*(R" mode, i.e. that the host is requested to
-provide time which you might synchronize to and, in addition, indicates
-that you are willing to have to remote host synchronize to your time
-if need be. The
+command specifies that the local server is to operate in \*(L"symmetric
+active\*(R" mode with the remote server
+.I host_address
+named in the command. In this mode the local server can be synchronized
+to the remote server and, in addition, the remote server can be
+synchronized by the local server. This is useful in a network of servers
+where, depending on various failure scenarios, either the local or
+remote server host may be the better source of time. The
.B server
-statement specifies that the given host is to be polled in
-\*(L"client\*(R" mode, i.e. that the host is requested to provide
-time which you might synchronize with but that you are unwilling to have
-the remote host synchronize to your own time. The
+command specifies that the local server is to operate in
+\*(L"client\*(R" mode with the remote server named in the command. In
+this mode the local server can be synchronized to the remote server, but
+the remote server can never be synchronized to the local server. The
.B broadcast
-statement requests your local daemon to transmit broadcast NTP to
-the specified address. The latter is usually the broadcast address
-on [one of] your local network[s] or a multicast address assigned to
-NTP. The Numbers Czar has assigned the address 224.0.1.1 to NTP; this
-is presently the only number that should be used. Note that the use
-of multicast requires a multicast kernel.
+command specifies that the local server is to operate in
+\*(L"broadcast\*(R" mode where the local server sends periodic broadcast
+messages to a client population at the broadcast/multicast address named
+in the command. Ordinarily, this specification applies only to the local
+server operating as a transmitter; for operation as a broadcast client,
+see the
+.B broadcastclient
+or
+.B multicastclient
+commands elsewhere in this document. In this mode the
+.I host_address
+is usually the broadcast address on [one of] the local network[s] or a
+multicast address assigned to NTP. The Numbers Czar has assigned the
+address 224.0.1.1 to NTP; this is presently the only number that should
+be used. Note that the use of multicast features requires a multicast
+kernel, which is not yet ubiquitous in vendor products.
.PP
The
.B key
option, when included, indicates that all packets sent to the address
are to include authentication fields encrypted using the specified key
-number (the range of which is that of an unsigned 32 bit integer). The
-default is to not include an encryption field. The
+number (the range of which is that of an unsigned 32 bit integer). The
+default is to not include an encryption field. The
.B version
option allows one to specify the version number to be used for outgoing
-NTP packets. Versions 1, 2, and 3 are the choices, version 3 is the default.
-The
+NTP packets. Versions 1, 2, and 3 are the choices, version 3 is the
+default. The
.B prefer
-option marks the host as a preferred host. All other things being equal, this
-host will be chosen for synchronization among a set of correctly operating
-hosts.
-.PP
-.B precision
-.I #
+option marks the host as a preferred host. All other things being equal,
+this host will be chosen for synchronization among a set of correctly
+operating hosts. The
+.B ttl
+option is used only with the broadcast mode. It specifies the time-to-
+live (TTL) to use on multicast packets. Selection of the proper value,
+which defaults to 127, is something of a black art and must be
+coordinated with the network admistrator(s).
.PP
-Indicates the precision of local timekeeping. The value is an integer
-which is approximately the base 2 logarithm of the local timekeeping
-precision in seconds. By default this value is set to -6.
+.B broadcastclient
.PP
-The precision declared by an implementation can affect several aspects
-of server operation, and can be used as a tuning parameter for your
-synchronization subnet. It should probably not be changed from the
-default value, however, unless there is a good reason to do so.
+This directs the local server to listen for broadcast messages on the
+local network, in order to discover other servers on the same subnet.
+Upon hearing a broadcast message for the first time, the local server
+measures the nominal network delay using a brief client/server exchange
+with the remote server, then enters the \*(L"broadcastclient\*(R" mode,
+in which it listens for and synchronizes to succeeding broadcast
+messages. Note that, in order to avoid accidental or malicious
+disruption in this mode, both the local and remote servers must operate
+using authentication and the same trusted key and key identifier.
.PP
-.B logfile
-.I filename
+.B multicastclient
+[
+.I IP address ...
+]
.PP
-Gives the file which is to be used instead of syslog output. This
-configuration option is also a compile time option (SYSLOG_FILE).
-So in order to be able to use this xntpd must be compiled with
--DSYSLOG_FILE.
+This command is used in the same way as the
+.IR broadcastclient
+command, but operates using IP multicasting. Support for this function
+requires a multicast kernel and the use of authentication. If one or
+more IP addresses are given, the server joins the respective multicast
+group(s). If none are given, the IP address assigned to NTP (224.0.1.1)
+is assumed.
.PP
.B driftfile
.I filename
.PP
-Specifies the name of the file used to record the \*(L"drift\*(R" (or
-frequency error) value
-.I xntpd
-has computed. If the file exists on startup, it is read and the value
-used to initialize
-.IR xntpd 's
-internal value of the frequency error. The file is then updated once
-every hour by replacing the old file with a new one containing the
-current value of the frequency error. Note that the file is updated
-by first writing the current drift value into a temporary file and
-then using
+This command specifies the name of the file used to record the frequency
+offset of the local clock oscillator. If the file exists, it is read at
+startup in order to set the initial frequency offset and then updated
+once per hour with the current offset computed by the daemon. If the
+file does not exist or this command is not given, the initial frequency
+offset is assumed zero. In this case, it may take some hours for the
+frequency to stabilize and the residual timing errors to subside. The
+file contains a single floating point value equal to the offset in
+parts-per-million (ppm). Note that the file is updated by first writing
+the current drift value into a temporary file and then using
.IR rename (3)
-to replace the old version. This implies that
+to replace the old version. This implies that
.I xntpd
must have write permission for the directory the drift file is located
in, and that file system links, symbolic or otherwise, should probably
be avoided.
.PP
-.B monitor yes|no
-.PP
-Indicates whether the
-.I xntpd
-traffic monitoring function should be enabled or not. When enabled,
-this causes the origin address of each packet received by the server
-to be recorded along with a limited amount of additional information, such
-as the mode of the request and whether it originated from an NTP server port
-or not. Traffic monitoring data may be inspected using the
-.IR xntpdc (8)
-.I monlist
-command. The default is \*(L"no\*(R", i.e. traffic monitoring should not
-be done.
-.PP
-Note that the traffic monitoring facility will increase the CPU used
-by
-.IR xntpd ,
-as well as increasing the daemon's memory utilization by as much as
-8.5 kilobytes. This facility is normally useful for the detection of
-peers with malfunctioning software or which are sending bogus data. It
-is primarily intended for very popular servers which exchange time with
-large numbers of peers, though it may also be useful for access monitoring
-of local servers if you are willing to accept the overhead.
-.PP
-.B broadcastclient
-.PP
-This directs the local server should listen for, and attempt to
-synchonize to, broadcast NTP. Note that authentication is required in
-this mode.
-.PP
-.B multicastclient
+.B enable auth|bclient|pll|monitor|stats
[
-.I IP address ...
+.I ...
]
.PP
-This directs the local server should listen for, and attempt to
-synchonize to, multicast NTP. This function requires a multicast kernel
-and the use of authentication.
-If one or more IP addresses are given, the server joins the respective
-multicast group. If none are given, the default address assigned to
-NTP (224.0.1.1) is assumed.
-.PP
-.B broadcastdelay
-.I seconds
-.PP
-Specifies the default round trip delay to the host whose broadcasts
-are being synchronized to. The value is specified in seconds and is
-typically (for ethernet) a number between 0.007 and 0.015 seconds. This
-initial estimate may be improved by polling each server to determine a
-more accurate value. Defaults to 0.008 seconds.
-.PP
-.B authenticate yes|no
-.PP
-Indicates whether the local server should operate in authenticate mode
-or not. If \*(L"yes\*(R", only peers which include an authentication field
-encrypted with one of our trusted keys (see below) will be considered
-as candidates for synchonizing to. The default is \*(L"no\*(R".
-.PP
-.B authdelay
-.I seconds
+Provides a way to enable various server options. Flags not mentioned are
+unaffected. The \*(L"auth\*(R" 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 \*(L"bclient\*(R" 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 \*(L"pll\*(R" 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 NTP is used only to provide
+synchronization to other clients. The \*(L"monitor\*(R" flag enables the
+monitoring facility (see elsewhere), with default enable (on). The
+\*(L"stats\*(R" flag enables statistics facility filegen (see
+description elsewhere.), with default enable (on).
+.PP
+.B disable auth|bclient|pll|monitor|stats
+[
+.I ...
+]
.PP
-Indicates the amount of time it takes to encrypt an NTP authentication
-field on the local computer. This value is used to correct transmit
-timestamps when the authentication is used on outgoing packets. The
-value usually lies somewhere in the range 0.0001 seconds to 0.003 seconds,
-though it is very dependent on the CPU speed of the host computer. The
-value is usually computed using the
-.I authspeed
-program included with the distribution.
+Provides a way to disable various server options. Flags not mentioned
+are unaffected. The flags presently available are described under the
+enable command.
+
+.SH "AUTHENTICATION OPTIONS"
.PP
.B keys
.I filename
.PP
-Specifies the name of a file which contains the encryption keys which
-are to be used by
-.IR xntpd .
-The format of this file is described below.
+This command specifies the name of a file which contains the encryption
+keys and key identifiers used by
+.I xntpd
+when operating in authenticated mode. The format of this file is
+described later in this document.
.PP
.B trustedkey
.I #
@@ -363,43 +361,67 @@ The format of this file is described below.
.I "# ..."
]
.PP
-Allows the specification of the encryption key numbers which are trusted
-for the purposes of determining peers suitable for time sychonization,
-when authentication is enabled. Only peers using one of these keys for
-encryption of the authentication field, and whose authenticity can be
-verified by successful decryption, will be considered as synchonization
-candidates. The arguments are 32 bit unsigned integers. Note, however,
-that NTP key 0 is fixed and globally known. If meaningful authentication
-is to be performed the 0 key should not be trusted.
+This command is used to specify the encryption key identifiers which are
+trusted for the purposes of authenticating peers suitable for
+sychonization. The authentication procedures require that both the local
+and remote servers share the same key and key identifier for this
+purpose, although different keys can be used with different servers. The
+arguments are 32 bit unsigned integers. Note, however, that NTP key 0 is
+fixed and globally known. If meaningful authentication is to be
+performed the 0 key should not be trusted.
.PP
.B requestkey
.I #
.PP
-.I Xntpd
-allows run time reconfiguration to be performed using the
+This command specifies the key identifier to use with the
.IR xntpdc (8)
-program. Such requests must be authenticated. The
-.B requestkey
-statement allows the specification of a 32 bit unsigned integer
-key number to be used for authenticating such requests. Note that
-if no
+program, which is useful to diagnose and repair problems that affect
+.IR xntpd (8)
+operation. The operation of the
+.I xntpdc
+program are specific to this particular implementation of xntpd and can
+be expected to work only with this and previous versions of the daemon.
+Requests from a remote xntpdc program which affect the state of the
+local server must be authenticated, which requires bot the remote
+program and local server share a common key and key identifier. The
+argument to this command is a 32 bit unsigned integer. If no
.B requestkey
-statement is included in the configuration file the run time reconfiguration
-facility will be disabled.
+command is included in the configuration file, or if the keys don't
+match, such requests will be ignored.
.PP
.B controlkey
.I #
.PP
-Certain changes can be made to the
+This command specifies the key identifier to use with the
+.IR ntpq (8)
+program, which is useful to diagnose and repair problems that affect
+.IR xntpd (8)
+operation. The operation of the
+.IR ntpq
+program and
.I xntpd
-server via mode 6 control messages, in particular the setting of
-leap second indications in a server with a radio clock.
-The
-.B controlkey
-statement specifies an encription key number to be used for authenticating
-such messages. Omitting this statement will cause control messages
-which would change the state of the server to be ignored.
+conform to those specified in RFC 1305. Requests from a remote
+.I ntpq
+program which affect the state of the local server must be
+authenticated, which requires bot the remote program and local server
+share a common key and key identifier. The argument to this command is a
+32 bit unsigned integer. If no
+.B requestkey
+command is included in the configuration file, or if the keys don't
+match, such requests will be ignored.
+.PP
+.B authdelay
+.I seconds
.PP
+Indicates the amount of time it takes to encrypt an NTP authentication
+field on the local computer. This value is used to correct transmit
+timestamps when the authentication is used on outgoing packets. The
+value usually lies somewhere in the range 0.0001 seconds to 0.003
+seconds, though it is very dependent on the CPU speed of the host
+computer. The value is usually computed using the
+.I authspeed
+program included with the distribution.
+.SH "ACCESS CONTROL OPTIONS"
.B restrict
.I address
[
@@ -411,202 +433,125 @@ which would change the state of the server to be ignored.
.I ...
]
.PP
-.I Xntpd
-implements a general purpose address\-and\-mask based restriction
-list. The list is sorted by address and by mask, and the list is
-searched in this order for matches, with the last match found defining
-the restriction flags associated with the incoming packets. The source
-address of incoming packets is used for the match, with the 32 bit address
-being and'ed with the mask associated with the restriction entry and
-then compared with the entry's address (which has also been and'ed with
-the mask) to look for a match. The \*(L"mask\*(R" argument defaults
+.I xntpd
+implements a general purpose address\-and\-mask based restriction list.
+The list is sorted by address and by mask, and the list is searched in
+this order for matches, with the last match found defining the
+restriction flags associated with the incoming packets. The source
+address of incoming packets is used for the match, with the 32 bit
+address being and'ed with the mask associated with the restriction entry
+and then compared with the entry's address (which has also been and'ed
+with the mask) to look for a match. The \*(L"mask\*(R" argument defaults
to 255.255.255.255, meaning that the \*(L"address\*(R" is treated as the
-address of an individual host. A default entry (address 0.0.0.0, mask
+address of an individual host. A default entry (address 0.0.0.0, mask
0.0.0.0) is always included and, given the sort algorithm, is always the
-first entry in the list. Note that, while \*(L"address\*(R" is normally
-given as a dotted\-quad address, the text string \*(L"default\*(R", with
-no mask option, may be used to indicate the default entry.
-.PP
-In the current implementation flags always restrict access, i.e. an entry
-with no flags indicates that free access to the server is to be given. The
-flags are not orthogonal, in that more restrictive flags will often make
-less restrictive ones redundant. The flags can generally be classed into
-two catagories, those which restrict time service and those which restrict
-informational queries and attempts to do run time reconfiguration of the
-server. One or more of the following flags may be specified:
+first entry in the list. Note that, while \*(L"address\*(R" is normally
+given in dotted\-quad format, the text string \*(L"default\*(R", with no
+mask option, may be used to indicate the default entry.
+.PP
+In the current implementation, flags always restrict access, i.e. an
+entry with no flags indicates that free access to the server is to be
+given. The flags are not orthogonal, in that more restrictive flags will
+often make less restrictive ones redundant. The flags can generally be
+classed into two catagories, those which restrict time service and those
+which restrict informational queries and attempts to do run time
+reconfiguration of the server. One or more of the following flags may be
+specified:
.Ip ignore 10
-Ignore all packets from hosts which match this entry. If this flag
-is specified neither queries nor time server polls will be responded
-to.
+Ignore all packets from hosts which match this entry. If this flag is
+specified neither queries nor time server polls will be responded to.
.Ip noquery 10
-Ignore all NTP mode 6 and 7 packets (i.e. information queries and configuration
-requests) from the source. Time service is not affected.
+Ignore all NTP mode 6 and 7 packets (i.e. information queries and
+configuration requests) from the source. Time service is not affected.
.Ip nomodify 10
-Ignore all NTP mode 6 and 7 packets which attempt to modify the state of the
-server (i.e. run time reconfiguration). Queries which return information
-are permitted.
+Ignore all NTP mode 6 and 7 packets which attempt to modify the state of
+the server (i.e. run time reconfiguration). Queries which return
+information are permitted.
.Ip notrap 10
Decline to provide mode 6 control message trap service to matching
-hosts. The trap service is a subsystem of the mode 6 control message
+hosts. The trap service is a subsystem of the mode 6 control message
protocol which is intended for use by remote event logging programs.
.Ip lowpriotrap 10
-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.
+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.
.Ip noserve 10
-Ignore NTP packets whose mode is other than 6 or 7. In effect, time service is
-denied, though queries may still be permitted.
+Ignore NTP packets whose mode is other than 6 or 7. In effect, time
+service is denied, though queries may still be permitted.
.Ip nopeer 10
-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.
+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.
.Ip notrust 10
Treat these hosts normally in other respects, but never use them as
synchronization sources.
.Ip limited 10
-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 \*(L"client_limit\*(R" hosts
-that have shown up at the server and that have been active during the
-last \*(L"client_limit_period\*(R" seconds are accepted. Requests from
-other clients from the same net are rejected. Only time request
-packets are taken into account. \*(L"Private\*(R", \*(L"control\*(R",
-and \*(L"broadcast\*(R" 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
-.IR xntpd .
-Thus, monitoring is active as long as there is a restriction entry
-with the \*(L"limited\*(R" flag. The default value for
-\*(L"client_limit\*(R" is 3. The default value for
-\*(L"client_limit_period\*(R" is 3600 seconds.
+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 \*(L"client_limit\*(R" hosts that have
+shown up at the server and that have been active during the last
+\*(L"client_limit_period\*(R" seconds are accepted. Requests from other
+clients from the same net are rejected. Only time request packets are
+taken into account. \*(L"Private\*(R", \*(L"control\*(R", and
+\*(L"broadcast\*(R" 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
+.I xntpd .
+Thus, monitoring is active as long as there is a restriction entry with
+the \*(L"limited\*(R" flag. The default value for \*(L"client_limit\*(R"
+is 3. The default value for \*(L"client_limit_period\*(R" is 3600
+seconds.
.Ip ntpport 10
This is actually a match algorithm modifier, rather than a restriction
-flag. Its presence causes the restriction entry to be matched only if
-the source port in the packet is the standard NTP UDP port (123). Both
-\*(L"ntpport\*(R" and non\-\*(L"ntpport\*(R" may be specified. The
+flag. Its presence causes the restriction entry to be matched only if
+the source port in the packet is the standard NTP UDP port (123). Both
+\*(L"ntpport\*(R" and non\-\*(L"ntpport\*(R" may be specified. The
\*(L"ntpport\*(R" is considered more specific and is sorted later in the
list.
.PP
-Default restriction list entries, with the flags \*(L"ignore, ntpport\*(R",
-for each of the local host's interface addresses are inserted into the
-table at startup to prevent the server from attempting to synchronize to
-its own time. A default entry is also always present, though if it is
-otherwise unconfigured no flags are associated with the default entry (i.e.
-everything besides your own NTP server is unrestricted).
+Default restriction list entries, with the flags \*(L"ignore,
+ntpport\*(R", for each of the local host's interface addresses are
+inserted into the table at startup to prevent the server from attempting
+to synchronize to its own time. A default entry is also always present,
+though if it is otherwise unconfigured no flags are associated with the
+default entry (i.e. everything besides your own NTP server is
+unrestricted).
.PP
The restriction facility was added to allow the current access policies
-of the time servers running on the NSFnet backbone to be implemented with
+of the time servers running on the NSFnet backbone to be implemented
+with
.I xntpd
-as well. While this facility may be otherwise useful for keeping unwanted or
-broken remote time servers from affecting your own, it should not be
-considered an alternative to the standard NTP authentication facility. Source
-address based restrictions are easily circumvented by a determined cracker.
+as well. While this facility may be otherwise useful for keeping
+unwanted or broken remote time servers from affecting your own, it
+should not be considered an alternative to the standard NTP
+authentication facility. Source address based restrictions are easily
+circumvented by a determined cracker.
.PP
.B clientlimit
.I limit
.PP
-Sets \*(L"client_limit\*(R" to \*(L"limit\*(R", allows configuration
-of client limitation policy. This variable defines the number of
-clients from the same network that are allowed to use the server.
+Sets \*(L"client_limit\*(R" to \*(L"limit\*(R", allows configuration of
+client limitation policy. This variable defines the number of clients
+from the same network that are allowed to use the server.
.PP
.B clientperiod
.I period
.PP
Sets \*(L"client_limit_period\*(R", allows configuration of client
-limitation policy. This variable specifies the number
-of seconds after which a client is considered inactive and thus no
-longer is counted for client limit restriction.
-.PP
-.B trap
-.I host_address
-[
-.B port
-.I port_number
-] [
-.B interface
-.I interface_addess
-]
-.PP
-Configures a trap receiver at the given host address and port number,
-sending messages with the specified local interface address. If the
-port number is unspecified a value of 18447 is used. If the interface
-address is not specified the message is sent with a source address
-which is that of the local interface the message is sent through. Note
-that on a multihomed host the interface used may vary from time to time
-with routing changes.
-.PP
-The trap receiver will generally log event messages and other information
-from the server in a log file. While such monitor programs may also
-request their own trap dynamically, configuring a trap receiver will
-ensure that no messages are lost when the server is started.
-.PP
-.B maxskew
-.I seconds
-.PP
-This command is obsolete and not available in this version of
-.I xntpd.
-.PP
-.B select
-.I algorithm_number
-.PP
-This command is obsolete and not available in this version of
-.I xntpd.
-.PP
-.B setvar
-.I variable
-.I [default]
-.PP
-This command adds an additional system variable. These variables can be
-used to distribute additional information such as the access policy. If
-the variable of the from <name>=<value> is followed by the
-.I default
-keyword the variable will be listed as part of the default system
-variables (ntpq rv command). These additional variables serve informational
-purposes only. They are not related to the protocol other that they can be
-listed. The known protocol variables will always overide any variables defined
-via the
-.I setvar
-mechanism.
-.PP
-There are three special variables that contain the names of all variable of
-the same group. The
-.I sys_var_list
-holds the names of all system variables. The
-.I peer_var_list
-holds the names of all peer variables and the
-.I clock_var_list
-hold the names of the reference clock variables.
-.PP
-.B resolver
-.I /path/xntpres
-.PP
-Normally, names requiring resolution (rather than numeric addresses)
-in the configuration file are resolved by code internal to
-.I xntpd;
-However, in those cases that require it, the code can be installed
-in a standalone program called
-.I xntpres.
-In these cases the full path to the
-.I xntpres
-program is given as the argument the command.
-As
-.I xntpres
-makes use of mode 7 runtime reconfiguration, this facility must also be
-enabled if the procedure is to exceed (see the
-.B requestkey
-and
-.B keys
-statements above).
+limitation policy. This variable specifies the number of seconds after
+which a client is considered inactive and thus no longer is counted for
+client limit restriction.
+.SH "MONITORING OPTIONS"
.PP
.B statsdir
.I /directory path/
.PP
-Indicates the full path of a directory where statistics files should
-be created (see below). This keyword allows the (otherwise constant) filegen
-filename prefix to be modified for file generation sets used for
+Indicates the full path of a directory where statistics files should be
+created (see below). This keyword allows the (otherwise constant)
+filegen filename prefix to be modified for file generation sets used for
handling statistics logs (see
.B filegen
statement below).
@@ -614,41 +559,41 @@ statement below).
.B statistics
.IR name \.\.\.
.PP
-Enables writing of statistics records.
-Currently, three kinds of statistics are supported.
+Enables writing of statistics records. Currently, three kinds of
+statistics are supported.
.Ip loopstats 10
-enables recording of loop filter statistics information.
-Each update of the local clock outputs a line of the
-following form to the file generation set named \*(L"loopstats\*(R":
+enables recording of loop filter statistics information. Each update of
+the local clock outputs a line of the following form to the file
+generation set named \*(L"loopstats\*(R":
.PP
.RS 5
48773 10847.650 0.0001307 17.3478 2
.RE
.RS 10
-The first two fields show the date (Modified Julian Day) and time (seconds
-and fraction past UTC midnight). The next three fields show time offset
-in seconds, frequency offset in parts-per-million and time constant of
-the clock-discipline algorithm at each update of the clock.
+The first two fields show the date (Modified Julian Day) and time
+(seconds and fraction past UTC midnight). The next three fields show
+time offset in seconds, frequency offset in parts-per-million and time
+constant of the clock-discipline algorithm at each update of the clock.
.RE
.Ip peerstats 10
enables recording of peer statistics information. This includes
statistics records of all peers of a NTP server and of the 1-pps signal,
-where present and configured. Each
-valid update appends a line of the following form to the current
-element of a file generation set named \*(L"peerstats\*(R":
+where present and configured. Each valid update appends a line of the
+following form to the current element of a file generation set named
+\*(L"peerstats\*(R":
.PP
.RS 5
48773 10847.650 127.127.4.1 9714 -0.001605 0.00000 0.00142
.RE
.RS 10
-The first two fields show the date (Modified Julian Day) and time (seconds
-and fraction past UTC midnight). The next two fields show the peer
-address in dotted-quad notation and status,
-respectively. The status field is encoded in hex in the format described
-in Appendix A of the NTP specification RFC 1305. The final three fields
-show the offset, delay and dispersion, all in seconds.
+The first two fields show the date (Modified Julian Day) and time
+(seconds and fraction past UTC midnight). The next two fields show the
+peer address in dotted-quad notation and status, respectively. The
+status field is encoded in hex in the format described in Appendix A of
+the NTP specification RFC 1305. The final three fields show the offset,
+delay and dispersion, all in seconds.
.RE
.Ip clockstats 10
enables recording of clock driver statistics information. Each update
@@ -656,23 +601,23 @@ received from a clock driver outputs a line of the following form to the
file generation set named \*(L"clockstats\*(R":
.PP
.RS 5
-49213 525.624 127.127.4.1 93 226 00:08:29.606 D
+49213 525.624 127.127.4.1 93 226 00:08:29.606 D
.RE
.RS 10
-The first two fields show the date (Modified Julian Day) and time (seconds
-and fraction past UTC midnight). The next field shows the clock
+The first two fields show the date (Modified Julian Day) and time
+(seconds and fraction past UTC midnight). The next field shows the clock
address in dotted-quad notation, The final field shows the last timecode
received from the clock in decoded ASCII format, where meaningful. In
some clock drivers a good deal of additional information can be gathered
-and displayed as well. See information specific to each clock
-for further details.
+and displayed as well. See information specific to each clock for
+further details.
.RE
.PP
-Statistic files are managed using file generation sets (see
+Statistic files are managed using file generation sets (see
.B filegen
-below). The information obtained by enabling statistics recording
-allows analysis of temporal properties of a
+below). The information obtained by enabling statistics recording allows
+analysis of temporal properties of a
.I xntpd
server. It is usually only useful to primary servers or maybe main
campus servers.
@@ -700,43 +645,41 @@ Generation file sets provide a means for handling files that are
continously growing during the lifetime of a server. Server statistics
are a typical example for such files. Generation file sets provide
access to a set of files used to store the actual data. At any time at
-most one element of the set is being written to. The
+most one element of the set is being written to. The
.I type
-given specifies when and how data will be directed to a new element
-of the set. This way, information stored in elements of a file set
-that are currently unused are available for administrational
-operations
-without the risc of desturbing the operation of
-.IR xntpd .
+given specifies when and how data will be directed to a new element of
+the set. This way, information stored in elements of a file set that are
+currently unused are available for administrational operations without
+the risc of desturbing the operation of
+.I xntpd .
(Most important: they can be removed to free space for new data
-produced.)
-Filenames of set members are built from three elements.
+produced.) Filenames of set members are built from three elements.
.Ip prefix 10
-This is a constant filename path. It is not subject to modifications
-via the
+This is a constant filename path. It is not subject to modifications via
+the
.B filegen
statement. It is defined by the server, usually specified as a compile
time constant. It may, however, be configurable for individual file
generation sets via other commands. For example, the prefix used with
-"loopstats" and "peerstats" filegens can be configured using the
-.B statsdir
+"loopstats" and "peerstats" filegens can be configured using the
+.B statsdir
statement explained above.
.Ip filename 10
This string is directly concatenated to the
.I prefix
mentioned above (no intervening \*(L'/\*(R' (slash)). This can be
modified using the \*(L"file\*(R" argument to the \*(L"filegen\*(R"
-statement. No \*(L"..\*(R" elements are allowed in this component to
+statement. No \*(L"..\*(R" elements are allowed in this component to
prevent filenames referring to parts outside the filesystem hierarchy
-denoted by \*(L"prefix\*(R".
+denoted by \*(L"prefix\*(R".
.Ip suffix 10
This part is reflects individual elements of a file set. It is generated
-according to the
+according to the
.I type
of a file set as explained below.
.PP
-A file generation set is characterized by its type.
-The following types are supported:
+A file generation set is characterized by its type. The following types
+are supported:
.Ip none 10
The file set is actually a single plain file.
.Ip pid 10
@@ -744,42 +687,41 @@ One element of file set is used per incarnation of a
.I xntpd
server. This type does not perform any changes to file set members
during runtime, however it provides an easy way of seperating files
-belonging to different
+belonging to different
.I xntpd
-server incarnations.
-The set member filename is built by appending a dot (\*(L'.\*(R') to
-concatentated \*(L"prefix\*(R" and \*(L"filename\*(R" strings, and
-appending the decimal representation of the process id of the
+server incarnations. The set member filename is built by appending a dot
+(\*(L'.\*(R') to concatentated \*(L"prefix\*(R" and \*(L"filename\*(R"
+strings, and appending the decimal representation of the process id of
+the
.I xntpd
server process.
.Ip day 10
One file generation set element is created per day. The term
.I day
-is based on
+is based on
.IR UTC .
-A day is defined as the period between 00:00 and 24:00 UTC.
-The file set member suffix consists of a dot \*(L".\*(R"
-and a day specification in the form
+A day is defined as the period between 00:00 and 24:00 UTC. The file set
+member suffix consists of a dot \*(L".\*(R" and a day specification in
+the form
.RI < YYYYMMDD >.
.I YYYY
is a 4 digit year number (e.g. 1992).
.I MM
is a two digit month number.
.I DD
-is a two digit day number.
-Thus, all information written at December 10th, 1992 would end up
-in a file named
+is a two digit day number. Thus, all information written at December
+10th, 1992 would end up in a file named
\*(L"<prefix><filename>.19921210\*(R".
.Ip week 10
Any file set member contains data related to a certain week of a year.
The term
.I week
is definied by computing \*(L"day of year\*(R" modulo 7. Elements of
-such a file generation set are distinguished by appending the
-following suffix to the file set filename base:
-A dot, a four digit year number, the letter \*(L"W\*(R",
-and a two digit week number. For example, information from Jamuary,
-10th 1992 would end up in a file with suffix \*(L".1992W1\*(R".
+such a file generation set are distinguished by appending the following
+suffix to the file set filename base: A dot, a four digit year number,
+the letter \*(L"W\*(R", and a two digit week number. For example,
+information from Jamuary, 10th 1992 would end up in a file with suffix
+\*(L".1992W1\*(R".
.Ip month 10
One generation file set element is generated per month. The file name
suffix consists of a dot, a four digit year number, and a two digit
@@ -789,145 +731,232 @@ One generation file elment is generated per year. The filename suffix
consists of a dot and a 4 digit year number.
.Ip age 10
This type of file generation sets changes to a new element of the file
-set every 24 hours of server operation. The filename suffix consists
-of a dot, the letter \*(L"a\*(R", and an eight digit number. This
-number is taken to be the number of seconds the server is running at
-the start of the corresponding 24 hour period.
+set every 24 hours of server operation. The filename suffix consists of
+a dot, the letter \*(L"a\*(R", and an eight digit number. This number is
+taken to be the number of seconds the server is running at the start of
+the corresponding 24 hour period.
.PP
Information is only written to a file generation set when this set is
-\*(L"enabled\*(R". Output is prevented by specifying
-\*(L"disabled\*(R".
+\*(L"enabled\*(R". Output is prevented by specifying \*(L"disabled\*(R".
.PP
-It is convenient to be able to access the
+It is convenient to be able to access the
.I current
element of a file generation set by a fixed name. This feature is
enabled by specifying \*(L"link\*(R" and disabled using
\*(L"nolink\*(R". If \*(L"link\*(R" is specified, a hard link from the
-current file set element to a file without suffix is created. When
-there is already a file with this name and the number of links of this
-file is one, it is renamed appending a dot, the letter \*(L"C\*(R",
-and the pid of the
+current file set element to a file without suffix is created. When there
+is already a file with this name and the number of links of this file is
+one, it is renamed appending a dot, the letter \*(L"C\*(R", and the pid
+of the
.I xntpd
server process. When the number of links is greater than one, the file
is unlinked. This allows the current file to be accessed by a constant
-name.
+name.
+.SH "MISCELLANEOUS OPTIONS"
+.PP
+.B precision
+.I #
+.PP
+This command specifies the nominal precision of the local clock. The
+value is an integer approximately equal to the base 2 logarithm of the
+local timekeeping precision in seconds. Normally, the daemon determines
+the precision automatically at startup, so this command is necessary
+only in special cases when the precision cannot be determined
+automatically.
+.PP
+.B broadcastdelay
+.I seconds
+.PP
+The broadcast and multicast modes require a special calibration to
+determine the network delay between the local and remote servers.
+Ordinarily, this is done automatically by the initial protocol exchanges
+between the local and remote servers. In some cases, the calibration
+procedure may fail due to network or server access controls, for
+example. This command specifies the default delay to be used under these
+circumstances. Typically (for Ethernet), a number between 0.003 and
+0.007 seconds is appropriate. The default when this command is not used
+is 0.004 seconds.
+.PP
+.B trap
+.I host_address
+[
+.B port
+.I port_number
+] [
+.B interface
+.I interface_addess
+]
+.PP
+This command configures a trap receiver at the given host address and
+port number for sending messages with the specified local interface
+address. If the port number is unspecified a value of 18447 is used. If
+the interface address is not specified the message is sent with a source
+address which is that of the local interface the message is sent
+through. Note that on a multihomed host the interface used may vary from
+time to time with routing changes.
+.PP
+The trap receiver will generally log event messages and other
+information from the server in a log file. While such monitor programs
+may also request their own trap dynamically, configuring a trap receiver
+will ensure that no messages are lost when the server is started.
+.PP
+.B setvar
+.I variable
+.I [default]
+.PP
+This command adds an additional system variable. These variables can be
+used to distribute additional information such as the access policy. If
+the variable of the from <name>=<value> is followed by the
+.I default
+keyword the variable will be listed as part of the default system
+variables (
+.I ntpq rv
+command). These additional variables serve informational purposes only.
+They are not related to the protocol other that they can be listed. The
+known protocol variables will always overide any variables defined via
+the
+.I setvar
+mechanism.
+.PP
+There are three special variables that contain the names of all variable
+of the same group. The
+.I sys_var_list
+holds the names of all system variables. The
+.I peer_var_list
+holds the names of all peer variables and the
+.I clock_var_list
+hold the names of the reference clock variables.
+.PP
+.B monitor yes|no
+.B authenticate yes|no
+.PP
+These commands have been superseded by the
+.B enable
+and
+.B disable
+commands. They are listed here for historical purposes.
.SH "AUTHENTICATION KEY FILE FORMAT"
.PP
-The NTP standard specifies an extension allowing
-verification of the authenticity of received NTP packets, and to provide
-an indication of authenticity in outgoing packets. This is implemented
-in
+The NTP standard specifies an extension allowing verification of the
+authenticity of received NTP packets, and to provide an indication of
+authenticity in outgoing packets. This is implemented in
+.I xntpd
+using the DES or MD5 algorithms to compute a digital signature, or
+message-digest. The specification allows any one of possibly 4 billion
+keys, numbered with 32 bit key identifiers, to be used to authenticate
+an association. The servers involved in an association must agree on the
+key and key identifier used to authenticate their data, though they must
+each learn the key and key identifer independently. In the case of DES,
+the keys are 56 bits long with, depending on type, a parity check on
+each byte. In the case of MD5, the keys are 64 bits (8 bytes).
.I xntpd
-using the DES encryption algorithm. The specification
-allows any one of a possible 4 billion keys, numbered with 32 bit unsigned
-integers, to be used to
-authenticate an association. The servers involved in an association
-must agree on the value of the key used to authenticate their data, though
-they must each learn the key independently. The keys are standard 56 bit
-DES keys.
-.PP
-Addionally, a new experimental authentication algorithm is available which
-uses an MD5 message digest to compute an authenticator. Currently the length
-of the key or password is limited to 8 characters, but this will eventually
-be changed to accomodate an effectively unlimited password phrase.
-.I Xntpd
reads its keys from a file specified using the
.B -k
command line option or the
.B keys
-statement in the configuration file. While key number 0 is fixed by the
+statement in the configuration file. While key number 0 is fixed by the
NTP standard (as 56 zero bits) and may not be changed, one or more of
the keys numbered 1 through 15 may be arbitrarily set in the keys file.
.PP
The key file uses the same comment conventions as the configuration
-file. Key entries use a fixed format of the form
+file. Key entries use a fixed format of the form
.Ip "" 5
-.I "keyno type key"
+.I "keyno type key"
.PP
-where \*(L"keyno\*(R" is a positive integer,
-\*(L"type\*(R" is a single character which defines the format the key
-is given in, and \*(L"key\*(R" is the key itself.
+where \*(L"keyno\*(R" is a positive integer, \*(L"type\*(R" is a single
+character which defines the format the key is given in, and
+\*(L"key\*(R" is the key itself.
.PP
The key may be given in one of three different formats, controlled by
-the \*(L"type\*(R" character. The three key types, and corresponding
+the \*(L"type\*(R" character. The three key types, and corresponding
formats, are listed following.
.Ip "S" 5
The \*(L"key\*(R" is a 64 bit hexadecimal number in the format specified
-in the DES document, that is the high order 7 bits of each octet are used
-to form the 56 bit key while the low order bit of each octet is given a
-value such that odd parity is maintained for the octet. Leading zeroes
-must be specified (i.e. the key must be exactly 16 hex digits long) and
-odd parity must be maintained. Hence a zero key, in standard format,
-would be given as
+in the DES document, that is the high order 7 bits of each octet are
+used to form the 56 bit key while the low order bit of each octet is
+given a value such that odd parity is maintained for the octet. Leading
+zeroes must be specified (i.e. the key must be exactly 16 hex digits
+long) and odd parity must be maintained. Hence a zero key, in standard
+format, would be given as
.I 0101010101010101 .
.Ip "N" 5
The \*(L"key\*(R" is a 64 bit hexadecimal number in the format specified
-in the NTP standard. This is the same as the DES format except the bits
+in the NTP standard. This is the same as the DES format except the bits
in each octet have been rotated one bit right so that the parity bit is
-now the high order bit of the octet. Leading zeroes must be specified
-and odd parity must be maintained. A zero key in NTP format would be specified
-as
+now the high order bit of the octet. Leading zeroes must be specified
+and odd parity must be maintained. A zero key in NTP format would be
+specified as
.I 8080808080808080
.Ip "A" 5
-The \*(L"key\*(R" is a 1\-to\-8 character ASCII string. A key is formed
-from this by using the lower order 7 bits of the ASCII representation
-of each character in the string, with zeroes being added on the right
-when necessary to form a full width 56 bit key, in the same way that
+The \*(L"key\*(R" is a 1\-to\-8 character ASCII string. A key is formed
+from this by using the lower order 7 bits of the ASCII representation of
+each character in the string, with zeroes being added on the right when
+necessary to form a full width 56 bit key, in the same way that
encryption keys are formed from Unix passwords.
.Ip "M" 5
The \*(L"key\*(R" is a 1\-to\-8 character ASCII string, using the MD5
-authentication scheme. Note that both the keys and the authentication
-schemes (DES or MD5) must be identical between a set of peers sharing
+authentication scheme. Note that both the keys and the authentication
+schemes (DES or MD5) must be identical between a set of peers sharing
the same key number.
.PP
One of the keys may be chosen,
by way of the configuration file
.B requestkey
-statement, to authenticate run time configuration
-requests made using the
+statement, to authenticate run time configuration requests made using
+the
.IR xntpdc (8)
-program. The latter program obtains the key from the terminal as
-a password, so it is generally appropriate to specify the key chosen
-to be used for this purpose in ASCII format.
+program. The latter program obtains the key from the terminal as a
+password, so it is generally appropriate to specify the key chosen to be
+used for this purpose in ASCII format.
.SH PRIMARY CLOCK SUPPORT
-.PP
-.I Xntpd
-can be optionally compiled to include support for a number of types
-of reference clocks. A reference clock will generally (though
-not always) be a radio timecode receiver which is synchronized to a
-source of standard time such as the services offered by the NRC in
-Canada and NIST in the U.S. The interface between the computer and
-the timecode receiver is device dependent and will vary, but is
-often a serial port.
+.I xntpd
+can be optionally compiled to include support for a number of types of
+reference clocks. A reference clock will generally (though not always)
+be a radio timecode receiver which is synchronized to a source of
+standard time such as the services offered by the NRC in Canada and NIST
+in the U.S. The interface between the computer and the timecode receiver
+is device dependent and will vary, but is often a serial port.
+.PP
+Support for the various reference clock drivers is conditionally
+compiled using the compiler define codes described elsewhere. An attempt
+to configure a reference clock when specific support is not available or
+the hardware port has not been appropriately configured results in a
+scolding remark to the system log file, but is otherwise non hazardous.
.PP
For the purposes of configuration,
.I xntpd
-treats reference clocks in a manner analogous to normal NTP peers
-as much as possible. Reference clocks are referred to by address,
-much as a normal peer is, though an invalid IP address is used to
-distinguish them from normal peers. Reference clock addresses are
-of the form
+treats reference clocks in a manner analogous to normal NTP peers as
+much as possible. Reference clocks are referred to by address, much as a
+normal peer is, though an invalid IP address is used to distinguish them
+from normal peers. Reference clock addresses are of the form
.I 127.127.t.u
where
.I t
is an integer denoting the clock type and
.I u
-indicates the type\-specific unit number. Reference clocks are normally
-enabled by configuring the clock as a server using a
+indicates the type\-specific unit number. Reference clocks are
+configured using a
.B server
-statement in the configuration file which references the clock's
-address (configuring a reference clock with a
-.B peer
-statement can also be done, though with some clock drivers this may cause
-the clock to be treated somewhat differently and by convention is used
-for debugging purposes). Clock addresses may generally
-be used anywhere else in the configuration file a normal IP address
-can be used, for example in
+statement in the configuration file where the
+.I host_address
+is the clock address. The
+.I key,
+.I version
+and
+.I ttl
+options are not used for reference clock support; however, the
+.I prefer
+option can be useful to persuade the server to cherish a reference clock
+with somewhat more enthusiasm than other reference clocks or peers, if
+this is advisable. Clock addresses may generally be used anywhere in the
+configuration file a normal IP address can be used, for example, in
.B restrict
-statements.
+statements, although such use would normally be considered strange.
.PP
-There is one additional configuration statement which becomes valid
-when reference clock support has been compiled in. Its format is:
+Reference clock support provides the
+.B fudge
+command, which can be used to configure reference clocks in special
+ways. Following is the generic format that applies to this command
.PP
.B fudge
.I 127.127.t.u
@@ -938,10 +967,10 @@ when reference clock support has been compiled in. Its format is:
.B time2
.I secs
] [
-.B value1
+.B stratum
.I int
] [
-.B value2
+.B refid
.I int
] [
.B flag1
@@ -949,502 +978,106 @@ when reference clock support has been compiled in. Its format is:
] [
.B flag2
.I 0|1
+] [
+.B flag3
+.I 0|1
+] [
+.B flag4
+.I 0|1
]
.PP
-There are two times (whose values are specified in fixed point seconds),
-two integral values and two binary flags available for customizing
-the operation of a clock. The interpretation of these values, and
-whether they are used at all, is a function of the needs of the particular
-clock driver.
-.PP
-.I Xntpd
-on Unix machines currently supports several different types of clock hardware
-plus a special pseudo\-clock used for backup or when no other clock
-source is available. In the case of most of the clock drivers, support
-for a 1-pps precision timing signal is available as described in the
-pps.txt file in the doc directory of the xntp3 distribution.
-The clock drivers, and the addresses used to configure
-them, are described following:
-.PP
-.B 127.127.1.u
-\- Local synchronization clock driver
-.PP
-This driver doesn't support an actual clock, but rather allows the
-server to synchronize to its own clock, in essence to free run without
-its stratum increasing to infinity. This can be used to run an
-isolated NTP synchronization network where no standard time source is
-available, by allowing a free running clock to appear as if it has
-external synchronization to other servers. By running the local clock
-at an elevated stratum it can also be used to prevent a server's stratum
-from rising above a fixed value, this allowing a synchronization subnet
-to synchonize to a single local server for periods when connectivity
-to the primary servers is lost.
-.PP
-The unit number of the clock (the least significant octet in the address)
-must lie in the range 0 through 15 inclusive and is used as the stratum
-the local clock will run at. Note that the server, when synchronized
-to the local clock, will advertise a stratum one greater than the clock
-peer's stratum. More than one local clock may be configured (indeed all
-16 units may be active at once), though this hardly seems useful.
-.PP
-The local clock driver uses only the fudge time1 parameter. This parameter
-provides read and write access to the local clock drift compensation
-register. This value, which actually provides a fine resolution speed
-adjustment for the local clock, is settable but will remain unchanged
-from any set value
-when the clock is free running without external synchronization. The
-fudge time1 parameter thus provides a way to manually adjust the speed of the
-clock to maintain reasonable synchronization with, say, a voice
-time announcement. It is actually more useful to manipulate this value
-with the
-.IR xntpdc (8)
-program.
-.PP
-.B 127.127.3.u
-\- Precision Standard Time/Traconex 1010/1020 WWV/H Receiver
-.PP
-This driver can be used with a PST/Traconex Time Source 1010 or 1020 WWV/WWVH
-Synchronized Clock connected via a serial port. Up to
-four units, with unit numbers in the range 0 through 3, can be
-configured. The driver assumes the serial port device name is
-/dev/pst%d (i.e. unit 1, at 127.127.3.1, opens the clock at
-/dev/pst1) and that the clock is configured for 9600-baud operation.
-.PP
-The fudge time1 and time2 parameters are configured directly into the receiver
-as nominal propagation delays when synchronized to WWV and WWVH,
-respectively; the internal DIPswitches ordinarily used for that purpose
-are disabled. The default values are 0.0075 and 0.0265 seconds,
-respectively, which are about right for Toronto. Values for other
-locations can be calculated using the
-.I propdelay
-program in the util directory of the xntp3 distribution or equivalent
-means described in the user's manual.
-.PP
-The fudge value1 parameter can be used to set the stratum at which
-the peer operates. The default is 0, which is correct if you want the
-clock to be considered for synchonization whenever it is operating, though
-higher values may be assigned if you only want the clock to provide backup
-service when all other primary sources have failed. The value2 parameter
-is set to the number of minutes which the daemon will allow the clock to go
-without synchronization before it starts disbelieving it. The default
-is 20, which is suitable if you have good quality backup NTP peers. If
-your network is isolated or your network connections are poor it might
-be advantageous to increase this value substantially.
-.PP
-The fudge flag1 can be used to modifiy the averaging algorithm used
-to smooth the clock indications. Ordinarily, the algorithm picks the
-median of a set of samples, which is appropriate under conditions
-of poor to fair radio propagation conditions. If the clock is located
-relatively close to the WWV or WWVH transmitters, setting this flag
-will cause the algorithm to average the set of samples, which can
-reduce the residual jitter and improve accuracy.
-.PP
-The fudge flag2 can be used to force the driver to send to
-the clock the commands required to reprogram the current WWV and WWVH fudge
-delays into it. This is normally done only when the values are to be changed,
-such as during inital setup and calibration. Setting
-the (otherwise undocumented) fudge flag3 will cause the driver to reset
-the clock. The latter two flags are generally useful primarily for debugging.
-.PP
-127.127.4.u
-\- Spectracom 8170 and Netclock/2 WWVB Synchronized Clocks
-.PP
-This driver can be used with a Spectracom 8170 or Netclock/2 WWVB
-Synchronized Clock connected via a serial port. Up to
-four units, with unit numbers in the range 0 through 3, can be
-configured. The driver assumes the serial port device name is
-/dev/wwvb%d (i.e., unit 1 at 127.127.4.1 opens the clock at
-/dev/wwvb1) and that the clock is configured for 9600-baud operation.
-.PP
-The fudge time1 parameter can be used to compensate for inherent
-latencies in the serial port hardware and operating system.
-The value, which defaults to zero, is in addition to the value
-programmed by the propagation switches on the receiver. The
-fudge value1 parameter can be used to specify the stratum of the clock
-in the same way described above for the WWV/WWVH clock 127.127.3.u.
-.PP
-.B 127.127.5.u
-\- Kinemetrics/TrueTime Timing Receivers
-.PP
-This driver can be used with at least two models of Kinemetrics/TrueTime
-Timing Receivers, the 468-DC MK III GOES Synchronized Clock and GPS-DC
-MK III GPS Synchronized Clock and very likely others in the same model
-family that use the same timecode formats. The clocks are connected
-via a serial port. Up to
-four units, with unit numbers in the range 0 through 3, can be
-configured. The driver assumes the serial port device name is
-/dev/goes%d (i.e., unit 1 at 127.127.5.1 opens the clock at
-/dev/goes1) and that the clock is configured for 9600-baud operation.
-.PP
-The fudge time1 parameter can be used to compensate for inherent
-latencies in the serial port hardware and operating system in the same
-way as described above for the WWVB clock 127.127.4.u.
-The fudge value1 parameter can be used to specify the stratum of the clock
-in the same way described above for the WWV/WWVH clock 127.127.3.u.
-.PP
-.B 127.127.6.0
-\- IRIG-B Audio Decoder
-.PP
-This driver can be used in conjuction with the Inter-Range Instrumentation
-Group standard time-distribution signal IRIG-B. This signal is generated
-by several radio clocks, including those made by Austron, TrueTime, Odetics
-and Spectracom, among others, although it is generally an add-on option.
-The signal is connected via an attenuator box and cable to the audio
-codec input on a Sun SPARCstation and requires a specially modified
-kernel audio driver. Details are in the irig.txt file in the doc
-directory of the xntp3 distribution. As only a single audio codec
-is built into a workstation, the driver assumes the device name is /dev/irig.
-.PP
-Timing jitter using the decoder and a Sun IPC is in the order of a few
-microseconds, although the overal timing accuracy is limited by the
-wander of the CPU oscillator used for timing purposes to a few hundred
-microseconds. These figures are comparable with what can be achieved
-using the 1-pps signal described in the pps.txt file in the doc
-directory of the xntp3 distribution.
-.PP
-.B 127.127.7.u
-\- CHU Modem Decoder
-.PP
-This driver can be used with a shortwave receiver and special modem
-circuitry described in the gadget directory of the xntp3 distribution.
-It requires the chu-clk line discipline or chu_clk STREAMS module
-described in the kernel directory of that distribution. It is connected
-via a serial port operating at 300 baud. Up to
-four units, with unit numbers in the range 0 through 3, can be
-configured. The driver assumes the serial port device name is
-/dev/chu%d (i.e., unit 1 at 127.127.7.1 opens the clock at
-/dev/chu1).
-.PP
-Unlike the NIST time services, whose timecode requires quite specialized
-hardware to interpret, the CHU timecode can be received directly via
-a serial port after demodulation. While there are currently no commercial
-CHU receivers, the hardware required to receive the CHU timecode is fairly
-simple to build. While it is possible to configure several CHU units
-simultaneously this is not recommended as the character interrupts from all
-units will be occuring at the same time and will interfere with each other.
-.PP
-The fudge time1 parameter is used to specify the propagation delay between
-the CHU transmitter at Ottawa, Ontario, and the receiver. The default
-value is 0.0025 seconds, which is about right for Toronto. Values for other
-locations can be calculated using the
-.I propdelay
-program in the util directory of the xntp3 distribution or equivalent
-means.
-The fudge time2
-parameter is used to compensate for inherent latencies in the modem,
-serial port hardware and operating system in the same way as described
-above for the WWVB clock 127.127.4.u. The default value is
-0.0002 seconds, which is about right for typical telephone modem chips.
-The fudge value1 parameter can be used to specify the stratum of the clock
-in the same way described above for the WWV/WWVH clock 127.127.3.u.
-The fudge flag1 can be used to modify the averaging algorithm in the
-same way as described for that clock.
-.PP
-.B 127.127.8.u
-\- Synchronisation to several receivers (DCF77, GPS)
-.PP
-The timecode of
-the receivers will be sampled via a STREAMS module in the kernel (The STREAMS module
-has been designed for use with SUN Systems under SunOS 4.1.x. It can be
-linked directly into the kernel or loaded via the loadable driver mechanism)
-This STREAMS module can be adepted to be able to convert different time code
-formats.
-If the daemon is compiled without the STREAM definition synchronisation
-will work without the Sun streams module, though accuracy is significantly
-degraded.
-.br
-The actual receiver status is mapped into various synchronisation
-states generally used by receivers. The STREAMS module is configured to
-interpret the time codes of DCF U/A 31, PZF535, GPS166, Trimble SV6 GPS, ELV DCF7000,
-Schmid and low cost receivers (see list below).
-.br
-The reference clock support in xntp contains the necessary configuration tables
-for those receivers. In addition to supporting up to 32 different clock types and
-4 devices the generation a a PPS signal is also provided as an configuration
-option. The PPS configuration option uses the receiver generated time stamps
-for feeding the PPS loopfilter control for much finer clock synchronisation.
-.br
-CAUTION: The PPS configuration option is different from the hardware PPS signal,
-which is also supported (see below), as it controls the way xntpd is synchronised
-to the reference clock, while the hardware PPS signal controls the way time
-offsets are determined.
-.br
-The use of the PPS option requires receivers with an accuracy of better than 1ms.
-.PP
-Fudge factors
-.PP
-Only two fudge factors are utilized. The
-.I time1
-fudge factor defines the phase offset of the sychnronisation character to the actual
-time.
-On the availability of PPS information the
-.I time2
-fudge factor defines the skew between the PPS time stamp and the reception
-time stamp of the PPS signal. This parameter is usually 0 as usually
-the PPS signal is believed in time and OS delays should be corrected
-in the machine specific section of the kernel driver.
-.I time2
-needs only be set when the actial PPS signal is delayed for some
-reason.
The
-.I flag0
-enables input filtering. This a median filter with continuous sampling. The
-.I flag1
-selects averaging of the samples remaining after the filtering. Leap second
-handling is controlled with the
-.I flag2.
-When set a leap second will be deleted on receipt of a leap second indication
-from the receiver. Otherwise the leap second will be added (which is the default).
+.I time1
+and
+.B time2
+options are specified in fixed point seconds and used in some clock
+drivers as calibration constants. By convention, and unless indicated
+otherwise,
+.B time1
+is used as a calibration constant to adjust the nominal time offset of a
+particular clock to agree with an external standard, such as a precision
+PPS signal. The specified offset is in addition to the propagation delay
+provided by other means, such as internal DIPswitches. The
+.B stratum
+option is a number in the range zero to 15 and is used to assign a
+nonstandard operating stratum to the clock. The
+.B refid
+option is an ASCII string in the range one to four characters and is
+used to assign a nonstandard reference identifier to the clock. Finally,
+the four binary flags
+.B flag1,
+.B flag2,
+.B flag3
+and
+.B flag4
+are used for customizing the clock driver. The interpretation of these
+values, and whether they are used at all, is a function of the needs of
+the particular clock driver. However, by convention, and unless
+indicated otherwise,
+.B flag3
+is used to attach the ppsclock streams module to the configured driver,
+while
+.B flag4
+is used to enable recording verbose monitoring data to the clockstats
+file configured with the
+.I filegen
+command. Further information on the ppsclock streams module is in the
+README file in the ./kernel directory in the current xntp3 program
+distribution. Further information on this feature is available in the
+./scripts/stats directory in the same distribution.
+.PP
+Ordinarily, the stratum of a reference clock is by default zero. Since
+the
+.I xntpd
+daemon adds one to the stratum of each peer, a primary server ordinarily
+displays stratum one. In order to provide engineered backups, it is
+often useful to specify the reference clock stratum as greater than
+zero. The
+.B stratum
+option is used for this purpose. Also, in cases involving both a
+reference clock and a 1-pps discipline signal, it is useful to specify
+the reference clock identifier as other than the default, depending on
+the driver. The
+.I refid
+option is used for this purpose. Except where noted, these options apply
+to all clock drivers.
.PP
-.I ntpq
-timecode variable
-.PP
-The ntpq read clock variables command list several variables. These
-hold followinf information:
-.I refclock_time
-is the local time with the offset to UTC (format HHMM).
-The currently active receiver flags are listed in
-.I refclock_status.
-Additional feature flags of the receiver are optionally listed in paranthesis.
-The actual time code is listed in
-.I timecode.
-A qualification of the decoded time code format is following in
-.I refclock_format.
-The last piece of information is the overall running time and the accumulated
-times for the clock event states in
-.I refclock_states.
-When PPS information is present additional variable are available.
-.I refclock_ppstime
-lists then the PPS timestamp and
-.I refclock_ppsskew
-lists the difference between RS232 derived timestamp and the PPS timestamp.
-.PP
-Unit encoding
-.PP
-The unit field <u> encodes the device, clock type and the PPS generation option.
-There are 4 possible devices which are encoded in the lower 2 bits of the <u>
-field. The devices are named
-.IR /dev/refclock-0
-through
-.IR /dev/refclock-3 .
-Bits 2 thru 6 encode the clock type. The fudge factors
-of the clock type are take from a table
-.I clockinfo
-in refclock_parse.c. The generation of PPS information for disciplining the
-local NTP clock is encoded in bit 7 of <u>.
-.PP
-Currently nine clock types (devices /dev/refclock-0 - /dev/refclock-3) are supported.
-.Ip 127.127.8.0-3 16
-Meinberg PZF535 receiver (FM demodulation/TCXO / 50us)
-.Ip 127.127.8.4-7 16
-Meinberg PZF535 receiver (FM demodulation/OCXO / 50us)
-.Ip 127.127.8.8-11 16
-Meinberg DCF U/A 31 receiver (AM demodulation / 4ms)
-.Ip 127.127.8.12-15 16
-ELV DCF7000 (sloppy AM demodulation / 50ms)
-.Ip 127.127.8.16-19 16
-Walter Schmid DCF receiver Kit (AM demodulation / 1ms)
-.Ip 127.127.8.20-23 16
-RAW DCF77 100/200ms pulses (Conrad DCF77 receiver module / 5ms)
-.Ip 127.127.8.24-27 16
-RAW DCF77 100/200ms pulses (TimeBrick DCF77 receiver module / 5ms)
-.Ip 127.127.8.28-31 16
-Meinberg GPS166 receiver (GPS / <<1us)
-.Ip 127.127.8.32-35 16
-Trimble SV6 GPS receiver (GPS / <<1us)
-.PP
-The reference clock support carefully monitors the state transitions of
-the receiver. All state changes and exceptional events such as loss of time code
-transmission are logged via the
-.I syslog
-facility.
-Every hour a summary of the accumulated times for the clock states is
-listed via syslog.
-.PP
-PPS support is only available when the receiver is completely
-synchronised. The receiver is believed to deliver correct time for an additional
-period of time after losing sychronisation unless a disruption in time code
-transmission is detected (possible power loss). The trust period is dependent
-on the receiver oscillator and thus a function of clock type. This is one of
-the parameters in the
-.I clockinfo
-field of the reference clock implementation. This parameter cannot be
-configured by xntpdc.
-.PP
-In addition to the PPS loopfilter control a true PPS hardware signal can be applied
-on Sun Sparc stations via the CPU serial ports on the CD pin. This signal is
-automatically detected and will be used for offset calculation. The input signal
-must be the time mark for the following time code. (The edge sensitivity can be
-selected - look into the appropriate kernel/parsestreams.c for details).
-Meinberg receivers can be connected by feeding the PPS pulse of the receiver via
-a 1488 level converter to Pin 8 (CD) of a Sun serial zs\-port.
-.PP
-There exists a special firmware release for the PZF535 Meinberg receivers.
-This release (PZFUERL 4.6 (or higher - The UERL is important)) is absolutely
-recommended for XNTP use, as it provides LEAP warning, time code time zone information
-and alternate antenna indication. Please check with Meinberg for this
-firmware release.
-For the Meinberg GPS166 receiver is also a special firmaware release available
-(Uni-Erlangen). This release must be used for proper operation.
-.PP
-The raw DCF77 pulses can be fed via a level converter directly into Pin 3 (Rx)
-of the Sun. The telegrams will be decoded an used for synchronisation.
-AM DCF77 receivers are running as low as $25. The accuracy is dependent on
-the receiver and is somewhere between 2ms (expensive) to 10ms (cheap).
-Upon bad signal reception of DCF77 sychronisation will cease as no backup
-oscillator is available as usually found in other reference clock receivers.
-So it is important to have a good place for the DCF77 antenna. For transmitter
-shutdowns you are out of luck unless you have other NTP servers with alternate
-time sources available.
-.PP
-127.127.9.u
-\- Magnavox MX4200 Navigation Receiver used as GPS Synchronized Clocks
-.PP
-This driver can be used with a Magnavox MX4200 Navigation Receiver
-adapted to precision timing applications. This requires an interface
-box described in the ppsclock directory of the xntp3 distribution.
-It is connected via a serial port and requires the ppsclock STREAMS
-module described in the same directory. Up to
-four units, with unit numbers in the range 0 through 3, can be
-configured. The driver assumes the serial port device name is
-/dev/gps%d (i.e., unit 1 at 127.127.9.1 opens the clock at
-/dev/gps1) and that the clock is configured for 9600-baud operation.
-.PP
-The fudge time1 parameter can be used to compensate for inherent
-latencies in the serial port hardware and operating system in the
-same way described above for the WWVB clock 127.127.4.u. The
-fudge value1 parameter can be used to specify the stratum of the clock
-in the same way described above for the WWV/WWVH clock 127.127.3.u.
-.PP
-127.127.10.u
-\- Austron 2200A/2201A GPS/LORAN Synchronized Clock and Timing Receiver
-.PP
-This driver can be used with an Austron 2200A/2201A GPS/LORAN Synchronized
-Clock and Timing Receiver connected via a serial port. It supports
-several special features of the clock, including the Input Burffer Module,
-Output Buffer Module, IRIG-B Interface Module and LORAN Assist Module. It
-requires the RS232 Serial Interface module for communication with
-the driver. Up to four units (which hardly seems affordable), with unit
-numbers in the range 0 through 3, can be
-configured. The driver assumes the serial port device name is
-/dev/gps%d (i.e., unit 1 at 127.127.10.1 opens the clock at
-/dev/gps1) and that the clock is configured for 9600-baud operation.
-.PP
-The fudge time1 parameter can be used to compensate for inherent
-latencies in the serial port hardware and operating system in the
-same way described above for the WWVB clock 127.127.4.u. The
-fudge value1 parameter can be used to specify the stratum of the clock
-in the same way described above for the WWV/WWVH clock 127.127.3.u.
-.PP
-This receiver is capable of a comprehensive and large volume of
-statistics and operational data. The specific data-collection
-commands and attributes are embedded in the driver source code;
-however, the collection process can be enabled or disabled
-using the flag4 flag. If set, collection is enabled; if not,
-which is the default, it is disabled. A comprehensive suite of data reduction
-and summary scripts is in the ./scripts/stats directory of the xntp
-distribution.
-.PP
-127.127.11.u
-\- Kinemetrics/TrueTime OMEGA-DC OMEGA Synchronized Clock
-.PP
-This driver can be used with a Kinemetrics/TrueTime OMEGA-DC OMEGA
-Synchronized Clock connected via a serial port. This clock is
-sufficiently different than other Kinemetrics/TrueTime models
-to require a separate driver. Up to
-four units, with unit numbers in the range 0 through 3, can be
-configured. The driver assumes the serial port device name is
-/dev/omega%d (i.e., unit 1 at 127.127.11.1 opens the clock at
-/dev/omega1) and that the clock is configured for 9600-baud operation.
-.PP
-The fudge time1 parameter can be used to compensate for inherent
-latencies in the serial port hardware and operating system in the
-same way described above for the WWVB clock 127.127.4.u. The
-fudge value1 parameter can be used to specify the stratum of the clock
-in the same way described above for the WWV/WWVH clock 127.127.3.u.
-.PP
-127.127.12.0
-\- KSI/Odeteics TPRO IRIG-B Decoder
-.PP
-This driver can be used with a KSI/Odeteics TPRO or TPRO-SAT IRIG-B
-Decoder, which is a module connected directly to the SBus of a
-Sun workstation. The module works with the IRIG-B signal generated
-by several radio clocks, including those made by Austron, TrueTime, Odetics
-and Spectracom, among others, although it is generally an add-on option.
-In the case of the TPRO-SAT, the module is an integral part of a GPS
-receiver, which serves as the primary timing source.
-As only a single module of this type can be
-used on a single workstation, only the unit number 0 is acceptable.
-The driver assumes the device name is /dev/tpro0.
-.PP
-The fudge time1 parameter can be used to compensate for inherent
-latencies in the serial port hardware and operating system in the
-same way described above for the WWVB clock 127.127.4.u. The
-fudge value1 parameter can be used to specify the stratum of the clock
-in the same way described above for the WWV/WWVH clock 127.127.3.u.
-.PP
-127.127.13.u
-\- Leitch CSD 500 Controller with HP 5061A Atomic Clock
-.PP
-This driver can be used with a Leitch CSD 500 Controller
-connected to an HP 5061A Atomic Clock or equivalent primary timing source
-and connected via a serial port. Up to
-four units, with unit numbers in the range 0 through 3, can be
-configured. The driver assumes the serial port device name is
-/dev/leitch%d (i.e., unit 1 at 127.127.13.1 opens the clock at
-/dev/leitch1) and that the clock is configured for 300-baud operation.
-.PP
-The fudge time1 parameter can be used to compensate for inherent
-latencies in the serial port hardware and operating system in the
-same way described above for the WWVB clock 127.127.4.u. The
-fudge value1 parameter can be used to specify the stratum of the clock
-in the same way described above for the WWV/WWVH clock 127.127.3.u.
-.PP
-127.127.14.u
-\- EES M201 MSF receiver
-.PP
-This driver can be used with an EES M201 MSF receiver connected
-to a Sun running SunOS 4.x with the "ppsclock" STREAMS module.
-.PP
-The fudge time1 and time2 parameters can be used to compensate for
-inherent latencies in the serial port hardware and operating system
-respectively in the same way described above for the WWVB clock 127.127.4.u.
-The bottom 4 bits of fudge value1 parameter can be used to specify
-the stratum of the clock in the same way described above for the
-WWV/WWVH clock 127.127.3.u.
-The fudge value2 parameter can be used to specify the debug mask.
-bit 0x1 causes logging of smoothing processing.
-bit 0x4 causes the clock buffer to be dumped.
-If flag1 is set, then the system clock is assumed to be sloppy
-(e.g. Sun4 with 20ms clock), so samples are averaged.
-If flag2 is set, then leaphold is set.
-If flag3 is set, then the sample information is dumped.
-If flag4 is set, then the input data is smoothed, and all data
-points are used.
+.I xntpd
+on Unix machines currently supports several different types of clock
+hardware plus a special pseudo\-clock used for backup or when no other
+clock source is available. In the case of most of the clock drivers,
+support for a 1-pps precision timing signal is available as described in
+the README file in the ./doc directory of the xntp3 progam distribution.
+The clock drivers, and the addresses used to configure them, are
+described in the README.refclocks in the doc directory of the current
+program distribution.
.PP
.SH VARIABLES
-Most variables used by the NTP protocol can be examined with the xntpdc
-(mode 7 messages) and the ntpq (mode 6 messages). Currently very few variables
-can be modified via mode 6 messages. These variables are either created with the
+Most variables used by the NTP protocol can be examined with the
+.I xntpdc
+(mode 7 messages) and the
+.I ntpq
+(mode 6 messages). Currently very few variables can be modified via mode
+6 messages. These variables are either created with the
.I setvar
-directive or the leap warning variables. The leap warning bits that can be
-set in the
+directive or the leap warning variables. The leap warning bits that can
+be set in the
.B leapwarning
variable (up to one month ahead). Both, the
-.B leapwarning and in the
+.B leapwarning and in the
.B leapindication
variable, have a slightly different encoding than the usual
.B leap
bits interpretation:
.P
.Ip 00 8
-The daemon passes the leap bits of its synchronisation source (usual mode of
-operation).
+The daemon passes the leap bits of its synchronisation source (usual
+mode of operation).
.Ip 01/10 8
A leap second is added/deleted (operator forced leap second).
.Ip 11 8
-Leap information from the sychronisation source is ignored (thus LEAP_NOWARNING
-is passed on).
+Leap information from the sychronisation source is ignored (thus
+LEAP_NOWARNING is passed on).
.PP
.SH FILES
.Ip /etc/ntp.conf 20
@@ -1460,20 +1093,13 @@ the conventional name of the key file
.IR ntpdate (8)
.SH HISTORY
.PP
-Written by Dennis Ferguson at the University of Toronto.
-Text amended by David Mills at the University of Delaware.
+Written by Dennis Ferguson at the University of Toronto. Text amended by
+David Mills at the University of Delaware.
.SH BUGS
.PP
-.I Xntpd
-has gotten rather fat. While not huge, it has gotten larger
-than might be desireable for an elevated\-priority daemon running on a
-workstation, particularly since many of the fancy features which
-consume the space were designed more with a busy primary server, rather
-than a high stratum workstation, in mind. This will eventually be corrected
-either by adopting the
-.I ntpd
-daemon as an alternative when it becomes able to match
-.IR xntpd 's
-performance, or if not than by producing a stripped down version of
.I xntpd
-specifically for workstation use.
+has gotten rather fat. While not huge, it has gotten larger than might
+be desireable for an elevated\-priority daemon running on a workstation,
+particularly since many of the fancy features which consume the space
+were designed more with a busy primary server, rather than a high
+stratum workstation, in mind.
diff --git a/usr.sbin/xntpd/doc/xntpdc.8 b/usr.sbin/xntpd/doc/xntpdc.8
index 80979e2675b4..739eeced707e 100644
--- a/usr.sbin/xntpd/doc/xntpdc.8
+++ b/usr.sbin/xntpd/doc/xntpdc.8
@@ -1,5 +1,5 @@
''' $Header
-'''
+'''
.de Sh
.br
.ne 5
@@ -48,7 +48,7 @@ xntpdc - query/control program for the Network Time Protocol daemon
[
.B -ilnps
] [
-.B -c
+.B -c
.I command
] [
.I host
@@ -59,12 +59,12 @@ xntpdc - query/control program for the Network Time Protocol daemon
.I Xntpdc
is used to query the
.IR xntpd (8)
-daemon about its current state and to request changes in that state. The
+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
+command line arguments. Extensive state and statistics information is
available through the
.I xntpdc
-interface. In addition, nearly all the configuration options which can
+interface. In addition, nearly all the configuration options which can
be specified at start up using
.IR xntpd 's
configuration file may also be specified at run time using
@@ -72,14 +72,14 @@ configuration file may also be specified at run time using
.PP
If one or more request options is included on the command line when
.I xntpdc
-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
+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
.I localhost
-by default. If no request options are given,
+by default. If no request options are given,
.I xntpdc
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
+on the NTP server running on the first host given on the command line,
+again defaulting to
.I localhost
when no other host is specified.
.I Xntpdc
@@ -88,60 +88,61 @@ will prompt for commands if the standard input is a terminal device.
.I Xntpdc
uses NTP mode 7 packets to communicate with the NTP server, and hence
can be used to query any compatable server on the network which permits
-it. Note that since NTP is a UDP protocol this communication will be
+it. Note that since NTP is a UDP protocol this communication will be
somewhat unreliable, especially over large distances in terms of network
topology.
.I 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
+Command line options are described following. Specifying a command line
+option other than
.B -i
or
.B -n
will cause the specified query (queries) to be sent to the indicated
-host(s) immediately. Otherwise,
+host(s) immediately. Otherwise,
.I xntpdc
-will attempt to read interactive format commands from the standard input.
+will attempt to read interactive format commands from the standard
+input.
.Ip -c 8
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
+host(s). Multiple
.B -c
options may be given.
.Ip -i 8
Force
.I xntpdc
-to operate in interactive mode. Prompts will be written to the
-standard output and commands read from the standard input.
+to operate in interactive mode. Prompts will be written to the standard
+output and commands read from the standard input.
.Ip -l 8
-Obtain a list of peers which are known to the server(s). This switch
-is equivalent to \*(L"-c listpeers\*(R".
+Obtain a list of peers which are known to the server(s). This switch is
+equivalent to \*(L"-c listpeers\*(R".
.Ip -n 8
Output all host addresses in dotted\-quad numeric format rather than
converting to the canonical host names.
.Ip -p 8
-Print a list of the peers known to the server as well as a summary
-of their state. This is equivalent to \*(L"-c peers\*(R".
+Print a list of the peers known to the server as well as a summary of
+their state. This is equivalent to \*(L"-c peers\*(R".
.Ip -s 8
-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
+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
.B -p
-switch. This is equivalent to \*(L"-c dmpeers\*(R".
+switch. This is equivalent to \*(L"-c dmpeers\*(R".
.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 \*(L">\*(R",
-followed by a file name, to the command line.
+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 \*(L">\*(R", followed by a
+file name, to the command line.
.PP
A number of interactive format commands are executed entirely within the
.I xntpdc
-program itself and do not result in NTP mode 7 requests being sent
-to a server. These are described following.
+program itself and do not result in NTP mode 7 requests being sent to a
+server. These are described following.
.PP
.B ?
[
@@ -152,7 +153,7 @@ A \*(L"?\*(R" by itself will print a list of all the command keywords
known to this incarnation of
.IR xntpdc .
A \*(L"?\*(R" followed by a command keyword will print funcation and
-usage information about the command. This command is probably a better
+usage information about the command. This command is probably a better
source of information about
.I xntpdc
than this manual page.
@@ -169,14 +170,14 @@ command.
.B timeout
.I millseconds
.PP
-Specify a time out period for responses to server queries. The default
+Specify a time out period for responses to server queries. The default
is about 8000 milliseconds.
.PP
.B delay
.I milliseconds
.PP
Specify a time interval to be added to timestamps included in requests
-which require authentication. This is used to enable (unreliable) server
+which require authentication. This is used to enable (unreliable) server
reconfiguration over long delay network paths or between machines whose
clocks are unsynchronized.
.PP
@@ -185,40 +186,27 @@ clocks are unsynchronized.
.PP
Set the host to which future queries will be sent.
.I Hostname
-may be either a host name or a numeric
-address.
-.PP
-.B poll
-[
-.I #
-] [
-.B verbose
-]
-.PP
-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.
+may be either a host name or a numeric (dotted quad) dmaddress.
.PP
.B keyid
.I #
.PP
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.
+authenticate configuration requests. This must correspond to the key
+number the server has been configured to use for this purpose.
.PP
.B passwd
.PP
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.
+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.
.PP
.B "hostnames yes|no"
.PP
If \*(L"yes\*(R" is specified, host names are printed in information
-displays. If \*(L"no\*(R" is given, numeric addresses are printed
-instead. The default is \*(L"yes\*(R" unless modified using the command
+displays. If \*(L"no\*(R" is given, numeric addresses are printed
+instead. The default is \*(L"yes\*(R" unless modified using the command
line
.B -n
switch.
@@ -230,51 +218,49 @@ Exit
.SH QUERY COMMANDS
.PP
Query commands result in NTP mode 7 packets containing requests for
-information being sent to the server. These are \*(L"read\-only\*(R"
+information being sent to the server. These are \*(L"read\-only\*(R"
commands in that they make no modification of the server configuration
state.
.PP
.B listpeers
.PP
-Obtains and prints 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 synchonization
-candidates.
+Obtains and prints 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 synchonization candidates.
.PP
.B peers
.PP
Obtains 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
-\*(L"+\*(R" denotes symmetric active, a \*(L"-\*(R" indicates symmetric
-passive, a \*(L"=\*(R" means the remote server is being polled in
-client mode, a \*(L"^\*(R" indicates that the server is broadcasting
-to this address, a \*(L"~\*(R" denotes that the remote peer is sending
-broadcasts and a \*(L"*\*(R" marks the peer the server is currently
-synchonizing 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
-\*(L"REFCLK(<implementation number>, <parameter>)\*(R". On \*(L"hostnames no\*(R"
-only IP\-addresses will be displayed.
+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 \*(L"+\*(R" denotes symmetric
+active, a \*(L"-\*(R" indicates symmetric passive, a \*(L"=\*(R" means
+the remote server is being polled in client mode, a \*(L"^\*(R"
+indicates that the server is broadcasting to this address, a \*(L"~\*(R"
+denotes that the remote peer is sending broadcasts and a \*(L"*\*(R"
+marks the peer the server is currently synchonizing 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 \*(L"REFCLK(<implementation number>, <parameter>)\*(R". On
+\*(L"hostnames no\*(R" only IP\-addresses will be displayed.
.PP
.B dmpeers
.PP
-A slightly different peer summary list. Identical to the output of the
+A slightly different peer summary list. Identical to the output of the
.B 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 \*(L".\*(R" indicates that this
-peer was cast off in the falseticker detection, while a \*(L"+\*(R"
-indicates that the peer made it through. A \*(L"*\*(R" denotes the
-peer the server is currently synchronizing with.
+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 \*(L".\*(R" indicates that this peer was cast off
+in the falseticker detection, while a \*(L"+\*(R" indicates that the
+peer made it through. A \*(L"*\*(R" denotes the peer the server is
+currently synchronizing with.
.PP
.B showpeer
.I peer_address
@@ -287,7 +273,7 @@ peer the server is currently synchronizing with.
]
.PP
Shows a detailed display of the current peer variables for one or more
-peers. Most of these values are described in the NTP Version 2
+peers. Most of these values are described in the NTP Version 2
specification.
.PP
.B pstats
@@ -302,72 +288,93 @@ specification.
.PP
Show per\-peer statistic counters associated with the specified peer(s).
.PP
+.B clockinfo
+.I clock_peer_address
+[
+.I addr2
+] [
+.I addr3
+] [
+.I addr4
+]
+.PP
+Obtain and print information concerning a peer clock. The values
+obtained provide information on the setting of fudge factors and other
+clock performance information.
+.PP
+.B kerninfo
+.PP
+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.
+.PP
.B loopinfo
[
.B oneline|multiline
]
.PP
-Print the values of selected loop filter variables. The loop filter is
-the part of NTP which deals with adjusting the local system clock. The
+Print the values of selected loop filter variables. The loop filter is
+the part of NTP which deals with adjusting the local system clock. The
\*(L"offset\*(R" is the last offset given to the loop filter by the
-packet processing code. The \*(L"frequency\*(R" is actually the
-frequency error, or drift, of your system's clock in the units NTP
-uses for internal computations. Dividing this number by 4096 should
-give you the actual drift rate. The \*(L"compliance\*(R" is actually
-a long term average offset and is used by NTP to control the gain of
-the loop filter. The \*(L"timer\*(R" value is the number of seconds
-which have elapsed since a new sample offset was given to the loop
-filter. The \*(L"oneline\*(R" and \*(L"multiline\*(R" options specify
-the format in which this information is to be printed. \*(L"multiline\*(R"
-is the default.
+packet processing code. The \*(L"frequency\*(R" is the frequency error
+of the local clock in parts-per-million (ppm). The \*(L"time_const\*(R"
+controls the "stiffness" of the phase-lock loop and thus the speed at
+which it can adapt to oscillator drift. The \*(L"watchdog timer\*(R"
+value is the number of seconds which have elapsed since the last sample
+offset was given to the loop filter. The \*(L"oneline\*(R" and
+\*(L"multiline\*(R" options specify the format in which this information
+is to be printed, with \*(L"multiline\*(R" as the default.
.PP
.B sysinfo
.PP
Print a variety of system state variables, i.e. state related to the
-local server. Many of these values are described in the NTP Version 2
-specification, RFC 1119.
+local server. All except the last four lines are described in the NTP
+Version 3 specification, RFC 1305. The \*(L"system flags\*(R" show
+various system flags, some of which can be set and cleared by the
+\*(L"enable\*(R" and \*(L"disable\*(R" configuration commands,
+respectively. The \*(L"stability\*(R" 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 \*(L"tick\*(R" may be incorrect. The
+\*(L"broadcastdelay\*(R" shows the default broadcast delay, as set by
+the \*(L"broadcastdelay\*(R" configuration command, while the
+\*(L"authdelay\*(R" shows the default authentication delay, as set by
+the \*(L"authdelay\*(R" configuration command.
.PP
.B sysstats
.PP
-Print a number of stat counters maintained in the protocol module.
+Print statistics counters maintained in the protocol module.
.PP
.B memstats
.PP
-Print a number of counters related to the peer memory allocation
+Print statistics counters related to memory allocation
code.
.PP
.B iostats
.PP
-Print counters maintained in the input\-output module.
+Print statistics counters maintained in the input\-output module.
.PP
.B timerstats
.PP
-Print counters maintained in the timer/event queue support code.
+Print statistics counters maintained in the timer/event queue support
+code.
.PP
.B reslist
.PP
-Obtain and print the server's restriction list. This list is (usually)
+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.
.PP
.B monlist
-.PP
-Obtain and print traffic counts collected and maintained by the
-monitor facility.
-.PP
-.B clockinfo
-.I clock_peer_address
[
-.I addr2
-] [
-.I addr3
-] [
-.I addr4
+.I version
]
.PP
-Obtain and print information concerning a peer clock. The values
-obtained provide information on the setting of fudge factors and
-other clock performance information.
+Obtain and print traffic counts collected and maintained by the monitor
+facility. The version number should not normally need to be specified.
.PP
.B clkbug
.I clock_peer_address
@@ -379,51 +386,43 @@ other clock performance information.
.I addr4
]
.PP
-Obtain debugging information for a clock peer. This information is
-provided only by some clock drivers and is mostly undecodable without
-a copy of the driver source in hand.
-.PP
-.B kerninfo
-.PP
-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.
+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.
.SH RUNTIME CONFIGURATION REQUESTS
.PP
All requests which cause state changes in the server are authenticated
by the server using a configured 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
+disabled by the server by not configuring a key). The key number and the
+corresponding key must also be made known to
.IR xtnpdc .
This can be done using the
.B keyid
and
.B 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.
+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.
.PP
@@ -434,24 +433,21 @@ The following commands all make authenticated requests.
] [
.I version#
] [
-.B minpoll|prefer
+.B prefer
]
.PP
-Add a configured, symmetric active peer association with a peer at the
-given address. If the optional \*(L"keyid\*(R" 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
-\*(L"version#\*(R" can be 1 or 2, and defaults to 2. If \*(L"minpoll\*(R"
-is specified the polling interval for the association will remain
-clamped at the minimum. The latter option is only useful for testing.
-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. The 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.
+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 \*(L"keyid\*(R" 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 \*(L"version#\*(R" can be 1, 2 or 3 and defaults to 3. The
+\*(L"prefer\*(R" 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.
.PP
.B addserver
.I peer_address
@@ -460,13 +456,12 @@ PPS signal.
] [
.I version#
] [
-.B minpoll|prefer
+.B prefer
]
.PP
Identical to the
.B addpeer
-command except that polling is done in client mode rather than
-symmetric active mode.
+command, except that the operating mode is client.
.PP
.B broadcast
.I peer_address
@@ -474,15 +469,15 @@ symmetric active mode.
.I keyid
] [
.I version#
-] [
-.B minpoll
]
.PP
Identical to the
.B addpeer
-command except that packets are instead sent in broadcast mode. The
-\*(L"peer_address\*(R" parameter will generally be a broadcast address
-on one of your local networks.
+command, except that the operating mode is broadcast. In this case a
+valid key identifier and key are required. The \*(L"peer_address\*(R"
+parameter can be the broadcast address of the local network or a
+multicast group address assigned to NTP. If a multicast address, a
+multicast-capable kernel is required.
.PP
.B unconfig
.I peer_address
@@ -495,34 +490,56 @@ on one of your local networks.
]
.PP
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.
+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.
+.PP
+.B fudge
+.I peer_address
+[
+.I time1
+] [
+.I time2
+] [
+.I stratum
+] [
+.I refid
+]
.PP
-.B set bclient|mclient|auth
+This command provides a way to set certain data for a reference clock.
+See the source listing for further information.
+.PP
+.B enable auth|bclient|pll|monitor|stats
[
.I ...
]
.PP
-Allows the setting of the broadcast/multicast client and/or authenticate
-system flags. Setting bclient causes the server to listen for broadcast
-NTP to to synchronize to broadcasts when appropriate. Setting mclient
-causes the same thing, but using multicast facilities, when available.
-Setting auth causes the server to only synchronize with peers which
-include an authentication field encrypted with one of the local server's
-trusted keys.
-.PP
-.B clear bclient|auth
+Provides a way to enable various server options. Flags not mentioned are
+unaffected. The \*(L"auth\*(R" 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 \*(L"bclient\*(R" 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 \*(L"pll\*(R" 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 NTP is used only to provide
+synchronization to other clients. The \*(L"monitor\*(R" flag enables the
+monitoring facility (see elsewhere), with default disable (off). The
+\*(L"stats\*(R" flag enables statistics facility filegen (see
+description elsewhere.), with default enable (on).
+.PP
+.B disable auth|bclient|pll|monitor|stats
[
.I ...
]
.PP
-Allows the broadcast/multicast client and/or authenticate system flags to be
-cleared. Clearing bclient causes incoming broadcast and multicast NTP packets
-to be ignored. Clearing auth allows peers which have not included
-an authentication field, or which have included one but have encrypted
-it with an untrusted key, to be considered synchronization candidates.
+Provides a way to disable various server options. Flags not mentioned
+are unaffected. The flags presently available are described under the
+enable command.
.PP
.B restrict
.I address
@@ -532,63 +549,61 @@ it with an untrusted key, to be considered synchronization candidates.
.I flag
]
.PP
-Causes 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
+Causes 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:
.Ip ignore 10
-Ignore all packets from hosts which match this entry. If this flag
-is specified neither queries nor time server polls will be responded
-to.
+Ignore all packets from hosts which match this entry. If this flag is
+specified neither queries nor time server polls will be responded to.
.Ip noquery 10
-Ignore all NTP mode 7 packets (i.e. information queries and configuration
-requests) from the source. Time service is not affected.
+Ignore all NTP mode 7 packets (i.e. information queries and
+configuration requests) from the source. Time service is not affected.
.Ip nomodify 10
Ignore all NTP mode 7 packets which attempt to modify the state of the
-server (i.e. run time reconfiguration). Queries which return information
+server (i.e. run time reconfiguration). Queries which return information
are permitted.
.Ip notrap 10
Decline to provide mode 6 control message trap service to matching
-hosts. The trap service is a subsystem of the mode 6 control message
+hosts. The trap service is a subsystem of the mode 6 control message
protocol which is intended for use by remote event logging programs.
.Ip lowpriotrap 10
-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.
+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.
.Ip noserve 10
-Ignore NTP packets whose mode is other than 7. In effect, time service is
-denied, though queries may still be permitted.
+Ignore NTP packets whose mode is other than 7. In effect, time service
+is denied, though queries may still be permitted.
.Ip nopeer 10
-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.
+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.
.Ip notrust 10
Treat these hosts normally in other respects, but never use them as
synchronization sources.
.Ip limited 10
-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 \*(L"client_limit\*(R" hosts
-that have shown up at the server and that have been active during the
-last \*(L"client_limit_period\*(R" seconds are accepted. Requests from
-other clients from the same net are rejected. Only time request
-packets are taken into account. \*(L"Private\*(R", \*(L"control\*(R",
-and \*(L"broadcast\*(R" 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
+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 \*(L"client_limit\*(R" hosts that have
+shown up at the server and that have been active during the last
+\*(L"client_limit_period\*(R" seconds are accepted. Requests from other
+clients from the same net are rejected. Only time request packets are
+taken into account. \*(L"Private\*(R", \*(L"control\*(R", and
+\*(L"broadcast\*(R" 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
.IR xntpd.
-Thus, monitoring is active as long as there is a restriction entry
-with the \*(L"limited\*(R" flag. The default value for
-\*(L"client_limit\*(R" is 3. The default value for
-\*(L"client_limit_period\*(R" is 3600 seconds. Currently both
-variables are not runtime configurable.
+Thus, monitoring is active as long as there is a restriction entry with
+the \*(L"limited\*(R" flag. The default value for \*(L"client_limit\*(R"
+is 3. The default value for \*(L"client_limit_period\*(R" is 3600
+seconds. Currently both variables are not runtime configurable.
.Ip ntpport 10
This is actually a match algorithm modifier, rather than a restriction
-flag. Its presence causes the restriction entry to be matched only if
-the source port in the packet is the standard NTP UDP port (123). Both
-\*(L"ntpport\*(R" and non\-\*(L"ntpport\*(R" may be specified. The
+flag. Its presence causes the restriction entry to be matched only if
+the source port in the packet is the standard NTP UDP port (123). Both
+\*(L"ntpport\*(R" and non\-\*(L"ntpport\*(R" may be specified. The
\*(L"ntpport\*(R" is considered more specific and is sorted later in the
list.
.PP
@@ -618,7 +633,7 @@ Delete the matching entry from the restrict list.
.PP
.B "monitor yes|no"
.PP
-Enable or disable the monitoring facility. Note that a
+Enable or disable the monitoring facility. Note that a
.B "monitor no"
command followed by a
.B "monitor yes"
@@ -626,11 +641,11 @@ command is a good way of resetting the packet counts.
.PP
.B readkeys
.PP
-Causes 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
+Causes 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
.I xntpd
-configuration file). This allows encryption keys to be changed without
+configuration file). This allows encryption keys to be changed without
restarting the server.
.PP
.B trustkey
@@ -643,9 +658,9 @@ restarting the server.
.I keyid
]
.PP
-Adds 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.
+Adds 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.
.PP
.B untrustkey
.I keyid
@@ -668,8 +683,40 @@ done.
.B setprecision
.I precision_value
.PP
-Sets the precision which the server advertises to the specified value. This
-should be a negative integer in the range -4 through -20.
+Sets the precision which the server advertises to the specified value.
+This should be a negative integer in the range -4 through -20.
+.PP
+.B traps
+.PP
+Display the traps set in the server. See the source listing for further
+information.
+.PP
+.B addtrap
+.I address
+[
+.I port
+] [
+.I interface
+]
+.PP
+Set a trap for asynchronous messages. See the source listing for further
+information.
+.PP
+.B clrtrap
+.I address
+[
+.I port
+] [
+.I interface
+]
+.PP
+Clear a trap for asynchronous messages. See the source listing for
+further information.
+.PP
+.B reset ...
+.PP
+Clear the statistics counters in various modules of the server. See the
+source listing for further information.
.SH SEE ALSO
.PP
.IR xntpd (8)
@@ -679,8 +726,8 @@ Written by Dennis Ferguson at the University of Toronto.
.SH BUGS
.PP
.I 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.
+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.
diff --git a/usr.sbin/xntpd/include/README b/usr.sbin/xntpd/include/README
index 5127b70a1b3a..73d0620569a2 100644
--- a/usr.sbin/xntpd/include/README
+++ b/usr.sbin/xntpd/include/README
@@ -4,3 +4,18 @@ 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.
diff --git a/usr.sbin/xntpd/include/in.h b/usr.sbin/xntpd/include/in.h
new file mode 100644
index 000000000000..abd404ceda8d
--- /dev/null
+++ b/usr.sbin/xntpd/include/in.h
@@ -0,0 +1,256 @@
+/* @(#)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*/
diff --git a/usr.sbin/xntpd/include/l_stdlib.h b/usr.sbin/xntpd/include/l_stdlib.h
index e0b7c474095c..426dc48b2e34 100644
--- a/usr.sbin/xntpd/include/l_stdlib.h
+++ b/usr.sbin/xntpd/include/l_stdlib.h
@@ -80,6 +80,7 @@ extern int link P((const char *, const char *));
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 *));
@@ -87,6 +88,7 @@ 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 *));
@@ -151,7 +153,43 @@ extern int nlist P((char *, struct nlist *));
#endif /* SYS_SUNOS4 */
/*
- * Unprototyped library functions for ULTRIX.
+ * 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));
@@ -162,7 +200,6 @@ extern char *mktemp P((char *));
extern int unlink P((const char *));
extern int link P((const char *, const char *));
-#if defined(LOG_DEBUG)
extern void closelog P((void));
extern void syslog P((int, char *, ...));
#ifndef LOG_DAEMON
@@ -170,7 +207,6 @@ extern void openlog P((char *, int));
#else
extern void openlog P((char *, int, int));
#endif
-#endif
extern int setpriority P((int ,int ,int ));
@@ -184,7 +220,9 @@ extern int recvfrom P((int, char *, int, int, struct sockaddr *, int *));
#endif /* SOCK_STREAM */
#ifdef _TIME_H_
-extern int adjtime P((struct timeval *, struct timeval *));
+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_ */
@@ -193,6 +231,12 @@ extern int setitimer P((int , struct itimerval *, struct itimerval *));
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));
@@ -204,15 +248,17 @@ extern int getdtablesize P((void));
extern int ran P((void));
extern int rand P((void));
extern void srand P((unsigned int));
-#if defined(_STDIO_H_)
-extern int setlinebuf P((FILE *));
-#endif
#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_ULTIRX */
+#endif /* SYS_ULTRIX */
#if defined(__convex__)
extern char * getpass P((char *));
@@ -230,5 +276,9 @@ extern char * getpass P((char *));
extern char * getpass P((char *));
#endif /* SYS_DOMAINOS */
+#ifdef SYS_BSD
+#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
+#endif
+
#endif /* l_stdlib_h */
diff --git a/usr.sbin/xntpd/include/md5.h b/usr.sbin/xntpd/include/md5.h
index c13f63905ebc..82b43e1b5da7 100644
--- a/usr.sbin/xntpd/include/md5.h
+++ b/usr.sbin/xntpd/include/md5.h
@@ -1,4 +1,4 @@
-/* md5.h,v 3.1 1993/07/06 01:06:44 jbj Exp
+/*
***********************************************************************
** md5.h -- header file for implementation of MD5 **
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
diff --git a/usr.sbin/xntpd/include/mx4200.h b/usr.sbin/xntpd/include/mx4200.h
index 5a9e49651ca4..13058deb1e5e 100644
--- a/usr.sbin/xntpd/include/mx4200.h
+++ b/usr.sbin/xntpd/include/mx4200.h
@@ -1,5 +1,3 @@
-/* @(#) mx4200.h,v 3.1 1993/07/06 01:06:46 jbj Exp */
-
/* records transmitted from extern CDU to MX 4200 */
#define PMVXG_S_INITMODEA 0 /* initialization/mode part A */
diff --git a/usr.sbin/xntpd/include/ntp.h b/usr.sbin/xntpd/include/ntp.h
index 01bfa16a7ad8..733f2e72893f 100644
--- a/usr.sbin/xntpd/include/ntp.h
+++ b/usr.sbin/xntpd/include/ntp.h
@@ -1,4 +1,4 @@
-/* ntp.h,v 3.1 1993/07/06 01:06:47 jbj Exp
+/*
* ntp.h - NTP definitions for the masses
*/
@@ -32,18 +32,20 @@ typedef signed char s_char;
#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 /* default min poll (64 sec) */
-#define NTP_MINPOLL 4 /* absolute min poll (16 sec) */
-#define NTP_MAXPOLL 10 /* actually 1<<10, or 1024 sec */
+#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 0x28f /* 0.01 sec in fp format */
-#define NTP_MAXDISPERSE (16*FP_SECOND) /* maximum dispersion (fp 16) */
-#define NTP_DISPFACTOR 20 /* MAXDISPERSE as a shift */
+#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.
@@ -62,27 +64,23 @@ typedef signed char s_char;
#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_WEIGHTTC 5 /* log2 time constant weight (32) */
-#define CLOCK_HOLDTC 128 /* time constant hold (sec) */
+#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_F 0x20c49ba6 /* 128 ms, in time stamp format */
-#define CLOCK_MAX_I 0x0 /* both fractional and integral parts */
+#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 */
/*
- * Unspecified default. sys.precision defaults to -6 unless otherwise
- * adjusted.
- */
-#define DEFAULT_SYS_PRECISION (-6)
-
-/*
* 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 128, to cover a time
- * period of 2**NTP_MAXPOLL (1024) seconds into the future before
+ * 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
@@ -92,7 +90,7 @@ struct event {
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 */
+ u_long event_time; /* expiry time of counter */
};
#define TIMER_SLOTTIME (1<<(NTP_MINPOLL-1))
@@ -162,9 +160,10 @@ struct interface {
struct sockaddr_in mask; /* interface mask */
char name[8]; /* name of interface */
int flags; /* interface flags */
- LONG received; /* number of incoming packets */
- LONG sent; /* number of outgoing packets */
- LONG notsent; /* number of send failures */
+ int last_ttl; /* last TTL specified */
+ long received; /* number of incoming packets */
+ long sent; /* number of outgoing packets */
+ long notsent; /* number of send failures */
};
/*
@@ -200,6 +199,7 @@ struct peer {
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 */
@@ -211,6 +211,7 @@ struct peer {
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 */
@@ -242,33 +243,30 @@ struct peer {
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 */
+ 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 */
- U_LONG estbdelay; /* broadcast delay, as a ts fraction */
+ 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 bogusrec; /* rejected due to bogus receive */
- U_LONG bogusdelay; /* rejected due to bogus delay */
- U_LONG disttoolarge; /* rejected due to large distance */
- 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_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 */
@@ -298,7 +296,7 @@ struct peer {
#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
@@ -315,8 +313,8 @@ struct peer {
*/
#define FLAG_CONFIG 0x1 /* association was configured */
#define FLAG_AUTHENABLE 0x2 /* this guy needs authentication */
-#define FLAG_UNUSED 0x4 /* (not used) */
-#define FLAG_DEFBDELAY 0x8 /* using default bdelay */
+#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 */
@@ -334,13 +332,13 @@ struct peer {
/*
* Reference clock identifiers (for pps signal)
*/
-#define PPSREFID "PPS " /* used when pps controls stratum > 1 */
+#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., ACTS) */
+#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 */
@@ -353,8 +351,16 @@ struct peer {
#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 /* MSF EES M201, UK */
-#define REFCLK_GPSTM_TRUETIME 15 /* TrueTime GPS/TM-TMD */
+#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
@@ -474,6 +480,7 @@ struct recvbuf {
#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 */
@@ -576,6 +583,10 @@ struct recvbuf {
#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
@@ -596,29 +607,38 @@ struct recvbuf {
/*
* Default parameters. We use these in the absense of something better.
*/
-#define DEFPRECISION (-5) /* conservatively low */
-#define DEFBROADDELAY (0x020c49ba) /* 8 ms. This is round trip delay */
+#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 *hash_prev; /* previous 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 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
*/
@@ -632,7 +652,7 @@ 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_long count; /* number of packets matched */
u_short flags; /* accesslist flags */
u_short mflags; /* match flags */
};
diff --git a/usr.sbin/xntpd/include/ntp_calendar.h b/usr.sbin/xntpd/include/ntp_calendar.h
index fc12f0b2945c..461aee4ce9af 100644
--- a/usr.sbin/xntpd/include/ntp_calendar.h
+++ b/usr.sbin/xntpd/include/ntp_calendar.h
@@ -1,4 +1,4 @@
-/* ntp_calendar.h,v 3.1 1993/07/06 01:06:48 jbj Exp
+/*
* ntp_calendar.h - definitions for the calendar time-of-day routine
*/
@@ -66,8 +66,8 @@ struct calendar {
* 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)
+#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.
@@ -75,6 +75,6 @@ struct calendar {
#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 *));
+extern void caljulian P((u_long, struct calendar *));
+extern u_long caltontp P((const struct calendar *));
diff --git a/usr.sbin/xntpd/include/ntp_control.h b/usr.sbin/xntpd/include/ntp_control.h
index 1e193835660d..1124bb0cbbba 100644
--- a/usr.sbin/xntpd/include/ntp_control.h
+++ b/usr.sbin/xntpd/include/ntp_control.h
@@ -1,4 +1,4 @@
-/* ntp_control.h,v 3.1 1993/07/06 01:06:50 jbj Exp
+/*
* ntp_control.h - definitions related to NTP mode 6 control messages
*/
@@ -236,10 +236,10 @@ struct ntp_control {
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_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 */
diff --git a/usr.sbin/xntpd/include/ntp_datum.h b/usr.sbin/xntpd/include/ntp_datum.h
new file mode 100644
index 000000000000..2aa2cb742d01
--- /dev/null
+++ b/usr.sbin/xntpd/include/ntp_datum.h
@@ -0,0 +1,30 @@
+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 */
diff --git a/usr.sbin/xntpd/include/ntp_filegen.h b/usr.sbin/xntpd/include/ntp_filegen.h
index 7281d597aaeb..9e75bc63fc97 100644
--- a/usr.sbin/xntpd/include/ntp_filegen.h
+++ b/usr.sbin/xntpd/include/ntp_filegen.h
@@ -1,5 +1,5 @@
/*
- * ntp_filegen.h,v 3.7 1994/01/25 19:04:16 kardel Exp
+ * ntp_filegen.h,v 3.8 1994/05/30 09:48:53 kardel Exp
*
* definitions for NTP file generations support
*
@@ -40,12 +40,12 @@ typedef struct FILEGEN
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_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_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 *));
diff --git a/usr.sbin/xntpd/include/ntp_fp.h b/usr.sbin/xntpd/include/ntp_fp.h
index 327306054b44..ec657f7fb451 100644
--- a/usr.sbin/xntpd/include/ntp_fp.h
+++ b/usr.sbin/xntpd/include/ntp_fp.h
@@ -1,4 +1,4 @@
-/* ntp_fp.h,v 3.1 1993/07/06 01:06:54 jbj Exp
+/*
* ntp_fp.h - definitions for NTP fixed point arithmetic
*/
@@ -10,7 +10,7 @@
/*
* 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
+ * 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,
@@ -103,13 +103,13 @@ typedef U_LONG u_fp;
* 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_ui, (v)->l_uf)
+#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
+ * 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.
@@ -263,7 +263,7 @@ typedef U_LONG u_fp;
((a_i) == (b_i) && (a_f) == (b_f))
/*
- * Operations on the LONG fp format
+ * 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)
@@ -277,6 +277,7 @@ typedef U_LONG u_fp;
#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 || \
@@ -284,7 +285,7 @@ typedef U_LONG u_fp;
#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 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 *));
diff --git a/usr.sbin/xntpd/include/ntp_if.h b/usr.sbin/xntpd/include/ntp_if.h
index 45a70c51bcd5..bc842fbcc644 100644
--- a/usr.sbin/xntpd/include/ntp_if.h
+++ b/usr.sbin/xntpd/include/ntp_if.h
@@ -12,7 +12,7 @@
#include <time.h>
#endif
-#if defined(SOLARIS)&&!defined(bsd)
+#if (defined(SOLARIS) && !defined(bsd)) || defined(SYS_SUNOS4)
#include <sys/sockio.h>
#endif
diff --git a/usr.sbin/xntpd/include/ntp_machine.h b/usr.sbin/xntpd/include/ntp_machine.h
index abc0acb0c61a..91c18dc306f5 100644
--- a/usr.sbin/xntpd/include/ntp_machine.h
+++ b/usr.sbin/xntpd/include/ntp_machine.h
@@ -1,4 +1,4 @@
-/* ntp_machine.h,v 3.1 1993/07/06 01:06:49 jbj Exp
+/*
* Collect all machine dependent idiosyncrasies in one place.
*/
@@ -180,6 +180,7 @@ in this file.
#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
@@ -218,6 +219,7 @@ in this file.
#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
@@ -276,6 +278,7 @@ in this file.
#define HAVE_BSD_NICE
#define RETSIGTYPE void
#define NTP_SYSCALLS_STD
+#define HAVE_MODEM_CONTROL
#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX/Ultrix"
#endif
@@ -364,6 +367,19 @@ in this file.
#endif
/*
+ * 4.4 bsd
+ */
+#if defined(SYS_44BSD)
+#define HAVE_SIGNALED_IO
+#define HAVE_LIBKVM
+#define NTP_POSIX_SOURCE
+#define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/4.4BSD"
+#endif
+#endif
+
+/*
* Linux
*/
#if defined(SYS_LINUX)
@@ -391,7 +407,7 @@ in this file.
#define NTP_POSIX_SOURCE
#define HAVE_BSD_NICE
#ifndef STR_SYSTEM
-#define STR_SYSTEM "UNIX/*BSD"
+#define STR_SYSTEM "UNIX/\052BSD"
#endif
#endif
@@ -404,12 +420,42 @@ in this file.
#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?
*/
diff --git a/usr.sbin/xntpd/include/ntp_refclock.h b/usr.sbin/xntpd/include/ntp_refclock.h
index cc026f5c742f..fcc120001acf 100644
--- a/usr.sbin/xntpd/include/ntp_refclock.h
+++ b/usr.sbin/xntpd/include/ntp_refclock.h
@@ -4,40 +4,48 @@
#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.
+ * 127.127.t.u address
*/
#define REFCLOCKTYPE(srcadr) ((SRCADR(srcadr) >> 8) & 0xff)
#define REFCLOCKUNIT(srcadr) (SRCADR(srcadr) & 0xff)
/*
- * list of reference clock names
- * see lib/clocktypes.c (must also agree with xntpd/refclock_conf.c)
+ * 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 *clocktype; /* long description */
char *abbrev; /* short description */
};
/*
- * Definitions for default values
- */
-#define noentry 0 /* flag for null routine */
-
-/*
- * Definitions for flags
- */
-#define NOFLAGS 0
-#define REF_FLAG_BCLIENT 0x1 /* clock prefers to run as a bclient */
-
-/*
- * Flag values
+ * Configuration flag values
*/
#define CLK_HAVETIME1 0x1
#define CLK_HAVETIME2 0x2
@@ -58,25 +66,25 @@ struct clktype {
* Structure for returning clock status
*/
struct refclockstat {
- u_char type;
- u_char flags;
- u_char haveflags;
- u_short lencode; /* ahem, we do have some longer "time-codes" */
- char *lastcode;
- U_LONG polls;
- U_LONG noresponse;
- U_LONG badformat;
- U_LONG baddata;
- U_LONG timereset;
- char *clockdesc; /* description of clock, in ASCII */
- l_fp fudgetime1;
- l_fp fudgetime2;
- LONG fudgeval1;
- LONG fudgeval2;
- u_char currentstatus;
- u_char lastevent;
- u_char unused;
- struct ctl_var *kv_list; /* additional variables */
+ 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 */
};
/*
@@ -84,59 +92,133 @@ struct refclockstat {
* the reference clock drivers and the I/O module.
*/
struct refclockio {
- struct refclockio *next;
- void (*clock_recv)();
- caddr_t srcclock; /* pointer to clock structure */
- int datalen;
- int fd;
- U_LONG recvcount;
+ 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 */
+};
/*
- * Sizes of things we return for debugging
+ * Structure interface between the reference clock support
+ * ntp_refclock.c and the driver utility routines
*/
-#define NCLKBUGVALUES 16
-#define NCLKBUGTIMES 32
+#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 */
/*
- * Structure for returning debugging info
+ * 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.
*/
-struct refclockbug {
- u_char nvalues;
- u_char ntimes;
- u_short svalues;
- U_LONG stimes;
- U_LONG values[NCLKBUGVALUES];
- l_fp times[NCLKBUGTIMES];
+#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 */
};
/*
- * Struct refclock provides the interface between the reference
- * clock support and particular clock drivers. There are entries
- * to open and close a unit, optional values to specify the
- * timer interval for calls to the transmit procedure and to
- * specify a polling routine to be called when the transmit
- * procedure executes. There is an entry which is called when
- * the transmit routine is about to shift zeroes into the
- * filter register, and entries for stuffing fudge factors into
- * the driver and getting statistics from it.
+ * 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((u_int, struct peer *)); /* start a clock unit */
- void (*clock_shutdown) P((int)); /* shut a clock down */
- void (*clock_poll) P((int, struct peer *)); /* called from the xmit routine */
- void (*clock_control) P((u_int, struct refclockstat *, struct refclockstat *)); /* set fudge values, return stats */
- void (*clock_init) P((void)); /* initialize driver data at startup */
- void (*clock_buginfo) P((int, struct refclockbug *)); /* get clock dependent bug info */
- U_LONG clock_flags; /* flag values */
+ 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 *));
-#endif /* REFCLOCK */
+#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 */
diff --git a/usr.sbin/xntpd/include/ntp_request.h b/usr.sbin/xntpd/include/ntp_request.h
index b1a947291316..698e20a99555 100644
--- a/usr.sbin/xntpd/include/ntp_request.h
+++ b/usr.sbin/xntpd/include/ntp_request.h
@@ -1,4 +1,4 @@
-/* ntp_request.h,v 3.1 1993/07/06 01:06:57 jbj Exp
+/*
* ntp_request.h - definitions for the xntpd remote query facility
*/
@@ -207,7 +207,6 @@ struct resp_pkt {
* the receive time stamp by no more than 10 seconds.
*/
#define INFO_TS_MAXSKEW_UI 10
-#define INFO_TS_MAXSKEW_UF 0
/*
* Universal request codes go here. There aren't any.
@@ -257,23 +256,33 @@ struct resp_pkt {
#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 information returns
+ * Flags in the peer information returns
*/
#define INFO_FLAG_CONFIG 0x1
#define INFO_FLAG_SYSPEER 0x2
-#define INFO_FLAG_MINPOLL 0x4
+#define INFO_FLAG_UNUSED 0x4
#define INFO_FLAG_REFCLOCK 0x8
-#define INFO_FLAG_MCLIENT 0x8 /* danger */
-#define INFO_FLAG_BCLIENT 0x10
-#define INFO_FLAG_PREFER 0x10 /* danger */
+#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.
*/
@@ -352,7 +361,7 @@ struct info_peer {
LONG unused5;
LONG unused6;
LONG unused7;
- U_LONG estbdelay; /* broadcast delay */
+ s_fp estbdelay; /* broadcast offset */
};
@@ -369,21 +378,21 @@ struct info_peer_stats {
U_LONG timetosend; /* time until a packet sent */
U_LONG timereachable; /* time peer has been reachable */
U_LONG sent; /* number sent */
- U_LONG received; /* number received */
+ U_LONG unused1; /* (unused) */
U_LONG processed; /* number processed */
- U_LONG badlength; /* rejected due to bad length */
- U_LONG badauth; /* rejected due to bad auth */
- U_LONG bogusorg; /* funny org time stamps */
- U_LONG oldpkt; /* duplicate packets */
- U_LONG baddelay; /* dropped due to bad delays */
- U_LONG seldelay; /* not selected due to delay */
- U_LONG seldisp; /* not selected due to dispersion */
- U_LONG selbroken; /* not selected because of brokenness */
- U_LONG selold; /* not selected because too old */
- u_char candidate; /* order after falseticker candidate select */
- u_char falseticker; /* order after resort for falseticker */
- u_char select; /* order after select */
- u_char select_total; /* number who made it to selection */
+ 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) */
};
@@ -417,9 +426,10 @@ struct info_sys {
u_char unused1; /* unused */
u_char unused2; /* unused */
u_char unused3; /* unused */
- l_fp bdelay; /* default broadcast delay */
+ s_fp bdelay; /* default broadcast offset */
+ s_fp frequency; /* frequency residual (scaled ppm) */
l_fp authdelay; /* default authentication delay */
- u_fp maxskew; /* (obsolete) */
+ u_fp stability; /* clock stability (scaled ppm) */
};
@@ -518,8 +528,7 @@ struct conf_peer {
};
#define CONF_FLAG_AUTHENABLE 0x1
-#define CONF_FLAG_MINPOLL 0x2
-#define CONF_FLAG_PREFER 0x4
+#define CONF_FLAG_PREFER 0x2
/*
* Structure for passing peer deletion information. Currently
@@ -530,7 +539,6 @@ struct conf_unpeer {
U_LONG peeraddr; /* address of peer */
};
-
/*
* Structure for carrying system flags.
*/
@@ -543,7 +551,10 @@ struct conf_sys_flags {
*/
#define SYS_FLAG_BCLIENT 0x1
#define SYS_FLAG_AUTHENTICATE 0x2
-#define SYS_FLAG_MCLIENT 0x4
+#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
@@ -571,6 +582,23 @@ struct conf_restrict {
/*
* 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 */
@@ -626,7 +654,7 @@ struct info_auth {
U_LONG keynotfound; /* requested key unknown */
U_LONG encryptions; /* number of encryptions */
U_LONG decryptions; /* number of decryptions */
- U_LONG decryptok; /* number of successful decryptions */
+ U_LONG unused; /* (unused) */
U_LONG keyuncached; /* calls to encrypt/decrypt with uncached key */
};
diff --git a/usr.sbin/xntpd/include/ntp_stdlib.h b/usr.sbin/xntpd/include/ntp_stdlib.h
index f68c768d82d3..646ce602e92b 100644
--- a/usr.sbin/xntpd/include/ntp_stdlib.h
+++ b/usr.sbin/xntpd/include/ntp_stdlib.h
@@ -1,4 +1,4 @@
-/* ntp_stdlib.h,v 3.1 1993/07/06 01:06:58 jbj Exp
+/*
* ntp_stdlib.h - Prototypes for XNTP lib.
*/
#include <sys/types.h>
@@ -24,28 +24,28 @@ extern void msyslog P((int, char *, ...));
extern void msyslog P(());
#endif
-extern void auth_des P((U_LONG *, u_char *));
+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 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 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 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 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));
@@ -53,41 +53,41 @@ 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 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 *));
+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 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_LONG netof P((U_LONG));
-extern char * numtoa P((U_LONG));
-extern char * numtohost P((U_LONG));
-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 u_long netof P((u_long));
+extern char * numtoa P((u_long));
+extern char * numtohost P((u_long));
+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 int decodenetnum P((const char *, u_long *));
extern RETSIGTYPE signal_no_reset P((int, RETSIGTYPE (*func)()));
diff --git a/usr.sbin/xntpd/include/ntp_syslog.h b/usr.sbin/xntpd/include/ntp_syslog.h
index 0d5dff8cc45a..38b847bb82ca 100644
--- a/usr.sbin/xntpd/include/ntp_syslog.h
+++ b/usr.sbin/xntpd/include/ntp_syslog.h
@@ -1,4 +1,4 @@
-/* ntp_syslog.h,v 3.1 1993/07/06 01:06:59 jbj Exp
+/*
* A hack for platforms which require specially built syslog facilities
*/
#ifdef GIZMO
diff --git a/usr.sbin/xntpd/include/ntp_types.h b/usr.sbin/xntpd/include/ntp_types.h
index 7a2a3474bdf3..ac3d76cbc911 100644
--- a/usr.sbin/xntpd/include/ntp_types.h
+++ b/usr.sbin/xntpd/include/ntp_types.h
@@ -1,4 +1,4 @@
-/* ntp_types.h,v 3.1 1993/07/06 01:07:00 jbj Exp
+/*
* 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
diff --git a/usr.sbin/xntpd/include/ntp_unixtime.h b/usr.sbin/xntpd/include/ntp_unixtime.h
index c1ab573f4d4c..8007a06640c9 100644
--- a/usr.sbin/xntpd/include/ntp_unixtime.h
+++ b/usr.sbin/xntpd/include/ntp_unixtime.h
@@ -1,4 +1,4 @@
-/* ntp_unixtime.h,v 3.1 1993/07/06 01:07:02 jbj Exp
+/*
* ntp_unixtime.h - contains constants and macros for converting between
* NTP time stamps (l_fp) and Unix times (struct timeval)
*/
@@ -34,9 +34,9 @@
* 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[];
+extern u_long ustotslo[];
+extern u_long ustotsmid[];
+extern u_long ustotshi[];
#define TVUTOTSF(tvu, tsf) \
(tsf) = ustotslo[(tvu) & 0xff] \
@@ -48,14 +48,14 @@ extern U_LONG ustotshi[];
*/
#define TVTOTS(tv, ts) \
do { \
- (ts)->l_ui = (unsigned LONG)(tv)->tv_sec; \
+ (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; \
+ long usec; \
(ts)->l_ui = (tv)->tv_sec; \
usec = (tv)->tv_usec; \
if (((tv)->tv_sec < 0) || ((tv)->tv_usec < 0)) { \
@@ -81,9 +81,9 @@ extern U_LONG ustotshi[];
* 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[];
+extern long tstouslo[];
+extern long tstousmid[];
+extern long tstoushi[];
#define TSFTOTVU(tsf, tvu) \
(tvu) = (tstoushi[((tsf) >> 24) & 0xff] \
@@ -109,8 +109,8 @@ extern LONG tstoushi[];
* 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[];
+extern u_long msutotsflo[];
+extern u_long msutotsfhi[];
#define MSUTOTSF(msu, tsf) \
(tsf) = msutotsfhi[((msu) >> 5) & 0x1f] + msutotsflo[(msu) & 0x1f]
diff --git a/usr.sbin/xntpd/include/ntpd.h b/usr.sbin/xntpd/include/ntpd.h
index 037e8cb366f4..53e3a913f2d6 100644
--- a/usr.sbin/xntpd/include/ntpd.h
+++ b/usr.sbin/xntpd/include/ntpd.h
@@ -63,10 +63,10 @@ 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 io_multicast_add P((u_long));
+extern void io_multicast_del P((u_long));
-extern void sendpkt P((struct sockaddr_in *, struct interface *, struct pkt *, int));
+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));
@@ -88,6 +88,7 @@ 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)
@@ -103,12 +104,12 @@ 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 *));
+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 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 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 *));
@@ -134,7 +135,7 @@ 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_config P((int, u_long));
extern void proto_clr_stats P((void));
#ifdef REFCLOCK
@@ -168,7 +169,7 @@ 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_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));
diff --git a/usr.sbin/xntpd/include/parse.h b/usr.sbin/xntpd/include/parse.h
index 6ce3f192754a..49ed4e55b82c 100644
--- a/usr.sbin/xntpd/include/parse.h
+++ b/usr.sbin/xntpd/include/parse.h
@@ -1,7 +1,7 @@
/*
- * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp
+ * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.21 1994/05/30 20:58:34 kardel Exp
*
- * parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp
+ * parse.h,v 3.21 1994/05/30 20:58:34 kardel Exp
*
* Copyright (c) 1989,1990,1991,1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
@@ -15,7 +15,7 @@
#ifndef __PARSE_H__
#define __PARSE_H__
#if !(defined(lint) || defined(__GNUC__))
- static char parsehrcsid[]="parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp";
+ static char parsehrcsid[]="parse.h,v 3.21 1994/05/30 20:58:34 kardel Exp";
#endif
#include "ntp_types.h"
@@ -50,7 +50,6 @@ extern int splhigh();
#define FREE(_X_, _Y_) kmem_free((caddr_t)_X_, _Y_)
#endif
#else
-/* extern char *malloc(); XXX defined elsewhere */
#define MALLOC(_X_) malloc(_X_)
#define FREE(_X_, _Y_) free(_X_)
#endif
@@ -74,6 +73,13 @@ extern int debug;
#endif /* DEBUG */
#endif /* PARSESTREAM */
+#if defined(timercmp) && defined(__GNUC__)
+#undef timercmp
+#define timercmp(tvp, uvp, cmp) \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec || \
+ ((tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec))
+#endif
+
#ifndef TIMES10
#define TIMES10(_X_) (((_X_) << 3) + ((_X_) << 1))
#endif
@@ -149,6 +155,7 @@ extern int debug;
#define PARSE_STAT_FILTER 0x01 /* filter incoming data */
#define PARSE_STAT_AVG 0x02 /* 1:median average / 0: median point */
#define PARSE_LEAP_DELETE 0x04 /* delete leap */
+#define PARSE_STATISTICS 0x08 /* enable statistics */
#define PARSE_FIXED_FMT 0x10 /* fixed format */
#define PARSE_PPSCLOCK 0x20 /* try to get PPS time stamp via ppsclock ioctl */
@@ -163,13 +170,13 @@ typedef union timestamp
*/
struct parsetime
{
- unsigned LONG parse_status; /* data status - CVT_OK, CVT_NONE, CVT_FAIL ... */
+ u_long parse_status; /* data status - CVT_OK, CVT_NONE, CVT_FAIL ... */
timestamp_t parse_time; /* PARSE timestamp */
timestamp_t parse_stime; /* telegram sample timestamp */
timestamp_t parse_ptime; /* PPS time stamp */
- LONG parse_usecerror; /* sampled/filtered usec error */
- LONG parse_usecdisp; /* sampled usecdispersion */
- unsigned LONG parse_state; /* current receiver state */
+ long parse_usecerror; /* sampled/filtered usec error */
+ long parse_usecdisp; /* sampled usecdispersion */
+ u_long parse_state; /* current receiver state */
unsigned short parse_format; /* format code */
};
@@ -212,13 +219,13 @@ union parsectl
{
struct parsestatus
{
- unsigned LONG flags; /* new/old flags */
+ u_long flags; /* new/old flags */
} parsestatus;
struct parsegettc
{
- unsigned LONG parse_state; /* last state */
- unsigned LONG parse_badformat; /* number of bad packets since last query */
+ u_long parse_state; /* last state */
+ u_long parse_badformat; /* number of bad packets since last query */
unsigned short parse_format;/* last decoded format */
unsigned short parse_count; /* count of valid time code bytes */
char parse_buffer[PARSE_TCMAX+1]; /* timecode buffer */
@@ -233,7 +240,7 @@ union parsectl
struct parsesetcs
{
- unsigned LONG parse_cs; /* character size (needed for stripping) */
+ u_long parse_cs; /* character size (needed for stripping) */
} parsesetcs;
};
@@ -269,21 +276,27 @@ struct parse /* parse module local data */
timestamp_t parse_lastchar; /* time stamp of last received character */
/*
+ * private data - fixed format only
+ */
+ unsigned short parse_plen; /* length of private data */
+ void *parse_pdata; /* private data pointer */
+
+ /*
* time code input buffer (from RS232 or PPS)
*/
unsigned short parse_index; /* current buffer index */
char *parse_data; /* data buffer */
unsigned short parse_dsize; /* size of data buffer */
unsigned short parse_lformat; /* last format used */
- unsigned LONG parse_lstate; /* last state code */
+ u_long parse_lstate; /* last state code */
char *parse_ldata; /* last data buffer */
unsigned short parse_ldsize; /* last data buffer length */
- unsigned LONG parse_badformat; /* number of unparsable pakets */
+ u_long parse_badformat; /* number of unparsable pakets */
/*
* time stamp filtering
*/
- LONG parse_delta[PARSE_DELTA]; /* delta buffer */
+ long parse_delta[PARSE_DELTA]; /* delta buffer */
int parse_dindex;
parsetime_t parse_dtime; /* external data prototype */
@@ -293,16 +306,16 @@ typedef struct parse parse_t;
struct clocktime /* clock time broken up from time code */
{
- LONG day;
- LONG month;
- LONG year;
- LONG hour;
- LONG minute;
- LONG second;
- LONG usecond;
- LONG utcoffset; /* in seconds */
+ long day;
+ long month;
+ long year;
+ long hour;
+ long minute;
+ long second;
+ long usecond;
+ long utcoffset; /* in seconds */
time_t utctime; /* the actual time - alternative to date/time */
- LONG flags; /* current clock status */
+ long flags; /* current clock status */
};
typedef struct clocktime clocktime_t;
@@ -335,20 +348,23 @@ typedef struct clocktime clocktime_t;
#define CVT_NONE 0x00000001 /* format not applicable */
#define CVT_FAIL 0x00000002 /* conversion failed - error code returned */
#define CVT_OK 0x00000004 /* conversion succeeded */
+#define CVT_SKIP 0x00000008 /* conversion succeeded */
#define CVT_BADFMT 0x00000010 /* general format error - (unparsable) */
#define CVT_BADDATE 0x00000020 /* date field incorrect */
#define CVT_BADTIME 0x00000040 /* time field incorrect */
struct clockformat
{
- unsigned LONG (*convert)(); /* conversion routine */
+ u_long (*input)(); /* special input protocol - implies fixed format */
+ u_long (*convert)(); /* conversion routine */
void (*syncevt)(); /* routine for handling RS232 sync events (time stamps) */
- unsigned LONG (*syncpps)(); /* PPS input routine */
- unsigned LONG (*synth)(); /* time code synthesizer */
+ u_long (*syncpps)(); /* PPS input routine */
+ u_long (*synth)(); /* time code synthesizer */
void *data; /* local parameters */
char *name; /* clock format name */
unsigned short length; /* maximum length of data packet */
- unsigned LONG flags; /* valid start symbols etc. */
+ u_long flags; /* valid start symbols etc. */
+ unsigned short plen; /* length of private data - implies fixed format */
struct timeval timeout; /* buffer restart after timeout (us) */
unsigned char startsym; /* start symbol */
unsigned char endsym; /* end symbol */
@@ -360,32 +376,44 @@ typedef struct clockformat clockformat_t;
/*
* parse interface
*/
-extern int parse_ioinit(/* parse_t *parseio */);
-extern void parse_ioend(/* parse_t *parseio */);
-extern int parse_ioread(/* parse_t *parseio, char ch, timestamp_t *ctime */);
-extern int parse_iopps(/* parse_t *parseio, int status, struct timeval *ptime, parsetime_t *dtime */);
-extern void parse_iodone(/* parse_t *parseio */);
-
-extern int parse_getstat(/* parsectl_t *dct, parse_t *parse */);
-extern int parse_setstat(/* parsectl_t *dct, parse_t *parse */);
-extern int parse_timecode(/* parsectl_t *dct, parse_t *parse */);
-extern int parse_getfmt(/* parsectl_t *dct, parse_t *parse */);
-extern int parse_setfmt(/* parsectl_t *dct, parse_t *parse */);
-extern int parse_setcs(/* parsectl_t *dct, parse_t *parse */);
+extern int parse_ioinit P((parse_t *));
+extern void parse_ioend P((parse_t *));
+extern int parse_ioread P((parse_t *, unsigned char, timestamp_t *));
+extern int parse_iopps P((parse_t *, int, timestamp_t *));
+extern void parse_iodone P((parse_t *));
+
+extern int parse_getstat P((parsectl_t *, parse_t *));
+extern int parse_setstat P((parsectl_t *, parse_t *));
+extern int parse_timecode P((parsectl_t *, parse_t *));
+extern int parse_getfmt P((parsectl_t *, parse_t *));
+extern int parse_setfmt P((parsectl_t *, parse_t *));
+extern int parse_setcs P((parsectl_t *, parse_t *));
extern int Strok P((char *, char *));
-extern int Stoi P((char *, LONG *, int));
+extern int Stoi P((char *, long *, int));
-extern time_t parse_to_unixtime P((clocktime_t *, unsigned LONG *));
-extern unsigned LONG updatetimeinfo P((parse_t *, time_t, unsigned LONG, unsigned LONG));
-extern void syn_simple P((parse_t *, timestamp_t *, struct format *, unsigned LONG));
-extern unsigned LONG pps_simple P((parse_t *, int status, timestamp_t *));
+extern time_t parse_to_unixtime P((clocktime_t *, u_long *));
+extern u_long updatetimeinfo P((parse_t *, time_t, u_long, u_long));
+extern void syn_simple P((parse_t *, timestamp_t *, struct format *, u_long));
+extern u_long pps_simple P((parse_t *, int, timestamp_t *));
#endif
/*
* History:
*
* parse.h,v
+ * Revision 3.21 1994/05/30 20:58:34 kardel
+ * fix prototypes
+ *
+ * Revision 3.20 1994/05/30 10:19:44 kardel
+ * LONG cleanup
+ *
+ * Revision 3.19 1994/05/15 11:30:33 kardel
+ * documented flag4 as statistics enable flag
+ *
+ * Revision 3.18 1994/05/12 12:40:34 kardel
+ * shut up gcc about broken Sun/BSD code
+ *
* Revision 3.17 1994/03/03 09:27:20 kardel
* rcs ids fixed
*
diff --git a/usr.sbin/xntpd/include/parse_conf.h b/usr.sbin/xntpd/include/parse_conf.h
index 13cec551db34..47f8c0c4fbd7 100644
--- a/usr.sbin/xntpd/include/parse_conf.h
+++ b/usr.sbin/xntpd/include/parse_conf.h
@@ -1,7 +1,7 @@
/*
- * /src/NTP/REPOSITORY/v3/include/parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp
+ * /src/NTP/REPOSITORY/v3/include/parse_conf.h,v 3.6 1994/05/30 10:19:49 kardel Exp
*
- * parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp
+ * parse_conf.h,v 3.6 1994/05/30 10:19:49 kardel Exp
*
* Copyright (c) 1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
@@ -15,7 +15,7 @@
#ifndef __PARSE_CONF_H__
#define __PARSE_CONF_H__
#if !(defined(lint) || defined(__GNUC__))
- static char dcfhrcsid[]="parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp FAU";
+ static char dcfhrcsid[]="parse_conf.h,v 3.6 1994/05/30 10:19:49 kardel Exp FAU";
#endif
/*
@@ -49,6 +49,6 @@ struct format
char length; /* length of field */
} field_offsets[O_COUNT];
char *fixed_string; /* string with must be chars (blanks = wildcards) */
- unsigned LONG flags;
+ u_long flags;
};
#endif
diff --git a/usr.sbin/xntpd/include/sys/bsd_audioirig.h b/usr.sbin/xntpd/include/sys/bsd_audioirig.h
index 1daeec700b42..6a23260b8147 100644
--- a/usr.sbin/xntpd/include/sys/bsd_audioirig.h
+++ b/usr.sbin/xntpd/include/sys/bsd_audioirig.h
@@ -13,14 +13,14 @@
/*
* irig ioctls
*/
-#if (defined(sun) || defined(ibm032)) && !defined(__GNUC__)
-#define AUDIO_IRIG_OPEN _IO(A, 50)
-#define AUDIO_IRIG_CLOSE _IO(A, 51)
-#define AUDIO_IRIG_SETFORMAT _IOWR(A, 52, int)
-#else
+#if defined(__STDC__) || !(defined(ibm032) && !defined(__GNUC))
#define AUDIO_IRIG_OPEN _IO('A', 50)
#define AUDIO_IRIG_CLOSE _IO('A', 51)
#define AUDIO_IRIG_SETFORMAT _IOWR('A', 52, int)
+#else
+#define AUDIO_IRIG_OPEN _IO(A, 50)
+#define AUDIO_IRIG_CLOSE _IO(A, 51)
+#define AUDIO_IRIG_SETFORMAT _IOWR(A, 52, int)
#endif
/*
diff --git a/usr.sbin/xntpd/include/sys/chudefs.h b/usr.sbin/xntpd/include/sys/chudefs.h
index 50f82527f468..f5549f58b828 100644
--- a/usr.sbin/xntpd/include/sys/chudefs.h
+++ b/usr.sbin/xntpd/include/sys/chudefs.h
@@ -1,4 +1,4 @@
-/* chudefs.h,v 3.1 1993/07/06 01:07:11 jbj Exp
+/*
* Definitions for the CHU line discipline v2.0
*/
diff --git a/usr.sbin/xntpd/include/sys/clkdefs.h b/usr.sbin/xntpd/include/sys/clkdefs.h
index b2596e110514..afbc77a8f1ac 100644
--- a/usr.sbin/xntpd/include/sys/clkdefs.h
+++ b/usr.sbin/xntpd/include/sys/clkdefs.h
@@ -1,8 +1,12 @@
-/* clkdefs.h,v 3.1 1993/07/06 01:07:12 jbj Exp
+/*
* Defines for the "clk" timestamping STREAMS module
*/
+#if defined(sun)
#include <sys/ioccom.h>
+#else
+#include <sys/ioctl.h>
+#endif
/*
* First, we need to define the maximum size of the set of
@@ -10,6 +14,9 @@
*/
#define CLK_MAXSTRSIZE 32
+struct clk_tstamp_charset { /* XXX to use _IOW not _IOWN */
+ char val[CLK_MAXSTRSIZE];
+};
/*
* ioctl(fd, CLK_SETSTR, (char*)c );
@@ -23,9 +30,9 @@
* change this file.
*/
-#if __STDC__
-#define CLK_SETSTR _IOWN('K',01,CLK_MAXSTRSIZE)
+#if defined(__STDC__) /* XXX avoid __STDC__=0 on SOLARIS */
+#define CLK_SETSTR _IOW('K', 01, struct clk_tstamp_charset)
#else
-#define CLK_SETSTR _IOWN(K,01,CLK_MAXSTRSIZE)
+#define CLK_SETSTR _IOW(K, 01, struct clk_tstamp_charset)
#endif
diff --git a/usr.sbin/xntpd/include/sys/parsestreams.h b/usr.sbin/xntpd/include/sys/parsestreams.h
index d07e75cbf26f..7c054afbace6 100644
--- a/usr.sbin/xntpd/include/sys/parsestreams.h
+++ b/usr.sbin/xntpd/include/sys/parsestreams.h
@@ -1,7 +1,7 @@
/*
- * /src/NTP/REPOSITORY/v3/include/sys/parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp
+ * /src/NTP/REPOSITORY/v3/include/sys/parsestreams.h,v 3.12 1994/06/01 08:21:08 kardel Exp
*
- * parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp
+ * parsestreams.h,v 3.12 1994/06/01 08:21:08 kardel Exp
*
* Copyright (c) 1989,1990,1991,1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
@@ -13,7 +13,7 @@
*/
#if !(defined(lint) || defined(__GNUC__))
- static char parse77hrcsid[]="parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp";
+ static char parse77hrcsid[]="parsestreams.h,v 3.12 1994/06/01 08:21:08 kardel Exp";
#endif
#undef PARSEKERNEL
@@ -42,7 +42,7 @@ typedef struct parsestream parsestream_t;
/*--------------- debugging support ---------------------------------*/
-#ifdef DEBUG_DCF
+#ifdef DEBUG_PARSE
extern int parsedebug;
diff --git a/usr.sbin/xntpd/include/sys/ppsclock.h b/usr.sbin/xntpd/include/sys/ppsclock.h
index 952a57bff1e1..edf28aa2e1e8 100644
--- a/usr.sbin/xntpd/include/sys/ppsclock.h
+++ b/usr.sbin/xntpd/include/sys/ppsclock.h
@@ -1,4 +1,3 @@
-/* ppsclock.h,v 3.1 1993/07/06 01:07:14 jbj Exp */
/*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66.
diff --git a/usr.sbin/xntpd/include/sys/timex.h b/usr.sbin/xntpd/include/sys/timex.h
new file mode 100644
index 000000000000..bc2d6349f46b
--- /dev/null
+++ b/usr.sbin/xntpd/include/sys/timex.h
@@ -0,0 +1,290 @@
+/******************************************************************************
+ * *
+ * 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 _SYS_TIMEX_H_
+#define _SYS_TIMEX_H_ 1
+
+#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) */
+
+};
+#ifdef __FreeBSD__
+
+#ifndef KERNEL
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+extern int ntp_gettime __P((struct ntptimeval *));
+extern int ntp_adjtime __P((struct timex *));
+__END_DECLS
+
+#endif /* not KERNEL */
+
+#endif /* __FreeBSD__ */
+#endif /* _SYS_TIMEX_H_ */
diff --git a/usr.sbin/xntpd/include/sys/tpro.h b/usr.sbin/xntpd/include/sys/tpro.h
index 1cdaf9c8e610..f276f81bead0 100644
--- a/usr.sbin/xntpd/include/sys/tpro.h
+++ b/usr.sbin/xntpd/include/sys/tpro.h
@@ -1,4 +1,4 @@
-/* tpro.h,v 3.1 1993/07/06 01:07:07 jbj Exp
+/*
* Structure for the KSI/Odetics TPRO-S data returned in reponse to a
* read() call. Note that these are driver-specific and not dependent on
* 32/64-bit architecture.
diff --git a/usr.sbin/xntpd/kernel/Makefile.tmpl b/usr.sbin/xntpd/kernel/Makefile.tmpl
index c40f810d5e65..8b40f4a92e05 100644
--- a/usr.sbin/xntpd/kernel/Makefile.tmpl
+++ b/usr.sbin/xntpd/kernel/Makefile.tmpl
@@ -13,9 +13,10 @@ CLOCKDEFS=
DEFS=
DEFS_OPT=
DEFS_LOCAL=
-#
+CLK_VDOBJS=clkinit.o tty_clk_STREAMS.o
+CHU_VDOBJS=chuinit.o tty_chu_STREAMS.o
INCL=-I../include
-CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL)
+CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL) -DKERNEL
CC= $(COMPILER)
#
@@ -30,6 +31,26 @@ all:
print "### The parse refclock implementation has their own support in"; \
print "### parse/*."; } }'
+loadable: clk.o chu.o
+
+clk.o: ${CLK_VDOBJS}
+ ld -r ${OBJS} -o clk.o
+
+clk.h:
+ echo "#define NCLK 2" > clk.h
+
+tty_clk_STREAMS.o: clk.h tty_clk_STREAMS.c
+ cc ${CFLAGS} tty_clk_STREAMS.c -c tty_clk_STREAMS.o
+
+chu.o: ${CHU_VDOBJS}
+ ld -r ${OBJS} -o chu.o
+
+chu.h:
+ echo "#define NCHU 2" > chu.h
+
+tty_chu_STREAMS.o: chu.h tty_chu_STREAMS.c
+ cc ${CFLAGS} tty_chu_STREAMS.c -c tty_chu_STREAMS.o
+
clean:
-@rm -f *~ *.o *.out *.ln make.log Makefile.bak \
lintlib.errs lint.errs
diff --git a/usr.sbin/xntpd/kernel/chuinit.c b/usr.sbin/xntpd/kernel/chuinit.c
new file mode 100644
index 000000000000..5fd96fdfee0b
--- /dev/null
+++ b/usr.sbin/xntpd/kernel/chuinit.c
@@ -0,0 +1,76 @@
+/*
+** dynamically loadable chu driver
+**
+** $Header: /usr/src/etc/xntp3.3ww/kernel/RCS/chuinit.c,v 1.1 1994/06/15 22:14:38 rob Exp $
+**
+** william robertson <rob@agate.berkeley.edu>
+*/
+
+#include <sys/types.h>
+#include <sys/conf.h>
+#include <sys/errno.h>
+#include <sys/stream.h>
+#include <sys/syslog.h>
+
+#include <sun/openprom.h>
+#include <sun/vddrv.h>
+
+extern int findmod(); /* os/str_io.c */
+
+extern struct streamtab chuinfo;
+
+struct vdldrv vd = {
+ VDMAGIC_USER,
+ "chu"
+ };
+
+
+int
+xxxinit(function_code, vdp, vdi, vds)
+unsigned int function_code;
+struct vddrv *vdp;
+addr_t vdi;
+struct vdstat *vds;
+{
+ register int i = 0;
+ register int j;
+
+ switch (function_code) {
+ case VDLOAD:
+
+ if (findmod("chu") >= 0) {
+ log(LOG_ERR, "chu stream module already loaded\n");
+ return (EADDRINUSE);
+ }
+
+ i = findmod("\0");
+
+ if (i == -1 || fmodsw[i].f_name[0] != '\0')
+ return(-1);
+
+ for (j = 0; vd.Drv_name[j] != '\0'; j++) /* XXX check bounds */
+ fmodsw[i].f_name[j] = vd.Drv_name[j];
+
+ fmodsw[i].f_name[j] = '\0';
+ fmodsw[i].f_str = &chuinfo;
+
+ vdp->vdd_vdtab = (struct vdlinkage *) &vd;
+
+ return(0);
+
+ case VDUNLOAD:
+ if ((i = findmod(vd.Drv_name)) == -1)
+ return(-1);
+
+ fmodsw[i].f_name[0] = '\0';
+ fmodsw[i].f_str = 0;
+
+ return(0);
+
+ case VDSTAT:
+ return(0);
+
+ default:
+ return(EIO);
+ }
+}
diff --git a/usr.sbin/xntpd/kernel/clkinit.c b/usr.sbin/xntpd/kernel/clkinit.c
new file mode 100644
index 000000000000..e15b114cf00f
--- /dev/null
+++ b/usr.sbin/xntpd/kernel/clkinit.c
@@ -0,0 +1,76 @@
+/*
+** dynamically loadable clk driver
+**
+** $Header: /usr/src/etc/xntp3.3ww/kernel/RCS/clkinit.c,v 1.1 1994/06/15 22:14:38 rob Exp $
+**
+** william robertson <rob@agate.berkeley.edu>
+*/
+
+#include <sys/types.h>
+#include <sys/conf.h>
+#include <sys/errno.h>
+#include <sys/stream.h>
+#include <sys/syslog.h>
+
+#include <sun/openprom.h>
+#include <sun/vddrv.h>
+
+extern int findmod(); /* os/str_io.c */
+
+extern struct streamtab clkinfo;
+
+struct vdldrv vd = {
+ VDMAGIC_USER,
+ "clk"
+ };
+
+
+int
+xxxinit(function_code, vdp, vdi, vds)
+unsigned int function_code;
+struct vddrv *vdp;
+addr_t vdi;
+struct vdstat *vds;
+{
+ register int i = 0;
+ register int j;
+
+ switch (function_code) {
+ case VDLOAD:
+
+ if (findmod("clk") >= 0) {
+ log(LOG_ERR, "clk stream module already loaded\n");
+ return (EADDRINUSE);
+ }
+
+ i = findmod("\0");
+
+ if (i == -1 || fmodsw[i].f_name[0] != '\0')
+ return(-1);
+
+ for (j = 0; vd.Drv_name[j] != '\0'; j++) /* XXX check bounds */
+ fmodsw[i].f_name[j] = vd.Drv_name[j];
+
+ fmodsw[i].f_name[j] = '\0';
+ fmodsw[i].f_str = &clkinfo;
+
+ vdp->vdd_vdtab = (struct vdlinkage *) &vd;
+
+ return(0);
+
+ case VDUNLOAD:
+ if ((i = findmod(vd.Drv_name)) == -1)
+ return(-1);
+
+ fmodsw[i].f_name[0] = '\0';
+ fmodsw[i].f_str = 0;
+
+ return(0);
+
+ case VDSTAT:
+ return(0);
+
+ default:
+ return(EIO);
+ }
+}
diff --git a/usr.sbin/xntpd/kernel/tty_clk.c b/usr.sbin/xntpd/kernel/tty_clk.c
index d1b4bbef64b4..072061039bf3 100644
--- a/usr.sbin/xntpd/kernel/tty_clk.c
+++ b/usr.sbin/xntpd/kernel/tty_clk.c
@@ -191,6 +191,19 @@ clkinput(c, tp)
if (putc(c, &clk->clkbuf) == -1)
goto flushout;
+#ifdef CLKLDISC
+ /*
+ * STREAMS people started writing timestamps this way.
+ * It's not my fault, I am just going along with the flow...
+ */
+ for (i = 0; i < sizeof(struct timeval); i++)
+ if (putc(*( ((char*)&tv) + i ), &clk->clkbuf) == -1)
+ goto flushout;
+#else
+ /*
+ * This is a machine independant way of puting longs into
+ * the datastream. It has fallen into disuse...
+ */
s = tv.tv_sec;
for (i = 0; i < sizeof(long); i++) {
if (putc((s >> 24) & 0xff, &clk->clkbuf) == -1)
@@ -204,6 +217,7 @@ clkinput(c, tp)
goto flushout;
s <<= 8;
}
+#endif
/*
* If the length of the rawq exceeds our sanity limit, dump
diff --git a/usr.sbin/xntpd/kernel/tty_clk_STREAMS.c b/usr.sbin/xntpd/kernel/tty_clk_STREAMS.c
index a69a7573be45..13b0a25f1d89 100644
--- a/usr.sbin/xntpd/kernel/tty_clk_STREAMS.c
+++ b/usr.sbin/xntpd/kernel/tty_clk_STREAMS.c
@@ -38,6 +38,7 @@
#include <sys/kernel.h>
#include <sys/user.h>
#include <sys/errno.h>
+#include <sys/syslog.h>
#include <sys/clkdefs.h>
diff --git a/usr.sbin/xntpd/lib/Makefile.tmpl b/usr.sbin/xntpd/lib/Makefile.tmpl
index 997aa8cbe04b..1a8d020bd886 100644
--- a/usr.sbin/xntpd/lib/Makefile.tmpl
+++ b/usr.sbin/xntpd/lib/Makefile.tmpl
@@ -1,5 +1,5 @@
#
-# Makefile.tmpl,v 3.1 1993/07/06 01:07:38 jbj Exp
+# Makefile.tmpl
#
LIBNAME= libntp
#
diff --git a/usr.sbin/xntpd/lib/a_md512crypt.c b/usr.sbin/xntpd/lib/a_md512crypt.c
index 6033dedcff44..e3705c0483ea 100644
--- a/usr.sbin/xntpd/lib/a_md512crypt.c
+++ b/usr.sbin/xntpd/lib/a_md512crypt.c
@@ -1,4 +1,4 @@
-/* authmd512crypt.c,v 3.1 1993/07/06 01:07:52 jbj Exp
+/*
* md5crypt - MD5 based authentication routines
*/
@@ -7,7 +7,7 @@
#include "md5.h"
#include "ntp_stdlib.h"
-extern U_LONG cache_keyid;
+extern u_long cache_keyid;
extern char *cache_key;
extern int cache_keylen;
@@ -17,7 +17,6 @@ extern int cache_keylen;
extern U_LONG authencryptions;
extern U_LONG authdecryptions;
extern U_LONG authkeyuncached;
-extern U_LONG authdecryptok;
extern U_LONG authnokey;
/*
@@ -41,7 +40,7 @@ static MD5_CTX ctx;
void
MD5auth1crypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
U_LONG *pkt;
int length; /* length of all encrypted data */
{
@@ -67,7 +66,7 @@ MD5auth1crypt(keyno, pkt, length)
*/
int
MD5auth2crypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
U_LONG *pkt;
int length; /* total length of encrypted area */
{
diff --git a/usr.sbin/xntpd/lib/a_md5decrypt.c b/usr.sbin/xntpd/lib/a_md5decrypt.c
index dc7acf6e44bb..bde17c0dbfc9 100644
--- a/usr.sbin/xntpd/lib/a_md5decrypt.c
+++ b/usr.sbin/xntpd/lib/a_md5decrypt.c
@@ -1,4 +1,4 @@
-/* authmd5decrypt.c,v 3.1 1993/07/06 01:07:53 jbj Exp
+/*
* md5crypt - MD5 based authentication routines
*/
@@ -7,7 +7,7 @@
#include "md5.h"
#include "ntp_stdlib.h"
-extern U_LONG cache_keyid;
+extern u_long cache_keyid;
extern char *cache_key;
extern int cache_keylen;
@@ -17,7 +17,6 @@ extern int cache_keylen;
extern U_LONG authencryptions;
extern U_LONG authdecryptions;
extern U_LONG authkeyuncached;
-extern U_LONG authdecryptok;
extern U_LONG authnokey;
/*
@@ -35,7 +34,7 @@ extern U_LONG authnokey;
int
MD5authdecrypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
const U_LONG *pkt;
int length; /* length of variable data in octets */
{
diff --git a/usr.sbin/xntpd/lib/a_md5encrypt.c b/usr.sbin/xntpd/lib/a_md5encrypt.c
index 2ae625810339..0d816dc20976 100644
--- a/usr.sbin/xntpd/lib/a_md5encrypt.c
+++ b/usr.sbin/xntpd/lib/a_md5encrypt.c
@@ -1,4 +1,4 @@
-/* authmd5encrypt.c,v 3.1 1993/07/06 01:07:54 jbj Exp
+/*
* md5crypt - MD5 based authentication routines
*/
@@ -7,7 +7,7 @@
#include "md5.h"
#include "ntp_stdlib.h"
-extern U_LONG cache_keyid;
+extern u_long cache_keyid;
extern char *cache_key;
extern int cache_keylen;
@@ -17,7 +17,6 @@ extern int cache_keylen;
extern U_LONG authencryptions;
extern U_LONG authdecryptions;
extern U_LONG authkeyuncached;
-extern U_LONG authdecryptok;
extern U_LONG authnokey;
/*
@@ -36,7 +35,7 @@ extern U_LONG authnokey;
int
MD5authencrypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
U_LONG *pkt;
int length; /* length of encrypted portion of packet */
{
diff --git a/usr.sbin/xntpd/lib/atoint.c b/usr.sbin/xntpd/lib/atoint.c
index 0e8ea8f6fc18..33b5c5d5bc31 100644
--- a/usr.sbin/xntpd/lib/atoint.c
+++ b/usr.sbin/xntpd/lib/atoint.c
@@ -1,4 +1,4 @@
-/* atoint.c,v 3.1 1993/07/06 01:07:39 jbj Exp
+/*
* atoint - convert an ascii string to a signed long, with error checking
*/
#include <sys/types.h>
@@ -9,9 +9,9 @@
int
atoint(str, ival)
const char *str;
- LONG *ival;
+ long *ival;
{
- register U_LONG u;
+ register long u;
register const char *cp;
register int isneg;
register int oflow_digit;
@@ -41,8 +41,8 @@ atoint(str, ival)
}
if (isneg)
- *ival = -((LONG)u);
+ *ival = -u;
else
- *ival = (LONG)u;
+ *ival = u;
return 1;
}
diff --git a/usr.sbin/xntpd/lib/atolfp.c b/usr.sbin/xntpd/lib/atolfp.c
index 9e2d88301471..649303e3caa6 100644
--- a/usr.sbin/xntpd/lib/atolfp.c
+++ b/usr.sbin/xntpd/lib/atolfp.c
@@ -1,4 +1,4 @@
-/* atolfp.c,v 3.1 1993/07/06 01:07:40 jbj Exp
+/*
* atolfp - convert an ascii string to an l_fp number
*/
#include <stdio.h>
@@ -10,7 +10,7 @@
/*
* Powers of 10
*/
-static U_LONG ten_to_the_n[10] = {
+static u_long ten_to_the_n[10] = {
0,
10,
100,
@@ -30,8 +30,8 @@ atolfp(str, lfp)
l_fp *lfp;
{
register const char *cp;
- register U_LONG dec_i;
- register U_LONG dec_f;
+ register u_long dec_i;
+ register u_long dec_f;
char *ind;
int ndec;
int isneg;
@@ -87,9 +87,9 @@ atolfp(str, lfp)
}
if (ndec > 0) {
- register U_LONG tmp;
- register U_LONG bit;
- register U_LONG ten_fact;
+ register u_long tmp;
+ register u_long bit;
+ register u_long ten_fact;
ten_fact = ten_to_the_n[ndec];
diff --git a/usr.sbin/xntpd/lib/atouint.c b/usr.sbin/xntpd/lib/atouint.c
index b27653f60a21..d826bb4f4d9a 100644
--- a/usr.sbin/xntpd/lib/atouint.c
+++ b/usr.sbin/xntpd/lib/atouint.c
@@ -1,4 +1,4 @@
-/* atouint.c,v 3.1 1993/07/06 01:07:42 jbj Exp
+/*
* atouint - convert an ascii string to an unsigned long, with error checking
*/
#include <sys/types.h>
@@ -9,9 +9,9 @@
int
atouint(str, uval)
const char *str;
- U_LONG *uval;
+ u_long *uval;
{
- register U_LONG u;
+ register u_long u;
register const char *cp;
cp = str;
diff --git a/usr.sbin/xntpd/lib/auth12crypt.c b/usr.sbin/xntpd/lib/auth12crypt.c
index a5d988972757..0e69dbea2b07 100644
--- a/usr.sbin/xntpd/lib/auth12crypt.c
+++ b/usr.sbin/xntpd/lib/auth12crypt.c
@@ -1,4 +1,4 @@
-/* auth12crypt.c,v 3.1 1993/07/06 01:07:43 jbj Exp
+/*
* auth12crypt.c - routines to support two stage NTP encryption
*/
#include "ntp_stdlib.h"
@@ -21,7 +21,7 @@
/*
* Imported from the key data base module
*/
-extern U_LONG cache_keyid; /* cached key ID */
+extern u_long cache_keyid; /* cached key ID */
extern u_char DEScache_ekeys[]; /* cached decryption keys */
extern u_char DESzeroekeys[]; /* zero key decryption keys */
@@ -38,7 +38,7 @@ extern U_LONG authnokey;
*/
void
DESauth1crypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
U_LONG *pkt;
int length; /* length of all encrypted data */
{
@@ -91,7 +91,7 @@ DESauth1crypt(keyno, pkt, length)
*/
int
DESauth2crypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
U_LONG *pkt;
int length; /* total length of encrypted area */
{
diff --git a/usr.sbin/xntpd/lib/authdecrypt.c b/usr.sbin/xntpd/lib/authdecrypt.c
index 7ff1129a479e..7462941bf662 100644
--- a/usr.sbin/xntpd/lib/authdecrypt.c
+++ b/usr.sbin/xntpd/lib/authdecrypt.c
@@ -1,4 +1,4 @@
-/* authdecrypt.c,v 3.1 1993/07/06 01:07:44 jbj Exp
+/*
* authdecrypt - routine to decrypt a packet to see if this guy knows our key.
*/
#include "ntp_stdlib.h"
@@ -19,7 +19,7 @@
/*
* Imported from the key data base module
*/
-extern U_LONG cache_keyid; /* cached key ID */
+extern u_long cache_keyid; /* cached key ID */
extern u_char DEScache_dkeys[]; /* cached decryption keys */
extern u_char DESzerodkeys[]; /* zero key decryption keys */
@@ -28,11 +28,10 @@ extern u_char DESzerodkeys[]; /* zero key decryption keys */
*/
extern U_LONG authdecryptions;
extern U_LONG authkeyuncached;
-extern U_LONG authdecryptok;
int
DESauthdecrypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
const U_LONG *pkt;
int length; /* length of variable data in octets */
{
@@ -77,9 +76,7 @@ DESauthdecrypt(keyno, pkt, length)
/*
* Success if the encryption data is zero
*/
- if ((work[0] == 0) && (work[1] == 0)) {
- authdecryptok++;
+ if ((work[0] == 0) && (work[1] == 0))
return 1;
- }
return 0;
}
diff --git a/usr.sbin/xntpd/lib/authdes.c b/usr.sbin/xntpd/lib/authdes.c
index 9f64c403c84c..dd122decf6b6 100644
--- a/usr.sbin/xntpd/lib/authdes.c
+++ b/usr.sbin/xntpd/lib/authdes.c
@@ -1,4 +1,4 @@
-/* authdes.c,v 3.1 1993/07/06 01:07:45 jbj Exp
+/*
* authdes.c - an implementation of the DES cipher algorithm for NTP
*/
#include "ntp_stdlib.h"
diff --git a/usr.sbin/xntpd/lib/authdes.c.export b/usr.sbin/xntpd/lib/authdes.c.export
index a63c6d3839c5..cb311f922034 100644
--- a/usr.sbin/xntpd/lib/authdes.c.export
+++ b/usr.sbin/xntpd/lib/authdes.c.export
@@ -1,4 +1,4 @@
-/* authdes.c.export,v 3.1 1993/07/06 01:07:48 jbj Exp
+/*
* authdes.c - dummy encryption routines for destinations outside the USA.
*
* Sorry, folks; I hate this, too. Send me your e-mail address in an
diff --git a/usr.sbin/xntpd/lib/authencrypt.c b/usr.sbin/xntpd/lib/authencrypt.c
index 66b5281b7ae5..eb203e426f64 100644
--- a/usr.sbin/xntpd/lib/authencrypt.c
+++ b/usr.sbin/xntpd/lib/authencrypt.c
@@ -1,4 +1,4 @@
-/* authencrypt.c,v 3.1 1993/07/06 01:07:50 jbj Exp
+/*
* authencrypt - compute and encrypt the mac field in an NTP packet
*/
#include "ntp_stdlib.h"
@@ -19,7 +19,7 @@
/*
* Imported from the key data base module
*/
-extern U_LONG cache_keyid; /* cached key ID */
+extern u_long cache_keyid; /* cached key ID */
extern u_char DEScache_ekeys[]; /* cached decryption keys */
extern u_char DESzeroekeys[]; /* zero key decryption keys */
@@ -32,7 +32,7 @@ extern U_LONG authnokey;
int
DESauthencrypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
U_LONG *pkt;
int length; /* length of encrypted portion of packet */
{
diff --git a/usr.sbin/xntpd/lib/authkeys.c b/usr.sbin/xntpd/lib/authkeys.c
index 743af83ba6e1..8e590ceb0945 100644
--- a/usr.sbin/xntpd/lib/authkeys.c
+++ b/usr.sbin/xntpd/lib/authkeys.c
@@ -1,4 +1,4 @@
-/* authkeys.c,v 3.1 1993/07/06 01:07:51 jbj Exp
+/*
* authkeys.c - routines to manage the storage of authentication keys
*/
#include <stdio.h>
@@ -21,7 +21,7 @@ struct savekey {
char MD5_key[32];
#endif
} k;
- U_LONG keyid;
+ u_long keyid;
u_short flags;
#ifdef MD5
int keylen;
@@ -57,7 +57,6 @@ U_LONG authkeyuncached;
U_LONG authnokey; /* calls to encrypt with no key */
U_LONG authencryptions;
U_LONG authdecryptions;
-U_LONG authdecryptok;
/*
* Storage for free key structures. We malloc() such things but
@@ -90,7 +89,7 @@ u_char DEScache_dkeys[KEY_SCHED_SIZE];
/*
* The key cache. We cache the last key we looked at here.
*/
-U_LONG cache_keyid;
+u_long cache_keyid;
u_short cache_flags;
#ifdef MD5
@@ -114,7 +113,7 @@ init_auth()
authnumfreekeys = authkeynotfound = authkeylookups = 0;
authnumkeys = authuncached = authkeyuncached = authnokey = 0;
- authencryptions = authdecryptions = authdecryptok = 0;
+ authencryptions = authdecryptions = 0;
#ifdef DES
/*
@@ -133,7 +132,7 @@ init_auth()
*/
struct savekey *
auth_findkey(keyno)
- U_LONG keyno;
+ u_long keyno;
{
register struct savekey *sk;
@@ -152,7 +151,7 @@ auth_findkey(keyno)
*/
int
auth_havekey(keyno)
- U_LONG keyno;
+ u_long keyno;
{
register struct savekey *sk;
@@ -182,7 +181,7 @@ auth_havekey(keyno)
*/
int
authhavekey(keyno)
- U_LONG keyno;
+ u_long keyno;
{
register struct savekey *sk;
@@ -249,7 +248,7 @@ auth_moremem()
*/
void
authtrust(keyno, trust)
- U_LONG keyno;
+ u_long keyno;
int trust;
{
register struct savekey *sk;
@@ -316,7 +315,7 @@ authtrust(keyno, trust)
*/
int
authistrusted(keyno)
- U_LONG keyno;
+ u_long keyno;
{
register struct savekey *sk;
@@ -345,7 +344,7 @@ authistrusted(keyno)
*/
void
DESauth_setkey(keyno, key)
- U_LONG keyno;
+ u_long keyno;
const U_LONG *key;
{
register struct savekey *sk;
@@ -393,7 +392,7 @@ DESauth_setkey(keyno, key)
#ifdef MD5
void
MD5auth_setkey(keyno, key)
- U_LONG keyno;
+ u_long keyno;
const U_LONG *key;
{
register struct savekey *sk;
@@ -487,7 +486,7 @@ auth_delkeys()
*/
void
auth1crypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
U_LONG *pkt;
int length; /* length of all encrypted data */
{
@@ -520,7 +519,7 @@ auth1crypt(keyno, pkt, length)
*/
int
auth2crypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
U_LONG *pkt;
int length; /* total length of encrypted area */
{
@@ -547,7 +546,7 @@ auth2crypt(keyno, pkt, length)
int
authencrypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
U_LONG *pkt;
int length; /* length of encrypted portion of packet */
{
@@ -576,7 +575,7 @@ authencrypt(keyno, pkt, length)
int
authdecrypt(keyno, pkt, length)
- U_LONG keyno;
+ u_long keyno;
U_LONG *pkt;
int length; /* length of variable data in octets */
{
diff --git a/usr.sbin/xntpd/lib/authparity.c b/usr.sbin/xntpd/lib/authparity.c
index 33562cb4b12a..a5b59e3eddb7 100644
--- a/usr.sbin/xntpd/lib/authparity.c
+++ b/usr.sbin/xntpd/lib/authparity.c
@@ -1,4 +1,4 @@
-/* authparity.c,v 3.1 1993/07/06 01:07:55 jbj Exp
+/*
* auth_parity - set parity on a key/check for odd parity
*/
#include "ntp_stdlib.h"
diff --git a/usr.sbin/xntpd/lib/authreadkeys.c b/usr.sbin/xntpd/lib/authreadkeys.c
index 5800186dc812..8d2697fa2bab 100644
--- a/usr.sbin/xntpd/lib/authreadkeys.c
+++ b/usr.sbin/xntpd/lib/authreadkeys.c
@@ -1,4 +1,4 @@
-/* authreadkeys.c,v 3.1 1993/07/06 01:07:57 jbj Exp
+/*
* authreadkeys.c - routines to support the reading of the key file
*/
#include <stdio.h>
@@ -80,7 +80,7 @@ authreadkeys(file)
FILE *fp;
char *line;
char *token;
- U_LONG keyno;
+ u_long keyno;
int keytype;
char buf[512]; /* lots of room for line? */
extern FILE * fopen P((const char *filename, const char *type));
@@ -111,7 +111,7 @@ extern int fclose P((FILE *stream));
/*
* First is key number. See if it is okay.
*/
- keyno = (U_LONG)atoi(token);
+ keyno = atoi(token);
if (keyno == 0) {
syslog(LOG_ERR,
"cannot change keyid 0, key entry `%s' ignored",
@@ -125,7 +125,7 @@ extern int fclose P((FILE *stream));
token = nexttok(&line);
if (token == 0) {
syslog(LOG_ERR,
- "no key type for key number %d, entry ignored",
+ "no key type for key number %ld, entry ignored",
keyno);
continue;
}
@@ -150,7 +150,7 @@ extern int fclose P((FILE *stream));
#endif
default:
syslog(LOG_ERR,
- "invalid key type for key number %d, entry ignored",
+ "invalid key type for key number %ld, entry ignored",
keyno);
continue;
}
@@ -161,7 +161,7 @@ extern int fclose P((FILE *stream));
token = nexttok(&line);
if (token == 0) {
syslog(LOG_ERR,
- "no key for number %d entry, entry ignored",
+ "no key for number %ld entry, entry ignored",
keyno);
} else {
switch(keytype) {
@@ -171,7 +171,7 @@ extern int fclose P((FILE *stream));
case KEY_TYPE_ASCII:
if (!authusekey(keyno, keytype, token))
syslog(LOG_ERR,
- "format/parity error for DES key %d, not used",
+ "format/parity error for DES key %ld, not used",
keyno);
break;
#endif
@@ -179,7 +179,7 @@ extern int fclose P((FILE *stream));
case KEY_TYPE_MD5:
if (!authusekey(keyno, keytype, token))
syslog(LOG_ERR,
- "format/parity error for MD5 key %d, not used",
+ "format/parity error for MD5 key %ld, not used",
keyno);
break;
#endif
diff --git a/usr.sbin/xntpd/lib/authusekey.c b/usr.sbin/xntpd/lib/authusekey.c
index c268c4d2455c..20d7f3c3f447 100644
--- a/usr.sbin/xntpd/lib/authusekey.c
+++ b/usr.sbin/xntpd/lib/authusekey.c
@@ -1,4 +1,4 @@
-/* authusekey.c,v 3.1 1993/07/06 01:07:58 jbj Exp
+/*
* authusekey - decode a key from ascii and use it
*/
#include <stdio.h>
@@ -30,7 +30,7 @@
int
authusekey(keyno, keytype, str)
- U_LONG keyno;
+ u_long keyno;
int keytype;
const char *str;
{
diff --git a/usr.sbin/xntpd/lib/buftvtots.c b/usr.sbin/xntpd/lib/buftvtots.c
index d9b484db2df0..7e1ec63a12f1 100644
--- a/usr.sbin/xntpd/lib/buftvtots.c
+++ b/usr.sbin/xntpd/lib/buftvtots.c
@@ -1,4 +1,4 @@
-/* buftvtots.c,v 3.1 1993/07/06 01:07:59 jbj Exp
+/*
* buftvtots - pull a Unix-format (struct timeval) time stamp out of
* an octet stream and convert it to a l_fp time stamp.
* This is useful when using the clock line discipline.
@@ -12,50 +12,50 @@ buftvtots(bufp, ts)
l_fp *ts;
{
register const u_char *bp;
- register U_LONG sec;
- register U_LONG usec;
+ register u_long sec;
+ register u_long usec;
#ifdef XNTP_BIG_ENDIAN
bp = (u_char *)bufp;
- sec = (U_LONG)*bp++ & 0xff;
+ sec = (u_long)*bp++ & 0xff;
sec <<= 8;
- sec += (U_LONG)*bp++ & 0xff;
+ sec += (u_long)*bp++ & 0xff;
sec <<= 8;
- sec += (U_LONG)*bp++ & 0xff;
+ sec += (u_long)*bp++ & 0xff;
sec <<= 8;
- sec += (U_LONG)*bp++ & 0xff;
+ sec += (u_long)*bp++ & 0xff;
- usec = (U_LONG)*bp++ & 0xff;
+ usec = (u_long)*bp++ & 0xff;
usec <<= 8;
- usec += (U_LONG)*bp++ & 0xff;
+ usec += (u_long)*bp++ & 0xff;
usec <<= 8;
- usec += (U_LONG)*bp++ & 0xff;
+ usec += (u_long)*bp++ & 0xff;
usec <<= 8;
- usec += (U_LONG)*bp & 0xff;
+ usec += (u_long)*bp & 0xff;
#else
bp = (u_char *)bufp + 7;
- usec = (U_LONG)*bp-- & 0xff;
+ usec = (u_long)*bp-- & 0xff;
usec <<= 8;
- usec += (U_LONG)*bp-- & 0xff;
+ usec += (u_long)*bp-- & 0xff;
usec <<= 8;
- usec += (U_LONG)*bp-- & 0xff;
+ usec += (u_long)*bp-- & 0xff;
usec <<= 8;
- usec += (U_LONG)*bp-- & 0xff;
+ usec += (u_long)*bp-- & 0xff;
- sec = (U_LONG)*bp-- & 0xff;
+ sec = (u_long)*bp-- & 0xff;
sec <<= 8;
- sec += (U_LONG)*bp-- & 0xff;
+ sec += (u_long)*bp-- & 0xff;
sec <<= 8;
- sec += (U_LONG)*bp-- & 0xff;
+ sec += (u_long)*bp-- & 0xff;
sec <<= 8;
- sec += (U_LONG)*bp & 0xff;
+ sec += (u_long)*bp & 0xff;
#endif
if (usec > 999999)
return 0;
- ts->l_ui = sec + (U_LONG)JAN_1970;
+ ts->l_ui = sec + (u_long)JAN_1970;
TVUTOTSF(usec, ts->l_uf);
return 1;
}
diff --git a/usr.sbin/xntpd/lib/caljulian.c b/usr.sbin/xntpd/lib/caljulian.c
index 92d6d742a63a..070fa0d6f34e 100644
--- a/usr.sbin/xntpd/lib/caljulian.c
+++ b/usr.sbin/xntpd/lib/caljulian.c
@@ -1,4 +1,4 @@
-/* caljulian.c,v 3.1 1993/07/06 01:08:00 jbj Exp
+/*
* caljulian - determine the Julian date from an NTP time.
*/
#include <sys/types.h>
@@ -37,11 +37,11 @@ static u_short caldaytab[YEARSPERCYCLE] = {
void
caljulian(ntptime, jt)
- U_LONG ntptime;
+ u_long ntptime;
register struct calendar *jt;
{
register int i;
- register U_LONG nt;
+ register u_long nt;
register u_short snt;
register int cyear;
diff --git a/usr.sbin/xntpd/lib/calleapwhen.c b/usr.sbin/xntpd/lib/calleapwhen.c
index 379643f09566..83613efc15ff 100644
--- a/usr.sbin/xntpd/lib/calleapwhen.c
+++ b/usr.sbin/xntpd/lib/calleapwhen.c
@@ -1,4 +1,4 @@
-/* calleapwhen.c,v 3.1 1993/07/06 01:08:02 jbj Exp
+/*
* calleapwhen - determine the number of seconds to the next possible
* leap occurance and the last one.
*/
@@ -11,7 +11,7 @@
/*
* calleaptab - leaps occur at the end of December and June
*/
-LONG calleaptab[10] = {
+long calleaptab[10] = {
-(JAN+FEBLEAP)*SECSPERDAY, /* leap previous to cycle */
(MAR+APR+MAY+JUN)*SECSPERDAY, /* end of June */
(MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV+DEC)*SECSPERDAY, /* end of Dec */
@@ -27,11 +27,11 @@ LONG calleaptab[10] = {
void
calleapwhen(ntpdate, leaplast, leapnext)
- U_LONG ntpdate;
- U_LONG *leaplast;
- U_LONG *leapnext;
+ u_long ntpdate;
+ u_long *leaplast;
+ u_long *leapnext;
{
- register U_LONG dateincycle;
+ register u_long dateincycle;
register int i;
/*
@@ -50,12 +50,12 @@ calleapwhen(ntpdate, leaplast, leapnext)
* Find where we are with respect to the leap events.
*/
for (i = 1; i < 9; i++)
- if (dateincycle < (U_LONG)calleaptab[i])
+ if (dateincycle < (u_long)calleaptab[i])
break;
/*
* i points at the next leap. Compute the last and the next.
*/
- *leaplast = (U_LONG)((LONG)dateincycle - calleaptab[i-1]);
- *leapnext = (U_LONG)(calleaptab[i] - (LONG)dateincycle);
+ *leaplast = (u_long)((long)dateincycle - calleaptab[i-1]);
+ *leapnext = (u_long)(calleaptab[i] - (long)dateincycle);
}
diff --git a/usr.sbin/xntpd/lib/caltontp.c b/usr.sbin/xntpd/lib/caltontp.c
index f5da0ab761e8..a0c8f610c7de 100644
--- a/usr.sbin/xntpd/lib/caltontp.c
+++ b/usr.sbin/xntpd/lib/caltontp.c
@@ -1,4 +1,4 @@
-/* caltontp.c,v 3.1 1993/07/06 01:08:04 jbj Exp
+/*
* caltontp - convert a julian date to an NTP time
*/
#include <sys/types.h>
@@ -25,13 +25,13 @@ static u_short calmonthtab[12] = {
(MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV+DEC+JAN), /* February */
};
-U_LONG
+u_long
caltontp(jt)
register const struct calendar *jt;
{
register int cyear;
register int resyear;
- register U_LONG nt;
+ register u_long nt;
register int yearday;
/*
@@ -77,14 +77,14 @@ caltontp(jt)
}
}
- nt = TIMESDPERC((U_LONG)cyear);
+ nt = TIMESDPERC((u_long)cyear);
while (resyear-- > 0)
nt += DAYSPERYEAR;
- nt += (U_LONG) (yearday - 1);
+ nt += (u_long) (yearday - 1);
- nt = TIMES24(nt) + (U_LONG)jt->hour;
- nt = TIMES60(nt) + (U_LONG)jt->minute;
- nt = TIMES60(nt) + (U_LONG)jt->second;
+ nt = TIMES24(nt) + (u_long)jt->hour;
+ nt = TIMES60(nt) + (u_long)jt->minute;
+ nt = TIMES60(nt) + (u_long)jt->second;
return nt + MAR1900;
}
diff --git a/usr.sbin/xntpd/lib/calyearstart.c b/usr.sbin/xntpd/lib/calyearstart.c
index 1bb3321f7252..015ed933b7fa 100644
--- a/usr.sbin/xntpd/lib/calyearstart.c
+++ b/usr.sbin/xntpd/lib/calyearstart.c
@@ -1,4 +1,4 @@
-/* calyearstart.c,v 3.1 1993/07/06 01:08:06 jbj Exp
+/*
* calyearstart - determine the NTP time at midnight of January 1 in
* the year of the given date.
*/
@@ -11,19 +11,19 @@
/*
* calyeartab - year start offsets from the beginning of a cycle
*/
-U_LONG calyeartab[YEARSPERCYCLE] = {
+u_long calyeartab[YEARSPERCYCLE] = {
(SECSPERLEAPYEAR-JANFEBLEAP),
(SECSPERLEAPYEAR-JANFEBLEAP) + SECSPERYEAR,
(SECSPERLEAPYEAR-JANFEBLEAP) + 2*SECSPERYEAR,
(SECSPERLEAPYEAR-JANFEBLEAP) + 3*SECSPERYEAR
};
-U_LONG
+u_long
calyearstart(dateinyear)
- register U_LONG dateinyear;
+ register u_long dateinyear;
{
- register U_LONG cyclestart;
- register U_LONG nextyear, lastyear;
+ register u_long cyclestart;
+ register u_long nextyear, lastyear;
register int i;
/*
diff --git a/usr.sbin/xntpd/lib/clocktime.c b/usr.sbin/xntpd/lib/clocktime.c
index 36b967e9a16c..0217f2b5c4a6 100644
--- a/usr.sbin/xntpd/lib/clocktime.c
+++ b/usr.sbin/xntpd/lib/clocktime.c
@@ -1,4 +1,4 @@
-/* clocktime.c,v 3.1 1993/07/06 01:08:07 jbj Exp
+/*
* clocktime - compute the NTP date from a day of year, hour, minute
* and second.
*/
@@ -34,21 +34,21 @@ clocktime(yday, hour, minute, second, tzoff, rec_ui, yearstart, ts_ui)
int minute;
int second;
int tzoff;
- U_LONG rec_ui;
- U_LONG *yearstart;
+ u_long rec_ui;
+ u_long *yearstart;
U_LONG *ts_ui;
{
- register LONG tmp;
- register U_LONG date;
- register U_LONG yst;
+ register long tmp;
+ register u_long date;
+ register u_long yst;
/*
* Compute the offset into the year in seconds. Note that
* this could come out to be a negative number.
*/
- tmp = (LONG)(MULBY24((yday-1)) + hour + tzoff);
- tmp = MULBY60(tmp) + (LONG)minute;
- tmp = MULBY60(tmp) + (LONG)second;
+ tmp = (long)(MULBY24((yday-1)) + hour + tzoff);
+ tmp = MULBY60(tmp) + (long)minute;
+ tmp = MULBY60(tmp) + (long)second;
/*
* Initialize yearstart, if necessary.
@@ -66,7 +66,7 @@ clocktime(yday, hour, minute, second, tzoff, rec_ui, yearstart, ts_ui)
* Use the current year start for the first check, this should
* work most of the time.
*/
- date = (U_LONG)(tmp + (LONG)yst);
+ date = (u_long)(tmp + (long)yst);
if (date < (rec_ui + CLOSETIME) &&
date > (rec_ui - CLOSETIME)) {
*ts_ui = date;
@@ -79,7 +79,7 @@ clocktime(yday, hour, minute, second, tzoff, rec_ui, yearstart, ts_ui)
*/
yst = calyearstart(rec_ui);
if (yst != *yearstart) {
- date = (U_LONG)((LONG)yst + tmp);
+ date = (u_long)((long)yst + tmp);
*ts_ui = date;
if (date < (rec_ui + CLOSETIME) &&
date > (rec_ui - CLOSETIME)) {
@@ -98,7 +98,7 @@ clocktime(yday, hour, minute, second, tzoff, rec_ui, yearstart, ts_ui)
if ((rec_ui - yst) < TWODAYS) {
yst = calyearstart(yst - TWODAYS);
if (yst != *yearstart) {
- date = (U_LONG)(tmp + (LONG)yst);
+ date = (u_long)(tmp + (long)yst);
if (date < (rec_ui + CLOSETIME) &&
date > (rec_ui - CLOSETIME)) {
*yearstart = yst;
@@ -115,7 +115,7 @@ clocktime(yday, hour, minute, second, tzoff, rec_ui, yearstart, ts_ui)
*/
yst = calyearstart(rec_ui + TWODAYS);
if (yst != *yearstart) {
- date = (U_LONG)((LONG)yst + tmp);
+ date = (u_long)((long)yst + tmp);
if (date < (rec_ui + CLOSETIME) &&
date > (rec_ui - CLOSETIME)) {
*yearstart = yst;
diff --git a/usr.sbin/xntpd/lib/clocktypes.c b/usr.sbin/xntpd/lib/clocktypes.c
index 816ef0708b3e..38b8cd28a6b2 100644
--- a/usr.sbin/xntpd/lib/clocktypes.c
+++ b/usr.sbin/xntpd/lib/clocktypes.c
@@ -1,4 +1,4 @@
-/* clocktypes.c,v 3.1 1993/07/06 01:08:09 jbj Exp
+/*
* Data for pretty printing clock types
*/
#include <stdio.h>
@@ -9,38 +9,64 @@
#include "ntp_refclock.h"
struct clktype clktypes[] = {
- { REFCLK_NONE, "unspecified type (0)", "UNKNOWN" },
- { REFCLK_LOCALCLOCK, "local clock synchronization (1)", "LOCAL" },
- { REFCLK_GPS_TRAK, "TRAK 8810 GPS Receiver (2)", "GPS_TRAK" },
- { REFCLK_WWV_PST, "Precision Standard Time WWV clock (3)", "WWV_PST" },
- { REFCLK_WWVB_SPECTRACOM, "Spectracom WWVB clock (4)", "WWVB_SPEC" },
- { REFCLK_GOES_TRUETIME, "True Time GPS/GOES clock (5)", "GPS_GOES_TRUE" },
- { REFCLK_IRIG_AUDIO, "IRIG audio decoder (6)", "IRIG_AUDIO" },
- { REFCLK_CHU, "Direct synced to CHU (7)", "CHU" },
- { REFCLK_PARSE, "Generic reference clock driver (8)", "GENERIC" },
- { REFCLK_GPS_MX4200, "Magnavox MX4200 GPS clock (9)", "GPS_MX4200" },
- { REFCLK_GPS_AS2201, "Austron 2201A GPS clock (10)", "GPS_AS2201" },
- { REFCLK_OMEGA_TRUETIME, "TrueTime OMEGA clock (11)", "OMEGA_TRUE" },
- { REFCLK_IRIG_TPRO, "Odetics/KSI TPRO IRIG decoder (12)", "IRIG_TPRO" },
- { REFCLK_ATOM_LEITCH, "Leitch CSD 5300 controller (13)", "ATOM_LEITCH" },
- { REFCLK_MSF_EES, "MSF EES M201, UK (14)", "MSF_EES" },
- { REFCLK_GPSTM_TRUETIME, "TrueTime GPS/TM-TMD clock (15)", "GPS_TRUE" },
+ { REFCLK_NONE, "unspecified type (0)",
+ "UNKNOWN" },
+ { REFCLK_LOCALCLOCK, "Undisciplined local clock (1)",
+ "LOCAL" },
+ { REFCLK_GPS_TRAK, "TRAK 8810 GPS Receiver (2)",
+ "GPS_TRAK" },
+ { REFCLK_WWV_PST, "PSTI/Traconex WWV/WWVH Receiver (3)",
+ "WWV_PST" },
+ { REFCLK_WWVB_SPECTRACOM, "Spectracom WWVB Receiver (4)",
+ "WWVB_SPEC" },
+ { REFCLK_GOES_TRUETIME, "TrueTime GPS/GOES Receivers (5)",
+ "GPS_GOES_TRUE" },
+ { REFCLK_IRIG_AUDIO, "IRIG Audio Decoder (6)",
+ "IRIG_AUDIO" },
+ { REFCLK_CHU, "Scratchbuilt CHU Receiver (7)",
+ "CHU" },
+ { REFCLK_PARSE, "Generic reference clock driver (8)",
+ "GENERIC" },
+ { REFCLK_GPS_MX4200, "Magnavox MX4200 GPS Receiver (9)",
+ "GPS_MX4200" },
+ { REFCLK_GPS_AS2201, "Austron 2201A GPS Receiver (10)",
+ "GPS_AS2201" },
+ { REFCLK_OMEGA_TRUETIME, "TrueTime OM-DC OMEGA Receiver (11)",
+ "OMEGA_TRUE" },
+ { REFCLK_IRIG_TPRO, "KSI/Odetics TPRO/S IRIG Interface (12)",
+ "IRIG_TPRO" },
+ { REFCLK_ATOM_LEITCH, "Leitch CSD 5300 Master Clock Controller (13)",
+ "ATOM_LEITCH" },
+ { REFCLK_MSF_EES, "EES M201 MSF Receiver (14)",
+ "MSF_EES" },
+ { REFCLK_GPSTM_TRUETIME, "TrueTime GPS/TM-TMD Receiver (15)",
+ "GPS_TRUE" },
+ { REFCLK_IRIG_BANCOMM, "Bancomm GPS/IRIG Receiver (16)",
+ "GPS_BANC" },
+ { REFCLK_GPS_DATUM, "Datum Precision Time System (17)",
+ "GPS_DATUM" },
+ { REFCLK_NIST_ACTS, "NIST Automated Computer Time Service (18)",
+ "NIST_ACTS" },
+ { REFCLK_WWV_HEATH, "Heath WWV/WWVH Receiver (19)",
+ "WWV_HEATH" },
+ { REFCLK_GPS_NMEA, "Generic NMEA GPS Receiver (20)",
+ "GPS_NMEA" },
+ { REFCLK_GPS_MOTO, "Motorola Six Gun GPS Receiver (21)",
+ "GPS_MOTO" },
+ { REFCLK_ATOM_PPS, "PPS Clock Discipline (22)",
+ "ATOM_PPS" },
{ -1, "", "" }
};
const char *
clockname(num)
- int num;
+ int num;
{
- register struct clktype *clk;
+ register struct clktype *clk;
- for (clk = clktypes; clk->code != -1; clk++)
- {
- if (num == clk->code)
- {
- return clk->abbrev;
+ for (clk = clktypes; clk->code != -1; clk++) {
+ if (num == clk->code)
+ return (clk->abbrev);
}
- }
-
- return NULL;
+ return (NULL);
}
diff --git a/usr.sbin/xntpd/lib/decodenetnum.c b/usr.sbin/xntpd/lib/decodenetnum.c
index 32320a24b881..65e77619c33d 100644
--- a/usr.sbin/xntpd/lib/decodenetnum.c
+++ b/usr.sbin/xntpd/lib/decodenetnum.c
@@ -1,4 +1,4 @@
-/* decodenetnum.c,v 3.1 1993/07/06 01:08:11 jbj Exp
+/*
* decodenetnum - return a net number (this is crude, but careful)
*/
#include <sys/types.h>
@@ -11,7 +11,7 @@
int
decodenetnum(num, netnum)
const char *num;
- U_LONG *netnum;
+ u_long *netnum;
{
register const char *cp;
register char *bp;
diff --git a/usr.sbin/xntpd/lib/dofptoa.c b/usr.sbin/xntpd/lib/dofptoa.c
index a496df85dd5b..31673fbbbc59 100644
--- a/usr.sbin/xntpd/lib/dofptoa.c
+++ b/usr.sbin/xntpd/lib/dofptoa.c
@@ -1,4 +1,4 @@
-/* dofptoa.c,v 3.1 1993/07/06 01:08:12 jbj Exp
+/*
* dofptoa - do the grunge work to convert an fp number to ascii
*/
#include <stdio.h>
@@ -16,7 +16,7 @@ dofptoa(fpv, neg, ndec, msec)
int msec;
{
register u_char *cp, *cpend;
- register U_LONG val;
+ register u_long val;
register short dec;
u_char cbuf[12];
u_char *cpdec;
diff --git a/usr.sbin/xntpd/lib/dolfptoa.c b/usr.sbin/xntpd/lib/dolfptoa.c
index ff37c9f1e1e6..a79d8c669577 100644
--- a/usr.sbin/xntpd/lib/dolfptoa.c
+++ b/usr.sbin/xntpd/lib/dolfptoa.c
@@ -1,4 +1,4 @@
-/* dolfptoa.c,v 3.1 1993/07/06 01:08:14 jbj Exp
+/*
* dolfptoa - do the grunge work of converting an l_fp number to decimal
*/
#include <stdio.h>
@@ -10,14 +10,14 @@
char *
dolfptoa(fpi, fpv, neg, ndec, msec)
- U_LONG fpi;
- U_LONG fpv;
+ u_long fpi;
+ u_long fpv;
int neg;
int ndec;
int msec;
{
register u_char *cp, *cpend;
- register U_LONG work_i;
+ register u_long lwork;
register int dec;
u_char cbuf[24];
u_char *cpdec;
@@ -39,22 +39,22 @@ dolfptoa(fpi, fpv, neg, ndec, msec)
* compiles fairly well for a 68000.
*/
cp = cpend = &cbuf[10];
- work_i = fpi;
- if (work_i & 0xffff0000) {
- register U_LONG lten = 10;
- register U_LONG ltmp;
+ lwork = fpi;
+ if (lwork & 0xffff0000) {
+ register u_long lten = 10;
+ register u_long ltmp;
do {
- ltmp = work_i;
- work_i /= lten;
- ltmp -= (work_i<<3) + (work_i<<1);
+ ltmp = lwork;
+ lwork /= lten;
+ ltmp -= (lwork << 3) + (lwork << 1);
*--cp = (u_char)ltmp;
- } while (work_i & 0xffff0000);
+ } while (lwork & 0xffff0000);
}
- if (work_i != 0) {
+ if (lwork != 0) {
register u_short sten = 10;
register u_short stmp;
- register u_short swork = (u_short)work_i;
+ register u_short swork = (u_short)lwork;
do {
stmp = swork;
@@ -86,12 +86,12 @@ dolfptoa(fpi, fpv, neg, ndec, msec)
* If there's a fraction to deal with, do so.
*/
if (fpv != 0) {
- register U_LONG work_f;
+ l_fp work;
- work_f = fpv;
+ work.l_ui = 0;
+ work.l_uf = fpv;
while (dec > 0) {
- register U_LONG tmp_i;
- register U_LONG tmp_f;
+ l_fp ftmp;
dec--;
/*
@@ -100,22 +100,21 @@ dolfptoa(fpi, fpv, neg, ndec, msec)
* a junk of BCD into the units part.
* record that and iterate.
*/
- work_i = 0;
- M_LSHIFT(work_i, work_f);
- tmp_i = work_i;
- tmp_f = work_f;
- M_LSHIFT(work_i, work_f);
- M_LSHIFT(work_i, work_f);
- M_ADD(work_i, work_f, tmp_i, tmp_f);
- *cpend++ = (u_char)work_i;
- if (work_f == 0)
+ work.l_ui = 0;
+ L_LSHIFT(&work);
+ ftmp = work;
+ L_LSHIFT(&work);
+ L_LSHIFT(&work);
+ L_ADD(&work, &ftmp);
+ *cpend++ = (u_char)work.l_ui;
+ if (work.l_uf == 0)
break;
}
/*
* Rounding is rotten
*/
- if (work_f & 0x80000000) {
+ if (work.l_uf & 0x80000000) {
register u_char *tp = cpend;
*(--tp) += 1;
diff --git a/usr.sbin/xntpd/lib/emalloc.c b/usr.sbin/xntpd/lib/emalloc.c
index d2a8e789f012..61d4cb6a9786 100644
--- a/usr.sbin/xntpd/lib/emalloc.c
+++ b/usr.sbin/xntpd/lib/emalloc.c
@@ -1,4 +1,4 @@
-/* emalloc.c,v 3.1 1993/07/06 01:08:15 jbj Exp
+/*
* emalloc - return new memory obtained from the system. Belch if none.
*/
#include "ntp_types.h"
@@ -8,7 +8,7 @@
char *
emalloc(size)
- unsigned int size;
+ u_int size;
{
char *mem;
diff --git a/usr.sbin/xntpd/lib/fptoa.c b/usr.sbin/xntpd/lib/fptoa.c
index d245e9fa6917..b0d7a1484ebb 100644
--- a/usr.sbin/xntpd/lib/fptoa.c
+++ b/usr.sbin/xntpd/lib/fptoa.c
@@ -1,4 +1,4 @@
-/* fptoa.c,v 3.1 1993/07/06 01:08:16 jbj Exp
+/*
* fptoa - return an asciized representation of an s_fp number
*/
#include "ntp_fp.h"
diff --git a/usr.sbin/xntpd/lib/fptoms.c b/usr.sbin/xntpd/lib/fptoms.c
index fb850c5362c2..f8ae6ba64e33 100644
--- a/usr.sbin/xntpd/lib/fptoms.c
+++ b/usr.sbin/xntpd/lib/fptoms.c
@@ -1,4 +1,4 @@
-/* fptoms.c,v 3.1 1993/07/06 01:08:17 jbj Exp
+/*
* fptoms - return an asciized s_fp number in milliseconds
*/
#include "ntp_fp.h"
diff --git a/usr.sbin/xntpd/lib/getopt.c b/usr.sbin/xntpd/lib/getopt.c
index 5519235180fa..8505d808d430 100644
--- a/usr.sbin/xntpd/lib/getopt.c
+++ b/usr.sbin/xntpd/lib/getopt.c
@@ -1,4 +1,4 @@
-/* getopt.c,v 3.1 1993/07/06 01:08:18 jbj Exp
+/*
* getopt - get option letter from argv
*
* This is a version of the public domain getopt() implementation by
diff --git a/usr.sbin/xntpd/lib/gettstamp.c b/usr.sbin/xntpd/lib/gettstamp.c
index 19bcb0c638ff..53b124a80ee1 100644
--- a/usr.sbin/xntpd/lib/gettstamp.c
+++ b/usr.sbin/xntpd/lib/gettstamp.c
@@ -1,4 +1,4 @@
-/* gettstamp.c,v 3.1 1993/07/06 01:08:20 jbj Exp
+/*
* gettstamp - return the system time in timestamp format
*/
#include <stdio.h>
diff --git a/usr.sbin/xntpd/lib/hextoint.c b/usr.sbin/xntpd/lib/hextoint.c
index 90329c4136f4..23f8c08464f8 100644
--- a/usr.sbin/xntpd/lib/hextoint.c
+++ b/usr.sbin/xntpd/lib/hextoint.c
@@ -1,4 +1,4 @@
-/* hextoint.c,v 3.1 1993/07/06 01:08:21 jbj Exp
+/*
* hextoint - convert an ascii string in hex to an unsigned
* long, with error checking
*/
@@ -9,9 +9,9 @@
int
hextoint(str, ival)
const char *str;
- U_LONG *ival;
+ u_long *ival;
{
- register U_LONG u;
+ register u_long u;
register const char *cp;
cp = str;
diff --git a/usr.sbin/xntpd/lib/hextolfp.c b/usr.sbin/xntpd/lib/hextolfp.c
index 6473c7c3dbca..d9291cc994a4 100644
--- a/usr.sbin/xntpd/lib/hextolfp.c
+++ b/usr.sbin/xntpd/lib/hextolfp.c
@@ -1,4 +1,4 @@
-/* hextolfp.c,v 3.1 1993/07/06 01:08:22 jbj Exp
+/*
* hextolfp - convert an ascii hex string to an l_fp number
*/
#include <stdio.h>
@@ -15,8 +15,8 @@ hextolfp(str, lfp)
{
register const char *cp;
register const char *cpstart;
- register U_LONG dec_i;
- register U_LONG dec_f;
+ register u_long dec_i;
+ register u_long dec_f;
char *ind = NULL;
static char *digits = "0123456789abcdefABCDEF";
diff --git a/usr.sbin/xntpd/lib/humandate.c b/usr.sbin/xntpd/lib/humandate.c
index 464ed6ba4de4..8ea936fa1e46 100644
--- a/usr.sbin/xntpd/lib/humandate.c
+++ b/usr.sbin/xntpd/lib/humandate.c
@@ -1,4 +1,4 @@
-/* humandate.c,v 3.1 1993/07/06 01:08:24 jbj Exp
+/*
* humandate - convert an NTP (or the current) time to something readable
*/
#include <stdio.h>
@@ -22,16 +22,16 @@ static char *days[] = {
char *
humandate(ntptime)
- U_LONG ntptime;
+ u_long ntptime;
{
char *bp;
struct tm *tm;
- U_LONG sec;
+ time_t sec;
LIB_GETBUF(bp);
sec = ntptime - JAN_1970;
- tm = localtime((LONG *)&sec);
+ tm = localtime(&sec);
(void) sprintf(bp, "%s, %s %2d %4d %2d:%02d:%02d",
days[tm->tm_wday], months[tm->tm_mon], tm->tm_mday,
diff --git a/usr.sbin/xntpd/lib/inttoa.c b/usr.sbin/xntpd/lib/inttoa.c
index 25ce26cb8144..ff886f592a84 100644
--- a/usr.sbin/xntpd/lib/inttoa.c
+++ b/usr.sbin/xntpd/lib/inttoa.c
@@ -1,4 +1,4 @@
-/* inttoa.c,v 3.1 1993/07/06 01:08:25 jbj Exp
+/*
* inttoa - return an asciized signed integer
*/
#include <stdio.h>
@@ -8,12 +8,12 @@
char *
inttoa(ival)
- LONG ival;
+ long ival;
{
register char *buf;
LIB_GETBUF(buf);
- (void) sprintf(buf, "%ld", ival);
+ (void) sprintf(buf, "%ld", (long)ival);
return buf;
}
diff --git a/usr.sbin/xntpd/lib/lib_strbuf.c b/usr.sbin/xntpd/lib/lib_strbuf.c
index 15661ab980ad..47df66decd21 100644
--- a/usr.sbin/xntpd/lib/lib_strbuf.c
+++ b/usr.sbin/xntpd/lib/lib_strbuf.c
@@ -1,4 +1,4 @@
-/* lib_strbuf.c,v 3.1 1993/07/06 01:08:27 jbj Exp
+/*
* lib_strbuf - library string storage
*/
diff --git a/usr.sbin/xntpd/lib/lib_strbuf.h b/usr.sbin/xntpd/lib/lib_strbuf.h
index 20720fd5892b..699b9787323b 100644
--- a/usr.sbin/xntpd/lib/lib_strbuf.h
+++ b/usr.sbin/xntpd/lib/lib_strbuf.h
@@ -1,4 +1,4 @@
-/* lib_strbuf.h,v 3.1 1993/07/06 01:08:28 jbj Exp
+/*
* lib_strbuf.h - definitions for routines which use the common string buffers
*/
diff --git a/usr.sbin/xntpd/lib/machines.c b/usr.sbin/xntpd/lib/machines.c
index 5e0169441fec..1d1cbc92faa4 100644
--- a/usr.sbin/xntpd/lib/machines.c
+++ b/usr.sbin/xntpd/lib/machines.c
@@ -41,3 +41,21 @@ ntp_memset(a, x, c)
*a++ = x;
}
#endif /*POSIX*/
+
+#if defined(USE_CLOCK_SETTIME)
+
+#include <time.h>
+
+int
+settimeofday(tvp)
+ struct timeval *tvp;
+{
+ struct timespec ts;
+
+ /* Convert timeval to timespec */
+ ts.tv_sec = tvp->tv_sec;
+ ts.tv_nsec = 1000 * tvp->tv_usec;
+
+ return clock_settime(CLOCK_REALTIME, &ts);
+}
+#endif /* USE_CLOCK_SETTIME */
diff --git a/usr.sbin/xntpd/lib/md5.c b/usr.sbin/xntpd/lib/md5.c
index 77644cb32aa6..2c373cf0d128 100644
--- a/usr.sbin/xntpd/lib/md5.c
+++ b/usr.sbin/xntpd/lib/md5.c
@@ -1,4 +1,4 @@
-/* md5.c,v 3.1 1993/07/06 01:08:29 jbj Exp
+/*
***********************************************************************
** md5.c -- the source code for MD5 routines **
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
diff --git a/usr.sbin/xntpd/lib/mfptoa.c b/usr.sbin/xntpd/lib/mfptoa.c
index 4e513d24f8b0..7de3b6e13e1a 100644
--- a/usr.sbin/xntpd/lib/mfptoa.c
+++ b/usr.sbin/xntpd/lib/mfptoa.c
@@ -1,13 +1,13 @@
-/* mfptoa.c,v 3.1 1993/07/06 01:08:30 jbj Exp
- * mfptoa - Return an asciized representation of a signed LONG fp number
+/*
+ * mfptoa - Return an asciized representation of a signed long fp number
*/
#include "ntp_fp.h"
#include "ntp_stdlib.h"
char *
mfptoa(fpi, fpf, ndec)
- U_LONG fpi;
- U_LONG fpf;
+ u_long fpi;
+ u_long fpf;
int ndec;
{
int isneg;
diff --git a/usr.sbin/xntpd/lib/mfptoms.c b/usr.sbin/xntpd/lib/mfptoms.c
index f686d413edba..01a6f09c2e1b 100644
--- a/usr.sbin/xntpd/lib/mfptoms.c
+++ b/usr.sbin/xntpd/lib/mfptoms.c
@@ -1,13 +1,13 @@
-/* mfptoms.c,v 3.1 1993/07/06 01:08:31 jbj Exp
- * mfptoms - Return an asciized signed LONG fp number in milliseconds
+/*
+ * mfptoms - Return an asciized signed long fp number in milliseconds
*/
#include "ntp_fp.h"
#include "ntp_stdlib.h"
char *
mfptoms(fpi, fpf, ndec)
- U_LONG fpi;
- U_LONG fpf;
+ u_long fpi;
+ u_long fpf;
int ndec;
{
int isneg;
diff --git a/usr.sbin/xntpd/lib/modetoa.c b/usr.sbin/xntpd/lib/modetoa.c
index 483327186a11..e8292b3fb548 100644
--- a/usr.sbin/xntpd/lib/modetoa.c
+++ b/usr.sbin/xntpd/lib/modetoa.c
@@ -1,4 +1,4 @@
-/* modetoa.c,v 3.1 1993/07/06 01:08:33 jbj Exp
+/*
* modetoa - return an asciized mode
*/
#include <stdio.h>
diff --git a/usr.sbin/xntpd/lib/mstolfp.c b/usr.sbin/xntpd/lib/mstolfp.c
index 8a642cf0a55b..f9c21b7e3da4 100644
--- a/usr.sbin/xntpd/lib/mstolfp.c
+++ b/usr.sbin/xntpd/lib/mstolfp.c
@@ -1,4 +1,4 @@
-/* mstolfp.c,v 3.1 1993/07/06 01:08:34 jbj Exp
+/*
* mstolfp - convert an ascii string in milliseconds to an l_fp number
*/
#include <stdio.h>
diff --git a/usr.sbin/xntpd/lib/msutotsf.c b/usr.sbin/xntpd/lib/msutotsf.c
index 412cfbd1ed96..eb3babe9cd1a 100644
--- a/usr.sbin/xntpd/lib/msutotsf.c
+++ b/usr.sbin/xntpd/lib/msutotsf.c
@@ -1,4 +1,4 @@
-/* msutotsf.c,v 3.1 1993/07/06 01:08:35 jbj Exp
+/*
* msutotsf - tables for converting from a subsecond millisecond value
* to a time stamp fraction.
*/
@@ -12,7 +12,7 @@
* truncated). The error in the result will thus be +-1 low order
* bit in the time stamp fraction.
*/
-U_LONG msutotsflo[32] = {
+u_long msutotsflo[32] = {
0x00000000, 0x00418937, 0x0083126f, 0x00c49ba6,
0x010624dd, 0x0147ae14, 0x0189374c, 0x01cac083,
0x020c49ba, 0x024dd2f2, 0x028f5c29, 0x02d0e560,
@@ -23,7 +23,7 @@ U_LONG msutotsflo[32] = {
0x072b020c, 0x076c8b44, 0x07ae147b, 0x07ef9db2
};
-U_LONG msutotsfhi[32] = {
+u_long msutotsfhi[32] = {
0x00000000, 0x083126e9, 0x10624dd3, 0x189374bc,
0x20c49ba6, 0x28f5c28f, 0x3126e979, 0x39581062,
0x4189374c, 0x49ba5e35, 0x51eb851f, 0x5a1cac08,
diff --git a/usr.sbin/xntpd/lib/msyslog.c b/usr.sbin/xntpd/lib/msyslog.c
index a6186b72ef34..b1c8e0df5960 100644
--- a/usr.sbin/xntpd/lib/msyslog.c
+++ b/usr.sbin/xntpd/lib/msyslog.c
@@ -1,4 +1,4 @@
-/* msyslog.c,v 3.1 1993/07/06 01:08:36 jbj Exp
+/*
* msyslog - either send a message to the terminal or print it on
* the standard output.
*
diff --git a/usr.sbin/xntpd/lib/netof.c b/usr.sbin/xntpd/lib/netof.c
index 286a5846eb40..def3013dd425 100644
--- a/usr.sbin/xntpd/lib/netof.c
+++ b/usr.sbin/xntpd/lib/netof.c
@@ -7,19 +7,18 @@
#include "ntp_fp.h"
#include "ntp_stdlib.h"
-U_LONG
+u_long
netof(num)
- U_LONG num;
+ u_long num;
{
- register U_LONG netnum;
+ register u_long netnum;
netnum = num;
-
if(IN_CLASSC(netnum))
netnum &= IN_CLASSC_NET;
else if (IN_CLASSB(netnum))
netnum &= IN_CLASSB_NET;
- else /* treat als other like class A */
+ else /* treat all other like class A */
netnum &= IN_CLASSA_NET;
return netnum;
}
diff --git a/usr.sbin/xntpd/lib/numtoa.c b/usr.sbin/xntpd/lib/numtoa.c
index c36885d19e68..ef291c8d6bcd 100644
--- a/usr.sbin/xntpd/lib/numtoa.c
+++ b/usr.sbin/xntpd/lib/numtoa.c
@@ -1,4 +1,4 @@
-/* numtoa.c,v 3.1 1993/07/06 01:08:38 jbj Exp
+/*
* numtoa - return asciized network numbers store in local array space
*/
#include <stdio.h>
@@ -9,16 +9,14 @@
char *
numtoa(num)
- U_LONG num;
+ u_long num;
{
- register U_LONG netnum;
+ register u_long netnum;
register char *buf;
netnum = ntohl(num);
LIB_GETBUF(buf);
-
- (void) sprintf(buf, "%d.%d.%d.%d", (netnum>>24)&0xff,
- (netnum>>16)&0xff, (netnum>>8)&0xff, netnum&0xff);
-
+ (void) sprintf(buf, "%lu.%lu.%lu.%lu", (netnum >> 24) & 0xff,
+ (netnum >> 16) & 0xff, (netnum >> 8) & 0xff, netnum & 0xff);
return buf;
}
diff --git a/usr.sbin/xntpd/lib/numtohost.c b/usr.sbin/xntpd/lib/numtohost.c
index 2f07c2c4dac5..844bbceb63b4 100644
--- a/usr.sbin/xntpd/lib/numtohost.c
+++ b/usr.sbin/xntpd/lib/numtohost.c
@@ -13,7 +13,7 @@
char *
numtohost(netnum)
- U_LONG netnum;
+ u_long netnum;
{
char *bp;
struct hostent *hp;
diff --git a/usr.sbin/xntpd/lib/octtoint.c b/usr.sbin/xntpd/lib/octtoint.c
index 1f25b1d57693..7598d723bd35 100644
--- a/usr.sbin/xntpd/lib/octtoint.c
+++ b/usr.sbin/xntpd/lib/octtoint.c
@@ -1,4 +1,4 @@
-/* octtoint.c,v 3.1 1993/07/06 01:08:41 jbj Exp
+/*
* octtoint - convert an ascii string in octal to an unsigned
* long, with error checking
*/
@@ -10,9 +10,9 @@
int
octtoint(str, ival)
const char *str;
- U_LONG *ival;
+ u_long *ival;
{
- register U_LONG u;
+ register u_long u;
register const char *cp;
cp = str;
diff --git a/usr.sbin/xntpd/lib/prettydate.c b/usr.sbin/xntpd/lib/prettydate.c
index ad679bd872ce..747e31018e7d 100644
--- a/usr.sbin/xntpd/lib/prettydate.c
+++ b/usr.sbin/xntpd/lib/prettydate.c
@@ -1,4 +1,4 @@
-/* prettydate.c,v 3.1 1993/07/06 01:08:42 jbj Exp
+/*
* prettydate - convert a time stamp to something readable
*/
#include <stdio.h>
@@ -18,8 +18,8 @@ prettydate(ts)
{
char *bp;
struct tm *tm;
- U_LONG sec;
- U_LONG msec;
+ time_t sec;
+ u_long msec;
static char *months[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
@@ -31,14 +31,14 @@ prettydate(ts)
LIB_GETBUF(bp);
sec = ts->l_ui - JAN_1970;
- msec = ts->l_uf / 4294967; /* fract / (2**32/1000) */
+ msec = ts->l_uf / 4294967; /* fract / (2 ** 32 / 1000) */
- tm = localtime((LONG *)&sec);
+ tm = localtime(&sec);
- (void) sprintf(bp, "%08x.%08x %s, %s %2d %4d %2d:%02d:%02d.%03d",
- ts->l_ui, ts->l_uf, days[tm->tm_wday], months[tm->tm_mon],
- tm->tm_mday, 1900+tm->tm_year, tm->tm_hour, tm->tm_min,
- tm->tm_sec, msec);
+ (void) sprintf(bp, "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03lu",
+ (u_long)ts->l_ui, (u_long)ts->l_uf, days[tm->tm_wday],
+ months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year,
+ tm->tm_hour,tm->tm_min, tm->tm_sec, msec);
return bp;
}
diff --git a/usr.sbin/xntpd/lib/ranny.c b/usr.sbin/xntpd/lib/ranny.c
index 2a47e03f59ac..3fe7b221c3b8 100644
--- a/usr.sbin/xntpd/lib/ranny.c
+++ b/usr.sbin/xntpd/lib/ranny.c
@@ -1,4 +1,4 @@
-/* ranny.c,v 3.1 1993/07/06 01:08:43 jbj Exp
+/*
* Random number generator is:
*
* Copyright 1988 by Rayan S. Zachariassen, all rights reserved.
@@ -20,9 +20,9 @@ extern time_t time P((time_t *loc));
* 55 random numbers, not all even. Note we don't initialize ran_y
* directly since I have had thoughts of putting this in an EPROM
*/
-static U_LONG ran_y[55];
+static time_t ran_y[55];
-static U_LONG init_ran_y[55] = {
+static time_t init_ran_y[55] = {
1860909544, 231033423, 437666411, 1349655137, 2014584962,
504613712, 656256107, 1246027206, 573713775, 643466871,
540235388, 1630565153, 443649364, 729302839, 1933991552,
@@ -41,38 +41,22 @@ static int ran_k;
/*
- * ranp2 - return a random integer in the range 0 .. (1<<m)-1
+ * ranp2 - return a random integer in the range 0 .. (1 << m) - 1
*/
-U_LONG
+u_long
ranp2(m)
int m;
{
- U_LONG r;
-
- ran_y[ran_k] += ran_y[ran_j]; /* overflow does a mod */
- r = ran_y[ran_k];
- if (ran_k-- == 0) ran_k = 54;
- if (ran_j-- == 0) ran_j = 54;
- return (r & ((1<<m)-1));
-}
-
-#ifdef notdef
-/*
- * ranny - return a random integer in the range 0 .. m-1
- */
-U_LONG
-ranny(m)
- u_int m;
-{
- unsigned LONG r;
+ time_t r;
ran_y[ran_k] += ran_y[ran_j]; /* overflow does a mod */
r = ran_y[ran_k];
- if (ran_k-- == 0) ran_k = 54;
- if (ran_j-- == 0) ran_j = 54;
- return (r % m);
+ if (ran_k-- == 0)
+ ran_k = 54;
+ if (ran_j-- == 0)
+ ran_j = 54;
+ return (u_long)(r & ((1 << m ) - 1));
}
-#endif /* notdef */
/*
* init_random - do initialization of random number routine
@@ -90,7 +74,7 @@ init_random()
* Randomize the seed array some more. The time of day
* should be initialized by now.
*/
- now = (time_t)(time((time_t *)0))|01;
+ now = time((time_t *)0) | 01;
for (i = 0; i < 55; ++i)
ran_y[i] = now * init_ran_y[i]; /* overflow does a mod */
diff --git a/usr.sbin/xntpd/lib/refnumtoa.c b/usr.sbin/xntpd/lib/refnumtoa.c
index 31175d9f877b..b46fdd8cb350 100644
--- a/usr.sbin/xntpd/lib/refnumtoa.c
+++ b/usr.sbin/xntpd/lib/refnumtoa.c
@@ -1,4 +1,4 @@
-/* refnumtoa.c,v 3.1 1993/07/06 01:08:44 jbj Exp
+/*
* refnumtoa - return asciized refclock addresses stored in local array space
*/
#include <stdio.h>
@@ -9,9 +9,9 @@
char *
refnumtoa(num)
- U_LONG num;
+ u_long num;
{
- register U_LONG netnum;
+ register u_long netnum;
register char *buf;
register const char *rclock;
@@ -19,16 +19,12 @@ refnumtoa(num)
LIB_GETBUF(buf);
- rclock = clockname((int)((netnum>>8)&0xff));
+ rclock = clockname((int)((netnum >> 8) & 0xff));
if (rclock != NULL)
- {
- (void) sprintf(buf, "%s(%d)", clockname((int)((netnum>>8)&0xff)), netnum&0xff);
- }
+ (void)sprintf(buf, "%s(%lu)", rclock, netnum & 0xff);
else
- {
- (void) sprintf(buf, "REFCLK(%d,%d)", (netnum>>8)&0xff, netnum&0xff);
- }
-
+ (void)sprintf(buf, "REFCLK(%lu,%lu)",
+ (netnum >> 8) & 0xff, netnum&0xff);
return buf;
}
diff --git a/usr.sbin/xntpd/lib/systime.c b/usr.sbin/xntpd/lib/systime.c
index 1d6c59a5d969..4464e8dae3f4 100644
--- a/usr.sbin/xntpd/lib/systime.c
+++ b/usr.sbin/xntpd/lib/systime.c
@@ -1,15 +1,16 @@
-/* systime.c,v 3.1 1993/07/06 01:08:46 jbj Exp
+/*
* systime -- routines to fiddle a UNIX clock.
*/
+#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
-#if defined(SYS_HPUX) || defined(sgi) || defined(SYS_BSDI)
+#if defined(SYS_HPUX) || defined(sgi) || defined(SYS_BSDI) || defined(SYS_44BSD)
#include <sys/param.h>
#include <utmp.h>
#endif
#ifdef SYS_LINUX
-#include <sys/timex.h>
+#include "sys/timex.h"
#endif
#include "ntp_fp.h"
@@ -47,12 +48,12 @@ extern int debug;
* We also remember the clock precision we computed from the kernel in
* case someone asks us.
*/
- LONG sys_clock;
+ long sys_clock;
- LONG adj_precision; /* adj precision in usec (tickadj) */
- LONG tvu_maxslew; /* maximum adjust doable in 1<<CLOCK_ADJ sec (usec) */
+ long adj_precision; /* adj precision in usec (tickadj) */
+ long tvu_maxslew; /* maximum adjust doable in 1<<CLOCK_ADJ sec (usec) */
- U_LONG tsf_maxslew; /* same as above, as LONG format */
+ u_long tsf_maxslew; /* same as above, as long format */
l_fp sys_clock_offset; /* correction for current system time */
@@ -83,7 +84,7 @@ get_systime(ts)
TVTOTS(&tv, ts);
L_ADD(ts, &sys_clock_offset);
if (ts->l_uf & TS_ROUNDBIT)
- L_ADDUF(ts, (unsigned LONG) TS_ROUNDBIT);
+ L_ADDUF(ts, TS_ROUNDBIT);
#endif /* !defined(SLEWALWAYS) */
ts->l_ui += JAN_1970;
ts->l_uf &= TS_MASK;
@@ -101,8 +102,8 @@ step_systime(ts)
{
#ifdef SLEWALWAYS
#ifdef STEP_SLEW
- register U_LONG tmp_ui;
- register U_LONG tmp_uf;
+ register u_long tmp_ui;
+ register u_long tmp_uf;
int isneg;
int n;
@@ -148,13 +149,13 @@ int
adj_systime(ts)
l_fp *ts;
{
- register unsigned LONG offset_i, offset_f;
- register LONG temp;
- register unsigned LONG residual;
+ register u_long offset_i, offset_f;
+ register long temp;
+ register u_long residual;
register int isneg = 0;
struct timeval adjtv, oadjtv;
l_fp oadjts;
- LONG adj = ts->l_f;
+ long adj = ts->l_f;
int rval;
adjtv.tv_sec = adjtv.tv_usec = 0;
@@ -199,8 +200,7 @@ adj_systime(ts)
#ifdef DEBUG
if (debug > 4)
- syslog(LOG_DEBUG,
- "maximum slew: %s%s, remainder = %s\n",
+ printf("systime: maximum slew: %s%s, remainder = %s\n",
isneg?"-":"", umfptoa(0, tsf_maxslew, 9),
mfptoa(offset_i, offset_f, 9));
#endif
@@ -232,8 +232,8 @@ adj_systime(ts)
}
#ifdef DEBUG
if (debug > 4)
- syslog(LOG_DEBUG,
- "slew adjtv = %s, adjts = %s, sys_clock_offset = %s\n",
+ printf(
+ "systime: adjtv = %s, adjts = %s, sys_clock_offset = %s\n",
tvtoa(&adjtv), umfptoa(0, residual, 9),
mfptoa(offset_i, offset_f, 9));
#endif
diff --git a/usr.sbin/xntpd/lib/tsftomsu.c b/usr.sbin/xntpd/lib/tsftomsu.c
index b9161141d359..9904b4f5de17 100644
--- a/usr.sbin/xntpd/lib/tsftomsu.c
+++ b/usr.sbin/xntpd/lib/tsftomsu.c
@@ -1,4 +1,4 @@
-/* tsftomsu.c,v 3.1 1993/07/06 01:08:47 jbj Exp
+/*
* tsftomsu - convert from a time stamp fraction to milliseconds
*/
#include "ntp_fp.h"
@@ -6,11 +6,11 @@
int
tsftomsu(tsf, round)
- U_LONG tsf;
+ u_long tsf;
int round;
{
- register U_LONG val_ui, val_uf;
- register U_LONG tmp_ui, tmp_uf;
+ register long val_ui, val_uf;
+ register long tmp_ui, tmp_uf;
register int i;
/*
diff --git a/usr.sbin/xntpd/lib/tstotv.c b/usr.sbin/xntpd/lib/tstotv.c
index c9b0d1c036ad..be4bdd44155d 100644
--- a/usr.sbin/xntpd/lib/tstotv.c
+++ b/usr.sbin/xntpd/lib/tstotv.c
@@ -1,4 +1,4 @@
-/* tstotv.c,v 3.1 1993/07/06 01:08:49 jbj Exp
+/*
* tstotv - tables for converting from NTP time stamps to struct timeval
*/
@@ -13,7 +13,7 @@
* These tables are rounded.
*/
-LONG tstoushi[256] = {
+long tstoushi[256] = {
0x000000, 0x007a12, 0x00f424, 0x016e36,
0x01e848, 0x02625a, 0x02dc6c, 0x03567e,
0x03d090, 0x044aa2, 0x04c4b4, 0x053ec6,
@@ -80,7 +80,7 @@ LONG tstoushi[256] = {
0x7829b8, 0x78a3ca, 0x791ddc, 0x7997ee
};
-LONG tstousmid[256] = {
+long tstousmid[256] = {
0x0000, 0x007a, 0x00f4, 0x016e, 0x01e8, 0x0262, 0x02dc, 0x0356,
0x03d1, 0x044b, 0x04c5, 0x053f, 0x05b9, 0x0633, 0x06ad, 0x0727,
0x07a1, 0x081b, 0x0895, 0x090f, 0x0989, 0x0a03, 0x0a7e, 0x0af8,
@@ -115,7 +115,7 @@ LONG tstousmid[256] = {
0x7641, 0x76bc, 0x7736, 0x77b0, 0x782a, 0x78a4, 0x791e, 0x7998
};
-LONG tstouslo[128] = {
+long tstouslo[128] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
diff --git a/usr.sbin/xntpd/lib/tvtoa.c b/usr.sbin/xntpd/lib/tvtoa.c
index 778caa1cee26..dd9ee7eec5ac 100644
--- a/usr.sbin/xntpd/lib/tvtoa.c
+++ b/usr.sbin/xntpd/lib/tvtoa.c
@@ -1,4 +1,4 @@
-/* tvtoa.c,v 3.1 1993/07/06 01:08:50 jbj Exp
+/*
* tvtoa - return an asciized representation of a struct timeval
*/
#include <stdio.h>
@@ -12,8 +12,8 @@ tvtoa(tv)
struct timeval *tv;
{
register char *buf;
- register U_LONG sec;
- register U_LONG usec;
+ register u_long sec;
+ register u_long usec;
register int isneg;
if (tv->tv_sec < 0 || tv->tv_usec < 0) {
diff --git a/usr.sbin/xntpd/lib/tvtots.c b/usr.sbin/xntpd/lib/tvtots.c
index befc48055933..0bd2b6911472 100644
--- a/usr.sbin/xntpd/lib/tvtots.c
+++ b/usr.sbin/xntpd/lib/tvtots.c
@@ -1,4 +1,4 @@
-/* tvtots.c,v 3.1 1993/07/06 01:08:51 jbj Exp
+/*
* tvtots - tables for converting from Unix struct timeval's to
* NTP time stamp format.
*/
@@ -17,7 +17,7 @@
* +- 1.5 low order bits.
*/
-U_LONG ustotslo[256] = {
+u_long ustotslo[256] = {
0x00000000, 0x000010c7, 0x0000218e, 0x00003255,
0x0000431c, 0x000053e3, 0x000064aa, 0x00007571,
0x00008638, 0x000096ff, 0x0000a7c6, 0x0000b88d,
@@ -84,7 +84,7 @@ U_LONG ustotslo[256] = {
0x001083dc, 0x001094a3, 0x0010a56a, 0x0010b631,
};
-U_LONG ustotsmid[256] = {
+u_long ustotsmid[256] = {
0x00000000, 0x0010c6f8, 0x00218def, 0x003254e7,
0x00431bde, 0x0053e2d6, 0x0064a9ce, 0x007570c5,
0x008637bd, 0x0096feb4, 0x00a7c5ac, 0x00b88ca4,
@@ -151,7 +151,7 @@ U_LONG ustotsmid[256] = {
0x1083dbbc, 0x1094a2b4, 0x10a569ab, 0x10b630a3,
};
-U_LONG ustotshi[16] = {
+u_long ustotshi[16] = {
0x00000000, 0x10c6f79a, 0x218def35, 0x3254e6cf,
0x431bde6a, 0x53e2d604, 0x64a9cd9f, 0x7570c539,
0x8637bcd3, 0x96feb46e, 0xa7c5ac08, 0xb88ca3a3,
diff --git a/usr.sbin/xntpd/lib/uglydate.c b/usr.sbin/xntpd/lib/uglydate.c
index 308c70336232..25a8e56fa911 100644
--- a/usr.sbin/xntpd/lib/uglydate.c
+++ b/usr.sbin/xntpd/lib/uglydate.c
@@ -1,4 +1,4 @@
-/* uglydate.c,v 3.1 1993/07/06 01:08:53 jbj Exp
+/*
* uglydate - convert a time stamp to something barely readable
* The string returned is 37 characters long.
*/
@@ -19,17 +19,15 @@ uglydate(ts)
char *bp;
char *timep;
struct tm *tm;
- U_LONG sec;
- U_LONG msec;
+ time_t sec;
+ long msec;
int year;
timep = ulfptoa(ts, 6); /* returns max 17 characters */
-
LIB_GETBUF(bp);
-
sec = ts->l_ui - JAN_1970;
msec = ts->l_uf / 4294967; /* fract / (2**32/1000) */
- tm = gmtime((LONG *)&sec);
+ tm = gmtime(&sec);
if (ts->l_ui == 0) {
/*
* Probably not a real good thing to do. Oh, well.
@@ -44,10 +42,8 @@ uglydate(ts)
while (year >= 100)
year -= 100;
}
-
- (void) sprintf(bp, "%17s %02d:%03d:%02d:%02d:%02d.%03d",
+ (void) sprintf(bp, "%17s %02d:%03d:%02d:%02d:%02d.%03ld",
timep, year, tm->tm_yday, tm->tm_hour, tm->tm_min,
tm->tm_sec, msec);
-
return bp;
}
diff --git a/usr.sbin/xntpd/lib/uinttoa.c b/usr.sbin/xntpd/lib/uinttoa.c
index ce29390342b0..7c406dd5902e 100644
--- a/usr.sbin/xntpd/lib/uinttoa.c
+++ b/usr.sbin/xntpd/lib/uinttoa.c
@@ -1,4 +1,4 @@
-/* uinttoa.c,v 3.1 1993/07/06 01:08:54 jbj Exp
+/*
* uinttoa - return an asciized unsigned integer
*/
#include <stdio.h>
@@ -8,12 +8,12 @@
char *
uinttoa(uval)
- U_LONG uval;
+ u_long uval;
{
register char *buf;
LIB_GETBUF(buf);
- (void) sprintf(buf, "%lu", uval);
+ (void) sprintf(buf, "%lu", (u_long)uval);
return buf;
}
diff --git a/usr.sbin/xntpd/lib/utvtoa.c b/usr.sbin/xntpd/lib/utvtoa.c
index b573f187a38f..48310a837135 100644
--- a/usr.sbin/xntpd/lib/utvtoa.c
+++ b/usr.sbin/xntpd/lib/utvtoa.c
@@ -1,4 +1,4 @@
-/* utvtoa.c,v 3.1 1993/07/06 01:08:55 jbj Exp
+/*
* utvtoa - return an asciized representation of an unsigned struct timeval
*/
#include <stdio.h>
@@ -15,7 +15,7 @@ utvtoa(tv)
LIB_GETBUF(buf);
- (void) sprintf(buf, "%lu.%06lu", (U_LONG)tv->tv_sec,
- (U_LONG)tv->tv_usec);
+ (void) sprintf(buf, "%lu.%06lu", (u_long)tv->tv_sec,
+ (u_long)tv->tv_usec);
return buf;
}
diff --git a/usr.sbin/xntpd/ntpdate/Makefile.tmpl b/usr.sbin/xntpd/ntpdate/Makefile.tmpl
index 170625f0e35b..34f8f666c4a4 100644
--- a/usr.sbin/xntpd/ntpdate/Makefile.tmpl
+++ b/usr.sbin/xntpd/ntpdate/Makefile.tmpl
@@ -1,5 +1,5 @@
#
-# Makefile.tmpl,v 3.1 1993/07/06 01:09:20 jbj Exp
+# Makefile.tmpl
#
PROGRAM= ntpdate
#
diff --git a/usr.sbin/xntpd/ntpdate/ntpdate.c b/usr.sbin/xntpd/ntpdate/ntpdate.c
index b5ad05dc9baa..20fa604f00eb 100644
--- a/usr.sbin/xntpd/ntpdate/ntpdate.c
+++ b/usr.sbin/xntpd/ntpdate/ntpdate.c
@@ -1,4 +1,4 @@
-/* ntpdate.c,v 3.1 1993/07/06 01:09:22 jbj Exp
+/*
* ntpdate - set the time of day by polling one or more NTP servers
*/
#include <stdio.h>
@@ -92,19 +92,19 @@ char *progname;
* Systemwide parameters and flags
*/
int sys_samples = DEFSAMPLES; /* number of samples/server */
-U_LONG sys_timeout = DEFTIMEOUT; /* timeout time, in TIMER_HZ units */
+u_long sys_timeout = DEFTIMEOUT; /* timeout time, in TIMER_HZ units */
struct server **sys_servers; /* the server list */
int sys_numservers = 0; /* number of servers to poll */
int sys_maxservers = 0; /* max number of servers to deal with */
int sys_authenticate = 0; /* true when authenticating */
-U_LONG sys_authkey = 0; /* set to authentication key in use */
-U_LONG sys_authdelay = 0; /* authentication delay */
+u_long sys_authkey = 0; /* set to authentication key in use */
+u_long sys_authdelay = 0; /* authentication delay */
int sys_version = NTP_VERSION; /* version to poll with */
/*
* The current internal time
*/
-U_LONG current_time = 0;
+u_long current_time = 0;
/*
* Counter for keeping track of completed servers
@@ -149,7 +149,7 @@ static void input_handler P((void));
static int l_adj_systime P((l_fp *));
static int l_step_systime P((l_fp *));
-static int getnetnum P((char *, U_LONG *));
+static int getnetnum P((char *, u_long *));
static void printserver P((struct server *, FILE *));
/*
@@ -183,7 +183,7 @@ main(argc, argv)
case 'a':
c = atoi(ntp_optarg);
sys_authenticate = 1;
- sys_authkey = (U_LONG)c;
+ sys_authkey = c;
break;
case 'b':
always_step++;
@@ -313,7 +313,7 @@ main(argc, argv)
if (!authhavekey(sys_authkey)) {
char buf[10];
- (void) sprintf(buf, "%u", sys_authkey);
+ (void) sprintf(buf, "%lu", (unsigned long)sys_authkey);
syslog(LOG_ERR, "authentication key %s unknown", buf);
exit(1);
}
@@ -418,7 +418,7 @@ transmit(server)
* Last message to this server timed out. Shift
* zeros into the filter.
*/
- ts.l_ui = ts.l_uf = 0;
+ L_CLR(&ts);
server_data(server, 0, &ts, 0);
}
@@ -444,9 +444,9 @@ transmit(server)
xpkt.rootdelay = htonl(NTPDATE_DISTANCE);
xpkt.rootdispersion = htonl(NTPDATE_DISP);
xpkt.refid = htonl(NTPDATE_REFID);
- xpkt.reftime.l_ui = xpkt.reftime.l_uf = 0;
- xpkt.org.l_ui = xpkt.org.l_uf = 0;
- xpkt.rec.l_ui = xpkt.rec.l_uf = 0;
+ L_CLR(&xpkt.reftime);
+ L_CLR(&xpkt.org);
+ L_CLR(&xpkt.rec);
/*
* Determine whether to authenticate or not. If so,
@@ -494,8 +494,7 @@ receive(rbufp)
register struct pkt *rpkt;
register struct server *server;
register s_fp di;
- register U_LONG t10_ui, t10_uf;
- register U_LONG t23_ui, t23_uf;
+ l_fp t10, t23;
l_fp org;
l_fp rec;
l_fp ci;
@@ -564,9 +563,9 @@ receive(rbufp)
is_authentic = 0;
if (debug > 3)
- printf("receive: rpkt keyid=%d sys_authkey=%d decrypt=%d\n",
- ntohl(rpkt->keyid), sys_authkey,
- authdecrypt(sys_authkey, (U_LONG *)rpkt,
+ printf("receive: rpkt keyid=%ld sys_authkey=%ld decrypt=%ld\n",
+ (long int)ntohl(rpkt->keyid), (long int)sys_authkey,
+ (long int)authdecrypt(sys_authkey, (U_LONG *)rpkt,
LEN_PKT_NOMAC));
if (has_mac && ntohl(rpkt->keyid) == sys_authkey &&
@@ -597,7 +596,7 @@ receive(rbufp)
* Make sure the server is at least somewhat sane. If not, try
* again.
*/
- if ((rec.l_ui == 0 && rec.l_uf == 0) || !L_ISHIS(&server->org, &rec)) {
+ if (L_ISZERO(&rec) || !L_ISHIS(&server->org, &rec)) {
transmit(server);
return;
}
@@ -609,36 +608,32 @@ receive(rbufp)
* d = (t2 - t3) - (t1 - t0)
* c = ((t2 - t3) + (t1 - t0)) / 2
*/
- t10_ui = server->org.l_ui; /* pkt.xmt == t1 */
- t10_uf = server->org.l_uf;
- M_SUB(t10_ui, t10_uf, rbufp->recv_time.l_ui,
- rbufp->recv_time.l_uf); /* recv_time == t0*/
+ t10 = server->org; /* pkt.xmt == t1 */
+ L_SUB(&t10, &rbufp->recv_time); /* recv_time == t0*/
- t23_ui = rec.l_ui; /* pkt.rec == t2 */
- t23_uf = rec.l_uf;
- M_SUB(t23_ui, t23_uf, org.l_ui, org.l_uf); /* pkt->org == t3 */
+ t23 = rec; /* pkt.rec == t2 */
+ L_SUB(&t23, &org); /* pkt->org == t3 */
/* now have (t2 - t3) and (t0 - t1). Calculate (ci) and (di) */
- ci.l_ui = t10_ui;
- ci.l_uf = t10_uf;
- M_ADD(ci.l_ui, ci.l_uf, t23_ui, t23_uf);
- M_RSHIFT(ci.l_i, ci.l_uf);
+ ci = t10;
+ L_ADD(&ci, &t23);
+ L_RSHIFT(&ci);
/*
* Calculate di in t23 in full precision, then truncate
* to an s_fp.
*/
- M_SUB(t23_ui, t23_uf, t10_ui, t10_uf);
- di = MFPTOFP(t23_ui, t23_uf);
+ L_SUB(&t23, &t10);
+ di = LFPTOFP(&t23);
if (debug > 3)
- printf("offset: %s, delay %s\n", lfptoa(&ci, 9), fptoa(di, 4));
+ printf("offset: %s, delay %s\n", lfptoa(&ci, 6), fptoa(di, 5));
di += (FP_SECOND >> (-(int)NTPDATE_PRECISION))
+ (FP_SECOND >> (-(int)server->precision)) + NTP_MAXSKW;
if (di <= 0) { /* value still too raunchy to use? */
- ci.l_ui = ci.l_uf = 0;
+ L_CLR(&ci);
di = 0;
} else {
di = max(di, NTP_MINDIST);
@@ -668,7 +663,7 @@ server_data(server, d, c, e)
if (i < NTP_SHIFT) {
server->filter_delay[i] = d;
server->filter_offset[i] = *c;
- server->filter_soffset[i] = MFPTOFP(c->l_ui, c->l_uf);
+ server->filter_soffset[i] = LFPTOFP(c);
server->filter_error[i] = e;
server->filter_nextpt = i + 1;
}
@@ -714,7 +709,7 @@ clock_filter(server)
*/
if (server->filter_delay[ord[0]] == 0) {
server->delay = 0;
- server->offset.l_ui = server->offset.l_uf = 0;
+ L_CLR(&server->offset);
server->soffset = 0;
server->dispersion = PEER_MAXDISP;
} else {
@@ -786,12 +781,12 @@ clock_select()
}
if (server->leap == LEAP_NOTINSYNC)
continue; /* he's in trouble */
- if (server->org.l_ui < server->reftime.l_ui) {
+ if (!L_ISHIS(&server->org, &server->reftime)) {
continue; /* very broken host */
}
if ((server->org.l_ui - server->reftime.l_ui)
>= NTP_MAXAGE) {
- continue; /* too LONG without sync */
+ continue; /* too long without sync */
}
if (server->trust != 0) {
continue;
@@ -984,13 +979,13 @@ clock_adjust()
if (simple_query || l_step_systime(&server->offset)) {
syslog(LOG_NOTICE, "step time server %s offset %s",
ntoa(&server->srcadr),
- lfptoa(&server->offset, 7));
+ lfptoa(&server->offset, 6));
}
} else {
if (simple_query || l_adj_systime(&server->offset)) {
syslog(LOG_NOTICE, "adjust time server %s offset %s",
ntoa(&server->srcadr),
- lfptoa(&server->offset, 7));
+ lfptoa(&server->offset, 6));
}
}
return(0);
@@ -1007,7 +1002,7 @@ addserver(serv)
char *serv;
{
register struct server *server;
- U_LONG netnum;
+ u_long netnum;
static int toomany = 0;
if (sys_numservers >= sys_maxservers) {
@@ -1037,7 +1032,7 @@ addserver(serv)
server->srcadr.sin_port = htons(NTP_PORT);
sys_servers[sys_numservers++] = server;
- server->event_time = (U_LONG)sys_numservers;
+ server->event_time = sys_numservers;
}
@@ -1049,7 +1044,7 @@ findserver(addr)
struct sockaddr_in *addr;
{
register int i;
- register U_LONG netnum;
+ register u_long netnum;
if (htons(addr->sin_port) != NTP_PORT)
return 0;
@@ -1191,7 +1186,7 @@ init_io()
memset((char *)&addr, 0, sizeof addr);
addr.sin_family = AF_INET;
addr.sin_port = htons(NTP_PORT);
- addr.sin_addr.s_addr = INADDR_ANY;
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
if (errno == EADDRINUSE)
syslog(LOG_ERR,
@@ -1366,7 +1361,7 @@ input_handler()
/*
- * adj_systime - do a big LONG slew of the system time
+ * adj_systime - do a big long slew of the system time
*/
static int
l_adj_systime(ts)
@@ -1425,8 +1420,7 @@ l_step_systime(ts)
{
#ifdef SLEWALWAYS
#ifdef STEP_SLEW
- register U_LONG tmp_ui;
- register U_LONG tmp_uf;
+ l_fp ftmp;
int isneg;
int n;
@@ -1434,17 +1428,17 @@ l_step_systime(ts)
/*
* Take the absolute value of the offset
*/
- tmp_ui = ts->l_ui;
- tmp_uf = ts->l_uf;
- if (M_ISNEG(tmp_ui, tmp_uf)) {
- M_NEG(tmp_ui, tmp_uf);
+ ftmp = ts;
+ if (L_ISNEG(&ftmp)) {
+ L_NEG(&tmp);
isneg = 1;
} else
isneg = 0;
if (tmp_ui >= 3) { /* Step it and slew - we might win */
n = step_systime_real(ts);
- if (!n) return n;
+ if (!n)
+ return n;
if (isneg)
ts->l_ui = ~0;
else
@@ -1456,7 +1450,8 @@ l_step_systime(ts)
* line.
*/
#endif
- if (debug) return 1;
+ if (debug)
+ return 1;
#ifdef FORCE_NTPDATE_STEP
return step_systime_real(ts);
#else
@@ -1464,7 +1459,8 @@ l_step_systime(ts)
return 1;
#endif
#else /* SLEWALWAYS */
- if (debug) return 1;
+ if (debug)
+ return 1;
return step_systime_real(ts);
#endif /* SLEWALWAYS */
}
@@ -1475,7 +1471,7 @@ l_step_systime(ts)
static int
getnetnum(host, num)
char *host;
- U_LONG *num;
+ u_long *num;
{
struct hostent *hp;
@@ -1504,7 +1500,7 @@ printserver(pp, fp)
if (!debug) {
(void) fprintf(fp, "server %s, stratum %d, offset %s, delay %s\n",
ntoa(&pp->srcadr), pp->stratum,
- lfptoa(&pp->offset, 7), ufptoa(pp->delay, 4));
+ lfptoa(&pp->offset, 6), fptoa(pp->delay, 5));
return;
}
@@ -1526,8 +1522,8 @@ printserver(pp, fp)
}
(void) fprintf(fp,
"refid [%s], delay %s, dispersion %s\n",
- str, fptoa(pp->delay, 4),
- ufptoa(pp->dispersion, 4));
+ str, fptoa(pp->delay, 5),
+ ufptoa(pp->dispersion, 5));
(void) fprintf(fp, "transmitted %d, in filter %d\n",
pp->xmtcnt, pp->filter_nextpt);
@@ -1541,7 +1537,7 @@ printserver(pp, fp)
(void) fprintf(fp, "filter delay: ");
for (i = 0; i < NTP_SHIFT; i++) {
- (void) fprintf(fp, " %-8.8s", ufptoa(pp->filter_delay[i],4));
+ (void) fprintf(fp, " %-8.8s", fptoa(pp->filter_delay[i], 5));
if (i == (NTP_SHIFT>>1)-1)
(void) fprintf(fp, "\n ");
}
@@ -1549,17 +1545,17 @@ printserver(pp, fp)
(void) fprintf(fp, "filter offset:");
for (i = 0; i < PEER_SHIFT; i++) {
- (void) fprintf(fp, " %-8.8s", lfptoa(&pp->filter_offset[i], 5));
+ (void) fprintf(fp, " %-8.8s", lfptoa(&pp->filter_offset[i], 6));
if (i == (PEER_SHIFT>>1)-1)
(void) fprintf(fp, "\n ");
}
(void) fprintf(fp, "\n");
(void) fprintf(fp, "delay %s, dispersion %s\n",
- ufptoa(pp->delay, 4), ufptoa(pp->dispersion, 4));
+ fptoa(pp->delay, 5), ufptoa(pp->dispersion, 5));
(void) fprintf(fp, "offset %s\n\n",
- lfptoa(&pp->offset, 7));
+ lfptoa(&pp->offset, 6));
}
#if defined(NEED_VSPRINTF)
diff --git a/usr.sbin/xntpd/ntpdate/ntpdate.h b/usr.sbin/xntpd/ntpdate/ntpdate.h
index f6d3ebf877f3..cfbe90a92334 100644
--- a/usr.sbin/xntpd/ntpdate/ntpdate.h
+++ b/usr.sbin/xntpd/ntpdate/ntpdate.h
@@ -1,4 +1,4 @@
-/* ntpdate.h,v 3.1 1993/07/06 01:09:23 jbj Exp
+/*
* ntpdate.h - declarations for the ntpdate program
*/
@@ -21,7 +21,7 @@ struct server {
u_fp rootdispersion; /* peer clock dispersion */
U_LONG refid; /* peer reference ID */
l_fp reftime; /* time of peer's last update */
- U_LONG event_time; /* time for next timeout */
+ u_long event_time; /* time for next timeout */
u_short xmtcnt; /* number of packets transmitted */
u_short filter_nextpt; /* index into filter shift register */
s_fp filter_delay[NTP_SHIFT]; /* delay part of shift register */
@@ -50,7 +50,7 @@ struct server {
#define TIMER_HZ (5) /* 5 per second */
/*
- * ntpdate will make a LONG adjustment using adjtime() if the times
+ * ntpdate will make a long adjustment using adjtime() if the times
* are close, or step the time if the times are farther apart. The
* following defines what is "close".
*/
@@ -87,4 +87,3 @@ struct server {
*/
#define DEFTIMEOUT 5 /* 5 timer increments */
#define DEFSAMPLES 4 /* get 4 samples per server */
-#define DEFPRECISION (-5) /* the precision we claim */
diff --git a/usr.sbin/xntpd/ntpq/Makefile.tmpl b/usr.sbin/xntpd/ntpq/Makefile.tmpl
index e80286123cf0..76a09ad6b7e1 100644
--- a/usr.sbin/xntpd/ntpq/Makefile.tmpl
+++ b/usr.sbin/xntpd/ntpq/Makefile.tmpl
@@ -1,5 +1,5 @@
#
-# Makefile.tmpl,v 3.1 1993/07/06 01:09:28 jbj Exp
+# Makefile.tmpl
#
PROGRAM= ntpq
#
diff --git a/usr.sbin/xntpd/ntpq/ntpq.c b/usr.sbin/xntpd/ntpq/ntpq.c
index 73c2a351aa70..441b283bad6d 100644
--- a/usr.sbin/xntpd/ntpq/ntpq.c
+++ b/usr.sbin/xntpd/ntpq/ntpq.c
@@ -1,4 +1,4 @@
-/* ntpq.c,v 3.1 1993/07/06 01:09:29 jbj Exp
+/*
* ntpq - query an NTP server using mode 6 commands
*/
#include <stdio.h>
@@ -27,7 +27,7 @@ char *prompt = "ntpq> "; /* prompt to ask him about */
/*
* Keyid used for authenticated requests. Obtained on the fly.
*/
-U_LONG info_auth_keyid = -1;
+u_long info_auth_keyid = -1;
/*
* Type of key md5 or des
@@ -88,7 +88,7 @@ struct ctl_var sys_var[] = {
{ CS_LEAP, LP, "leap" }, /* 1 */
{ CS_STRATUM, UI, "stratum" }, /* 2 */
{ CS_PRECISION, IN, "precision" }, /* 3 */
- { CS_ROOTDELAY, FU, "rootdelay" }, /* 4 */
+ { CS_ROOTDELAY, FS, "rootdelay" }, /* 4 */
{ CS_ROOTDISPERSION, FU, "rootdispersion" }, /* 5 */
{ CS_REFID, RF, "refid" }, /* 6 */
{ CS_REFTIME, TS, "reftime" }, /* 7 */
@@ -96,7 +96,7 @@ struct ctl_var sys_var[] = {
{ CS_PEERID, UI, "peer" }, /* 9 */
{ CS_OFFSET, FL, "phase" }, /* 10 */
{ CS_DRIFT, FS, "freq" }, /* 11 */
- { CS_COMPLIANCE, UI, "compliance" }, /* 12 */
+ { CS_COMPLIANCE, FU, "error" }, /* 12 */
{ CS_CLOCK, TS, "clock" }, /* 13 */
{ CS_LEAPIND, LP, "leapindicator" }, /* 14 */
{ CS_LEAPWARNING, LP, "leapwarning" }, /* 15 */
@@ -149,7 +149,7 @@ struct ctl_var peer_var[] = {
{ CP_FLASH, TST, "flash"}, /* 34 */
{ CP_DISP, AR, "disp" }, /* 35 */
/*
- * These are duplicate entires so that we can
+ * These are duplicate entries so that we can
* process deviant version of the xntp protocal.
*/
{ CP_SRCADR, HA, "peeraddr" }, /* 4 */
@@ -173,8 +173,8 @@ struct ctl_var clock_var[] = {
{ CC_BADDATA, UI, "baddata" }, /* 6 */
{ CC_FUDGETIME1, FL, "fudgetime1" }, /* 7 */
{ CC_FUDGETIME2, FL, "fudgetime2" }, /* 8 */
- { CC_FUDGEVAL1, IN, "fudgeval1" }, /* 9 */
- { CC_FUDGEVAL2, IN, "fudgeval2" }, /* 10 */
+ { CC_FUDGEVAL1, UI, "stratum" }, /* 9 */
+ { CC_FUDGEVAL2, RF, "refid" }, /* 10 */
{ CC_FLAGS, UI, "flags" }, /* 11 */
{ CC_DEVICE, ST, "device" }, /* 12 */
{ 0, EOV, "" }
@@ -308,11 +308,6 @@ static void tokenize P((char *, char **, int *));
static int findcmd P((char *, struct xcmd *, struct xcmd *, struct xcmd **));
static int getarg P((char *, int, arg_v *));
static int rtdatetolfp P((char *, l_fp *));
-
-#ifdef UNUSED
-static int decodereach P((char *, U_LONG *));
-#endif /* UNUSED */
-
static int decodearr P((char *, int *, l_fp *));
static char * getcode P((int, struct codestring *));
static void help P((struct parse *, FILE *));
@@ -339,7 +334,7 @@ static void authenticate P((struct parse *, FILE *));
static void ntpversion P((struct parse *, FILE *));
static void warning P((char *, char *, char *));
static void error P((char *, char *, char *));
-static U_LONG getkeyid P((char *));
+static u_long getkeyid P((char *));
static void atoascii P((int, char *, char *));
static void makeascii P((int, char *, FILE *));
static char * getevents P((int));
@@ -424,7 +419,7 @@ struct xcmd builtins[] = {
#define DEFSTIMEOUT (2) /* 2 second time out after first */
#define DEFDELAY 0x51EB852 /* 20 milliseconds, l_fp fraction */
#define DEFHOST "localhost" /* default host name */
-#define LENHOSTNAME 256 /* host name is 256 characters LONG */
+#define LENHOSTNAME 256 /* host name is 256 characters long */
#define MAXCMDS 100 /* maximum commands on cmd line */
#define MAXHOSTS 100 /* maximum hosts on cmd line */
#define MAXLINE 512 /* maximum line length */
@@ -454,12 +449,12 @@ struct servent *server_entry = NULL; /* server entry for ntp */
u_short sequence;
/*
- * Holds data returned from queries. Declare buffer LONG to be sure of
+ * Holds data returned from queries. Declare buffer long to be sure of
* alignment.
*/
#define MAXFRAGS 24 /* maximum number of fragments */
#define DATASIZE (MAXFRAGS*480) /* maximum amount of data */
-LONG pktdata[DATASIZE/sizeof(LONG)];
+long pktdata[DATASIZE/sizeof(long)];
/*
* Holds association data for use with the &n operator.
@@ -597,7 +592,7 @@ static int
openhost(hname)
char *hname;
{
- U_LONG netnum;
+ u_long netnum;
char temphost[LENHOSTNAME];
if (server_entry == NULL) {
@@ -712,9 +707,9 @@ getresponse(opcode, associd, rstatus, rsize, rdata, timeo)
/*
* This is pretty tricky. We may get between 1 and MAXFRAG packets
* back in response to the request. We peel the data out of
- * each packet and collect it in one LONG block. When the last
+ * each packet and collect it in one long block. When the last
* packet in the sequence is received we'll know how much data we
- * should have had. Note we use one LONG time out, should reconsider.
+ * should have had. Note we use one long time out, should reconsider.
*/
*rsize = 0;
if (rstatus)
@@ -879,8 +874,8 @@ again:
if (debug >= 3) {
int shouldbesize;
- U_LONG key;
- U_LONG *lpkt;
+ u_long key;
+ u_long *lpkt;
int maclen;
/*
@@ -898,15 +893,15 @@ again:
printf(
"Packet shows signs of authentication (total %d, data %d, mac %d)\n",
n, shouldbesize, maclen);
- lpkt = (U_LONG *)&rpkt;
+ lpkt = (u_long *)&rpkt;
printf("%08lx %08lx %08lx %08lx %08lx %08lx\n",
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG) - 3]),
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG) - 2]),
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG) - 1]),
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG)]),
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG) + 1]),
- ntohl(lpkt[(n - maclen)/sizeof(U_LONG) + 2]));
- key = ntohl(lpkt[(n - maclen) / sizeof(U_LONG)]);
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) - 3]),
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) - 2]),
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) - 1]),
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long)]),
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) + 1]),
+ (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) + 2]));
+ key = ntohl(lpkt[(n - maclen) / sizeof(u_long)]);
printf("Authenticated with keyid %lu\n", key);
if (key != 0 && key != info_auth_keyid) {
printf("We don't know that key\n");
@@ -1067,7 +1062,7 @@ sendrequest(opcode, associd, auth, qsize, qdata)
if (qsize > 0) {
memmove((char *)qpkt.data, qdata, qsize);
pktsize = qsize + CTL_HEADER_LEN;
- while (pktsize & (sizeof(U_LONG)-1)) {
+ while (pktsize & (sizeof(u_long) - 1)) {
qpkt.data[qsize++] = 0;
pktsize++;
}
@@ -1118,7 +1113,7 @@ sendrequest(opcode, associd, auth, qsize, qdata)
* cp currently points. Cp should be aligned
* properly. Then do the encryptions.
*/
- *(U_LONG *)(&qpkt.data[qsize]) = htonl(info_auth_keyid);
+ *(u_long *)(&qpkt.data[qsize]) = htonl(info_auth_keyid);
maclen = authencrypt(info_auth_keyid, (U_LONG *)&qpkt,
pktsize);
return sendpkt((char *)&qpkt, pktsize + maclen);
@@ -1542,21 +1537,22 @@ getarg(str, code, argp)
int
getnetnum(host, num, fullhost)
char *host;
- U_LONG *num;
+ u_long *num;
char *fullhost;
{
struct hostent *hp;
if (decodenetnum(host, num)) {
if (fullhost != 0) {
- (void) sprintf(fullhost,
- "%d.%d.%d.%d", ((htonl(*num)>>24)&0xff),
- ((htonl(*num)>>16)&0xff), ((htonl(*num)>>8)&0xff),
- (htonl(*num)&0xff));
+ (void) sprintf(fullhost, "%lu.%lu.%lu.%lu",
+ (u_long)((htonl(*num) >> 24) & 0xff),
+ (u_long)((htonl(*num) >> 16) & 0xff),
+ (u_long)((htonl(*num) >> 8) & 0xff),
+ (u_long)(htonl(*num) & 0xff));
}
return 1;
} else if ((hp = gethostbyname(host)) != 0) {
- memmove((char *)num, hp->h_addr, sizeof(U_LONG));
+ memmove((char *)num, hp->h_addr, sizeof(u_long));
if (fullhost != 0)
(void) strcpy(fullhost, hp->h_name);
return 1;
@@ -1573,7 +1569,7 @@ getnetnum(host, num, fullhost)
*/
char *
nntohost(netnum)
- U_LONG netnum;
+ u_long netnum;
{
if (!showhostnames)
return numtoa(netnum);
@@ -1613,7 +1609,7 @@ rtdatetolfp(str, lfp)
/*
* Catch special case
*/
- lfp->l_ui = lfp->l_uf = 0;
+ L_CLR(lfp);
return 1;
}
return 0;
@@ -1654,7 +1650,7 @@ rtdatetolfp(str, lfp)
* Catch special case. If cal.year == 0 this is a zero timestamp.
*/
if (cal.year == 0) {
- lfp->l_ui = lfp->l_uf = 0;
+ L_CLR(lfp);
return 1;
}
@@ -1748,49 +1744,18 @@ decodetime(str, lfp)
}
-#ifdef UNUSED
-/*
- * decodereach - decode a (possibly octal or hex, damn fuzzballs) reachability
- */
-static int
-decodereach(str, uval)
- char *str;
- U_LONG *uval;
-{
- U_LONG u;
-
- if (*str == '0') {
- /*
- * Could be octal or hex
- */
- if (*(str+1) == 'x' || *(str+1) == 'X')
- return hextoint(str+2, uval);
- return octtoint(str, uval);
- }
-
- if (!atouint(str, &u))
- return 0;
-
- if (u > 255)
- return octtoint(str, uval);
- *uval = u;
- return 1;
-}
-#endif /* UNUSED */
-
-
/*
* decodeint - decode an integer
*/
int
decodeint(str, val)
char *str;
- LONG *val;
+ long *val;
{
if (*str == '0') {
if (*(str+1) == 'x' || *(str+1) == 'X')
- return hextoint(str+2, (U_LONG *)val);
- return octtoint(str, (U_LONG *)val);
+ return hextoint(str+2, (u_long *)&val);
+ return octtoint(str, (u_long *)&val);
}
return atoint(str, val);
}
@@ -1802,7 +1767,7 @@ decodeint(str, val)
int
decodeuint(str, val)
char *str;
- U_LONG *val;
+ u_long *val;
{
if (*str == '0') {
if (*(str+1) == 'x' || *(str+1) == 'X')
@@ -2017,18 +1982,18 @@ delay(pcmd, fp)
FILE *fp;
{
int isneg;
- U_LONG val;
+ u_long val;
if (pcmd->nargs == 0) {
val = delay_time.l_ui * 1000 + delay_time.l_uf / 4294967;
- (void) fprintf(fp, "delay %d ms\n", val);
+ (void) fprintf(fp, "delay %lu ms\n", val);
} else {
if (pcmd->argval[0].ival < 0) {
isneg = 1;
- val = (U_LONG)(-pcmd->argval[0].ival);
+ val = (u_long)(-pcmd->argval[0].ival);
} else {
isneg = 0;
- val = (U_LONG)pcmd->argval[0].ival;
+ val = (u_long)pcmd->argval[0].ival;
}
delay_time.l_ui = val / 1000;
@@ -2092,7 +2057,7 @@ keyid(pcmd, fp)
if (info_auth_keyid == -1)
(void) fprintf(fp, "no keyid defined\n");
else
- (void) fprintf(fp, "keyid is %u\n", info_auth_keyid);
+ (void) fprintf(fp, "keyid is %lu\n", info_auth_keyid);
} else {
info_auth_keyid = pcmd->argval[0].uval;
}
@@ -2344,7 +2309,7 @@ error(fmt, st1, st2)
/*
* getkeyid - prompt the user for a keyid to use
*/
-static U_LONG
+static u_long
getkeyid(prompt)
char *prompt;
{
@@ -2368,7 +2333,7 @@ char *prompt;
if (strcmp(pbuf, "0") == 0)
return 0;
- return (U_LONG) atoi(pbuf);
+ return (u_long) atoi(pbuf);
}
@@ -2515,7 +2480,9 @@ statustoa(type, st)
case TYPE_SYS:
(void)strcpy(cb, getcode(CTL_SYS_LI(st), leap_codes));
(void)strcat(cb, ", ");
- (void)strcat(cb, getcode(CTL_SYS_SOURCE(st), sync_codes));
+ (void)strcat(cb, getcode(CTL_SYS_SOURCE(st) & ~CTL_SST_TS_PPS, sync_codes));
+ if (CTL_SYS_SOURCE(st) & CTL_SST_TS_PPS)
+ (void)strcat(cb, "/PPS");
(void)strcat(cb, ", ");
(void)strcat(cb, getevents(CTL_SYS_NEVNT(st)));
(void)strcat(cb, ", ");
@@ -2853,7 +2820,7 @@ outputarr(fp, name, narr, lfp)
static char *
tstflags(val)
- U_LONG val;
+ u_long val;
{
register char *cb, *s;
register int i;
@@ -2865,7 +2832,7 @@ tstflags(val)
if (++nextcb >= NUMCB)
nextcb = 0;
- sprintf(cb, "0x%x", val);
+ sprintf(cb, "0x%lx", val);
cb += strlen(cb);
if (val <= ((1<<8)-1)) {
if (!val) {
@@ -2909,8 +2876,9 @@ cookedprint(datatype, length, data, status, fp)
int fmt;
struct ctl_var *varlist;
l_fp lfp;
- LONG ival;
- U_LONG uval;
+ long ival;
+ u_long hval;
+ u_long uval;
l_fp lfparr[8];
int narr;
@@ -2986,12 +2954,12 @@ cookedprint(datatype, length, data, status, fp)
case HA:
case NA:
- if (!decodenetnum(value, &uval))
+ if (!decodenetnum(value, &hval))
output_raw = '?';
else if (fmt == HA)
- output(fp, name, nntohost(uval));
+ output(fp, name, nntohost(hval));
else
- output(fp, name, numtoa(uval));
+ output(fp, name, numtoa(hval));
break;
case ST:
@@ -2999,8 +2967,8 @@ cookedprint(datatype, length, data, status, fp)
break;
case RF:
- if (decodenetnum(value, &uval))
- output(fp, name, nntohost(uval));
+ if (decodenetnum(value, &hval))
+ output(fp, name, nntohost(hval));
else if ((int)strlen(value) <= 4)
output(fp, name, value);
else
@@ -3028,7 +2996,7 @@ cookedprint(datatype, length, data, status, fp)
else {
char b[10];
- (void) sprintf(b, "%03o", uval);
+ (void) sprintf(b, "%03lo", uval);
output(fp, name, b);
}
break;
diff --git a/usr.sbin/xntpd/ntpq/ntpq.h b/usr.sbin/xntpd/ntpq/ntpq.h
index edfc9b599028..c233b240ec5f 100644
--- a/usr.sbin/xntpd/ntpq/ntpq.h
+++ b/usr.sbin/xntpd/ntpq/ntpq.h
@@ -1,4 +1,4 @@
-/* ntpq.h,v 3.1 1993/07/06 01:09:30 jbj Exp
+/*
* ntpq.h - definitions of interest to ntpq
*/
#include "ntp_fp.h"
@@ -28,9 +28,9 @@
*/
typedef union {
char *string;
- LONG ival;
- U_LONG uval;
- U_LONG netnum;
+ long ival;
+ u_long uval;
+ u_long netnum;
} arg_v;
/*
@@ -84,14 +84,14 @@ struct ctl_var {
};
extern void asciize P((int, char *, FILE *));
-extern int getnetnum P((char *, U_LONG *, char *));
+extern int getnetnum P((char *, u_long *, char *));
extern void sortassoc P((void));
extern int doquery P((int, int, int, int, char *, u_short *, int *, char **));
-extern char * nntohost P((U_LONG));
+extern char * nntohost P((u_long));
extern int decodets P((char *, l_fp *));
-extern int decodeuint P((char *, U_LONG *));
+extern int decodeuint P((char *, u_long *));
extern int nextvar P((int *, char **, char **, char **));
extern int decodetime P((char *, l_fp *));
extern void printvars P((int, char *, int, int, FILE *));
-extern int decodeint P((char *, LONG *));
+extern int decodeint P((char *, long *));
extern int findvar P((char *, struct ctl_var *));
diff --git a/usr.sbin/xntpd/ntpq/ntpq_ops.c b/usr.sbin/xntpd/ntpq/ntpq_ops.c
index 395a9ecfd914..8bab73df576f 100644
--- a/usr.sbin/xntpd/ntpq/ntpq_ops.c
+++ b/usr.sbin/xntpd/ntpq/ntpq_ops.c
@@ -1,4 +1,4 @@
-/* ntpq_ops.c,v 3.1 1993/07/06 01:09:32 jbj Exp
+/*
* ntpdc_ops.c - subroutines which are called to perform operations by xntpdc
*/
#include <stdio.h>
@@ -18,7 +18,7 @@ int maxhostlen;
/*
* Declarations for command handlers in here
*/
-static int checkassocid P((U_LONG));
+static int checkassocid P((u_long));
static char * strsave P((char *));
static struct varlist *findlistvar P((struct varlist *, char *));
static void doaddvlist P((struct varlist *, char *));
@@ -38,7 +38,7 @@ static void readvar P((struct parse *, FILE *));
static void writevar P((struct parse *, FILE *));
static void clocklist P((struct parse *, FILE *));
static void clockvar P((struct parse *, FILE *));
-static int findassidrange P((U_LONG, U_LONG, int *, int *));
+static int findassidrange P((u_long, u_long, int *, int *));
static void mreadlist P((struct parse *, FILE *));
static void mreadvar P((struct parse *, FILE *));
static int dogetassoc P((FILE *));
@@ -159,7 +159,7 @@ struct xcmd opcmds[] = {
* Variable list data space
*/
#define MAXLIST 64 /* maximum number of variables in list */
-#define LENHOSTNAME 256 /* host name is 256 characters LONG */
+#define LENHOSTNAME 256 /* host name is 256 characters long */
/*
* Old CTL_PST defines for version 2.
*/
@@ -205,7 +205,7 @@ extern u_char pktversion;
*/
static int
checkassocid(value)
- U_LONG value;
+ u_long value;
{
if (value == 0 || value >= 65536) {
(void) fprintf(stderr, "***Invalid association ID specified\n");
@@ -706,8 +706,8 @@ clockvar(pcmd, fp)
*/
static int
findassidrange(assid1, assid2, from, to)
- U_LONG assid1;
- U_LONG assid2;
+ u_long assid1;
+ u_long assid2;
int *from;
int *to;
{
@@ -716,13 +716,13 @@ findassidrange(assid1, assid2, from, to)
if (assid1 == 0 || assid1 > 65535) {
(void) fprintf(stderr,
- "***Invalid association ID %lu specified\n", assid1);
+ "***Invalid association ID %lu specified\n", (u_long)assid1);
return 0;
}
if (assid2 == 0 || assid2 > 65535) {
(void) fprintf(stderr,
- "***Invalid association ID %lu specified\n", assid2);
+ "***Invalid association ID %lu specified\n", (u_long)assid2);
return 0;
}
@@ -743,7 +743,7 @@ findassidrange(assid1, assid2, from, to)
if (f == -1 || t == -1) {
(void) fprintf(stderr,
"***Association ID %lu not found in list\n",
- (f == -1) ? assid1 : assid2);
+ (f == -1) ? (u_long)assid1 : (u_long)assid2);
return 0;
}
@@ -876,7 +876,7 @@ printassoc(showall, fp)
int i;
u_char statval;
int event;
- U_LONG event_count;
+ u_long event_count;
char *conf;
char *reach;
char *auth;
@@ -1028,7 +1028,7 @@ associations(pcmd, fp)
/*
- * lassociations - get, record and print a LONG list of associations
+ * lassociations - get, record and print a long list of associations
*/
/*ARGSUSED*/
static void
@@ -1055,7 +1055,7 @@ passociations(pcmd, fp)
/*
- * lpassociations - print the LONG association list
+ * lpassociations - print the long association list
*/
/*ARGSUSED*/
static void
@@ -1146,7 +1146,7 @@ fixup(width, str)
/*
- * when - print how LONG its been since his last packet arrived
+ * when - print how long its been since his last packet arrived
*/
static char *
when(ts, rec, reftime)
@@ -1154,7 +1154,7 @@ when(ts, rec, reftime)
l_fp *rec;
l_fp *reftime;
{
- LONG diff;
+ long diff;
l_fp *lasttime;
static char buf[20];
@@ -1165,7 +1165,7 @@ when(ts, rec, reftime)
else
return "-";
- diff = (LONG)(ts->l_ui - lasttime->l_ui);
+ diff = (long)(ts->l_ui - lasttime->l_ui);
if (diff <= 0) {
/*
* Time warp?
@@ -1174,24 +1174,24 @@ when(ts, rec, reftime)
}
if (diff <= 2048) {
- (void) sprintf(buf, "%d", diff);
+ (void) sprintf(buf, "%ld", (long int)diff);
return buf;
}
diff = (diff + 29) / 60;
if (diff <= 300) {
- (void) sprintf(buf, "%dm", diff);
+ (void) sprintf(buf, "%ldm", (long int)diff);
return buf;
}
diff = (diff + 29) / 60;
if (diff <= 96) {
- (void) sprintf(buf, "%dh", diff);
+ (void) sprintf(buf, "%ldh", (long int)diff);
return buf;
}
diff = (diff + 11) / 24;
- (void) sprintf(buf, "%dd", diff);
+ (void) sprintf(buf, "%ldd", (long int)diff);
return buf;
}
@@ -1264,14 +1264,14 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
int i;
int c;
- U_LONG srcadr;
- U_LONG dstadr;
- U_LONG srcport;
+ u_long srcadr;
+ u_long dstadr;
+ u_long srcport;
char *dstadr_refid = "0.0.0.0";
- U_LONG stratum;
- LONG ppoll;
- LONG hpoll;
- U_LONG reach;
+ u_long stratum;
+ long ppoll;
+ long hpoll;
+ u_long reach;
l_fp estdelay;
l_fp estoffset;
l_fp estdisp;
@@ -1279,7 +1279,8 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
l_fp reftime;
l_fp ts;
u_char havevar[MAXHAVE];
- U_LONG poll;
+ u_long poll;
+ char type = '?';
char refid_string[10];
extern struct ctl_var peer_var[];
@@ -1287,6 +1288,7 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
gettstamp(&ts);
while (nextvar(&datalen, &data, &name, &value)) {
+ u_long dummy;
i = findvar(name, peer_var);
if (i == 0)
continue; /* don't know this one */
@@ -1296,6 +1298,14 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
havevar[HAVE_SRCADR] = 1;
break;
case CP_DSTADR:
+ if (decodenetnum(value, &dummy)) {
+ dummy = ntohl(dummy);
+ type = ((dummy&0xf0000000)==0xe0000000) ? 'm' :
+ ((dummy&0x000000ff)==0x000000ff) ? 'b' :
+ ((dummy&0xffffffff)==0x7f000001) ? 'l' :
+ ((dummy&0xffffffe0)==0x00000000) ? '-' :
+ 'u';
+ }
if (pvl == opeervarlist) {
if (decodenetnum(value, &dstadr)) {
havevar[HAVE_DSTADR] = 1;
@@ -1370,7 +1380,7 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
case CP_REFTIME:
havevar[HAVE_REFTIME] = 1;
if (!decodets(value, &reftime))
- reftime.l_ui = reftime.l_uf = 0;
+ L_CLR(&reftime);
break;
default:
break;
@@ -1408,11 +1418,10 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
if (numhosts > 1)
(void) fprintf(fp, "%-*s ", maxhostlen, currenthost);
(void) fprintf(fp,
- "%c%-15.15s %-15.15s %2d %4.4s %4d %3o %7.7s %7.7s %7.7s\n",
- c, nntohost(srcadr), dstadr_refid, stratum,
- when(&ts, &rec, &reftime),
- poll, reach, fixup(7, lfptoms(&estdelay, 2)),
- fixup(7, lfptoms(&estoffset, 2)),
+ "%c%-15.15s %-15.15s %2ld %c %4.4s %4ld %3lo %7.7s %8.7s %7.7s\n",
+ c, nntohost(srcadr), dstadr_refid, stratum, type,
+ when(&ts, &rec, &reftime), poll, reach,
+ fixup(7, lfptoms(&estdelay, 2)), fixup(8, lfptoms(&estoffset, 3)),
fixup(7, lfptoms(&estdisp, 2)));
return 1;
}
@@ -1484,7 +1493,7 @@ dopeers(showall, fp)
{
register int i;
char fullname[LENHOSTNAME];
- U_LONG netnum;
+ u_long netnum;
if (!dogetassoc(fp))
@@ -1498,12 +1507,12 @@ dopeers(showall, fp)
if (numhosts > 1)
(void) fprintf(fp, "%-*.*s ", maxhostlen, maxhostlen, "host");
(void) fprintf(fp,
-" remote refid st when poll reach delay offset disp\n");
+" remote refid st t when poll reach delay offset disp\n");
if (numhosts > 1)
for (i = 0; i <= maxhostlen; ++i)
(void) fprintf(fp, "=");
(void) fprintf(fp,
-"===========================================================================\n");
+"==============================================================================\n");
for (i = 0; i < numassoc; i++) {
if (!showall &&
@@ -1558,9 +1567,9 @@ doopeers(showall, fp)
return;
(void) fprintf(fp,
-" remote local st when poll reach delay offset disp\n");
+" remote local st t when poll reach delay offset disp\n");
(void) fprintf(fp,
-"=========================================================================\n");
+"===========================================================================\n");
for (i = 0; i < numassoc; i++) {
if (!showall &&
diff --git a/usr.sbin/xntpd/ntptrace/Makefile.tmpl b/usr.sbin/xntpd/ntptrace/Makefile.tmpl
index c98482da06ec..ca321f13931d 100644
--- a/usr.sbin/xntpd/ntptrace/Makefile.tmpl
+++ b/usr.sbin/xntpd/ntptrace/Makefile.tmpl
@@ -1,5 +1,5 @@
#
-# Makefile.tmpl,v 3.1 1993/07/06 01:09:37 jbj Exp
+# Makefile.tmpl
#
PROGRAM= ntptrace
#
diff --git a/usr.sbin/xntpd/ntptrace/ntptrace.c b/usr.sbin/xntpd/ntptrace/ntptrace.c
index 6454ec1df1f4..b4c5c57138af 100644
--- a/usr.sbin/xntpd/ntptrace/ntptrace.c
+++ b/usr.sbin/xntpd/ntptrace/ntptrace.c
@@ -1,4 +1,4 @@
-/* ntptrace.c,v 3.1 1993/07/06 01:09:38 jbj Exp
+/*
* ntptrace - show the chain from an NTP host leading back to
* its source of time
*
@@ -56,7 +56,7 @@ char *progname;
* Systemwide parameters and flags
*/
int sys_retries = 5; /* # of retry attempts per server */
-U_LONG sys_timeout = 2; /* timeout time, in seconds */
+int sys_timeout = 2; /* timeout time, in seconds */
struct server **sys_servers; /* the server list */
int sys_numservers = 0; /* number of servers to poll */
int sys_maxservers = NTP_MAXSTRATUM+1; /* max number of servers to deal with */
@@ -68,7 +68,7 @@ int sys_version = NTP_OLDVERSION; /* version to poll with */
struct recvbuf *freelist; /* free buffers */
struct recvbuf *fulllist; /* buffers with data */
-int full_recvbufs; /* number of full ones */
+int full_recvbufs; /* number of full ones */
int free_recvbufs;
/*
@@ -94,8 +94,8 @@ static struct server *addservbyname P((char *));
static void setup_io P((void));
static void freerecvbuf P((struct recvbuf *));
static void sendpkt P((struct sockaddr_in *, struct pkt *, int));
-static int getipaddr P((char *, U_LONG *));
-static int decodeipaddr P((char *, U_LONG *));
+static int getipaddr P((char *, long *));
+static int decodeipaddr P((char *, long *));
static void printserver P((struct server *, FILE *));
static void printrefid P((FILE *, struct server *));
@@ -253,9 +253,9 @@ register struct server *server;
xpkt.rootdelay = htonl(NTPTRACE_DISTANCE);
xpkt.rootdispersion = htonl(NTPTRACE_DISP);
xpkt.refid = htonl(NTPTRACE_REFID);
- xpkt.reftime.l_ui = xpkt.reftime.l_uf = 0;
- xpkt.org.l_ui = xpkt.org.l_uf = 0;
- xpkt.rec.l_ui = xpkt.rec.l_uf = 0;
+ L_CLR(&xpkt.reftime);
+ L_CLR(&xpkt.org);
+ L_CLR(&xpkt.rec);
/*
* just timestamp packet and send it away.
@@ -351,8 +351,7 @@ ReceiveBuf(server, rbufp)
{
register struct pkt *rpkt;
register s_fp di;
- register U_LONG t10_ui, t10_uf;
- register U_LONG t23_ui, t23_uf;
+ l_fp t10, t23;
l_fp org;
l_fp rec;
l_fp ci;
@@ -431,7 +430,7 @@ ReceiveBuf(server, rbufp)
* Make sure the server is at least somewhat sane. If not, try
* again.
*/
- if ((rec.l_ui == 0 && rec.l_uf == 0) || !L_ISHIS(&server->org, &rec)) {
+ if (L_ISZERO(&rec) || !L_ISHIS(&server->org, &rec)) {
return(0);
}
@@ -442,27 +441,23 @@ ReceiveBuf(server, rbufp)
* d = (t2 - t3) - (t1 - t0)
* c = ((t2 - t3) + (t1 - t0)) / 2
*/
- t10_ui = server->org.l_ui; /* pkt.xmt == t1 */
- t10_uf = server->org.l_uf;
- M_SUB(t10_ui, t10_uf, rbufp->recv_time.l_ui,
- rbufp->recv_time.l_uf); /* recv_time == t0*/
+ t10 = server->org; /* pkt.xmt == t1 */
+ L_SUB(&t10, &rbufp->recv_time); /* recv_time == t0*/
- t23_ui = rec.l_ui; /* pkt.rec == t2 */
- t23_uf = rec.l_uf;
- M_SUB(t23_ui, t23_uf, org.l_ui, org.l_uf); /* pkt->org == t3 */
+ t23 = rec; /* pkt.rec == t2 */
+ L_SUB(&t23, &org); /* pkt->org == t3 */
/* now have (t2 - t3) and (t0 - t1). Calculate (ci) and (di) */
- ci.l_ui = t10_ui;
- ci.l_uf = t10_uf;
- M_ADD(ci.l_ui, ci.l_uf, t23_ui, t23_uf);
- M_RSHIFT(ci.l_i, ci.l_uf);
+ ci = t10;
+ L_ADD(&ci, &t23);
+ L_RSHIFT(&ci);
/*
* Calculate di in t23 in full precision, then truncate
* to an s_fp.
*/
- M_SUB(t23_ui, t23_uf, t10_ui, t10_uf);
- di = MFPTOFP(t23_ui, t23_uf);
+ L_SUB(&t23, &t10);
+ di = LFPTOFP(&t23);
server->offset = ci;
server->delay = di;
@@ -520,7 +515,7 @@ static struct server *
addservbyname(serv)
char *serv;
{
- U_LONG ipaddr;
+ long ipaddr;
struct in_addr ia;
if (!getipaddr(serv, &ipaddr)) {
@@ -609,14 +604,14 @@ sendpkt(dest, pkt, len)
static int
getipaddr(host, num)
char *host;
- U_LONG *num;
+ long *num;
{
struct hostent *hp;
if (decodeipaddr(host, num)) {
return 1;
} else if ((hp = gethostbyname(host)) != 0) {
- memmove((char *)num, hp->h_addr, sizeof(U_LONG));
+ memmove((char *)num, hp->h_addr, sizeof(long));
return 1;
}
return 0;
@@ -628,7 +623,7 @@ getipaddr(host, num)
static int
decodeipaddr(num, ipaddr)
char *num;
- U_LONG *ipaddr;
+ long *ipaddr;
{
register char *cp;
register char *bp;
@@ -682,8 +677,8 @@ printserver(pp, fp)
if (!verbose) {
(void) fprintf(fp, "stratum %d, offset %s, synch distance %s",
pp->stratum,
- lfptoa(&pp->offset, 7),
- ufptoa(synchdist, 7));
+ lfptoa(&pp->offset, 6),
+ ufptoa(synchdist, 5));
if (pp->stratum == 1) {
(void) fprintf(fp, ", refid ");
printrefid(fp, pp);
@@ -705,14 +700,14 @@ printserver(pp, fp)
(void) fprintf(fp,
" delay %s, dispersion %s ",
- fptoa(pp->delay, 7),
- ufptoa(pp->dispersion, 4));
+ fptoa(pp->delay, 5),
+ ufptoa(pp->dispersion, 5));
(void) fprintf(fp, "offset %s\n",
- lfptoa(&pp->offset, 7));
+ lfptoa(&pp->offset, 6));
(void) fprintf(fp, "rootdelay %s, rootdispersion %s",
- fptoa(pp->rootdelay, 7), ufptoa(pp->rootdispersion, 4));
+ fptoa(pp->rootdelay, 5), ufptoa(pp->rootdispersion, 5));
(void) fprintf(fp, ", synch dist %s\n",
- ufptoa(synchdist, 7));
+ ufptoa(synchdist, 5));
(void) fprintf(fp, "reference time: %s\n",
prettydate(&pp->reftime));
diff --git a/usr.sbin/xntpd/ntptrace/ntptrace.h b/usr.sbin/xntpd/ntptrace/ntptrace.h
index 3367c226a89d..65b72fb71c66 100644
--- a/usr.sbin/xntpd/ntptrace/ntptrace.h
+++ b/usr.sbin/xntpd/ntptrace/ntptrace.h
@@ -1,4 +1,4 @@
-/* ntptrace.h,v 3.1 1993/07/06 01:09:39 jbj Exp
+/*
* ntptrace.h - declarations for the ntptrace program
*/
diff --git a/usr.sbin/xntpd/parse/Makefile.kernel b/usr.sbin/xntpd/parse/Makefile.kernel
index aceb0a5bb639..4cd0acede737 100644
--- a/usr.sbin/xntpd/parse/Makefile.kernel
+++ b/usr.sbin/xntpd/parse/Makefile.kernel
@@ -2,7 +2,7 @@
# very simple makefile (SunOS!)
#
# Possible defines:
-# DEBUG_DCF: include debug code (STREAMS mechanism and parsing)
+# DEBUG_PARSE: include debug code (STREAMS mechanism and parsing)
# DEBUG_CD: include signal propagation to sun4c LED (sun4c only)
#
# Possible defines (parsestreams variants only):
@@ -30,19 +30,19 @@ parse: parsesolaris.c libparse_kernel.a ../lib/libntp.a
ld -r -o parse parsesolaris.o libparse_kernel.a ../lib/libntp.a
@echo "--- Install 'parse' in /kernel/strmod for automatic loading"
-mparsestreams.o: mparsestreams.o.$(KARCH)
- @echo "--- You may load mparsestreams.o.$(KARCH) via 'modload mparsestreams.o.$(KARCH)' into the kernel"
+mparsestreams.o: mparsestreams.$(KARCH).o
+ @echo "--- You may load mparsestreams.$(KARCH).o via 'modload mparsestreams.$(KARCH).o' into the kernel"
-mparsestreams.o.$(KARCH): parsestreams.c microtime.o ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h
+mparsestreams.$(KARCH).o: parsestreams.c microtime.o ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h
cc -c -DMICROTIME $(DEFS) -I../include parsestreams.c
ld -r -o $@ parsestreams.o ../lib/libntp.a libparse_kernel.a \
microtime.o
rm -f parsestreams.o
-parsestreams.o: parsestreams.o.$(KARCH)
- @echo "--- You may load parsestreams.o.$(KARCH) via 'modload parsestreams.o' (put in e.g. /sys/<karch>/OBJ) into the kernel"
+parsestreams.o: parsestreams.$(KARCH).o
+ @echo "--- You may load parsestreams.$(KARCH).o via 'modload parsestreams.o' (put in e.g. /sys/<karch>/OBJ) into the kernel"
-parsestreams.o.$(KARCH): parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h
+parsestreams.$(KARCH).o: parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h
cc -c $(DEFS) -I../include parsestreams.c
ld -r -o $@ parsestreams.o ../lib/libntp.a libparse_kernel.a
rm -f parsestreams.o
diff --git a/usr.sbin/xntpd/parse/Makefile.tmpl b/usr.sbin/xntpd/parse/Makefile.tmpl
index 29a3029eb147..781fed69e5d1 100644
--- a/usr.sbin/xntpd/parse/Makefile.tmpl
+++ b/usr.sbin/xntpd/parse/Makefile.tmpl
@@ -22,10 +22,10 @@ CFLAGS= $(COPTS) $(DEFS) $(DEFS_LOCAL) $(INCL)
CC= $(COMPILER)
#
SOURCE= parse.c parse_conf.c clk_meinberg.c clk_schmid.c clk_rawdcf.c \
- clk_dcf7000.c clk_trimble.c
+ clk_dcf7000.c clk_trimtaip.c clk_trimtsip.c
OBJS= parse.o parse_conf.o clk_meinberg.o clk_schmid.o clk_rawdcf.o \
- clk_dcf7000.o clk_trimble.o
+ clk_dcf7000.o clk_trimtaip.o clk_trimtsip.o
all:
@echo $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) | \
diff --git a/usr.sbin/xntpd/parse/README.new_clocks b/usr.sbin/xntpd/parse/README.new_clocks
index 8fdd7cbd4250..5b2d29e67816 100644
--- a/usr.sbin/xntpd/parse/README.new_clocks
+++ b/usr.sbin/xntpd/parse/README.new_clocks
@@ -15,16 +15,16 @@ Make a conversion module (parse/clk_*.c)
You will have to convert the data from a string into a struct clocktime:
struct clocktime /* clock time broken up from time code */
{
- LONG day;
- LONG month;
- LONG year;
- LONG hour;
- LONG minute;
- LONG second;
- LONG usecond;
- LONG utcoffset; /* in seconds */
+ long day;
+ long month;
+ long year;
+ long hour;
+ long minute;
+ long second;
+ long usecond;
+ long utcoffset; /* in seconds */
time_t utcoffset; /* true utc time instead of date/time */
- LONG flags; /* current clock status */
+ long flags; /* current clock status */
};
Conversion is usually simple and straight forward. For the flags following
@@ -87,14 +87,14 @@ Make a conversion module (parse/clk_*.c)
struct clockformat
{
- unsigned LONG (*convert)();
+ u_long (*convert)();
/* conversion routine - your routine - cvt_<yourclock> */
void (*syncevt)();
/* routine for handling RS232 sync events (time stamps) - usually sync_simple */
- unsigned LONG (*syncpps)();
+ u_long (*syncpps)();
/* PPS input routine - usually pps_simple */
- unsigned LONG (*synth)();
- /* time code synthesizer - usually not used - (LONG (*)())0 */
+ u_long (*synth)();
+ /* time code synthesizer - usually not used - (long (*)())0 */
void *data;
/* local parameters - any parameters/data/configuration info your conversion
routine might need */
@@ -102,7 +102,7 @@ struct clockformat
/* clock format name - Name of the time code */
unsigned short length;
/* maximum length of data packet for your clock format */
- unsigned LONG flags;
+ u_long flags;
/* information for the parser what to look for */
struct timeval timeout;
/* buffer restart after timeout (us) - some clocks preceede new data by
@@ -148,7 +148,7 @@ xntpd/refclock_parse.c
(see all the other clocks for example)
struct clockinfo
{
- U_LONG cl_flags; /* operation flags (io modes) */
+ u_long cl_flags; /* operation flags (io modes) */
PARSE_F_NOPOLLONLY always do async io - read whenever input comes
PARSE_F_POLLONLY never do async io - only read when expecting data
PARSE_F_PPSPPS use loopfilter PPS code (CIOGETEV)
@@ -166,10 +166,10 @@ xntpd/refclock_parse.c
local data for polling routines
u_fp cl_rootdelay; /* rootdelay */
NTP rottdelay estimate (usually 0)
- U_LONG cl_basedelay; /* current offset - unsigned l_fp fractional par
+ u_long cl_basedelay; /* current offset - unsigned l_fp fractional par
time (fraction) by which the RS232 time code is delayed from the actual time.
t */
- U_LONG cl_ppsdelay; /* current PPS offset - unsigned l_fp fractional
+ u_long cl_ppsdelay; /* current PPS offset - unsigned l_fp fractional
time (fraction) by which the PPS time stamp is delayed (usually 0)
part */
char *cl_id; /* ID code (usually "DCF") */
@@ -181,14 +181,14 @@ xntpd/refclock_parse.c
as in clk_*.c clockformat.
u_char cl_type; /* clock type (ntp control) */
Type if clock as in clock status word (ntp control messages) - usually 0
- U_LONG cl_maxunsync; /* time to trust oscillator after loosing synch
+ u_long cl_maxunsync; /* time to trust oscillator after loosing synch
*/
seconds a clock can be trusted after loosing synchronisation.
- U_LONG cl_cflag; /* terminal io flags */
- U_LONG cl_iflag; /* terminal io flags */
- U_LONG cl_oflag; /* terminal io flags */
- U_LONG cl_lflag; /* terminal io flags */
+ u_long cl_cflag; /* terminal io flags */
+ u_long cl_iflag; /* terminal io flags */
+ u_long cl_oflag; /* terminal io flags */
+ u_long cl_lflag; /* terminal io flags */
termio*.h tty modes.
} clockinfo[] = {
...,<other clocks>,...
diff --git a/usr.sbin/xntpd/parse/clk_dcf7000.c b/usr.sbin/xntpd/parse/clk_dcf7000.c
index 8b55e2f23280..208e52932ae0 100644
--- a/usr.sbin/xntpd/parse/clk_dcf7000.c
+++ b/usr.sbin/xntpd/parse/clk_dcf7000.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_DCF7000)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_dcf7000.c,v 3.11 1994/02/02 17:45:14 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_dcf7000.c,v 3.12 1994/05/30 10:19:57 kardel Exp
*
- * clk_dcf7000.c,v 3.11 1994/02/02 17:45:14 kardel Exp
+ * clk_dcf7000.c,v 3.12 1994/05/30 10:19:57 kardel Exp
*
* ELV DCF7000 module
*
@@ -35,18 +35,20 @@ static struct format dcf7000_fmt =
0
};
-static unsigned LONG cvt_dcf7000();
+static u_long cvt_dcf7000();
clockformat_t clock_dcf7000 =
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_dcf7000, /* ELV DCF77 conversion */
syn_simple, /* easy time stamps */
- (unsigned LONG (*)())0, /* no direct PPS monitoring */
- (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (u_long (*)())0, /* no direct PPS monitoring */
+ (u_long (*)())0, /* no time code synthesizer monitoring */
(void *)&dcf7000_fmt, /* conversion configuration */
"ELV DCF7000", /* ELV clock */
24, /* string buffer */
F_END|SYNC_END, /* END packet delimiter / synchronisation */
+ 0, /* no private data (complete pakets) */
{ 0, 0},
'\0',
'\r',
@@ -58,7 +60,7 @@ clockformat_t clock_dcf7000 =
*
* convert dcf7000 type format
*/
-static unsigned LONG
+static u_long
cvt_dcf7000(buffer, size, format, clock)
register char *buffer;
register int size;
@@ -89,7 +91,7 @@ cvt_dcf7000(buffer, size, format, clock)
else
{
char *f = &buffer[format->field_offsets[O_FLAGS].offset];
- LONG flags;
+ long flags;
clock->flags = 0;
clock->usecond = 0;
@@ -121,6 +123,9 @@ cvt_dcf7000(buffer, size, format, clock)
* History:
*
* clk_dcf7000.c,v
+ * Revision 3.12 1994/05/30 10:19:57 kardel
+ * LONG cleanup
+ *
* Revision 3.11 1994/02/02 17:45:14 kardel
* rcs ids fixed
*
diff --git a/usr.sbin/xntpd/parse/clk_meinberg.c b/usr.sbin/xntpd/parse/clk_meinberg.c
index 69f88b90d30e..6e3b22453bc9 100644
--- a/usr.sbin/xntpd/parse/clk_meinberg.c
+++ b/usr.sbin/xntpd/parse/clk_meinberg.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_MEINBERG)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.14 1994/02/20 13:04:37 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.15 1994/05/30 10:19:59 kardel Exp
*
- * clk_meinberg.c,v 3.14 1994/02/20 13:04:37 kardel Exp
+ * clk_meinberg.c,v 3.15 1994/05/30 10:19:59 kardel Exp
*
* Meinberg clock support
*
@@ -136,48 +136,54 @@ static struct format meinberg_fmt[] =
}
};
-static unsigned LONG cvt_meinberg();
-static unsigned LONG cvt_mgps();
+static u_long cvt_meinberg();
+static u_long cvt_mgps();
clockformat_t clock_meinberg[] =
{
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_meinberg, /* Meinberg conversion */
syn_simple, /* easy time stamps for RS232 (fallback) */
pps_simple, /* easy PPS monitoring */
- (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (u_long (*)())0, /* no time code synthesizer monitoring */
(void *)&meinberg_fmt[0], /* conversion configuration */
"Meinberg Standard", /* Meinberg simple format - beware */
32, /* string buffer */
F_START|F_END|SYNC_START|SYNC_ONE, /* paket START/END delimiter, START synchronisation, PPS ONE sampling */
+ 0, /* no private data (complete pakets) */
{ 0, 0},
'\2',
'\3',
'\0'
},
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_meinberg, /* Meinberg conversion */
syn_simple, /* easy time stamps for RS232 (fallback) */
pps_simple, /* easy PPS monitoring */
- (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (u_long (*)())0, /* no time code synthesizer monitoring */
(void *)&meinberg_fmt[1], /* conversion configuration */
"Meinberg Extended", /* Meinberg enhanced format */
32, /* string buffer */
F_START|F_END|SYNC_START|SYNC_ONE, /* paket START/END delimiter, START synchronisation, PPS ONE sampling */
+ 0, /* no private data (complete pakets) */
{ 0, 0},
'\2',
'\3',
'\0'
},
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_mgps, /* Meinberg GPS166 conversion */
syn_simple, /* easy time stamps for RS232 (fallback) */
pps_simple, /* easy PPS monitoring */
- (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (u_long (*)())0, /* no time code synthesizer monitoring */
(void *)&meinberg_fmt[2], /* conversion configuration */
"Meinberg GPS Extended", /* Meinberg FAU GPS format */
70, /* string buffer */
F_START|F_END|SYNC_START|SYNC_ONE, /* paket START/END delimiter, START synchronisation, PPS ONE sampling */
+ 0, /* no private data (complete pakets) */
{ 0, 0},
'\2',
'\3',
@@ -190,7 +196,7 @@ clockformat_t clock_meinberg[] =
*
* convert simple type format
*/
-static unsigned LONG
+static u_long
cvt_meinberg(buffer, size, format, clock)
register char *buffer;
register int size;
@@ -305,7 +311,7 @@ cvt_meinberg(buffer, size, format, clock)
*
* convert Meinberg GPS format
*/
-static unsigned LONG
+static u_long
cvt_mgps(buffer, size, format, clock)
register char *buffer;
register int size;
@@ -335,7 +341,7 @@ cvt_mgps(buffer, size, format, clock)
}
else
{
- LONG h;
+ long h;
char *f = &buffer[format->field_offsets[O_FLAGS].offset];
clock->flags = PARSEB_S_LEAP|PARSEB_S_POSITION;
@@ -422,6 +428,9 @@ cvt_mgps(buffer, size, format, clock)
* History:
*
* clk_meinberg.c,v
+ * Revision 3.15 1994/05/30 10:19:59 kardel
+ * LONG cleanup
+ *
* Revision 3.14 1994/02/20 13:04:37 kardel
* parse add/delete second support
*
diff --git a/usr.sbin/xntpd/parse/clk_rawdcf.c b/usr.sbin/xntpd/parse/clk_rawdcf.c
index 6b02031b6394..296af9e22b02 100644
--- a/usr.sbin/xntpd/parse/clk_rawdcf.c
+++ b/usr.sbin/xntpd/parse/clk_rawdcf.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RAWDCF)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.13 1994/03/10 19:00:43 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.16 1994/05/31 20:02:40 kardel Exp
*
- * clk_rawdcf.c,v 3.13 1994/03/10 19:00:43 kardel Exp
+ * clk_rawdcf.c,v 3.16 1994/05/31 20:02:40 kardel Exp
*
* Raw DCF77 pulse clock support
*
@@ -79,12 +79,13 @@
* 59 - usually missing (minute indication), except for leap insertion
*/
-static unsigned LONG cvt_rawdcf();
-static unsigned LONG pps_rawdcf();
-static unsigned LONG snt_rawdcf();
+static u_long cvt_rawdcf();
+static u_long pps_rawdcf();
+static u_long snt_rawdcf();
clockformat_t clock_rawdcf =
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_rawdcf, /* raw dcf input conversion */
(void (*)())0, /* no character bound synchronisation */
pps_rawdcf, /* examining PPS information */
@@ -94,6 +95,7 @@ clockformat_t clock_rawdcf =
61, /* bit buffer */
SYNC_ONE|SYNC_ZERO|SYNC_TIMEOUT|SYNC_SYNTHESIZE|CVT_FIXEDONLY,
/* catch all transitions, buffer restart on timeout, fixed configuration only */
+ 0, /* no private data (currently in input buffer) */
{ 1, 500000}, /* restart after 1.5 seconds */
'\0',
'\0',
@@ -155,12 +157,12 @@ static struct partab
#define DCF_Z_MET 0x2
#define DCF_Z_MED 0x1
-static unsigned LONG ext_bf(buf, idx, zero)
+static u_long ext_bf(buf, idx, zero)
register char *buf;
register int idx;
register char *zero;
{
- register unsigned LONG sum = 0;
+ register u_long sum = 0;
register int i, first;
first = rawdcfcode[idx].offset;
@@ -189,7 +191,7 @@ static unsigned pcheck(buf, idx, zero)
return psum;
}
-static unsigned LONG convert_rawdcf(buffer, size, dcfparam, clock)
+static u_long convert_rawdcf(buffer, size, dcfparam, clock)
register unsigned char *buffer;
register int size;
register struct dcfparam *dcfparam;
@@ -284,9 +286,9 @@ static unsigned LONG convert_rawdcf(buffer, size, dcfparam, clock)
if (ext_bf(buffer, DCF_R, dcfparam->zerobits))
clock->flags |= PARSEB_ALTERNATE;
- parseprintf(DD_RAWDCF,("parse: convert_rawdcf: TIME CODE OK: %d:%d, %d.%d.%d, flags 0x%x\n",
- clock->hour, clock->minute, clock->day, clock->month, clock->year,
- clock->flags));
+ parseprintf(DD_RAWDCF,("parse: convert_rawdcf: TIME CODE OK: %d:%d, %d.%d.%d, flags 0x%lx\n",
+ (int)clock->hour, (int)clock->minute, (int)clock->day, (int)clock->month,(int) clock->year,
+ (u_long)clock->flags));
return CVT_OK;
}
else
@@ -307,7 +309,7 @@ static unsigned LONG convert_rawdcf(buffer, size, dcfparam, clock)
* raw dcf input routine - needs to fix up 50 baud
* characters for 1/0 decision
*/
-static unsigned LONG cvt_rawdcf(buffer, size, param, clock)
+static u_long cvt_rawdcf(buffer, size, param, clock)
register unsigned char *buffer;
register int size;
register void *param;
@@ -465,12 +467,12 @@ static unsigned LONG cvt_rawdcf(buffer, size, param, clock)
* also ones and zeros (which is easy)
*/
/*ARGSUSED*/
-static unsigned LONG pps_rawdcf(parseio, status, ptime)
+static u_long pps_rawdcf(parseio, status, ptime)
register parse_t *parseio;
register int status;
register timestamp_t *ptime;
{
- if (!status)
+ if (status)
{
parseio->parse_dtime.parse_ptime = *ptime;
parseio->parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
@@ -480,12 +482,12 @@ static unsigned LONG pps_rawdcf(parseio, status, ptime)
}
/*ARGSUSED*/
-static unsigned LONG snt_rawdcf(parseio, ptime)
+static u_long snt_rawdcf(parseio, ptime)
register parse_t *parseio;
register timestamp_t *ptime;
{
clocktime_t clock;
- unsigned LONG cvtrtc;
+ u_long cvtrtc;
time_t t;
/*
@@ -529,7 +531,16 @@ static unsigned LONG snt_rawdcf(parseio, ptime)
/*
* History:
*
- * clk_rawdcf.c,v
+ * clk_rawdcf.c,v $
+ * Revision 3.16 1994/05/31 20:02:40 kardel
+ * sync on ONE transition
+ *
+ * Revision 3.15 1994/05/30 10:20:01 kardel
+ * LONG cleanup
+ *
+ * Revision 3.14 1994/05/12 12:49:09 kardel
+ * printf fmt/arg cleanup
+ *
* Revision 3.13 1994/03/10 19:00:43 kardel
* clear utctime field to avoid confusion on synthesize time stamps
*
diff --git a/usr.sbin/xntpd/parse/clk_schmid.c b/usr.sbin/xntpd/parse/clk_schmid.c
index 8129474782bb..d15ba908da55 100644
--- a/usr.sbin/xntpd/parse/clk_schmid.c
+++ b/usr.sbin/xntpd/parse/clk_schmid.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_SCHMID)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.13 1994/02/20 13:04:41 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.16 1994/05/30 10:20:03 kardel Exp
*
- * clk_schmid.c,v 3.13 1994/02/20 13:04:41 kardel Exp
+ * clk_schmid.c,v 3.16 1994/05/30 10:20:03 kardel Exp
*
* Schmid clock support
*
@@ -58,18 +58,20 @@
#define WS_MEST 0x04
#define WS_LEAP 0x10
-static unsigned LONG cvt_schmid();
+static u_long cvt_schmid();
clockformat_t clock_schmid =
{
+ (unsigned LONG (*)())0, /* no input handling */
cvt_schmid, /* Schmid conversion */
syn_simple, /* easy time stamps */
- (unsigned LONG (*)())0, /* not direct PPS monitoring */
- (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (u_long (*)())0, /* not direct PPS monitoring */
+ (u_long (*)())0, /* no time code synthesizer monitoring */
(void *)0, /* conversion configuration */
"Schmid", /* Schmid receiver */
12, /* binary data buffer */
F_END|SYNC_START, /* END packet delimiter / synchronisation */
+ 0, /* no private data (complete messages) */
{ 0, 0},
'\0',
(unsigned char)'\375',
@@ -77,21 +79,20 @@ clockformat_t clock_schmid =
};
-static unsigned LONG
+static u_long
cvt_schmid(buffer, size, format, clock)
- register char *buffer;
+ register unsigned char *buffer;
register int size;
register struct format *format;
register clocktime_t *clock;
{
- if ((size != 11) || (buffer[10] != '\375'))
+ if ((size != 11) || (buffer[10] != (unsigned char)'\375'))
{
return CVT_NONE;
}
else
{
- if (buffer[0] > 23 || buffer[1] > 59 || buffer[2] > 59 || buffer[3] > 9 /* Time */
- || buffer[0] < 0 || buffer[1] < 0 || buffer[2] < 0 || buffer[3] < 0)
+ if (buffer[0] > 23 || buffer[1] > 59 || buffer[2] > 59 || buffer[3] > 9) /* Time */
{
return CVT_FAIL|CVT_BADTIME;
}
@@ -168,6 +169,15 @@ cvt_schmid(buffer, size, format, clock)
* History:
*
* clk_schmid.c,v
+ * Revision 3.16 1994/05/30 10:20:03 kardel
+ * LONG cleanup
+ *
+ * Revision 3.15 1994/05/12 12:34:48 kardel
+ * data type cleanup
+ *
+ * Revision 3.14 1994/04/12 14:56:31 kardel
+ * fix declaration
+ *
* Revision 3.13 1994/02/20 13:04:41 kardel
* parse add/delete second support
*
diff --git a/usr.sbin/xntpd/parse/clk_trimtaip.c b/usr.sbin/xntpd/parse/clk_trimtaip.c
new file mode 100644
index 000000000000..87538f1eb8a1
--- /dev/null
+++ b/usr.sbin/xntpd/parse/clk_trimtaip.c
@@ -0,0 +1,140 @@
+#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_TRIMTAIP)
+/*
+ * $Header: /src/NTP/REPOSITORY/v3/parse/clk_trimble.c,v 3.9 1994/02/02 17:45:27 kardel Exp $
+ *
+ * Trimble SV6 clock support
+ */
+
+#include "sys/types.h"
+#include "sys/time.h"
+#include "sys/errno.h"
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
+/* 0000000000111111111122222222223333333 / char
+ * 0123456789012345678901234567890123456 \ posn
+ * >RTMhhmmssdddDDMMYYYYoodnnvrrrrr;*xx< Actual
+ * ----33445566600112222BB7__-_____--99- Parse
+ * >RTM 1 ;* <", Check
+ */
+
+#define hexval(x) (('0' <= (x) && (x) <= '9') ? (x) - '0' : \
+ ('a' <= (x) && (x) <= 'f') ? (x) - 'a' + 10 : \
+ ('A' <= (x) && (x) <= 'F') ? (x) - 'A' + 10 : \
+ -1)
+#define O_USEC O_WDAY
+#define O_GPSFIX O_FLAGS
+#define O_CHKSUM O_UTCHOFFSET
+static struct format trimsv6_fmt =
+{ { { 13, 2 }, {15, 2}, { 17, 4}, /* Day, Month, Year */
+ { 4, 2 }, { 6, 2}, { 8, 2}, /* Hour, Minute, Second */
+ { 10, 3 }, {23, 1}, { 0, 0}, /* uSec, FIXes (WeekDAY, FLAGS, ZONE) */
+ { 34, 2 }, { 0, 0}, { 21, 2}, /* cksum, -, utcS (UTC[HMS]OFFSET) */
+ },
+ ">RTM 1 ;* <",
+ 0
+};
+
+static unsigned LONG cvt_trimtaip();
+
+clockformat_t clock_trimtaip =
+{
+ (unsigned LONG (*)())0, /* no input handling */
+ cvt_trimtaip, /* Trimble conversion */
+ syn_simple, /* easy time stamps for RS232 (fallback) */
+ pps_simple, /* easy PPS monitoring */
+ (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (void *)&trimsv6_fmt, /* conversion configuration */
+ "Trimble SV6/TAIP",
+ 37, /* string buffer */
+ F_START|F_END|SYNC_START|SYNC_ONE, /* paket START/END delimiter, START synchronisation, PPS ONE sampling */
+ 0, /* no private data */
+ { 0, 0},
+ '>',
+ '<',
+ '\0'
+};
+
+static unsigned LONG
+cvt_trimtaip(buffer, size, format, clock)
+ register char *buffer;
+ register int size;
+ register struct format *format;
+ register clocktime_t *clock;
+{
+ LONG gpsfix;
+ u_char calc_csum = 0;
+ long recv_csum;
+ int i;
+
+ if (!Strok(buffer, format->fixed_string)) return CVT_NONE;
+#define OFFS(x) format->field_offsets[(x)].offset
+#define STOI(x, y) \
+ Stoi(&buffer[OFFS(x)], y, \
+ format->field_offsets[(x)].length)
+ if ( STOI(O_DAY, &clock->day) ||
+ STOI(O_MONTH, &clock->month) ||
+ STOI(O_YEAR, &clock->year) ||
+ STOI(O_HOUR, &clock->hour) ||
+ STOI(O_MIN, &clock->minute) ||
+ STOI(O_SEC, &clock->second) ||
+ STOI(O_USEC, &clock->usecond)||
+ STOI(O_GPSFIX, &gpsfix)
+ ) return CVT_FAIL|CVT_BADFMT;
+
+ clock->usecond *= 1000;
+ /* Check that the checksum is right */
+ for (i=OFFS(O_CHKSUM)-1; i >= 0; i--) calc_csum ^= buffer[i];
+ recv_csum = (hexval(buffer[OFFS(O_CHKSUM)]) << 4) |
+ hexval(buffer[OFFS(O_CHKSUM)+1]);
+ if (recv_csum < 0) return CVT_FAIL|CVT_BADTIME;
+ if (((u_char) recv_csum) != calc_csum) return CVT_FAIL|CVT_BADTIME;
+
+ clock->utcoffset = 0;
+
+ /* What should flags be set to ? */
+ clock->flags = PARSEB_UTC;
+
+ /* if the current GPS fix is 9 (unknown), reject */
+ if (0 > gpsfix || gpsfix > 9) clock->flags |= PARSEB_POWERUP;
+
+ return CVT_OK;
+}
+#endif /* defined(PARSE) && defined(CLOCK_TRIMTAIP) */
+
+/*
+ * History:
+ *
+ * $Log: clk_trimble.c,v $
+ * Revision 3.9 1994/02/02 17:45:27 kardel
+ * rcs ids fixed
+ *
+ * Revision 3.7 1994/01/25 19:05:17 kardel
+ * 94/01/23 reconcilation
+ *
+ * Revision 3.6 1993/10/30 09:44:45 kardel
+ * conditional compilation flag cleanup
+ *
+ * Revision 3.5 1993/10/09 15:01:35 kardel
+ * file structure unified
+ *
+ * revision 3.4
+ * date: 1993/10/08 14:44:51; author: kardel;
+ * trimble - initial working version
+ *
+ * revision 3.3
+ * date: 1993/10/03 19:10:50; author: kardel;
+ * restructured I/O handling
+ *
+ * revision 3.2
+ * date: 1993/09/27 21:07:17; author: kardel;
+ * Trimble alpha integration
+ *
+ * revision 3.1
+ * date: 1993/09/26 23:40:29; author: kardel;
+ * new parse driver logic
+ *
+ */
diff --git a/usr.sbin/xntpd/parse/clk_trimtsip.c b/usr.sbin/xntpd/parse/clk_trimtsip.c
new file mode 100644
index 000000000000..f622beac08db
--- /dev/null
+++ b/usr.sbin/xntpd/parse/clk_trimtsip.c
@@ -0,0 +1,471 @@
+#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_TRIMTSIP)
+/*
+ * $Header: /src/NTP/REPOSITORY/v3/parse/clk_trimble.c,v 3.9 1994/02/02 17:45:27 kardel Exp $
+ *
+ * Trimble TSIP support - CURRENTLY VERY MUCH UNDER CONSTRUCTION
+ */
+
+#include "sys/types.h"
+#include "sys/time.h"
+#include "sys/errno.h"
+
+#include "ntp_syslog.h"
+#include "ntp_types.h"
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
+/*
+ * Trimble TSIP parser
+ *
+ * The receiver uses a serial message protocol called Trimble Standard
+ * Interface Protocol (it can support others but this driver only supports
+ * TSIP). Messages in this protocol have the following form:
+ *
+ * <DLE><id> ... <data> ... <DLE><ETX>
+ *
+ * Any bytes within the <data> portion of value 10 hex (<DLE>) are doubled
+ * on transmission and compressed back to one on reception. Otherwise
+ * the values of data bytes can be anything. The serial interface is RS-422
+ * asynchronous using 9600 baud, 8 data bits with odd party (**note** 9 bits
+ * in total!), and 1 stop bit. The protocol supports byte, integer, single,
+ * and double datatypes. Integers are two bytes, sent most significant first.
+ * Singles are IEEE754 single precision floating point numbers (4 byte) sent
+ * sign & exponent first. Doubles are IEEE754 double precision floating point
+ * numbers (8 byte) sent sign & exponent first.
+ * The receiver supports a large set of messages, only a small subset of
+ * which are used here. From driver to receiver the following are used:
+ *
+ * ID Description
+ *
+ * 21 Request current time
+ * 22 Mode Select
+ * 2C Set/Request operating parameters
+ * 2F Request UTC info
+ * 35 Set/Request I/O options
+ *
+ * From receiver to driver the following are recognised:
+ *
+ * ID Description
+ *
+ * 41 GPS Time
+ * 44 Satellite selection, PDOP, mode
+ * 46 Receiver health
+ * 4B Machine code/status
+ * 4C Report operating parameters (debug only)
+ * 4F UTC correction data (used to get leap second warnings)
+ * 55 I/O options (debug only)
+ *
+ * All others are accepted but ignored.
+ *
+ */
+
+extern int debug;
+
+struct trimble
+{
+ u_char t_in_pkt; /* first DLE received */
+ u_char t_dle; /* subsequent DLE received */
+ u_char t_status; /* last status */
+ u_char t_error; /* last error */
+ u_short t_week; /* GPS week */
+ u_short t_weekleap; /* GPS week of next/last week */
+ u_short t_dayleap; /* day in week */
+ u_short t_gpsutc; /* GPS - UTC offset */
+ u_short t_gpsutcleap; /* offset at next/last leap */
+ u_char t_operable; /* receiver feels OK */
+ u_char t_leap; /* possible leap warning */
+};
+
+static unsigned LONG inp_tsip();
+static unsigned LONG cvt_trimtsip();
+
+struct clockformat clock_trimtsip =
+{
+ inp_tsip, /* Trimble TSIP input handler */
+ cvt_trimtsip, /* Trimble TSIP conversion */
+ syn_simple, /* easy time stamps for RS232 (fallback) */
+ pps_simple, /* easy PPS monitoring */
+ (unsigned LONG (*)())0, /* no time code synthesizer monitoring */
+ (void *)0, /* no configuration data */
+ "Trimble SV6/TSIP",
+ 128, /* input buffer */
+ CVT_FIXEDONLY, /* we do our own input handling */
+ sizeof(struct trimble), /* no private data */
+ { 0, 0},
+ '\0',
+ '\0',
+ '\0'
+};
+
+#define ADDSECOND 0x01
+#define DELSECOND 0x02
+
+#define DLE 0x10
+#define ETX 0x03
+
+static unsigned LONG inp_tsip(parseio, ch, ctime)
+ register parse_t *parseio;
+ register unsigned char ch;
+ register timestamp_t *ctime;
+{
+ register struct trimble *t = (struct trimble *)parseio->parse_pdata;
+
+ if (!t)
+ return 0; /* local data not allocated - sigh! */
+
+ if (!t->t_in_pkt && ch != DLE) {
+ /* wait for start of packet */
+#ifdef DEBUG
+ if (debug > 2)
+ printf("sv6+ discarding %2.2x\n", ch);
+#endif
+ return 0;
+ }
+
+ switch (ch) {
+ case DLE:
+ if (!t->t_in_pkt) {
+ t->t_dle = 0;
+ t->t_in_pkt = 1;
+ parseio->parse_index = 0;
+ parseio->parse_data[parseio->parse_index++] = ch;
+ parseio->parse_dtime.parse_stime = *ctime; /* pick up time stamp at packet start */
+ } else if (t->t_dle) {
+ /* Double DLE -> insert a DLE */
+ t->t_dle = 0;
+ parseio->parse_data[parseio->parse_index++] = DLE;
+ } else
+ t->t_dle = 1;
+ break;
+ case ETX:
+ if (t->t_dle) {
+ /* DLE,ETX -> end of packet */
+ parseio->parse_data[parseio->parse_index++] = DLE;
+ parseio->parse_data[parseio->parse_index++] = ch;
+ parseio->parse_data[parseio->parse_index] = '\0';
+ parseio->parse_ldsize = parseio->parse_index+1;
+ bcopy(parseio->parse_data, parseio->parse_ldata, parseio->parse_ldsize);
+ t->t_in_pkt = t->t_dle = 0;
+ return 1;
+ }
+ /* fall into ... */
+ default:
+ t->t_dle = 0;
+ parseio->parse_data[parseio->parse_index++] = ch;
+ }
+
+ return (parseio->parse_index == parseio->parse_dsize-1); /* buffer full - attempt to parse (likely to fail) */
+}
+
+#define GPSORIGIN 2524953600 /* NTP origin - GPS origin in seconds */
+#define SECSPERWEEK 604800 /* seconds per week - GPS tells us about weeks */
+#define L_UF_SCALE 4294967296.0 /* scale a float fraction to l_uf units */
+
+/*
+ * mapping union for ints, floats, doubles for both input & output to the
+ * receiver
+ *
+ * CAVEAT: must disappear - non portable
+ */
+
+union {
+ u_char bd[8];
+ int iv;
+ float fv;
+ double dv;
+} uval;
+
+static float getflt P((u_char *));
+static double getdbl P((u_char *));
+static int getint P((u_char *));
+
+/*
+ * cvt_trimtsip
+ *
+ * convert TSIP type format
+ */
+static unsigned LONG
+cvt_trimtsip(buffer, size, format, clock, t)
+ register char *buffer;
+ register int size;
+ register struct format *format;
+ register clocktime_t *clock;
+ register struct trimble *t;
+{
+#define mb(_X_) (buffer[2+(_X_)]) /* shortcut for buffer access */
+ register u_char cmd;
+
+ if (!t) {
+#ifdef DEBUG
+ if (debug) printf("sv6+ BAD call (t=0)\n");
+#endif
+ return CVT_NONE; /* local data not allocated - sigh! */
+ }
+
+ if ((size < 4) ||
+ (buffer[0] != DLE) ||
+ (buffer[size-1] != ETX) ||
+ (buffer[size-2] != DLE))
+ {
+#ifdef DEBUG
+ if (debug > 2) {
+ int i;
+
+ printf("sv6+ BAD packet, size %d:\n ", size);
+ for (i = 0; i < size; i++) {
+ printf ("%2.2x, ", buffer[i]&0xff);
+ if (i%16 == 15) printf("\n\t");
+ }
+ printf("\n");
+ }
+#endif
+ return CVT_NONE;
+ }
+ else
+ {
+ cmd = buffer[1];
+
+#ifdef DEBUG
+ if (debug > 1)
+ switch(cmd)
+ {
+ case 0x41:
+ printf("sv6+ gps time: %f, %d, %f\n",
+ getflt(&mb(0)), getint(&mb(4)), getflt(&mb(6)));
+ break;
+
+ case 0x44:
+ printf("sv6+ sats: %2x, %2d %2d %2d %2d, %.2f\n",
+ mb(0), mb(1), mb(2), mb(3), mb(4), getflt(&mb(5)));
+ break;
+
+ case 0x45:
+ printf("sv6+ software: %d.%d (19%d/%d/%d)\n",
+ mb(0)&0xff, mb(1)&0xff, mb(4)&0xff, mb(2)&0xff, mb(3)&0xff);
+ break;
+
+ case 0x46:
+ printf("sv6+ health: %2x %2x\n",
+ mb(0), mb(1));
+ break;
+
+ case 0x48:
+ printf("sv6+ gps message: '%.22s'\n", &mb(0));
+ break;
+
+ case 0x4b:
+ printf("sv6+ status: %2d %2x\n",
+ mb(0), mb(1));
+ break;
+
+ case 0x4c:
+ printf("sv6+ op params: %2x %.1f %.1f %.1f %.1f\n",
+ mb(0), getflt(&mb(1)), getflt(&mb(5)),
+ getflt(&mb(9)), getflt(&mb(13)));
+ break;
+
+ case 0x4f:
+ printf("sv6+ utc data: %.3e %.3e %d %d %d %d %d\n",
+ getdbl(&mb(0)), getflt(&mb(8)), getint(&mb(18)),
+ getint(&mb(12)), getint(&mb(20)), getint(&mb(22)), getint(&mb(24)));
+ break;
+
+ case 0x54:
+ /*printf("sv6+ bias and rate: %.1fm %.2fm/s at %.1fs\n",
+ getflt(&mb(0)), getflt(&mb(4)), getflt(&mb(8))); ignore it*/
+ break;
+
+ case 0x55:
+ printf("sv6+ io opts: %2x %2x %2x %2x\n",
+ mb(0), mb(1), mb(2), mb(3));
+ break;
+
+ case 0x8f:
+ {
+#define RTOD (180.0 / 3.1415926535898)
+ double lat = getdbl(&mb(2));
+ double lng = getdbl(&mb(10));
+ printf("sv6+ last fix: %2.2x %d lat %f %c, long %f %c, alt %.2fm\n",
+ mb(1)&0xff, mb(40)&0xff,
+ ((lat < 0) ? (-lat) : (lat))*RTOD, (lat < 0 ? 'S' : 'N'),
+ ((lng < 0) ? (-lng) : (lng))*RTOD, (lng < 0 ? 'W' : 'E'),
+ getdbl(&mb(18)));
+ }
+ break;
+
+ case 0x40:
+ case 0x5b:
+ case 0x6d:
+ /* Ignore */
+ break;
+
+ default:
+ printf("sv6+ cmd ignored: %2x, length: %d\n",
+ cmd, size);
+ break;
+ }
+#endif /* DEBUG */
+
+ switch(cmd)
+ {
+ case 0x41:
+ { /* GPS time */
+ float secs = getflt(&mb(0));
+ int week = getint(&mb(4));
+ int secint;
+ float secfrac;
+ l_fp gpstime, off;
+
+ if (secs <= 0)
+ {
+#ifdef DEBUG
+ if (debug)
+ printf("sv6+ seconds <= 0 (%e), setting POWERUP\n");
+#endif
+ clock->flags = PARSEB_POWERUP;
+ return CVT_OK;
+ }
+
+ /* time OK */
+ secint = secs; /* integer part, hopefully */
+ secfrac = secs - secint; /* 0.0 <= secfrac < 1.0 */
+ secint -= getflt(&mb(6)); /* UTC offset */
+ gpstime.l_ui = week*SECSPERWEEK + secint + GPSORIGIN; /* convert to NTP time */
+ gpstime.l_uf = secfrac*L_UF_SCALE;
+
+ clock->utctime = gpstime.l_ui - JAN_1970;
+ TSFTOTVU(gpstime.l_uf, clock->usecond);
+
+ if (t->t_leap == ADDSECOND)
+ clock->flags |= PARSEB_LEAPADD;
+
+ if (t->t_leap == DELSECOND)
+ clock->flags |= PARSEB_LEAPDEL;
+
+ if (t->t_operable)
+ clock->flags &= ~(PARSEB_NOSYNC|PARSEB_POWERUP);
+ else
+ clock->flags |= PARSEB_NOSYNC;
+ return CVT_OK;
+
+ } /* case 0x41 */
+ break;
+
+ case 0x46:
+ {
+ /* sv6+ health */
+ u_char status = t->t_status = mb(0);
+ u_char error = t->t_error = mb(1);
+
+ if (status == 0 || status == 9 || status == 10 || status == 11)
+ {
+ if (!t->t_operable)
+ syslog(LOG_ERR, "Trimble clock synced");
+ t->t_operable = 1;
+ }
+ else
+ {
+ if (t->t_operable)
+ syslog(LOG_ERR, "Trimble clock unsynced");
+ t->t_operable = 0;
+ }
+ }
+ break;
+
+ case 0x4f:
+ {
+ /* UTC correction data - derive a leap warning */
+ int tls = t->t_gpsutc = getint(&mb(12)); /* current leap correction (GPS-UTC) */
+ int wnlsf = t->t_weekleap = getint(&mb(20)); /* week no of leap correction */
+ int dn = t->t_dayleap = getint(&mb(22)); /* day in week of leap correction */
+ int tlsf = t->t_gpsutcleap = getint(&mb(24)); /* new leap correction */
+ U_LONG now, leaptime;
+
+ t->t_week = getint(&mb(18)); /* current week no */
+
+ /* this stuff hasn't been tested yet... */
+ now = clock->utctime + JAN_1970; /* now in GPS seconds */
+ leaptime = (wnlsf*7 + dn)*86400; /* time of leap in GPS seconds */
+ if ((leaptime > now) && ((leaptime-now) < 86400*28))
+ {
+ /* generate a leap warning */
+ if (tlsf > tls)
+ t->t_leap = ADDSECOND;
+ else
+ t->t_leap = DELSECOND;
+ }
+ else
+ {
+ t->t_leap = 0;
+ }
+ }
+ break;
+
+ default:
+ /* it's validly formed, but we don't care about it! */
+ break;
+ }
+ }
+ return CVT_SKIP;
+}
+
+/*
+ * getflt, getdbl, getint convert fields in the incoming data into the
+ * appropriate type of item
+ *
+ * CAVEAT: these routines are currently definitely byte order dependent
+ * and assume Representation(float) == IEEE754
+ * These functions MUST be converted to portable versions (especially
+ * converting the float representation into ntp_fp formats in order
+ * to avoid floating point operations at all!
+ */
+
+static float
+getflt(bp)
+ u_char *bp;
+{
+ uval.bd[0] = *bp++;
+ uval.bd[1] = *bp++;
+ uval.bd[2] = *bp++;
+ uval.bd[3] = *bp;
+ return uval.fv;
+}
+
+static double
+getdbl(bp)
+ u_char *bp;
+{
+ uval.bd[0] = *bp++;
+ uval.bd[1] = *bp++;
+ uval.bd[2] = *bp++;
+ uval.bd[3] = *bp++;
+ uval.bd[4] = *bp++;
+ uval.bd[5] = *bp++;
+ uval.bd[6] = *bp++;
+ uval.bd[7] = *bp;
+ return uval.dv;
+}
+
+static int
+getint(bp)
+ u_char *bp;
+{
+ uval.bd[2] = *bp++;
+ uval.bd[3] = *bp;
+ if (uval.bd[2] & 0x80) /* sign-extend */
+ uval.bd[0] = uval.bd[1] = 0xff;
+ else
+ uval.bd[0] = uval.bd[1] = 0;
+ return uval.iv;
+}
+
+#endif /* defined(PARSE) && defined(CLOCK_TRIMTSIP) */
+
+/*
+ * History:
+ *
+ * $Log: clk_trimble.c,v $
+ */
diff --git a/usr.sbin/xntpd/parse/parse.c b/usr.sbin/xntpd/parse/parse.c
index 84bfa39d1293..16c7813acedc 100644
--- a/usr.sbin/xntpd/parse/parse.c
+++ b/usr.sbin/xntpd/parse/parse.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS))
/*
- * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.23 1994/03/25 13:09:02 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.27 1994/06/01 08:18:33 kardel Exp
*
- * parse.c,v 3.23 1994/03/25 13:09:02 kardel Exp
+ * parse.c,v 3.27 1994/06/01 08:18:33 kardel Exp
*
* Parser module for reference clock
*
@@ -64,7 +64,7 @@ static char rcsid[] = "parse.c,v 3.19 1994/01/25 19:05:20 kardel Exp";
extern clockformat_t *clockformats[];
extern unsigned short nformats;
-static unsigned LONG timepacket();
+static u_long timepacket();
/*
* strings support usually not in kernel - duplicated, but what the heck
@@ -120,9 +120,9 @@ timedout(parseio, ctime)
delta.tv_usec += 1000000;
}
#else
- extern LONG tstouslo[];
- extern LONG tstousmid[];
- extern LONG tstoushi[];
+ extern long tstouslo[];
+ extern long tstousmid[];
+ extern long tstoushi[];
l_fp delt;
@@ -145,6 +145,8 @@ timedout(parseio, ctime)
/*
* setup_bitmaps
+ * WARNING: NOT TO BE CALLED CONCURRENTLY WITH
+ * parse_ioread, parse_ioend, parse_ioinit
*/
static int
setup_bitmaps(parseio, low, high)
@@ -155,7 +157,7 @@ setup_bitmaps(parseio, low, high)
register unsigned short i;
register int f = 0;
register clockformat_t *fmt;
- register unsigned index, mask;
+ register unsigned short index, mask, plen;
if ((low >= high) ||
(high > nformats))
@@ -167,6 +169,9 @@ setup_bitmaps(parseio, low, high)
bzero(parseio->parse_startsym, sizeof (parseio->parse_startsym));
bzero(parseio->parse_endsym, sizeof (parseio->parse_endsym));
bzero(parseio->parse_syncsym, sizeof (parseio->parse_syncsym));
+
+ plen = 0;
+
parseio->parse_syncflags = 0;
parseio->parse_timeout.tv_sec = 0;
parseio->parse_timeout.tv_usec = 0;
@@ -179,13 +184,16 @@ setup_bitmaps(parseio, low, high)
fmt = clockformats[i];
if (!(parseio->parse_flags & PARSE_FIXED_FMT) &&
- (fmt->flags & CVT_FIXEDONLY))
+ (fmt->flags & CVT_FIXEDONLY)) {
+ if (parseio->parse_dsize < fmt->length)
+ parseio->parse_dsize = fmt->length;
continue;
+ }
if (fmt->flags & F_START)
{
- index = fmt->startsym / 8;
- mask = 1 << (fmt->startsym % 8);
+ index = fmt->startsym >> 3;
+ mask = 1 << (fmt->startsym & 0x7);
if (parseio->parse_endsym[index] & mask)
{
@@ -205,8 +213,8 @@ setup_bitmaps(parseio, low, high)
if (fmt->flags & F_END)
{
- index = fmt->endsym / 8;
- mask = 1 << (fmt->endsym % 8);
+ index = fmt->endsym >> 3;
+ mask = 1 << (fmt->endsym & 0x7);
if (parseio->parse_startsym[index] & mask)
{
@@ -226,12 +234,12 @@ setup_bitmaps(parseio, low, high)
if (fmt->flags & SYNC_CHAR)
{
- parseio->parse_syncsym[fmt->syncsym / 8] |= (1 << (fmt->syncsym % 8));
+ parseio->parse_syncsym[fmt->syncsym >> 3] |= (1 << (fmt->syncsym & 0x7));
}
parseio->parse_syncflags |= fmt->flags & (SYNC_START|SYNC_END|SYNC_CHAR|SYNC_ONE|SYNC_ZERO|SYNC_TIMEOUT|SYNC_SYNTHESIZE);
- if ((fmt->flags & SYNC_TIMEOUT) &&
+ if (((fmt->flags & (SYNC_TIMEOUT|CVT_FIXEDONLY)) == (SYNC_TIMEOUT|CVT_FIXEDONLY)) &&
((parseio->parse_timeout.tv_sec || parseio->parse_timeout.tv_usec) ? timercmp(&parseio->parse_timeout, &fmt->timeout, >) : 1))
{
parseio->parse_timeout = fmt->timeout;
@@ -241,6 +249,13 @@ setup_bitmaps(parseio, low, high)
parseio->parse_dsize = fmt->length;
}
+ if (parseio->parse_pdata)
+ {
+ FREE(parseio->parse_pdata, parseio->parse_plen);
+ parseio->parse_plen = 0;
+ parseio->parse_pdata = (void *)0;
+ }
+
if (!f && ((int)(high - low) > 1))
{
/*
@@ -254,6 +269,27 @@ setup_bitmaps(parseio, low, high)
return 0;
}
+ if ((high - low == 1) && (clockformats[low]->flags & CVT_FIXEDONLY) &&
+ (clockformats[low]->plen))
+ {
+ parseio->parse_plen = clockformats[low]->plen;
+ parseio->parse_pdata = (void *)MALLOC(parseio->parse_plen);
+
+ if (!parseio->parse_pdata)
+ {
+ /*
+ * no memory
+ */
+#ifdef PARSEKERNEL
+ printf("parse: setup_bitmaps: failed: no memory for private data\n");
+#else
+ syslog(LOG_ERR, "parse: setup_bitmaps: failed: no memory for private data\n");
+#endif
+ return 0;
+ }
+ bzero((char *)parseio->parse_pdata, parseio->parse_plen);
+ }
+
return 1;
}
@@ -264,6 +300,9 @@ parse_ioinit(parseio)
{
parseprintf(DD_PARSE, ("parse_iostart\n"));
+ parseio->parse_plen = 0;
+ parseio->parse_pdata = (void *)0;
+
if (!setup_bitmaps(parseio, 0, nformats))
return 0;
@@ -294,6 +333,10 @@ parse_ioend(parseio)
register parse_t *parseio;
{
parseprintf(DD_PARSE, ("parse_ioend\n"));
+
+ if (parseio->parse_pdata)
+ FREE(parseio->parse_pdata, parseio->parse_plen);
+
if (parseio->parse_data)
FREE(parseio->parse_data, parseio->parse_dsize * 2 + 2);
}
@@ -309,24 +352,6 @@ parse_ioread(parseio, ch, ctime)
register unsigned short low, high;
register unsigned index, mask;
- parseprintf(DD_PARSE, ("parse_ioread(0x%x, char=0x%x, ..., ...)\n", (unsigned int)parseio, ch & 0xFF));
-
- if (parseio->parse_flags & PARSE_FIXED_FMT)
- {
- if (!clockformats[parseio->parse_lformat]->convert)
- {
- parseprintf(DD_PARSE, ("parse_ioread: input dropped.\n"));
- return CVT_NONE;
- }
- low = parseio->parse_lformat;
- high = low + 1;