aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>1994-02-03 22:09:07 +0000
committerGarrett Wollman <wollman@FreeBSD.org>1994-02-03 22:09:07 +0000
commitb9eb1bdbc43bbeeeabbdfcd521834d1fba15346d (patch)
tree01196d65bcdba65782a87cc58bbfbc41baf5fc1d
parente7c996d95e438eb882cfb523ba6e047f12adb01f (diff)
downloadsrc-b9eb1bdbc43bbeeeabbdfcd521834d1fba15346d.tar.gz
src-b9eb1bdbc43bbeeeabbdfcd521834d1fba15346d.zip
xntpd version 3.3z from UDel
Notes
Notes: svn path=/cvs2svn/branches/UDEL/; revision=1081
-rw-r--r--usr.sbin/xntpd/COPYRIGHT6
-rw-r--r--usr.sbin/xntpd/Config.local.dist11
-rw-r--r--usr.sbin/xntpd/Makefile2
-rw-r--r--usr.sbin/xntpd/README57
-rw-r--r--usr.sbin/xntpd/RELNOTES27
-rw-r--r--usr.sbin/xntpd/TODO13
-rw-r--r--usr.sbin/xntpd/VERSION2
-rw-r--r--usr.sbin/xntpd/adjtime/adjtimed.c19
-rw-r--r--usr.sbin/xntpd/authstuff/authspeed.c14
-rw-r--r--usr.sbin/xntpd/authstuff/keyparity.c20
-rw-r--r--usr.sbin/xntpd/authstuff/makeIPFP.c8
-rw-r--r--usr.sbin/xntpd/authstuff/makePC1.c12
-rw-r--r--usr.sbin/xntpd/authstuff/makePC2.c12
-rw-r--r--usr.sbin/xntpd/authstuff/makeSP.c8
-rw-r--r--usr.sbin/xntpd/authstuff/md5driver.c4
-rw-r--r--usr.sbin/xntpd/authstuff/mkrandkeys.c16
-rw-r--r--usr.sbin/xntpd/authstuff/omakeIPFP.c8
-rw-r--r--usr.sbin/xntpd/clockstuff/chutest.c10
-rw-r--r--usr.sbin/xntpd/clockstuff/clktest.c24
-rw-r--r--usr.sbin/xntpd/clockstuff/propdelay.c34
-rw-r--r--usr.sbin/xntpd/compilers/domainos.cc1
-rw-r--r--usr.sbin/xntpd/conf/Config.CHATHAM5
-rw-r--r--usr.sbin/xntpd/conf/Config.MONOMOY5
-rw-r--r--usr.sbin/xntpd/conf/Config.TIGER5
-rw-r--r--usr.sbin/xntpd/conf/Config.TRURO5
-rw-r--r--usr.sbin/xntpd/conf/Config.local2
-rw-r--r--usr.sbin/xntpd/doc/xntpd.871
-rw-r--r--usr.sbin/xntpd/hints/linux29
-rw-r--r--usr.sbin/xntpd/hints/sun417
-rw-r--r--usr.sbin/xntpd/include/l_stdlib.h10
-rw-r--r--usr.sbin/xntpd/include/ntp.h5
-rw-r--r--usr.sbin/xntpd/include/ntp_control.h13
-rw-r--r--usr.sbin/xntpd/include/ntp_filegen.h2
-rw-r--r--usr.sbin/xntpd/include/ntp_machine.h223
-rw-r--r--usr.sbin/xntpd/include/ntp_refclock.h4
-rw-r--r--usr.sbin/xntpd/include/ntp_select.h2
-rw-r--r--usr.sbin/xntpd/include/ntp_stdlib.h2
-rw-r--r--usr.sbin/xntpd/include/ntp_string.h34
-rw-r--r--usr.sbin/xntpd/include/ntpd.h31
-rw-r--r--usr.sbin/xntpd/include/parse.h14
-rw-r--r--usr.sbin/xntpd/include/parse_conf.h8
-rw-r--r--usr.sbin/xntpd/include/sys/parsestreams.h8
-rw-r--r--usr.sbin/xntpd/kernel/Makefile.tmpl5
-rw-r--r--usr.sbin/xntpd/kernel/tty_chu_STREAMS.c169
-rw-r--r--usr.sbin/xntpd/kernel/tty_clk_STREAMS.c2
-rw-r--r--usr.sbin/xntpd/lib/a_md512crypt.c7
-rw-r--r--usr.sbin/xntpd/lib/a_md5decrypt.c4
-rw-r--r--usr.sbin/xntpd/lib/a_md5encrypt.c6
-rw-r--r--usr.sbin/xntpd/lib/authdes.c46
-rw-r--r--usr.sbin/xntpd/lib/authdes.c.export1
-rw-r--r--usr.sbin/xntpd/lib/authkeys.c2
-rw-r--r--usr.sbin/xntpd/lib/authusekey.c2
-rw-r--r--usr.sbin/xntpd/lib/clocktypes.c1
-rw-r--r--usr.sbin/xntpd/lib/dofptoa.c2
-rw-r--r--usr.sbin/xntpd/lib/dolfptoa.c2
-rw-r--r--usr.sbin/xntpd/lib/getopt.c89
-rw-r--r--usr.sbin/xntpd/lib/machines.c117
-rw-r--r--usr.sbin/xntpd/lib/msyslog.c3
-rw-r--r--usr.sbin/xntpd/lib/numtohost.c2
-rw-r--r--usr.sbin/xntpd/lib/systime.c48
-rw-r--r--usr.sbin/xntpd/machines/README2
-rw-r--r--usr.sbin/xntpd/machines/aix3.22
-rw-r--r--usr.sbin/xntpd/machines/bsdi3
-rw-r--r--usr.sbin/xntpd/machines/dell.svr49
-rw-r--r--usr.sbin/xntpd/machines/domainos7
-rw-r--r--usr.sbin/xntpd/machines/freebsd2
-rw-r--r--usr.sbin/xntpd/machines/hpux2
-rw-r--r--usr.sbin/xntpd/machines/hpux10+2
-rw-r--r--usr.sbin/xntpd/machines/i386svr44
-rw-r--r--usr.sbin/xntpd/machines/linux2
-rw-r--r--usr.sbin/xntpd/machines/netbsd2
-rw-r--r--usr.sbin/xntpd/machines/ptx2
-rw-r--r--usr.sbin/xntpd/machines/sequent2
-rw-r--r--usr.sbin/xntpd/machines/sunos5.12
-rw-r--r--usr.sbin/xntpd/machines/sunos5.22
-rw-r--r--usr.sbin/xntpd/machines/svr42
-rw-r--r--usr.sbin/xntpd/ntpdate/ntpdate.c52
-rw-r--r--usr.sbin/xntpd/ntpq/ntpq.c50
-rw-r--r--usr.sbin/xntpd/ntpq/ntpq_ops.c19
-rw-r--r--usr.sbin/xntpd/ntptrace/ntptrace.c24
-rw-r--r--usr.sbin/xntpd/parse/Makefile.kernel15
-rw-r--r--usr.sbin/xntpd/parse/Makefile.tmpl2
-rw-r--r--usr.sbin/xntpd/parse/clk_dcf7000.c6
-rw-r--r--usr.sbin/xntpd/parse/clk_meinberg.c12
-rw-r--r--usr.sbin/xntpd/parse/clk_rawdcf.c14
-rw-r--r--usr.sbin/xntpd/parse/clk_schmid.c12
-rw-r--r--usr.sbin/xntpd/parse/clk_trimble.c5
-rw-r--r--usr.sbin/xntpd/parse/parse.c41
-rw-r--r--usr.sbin/xntpd/parse/parse_conf.c12
-rw-r--r--usr.sbin/xntpd/parse/parsesolaris.c59
-rw-r--r--usr.sbin/xntpd/parse/parsestreams.c27
-rw-r--r--usr.sbin/xntpd/parse/util/Makefile.tmpl2
-rw-r--r--usr.sbin/xntpd/parse/util/dcfd.c503
-rw-r--r--usr.sbin/xntpd/parse/util/parsetest.c6
-rw-r--r--usr.sbin/xntpd/parse/util/testdcf.c8
-rw-r--r--usr.sbin/xntpd/refclocks/Dependencies6
-rw-r--r--usr.sbin/xntpd/refclocks/rclk.GPSTM33
-rw-r--r--usr.sbin/xntpd/refclocks/rclk.PARSE2
-rw-r--r--usr.sbin/xntpd/refclocks/rconfig4
-rwxr-xr-xusr.sbin/xntpd/scripts/Guess.sh10
-rwxr-xr-xusr.sbin/xntpd/scripts/autoconf4
-rw-r--r--usr.sbin/xntpd/scripts/stats/clock.awk4
-rwxr-xr-xusr.sbin/xntpd/scripts/stats/summary.sh15
-rw-r--r--usr.sbin/xntpd/util/Makefile.tmpl2
-rw-r--r--usr.sbin/xntpd/util/ntptime.c22
-rw-r--r--usr.sbin/xntpd/util/tickadj.c31
-rw-r--r--usr.sbin/xntpd/xntpd/Makefile.tmpl7
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_config.c95
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_control.c498
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_filegen.c2
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_intres.c19
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_io.c9
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_loopfilter.c38
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_monitor.c5
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_peer.c2
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_proto.c6
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_request.c29
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_restrict.c6
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_unixclock.c12
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_util.c10
-rw-r--r--usr.sbin/xntpd/xntpd/ntpd.c13
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_as2201.c46
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_chu.c47
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_conf.c7
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_goes.c48
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_gpstm.c1015
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_irig.c12
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_leitch.c40
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_local.c8
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_msfees.c32
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_mx4200.c52
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_omega.c46
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_parse.c175
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_pst.c46
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_tpro.c12
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_wwvb.c46
-rw-r--r--usr.sbin/xntpd/xntpdc/ntpdc.c32
-rw-r--r--usr.sbin/xntpd/xntpdc/ntpdc_ops.c6
-rw-r--r--usr.sbin/xntpd/xntpres/xntpres.c31
139 files changed, 3597 insertions, 1215 deletions
diff --git a/usr.sbin/xntpd/COPYRIGHT b/usr.sbin/xntpd/COPYRIGHT
index be272fe18063..711a8f1efcb4 100644
--- a/usr.sbin/xntpd/COPYRIGHT
+++ b/usr.sbin/xntpd/COPYRIGHT
@@ -1,6 +1,6 @@
/******************************************************************************
* *
- * Copyright (c) David L. Mills 1992, 1993 *
+ * Copyright (c) David L. Mills 1992, 1993, 1994 *
* *
* Permission to use, copy, modify, and distribute this software and its *
* documentation for any purpose and without fee is hereby granted, provided *
@@ -53,4 +53,6 @@
* support)
* Karl Berry <karl@owl.HQ.ileaf.com> (syslog to file option)
* Torsten Duwe <duwe@immd4.informatik.uni-erlangen.de> (Linux Port)
- */
+ * Paul A Vixie <vixie@vix.com> (TrueTime GPS driver)
+ * Jim Jagielski <jim@jagubox.gsfc.nasa.gov> (A/UX port)
+*/
diff --git a/usr.sbin/xntpd/Config.local.dist b/usr.sbin/xntpd/Config.local.dist
index 4c5c24672700..97c01c065b42 100644
--- a/usr.sbin/xntpd/Config.local.dist
+++ b/usr.sbin/xntpd/Config.local.dist
@@ -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
@@ -152,6 +154,9 @@ DEFS_LOCAL= $(DEFS_OPT) #GREEN -DREFCLOCK #TEST -DPPSPPS -DKERNEL_PLL
# 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 -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.
diff --git a/usr.sbin/xntpd/Makefile b/usr.sbin/xntpd/Makefile
index 30e59bbb5ce0..1e9c0b14afc3 100644
--- a/usr.sbin/xntpd/Makefile
+++ b/usr.sbin/xntpd/Makefile
@@ -66,7 +66,7 @@ TARGETS = xntpd/xntpd xntpdc/xntpdc ntpq/ntpq ntpdate/ntpdate \
OPTTARG = adjtime/adjtimed util/ntptime util/precision
REFCONF=
COMPRESSOR=compress
-# Base distribution name (will be extended by <VERSION>.tar.<comperssorsuffix>)
+# Base distribution name (will be extended by <VERSION>.tar.<compressorsuffix>)
DISTNAME=xntp-
MAKE= make
diff --git a/usr.sbin/xntpd/README b/usr.sbin/xntpd/README
index 76414a2a52d5..83d38a8fe5f6 100644
--- a/usr.sbin/xntpd/README
+++ b/usr.sbin/xntpd/README
@@ -16,20 +16,20 @@ the subdirectories contain README files describing their contents. The
base directory ./ includes:
COPYRIGHT file specifying copyright conditions, together with a
- list of major authors and electric addresses
+ list of major authors and electric addresses.
Config * configuration file built by the configuration script
- "make makeconfig" and used to buile the makefiles in the
+ "make makeconfig" and used to build the makefiles in the
various subdirectories. Do not edit.
Config.local * Unless you have a reference clock (besides the local
- computer clock) or want to change the default installlation
+ computer clock) or want to change the default installation
directory (/usr/local/bin) not action is needed. For
configuring a reference clock a "make refconf" should
suffice. Diehards can still use an editor on this file.
Config.local.dist file used to generate a plausible Config.local by commands
- such as "make Config.local.green"
+ such as "make Config.local.green".
Config.sed * sed script used to build makefiles from the
configuration file. Do not edit.
@@ -38,17 +38,17 @@ Makefile this is the root of the makefile tree. Do not edit.
(Contents under pressure - qualified personel only 8-)
PORTING contains useful information for porting to unexplored
- new systems
+ new systems.
RELNOTES instructions for compiling and installing the daemon and
- supporting programs
+ supporting programs.
-README this file
+README this file.
TODO our current problems where we could need help.
adjtime directory containing the sources for the adjtime daemon
- for HP/UX systems
+ for HP/UX systems.
authstuff directory containing sources for miscellaneous programs
to test, calibrate and certify the cryptographic
@@ -61,44 +61,39 @@ clockstuff directory containing sources for miscellaneous programs
kernel configurations, together with a program to
calculate propagation delays for use with radio clocks
and national time dissemination services such as
- WWV/WWVH, WWVB and CHU
+ WWV/WWVH, WWVB and CHU.
compilers directory containing configuration scripts for various
- compilers and operating systems
+ compilers and operating systems.
conf directory containing a motley collection of
configuration files for various systems. For example
only.
doc directory containing miscellaneous man pages and memos
- useful for installation and subnet management
+ useful for installation and subnet management.
gadget directory containing instructions and construction data
for a mysterious little box used as a CHU radio
demodulator and/or a level converter-pulse generator for
- a precision 1-pps signal
+ a precision 1-pps signal.
include directory containing include header files used by most
- programs in the distribution
+ programs in the distribution.
hints directory containing files with hints on particular
topics like installation on specific OS variants or
- general information
-
-historical.tar.Z
- tar file with stuff believed to be old. If you find things
- in there that are helpful for the current release, please
- send email to mills@udel.edu.
+ general information.
kernel directory containing sources for kernel programs such as
line disciplines and STREAMS modules used with the CHU
- decoder and precision 1-pps signals
+ decoder and precision 1-pps signals.
lib directory containing sources for the library programs
- used by most programs in the distribution
+ used by most programs in the distribution.
machines directory containing configuration scripts for various
- operating systems
+ operating systems.
ntpdate directory containing sources for a program to set the
local machine time from one or more remote machines
@@ -114,17 +109,17 @@ ntpq directory containing sources for a utility program to
ntptrace directory containing sources for a utility program that
can be used to reveal the chain of NTP peers from a
designated peer to the primary server at the root of the
- timekeeping subnet
+ timekeeping subnet.
parse directory containing file belonging to the generic parse
- reference clock driver. for reasonable simple clocks it
+ reference clock driver. For reasonably simple clocks it
is possible to get away with about 3-4Kb of code.
additionally the SunOS 4.x streams module for parse is
residing here.
parse/util some goodies for testing parse processing of DCF77 information.
- (primarily for use on Suns / although others may work
- also - possibly with a little porting)
+ (primarily for use on Suns, although others may work
+ also - possibly with a little porting.)
one little gem is dcfd.c - DCF77 decoder with ntp loopfilter
code for standalone DCF77 synchronisation without the full
works of NTP.
@@ -135,9 +130,6 @@ ppsclock directory containing sources for modifications to the
4.1.X systems only.
refclocks directory containing reference clock configuration support
- the file in here are still experimental. Do not expect them
- to work flawlessly on all architectures. the coded dependencies
- might not even be correct.
scripts directory containing scripts to build the configuration
file "config" in this directory and then the makefiles
@@ -147,10 +139,9 @@ scripts directory containing scripts to build the configuration
and daemon startup.
util directory containing sources for various utility and
- testing programs
+ testing programs.
-xntpd directory containing sources for the NTP Version 3
- daemon
+xntpd directory containing sources for the NTP Version 3 daemon.
xntpdc directory containing sources for a utility program to
query local and remote NTP peers for state variables and
@@ -160,4 +151,4 @@ xntpdc directory containing sources for a utility program to
Specification RFC 1305.
xntpres directory containing sources for a name-resolution
- program used in some configurations of NTP Version 3
+ program used in some configurations of NTP Version 3.
diff --git a/usr.sbin/xntpd/RELNOTES b/usr.sbin/xntpd/RELNOTES
index 277b8921de82..1b9d9c02c3b3 100644
--- a/usr.sbin/xntpd/RELNOTES
+++ b/usr.sbin/xntpd/RELNOTES
@@ -7,7 +7,7 @@ this distribution. To make these programs:
(0) Make sure that you have all necessary tools for building executables.
These tools include cc/gcc, make, awk, sed, tr, sh, grep, egrep and
a few others. Not all of these tools exist in the standard distribution
- of todays Unix versions (Compilers are likely to be an extra product).
+ of todays UNIX versions (compilers are likely to be an extra product).
For a successful build all of these tools should be accessible via the
current path.
@@ -26,7 +26,7 @@ this distribution. To make these programs:
To set up for a radio clock, type "make refconf" and answer the questions
about PLL, PPS and radio clock type.
If this is the first use of the ref clock, don't forget to make suitable
- files in /dev/
+ files in /dev/.
For custom tailored configuration copying Config.local.dist to Config.local
and editing Config.local to suit the local needs is neccessary (at most
@@ -130,20 +130,25 @@ the meal. The converse is not always true.
Convex Convex OS 10.1 ? ?
SGI IRIX 4.0.5F gcc no REFCLOCK (pb 93/11/10)
AIX 3.2 ? ?
- A/UX 2.0.1, 3.0.x ? ?
+ A/UX 2.0.1, 3.x.x gcc LOCAL_CLOCK (jmj (94/01/26 see hints)
RS6000 AIX 3.2 gcc no REFCLOCK
MX500 Sinix-m V5.40 cc PARSE REFCLOCK
S2000 Sequent PTX 1.4 cc LOCAL_CLOCK (kd 93/11/10)
S2000 Sequent PTX 1.4 gcc LOCAL_CLOCK (kd 93/11/10)
PC FreeBSD gcc LOCAL_CLOCK see "build problems"
PC NetBSD? gcc LOCAL_CLOCK possibly see "build problems"
- PC BSDI? gcc LOCAL_CLOCK possibly see "build problems"
+ PC BSD/386 1.0 gcc LOCAL_CLOCK possibly see "build problems"
PC Linux (pl14) gcc LOCAL_CLOCK (dw 93/10/30)
+ PC Dell SVR4 v2.2 gcc ? (tl 93/12/30)
+ NCR3445 NCR SVR4 cc LOCAL_CLOCK (tm 93/11/29)
pb: Piete Brooks
kd: Frank Kardel
dw: Torsten Duwe (duwe@informatik.uni-erlangen.de)
dm: David Mills (mills@udel.edu)
+ tl: Tony Lill <ajlill@tlill.hookup.net>
+ tm: Tom Moore <Tom.Moore@DaytonOH.NCR.COM>
+ jmj: Jim Jagielski <jim@jagubox.gsfc.nasa.gov>
Build Problems (and workaround):
@@ -152,7 +157,7 @@ of "make" and "sh" and "awk" features in different implementations.
If you have problems other tha the one listed below please check for
usualy things like the latest sh compatible pd shell in your own
environment. Things like this are known to hinder compilation if
-they ate not fully compatible with sh or are buggy.
+they are not fully compatible with sh or are buggy.
Current build problem on (Mac) NetBSD, possibly BSDI and 386BSD:
pmake (e. g. NetBSD on MAC, possible other BNR2+pmake systems)
@@ -170,9 +175,17 @@ Current build problem on (Mac) NetBSD, possibly BSDI and 386BSD:
by failure to build with the message:
"don't know how to make make".
+ On BSD/386 the solution is to get GNU make and run build as:
+ % gnumake MAKE=gnumake
+ Note that BSD/386 1.0's "sed" goes into an infinite loop if
+ you try to make the "refconf" target -- so edit Config.local
+ by hand if you have a reference clock. (BSD/386 1.1 will fix
+ this "sed" bug.)
+
+ The NetBSD people claim that this problem goes away
+ when you compile make with POSIX compilation options.
+
The known sh and some make pecularities have already been taken care of.
-The pmake (in the BNR2 branches) problem seems to be real at the time of this
-writing. If you know a portable(!) fix we'd like to hear from you.
Usually the vendor should fix these bugs in vital utilities.
We try to circumvent these bugs in a hopefully portable way.
diff --git a/usr.sbin/xntpd/TODO b/usr.sbin/xntpd/TODO
index 9b803722efc9..e4bbe4713c94 100644
--- a/usr.sbin/xntpd/TODO
+++ b/usr.sbin/xntpd/TODO
@@ -1,5 +1,5 @@
#
-# TODO,v 3.3 1993/11/09 23:20:16 kardel Exp
+# TODO,v 3.5 1994/01/25 19:03:55 kardel Exp
#
This file contains problems known to the authors that still need to be done.
We would appreciate if you could spare some of your time to look through
@@ -19,17 +19,6 @@ Thank you for your help !
Open issues:
-HPUX:
- - Time warp
- During the last few month disturbing reports about xntp setting
- preposterous times during periods of high load have been reported
- on HPUX 8 and 9. The theory is that the adjtimed message queue
- gets deleted. Symptoms are that xntp() complains about interrupted
- system calls in adjtime()-emulation and the time is set to some
- invalid date. Also the adjtimed seems to have problems. We could
- need some help here by an experienced HPUX guru.
- Files affected: adjtime/*
-
Apollo:
- terminal affiliation
Check whether thing are still correct in respect to breaking
diff --git a/usr.sbin/xntpd/VERSION b/usr.sbin/xntpd/VERSION
index 80868e3ba5fb..85051bd4db45 100644
--- a/usr.sbin/xntpd/VERSION
+++ b/usr.sbin/xntpd/VERSION
@@ -1 +1 @@
-version=3.3b (beta)
+version=3.3c (beta)
diff --git a/usr.sbin/xntpd/adjtime/adjtimed.c b/usr.sbin/xntpd/adjtime/adjtimed.c
index f2de6921cf34..44e544441693 100644
--- a/usr.sbin/xntpd/adjtime/adjtimed.c
+++ b/usr.sbin/xntpd/adjtime/adjtimed.c
@@ -30,6 +30,7 @@ static char RCSid[] = "adjtimed.c,v 3.1 1993/07/06 01:04:45 jbj Exp";
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
+#include <sys/lock.h>
#include <time.h>
#include <signal.h>
#include <nlist.h>
@@ -40,8 +41,8 @@ static char RCSid[] = "adjtimed.c,v 3.1 1993/07/06 01:04:45 jbj Exp";
#include "adjtime.h"
double atof();
-extern int optind;
-extern char *optarg;
+extern int ntp_optind;
+extern char *ntp_optarg;
int InitClockRate();
int AdjustClockRate();
@@ -80,9 +81,13 @@ main(argc, argv)
progname = argv[0];
+#ifdef LOG_LOCAL6
openlog("adjtimed", LOG_PID, LOG_LOCAL6);
+#else
+ openlog("adjtimed", LOG_PID);
+#endif
- while ((ch = getopt(argc, argv, "hkrvdfp:")) != EOF) {
+ while ((ch = ntp_getopt(argc, argv, "hkrvdfp:")) != EOF) {
switch (ch) {
case 'k':
case 'r':
@@ -112,7 +117,7 @@ main(argc, argv)
break;
case 'p':
- if ((RATE = atof(optarg)) <= 0.0 || RATE >= 100.0) {
+ if ((RATE = atof(ntp_optarg)) <= 0.0 || RATE >= 100.0) {
fputs("adjtimed: percentage must be between 0.0 and 100.0\n", stderr);
exit(1);
}
@@ -202,6 +207,12 @@ main(argc, argv)
Exit(1);
}
+ if (plock(PROCLOCK)) {
+ syslog(LOG_ERR, "plock: %m");
+ perror("adjtimed: plock");
+ Cleanup();
+ }
+
for (;;) {
if (msgrcv(mqid, &msg.msgp, MSGSIZE, CLIENT, 0) == -1) {
if (errno == EINTR) continue;
diff --git a/usr.sbin/xntpd/authstuff/authspeed.c b/usr.sbin/xntpd/authstuff/authspeed.c
index 05af1326d8ed..c83d5b24497e 100644
--- a/usr.sbin/xntpd/authstuff/authspeed.c
+++ b/usr.sbin/xntpd/authstuff/authspeed.c
@@ -65,12 +65,12 @@ char *argv[];
int loops;
int i;
int errflg = 0;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
progname = argv[0];
loops = DEFLOOPS;
- while ((c = getopt_l(argc, argv, "cdmn:")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "cdmn:")) != EOF)
switch (c) {
case 'c':
totalcost++;
@@ -82,11 +82,11 @@ char *argv[];
domd5 = 16; /* offset into list of keys */
break;
case 'n':
- loops = atoi(optarg);
+ loops = atoi(ntp_optarg);
if (loops <= 0) {
(void) fprintf(stderr,
"%s: %s is unlikely to be a useful number of loops\n",
- progname, optarg);
+ progname, ntp_optarg);
errflg++;
}
break;
@@ -94,7 +94,7 @@ char *argv[];
errflg++;
break;
}
- if (errflg || optind == argc) {
+ if (errflg || ntp_optind == argc) {
(void) fprintf(stderr,
"usage: %s [-d] [-n loops] [ -c ] auth.samplekeys\n",
progname);
@@ -108,7 +108,7 @@ char *argv[];
printf(" based authentication.\n");
init_auth();
- authreadkeys(argv[optind]);
+ authreadkeys(argv[ntp_optind]);
for (i = 0; i < 16; i++) {
if (!auth_havekey(i + domd5)) {
errflg++;
diff --git a/usr.sbin/xntpd/authstuff/keyparity.c b/usr.sbin/xntpd/authstuff/keyparity.c
index 45a706173b43..424fade71745 100644
--- a/usr.sbin/xntpd/authstuff/keyparity.c
+++ b/usr.sbin/xntpd/authstuff/keyparity.c
@@ -49,11 +49,11 @@ char *argv[];
int errflg = 0;
int keytype;
U_LONG key[2];
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
progname = argv[0];
- while ((c = getopt_l(argc, argv, "adno:s")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "adno:s")) != EOF)
switch (c) {
case 'a':
asciiflag = 1;
@@ -68,10 +68,10 @@ char *argv[];
stdflag = 1;
break;
case 'o':
- if (*optarg == 'n') {
+ if (*ntp_optarg == 'n') {
ntpoutflag = 1;
gotoopt = 1;
- } else if (*optarg == 's') {
+ } else if (*ntp_optarg == 's') {
ntpoutflag = 0;
gotoopt = 1;
} else {
@@ -85,7 +85,7 @@ char *argv[];
errflg++;
break;
}
- if (errflg || optind == argc) {
+ if (errflg || ntp_optind == argc) {
(void) fprintf(stderr,
"usage: %s -n|-s [-a] [-o n|s] key [...]\n",
progname);
@@ -118,11 +118,11 @@ char *argv[];
else
keytype = KEY_TYPE_STD;
- for (; optind < argc; optind++) {
- if (!decodekey(keytype, argv[optind], key)) {
+ for (; ntp_optind < argc; ntp_optind++) {
+ if (!decodekey(keytype, argv[ntp_optind], key)) {
(void) fprintf(stderr,
"%s: format of key %s invalid\n",
- progname, argv[optind]);
+ progname, argv[ntp_optind]);
exit(1);
}
(void) parity(key);
@@ -242,7 +242,7 @@ decodekey(keytype, str, key)
/*
* Make up key from ascii representation
*/
- bzero(keybytes, sizeof(keybytes));
+ memset(keybytes, 0, sizeof(keybytes));
for (i = 0; i < 8 && i < len; i++)
keybytes[i] = *cp++ << 1;
key[0] = keybytes[0] << 24 | keybytes[1] << 16
diff --git a/usr.sbin/xntpd/authstuff/makeIPFP.c b/usr.sbin/xntpd/authstuff/makeIPFP.c
index 51f8a55e7240..50b31f4f2513 100644
--- a/usr.sbin/xntpd/authstuff/makeIPFP.c
+++ b/usr.sbin/xntpd/authstuff/makeIPFP.c
@@ -28,11 +28,11 @@ char *argv[];
{
int c;
int errflg = 0;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
progname = argv[0];
- while ((c = getopt_l(argc, argv, "d")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "d")) != EOF)
switch (c) {
case 'd':
++debug;
@@ -183,7 +183,7 @@ doit()
int ind4, ind5, ind6, ind7;
int octbits;
- bzero((char *)bits, sizeof bits);
+ memset((char *)bits, 0, sizeof bits);
/*
* Do the rounds for the IP table. We save the results of
diff --git a/usr.sbin/xntpd/authstuff/makePC1.c b/usr.sbin/xntpd/authstuff/makePC1.c
index c0109892fa10..337353c1516b 100644
--- a/usr.sbin/xntpd/authstuff/makePC1.c
+++ b/usr.sbin/xntpd/authstuff/makePC1.c
@@ -25,11 +25,11 @@ char *argv[];
{
int c;
int errflg = 0;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
progname = argv[0];
- while ((c = getopt_l(argc, argv, "d")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "d")) != EOF)
switch (c) {
case 'd':
++debug;
@@ -82,8 +82,8 @@ permute(bits, cp, dp)
u_char c[28];
u_char d[28];
- bzero((char *)c, sizeof c);
- bzero((char *)d, sizeof d);
+ memset((char *)c, 0, sizeof c);
+ memset((char *)d, 0, sizeof d);
for (i = 0; i < 28; i++) {
c[i] = bits[PC1_C[i]];
@@ -140,7 +140,7 @@ doit()
U_LONG d;
u_char bits[64];
- bzero((char *)bits, sizeof bits);
+ memset((char *)bits, 0, sizeof bits);
printf("static U_LONG PC1_CL[8] = {");
for (i = 0; i < 4; i++) {
diff --git a/usr.sbin/xntpd/authstuff/makePC2.c b/usr.sbin/xntpd/authstuff/makePC2.c
index d92d2b2a9eaf..9795b6215a20 100644
--- a/usr.sbin/xntpd/authstuff/makePC2.c
+++ b/usr.sbin/xntpd/authstuff/makePC2.c
@@ -26,11 +26,11 @@ char *argv[];
{
int c;
int errflg = 0;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
progname = argv[0];
- while ((c = getopt_l(argc, argv, "d")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "d")) != EOF)
switch (c) {
case 'd':
++debug;
@@ -87,7 +87,7 @@ permc(bits, resp)
register U_LONG mask;
u_char res[24];
- bzero((char *)res, sizeof res);
+ memset((char *)res, 0, sizeof res);
for (i = 0; i < 24; i++) {
res[i] = bits[PC2_C[i]];
@@ -117,7 +117,7 @@ permd(bits, resp)
register U_LONG mask;
u_char res[24];
- bzero((char *)res, sizeof res);
+ memset((char *)res, 0, sizeof res);
for (i = 0; i < 24; i++) {
res[i] = bits[PC2_D[i]];
@@ -168,7 +168,7 @@ doit()
U_LONG res;
u_char bits[28];
- bzero((char *)bits, sizeof bits);
+ memset((char *)bits, 0, sizeof bits);
printf("static U_LONG PC2_C[4][64] = {");
for (i = 0; i < 4; i++) {
diff --git a/usr.sbin/xntpd/authstuff/makeSP.c b/usr.sbin/xntpd/authstuff/makeSP.c
index bfeb82c1304e..7bfd93e2cbd6 100644
--- a/usr.sbin/xntpd/authstuff/makeSP.c
+++ b/usr.sbin/xntpd/authstuff/makeSP.c
@@ -25,11 +25,11 @@ char *argv[];
{
int c;
int errflg = 0;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
progname = argv[0];
- while ((c = getopt_l(argc, argv, "d")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "d")) != EOF)
switch (c) {
case 'd':
++debug;
@@ -165,7 +165,7 @@ doit()
U_LONG result;
int sixbits;
- bzero((char *)bits, sizeof bits);
+ memset((char *)bits, 0, sizeof bits);
printf("static U_LONG SP[8][64] = {");
for (selno = 0; selno < 8; selno++) {
for (sixbits = 0; sixbits < 64; sixbits++) {
diff --git a/usr.sbin/xntpd/authstuff/md5driver.c b/usr.sbin/xntpd/authstuff/md5driver.c
index 73db940598fd..b85348fc36d4 100644
--- a/usr.sbin/xntpd/authstuff/md5driver.c
+++ b/usr.sbin/xntpd/authstuff/md5driver.c
@@ -25,9 +25,9 @@
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
-#ifdef __bsdi__
+#ifdef SYS_BSDI
#include <sys/time.h>
-#endif /* __bsdi__ */
+#endif /* SYS_BSDI */
#include "md5.h"
#define MD5
diff --git a/usr.sbin/xntpd/authstuff/mkrandkeys.c b/usr.sbin/xntpd/authstuff/mkrandkeys.c
index 3bb987af8f2d..454b3418bbb1 100644
--- a/usr.sbin/xntpd/authstuff/mkrandkeys.c
+++ b/usr.sbin/xntpd/authstuff/mkrandkeys.c
@@ -34,14 +34,14 @@ char *argv[];
int numkeys;
U_LONG tmp;
char *passwd;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
extern char *getpass();
numkeys = 0;
progname = argv[0];
passwd = NULL;
- while ((c = getopt_l(argc, argv, "dnp:s")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "dnp:s")) != EOF)
switch (c) {
case 'd':
++debug;
@@ -50,7 +50,7 @@ char *argv[];
std = 0;
break;
case 'p':
- passwd = optarg;
+ passwd = ntp_optarg;
break;
case 's':
std = 1;
@@ -61,11 +61,11 @@ char *argv[];
}
numkeys = 0;
- for (; !errflg && optind < argc; optind++) {
- c = atoi(argv[optind]);
+ for (; !errflg && ntp_optind < argc; ntp_optind++) {
+ c = atoi(argv[ntp_optind]);
if (c <= 0 || c > 15) {
- (void) fprintf("%s: invalid key number `%s'\n",
- progname, argv[optind]);
+ (void) fprintf(stderr, "%s: invalid key number `%s'\n",
+ progname, argv[ntp_optind]);
exit(2);
}
dokey[c] = 1;
diff --git a/usr.sbin/xntpd/authstuff/omakeIPFP.c b/usr.sbin/xntpd/authstuff/omakeIPFP.c
index 887cc58c287b..0751a5d96b9c 100644
--- a/usr.sbin/xntpd/authstuff/omakeIPFP.c
+++ b/usr.sbin/xntpd/authstuff/omakeIPFP.c
@@ -34,11 +34,11 @@ char *argv[];
{
int c;
int errflg = 0;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
progname = argv[0];
- while ((c = getopt_l(argc, argv, "d")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "d")) != EOF)
switch (c) {
case 'd':
++debug;
@@ -188,7 +188,7 @@ doit()
int ind0, ind1, ind2, ind3;
int quadbits;
- bzero((char *)bits, sizeof bits);
+ memset((char *)bits, 0, sizeof bits);
/*
* Do the rounds for the IPL table. We save the results of
diff --git a/usr.sbin/xntpd/clockstuff/chutest.c b/usr.sbin/xntpd/clockstuff/chutest.c
index f65686c3b3ca..2bf058c3b012 100644
--- a/usr.sbin/xntpd/clockstuff/chutest.c
+++ b/usr.sbin/xntpd/clockstuff/chutest.c
@@ -68,12 +68,12 @@ char *argv[];
{
int c;
int errflg = 0;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
void init_chu();
progname = argv[0];
- while ((c = getopt_l(argc, argv, "cdfpt")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "cdfpt")) != EOF)
switch (c) {
case 'c':
#ifdef STREAM
@@ -107,7 +107,7 @@ char *argv[];
errflg++;
break;
}
- if (errflg || optind+1 != argc) {
+ if (errflg || ntp_optind+1 != argc) {
#ifdef STREAM
(void) fprintf(stderr, "usage: %s [-dft] tty_device\n",
progname);
@@ -126,7 +126,7 @@ char *argv[];
}
(void) gettimeofday(&lasttv, (struct timezone *)0);
- c = openterm(argv[optind]);
+ c = openterm(argv[ntp_optind]);
init_chu();
#ifdef STREAM
if (usechuldisc)
diff --git a/usr.sbin/xntpd/clockstuff/clktest.c b/usr.sbin/xntpd/clockstuff/clktest.c
index 7ed13b3aa33c..b54048576c41 100644
--- a/usr.sbin/xntpd/clockstuff/clktest.c
+++ b/usr.sbin/xntpd/clockstuff/clktest.c
@@ -105,8 +105,8 @@ char *argv[];
int fd;
struct sgttyb ttyb;
struct itimerval itimer;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
int alarming();
int ioready();
@@ -114,13 +114,13 @@ char *argv[];
#ifdef STREAM
magic[0] = 0;
#endif
- while ((c = getopt_l(argc, argv, "a:b:c:dfs:t:")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "a:b:c:dfs:t:")) != EOF)
switch (c) {
#ifdef CLKLDISC
case 'a':
#endif
case 'c':
- if (!atouint(optarg, &tmp)) {
+ if (!atouint(ntp_optarg, &tmp)) {
(void) fprintf(stderr,
"%s: argument for -%c must be integer\n",
progname, c);
@@ -139,7 +139,7 @@ char *argv[];
#endif
break;
case 'b':
- if (!atouint(optarg, &tmp)) {
+ if (!atouint(ntp_optarg, &tmp)) {
errflg++;
break;
}
@@ -163,14 +163,14 @@ char *argv[];
ttflags |= CRMOD;
break;
case 's':
- cmdlen = strlen(optarg);
+ cmdlen = strlen(ntp_optarg);
if (cmdlen == 0)
errflg++;
else
- cmd = optarg;
+ cmd = ntp_optarg;
break;
case 't':
- if (!atouint(optarg, &tmp))
+ if (!atouint(ntp_optarg, &tmp))
errflg++;
else {
timeout.tv_sec = (long)tmp;
@@ -181,7 +181,7 @@ char *argv[];
errflg++;
break;
}
- if (errflg || optind+1 != argc) {
+ if (errflg || ntp_optind+1 != argc) {
(void) fprintf(stderr,
#ifdef CLKLDISC
"usage: %s [-b bps] [-c magic1] [-a magic2] [-f] [-s cmd] [-t timeo] tty_device\n",
@@ -199,12 +199,12 @@ char *argv[];
#endif
if (docmd)
- fd = open(argv[optind], O_RDWR, 0777);
+ fd = open(argv[ntp_optind], O_RDWR, 0777);
else
- fd = open(argv[optind], O_RDONLY, 0777);
+ fd = open(argv[ntp_optind], O_RDONLY, 0777);
if (fd == -1) {
(void) fprintf(stderr, "%s: open(%s): ", progname,
- argv[optind]);
+ argv[ntp_optind]);
perror("");
exit(1);
}
diff --git a/usr.sbin/xntpd/clockstuff/propdelay.c b/usr.sbin/xntpd/clockstuff/propdelay.c
index 5ba1789eee67..0c1f1bb3e38c 100644
--- a/usr.sbin/xntpd/clockstuff/propdelay.c
+++ b/usr.sbin/xntpd/clockstuff/propdelay.c
@@ -140,21 +140,21 @@ char *argv[];
double lat1, long1;
double lat2, long2;
double lat3, long3;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
progname = argv[0];
- while ((c = getopt_l(argc, argv, "dh:CWG")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "dh:CWG")) != EOF)
switch (c) {
case 'd':
++debug;
break;
case 'h':
hflag++;
- height = atof(optarg);
+ height = atof(ntp_optarg);
if (height <= 0.0) {
(void) fprintf(stderr, "height %s unlikely\n",
- optarg);
+ ntp_optarg);
errflg++;
}
break;
@@ -171,8 +171,8 @@ char *argv[];
errflg++;
break;
}
- if (errflg || (!(Cflag || Wflag || Gflag) && optind+4 != argc) ||
- ((Cflag || Wflag || Gflag) && optind+2 != argc)) {
+ if (errflg || (!(Cflag || Wflag || Gflag) && ntp_optind+4 != argc) ||
+ ((Cflag || Wflag || Gflag) && ntp_optind+2 != argc)) {
(void) fprintf(stderr,
"usage: %s [-d] [-h height] lat1 long1 lat2 long2\n",
progname);
@@ -185,10 +185,10 @@ char *argv[];
if (!(Cflag || Wflag || Gflag)) {
- lat1 = latlong(argv[optind], 1);
- long1 = latlong(argv[optind + 1], 0);
- lat2 = latlong(argv[optind + 2], 1);
- long2 = latlong(argv[optind + 3], 0);
+ lat1 = latlong(argv[ntp_optind], 1);
+ long1 = latlong(argv[ntp_optind + 1], 0);
+ lat2 = latlong(argv[ntp_optind + 2], 1);
+ long2 = latlong(argv[ntp_optind + 3], 0);
if (hflag) {
doit(lat1, long1, lat2, long2, height, "");
} else {
@@ -201,8 +201,8 @@ char *argv[];
/*
* Compute delay from WWV
*/
- lat1 = latlong(argv[optind], 1);
- long1 = latlong(argv[optind + 1], 0);
+ lat1 = latlong(argv[ntp_optind], 1);
+ long1 = latlong(argv[ntp_optind + 1], 0);
lat2 = latlong(wwvlat, 1);
long2 = latlong(wwvlong, 0);
if (hflag) {
@@ -228,8 +228,8 @@ char *argv[];
"WWVH winter propagation, ");
}
} else if (Cflag) {
- lat1 = latlong(argv[optind], 1);
- long1 = latlong(argv[optind + 1], 0);
+ lat1 = latlong(argv[ntp_optind], 1);
+ long1 = latlong(argv[ntp_optind + 1], 0);
lat2 = latlong(chulat, 1);
long2 = latlong(chulong, 0);
if (hflag) {
@@ -243,8 +243,8 @@ char *argv[];
} else if (Gflag) {
lat1 = latlong(goes_up_lat, 1);
long1 = latlong(goes_up_long, 0);
- lat3 = latlong(argv[optind], 1);
- long3 = latlong(argv[optind + 1], 0);
+ lat3 = latlong(argv[ntp_optind], 1);
+ long3 = latlong(argv[ntp_optind + 1], 0);
lat2 = latlong(goes_sat_lat, 1);
diff --git a/usr.sbin/xntpd/compilers/domainos.cc b/usr.sbin/xntpd/compilers/domainos.cc
new file mode 100644
index 000000000000..eb4dd629860a
--- /dev/null
+++ b/usr.sbin/xntpd/compilers/domainos.cc
@@ -0,0 +1 @@
+COMPILER= cc
diff --git a/usr.sbin/xntpd/conf/Config.CHATHAM b/usr.sbin/xntpd/conf/Config.CHATHAM
index 41e6fc2aa340..b1f980be477b 100644
--- a/usr.sbin/xntpd/conf/Config.CHATHAM
+++ b/usr.sbin/xntpd/conf/Config.CHATHAM
@@ -89,9 +89,6 @@ RANLIB= ranlib
# to configure the particular clock drivers you want in the
# CLOCKDEFS= line below. This flag affects xntpd only.
#
-# There is an occurance of a call to rindex() in the daemon. You may
-# have to include a -Drindex=strrchr to get this to load right.
-#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
@@ -109,7 +106,7 @@ RANLIB= ranlib
# (for SunOS 4.1.1) that intercepts carrier-detect transitions
# generated by the pps signal. Only one of these flags should be defined.
#
-DEFS= -DUSELIBKVM -DDEBUG -DSTREAM -DREFCLOCK -DNO_SIGNED_CHAR_DECL -DPPS -DPPSDEV -DXNTP_RETROFIT_STDLIB -DHAVE_UNISTD_H
+DEFS= -DUSELIBKVM -DDEBUG -DSTREAM -DREFCLOCK -DNO_SIGNED_CHAR_DECL -DPPS -DPPSDEV -DXNTP_RETROFIT_STDLIB -DNTP_POSIX_SOURCE
#
# Authentication types supported. Choose from DES and MD5. If you
diff --git a/usr.sbin/xntpd/conf/Config.MONOMOY b/usr.sbin/xntpd/conf/Config.MONOMOY
index b9e075fbfce6..18dddffe6ff1 100644
--- a/usr.sbin/xntpd/conf/Config.MONOMOY
+++ b/usr.sbin/xntpd/conf/Config.MONOMOY
@@ -84,9 +84,6 @@ RANLIB= ranlib
# to configure the particular clock drivers you want in the
# CLOCKDEFS= line below. This flag affects xntpd only.
#
-# There is an occurance of a call to rindex() in the daemon. You may
-# have to include a -Drindex=strrchr to get this to load right.
-#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
@@ -104,7 +101,7 @@ RANLIB= ranlib
# the reference clock module (only one source of PPS signal should
# be used)
#
-DEFS= -DBSDI -DUSELIBKVM -DDEBUG -DREFCLOCK -DPPS -DCONFIG_FILE=\\"/usr/local/etc/xntp.conf\\" -DHAVE_UNISTD_H
+DEFS= -DBSDI -DUSELIBKVM -DDEBUG -DREFCLOCK -DPPS -DCONFIG_FILE=\\"/usr/local/etc/xntp.conf\\" -DNTP_POSIX_SOURCE
#
# Authentication types supported. Choose from DES and MD5. If you
diff --git a/usr.sbin/xntpd/conf/Config.TIGER b/usr.sbin/xntpd/conf/Config.TIGER
index c757ad90e186..29c6cbd28cbe 100644
--- a/usr.sbin/xntpd/conf/Config.TIGER
+++ b/usr.sbin/xntpd/conf/Config.TIGER
@@ -80,9 +80,6 @@ RANLIB= ranlib
# to configure the particular clock drivers you want in the
# CLOCKDEFS= line below. This flag affects xntpd only.
#
-# There is an occurance of a call to rindex() in the daemon. You may
-# have to include a -Drindex=strrchr to get this to load right.
-#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
@@ -100,7 +97,7 @@ RANLIB= ranlib
# the reference clock module (only one source of PPS signal should
# be used)
#
-DEFS= -DREFCLOCK -DS_CHAR_DEFINED -DREADKMEM -DDEBUG -DPLL -DXNTP_RETROFIT_STDLIB -DHAVE_UNISTD_H
+DEFS= -DREFCLOCK -DS_CHAR_DEFINED -DREADKMEM -DDEBUG -DPLL -DXNTP_RETROFIT_STDLIB -DNTP_POSIX_SOURCE
#
# Authentication types supported. Choose from DES and MD5. If you
diff --git a/usr.sbin/xntpd/conf/Config.TRURO b/usr.sbin/xntpd/conf/Config.TRURO
index 6caa2b82d62e..2fc258002096 100644
--- a/usr.sbin/xntpd/conf/Config.TRURO
+++ b/usr.sbin/xntpd/conf/Config.TRURO
@@ -86,9 +86,6 @@ RANLIB= : # ar does the work of ranlib under System V
# to configure the particular clock drivers you want in the
# CLOCKDEFS= line below. This flag affects xntpd only.
#
-# There is an occurance of a call to rindex() in the daemon. You may
-# have to include a -Drindex=strrchr to get this to load right.
-#
# To change the location of the configuration file, use a
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
#
@@ -109,7 +106,7 @@ RANLIB= : # ar does the work of ranlib under System V
# (for SunOS 4.1.1) that intercepts carrier-detect transitions
# generated by the pps signal. Only one of these flags should be defined.
#
-DEFS= -DDEBUG -DSTREAM -DREFCLOCK -DNO_SIGNED_CHAR_DECL -DSLEWALWAYS -DSOLARIS -DPPS -DSTUPID_SIGNAL -DXNTP_RETROFIT_STDLIB -DHAVE_UNISTD_H
+DEFS= -DDEBUG -DSTREAM -DREFCLOCK -DNO_SIGNED_CHAR_DECL -DSLEWALWAYS -DSOLARIS -DPPS -DSTUPID_SIGNAL -DXNTP_RETROFIT_STDLIB -DNTP_POSIX_SOURCE
#
# Authentication types supported. Choose from DES and MD5. If you
diff --git a/usr.sbin/xntpd/conf/Config.local b/usr.sbin/xntpd/conf/Config.local
index 4c5095c164da..12a6dfece755 100644
--- a/usr.sbin/xntpd/conf/Config.local
+++ b/usr.sbin/xntpd/conf/Config.local
@@ -182,7 +182,7 @@ DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DPPSPPS -DKERNEL_PLL
# under Ultrix 4.2a/3. If the MX4200 is removed, all the rest compile on a DEC
# OSF/1 Alpha.
#
-CLOCKDEFS= -DLOCAL_CLOCK -DAS2201PPS -DCHU -DGOES -DIRIG -DMX4200PPS -DOMEGA -DPSTCLK -DTPRO -DWWVBCLK -DMSFEESPPS -DLEITCH
+CLOCKDEFS= -DLOCAL_CLOCK -DAS2201PPS -DCHUPPS -DGOES -DIRIG -DMX4200PPS -DOMEGA -DPSTCLK -DTPRO -DWWVBCLK -DMSFEESPPS -DLEITCH
#
# Directory into which binaries should be installed (default /usr/local)
diff --git a/usr.sbin/xntpd/doc/xntpd.8 b/usr.sbin/xntpd/doc/xntpd.8
index b02101980d97..ff6386e38d7a 100644
--- a/usr.sbin/xntpd/doc/xntpd.8
+++ b/usr.sbin/xntpd/doc/xntpd.8
@@ -74,6 +74,12 @@ xntpd - Network Time Protocol daemon
] [
.B -t
.I trustedkey
+] [
+.B -v
+.I variable
+] [
+.B -V
+.I variable
]
.SH DESCRIPTION
.I Xntpd
@@ -140,6 +146,10 @@ to be used when synchronizing to broadcasts
specify a directory to be used for creating statistics files
.Ip -t 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
@@ -494,6 +504,31 @@ This command is obsolete and not available in this version of
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
@@ -1093,9 +1128,13 @@ fudge factor defines the phase offset of the sychnronisation character to the ac
time.
On the availability of PPS information the
.I time2
-fudge factor show the difference betwteen the PPS time stamp and the reception
-time stamp of the serial signal. This parameter is read only attempts to
-set this parameter will be ignored.
+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
@@ -1109,13 +1148,25 @@ from the receiver. Otherwise the leap second will be added (which is the default
.I ntpq
timecode variable
.PP
-The timecode variable in the ntpq read clock variable command contains several
-fields. The first field is the local time in Unix format. The second field is
-the offset to UTC (format HHMM). The currently active receiver flags are listed
-next. Additional feature flags of the receiver are optionally listed in paranthesis.
-The actual time code is enclosed in angle brackets < >. A qualification of the
-decoded time code format is following the time code. The last piece of information
-is the overall running time and the accumulated times for the clock event states.
+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
diff --git a/usr.sbin/xntpd/hints/linux b/usr.sbin/xntpd/hints/linux
new file mode 100644
index 000000000000..f243bd2110aa
--- /dev/null
+++ b/usr.sbin/xntpd/hints/linux
@@ -0,0 +1,29 @@
+
+Requirements: kernel 0.99.14 or newer, libc 4.5 or newer
+------------
+
+ With this configuration, xntp should build an run right out of the
+box (see generic hints for how-to), with one big limitation: tickadj doesn't
+work yet. This is especially painful since PCs are usually equipped with
+untuned, badly-drifting quartzes, values up to 200 ppm being no exception.
+Because the loop filter algorithms are limited to compensating no more than
+100 ppm, currently only one workaround is possible:
+ Compile your own kernel and adjust linux/include/linux/timex.h,
+line 67 (in pl14):
+
+#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
+
+ Since this is surely not true for your hardware, adjust the hundreds
+to match your quartz. Adding 100 compensates for a drift of -83.8 ppm
+(1/CLOCK_TICK_RATE). The number gets rounded to the nearest 100 so don't
+bother to tune any finer.
+
+Fixing tickadj is already in my work queue, so the previous comment should be
+obsolete RSN. If you really need to run xntp on any earlier versions of the
+kernel or libc, or have any other question not covered in the READMEs / hint
+files (sorry, necessary comment in the Linux community ;-) feel free to ask
+me (duwe@informatik.uni-erlangen.de)
+
+xntp3.3b of 1993/12/06 : remember to change #define ntp_adjtime adjtimex to
+__adjtimex in the Linux section (line 316). This is hopefully done if you
+(don't :-) see this paragraph in the xntp3.x distribution.
diff --git a/usr.sbin/xntpd/hints/sun4 b/usr.sbin/xntpd/hints/sun4
new file mode 100644
index 000000000000..6dc36ea5429d
--- /dev/null
+++ b/usr.sbin/xntpd/hints/sun4
@@ -0,0 +1,17 @@
+Notes on CPU clock oscillator tolerance with SunOS 4.1.1 and 4.1.3
+
+A bug in SunOS 4.1.1 results in the kernel time losing 1 microsecond
+per tick of the system clock. The bug was fixed (bugid 1094383) for
+SunOS 4.1.1 and corrected in SunOS 4.1.3. The easiest way to fix this
+is to replace the 4.1.1 binary clock.o with the corresponding 4.1.3
+binary. Without this change it is necessary to use the tickadj program
+included in this distribution with the -t 9999 option.
+
+The tickadj option will work in all cases except when the kernel has
+been modified to correct the CPU clock oscillator frequency using a
+1-pps signal from a precision source. The bugfix must be installed for
+this wrinkle to work properly.
+
+Dave Mills (mills@udle.edu)
+
+
diff --git a/usr.sbin/xntpd/include/l_stdlib.h b/usr.sbin/xntpd/include/l_stdlib.h
index 7a4383dcd2a3..89a8092853b5 100644
--- a/usr.sbin/xntpd/include/l_stdlib.h
+++ b/usr.sbin/xntpd/include/l_stdlib.h
@@ -38,7 +38,6 @@ extern long strtol P((char *, char **, int));
#if !defined(NTP_POSIX_SOURCE)
extern int atoi P((char *));
-extern void bcopy P((char *, char *, int));
extern int dup2 P((int, int));
extern int execve P((char *, char **,char **));
extern int fork P((void));
@@ -48,11 +47,13 @@ extern int qsort P((void *, int , int,
extern int rand P((void));
extern int setpgrp P((int, int));
extern void srand P((unsigned int));
+extern void bcopy P((char *, char *, int));
#endif
#ifndef bzero /* XXX macro prototyping clash */
extern void bzero P((char *, int));
extern int bcmp P((char *, char *, int));
+extern void bcopy P((char *, char *, int));
#endif
extern char *mktemp P((char *));
@@ -97,11 +98,13 @@ extern int setlinebuf P((FILE *));
#ifdef _ntp_string_h
#ifdef NTP_POSIX_SOURCE /* these are builtins */
+#ifndef NTP_NEED_BOPS /* but may be emulated by bops */
extern char *memcpy();
extern char *memset();
extern int memcmp();
#endif
#endif
+#endif
#ifdef _sys_socket_h
extern int bind P((int, struct sockaddr *, int));
@@ -192,7 +195,6 @@ extern int nlist P((char *, struct nlist *));
#ifndef NTP_POSIX_SOURCE
extern int atoi P((char *));
-extern void bcopy P((char *, char *, int));
extern void bzero P((char *, int));
extern int bcmp P((char *, char *, int));
extern void bcopy P((char *, char *, int));
@@ -224,5 +226,9 @@ extern char * getpass P((char *));
extern char * getpass P((char *));
#endif /* VAX */
+#ifdef SYS_DOMAINOS
+extern char * getpass P((char *));
+#endif /* SYS_DOMAINOS */
+
#endif /* l_stdlib_h */
diff --git a/usr.sbin/xntpd/include/ntp.h b/usr.sbin/xntpd/include/ntp.h
index 98a083aa17b8..310353f1cda2 100644
--- a/usr.sbin/xntpd/include/ntp.h
+++ b/usr.sbin/xntpd/include/ntp.h
@@ -328,7 +328,7 @@ struct peer {
#define FLAG_PREFER 0x80 /* this is the preferred peer */
/*
- * Definitions for the clear() routine. We use bzero() to clear
+ * Definitions for the clear() routine. We use memset() to clear
* the parts of the peer structure which go to zero. These are
* used to calculate the start address and length of the area.
*/
@@ -358,7 +358,8 @@ 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 /* reserved for Piete Brooks */
+#define REFCLK_MSF_EES 14 /* MSF EES M201, UK */
+#define REFCLK_GPSTM_TRUETIME 15 /* TrueTime GPS/TM-TMD */
/*
* We tell reference clocks from real peers by giving the reference
diff --git a/usr.sbin/xntpd/include/ntp_control.h b/usr.sbin/xntpd/include/ntp_control.h
index 89f62298d437..74f75f17f51a 100644
--- a/usr.sbin/xntpd/include/ntp_control.h
+++ b/usr.sbin/xntpd/include/ntp_control.h
@@ -163,9 +163,9 @@ struct ntp_control {
#define CS_SYSTEM 17
#define CS_KEYID 18
#define CS_REFSKEW 19
-#define CS_VERSION 20
+#define CS_VARLIST 20
-#define CS_MAXCODE CS_VERSION
+#define CS_MAXCODE CS_VARLIST
/*
* Peer variables we understand
@@ -204,8 +204,10 @@ struct ntp_control {
#define CP_SENT 32
#define CP_FILTERROR 33
#define CP_FLASH 34
-#define CP_DISP 35
-#define CP_MAXCODE CP_DISP
+#define CP_DISP 35
+#define CP_VARLIST 36
+
+#define CP_MAXCODE CP_VARLIST
/*
* Clock variables we understand
@@ -222,8 +224,9 @@ struct ntp_control {
#define CC_FUDGEVAL2 10
#define CC_FLAGS 11
#define CC_DEVICE 12
+#define CC_VARLIST 13
-#define CC_MAXCODE CC_DEVICE
+#define CC_MAXCODE CC_VARLIST
/*
* Definition of the structure used internally to hold trap information.
diff --git a/usr.sbin/xntpd/include/ntp_filegen.h b/usr.sbin/xntpd/include/ntp_filegen.h
index 263f56118f64..7281d597aaeb 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.6 1993/09/01 21:51:24 kardel Exp
+ * ntp_filegen.h,v 3.7 1994/01/25 19:04:16 kardel Exp
*
* definitions for NTP file generations support
*
diff --git a/usr.sbin/xntpd/include/ntp_machine.h b/usr.sbin/xntpd/include/ntp_machine.h
index 97f5729f4240..1c3983e4a9ef 100644
--- a/usr.sbin/xntpd/include/ntp_machine.h
+++ b/usr.sbin/xntpd/include/ntp_machine.h
@@ -1,4 +1,4 @@
-/* ntp_compat.h,v 3.1 1993/07/06 01:06:49 jbj Exp
+/* ntp_machine.h,v 3.1 1993/07/06 01:06:49 jbj Exp
* Collect all machine dependent idiosyncrasies in one place.
*/
@@ -41,21 +41,21 @@ Signaled IO - Signled IO defines.
UDP_BACKWARDS_SETOWN - SunOS 3.5 or Ultirx 2.0 system.
-WHICH TERMINAL MODEL TO USE - I would assume HAVE_POSIX_TTYS if
- NTP_POSIX_SOURCE was set but cann't. The
+WHICH TERMINAL MODEL TO USE - I would assume HAVE_TERMIOS if
+ NTP_POSIX_SOURCE was set but can't. The
posix tty driver is too restrictive on most systems.
It defined if you define STREAMS.
HAVE_SYSV_TTYS - Use SYSV termio.h
HAVE_BSD_TTYS - Use BSD stty.h
- HAVE_POSIX_TTYS - "struct termios" has c_line defined
+ HAVE_TERMIOS - Use POSIX termios.h
THIS MAKES PORTS TO NEW SYSTEMS EASY - You only have to wory about
- kernal mucking.
+ kernel mucking.
NTP_POSIX_SOURCE - Use POSIX functions over bsd functions and att functions.
This is NOT the same as _POSIX_SOURCE.
- It is much weeker!
+ It is much weaker!
STEP SLEW OR TWO STEP - The Default is to step.
@@ -80,11 +80,20 @@ INFO ON NEW KERNEL PLL SYS CALLS
NTP_SYSCALL_GET - SYS_ntp_gettime id
NTP_SYSCALL_ADJ - SYS_ntp_adjtime id
+HOW TO GET IP INTERFACE INFORMATION
+
+ Some UNIX V.4 machines implement a sockets library on top of
+ streams. For these systems, you must use send the SIOCGIFCONF down
+ the stream in an I_STR ioctl. This ususally also implies
+ USE_STREAMS_DEVICE FOR IF_CONFIG. Dell UNIX is a notable exception.
+
+ STREAMS_TLI - use ioctl(I_STR) to implement ioctl(SIOCGIFCONF)
+
WHAT DOES IOCTL(SIOCGIFCONF) RETURN IN THE BUFFER
UNIX V.4 machines implement a sockets library on top of streams.
When requesting the IP interface configuration with an ioctl(2) calll,
- an arrat of ifreq structures are placed in the provided buffer. Some
+ an array of ifreq structures are placed in the provided buffer. Some
implementations also place the length of the buffer information in
the first integer position of the buffer.
@@ -104,22 +113,28 @@ MISC
DOSYNCTODR - Resync TODR clock every hour.
RETSIGTYPE - Define signal function type.
NO_SIGNED_CHAR_DECL - No "signed char" see include/ntp.h
- LOCK_PROCESS - Have plock.
+ LOCK_PROCESS - Have plock.
UDP_WILDCARD_DELIVERY
- - these systems deliver broadcast pakets to the wildcard
+ - these systems deliver broadcast packets to the wildcard
port instead to a port bound to the interface bound
to the correct broadcast address - are these
implementations broken or did the spec change ?
- HAVE_UNISTD_H - Maybe should be part of NTP_POSIX_SOURCE ?
+DEFINITIONS FOR SYSTEM && PROCESSOR
+ STR_SYSTEM - value of system variable
+ STR_PROCESSOR - value of processor variable
You could just put the defines on the DEFS line in machines/<os> file.
-I don't since there are lost of different types compiler that a systemm might
-have, some that can do proto typing and others that cannot on the saem system.
-I get a chanse to twiddle some of the configuration paramasters at compile
-time based on compler/machine combinatsions by using this include file.
+I don't since there are lots of different types of compilers that a system might
+have, some that can do proto typing and others that cannot on the same system.
+I get a chance to twiddle some of the configuration parameters at compile
+time based on compiler/machine combinations by using this include file.
See convex, aix and sun configurations see how complex it get.
-
+
+Note that it _is_ considered reasonable to add some system-specific defines
+to the machine/<os> file if it would be too inconvenient to puzzle them out
+in this file.
+
*/
@@ -134,14 +149,17 @@ See convex, aix and sun configurations see how complex it get.
/*
* Keep USE_PROTOTYPES and _NO_PROTO in step.
*/
-#if defined(_NO_PROTO)&&defined(USE_PROTOTYPES)
+#if defined(_NO_PROTO) && defined(USE_PROTOTYPES)
#undef USE_PROTOTYPES
#endif
-#if !defined(_NO_PROTO)&&!defined(USE_PROTOTYPES)
+#if !defined(_NO_PROTO) && !defined(USE_PROTOTYPES)
#define USE_PROTOTYPES
#endif
#endif /*_BSD */
#define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/AIX"
+#endif
#endif /* RS6000 */
/*
@@ -149,6 +167,7 @@ See convex, aix and sun configurations see how complex it get.
* Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO
*/
#if defined(SYS_SUNOS4)
+#define NTP_NEED_BOPS
#define NO_SIGNED_CHAR_DECL
#define HAVE_LIBKVM
#define HAVE_MALLOC_H
@@ -156,6 +175,9 @@ See convex, aix and sun configurations see how complex it get.
#define RETSIGTYPE void
#define NTP_SYSCALL_GET 132
#define NTP_SYSCALL_ADJ 147
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/SunOS 4.x"
+#endif
#endif
/*
@@ -165,12 +187,16 @@ See convex, aix and sun configurations see how complex it get.
#undef HAVE_SIGNALED_IO
#undef USE_TTY_SIGPOLL
#undef USE_UDP_SIGPOLL
+#define STREAMS_TLI
#define NO_SIGNED_CHAR_DECL
#define STEP_SLEW /* TWO step */
#define RETSIGTYPE void
#define NTP_POSIX_SOURCE
#define HAVE_ATT_SETPGRP
#define HAVE_ATT_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/SINIX-M"
+#endif
#endif
/*
@@ -187,12 +213,15 @@ See convex, aix and sun configurations see how complex it get.
#define HAVE_ATT_SETPGRP
#define HAVE_ATT_NICE
#define UDP_WILDCARD_DELIVERY
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Solaris 2.x"
+#endif
#endif
/*
* Convex
*/
-#if defined(SYS_CONVEXOS10)||defined(SYS_CONVEXOS9)
+#if defined(SYS_CONVEXOS10) || defined(SYS_CONVEXOS9)
#define HAVE_SIGNALED_IO
#define HAVE_N_UN
#define HAVE_READKMEM
@@ -201,15 +230,18 @@ See convex, aix and sun configurations see how complex it get.
#define RETSIGTYPE int
#define NO_SIGNED_CHAR_DECL
#else
-#if defined(__stdc__)&&!defined(USE_PROTOTYPES)
+#if defined(__stdc__) && !defined(USE_PROTOTYPES)
#define USE_PROTOTYPES
#endif
-#if !defined(__stdc__)&&defined(USE_PROTOTYPES)
-#undef USE_PROTOTYPES
+#if !defined(__stdc__) && defined(USE_PROTOTYPES)
+#undef USE_PROTOTYPES
#endif
#define NTP_POSIX_SOURCE
#define HAVE_ATT_SETPGRP
#endif
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/ConvexOS"
+#endif
#endif
/*
@@ -224,6 +256,9 @@ See convex, aix and sun configurations see how complex it get.
#define HAVE_ATT_SETPGRP
#define HAVE_BSD_NICE
#define NTP_POSIX_SOURCE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/IRIX"
+#endif
#endif
/*
@@ -236,12 +271,16 @@ See convex, aix and sun configurations see how complex it get.
#define HAVE_BSD_NICE
#define RETSIGTYPE void
#define NTP_SYSCALLS_STD
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Ultrix"
+#endif
+#define HAVE_TERMIOS
#endif
/*
* AUX
*/
-#if defined(SYS_AUX2)||defined(SYS_AUX3)
+#if defined(SYS_AUX2) || defined(SYS_AUX3)
#define NO_SIGNED_CHAR_DECL
#define HAVE_READKMEM
#define HAVE_ATT_NICE
@@ -261,6 +300,9 @@ See convex, aix and sun configurations see how complex it get.
#define HAVE_BSD_TTYS
#define LOG_NTP LOG_LOCAL1
#define HAVE_SIGNALED_IO
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/AUX"
+#endif
#endif
/*
@@ -272,6 +314,9 @@ See convex, aix and sun configurations see how complex it get.
#define HAVE_BSD_NICE
#define HAVE_N_UN
#undef NTP_POSIX_SOURCE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Next"
+#endif
#endif
/*
@@ -280,7 +325,8 @@ See convex, aix and sun configurations see how complex it get.
#if defined(SYS_HPUX)
#define NTP_POSIX_SOURCE
#define HAVE_SIGNALED_IO
-#define HAVE_UNISTD_H
+#define getdtablesize() sysconf(_SC_OPEN_MAX)
+#define setlinebuf(f) setvbuf(f, NULL, _IOLBF, 0)
#define NO_SIGNED_CHAR_DECL
#define LOCK_PROCESS
#define HAVE_NO_NICE /* HPUX uses rtprio instead */
@@ -290,6 +336,9 @@ See convex, aix and sun configurations see how complex it get.
#else
#define HAVE_READKMEM
#endif
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/HPUX"
+#endif
#endif
/*
@@ -300,6 +349,11 @@ See convex, aix and sun configurations see how complex it get.
#define HAVE_LIBKVM
#define NTP_POSIX_SOURCE
#define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/BSDI"
+#endif
+#define HAVE_BSD_TTYS
+#define HAVE_TERMIOS
#endif
/*
@@ -311,8 +365,13 @@ See convex, aix and sun configurations see how complex it get.
#define NTP_POSIX_SOURCE
#define ADJTIME_IS_ACCURATE
#define HAVE_SYS_TIMEX_H
-#define ntp_adjtime adjtimex
+/* hope there will be a standard interface
+ * along with a standard name one day ! */
+#define ntp_adjtime __adjtimex
#define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Linux"
+#endif
#endif
/*
@@ -324,10 +383,13 @@ See convex, aix and sun configurations see how complex it get.
#define HAVE_READKMEM
#define NTP_POSIX_SOURCE
#define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/*BSD"
+#endif
#endif
/*
- * DECOSF1
+ * DEC AXP OSF/1
*/
#if defined(SYS_DECOSF1)
#define HAVE_SIGNALED_IO
@@ -335,15 +397,22 @@ See convex, aix and sun configurations see how complex it get.
#define NTP_POSIX_SOURCE
#define NTP_SYSCALLS_STD
#define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/DECOSF1"
+#endif
#endif
/*
* I386
+ * XXX - what OS?
*/
#if defined(SYS_I386)
#define HAVE_READKMEM
#define S_CHAR_DEFINED
#define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/I386"
+#endif
#endif
/*
@@ -352,6 +421,9 @@ See convex, aix and sun configurations see how complex it get.
#if defined(SYS_MIPS)
#define NOKMEM
#define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Mips"
+#endif
#endif
/*
@@ -359,6 +431,9 @@ See convex, aix and sun configurations see how complex it get.
*/
#if defined(SYS_SEQUENT)
#define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Sequent Dynix 3"
+#endif
#endif
/*
@@ -369,6 +444,7 @@ See convex, aix and sun configurations see how complex it get.
#ifndef HAVE_SYSV_TTYS
#define HAVE_SYSV_TTYS
#endif
+#define STREAMS_TLI
#define HAVE_ATT_SETPGRP
#define HAVE_SIGNALED_IO
#define USE_UDP_SIGPOLL
@@ -392,25 +468,35 @@ typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned long u_long;
#endif
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Sequent PTX"
+#endif
#endif
/*
- * Sony
+ * Sony NEWS
*/
#if defined(SYS_SONY)
#define NO_SIGNED_CHAR_DECL
#define HAVE_READKMEM
#define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Sony"
+#endif
#endif
/*
* VAX
+ * XXX - VMS?
*/
#if defined(SYS_VAX)
#define NO_SIGNED_CHAR_DECL
#define HAVE_READKMEM
#define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/VAX"
+#endif
#endif
/*
@@ -419,11 +505,9 @@ typedef unsigned long u_long;
#if defined(SYS_SVR4)
#define HAVE_ATT_SETPGRP
#define USE_PROTOTYPES
-#define HAVE_UNISTD_H
#define NTP_POSIX_SOURCE
#define HAVE_ATT_NICE
#define HAVE_READKMEM
-#define HAVE_SIGNALED_IO
#define USE_TTY_SIGPOLL
#define USE_UDP_SIGPOLL
#define STREAM
@@ -431,6 +515,31 @@ typedef unsigned long u_long;
#define LOCK_PROCESS
#define SYSV_TIMEOFDAY
#define SIZE_RETURNED_IN_BUFFER
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/SysVR4"
+#endif
+#endif
+
+/*
+ * DomainOS
+ */
+#if defined(SYS_DOMAINOS)
+#define HAVE_BSD_NICE
+#define NOKMEM
+#define HAVE_SIGNALED_IO
+#define HAVE_BSD_TTYS
+#define NTP_SYSCALLS_STD
+#define USE_PROTOTYPES
+#define UDP_WILDCARD_DELIVERY
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/DOMAINOS"
+#endif
+#endif
+
+#ifdef STREAM /* STREAM implies TERMIOS */
+#ifndef HAVE_TERMIOS
+#define HAVE_TERMIOS
+#endif
#endif
#ifndef RETSIGTYPE
@@ -450,8 +559,64 @@ typedef unsigned long u_long;
#endif
#endif /* NTP_SYSCALLS_STD */
-#if !defined(HAVE_ATT_NICE) && !defined(HAVE_BSD_NICE) && !defined(HAVE_NO_NICE)
+#if !defined(HAVE_ATT_NICE) \
+ && !defined(HAVE_BSD_NICE) \
+ && !defined(HAVE_NO_NICE)
ERROR You_must_define_one_of_the_HAVE_xx_NICE_defines
#endif
+#if !defined(HAVE_SYSV_TTYS) \
+ && !defined(HAVE_BSD_TTYS) \
+ && !defined(HAVE_TERMIOS)
+ ERROR no_tty_type_defined
+#endif
+
+
+#if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
+
+# if defined(XNTP_AUTO_ENDIAN)
+# include <netinet/in.h>
+
+# if BYTE_ORDER == BIG_ENDIAN
+# define XNTP_BIG_ENDIAN
+# endif
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define XNTP_LITTLE_ENDIAN
+# endif
+
+# else /* AUTO */
+
+# ifdef WORDS_BIGENDIAN
+# define XNTP_BIG_ENDIAN 1
+# else
+# define XNTP_LITTLE_ENDIAN 1
+# endif
+
+# endif /* AUTO */
+
+#endif /* !BIG && !LITTLE */
+
+/*
+ * Byte order woes. The DES code is sensitive to byte order. This
+ * used to be resolved by calling ntohl() and htonl() to swap things
+ * around, but this turned out to be quite costly on Vaxes where those
+ * things are actual functions. The code now straightens out byte
+ * order troubles on its own, with no performance penalty for little
+ * end first machines, but at great expense to cleanliness.
+ */
+#if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
+ /*
+ * Pick one or the other.
+ */
+ BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
+#endif
+
+#if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN)
+ /*
+ * Pick one or the other.
+ */
+ BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
+#endif
+
+
#endif /* __ntp_machine */
diff --git a/usr.sbin/xntpd/include/ntp_refclock.h b/usr.sbin/xntpd/include/ntp_refclock.h
index 96e63ac8bba8..cc026f5c742f 100644
--- a/usr.sbin/xntpd/include/ntp_refclock.h
+++ b/usr.sbin/xntpd/include/ntp_refclock.h
@@ -75,10 +75,10 @@ struct refclockstat {
LONG fudgeval2;
u_char currentstatus;
u_char lastevent;
- u_char unused[1];
+ u_char unused;
+ struct ctl_var *kv_list; /* additional variables */
};
-
/*
* Reference clock I/O structure. Used to provide an interface between
* the reference clock drivers and the I/O module.
diff --git a/usr.sbin/xntpd/include/ntp_select.h b/usr.sbin/xntpd/include/ntp_select.h
index 5dd18682104d..e3ce0e7e41bb 100644
--- a/usr.sbin/xntpd/include/ntp_select.h
+++ b/usr.sbin/xntpd/include/ntp_select.h
@@ -14,7 +14,7 @@
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
-#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
+#define FD_ZERO(p) memset((char *)(p), 0, sizeof(*(p)))
#endif
#endif /* _ntp_select_h */
diff --git a/usr.sbin/xntpd/include/ntp_stdlib.h b/usr.sbin/xntpd/include/ntp_stdlib.h
index fcccd6e7e7d0..0ec062581616 100644
--- a/usr.sbin/xntpd/include/ntp_stdlib.h
+++ b/usr.sbin/xntpd/include/ntp_stdlib.h
@@ -47,7 +47,7 @@ extern U_LONG calyearstart P((U_LONG));
extern const char *clockname P((int));
extern int clocktime P((int, int, int, int, int, U_LONG, U_LONG *, U_LONG *));
extern char * emalloc P((u_int));
-extern int getopt_l P((int, char **, char *));
+extern int ntp_getopt P((int, char **, char *));
extern void init_auth P((void));
extern void init_lib P((void));
extern void init_random P((void));
diff --git a/usr.sbin/xntpd/include/ntp_string.h b/usr.sbin/xntpd/include/ntp_string.h
index f17905ea8f71..cc2eec858069 100644
--- a/usr.sbin/xntpd/include/ntp_string.h
+++ b/usr.sbin/xntpd/include/ntp_string.h
@@ -1,29 +1,35 @@
/*
- * Define bcopy, bzero, and bcmp and string op's
+ * Define string ops: strchr strrchr memcmp memmove memset
*/
#ifndef _ntp_string_h
#define _ntp_string_h
-#ifdef NTP_POSIX_SOURCE
+#if defined(NTP_POSIX_SOURCE)
-#if defined(HAVE_MEMORY_H)
-#include <memory.h>
-#endif
+# if defined(HAVE_MEMORY_H)
+# include <memory.h>
+# endif
-#include <string.h>
+# include <string.h>
-#define bcopy(s1,s2,n) memcpy(s2, s1, n)
-#define bzero(s,n) memset(s, 0, n)
-#define bcmp(s1,s2,n) memcmp(s1, s2, n)
+#else
-#else /* NTP_POSIX_SOURCE */
+# include <strings.h>
+# define strchr(s,c) index(s,c)
+# define strrchr(s,c) rindex(s,c)
+# ifndef NTP_NEED_BOPS
+# define NTP_NEED_BOPS
+# endif
+#endif /* NTP_POSIX_SOURCE */
-#include <strings.h>
+#ifdef NTP_NEED_BOPS
-#define strrchr rindex
-#define strchr index
+# define memcmp(a,b,c) bcmp(a,b,c)
+# define memmove(t,f,c) bcopy(f,t,c)
+# define memset(a,x,c) if (x == 0x00) bzero(a,c); else ntp_memset((char*)a,x,c)
+void ntp_memset P((char *, int, int));
-#endif /* NTP_POSIX_SOURCE */
+#endif /* NTP_NEED_BOPS */
#endif /* _ntp_string_h */
diff --git a/usr.sbin/xntpd/include/ntpd.h b/usr.sbin/xntpd/include/ntpd.h
index 85a812520f52..f2c56af20b90 100644
--- a/usr.sbin/xntpd/include/ntpd.h
+++ b/usr.sbin/xntpd/include/ntpd.h
@@ -1,4 +1,4 @@
-/* ntpd.h,v 3.1 1993/07/06 01:07:03 jbj Exp
+/*
* ntpd.h - Prototypes for xntpd.
*/
@@ -21,6 +21,35 @@ extern void init_control P((void));
extern void process_control P((struct recvbuf *, int));
extern void report_event P((int, struct peer *));
+/* ntp_control.c */
+/*
+ * Structure for translation tables between internal system
+ * variable indices and text format.
+ */
+struct ctl_var {
+ u_short code;
+ u_short flags;
+ char *text;
+};
+/*
+ * Flag values
+ */
+#define CAN_READ 0x01
+#define CAN_WRITE 0x02
+
+#define DEF 0x20
+#define PADDING 0x40
+#define EOV 0x80
+
+#define RO (CAN_READ)
+#define WO (CAN_WRITE)
+#define RW (CAN_READ|CAN_WRITE)
+
+extern char * add_var P((struct ctl_var **, unsigned long, int));
+extern void free_varlist P((struct ctl_var *));
+extern void set_var P((struct ctl_var **, char *, unsigned long, int));
+extern void set_sys_var P((char *, unsigned long, int));
+
/* ntp_intres.c */
extern void ntp_intres P((void));
diff --git a/usr.sbin/xntpd/include/parse.h b/usr.sbin/xntpd/include/parse.h
index 9c8befee7b57..31041afe292f 100644
--- a/usr.sbin/xntpd/include/parse.h
+++ b/usr.sbin/xntpd/include/parse.h
@@ -1,9 +1,9 @@
/*
- * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.11 1993/11/11 11:20:18 kardel Exp
+ * /src/NTP/REPOSITORY/v3/include/parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp
*
- * parse.h,v 3.11 1993/11/11 11:20:18 kardel Exp
+ * parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp
*
- * Copyright (c) 1989,1990,1991,1992,1993
+ * Copyright (c) 1989,1990,1991,1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -15,7 +15,7 @@
#ifndef __PARSE_H__
#define __PARSE_H__
#if !(defined(lint) || defined(__GNUC__))
- static char parsehrcsid[]="parse.h,v 3.11 1993/11/11 11:20:18 kardel Exp FAU";
+ static char parsehrcsid[]="parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp FAU";
#endif
#include "ntp_types.h"
@@ -365,6 +365,12 @@ extern unsigned LONG pps_simple P((parse_t *, int status, timestamp_t *));
* History:
*
* parse.h,v
+ * Revision 3.13 1994/01/25 19:04:21 kardel
+ * 94/01/23 reconcilation
+ *
+ * Revision 3.12 1994/01/23 17:23:05 kardel
+ * 1994 reconcilation
+ *
* Revision 3.11 1993/11/11 11:20:18 kardel
* declaration fixes
*
diff --git a/usr.sbin/xntpd/include/parse_conf.h b/usr.sbin/xntpd/include/parse_conf.h
index 3cc634891e40..13cec551db34 100644
--- a/usr.sbin/xntpd/include/parse_conf.h
+++ b/usr.sbin/xntpd/include/parse_conf.h
@@ -1,9 +1,9 @@
/*
- * /src/NTP/REPOSITORY/v3/include/parse_conf.h,v 3.3 1993/10/22 14:27:10 kardel Exp
+ * /src/NTP/REPOSITORY/v3/include/parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp
*
- * parse_conf.h,v 3.3 1993/10/22 14:27:10 kardel Exp
+ * parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp
*
- * Copyright (c) 1993
+ * Copyright (c) 1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -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.3 1993/10/22 14:27:10 kardel Exp FAU";
+ static char dcfhrcsid[]="parse_conf.h,v 3.5 1994/01/25 19:04:23 kardel Exp FAU";
#endif
/*
diff --git a/usr.sbin/xntpd/include/sys/parsestreams.h b/usr.sbin/xntpd/include/sys/parsestreams.h
index 91786c163f85..d07e75cbf26f 100644
--- a/usr.sbin/xntpd/include/sys/parsestreams.h
+++ b/usr.sbin/xntpd/include/sys/parsestreams.h
@@ -1,9 +1,9 @@
/*
- * /src/NTP/REPOSITORY/v3/include/sys/parsestreams.h,v 3.9 1993/11/01 19:59:57 kardel Exp
+ * /src/NTP/REPOSITORY/v3/include/sys/parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp
*
- * parsestreams.h,v 3.9 1993/11/01 19:59:57 kardel Exp
+ * parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp
*
- * Copyright (c) 1989,1990,1991,1992,1993
+ * Copyright (c) 1989,1990,1991,1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -13,7 +13,7 @@
*/
#if !(defined(lint) || defined(__GNUC__))
- static char parse77hrcsid[]="parsestreams.h,v 3.9 1993/11/01 19:59:57 kardel Exp";
+ static char parse77hrcsid[]="parsestreams.h,v 3.11 1994/01/25 19:04:30 kardel Exp";
#endif
#undef PARSEKERNEL
diff --git a/usr.sbin/xntpd/kernel/Makefile.tmpl b/usr.sbin/xntpd/kernel/Makefile.tmpl
index 700efa6925c8..c40f810d5e65 100644
--- a/usr.sbin/xntpd/kernel/Makefile.tmpl
+++ b/usr.sbin/xntpd/kernel/Makefile.tmpl
@@ -1,6 +1,5 @@
#
-# /src/NTP/REPOSITORY/v3/kernel/Makefile.tmpl,v 3.4 1993/11/05 23:51:26 kardel Exp
-#
+# /src/NTP/REPOSITORY/v3/kernel/Makefile.tmpl,v 3.6 1994/01/25 19:04:35 kardel Exp
#
# parse routine that could be used in two places
#
@@ -28,7 +27,7 @@ all:
print "### STREAMS kernel modules ppsclock, ppsclocd or line disciplines must"; \
print "### be installed manually if needed"; \
print "### see kernel/README* for details"; \
- print "### The parse reclock implementation has their own support in"; \
+ print "### The parse refclock implementation has their own support in"; \
print "### parse/*."; } }'
clean:
diff --git a/usr.sbin/xntpd/kernel/tty_chu_STREAMS.c b/usr.sbin/xntpd/kernel/tty_chu_STREAMS.c
index eea792d91c6b..68661457156c 100644
--- a/usr.sbin/xntpd/kernel/tty_chu_STREAMS.c
+++ b/usr.sbin/xntpd/kernel/tty_chu_STREAMS.c
@@ -1,37 +1,54 @@
-/* tty_chu_STREAMS.c,v 3.1 1993/07/06 01:07:32 jbj Exp
- * CHU STREAMS module for SunOS 4.1.x
+/*
+ * CHU STREAMS module for SunOS
*
- * Version 2.1
+ * Version 2.3
*
- * Copyright 1991-1993, Nick Sayer
+ * Copyright 1991-1994, Nick Sayer
*
* Special thanks to Greg Onufer for his debug assists.
- * Special thanks to Matthias Urlichs for the loadable driver support
+ * Special thanks to Matthias Urlichs for the 4.1.x loadable driver support
* code.
+ * Special wet-noodle whippings to Sun for not properly documenting
+ * ANYTHING that makes this stuff at all possible.
*
* Should be PUSHed directly on top of a serial I/O channel.
* Provides complete chucode structures to user space.
*
* COMPILATION:
*
+ *
* To make a SunOS 4.1.x compatable loadable module (from the ntp kernel
* directory):
*
* % cc -c -I../include -DLOADABLE tty_chu_STREAMS.c
*
* The resulting .o file is the loadable module. Modload it
- * with -entry _chuinit.
+ * thusly:
+ *
+ * % modload tty_chu_STREAMS.o -entry _chuinit
+ *
+ * When none of the instances are pushed in a STREAM, you can
+ * modunload the driver in the usual manner if you wish.
+ *
+ * As an alternative to loading it dynamically you can compile it
+ * directly into the kernel by hacking str_conf.c. See the README
+ * file for more details on doing it the old fashioned way.
*
- * You can also add it into the kernel by hacking it into the streams
- * table in the kernel, then adding it to config:
*
- * pseudo-device chuN
+ * To make a Solaris 2.x compatable module (from the ntp kernel
+ * directory):
+ *
+ * % {gcc,cc} -c -I../include -DSOLARIS2 tty_chu_STREAMS.c
+ * % ld -r -o /usr/kernel/strmod/chu tty_chu_STREAMS.o
+ * % chmod 755 /usr/kernel/strmod/chu
+ *
+ * The OS will load it for you automagically when it is first pushed.
*
- * where N is the maximum number of concurent chu sessions you expect
- * to have.
*
* HISTORY:
*
+ * v2.3 - Added support for Solaris 2.x.
+ * v2.2 - Added SERVICE IMMEDIATE hack.
* v2.1 - Added 'sixth byte' heuristics.
* v2.0 - first version with an actual version number.
* Added support for new CHU 'second 31' data format.
@@ -39,13 +56,18 @@
*
*/
-#ifndef LOADABLE
-# include "chu.h"
-#else
+#ifdef SOLARIS2
+# ifndef NCHU
+# define NCHU 3
+# define _KERNEL
+# endif
+#elif defined(LOADABLE)
# ifndef NCHU
# define NCHU 3
# define KERNEL
# endif
+#else
+# include "chu.h"
#endif
#if NCHU > 0
@@ -61,12 +83,35 @@
#include <sys/stream.h>
#include <sys/param.h>
#include <sys/time.h>
-#include <sys/kernel.h>
#include <sys/errno.h>
#include <sys/user.h>
+#include <syslog.h>
+#include <sys/tty.h>
#include <sys/chudefs.h>
+#ifdef SOLARIS2
+
+#include <sys/conf.h>
+#include <sys/strtty.h>
+#include <sys/modctl.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+#endif
+
+#ifdef LOADABLE
+
+#include <sys/kernel.h>
+#include <sys/conf.h>
+#include <sys/buf.h>
+#include <sundev/mbvar.h>
+#include <sun/autoconf.h>
+#include <sun/vddrv.h>
+
+#endif
+
+
static struct module_info rminfo = { 0, "chu", 0, INFPSZ, 0, 0 };
static struct module_info wminfo = { 0, "chu", 0, INFPSZ, 0, 0 };
static int chuopen(), churput(), chuwput(), chuclose();
@@ -88,14 +133,67 @@ struct priv_data
struct chucode chu_struct;
} our_priv_data[NCHU];
+#ifdef SOLARIS2
+
+static struct fmodsw fsw =
+{
+ "chu",
+ &chuinfo,
+ D_NEW
+};
+
+extern struct mod_ops mod_strmodops;
+
+static struct modlstrmod modlstrmod =
+{
+ &mod_strmodops,
+ "CHU timecode decoder v2.3",
+ &fsw
+};
+
+static struct modlinkage modlinkage =
+{
+ MODREV_1,
+ (void*) &modlstrmod,
+ NULL
+};
+
+int _init()
+{
+ int i;
+
+ for (i=0; i<NCHU; i++)
+ our_priv_data[i].in_use=0;
+
+ return mod_install(&modlinkage);
+}
+
+int _info(foo)
+struct modinfo *foo;
+{
+ return mod_info(&modlinkage,foo);
+}
+
+int _fini()
+{
+ int dev;
+
+ for (dev = 0; dev < NCHU; dev++)
+ if (our_priv_data[dev].in_use)
+ {
+ /* One of the modules is still open */
+ /* This is likely supposed to be impossible under Solaris 2.x */
+ return (EBUSY);
+ }
+
+ return mod_remove(&modlinkage);
+}
+
+#endif /* SOLARIS2 */
+
#ifdef LOADABLE
-#ifdef sun
-#include <sys/conf.h>
-#include <sys/buf.h>
-#include <sundev/mbvar.h>
-#include <sun/autoconf.h>
-#include <sun/vddrv.h>
+# ifdef sun
static struct vdldrv vd =
{
@@ -163,9 +261,11 @@ chuinit (fc, vdp, vdi, vds)
}
}
-#endif
+# endif /* sun */
-#else
+#endif /* LOADABLE */
+
+#if !defined(LOADABLE) && !defined(SOLARIS2)
char chu_first_open=1;
@@ -180,7 +280,7 @@ int sflag;
{
int i;
-#ifndef LOADABLE
+#if !defined(LOADABLE) && !defined(SOLARIS2)
if (chu_first_open)
{
chu_first_open=0;
@@ -196,11 +296,25 @@ int sflag;
((struct priv_data *) (q->q_ptr))=&(our_priv_data[i]);
our_priv_data[i].in_use++;
our_priv_data[i].chu_struct.ncodechars = 0;
+ if (!putctl1(WR(q)->q_next, M_CTL, MC_SERVICEIMM))
+ {
+ our_priv_data[i].in_use=0;
+#ifdef SOLARIS2
+ return (EFAULT);
+#else
+ u.u_error = EFAULT;
+ return (OPENFAIL);
+#endif
+ }
return 0;
}
+#ifdef SOLARIS2
+ return (EBUSY);
+#else
u.u_error = EBUSY;
return (OPENFAIL);
+#endif
}
@@ -282,7 +396,12 @@ queue_t *q;
if (mp==NULL)
{
+#ifdef SOLARIS2
+ /* XXX we can't log it because strlog() is too complicated. This isn't
+ supposed to happen anyway. The hell with it. */
+#else
log(LOG_ERR,"chu: cannot allocate message");
+#endif
return;
}
@@ -441,4 +560,4 @@ queue_t *q;
}
}
-#endif
+#endif /* NCHU > 0 */
diff --git a/usr.sbin/xntpd/kernel/tty_clk_STREAMS.c b/usr.sbin/xntpd/kernel/tty_clk_STREAMS.c
index f41af285dc3b..a69a7573be45 100644
--- a/usr.sbin/xntpd/kernel/tty_clk_STREAMS.c
+++ b/usr.sbin/xntpd/kernel/tty_clk_STREAMS.c
@@ -62,7 +62,7 @@ struct priv_data_type
char first_open=1;
/*
- * God only knows why, but linking with strchr() and index() fail
+ * God only knows why, but linking with strchr() fails
* on my system, so here's a renamed copy.
*/
diff --git a/usr.sbin/xntpd/lib/a_md512crypt.c b/usr.sbin/xntpd/lib/a_md512crypt.c
index a3714a24085e..6033dedcff44 100644
--- a/usr.sbin/xntpd/lib/a_md512crypt.c
+++ b/usr.sbin/xntpd/lib/a_md512crypt.c
@@ -80,7 +80,8 @@ MD5auth2crypt(keyno, pkt, length)
MD5Update(&ctx, (char *)(pkt) + length - 8, 8);
MD5Final(&ctx);
- bcopy((char *)ctx.digest, (char *) &pkt[NOCRYPT_LONGS + length/sizeof(U_LONG)],
- BLOCK_OCTETS);
- return 4 + BLOCK_OCTETS;
+ memmove((char *) &pkt[NOCRYPT_LONGS + length/sizeof(U_LONG)],
+ (char *) ctx.digest,
+ BLOCK_OCTETS);
+ return (4 + BLOCK_OCTETS);
}
diff --git a/usr.sbin/xntpd/lib/a_md5decrypt.c b/usr.sbin/xntpd/lib/a_md5decrypt.c
index 892e52e60624..dc7acf6e44bb 100644
--- a/usr.sbin/xntpd/lib/a_md5decrypt.c
+++ b/usr.sbin/xntpd/lib/a_md5decrypt.c
@@ -54,5 +54,7 @@ MD5authdecrypt(keyno, pkt, length)
MD5Update(&ctx, (char *)pkt, length);
MD5Final(&ctx);
- return (0 == bcmp((char *)ctx.digest, (char *)pkt + length + 4, BLOCK_OCTETS));
+ return (!memcmp((char *)ctx.digest,
+ (char *)pkt + length + 4,
+ BLOCK_OCTETS));
}
diff --git a/usr.sbin/xntpd/lib/a_md5encrypt.c b/usr.sbin/xntpd/lib/a_md5encrypt.c
index a26e8f0d2afc..2ae625810339 100644
--- a/usr.sbin/xntpd/lib/a_md5encrypt.c
+++ b/usr.sbin/xntpd/lib/a_md5encrypt.c
@@ -63,6 +63,8 @@ MD5authencrypt(keyno, pkt, length)
MD5Update(&ctx, (char *)pkt, length);
MD5Final(&ctx);
- bcopy((char *)ctx.digest, (char *) &pkt[NOCRYPT_LONGS + len], BLOCK_OCTETS);
- return 4 + BLOCK_OCTETS; /* return size of key and MAC */
+ memmove((char *)&pkt[NOCRYPT_LONGS + len],
+ (char *)ctx.digest,
+ BLOCK_OCTETS);
+ return (4 + BLOCK_OCTETS); /* return size of key and MAC */
}
diff --git a/usr.sbin/xntpd/lib/authdes.c b/usr.sbin/xntpd/lib/authdes.c
index 36077fc0adaf..9f64c403c84c 100644
--- a/usr.sbin/xntpd/lib/authdes.c
+++ b/usr.sbin/xntpd/lib/authdes.c
@@ -3,30 +3,6 @@
*/
#include "ntp_stdlib.h"
-#if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
-
-#if defined(XNTP_AUTO_ENDIAN)
-#include <netinet/in.h>
-
-#if BYTE_ORDER == BIG_ENDIAN
-#define XNTP_BIG_ENDIAN
-#endif
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define XNTP_LITTLE_ENDIAN
-#endif
-
-#else /* AUTO */
-
-#ifdef WORDS_BIGENDIAN
-#define XNTP_BIG_ENDIAN 1
-#else
-#define XNTP_LITTLE_ENDIAN 1
-#endif
-
-#endif /* AUTO */
-
-#endif /* !BIG && !LITTLE */
-
/*
* There are two entries in here. auth_subkeys() called to
* compute the encryption and decryption key schedules, while
@@ -34,28 +10,6 @@
*/
/*
- * Byte order woes. The DES code is sensitive to byte order. This
- * used to be resolved by calling ntohl() and htonl() to swap things
- * around, but this turned out to be quite costly on Vaxes where those
- * things are actual functions. The code now straightens out byte
- * order troubles on its own, with no performance penalty for little
- * end first machines, but at great expense to cleanliness.
- */
-#if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
- /*
- * Pick one or the other.
- */
- BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
-#endif
-
-#if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN)
- /*
- * Pick one or the other.
- */
- BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
-#endif
-
-/*
* Key setup. Here we entirely permute a key, saving the results
* for both the encryption and decryption. Note that while the
* decryption subkeys are simply the encryption keys reordered,
diff --git a/usr.sbin/xntpd/lib/authdes.c.export b/usr.sbin/xntpd/lib/authdes.c.export
index b0323a0a6be1..a63c6d3839c5 100644
--- a/usr.sbin/xntpd/lib/authdes.c.export
+++ b/usr.sbin/xntpd/lib/authdes.c.export
@@ -15,6 +15,7 @@
* to its exportable state, copy this file to authdes.c .
*/
#include <sys/types.h>
+#include "ntp_stdlib.h"
/*
* This routine is normally called to compute the key schedule.
diff --git a/usr.sbin/xntpd/lib/authkeys.c b/usr.sbin/xntpd/lib/authkeys.c
index 2d46eee3931e..743af83ba6e1 100644
--- a/usr.sbin/xntpd/lib/authkeys.c
+++ b/usr.sbin/xntpd/lib/authkeys.c
@@ -109,7 +109,7 @@ init_auth()
/*
* Initialize hash table and free list
*/
- bzero((char *)key_hash, sizeof key_hash);
+ memset((char *)key_hash, 0, sizeof key_hash);
cache_flags = cache_keyid = 0;
authnumfreekeys = authkeynotfound = authkeylookups = 0;
diff --git a/usr.sbin/xntpd/lib/authusekey.c b/usr.sbin/xntpd/lib/authusekey.c
index 0452031fb05e..c268c4d2455c 100644
--- a/usr.sbin/xntpd/lib/authusekey.c
+++ b/usr.sbin/xntpd/lib/authusekey.c
@@ -96,7 +96,7 @@ authusekey(keyno, keytype, str)
/*
* Make up key from ascii representation
*/
- bzero((char *) keybytes, sizeof(keybytes));
+ memset((char *) keybytes, 0, sizeof(keybytes));
for (i = 0; i < 8 && i < len; i++)
keybytes[i] = *cp++ << 1;
key[0] = (U_LONG)keybytes[0] << 24 | (U_LONG)keybytes[1] << 16
diff --git a/usr.sbin/xntpd/lib/clocktypes.c b/usr.sbin/xntpd/lib/clocktypes.c
index f6fc003699ce..2701e3f1d0ef 100644
--- a/usr.sbin/xntpd/lib/clocktypes.c
+++ b/usr.sbin/xntpd/lib/clocktypes.c
@@ -24,6 +24,7 @@ struct clktype clktypes[] = {
{ 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" },
{ -1, "", "" }
};
diff --git a/usr.sbin/xntpd/lib/dofptoa.c b/usr.sbin/xntpd/lib/dofptoa.c
index c6e317f69d43..a496df85dd5b 100644
--- a/usr.sbin/xntpd/lib/dofptoa.c
+++ b/usr.sbin/xntpd/lib/dofptoa.c
@@ -31,7 +31,7 @@ dofptoa(fpv, neg, ndec, msec)
/*
* Zero out the buffer
*/
- bzero((char *)cbuf, sizeof cbuf);
+ memset((char *)cbuf, 0, sizeof cbuf);
/*
* Set the pointers to point at the first
diff --git a/usr.sbin/xntpd/lib/dolfptoa.c b/usr.sbin/xntpd/lib/dolfptoa.c
index ff341536ee68..ff37c9f1e1e6 100644
--- a/usr.sbin/xntpd/lib/dolfptoa.c
+++ b/usr.sbin/xntpd/lib/dolfptoa.c
@@ -32,7 +32,7 @@ dolfptoa(fpi, fpv, neg, ndec, msec)
/*
* Zero the character buffer
*/
- bzero((char *) cbuf, sizeof(cbuf));
+ memset((char *) cbuf, 0, sizeof(cbuf));
/*
* Work on the integral part. This is biased by what I know
diff --git a/usr.sbin/xntpd/lib/getopt.c b/usr.sbin/xntpd/lib/getopt.c
index 0ab3c2917fc3..5519235180fa 100644
--- a/usr.sbin/xntpd/lib/getopt.c
+++ b/usr.sbin/xntpd/lib/getopt.c
@@ -4,7 +4,9 @@
* This is a version of the public domain getopt() implementation by
* Henry Spencer, changed for 4.3BSD compatibility (in addition to System V).
* It allows rescanning of an option list by setting optind to 0 before
- * calling. Thanks to Dennis Ferguson for the appropriate modifications.
+ * calling, which is why we use it even if the system has its own (in fact,
+ * this one has a unique name so as not to conflict with the system's).
+ * Thanks to Dennis Ferguson for the appropriate modifications.
*
* This file is in the Public Domain.
*/
@@ -20,39 +22,33 @@
#define putc fputc
#endif /* lint */
-char *optarg; /* Global argument pointer. */
-#ifndef __convex__
-int optind = 0; /* Global argv index. */
-#else /* __convex__ */
-extern int optind; /* Global argv index. */
-#endif /* __convex__ */
-
-/*
- * N.B. use following at own risk
- */
-#ifndef __convex__
-int opterr = 1; /* for compatibility, should error be printed? */
-#else /* __convex__ */
-extern int opterr; /* for compatibility, should error be printed? */
-#endif /* __convex__ */
-int optopt; /* for compatibility, option character checked */
+char *ntp_optarg; /* Global argument pointer. */
+int ntp_optind = 0; /* Global argv index. */
+int ntp_opterr = 1; /* for compatibility, should error be printed? */
+int ntp_optopt; /* for compatibility, option character checked */
static char *scan = NULL; /* Private scan pointer. */
+static char *prog = "amnesia";
/*
- * Print message about a bad option. Watch this definition, it's
- * not a single statement.
+ * Print message about a bad option.
*/
-#define BADOPT(mess, ch) if (opterr) { \
- fputs(argv[0], stderr); \
- fputs(mess, stderr); \
- (void) putc(ch, stderr); \
- (void) putc('\n', stderr); \
- } \
- return('?')
+static int
+badopt(mess, ch)
+ char *mess;
+ int ch;
+{
+ if (ntp_opterr) {
+ fputs(prog, stderr);
+ fputs(mess, stderr);
+ (void) putc(ch, stderr);
+ (void) putc('\n', stderr);
+ }
+ return ('?');
+}
int
-getopt_l(argc, argv, optstring)
+ntp_getopt(argc, argv, optstring)
int argc;
char *argv[];
char *optstring;
@@ -60,47 +56,50 @@ getopt_l(argc, argv, optstring)
register char c;
register char *place;
- optarg = NULL;
+ prog = argv[0];
+ ntp_optarg = NULL;
- if (optind == 0) {
+ if (ntp_optind == 0) {
scan = NULL;
- optind++;
+ ntp_optind++;
}
if (scan == NULL || *scan == '\0') {
- if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
- return EOF;
- if (argv[optind][1] == '-' && argv[optind][2] == '\0') {
- optind++;
- return EOF;
+ if (ntp_optind >= argc
+ || argv[ntp_optind][0] != '-'
+ || argv[ntp_optind][1] == '\0') {
+ return (EOF);
+ }
+ if (argv[ntp_optind][1] == '-'
+ && argv[ntp_optind][2] == '\0') {
+ ntp_optind++;
+ return (EOF);
}
- scan = argv[optind]+1;
- optind++;
+ scan = argv[ntp_optind++]+1;
}
c = *scan++;
- optopt = c & 0377;
+ ntp_optopt = c & 0377;
for (place = optstring; place != NULL && *place != '\0'; ++place)
if (*place == c)
break;
if (place == NULL || *place == '\0' || c == ':' || c == '?') {
- BADOPT(": unknown option -", c);
+ return (badopt(": unknown option -", c));
}
place++;
if (*place == ':') {
if (*scan != '\0') {
- optarg = scan;
+ ntp_optarg = scan;
scan = NULL;
- } else if (optind >= argc) {
- BADOPT(": option requires argument -", c);
+ } else if (ntp_optind >= argc) {
+ return (badopt(": option requires argument -", c));
} else {
- optarg = argv[optind];
- optind++;
+ ntp_optarg = argv[ntp_optind++];
}
}
- return c&0377;
+ return (c & 0377);
}
diff --git a/usr.sbin/xntpd/lib/machines.c b/usr.sbin/xntpd/lib/machines.c
index f7a400c1d5db..5e0169441fec 100644
--- a/usr.sbin/xntpd/lib/machines.c
+++ b/usr.sbin/xntpd/lib/machines.c
@@ -1,118 +1,43 @@
-/*
- * provide special support for peculiar architectures
+/* machines.c - provide special support for peculiar architectures
*
* Real bummers unite !
+ *
+ * $Id:$
*/
+#include "ntp_stdlib.h"
+
#ifdef SYS_PTX
#include <sys/types.h>
#include <sys/procstats.h>
-int settimeofday(tvp)
+
+int
+settimeofday(tvp)
struct timeval *tvp;
{
- return stime(&tvp->tv_sec); /* lie as bad as SysVR4 */
+ return (stime(&tvp->tv_sec)); /* lie as bad as SysVR4 */
}
-int gettimeofday(tvp)
+int
+gettimeofday(tvp)
struct timeval *tvp;
{
/*
* hi, this is Sequents sneak path to get to a clock
* this is also the most logical syscall for such a function
*/
- return get_process_stats(tvp, PS_SELF, (struct procstats *) 0,
- (struct procstats *) 0);
+ return (get_process_stats(tvp, PS_SELF, (struct procstats *) 0,
+ (struct procstats *) 0));
}
#endif
-#ifdef SYS_HPUX
-/* hpux.c,v 3.1 1993/07/06 01:08:23 jbj Exp
- * hpux.c -- compatibility routines for HP-UX.
- * XXX many of these are not needed anymore.
- */
-#include "ntp_machine.h"
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdio.h>
-
-#include "ntp_stdlib.h"
-
-#if (SYS_HPUX < 8)
-char
-*index(s, c)
-register char *s;
-register int c;
+#if !defined(NTP_POSIX_SOURCE) || defined(NTP_NEED_BOPS)
+void
+ntp_memset(a, x, c)
+ char *a;
+ int x, c;
{
- return strchr (s, c);
+ while (c-- > 0)
+ *a++ = x;
}
-
-
-char
-*rindex(s, c)
-register char *s;
-register int c;
-{
- return strrchr (s, c);
-}
-
-
-int
-bcmp(a, b, count)
-register char *a, *b;
-register int count;
-{
- return memcmp (a, b, count);
-}
-
-
-void
-bcopy(from, to, count)
-register char *from;
-register char *to;
-register int count;
-{
- if ((to == from) || (count <= 0))
- return;
-
- if ((to > from) && (to <= (from + count))) {
- to += count;
- from += count;
-
- do {
- *--to = *--from;
- } while (--count);
- }
- else {
- do {
- *to++ = *from++;
- } while (--count);
- }
-}
-
-
-void
-bzero(area, count)
-register char *area;
-register int count;
-{
- memset(area, 0, count);
-}
-#endif
-
-
-getdtablesize()
-{
- return(sysconf(_SC_OPEN_MAX));
-}
-
-
-int
-setlinebuf(a_stream)
- FILE *a_stream;
-{
- return setvbuf(a_stream, (char *) NULL, _IOLBF, 0);
-}
-
-#endif
+#endif /*POSIX*/
diff --git a/usr.sbin/xntpd/lib/msyslog.c b/usr.sbin/xntpd/lib/msyslog.c
index a8df27d3b9fc..a6186b72ef34 100644
--- a/usr.sbin/xntpd/lib/msyslog.c
+++ b/usr.sbin/xntpd/lib/msyslog.c
@@ -81,7 +81,8 @@ void msyslog(va_alist)
n += strlen(err);
}
}
- *n++ = '\n';
+ if (!syslogit)
+ *n++ = '\n';
*n = '\0';
vsprintf(buf, nfmt, ap);
diff --git a/usr.sbin/xntpd/lib/numtohost.c b/usr.sbin/xntpd/lib/numtohost.c
index c8b532f1fd7c..e22b6231790a 100644
--- a/usr.sbin/xntpd/lib/numtohost.c
+++ b/usr.sbin/xntpd/lib/numtohost.c
@@ -1,7 +1,7 @@
/* numtohost.c,v 3.1 1993/07/06 01:08:40 jbj Exp
* numtohost - convert network number to host name.
*/
-#include <string.h>
+#include "ntp_types.h"
#include <netdb.h>
#include "ntp_fp.h"
diff --git a/usr.sbin/xntpd/lib/systime.c b/usr.sbin/xntpd/lib/systime.c
index 99e715a54a02..ea15734f1abb 100644
--- a/usr.sbin/xntpd/lib/systime.c
+++ b/usr.sbin/xntpd/lib/systime.c
@@ -3,7 +3,7 @@
*/
#include <sys/types.h>
#include <sys/time.h>
-#if defined(SYS_HPUX) || defined(sgi) || defined(__bsdi__)
+#if defined(SYS_HPUX) || defined(sgi) || defined(SYS_BSDI)
#include <sys/param.h>
#include <utmp.h>
#endif
@@ -238,36 +238,40 @@ adj_systime(ts)
#endif
}
- sys_clock_offset.l_ui = offset_i;
- sys_clock_offset.l_uf = offset_f;
-
if (adjtime(&adjtv, &oadjtv) < 0) {
syslog(LOG_ERR, "Can't do time adjustment: %m");
rval = 0;
- } else
+ } else {
+ sys_clock_offset.l_ui = offset_i;
+ sys_clock_offset.l_uf = offset_f;
rval = 1;
#ifdef DEBUGRS6000
- syslog(LOG_ERR, "adj_systime(%s): offset = %s%s\n",
- mfptoa((adj<0?-1:0), adj, 9), isneg?"-":"",
- umfptoa(offset_i, offset_f, 9));
- syslog(LOG_ERR, "%d %d %d %d\n", (int) adjtv.tv_sec,
- (int) adjtv.tv_usec, (int) oadjtv.tv_sec, (int)
- oadjtv.tv_usec);
+ syslog(LOG_ERR, "adj_systime(%s): offset = %s%s\n",
+ mfptoa((adj<0?-1:0), adj, 9), isneg?"-":"",
+ umfptoa(offset_i, offset_f, 9));
+ syslog(LOG_ERR, "%d %d %d %d\n", (int) adjtv.tv_sec,
+ (int) adjtv.tv_usec, (int) oadjtv.tv_sec, (int)
+ oadjtv.tv_usec);
#endif /* DEBUGRS6000 */
- if ((oadjtv.tv_sec != 0 || oadjtv.tv_usec != 0) && (max_no_complete > 0)) {
- sTVTOTS(&oadjtv, &oadjts);
- L_ADD(&sys_clock_offset, &oadjts);
- syslog(LOG_WARNING, "Previous time adjustment didn't complete");
+ if (oadjtv.tv_sec != 0 || oadjtv.tv_usec != 0) {
+ sTVTOTS(&oadjtv, &oadjts);
+ L_ADD(&sys_clock_offset, &oadjts);
+ if (max_no_complete > 0) {
+ syslog(LOG_WARNING,
+ "Previous time adjustment didn't complete");
#ifdef DEBUG
- if (debug > 4)
- syslog(LOG_DEBUG,
- "Previous adjtime() incomplete, residual = %s\n",
- tvtoa(&oadjtv));
+ if (debug > 4)
+ syslog(LOG_DEBUG,
+ "Previous adjtime() incomplete, residual = %s\n",
+ tvtoa(&oadjtv));
#endif
- if (--max_no_complete == 0) syslog(LOG_WARNING,
- "*** No more 'Prev time adj didn't complete'");
+ if (--max_no_complete == 0)
+ syslog(LOG_WARNING,
+ "*** No more 'Prev time adj didn't complete'");
+ }
+ }
}
return(rval);
}
@@ -345,7 +349,7 @@ step_systime_real(ts)
* is greater than one second.
*/
if (oldtime != timetv.tv_sec) {
- bzero((char *)&ut, sizeof(ut));
+ memset((char *)&ut, 0, sizeof(ut));
ut.ut_type = OLD_TIME;
ut.ut_time = oldtime;
(void)strcpy(ut.ut_line, OTIME_MSG);
diff --git a/usr.sbin/xntpd/machines/README b/usr.sbin/xntpd/machines/README
index d40d8cb0f652..b12db88d9c61 100644
--- a/usr.sbin/xntpd/machines/README
+++ b/usr.sbin/xntpd/machines/README
@@ -2,4 +2,4 @@ README file for directory ./machines of the NTP Version 3 distribution
This directory contains configuration files for the various machines
and compilers supported by the distribution. README and RELNOTES files in the
-parent directory for directions on how to use these files.
+parent directory contain directions on how to use these files.
diff --git a/usr.sbin/xntpd/machines/aix3.2 b/usr.sbin/xntpd/machines/aix3.2
index 70607d81a6bc..93a0181ca63d 100644
--- a/usr.sbin/xntpd/machines/aix3.2
+++ b/usr.sbin/xntpd/machines/aix3.2
@@ -1,6 +1,6 @@
RANLIB= :
DEFS_LOCAL= -DREFCLOCK
-DEFS= -DRS6000 -DSYS_AIX
+DEFS= -DRS6000 -DSYS_AIX -DHAVE_TERMIOS
AUTHDEFS= -DDES -DMD5
CLOCKDEFS= -DLOCAL_CLOCK
DAEMONLIBS=
diff --git a/usr.sbin/xntpd/machines/bsdi b/usr.sbin/xntpd/machines/bsdi
index 040bab4fe155..e948376c6cd7 100644
--- a/usr.sbin/xntpd/machines/bsdi
+++ b/usr.sbin/xntpd/machines/bsdi
@@ -5,5 +5,4 @@ AUTHDEFS= -DDES -DMD5
CLOCKDEFS= -DLOCAL_CLOCK
DAEMONLIBS= -lkvm
RESLIB=
-COPTS= -g
-
+COPTS= -g -O
diff --git a/usr.sbin/xntpd/machines/dell.svr4 b/usr.sbin/xntpd/machines/dell.svr4
new file mode 100644
index 000000000000..81ab4a15ca2b
--- /dev/null
+++ b/usr.sbin/xntpd/machines/dell.svr4
@@ -0,0 +1,9 @@
+SHELL= /bin/sh
+RANLIB= ls # ar does the work of ranlib under System V
+DEFS_LOCAL= -DREFCLOCK
+DEFS= -DSYS_SVR4
+AUTHDEFS= -DDES -DMD5
+CLOCKDEFS= -DLOCAL_CLOCK
+DAEMONLIBS=
+RESLIB= -lnsl -lsocket -lelf
+INSTALL= /usr/ucb/install
diff --git a/usr.sbin/xntpd/machines/domainos b/usr.sbin/xntpd/machines/domainos
new file mode 100644
index 000000000000..6bc8f66e830a
--- /dev/null
+++ b/usr.sbin/xntpd/machines/domainos
@@ -0,0 +1,7 @@
+RANLIB= ranlib
+DEFS_LOCAL= -DREFCLOCK
+DEFS= -DSYS_DOMAINOS -D_INCLUDE_BSD_SOURCE -D_INCLUDE_XOPEN_SOURCE -D_INCLUDE_POSIX_SOURCE
+AUTHDEFS= -DDES -DMD5
+CLOCKDEFS= -DLOCAL_CLOCK
+DAEMONLIBS=
+COMPAT=
diff --git a/usr.sbin/xntpd/machines/freebsd b/usr.sbin/xntpd/machines/freebsd
index 1914de0de4a6..9380c0e8455d 100644
--- a/usr.sbin/xntpd/machines/freebsd
+++ b/usr.sbin/xntpd/machines/freebsd
@@ -1,6 +1,6 @@
RANLIB= ranlib
DEFS_LOCAL=-DREFCLOCK
-DEFS= -DSYS_FREEBSD -DSYS_386BSD
+DEFS= -DSYS_FREEBSD -DSYS_386BSD -DHAVE_TERMIOS
AUTHDEFS= -DDES -DMD5
CLOCKDEFS= -DLOCAL_CLOCK
DAEMONLIBS= -lcrypt
diff --git a/usr.sbin/xntpd/machines/hpux b/usr.sbin/xntpd/machines/hpux
index 60ec6780d361..fdb07897c900 100644
--- a/usr.sbin/xntpd/machines/hpux
+++ b/usr.sbin/xntpd/machines/hpux
@@ -1,7 +1,7 @@
SHELL= /bin/sh
RANLIB= ls # ar does the work of ranlib under System V
DEFS_LOCAL= -DREFCLOCK
-DEFS= -DHAVE_SYSV_TTYS -DSYS_HPUX=8
+DEFS= -DHAVE_TERMIOS -DSYS_HPUX=8
AUTHDEFS= -DDES -DMD5
CLOCKDEFS= -DLOCAL_CLOCK
COPTS=
diff --git a/usr.sbin/xntpd/machines/hpux10+ b/usr.sbin/xntpd/machines/hpux10+
index f4b420c149d2..0119b6329d7e 100644
--- a/usr.sbin/xntpd/machines/hpux10+
+++ b/usr.sbin/xntpd/machines/hpux10+
@@ -1,7 +1,7 @@
SHELL= /bin/sh
RANLIB= ls # ar does the work of ranlib under System V
DEFS_LOCAL= -DREFCLOCK
-DEFS= -DHAVE_SYSV_TTYS -DSYS_HPUX=10
+DEFS= -DHAVE_TERMIOS -DSYS_HPUX=10
AUTHDEFS= -DDES -DMD5
CLOCKDEFS= -DLOCAL_CLOCK
COPTS=
diff --git a/usr.sbin/xntpd/machines/i386svr4 b/usr.sbin/xntpd/machines/i386svr4
index b33e3c3b8b00..9ae1cc77335c 100644
--- a/usr.sbin/xntpd/machines/i386svr4
+++ b/usr.sbin/xntpd/machines/i386svr4
@@ -1,9 +1,9 @@
SHELL= /bin/sh
RANLIB= ls # ar does the work of ranlib under System V
DEFS_LOCAL= -DREFCLOCK
-DEFS= -DSYS_SVR4
+DEFS= -DSYS_SVR4 -DSTREAMS_TLI
AUTHDEFS= -DDES -DMD5
CLOCKDEFS= -DLOCAL_CLOCK
-DAEMONLIBS= -lnsl -lsocket -lelf
+DAEMONLIBS=
RESLIB= -lnsl -lsocket -lelf
INSTALL= /usr/ucb/install
diff --git a/usr.sbin/xntpd/machines/linux b/usr.sbin/xntpd/machines/linux
index 853654acebab..d7a8ac4e1871 100644
--- a/usr.sbin/xntpd/machines/linux
+++ b/usr.sbin/xntpd/machines/linux
@@ -1,6 +1,6 @@
SHELL= /bin/sh
RANLIB= ranlib
-DEFS= -DSYS_LINUX -DHAVE_SYSV_TTYS
+DEFS= -DSYS_LINUX -DHAVE_TERMIOS
AUTHDEFS= -DDES -DMD5
INCL= -I../include -I/usr/include/bsd
CLOCKDEFS=
diff --git a/usr.sbin/xntpd/machines/netbsd b/usr.sbin/xntpd/machines/netbsd
index c1995eabb6b4..1cfd8e1080ad 100644
--- a/usr.sbin/xntpd/machines/netbsd
+++ b/usr.sbin/xntpd/machines/netbsd
@@ -1,6 +1,6 @@
RANLIB= ranlib
DEFS_LOCAL=-DREFCLOCK
-DEFS= -DSYS_NETBSD -DSYS_386BSD
+DEFS= -DSYS_NETBSD -DSYS_386BSD -DHAVE_TERMIOS
AUTHDEFS= -DDES -DMD5
CLOCKDEFS= -DLOCAL_CLOCK
DAEMONLIBS= -lcrypt -lutil
diff --git a/usr.sbin/xntpd/machines/ptx b/usr.sbin/xntpd/machines/ptx
index c1d9da2e5d05..4759851a4724 100644
--- a/usr.sbin/xntpd/machines/ptx
+++ b/usr.sbin/xntpd/machines/ptx
@@ -1,6 +1,6 @@
RANLIB= :
DEFS_LOCAL= -DREFCLOCK
-DEFS= -DREADKMEM -DSYS_PTX -DHAVE_SYSV_TTYS
+DEFS= -DREADKMEM -DSYS_PTX -DHAVE_TERMIOS
AUTHDEFS= -DDES -DMD5
CLOCKDEFS= -DLOCAL_CLOCK
DAEMONLIBS=
diff --git a/usr.sbin/xntpd/machines/sequent b/usr.sbin/xntpd/machines/sequent
index 309b11bf91a8..e8e449934d2b 100644
--- a/usr.sbin/xntpd/machines/sequent
+++ b/usr.sbin/xntpd/machines/sequent
@@ -1,6 +1,6 @@
RANLIB= ranlib
DEFS_LOCAL= -DREFCLOCK
-DEFS= -DREADKMEM -DSYS_SEQUENT
+DEFS= -DHAVE_READ_KMEM -DSYS_SEQUENT
AUTHDEFS= -DDES -DMD5
CLOCKDEFS= -DLOCAL_CLOCK
DAEMONLIBS=
diff --git a/usr.sbin/xntpd/machines/sunos5.1 b/usr.sbin/xntpd/machines/sunos5.1
index 55cccad59edd..22e0d1e3bbb0 100644
--- a/usr.sbin/xntpd/machines/sunos5.1
+++ b/usr.sbin/xntpd/machines/sunos5.1
@@ -1,6 +1,6 @@
RANLIB= :
DEFS_LOCAL=-DREFCLOCK
-DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS
+DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS -DNTP_POSIX_SOURCE
AUTHDEFS= -DDES -DMD5
CLOCKDEFS= -DLOCAL_CLOCK
DAEMONLIBS=
diff --git a/usr.sbin/xntpd/machines/sunos5.2 b/usr.sbin/xntpd/machines/sunos5.2
index 3e09c15714e0..fc735b008dd2 100644
--- a/usr.sbin/xntpd/machines/sunos5.2
+++ b/usr.sbin/xntpd/machines/sunos5.2
@@ -1,6 +1,6 @@
RANLIB= :
DEFS_LOCAL= -DREFCLOCK
-DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS -DADJTIME_IS_ACCURATE
+DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS -DADJTIME_IS_ACCURATE -DNTP_POSIX_SOURCE
AUTHDEFS= -DDES -DMD5
CLOCKDEFS= -DLOCAL_CLOCK
DAEMONLIBS=
diff --git a/usr.sbin/xntpd/machines/svr4 b/usr.sbin/xntpd/machines/svr4
index 1cf90f58ca9d..752bd112424a 100644
--- a/usr.sbin/xntpd/machines/svr4
+++ b/usr.sbin/xntpd/machines/svr4
@@ -1,6 +1,6 @@
SHELL= /bin/sh
RANLIB= ls # ar does the work of ranlib under System V
-DEFS= -DSYS_SVR4
+DEFS= -DSYS_SVR4 -DSTREAMS_TLI
AUTHDEFS= -DDES -DMD5
CLOCKDEFS=
DAEMONLIBS= -lnet -lnsl -lsocket -lelf
diff --git a/usr.sbin/xntpd/ntpdate/ntpdate.c b/usr.sbin/xntpd/ntpdate/ntpdate.c
index e144d8c1eb06..b5ad05dc9baa 100644
--- a/usr.sbin/xntpd/ntpdate/ntpdate.c
+++ b/usr.sbin/xntpd/ntpdate/ntpdate.c
@@ -167,8 +167,8 @@ main(argc, argv)
l_fp tmp;
int errflg;
int c;
- extern char *optarg;
- extern int optind;
+ extern char *ntp_optarg;
+ extern int ntp_optind;
extern char *Version;
errflg = 0;
@@ -178,10 +178,10 @@ main(argc, argv)
/*
* Decode argument list
*/
- while ((c = getopt_l(argc, argv, "a:bde:k:o:p:qst:v")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "a:bde:k:o:p:qst:v")) != EOF)
switch (c) {
case 'a':
- c = atoi(optarg);
+ c = atoi(ntp_optarg);
sys_authenticate = 1;
sys_authkey = (U_LONG)c;
break;
@@ -192,24 +192,24 @@ main(argc, argv)
++debug;
break;
case 'e':
- if (!atolfp(optarg, &tmp)
+ if (!atolfp(ntp_optarg, &tmp)
|| tmp.l_ui != 0) {
(void) fprintf(stderr,
"%s: encryption delay %s is unlikely\n",
- progname, optarg);
+ progname, ntp_optarg);
errflg++;
} else {
sys_authdelay = tmp.l_uf;
}
break;
case 'k':
- key_file = optarg;
+ key_file = ntp_optarg;
break;
case 'o':
- sys_version = atoi(optarg);
+ sys_version = atoi(ntp_optarg);
break;
case 'p':
- c = atoi(optarg);
+ c = atoi(ntp_optarg);
if (c <= 0 || c > NTP_SHIFT) {
(void) fprintf(stderr,
"%s: number of samples (%d) is invalid\n",
@@ -226,10 +226,10 @@ main(argc, argv)
syslogit = 1;
break;
case 't':
- if (!atolfp(optarg, &tmp)) {
+ if (!atolfp(ntp_optarg, &tmp)) {
(void) fprintf(stderr,
"%s: timeout %s is undecodeable\n",
- progname, optarg);
+ progname, ntp_optarg);
errflg++;
} else {
sys_timeout = ((LFPTOFP(&tmp) * TIMER_HZ)
@@ -248,7 +248,7 @@ main(argc, argv)
break;
}
- sys_maxservers = argc - optind;
+ sys_maxservers = argc - ntp_optind;
if (errflg || sys_maxservers == 0) {
(void) fprintf(stderr,
"usage: %s [-bqs] [-a key#] [-k file] [-p samples] [-t timeo] server ...\n",
@@ -293,8 +293,8 @@ main(argc, argv)
/*
* Add servers we are going to be polling
*/
- for ( ; optind < argc; optind++)
- addserver(argv[optind]);
+ for ( ; ntp_optind < argc; ntp_optind++)
+ addserver(argv[ntp_optind]);
if (sys_numservers == 0) {
syslog(LOG_ERR, "no servers can be used, exiting");
@@ -520,16 +520,8 @@ receive(rbufp)
}
rpkt = &(rbufp->recv_pkt);
- if (PKT_VERSION(rpkt->li_vn_mode) == NTP_OLDVERSION) {
-#ifdef notdef
- /*
- * Fuzzballs do encryption but still claim
- * to be version 1.
- */
- if (has_mac)
- return;
-#endif
- } else if (PKT_VERSION(rpkt->li_vn_mode) != NTP_VERSION) {
+ if (PKT_VERSION(rpkt->li_vn_mode) < NTP_OLDVERSION ||
+ PKT_VERSION(rpkt->li_vn_mode) > NTP_VERSION) {
return;
}
@@ -1038,7 +1030,7 @@ addserver(serv)
}
server = (struct server *)emalloc(sizeof(struct server));
- bzero((char *)server, sizeof(struct server));
+ memset((char *)server, 0, sizeof(struct server));
server->srcadr.sin_family = AF_INET;
server->srcadr.sin_addr.s_addr = netnum;
@@ -1196,7 +1188,7 @@ init_io()
if (!debug && !simple_query) {
struct sockaddr_in addr;
- bzero((char *)&addr, sizeof addr);
+ memset((char *)&addr, 0, sizeof addr);
addr.sin_family = AF_INET;
addr.sin_port = htons(NTP_PORT);
addr.sin_addr.s_addr = INADDR_ANY;
@@ -1490,10 +1482,10 @@ getnetnum(host, num)
if (decodenetnum(host, num)) {
return 1;
} else if ((hp = gethostbyname(host)) != 0) {
- bcopy(hp->h_addr, (char *)num, sizeof(U_LONG));
- return 1;
+ memmove((char *)num, hp->h_addr, sizeof(U_LONG));
+ return (1);
}
- return 0;
+ return (0);
}
/* XXX ELIMINATE printserver similar in ntptrace.c, ntpdate.c */
@@ -1527,7 +1519,7 @@ printserver(pp, fp)
if (pp->stratum == 1) {
junk[4] = 0;
- bcopy((char *)&pp->refid, junk, 4);
+ memmove(junk, (char *)&pp->refid, 4);
str = junk;
} else {
str = numtoa(pp->refid);
diff --git a/usr.sbin/xntpd/ntpq/ntpq.c b/usr.sbin/xntpd/ntpq/ntpq.c
index e9db0086c0f9..5cfc3daff820 100644
--- a/usr.sbin/xntpd/ntpq/ntpq.c
+++ b/usr.sbin/xntpd/ntpq/ntpq.c
@@ -301,7 +301,7 @@ static int decodereach P((char *, U_LONG *));
static int decodearr P((char *, int *, l_fp *));
static char * getcode P((int, struct codestring *));
static void help P((struct parse *, FILE *));
-#if defined(sgi)
+#if defined(sgi) || defined(SYS_BSDI)
static int helpsort P((const void *, const void *));
#else
static int helpsort P((char **, char **));
@@ -335,11 +335,11 @@ static void output P((FILE *, char *, char *));
static void endoutput P((FILE *));
static void outputarr P((FILE *, char *, int, l_fp *));
static void cookedprint P((int, int, char *, int, FILE *));
-#if defined(sgi)
+#if defined(sgi) || defined(SYS_BSDI)
static int assoccmp P((const void *, const void *));
#else
static int assoccmp P((struct association *, struct association *));
-#endif /* sgi */
+#endif /* sgi || bsdi */
/*
@@ -509,17 +509,17 @@ char *argv[];
{
int c;
int errflg = 0;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
delay_time.l_ui = 0;
delay_time.l_uf = DEFDELAY;
progname = argv[0];
- while ((c = getopt_l(argc, argv, "c:dinp")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "c:dinp")) != EOF)
switch (c) {
case 'c':
- ADDCMD(optarg);
+ ADDCMD(ntp_optarg);
break;
case 'd':
++debug;
@@ -543,11 +543,11 @@ char *argv[];
progname);
exit(2);
}
- if (optind == argc) {
+ if (ntp_optind == argc) {
ADDHOST(DEFHOST);
} else {
- for (; optind < argc; optind++)
- ADDHOST(argv[optind]);
+ for (; ntp_optind < argc; ntp_optind++)
+ ADDHOST(argv[ntp_optind]);
}
if (numcmds == 0 && interactive == 0
@@ -982,7 +982,7 @@ again:
/*
* Copy the data into the data buffer.
*/
- bcopy((char *)rpkt.data, (char *)pktdata + offset, count);
+ memmove((char *)pktdata + offset, (char *)rpkt.data, count);
/*
* If we've seen the last fragment, look for holes in the sequence.
@@ -1050,7 +1050,7 @@ sendrequest(opcode, associd, auth, qsize, qdata)
* bit boundary.
*/
if (qsize > 0) {
- bcopy(qdata, (char *)qpkt.data, qsize);
+ memmove((char *)qpkt.data, qdata, qsize);
pktsize = qsize + CTL_HEADER_LEN;
while (pktsize & (sizeof(U_LONG)-1)) {
qpkt.data[qsize++] = 0;
@@ -1541,7 +1541,7 @@ getnetnum(host, num, fullhost)
}
return 1;
} else if ((hp = gethostbyname(host)) != 0) {
- bcopy(hp->h_addr, (char *)num, sizeof(U_LONG));
+ memmove((char *)num, hp->h_addr, sizeof(U_LONG));
if (fullhost != 0)
(void) strcpy(fullhost, hp->h_name);
return 1;
@@ -1888,11 +1888,11 @@ help(pcmd, fp)
for (xcp = opcmds; xcp->keyword != 0; xcp++)
cmdsort[n++] = xcp->keyword;
-#if defined(sgi)
+#if defined(sgi) || defined(SYS_BSDI)
qsort((void *)cmdsort, n, sizeof(char *), helpsort);
#else
qsort((char *)cmdsort, n, sizeof(char *), helpsort);
-#endif /* sgi */
+#endif /* sgi || bsdi */
maxlength = 0;
for (i = 0; i < n; i++) {
@@ -1934,7 +1934,7 @@ help(pcmd, fp)
* helpsort - do hostname qsort comparisons
*/
static int
-#if defined(sgi)
+#if defined(sgi) || defined(SYS_BSDI)
helpsort(t1, t2)
const void *t1;
const void *t2;
@@ -1946,7 +1946,7 @@ helpsort(name1, name2)
char **name1;
char **name2;
{
-#endif /* sgi */
+#endif /* sgi || bsdi */
return strcmp(*name1, *name2);
}
@@ -2577,6 +2577,7 @@ nextvar(datalen, datap, vname, vvalue)
register char *cp;
register char *np;
register char *cpend;
+ int quoted = 0;
static char name[MAXVARLEN];
static char value[MAXVALLEN];
@@ -2623,8 +2624,11 @@ nextvar(datalen, datap, vname, vvalue)
while (cp < cpend && (isspace(*cp) && *cp != '\r' && *cp != '\n'))
cp++;
np = value;
- while (cp < cpend && *cp != ',')
- *np++ = *cp++;
+ while (cp < cpend && ((*cp != ',') || quoted))
+ {
+ quoted ^= ((*np++ = *cp++) == '"');
+ }
+
while (np > value && isspace(*(np-1)))
np--;
*np = '\0';
@@ -3024,13 +3028,13 @@ void
sortassoc()
{
if (numassoc > 1)
-#if defined(sgi)
+#if defined(sgi) || defined(SYS_BSDI)
qsort((void *)assoc_cache, numassoc,
sizeof(struct association), assoccmp);
#else
qsort((char *)assoc_cache, numassoc,
sizeof(struct association), assoccmp);
-#endif /* sgi */
+#endif /* sgi || bsdi */
}
@@ -3038,7 +3042,7 @@ sortassoc()
* assoccmp - compare two associations
*/
static int
-#if defined(sgi)
+#if defined(sgi) || defined(SYS_BSDI)
assoccmp(t1, t2)
const void *t1;
const void *t2;
@@ -3050,7 +3054,7 @@ assoccmp(ass1, ass2)
struct association *ass1;
struct association *ass2;
{
-#endif /* sgi */
+#endif /* sgi || bsdi */
if (ass1->assid < ass2->assid)
return -1;
if (ass1->assid > ass2->assid)
diff --git a/usr.sbin/xntpd/ntpq/ntpq_ops.c b/usr.sbin/xntpd/ntpq/ntpq_ops.c
index 17929ac2f1a4..395a9ecfd914 100644
--- a/usr.sbin/xntpd/ntpq/ntpq_ops.c
+++ b/usr.sbin/xntpd/ntpq/ntpq_ops.c
@@ -217,6 +217,7 @@ checkassocid(value)
/*
* strsave - save a string
+ * XXX - should be in libntp.a
*/
static char *
strsave(str)
@@ -231,8 +232,8 @@ strsave(str)
exit(1);
}
- bcopy(str, cp, len);
- return cp;
+ memmove(cp, str, len);
+ return (cp);
}
@@ -372,11 +373,11 @@ makequerydata(vlist, datalen, data)
if (cp != data)
*cp++ = ',';
- bcopy(vl->name, cp, namelen);
+ memmove(cp, vl->name, namelen);
cp += namelen;
if (valuelen != 0) {
*cp++ = '=';
- bcopy(vl->value, cp, valuelen);
+ memmove(cp, vl->value, valuelen);
cp += valuelen;
}
}
@@ -600,7 +601,7 @@ readvar(pcmd, fp)
else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
return;
- bzero((char *)tmplist, sizeof(tmplist));
+ memset((char *)tmplist, 0, sizeof(tmplist));
if (pcmd->nargs >= 2)
doaddvlist(tmplist, pcmd->argval[1].string);
@@ -631,7 +632,7 @@ writevar(pcmd, fp)
else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
return;
- bzero((char *)tmplist, sizeof(tmplist));
+ memset((char *)tmplist, 0, sizeof(tmplist));
doaddvlist(tmplist, pcmd->argval[1].string);
res = doquerylist(tmplist, CTL_OP_WRITEVAR, associd, 0, &rstatus,
@@ -690,7 +691,7 @@ clockvar(pcmd, fp)
else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
return;
- bzero((char *)tmplist, sizeof(tmplist));
+ memset((char *)tmplist, 0, sizeof(tmplist));
if (pcmd->nargs >= 2)
doaddvlist(tmplist, pcmd->argval[1].string);
@@ -802,7 +803,7 @@ mreadvar(pcmd, fp)
&from, &to))
return;
- bzero((char *)tmplist, sizeof(tmplist));
+ memset((char *)tmplist, 0, sizeof(tmplist));
if (pcmd->nargs >= 3)
doaddvlist(tmplist, pcmd->argval[2].string);
@@ -1282,7 +1283,7 @@ doprintpeers(pvl, associd, rstatus, datalen, data, fp)
char refid_string[10];
extern struct ctl_var peer_var[];
- bzero((char *)havevar, sizeof(havevar));
+ memset((char *)havevar, 0, sizeof(havevar));
gettstamp(&ts);
while (nextvar(&datalen, &data, &name, &value)) {
diff --git a/usr.sbin/xntpd/ntptrace/ntptrace.c b/usr.sbin/xntpd/ntptrace/ntptrace.c
index 57d86ba5ab57..6454ec1df1f4 100644
--- a/usr.sbin/xntpd/ntptrace/ntptrace.c
+++ b/usr.sbin/xntpd/ntptrace/ntptrace.c
@@ -111,8 +111,8 @@ main(argc, argv)
struct server *firstserver;
int errflg;
int c;
- extern char *optarg;
- extern int optind;
+ extern char *ntp_optarg;
+ extern int ntp_optind;
extern char *Version;
errflg = 0;
@@ -121,7 +121,7 @@ main(argc, argv)
/*
* Decode argument list
*/
- while ((c = getopt_l(argc, argv, "do:nr:t:v")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "do:nr:t:v")) != EOF)
switch (c) {
case 'd':
++debug;
@@ -130,10 +130,10 @@ main(argc, argv)
nonames = 1;
break;
case 'o':
- sys_version = atoi(optarg);
+ sys_version = atoi(ntp_optarg);
break;
case 'r':
- sys_retries = atoi(optarg);
+ sys_retries = atoi(ntp_optarg);
if (sys_retries < 1) {
(void)fprintf(stderr,
"%s: retries (%d) too small\n",
@@ -142,7 +142,7 @@ main(argc, argv)
}
break;
case 't':
- sys_timeout = atoi(optarg);
+ sys_timeout = atoi(ntp_optarg);
if (sys_timeout < 1) {
(void)fprintf(stderr,
"%s: timeout (%d) too short\n",
@@ -160,7 +160,7 @@ main(argc, argv)
break;
}
- if (errflg || (argc - optind) > 1) {
+ if (errflg || (argc - ntp_optind) > 1) {
(void) fprintf(stderr,
"usage: %s [-vnd] [-r retries] [-t timeout] [server]\n",
progname);
@@ -182,8 +182,8 @@ main(argc, argv)
if (debug || verbose)
syslog(LOG_NOTICE, "%s", Version);
- if ((argc - optind) == 1)
- firstserver = addservbyname(argv[optind]);
+ if ((argc - ntp_optind) == 1)
+ firstserver = addservbyname(argv[ntp_optind]);
else
firstserver = addservbyname("localhost");
@@ -502,7 +502,7 @@ struct in_addr *iap;
}
server = (struct server *)emalloc(sizeof(struct server));
- bzero((char *)server, sizeof(struct server));
+ memset((char *)server, 0, sizeof(struct server));
server->srcadr.sin_family = AF_INET;
server->srcadr.sin_addr = *iap;
@@ -616,7 +616,7 @@ getipaddr(host, num)
if (decodeipaddr(host, num)) {
return 1;
} else if ((hp = gethostbyname(host)) != 0) {
- bcopy(hp->h_addr, (char *)num, sizeof(U_LONG));
+ memmove((char *)num, hp->h_addr, sizeof(U_LONG));
return 1;
}
return 0;
@@ -735,7 +735,7 @@ struct server *pp;
if (pp->stratum == 1) {
junk[4] = 0;
- bcopy((char *)&pp->refid, junk, 4);
+ memmove(junk, (char *)&pp->refid, 4);
str = junk;
(void) fprintf(fp, "'%s'", str);
} else {
diff --git a/usr.sbin/xntpd/parse/Makefile.kernel b/usr.sbin/xntpd/parse/Makefile.kernel
index 36dcf86e7239..95de49473f37 100644
--- a/usr.sbin/xntpd/parse/Makefile.kernel
+++ b/usr.sbin/xntpd/parse/Makefile.kernel
@@ -30,17 +30,22 @@ 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: parsestreams.c microtime.o ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h
+mparsestreams.o: mparsestreams.o.$(KARCH)
+ @echo "--- You may load mparsestreams.o.$(KARCH) via 'modload mparsestreams.o.$(KARCH)' into the kernel"
+
+mparsestreams.o.$(KARCH): 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
- @echo "--- You may load mparsestreams.o via 'modload mparsestreams.o' into the kernel"
-parsestreams.o: parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h
+parsestreams.o: parsestreams.o.$(KARCH)
+ @echo "--- You may load parsestreams.o.$(KARCH) via 'modload parsestreams.o.$(KARCH)' into the kernel"
+
+parsestreams.o.$(KARCH): 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 $@ $@ ../lib/libntp.a libparse_kernel.a
- @echo "--- You may load parsestreams.o via 'modload parsestreams.o' into the kernel"
+ ld -r -o $@ parsestreams.o ../lib/libntp.a libparse_kernel.a
+ rm -f parsestreams.o
microtime.o: $(MICROTIME) assym.s
cc -E -I. $(MICROTIME) | sed -e '/\.global _uniqtime/d' > $@.i
diff --git a/usr.sbin/xntpd/parse/Makefile.tmpl b/usr.sbin/xntpd/parse/Makefile.tmpl
index 173c91b3d89b..29a3029eb147 100644
--- a/usr.sbin/xntpd/parse/Makefile.tmpl
+++ b/usr.sbin/xntpd/parse/Makefile.tmpl
@@ -92,7 +92,7 @@ depend:
clean:
-@rm -f $(LIBNAME).a $(KLIBNAME).a *.o *.out *.ln make.log Makefile.bak \
- lintlib.errs lint.errs genassym assym.s parsestreams parse
+ lintlib.errs lint.errs genassym assym.s parsestreams parse parsestreams.o.*
-@cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl clean
distclean: clean
diff --git a/usr.sbin/xntpd/parse/clk_dcf7000.c b/usr.sbin/xntpd/parse/clk_dcf7000.c
index c1c01d2480a7..5655d0a017f0 100644
--- a/usr.sbin/xntpd/parse/clk_dcf7000.c
+++ b/usr.sbin/xntpd/parse/clk_dcf7000.c
@@ -1,12 +1,12 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_DCF7000)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_dcf7000.c,v 3.8 1993/10/30 09:44:35 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_dcf7000.c,v 3.10 1994/01/25 19:05:07 kardel Exp
*
- * clk_dcf7000.c,v 3.8 1993/10/30 09:44:35 kardel Exp
+ * clk_dcf7000.c,v 3.10 1994/01/25 19:05:07 kardel Exp
*
* ELV DCF7000 module
*
- * Copyright (c) 1992,1993
+ * Copyright (c) 1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
diff --git a/usr.sbin/xntpd/parse/clk_meinberg.c b/usr.sbin/xntpd/parse/clk_meinberg.c
index 363120b1eb1e..b08dfec91152 100644
--- a/usr.sbin/xntpd/parse/clk_meinberg.c
+++ b/usr.sbin/xntpd/parse/clk_meinberg.c
@@ -1,12 +1,12 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_MEINBERG)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.9 1993/10/30 09:44:38 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.11 1994/01/25 19:05:10 kardel Exp
*
- * clk_meinberg.c,v 3.9 1993/10/30 09:44:38 kardel Exp
+ * clk_meinberg.c,v 3.11 1994/01/25 19:05:10 kardel Exp
*
* Meinberg clock support
*
- * Copyright (c) 1992,1993
+ * Copyright (c) 1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -414,6 +414,12 @@ cvt_mgps(buffer, size, format, clock)
* History:
*
* clk_meinberg.c,v
+ * Revision 3.11 1994/01/25 19:05:10 kardel
+ * 94/01/23 reconcilation
+ *
+ * Revision 3.10 1994/01/23 17:21:54 kardel
+ * 1994 reconcilation
+ *
* Revision 3.9 1993/10/30 09:44:38 kardel
* conditional compilation flag cleanup
*
diff --git a/usr.sbin/xntpd/parse/clk_rawdcf.c b/usr.sbin/xntpd/parse/clk_rawdcf.c
index 4a5ad5608a4e..2fd3cae20b89 100644
--- a/usr.sbin/xntpd/parse/clk_rawdcf.c
+++ b/usr.sbin/xntpd/parse/clk_rawdcf.c
@@ -1,12 +1,12 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RAWDCF)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.7 1993/10/30 09:44:41 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.9 1994/01/25 19:05:12 kardel Exp
*
- * clk_rawdcf.c,v 3.7 1993/10/30 09:44:41 kardel Exp
+ * clk_rawdcf.c,v 3.9 1994/01/25 19:05:12 kardel Exp
*
* Raw DCF77 pulse clock support
*
- * Copyright (c) 1992,1993
+ * Copyright (c) 1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -469,7 +469,7 @@ static unsigned LONG pps_rawdcf(parseio, status, ptime)
register int status;
register timestamp_t *ptime;
{
- if (status == SYNC_ONE)
+ if (!status)
{
parseio->parse_dtime.parse_ptime = *ptime;
parseio->parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
@@ -529,6 +529,12 @@ static unsigned LONG snt_rawdcf(parseio, ptime)
* History:
*
* clk_rawdcf.c,v
+ * Revision 3.9 1994/01/25 19:05:12 kardel
+ * 94/01/23 reconcilation
+ *
+ * Revision 3.8 1994/01/22 11:24:11 kardel
+ * fixed PPS handling
+ *
* Revision 3.7 1993/10/30 09:44:41 kardel
* conditional compilation flag cleanup
*
diff --git a/usr.sbin/xntpd/parse/clk_schmid.c b/usr.sbin/xntpd/parse/clk_schmid.c
index 12b06fdcc304..a8ec8a64b546 100644
--- a/usr.sbin/xntpd/parse/clk_schmid.c
+++ b/usr.sbin/xntpd/parse/clk_schmid.c
@@ -1,12 +1,12 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_SCHMID)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.8 1993/11/01 20:00:18 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.10 1994/01/25 19:05:15 kardel Exp
*
- * clk_schmid.c,v 3.8 1993/11/01 20:00:18 kardel Exp
+ * clk_schmid.c,v 3.10 1994/01/25 19:05:15 kardel Exp
*
* Schmid clock support
*
- * Copyright (c) 1992,1993
+ * Copyright (c) 1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -168,6 +168,12 @@ cvt_schmid(buffer, size, format, clock)
* History:
*
* clk_schmid.c,v
+ * Revision 3.10 1994/01/25 19:05:15 kardel
+ * 94/01/23 reconcilation
+ *
+ * Revision 3.9 1994/01/23 17:21:56 kardel
+ * 1994 reconcilation
+ *
* Revision 3.8 1993/11/01 20:00:18 kardel
* parse Solaris support (initial version)
*
diff --git a/usr.sbin/xntpd/parse/clk_trimble.c b/usr.sbin/xntpd/parse/clk_trimble.c
index c9c124ea4dee..bfbf1e6bc796 100644
--- a/usr.sbin/xntpd/parse/clk_trimble.c
+++ b/usr.sbin/xntpd/parse/clk_trimble.c
@@ -1,6 +1,6 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_TRIMSV6)
/*
- * /src/NTP/REPOSITORY/v3/parse/clk_trimble.c,v 3.6 1993/10/30 09:44:45 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/clk_trimble.c,v 3.7 1994/01/25 19:05:17 kardel Exp
*
* Trimble SV6 clock support
*/
@@ -106,6 +106,9 @@ cvt_trimsv6(buffer, size, format, clock)
* History:
*
* clk_trimble.c,v
+ * 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
*
diff --git a/usr.sbin/xntpd/parse/parse.c b/usr.sbin/xntpd/parse/parse.c
index 7a360021e167..ed5fd9a8fad7 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.17 1993/11/11 11:20:29 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.19 1994/01/25 19:05:20 kardel Exp
*
- * parse.c,v 3.17 1993/11/11 11:20:29 kardel Exp
+ * parse.c,v 3.19 1994/01/25 19:05:20 kardel Exp
*
* Parser module for reference clock
*
@@ -12,7 +12,7 @@
* a struct timeval.
* when PARSEKERNEL is not defined NTP time stamps will be used.
*
- * Copyright (c) 1992,1993
+ * Copyright (c) 1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -22,30 +22,39 @@
*/
#if !(defined(lint) || defined(__GNUC__))
-static char rcsid[] = "parse.c,v 3.17 1993/11/11 11:20:29 kardel Exp";
+static char rcsid[] = "parse.c,v 3.19 1994/01/25 19:05:20 kardel Exp";
#endif
#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"
+#include "ntp_machine.h"
#if defined(PARSESTREAM) && (defined(SYS_SUNOS4) || defined(SYS_SOLARIS)) && defined(STREAM)
/*
- * Sorry, but in SunOS 4.x kernels there are no
+ * Sorry, but in SunOS 4.x AND Solaris 2.x kernels there are no
* mem* operations. I don't want them - bcopy, bzero
* are fine in the kernel
*/
-#define _ntp_string_h
-extern void bcopy();
-extern void bzero();
+#ifndef NTP_NEED_BOPS
+#define NTP_NEED_BOPS
+#endif
+#else
+#ifndef NTP_NEED_BOPS
+#ifndef bzero
+#define bzero(_X_, _Y_) memset(_X_, 0, _Y_)
+#define bcopy(_X_, _Y_, _Z_) memmove(_Y_, _X_, _Z_)
+#endif
+#endif
#endif
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
#include "ntp_stdlib.h"
#ifdef PARSESTREAM
@@ -1139,6 +1148,12 @@ parse_setcs(dct, parse)
* History:
*
* parse.c,v
+ * Revision 3.19 1994/01/25 19:05:20 kardel
+ * 94/01/23 reconcilation
+ *
+ * Revision 3.18 1994/01/23 17:21:59 kardel
+ * 1994 reconcilation
+ *
* Revision 3.17 1993/11/11 11:20:29 kardel
* declaration fixes
*
diff --git a/usr.sbin/xntpd/parse/parse_conf.c b/usr.sbin/xntpd/parse/parse_conf.c
index 78ddb3a1c9dd..0281c9dd1071 100644
--- a/usr.sbin/xntpd/parse/parse_conf.c
+++ b/usr.sbin/xntpd/parse/parse_conf.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS))
/*
- * /src/NTP/REPOSITORY/v3/parse/parse_conf.c,v 3.11 1993/11/01 20:00:24 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/parse_conf.c,v 3.13 1994/01/25 19:05:23 kardel Exp
*
- * parse_conf.c,v 3.11 1993/11/01 20:00:24 kardel Exp
+ * parse_conf.c,v 3.13 1994/01/25 19:05:23 kardel Exp
*
* Parser configuration module for reference clocks
*
@@ -12,7 +12,7 @@
* a struct timeval.
* when STREAM is not defined NTP time stamps will be used.
*
- * Copyright (c) 1992,1993
+ * Copyright (c) 1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -81,6 +81,12 @@ unsigned short nformats = sizeof(clockformats) / sizeof(clockformats[0]) - 1;
* History:
*
* parse_conf.c,v
+ * Revision 3.13 1994/01/25 19:05:23 kardel
+ * 94/01/23 reconcilation
+ *
+ * Revision 3.12 1994/01/23 17:22:02 kardel
+ * 1994 reconcilation
+ *
* Revision 3.11 1993/11/01 20:00:24 kardel
* parse Solaris support (initial version)
*
diff --git a/usr.sbin/xntpd/parse/parsesolaris.c b/usr.sbin/xntpd/parse/parsesolaris.c
index 0da27e7a087a..09fac2861f0c 100644
--- a/usr.sbin/xntpd/parse/parsesolaris.c
+++ b/usr.sbin/xntpd/parse/parsesolaris.c
@@ -1,13 +1,13 @@
/*
- * /src/NTP/REPOSITORY/v3/parse/parsesolaris.c,v 3.4 1993/11/13 11:13:17 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/parsesolaris.c,v 3.9 1994/01/25 19:05:26 kardel Exp
*
- * parsesolaris.c,v 3.4 1993/11/13 11:13:17 kardel Exp
+ * parsesolaris.c,v 3.9 1994/01/25 19:05:26 kardel Exp
*
* STREAMS module for reference clocks
* (SunOS5.x - not fully tested - buyer beware ! - OS KILLERS may still be
* lurking in the code!)
*
- * Copyright (c) 1993
+ * Copyright (c) 1993,1994
* derived work from parsestreams.c ((c) 1991-1993, Frank Kardel) and
* dcf77sync.c((c) Frank Kardel)
* Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg
@@ -19,7 +19,7 @@
*/
#ifndef lint
-static char rcsid[] = "parsesolaris.c,v 3.4 1993/11/13 11:13:17 kardel Exp";
+static char rcsid[] = "parsesolaris.c,v 3.9 1994/01/25 19:05:26 kardel Exp";
#endif
/*
@@ -139,7 +139,7 @@ int Strcmp(s, t)
/*ARGSUSED*/
int _init(void)
{
- static char revision[] = "3.4";
+ static char revision[] = "3.9";
char *s, *S, *t;
/*
@@ -668,6 +668,7 @@ static int parserput(queue_t *q, mblk_t *imp)
* the service routine will move it to the next one
*/
parseprintf(DD_RPUT,("parse: parserput - forward type 0x%x\n", type));
+
if (canput(q->q_next) || (mp->b_datap->db_type > QPCTL))
{
putnext(q, mp);
@@ -701,8 +702,9 @@ static int parserput(queue_t *q, mblk_t *imp)
}
else
{
+#if 0
parseprintf(DD_RPUT,("parse: parserput - M_%s\n", (type == M_DATA) ? "DATA" : "BREAK"));
-
+#endif
if (type == M_DATA)
{
/*
@@ -787,7 +789,15 @@ static int parserput(queue_t *q, mblk_t *imp)
else
if (nmp) freemsg(nmp);
parse_iodone(&parse->parse_io);
+ freemsg(mp);
}
+ else
+ if (canput(q->q_next) || (mp->b_datap->db_type > QPCTL))
+ {
+ putnext(q, mp);
+ }
+ else
+ putq(q, mp);
if (status)
{
@@ -929,6 +939,11 @@ static int init_zs_linemon(queue_t *q, queue_t *my_q)
emergencyzs = zs->zs_ops;
zs->zs_ops = &szs->zsops; /* hook it up */
+ /*
+ * XXX: this is usually done via zsopinit()
+ * - have yet to find a way to call that routine
+ */
+ zs->zs_xsint = (void (*)())zs_xsisr;
mutex_exit(zs->zs_excl);
@@ -961,6 +976,11 @@ static void close_zs_linemon(queue_t *q, queue_t *my_q)
mutex_enter(zs->zs_excl);
zs->zs_ops = szs->oldzsops; /* reset to previous handler functions */
+ /*
+ * XXX: revert xsint (usually done via zsopinit() - have still to find
+ * a way to call that bugger
+ */
+ zs->zs_xsint = zs->zs_ops->zsop_xsint;
mutex_exit(zs->zs_excl);
@@ -971,6 +991,8 @@ static void close_zs_linemon(queue_t *q, queue_t *my_q)
}
}
+#define ZSRR0_IGNORE (ZSRR0_CD|ZSRR0_SYNC|ZSRR0_CTS)
+
#define MAXDEPTH 50 /* maximum allowed stream crawl */
/*
@@ -1072,11 +1094,12 @@ static void zs_xsisr(struct zscom *zs)
}
/*
- * only pretend that CD has been handled
+ * only pretend that CD and ignored transistion (SYNC,CTS)
+ * have been handled
*/
- za->za_rr0 = za->za_rr0 & ~ZSRR0_CD | zsstatus & ZSRR0_CD;
+ za->za_rr0 = (za->za_rr0 & ~ZSRR0_IGNORE) | (zsstatus & ZSRR0_IGNORE);
- if (!((za->za_rr0 ^ zsstatus) & ~ZSRR0_CD))
+ if (((za->za_rr0 ^ zsstatus) & ~ZSRR0_IGNORE) == 0)
{
/*
* all done - kill status indication and return
@@ -1086,6 +1109,8 @@ static void zs_xsisr(struct zscom *zs)
}
}
+ parseprintf(DD_ISR, ("zs_xsisr: non CD event 0x%x for \"%s\"\n",
+ (za->za_rr0 ^ zsstatus) & ~ZSRR0_CD,dname));
/*
* we are now gathered here to process some unusual external status
* interrupts.
@@ -1154,6 +1179,21 @@ static void zs_xsisr(struct zscom *zs)
* History:
*
* parsesolaris.c,v
+ * Revision 3.9 1994/01/25 19:05:26 kardel
+ * 94/01/23 reconcilation
+ *
+ * Revision 3.8 1994/01/23 17:22:04 kardel
+ * 1994 reconcilation
+ *
+ * Revision 3.7 1993/12/15 18:24:41 kardel
+ * Now also ignoring state changes on ZSRR0_{SYNC,CTS} to avoid zs driver bugs (Solaris 2.3)
+ *
+ * Revision 3.6 1993/12/15 12:48:53 kardel
+ * fixed message loss on M_*HANHUP messages
+ *
+ * Revision 3.5 1993/12/14 21:05:12 kardel
+ * PPS working now for SunOS 5.x zs external status hook
+ *
* Revision 3.4 1993/11/13 11:13:17 kardel
* Solaris 2.3 additional includes
*
@@ -1166,5 +1206,4 @@ static void zs_xsisr(struct zscom *zs)
* Revision 3.1 1993/11/01 20:00:29 kardel
* parse Solaris support (initial version)
*
- *
*/
diff --git a/usr.sbin/xntpd/parse/parsestreams.c b/usr.sbin/xntpd/parse/parsestreams.c
index 56ce07c93e6a..b371aedafcee 100644
--- a/usr.sbin/xntpd/parse/parsestreams.c
+++ b/usr.sbin/xntpd/parse/parsestreams.c
@@ -1,12 +1,12 @@
/*
- * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.9 1993/11/05 15:34:55 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.12 1994/01/25 19:05:30 kardel Exp
*
- * parsestreams.c,v 3.9 1993/11/05 15:34:55 kardel Exp
+ * parsestreams.c,v 3.12 1994/01/25 19:05:30 kardel Exp
*
* STREAMS module for reference clocks
* (SunOS4.x)
*
- * Copyright (c) 1989,1990,1991,1992,1993
+ * Copyright (c) 1989,1990,1991,1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -16,7 +16,7 @@
*/
#ifndef lint
-static char rcsid[] = "parsestreams.c,v 3.9 1993/11/05 15:34:55 kardel Exp";
+static char rcsid[] = "parsestreams.c,v 3.12 1994/01/25 19:05:30 kardel Exp";
#endif
#include "sys/types.h"
@@ -195,7 +195,7 @@ int xxxinit(fc, vdp, vdi, vds)
}
else
{
- static char revision[] = "3.9";
+ static char revision[] = "3.12";
char *s, *S, *t;
strncpy(ifm->f_name, mname, FMNAMESZ);
@@ -884,7 +884,15 @@ static int parserput(q, mp)
else
if (nmp) freemsg(nmp);
parse_iodone(&parse->parse_io);
+ freemsg(mp);
}
+ else
+ if (canput(q->q_next) || (mp->b_datap->db_type > QPCTL))
+ {
+ putnext(q, mp);
+ }
+ else
+ putq(q, mp);
if (status)
{
@@ -1250,6 +1258,15 @@ static void zs_xsisr(zs)
* History:
*
* parsestreams.c,v
+ * Revision 3.12 1994/01/25 19:05:30 kardel
+ * 94/01/23 reconcilation
+ *
+ * Revision 3.11 1994/01/23 17:22:07 kardel
+ * 1994 reconcilation
+ *
+ * Revision 3.10 1993/12/15 12:48:58 kardel
+ * fixed message loss on M_*HANHUP messages
+ *
* Revision 3.9 1993/11/05 15:34:55 kardel
* shut up nice feature detection
*
diff --git a/usr.sbin/xntpd/parse/util/Makefile.tmpl b/usr.sbin/xntpd/parse/util/Makefile.tmpl
index a72100f9ec75..aa0b26225952 100644
--- a/usr.sbin/xntpd/parse/util/Makefile.tmpl
+++ b/usr.sbin/xntpd/parse/util/Makefile.tmpl
@@ -1,5 +1,5 @@
#
-# /src/NTP/REPOSITORY/v3/parse/util/Makefile.tmpl,v 3.11 1993/11/17 13:34:12 kardel Exp
+# /src/NTP/REPOSITORY/v3/parse/util/Makefile.tmpl,v 3.12 1994/01/25 19:05:39 kardel Exp
#
COMPILER= cc
DEFS=
diff --git a/usr.sbin/xntpd/parse/util/dcfd.c b/usr.sbin/xntpd/parse/util/dcfd.c
index 723e2c8e8cad..23934a8e104e 100644
--- a/usr.sbin/xntpd/parse/util/dcfd.c
+++ b/usr.sbin/xntpd/parse/util/dcfd.c
@@ -1,7 +1,7 @@
/*
- * /src/NTP/REPOSITORY/v3/parse/util/dcfd.c,v 3.8 1993/11/04 20:02:05 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/util/dcfd.c,v 3.15 1994/01/25 19:05:42 kardel Exp
*
- * dcfd.c,v 3.8 1993/11/04 20:02:05 kardel Exp
+ * dcfd.c,v 3.15 1994/01/25 19:05:42 kardel Exp
*
* DCF77 100/200ms pulse synchronisation daemon program (via 50Baud serial line)
*
@@ -13,7 +13,7 @@
* Lacks:
* Leap second handling (at that level you should switch to xntp3 - really!)
*
- * Copyright (c) 1993
+ * Copyright (c) 1993,1994
* Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -33,6 +33,9 @@
#include <sys/errno.h>
#include <syslog.h>
+/*
+ * NTP compilation environment
+ */
#ifdef USE_PROTOTYPES
#include "ntp_stdlib.h"
extern int sigvec P((int, struct sigvec *, struct sigvec *));
@@ -43,6 +46,9 @@ extern int fscanf P((FILE *, char *, ...));
#include "ntp_timex.h"
#endif
+/*
+ * select which terminal handling to use (currently only SysV variants)
+ */
#if defined(HAVE_TERMIOS) || defined(STREAM)
#include <termios.h>
#define TTY_GETATTR(_FD_, _ARG_) tcgetattr((_FD_), (_ARG_))
@@ -63,24 +69,33 @@ MUST DEFINE ONE OF "HAVE_TERMIOS" or "HAVE_TERMIO"
#define dysize(_x_) (((_x_) % 4) ? 365 : (((_x_) % 400) ? 365 : 366))
#endif
-#define timernormalize(_a_, _b_) \
+#define timernormalize(_a_) \
if ((_a_)->tv_usec >= 1000000) \
{ \
(_a_)->tv_sec += (_a_)->tv_usec / 1000000; \
- (_a_)->tv_usec -= (_a_)->tv_usec % 1000000; \
+ (_a_)->tv_usec = (_a_)->tv_usec % 1000000; \
} \
+ if ((_a_)->tv_usec < 0) \
+ { \
+ (_a_)->tv_sec -= 1 + -(_a_)->tv_usec / 1000000; \
+ (_a_)->tv_usec = 1000000 - (-(_a_)->tv_usec % 1000000); \
+ }
#define timeradd(_a_, _b_) \
(_a_)->tv_sec += (_b_)->tv_sec; \
(_a_)->tv_usec += (_b_)->tv_usec; \
- timernormalize((_a_), (_b_))
+ timernormalize((_a_))
#define timersub(_a_, _b_) \
(_a_)->tv_sec -= (_b_)->tv_sec; \
(_a_)->tv_usec -= (_b_)->tv_usec; \
- timernormalize((_a_), (_b_))
+ timernormalize((_a_))
+/*
+ * debug macros
+ */
#define PRINTF if (interactive) printf
+#define LPRINTF if (interactive && loop_filter_debug) printf
#ifdef DEBUG
#define dprintf(_x_) PRINTF _x_
@@ -90,9 +105,31 @@ MUST DEFINE ONE OF "HAVE_TERMIOS" or "HAVE_TERMIO"
extern int errno;
+/*
+ * display received data (avoids also detaching from tty)
+ */
static int interactive = 0;
+
+/*
+ * display loopfilter (clock control) variables
+ */
static int loop_filter_debug = 0;
+/*
+ * do not set/adjust system time
+ */
+static int no_set = 0;
+
+/*
+ * time that passes between start of DCF impulse and time stamping (fine
+ * adjustment) in microseconds (receiver/OS dependent)
+ */
+#define DEFAULT_DELAY 230000 /* rough estimate */
+
+/*
+ * The two states we can be in - eithe we receive nothing
+ * usable or we have the correct time
+ */
#define NO_SYNC 0x01
#define SYNC 0x02
@@ -105,7 +142,7 @@ static char pat[] = "-\\|/";
#define LINES (24-2) /* error lines after which the two headlines are repeated */
-#define MAX_UNSYNC (5*60) /* allow synchronisation loss for 5 minutes */
+#define MAX_UNSYNC (10*60) /* allow synchronisation loss for 10 minutes */
#define NOTICE_INTERVAL (20*60) /* mention missing synchronisation every 20 minutes */
/*
@@ -113,7 +150,7 @@ static char pat[] = "-\\|/";
*/
#define USECSCALE 10
-#define TIMECONSTANT 0
+#define TIMECONSTANT 2
#define ADJINTERVAL 0
#define FREQ_WEIGHT 18
#define PHASE_WEIGHT 7
@@ -129,7 +166,7 @@ static long adjustments = 0;
static char skip_adjust = 1; /* discard first adjustment (bad samples) */
/*
- * state flags
+ * DCF77 state flags
*/
#define DCFB_ANNOUNCE 0x0001 /* switch time zone warning (DST switch) */
#define DCFB_DST 0x0002 /* DST in effect */
@@ -138,7 +175,7 @@ static char skip_adjust = 1; /* discard first adjustment (bad samples) */
struct clocktime /* clock time broken up from time code */
{
- long wday;
+ long wday; /* Day of week: 1: Monday - 7: Sunday */
long day;
long month;
long year;
@@ -147,18 +184,24 @@ struct clocktime /* clock time broken up from time code */
long second;
long usecond;
long utcoffset; /* in minutes */
- long flags; /* current clock status */
+ long flags; /* current clock status (DCF77 state flags) */
};
typedef struct clocktime clocktime_t;
+/*
+ * (usually) quick constant multiplications
+ */
#define TIMES10(_X_) (((_X_) << 3) + ((_X_) << 1)) /* *8 + *2 */
#define TIMES24(_X_) (((_X_) << 4) + ((_X_) << 3)) /* *16 + *8 */
#define TIMES60(_X_) ((((_X_) << 4) - (_X_)) << 2) /* *(16 - 1) *4 */
+/*
+ * generic abs() function
+ */
#define abs(_x_) (((_x_) < 0) ? -(_x_) : (_x_))
/*
- * parser related return/error codes
+ * conversion related return/error codes
*/
#define CVT_MASK 0x0000000F /* conversion exit code */
#define CVT_NONE 0x00000001 /* format not applicable */
@@ -216,6 +259,14 @@ typedef struct clocktime clocktime_t;
* 59 - usually missing (minute indication), except for leap insertion
*/
+/*-----------------------------------------------------------------------
+ * conversion table to map DCF77 bit stream into data fields.
+ * Encoding:
+ * Each field of the DCF77 code is described with two adjacent entries in
+ * this table. The first entry specifies the offset into the DCF77 data stream
+ * while the length is given as the difference between the start index and
+ * the start index of the following field.
+ */
static struct rawdcfcode
{
char offset; /* start bit */
@@ -225,6 +276,10 @@ static struct rawdcfcode
{ 33 }, { 35 }, { 36 }, { 40 }, { 42 }, { 45 }, { 49 }, { 50 }, { 54 }, { 58 }, { 59 }
};
+/*-----------------------------------------------------------------------
+ * symbolic names for the fields of DCF77 describes in "rawdcfcode".
+ * see comment above for the structure of the DCF77 data
+ */
#define DCF_M 0
#define DCF_R 1
#define DCF_A1 2
@@ -246,6 +301,11 @@ static struct rawdcfcode
#define DCF_Y10 18
#define DCF_P3 19
+/*-----------------------------------------------------------------------
+ * parity field table (same encoding as rawdcfcode)
+ * This table describes the sections of the DCF77 code that are
+ * parity protected
+ */
static struct partab
{
char offset; /* start bit of parity field */
@@ -254,6 +314,22 @@ static struct partab
{ 21 }, { 29 }, { 36 }, { 59 }
};
+/*-----------------------------------------------------------------------
+ * offsets for parity field descriptions
+ */
+#define DCF_P_P1 0
+#define DCF_P_P2 1
+#define DCF_P_P3 2
+
+/*-----------------------------------------------------------------------
+ * legal values for time zone information
+ */
+#define DCF_Z_MET 0x2
+#define DCF_Z_MED 0x1
+
+/*-----------------------------------------------------------------------
+ * symbolic representation if the DCF77 data stream
+ */
static struct dcfparam
{
unsigned char onebits[60];
@@ -264,13 +340,13 @@ static struct dcfparam
"--------------------s-------p------p----------------------p" /* 'ZERO' representation */
};
-#define DCF_P_P1 0
-#define DCF_P_P2 1
-#define DCF_P_P3 2
-
-#define DCF_Z_MET 0x2
-#define DCF_Z_MED 0x1
-
+/*-----------------------------------------------------------------------
+ * extract a bitfield from DCF77 datastream
+ * All numeric field are LSB first.
+ * buf holds a pointer to a DCF77 data buffer in symbolic
+ * representation
+ * idx holds the index to the field description in rawdcfcode
+ */
static unsigned long ext_bf(buf, idx)
register unsigned char *buf;
register int idx;
@@ -288,6 +364,13 @@ static unsigned long ext_bf(buf, idx)
return sum;
}
+/*-----------------------------------------------------------------------
+ * check even parity integrity for a bitfield
+ *
+ * buf holds a pointer to a DCF77 data buffer in symbolic
+ * representation
+ * idx holds the index to the field description in partab
+ */
static unsigned pcheck(buf, idx)
register unsigned char *buf;
register int idx;
@@ -303,6 +386,15 @@ static unsigned pcheck(buf, idx)
return psum;
}
+/*-----------------------------------------------------------------------
+ * convert a DCF77 data buffer into wall clock time + flags
+ *
+ * buffer holds a pointer to a DCF77 data buffer in symbolic
+ * representation
+ * size describes the length of DCF77 information in bits (represented
+ * as chars in symbolic notation
+ * clock points to a wall clock time description of the DCF77 data (result)
+ */
static unsigned long convert_rawdcf(buffer, size, clock)
register unsigned char *buffer;
register int size;
@@ -323,7 +415,7 @@ static unsigned long convert_rawdcf(buffer, size, clock)
pcheck(buffer, DCF_P_P3))
{
/*
- * buffer OK
+ * buffer OK - extract all fields and build wall clock time from them
*/
clock->flags = 0;
@@ -341,6 +433,9 @@ static unsigned long convert_rawdcf(buffer, size, clock)
clock->year = TIMES10(clock->year) + ext_bf(buffer, DCF_Y1);
clock->wday = ext_bf(buffer, DCF_DW);
+ /*
+ * determine offset to UTC by examining the time zone
+ */
switch (ext_bf(buffer, DCF_Z))
{
case DCF_Z_MET:
@@ -357,6 +452,9 @@ static unsigned long convert_rawdcf(buffer, size, clock)
return CVT_FAIL|CVT_BADFMT;
}
+ /*
+ * extract various warnings from DCF77
+ */
if (ext_bf(buffer, DCF_A1))
clock->flags |= DCFB_ANNOUNCE;
@@ -378,7 +476,7 @@ static unsigned long convert_rawdcf(buffer, size, clock)
}
}
-/*
+/*-----------------------------------------------------------------------
* raw dcf input routine - fix up 50 baud
* characters for 1/0 decision
*/
@@ -402,8 +500,20 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
* a 100ms pulse would generate a 4 bit train (20ms per bit and
* start bit)
* a 200ms pulse would create all zeroes (and probably a frame error)
+ *
+ * The basic idea is that on corret reception we must have two
+ * maxima in the pulse length distribution histogram. (one for
+ * the zero representing pulses and one for the one representing
+ * pulses)
+ * There will always be ones in the datastream, thus we have to see
+ * two maxima.
+ * The best point to cut for a 1/0 decision is the minimum between those
+ * between the maxima. The following code tries to find this cutoff point.
*/
+ /*
+ * clear histogram buffer
+ */
for (i = 0; i < BITS; i++)
{
histbuf[i] = 0;
@@ -412,15 +522,21 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
cutoff = 0;
lowmax = 0;
+ /*
+ * convert sequences of set bits into bits counts updating
+ * the histogram alongway
+ */
while (s < e)
{
register unsigned int ch = *s ^ 0xFF;
/*
- * these lines are left as an excercise to the reader 8-)
+ * check integrity and update histogramm
*/
if (!((ch+1) & ch) || !*s)
{
-
+ /*
+ * character ok
+ */
for (i = 0; ch; i++)
{
ch >>= 1;
@@ -433,6 +549,9 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
}
else
{
+ /*
+ * invalid character (no consecutive bit sequence)
+ */
dprintf(("parse: cvt_rawdcf: character check for 0x%x@%d FAILED\n", *s, s - buffer));
*s = ~0;
rtc = CVT_FAIL|CVT_BADFMT;
@@ -440,6 +559,10 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
s++;
}
+ /*
+ * first cutoff estimate (average bit count - must be between both
+ * maxima)
+ */
if (lowmax)
{
cutoff /= lowmax;
@@ -451,20 +574,31 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
dprintf(("parse: cvt_rawdcf: average bit count: %d\n", cutoff));
- lowmax = 0;
- highmax = 0;
+ lowmax = 0; /* weighted sum */
+ highmax = 0; /* bitcount */
+ /*
+ * collect weighted sum of lower bits (left of initial guess)
+ */
dprintf(("parse: cvt_rawdcf: histogram:"));
for (i = 0; i <= cutoff; i++)
{
- lowmax+=histbuf[i] * i;
+ lowmax += histbuf[i] * i;
highmax += histbuf[i];
dprintf((" %d", histbuf[i]));
}
dprintf((" <M>"));
+ /*
+ * round up
+ */
lowmax += highmax / 2;
+ /*
+ * calculate lower bit maximum (weighted sum / bit count)
+ *
+ * avoid divide by zero
+ */
if (highmax)
{
lowmax /= highmax;
@@ -474,9 +608,12 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
lowmax = 0;
}
- highmax = 0;
- cutoff = 0;
+ highmax = 0; /* weighted sum of upper bits counts */
+ cutoff = 0; /* bitcount */
+ /*
+ * collect weighted sum of lower bits (right of initial guess)
+ */
for (; i < BITS; i++)
{
highmax+=histbuf[i] * i;
@@ -485,6 +622,9 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
}
dprintf(("\n"));
+ /*
+ * determine upper maximum (weighted sum / bit count)
+ */
if (cutoff)
{
highmax /= cutoff;
@@ -494,34 +634,64 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
highmax = BITS-1;
}
+ /*
+ * following now holds:
+ * lowmax <= cutoff(initial guess) <= highmax
+ * best cutoff is the minimum nearest to higher bits
+ */
+
+ /*
+ * find the minimum between lowmax and highmax (detecting
+ * possibly a minimum span)
+ */
span = cutoff = lowmax;
for (i = lowmax; i <= highmax; i++)
{
if (histbuf[cutoff] > histbuf[i])
{
- cutoff = i;
- span = i;
+ /*
+ * got a new minimum move beginning of minimum (cutoff) and
+ * end of minimum (span) there
+ */
+ cutoff = span = i;
}
else
if (histbuf[cutoff] == histbuf[i])
{
+ /*
+ * minimum not better yet - but it spans more than
+ * one bit value - follow it
+ */
span = i;
}
}
+ /*
+ * cutoff point for 1/0 decision is the middle of the minimum section
+ * in the histogram
+ */
cutoff = (cutoff + span) / 2;
dprintf(("parse: cvt_rawdcf: lower maximum %d, higher maximum %d, cutoff %d\n", lowmax, highmax, cutoff));
+ /*
+ * convert the bit counts to symbolic 1/0 information for data conversion
+ */
s = buffer;
while ((s < e) && *c && *b)
{
if (*s == (unsigned char)~0)
{
+ /*
+ * invalid character
+ */
*s = '?';
}
else
{
+ /*
+ * symbolic 1/0 representation
+ */
*s = (*s >= cutoff) ? *b : *c;
}
s++;
@@ -529,11 +699,19 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
c++;
}
+ /*
+ * if everything went well so far return the result of the symbolic
+ * conversion routine else just the accumulated errors
+ */
return (rtc == CVT_NONE) ? convert_rawdcf(buffer, size, clock) : rtc;
}
+/*-----------------------------------------------------------------------
+ * convert a wall clock time description of DCF77 to a Unix time (seconds
+ * since 1.1. 1970 UTC)
+ */
time_t
-parse_to_unixtime(clock, cvtrtc)
+dcf_to_unixtime(clock, cvtrtc)
register clocktime_t *clock;
register unsigned long *cvtrtc;
{
@@ -545,12 +723,22 @@ parse_to_unixtime(clock, cvtrtc)
register int i;
time_t t;
+ /*
+ * map 2 digit years to 19xx (DCF77 is a 20th century item)
+ */
if (clock->year < 100)
clock->year += 1900;
- if (clock->year < 1970)
- clock->year += 100; /* XXX this will do it till <2070 */
+ /*
+ * assume that we convert timecode within the unix/UTC epoch -
+ * prolonges validity of 2 digit years
+ */
+ if (clock->year < 1994)
+ clock->year += 100; /* XXX this will do it till <2094 */
+ /*
+ * must have been a really negative year code - drop it
+ */
if (clock->year < 0)
{
SETRTC(CVT_FAIL|CVT_BADDATE);
@@ -560,6 +748,10 @@ parse_to_unixtime(clock, cvtrtc)
/*
* sorry, slow section here - but it's not time critical anyway
*/
+
+ /*
+ * calculate days since 1970 (watching leap years)
+ */
t = (clock->year - 1970) * 365;
t += (clock->year >> 2) - (1970 >> 2);
t -= clock->year / 400 - 1970 / 400;
@@ -570,10 +762,13 @@ parse_to_unixtime(clock, cvtrtc)
SETRTC(CVT_FAIL|CVT_BADDATE);
return -1; /* bad month */
}
- /* adjust leap year */
+ /* adjust current leap year */
if (clock->month >= 3 && dysize(clock->year) == 366)
t++;
+ /*
+ * collect days from months excluding the current one
+ */
for (i = 1; i < clock->month; i++)
{
t += days_of_month[i];
@@ -586,7 +781,11 @@ parse_to_unixtime(clock, cvtrtc)
return -1; /* bad day */
}
+ /*
+ * collect days from date excluding the current one
+ */
t += clock->day - 1;
+
/* hour */
if (clock->hour < 0 || clock->hour >= 24)
{
@@ -594,6 +793,9 @@ parse_to_unixtime(clock, cvtrtc)
return -1; /* bad hour */
}
+ /*
+ * calculate hours from 1. 1. 1970
+ */
t = TIMES24(t) + clock->hour;
/* min */
@@ -603,10 +805,16 @@ parse_to_unixtime(clock, cvtrtc)
return -1; /* bad min */
}
+ /*
+ * calculate minutes from 1. 1. 1970
+ */
t = TIMES60(t) + clock->minute;
/* sec */
- t += clock->utcoffset; /* warp to UTC */
+ /*
+ * calculate UTC in minutes
+ */
+ t += clock->utcoffset;
if (clock->second < 0 || clock->second > 60) /* allow for LEAPs */
{
@@ -614,12 +822,15 @@ parse_to_unixtime(clock, cvtrtc)
return -1; /* bad sec */
}
+ /*
+ * calculate UTC in seconds - phew !
+ */
t = TIMES60(t) + clock->second;
/* done */
return t;
}
-/*
+/*-----------------------------------------------------------------------
* cheap half baked 1/0 decision - for interactive operation only
*/
static char type(c)
@@ -629,6 +840,9 @@ unsigned char c;
return (c > 0xF);
}
+/*-----------------------------------------------------------------------
+ * week day representation
+ */
static char *wday[8] =
{
"??",
@@ -641,6 +855,9 @@ static char *wday[8] =
"Su"
};
+/*-----------------------------------------------------------------------
+ * generate a string representation for a timeval
+ */
static char * pr_timeval(val)
struct timeval *val;
{
@@ -653,11 +870,20 @@ static char * pr_timeval(val)
return buf;
}
+/*-----------------------------------------------------------------------
+ * correct the current time by an offset by setting the time rigorously
+ */
static void set_time(offset)
struct timeval *offset;
{
struct timeval the_time;
- /*XXX*/ if (loop_filter_debug) printf("set_time: %s ", pr_timeval(offset));
+
+ if (no_set)
+ return;
+
+ LPRINTF("set_time: %s ", pr_timeval(offset));
+ syslog(LOG_NOTICE, "setting time (offset %s)", pr_timeval(offset));
+
if (gettimeofday(&the_time, 0L) == -1)
{
perror("gettimeofday()");
@@ -672,20 +898,28 @@ static void set_time(offset)
}
}
+/*-----------------------------------------------------------------------
+ * slew the time by a given offset
+ */
static void adj_time(offset)
register long offset;
{
struct timeval time_offset;
+ if (no_set)
+ return;
+
time_offset.tv_sec = offset / 1000000;
time_offset.tv_usec = offset % 1000000;
- /*XXX*/ if (loop_filter_debug)
- printf("adj_time: %d us ", offset);
+ LPRINTF("adj_time: %d us ", offset);
if (adjtime(&time_offset, 0L) == -1)
perror("adjtime()");
}
+/*-----------------------------------------------------------------------
+ * read in a possibly previously written drift value
+ */
static void read_drift(drift_file)
char *drift_file;
{
@@ -698,17 +932,18 @@ static void read_drift(drift_file)
fscanf(df, "%4d.%03d", &idrift, &fdrift);
fclose(df);
- /*XXX*/ if (loop_filter_debug)
- printf("read_drift: %d.%03d ppm ", idrift, fdrift);
+ LPRINTF("read_drift: %d.%03d ppm ", idrift, fdrift);
drift_comp = idrift << USECSCALE;
fdrift = (fdrift << USECSCALE) / 1000;
drift_comp += fdrift & (1<<USECSCALE);
- /*XXX*/ if (loop_filter_debug)
- printf("read_drift: drift_comp %d ", drift_comp);
+ LPRINTF("read_drift: drift_comp %d ", drift_comp);
}
}
+/*-----------------------------------------------------------------------
+ * write out the current drift value
+ */
static void update_drift(drift_file, offset, reftime)
char *drift_file;
long offset;
@@ -722,18 +957,20 @@ static void update_drift(drift_file, offset, reftime)
int idrift = R_SHIFT(drift_comp, USECSCALE);
int fdrift = drift_comp & ((1<<USECSCALE)-1);
- /*XXX*/ if (loop_filter_debug)
- printf("update_drift: drift_comp %d ", drift_comp);
+ LPRINTF("update_drift: drift_comp %d ", drift_comp);
fdrift = (fdrift * 1000) / (1<<USECSCALE);
fprintf(df, "%4d.%03d %c%d.%06d %.24s\n", idrift, fdrift,
(offset < 0) ? '-' : '+', abs(offset) / 1000000, abs(offset) % 1000000,
asctime(localtime(&reftime)));
fclose(df);
- /*XXX*/ if (loop_filter_debug)
- printf("update_drift: %d.%03d ppm ", idrift, fdrift);
+ LPRINTF("update_drift: %d.%03d ppm ", idrift, fdrift);
}
}
+/*-----------------------------------------------------------------------
+ * process adjustments derived from the DCF77 observation
+ * (controls clock PLL)
+ */
static void adjust_clock(offset, drift_file, reftime)
struct timeval *offset;
char *drift_file;
@@ -743,6 +980,9 @@ static void adjust_clock(offset, drift_file, reftime)
register long usecoffset;
int tmp;
+ if (no_set)
+ return;
+
if (skip_adjust)
{
skip_adjust = 0;
@@ -783,11 +1023,13 @@ static void adjust_clock(offset, drift_file, reftime)
drift_comp = -MAX_DRIFT;
update_drift(drift_file, usecoffset, reftime);
- /*XXX*/ if (loop_filter_debug)
- printf("clock_adjust: %s, clock_adjust %d, drift_comp %d(%d) ",
+ LPRINTF("clock_adjust: %s, clock_adjust %d, drift_comp %d(%d) ",
pr_timeval(offset), R_SHIFT(clock_adjust, USECSCALE) , R_SHIFT(drift_comp, USECSCALE), drift_comp);
}
+/*-----------------------------------------------------------------------
+ * adjust the clock by a small mount to simulate frequency correction
+ */
static void periodic_adjust()
{
register long adjustment;
@@ -803,9 +1045,13 @@ static void periodic_adjust()
adj_time(adjustment);
}
+/*-----------------------------------------------------------------------
+ * control synchronisation status (warnings) and do periodic adjusts
+ * (frequency control simulation)
+ */
static void tick()
{
- static unsigned long last_notice;
+ static unsigned long last_notice = 0;
#ifndef SV_ONSTACK
(void)signal(SIGALRM, tick);
@@ -815,11 +1061,29 @@ static void tick()
ticks += 1<<ADJINTERVAL;
- if ((sync_state == NO_SYNC) && ((ticks - last_sync) > MAX_UNSYNC) &&
- ((last_notice - ticks) > NOTICE_INTERVAL))
+ if ((ticks - last_sync) > MAX_UNSYNC)
{
- syslog(LOG_NOTICE, "still not synchronized - check receiver/signal");
- last_notice = ticks;
+ /*
+ * not getting time for a while
+ */
+ if (sync_state == SYNC)
+ {
+ /*
+ * completely lost information
+ */
+ sync_state = NO_SYNC;
+ syslog(LOG_INFO, "DCF77 reception lost (timeout)");
+ last_notice = ticks;
+ }
+ else
+ /*
+ * in NO_SYNC state - look whether its time to speak up again
+ */
+ if ((ticks - last_notice) > NOTICE_INTERVAL)
+ {
+ syslog(LOG_NOTICE, "still not synchronized to DCF77 - check receiver/signal");
+ last_notice = ticks;
+ }
}
#ifndef ITIMER_REAL
@@ -827,6 +1091,10 @@ static void tick()
#endif
}
+/*-----------------------------------------------------------------------
+ * break association from terminal to avaoid catching terminal
+ * or process group related signals (-> daemon operation)
+ */
static void detach()
{
int s;
@@ -855,18 +1123,26 @@ static void detach()
#endif /* hpux */
}
+/*-----------------------------------------------------------------------
+ * list possible arguments and options
+ */
static void usage(program)
char *program;
{
fprintf(stderr, "usage: %s [-f] [-l] [-t] [-i] [-o] [-d <drift_file>] <device>\n", program);
+ fprintf(stderr, "\t-n do not change time\n");
fprintf(stderr, "\t-i interactive\n");
fprintf(stderr, "\t-t trace (print all datagrams)\n");
fprintf(stderr, "\t-f print all databits (includes PTB private data)\n");
fprintf(stderr, "\t-l print loop filter debug information\n");
fprintf(stderr, "\t-o print offet average for current minute\n");
fprintf(stderr, "\t-d <drift_file> specify alternate drift file\n");
+ fprintf(stderr, "\t-D <input delay>specify delay from input edge to processing in micro seconds\n");
}
+/*-----------------------------------------------------------------------
+ * main loop - argument interpreter / setup / main loop
+ */
int
main(argc, argv)
int argc;
@@ -880,9 +1156,13 @@ main(argc, argv)
int fd;
int offset = 15;
int offsets = 0;
+ int delay = DEFAULT_DELAY; /* average delay from input edge to time stamping */
int trace = 0;
int errs = 0;
+ /*
+ * process arguments
+ */
while (--ac)
{
char *arg = *++a;
@@ -906,6 +1186,10 @@ main(argc, argv)
interactive = 1;
break;
+ case 'n':
+ no_set = 1;
+ break;
+
case 'o':
offsets = 1;
interactive = 1;
@@ -915,6 +1199,19 @@ main(argc, argv)
interactive = 1;
break;
+ case 'D':
+ if (ac > 1)
+ {
+ delay = atoi(*++a);
+ ac--;
+ }
+ else
+ {
+ fprintf(stderr, "%s: -D requires integer argument\n", argv[0]);
+ errs=1;
+ }
+ break;
+
case 'd':
if (ac > 1)
{
@@ -958,6 +1255,9 @@ main(argc, argv)
errs = LINES+1;
+ /*
+ * get access to DCF77 tty port
+ */
fd = open(file, O_RDONLY);
if (fd == -1)
{
@@ -975,6 +1275,7 @@ main(argc, argv)
char buf[61]; /* raw data */
clocktime_t clock; /* wall clock time */
time_t utc_time = 0;
+ time_t last_utc_time = 0;
long usecerror = 0;
long lasterror = 0;
#if defined(HAVE_TERMIOS) || defined(STREAM)
@@ -989,8 +1290,11 @@ main(argc, argv)
timeout.tv_usec = 500000;
phase.tv_sec = 0;
- phase.tv_usec = 230000;
+ phase.tv_usec = delay;
+ /*
+ * setup TTY (50 Baud, Read, 8Bit, No Hangup, 1 character IO)
+ */
if (TTY_GETATTR(fd, &term) == -1)
{
perror("tcgetattr");
@@ -1010,15 +1314,24 @@ main(argc, argv)
exit(1);
}
+ /*
+ * loose terminal if in daemon operation
+ */
if (!interactive)
detach();
+ /*
+ * get syslog() initialized
+ */
#ifdef LOG_DAEMON
openlog("dcfd", LOG_PID, LOG_DAEMON);
#else
openlog("dcfd", LOG_PID);
#endif
+ /*
+ * setup periodic operations (state control / frequency control)
+ */
#ifdef SV_ONSTACK
{
struct sigvec vec;
@@ -1064,10 +1377,19 @@ main(argc, argv)
read_drift(drift_file);
+ /*
+ * what time is it now (for interval measurement)
+ */
gettimeofday(&tlast, 0L);
i = 0;
+ /*
+ * loop until input trouble ...
+ */
do
{
+ /*
+ * get an impulse
+ */
while ((rrc = read(fd, &c, 1)) == 1)
{
gettimeofday(&t, 0L);
@@ -1081,23 +1403,32 @@ main(argc, argv)
errs = 0;
}
+ /*
+ * timeout -> possible minute mark -> interpretation
+ */
if (timercmp(&t, &timeout, >))
{
PRINTF("%c %.*s ", pat[i % (sizeof(pat)-1)], 59 - offset, &pbuf[offset]);
if ((rtc = cvt_rawdcf(buf, i, &clock)) != CVT_OK)
{
+ /*
+ * this data was bad - well - forget synchronisation for now
+ */
PRINTF("\n");
if (sync_state == SYNC)
{
sync_state = NO_SYNC;
- syslog(LOG_DEBUG, "DCF77 reception lost");
+ syslog(LOG_INFO, "DCF77 reception lost (bad data)");
}
errs++;
}
buf[0] = c;
+ /*
+ * collect first character
+ */
if (((c^0xFF)+1) & (c^0xFF))
pbuf[0] = '?';
else
@@ -1110,6 +1441,9 @@ main(argc, argv)
}
else
{
+ /*
+ * collect character
+ */
buf[i] = c;
/*
@@ -1125,12 +1459,34 @@ main(argc, argv)
if (i == 0 && rtc == CVT_OK)
{
- if ((utc_time = parse_to_unixtime(&clock, &rtc)) == -1)
+ /*
+ * we got a good time code here - try to convert it to
+ * UTC
+ */
+ if ((utc_time = dcf_to_unixtime(&clock, &rtc)) == -1)
{
PRINTF("*** BAD CONVERSION\n");
}
- usecerror = 0;
+ if (utc_time != (last_utc_time + 60))
+ {
+ /*
+ * well, two successive sucessful telegrams are not 60 seconds
+ * apart
+ */
+ PRINTF("*** NO MINUTE INC\n");
+ if (sync_state == SYNC)
+ {
+ sync_state = NO_SYNC;
+ syslog(LOG_INFO, "DCF77 reception lost (data mismatch)");
+ }
+ errs++;
+ rtc = CVT_FAIL|CVT_BADTIME|CVT_BADDATE;
+ }
+ else
+ usecerror = 0;
+
+ last_utc_time = utc_time;
}
if (rtc == CVT_OK)
@@ -1142,14 +1498,25 @@ main(argc, argv)
if (i == 0)
{
- time_offset.tv_sec = lasterror / 1000000;
- time_offset.tv_usec = lasterror % 1000000;
- adjust_clock(&time_offset, drift_file, utc_time+i);
+ /*
+ * valid time code - determine offset and
+ * note regained reception
+ */
last_sync = ticks;
if (sync_state == NO_SYNC)
{
syslog(LOG_INFO, "receiving DCF77");
}
+ else
+ {
+ /*
+ * we had at least one minute SYNC - thus
+ * last error is valid
+ */
+ time_offset.tv_sec = lasterror / 1000000;
+ time_offset.tv_usec = lasterror % 1000000;
+ adjust_clock(&time_offset, drift_file, utc_time);
+ }
sync_state = SYNC;
}
@@ -1161,6 +1528,9 @@ main(argc, argv)
usecerror += (time_offset.tv_sec - tt.tv_sec) * 1000000 + time_offset.tv_usec
-tt.tv_usec;
+ /*
+ * output interpreted DCF77 data
+ */
PRINTF(offsets ? "%s, %2d:%02d:%02d, %d.%02d.%02d, <%s%s%s%s> (%c%d.%06ds)" :
"%s, %2d:%02d:%02d, %d.%02d.%02d, <%s%s%s%s>",
wday[clock.wday],
@@ -1180,6 +1550,10 @@ main(argc, argv)
}
lasterror = usecerror / (i+1);
}
+ else
+ {
+ lasterror = 0; /* we cannot calculate phase errors on bad reception */
+ }
PRINTF("\r");
@@ -1195,7 +1569,10 @@ main(argc, argv)
}
} while ((rrc == -1) && (errno == EINTR));
- syslog(LOG_ERR, "TERMINATING - cannot read from device %s", file);
+ /*
+ * lost IO - sorry guys
+ */
+ syslog(LOG_ERR, "TERMINATING - cannot read from device %s (%m)", file);
(void)close(fd);
}
diff --git a/usr.sbin/xntpd/parse/util/parsetest.c b/usr.sbin/xntpd/parse/util/parsetest.c
index 4f26a0a6a98a..9028b4cf4cf4 100644
--- a/usr.sbin/xntpd/parse/util/parsetest.c
+++ b/usr.sbin/xntpd/parse/util/parsetest.c
@@ -1,9 +1,9 @@
/*
* /src/NTP/REPOSITORY/v3/kernel/parsetest.c,v 3.4 1993/03/17 17:16:57 kardel Exp
*
- * parsetest.c,v 3.4 1993/03/17 17:16:57 kardel Exp
+ * parsetest.c,v 3.10 1994/01/23 17:22:18 kardel Exp
*
- * Copyright (c) 1989,1990,1991,1992,1993
+ * Copyright (c) 1989,1990,1991,1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -198,7 +198,7 @@ main(argc, argv)
parsetime_t parsetime;
struct strioctl strioc;
- printf("parsetest.c,v 3.9 1993/10/10 21:18:49 kardel Exp\n");
+ printf("parsetest.c,v 3.10 1994/01/23 17:22:18 kardel Exp\n");
while (ioctl(fd, I_POP, 0) == 0)
;
diff --git a/usr.sbin/xntpd/parse/util/testdcf.c b/usr.sbin/xntpd/parse/util/testdcf.c
index e07bc0c1cc01..ebdfd2fded07 100644
--- a/usr.sbin/xntpd/parse/util/testdcf.c
+++ b/usr.sbin/xntpd/parse/util/testdcf.c
@@ -1,11 +1,11 @@
/*
- * /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.7 1993/10/10 22:44:48 kardel Exp
+ * /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.9 1994/01/25 19:05:45 kardel Exp
*
- * testdcf.c,v 3.7 1993/10/10 22:44:48 kardel Exp
+ * testdcf.c,v 3.9 1994/01/25 19:05:45 kardel Exp
*
* simple DCF77 100/200ms pulse test program (via 50Baud serial line)
*
- * Copyright (c) 1993
+ * Copyright (c) 1993,1994
* Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -352,7 +352,7 @@ main(argc, argv)
exit(1);
}
- bzero(term.c_cc, sizeof(term.c_cc));
+ memset(term.c_cc, 0, sizeof(term.c_cc));
term.c_cc[VMIN] = 1;
term.c_cflag = B50|CS8|CREAD|CLOCAL;
term.c_iflag = 0;
diff --git a/usr.sbin/xntpd/refclocks/Dependencies b/usr.sbin/xntpd/refclocks/Dependencies
index d5e68d3da939..28294765f79e 100644
--- a/usr.sbin/xntpd/refclocks/Dependencies
+++ b/usr.sbin/xntpd/refclocks/Dependencies
@@ -11,14 +11,16 @@ WWVB WWVB
WWVBCLK /LD/||/STREAM/ PPSPPS LD||STREAM(tty_clock||tty_clk_streams)
WWVBPPS /PPSPPS/
CHU CHU /SUNOS4/ none
-PARSE PARSE /SYS_V_TTYS/||/STREAM/ PPS any||STREAM(parse||ppsclock||ppsclocd)
- PARSEPPS /SYS_V_TTYS/||/STREAM/ PPS any||STREAM(parse||ppsclock||ppsclocd)
+PARSE PARSE /SYSV_TTYS/||/STREAM/||/TERMIOS/ PPS any||STREAM(parse||ppsclock||ppsclocd)
+ PARSEPPS /SYSV_TTYS/||/STREAM/||/TERMIOS/ PPS any||STREAM(parse||ppsclock||ppsclocd)
CLOCK_*
MX4200 MX4200PPS /PPSPPS/
AS2201 AS2201
AS2201PPS /PPSPPS/
GOES GOES
GOESPPS /PPSPPS/
+GPSTM GPSTM
+ GPSTTMPPS /PPSPPS/
OMEGA OMEGA
OMEGAPPS /PPSPPS/
TPRO TPRO /SUNOS/
diff --git a/usr.sbin/xntpd/refclocks/rclk.GPSTM b/usr.sbin/xntpd/refclocks/rclk.GPSTM
new file mode 100644
index 000000000000..552747a57afd
--- /dev/null
+++ b/usr.sbin/xntpd/refclocks/rclk.GPSTM
@@ -0,0 +1,33 @@
+#!/bin/sh -
+CMD="$1"
+shift;
+
+. refclocks/setup
+
+case "$CMD" in
+ info)
+ echo " GPSTM - Kinemetrics/TrueTime GPS-TM/TMD receiver"
+ ;;
+ check)
+ if check "$RCONFIG" '$0 ~ /GPSTM/'; then
+ echo "GPSTM - Kinemetrics/TrueTime GPS-TM/TMD receiver"
+ fi
+ ;;
+ config)
+ if check "$REFCONF" '$0 ~ /GPSTM/' ||
+ ( [ ! "$REFCONF" ] &&
+ query "Include Kinemetrics/TrueTime GPS-TM/TMD receiver (GPSTM)" n); then
+ if check "$PPSFEATURES" '$0 ~ /CD/'; then
+ if [ "$PPSOK" -eq 1 ] &&
+ (check "$REFCONF" '$0 ~ /GPSTMPPS/' ||
+ ( [ ! "$REFCONF" ] && query " Use GPSTM for PPS" n)); then
+ echo "-DGPSTMPPS" >> $RCONFIG
+ else
+ echo "-DGPSTM" >> $RCONFIG
+ fi
+ else
+ echo "-DGPSTM" >> $RCONFIG
+ fi
+ fi
+ ;;
+esac
diff --git a/usr.sbin/xntpd/refclocks/rclk.PARSE b/usr.sbin/xntpd/refclocks/rclk.PARSE
index 0bcf6972eb4c..b91ed8bf8153 100644
--- a/usr.sbin/xntpd/refclocks/rclk.PARSE
+++ b/usr.sbin/xntpd/refclocks/rclk.PARSE
@@ -4,7 +4,7 @@ shift;
. refclocks/setup
-if check "$DEFS" '$0 ~ /HAVE_SYSV_TTYS|STREAM/'; then
+if check "$DEFS" '$0 ~ /HAVE_SYSV_TTYS|STREAM|HAVE_TERMIOS/'; then
case "$CMD" in
info)
echo " PARSE - GENERIC refence clock driver"
diff --git a/usr.sbin/xntpd/refclocks/rconfig b/usr.sbin/xntpd/refclocks/rconfig
index 727f0a8707da..75f43fad2087 100644
--- a/usr.sbin/xntpd/refclocks/rconfig
+++ b/usr.sbin/xntpd/refclocks/rconfig
@@ -81,11 +81,11 @@ else
for i in $rcfg
do
sh $i config "$RCONFIG" "$PPSFEATURES" "$PPSOK" "$DEFS" "$REFCONF"
- if [ "$PPSOK" -eq 1 ] && egrep -s -e '-D..*PPS' "$RCONFIG" >/dev/null 2>&1; then
+ if [ "$PPSOK" -eq 1 ] && egrep -e '-D..*PPS' "$RCONFIG" >/dev/null 2>&1; then
PPSOK=0
fi
done
- if egrep -s -e '-D..*PPS' "$RCONFIG" >/dev/null 2>&1; then
+ if egrep -e '-D..*PPS' "$RCONFIG" >/dev/null 2>&1; then
PPS="-DPPSPPS $PPS"
fi
CLOCKDEFS="`tr '\012' ' ' < $RCONFIG`"
diff --git a/usr.sbin/xntpd/scripts/Guess.sh b/usr.sbin/xntpd/scripts/Guess.sh
index 97fd4c7cb24e..c2be5697eab7 100755
--- a/usr.sbin/xntpd/scripts/Guess.sh
+++ b/usr.sbin/xntpd/scripts/Guess.sh
@@ -19,7 +19,8 @@ if [ -f /bin/uname -o -f /usr/bin/uname ]; then
sinix-m)
guess=sinix-m
;;
- sunos) case "$3" in
+ sunos|solaris)
+ case "$3" in
4.1*) guess="sunos4" ;;
5.1) guess="sunos5.1" ;;
5.*) guess="sunos5.2" ;;
@@ -59,7 +60,7 @@ if [ -f /bin/uname -o -f /usr/bin/uname ]; then
guess="netbsd"
;;
# now the fun starts - there are vendors that
- # do not really identify their OS un uname.
+ # do not really identify their OS in uname.
# Fine - now I look at our version and hope
# that nobody else had this marvellous idea.
# I am not willing to mention the vendor explicitly
@@ -109,6 +110,11 @@ if [ -f /netbsd ]; then
exit 0
fi
+if [ -f /lib/clib -a -f /lib/libc ]; then
+ echo domainos
+ exit 0
+fi
+
case "$guess" in
'') guess="none"
esac
diff --git a/usr.sbin/xntpd/scripts/autoconf b/usr.sbin/xntpd/scripts/autoconf
index d1dc4c0bae71..b661910b5e23 100755
--- a/usr.sbin/xntpd/scripts/autoconf
+++ b/usr.sbin/xntpd/scripts/autoconf
@@ -323,8 +323,8 @@ err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
{
test -n "$verbose" && \
-echo ' defining' HAVE_UNISTD_H
-DEFS="$DEFS -DHAVE_UNISTD_H=1"
+echo ' defining' NTP_POSIX_SOURCE
+DEFS="$DEFS -DNTP_POSIX_SOURCE=1"
}
fi
diff --git a/usr.sbin/xntpd/scripts/stats/clock.awk b/usr.sbin/xntpd/scripts/stats/clock.awk
index f6afc994fd83..c9d1455b6fef 100644
--- a/usr.sbin/xntpd/scripts/stats/clock.awk
+++ b/usr.sbin/xntpd/scripts/stats/clock.awk
@@ -107,7 +107,7 @@ BEGIN {
# select ITF records
# see summary for decode
#
- else if (NF >= 13 && $5 == "ITF" && $12 >= 500) {
+ else if (NF >= 13 && $5 == "ITF" && $12 >= 100) {
itf_count++
if ($9 > 200e-9 || $9 < -200e-9)
itf_200++
@@ -122,7 +122,7 @@ BEGIN {
# select ETF records
# see summary for decode
#
- else if (NF >= 13 && $5 == "ETF" && $13 >= 500) {
+ else if (NF >= 13 && $5 == "ETF" && $13 >= 100) {
etf_count++
if ($6 > etf_max)
etf_max = $6
diff --git a/usr.sbin/xntpd/scripts/stats/summary.sh b/usr.sbin/xntpd/scripts/stats/summary.sh
index e27ecfa94650..ab99f4d8e8d5 100755
--- a/usr.sbin/xntpd/scripts/stats/summary.sh
+++ b/usr.sbin/xntpd/scripts/stats/summary.sh
@@ -4,9 +4,14 @@
#
# This script can be run from a cron job once per day, week or month. It
# runs the file-specific summary script and appends the summary data to
-# designated files.
+# designated files, which must be created first.
#
-peer.sh >>peer_summary
-loop.sh >>loop_summary
-clock.sh >>clock_summary
-
+if ( -e peer_summary ) then
+ peer.sh >>peer_summary
+endif
+if ( -e loop_summary ) then
+ loop.sh >>loop_summary
+endif
+if ( -e clock_summary ) then
+ clock.sh >>clock_summary
+endif
diff --git a/usr.sbin/xntpd/util/Makefile.tmpl b/usr.sbin/xntpd/util/Makefile.tmpl
index 1115ef83a7d4..be1681f3af54 100644
--- a/usr.sbin/xntpd/util/Makefile.tmpl
+++ b/usr.sbin/xntpd/util/Makefile.tmpl
@@ -32,7 +32,7 @@ EXECS= ntptime jitter timetrim kern byteorder longsize precision
all: $(PROGRAM)
tickadj: $(TKOBJS)
- $(CC) $(COPTS) -o $@ $(TKOBJS) $(DAEMONLIBS) $(RESLIB) $(COMPAT)
+ $(CC) $(COPTS) -o $@ $(TKOBJS) $(LIB) $(DAEMONLIBS) $(RESLIB) $(COMPAT)
ntptime: $(NTOBJS)
$(CC) $(COPTS) -o $@ $(NTOBJS) $(LIB)
diff --git a/usr.sbin/xntpd/util/ntptime.c b/usr.sbin/xntpd/util/ntptime.c
index e528802f7298..c0512df90a87 100644
--- a/usr.sbin/xntpd/util/ntptime.c
+++ b/usr.sbin/xntpd/util/ntptime.c
@@ -37,7 +37,6 @@
extern int sigvec P((int, struct sigvec *, struct sigvec *));
void pll_trap P((void));
-extern int getopt_l P((int, char **, char *));
static struct sigvec newsigsys; /* new sigvec status */
static struct sigvec sigsys; /* current sigvec status */
@@ -51,8 +50,8 @@ main(argc, argv)
int argc;
char *argv[];
{
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
int status;
struct ntptimeval ntv;
struct timex ntx, _ntx;
@@ -66,46 +65,47 @@ main(argc, argv)
ntx.mode = 0;
progname = argv[0];
- while ((c = getopt_l(argc, argv, optargs)) != EOF) switch (c) {
+ while ((c = ntp_getopt(argc, argv, optargs)) != EOF) switch (c) {
case 'c':
cost++;
break;
case 'e':
ntx.mode |= ADJ_ESTERROR;
- ntx.esterror = atoi(optarg);
+ ntx.esterror = atoi(ntp_optarg);
break;
case 'f':
ntx.mode |= ADJ_FREQUENCY;
- ntx.frequency = (int) (atof(optarg) * (1 << SHIFT_USEC));
+ ntx.frequency = (int) (atof(ntp_optarg)
+ * (1 << SHIFT_USEC));
if (ntx.frequency < (-100 << SHIFT_USEC)
|| ntx.frequency > ( 100 << SHIFT_USEC)) errflg++;
break;
case 'm':
ntx.mode |= ADJ_MAXERROR;
- ntx.maxerror = atoi(optarg);
+ ntx.maxerror = atoi(ntp_optarg);
break;
case 'o':
ntx.mode |= ADJ_OFFSET;
- ntx.offset = atoi(optarg);
+ ntx.offset = atoi(ntp_optarg);
break;
case 'r':
rawtime++;
break;
case 's':
ntx.mode |= ADJ_STATUS;
- ntx.status = atoi(optarg);
+ ntx.status = atoi(ntp_optarg);
if (ntx.status < 0 || ntx.status > 4) errflg++;
break;
case 't':
ntx.mode |= ADJ_TIMECONST;
- ntx.time_constant = atoi(optarg);
+ ntx.time_constant = atoi(ntp_optarg);
if (ntx.time_constant < 0 || ntx.time_constant > MAXTC)
errflg++;
break;
default:
errflg++;
}
- if (errflg || (optind != argc)) {
+ if (errflg || (ntp_optind != argc)) {
(void) fprintf(stderr,
"usage: %s [-%s]\n\n\
-c display the time taken to call ntp_gettime (us)\n\
diff --git a/usr.sbin/xntpd/util/tickadj.c b/usr.sbin/xntpd/util/tickadj.c
index da18e0660318..ab10b3728a0e 100644
--- a/usr.sbin/xntpd/util/tickadj.c
+++ b/usr.sbin/xntpd/util/tickadj.c
@@ -61,9 +61,6 @@ static char * getoffsets P((char *, unsigned long *, unsigned long *, unsigned l
static int openfile P((char *, int));
static void writevar P((int, unsigned long, int));
static void readvar P((int, unsigned long, int *));
-#ifndef NTP_POSIX_SOURCE
-extern int getopt P((int, char **, char *));
-#endif
/*
* main - parse arguments and handle options
@@ -75,8 +72,8 @@ char *argv[];
{
int c;
int errflg = 0;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
unsigned long tickadj_offset;
unsigned long tick_offset;
unsigned long dosync_offset;
@@ -94,7 +91,7 @@ char *argv[];
void writevar();
progname = argv[0];
- while ((c = getopt(argc, argv, "a:Adkqpst:")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "a:Adkqpst:")) != EOF)
switch (c) {
case 'd':
++debug;
@@ -109,11 +106,11 @@ char *argv[];
quiet = 1;
break;
case 'a':
- writetickadj = atoi(optarg);
+ writetickadj = atoi(ntp_optarg);
if (writetickadj <= 0) {
(void) fprintf(stderr,
"%s: unlikely value for tickadj: %s\n",
- progname, optarg);
+ progname, ntp_optarg);
errflg++;
}
break;
@@ -124,11 +121,11 @@ char *argv[];
unsetdosync = 1;
break;
case 't':
- writetick = atoi(optarg);
+ writetick = atoi(ntp_optarg);
if (writetick <= 0) {
(void) fprintf(stderr,
"%s: unlikely value for tick: %s\n",
- progname, optarg);
+ progname, ntp_optarg);
errflg++;
}
break;
@@ -136,7 +133,7 @@ char *argv[];
errflg++;
break;
}
- if (errflg || optind != argc) {
+ if (errflg || ntp_optind != argc) {
(void) fprintf(stderr,
"usage: %s [-Aqsp] [-a newadj] [-t newtick]\n", progname);
exit(2);
@@ -154,25 +151,25 @@ char *argv[];
if (setnoprintf && (noprintf_offset == 0)) {
(void) fprintf(stderr,
"No noprintf kernal variable\n");
- exit(1);
+ errflg++;
}
if (unsetdosync && (dosync_offset == 0)) {
(void) fprintf(stderr,
"No dosynctodr kernal variable\n");
- exit(1);
+ errflg++;
}
if (writeopttickadj && (tickadj_offset == 0)) {
(void) fprintf(stderr,
"No tickadj kernal variable\n");
- exit(1);
+ errflg++;
}
if (writetick && (tick_offset == 0)) {
(void) fprintf(stderr,
"No tick kernal variable\n");
- exit(1);
+ errflg++;
}
@@ -234,7 +231,7 @@ char *argv[];
if (writetickadj == 0 && !writeopttickadj &&
!unsetdosync && writetick == 0 && !setnoprintf)
- exit(0);
+ exit(errflg ? 1 : 0);
if (writetickadj == 0 && writeopttickadj)
writetickadj = recommend_tickadj;
@@ -283,7 +280,7 @@ char *argv[];
(void) fprintf(stderr, "done!\n");
}
(void) close(fd);
- exit(0);
+ exit(errflg ? 1 : 0);
}
/*
diff --git a/usr.sbin/xntpd/xntpd/Makefile.tmpl b/usr.sbin/xntpd/xntpd/Makefile.tmpl
index a51dbd7becea..ec600ac79bb2 100644
--- a/usr.sbin/xntpd/xntpd/Makefile.tmpl
+++ b/usr.sbin/xntpd/xntpd/Makefile.tmpl
@@ -34,7 +34,7 @@ SOURCE= ntp_config.c ntp_control.c ntp_io.c ntp_leap.c \
refclock_wwvb.c refclock_goes.c refclock_mx4200.c \
refclock_parse.c refclock_as2201.c refclock_omega.c \
refclock_tpro.c refclock_leitch.c refclock_irig.c \
- refclock_msfees.c ntp_intres.c ntp_filegen.c
+ refclock_msfees.c refclock_gpstm.c ntp_intres.c ntp_filegen.c
OBJS= ntp_config.o ntp_control.o ntp_io.o ntp_leap.o \
ntp_loopfilter.o ntp_monitor.o ntp_peer.o ntp_proto.o \
@@ -44,7 +44,7 @@ OBJS= ntp_config.o ntp_control.o ntp_io.o ntp_leap.o \
refclock_wwvb.o refclock_goes.o refclock_mx4200.o \
refclock_parse.o refclock_as2201.o refclock_omega.o \
refclock_tpro.o refclock_leitch.o refclock_irig.o \
- refclock_msfees.o ntp_intres.o ntp_filegen.o
+ refclock_msfees.o refclock_gpstm.o ntp_intres.o ntp_filegen.o
all: $(PROGRAM)
@@ -136,3 +136,6 @@ refclock_irig.o: refclock_irig.c
refclock_msfees.o: refclock_msfees.c
$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c
+
+refclock_gpstm.o: refclock_gpstm.c
+ $(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c
diff --git a/usr.sbin/xntpd/xntpd/ntp_config.c b/usr.sbin/xntpd/xntpd/ntp_config.c
index 1a0e9ef4bf24..1b716f69fab5 100644
--- a/usr.sbin/xntpd/xntpd/ntp_config.c
+++ b/usr.sbin/xntpd/xntpd/ntp_config.c
@@ -1,4 +1,4 @@
-/* ntp_config.c,v 3.1 1993/07/06 01:11:12 jbj Exp
+/*
* ntp_config.c - read and apply configuration information
*/
#define RESOLVE_INTERNAL /* gdt */
@@ -93,6 +93,7 @@
#define CONFIG_PPS 24
#define CONFIG_PIDFILE 25
#define CONFIG_LOGFILE 26
+#define CONFIG_SETVAR 27
#define CONF_MOD_VERSION 1
#define CONF_MOD_KEY 2
@@ -177,6 +178,7 @@ static struct keyword keywords[] = {
{ "statistics", CONFIG_STATISTICS },
{ "pidfile", CONFIG_PIDFILE },
{ "logfile", CONFIG_LOGFILE },
+ { "setvar", CONFIG_SETVAR },
{ "", CONFIG_UNKNOWN }
};
@@ -316,7 +318,7 @@ extern int debug;
#endif
extern char *FindConfig();
char *progname;
-static char *xntp_options = "abc:de:f:k:l:p:r:s:t:";
+static char *xntp_options = "abc:de:f:k:l:p:r:s:t:v:V:";
static int gettokens P((FILE *, char *, char **, int *));
static int matchkey P((char *, struct keyword *));
@@ -340,7 +342,7 @@ getstartup(argc, argv)
#ifdef DEBUG
int errflg;
int c;
- extern int optind;
+ extern int ntp_optind;
debug = 0; /* no debugging by default */
@@ -352,7 +354,7 @@ getstartup(argc, argv)
* don't want to initialize anything until after detaching from
* the terminal, but we won't know to do that until we've
* parsed the command line. Do that now, crudely, and do it
- * again later. Our getopt_l() is explicitly reusable, by the
+ * again later. Our ntp_getopt() is explicitly reusable, by the
* way. Your own mileage may vary.
*/
errflg = 0;
@@ -361,7 +363,7 @@ getstartup(argc, argv)
/*
* Decode argument list
*/
- while ((c = getopt_l(argc, argv, xntp_options)) != EOF)
+ while ((c = ntp_getopt(argc, argv, xntp_options)) != EOF)
switch (c) {
case 'd':
++debug;
@@ -373,12 +375,14 @@ getstartup(argc, argv)
break;
}
- if (errflg || optind != argc) {
- (void) fprintf(stderr,
- "usage: %s [ -bd ] [ -c config_file ]\n", progname);
+ if (errflg || ntp_optind != argc) {
+ (void) fprintf(stderr, "usage: %s [ -abd ] [ -c config_file ] [ -e encryption delay ]\n", progname);
+ (void) fprintf(stderr, "\t\t[ -f frequency file ] [ -k key file ] [ -l log file ]\n");
+ (void) fprintf(stderr, "\t\t[ -p pid file ] [ -r broadcast delay ] [ -s status directory ]\n");
+ (void) fprintf(stderr, "\t\t[ -t trusted key ] [ -v sys variable ] [ -V default sys variable ]\n");
exit(2);
}
- optind = 0; /* reset optind to restart getopt_l */
+ ntp_optind = 0; /* reset ntp_optind to restart ntp_getopt */
if (debug) {
#ifdef NTP_POSIX_SOURCE
@@ -426,8 +430,9 @@ getconfig(argc, argv)
char resolver_name[MAXFILENAME];
int have_keyfile;
char keyfile[MAXFILENAME];
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
+ extern char *Version;
extern U_LONG info_auth_keyid;
FILEGEN *filegen;
@@ -443,6 +448,12 @@ getconfig(argc, argv)
res_fp = NULL;
have_resolver = have_keyfile = 0;
+ /*
+ * install a non default variable with this daemon version
+ */
+ (void) sprintf(line, "daemon_version=\"%s\"", Version);
+ set_sys_var(line, strlen(line)+1, RO);
+
#ifdef RESOLVE_INTERNAL
resolve_internal = 1;
#endif
@@ -450,7 +461,7 @@ getconfig(argc, argv)
/*
* Decode argument list
*/
- while ((c = getopt_l(argc, argv, xntp_options)) != EOF) {
+ while ((c = ntp_getopt(argc, argv, xntp_options)) != EOF) {
switch (c) {
case 'a':
proto_config(PROTO_AUTHENTICATE, (LONG)1);
@@ -459,7 +470,7 @@ getconfig(argc, argv)
proto_config(PROTO_BROADCLIENT, (LONG)1);
break;
case 'c':
- config_file = optarg;
+ config_file = ntp_optarg;
break;
case 'd':
#ifdef DEBUG
@@ -473,15 +484,15 @@ getconfig(argc, argv)
do {
l_fp tmp;
- if (!atolfp(optarg, &tmp)) {
+ if (!atolfp(ntp_optarg, &tmp)) {
syslog(LOG_ERR,
"command line encryption delay value %s undecodable",
- optarg);
+ ntp_optarg);
errflg++;
} else if (tmp.l_ui != 0) {
syslog(LOG_ERR,
"command line encryption delay value %s is unlikely",
- optarg);
+ ntp_optarg);
errflg++;
} else {
proto_config(PROTO_AUTHDELAY, tmp.l_f);
@@ -490,37 +501,37 @@ getconfig(argc, argv)
break;
case 'f':
- stats_config(STATS_FREQ_FILE, optarg);
+ stats_config(STATS_FREQ_FILE, ntp_optarg);
break;
case 'k':
- getauthkeys(optarg);
- if ((int)strlen(optarg) >= MAXFILENAME) {
+ getauthkeys(ntp_optarg);
+ if ((int)strlen(ntp_optarg) >= MAXFILENAME) {
syslog(LOG_ERR,
"key file name too LONG (>%d, sigh), no name resolution possible",
MAXFILENAME);
} else {
have_keyfile = 1;
- (void)strcpy(keyfile, optarg);
+ (void)strcpy(keyfile, ntp_optarg);
}
break;
case 'p':
- stats_config(STATS_PID_FILE, optarg);
+ stats_config(STATS_PID_FILE, ntp_optarg);
break;
case 'r':
do {
l_fp tmp;
- if (!atolfp(optarg, &tmp)) {
+ if (!atolfp(ntp_optarg, &tmp)) {
syslog(LOG_ERR,
"command line broadcast delay value %s undecodable",
- optarg);
+ ntp_optarg);
} else if (tmp.l_ui != 0) {
syslog(LOG_ERR,
"command line broadcast delay value %s is unlikely",
- optarg);
+ ntp_optarg);
} else {
proto_config(PROTO_BROADDELAY, tmp.l_f);
}
@@ -528,24 +539,28 @@ getconfig(argc, argv)
break;
case 's':
- stats_config(STATS_STATSDIR, optarg);
+ stats_config(STATS_STATSDIR, ntp_optarg);
break;
case 't':
do {
int tkey;
- tkey = atoi(optarg);
+ tkey = atoi(ntp_optarg);
if (tkey <= 0 || tkey > NTP_MAXKEY) {
syslog(LOG_ERR,
"command line trusted key %s is unlikely",
- optarg);
+ ntp_optarg);
} else {
authtrust(tkey, (LONG)1);
}
} while (0);
break;
+ case 'v':
+ case 'V':
+ set_sys_var(ntp_optarg, strlen(ntp_optarg)+1, RW | ((c == 'V') ? DEF : 0));
+ break;
default:
errflg++;
@@ -553,7 +568,7 @@ getconfig(argc, argv)
}
}
- if (errflg || optind != argc) {
+ if (errflg || ntp_optind != argc) {
(void) fprintf(stderr,
"usage: %s [ -bd ] [ -c config_file ]\n", progname);
exit(2);
@@ -1129,7 +1144,7 @@ getconfig(argc, argv)
break;
}
- bzero((char *)&clock, sizeof clock);
+ memset((char *)&clock, 0, sizeof clock);
errflg = 0;
for (i = 2; i < ntokens-1; i++) {
switch (c = matchkey(tokens[i],
@@ -1386,7 +1401,19 @@ getconfig(argc, argv)
(u_char)peerkey, (u_char)peerflags);
}
break;
-
+
+ case CONFIG_SETVAR:
+ if (ntokens < 2)
+ {
+ syslog(LOG_ERR,
+ "no value for setvar command - line ignored");
+ }
+ else
+ {
+ set_sys_var(tokens[1], strlen(tokens[1])+1, RW |
+ ((((ntokens > 2) && !strcmp(tokens[2], "default"))) ? DEF : 0));
+ }
+ break;
}
}
(void) fclose(fp);
@@ -1445,6 +1472,7 @@ gettokens(fp, line, tokenlist, ntokens)
register char *cp;
register int eol;
register int ntok;
+ register int quoted = 0;
/*
* Find start of first token
@@ -1469,8 +1497,9 @@ again:
ntok = 0;
while (!eol) {
tokenlist[ntok++] = cp;
- while (!ISEOL(*cp) && !ISSPACE(*cp))
- cp++;
+ while (!ISEOL(*cp) && (!ISSPACE(*cp) || quoted))
+ quoted ^= (*cp++ == '"');
+
if (ISEOL(*cp)) {
*cp = '\0';
eol = 1;
@@ -1581,7 +1610,7 @@ getnetnum(num, addr, complain)
/*
* make up socket address. Clear it out for neatness.
*/
- bzero((char *)addr, sizeof(struct sockaddr_in));
+ memset((char *)addr, 0, sizeof(struct sockaddr_in));
addr->sin_family = AF_INET;
addr->sin_port = htons(NTP_PORT);
addr->sin_addr.s_addr = htonl(netnum);
diff --git a/usr.sbin/xntpd/xntpd/ntp_control.c b/usr.sbin/xntpd/xntpd/ntp_control.c
index 5e71196e4e16..f63836704b2c 100644
--- a/usr.sbin/xntpd/xntpd/ntp_control.c
+++ b/usr.sbin/xntpd/xntpd/ntp_control.c
@@ -1,4 +1,4 @@
-/* ntp_control.c,v 3.1 1993/07/06 01:11:13 jbj Exp
+/*
* ntp_control.c - respond to control messages and send async traps
*/
#include <stdio.h>
@@ -61,6 +61,7 @@ static void ctl_putpeer P((int, struct peer *));
static void ctl_putclock P((int, struct refclockstat *, int));
#endif /* REFCLOCK */
static struct ctl_var *ctl_getitem P((struct ctl_var *, char **));
+static unsigned long count_var P((struct ctl_var *));
static void control_unspec P((struct recvbuf *, int));
static void read_status P((struct recvbuf *, int));
static void read_variables P((struct recvbuf *, int));
@@ -83,30 +84,6 @@ static struct ctl_proc control_codes[] = {
{ NO_REQUEST, 0 }
};
-
-/*
- * Structure for translation tables between internal system
- * variable indices and text format.
- */
-struct ctl_var {
- u_short code;
- u_short flags;
- char *text;
-};
-
-/*
- * Flag values
- */
-#define CAN_READ 0x1
-#define CAN_WRITE 0x2
-#define PADDING 0x80
-#define EOV 0x40
-
-#define RO (CAN_READ)
-#define WO (CAN_WRITE)
-#define RW (CAN_READ|CAN_WRITE)
-
-
/*
* System variable values. The array can be indexed by
* the variable index to find the textual name.
@@ -132,10 +109,12 @@ static struct ctl_var sys_var[] = {
{ CS_SYSTEM, RO, "system" }, /* 17 */
{ CS_KEYID, RO, "keyid" }, /* 18 */
{ CS_REFSKEW, RO, "refskew" }, /* 19 */
- { CS_VERSION, RO, "daemon_version" }, /* 20 */
+ { CS_VARLIST, RO, "sys_var_list" },/* 20 */
{ 0, EOV, "" }
};
+static struct ctl_var *ext_sys_var = (struct ctl_var *)0;
+
/*
* System variables we print by default (in fuzzball order, more-or-less)
*/
@@ -153,7 +132,6 @@ static u_char def_sys_var[] = {
CS_OFFSET,
CS_DRIFT,
CS_COMPLIANCE,
- CS_VERSION,
0
};
@@ -197,6 +175,8 @@ static struct ctl_var peer_var[] = {
{ CP_SENT, RO, "sent" }, /* 32 */
{ CP_FILTERROR, RO, "filterror" }, /* 33 */
{ CP_FLASH, RO, "flash" }, /* 34 */
+ { CP_DISP, PADDING,"" }, /* 35 */
+ { CP_VARLIST, RO, "peer_var_list" }, /* 36 */
{ 0, EOV, "" }
};
@@ -255,6 +235,7 @@ static struct ctl_var clock_var[] = {
{ CC_FUDGEVAL2, RO, "fudgeval2" }, /* 10 */
{ CC_FLAGS, RO, "flags" }, /* 11 */
{ CC_DEVICE, RO, "device" }, /* 12 */
+ { CC_VARLIST, RO, "clock_var_list" },/* 13 */
{ 0, EOV, "" }
};
@@ -283,8 +264,15 @@ static u_char def_clock_var[] = {
/*
* System and processor definitions. These will change for the gizmo board.
*/
+#ifndef STR_SYSTEM
#define STR_SYSTEM "UNIX"
+#endif
+#ifndef STR_PROCESSOR
#define STR_PROCESSOR "unknown"
+#endif
+
+static char str_system[] = STR_SYSTEM;
+static char str_processor[] = STR_PROCESSOR;
/*
* Trap structures. We only allow a few of these, and send
@@ -872,7 +860,7 @@ ctl_putdata(dp, dlen, bin)
ctl_flushpkt(CTL_MORE);
}
- bcopy(dp, (char *)datapt, dlen);
+ memmove((char *)datapt, dp, dlen);
datapt += dlen;
datalinelen += dlen;
}
@@ -900,7 +888,7 @@ ctl_putstr(tag, data, len)
*cp++ = '"';
if (len > (sizeof(buffer) - (cp - buffer) - 1))
len = sizeof(buffer) - (cp - buffer) - 1;
- bcopy(data, cp, len);
+ memmove(cp, data, len);
cp += len;
*cp++ = '"';
}
@@ -1221,7 +1209,6 @@ static void
ctl_putsys(varid)
int varid;
{
- extern char *Version;
l_fp tmp;
switch (varid) {
@@ -1280,12 +1267,12 @@ ctl_putsys(varid)
ctl_putuint(sys_var[CS_LEAPWARNING].text, (U_LONG)leap_warning);
break;
case CS_PROCESSOR:
- ctl_putstr(sys_var[CS_PROCESSOR].text, STR_PROCESSOR,
- sizeof(STR_PROCESSOR) - 1);
+ ctl_putstr(sys_var[CS_PROCESSOR].text, str_processor,
+ sizeof(str_processor) - 1);
break;
case CS_SYSTEM:
- ctl_putstr(sys_var[CS_SYSTEM].text, STR_SYSTEM,
- sizeof(STR_SYSTEM) - 1);
+ ctl_putstr(sys_var[CS_SYSTEM].text, str_system,
+ sizeof(str_system) - 1);
break;
case CS_KEYID:
ctl_putuint(sys_var[CS_KEYID].text, (U_LONG)0);
@@ -1293,9 +1280,66 @@ ctl_putsys(varid)
case CS_REFSKEW:
ctl_putlfp(sys_var[CS_REFSKEW].text, &sys_refskew);
break;
- case CS_VERSION:
- ctl_putstr(sys_var[CS_VERSION].text, Version,
- strlen(Version));
+ case CS_VARLIST:
+ {
+ char buf[CTL_MAX_DATA_LEN];
+ register char *s, *ss, *t, *be;
+ register int i;
+ register struct ctl_var *k;
+
+ s = buf;
+ be = buf + sizeof(buf) - strlen(sys_var[CS_VARLIST].text) - 4;
+ if (s > be)
+ break; /* really long var name 8-( - Killer */
+
+ strcpy(s, sys_var[CS_VARLIST].text);
+ strcat(s, "=\"");
+ s += strlen(s);
+ t = s;
+
+ for (k = sys_var; !(k->flags &EOV); k++)
+ {
+ if (k->flags & PADDING)
+ continue;
+
+ i = strlen(k->text);
+ if (s+i+1 >= be)
+ break;
+ if (s != t)
+ *s++ = ',';
+ strcpy(s, k->text);
+ s += i;
+ }
+
+ for (k = ext_sys_var; k && !(k->flags &EOV); k++)
+ {
+ if (k->flags & PADDING)
+ continue;
+
+ ss = k->text;
+ if (!ss)
+ continue;
+
+ while (*ss && *ss != '=')
+ ss++;
+
+ i = ss - k->text;
+ if (s+i+1 >= be)
+ break;
+ if (s != t)
+ *s++ = ',';
+ strncpy(s, k->text, i);
+ s += i;
+ }
+
+ if (s+2 >= be)
+ break;
+
+ *s++ = '"';
+ *s = '\0';
+
+ ctl_putdata(buf, s - buf, 0);
+ }
break;
}
}
@@ -1428,6 +1472,46 @@ ctl_putpeer(varid, peer)
case CP_SENT:
ctl_putuint(peer_var[CP_SENT].text, peer->sent);
break;
+ case CP_VARLIST:
+ {
+ char buf[CTL_MAX_DATA_LEN];
+ register char *s, *t, *be;
+ register int i;
+ register struct ctl_var *k;
+
+ s = buf;
+ be = buf + sizeof(buf) - strlen(peer_var[CP_VARLIST].text) - 4;
+ if (s > be)
+ break; /* really long var name 8-( - Killer */
+
+ strcpy(s, peer_var[CP_VARLIST].text);
+ strcat(s, "=\"");
+ s += strlen(s);
+ t = s;
+
+ for (k = peer_var; !(k->flags &EOV); k++)
+ {
+ if (k->flags & PADDING)
+ continue;
+
+ i = strlen(k->text);
+ if (s+i+1 >= be)
+ break;
+ if (s != t)
+ *s++ = ',';
+ strcpy(s, k->text);
+ s += i;
+ }
+
+ if (s+2 >= be)
+ break;
+
+ *s++ = '"';
+ *s = '\0';
+
+ ctl_putdata(buf, s - buf, 0);
+ }
+ break;
}
}
@@ -1501,6 +1585,68 @@ ctl_putclock(varid, clock, mustput)
strlen(clock->clockdesc));
}
break;
+ case CC_VARLIST:
+ {
+ char buf[CTL_MAX_DATA_LEN];
+ register char *s, *ss, *t, *be;
+ register int i;
+ register struct ctl_var *k;
+
+ s = buf;
+ be = buf + sizeof(buf) - strlen(clock_var[CC_VARLIST].text) - 4;
+ if (s > be)
+ break; /* really long var name 8-( - Killer */
+
+ strcpy(s, clock_var[CC_VARLIST].text);
+ strcat(s, "=\"");
+ s += strlen(s);
+ t = s;
+
+ for (k = clock_var; !(k->flags &EOV); k++)
+ {
+ if (k->flags & PADDING)
+ continue;
+
+ i = strlen(k->text);
+ if (s+i+1 >= be)
+ break;
+ if (s != t)
+ *s++ = ',';
+ strcpy(s, k->text);
+ s += i;
+ }
+
+ for (k = clock->kv_list; k && !(k->flags &EOV); k++)
+ {
+ if (k->flags & PADDING)
+ continue;
+
+ ss = k->text;
+ if (!ss)
+ continue;
+
+ while (*ss && *ss != '=')
+ ss++;
+
+ i = ss - k->text;
+ if (s+i+1 >= be)
+ break;
+ if (s != t)
+ *s++ = ',';
+ strncpy(s, k->text, i);
+ s += i;
+ *s = '\0';
+ }
+
+ if (s+2 >= be)
+ break;
+
+ *s++ = '"';
+ *s = '\0';
+
+ ctl_putdata(buf, s - buf, 0);
+ }
+ break;
}
}
#endif
@@ -1517,6 +1663,7 @@ ctl_getitem(var_list, data)
{
register struct ctl_var *v;
register char *cp, *tp;
+ static struct ctl_var eol = { 0, EOV, };
static char buf[128];
/*
@@ -1528,6 +1675,9 @@ ctl_getitem(var_list, data)
if (reqpt >= reqend)
return 0;
+
+ if (var_list == (struct ctl_var *)0)
+ return &eol;
/*
* Look for a first character match on the tag. If we find
@@ -1538,11 +1688,11 @@ ctl_getitem(var_list, data)
while (!(v->flags & EOV)) {
if (!(v->flags & PADDING) && *cp == *(v->text)) {
tp = v->text;
- while (*tp != '\0' && cp < reqend && *cp == *tp) {
+ while (*tp != '\0' && *tp != '=' && cp < reqend && *cp == *tp) {
cp++;
tp++;
}
- if (*tp == '\0') {
+ if ((*tp == '\0') || (*tp == '=')) {
while (cp < reqend && isspace(*cp))
cp++;
if (cp == reqend || *cp == ',') {
@@ -1685,8 +1835,8 @@ read_variables(rbufp, restrict)
register struct ctl_var *v;
register int i;
char *valuep;
- u_char wants[(CS_MAXCODE>CP_MAXCODE) ? (CS_MAXCODE+1) : (CP_MAXCODE+1)];
- int gotvar;
+ u_char *wants;
+ int gotvar = (CS_MAXCODE>CP_MAXCODE) ? (CS_MAXCODE+1) : (CP_MAXCODE+1);
if (res_associd == 0) {
/*
@@ -1696,12 +1846,24 @@ read_variables(rbufp, restrict)
rpkt.status = htons(ctlsysstatus());
if (res_authokay)
ctl_sys_num_events = 0;
- bzero((char *)wants, CS_MAXCODE+1);
+ gotvar += count_var(ext_sys_var);
+ wants = (u_char *)emalloc(gotvar);
+ memset((char *)wants, 0, gotvar);
gotvar = 0;
while ((v = ctl_getitem(sys_var, &valuep)) != 0) {
if (v->flags & EOV) {
- ctl_error(CERR_UNKNOWNVAR);
- return;
+ if ((v = ctl_getitem(ext_sys_var, &valuep)) != 0) {
+ if (v->flags & EOV) {
+ ctl_error(CERR_UNKNOWNVAR);
+ free((char *)wants);
+ return;
+ }
+ wants[CS_MAXCODE+1+v->code] = 1;
+ gotvar = 1;
+ continue;
+ } else {
+ break; /* shouldn't happen ! */
+ }
}
wants[v->code] = 1;
gotvar = 1;
@@ -1710,12 +1872,21 @@ read_variables(rbufp, restrict)
for (i = 1; i <= CS_MAXCODE; i++)
if (wants[i])
ctl_putsys(i);
+ for (i = 0; ext_sys_var && !(ext_sys_var[i].flags & EOV); i++)
+ if (wants[i+CS_MAXCODE+1])
+ ctl_putdata(ext_sys_var[i].text,
+ strlen(ext_sys_var[i].text), 0);
} else {
register u_char *cs;
+ register struct ctl_var *kv;
for (cs = def_sys_var; *cs != 0; cs++)
- ctl_putsys((int)*cs);
+ ctl_putsys((int)*cs);
+ for (kv = ext_sys_var; kv && !(kv->flags & EOV); kv++)
+ if (kv->flags & DEF)
+ ctl_putdata(kv->text, strlen(kv->text), 0);
}
+ free((char *)wants);
} else {
register struct peer *peer;
@@ -1732,11 +1903,13 @@ read_variables(rbufp, restrict)
rpkt.status = htons(ctlpeerstatus(peer));
if (res_authokay)
peer->num_events = 0;
- bzero((char*)wants, CP_MAXCODE+1);
+ wants = (u_char *)emalloc(gotvar);
+ memset((char*)wants, 0, gotvar);
gotvar = 0;
while ((v = ctl_getitem(peer_var, &valuep)) != 0) {
if (v->flags & EOV) {
ctl_error(CERR_UNKNOWNVAR);
+ free((char *)wants);
return;
}
wants[v->code] = 1;
@@ -1752,6 +1925,7 @@ read_variables(rbufp, restrict)
for (cp = def_peer_var; *cp != 0; cp++)
ctl_putpeer((int)*cp, peer);
}
+ free((char *)wants);
}
ctl_flushpkt(0);
}
@@ -1768,6 +1942,7 @@ write_variables(rbufp, restrict)
int restrict;
{
register struct ctl_var *v;
+ register int ext_var;
char *valuep;
LONG val;
u_char leapind, leapwarn;
@@ -1795,37 +1970,60 @@ write_variables(rbufp, restrict)
* Look through the variables. Dump out at the first sign of trouble.
*/
while ((v = ctl_getitem(sys_var, &valuep)) != 0) {
+ ext_var = 0;
if (v->flags & EOV) {
- ctl_error(CERR_UNKNOWNVAR);
- return;
+ if ((v = ctl_getitem(ext_sys_var, &valuep)) != 0) {
+ if (v->flags & EOV) {
+ ctl_error(CERR_UNKNOWNVAR);
+ return;
+ }
+ ext_var = 1;
+ } else {
+ break;
+ }
}
if (!(v->flags & CAN_WRITE)) {
ctl_error(CERR_PERMISSION);
return;
}
- if (*valuep == '\0' || !atoint(valuep, &val)) {
+ if (!ext_var && (*valuep == '\0' || !atoint(valuep, &val))) {
ctl_error(CERR_BADFMT);
return;
}
- if ((val & ~LEAP_NOTINSYNC) != 0) {
+ if (!ext_var && (val & ~LEAP_NOTINSYNC) != 0) {
ctl_error(CERR_BADVALUE);
return;
}
- /*
- * This one seems sane. Save it.
- */
- switch(v->code) {
- case CS_LEAP:
- case CS_LEAPIND:
- leapind = (u_char)val;
- break;
- case CS_LEAPWARNING:
- leapwarn = (u_char)val;
- break;
- default:
- ctl_error(CERR_UNSPEC); /* our fault, really */
- return;
+ if (ext_var) {
+ char *s = emalloc(strlen(v->text)+strlen(valuep)+2);
+ char *t, *tt = s;
+
+ t = v->text;
+ while (*t && *t != '=')
+ *tt++ = *t++;
+
+ *tt++ = '=';
+ strcat(tt, valuep);
+
+ set_sys_var(s, strlen(s)+1, v->flags);
+ free(s);
+ } else {
+ /*
+ * This one seems sane. Save it.
+ */
+ switch(v->code) {
+ case CS_LEAP:
+ case CS_LEAPIND:
+ leapind = (u_char)val;
+ break;
+ case CS_LEAPWARNING:
+ leapwarn = (u_char)val;
+ break;
+ default:
+ ctl_error(CERR_UNSPEC); /* our fault, really */
+ return;
+ }
}
}
@@ -1861,7 +2059,7 @@ read_clock_status(rbufp, restrict)
register int i;
register struct peer *peer;
char *valuep;
- u_char wants[CC_MAXCODE+1];
+ u_char *wants;
int gotvar;
struct refclockstat clock;
@@ -1898,18 +2096,33 @@ read_clock_status(rbufp, restrict)
/*
* If we got here we have a peer which is a clock. Get his status.
*/
+ clock.kv_list = (struct ctl_var *)0;
+
refclock_control(&peer->srcadr, (struct refclockstat *)0, &clock);
/*
* Look for variables in the packet.
*/
rpkt.status = htons(ctlclkstatus(&clock));
+ gotvar = CC_MAXCODE+1+count_var(clock.kv_list);
+ wants = (u_char *)emalloc(gotvar);
+ memset((char*)wants, 0, gotvar);
gotvar = 0;
- bzero((char*)wants, CC_MAXCODE+1);
- while ((v = ctl_getitem(sys_var, &valuep)) != 0) {
+ while ((v = ctl_getitem(clock_var, &valuep)) != 0) {
if (v->flags & EOV) {
- ctl_error(CERR_UNKNOWNVAR);
- return;
+ if ((v = ctl_getitem(clock.kv_list, &valuep)) != 0) {
+ if (v->flags & EOV) {
+ ctl_error(CERR_UNKNOWNVAR);
+ free((char*)wants);
+ free_varlist(clock.kv_list);
+ return;
+ }
+ wants[CC_MAXCODE+1+v->code] = 1;
+ gotvar = 1;
+ continue;
+ } else {
+ break; /* shouldn't happen ! */
+ }
}
wants[v->code] = 1;
gotvar = 1;
@@ -1919,12 +2132,24 @@ read_clock_status(rbufp, restrict)
for (i = 1; i <= CC_MAXCODE; i++)
if (wants[i])
ctl_putclock(i, &clock, 1);
+ for (i = 0; clock.kv_list && !(clock.kv_list[i].flags & EOV); i++)
+ if (wants[i+CC_MAXCODE+1])
+ ctl_putdata(clock.kv_list[i].text,
+ strlen(clock.kv_list[i].text), 0);
} else {
register u_char *cc;
+ register struct ctl_var *kv;
for (cc = def_clock_var; *cc != 0; cc++)
ctl_putclock((int)*cc, &clock, 0);
+ for (kv = clock.kv_list; kv && !(kv->flags & EOV); kv++)
+ if (kv->flags & DEF)
+ ctl_putdata(kv->text, strlen(kv->text), 0);
}
+
+ free((char*)wants);
+ free_varlist(clock.kv_list);
+
ctl_flushpkt(0);
#endif
}
@@ -2237,13 +2462,23 @@ report_event(err, peer)
*/
if (err == EVNT_CLOCKEXCPT) {
struct refclockstat clock;
- refclock_control(&peer->srcadr,
+ struct ctl_var *kv;
+
+ clock.kv_list = (struct ctl_var *)0;
+
+ refclock_control(&peer->srcadr,
(struct refclockstat *)0,
&clock);
ctl_puthex("refclockstatus",
(U_LONG)ctlclkstatus(&clock));
+
for (i = 1; i <= CC_MAXCODE; i++)
ctl_putclock(i, &clock, 0);
+ for (kv = clock.kv_list; kv && !(kv->flags & EOV); kv++)
+ if (kv->flags & DEF)
+ ctl_putdata(kv->text, strlen(kv->text), 0);
+
+ free_varlist(clock.kv_list);
}
#endif /*REFCLOCK*/
} else {
@@ -2262,13 +2497,24 @@ report_event(err, peer)
*/
if (err == EVNT_PEERCLOCK) {
struct refclockstat clock;
+ struct ctl_var *kv;
+
+ clock.kv_list = (struct ctl_var *)0;
+
refclock_control(&peer->srcadr,
(struct refclockstat *)0,
&clock);
+
ctl_puthex("refclockstatus",
(U_LONG)ctlclkstatus(&clock));
+
for (i = 1; i <= CC_MAXCODE; i++)
ctl_putclock(i, &clock, 0);
+ for (kv = clock.kv_list; kv && !(kv->flags & EOV); kv++)
+ if (kv->flags & DEF)
+ ctl_putdata(kv->text, strlen(kv->text), 0);
+
+ free_varlist(clock.kv_list);
}
#endif /*REFCLOCK*/
}
@@ -2303,3 +2549,115 @@ ctl_clr_stats()
numctlbadop = 0;
numasyncmsgs = 0;
}
+
+static unsigned long
+count_var(k)
+ struct ctl_var *k;
+{
+ register unsigned long c;
+
+ c = 0;
+ while (k && !(k++->flags & EOV))
+ c++;
+
+ return c;
+}
+
+char *
+add_var(kv, size, def)
+ struct ctl_var **kv;
+ unsigned long size;
+ int def;
+{
+ register unsigned long c;
+ register struct ctl_var *k;
+
+ c = count_var(*kv);
+
+ k = *kv;
+ *kv = (struct ctl_var *)emalloc((c+2)*sizeof(struct ctl_var));
+ if (k)
+ {
+ memmove((char *)*kv, (char *)k, sizeof(struct ctl_var)*c);
+ free((char *)k);
+ }
+
+ (*kv)[c].code = c;
+ (*kv)[c].text = (char *)emalloc(size);
+ (*kv)[c].flags = def;
+ (*kv)[c+1].code = 0;
+ (*kv)[c+1].text = (char *)0;
+ (*kv)[c+1].flags = EOV;
+ return (*kv)[c].text;
+}
+
+void
+set_var(kv, data, size, def)
+ struct ctl_var **kv;
+ char *data;
+ unsigned long size;
+ int def;
+{
+ register struct ctl_var *k;
+ register char *s, *t;
+
+ if (!data || !size)
+ return;
+
+ if ((k = *kv))
+ {
+ while (!(k->flags & EOV))
+ {
+ s = data;
+ t = k->text;
+ if (t)
+ {
+ while (*t != '=' && *s - *t == 0)
+ {
+ s++;
+ t++;
+ }
+ if (*s == *t && ((*t == '=') || !*t))
+ {
+ free(k->text);
+ k->text = (char *)emalloc(size);
+ memmove(k->text, data, size);
+ k->flags = def;
+ return;
+ }
+ }
+ else
+ {
+ k->text = (char *)emalloc(size);
+ memmove(k->text, data, size);
+ k->flags = def;
+ return;
+ }
+ k++;
+ }
+ }
+ t = add_var(kv, size, def);
+ memmove(t, data, size);
+}
+
+void
+set_sys_var(data, size, def)
+ char *data;
+ unsigned long size;
+ int def;
+{
+ set_var(&ext_sys_var, data, size, def);
+}
+
+void
+free_varlist(kv)
+ struct ctl_var *kv;
+{
+ struct ctl_var *k;
+ if (kv)
+ {
+ for (k = kv; !(k->flags & EOV); k++)
+ free(k->text);
+ free((char *)kv);
+ }
+}
diff --git a/usr.sbin/xntpd/xntpd/ntp_filegen.c b/usr.sbin/xntpd/xntpd/ntp_filegen.c
index bbbd24270d7d..55cf1aebab13 100644
--- a/usr.sbin/xntpd/xntpd/ntp_filegen.c
+++ b/usr.sbin/xntpd/xntpd/ntp_filegen.c
@@ -1,5 +1,5 @@
/*
- * ntp_filegen.c,v 3.10 1993/12/03 03:55:35 pruy Exp
+ * ntp_filegen.c,v 3.12 1994/01/25 19:06:11 kardel Exp
*
* implements file generations support for NTP
* logfiles and statistic files
diff --git a/usr.sbin/xntpd/xntpd/ntp_intres.c b/usr.sbin/xntpd/xntpd/ntp_intres.c
index ebd3d52d0511..20561e91b82d 100644
--- a/usr.sbin/xntpd/xntpd/ntp_intres.c
+++ b/usr.sbin/xntpd/xntpd/ntp_intres.c
@@ -294,7 +294,7 @@ addentry(name, mode, version, minpoll, maxpoll, flags, keyid)
len = strlen(name) + 1;
cp = emalloc((unsigned)len);
- bcopy(name, cp, len);
+ memmove(cp, name, len);
ce = (struct conf_entry *)emalloc(sizeof(struct conf_entry));
ce->ce_name = cp;
@@ -347,9 +347,9 @@ findhostaddr(entry)
extern int h_errno;
if (h_errno == TRY_AGAIN)
- return 1;
+ return (1);
#endif
- return 0;
+ return (0);
}
/*
@@ -357,9 +357,10 @@ findhostaddr(entry)
* tell preferences and older gethostbyname() implementations
* only return one.
*/
- (void) bcopy(hp->h_addr, (char *)&(entry->ce_peeraddr),
- sizeof(struct in_addr));
- return 1;
+ memmove((char *)&(entry->ce_peeraddr),
+ (char *)hp->h_addr,
+ sizeof(struct in_addr));
+ return (1);
}
@@ -380,7 +381,7 @@ openntp()
exit(1);
}
- bzero((char *)&saddr, sizeof(saddr));
+ memset((char *)&saddr, 0, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_port = htons(NTP_PORT); /* trash */
saddr.sin_addr.s_addr = htonl(LOCALHOST); /* garbage */
@@ -448,7 +449,7 @@ request(conf)
/*
* Make up a request packet with the configuration info
*/
- bzero((char *)&reqpkt, sizeof(reqpkt));
+ memset((char *)&reqpkt, 0, sizeof(reqpkt));
reqpkt.rm_vn_mode = RM_VN_MODE(0, 0);
reqpkt.auth_seq = AUTH_SEQ(1, 0); /* authenticated, no seq */
@@ -456,7 +457,7 @@ request(conf)
reqpkt.request = REQ_CONFIG; /* configure a new peer */
reqpkt.err_nitems = ERR_NITEMS(0, 1); /* one item */
reqpkt.mbz_itemsize = MBZ_ITEMSIZE(sizeof(struct conf_peer));
- bcopy((char *)conf, reqpkt.data, sizeof(struct conf_peer));
+ memmove(reqpkt.data, (char *)conf, sizeof(struct conf_peer));
reqpkt.keyid = htonl(req_keyid);
auth1crypt(req_keyid, (U_LONG *)&reqpkt, REQ_LEN_NOMAC);
diff --git a/usr.sbin/xntpd/xntpd/ntp_io.c b/usr.sbin/xntpd/xntpd/ntp_io.c
index e765b03f31a2..614d5c52bde9 100644
--- a/usr.sbin/xntpd/xntpd/ntp_io.c
+++ b/usr.sbin/xntpd/xntpd/ntp_io.c
@@ -51,13 +51,6 @@
*/
/*
- * select network interfacing
- */
-#if defined(SYS_SVR4) || defined(SYS_PTX) || defined(SYS_SINIXM)
-#define STREAMS_TLI
-#endif
-
-/*
* Block the interrupt, for critical sections.
*/
@@ -457,8 +450,10 @@ io_setbclient()
#ifdef SOLARIS
inter_list[i].bcast.sin_addr.s_addr = INADDR_ANY;
#endif
+#ifndef SYS_DOMAINOS
inter_list[i].bfd = open_socket(&inter_list[i].bcast, 0);
inter_list[i].flags |= INT_BCASTOPEN;
+#endif
}
}
diff --git a/usr.sbin/xntpd/xntpd/ntp_loopfilter.c b/usr.sbin/xntpd/xntpd/ntp_loopfilter.c
index d74da9956e16..6d79c5d52ff4 100644
--- a/usr.sbin/xntpd/xntpd/ntp_loopfilter.c
+++ b/usr.sbin/xntpd/xntpd/ntp_loopfilter.c
@@ -28,8 +28,10 @@
#include <termio.h>
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#ifdef HAVE_TERMIOS
#include <termios.h>
+#endif
+#if defined(STREAM)
#include <stropts.h>
#if defined(PPSCLK)
#include <sys/clkdefs.h>
@@ -270,9 +272,9 @@ init_loopfilter()
*/
PPSCLK SUPPORT NOT AVAILABLE IN TERMIO INTERFACE
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
/*
- * POSIX/STREAMS serial line parameters (termios interface)
+ * POSIX serial line parameters (termios interface)
*
* The PPSCLK option provides timestamping at the driver level.
* It uses a 1-pps signal and level converter (gadget box) and
@@ -302,17 +304,19 @@ init_loopfilter()
"loopfilter: tcflush(%s): %m", PPS_DEV);
goto screwed;
}
- while (ioctl(fd232, I_POP, 0 ) >= 0) ;
- if (ioctl(fd232, I_PUSH, "clk") < 0) {
- syslog(LOG_ERR,
- "loopfilter: ioctl(%s, I_PUSH, clk): %m", PPS_DEV);
- goto screwed;
- }
- if (ioctl(fd232, CLK_SETSTR, PPS_XCPT) < 0) {
- syslog(LOG_ERR,
- "loopfilter: ioctl(%s, CLK_SETSTR, PPS_XCPT): %m", PPS_DEV);
- goto screwed;
- }
+ }
+#endif /* HAVE_TERMIOS */
+#if defined(STREAM)
+ while (ioctl(fd232, I_POP, 0 ) >= 0) ;
+ if (ioctl(fd232, I_PUSH, "clk") < 0) {
+ syslog(LOG_ERR,
+ "loopfilter: ioctl(%s, I_PUSH, clk): %m", PPS_DEV);
+ goto screwed;
+ }
+ if (ioctl(fd232, CLK_SETSTR, PPS_XCPT) < 0) {
+ syslog(LOG_ERR,
+ "loopfilter: ioctl(%s, CLK_SETSTR, PPS_XCPT): %m", PPS_DEV);
+ goto screwed;
}
#endif /* STREAM */
#if defined(HAVE_BSD_TTYS)
@@ -762,9 +766,9 @@ loop_config(item, lfp_value, int_value)
#if defined(PPSCLK)
case LOOP_PPSBAUD:
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
/*
- * System V STREAM serial line parameters
+ * System V TERMIOS serial line parameters
* (termios interface)
*/
{ struct termios ttyb, *ttyp;
@@ -778,7 +782,7 @@ loop_config(item, lfp_value, int_value)
if (tcsetattr(fdpps, TCSANOW, ttyp) < 0)
return;
}
-#endif /* STREAM */
+#endif /* HAVE_TERMIOS */
#if defined(HAVE_BSD_TTYS)
/*
diff --git a/usr.sbin/xntpd/xntpd/ntp_monitor.c b/usr.sbin/xntpd/xntpd/ntp_monitor.c
index 5d589e87454c..63af8d4d4d97 100644
--- a/usr.sbin/xntpd/xntpd/ntp_monitor.c
+++ b/usr.sbin/xntpd/xntpd/ntp_monitor.c
@@ -102,7 +102,7 @@ init_mon()
mon_free = 0;
mon_hash = 0;
mon_hash_count = 0;
- bzero((char *)&mon_mru_list, sizeof mon_mru_list);
+ memset((char *)&mon_mru_list, 0, sizeof mon_mru_list);
}
@@ -121,7 +121,8 @@ mon_start()
if (!mon_have_memory) {
mon_hash = (struct mon_data *)
emalloc(MON_HASH_SIZE * sizeof(struct mon_data));
- bzero((char *)mon_hash, MON_HASH_SIZE*sizeof(struct mon_data));
+ memset((char *)mon_hash, 0,
+ MON_HASH_SIZE*sizeof(struct mon_data));
mon_hash_count = (int *)emalloc(MON_HASH_SIZE * sizeof(int));
mon_free_mem = 0;
mon_total_mem = 0;
diff --git a/usr.sbin/xntpd/xntpd/ntp_peer.c b/usr.sbin/xntpd/xntpd/ntp_peer.c
index 5e3b13455e42..cadd415346a9 100644
--- a/usr.sbin/xntpd/xntpd/ntp_peer.c
+++ b/usr.sbin/xntpd/xntpd/ntp_peer.c
@@ -439,7 +439,7 @@ newpeer(srcadr, dstadr, hmode, version, minpoll, maxpoll, key)
*
* Zero the whole thing for now. We might be pickier later.
*/
- bzero((char *)peer, sizeof(struct peer));
+ memset((char *)peer, 0, sizeof(struct peer));
peer->srcadr = *srcadr;
if (dstadr != 0)
diff --git a/usr.sbin/xntpd/xntpd/ntp_proto.c b/usr.sbin/xntpd/xntpd/ntp_proto.c
index a13262440653..88e95bbf8d13 100644
--- a/usr.sbin/xntpd/xntpd/ntp_proto.c
+++ b/usr.sbin/xntpd/xntpd/ntp_proto.c
@@ -1078,7 +1078,7 @@ clock_update(peer)
sys_refid = peer->refid;
else {
if (pps_control)
- bcopy(PPSREFID, (char *)&sys_refid, 4);
+ memmove((char *)&sys_refid, PPSREFID, 4);
else
sys_refid = peer->srcadr.sin_addr.s_addr;
}
@@ -1127,7 +1127,7 @@ clock_update(peer)
if (peer->flags & FLAG_REFCLOCK)
sys_refid = peer->refid;
else
- bcopy(PPSREFID, (char *)&sys_refid, 4);
+ memmove((char *)&sys_refid, PPSREFID, 4);
}
}
@@ -1250,7 +1250,7 @@ peer_clear(peer)
if (debug)
printf("clear(%s)\n", ntoa(&peer->srcadr));
#endif
- bzero(CLEAR_TO_ZERO(peer), LEN_CLEAR_TO_ZERO);
+ memset(CLEAR_TO_ZERO(peer), 0, LEN_CLEAR_TO_ZERO);
peer->hpoll = peer->minpoll;
peer->dispersion = NTP_MAXDISPERSE;
for (i = 0; i < NTP_SHIFT; i++)
diff --git a/usr.sbin/xntpd/xntpd/ntp_request.c b/usr.sbin/xntpd/xntpd/ntp_request.c
index 96def3fa13cf..c19d1925a818 100644
--- a/usr.sbin/xntpd/xntpd/ntp_request.c
+++ b/usr.sbin/xntpd/xntpd/ntp_request.c
@@ -312,7 +312,7 @@ more_pkt()
/*
* Copy data out of exbuf into the packet.
*/
- bcopy(exbuf, &rpkt.data[0], itemsize);
+ memmove(&rpkt.data[0], exbuf, itemsize);
seqno++;
databytes = 0;
nitems = 0;
@@ -682,7 +682,7 @@ peer_info (srcadr, inter, inpkt)
struct sockaddr_in addr;
extern struct peer *sys_peer;
- bzero((char *)&addr, sizeof addr);
+ memset((char *)&addr, 0, sizeof addr);
addr.sin_family = AF_INET;
items = INFO_NITEMS(inpkt->err_nitems);
ipl = (struct info_peer_list *) inpkt->data;
@@ -773,7 +773,7 @@ peer_stats (srcadr, inter, inpkt)
struct sockaddr_in addr;
extern struct peer *sys_peer;
- bzero((char *)&addr, sizeof addr);
+ memset((char *)&addr, 0, sizeof addr);
addr.sin_family = AF_INET;
items = INFO_NITEMS(inpkt->err_nitems);
ipl = (struct info_peer_list *) inpkt->data;
@@ -1141,7 +1141,7 @@ do_conf(srcadr, inter, inpkt)
*/
items = INFO_NITEMS(inpkt->err_nitems);
cp = (struct conf_peer *)inpkt->data;
- bzero((char *)&peeraddr, sizeof(struct sockaddr_in));
+ memset((char *)&peeraddr, 0, sizeof(struct sockaddr_in));
peeraddr.sin_family = AF_INET;
peeraddr.sin_port = htons(NTP_PORT);
@@ -1451,8 +1451,8 @@ do_restrict(srcadr, inter, inpkt, op)
*/
items = INFO_NITEMS(inpkt->err_nitems);
cr = (struct conf_restrict *)inpkt->data;
- bzero((char *)&matchaddr, sizeof(struct sockaddr_in));
- bzero((char *)&matchmask, sizeof(struct sockaddr_in));
+ memset((char *)&matchaddr, 0, sizeof(struct sockaddr_in));
+ memset((char *)&matchmask, 0, sizeof(struct sockaddr_in));
matchaddr.sin_family = AF_INET;
matchmask.sin_family = AF_INET;
@@ -1869,7 +1869,7 @@ do_setclr_trap(srcadr, inter, inpkt, set)
/*
* Prepare sockaddr_in structure
*/
- bzero((char *)&laddr, sizeof laddr);
+ memset((char *)&laddr, 0, sizeof laddr);
laddr.sin_family = AF_INET;
laddr.sin_port = ntohs(NTP_PORT);
@@ -2095,7 +2095,7 @@ get_clock_info(srcadr, inter, inpkt)
struct refclockstat clock;
struct sockaddr_in addr;
- bzero((char *)&addr, sizeof addr);
+ memset((char *)&addr, 0, sizeof addr);
addr.sin_family = AF_INET;
addr.sin_port = htons(NTP_PORT);
items = INFO_NITEMS(inpkt->err_nitems);
@@ -2111,6 +2111,9 @@ get_clock_info(srcadr, inter, inpkt)
req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
return;
}
+
+ clock.kv_list = (struct ctl_var *)0;
+
refclock_control(&addr, (struct refclockstat *)0, &clock);
ic->clockadr = addr.sin_addr.s_addr;
@@ -2128,6 +2131,8 @@ get_clock_info(srcadr, inter, inpkt)
ic->fudgeval1 = htonl(clock.fudgeval1);
ic->fudgeval2 = htonl(clock.fudgeval2);
+ free_varlist(clock.kv_list);
+
ic = (struct info_clock *)more_pkt();
}
flush_pkt();
@@ -2149,8 +2154,8 @@ set_clock_fudge(srcadr, inter, inpkt)
struct refclockstat clock;
struct sockaddr_in addr;
- bzero((char *)&addr, sizeof addr);
- bzero((char *)&clock, sizeof clock);
+ memset((char *)&addr, 0, sizeof addr);
+ memset((char *)&clock, 0, sizeof clock);
addr.sin_family = AF_INET;
addr.sin_port = htons(NTP_PORT);
items = INFO_NITEMS(inpkt->err_nitems);
@@ -2286,7 +2291,7 @@ get_clkbug_info(srcadr, inter, inpkt)
struct refclockbug bug;
struct sockaddr_in addr;
- bzero((char *)&addr, sizeof addr);
+ memset((char *)&addr, 0, sizeof addr);
addr.sin_family = AF_INET;
addr.sin_port = htons(NTP_PORT);
items = INFO_NITEMS(inpkt->err_nitems);
@@ -2303,7 +2308,7 @@ get_clkbug_info(srcadr, inter, inpkt)
return;
}
- bzero((char *)&bug, sizeof bug);
+ memset((char *)&bug, 0, sizeof bug);
refclock_buginfo(&addr, &bug);
if (bug.nvalues == 0 && bug.ntimes == 0) {
req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
diff --git a/usr.sbin/xntpd/xntpd/ntp_restrict.c b/usr.sbin/xntpd/xntpd/ntp_restrict.c
index 9bd977958967..51d896806207 100644
--- a/usr.sbin/xntpd/xntpd/ntp_restrict.c
+++ b/usr.sbin/xntpd/xntpd/ntp_restrict.c
@@ -81,7 +81,7 @@ init_restrict()
* Zero the list and put all but one on the free list
*/
resfree = 0;
- bzero((char *)resinit, sizeof resinit);
+ memset((char *)resinit, 0, sizeof resinit);
for (i = 1; i < INITRESLIST; i++) {
resinit[i].next = resfree;
@@ -234,7 +234,7 @@ restrict(op, resaddr, resmask, mflags, flags)
if (numresfree == 0) {
rl = (struct restrictlist *) emalloc(
INCRESLIST*sizeof(struct restrictlist));
- bzero((char *)rl,
+ memset((char *)rl, 0,
INCRESLIST*sizeof(struct restrictlist));
for (i = 0; i < INCRESLIST; i++) {
@@ -280,7 +280,7 @@ restrict(op, resaddr, resmask, mflags, flags)
&& !(rl->mflags & RESM_INTERFACE)) {
rlprev->next = rl->next;
restrictcount--;
- bzero((char *)rl, sizeof(struct restrictlist));
+ memset((char *)rl, 0, sizeof(struct restrictlist));
rl->next = resfree;
resfree = rl;
diff --git a/usr.sbin/xntpd/xntpd/ntp_unixclock.c b/usr.sbin/xntpd/xntpd/ntp_unixclock.c
index 4ac7cd223afd..6b661835dbb7 100644
--- a/usr.sbin/xntpd/xntpd/ntp_unixclock.c
+++ b/usr.sbin/xntpd/xntpd/ntp_unixclock.c
@@ -9,7 +9,7 @@
#include <sys/stat.h>
#include <sys/time.h>
-#if defined(SYS_HPUX) || defined(sgi) || defined(__bsdi__)
+#if defined(SYS_HPUX) || defined(sgi) || defined(SYS_BSDI)
#include <sys/param.h>
#include <utmp.h>
#endif
@@ -20,9 +20,9 @@
#include "ntp_stdlib.h"
#if defined(HAVE_LIBKVM)
-#ifdef __bsdi__
+#ifdef SYS_BSDI
#include <sys/proc.h>
-#endif /* __bsdi__ */
+#endif /* SYS_BSDI */
#include <kvm.h>
#include <limits.h>
@@ -440,8 +440,12 @@ clock_parms(tickadj, tick)
{
#ifdef RS6000
*tickadj = 1000;
-#else
+#else /*RS6000*/
+#if SYS_DOMAINOS
+ *tickadj = 668;
+#else /*SYS_DOMAINOS*/
*tickadj = 500 / HZ;
+#endif /*SYS_DOMAINOS*/
#endif /*RS6000*/
*tick = 1000000L / HZ;
diff --git a/usr.sbin/xntpd/xntpd/ntp_util.c b/usr.sbin/xntpd/xntpd/ntp_util.c
index 394d6dfd2938..4cbb7ac27f53 100644
--- a/usr.sbin/xntpd/xntpd/ntp_util.c
+++ b/usr.sbin/xntpd/xntpd/ntp_util.c
@@ -165,7 +165,7 @@ hourly_stats()
skip:
#endif
- syslog(LOG_NOTICE, "offset %s freq %s comp %d",
+ syslog(LOG_INFO, "offset %s freq %s comp %d",
lfptoa(&last_offset, 6), fptoa(drift_comp, 5), time_constant);
if (stats_drift_file != 0) {
@@ -223,9 +223,9 @@ stats_config(item, value)
stats_drift_file = emalloc((u_int)(len + 1));
stats_temp_file = emalloc((u_int)(len + sizeof(".TEMP")));
- bcopy(value, stats_drift_file, len+1);
- bcopy(value, stats_temp_file, len);
- bcopy(".TEMP", stats_temp_file + len, sizeof(".TEMP"));
+ memmove(stats_drift_file, value, len+1);
+ memmove(stats_temp_file, value, len);
+ memmove(stats_temp_file + len, ".TEMP", sizeof(".TEMP"));
L_CLR(&old_drift);
#ifdef DEBUG
@@ -449,7 +449,7 @@ getauthkeys(keyfile)
if (key_file_name == 0)
key_file_name = emalloc((u_int)(len + 1));
- bcopy(keyfile, key_file_name, len+1);
+ memmove(key_file_name, keyfile, len+1);
authreadkeys(key_file_name);
}
diff --git a/usr.sbin/xntpd/xntpd/ntpd.c b/usr.sbin/xntpd/xntpd/ntpd.c
index f29f741c9d21..abe86d945151 100644
--- a/usr.sbin/xntpd/xntpd/ntpd.c
+++ b/usr.sbin/xntpd/xntpd/ntpd.c
@@ -15,11 +15,11 @@
#endif
#if defined(SYS_SVR4)
-#include <sys/termios.h>
+#include <termios.h>
#endif
#if (defined(SYS_SOLARIS)&&!defined(bsd)) || defined(__svr4__)
-#include <sys/termios.h>
+#include <termios.h>
#endif
#include "ntpd.h"
@@ -139,7 +139,7 @@ main(argc, argv)
(void) dup2(0, 1);
(void) dup2(0, 2);
#ifdef NTP_POSIX_SOURCE
-#if defined(SOLARIS) || defined(SYS_PTX)
+#if defined(SOLARIS) || defined(SYS_PTX) || defined(SYS_AUX3) || defined(SYS_AIX)
(void) setsid();
#else
(void) setpgid(0, 0);
@@ -154,12 +154,12 @@ main(argc, argv)
if (fork())
exit(0);
#else /* SYS_HPUX */
-#if defined(apollo)
+#ifdef SYS_DOMAINOS
/*
* This breaks... the program fails to listen to any packets coming
* in on the UDP socket. So how do you break terminal affiliation?
*/
-#else /* apollo */
+#else /* SYS_DOMAINOS */
{
int fid;
@@ -169,8 +169,9 @@ main(argc, argv)
(char *) 0);
(void) close(fid);
}
+ (void) setpgrp(0, getpid());
}
-#endif /* apollo */
+#endif /* SYS_DOMAINOS */
#endif /* SYS_HPUX */
#endif /* NTP_POSIX_SOURCE */
}
diff --git a/usr.sbin/xntpd/xntpd/refclock_as2201.c b/usr.sbin/xntpd/xntpd/refclock_as2201.c
index f04d6d0659ca..97b5837c2f3b 100644
--- a/usr.sbin/xntpd/xntpd/refclock_as2201.c
+++ b/usr.sbin/xntpd/xntpd/refclock_as2201.c
@@ -20,8 +20,10 @@
#include <termio.h>
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
#include <termios.h>
+#endif
+#if defined(STREAM)
#include <stropts.h>
#if defined(AS2201CLK)
#include <sys/clkdefs.h>
@@ -248,8 +250,8 @@ as2201_init()
/*
* Just zero the data arrays
*/
- bzero((char *)gpsunits, sizeof gpsunits);
- bzero((char *)unitinuse, sizeof unitinuse);
+ memset((char *)gpsunits, 0, sizeof gpsunits);
+ memset((char *)unitinuse, 0, sizeof unitinuse);
/*
* Initialize fudge factors to default.
@@ -324,9 +326,9 @@ as2201_start(unit, peer)
}
}
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
/*
- * POSIX/STREAMS serial line parameters (termios interface)
+ * POSIX serial line parameters (termios interface)
*
* The AS2201CLK option provides timestamping at the driver level.
* It requires the tty_clk streams module.
@@ -359,22 +361,24 @@ as2201_start(unit, peer)
"as2201_start: tcflush(%s): %m", as2201dev);
goto screwed;
}
+ }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
#if defined(AS2201CLK)
- if (ioctl(fd232, I_PUSH, "clk") < 0)
- syslog(LOG_ERR,
- "as2201_start: ioctl(%s, I_PUSH, clk): %m", as2201dev);
- if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
- syslog(LOG_ERR,
- "as2201_start: ioctl(%s, CLK_SETSTR): %m", as2201dev);
+ if (ioctl(fd232, I_PUSH, "clk") < 0)
+ syslog(LOG_ERR,
+ "as2201_start: ioctl(%s, I_PUSH, clk): %m", as2201dev);
+ if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
+ syslog(LOG_ERR,
+ "as2201_start: ioctl(%s, CLK_SETSTR): %m", as2201dev);
#endif /* AS2201CLK */
#if defined(AS2201PPS)
- if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
- syslog(LOG_ERR,
- "as2201_start: ioctl(%s, I_PUSH, ppsclock): %m", as2201dev);
- else
- fdpps = fd232;
+ if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
+ syslog(LOG_ERR,
+ "as2201_start: ioctl(%s, I_PUSH, ppsclock): %m", as2201dev);
+ else
+ fdpps = fd232;
#endif /* AS2201PPS */
- }
#endif /* STREAM */
#if defined(HAVE_BSD_TTYS)
/*
@@ -437,7 +441,7 @@ as2201_start(unit, peer)
emalloc(sizeof(struct gpsunit));
}
}
- bzero((char *)gps, sizeof(struct gpsunit));
+ memset((char *)gps, 0, sizeof(struct gpsunit));
gpsunits[unit] = gps;
/*
@@ -475,7 +479,7 @@ as2201_start(unit, peer)
peer->rootdispersion = 0;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(GPSREFID, (char *)&peer->refid, 4);
+ memmove((char *)&peer->refid, GPSREFID, 4);
else
peer->refid = htonl(GPSHSREFID);
unitinuse[unit] = 1;
@@ -903,8 +907,8 @@ as2201_control(unit, in, out)
peer = gps->peer;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(GPSREFID, (char *)&peer->refid,
- 4);
+ memmove((char *)&peer->refid,
+ GPSREFID, 4);
else
peer->refid = htonl(GPSHSREFID);
}
diff --git a/usr.sbin/xntpd/xntpd/refclock_chu.c b/usr.sbin/xntpd/xntpd/refclock_chu.c
index 05379b6331f2..1c7c3bfa61c1 100644
--- a/usr.sbin/xntpd/xntpd/refclock_chu.c
+++ b/usr.sbin/xntpd/xntpd/refclock_chu.c
@@ -20,8 +20,10 @@
#include <termio.h>
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
#include <termios.h>
+#endif
+#if defined(STREAM)
#include <stropts.h>
#endif /* STREAM */
@@ -291,8 +293,8 @@ chu_init()
/*
* Just zero the data arrays
*/
- bzero((char *)chuunits, sizeof chuunits);
- bzero((char *)unitinuse, sizeof unitinuse);
+ memset((char *)chuunits, 0, sizeof chuunits);
+ memset((char *)unitinuse, 0, sizeof unitinuse);
/*
* Initialize fudge factors to default.
@@ -352,9 +354,9 @@ chu_start(unit, peer)
*/
CHU SUPPORT NOT AVAILABLE IN TERMIO INTERFACE
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
/*
- * POSIX/STREAMS serial line parameters (termios interface)
+ * POSIX serial line parameters (termios interface)
*
* The CHUCLK support uses a 300-baud modem and level converter
* (gadget box). It requires the chu_clk streams module and
@@ -390,20 +392,22 @@ chu_start(unit, peer)
"chu_start: tcflush(%s): %m", chudev);
goto screwed;
}
- while (ioctl(fd232, I_POP, 0 ) >= 0) ;
- if (ioctl(fd232, I_PUSH, "chu" ) < 0) {
- syslog(LOG_ERR,
- "chu_start: ioctl(%s, I_PUSH, chu): %m", chudev);
- goto screwed;
- }
+ }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
+ while (ioctl(fd232, I_POP, 0 ) >= 0) ;
+ if (ioctl(fd232, I_PUSH, "chu" ) < 0) {
+ syslog(LOG_ERR,
+ "chu_start: ioctl(%s, I_PUSH, chu): %m", chudev);
+ goto screwed;
+ }
#if defined(CHUPPS)
- if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
- syslog(LOG_ERR,
- "chu_start: ioctl(%s, I_PUSH, ppsclock): %m", chudev);
- else
- fdpps = fd232;
+ if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
+ syslog(LOG_ERR,
+ "chu_start: ioctl(%s, I_PUSH, ppsclock): %m", chudev);
+ else
+ fdpps = fd232;
#endif /* CHUPPS */
- }
#endif /* STREAM */
#if defined(HAVE_BSD_TTYS)
/*
@@ -457,7 +461,7 @@ chu_start(unit, peer)
chu = (struct chuunit *)emalloc(sizeof(struct chuunit));
}
}
- bzero((char *)chu, sizeof(struct chuunit));
+ memset((char *)chu, 0, sizeof(struct chuunit));
chuunits[unit] = chu;
/*
@@ -494,11 +498,11 @@ chu_start(unit, peer)
peer->rootdispersion = 0;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(CHUREFID, (char *)&peer->refid, 4);
+ memmove((char *)&peer->refid, CHUREFID, 4);
else
peer->refid = htonl(CHUHSREFID);
unitinuse[unit] = 1;
- return 1;
+ return (1);
/*
* Something broke; abandon ship.
@@ -1086,7 +1090,8 @@ chu_control(unit, in, out)
peer = chuunits[unit]->peer;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(CHUREFID, (char *)&peer->refid,4);
+ memmove((char *)&peer->refid,
+ CHUREFID, 4);
else
peer->refid = htonl(CHUHSREFID);
}
diff --git a/usr.sbin/xntpd/xntpd/refclock_conf.c b/usr.sbin/xntpd/xntpd/refclock_conf.c
index efe096647bd8..430c4a60f3fa 100644
--- a/usr.sbin/xntpd/xntpd/refclock_conf.c
+++ b/usr.sbin/xntpd/xntpd/refclock_conf.c
@@ -92,6 +92,12 @@ extern struct refclock refclock_msfees;
#define refclock_msfees refclock_none
#endif
+#if defined(GPSTM) || defined(GPSTMCLK) || defined(GPSTMPPS)
+extern struct refclock refclock_gpstm;
+#else
+#define refclock_gpstm refclock_none
+#endif
+
/*
* Order is clock_start(), clock_shutdown(), clock_poll(),
* clock_control(), clock_init(), clock_buginfo, clock_flags;
@@ -114,6 +120,7 @@ struct refclock *refclock_conf[] = {
&refclock_tpro, /* 12 REFCLK_IRIG_TPRO */
&refclock_leitch, /* 13 REFCLK_ATOM_LEITCH */
&refclock_msfees, /* 14 REFCLK_MSF_EES */
+ &refclock_gpstm, /* 15 REFCLK_GPSTM_TRUETIME */
};
u_char num_refclock_conf = sizeof(refclock_conf)/sizeof(struct refclock *);
diff --git a/usr.sbin/xntpd/xntpd/refclock_goes.c b/usr.sbin/xntpd/xntpd/refclock_goes.c
index 60b19f69aecf..0b53326dc5d2 100644
--- a/usr.sbin/xntpd/xntpd/refclock_goes.c
+++ b/usr.sbin/xntpd/xntpd/refclock_goes.c
@@ -22,8 +22,10 @@
#include <termio.h>
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
#include <termios.h>
+#endif
+#if defined(STREAM)
#include <stropts.h>
#if defined(GOESCLK)
#include <clkdefs.h>
@@ -51,7 +53,7 @@
* space less than 1 millisecond
* C - Carriage return
* L - Line feed
- * The cariage return start bit begins on 0 seconds and extends to 1 bit time.
+ * The carriage return start bit begins on 0 seconds and extends to 1 bit time.
*
* Unless you live on 125 degrees west longitude, you can't set your clock
* propagation delay settings correctly and still use automatic mode.
@@ -208,8 +210,8 @@ goes_init()
/*
* Just zero the data arrays
*/
- bzero((char *)goesunits, sizeof goesunits);
- bzero((char *)unitinuse, sizeof unitinuse);
+ memset((char *)goesunits, 0, sizeof goesunits);
+ memset((char *)unitinuse, 0, sizeof unitinuse);
/*
* Initialize fudge factors to default.
@@ -283,9 +285,9 @@ goes_start(unit, peer)
}
}
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
/*
- * POSIX/STREAMS serial line parameters (termios interface)
+ * POSIX serial line parameters (termios interface)
*
* The GOESCLK option provides timestamping at the driver level.
* It requires the tty_clk streams module.
@@ -318,22 +320,24 @@ goes_start(unit, peer)
"goes_start: tcflush(%s): %m", goesdev);
goto screwed;
}
+ }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
#if defined(GOESCLK)
- if (ioctl(fd232, I_PUSH, "clk") < 0)
- syslog(LOG_ERR,
- "goes_start: ioctl(%s, I_PUSH, clk): %m", goesdev);
- if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
- syslog(LOG_ERR,
- "goes_start: ioctl(%s, CLK_SETSTR): %m", goesdev);
+ if (ioctl(fd232, I_PUSH, "clk") < 0)
+ syslog(LOG_ERR,
+ "goes_start: ioctl(%s, I_PUSH, clk): %m", goesdev);
+ if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
+ syslog(LOG_ERR,
+ "goes_start: ioctl(%s, CLK_SETSTR): %m", goesdev);
#endif /* GOESCLK */
#if defined(GOESPPS)
- if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
- syslog(LOG_ERR,
- "goes_start: ioctl(%s, I_PUSH, ppsclock): %m", goesdev);
- else
- fdpps = fd232;
+ if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
+ syslog(LOG_ERR,
+ "goes_start: ioctl(%s, I_PUSH, ppsclock): %m", goesdev);
+ else
+ fdpps = fd232;
#endif /* GOESPPS */
- }
#endif /* STREAM */
#if defined(HAVE_BSD_TTYS)
/*
@@ -396,7 +400,7 @@ goes_start(unit, peer)
emalloc(sizeof(struct goesunit));
}
}
- bzero((char *)goes, sizeof(struct goesunit));
+ memset((char *)goes, 0, sizeof(struct goesunit));
goesunits[unit] = goes;
/*
@@ -424,7 +428,7 @@ goes_start(unit, peer)
peer->rootdispersion = 0;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(GOESREFID, (char *)&peer->refid, 4);
+ memmove((char *)&peer->refid, GOESREFID, 4);
else
peer->refid = htonl(GOESHSREFID);
unitinuse[unit] = 1;
@@ -919,8 +923,8 @@ goes_control(unit, in, out)
peer = goes->peer;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(GOESREFID, (char *)&peer->refid,
- 4);
+ memmove((char *)&peer->refid,
+ GOESREFID, 4);
else
peer->refid = htonl(GOESHSREFID);
}
diff --git a/usr.sbin/xntpd/xntpd/refclock_gpstm.c b/usr.sbin/xntpd/xntpd/refclock_gpstm.c
new file mode 100644
index 000000000000..93abcf93773c
--- /dev/null
+++ b/usr.sbin/xntpd/xntpd/refclock_gpstm.c
@@ -0,0 +1,1015 @@
+/*
+ * refclock_gpstm - clock driver for the Kinimetrics Truetime GPSTM/TMD rcvr
+ * Version 1.0 (from Version 2.0 of the GOES driver, as of 03Jan94)
+ */
+
+#if defined(REFCLOCK) && (defined(GPSTM) || defined(GPSTMCLK) \
+ || defined(GPSTMPPS))
+
+#include <stdio.h>
+#include <ctype.h>
+#include <sys/time.h>
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+
+#ifdef SYS_BSDI
+#undef HAVE_BSD_TTYS
+#include <sys/ioctl.h>
+#endif
+
+#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(GPSTMCLK)
+#include <clkdefs.h>
+#endif /* GPSTMCLK */
+#endif /* STREAM */
+
+#if defined(GPSTMPPS)
+#include <sys/ppsclock.h>
+#endif /* GPSTMPPS */
+
+#include "ntp_stdlib.h"
+
+/*
+ * Support for Kinemetrics Truetime GPS-TM/TMD Receiver
+ *
+ * Most of this code is copied from refclock_goes.c with thanks.
+ *
+ * the time code looks like follows:
+ *
+ * ADDD:HH:MM:SSQCL
+ * A - control A
+ * Q Quality indication: indicates possible error of
+ * ? +/- 500 milliseconds # +/- 50 milliseconds
+ * * +/- 5 milliseconds . +/- 1 millisecond
+ * space less than 1 millisecond
+ * C - Carriage return
+ * L - Line feed
+ * The carriage return start bit begins on 0 seconds and extends to 1 bit time.
+ *
+ * Flag1 set to 1 will silence the clock side of xntpd, just reading the
+ * clock without trying to write to it. This is usefull if several
+ * xntpds listen to the same clock. This has not been tested yet...
+ */
+
+/*
+ * Definitions
+ */
+#define MAXUNITS 4 /* max number of GPSTM units */
+#define GPSTM232 "/dev/gpstm%d"
+#define SPEED232 B9600 /* 9600 baud */
+
+/*
+ * Radio interface parameters
+ */
+#define MAXDISPERSE (FP_SECOND>>1) /* max error for synchronized clock (0.5 s as an u_fp) */
+#define PRECISION (-20) /* precision assumed (about 1 ms) */
+#define REFID "GPS\0" /* reference id */
+#define DESCRIPTION "Kinemetrics GPS-TM/TMD Receiver" /* who we are */
+#define HSREFID 0x7f7f0f0a /* 127.127.15.10 refid hi strata */
+#define GMT 0 /* hour offset from Greenwich */
+#define NCODES 3 /* stages of median filter */
+#define BMAX 99 /* timecode buffer length */
+#define CODEDIFF 0x20000000 /* 0.125 seconds as an l_fp fraction */
+#define TIMEOUT 180 /* ping the clock if it's silent this long */
+
+/*
+ * used by the state machine
+ */
+enum gpstm_event {e_Init, e_F18, e_F50, e_F51, e_TS};
+static enum {Base, Start, F18, F50, F51, F08} State[MAXUNITS];
+static time_t Last[MAXUNITS];
+static void gpstm_doevent P((int, enum gpstm_event));
+static void gpstm_initstate P((int));
+
+/*
+ * Hack to avoid excercising the multiplier. I have no pride.
+ */
+#define MULBY10(x) (((x)<<3) + ((x)<<1))
+
+/*
+ * Imported from the timer module
+ */
+extern U_LONG current_time;
+extern struct event timerqueue[];
+
+/*
+ * Imported from ntp_loopfilter module
+ */
+extern int fdpps; /* pps file descriptor */
+
+/*
+ * Imported from ntpd module
+ */
+extern int debug; /* global debug flag */
+
+/*
+ * GPSTM unit control structure
+ */
+struct gpstm_unit {
+ struct peer *peer; /* associated peer structure */
+ struct refclockio io; /* given to the I/O handler */
+ l_fp lastrec; /* last receive time */
+ l_fp lastref; /* last timecode time */
+ l_fp offset[NCODES]; /* recent sample offsets */
+ char lastcode[BMAX]; /* last timecode received */
+ u_short polled; /* Hand in a time sample? */
+ u_char lencode; /* length of last timecode */
+ U_LONG lasttime; /* last time clock heard from */
+ u_char unit; /* unit number for this guy */
+ u_char status; /* clock status */
+ u_char lastevent; /* last clock event */
+ u_char reason; /* reason for last abort */
+ u_char year; /* year of eternity */
+ u_short day; /* day of year */
+ u_char hour; /* hour of day */
+ u_char minute; /* minute of hour */
+ u_char second; /* seconds of minute */
+ u_char leap; /* leap indicators */
+ u_short msec; /* millisecond of second */
+ u_char quality; /* quality character */
+ U_LONG yearstart; /* start of current year */
+ /*
+ * Status tallies
+ */
+ U_LONG polls; /* polls sent */
+ U_LONG noreply; /* no replies to polls */
+ U_LONG coderecv; /* timecodes received */
+ U_LONG badformat; /* bad format */
+ U_LONG baddata; /* bad data */
+ U_LONG timestarted; /* time we started this */
+};
+
+/*
+ * Data space for the unit structures. Note that we allocate these on
+ * the fly, but never give them back.
+ */
+static struct gpstm_unit *gpstm_units[MAXUNITS];
+static u_char unitinuse[MAXUNITS];
+
+/*
+ * Keep the fudge factors separately so they can be set even
+ * when no clock is configured.
+ */
+static l_fp fudgefactor1[MAXUNITS];
+static l_fp fudgefactor2[MAXUNITS];
+static u_char stratumtouse[MAXUNITS];
+static u_char readonlyclockflag[MAXUNITS];
+
+/*
+ * Function prototypes
+ */
+static void gpstm_init P((void));
+static int gpstm_start P((u_int, struct peer *));
+static void gpstm_shutdown P((int));
+static void gpstm_rep_event P((struct gpstm_unit *, int));
+static void gpstm_receive P((struct recvbuf *));
+static char gpstm_process P((struct gpstm_unit *, l_fp *, u_fp *));
+static void gpstm_poll P((int, struct peer *));
+static void gpstm_control P((u_int, struct refclockstat *,
+ struct refclockstat *));
+static void gpstm_buginfo P((int, struct refclockbug *));
+static void gpstm_send P((struct gpstm_unit *, char *));
+
+struct refclock refclock_gpstm = {
+ gpstm_start, gpstm_shutdown, gpstm_poll,
+ gpstm_control, gpstm_init, gpstm_buginfo, NOFLAGS
+};
+
+/*
+ * gpstm_init - initialize internal driver data
+ */
+static void
+gpstm_init()
+{
+ register int i;
+ /*
+ * Just zero the data arrays
+ */
+ memset((char *)gpstm_units, 0, sizeof gpstm_units);
+ memset((char *)unitinuse, 0, sizeof unitinuse);
+
+ /*
+ * Initialize fudge factors to default.
+ */
+ for (i = 0; i < MAXUNITS; i++) {
+ fudgefactor1[i].l_ui = 0;
+ fudgefactor1[i].l_uf = 0;
+ fudgefactor2[i].l_ui = 0;
+ fudgefactor2[i].l_uf = 0;
+ stratumtouse[i] = 0;
+ readonlyclockflag[i] = 0;
+ }
+}
+
+
+/*
+ * gpstm_start - open the device and initialize data for processing
+ */
+static int
+gpstm_start(unit, peer)
+ u_int unit;
+ struct peer *peer;
+{
+ register struct gpstm_unit *gpstm;
+ register int i;
+ int fd232;
+ char dev[20];
+
+ /*
+ * Check configuration info
+ */
+ if (unit >= MAXUNITS) {
+ syslog(LOG_ERR, "gpstm_start: unit %d invalid", unit);
+ return 0;
+ }
+ if (unitinuse[unit]) {
+ syslog(LOG_ERR, "gpstm_start: unit %d in use", unit);
+ return 0;
+ }
+
+ /*
+ * Open serial port
+ */
+ (void) sprintf(dev, GPSTM232, unit);
+ fd232 = open(dev, O_RDWR, 0777);
+ if (fd232 == -1) {
+ syslog(LOG_ERR, "gpstm_start: open of %s: %m", dev);
+ return 0;
+ }
+
+#if defined(HAVE_SYSV_TTYS)
+ /*
+ * System V serial line parameters (termio interface)
+ *
+ */
+ { struct termio ttyb;
+ if (ioctl(fd232, TCGETA, &ttyb) < 0) {
+ syslog(LOG_ERR,
+ "gpstm_start: ioctl(%s, TCGETA): %m", dev);
+ goto screwed;
+ }
+ ttyb.c_iflag = IGNBRK|IGNPAR|ICRNL;
+ ttyb.c_oflag = 0;
+ ttyb.c_cflag = SPEED232|CS8|CLOCAL|CREAD;
+ ttyb.c_lflag = ICANON;
+ ttyb.c_cc[VERASE] = ttyb.c_cc[VKILL] = '\0';
+ if (ioctl(fd232, TCSETA, &ttyb) < 0) {
+ syslog(LOG_ERR,
+ "gpstm_start: ioctl(%s, TCSETA): %m", dev);
+ goto screwed;
+ }
+ }
+#endif /* HAVE_SYSV_TTYS */
+#if defined(HAVE_TERMIOS)
+ /*
+ * POSIX serial line parameters (termios interface)
+ *
+ * The GPSTMCLK option provides timestamping at the driver level.
+ * It requires the tty_clk streams module.
+ *
+ * The GPSTMPPS option provides timestamping at the driver level.
+ * It uses a 1-pps signal and level converter (gadget box) and
+ * requires the ppsclock streams module and SunOS 4.1.1 or
+ * later.
+ */
+ { struct termios ttyb, *ttyp;
+ ttyp = &ttyb;
+
+ if (tcgetattr(fd232, ttyp) < 0) {
+ syslog(LOG_ERR,
+ "gpstm_start: tcgetattr(%s): %m", dev);
+ goto screwed;
+ }
+ ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL;
+ ttyp->c_oflag = 0;
+ ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD;
+ ttyp->c_lflag = ICANON;
+ ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0';
+ if (tcsetattr(fd232, TCSANOW, ttyp) < 0) {
+ syslog(LOG_ERR,
+ "gpstm_start: tcsetattr(%s): %m", dev);
+ goto screwed;
+ }
+ if (tcflush(fd232, TCIOFLUSH) < 0) {
+ syslog(LOG_ERR,
+ "gpstm_start: tcflush(%s): %m", dev);
+ goto screwed;
+ }
+#if defined(STREAM)
+#if defined(GPSTMCLK)
+ if (ioctl(fd232, I_PUSH, "clk") < 0)
+ syslog(LOG_ERR,
+ "gpstm_start: ioctl(%s, I_PUSH, clk): %m", dev);
+ if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
+ syslog(LOG_ERR,
+ "gpstm_start: ioctl(%s, CLK_SETSTR): %m", dev);
+#endif /* GPSTMCLK */
+#if defined(GPSTMPPS)
+ if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
+ syslog(LOG_ERR,
+ "gpstm_start: ioctl(%s, I_PUSH, ppsclock): %m", dev);
+ else
+ fdpps = fd232;
+#endif /* GPSTMPPS */
+#endif /* STREAM */
+ }
+#endif /* HAVE_TERMIOS */
+#if defined(HAVE_BSD_TTYS)
+ /*
+ * 4.3bsd serial line parameters (sgttyb interface)
+ *
+ * The GPSTMCLK option provides timestamping at the driver level.
+ * It requires the tty_clk line discipline and 4.3bsd or later.
+ */
+ { struct sgttyb ttyb;
+#if defined(GPSTMCLK)
+ int ldisc = CLKLDISC;
+#endif /* GPSTMCLK */
+
+ if (ioctl(fd232, TIOCGETP, &ttyb) < 0) {
+ syslog(LOG_ERR,
+ "gpstm_start: ioctl(%s, TIOCGETP): %m", dev);
+ goto screwed;
+ }
+ ttyb.sg_ispeed = ttyb.sg_ospeed = SPEED232;
+#if defined(GPSTMCLK)
+ ttyb.sg_erase = ttyb.sg_kill = '\r';
+ ttyb.sg_flags = RAW;
+#else
+ ttyb.sg_erase = ttyb.sg_kill = '\0';
+ ttyb.sg_flags = EVENP|ODDP|CRMOD;
+#endif /* GPSTMCLK */
+ if (ioctl(fd232, TIOCSETP, &ttyb) < 0) {
+ syslog(LOG_ERR,
+ "gpstm_start: ioctl(%s, TIOCSETP): %m", dev);
+ goto screwed;
+ }
+#if defined(GPSTMCLK)
+ if (ioctl(fd232, TIOCSETD, &ldisc) < 0) {
+ syslog(LOG_ERR,
+ "gpstm_start: ioctl(%s, TIOCSETD): %m", dev);
+ goto screwed;
+ }
+#endif /* GPSTMCLK */
+ }
+#endif /* HAVE_BSD_TTYS */
+
+ /*
+ * Allocate unit structure
+ */
+ if (gpstm_units[unit] != 0) {
+ gpstm = gpstm_units[unit]; /* The one we want is okay */
+ } else {
+ for (i = 0; i < MAXUNITS; i++) {
+ if (!unitinuse[i] && gpstm_units[i] != 0)
+ break;
+ }
+ if (i < MAXUNITS) {
+ /*
+ * Reclaim this one
+ */
+ gpstm = gpstm_units[i];
+ gpstm_units[i] = 0;
+ } else {
+ gpstm = (struct gpstm_unit *)
+ emalloc(sizeof(struct gpstm_unit));
+ }
+ }
+ memset((char *)gpstm, 0, sizeof(struct gpstm_unit));
+ gpstm_units[unit] = gpstm;
+
+ /*
+ * Set up the structures
+ */
+ gpstm->peer = peer;
+ gpstm->unit = (u_char)unit;
+ gpstm->timestarted = current_time;
+
+ gpstm->io.clock_recv = gpstm_receive;
+ gpstm->io.srcclock = (caddr_t)gpstm;
+ gpstm->io.datalen = 0;
+ gpstm->io.fd = fd232;
+ if (!io_addclock(&gpstm->io)) {
+ goto screwed;
+ }
+
+ /*
+ * All done. Initialize a few random peer variables, then
+ * return success.
+ */
+ peer->precision = PRECISION;
+ peer->rootdelay = 0;
+ peer->rootdispersion = 0;
+ peer->stratum = stratumtouse[unit];
+ if (stratumtouse[unit] <= 1)
+ memmove((char *)&peer->refid, REFID, 4);
+ else
+ peer->refid = htonl(HSREFID);
+ unitinuse[unit] = 1;
+ gpstm_initstate(unit);
+ return 1;
+
+ /*
+ * Something broke; abandon ship
+ */
+screwed:
+ (void) close(fd232);
+ return 0;
+}
+
+/*
+ * gpstm_shutdown - shut down a clock
+ */
+static void
+gpstm_shutdown(unit)
+ int unit;
+{
+ register struct gpstm_unit *gpstm;
+
+ if (unit >= MAXUNITS) {
+ syslog(LOG_ERR, "gpstm_shutdown: unit %d invalid", unit);
+ return;
+ }
+ if (!unitinuse[unit]) {
+ syslog(LOG_ERR, "gpstm_shutdown: unit %d not in use", unit);
+ return;
+ }
+
+ /*
+ * Tell the I/O module to turn us off. We're history.
+ */
+ gpstm = gpstm_units[unit];
+ io_closeclock(&gpstm->io);
+ unitinuse[unit] = 0;
+}
+
+
+/*
+ * gpstm_rep_event - note the occurance of an event
+ */
+static void
+gpstm_rep_event(gpstm, code)
+ struct gpstm_unit *gpstm;
+ int code;
+{
+ struct peer *peer;
+
+ peer = gpstm->peer;
+ if (gpstm->status != (u_char)code) {
+ gpstm->status = (u_char)code;
+ if (code != CEVNT_NOMINAL)
+ gpstm->lastevent = (u_char)code;
+ syslog(LOG_INFO,
+ "clock %s event %x\n", ntoa(&peer->srcadr), code);
+#ifdef DEBUG
+ if (debug) {
+ printf("gpstm_rep_event(gpstm%d, code %d)\n",
+ gpstm->unit, code);
+ }
+#endif
+ }
+ if (code == CEVNT_BADREPLY)
+ gpstm_initstate(gpstm->unit);
+}
+
+
+/*
+ * gpstm_receive - receive data from the serial interface on a clock
+ */
+static void
+gpstm_receive(rbufp)
+ struct recvbuf *rbufp;
+{
+ register int i;
+ register struct gpstm_unit *gpstm;
+ register u_char *dpt;
+ register char *cp;
+ register u_char *dpend;
+ l_fp tstmp;
+ u_fp dispersion;
+
+ /*
+ * Get the clock this applies to and a pointers to the data
+ */
+ gpstm = (struct gpstm_unit *)rbufp->recv_srcclock;
+ dpt = (u_char *)&rbufp->recv_space;
+
+ /*
+ * Edit timecode to remove control chars
+ */
+ dpend = dpt + rbufp->recv_length;
+ cp = gpstm->lastcode;
+ while (dpt < dpend) {
+ if ((*cp = 0x7f & *dpt++) >= ' ') cp++;
+#ifdef GPSTMCLK
+ else if (*cp == '\r') {
+ if (dpend - dpt < 8) {
+ /* short timestamp */
+ return;
+ }
+ if (!buftvtots(dpt,&gpstm->lastrec)) {
+ /* screwy timestamp */
+ return;
+ }
+ dpt += 8;
+ }
+#endif
+ }
+ *cp = '\0';
+ gpstm->lencode = cp - gpstm->lastcode;
+ if (gpstm->lencode == 0)
+ return;
+#ifndef GPSTMCLK
+ gpstm->lastrec = rbufp->recv_time;
+#endif /* GPSTMCLK */
+#if !defined(GPSTMCLK) && !defined(GPSTMPPS) && defined(TIOCMODT)
+ do {
+ auto struct timeval cur, now;
+ register long usec;
+
+ if (ioctl(gpstm->io.fd, TIOCMODT, &cur) < 0) {
+ syslog(LOG_ERR, "TIOCMODT: %m");
+#ifdef DEBUG
+ if (debug) perror("TIOCMODT");
+ break;
+#endif
+ }
+ if (cur.tv_sec == 0) {
+ /* no timestamps yet */
+ if (debug) printf("MODT tv_sec == 0\n");
+ break;
+ }
+
+ gettimeofday(&now, NULL);
+ usec = 1000000 * (now.tv_sec - cur.tv_sec)
+ + (now.tv_usec - cur.tv_usec);
+#ifdef DEBUG
+ if (debug) printf("lastmodem: delay=%d us\n", usec);
+#endif
+ if (usec < 0 || usec > 10000) {
+ /* time warp or stale timestamp */
+ break;
+ }
+ if (!buftvtots((char *)&cur, &gpstm->lastrec)) {
+ /* screwy timestamp */
+ break;
+ }
+ } while (0);
+#endif /*TIOCMODT*/
+
+#ifdef DEBUG
+ if (debug)
+ printf("gpstm: timecode %d %s\n",
+ gpstm->lencode, gpstm->lastcode);
+#endif
+
+ cp = gpstm->lastcode;
+ gpstm->leap = 0;
+ if ((cp[0] == 'F' && isdigit(cp[1]) && isdigit(cp[2]))
+ || (cp[0] == ' ' && cp[1] == 'T' && cp[2] == 'R')) {
+ enum gpstm_event event;
+
+ syslog(LOG_NOTICE, "gpstm%d: \"%s\"", gpstm->unit, cp);
+ if (cp[1] == '5' && cp[2] == '0')
+ event = e_F50;
+ else if (cp[1] == '5' && cp[2] == '1')
+ event = e_F51;
+ else if (!strncmp(" TRUETIME Mk III", cp, 16))
+ event = e_F18;
+ else {
+ gpstm_rep_event(gpstm, CEVNT_BADREPLY);
+ return;
+ }
+ gpstm_doevent(gpstm->unit, event);
+ return;
+ } else if (gpstm->lencode == 13) {
+ /*
+ * Check timecode format 0
+ */
+ if (!isdigit(cp[0]) /* day of year */
+ || !isdigit(cp[1])
+ || !isdigit(cp[2])
+ || cp[3] != ':' /* : separator */
+ || !isdigit(cp[4]) /* hours */
+ || !isdigit(cp[5])
+ || cp[6] != ':' /* : separator */
+ || !isdigit(cp[7]) /* minutes */
+ || !isdigit(cp[8])
+ || cp[9] != ':' /* : separator */
+ || !isdigit(cp[10]) /* seconds */
+ || !isdigit(cp[11]))
+ {
+ gpstm->badformat++;
+ gpstm_rep_event(gpstm, CEVNT_BADREPLY);
+ return;
+ }
+
+ /*
+ * Convert format 0 and check values
+ */
+ gpstm->year = 0; /* fake */
+ gpstm->day = cp[0] - '0';
+ gpstm->day = MULBY10(gpstm->day) + cp[1] - '0';
+ gpstm->day = MULBY10(gpstm->day) + cp[2] - '0';
+ gpstm->hour = MULBY10(cp[4] - '0') + cp[5] - '0';
+ gpstm->minute = MULBY10(cp[7] - '0') + cp[8] - '0';
+ gpstm->second = MULBY10(cp[10] - '0') + cp[11] - '0';
+ gpstm->msec = 0;
+
+ if (cp[12] != ' ' && cp[12] != '.' && cp[12] != '*')
+ gpstm->leap = LEAP_NOTINSYNC;
+ else
+ gpstm->lasttime = current_time;
+
+ if (gpstm->day < 1 || gpstm->day > 366) {
+ gpstm->baddata++;
+ gpstm_rep_event(gpstm, CEVNT_BADDATE);
+ return;
+ }
+ if (gpstm->hour > 23 || gpstm->minute > 59
+ || gpstm->second > 59) {
+ gpstm->baddata++;
+ gpstm_rep_event(gpstm, CEVNT_BADTIME);
+ return;
+ }
+ gpstm_doevent(gpstm->unit, e_TS);
+ } else {
+ gpstm_rep_event(gpstm, CEVNT_BADREPLY);
+ return;
+ }
+
+ /*
+ * The clock will blurt a timecode every second but we only
+ * want one when polled. If we havn't been polled, bail out.
+ */
+ if (!gpstm->polled)
+ return;
+
+ /*
+ * Now, compute the reference time value. Use the heavy
+ * machinery for the seconds and the millisecond field for the
+ * fraction when present.
+ *
+ * this code does not yet know how to do the years
+ */
+ tstmp = gpstm->lastrec;
+ if (!clocktime(gpstm->day, gpstm->hour, gpstm->minute,
+ gpstm->second, GMT, tstmp.l_ui,
+ &gpstm->yearstart, &gpstm->lastref.l_ui))
+ {
+ gpstm->baddata++;
+ gpstm_rep_event(gpstm, CEVNT_BADTIME);
+ return;
+ }
+ MSUTOTSF(gpstm->msec, gpstm->lastref.l_uf);
+
+ i = ((int)(gpstm->coderecv)) % NCODES;
+ gpstm->offset[i] = gpstm->lastref;
+ L_SUB(&gpstm->offset[i], &tstmp);
+ if (gpstm->coderecv == 0)
+ for (i = 1; i < NCODES; i++)
+ gpstm->offset[i] = gpstm->offset[0];
+
+ gpstm->coderecv++;
+
+ /*
+ * Process the median filter, and pass the
+ * offset and dispersion along. 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.
+ */
+ if (!gpstm_process(gpstm, &tstmp, &dispersion)) {
+ gpstm->baddata++;
+ gpstm_rep_event(gpstm, CEVNT_BADTIME);
+ return;
+ }
+ refclock_receive(gpstm->peer, &tstmp, GMT, dispersion,
+ &gpstm->lastrec, &gpstm->lastrec, gpstm->leap);
+
+ /*
+ * We have succedded in answering the poll. Turn off the flag
+ */
+ gpstm->polled = 0;
+}
+
+/*
+ * gpstm_send - time to send the clock a signal to cough up a time sample
+ */
+static void
+gpstm_send(gpstm, cmd)
+ struct gpstm_unit *gpstm;
+ char *cmd;
+{
+#ifdef DEBUG
+ if (debug) {
+ printf("gpstm_send(gpstm%d): %s\n", gpstm->unit, cmd);
+ }
+#endif
+ if (!readonlyclockflag[gpstm->unit]) {
+ register int len = strlen(cmd);
+
+ if (write(gpstm->io.fd, cmd, len) != len) {
+ syslog(LOG_ERR, "gpstm_send: unit %d: %m",
+ gpstm->unit);
+ gpstm_rep_event(gpstm, CEVNT_FAULT);
+ }
+ }
+}
+
+/*
+ * state machine for initializing the clock
+ */
+
+static void
+gpstm_doevent(unit, event)
+ int unit;
+ enum gpstm_event event;
+{
+ struct gpstm_unit *gpstm = gpstm_units[unit];
+
+#ifdef DEBUG
+ if (debug) {
+ printf("gpstm_doevent(gpstm%d, %d)\n", unit, (int)event);
+ }
+#endif
+ if (event == e_TS && State[unit] != F51 && State[unit] != F08) {
+ gpstm_send(gpstm, "\03\r");
+ }
+
+ switch (event) {
+ case e_Init:
+ gpstm_send(gpstm, "F18\r");
+ State[unit] = Start;
+ break;
+ case e_F18:
+ gpstm_send(gpstm, "F50\r");
+ State[unit] = F18;
+ break;
+ case e_F50:
+ gpstm_send(gpstm, "F51\r");
+ State[unit] = F50;
+ break;
+ case e_F51:
+ gpstm_send(gpstm, "F08\r");
+ State[unit] = F51;
+ break;
+ case e_TS:
+ /* nothing to send - we like this mode */
+ State[unit] = F08;
+ break;
+ }
+}
+
+static void
+gpstm_initstate(unit) {
+ State[unit] = Base; /* just in case */
+ gpstm_doevent(unit, e_Init);
+}
+
+/*
+ * gpstm_process - process a pile of samples from the clock
+ */
+static char
+gpstm_process(gpstm, offset, dispersion)
+ struct gpstm_unit *gpstm;
+ l_fp *offset;
+ u_fp *dispersion;
+{
+ register int i, j;
+ register U_LONG tmp_ui, tmp_uf;
+ int not_median1 = -1; /* XXX correct? */
+ int not_median2 = -1; /* XXX correct? */
+ int median;
+ u_fp disp_tmp, disp_tmp2;
+
+ /*
+ * This code implements a three-stage median filter. First, we
+ * check if the samples are within 125 ms of each other. If not,
+ * dump the sample set. We take the median of the three offsets
+ * and use that as the sample offset. We take the maximum
+ * difference and use that as the sample dispersion. There
+ * probably is not much to be gained by a longer filter, since
+ * the clock filter in ntp_proto should do its thing.
+ */
+ disp_tmp2 = 0;
+ for (i = 0; i < NCODES-1; i++) {
+ for (j = i+1; j < NCODES; j++) {
+ tmp_ui = gpstm->offset[i].l_ui;
+ tmp_uf = gpstm->offset[i].l_uf;
+ M_SUB(tmp_ui, tmp_uf, gpstm->offset[j].l_ui,
+ gpstm->offset[j].l_uf);
+ if (M_ISNEG(tmp_ui, tmp_uf)) {
+ M_NEG(tmp_ui, tmp_uf);
+ }
+ if (tmp_ui != 0 || tmp_uf > CODEDIFF) {
+ return 0;
+ }
+ disp_tmp = MFPTOFP(0, tmp_uf);
+ if (disp_tmp > disp_tmp2) {
+ disp_tmp2 = disp_tmp;
+ not_median1 = i;
+ not_median2 = j;
+ }
+ }
+ }
+
+ /*
+ * It seems as if all are within 125 ms of each other.
+ * Now to determine the median of the three. Whlie the
+ * 125 ms check was going on, we also subtly catch the
+ * dispersion and set-up for a very easy median calculation.
+ * The largest difference between any two samples constitutes
+ * the dispersion. The sample not involve in the dispersion is
+ * the median sample. EASY!
+ */
+ if (gpstm->lasttime == 0 || disp_tmp2 > MAXDISPERSE)
+ disp_tmp2 = MAXDISPERSE;
+ if (not_median1 == 0) {
+ if (not_median2 == 1)
+ median = 2;
+ else
+ median = 1;
+ } else {
+ median = 0;
+ }
+ *offset = gpstm->offset[median];
+ *dispersion = disp_tmp2;
+ return 1;
+}
+
+/*
+ * gpstm_poll - called by the transmit procedure
+ */
+static void
+gpstm_poll(unit, peer)
+ int unit;
+ struct peer *peer;
+{
+ struct gpstm_unit *gpstm;
+
+ /*
+ * You don't need to poll this clock. It puts out timecodes
+ * once per second. If asked for a timestamp, take note.
+ * The next time a timecode comes in, it will be fed back.
+ */
+ if (unit >= MAXUNITS) {
+ syslog(LOG_ERR, "gpstm_poll: unit %d invalid", unit);
+ return;
+ }
+ if (!unitinuse[unit]) {
+ syslog(LOG_ERR, "gpstm_poll: unit %d not in use", unit);
+ return;
+ }
+ gpstm = gpstm_units[unit];
+ if ((current_time - gpstm->lasttime) > 150) {
+ gpstm->noreply++;
+ gpstm_rep_event(gpstm_units[unit], CEVNT_TIMEOUT);
+ gpstm_initstate(gpstm->unit);
+ }
+
+ /*
+ * polled every 64 seconds. Ask our receiver to hand in a timestamp.
+ */
+ gpstm->polled = 1;
+ gpstm->polls++;
+}
+
+/*
+ * gpstm_control - set fudge factors, return statistics
+ */
+static void
+gpstm_control(unit, in, out)
+ u_int unit;
+ struct refclockstat *in;
+ struct refclockstat *out;
+{
+ register struct gpstm_unit *gpstm;
+
+ if (unit >= MAXUNITS) {
+ syslog(LOG_ERR, "gpstm_control: unit %d invalid", unit);
+ return;
+ }
+ gpstm = gpstm_units[unit];
+
+ if (in != 0) {
+ if (in->haveflags & CLK_HAVETIME1)
+ fudgefactor1[unit] = in->fudgetime1;
+ if (in->haveflags & CLK_HAVETIME2)
+ fudgefactor2[unit] = in->fudgetime2;
+ if (in->haveflags & CLK_HAVEVAL1) {
+ stratumtouse[unit] = (u_char)(in->fudgeval1 & 0xf);
+ if (unitinuse[unit]) {
+ struct peer *peer;
+
+ /*
+ * Should actually reselect clock, but
+ * will wait for the next timecode
+ */
+ peer = gpstm->peer;
+ peer->stratum = stratumtouse[unit];
+ if (stratumtouse[unit] <= 1)
+ memmove((char *)&peer->refid,
+ REFID, 4);
+ else
+ peer->refid = htonl(HSREFID);
+ }
+ }
+ if (in->haveflags & CLK_HAVEFLAG1) {
+ readonlyclockflag[unit] = in->flags & CLK_FLAG1;
+ }
+ }
+
+ if (out != 0) {
+ out->type = REFCLK_GPSTM_TRUETIME;
+ out->haveflags = CLK_HAVETIME1 | CLK_HAVETIME2
+ | CLK_HAVEVAL1 | CLK_HAVEVAL2
+ | CLK_HAVEFLAG1;
+ out->clockdesc = DESCRIPTION;
+ out->fudgetime1 = fudgefactor1[unit];
+ out->fudgetime2 = fudgefactor2[unit];
+ out->fudgeval1 = (LONG)stratumtouse[unit];
+ out->fudgeval2 = 0;
+ out->flags = readonlyclockflag[unit];
+ if (unitinuse[unit]) {
+ out->lencode = gpstm->lencode;
+ out->lastcode = gpstm->lastcode;
+ out->timereset = current_time - gpstm->timestarted;
+ out->polls = gpstm->polls;
+ out->noresponse = gpstm->noreply;
+ out->badformat = gpstm->badformat;
+ out->baddata = gpstm->baddata;
+ out->lastevent = gpstm->lastevent;
+ out->currentstatus = gpstm->status;
+ } else {
+ out->lencode = 0;
+ out->lastcode = "";
+ out->polls = out->noresponse = 0;
+ out->badformat = out->baddata = 0;
+ out->timereset = 0;
+ out->currentstatus = out->lastevent = CEVNT_NOMINAL;
+ }
+ }
+}
+
+/*
+ * gpstm_buginfo - return clock dependent debugging info
+ */
+static void
+gpstm_buginfo(unit, bug)
+ int unit;
+ register struct refclockbug *bug;
+{
+ register struct gpstm_unit *gpstm;
+
+ if (unit >= MAXUNITS) {
+ syslog(LOG_ERR, "gpstm_buginfo: unit %d invalid", unit);
+ return;
+ }
+
+ if (!unitinuse[unit])
+ return;
+ gpstm = gpstm_units[unit];
+
+ bug->nvalues = 11;
+ bug->ntimes = 5;
+ if (gpstm->lasttime != 0)
+ bug->values[0] = current_time - gpstm->lasttime;
+ else
+ bug->values[0] = 0;
+ bug->values[1] = (U_LONG)gpstm->reason;
+ bug->values[2] = (U_LONG)gpstm->year;
+ bug->values[3] = (U_LONG)gpstm->day;
+ bug->values[4] = (U_LONG)gpstm->hour;
+ bug->values[5] = (U_LONG)gpstm->minute;
+ bug->values[6] = (U_LONG)gpstm->second;
+ bug->values[7] = (U_LONG)gpstm->msec;
+ bug->values[8] = gpstm->noreply;
+ bug->values[9] = gpstm->yearstart;
+ bug->values[10] = gpstm->quality;
+ bug->stimes = 0x1c;
+ bug->times[0] = gpstm->lastref;
+ bug->times[1] = gpstm->lastrec;
+ bug->times[2] = gpstm->offset[0];
+ bug->times[3] = gpstm->offset[1];
+ bug->times[4] = gpstm->offset[2];
+}
+
+#endif /*GPSTM et al*/
diff --git a/usr.sbin/xntpd/xntpd/refclock_irig.c b/usr.sbin/xntpd/xntpd/refclock_irig.c
index fb9424116eb6..40345bbefde7 100644
--- a/usr.sbin/xntpd/xntpd/refclock_irig.c
+++ b/usr.sbin/xntpd/xntpd/refclock_irig.c
@@ -169,8 +169,8 @@ irig_init()
/*
* Just zero the data arrays
*/
- bzero((char *) irigunits, sizeof irigunits);
- bzero((char *) unitinuse, sizeof unitinuse);
+ memset((char *) irigunits, 0, sizeof irigunits);
+ memset((char *) unitinuse, 0, sizeof unitinuse);
/*
* Initialize fudge factors to default.
@@ -250,7 +250,7 @@ struct peer *peer;
emalloc(sizeof(struct irigunit));
}
}
- bzero((char *) irig, sizeof(struct irigunit));
+ memset((char *) irig, 0, sizeof(struct irigunit));
irigunits[unit] = irig;
@@ -276,7 +276,7 @@ struct peer *peer;
peer->rootdispersion = 0;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(IRIGREFID, (char *) &peer->refid, 4);
+ memmove((char *) &peer->refid, IRIGREFID, 4);
else
peer->refid = htonl(IRIGHSREFID);
unitinuse[unit] = 1;
@@ -485,8 +485,8 @@ irig_control(unit, in, out)
peer = irig->peer;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(IRIGREFID, (char *) &peer->refid,
- 4);
+ memmove((char *) &peer->refid,
+ IRIGREFID, 4);
else
peer->refid = htonl(IRIGHSREFID);
}
diff --git a/usr.sbin/xntpd/xntpd/refclock_leitch.c b/usr.sbin/xntpd/xntpd/refclock_leitch.c
index 0fa996c7c5c6..330712997eba 100644
--- a/usr.sbin/xntpd/xntpd/refclock_leitch.c
+++ b/usr.sbin/xntpd/xntpd/refclock_leitch.c
@@ -20,8 +20,10 @@
#include <termio.h>
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
#include <termios.h>
+#endif
+#ifdef STREAM
#include <stropts.h>
#if defined(LEITCHCLK)
#include <sys/clkdefs.h>
@@ -142,8 +144,8 @@ struct refclock refclock_leitch = {
static void
leitch_init()
{
- bzero((char*)leitchunits,sizeof(leitchunits));
- bzero((char*)unitinuse,sizeof(unitinuse));
+ memset((char*)leitchunits, 0, sizeof(leitchunits));
+ memset((char*)unitinuse, 0, sizeof(unitinuse));
}
/*
@@ -268,7 +270,7 @@ leitch_start(unit, peer)
}
leitch = &leitchunits[unit];
- bzero((char*)leitch,sizeof(*leitch));
+ memset((char*)leitch, 0, sizeof(*leitch));
#if defined(HAVE_SYSV_TTYS)
/*
@@ -293,9 +295,9 @@ leitch_start(unit, peer)
}
}
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
/*
- * POSIX/STREAMS serial line parameters (termios interface)
+ * POSIX serial line parameters (termios interface)
*
* The LEITCHCLK option provides timestamping at the driver level.
* It requires the tty_clk streams module.
@@ -328,22 +330,24 @@ leitch_start(unit, peer)
"leitch_start: tcflush(%s): %m", leitchdev);
goto screwed;
}
+ }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
#if defined(LEITCHCLK)
- if (ioctl(fd232, I_PUSH, "clk") < 0)
- syslog(LOG_ERR,
- "leitch_start: ioctl(%s, I_PUSH, clk): %m", leitchdev);
- if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
- syslog(LOG_ERR,
- "leitch_start: ioctl(%s, CLK_SETSTR): %m", leitchdev);
+ if (ioctl(fd232, I_PUSH, "clk") < 0)
+ syslog(LOG_ERR,
+ "leitch_start: ioctl(%s, I_PUSH, clk): %m", leitchdev);
+ if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
+ syslog(LOG_ERR,
+ "leitch_start: ioctl(%s, CLK_SETSTR): %m", leitchdev);
#endif /* LEITCHCLK */
#if defined(LEITCHPPS)
- if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
- syslog(LOG_ERR,
- "leitch_start: ioctl(%s, I_PUSH, ppsclock): %m", leitchdev);
- else
- fdpps = fd232;
+ if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
+ syslog(LOG_ERR,
+ "leitch_start: ioctl(%s, I_PUSH, ppsclock): %m", leitchdev);
+ else
+ fdpps = fd232;
#endif /* LEITCHPPS */
- }
#endif /* STREAM */
#if defined(HAVE_BSD_TTYS)
/*
diff --git a/usr.sbin/xntpd/xntpd/refclock_local.c b/usr.sbin/xntpd/xntpd/refclock_local.c
index 0925a7df5b5e..1323ca91ed62 100644
--- a/usr.sbin/xntpd/xntpd/refclock_local.c
+++ b/usr.sbin/xntpd/xntpd/refclock_local.c
@@ -100,8 +100,8 @@ local_init()
/*
* Just zero the data arrays
*/
- bzero((char *)lclunits, sizeof lclunits);
- bzero((char *)unitinuse, sizeof unitinuse);
+ memset((char *)lclunits, 0, sizeof lclunits);
+ memset((char *)unitinuse, 0, sizeof unitinuse);
}
@@ -148,7 +148,7 @@ local_start(unit, peer)
lcl = (struct lclunit *)emalloc(sizeof(struct lclunit));
}
}
- bzero((char *)lcl, sizeof(struct lclunit));
+ memset((char *)lcl, 0, sizeof(struct lclunit));
lclunits[unit] = lcl;
/*
@@ -166,7 +166,7 @@ local_start(unit, peer)
peer->rootdispersion = LCLROOTDISPERSION;
peer->stratum = (u_char)unit;
if (unit <= 1)
- bcopy(LCLREFID, (char *)&peer->refid, 4);
+ memmove((char *)&peer->refid, LCLREFID, 4);
else
peer->refid = htonl(LCLHSREFID);
unitinuse[unit] = 1;
diff --git a/usr.sbin/xntpd/xntpd/refclock_msfees.c b/usr.sbin/xntpd/xntpd/refclock_msfees.c
index 699ff0d202cd..b301bc2ebb23 100644
--- a/usr.sbin/xntpd/xntpd/refclock_msfees.c
+++ b/usr.sbin/xntpd/xntpd/refclock_msfees.c
@@ -379,8 +379,8 @@ static void msfees_init()
{
register int i;
/* Just zero the data arrays */
- bzero((char *)eesunits, sizeof eesunits);
- bzero((char *)unitinuse, sizeof unitinuse);
+ memset((char *)eesunits, 0, sizeof eesunits);
+ memset((char *)unitinuse, 0, sizeof unitinuse);
acceptable_slop.l_ui = 0;
acceptable_slop.l_uf = 1 << (FRACTION_PREC -2);
@@ -506,7 +506,7 @@ static int msfees_start(unit, peer)
} /* no spare -- make a new one */
else ees = (struct eesunit *) emalloc(sizeof(struct eesunit));
}
- bzero((char *)ees, sizeof(struct eesunit));
+ memset((char *)ees, 0, sizeof(struct eesunit));
eesunits[unit] = ees;
/* Set up the structures */
@@ -547,8 +547,7 @@ static int msfees_start(unit, peer)
/* Add the clock */
if (!io_addclock(&ees->io)) {
/* Oh shit. Just close and return. */
- syslog(LOG_ERR, "ees clock: io_addclock(%s): %m",
- eesdev);
+ syslog(LOG_ERR, "ees clock: io_addclock(%s): %m", eesdev);
goto screwed;
}
@@ -559,18 +558,21 @@ static int msfees_start(unit, peer)
peer->stratum = stratumtouse[unit];
peer->rootdelay = 0; /* ++++ */
peer->rootdispersion = 0; /* ++++ */
- if (stratumtouse[unit] <= 1)
- { bcopy(EESREFID, (char *)&peer->refid, 4);
- if (unit>0 && unit<10) ((char *)&peer->refid)[3] = '0' + unit;
+ if (stratumtouse[unit] <= 1) {
+ memmove((char *)&peer->refid, EESREFID, 4);
+ if (unit > 0 && unit < 10)
+ ((char *)&peer->refid)[3] = '0' + unit;
+ } else {
+ peer->refid = htonl(EESHSREFID);
}
- else peer->refid = htonl(EESHSREFID);
unitinuse[unit] = 1;
syslog(LOG_ERR, "ees clock: %s OK on %d", eesdev, unit);
- return 1;
+ return (1);
screwed:
- if (fd232 != -1) (void) close(fd232);
- return 0;
+ if (fd232 != -1)
+ (void) close(fd232);
+ return (0);
}
@@ -859,7 +861,7 @@ static void ees_receive(rbufp)
/* Number of seconds since the last step */
sincelast = this_uisec - ees->last_step;
- bzero(&ppsclockev, sizeof ppsclockev);
+ memset(&ppsclockev, 0, sizeof ppsclockev);
rc = ioctl(ees->io.fd, CIOGETEV, (char *) &ppsclockev);
if (debug & DB_PRINT_EV) fprintf(stderr,
@@ -1443,8 +1445,8 @@ static void msfees_control(unit, in, out)
struct peer *peer = ees->peer;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1) {
- bcopy(EESREFID, (char *)&peer->refid,
- 4);
+ memmove((char *)&peer->refid,
+ EESREFID, 4);
if (unit>0 && unit<10)
((char *)&peer->refid)[3] =
'0' + unit;
diff --git a/usr.sbin/xntpd/xntpd/refclock_mx4200.c b/usr.sbin/xntpd/xntpd/refclock_mx4200.c
index 3d98d106857c..3c0d097a8d9e 100644
--- a/usr.sbin/xntpd/xntpd/refclock_mx4200.c
+++ b/usr.sbin/xntpd/xntpd/refclock_mx4200.c
@@ -65,8 +65,10 @@ static char rcsid[] =
#include <termio.h>
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
#include <termios.h>
+#endif
+#if defined(STREAM)
#include <stropts.h>
#if defined(MX4200CLK)
#include <sys/clkdefs.h>
@@ -260,8 +262,8 @@ mx4200_init()
/*
* Just zero the data arrays
*/
- bzero((char *)mx4200units, sizeof mx4200units);
- bzero((char *)unitinuse, sizeof unitinuse);
+ memset((char *)mx4200units, 0, sizeof mx4200units);
+ memset((char *)unitinuse, 0, sizeof unitinuse);
/*
* Initialize fudge factors to default.
@@ -368,9 +370,9 @@ mx4200_start(unit, peer)
}
}
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
/*
- * POSIX/STREAMS serial line parameters (termios interface)
+ * POSIX serial line parameters (termios interface)
*
* The MX4200CLK option provides timestamping at the driver level.
* It requires the tty_clk streams module.
@@ -403,22 +405,24 @@ mx4200_start(unit, peer)
"mx4200_start: tcflush(%s): %m", mx4200dev);
goto screwed;
}
+ }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
#if defined(MX4200CLK)
- if (ioctl(fd232, I_PUSH, "clk") < 0)
- syslog(LOG_ERR,
- "mx4200_start: ioctl(%s, I_PUSH, clk): %m", mx4200dev);
- if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
- syslog(LOG_ERR,
- "mx4200_start: ioctl(%s, CLK_SETSTR): %m", mx4200dev);
+ if (ioctl(fd232, I_PUSH, "clk") < 0)
+ syslog(LOG_ERR,
+ "mx4200_start: ioctl(%s, I_PUSH, clk): %m", mx4200dev);
+ if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
+ syslog(LOG_ERR,
+ "mx4200_start: ioctl(%s, CLK_SETSTR): %m", mx4200dev);
#endif /* MX4200CLK */
#if defined(MX4200PPS)
- if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
- syslog(LOG_ERR,
- "mx4200_start: ioctl(%s, I_PUSH, ppsclock): %m", mx4200dev);
- else
- fdpps = fd232;
+ if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
+ syslog(LOG_ERR,
+ "mx4200_start: ioctl(%s, I_PUSH, ppsclock): %m", mx4200dev);
+ else
+ fdpps = fd232;
#endif /* MX4200PPS */
- }
#endif /* STREAM */
#if defined(HAVE_BSD_TTYS)
/*
@@ -482,7 +486,7 @@ mx4200_start(unit, peer)
}
}
- bzero((char *)mx4200, sizeof(struct mx4200unit));
+ memset((char *)mx4200, 0, sizeof(struct mx4200unit));
mx4200units[unit] = mx4200;
/*
@@ -508,7 +512,7 @@ mx4200_start(unit, peer)
peer->rootdispersion = 0;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(MX4200REFID, (char *)&peer->refid, 4);
+ memmove((char *)&peer->refid, MX4200REFID, 4);
else
peer->refid = htonl(MX4200HSREFID);
unitinuse[unit] = 1;
@@ -697,7 +701,7 @@ mx4200_receive(rbufp)
if (n <= 1)
return;
mx4200->lencode = n;
- bcopy(dpt, mx4200->lastcode, n);
+ memmove(mx4200->lastcode, dpt, n);
/*
* We expect to see something like:
@@ -1047,8 +1051,8 @@ mx4200_control(unit, in, out)
peer = mx4200->peer;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(MX4200REFID, (char *)&peer->refid,
- 4);
+ memmove((char *)&peer->refid,
+ MX4200REFID, 4);
else
peer->refid = htonl(MX4200HSREFID);
}
@@ -1111,7 +1115,7 @@ mx4200_buginfo(unit, bug)
return;
mx4200 = mx4200units[unit];
- bzero((char *)bug, sizeof(*bug));
+ memset((char *)bug, 0, sizeof(*bug));
bug->nvalues = 10;
bug->ntimes = 2;
if (mx4200->lasttime != 0)
@@ -1207,7 +1211,7 @@ mx4200_parse(buf, jt, validp, leapsecp)
char *cp;
cp = buf;
- bzero((char *)jt, sizeof(*jt));
+ memset((char *)jt, 0, sizeof(*jt));
if ((cp = strchr(cp, ',')) == NULL)
return ("no rec-type");
diff --git a/usr.sbin/xntpd/xntpd/refclock_omega.c b/usr.sbin/xntpd/xntpd/refclock_omega.c
index 4dee7aa74aa7..73be84d3859b 100644
--- a/usr.sbin/xntpd/xntpd/refclock_omega.c
+++ b/usr.sbin/xntpd/xntpd/refclock_omega.c
@@ -31,8 +31,10 @@
#include <termio.h>
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
#include <termios.h>
+#endif
+#if defined(STREAM)
#include <stropts.h>
#if defined(OMEGACLK)
#include <sys/clkdefs.h>
@@ -224,8 +226,8 @@ omega_init()
/*
* Just zero the data arrays
*/
- bzero((char *)omegaunits, sizeof omegaunits);
- bzero((char *)unitinuse, sizeof unitinuse);
+ memset((char *)omegaunits, 0, sizeof omegaunits);
+ memset((char *)unitinuse, 0, sizeof unitinuse);
/*
* Initialize fudge factors to default.
@@ -299,9 +301,9 @@ omega_start(unit, peer)
}
}
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
/*
- * POSIX/STREAMS serial line parameters (termios interface)
+ * POSIX serial line parameters (termios interface)
*
* The OMEGACLK option provides timestamping at the driver level.
* It requires the tty_clk streams module.
@@ -334,22 +336,24 @@ omega_start(unit, peer)
"omega_start: tcflush(%s): %m", omegadev);
goto screwed;
}
+ }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
#if defined(OMEGACLK)
- if (ioctl(fd232, I_PUSH, "clk") < 0)
- syslog(LOG_ERR,
- "omega_start: ioctl(%s, I_PUSH, clk): %m", omegadev);
- if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
- syslog(LOG_ERR,
- "omega_start: ioctl(%s, CLK_SETSTR): %m", omegadev);
+ if (ioctl(fd232, I_PUSH, "clk") < 0)
+ syslog(LOG_ERR,
+ "omega_start: ioctl(%s, I_PUSH, clk): %m", omegadev);
+ if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
+ syslog(LOG_ERR,
+ "omega_start: ioctl(%s, CLK_SETSTR): %m", omegadev);
#endif /* OMEGACLK */
#if defined(OMEGAPPS)
- if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
- syslog(LOG_ERR,
- "omega_start: ioctl(%s, I_PUSH, ppsclock): %m", omegadev);
- else
- fdpps = fd232;
+ if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
+ syslog(LOG_ERR,
+ "omega_start: ioctl(%s, I_PUSH, ppsclock): %m", omegadev);
+ else
+ fdpps = fd232;
#endif /* OMEGAPPS */
- }
#endif /* STREAM */
#if defined(HAVE_BSD_TTYS)
/*
@@ -412,7 +416,7 @@ omega_start(unit, peer)
emalloc(sizeof(struct omegaunit));
}
}
- bzero((char *)omega, sizeof(struct omegaunit));
+ memset((char *)omega, 0, sizeof(struct omegaunit));
omegaunits[unit] = omega;
/*
@@ -440,7 +444,7 @@ omega_start(unit, peer)
peer->rootdispersion = 0;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(OMEGAREFID, (char *)&peer->refid, 4);
+ memmove((char *)&peer->refid, OMEGAREFID, 4);
else
peer->refid = htonl(OMEGAHSREFID);
unitinuse[unit] = 1;
@@ -923,8 +927,8 @@ omega_control(unit, in, out)
peer = omega->peer;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(OMEGAREFID, (char *)&peer->refid,
- 4);
+ memmove((char *)&peer->refid,
+ OMEGAREFID, 4);
else
peer->refid = htonl(OMEGAHSREFID);
}
diff --git a/usr.sbin/xntpd/xntpd/refclock_parse.c b/usr.sbin/xntpd/xntpd/refclock_parse.c
index 9e34d6e1595c..69e483764354 100644
--- a/usr.sbin/xntpd/xntpd/refclock_parse.c
+++ b/usr.sbin/xntpd/xntpd/refclock_parse.c
@@ -1,8 +1,8 @@
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS))
/*
- * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.41 1993/11/27 18:44:37 kardel Exp
+ * /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp
*
- * refclock_parse.c,v 3.41 1993/11/27 18:44:37 kardel Exp
+ * refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp
*
* generic reference clock driver for receivers
*
@@ -10,7 +10,7 @@
* available and configured. Currently the STREAMS module
* is only available for Suns running SunOS 4.x and SunOS5.x (new - careful!)
*
- * Copyright (c) 1989,1990,1991,1992,1993
+ * Copyright (c) 1989,1990,1991,1992,1993,1994
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
*
* This program is distributed in the hope that it will be useful,
@@ -29,6 +29,12 @@
* backward compatibilty only)
* PPS - supply loopfilter with PPS samples (if configured)
* PPSPPS - notify loopfilter of PPS file descriptor
+ *
+ * TTY defines:
+ * HAVE_BSD_TTYS - currently unsupported
+ * HAVE_SYSV_TTYS - will use termio.h
+ * HAVE_TERMIOS - will use termios.h
+ * STREAM - will use streams and implies HAVE_TERMIOS
*/
/*
@@ -78,22 +84,28 @@
#include <sys/errno.h>
extern int errno;
-#if !defined(STREAM) && !defined(HAVE_SYSV_TTYS) && !defined(HAVE_BSD_TTYS)
+#if !defined(STREAM) && !defined(HAVE_SYSV_TTYS) && !defined(HAVE_BSD_TTYS) && !defined(HAVE_TERMIOS)
/* #error NEED TO DEFINE ONE OF "STREAM" or "HAVE_SYSV_TTYS" */
-NEED TO DEFINE ONE OF "STREAM" or "HAVE_SYSV_TTYS"
+NEED TO DEFINE ONE OF "STREAM", "HAVE_SYSV_TTYS" or "HAVE_TERMIOS"
#endif
#ifdef STREAM
#include <sys/stream.h>
#include <sys/stropts.h>
-#include <sys/termios.h>
+#ifndef HAVE_TERMIOS
+#define HAVE_TERMIOS
+#endif
+#endif
+
+#ifdef HAVE_TERMIOS
+#include <termios.h>
#define TTY_GETATTR(_FD_, _ARG_) tcgetattr((_FD_), (_ARG_))
#define TTY_SETATTR(_FD_, _ARG_) tcsetattr((_FD_), TCSANOW, (_ARG_))
#undef HAVE_SYSV_TTYS
#endif
#ifdef HAVE_SYSV_TTYS
-#include <sys/termio.h>
+#include <termio.h>
#define TTY_GETATTR(_FD_, _ARG_) ioctl((_FD_), TCGETA, (_ARG_))
#define TTY_SETATTR(_FD_, _ARG_) ioctl((_FD_), TCSETAW, (_ARG_))
#endif
@@ -117,7 +129,7 @@ CURRENTLY NO BSD TTY SUPPORT
#include "parse.h"
#if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__)
-static char rcsid[]="refclock_parse.c,v 3.41 1993/11/27 18:44:37 kardel Exp";
+static char rcsid[]="refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp";
#endif
/**===========================================================================
@@ -231,6 +243,7 @@ struct parseunit
* clock specific configuration
*/
l_fp basedelay; /* clock local phase offset */
+ l_fp ppsdelay; /* clock local pps phase offset */
/*
* clock state handling/reporting
@@ -283,6 +296,7 @@ typedef struct poll_info
#define NO_END (void (*)())0
#define NO_DATA (void *)0
#define NO_FORMAT ""
+#define NO_PPSDELAY 0
#define DCF_ID "DCF" /* generic DCF */
#define DCF_A_ID "DCFa" /* AM demodulation */
@@ -485,6 +499,7 @@ static struct clockinfo
void *cl_data; /* local data area for "poll" mechanism */
u_fp cl_rootdelay; /* rootdelay */
U_LONG cl_basedelay; /* current offset - unsigned l_fp fractional part */
+ U_LONG cl_ppsdelay; /* current PPS offset - unsigned l_fp fractional part */
char *cl_id; /* ID code (usually "DCF") */
char *cl_description; /* device name */
char *cl_format; /* fixed format */
@@ -504,6 +519,7 @@ static struct clockinfo
NO_DATA,
DCFPZF535_ROOTDELAY,
DCFPZF535_BASEDELAY,
+ NO_PPSDELAY,
DCF_P_ID,
DCFPZF535_DESCRIPTION,
NO_FORMAT,
@@ -522,6 +538,7 @@ static struct clockinfo
NO_DATA,
DCFPZF535OCXO_ROOTDELAY,
DCFPZF535OCXO_BASEDELAY,
+ NO_PPSDELAY,
DCF_P_ID,
DCFPZF535OCXO_DESCRIPTION,
NO_FORMAT,
@@ -540,6 +557,7 @@ static struct clockinfo
NO_DATA,
DCFUA31_ROOTDELAY,
DCFUA31_BASEDELAY,
+ NO_PPSDELAY,
DCF_A_ID,
DCFUA31_DESCRIPTION,
NO_FORMAT,
@@ -558,6 +576,7 @@ static struct clockinfo
NO_DATA,
DCF7000_ROOTDELAY,
DCF7000_BASEDELAY,
+ NO_PPSDELAY,
DCF_A_ID,
DCF7000_DESCRIPTION,
NO_FORMAT,
@@ -576,6 +595,7 @@ static struct clockinfo
WSDCF_DATA,
WSDCF_ROOTDELAY,
WSDCF_BASEDELAY,
+ NO_PPSDELAY,
DCF_A_ID,
WSDCF_DESCRIPTION,
WSDCF_FORMAT,
@@ -594,6 +614,7 @@ static struct clockinfo
NO_DATA,
RAWDCF_ROOTDELAY,
CONRAD_BASEDELAY,
+ NO_PPSDELAY,
DCF_A_ID,
CONRAD_DESCRIPTION,
RAWDCF_FORMAT,
@@ -612,6 +633,7 @@ static struct clockinfo
NO_DATA,
RAWDCF_ROOTDELAY,
TIMEBRICK_BASEDELAY,
+ NO_PPSDELAY,
DCF_A_ID,
TIMEBRICK_DESCRIPTION,
RAWDCF_FORMAT,
@@ -630,6 +652,7 @@ static struct clockinfo
GPS166_DATA,
GPS166_ROOTDELAY,
GPS166_BASEDELAY,
+ NO_PPSDELAY,
GPS166_ID,
GPS166_DESCRIPTION,
GPS166_FORMAT,
@@ -648,6 +671,7 @@ static struct clockinfo
TRIMBLESV6_DATA,
TRIMBLESV6_ROOTDELAY,
TRIMBLESV6_BASEDELAY,
+ NO_PPSDELAY,
TRIMBLESV6_ID,
TRIMBLESV6_DESCRIPTION,
TRIMBLESV6_FORMAT,
@@ -1055,7 +1079,9 @@ stream_receive(rbufp)
parse_event(parse, CEVNT_BADREPLY);
return;
}
- bcopy((caddr_t)&rbufp->recv_space, (caddr_t)&parsetime, sizeof(parsetime_t));
+ memmove((caddr_t)&parsetime,
+ (caddr_t)&rbufp->recv_space,
+ sizeof(parsetime_t));
/*
* switch time stamp world - be sure to normalize small usec field
@@ -1996,7 +2022,7 @@ cparse_statistics(peer)
static void
parse_init()
{
- bzero((caddr_t)parseunits, sizeof parseunits);
+ memset((caddr_t)parseunits, 0, sizeof parseunits);
}
@@ -2075,7 +2101,7 @@ parse_start(sysunit, peer)
{
u_int unit;
int fd232, i;
-#ifdef STREAM
+#ifdef HAVE_TERMIOS
struct termios tm; /* NEEDED FOR A LONG TIME ! */
#endif
#ifdef HAVE_SYSV_TTYS
@@ -2156,7 +2182,7 @@ parse_start(sysunit, peer)
}
}
- bzero((char *)parse, sizeof(struct parseunit));
+ memset((char *)parse, 0, sizeof(struct parseunit));
parseunits[unit] = parse;
/*
@@ -2186,12 +2212,15 @@ parse_start(sysunit, peer)
parse->basedelay.l_ui = 0; /* we can only pre-configure delays less than 1 second */
parse->basedelay.l_uf = parse->parse_type->cl_basedelay;
+ parse->ppsdelay.l_ui = 0; /* we can only pre-configure delays less than 1 second */
+ parse->ppsdelay.l_uf = parse->parse_type->cl_ppsdelay;
+
peer->rootdelay = parse->parse_type->cl_rootdelay;
peer->sstclktype = parse->parse_type->cl_type;
peer->precision = sys_precision;
peer->stratum = STRATUM_REFCLOCK;
if (peer->stratum <= 1)
- bcopy(parse->parse_type->cl_id, (char *)&peer->refid, 4);
+ memmove((char *)&peer->refid, parse->parse_type->cl_id, 4);
else
peer->refid = htonl(PARSEHSREFID);
@@ -2220,7 +2249,7 @@ parse_start(sysunit, peer)
else
{
#ifndef _PC_VDISABLE
- bzero((char *)tm.c_cc, sizeof(tm.c_cc));
+ memset((char *)tm.c_cc, 0, sizeof(tm.c_cc));
#else
int disablec;
errno = 0; /* pathconf can deliver -1 without changing errno ! */
@@ -2542,6 +2571,7 @@ parse_control(unit, in, out)
out->badformat = out->baddata = 0;
out->timereset = 0;
out->currentstatus = out->lastevent = CEVNT_NOMINAL;
+ out->kv_list = (struct ctl_var *)0;
}
if (unit >= MAXUNITS)
@@ -2567,14 +2597,16 @@ parse_control(unit, in, out)
if (in->haveflags & CLK_HAVETIME2)
{
- /* not USED */
+ parse->ppsdelay = in->fudgetime2;
}
if (in->haveflags & CLK_HAVEVAL1)
{
parse->peer->stratum = (u_char)(in->fudgeval1 & 0xf);
if (parse->peer->stratum <= 1)
- bcopy(parse->parse_type->cl_id, (char *)&parse->peer->refid, 4);
+ memmove((char *)&parse->peer->refid,
+ parse->parse_type->cl_id,
+ 4);
else
parse->peer->refid = htonl(PARSEHSREFID);
}
@@ -2607,19 +2639,21 @@ parse_control(unit, in, out)
if (out)
{
register unsigned LONG sum = 0;
- register char *t;
+ register char *t, *tt;
register struct tm *tm;
register short utcoff;
register char sign;
register int i;
time_t tim;
- out->haveflags = CLK_HAVETIME1|CLK_HAVEVAL1|CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3;
+ outstatus[0] = '\0';
+
+ out->haveflags = CLK_HAVETIME1|CLK_HAVETIME2|CLK_HAVEVAL1|CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3;
out->clockdesc = parse->parse_type->cl_description;
out->fudgetime1 = parse->basedelay;
- L_CLR(&out->fudgetime2);
+ out->fudgetime2 = parse->ppsdelay;
out->fudgeval1 = (LONG)parse->peer->stratum;
@@ -2645,11 +2679,17 @@ parse_control(unit, in, out)
*/
off = parse->time.parse_stime.fp;
L_SUB(&off, &parse->time.parse_ptime.fp); /* true offset */
- out->fudgetime2 = off;
- out->haveflags |= CLK_HAVETIME2;
+ tt = add_var(&out->kv_list, 40, RO);
+ sprintf(tt, "refclock_ppsskew=%s", lfptoms(&off, 6));
}
}
+ if (PARSE_PPS(parse->time.parse_state))
+ {
+ tt = add_var(&out->kv_list, 80, RO|DEF);
+ sprintf(tt, "refclock_ppstime=\"%s\"", prettydate(&parse->time.parse_ptime.fp));
+ }
+
/*
* all this for just finding out the +-xxxx part (there are always
* new and changing fields in the standards 8-().
@@ -2674,17 +2714,20 @@ parse_control(unit, in, out)
sign = '+';
}
- tim = parse->time.parse_time.fp.l_ui - JAN_1970;
- strcpy(outstatus, ctime(&tim));
- t = strrchr(outstatus, '\n');
- if (!t)
+ tt = add_var(&out->kv_list, 128, RO|DEF);
+ sprintf(tt, "refclock_time=\"");
+ tt += strlen(tt);
+
+ if (parse->time.parse_time.fp.l_ui == 0)
{
- t = outstatus + strlen(outstatus);
- }
+ strcpy(tt, "<UNDEFINED>\"");
+ }
else
{
- sprintf(t, " %c%02d%02d", sign, utcoff / 60, utcoff % 60);
- t += strlen(t);
+ strcpy(tt, prettydate(&parse->time.parse_time.fp));
+ t = tt + strlen(tt);
+
+ sprintf(t, " (%c%02d%02d)\"", sign, utcoff / 60, utcoff % 60);
}
if (!PARSE_GETTIMECODE(parse, &tmpctl))
@@ -2693,27 +2736,24 @@ parse_control(unit, in, out)
}
else
{
+ tt = add_var(&out->kv_list, 128, RO|DEF);
+ sprintf(tt, "refclock_status=\"");
+ tt += strlen(tt);
+
/*
* copy PPS flags from last read transaction (informational only)
*/
tmpctl.parsegettc.parse_state |= parse->time.parse_state &
(PARSEB_PPS|PARSEB_S_PPS);
- if (t)
- {
- *t = ' ';
- (void) parsestate(tmpctl.parsegettc.parse_state, t+1);
- }
- else
- {
- strcat(outstatus, " ");
- (void) parsestate(tmpctl.parsegettc.parse_state, outstatus + strlen(outstatus));
- }
- strcat(outstatus," <");
+ (void) parsestate(tmpctl.parsegettc.parse_state, tt);
+
+ strcat(tt, "\"");
+
if (tmpctl.parsegettc.parse_count)
- mkascii(outstatus+strlen(outstatus), sizeof(outstatus) - strlen(outstatus) - 1,
+ mkascii(outstatus+strlen(outstatus), sizeof(outstatus)- strlen(outstatus) - 1,
tmpctl.parsegettc.parse_buffer, tmpctl.parsegettc.parse_count - 1);
- strcat(outstatus,">");
+
parse->badformat += tmpctl.parsegettc.parse_badformat;
}
@@ -2725,16 +2765,20 @@ parse_control(unit, in, out)
}
else
{
- strcat(outstatus," (");
- strncat(outstatus, tmpctl.parseformat.parse_buffer, tmpctl.parseformat.parse_count);
- strcat(outstatus,")");
+ tt = add_var(&out->kv_list, 80, RO|DEF);
+ sprintf(tt, "refclock_format=\"");
+
+ strncat(tt, tmpctl.parseformat.parse_buffer, tmpctl.parseformat.parse_count);
+ strcat(tt,"\"");
}
/*
* gather state statistics
*/
- t = outstatus + strlen(outstatus);
+ tt = add_var(&out->kv_list, 200, RO|DEF);
+ strcpy(tt, "refclock_states=\"");
+ tt += strlen(tt);
for (i = 0; i <= CEVNT_MAX; i++)
{
@@ -2757,18 +2801,27 @@ parse_control(unit, in, out)
if (stime)
{
- sprintf(t, "%s%s%s: %s (%d.%02d%%)",
- sum ? "; " : " [",
+ sprintf(tt, "%s%s%s: %s (%d.%02d%%)",
+ sum ? "; " : "",
(parse->status == i) ? "*" : "",
clockstatus(i),
l_mktime(stime),
percent / 100, percent % 100);
sum += stime;
- t += strlen(t);
+ tt += strlen(tt);
}
}
- sprintf(t, "; running time: %s]", l_mktime(sum));
+ sprintf(tt, "; running time: %s\"", l_mktime(sum));
+
+ tt = add_var(&out->kv_list, 32, RO);
+ sprintf(tt, "refclock_id=\"%s\"", parse->parse_type->cl_id);
+
+ tt = add_var(&out->kv_list, 80, RO);
+ sprintf(tt, "refclock_iomode=\"%s\"", parse->binding->bd_description);
+
+ tt = add_var(&out->kv_list, 128, RO);
+ sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp\"");
out->lencode = strlen(outstatus);
out->lastcode = outstatus;
@@ -3074,6 +3127,8 @@ parse_process(parse, parsetime)
*/
offset = parsetime->parse_ptime.fp;
+ L_ADD(&offset, &parse->ppsdelay);
+
if (PARSE_TIMECODE(parsetime->parse_state))
{
if (M_ISGEQ(off.l_i, off.l_f, -1, 0x80000000) &&
@@ -3136,7 +3191,7 @@ parse_process(parse, parsetime)
}
-#if defined(PPS) || defined(PPSCLK) || defined(PPSPPS)
+#if defined(PPS) || defined(PPSCLK) || defined(PPSPPS) || defined(PARSEPPS)
if (CL_PPS(parse->unit) && !parse->pollonly && PARSE_SYNC(parsetime->parse_state))
{
/*
@@ -3150,7 +3205,7 @@ parse_process(parse, parsetime)
#endif
(void) pps_sample(&off);
}
-#endif /* PPS || PPSCLK || PPSPPS */
+#endif /* PPS || PPSCLK || PPSPPS || PARSEPPS */
/*
* ready, unless the machine wants a sample
@@ -3267,7 +3322,7 @@ poll_init(parse)
if (((poll_info_t *)parse->parse_type->cl_data)->rate)
{
parse->localdata = (void *)malloc(sizeof(poll_timer_t));
- bzero((char *)parse->localdata, sizeof(poll_timer_t));
+ memset((char *)parse->localdata, 0, sizeof(poll_timer_t));
pt = (poll_timer_t *)parse->localdata;
@@ -3309,7 +3364,7 @@ static int
trimble_init(parse)
struct parseunit *parse;
{
-#ifdef STREAM
+#ifdef HAVE_TERMIOS
struct termios tm;
#endif
#ifdef HAVE_SYSV_TTYS
@@ -3341,6 +3396,18 @@ trimble_init(parse)
* History:
*
* refclock_parse.c,v
+ * Revision 3.45 1994/01/25 19:06:27 kardel
+ * 94/01/23 reconcilation
+ *
+ * Revision 3.44 1994/01/25 17:32:23 kardel
+ * settable extended variables
+ *
+ * Revision 3.43 1994/01/23 16:28:39 kardel
+ * HAVE_TERMIOS introduced
+ *
+ * Revision 3.42 1994/01/22 11:35:04 kardel
+ * added HAVE_TERMIOS
+ *
* Revision 3.41 1993/11/27 18:44:37 kardel
* can't trust GPS166 on unsync
*
diff --git a/usr.sbin/xntpd/xntpd/refclock_pst.c b/usr.sbin/xntpd/xntpd/refclock_pst.c
index e72ac8bf082a..4b8909afb801 100644
--- a/usr.sbin/xntpd/xntpd/refclock_pst.c
+++ b/usr.sbin/xntpd/xntpd/refclock_pst.c
@@ -20,8 +20,10 @@
#include <termio.h>
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
#include <termios.h>
+#endif
+#if defined(STREAM)
#include <stropts.h>
#if defined(PSTCLK)
#include <sys/clkdefs.h>
@@ -435,8 +437,8 @@ pst_init()
/*
* Just zero the data arrays
*/
- bzero((char *)pstunits, sizeof pstunits);
- bzero((char *)unitinuse, sizeof unitinuse);
+ memset((char *)pstunits, 0, sizeof pstunits);
+ memset((char *)unitinuse, 0, sizeof unitinuse);
/*
* Initialize fudge factors to default.
@@ -513,9 +515,9 @@ pst_start(unit, peer)
}
}
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
/*
- * POSIX/STREAMS serial line parameters (termios interface)
+ * POSIX serial line parameters (termios interface)
*
* The PSTCLK option provides timestamping at the driver level.
* It requires the tty_clk streams module.
@@ -548,22 +550,24 @@ pst_start(unit, peer)
"pst_start: tcflush(%s): %m", pstdev);
goto screwed;
}
+ }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
#if defined(PSTCLK)
- if (ioctl(fd232, I_PUSH, "clk") < 0)
- syslog(LOG_ERR,
- "pst_start: ioctl(%s, I_PUSH, clk): %m", pstdev);
- if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
- syslog(LOG_ERR,
- "pst_start: ioctl(%s, CLK_SETSTR): %m", pstdev);
+ if (ioctl(fd232, I_PUSH, "clk") < 0)
+ syslog(LOG_ERR,
+ "pst_start: ioctl(%s, I_PUSH, clk): %m", pstdev);
+ if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
+ syslog(LOG_ERR,
+ "pst_start: ioctl(%s, CLK_SETSTR): %m", pstdev);
#endif /* PSTCLK */
#if defined(PSTPPS)
- if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
- syslog(LOG_ERR,
- "pst_start: ioctl(%s, I_PUSH, ppsclock): %m", pstdev);
- else
- fdpps = fd232;
+ if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
+ syslog(LOG_ERR,
+ "pst_start: ioctl(%s, I_PUSH, ppsclock): %m", pstdev);
+ else
+ fdpps = fd232;
#endif /* PSTPPS */
- }
#endif /* STREAM */
#if defined(HAVE_BSD_TTYS)
/*
@@ -625,7 +629,7 @@ pst_start(unit, peer)
pst = (struct pstunit *)emalloc(sizeof(struct pstunit));
}
}
- bzero((char *)pst, sizeof(struct pstunit));
+ memset((char *)pst, 0, sizeof(struct pstunit));
pstunits[unit] = pst;
/*
@@ -658,7 +662,7 @@ pst_start(unit, peer)
peer->rootdispersion = 0;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(WWVREFID, (char *)&peer->refid, 4);
+ memmove((char *)&peer->refid, WWVREFID, 4);
else
peer->refid = htonl(PSTHSREFID);
pst->psttimer.event_time = current_time + PSTMINTIMEOUT;
@@ -1456,9 +1460,9 @@ pst_process(pst)
*/
if (stratumtouse[pst->unit] <= 1) {
if (pst->station >= 0)
- bcopy(WWVREFID, (char *)&pst->peer->refid, 4);
+ memmove((char *)&pst->peer->refid, WWVREFID, 4);
else
- bcopy(WWVHREFID, (char *)&pst->peer->refid, 4);
+ memmove((char *)&pst->peer->refid, WWVHREFID, 4);
}
/*
diff --git a/usr.sbin/xntpd/xntpd/refclock_tpro.c b/usr.sbin/xntpd/xntpd/refclock_tpro.c
index 59881800bd63..54d9f3cb5287 100644
--- a/usr.sbin/xntpd/xntpd/refclock_tpro.c
+++ b/usr.sbin/xntpd/xntpd/refclock_tpro.c
@@ -130,8 +130,8 @@ tpro_init()
/*
* Just zero the data arrays
*/
- bzero((char *)tprounits, sizeof tprounits);
- bzero((char *)unitinuse, sizeof unitinuse);
+ memset((char *)tprounits, 0, sizeof tprounits);
+ memset((char *)unitinuse, 0, sizeof unitinuse);
/*
* Initialize fudge factors to default.
@@ -200,7 +200,7 @@ tpro_start(unit, peer)
emalloc(sizeof(struct tprounit));
}
}
- bzero((char *)tpro, sizeof(struct tprounit));
+ memset((char *)tpro, 0, sizeof(struct tprounit));
tprounits[unit] = tpro;
/*
@@ -225,7 +225,7 @@ tpro_start(unit, peer)
peer->rootdispersion = 0;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(TPROREFID, (char *)&peer->refid, 4);
+ memmove((char *)&peer->refid, TPROREFID, 4);
else
peer->refid = htonl(TPROHSREFID);
unitinuse[unit] = 1;
@@ -415,8 +415,8 @@ tpro_control(unit, in, out)
peer = tpro->peer;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(TPROREFID, (char *)&peer->refid,
- 4);
+ memmove((char *)&peer->refid,
+ TPROREFID, 4);
else
peer->refid = htonl(TPROHSREFID);
}
diff --git a/usr.sbin/xntpd/xntpd/refclock_wwvb.c b/usr.sbin/xntpd/xntpd/refclock_wwvb.c
index 602eee0ee424..9b2563a797db 100644
--- a/usr.sbin/xntpd/xntpd/refclock_wwvb.c
+++ b/usr.sbin/xntpd/xntpd/refclock_wwvb.c
@@ -20,8 +20,10 @@
#include <termio.h>
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
#include <termios.h>
+#endif
+#if defined(STREAM)
#include <stropts.h>
#if defined(WWVBCLK)
#include <sys/clkdefs.h>
@@ -217,8 +219,8 @@ wwvb_init()
/*
* Just zero the data arrays
*/
- bzero((char *)wwvbunits, sizeof wwvbunits);
- bzero((char *)unitinuse, sizeof unitinuse);
+ memset((char *)wwvbunits, 0, sizeof wwvbunits);
+ memset((char *)unitinuse, 0, sizeof unitinuse);
/*
* Initialize fudge factors to default.
@@ -290,9 +292,9 @@ wwvb_start(unit, peer)
}
}
#endif /* HAVE_SYSV_TTYS */
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
/*
- * POSIX/STREAMS serial line parameters (termios interface)
+ * POSIX serial line parameters (termios interface)
*
* The WWVBCLK option provides timestamping at the driver level.
* It requires the tty_clk streams module.
@@ -325,22 +327,24 @@ wwvb_start(unit, peer)
"wwvb_start: tcflush(%s): %m", wwvbdev);
goto screwed;
}
+ }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
#if defined(WWVBCLK)
- if (ioctl(fd232, I_PUSH, "clk") < 0)
- syslog(LOG_ERR,
- "wwvb_start: ioctl(%s, I_PUSH, clk): %m", wwvbdev);
- if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
- syslog(LOG_ERR,
- "wwvb_start: ioctl(%s, CLK_SETSTR): %m", wwvbdev);
+ if (ioctl(fd232, I_PUSH, "clk") < 0)
+ syslog(LOG_ERR,
+ "wwvb_start: ioctl(%s, I_PUSH, clk): %m", wwvbdev);
+ if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
+ syslog(LOG_ERR,
+ "wwvb_start: ioctl(%s, CLK_SETSTR): %m", wwvbdev);
#endif /* WWVBCLK */
#if defined(WWVBPPS)
- if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
- syslog(LOG_ERR,
- "wwvb_start: ioctl(%s, I_PUSH, ppsclock): %m", wwvbdev);
- else
- fdpps = fd232;
+ if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
+ syslog(LOG_ERR,
+ "wwvb_start: ioctl(%s, I_PUSH, ppsclock): %m", wwvbdev);
+ else
+ fdpps = fd232;
#endif /* WWVBPPS */
- }
#endif /* STREAM */
#if defined(HAVE_BSD_TTYS)
/*
@@ -403,7 +407,7 @@ wwvb_start(unit, peer)
emalloc(sizeof(struct wwvbunit));
}
}
- bzero((char *)wwvb, sizeof(struct wwvbunit));
+ memset((char *)wwvb, 0, sizeof(struct wwvbunit));
wwvbunits[unit] = wwvb;
/*
@@ -431,7 +435,7 @@ wwvb_start(unit, peer)
peer->rootdispersion = 0;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(WWVBREFID, (char *)&peer->refid, 4);
+ memmove((char *)&peer->refid, WWVBREFID, 4);
else
peer->refid = htonl(WWVBHSREFID);
unitinuse[unit] = 1;
@@ -952,8 +956,8 @@ wwvb_control(unit, in, out)
peer = wwvb->peer;
peer->stratum = stratumtouse[unit];
if (stratumtouse[unit] <= 1)
- bcopy(WWVBREFID, (char *)&peer->refid,
- 4);
+ memmove((char *)&peer->refid,
+ WWVBREFID, 4);
else
peer->refid = htonl(WWVBHSREFID);
}
diff --git a/usr.sbin/xntpd/xntpdc/ntpdc.c b/usr.sbin/xntpd/xntpdc/ntpdc.c
index c5fdf72eb7cb..001bd77c1e55 100644
--- a/usr.sbin/xntpd/xntpdc/ntpdc.c
+++ b/usr.sbin/xntpd/xntpdc/ntpdc.c
@@ -53,7 +53,7 @@ static int findcmd P((char *, struct xcmd *, struct xcmd *, struct xcmd **));
static int getarg P((char *, int, arg_v *));
static int getnetnum P((char *, U_LONG *, char *));
static void help P((struct parse *, FILE *));
-#if defined(sgi)
+#if defined(sgi) || defined(SYS_BSDI)
static int helpsort P((const void *, const void *));
#else
static int helpsort P((char **, char **));
@@ -221,17 +221,17 @@ char *argv[];
{
int c;
int errflg = 0;
- extern int optind;
- extern char *optarg;
+ extern int ntp_optind;
+ extern char *ntp_optarg;
delay_time.l_ui = 0;
delay_time.l_uf = DEFDELAY;
progname = argv[0];
- while ((c = getopt_l(argc, argv, "c:dilnps")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "c:dilnps")) != EOF)
switch (c) {
case 'c':
- ADDCMD(optarg);
+ ADDCMD(ntp_optarg);
break;
case 'd':
++debug;
@@ -261,11 +261,11 @@ char *argv[];
progname);
exit(2);
}
- if (optind == argc) {
+ if (ntp_optind == argc) {
ADDHOST(DEFHOST);
} else {
- for (; optind < argc; optind++)
- ADDHOST(argv[optind]);
+ for (; ntp_optind < argc; ntp_optind++)
+ ADDHOST(argv[ntp_optind]);
}
if (numcmds == 0 && interactive == 0
@@ -439,7 +439,7 @@ getresponse(implcode, reqcode, ritems, rsize, rdata)
numrecv = 0;
*rdata = datap = pktdata;
lastseq = 999; /* too big to be a sequence number */
- bzero(haveseq, sizeof(haveseq));
+ memset(haveseq, 0, sizeof(haveseq));
FD_ZERO(&fds);
again:
@@ -600,7 +600,7 @@ again:
*/
if ((datap + datasize) > (pktdata + pktdatasize))
growpktdata();
- bcopy((char *)rpkt.data, datap, datasize);
+ memmove(datap, (char *)rpkt.data, datasize);
datap += datasize;
if (firstpkt) {
firstpkt = 0;
@@ -634,7 +634,7 @@ sendrequest(implcode, reqcode, auth, qitems, qsize, qdata)
struct req_pkt qpkt;
int datasize;
- bzero((char *)&qpkt, sizeof qpkt);
+ memset((char *)&qpkt, 0, sizeof qpkt);
qpkt.rm_vn_mode = RM_VN_MODE(0, 0);
qpkt.implementation = (u_char)implcode;
@@ -642,7 +642,7 @@ sendrequest(implcode, reqcode, auth, qitems, qsize, qdata)
datasize = qitems * qsize;
if (datasize != 0 && qdata != NULL) {
- bcopy(qdata, (char *)qpkt.data, datasize);
+ memmove((char *)qpkt.data, qdata, datasize);
qpkt.err_nitems = ERR_NITEMS(0, qitems);
qpkt.mbz_itemsize = MBZ_ITEMSIZE(qsize);
} else {
@@ -1091,7 +1091,7 @@ getnetnum(host, num, fullhost)
}
return 1;
} else if ((hp = gethostbyname(host)) != 0) {
- bcopy(hp->h_addr, (char *)num, sizeof(U_LONG));
+ memmove((char *)num, hp->h_addr, sizeof(U_LONG));
if (fullhost != 0)
(void) strcpy(fullhost, hp->h_name);
return 1;
@@ -1149,7 +1149,7 @@ help(pcmd, fp)
for (xcp = opcmds; xcp->keyword != 0; xcp++)
cmdsort[n++] = xcp->keyword;
-#if defined(sgi)
+#if defined(sgi) || defined(SYS_BSDI)
qsort((void *)cmdsort, n, sizeof(char *), helpsort);
#else
qsort((char *)cmdsort, n, sizeof(char *), helpsort);
@@ -1195,7 +1195,7 @@ help(pcmd, fp)
* helpsort - do hostname qsort comparisons
*/
static int
-#if defined(sgi)
+#if defined(sgi) || defined(SYS_BSDI)
helpsort(t1, t2)
const void *t1;
const void *t2;
@@ -1207,7 +1207,7 @@ helpsort(name1, name2)
char **name1;
char **name2;
{
-#endif /* sgi */
+#endif /* sgi || bsdi */
return strcmp(*name1, *name2);
}
diff --git a/usr.sbin/xntpd/xntpdc/ntpdc_ops.c b/usr.sbin/xntpd/xntpdc/ntpdc_ops.c
index 26f7e91d8fa3..55483faeba10 100644
--- a/usr.sbin/xntpd/xntpdc/ntpdc_ops.c
+++ b/usr.sbin/xntpd/xntpdc/ntpdc_ops.c
@@ -442,7 +442,7 @@ printpeer(pp, fp)
if (pp->stratum <= 1) {
junk[4] = 0;
- bcopy((char *)&pp->refid, junk, 4);
+ memmove(junk, (char *)&pp->refid, 4);
str = junk;
} else {
str = numtoa(pp->refid);
@@ -788,7 +788,7 @@ sysinfo(pcmd, fp)
ufptoa(NTOHS_FP(is->rootdispersion), 4));
if (is->stratum <= 1) {
junk[4] = 0;
- bcopy((char *)&is->refid, junk, 4);
+ memmove(junk, (char *)&is->refid, 4);
str = junk;
} else {
str = numtoa(is->refid);
@@ -2192,7 +2192,7 @@ fudge(pcmd, fp)
err = 0;
- bzero((char *)&fudgedata, sizeof fudgedata);
+ memset((char *)&fudgedata, 0, sizeof fudgedata);
fudgedata.clockadr = pcmd->argval[0].netnum;
if (STREQ(pcmd->argval[1].string, "time1")) {
diff --git a/usr.sbin/xntpd/xntpres/xntpres.c b/usr.sbin/xntpd/xntpres/xntpres.c
index cf0d850bd888..ee88b1f3be98 100644
--- a/usr.sbin/xntpd/xntpres/xntpres.c
+++ b/usr.sbin/xntpd/xntpres/xntpres.c
@@ -148,7 +148,7 @@ main(argc, argv)
int errflg = 0;
char *cp;
FILE *in;
- extern int optind;
+ extern int ntp_optind;
progname = argv[0];
@@ -180,7 +180,7 @@ main(argc, argv)
syslog(LOG_NOTICE, Version);
- while ((c = getopt_l(argc, argv, "dr")) != EOF)
+ while ((c = ntp_getopt(argc, argv, "dr")) != EOF)
switch (c) {
case 'd':
++debug;
@@ -192,20 +192,20 @@ main(argc, argv)
errflg++;
break;
}
- if (errflg || (optind + 3) != argc) {
+ if (errflg || (ntp_optind + 3) != argc) {
(void) fprintf(stderr,
"usage: %s [-d] [-r] keyid keyfile conffile\n", progname);
syslog(LOG_ERR, "exiting due to usage error");
exit(2);
}
- if (!atouint(argv[optind], &req_keyid)) {
- syslog(LOG_ERR, "undecodeable keyid %s", argv[optind]);
+ if (!atouint(argv[ntp_optind], &req_keyid)) {
+ syslog(LOG_ERR, "undecodeable keyid %s", argv[ntp_optind]);
exit(1);
}
- keyfile = argv[optind+1];
- conffile = argv[optind+2];
+ keyfile = argv[ntp_optind+1];
+ conffile = argv[ntp_optind+2];
/*
* Make sure we have the key we need
@@ -353,7 +353,7 @@ addentry(name, mode, version, minpoll, maxpoll, flags, keyid)
len = strlen(name) + 1;
cp = emalloc((unsigned)len);
- bcopy(name, cp, len);
+ memmove(cp, name, len);
ce = (struct conf_entry *)emalloc(sizeof(struct conf_entry));
ce->ce_name = cp;
@@ -408,7 +408,7 @@ findhostaddr(entry)
if (h_errno == TRY_AGAIN)
return 1;
#endif
- return 0;
+ return (0);
}
/*
@@ -416,9 +416,10 @@ findhostaddr(entry)
* tell preferences and older gethostbyname() implementations
* only return one.
*/
- (void) bcopy(hp->h_addr, (char *)&(entry->ce_peeraddr),
- sizeof(struct in_addr));
- return 1;
+ memmove((char *)&(entry->ce_peeraddr),
+ hp->h_addr,
+ sizeof(struct in_addr));
+ return (1);
}
@@ -439,7 +440,7 @@ openntp()
exit(1);
}
- bzero((char *)&saddr, sizeof(saddr));
+ memset((char *)&saddr, 0, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_port = htons(NTP_PORT); /* trash */
saddr.sin_addr.s_addr = htonl(LOCALHOST); /* garbage */
@@ -499,7 +500,7 @@ request(conf)
/*
* Make up a request packet with the configuration info
*/
- bzero((char *)&reqpkt, sizeof(reqpkt));
+ memset((char *)&reqpkt, 0, sizeof(reqpkt));
reqpkt.rm_vn_mode = RM_VN_MODE(0, 0);
reqpkt.auth_seq = AUTH_SEQ(1, 0); /* authenticated, no seq */
@@ -507,7 +508,7 @@ request(conf)
reqpkt.request = REQ_CONFIG; /* configure a new peer */
reqpkt.err_nitems = ERR_NITEMS(0, 1); /* one item */
reqpkt.mbz_itemsize = MBZ_ITEMSIZE(sizeof(struct conf_peer));
- bcopy((char *)conf, reqpkt.data, sizeof(struct conf_peer));
+ memmove(reqpkt.data, (char *)conf, sizeof(struct conf_peer));
reqpkt.keyid = htonl(req_keyid);
auth1crypt(req_keyid, (U_LONG *)&reqpkt, REQ_LEN_NOMAC);