xntpd version 3.3z from UDel
authorGarrett Wollman <wollman@FreeBSD.org>
Thu, 3 Feb 1994 22:09:07 +0000 (22:09 +0000)
committerGarrett Wollman <wollman@FreeBSD.org>
Thu, 3 Feb 1994 22:09:07 +0000 (22:09 +0000)
141 files changed:
contrib/xntpd/COPYRIGHT
contrib/xntpd/Config.local.dist
contrib/xntpd/Makefile
contrib/xntpd/README
contrib/xntpd/RELNOTES
contrib/xntpd/TODO
contrib/xntpd/VERSION
contrib/xntpd/adjtime/adjtimed.c
contrib/xntpd/authstuff/authspeed.c
contrib/xntpd/authstuff/keyparity.c
contrib/xntpd/authstuff/makeIPFP.c
contrib/xntpd/authstuff/makePC1.c
contrib/xntpd/authstuff/makePC2.c
contrib/xntpd/authstuff/makeSP.c
contrib/xntpd/authstuff/md5driver.c
contrib/xntpd/authstuff/mkrandkeys.c
contrib/xntpd/authstuff/omakeIPFP.c
contrib/xntpd/clockstuff/chutest.c
contrib/xntpd/clockstuff/clktest.c
contrib/xntpd/clockstuff/propdelay.c
contrib/xntpd/compilers/domainos.cc [new file with mode: 0644]
contrib/xntpd/conf/Config.CHATHAM
contrib/xntpd/conf/Config.MONOMOY
contrib/xntpd/conf/Config.TIGER
contrib/xntpd/conf/Config.TRURO
contrib/xntpd/conf/Config.local
contrib/xntpd/doc/xntpd.8
contrib/xntpd/hints/linux [new file with mode: 0644]
contrib/xntpd/hints/sun4 [new file with mode: 0644]
contrib/xntpd/include/l_stdlib.h
contrib/xntpd/include/ntp.h
contrib/xntpd/include/ntp_control.h
contrib/xntpd/include/ntp_filegen.h
contrib/xntpd/include/ntp_machine.h
contrib/xntpd/include/ntp_refclock.h
contrib/xntpd/include/ntp_select.h
contrib/xntpd/include/ntp_stdlib.h
contrib/xntpd/include/ntp_string.h
contrib/xntpd/include/ntpd.h
contrib/xntpd/include/parse.h
contrib/xntpd/include/parse_conf.h
contrib/xntpd/include/sys/parsestreams.h
contrib/xntpd/kernel/Makefile.tmpl
contrib/xntpd/kernel/tty_chu_STREAMS.c
contrib/xntpd/kernel/tty_clk_STREAMS.c
contrib/xntpd/lib/a_md512crypt.c
contrib/xntpd/lib/a_md5decrypt.c
contrib/xntpd/lib/a_md5encrypt.c
contrib/xntpd/lib/authdes.c
contrib/xntpd/lib/authdes.c.export
contrib/xntpd/lib/authkeys.c
contrib/xntpd/lib/authusekey.c
contrib/xntpd/lib/clocktypes.c
contrib/xntpd/lib/dofptoa.c
contrib/xntpd/lib/dolfptoa.c
contrib/xntpd/lib/getopt.c
contrib/xntpd/lib/machines.c
contrib/xntpd/lib/msyslog.c
contrib/xntpd/lib/numtohost.c
contrib/xntpd/lib/systime.c
contrib/xntpd/machines/README
contrib/xntpd/machines/aix3.2
contrib/xntpd/machines/bsdi
contrib/xntpd/machines/dell.svr4 [new file with mode: 0644]
contrib/xntpd/machines/domainos [new file with mode: 0644]
contrib/xntpd/machines/freebsd
contrib/xntpd/machines/hpux
contrib/xntpd/machines/hpux10+
contrib/xntpd/machines/i386svr4
contrib/xntpd/machines/linux
contrib/xntpd/machines/netbsd
contrib/xntpd/machines/ptx
contrib/xntpd/machines/sequent
contrib/xntpd/machines/sunos5.1
contrib/xntpd/machines/sunos5.2
contrib/xntpd/machines/svr4
contrib/xntpd/ntpdate/ntpdate.c
contrib/xntpd/ntpq/ntpq.c
contrib/xntpd/ntpq/ntpq_ops.c
contrib/xntpd/ntptrace/ntptrace.c
contrib/xntpd/parse/Makefile.kernel
contrib/xntpd/parse/Makefile.tmpl
contrib/xntpd/parse/clk_dcf7000.c
contrib/xntpd/parse/clk_meinberg.c
contrib/xntpd/parse/clk_rawdcf.c
contrib/xntpd/parse/clk_schmid.c
contrib/xntpd/parse/clk_trimble.c
contrib/xntpd/parse/parse.c
contrib/xntpd/parse/parse_conf.c
contrib/xntpd/parse/parsesolaris.c
contrib/xntpd/parse/parsestreams.c
contrib/xntpd/parse/util/Makefile.tmpl
contrib/xntpd/parse/util/dcfd.c
contrib/xntpd/parse/util/parsetest.c
contrib/xntpd/parse/util/testdcf.c
contrib/xntpd/ppsclock/ppstest/ppstest.c
contrib/xntpd/ppsclock/sys/sundev/ppsclock.c
contrib/xntpd/refclocks/Dependencies
contrib/xntpd/refclocks/rclk.GPSTM [new file with mode: 0644]
contrib/xntpd/refclocks/rclk.PARSE
contrib/xntpd/refclocks/rconfig
contrib/xntpd/scripts/Guess.sh
contrib/xntpd/scripts/autoconf
contrib/xntpd/scripts/stats/clock.awk
contrib/xntpd/scripts/stats/summary.sh
contrib/xntpd/util/Makefile.tmpl
contrib/xntpd/util/ntptime.c
contrib/xntpd/util/tickadj.c
contrib/xntpd/xntpd/Makefile.tmpl
contrib/xntpd/xntpd/ntp_config.c
contrib/xntpd/xntpd/ntp_control.c
contrib/xntpd/xntpd/ntp_filegen.c
contrib/xntpd/xntpd/ntp_intres.c
contrib/xntpd/xntpd/ntp_io.c
contrib/xntpd/xntpd/ntp_loopfilter.c
contrib/xntpd/xntpd/ntp_monitor.c
contrib/xntpd/xntpd/ntp_peer.c
contrib/xntpd/xntpd/ntp_proto.c
contrib/xntpd/xntpd/ntp_request.c
contrib/xntpd/xntpd/ntp_restrict.c
contrib/xntpd/xntpd/ntp_unixclock.c
contrib/xntpd/xntpd/ntp_util.c
contrib/xntpd/xntpd/ntpd.c
contrib/xntpd/xntpd/refclock_as2201.c
contrib/xntpd/xntpd/refclock_chu.c
contrib/xntpd/xntpd/refclock_conf.c
contrib/xntpd/xntpd/refclock_goes.c
contrib/xntpd/xntpd/refclock_gpstm.c [new file with mode: 0644]
contrib/xntpd/xntpd/refclock_irig.c
contrib/xntpd/xntpd/refclock_leitch.c
contrib/xntpd/xntpd/refclock_local.c
contrib/xntpd/xntpd/refclock_msfees.c
contrib/xntpd/xntpd/refclock_mx4200.c
contrib/xntpd/xntpd/refclock_omega.c
contrib/xntpd/xntpd/refclock_parse.c
contrib/xntpd/xntpd/refclock_pst.c
contrib/xntpd/xntpd/refclock_tpro.c
contrib/xntpd/xntpd/refclock_wwvb.c
contrib/xntpd/xntpdc/ntpdc.c
contrib/xntpd/xntpdc/ntpdc_ops.c
contrib/xntpd/xntpres/xntpres.c

index be272fe..711a8f1 100644 (file)
@@ -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  *
  *                                                                            *
  * 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)
  *     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)
+*/
index 4c5c246..97c01c0 100644 (file)
 # -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
 #
 # The -DSYSLOG_FILE defines allows logging messages that are normally
 # -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
 # 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
 # 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.
 #
 # 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.
 # 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.
index 30e59bb..1e9c0b1 100644 (file)
@@ -66,7 +66,7 @@ TARGETS       = xntpd/xntpd xntpdc/xntpdc ntpq/ntpq ntpdate/ntpdate \
 OPTTARG = adjtime/adjtimed util/ntptime util/precision
 REFCONF=
 COMPRESSOR=compress
 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
 
 DISTNAME=xntp-
 MAKE=  make
 
index 76414a2..83d38a8 100644 (file)
@@ -16,20 +16,20 @@ the subdirectories contain README files describing their contents. The
 base directory ./ includes:
 
 COPYRIGHT       file specifying copyright conditions, together with a
 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
 
 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
                 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
                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.
 
 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
                (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
 
 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
 
 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
 
 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
                 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       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
 
 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
 
 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
 
 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
 
 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
 
 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
 
 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
 
 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
 
 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
 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
 
 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.
                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.
                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
                 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
 
 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
                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
 
 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
                 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.
index 277b892..1b9d9c0 100644 (file)
@@ -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
 (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.
 
     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
     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
 
     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             ?       ?
        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"
        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      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)
 
        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):
 
 
 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
 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)
 
 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".
 
                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 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.
 
 Usually the vendor should fix these bugs in vital utilities.
 We try to circumvent these bugs in a hopefully portable way.
index 9b80372..e4bbe47 100644 (file)
@@ -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
 #
 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:
 
 
 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
 Apollo:
        - terminal affiliation
        Check whether thing are still correct in respect to breaking
index 80868e3..85051bd 100644 (file)
@@ -1 +1 @@
-version=3.3b (beta)
+version=3.3c (beta)
index f2de692..44e5444 100644 (file)
@@ -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/types.h>
 #include <sys/ipc.h>
 #include <sys/msg.h>
+#include <sys/lock.h>
 #include <time.h>
 #include <signal.h>
 #include <nlist.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();
 #include "adjtime.h"
 
 double atof();
-extern int optind;
-extern char *optarg;
+extern int ntp_optind;
+extern char *ntp_optarg;
 
 int InitClockRate();
 int AdjustClockRate();
 
 int InitClockRate();
 int AdjustClockRate();
@@ -80,9 +81,13 @@ main(argc, argv)
 
   progname = argv[0];
 
 
   progname = argv[0];
 
+#ifdef LOG_LOCAL6
   openlog("adjtimed", LOG_PID, 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':
     switch (ch) {
     case 'k':
     case 'r':
@@ -112,7 +117,7 @@ main(argc, argv)
       break;
 
     case 'p':
       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);
       }
        fputs("adjtimed: percentage must be between 0.0 and 100.0\n", stderr);
        exit(1);
       }
@@ -202,6 +207,12 @@ main(argc, argv)
     Exit(1);
   }
 
     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;
   for (;;) {
     if (msgrcv(mqid, &msg.msgp, MSGSIZE, CLIENT, 0) == -1) {
       if (errno == EINTR) continue;
index 05af132..c83d5b2 100644 (file)
@@ -65,12 +65,12 @@ char *argv[];
        int loops;
        int i;
        int errflg = 0;
        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;
 
        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++;
                switch (c) {
                case 'c':
                        totalcost++;
@@ -82,11 +82,11 @@ char *argv[];
                        domd5 = 16;     /* offset into list of keys */
                        break;
                case 'n':
                        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",
                        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;
                                errflg++;
                        }
                        break;
@@ -94,7 +94,7 @@ char *argv[];
                        errflg++;
                        break;
                }
                        errflg++;
                        break;
                }
-       if (errflg || optind == argc) {
+       if (errflg || ntp_optind == argc) {
                (void) fprintf(stderr,
                    "usage: %s [-d] [-n loops] [ -c ] auth.samplekeys\n",
                    progname);
                (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();
        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++;
        for (i = 0; i < 16; i++) {
                if (!auth_havekey(i + domd5)) {
                        errflg++;
index 45a7061..424fade 100644 (file)
@@ -49,11 +49,11 @@ char *argv[];
        int errflg = 0;
        int keytype;
        U_LONG key[2];
        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];
 
        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;
                switch (c) {
                case 'a':
                        asciiflag = 1;
@@ -68,10 +68,10 @@ char *argv[];
                        stdflag = 1;
                        break;
                case 'o':
                        stdflag = 1;
                        break;
                case 'o':
-                       if (*optarg == 'n') {
+                       if (*ntp_optarg == 'n') {
                                ntpoutflag = 1;
                                gotoopt = 1;
                                ntpoutflag = 1;
                                gotoopt = 1;
-                       } else if (*optarg == 's') {
+                       } else if (*ntp_optarg == 's') {
                                ntpoutflag = 0;
                                gotoopt = 1;
                        } else {
                                ntpoutflag = 0;
                                gotoopt = 1;
                        } else {
@@ -85,7 +85,7 @@ char *argv[];
                        errflg++;
                        break;
                }
                        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);
                (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;
 
        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",
                        (void) fprintf(stderr,
                            "%s: format of key %s invalid\n",
-                           progname, argv[optind]);
+                           progname, argv[ntp_optind]);
                        exit(1);
                }
                (void) parity(key);
                        exit(1);
                }
                (void) parity(key);
@@ -242,7 +242,7 @@ decodekey(keytype, str, key)
                /*
                 * Make up key from ascii representation
                 */
                /*
                 * 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
                for (i = 0; i < 8 && i < len; i++)
                        keybytes[i] = *cp++ << 1;
                key[0] = keybytes[0] << 24 | keybytes[1] << 16
index 51f8a55..50b31f4 100644 (file)
@@ -28,11 +28,11 @@ char *argv[];
 {
        int c;
        int errflg = 0;
 {
        int c;
        int errflg = 0;
-       extern int optind;
-       extern char *optarg;
+       extern int ntp_optind;
+       extern char *ntp_optarg;
 
        progname = argv[0];
 
        progname = argv[0];
-       while ((c = getopt_l(argc, argv, "d")) != EOF)
+       while ((c = ntp_getopt(argc, argv, "d")) != EOF)
                switch (c) {
                case 'd':
                        ++debug;
                switch (c) {
                case 'd':
                        ++debug;
@@ -183,7 +183,7 @@ doit()
        int ind4, ind5, ind6, ind7;
        int octbits;
 
        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
 
        /*
         * Do the rounds for the IP table.  We save the results of
index c010989..337353c 100644 (file)
@@ -25,11 +25,11 @@ char *argv[];
 {
        int c;
        int errflg = 0;
 {
        int c;
        int errflg = 0;
-       extern int optind;
-       extern char *optarg;
+       extern int ntp_optind;
+       extern char *ntp_optarg;
 
        progname = argv[0];
 
        progname = argv[0];
-       while ((c = getopt_l(argc, argv, "d")) != EOF)
+       while ((c = ntp_getopt(argc, argv, "d")) != EOF)
                switch (c) {
                case 'd':
                        ++debug;
                switch (c) {
                case 'd':
                        ++debug;
@@ -82,8 +82,8 @@ permute(bits, cp, dp)
        u_char c[28];
        u_char d[28];
 
        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]];
 
        for (i = 0; i < 28; i++) {
                c[i] = bits[PC1_C[i]];
@@ -140,7 +140,7 @@ doit()
        U_LONG d;
        u_char bits[64];
 
        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++) {
 
        printf("static U_LONG PC1_CL[8] = {");
        for (i = 0; i < 4; i++) {
index d92d2b2..9795b62 100644 (file)
@@ -26,11 +26,11 @@ char *argv[];
 {
        int c;
        int errflg = 0;
 {
        int c;
        int errflg = 0;
-       extern int optind;
-       extern char *optarg;
+       extern int ntp_optind;
+       extern char *ntp_optarg;
 
        progname = argv[0];
 
        progname = argv[0];
-       while ((c = getopt_l(argc, argv, "d")) != EOF)
+       while ((c = ntp_getopt(argc, argv, "d")) != EOF)
                switch (c) {
                case 'd':
                        ++debug;
                switch (c) {
                case 'd':
                        ++debug;
@@ -87,7 +87,7 @@ permc(bits, resp)
        register U_LONG mask;
        u_char res[24];
 
        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]];
 
        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];
 
        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]];
 
        for (i = 0; i < 24; i++) {
                res[i] = bits[PC2_D[i]];
@@ -168,7 +168,7 @@ doit()
        U_LONG res;
        u_char bits[28];
 
        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++) {
 
        printf("static U_LONG PC2_C[4][64] = {");
        for (i = 0; i < 4; i++) {
index bfeb82c..7bfd93e 100644 (file)
@@ -25,11 +25,11 @@ char *argv[];
 {
        int c;
        int errflg = 0;
 {
        int c;
        int errflg = 0;
-       extern int optind;
-       extern char *optarg;
+       extern int ntp_optind;
+       extern char *ntp_optarg;
 
        progname = argv[0];
 
        progname = argv[0];
-       while ((c = getopt_l(argc, argv, "d")) != EOF)
+       while ((c = ntp_getopt(argc, argv, "d")) != EOF)
                switch (c) {
                case 'd':
                        ++debug;
                switch (c) {
                case 'd':
                        ++debug;
@@ -165,7 +165,7 @@ doit()
        U_LONG result;
        int sixbits;
 
        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++) {
        printf("static U_LONG SP[8][64] = {");
        for (selno = 0; selno < 8; selno++) {
                for (sixbits = 0; sixbits < 64; sixbits++) {
index 73db940..b85348f 100644 (file)
@@ -25,9 +25,9 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <time.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <time.h>
-#ifdef __bsdi__
+#ifdef SYS_BSDI
 #include <sys/time.h>
 #include <sys/time.h>
-#endif /* __bsdi__ */
+#endif /* SYS_BSDI */
 #include "md5.h"
 
 #define        MD5
 #include "md5.h"
 
 #define        MD5
index 3bb987a..454b341 100644 (file)
@@ -34,14 +34,14 @@ char *argv[];
        int numkeys;
        U_LONG tmp;
        char *passwd;
        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;
        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;
                switch (c) {
                case 'd':
                        ++debug;
@@ -50,7 +50,7 @@ char *argv[];
                        std = 0;
                        break;
                case 'p':
                        std = 0;
                        break;
                case 'p':
-                       passwd = optarg;
+                       passwd = ntp_optarg;
                        break;
                case 's':
                        std = 1;
                        break;
                case 's':
                        std = 1;
@@ -61,11 +61,11 @@ char *argv[];
                }
 
        numkeys = 0;
                }
 
        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) {
                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;
                        exit(2);
                }
                dokey[c] = 1;
index 887cc58..0751a5d 100644 (file)
@@ -34,11 +34,11 @@ char *argv[];
 {
        int c;
        int errflg = 0;
 {
        int c;
        int errflg = 0;
-       extern int optind;
-       extern char *optarg;
+       extern int ntp_optind;
+       extern char *ntp_optarg;
 
        progname = argv[0];
 
        progname = argv[0];
-       while ((c = getopt_l(argc, argv, "d")) != EOF)
+       while ((c = ntp_getopt(argc, argv, "d")) != EOF)
                switch (c) {
                case 'd':
                        ++debug;
                switch (c) {
                case 'd':
                        ++debug;
@@ -188,7 +188,7 @@ doit()
        int ind0, ind1, ind2, ind3;
        int quadbits;
 
        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
 
        /*
         * Do the rounds for the IPL table.  We save the results of
index f65686c..2bf058c 100644 (file)
@@ -68,12 +68,12 @@ char *argv[];
 {
        int c;
        int errflg = 0;
 {
        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];
        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
                switch (c) {
                case 'c':
 #ifdef STREAM
@@ -107,7 +107,7 @@ char *argv[];
                        errflg++;
                        break;
                }
                        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);
 #ifdef STREAM
                (void) fprintf(stderr, "usage: %s [-dft] tty_device\n",
                    progname);
@@ -126,7 +126,7 @@ char *argv[];
        }
 
        (void) gettimeofday(&lasttv, (struct timezone *)0);
        }
 
        (void) gettimeofday(&lasttv, (struct timezone *)0);
-       c = openterm(argv[optind]);
+       c = openterm(argv[ntp_optind]);
        init_chu();
 #ifdef STREAM
        if (usechuldisc)
        init_chu();
 #ifdef STREAM
        if (usechuldisc)
index 7ed13b3..b540485 100644 (file)
@@ -105,8 +105,8 @@ char *argv[];
        int fd;
        struct sgttyb ttyb;
        struct itimerval itimer;
        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();
 
        int alarming();
        int ioready();
 
@@ -114,13 +114,13 @@ char *argv[];
 #ifdef STREAM
        magic[0] = 0;
 #endif
 #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':
                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);
                                (void) fprintf(stderr,
                                    "%s: argument for -%c must be integer\n",
                                    progname, c);
@@ -139,7 +139,7 @@ char *argv[];
 #endif
                        break;
                case 'b':
 #endif
                        break;
                case 'b':
-                       if (!atouint(optarg, &tmp)) {
+                       if (!atouint(ntp_optarg, &tmp)) {
                                errflg++;
                                break;
                        }
                                errflg++;
                                break;
                        }
@@ -163,14 +163,14 @@ char *argv[];
                        ttflags |= CRMOD;
                        break;
                case 's':
                        ttflags |= CRMOD;
                        break;
                case 's':
-                       cmdlen = strlen(optarg);
+                       cmdlen = strlen(ntp_optarg);
                        if (cmdlen == 0)
                                errflg++;
                        else
                        if (cmdlen == 0)
                                errflg++;
                        else
-                               cmd = optarg;
+                               cmd = ntp_optarg;
                        break;
                case 't':
                        break;
                case 't':
-                       if (!atouint(optarg, &tmp))
+                       if (!atouint(ntp_optarg, &tmp))
                                errflg++;
                        else {
                                timeout.tv_sec = (long)tmp;
                                errflg++;
                        else {
                                timeout.tv_sec = (long)tmp;
@@ -181,7 +181,7 @@ char *argv[];
                        errflg++;
                        break;
                }
                        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",
                (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)
 #endif
 
        if (docmd)
-               fd = open(argv[optind], O_RDWR, 0777);
+               fd = open(argv[ntp_optind], O_RDWR, 0777);
        else
        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,
        if (fd == -1) {
                (void) fprintf(stderr, "%s: open(%s): ", progname,
-                   argv[optind]);
+                              argv[ntp_optind]);
                perror("");
                exit(1);
        }
                perror("");
                exit(1);
        }
index 5ba1789..0c1f1bb 100644 (file)
@@ -140,21 +140,21 @@ char *argv[];
        double lat1, long1;
        double lat2, long2;
        double lat3, long3;
        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];
 
        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++;
                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",
                        if (height <= 0.0) {
                                (void) fprintf(stderr, "height %s unlikely\n",
-                                   optarg);
+                                              ntp_optarg);
                                errflg++;
                        }
                        break;
                                errflg++;
                        }
                        break;
@@ -171,8 +171,8 @@ char *argv[];
                        errflg++;
                        break;
                }
                        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);
                (void) fprintf(stderr,
                    "usage: %s [-d] [-h height] lat1 long1 lat2 long2\n",
                    progname);
@@ -185,10 +185,10 @@ char *argv[];
 
                   
        if (!(Cflag || Wflag || Gflag)) {
 
                   
        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 {
                if (hflag) {
                        doit(lat1, long1, lat2, long2, height, "");
                } else {
@@ -201,8 +201,8 @@ char *argv[];
                /*
                 * Compute delay from WWV
                 */
                /*
                 * 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) {
                lat2 = latlong(wwvlat, 1);
                long2 = latlong(wwvlong, 0);
                if (hflag) {
@@ -228,8 +228,8 @@ char *argv[];
                            "WWVH winter propagation, ");
                }
        } else if (Cflag) {
                            "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) {
                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);
        } 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);
 
 
                lat2 = latlong(goes_sat_lat, 1);
 
diff --git a/contrib/xntpd/compilers/domainos.cc b/contrib/xntpd/compilers/domainos.cc
new file mode 100644 (file)
index 0000000..eb4dd62
--- /dev/null
@@ -0,0 +1 @@
+COMPILER= cc
index 41e6fc2..b1f980b 100644 (file)
@@ -89,9 +89,6 @@ RANLIB=               ranlib
 #      to configure the particular clock drivers you want in the
 #      CLOCKDEFS= line below.  This flag affects xntpd only.
 #
 #      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.
 #
 # 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.
 #
 #      (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
 
 #
 #  Authentication types supported.  Choose from DES and MD5.  If you
index b9e075f..18dddff 100644 (file)
@@ -84,9 +84,6 @@ RANLIB=               ranlib
 #      to configure the particular clock drivers you want in the
 #      CLOCKDEFS= line below.  This flag affects xntpd only.
 #
 #      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.
 #
 # 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)
 #
 #      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
 
 #
 #  Authentication types supported.  Choose from DES and MD5.  If you
index c757ad9..29c6cbd 100644 (file)
@@ -80,9 +80,6 @@ RANLIB=               ranlib
 #      to configure the particular clock drivers you want in the
 #      CLOCKDEFS= line below.  This flag affects xntpd only.
 #
 #      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.
 #
 # 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)
 #
 #      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
 
 #
 #  Authentication types supported.  Choose from DES and MD5.  If you
index 6caa2b8..2fc2580 100644 (file)
@@ -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.
 #
 #      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.
 #
 # 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.
 #
 #      (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
 
 #
 #  Authentication types supported.  Choose from DES and MD5.  If you
index 4c5095c..12a6dfe 100644 (file)
@@ -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.
 #
 # 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)
 
 #
 # Directory into which binaries should be installed (default /usr/local)
index b021019..ff6386e 100644 (file)
@@ -74,6 +74,12 @@ xntpd - Network Time Protocol daemon
 ] [
 .B -t
 .I trustedkey
 ] [
 .B -t
 .I trustedkey
+] [
+.B -v
+.I variable
+] [
+.B -V
+.I variable
 ]
 .SH DESCRIPTION
 .I Xntpd
 ]
 .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
 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
 .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
 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
 .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
 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
 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
 .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
 .PP
 Unit encoding
 .PP
diff --git a/contrib/xntpd/hints/linux b/contrib/xntpd/hints/linux
new file mode 100644 (file)
index 0000000..f243bd2
--- /dev/null
@@ -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/contrib/xntpd/hints/sun4 b/contrib/xntpd/hints/sun4
new file mode 100644 (file)
index 0000000..6dc36ea
--- /dev/null
@@ -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)
+
+
index 7a4383d..89a8092 100644 (file)
@@ -38,7 +38,6 @@ extern        long    strtol          P((char *, char **, int));
 
 #if !defined(NTP_POSIX_SOURCE)
 extern  int    atoi            P((char *));
 
 #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));
 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 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));
 #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 *));    
 
 #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 */
 
 #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
 extern char    *memcpy();
 extern char    *memset();
 extern int     memcmp();
 #endif
 #endif
+#endif
 
 #ifdef _sys_socket_h
 extern  int    bind            P((int, struct sockaddr *, int));
 
 #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 *));
 
 #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));
 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 */
 
 extern char *  getpass         P((char *));
 #endif /* VAX */
 
+#ifdef SYS_DOMAINOS
+extern char *  getpass         P((char *));
+#endif /* SYS_DOMAINOS */
+
 #endif /* l_stdlib_h */
 
 #endif /* l_stdlib_h */
 
index 98a083a..310353f 100644 (file)
@@ -328,7 +328,7 @@ struct peer {
 #define FLAG_PREFER            0x80    /* this is the preferred 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.
  */
  * 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_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
 
 /*
  * We tell reference clocks from real peers by giving the reference
index 89f6229..74f75f1 100644 (file)
@@ -163,9 +163,9 @@ struct ntp_control {
 #define        CS_SYSTEM       17
 #define        CS_KEYID        18
 #define        CS_REFSKEW      19
 #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
 
 /*
  * 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_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
 
 /*
  * 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_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.
 
 /*
  * Definition of the structure used internally to hold trap information.
index 263f561..7281d59 100644 (file)
@@ -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
  *
  *
  * definitions for NTP file generations support
  *
index 97f5729..1c3983e 100644 (file)
@@ -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.
  */
 
  * 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.
              
 
   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
                      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
 
 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.
 
   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.
 
 
 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
 
   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,
 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.  
   
   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
   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
   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 ?
 
                      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.
 
 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.
 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.
  */
 /*
  * 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
 #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
 #define USE_PROTOTYPES
 #endif
 #endif /*_BSD */
 #define        HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/AIX"
+#endif
 #endif /* RS6000 */
 
 /*
 #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)
  * Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO
  */
 #if defined(SYS_SUNOS4)
+#define NTP_NEED_BOPS
 #define NO_SIGNED_CHAR_DECL
 #define HAVE_LIBKVM 
 #define HAVE_MALLOC_H
 #define 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
 #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
 
 /*
 #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
 #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
 #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
 
 /*
 #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
 #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
  */
 #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 
 #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
 #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
 #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
 #endif
 #define NTP_POSIX_SOURCE
 #define HAVE_ATT_SETPGRP
 #endif
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/ConvexOS"
+#endif
 #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
 #define HAVE_ATT_SETPGRP
 #define HAVE_BSD_NICE
 #define NTP_POSIX_SOURCE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/IRIX"
+#endif
 #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
 #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
  */
 #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
 #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
 #define HAVE_BSD_TTYS
 #define LOG_NTP LOG_LOCAL1
 #define HAVE_SIGNALED_IO
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/AUX"
+#endif
 #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
 #define HAVE_BSD_NICE
 #define HAVE_N_UN
 #undef NTP_POSIX_SOURCE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Next"
+#endif
 #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
 #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 */
 #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
 #else
 #define HAVE_READKMEM
 #endif
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/HPUX"
+#endif
 #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
 #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
 
 /*
 #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_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
 #define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Linux"
+#endif
 #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
 #define HAVE_READKMEM
 #define NTP_POSIX_SOURCE
 #define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/*BSD"
+#endif
 #endif
 
 /*
 #endif
 
 /*
- * DECOSF1
+ * DEC AXP OSF/1
  */
 #if defined(SYS_DECOSF1)
 #define HAVE_SIGNALED_IO
  */
 #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
 #define NTP_POSIX_SOURCE
 #define        NTP_SYSCALLS_STD
 #define        HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/DECOSF1"
+#endif
 #endif
 
 /*
  * I386
 #endif
 
 /*
  * I386
+ * XXX - what OS?
  */
 #if defined(SYS_I386)
 #define HAVE_READKMEM 
 #define S_CHAR_DEFINED 
 #define HAVE_BSD_NICE
  */
 #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
 
 /*
 #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
 #if defined(SYS_MIPS)
 #define NOKMEM 
 #define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Mips"
+#endif
 #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
  */
 #if defined(SYS_SEQUENT)
 #define HAVE_BSD_NICE
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Sequent Dynix 3"
+#endif
 #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
 #ifndef HAVE_SYSV_TTYS
 #define HAVE_SYSV_TTYS
 #endif
+#define STREAMS_TLI
 #define HAVE_ATT_SETPGRP 
 #define HAVE_SIGNALED_IO
 #define USE_UDP_SIGPOLL
 #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
 typedef unsigned short u_short;
 typedef unsigned long u_long;
 #endif
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "UNIX/Sequent PTX"
+#endif
 #endif
 
 
 /*
 #endif
 
 
 /*
- * Sony
+ * Sony NEWS
  */
 #if defined(SYS_SONY)
 #define NO_SIGNED_CHAR_DECL 
 #define HAVE_READKMEM
 #define HAVE_BSD_NICE
  */
 #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
 #endif
 
 /*
  * VAX
+ * XXX - VMS?
  */
 #if defined(SYS_VAX)
 #define NO_SIGNED_CHAR_DECL 
 #define HAVE_READKMEM 
 #define HAVE_BSD_NICE
  */
 #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
 
 /* 
 #endif
 
 /* 
@@ -419,11 +505,9 @@ typedef unsigned long u_long;
 #if defined(SYS_SVR4)
 #define HAVE_ATT_SETPGRP
 #define USE_PROTOTYPES
 #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 NTP_POSIX_SOURCE
 #define HAVE_ATT_NICE
 #define HAVE_READKMEM 
-#define HAVE_SIGNALED_IO
 #define USE_TTY_SIGPOLL
 #define USE_UDP_SIGPOLL
 #define STREAM
 #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
 #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
 #endif
 
 #ifndef        RETSIGTYPE
@@ -450,8 +559,64 @@ typedef unsigned long u_long;
 #endif
 #endif /* NTP_SYSCALLS_STD */
 
 #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
 
        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 */
 #endif /* __ntp_machine */
index 96e63ac..cc026f5 100644 (file)
@@ -75,10 +75,10 @@ struct refclockstat {
        LONG fudgeval2;
        u_char currentstatus;
        u_char lastevent;
        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.
 /*
  * Reference clock I/O structure.  Used to provide an interface between
  * the reference clock drivers and the I/O module.
index 5dd1868..e3ce0e7 100644 (file)
@@ -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_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 */
 #endif
 
 #endif /* _ntp_select_h */
index fcccd6e..0ec0625 100644 (file)
@@ -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 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));
 extern void    init_auth       P((void));
 extern void    init_lib        P((void));
 extern void    init_random     P((void));
index f17905e..cc2eec8 100644 (file)
@@ -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
 
  */
 
 #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 */
 
 #endif /* _ntp_string_h */
index 85a8125..f2c56af 100644 (file)
@@ -1,4 +1,4 @@
-/* ntpd.h,v 3.1 1993/07/06 01:07:03 jbj Exp
+/*
  * ntpd.h - Prototypes for xntpd.
  */
 
  * 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 *));
 
 extern void    process_control P((struct recvbuf *, int));
 extern void    report_event    P((int, struct peer *));
 
+/* ntp_control.c */
+/*
+ * Structure for translation tables between internal system
+ * variable indices and text format.
+ */
+struct ctl_var {
+       u_short code;
+       u_short flags;
+       char *text;
+};
+/*
+ * Flag values
+ */
+#define        CAN_READ        0x01
+#define        CAN_WRITE       0x02
+
+#define DEF            0x20
+#define        PADDING         0x40
+#define        EOV             0x80
+
+#define        RO      (CAN_READ)
+#define        WO      (CAN_WRITE)
+#define        RW      (CAN_READ|CAN_WRITE)
+
+extern  char *  add_var P((struct ctl_var **, unsigned long, int));
+extern  void    free_varlist P((struct ctl_var *));
+extern  void    set_var P((struct ctl_var **, char *, unsigned long, int));
+extern  void    set_sys_var P((char *, unsigned long, int));
+
 /* ntp_intres.c */
 extern void    ntp_intres      P((void));
 
 /* ntp_intres.c */
 extern void    ntp_intres      P((void));
 
index 9c8befe..31041af 100644 (file)
@@ -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,
  * 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__))
 #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"
 #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
  * 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
  *
  * Revision 3.11  1993/11/11  11:20:18  kardel
  * declaration fixes
  *
index 3cc6348..13cec55 100644 (file)
@@ -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,
  * 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__))
 #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
 
 /*
 #endif
 
 /*
index 91786c1..d07e75c 100644 (file)
@@ -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,
  * 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__))
  */
 
 #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
 #endif
 
 #undef PARSEKERNEL
index 700efa6..c40f810 100644 (file)
@@ -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
 #
 #
 # 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 "### 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:
                                  print "### parse/*."; } }'
 
 clean:
index eea792d..6866145 100644 (file)
@@ -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 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.
  *   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:
  *
  *
  * 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
  * 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:
  *
  *
  * 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.
  * v2.1 - Added 'sixth byte' heuristics.
  * v2.0 - first version with an actual version number.
  *        Added support for new CHU 'second 31' data format.
  *
  */
 
  *
  */
 
-#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
 # ifndef NCHU
 #  define NCHU 3
 #  define KERNEL
 # endif
+#else
+# include "chu.h"
 #endif
 
 #if NCHU > 0
 #endif
 
 #if NCHU > 0
 #include <sys/stream.h>
 #include <sys/param.h>
 #include <sys/time.h>
 #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 <sys/errno.h>
 #include <sys/user.h>
+#include <syslog.h>
+#include <sys/tty.h>
 
 #include <sys/chudefs.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();
 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];
 
   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 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 =
 {
 
 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;
 
 
 char chu_first_open=1;
 
@@ -180,7 +280,7 @@ int sflag;
 {
   int i;
 
 {
   int i;
 
-#ifndef LOADABLE
+#if !defined(LOADABLE) && !defined(SOLARIS2)
   if (chu_first_open)
   {
     chu_first_open=0;
   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;
       ((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;
     }
 
       return 0;
     }
 
+#ifdef SOLARIS2
+  return (EBUSY);
+#else
   u.u_error = EBUSY;
   return (OPENFAIL);
   u.u_error = EBUSY;
   return (OPENFAIL);
+#endif
 
 }
 
 
 }
 
@@ -282,7 +396,12 @@ queue_t *q;
 
   if (mp==NULL)
   {
 
   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");
     log(LOG_ERR,"chu: cannot allocate message");
+#endif
     return;
   }
 
     return;
   }
 
@@ -441,4 +560,4 @@ queue_t *q;
   }
 }
 
   }
 }
 
-#endif
+#endif /* NCHU > 0 */
index f41af28..a69a757 100644 (file)
@@ -62,7 +62,7 @@ struct priv_data_type
 char first_open=1;
 
 /*
 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.
  */
 
  * on my system, so here's a renamed copy.
  */
 
index a3714a2..6033ded 100644 (file)
@@ -80,7 +80,8 @@ MD5auth2crypt(keyno, pkt, length)
     MD5Update(&ctx, (char *)(pkt) + length - 8, 8);
     MD5Final(&ctx);
 
     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);
 }
 }
index 892e52e..dc7acf6 100644 (file)
@@ -54,5 +54,7 @@ MD5authdecrypt(keyno, pkt, length)
     MD5Update(&ctx, (char *)pkt, length);
     MD5Final(&ctx);
 
     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));
 }
 }
index a26e8f0..2ae6258 100644 (file)
@@ -63,6 +63,8 @@ MD5authencrypt(keyno, pkt, length)
     MD5Update(&ctx, (char *)pkt, length);
     MD5Final(&ctx);
 
     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  */
 }
 }
index 36077fc..9f64c40 100644 (file)
@@ -3,58 +3,12 @@
  */
 #include "ntp_stdlib.h"
 
  */
 #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
  * auth_des() is called to do the actual encryption/decryption
  */
 
 /*
  * There are two entries in here.  auth_subkeys() called to
  * compute the encryption and decryption key schedules, while
  * auth_des() is called to do the actual encryption/decryption
  */
 
-/*
- * 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
 /*
  * Key setup.  Here we entirely permute a key, saving the results
  * for both the encryption and decryption.  Note that while the
index b0323a0..a63c6d3 100644 (file)
@@ -15,6 +15,7 @@
  * to its exportable state, copy this file to authdes.c . 
  */
 #include <sys/types.h>
  * 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.
 
 /*
  * This routine is normally called to compute the key schedule.
index 2d46eee..743af83 100644 (file)
@@ -109,7 +109,7 @@ init_auth()
        /*
         * Initialize hash table and free list
         */
        /*
         * 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;
        cache_flags = cache_keyid = 0;
 
        authnumfreekeys =  authkeynotfound = authkeylookups = 0;
index 0452031..c268c4d 100644 (file)
@@ -96,7 +96,7 @@ authusekey(keyno, keytype, str)
                /*
                 * Make up key from ascii representation
                 */
                /*
                 * 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
                for (i = 0; i < 8 && i < len; i++)
                        keybytes[i] = *cp++ << 1;
                key[0] = (U_LONG)keybytes[0] << 24 | (U_LONG)keybytes[1] << 16
index f6fc003..2701e3f 100644 (file)
@@ -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_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,                   "", "" }
 };
 
        { -1,                   "", "" }
 };
 
index c6e317f..a496df8 100644 (file)
@@ -31,7 +31,7 @@ dofptoa(fpv, neg, ndec, msec)
        /*
         * Zero out the buffer
         */
        /*
         * Zero out the buffer
         */
-       bzero((char *)cbuf, sizeof cbuf);
+       memset((char *)cbuf, 0, sizeof cbuf);
 
        /*
         * Set the pointers to point at the first
 
        /*
         * Set the pointers to point at the first
index ff34153..ff37c9f 100644 (file)
@@ -32,7 +32,7 @@ dolfptoa(fpi, fpv, neg, ndec, msec)
        /*
         * Zero the character buffer
         */
        /*
         * 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
 
        /*
         * Work on the integral part.  This is biased by what I know
index 0ab3c29..5519235 100644 (file)
@@ -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
  * 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.
  */
  *
  * This file is in the Public Domain.
  */
 #define        putc    fputc
 #endif /* lint */
 
 #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    *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
 
 int
-getopt_l(argc, argv, optstring)
+ntp_getopt(argc, argv, optstring)
        int argc;
        char *argv[];
        char *optstring;
        int argc;
        char *argv[];
        char *optstring;
@@ -60,47 +56,50 @@ getopt_l(argc, argv, optstring)
        register char c;
        register char *place;
 
        register char c;
        register char *place;
 
-       optarg = NULL;
+       prog = argv[0];
+       ntp_optarg = NULL;
 
 
-       if (optind == 0) {
+       if (ntp_optind == 0) {
                scan = NULL;
                scan = NULL;
-               optind++;
+               ntp_optind++;
        }
        
        if (scan == NULL || *scan == '\0') {
        }
        
        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++;
        }
 
        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 == '?') {
        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') {
        }
 
        place++;
        if (*place == ':') {
                if (*scan != '\0') {
-                       optarg = scan;
+                       ntp_optarg = scan;
                        scan = NULL;
                        scan = NULL;
-               } else if (optind >= argc) {
-                       BADOPT(": option requires argument -", c);
+               } else if (ntp_optind >= argc) {
+                       return (badopt(": option requires argument -", c));
                } else {
                } else {
-                       optarg = argv[optind];
-                       optind++;
+                       ntp_optarg = argv[ntp_optind++];
                }
        }
 
                }
        }
 
-       return c&0377;
+       return (c & 0377);
 }
 }
index f7a400c..5e01694 100644 (file)
-/*
- * provide special support for peculiar architectures
+/* machines.c - provide special support for peculiar architectures
  *
  * Real bummers unite !
  *
  * Real bummers unite !
+ *
+ * $Id:$
  */
 
  */
 
+#include "ntp_stdlib.h"
+
 #ifdef SYS_PTX
 #include <sys/types.h>
 #include <sys/procstats.h>
 #ifdef SYS_PTX
 #include <sys/types.h>
 #include <sys/procstats.h>
-int settimeofday(tvp)
+
+int
+settimeofday(tvp)
        struct timeval *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
         */
        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
 
 }
 #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*/
index a8df27d..a6186b7 100644 (file)
@@ -81,7 +81,8 @@ void msyslog(va_alist)
                        n += strlen(err);
                }
        }
                        n += strlen(err);
                }
        }
-       *n++ = '\n';
+       if (!syslogit)
+         *n++ = '\n';
        *n = '\0';
 
        vsprintf(buf, nfmt, ap);
        *n = '\0';
 
        vsprintf(buf, nfmt, ap);
index c8b532f..e22b623 100644 (file)
@@ -1,7 +1,7 @@
 /* numtohost.c,v 3.1 1993/07/06 01:08:40 jbj Exp
  * numtohost - convert network number to host name.
  */
 /* 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"
 #include <netdb.h>
 
 #include "ntp_fp.h"
index 99e715a..ea15734 100644 (file)
@@ -3,7 +3,7 @@
  */
 #include <sys/types.h>
 #include <sys/time.h>
  */
 #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
 #include <sys/param.h>
 #include <utmp.h>
 #endif
@@ -238,36 +238,40 @@ adj_systime(ts)
 #endif
        }
 
 #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;
        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
                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 */
 
 #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
 #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
 #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);
 }
        }
        return(rval);
 }
@@ -345,7 +349,7 @@ step_systime_real(ts)
         * is greater than one second.
         */
        if (oldtime != timetv.tv_sec) {
         * 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);
                ut.ut_type = OLD_TIME;
                ut.ut_time = oldtime;
                (void)strcpy(ut.ut_line, OTIME_MSG);
index d40d8cb..b12db88 100644 (file)
@@ -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
 
 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.
index 70607d8..93a0181 100644 (file)
@@ -1,6 +1,6 @@
 RANLIB=           : 
 DEFS_LOCAL= -DREFCLOCK
 RANLIB=           : 
 DEFS_LOCAL= -DREFCLOCK
-DEFS=      -DRS6000 -DSYS_AIX
+DEFS=      -DRS6000 -DSYS_AIX -DHAVE_TERMIOS
 AUTHDEFS=  -DDES -DMD5
 CLOCKDEFS= -DLOCAL_CLOCK
 DAEMONLIBS=
 AUTHDEFS=  -DDES -DMD5
 CLOCKDEFS= -DLOCAL_CLOCK
 DAEMONLIBS=
index 040bab4..e948376 100644 (file)
@@ -5,5 +5,4 @@ AUTHDEFS=  -DDES -DMD5
 CLOCKDEFS= -DLOCAL_CLOCK
 DAEMONLIBS= -lkvm
 RESLIB=
 CLOCKDEFS= -DLOCAL_CLOCK
 DAEMONLIBS= -lkvm
 RESLIB=
-COPTS=      -g
-
+COPTS=      -g -O
diff --git a/contrib/xntpd/machines/dell.svr4 b/contrib/xntpd/machines/dell.svr4
new file mode 100644 (file)
index 0000000..81ab4a1
--- /dev/null
@@ -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/contrib/xntpd/machines/domainos b/contrib/xntpd/machines/domainos
new file mode 100644 (file)
index 0000000..6bc8f66
--- /dev/null
@@ -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=
index 1914de0..9380c0e 100644 (file)
@@ -1,6 +1,6 @@
 RANLIB=            ranlib
 DEFS_LOCAL=-DREFCLOCK
 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
 AUTHDEFS=  -DDES -DMD5
 CLOCKDEFS= -DLOCAL_CLOCK
 DAEMONLIBS= -lcrypt
index 60ec678..fdb0789 100644 (file)
@@ -1,7 +1,7 @@
 SHELL=         /bin/sh
 RANLIB=               ls # ar does the work of ranlib under System V
 DEFS_LOCAL=    -DREFCLOCK
 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=
 AUTHDEFS=      -DDES -DMD5
 CLOCKDEFS=     -DLOCAL_CLOCK
 COPTS=
index f4b420c..0119b63 100644 (file)
@@ -1,7 +1,7 @@
 SHELL=         /bin/sh
 RANLIB=               ls # ar does the work of ranlib under System V
 DEFS_LOCAL=    -DREFCLOCK
 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=
 AUTHDEFS=      -DDES -DMD5
 CLOCKDEFS=     -DLOCAL_CLOCK
 COPTS=
index b33e3c3..9ae1cc7 100644 (file)
@@ -1,9 +1,9 @@
 SHELL=       /bin/sh
 RANLIB=      ls # ar does the work of ranlib under System V
 DEFS_LOCAL=  -DREFCLOCK
 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
 AUTHDEFS=    -DDES -DMD5
 CLOCKDEFS=   -DLOCAL_CLOCK
-DAEMONLIBS=  -lnsl -lsocket -lelf
+DAEMONLIBS=  
 RESLIB=      -lnsl -lsocket -lelf
 INSTALL=     /usr/ucb/install
 RESLIB=      -lnsl -lsocket -lelf
 INSTALL=     /usr/ucb/install
index 853654a..d7a8ac4 100644 (file)
@@ -1,6 +1,6 @@
 SHELL=     /bin/sh
 RANLIB=            ranlib
 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=
 AUTHDEFS=   -DDES -DMD5
 INCL=      -I../include -I/usr/include/bsd
 CLOCKDEFS=
index c1995ea..1cfd8e1 100644 (file)
@@ -1,6 +1,6 @@
 RANLIB=            ranlib
 DEFS_LOCAL=-DREFCLOCK
 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
 AUTHDEFS=  -DDES -DMD5
 CLOCKDEFS= -DLOCAL_CLOCK
 DAEMONLIBS= -lcrypt -lutil
index c1d9da2..4759851 100644 (file)
@@ -1,6 +1,6 @@
 RANLIB=             :
 DEFS_LOCAL=  -DREFCLOCK
 RANLIB=             :
 DEFS_LOCAL=  -DREFCLOCK
-DEFS=        -DREADKMEM -DSYS_PTX -DHAVE_SYSV_TTYS
+DEFS=        -DREADKMEM -DSYS_PTX -DHAVE_TERMIOS
 AUTHDEFS=    -DDES -DMD5
 CLOCKDEFS=   -DLOCAL_CLOCK
 DAEMONLIBS=
 AUTHDEFS=    -DDES -DMD5
 CLOCKDEFS=   -DLOCAL_CLOCK
 DAEMONLIBS=
index 309b11b..e8e4499 100644 (file)
@@ -1,6 +1,6 @@
 RANLIB=             ranlib
 DEFS_LOCAL=  -DREFCLOCK
 RANLIB=             ranlib
 DEFS_LOCAL=  -DREFCLOCK
-DEFS=        -DREADKMEM -DSYS_SEQUENT
+DEFS=        -DHAVE_READ_KMEM -DSYS_SEQUENT
 AUTHDEFS=    -DDES -DMD5
 CLOCKDEFS=   -DLOCAL_CLOCK
 DAEMONLIBS=
 AUTHDEFS=    -DDES -DMD5
 CLOCKDEFS=   -DLOCAL_CLOCK
 DAEMONLIBS=
index 55cccad..22e0d1e 100644 (file)
@@ -1,6 +1,6 @@
 RANLIB=           : 
 DEFS_LOCAL=-DREFCLOCK
 RANLIB=           : 
 DEFS_LOCAL=-DREFCLOCK
-DEFS=      -DSTREAM -DSOLARIS  -DSYS_SOLARIS
+DEFS=      -DSTREAM -DSOLARIS -DSYS_SOLARIS -DNTP_POSIX_SOURCE
 AUTHDEFS=  -DDES -DMD5
 CLOCKDEFS= -DLOCAL_CLOCK
 DAEMONLIBS= 
 AUTHDEFS=  -DDES -DMD5
 CLOCKDEFS= -DLOCAL_CLOCK
 DAEMONLIBS= 
index 3e09c15..fc735b0 100644 (file)
@@ -1,6 +1,6 @@
 RANLIB=            : 
 DEFS_LOCAL= -DREFCLOCK
 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= 
 AUTHDEFS=   -DDES -DMD5
 CLOCKDEFS=  -DLOCAL_CLOCK
 DAEMONLIBS= 
index 1cf90f5..752bd11 100644 (file)
@@ -1,6 +1,6 @@
 SHELL=       /bin/sh
 RANLIB=             ls # ar does the work of ranlib under System V
 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
 AUTHDEFS=    -DDES -DMD5
 CLOCKDEFS=   
 DAEMONLIBS=  -lnet -lnsl -lsocket -lelf
index e144d8c..b5ad05d 100644 (file)
@@ -167,8 +167,8 @@ main(argc, argv)
        l_fp tmp;
        int errflg;
        int c;
        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;
        extern char *Version;
 
        errflg = 0;
@@ -178,10 +178,10 @@ main(argc, argv)
        /*
         * Decode argument list
         */
        /*
         * 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':
                switch (c) {
                case 'a':
-                       c = atoi(optarg);
+                       c = atoi(ntp_optarg);
                        sys_authenticate = 1;
                        sys_authkey = (U_LONG)c;
                        break;
                        sys_authenticate = 1;
                        sys_authkey = (U_LONG)c;
                        break;
@@ -192,24 +192,24 @@ main(argc, argv)
                        ++debug;
                        break;
                case 'e':
                        ++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",
                            || 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':
                                errflg++;
                        } else {
                                sys_authdelay = tmp.l_uf;
                        }
                        break;
                case 'k':
-                       key_file = optarg;
+                       key_file = ntp_optarg;
                        break;
                case 'o':
                        break;
                case 'o':
-                       sys_version = atoi(optarg);
+                       sys_version = atoi(ntp_optarg);
                        break;
                case 'p':
                        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",
                        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':
                        syslogit = 1;
                        break;
                case 't':
-                       if (!atolfp(optarg, &tmp)) {
+                       if (!atolfp(ntp_optarg, &tmp)) {
                                (void) fprintf(stderr,
                                    "%s: timeout %s is undecodeable\n",
                                (void) fprintf(stderr,
                                    "%s: timeout %s is undecodeable\n",
-                                   progname, optarg);
+                                   progname, ntp_optarg);
                                errflg++;
                        } else {
                                sys_timeout = ((LFPTOFP(&tmp) * TIMER_HZ)
                                errflg++;
                        } else {
                                sys_timeout = ((LFPTOFP(&tmp) * TIMER_HZ)
@@ -248,7 +248,7 @@ main(argc, argv)
                        break;
                }
        
                        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",
        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
         */
        /*
         * 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");
 
        if (sys_numservers == 0) {
                syslog(LOG_ERR, "no servers can be used, exiting");
@@ -520,16 +520,8 @@ receive(rbufp)
        }
 
        rpkt = &(rbufp->recv_pkt);
        }
 
        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;
        }
 
                return;
        }
 
@@ -1038,7 +1030,7 @@ addserver(serv)
        }
 
        server = (struct server *)emalloc(sizeof(struct server));
        }
 
        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;
 
        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;
 
        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;
                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) {
        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 */
 }
 
 /* XXX ELIMINATE printserver similar in ntptrace.c, ntpdate.c */
@@ -1527,7 +1519,7 @@ printserver(pp, fp)
        
        if (pp->stratum == 1) {
                junk[4] = 0;
        
        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);
                str = junk;
        } else {
                str = numtoa(pp->refid);
index e9db008..5cfc3da 100644 (file)
@@ -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 *));
 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 **));
 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 *));
 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 *));
 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;
 {
        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];
 
        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':
                switch (c) {
                case 'c':
-                       ADDCMD(optarg);
+                       ADDCMD(ntp_optarg);
                        break;
                case 'd':
                        ++debug;
                        break;
                case 'd':
                        ++debug;
@@ -543,11 +543,11 @@ char *argv[];
                    progname);
                exit(2);
        }
                    progname);
                exit(2);
        }
-       if (optind == argc) {
+       if (ntp_optind == argc) {
                ADDHOST(DEFHOST);
        } else {
                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
        }
 
        if (numcmds == 0 && interactive == 0
@@ -982,7 +982,7 @@ again:
        /*
         * Copy the data into the data buffer.
         */
        /*
         * 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.
 
        /*
         * 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) {
         * 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;
                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) {
                }
                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;
                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;
 
                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);
                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++) {
 
                maxlength = 0;
                for (i = 0; i < n; i++) {
@@ -1934,7 +1934,7 @@ help(pcmd, fp)
  * helpsort - do hostname qsort comparisons
  */
 static int
  * 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;
 helpsort(t1, t2)
        const void *t1;
        const void *t2;
@@ -1946,7 +1946,7 @@ helpsort(name1, name2)
        char **name1;
        char **name2;
 {
        char **name1;
        char **name2;
 {
-#endif /* sgi */
+#endif /* sgi || bsdi */
        return strcmp(*name1, *name2);
 }
 
        return strcmp(*name1, *name2);
 }
 
@@ -2577,6 +2577,7 @@ nextvar(datalen, datap, vname, vvalue)
        register char *cp;
        register char *np;
        register char *cpend;
        register char *cp;
        register char *np;
        register char *cpend;
+       int quoted = 0;
        static char name[MAXVARLEN];
        static char value[MAXVALLEN];
 
        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 && (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';
        while (np > value && isspace(*(np-1)))
                np--;
        *np = '\0';
@@ -3024,13 +3028,13 @@ void
 sortassoc()
 {
        if (numassoc > 1)
 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);
                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
  * assoccmp - compare two associations
  */
 static int
-#if defined(sgi)
+#if defined(sgi) || defined(SYS_BSDI)
 assoccmp(t1, t2)
        const void *t1;
        const void *t2;
 assoccmp(t1, t2)
        const void *t1;
        const void *t2;
@@ -3050,7 +3054,7 @@ assoccmp(ass1, ass2)
        struct association *ass1;
        struct association *ass2;
 {
        struct association *ass1;
        struct association *ass2;
 {
-#endif /* sgi */
+#endif /* sgi || bsdi */
        if (ass1->assid < ass2->assid)
                return -1;
        if (ass1->assid > ass2->assid)
        if (ass1->assid < ass2->assid)
                return -1;
        if (ass1->assid > ass2->assid)
index 17929ac..395a9ec 100644 (file)
@@ -217,6 +217,7 @@ checkassocid(value)
 
 /*
  * strsave - save a string
 
 /*
  * strsave - save a string
+ * XXX - should be in libntp.a
  */
 static char *
 strsave(str)
  */
 static char *
 strsave(str)
@@ -231,8 +232,8 @@ strsave(str)
                exit(1);
        }
 
                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++ = ',';
                
                if (cp != data)
                        *cp++ = ',';
-               bcopy(vl->name, cp, namelen);
+               memmove(cp, vl->name, namelen);
                cp += namelen;
                if (valuelen != 0) {
                        *cp++ = '=';
                cp += namelen;
                if (valuelen != 0) {
                        *cp++ = '=';
-                       bcopy(vl->value, cp, valuelen);
+                       memmove(cp, vl->value, valuelen);
                        cp += valuelen;
                }
        }
                        cp += valuelen;
                }
        }
@@ -600,7 +601,7 @@ readvar(pcmd, fp)
        else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
                return;
 
        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);
 
        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;
 
        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,
        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;
 
        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);
 
        if (pcmd->nargs >= 2)
                doaddvlist(tmplist, pcmd->argval[1].string);
 
@@ -802,7 +803,7 @@ mreadvar(pcmd, fp)
            &from, &to))
                return;
 
            &from, &to))
                return;
 
-       bzero((char *)tmplist, sizeof(tmplist));
+       memset((char *)tmplist, 0, sizeof(tmplist));
        if (pcmd->nargs >= 3)
                doaddvlist(tmplist, pcmd->argval[2].string);
 
        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[];
 
        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)) {
        gettstamp(&ts);
        
        while (nextvar(&datalen, &data, &name, &value)) {
index 57d86ba..6454ec1 100644 (file)
@@ -111,8 +111,8 @@ main(argc, argv)
        struct server *firstserver;
        int errflg;
        int c;
        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;
        extern char *Version;
 
        errflg = 0;
@@ -121,7 +121,7 @@ main(argc, argv)
        /*
         * Decode argument list
         */
        /*
         * 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;
                switch (c) {
                case 'd':
                        ++debug;
@@ -130,10 +130,10 @@ main(argc, argv)
                        nonames = 1;
                        break;
                case 'o':
                        nonames = 1;
                        break;
                case 'o':
-                       sys_version = atoi(optarg);
+                       sys_version = atoi(ntp_optarg);
                        break;
                case 'r':
                        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",
                        if (sys_retries < 1) {
                            (void)fprintf(stderr,
                                        "%s: retries (%d) too small\n",
@@ -142,7 +142,7 @@ main(argc, argv)
                        }
                        break;
                case 't':
                        }
                        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",
                        if (sys_timeout < 1) {
                            (void)fprintf(stderr,
                                        "%s: timeout (%d) too short\n",
@@ -160,7 +160,7 @@ main(argc, argv)
                        break;
                }
        
                        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);
                (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 (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");
                
        else
                firstserver = addservbyname("localhost");
                
@@ -502,7 +502,7 @@ struct in_addr *iap;
        }
 
        server = (struct server *)emalloc(sizeof(struct server));
        }
 
        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;
 
        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) {
        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;
                return 1;
        }
        return 0;
@@ -735,7 +735,7 @@ struct server *pp;
 
        if (pp->stratum == 1) {
                junk[4] = 0;
 
        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 {
                str = junk;
                (void) fprintf(fp, "'%s'", str);
        } else {
index 36dcf86..95de494 100644 (file)
@@ -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"
 
        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
        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
        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
 
 microtime.o: $(MICROTIME) assym.s
        cc -E -I. $(MICROTIME) | sed -e '/\.global _uniqtime/d' > $@.i
index 173c91b..29a3029 100644 (file)
@@ -92,7 +92,7 @@ depend:
 
 clean:
        -@rm -f $(LIBNAME).a $(KLIBNAME).a *.o *.out *.ln make.log Makefile.bak \
 
 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
        -@cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl clean
 
 distclean:     clean
index c1c01d2..5655d0a 100644 (file)
@@ -1,12 +1,12 @@
 #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_DCF7000)
 /*
 #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
  *
  *
  * 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,
  * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
  *                                    
  * This program is distributed in the hope that it will be useful,
index 363120b..b08dfec 100644 (file)
@@ -1,12 +1,12 @@
 #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_MEINBERG)
 /*
 #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
  *
  *
  * 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,
  * 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
  * 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
  *
  * Revision 3.9  1993/10/30  09:44:38  kardel
  * conditional compilation flag cleanup
  *
index 4a5ad56..2fd3cae 100644 (file)
@@ -1,12 +1,12 @@
 #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RAWDCF)
 /*
 #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
  *
  *
  * 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,
  * 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;
 {
   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;
     {
       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
  * 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
  *
  * Revision 3.7  1993/10/30  09:44:41  kardel
  * conditional compilation flag cleanup
  *
index 12b06fd..a8ec8a6 100644 (file)
@@ -1,12 +1,12 @@
 #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_SCHMID)
 /*
 #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
  *
  *
  * 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,
  * 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
  * 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)
  *
  * Revision 3.8  1993/11/01  20:00:18  kardel
  * parse Solaris support (initial version)
  *
index c9c124e..bfbf1e6 100644 (file)
@@ -1,6 +1,6 @@
 #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_TRIMSV6)
 /*
 #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
  */
  *
  * Trimble SV6 clock support
  */
@@ -106,6 +106,9 @@ cvt_trimsv6(buffer, size, format, clock)
  * History:
  *
  * clk_trimble.c,v
  * 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
  *
  * Revision 3.6  1993/10/30  09:44:45  kardel
  * conditional compilation flag cleanup
  *
index 7a36002..ed5fd9a 100644 (file)
@@ -1,8 +1,8 @@
 #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS))
 /*
 #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
  *
  *
  * Parser module for reference clock
  *
@@ -12,7 +12,7 @@
  * a struct timeval.
  * when PARSEKERNEL is not defined NTP time stamps will be used.
  *
  * 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,
  * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
  *                                    
  * This program is distributed in the hope that it will be useful,
  */
 
 #if    !(defined(lint) || defined(__GNUC__))
  */
 
 #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"
 
 #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)
 /*
 
 #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
  */
  * 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
 
 #endif
 
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
 #include "ntp_stdlib.h"
 
 #ifdef PARSESTREAM
 #include "ntp_stdlib.h"
 
 #ifdef PARSESTREAM
@@ -1139,6 +1148,12 @@ parse_setcs(dct, parse)
  * History:
  *
  * parse.c,v
  * 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
  *
  * Revision 3.17  1993/11/11  11:20:29  kardel
  * declaration fixes
  *
index 78ddb3a..0281c9d 100644 (file)
@@ -1,8 +1,8 @@
 #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS))
 /*
 #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
  *
  *
  * Parser configuration module for reference clocks
  *
@@ -12,7 +12,7 @@
  * a struct timeval.
  * when STREAM is not defined NTP time stamps will be used.
  *
  * 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,
  * 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
  * 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)
  *
  * Revision 3.11  1993/11/01  20:00:24  kardel
  * parse Solaris support (initial version)
  *
index 0da27e7..09fac28 100644 (file)
@@ -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!)
  *
  *
  * 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
  * 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
  */
 
 #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
 
 /*
 #endif
 
 /*
@@ -139,7 +139,7 @@ int Strcmp(s, t)
 /*ARGSUSED*/
 int _init(void)
 {
 /*ARGSUSED*/
 int _init(void)
 {
-  static char revision[] = "3.4";
+  static char revision[] = "3.9";
   char *s, *S, *t;
   
   /*
   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));
        * 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);
       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
          {
          }
        else
          {
+#if 0
            parseprintf(DD_RPUT,("parse: parserput - M_%s\n", (type == M_DATA) ? "DATA" : "BREAK"));
            parseprintf(DD_RPUT,("parse: parserput - M_%s\n", (type == M_DATA) ? "DATA" : "BREAK"));
-
+#endif
            if (type == M_DATA)
              {
                /*
            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);
            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)
          {
        
        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 */
       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);
 
       
       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 */
       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);
 
 
       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 */
 
 /*
 #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
        {
          /*
           * 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.
   /*
    * 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
  * 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
  *
  * 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)
  *
  * Revision 3.1  1993/11/01  20:00:29  kardel
  * parse Solaris support (initial version)
  *
- *
  */
  */
index 56ce07c..b371aed 100644 (file)
@@ -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)
  *
  *
  * 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,
  * 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
  */
 
 #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"
 #endif
 
 #include "sys/types.h"
@@ -195,7 +195,7 @@ int xxxinit(fc, vdp, vdi, vds)
        }
       else
         {
        }
       else
         {
-         static char revision[] = "3.9";
+         static char revision[] = "3.12";
          char *s, *S, *t;
          
          strncpy(ifm->f_name, mname, FMNAMESZ);
          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);
            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)
          {
        
        if (status)
          {
@@ -1250,6 +1258,15 @@ static void zs_xsisr(zs)
  * History:
  *
  * parsestreams.c,v
  * 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
  *
  * Revision 3.9  1993/11/05  15:34:55  kardel
  * shut up nice feature detection
  *
index a72100f..aa0b262 100644 (file)
@@ -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=
 #
 COMPILER= cc
 DEFS=
index 723e2c8..23934a8 100644 (file)
@@ -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)
  *
  *
  * 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!)
  *
  * 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,
  * 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>
 
 #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 *));
 #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
 
 #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_))
 #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 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; \
                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; \
 
 #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; \
 
 #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 PRINTF if (interactive) printf
+#define LPRINTF if (interactive && loop_filter_debug) printf
 
 #ifdef DEBUG
 #define dprintf(_x_) PRINTF _x_
 
 #ifdef DEBUG
 #define dprintf(_x_) PRINTF _x_
@@ -90,9 +105,31 @@ MUST DEFINE ONE OF "HAVE_TERMIOS" or "HAVE_TERMIO"
 
 extern int errno;
 
 
 extern int errno;
 
+/*
+ * display received data (avoids also detaching from tty)
+ */
 static int interactive = 0;
 static int interactive = 0;
+
+/*
+ * display loopfilter (clock control) variables
+ */
 static int loop_filter_debug = 0;
 
 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
 
 #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 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 */
 
 /*
 #define NOTICE_INTERVAL (20*60)        /* mention missing synchronisation every 20 minutes */
 
 /*
@@ -113,7 +150,7 @@ static char pat[] = "-\\|/";
  */
 
 #define USECSCALE      10
  */
 
 #define USECSCALE      10
-#define TIMECONSTANT   0
+#define TIMECONSTANT   2
 #define ADJINTERVAL    0
 #define FREQ_WEIGHT    18
 #define PHASE_WEIGHT   7
 #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) */
 
 /*
 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 */
  */
 #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 */
 {
 
 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;
   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 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;
 
 };
 
 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 */
 #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_))
 
 /*
 #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 */
  */
 #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
  */
 
  * 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 */
 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 }
 };
 
   { 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
 #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
 
 #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 */
 static struct partab
 {
   char offset;                 /* start bit of parity field */
@@ -254,6 +314,22 @@ static struct partab
   { 21 }, { 29 }, { 36 }, { 59 }
 };
 
   { 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];
 static struct dcfparam
 {
   unsigned char onebits[60];
@@ -264,13 +340,13 @@ static struct dcfparam
   "--------------------s-------p------p----------------------p"  /* 'ZERO' representation */
 };
 
   "--------------------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;
 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;
 }
 
   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;
 static unsigned pcheck(buf, idx)
   register unsigned char *buf;
   register int   idx;
@@ -303,6 +386,15 @@ static unsigned pcheck(buf, idx)
   return psum;
 }
 
   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;
 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))
     {
       /*
       pcheck(buffer, DCF_P_P3))
     {
       /*
-       * buffer OK
+       * buffer OK - extract all fields and build wall clock time from them
        */
 
       clock->flags  = 0;
        */
 
       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);
 
       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:
       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;
        }
 
          return CVT_FAIL|CVT_BADFMT;
        }
 
+      /*
+       * extract various warnings from DCF77
+       */
       if (ext_bf(buffer, DCF_A1))
        clock->flags |= DCFB_ANNOUNCE;
 
       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
  */
  * 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)
    * 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;
   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;
 
   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;
       /*
   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)
        {
        */
       if (!((ch+1) & ch) || !*s)
        {
-
+         /*
+          * character ok
+          */
          for (i = 0; ch; i++)
            {
              ch >>= 1;
          for (i = 0; ch; i++)
            {
              ch >>= 1;
@@ -433,6 +549,9 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
        }
       else
        {
        }
       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;
          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++;
     }
 
       s++;
     }
 
+  /*
+   * first cutoff estimate (average bit count - must be between both
+   * maxima)
+   */
   if (lowmax)
     {
       cutoff /= lowmax;
   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));
 
 
   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++)
     {
   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>"));
 
       highmax += histbuf[i];
       dprintf((" %d", histbuf[i]));
     }
   dprintf((" <M>"));
 
+  /*
+   * round up
+   */
   lowmax += highmax / 2;
 
   lowmax += highmax / 2;
 
+  /*
+   * calculate lower bit maximum (weighted sum / bit count)
+   *
+   * avoid divide by zero
+   */
   if (highmax)
     {
       lowmax /= highmax;
   if (highmax)
     {
       lowmax /= highmax;
@@ -474,9 +608,12 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
       lowmax = 0;
     }
 
       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;
   for (; i < BITS; i++)
     {
       highmax+=histbuf[i] * i;
@@ -485,6 +622,9 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
     }
   dprintf(("\n"));
 
     }
   dprintf(("\n"));
 
+  /*
+   * determine upper maximum (weighted sum / bit count)
+   */
   if (cutoff)
     {
       highmax /= cutoff;
   if (cutoff)
     {
       highmax /= cutoff;
@@ -494,34 +634,64 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
       highmax = BITS-1;
     }
 
       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])
        {
   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])
          {
        }
       else
         if (histbuf[cutoff] == histbuf[i])
          {
+           /*
+            * minimum not better yet - but it spans more than
+            * one bit value - follow it
+            */
            span = i;
          }
     }
 
            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));
 
   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)
        {
   s = buffer;
   while ((s < e) && *c && *b)
     {
       if (*s == (unsigned char)~0)
        {
+         /*
+          * invalid character
+          */
          *s = '?';
        }
       else
        {
          *s = '?';
        }
       else
        {
+         /*
+          * symbolic 1/0 representation
+          */
          *s = (*s >= cutoff) ? *b : *c;
        }
       s++;
          *s = (*s >= cutoff) ? *b : *c;
        }
       s++;
@@ -529,11 +699,19 @@ static unsigned long cvt_rawdcf(buffer, size, clock)
       c++;
     }
 
       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;
 }
 
   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
 time_t
-parse_to_unixtime(clock, cvtrtc)
+dcf_to_unixtime(clock, cvtrtc)
   register clocktime_t   *clock;
   register unsigned long *cvtrtc;
 {
   register clocktime_t   *clock;
   register unsigned long *cvtrtc;
 {
@@ -545,12 +723,22 @@ parse_to_unixtime(clock, cvtrtc)
   register int i;
   time_t t;
   
   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 < 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);
   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
    */
   /*
    * 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;
   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 */
     }
       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++;
 
   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];
   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 */
     }
 
       return -1;               /* bad day */
     }
 
+  /*
+   * collect days from date excluding the current one
+   */
   t += clock->day - 1;
   t += clock->day - 1;
+
                                /* hour */
   if (clock->hour < 0 || clock->hour >= 24)
     {
                                /* hour */
   if (clock->hour < 0 || clock->hour >= 24)
     {
@@ -594,6 +793,9 @@ parse_to_unixtime(clock, cvtrtc)
       return -1;               /* bad hour */
     }
 
       return -1;               /* bad hour */
     }
 
+  /*
+   * calculate hours from 1. 1. 1970
+   */
   t = TIMES24(t) + clock->hour;
 
                                /* min */
   t = TIMES24(t) + clock->hour;
 
                                /* min */
@@ -603,10 +805,16 @@ parse_to_unixtime(clock, cvtrtc)
       return -1;               /* bad min */
     }
 
       return -1;               /* bad min */
     }
 
+  /*
+   * calculate minutes from 1. 1. 1970
+   */
   t = TIMES60(t) + clock->minute;
                                /* sec */
   
   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 */
     {
 
   if (clock->second < 0 || clock->second > 60) /* allow for LEAPs */
     {
@@ -614,12 +822,15 @@ parse_to_unixtime(clock, cvtrtc)
       return -1;               /* bad sec */
     }
 
       return -1;               /* bad sec */
     }
 
+  /*
+   * calculate UTC in seconds - phew !
+   */
   t  = TIMES60(t) + clock->second;
                                /* done */
   return t;
 }
 
   t  = TIMES60(t) + clock->second;
                                /* done */
   return t;
 }
 
-/*
+/*-----------------------------------------------------------------------
  * cheap half baked 1/0 decision - for interactive operation only
  */
 static char type(c)
  * cheap half baked 1/0 decision - for interactive operation only
  */
 static char type(c)
@@ -629,6 +840,9 @@ unsigned char c;
   return (c > 0xF);
 }
 
   return (c > 0xF);
 }
 
+/*-----------------------------------------------------------------------
+ * week day representation
+ */
 static char *wday[8] =
 {
   "??",
 static char *wday[8] =
 {
   "??",
@@ -641,6 +855,9 @@ static char *wday[8] =
   "Su"
 };
 
   "Su"
 };
 
+/*-----------------------------------------------------------------------
+ * generate a string representation for a timeval
+ */
 static char * pr_timeval(val)
   struct timeval *val;
 {
 static char * pr_timeval(val)
   struct timeval *val;
 {
@@ -653,11 +870,20 @@ static char * pr_timeval(val)
   return buf;
 }
 
   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;
 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()");
   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;
 
 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;
 
   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()");
 }
 
   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;
 {
 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);
 
       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);
 
       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;
 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);
 
       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);
       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;
 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;
 
   register long usecoffset;
   int tmp;
 
+  if (no_set)
+    return;
+
   if (skip_adjust)
     {
       skip_adjust = 0;
   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);
       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);
 }
 
                  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;
 static void periodic_adjust()
 {
   register long adjustment;
@@ -803,9 +1045,13 @@ static void periodic_adjust()
   adj_time(adjustment);
 }
 
   adj_time(adjustment);
 }
 
+/*-----------------------------------------------------------------------
+ * control synchronisation status (warnings) and do periodic adjusts
+ * (frequency control simulation)
+ */
 static void tick()
 {
 static void tick()
 {
-  static unsigned long last_notice;
+  static unsigned long last_notice = 0;
 
 #ifndef SV_ONSTACK
   (void)signal(SIGALRM, tick);
 
 #ifndef SV_ONSTACK
   (void)signal(SIGALRM, tick);
@@ -815,11 +1061,29 @@ static void tick()
 
   ticks += 1<<ADJINTERVAL;
 
 
   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
     }
 
 #ifndef ITIMER_REAL
@@ -827,6 +1091,10 @@ static void tick()
 #endif
 }
 
 #endif
 }
 
+/*-----------------------------------------------------------------------
+ * break association from terminal to avaoid catching terminal
+ * or process group related signals (-> daemon operation)
+ */
 static void detach()
 {
   int s;
 static void detach()
 {
   int s;
@@ -855,18 +1123,26 @@ static void detach()
 #endif /* hpux */
 }
 
 #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);
 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-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;
 int
 main(argc, argv)
   int argc;
@@ -880,9 +1156,13 @@ main(argc, argv)
   int fd;
   int offset = 15;
   int offsets = 0;
   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;
 
   int trace = 0;
   int errs = 0;
 
+  /*
+   * process arguments
+   */
   while (--ac)
     {
       char *arg = *++a;
   while (--ac)
     {
       char *arg = *++a;
@@ -906,6 +1186,10 @@ main(argc, argv)
                    interactive = 1;
                    break;
 
                    interactive = 1;
                    break;
 
+              case 'n':
+                   no_set = 1;
+                   break;
+
              case 'o':
                    offsets = 1;
                    interactive = 1;
              case 'o':
                    offsets = 1;
                    interactive = 1;
@@ -915,6 +1199,19 @@ main(argc, argv)
                    interactive = 1;
                    break;
 
                    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)
                      {
              case 'd':
                    if (ac > 1)
                      {
@@ -958,6 +1255,9 @@ main(argc, argv)
 
   errs = LINES+1;
 
 
   errs = LINES+1;
 
+  /*
+   * get access to DCF77 tty port
+   */
   fd = open(file, O_RDONLY);
   if (fd == -1)
     {
   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;
       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)
       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;
       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");
       if (TTY_GETATTR(fd,  &term) == -1)
        {
          perror("tcgetattr");
@@ -1010,15 +1314,24 @@ main(argc, argv)
          exit(1);
        }
 
          exit(1);
        }
 
+      /*
+       * loose terminal if in daemon operation
+       */
       if (!interactive)
        detach();
       
       if (!interactive)
        detach();
       
+      /*
+       * get syslog() initialized
+       */
 #ifdef LOG_DAEMON
       openlog("dcfd", LOG_PID, LOG_DAEMON);
 #else
       openlog("dcfd", LOG_PID);
 #endif
 
 #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;
 #ifdef SV_ONSTACK
       {
        struct sigvec vec;
@@ -1064,10 +1377,19 @@ main(argc, argv)
 
       read_drift(drift_file);
 
 
       read_drift(drift_file);
 
+      /*
+       * what time is it now (for interval measurement)
+       */
       gettimeofday(&tlast, 0L);
       i = 0;
       gettimeofday(&tlast, 0L);
       i = 0;
+      /*
+       * loop until input trouble ...
+       */
       do
        {
       do
        {
+         /*
+          * get an impulse
+          */
          while ((rrc = read(fd, &c, 1)) == 1)
            {
              gettimeofday(&t, 0L);
          while ((rrc = read(fd, &c, 1)) == 1)
            {
              gettimeofday(&t, 0L);
@@ -1081,23 +1403,32 @@ main(argc, argv)
                  errs = 0;
                }
 
                  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)
                    {
              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;
                      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;
 
                        }
                      errs++;
                    }
 
                  buf[0] = c;
 
+                 /*
+                  * collect first character
+                  */
                  if (((c^0xFF)+1) & (c^0xFF))
                    pbuf[0] = '?';
                  else
                  if (((c^0xFF)+1) & (c^0xFF))
                    pbuf[0] = '?';
                  else
@@ -1110,6 +1441,9 @@ main(argc, argv)
                }
              else
                {
                }
              else
                {
+                 /*
+                  * collect character
+                  */
                  buf[i] = c;
 
                  /*
                  buf[i] = c;
 
                  /*
@@ -1125,12 +1459,34 @@ main(argc, argv)
 
              if (i == 0 && rtc == CVT_OK)
                {
 
              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");
                    }
 
                    {
                      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)
                }
 
              if (rtc == CVT_OK)
@@ -1142,14 +1498,25 @@ main(argc, argv)
 
                  if (i == 0)
                    {
 
                  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");
                        }
                      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;
                    }
 
                      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;
 
                  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],
                  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);
                }
                    }
                  lasterror = usecerror / (i+1);
                }
+             else
+               {
+                  lasterror = 0; /* we cannot calculate phase errors on bad reception */
+               }
 
              PRINTF("\r");
 
 
              PRINTF("\r");
 
@@ -1195,7 +1569,10 @@ main(argc, argv)
            }
        } while ((rrc == -1) && (errno == EINTR));
       
            }
        } 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);
     }
 
       (void)close(fd);
     }
index 4f26a0a..9028b4c 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * /src/NTP/REPOSITORY/v3/kernel/parsetest.c,v 3.4 1993/03/17 17:16:57 kardel Exp
  *
 /*
  * /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,
  * 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;
          
          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)
            ;
          
          while (ioctl(fd, I_POP, 0) == 0)
            ;
index e07bc0c..ebdfd2f 100644 (file)
@@ -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)
  *
  *
  * 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,
  * 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);
            }
 
              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;
          term.c_cc[VMIN] = 1;
          term.c_cflag = B50|CS8|CREAD|CLOCAL;
          term.c_iflag = 0;
index ece8dbe..d56f5c0 100644 (file)
@@ -102,7 +102,7 @@ gpsinit(fd)
        struct termios termios;
        speed_t speed = B4800;
 
        struct termios termios;
        speed_t speed = B4800;
 
-       bzero((char *)&termios, sizeof(termios));
+       memset((char *)&termios, 0, sizeof(termios));
        termios.c_cflag = CS8 | CREAD | CLOCAL;
        termios.c_iflag = IGNCR;
        termios.c_lflag = ICANON;
        termios.c_cflag = CS8 | CREAD | CLOCAL;
        termios.c_iflag = IGNCR;
        termios.c_lflag = ICANON;
index cb0563b..e86d43b 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef lint
 static char rcsid[] =
 #ifndef lint
 static char rcsid[] =
-    "ppsclock.c,v 3.1 1993/07/06 01:10:17 jbj Exp (LBL)";
+    "@(#) $Header: ppsclock.c,v 1.5 92/08/20 19:46:35 leres Exp $ (LBL)";
 #endif
 /*
  * This software was developed by the Computer Systems Engineering group
 #endif
 /*
  * This software was developed by the Computer Systems Engineering group
@@ -119,6 +119,15 @@ extern struct zsaline *zsaline;
 extern struct zsaline zsaline[];
 #endif
 
 extern struct zsaline zsaline[];
 #endif
 
+#ifdef PPS_SYNC
+/*
+ * The hardpps() routine is called at every pps interrupt in order to
+ * discipline the cpu clock oscillator. It requires corresponding kernel
+ * support.
+ */
+extern hardpps();
+#endif /* PPS_SYNC */
+
 /*
  * open CLOCK STREAMS module
  */
 /*
  * open CLOCK STREAMS module
  */
@@ -238,6 +247,15 @@ ppsclock_intr(zs)
 #endif
                                uniqtime(&ppsclockev.tv);
                        ++ppsclockev.serial;
 #endif
                                uniqtime(&ppsclockev.tv);
                        ++ppsclockev.serial;
+
+#ifdef PPS_SYNC
+                       /*
+                        * If the 1-pps cpu oscillator discipline has been
+                        * configured in the kernel, give it something to
+                        * chew on.
+                        */
+                       hardpps();
+#endif /* PPS_SYNC */
                }
                za->za_rr0 = s0;
                zsaddr->zscc_control = ZSWR0_RESET_STATUS;
                }
                za->za_rr0 = s0;
                zsaddr->zscc_control = ZSWR0_RESET_STATUS;
index d5e68d3..2829476 100644 (file)
@@ -11,14 +11,16 @@ WWVB        WWVB
        WWVBCLK         /LD/||/STREAM/          PPSPPS     LD||STREAM(tty_clock||tty_clk_streams)
        WWVBPPS         /PPSPPS/
 CHU    CHU             /SUNOS4/                           none
        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/
        CLOCK_*
 MX4200 MX4200PPS       /PPSPPS/
 AS2201 AS2201
        AS2201PPS       /PPSPPS/
 GOES   GOES
        GOESPPS         /PPSPPS/
+GPSTM  GPSTM
+       GPSTTMPPS       /PPSPPS/
 OMEGA  OMEGA
        OMEGAPPS        /PPSPPS/
 TPRO   TPRO            /SUNOS/
 OMEGA  OMEGA
        OMEGAPPS        /PPSPPS/
 TPRO   TPRO            /SUNOS/
diff --git a/contrib/xntpd/refclocks/rclk.GPSTM b/contrib/xntpd/refclocks/rclk.GPSTM
new file mode 100644 (file)
index 0000000..552747a
--- /dev/null
@@ -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
index 0bcf697..b91ed8b 100644 (file)
@@ -4,7 +4,7 @@ shift;
 
 . refclocks/setup
 
 
 . 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"
   case "$CMD" in
     info)
        echo "  PARSE           - GENERIC refence clock driver"
index 727f0a8..75f43fa 100644 (file)
@@ -81,11 +81,11 @@ else
     for i in $rcfg
     do
       sh $i config "$RCONFIG" "$PPSFEATURES" "$PPSOK" "$DEFS" "$REFCONF"
     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
        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`"
       PPS="-DPPSPPS $PPS"
     fi
     CLOCKDEFS="`tr '\012' ' ' < $RCONFIG`"
index 97fd4c7..c2be569 100644 (file)
@@ -19,7 +19,8 @@ if [ -f /bin/uname -o -f /usr/bin/uname ]; then
                sinix-m)
                        guess=sinix-m
                        ;;
                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" ;;
                        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
                        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
                # 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
 
        exit 0
 fi
 
+if [ -f /lib/clib -a -f /lib/libc ]; then
+       echo domainos
+       exit 0
+fi
+
 case "$guess" in
        '') guess="none"
 esac
 case "$guess" in
        '') guess="none"
 esac
index d1dc4c0..b661910 100644 (file)
@@ -323,8 +323,8 @@ err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
 if test -z "$err"; then
   {
 test -n "$verbose" && \
 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
 }
 
 fi
index f6afc99..c9d1455 100644 (file)
@@ -107,7 +107,7 @@ BEGIN {
        # select ITF records
        # see summary for decode
        #
        # 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++
                itf_count++
                if ($9 > 200e-9 || $9 < -200e-9)
                        itf_200++
@@ -122,7 +122,7 @@ BEGIN {
        # select ETF records
        # see summary for decode
        #
        # 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
                etf_count++
                if ($6 > etf_max)
                        etf_max = $6
index e27ecfa..ab99f4d 100644 (file)
@@ -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 
 #
 # 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
index 1115ef8..be1681f 100644 (file)
@@ -32,7 +32,7 @@ EXECS=                ntptime jitter timetrim kern byteorder longsize precision
 all:   $(PROGRAM)
 
 tickadj: $(TKOBJS)
 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)
 
 ntptime: $(NTOBJS)
        $(CC) $(COPTS) -o $@ $(NTOBJS) $(LIB)
index e528802..c0512df 100644 (file)
@@ -37,7 +37,6 @@
 
 extern int sigvec      P((int, struct sigvec *, struct sigvec *));
 void pll_trap          P((void));
 
 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 */
 
 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[];
 {
        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;
        int status;
        struct ntptimeval ntv;
        struct timex ntx, _ntx;
@@ -66,46 +65,47 @@ main(argc, argv)
 
        ntx.mode = 0;
         progname = argv[0];
 
        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;
                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;
                        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;
                        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;
                        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;
                        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;
                        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 (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\
                (void) fprintf(stderr,
                        "usage: %s [-%s]\n\n\
        -c              display the time taken to call ntp_gettime (us)\n\
index da18e06..ab10b37 100644 (file)
@@ -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 *));
 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
 
 /*
  * main - parse arguments and handle options
@@ -75,8 +72,8 @@ char *argv[];
 {
        int c;
        int errflg = 0;
 {
        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;
        unsigned long tickadj_offset;
        unsigned long tick_offset;
        unsigned long dosync_offset;
@@ -94,7 +91,7 @@ char *argv[];
        void writevar();
 
        progname = argv[0];
        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;
                switch (c) {
                case 'd':
                        ++debug;
@@ -109,11 +106,11 @@ char *argv[];
                        quiet = 1;
                        break;
                case 'a':
                        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",
                        if (writetickadj <= 0) {
                                (void) fprintf(stderr,
                                    "%s: unlikely value for tickadj: %s\n",
-                                   progname, optarg);
+                                   progname, ntp_optarg);
                                errflg++;
                        }
                        break;
                                errflg++;
                        }
                        break;
@@ -124,11 +121,11 @@ char *argv[];
                        unsetdosync = 1;
                        break;
                case 't':
                        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",
                        if (writetick <= 0) {
                                (void) fprintf(stderr,
                                    "%s: unlikely value for tick: %s\n",
-                                   progname, optarg);
+                                   progname, ntp_optarg);
                                errflg++;
                        }
                        break;
                                errflg++;
                        }
                        break;
@@ -136,7 +133,7 @@ char *argv[];
                        errflg++;
                        break;
                }
                        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);
                (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");
        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");
        }
 
        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");
        }
        
        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");
        }
 
        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)
        
        if (writetickadj == 0 && !writeopttickadj &&
            !unsetdosync && writetick == 0 && !setnoprintf)
-               exit(0);
+               exit(errflg ? 1 : 0);
 
        if (writetickadj == 0 && writeopttickadj)
                writetickadj = recommend_tickadj;
 
        if (writetickadj == 0 && writeopttickadj)
                writetickadj = recommend_tickadj;
@@ -283,7 +280,7 @@ char *argv[];
                        (void) fprintf(stderr, "done!\n");
        }
        (void) close(fd);
                        (void) fprintf(stderr, "done!\n");
        }
        (void) close(fd);
-       exit(0);
+       exit(errflg ? 1 : 0);
 }
 
 /*
 }
 
 /*
index a51dbd7..ec600ac 100644 (file)
@@ -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_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 \
 
 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_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)
 
 
 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_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
index 1a0e9ef..1b716f6 100644 (file)
@@ -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 */
  * 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_PPS             24
 #define        CONFIG_PIDFILE          25
 #define        CONFIG_LOGFILE          26
+#define CONFIG_SETVAR          27
 
 #define        CONF_MOD_VERSION        1
 #define        CONF_MOD_KEY            2
 
 #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 },
        { "statistics",         CONFIG_STATISTICS },
        { "pidfile",            CONFIG_PIDFILE },
        { "logfile",            CONFIG_LOGFILE },
+       { "setvar",             CONFIG_SETVAR },
        { "",                   CONFIG_UNKNOWN }
 };
 
        { "",                   CONFIG_UNKNOWN }
 };
 
@@ -316,7 +318,7 @@ extern int debug;
 #endif
 extern char *FindConfig();
        char *progname;
 #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 *));
 
 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;
 #ifdef DEBUG
        int errflg;
        int c;
-       extern int optind;
+       extern int ntp_optind;
 
        debug = 0;              /* no debugging by default */
 
 
        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
         * 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;
         * way.  Your own mileage may vary.
         */
        errflg = 0;
@@ -361,7 +363,7 @@ getstartup(argc, argv)
        /*
         * Decode argument list
         */
        /*
         * 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;
                switch (c) {
                case 'd':
                        ++debug;
@@ -373,12 +375,14 @@ getstartup(argc, argv)
                        break;
                }
        
                        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);
        }
                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
 
        if (debug) {
 #ifdef NTP_POSIX_SOURCE
@@ -426,8 +430,9 @@ getconfig(argc, argv)
        char resolver_name[MAXFILENAME];
        int have_keyfile;
        char keyfile[MAXFILENAME];
        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;
 
        extern U_LONG info_auth_keyid;
        FILEGEN *filegen;
 
@@ -443,6 +448,12 @@ getconfig(argc, argv)
        res_fp = NULL;
        have_resolver = have_keyfile = 0;
 
        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
 #ifdef RESOLVE_INTERNAL
        resolve_internal = 1;
 #endif
@@ -450,7 +461,7 @@ getconfig(argc, argv)
        /*
         * Decode argument list
         */
        /*
         * 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);
                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':
                        proto_config(PROTO_BROADCLIENT, (LONG)1);
                        break;
                case 'c':
-                       config_file = optarg;
+                       config_file = ntp_optarg;
                        break;
                case 'd':
 #ifdef DEBUG
                        break;
                case 'd':
 #ifdef DEBUG
@@ -473,15 +484,15 @@ getconfig(argc, argv)
                        do {
                                l_fp tmp;
                                
                        do {
                                l_fp tmp;
                                
-                               if (!atolfp(optarg, &tmp)) {
+                               if (!atolfp(ntp_optarg, &tmp)) {
                                        syslog(LOG_ERR,
                        "command line encryption delay value %s undecodable",
                                        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",
                                        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);
                                        errflg++;
                                } else {
                                        proto_config(PROTO_AUTHDELAY, tmp.l_f);
@@ -490,37 +501,37 @@ getconfig(argc, argv)
                        break;
                        
                case 'f':
                        break;
                        
                case 'f':
-                       stats_config(STATS_FREQ_FILE, optarg);
+                       stats_config(STATS_FREQ_FILE, ntp_optarg);
                        break;
 
                case 'k':
                        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;
                                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':
                        }
                        break;
 
                case 'p':
-                       stats_config(STATS_PID_FILE, optarg);
+                       stats_config(STATS_PID_FILE, ntp_optarg);
                        break;
 
                case 'r':
                        do {
                                l_fp tmp;
                                
                        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",
                                        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",
                                } 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);
                                }
                                } else {
                                        proto_config(PROTO_BROADDELAY, tmp.l_f);
                                }
@@ -528,24 +539,28 @@ getconfig(argc, argv)
                        break;
                        
                case 's':
                        break;
                        
                case 's':
-                       stats_config(STATS_STATSDIR, optarg);
+                       stats_config(STATS_STATSDIR, ntp_optarg);
                        break;
                        
                case 't':
                        do {
                                int tkey;
                                
                        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",
                                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;
                        
                                } 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++;
                        
                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);
                (void) fprintf(stderr,
                    "usage: %s [ -bd ] [ -c config_file ]\n", progname);
                exit(2);
@@ -1129,7 +1144,7 @@ getconfig(argc, argv)
                                break;
                        }
                        
                                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],
                        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;
                                    (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);
                }
        }
        (void) fclose(fp);
@@ -1445,6 +1472,7 @@ gettokens(fp, line, tokenlist, ntokens)
        register char *cp;
        register int eol;
        register int ntok;
        register char *cp;
        register int eol;
        register int ntok;
+       register int quoted = 0;
 
        /*
         * Find start of first token
 
        /*
         * Find start of first token
@@ -1469,8 +1497,9 @@ again:
        ntok = 0;
        while (!eol) {
                tokenlist[ntok++] = cp;
        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;
                if (ISEOL(*cp)) {
                        *cp = '\0';
                        eol = 1;
@@ -1581,7 +1610,7 @@ getnetnum(num, addr, complain)
        /*
         * make up socket address.  Clear it out for neatness.
         */
        /*
         * 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);
        addr->sin_family = AF_INET;
        addr->sin_port = htons(NTP_PORT);
        addr->sin_addr.s_addr = htonl(netnum);
index 5e71196..f638367 100644 (file)
@@ -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>
  * 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 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));
 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 }
 };
 
        { 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.
 /*
  * 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_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,    ""      }
 };
 
        { 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)
  */
 /*
  * 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_OFFSET,
        CS_DRIFT,
        CS_COMPLIANCE,
-       CS_VERSION,
        0
 };
 
        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_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,    ""      }
 };
 
        { 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_FUDGEVAL2, RO,     "fudgeval2" },  /* 10 */
        { CC_FLAGS,     RO,     "flags" },      /* 11 */
        { CC_DEVICE,    RO,     "device" },     /* 12 */
+       { CC_VARLIST,   RO,     "clock_var_list" },/* 13 */
        { 0,            EOV,    ""      }
 };
 
        { 0,            EOV,    ""      }
 };
 
@@ -283,8 +264,15 @@ static     u_char def_clock_var[] = {
 /*
  * System and processor definitions.  These will change for the gizmo board.
  */
 /*
  * System and processor definitions.  These will change for the gizmo board.
  */
+#ifndef STR_SYSTEM
 #define        STR_SYSTEM      "UNIX"
 #define        STR_SYSTEM      "UNIX"
+#endif
+#ifndef STR_PROCESSOR
 #define        STR_PROCESSOR   "unknown"
 #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
 
 /*
  * Trap structures.  We only allow a few of these, and send
@@ -872,7 +860,7 @@ ctl_putdata(dp, dlen, bin)
                ctl_flushpkt(CTL_MORE);
        }
 
                ctl_flushpkt(CTL_MORE);
        }
 
-       bcopy(dp, (char *)datapt, dlen);
+       memmove((char *)datapt, dp, dlen);
        datapt += dlen;
        datalinelen += 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;
                *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++ = '"';
        }
                cp += len;
                *cp++ = '"';
        }
@@ -1221,7 +1209,6 @@ static void
 ctl_putsys(varid)
        int varid;
 {
 ctl_putsys(varid)
        int varid;
 {
-       extern char *Version;
        l_fp tmp;
 
        switch (varid) {
        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_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:
                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);
                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_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;
        }
 }
                break;
        }
 }
@@ -1428,6 +1472,46 @@ ctl_putpeer(varid, peer)
        case CP_SENT:
                ctl_putuint(peer_var[CP_SENT].text, peer->sent);
                break;
        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;
                            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
        }
 }
 #endif
@@ -1517,6 +1663,7 @@ ctl_getitem(var_list, data)
 {
        register struct ctl_var *v;
        register char *cp, *tp;
 {
        register struct ctl_var *v;
        register char *cp, *tp;
+       static struct ctl_var eol = { 0, EOV, };
        static char buf[128];
 
        /*
        static char buf[128];
 
        /*
@@ -1528,6 +1675,9 @@ ctl_getitem(var_list, data)
 
        if (reqpt >= reqend)
                return 0;
 
        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
        
        /*
         * 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 (!(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++;
                        }
                                cp++;
                                tp++;
                        }
-                       if (*tp == '\0') {
+                       if ((*tp == '\0') || (*tp == '=')) {
                                while (cp < reqend && isspace(*cp))
                                        cp++;
                                if (cp == reqend || *cp == ',') {
                                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;
        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) {
                /*
 
        if (res_associd == 0) {
                /*
@@ -1696,12 +1846,24 @@ read_variables(rbufp, restrict)
                rpkt.status = htons(ctlsysstatus());
                if (res_authokay)
                        ctl_sys_num_events = 0;
                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) {
                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;
                        }
                        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 = 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;
                } else {
                        register u_char *cs;
+                       register struct ctl_var *kv;
 
                        for (cs = def_sys_var; *cs != 0; cs++)
 
                        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;
 
        } 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;
                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);
                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;
                                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);
                }
                        for (cp = def_peer_var; *cp != 0; cp++)
                                ctl_putpeer((int)*cp, peer);
                }
+               free((char *)wants);
        }
        ctl_flushpkt(0);
 }
        }
        ctl_flushpkt(0);
 }
@@ -1768,6 +1942,7 @@ write_variables(rbufp, restrict)
        int restrict;
 {
        register struct ctl_var *v;
        int restrict;
 {
        register struct ctl_var *v;
+       register int ext_var;
        char *valuep;
        LONG val;
        u_char leapind, leapwarn;
        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) {
         * 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) {
                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 (!(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;
                }
                        ctl_error(CERR_BADFMT);
                        return;
                }
-               if ((val & ~LEAP_NOTINSYNC) != 0) {
+               if (!ext_var && (val & ~LEAP_NOTINSYNC) != 0) {
                        ctl_error(CERR_BADVALUE);
                        return;
                }
 
                        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;
        register int i;
        register struct peer *peer;
        char *valuep;
-       u_char wants[CC_MAXCODE+1];
+       u_char *wants;
        int gotvar;
        struct refclockstat clock;
 
        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.
         */
        /*
         * 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));
        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;
        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) {
                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;
                }
                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 = 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;
        } 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 (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
 }
        ctl_flushpkt(0);
 #endif
 }
@@ -2237,13 +2462,23 @@ report_event(err, peer)
                 */
                if (err == EVNT_CLOCKEXCPT) {
                        struct refclockstat clock;
                 */
                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));
                                         (struct refclockstat *)0,
                                         &clock);
                        ctl_puthex("refclockstatus",
                                   (U_LONG)ctlclkstatus(&clock));
+
                        for (i = 1; i <= CC_MAXCODE; i++)
                                        ctl_putclock(i, &clock, 0);
                        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 {
                }
 #endif /*REFCLOCK*/
        } else {
@@ -2262,13 +2497,24 @@ report_event(err, peer)
                         */
                        if (err == EVNT_PEERCLOCK) {
                                struct refclockstat clock;
                         */
                        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);
                                refclock_control(&peer->srcadr,
                                                 (struct refclockstat *)0,
                                                 &clock);
+
                                ctl_puthex("refclockstatus",
                                           (U_LONG)ctlclkstatus(&clock));
                                ctl_puthex("refclockstatus",
                                           (U_LONG)ctlclkstatus(&clock));
+
                                for (i = 1; i <= CC_MAXCODE; i++)
                                        ctl_putclock(i, &clock, 0);
                                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*/
        }
                        }
 #endif /*REFCLOCK*/
        }
@@ -2303,3 +2549,115 @@ ctl_clr_stats()
        numctlbadop = 0;
        numasyncmsgs = 0;
 }
        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);
+    }
+}
index bbbd242..55cf1ae 100644 (file)
@@ -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
  *
  *  implements file generations support for NTP
  *  logfiles and statistic files
index ebd3d52..20561e9 100644 (file)
@@ -294,7 +294,7 @@ addentry(name, mode, version, minpoll, maxpoll, flags, keyid)
 
        len = strlen(name) + 1;
        cp = emalloc((unsigned)len);
 
        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;
 
        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)
                extern int h_errno;
 
                if (h_errno == TRY_AGAIN)
-                       return 1;
+                       return (1);
 #endif
 #endif
-               return 0;
+               return (0);
        }
 
        /*
        }
 
        /*
@@ -357,9 +357,10 @@ findhostaddr(entry)
         * tell preferences and older gethostbyname() implementations
         * only return one.
         */
         * 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);
        }
 
                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 */
        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
         */
        /*
         * 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 */
 
        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));
        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);
        reqpkt.keyid = htonl(req_keyid);
 
        auth1crypt(req_keyid, (U_LONG *)&reqpkt, REQ_LEN_NOMAC);
index e765b03..614d5c5 100644 (file)
  * better to drop a packet than to be inaccurate.
  */
 
  * better to drop a packet than to be inaccurate.
  */
 
-/*
- * select network interfacing
- */
-#if defined(SYS_SVR4) || defined(SYS_PTX) || defined(SYS_SINIXM)
-#define STREAMS_TLI
-#endif
-
 /*
  * Block the interrupt, for critical sections.
  */
 /*
  * 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
 #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;
                inter_list[i].bfd = open_socket(&inter_list[i].bcast, 0);
                inter_list[i].flags |= INT_BCASTOPEN;
+#endif
        }
 }
 
        }
 }
 
index d74da99..6d79c5d 100644 (file)
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
-#if defined(STREAM)
+#ifdef HAVE_TERMIOS
 #include <termios.h>
 #include <termios.h>
+#endif
+#if defined(STREAM)
 #include <stropts.h>
 #if defined(PPSCLK)
 #include <sys/clkdefs.h>
 #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 */
         */
        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
         *
         * 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;
         }
                    "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)
     }
 #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(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;
                 * (termios interface)
                 */
     {          struct termios ttyb, *ttyp;
@@ -778,7 +782,7 @@ loop_config(item, lfp_value, int_value)
                if (tcsetattr(fdpps, TCSANOW, ttyp) < 0)
                        return;
     }
                if (tcsetattr(fdpps, TCSANOW, ttyp) < 0)
                        return;
     }
-#endif /* STREAM */
+#endif /* HAVE_TERMIOS */
 #if defined(HAVE_BSD_TTYS)
 
                /*
 #if defined(HAVE_BSD_TTYS)
 
                /*
index 5d589e8..63af8d4 100644 (file)
@@ -102,7 +102,7 @@ init_mon()
        mon_free = 0;
        mon_hash = 0;
        mon_hash_count = 0;
        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));
        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;
                mon_hash_count = (int *)emalloc(MON_HASH_SIZE * sizeof(int));
                mon_free_mem = 0;
                mon_total_mem = 0;
index 5e3b134..cadd415 100644 (file)
@@ -439,7 +439,7 @@ newpeer(srcadr, dstadr, hmode, version, minpoll, maxpoll, key)
         *
         * Zero the whole thing for now.  We might be pickier later.
         */
         *
         * 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)
 
        peer->srcadr = *srcadr;
        if (dstadr != 0)
index a132624..88e95bb 100644 (file)
@@ -1078,7 +1078,7 @@ clock_update(peer)
                sys_refid = peer->refid;
        else {
                if (pps_control)
                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;
        }
                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
                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
        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++)
        peer->hpoll = peer->minpoll;
        peer->dispersion = NTP_MAXDISPERSE;
        for (i = 0; i < NTP_SHIFT; i++)
index 96def3f..c19d192 100644 (file)
@@ -312,7 +312,7 @@ more_pkt()
                /*
                 * Copy data out of exbuf into the packet.
                 */
                /*
                 * 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;
                seqno++;
                databytes = 0;
                nitems = 0;
@@ -682,7 +682,7 @@ peer_info (srcadr, inter, inpkt)
        struct sockaddr_in addr;
        extern struct peer *sys_peer;
 
        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;
        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;
 
        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;
        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;
         */
        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);
 
        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;
         */
        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;
 
        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
         */
        /*
         * 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);
 
        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;
 
        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);
        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;
                }
                        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;
                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);
 
                ic->fudgeval1 = htonl(clock.fudgeval1);
                ic->fudgeval2 = htonl(clock.fudgeval2);
 
+               free_varlist(clock.kv_list);
+
                ic = (struct info_clock *)more_pkt();
        }
        flush_pkt();
                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;
 
        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);
        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;
 
        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);
        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;
                }
 
                        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);
                refclock_buginfo(&addr, &bug);
                if (bug.nvalues == 0 && bug.ntimes == 0) {
                        req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
index 9bd9779..51d8968 100644 (file)
@@ -81,7 +81,7 @@ init_restrict()
         * Zero the list and put all but one on the free list
         */
        resfree = 0;
         * 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;
 
        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));
                        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++) {
                                    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--;
                    && !(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;
 
                        rl->next = resfree;
                        resfree = rl;
index 4ac7cd2..6b66183 100644 (file)
@@ -9,7 +9,7 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
 #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
 #include <sys/param.h>
 #include <utmp.h>
 #endif
@@ -20,9 +20,9 @@
 #include "ntp_stdlib.h"
 
 #if defined(HAVE_LIBKVM)
 #include "ntp_stdlib.h"
 
 #if defined(HAVE_LIBKVM)
-#ifdef __bsdi__
+#ifdef SYS_BSDI
 #include <sys/proc.h>
 #include <sys/proc.h>
-#endif /* __bsdi__ */
+#endif /* SYS_BSDI */
 #include <kvm.h>
 #include <limits.h>
 
 #include <kvm.h>
 #include <limits.h>
 
@@ -440,8 +440,12 @@ clock_parms(tickadj, tick)
 {
 #ifdef RS6000
        *tickadj = 1000;
 {
 #ifdef RS6000
        *tickadj = 1000;
-#else
+#else  /*RS6000*/
+#if  SYS_DOMAINOS
+       *tickadj = 668;
+#else  /*SYS_DOMAINOS*/
        *tickadj = 500 / HZ;
        *tickadj = 500 / HZ;
+#endif /*SYS_DOMAINOS*/
 #endif /*RS6000*/
        *tick = 1000000L / HZ;
 
 #endif /*RS6000*/
        *tick = 1000000L / HZ;
 
index 394d6df..4cbb7ac 100644 (file)
@@ -165,7 +165,7 @@ hourly_stats()
  skip:
 #endif
 
  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) {
               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")));
 
                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
                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));
        
        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);
 }
 
        authreadkeys(key_file_name);
 }
index f29f741..abe86d9 100644 (file)
 #endif
 
 #if defined(SYS_SVR4)
 #endif
 
 #if defined(SYS_SVR4)
-#include <sys/termios.h>
+#include <termios.h>
 #endif
 
 #if (defined(SYS_SOLARIS)&&!defined(bsd)) || defined(__svr4__)
 #endif
 
 #if (defined(SYS_SOLARIS)&&!defined(bsd)) || defined(__svr4__)
-#include <sys/termios.h>
+#include <termios.h>
 #endif
 
 #include "ntpd.h"
 #endif
 
 #include "ntpd.h"
@@ -139,7 +139,7 @@ main(argc, argv)
                        (void) dup2(0, 1);
                        (void) dup2(0, 2);
 #ifdef NTP_POSIX_SOURCE
                        (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);
                        (void) setsid();
 #else
                        (void) setpgid(0, 0);
@@ -154,12 +154,12 @@ main(argc, argv)
                        if (fork())
                                exit(0);
 #else /* SYS_HPUX */
                        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?
  */
 /*
  * 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;
 
                        {
                                int fid;
 
@@ -169,8 +169,9 @@ main(argc, argv)
                                                (char *) 0);
                                        (void) close(fid);
                                }
                                                (char *) 0);
                                        (void) close(fid);
                                }
+                               (void) setpgrp(0, getpid());
                        }
                        }
-#endif /* apollo */
+#endif /* SYS_DOMAINOS */
 #endif /* SYS_HPUX */
 #endif /* NTP_POSIX_SOURCE */
                }
 #endif /* SYS_HPUX */
 #endif /* NTP_POSIX_SOURCE */
                }
index f04d6d0..97b5837 100644 (file)
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
 #include <termios.h>
 #include <termios.h>
+#endif
+#if defined(STREAM)
 #include <stropts.h>
 #if defined(AS2201CLK)
 #include <sys/clkdefs.h>
 #include <stropts.h>
 #if defined(AS2201CLK)
 #include <sys/clkdefs.h>
@@ -248,8 +250,8 @@ as2201_init()
        /*
         * Just zero the data arrays
         */
        /*
         * 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.
 
        /*
         * Initialize fudge factors to default.
@@ -324,9 +326,9 @@ as2201_start(unit, peer)
         }
     }
 #endif /* HAVE_SYSV_TTYS */
         }
     }
 #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.
         *
         * 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;
         }
                    "as2201_start: tcflush(%s): %m", as2201dev);
                 goto screwed;
         }
+    }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
 #if defined(AS2201CLK)
 #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)
 #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 /* AS2201PPS */
-    }
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
@@ -437,7 +441,7 @@ as2201_start(unit, peer)
                            emalloc(sizeof(struct gpsunit));
                }
        }
                            emalloc(sizeof(struct gpsunit));
                }
        }
-       bzero((char *)gps, sizeof(struct gpsunit));
+       memset((char *)gps, 0, sizeof(struct gpsunit));
        gpsunits[unit] = gps;
 
        /*
        gpsunits[unit] = gps;
 
        /*
@@ -475,7 +479,7 @@ as2201_start(unit, peer)
        peer->rootdispersion = 0;
        peer->stratum = stratumtouse[unit];
        if (stratumtouse[unit] <= 1)
        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;
        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)
                                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);
                        }
                                else
                                        peer->refid = htonl(GPSHSREFID);
                        }
index 05379b6..1c7c3bf 100644 (file)
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
 #include <termios.h>
 #include <termios.h>
+#endif
+#if defined(STREAM)
 #include <stropts.h>
 #endif /* STREAM */
 
 #include <stropts.h>
 #endif /* STREAM */
 
@@ -291,8 +293,8 @@ chu_init()
        /*
         * Just zero the data arrays
         */
        /*
         * 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.
 
        /*
         * Initialize fudge factors to default.
@@ -352,9 +354,9 @@ chu_start(unit, peer)
         */
        CHU SUPPORT NOT AVAILABLE IN TERMIO INTERFACE
 #endif /* HAVE_SYSV_TTYS */
         */
        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
         *
         * 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;
         }
                    "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 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 /* CHUPPS */
-    }
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
@@ -457,7 +461,7 @@ chu_start(unit, peer)
                        chu = (struct chuunit *)emalloc(sizeof(struct chuunit));
                }
        }
                        chu = (struct chuunit *)emalloc(sizeof(struct chuunit));
                }
        }
-       bzero((char *)chu, sizeof(struct chuunit));
+       memset((char *)chu, 0, sizeof(struct chuunit));
        chuunits[unit] = chu;
 
        /*
        chuunits[unit] = chu;
 
        /*
@@ -494,11 +498,11 @@ chu_start(unit, peer)
        peer->rootdispersion = 0;
        peer->stratum = stratumtouse[unit];
        if (stratumtouse[unit] <= 1)
        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;
        else
                peer->refid = htonl(CHUHSREFID);
        unitinuse[unit] = 1;
-       return 1;
+       return (1);
 
        /*
         * Something broke; abandon ship.
 
        /*
         * 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)
                                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);
                        }
                                else
                                        peer->refid = htonl(CHUHSREFID);
                        }
index efe0966..430c4a6 100644 (file)
@@ -92,6 +92,12 @@ extern       struct refclock         refclock_msfees;
 #define refclock_msfees        refclock_none
 #endif
 
 #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;
 /*
  * 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_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 *);
 };
 
 u_char num_refclock_conf = sizeof(refclock_conf)/sizeof(struct refclock *);
index 60b19f6..0b53326 100644 (file)
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
 #include <termios.h>
 #include <termios.h>
+#endif
+#if defined(STREAM)
 #include <stropts.h>
 #if defined(GOESCLK)
 #include <clkdefs.h>
 #include <stropts.h>
 #if defined(GOESCLK)
 #include <clkdefs.h>
@@ -51,7 +53,7 @@
  *   space   less than 1 millisecond
  * C - Carriage return
  * L - Line feed
  *   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.
  *
  * 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
         */
        /*
         * 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.
 
        /*
         * Initialize fudge factors to default.
@@ -283,9 +285,9 @@ goes_start(unit, peer)
         }
     }
 #endif /* HAVE_SYSV_TTYS */
         }
     }
 #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.
         *
         * 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;
         }
                    "goes_start: tcflush(%s): %m", goesdev);
                 goto screwed;
         }
+    }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
 #if defined(GOESCLK)
 #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)
 #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 /* GOESPPS */
-    }
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
@@ -396,7 +400,7 @@ goes_start(unit, peer)
                            emalloc(sizeof(struct goesunit));
                }
        }
                            emalloc(sizeof(struct goesunit));
                }
        }
-       bzero((char *)goes, sizeof(struct goesunit));
+       memset((char *)goes, 0, sizeof(struct goesunit));
        goesunits[unit] = goes;
 
        /*
        goesunits[unit] = goes;
 
        /*
@@ -424,7 +428,7 @@ goes_start(unit, peer)
        peer->rootdispersion = 0;
        peer->stratum = stratumtouse[unit];
        if (stratumtouse[unit] <= 1)
        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;
        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)
                                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);
                        }
                                else
                                        peer->refid = htonl(GOESHSREFID);
                        }
diff --git a/contrib/xntpd/xntpd/refclock_gpstm.c b/contrib/xntpd/xntpd/refclock_gpstm.c
new file mode 100644 (file)
index 0000000..93abcf9
--- /dev/null
@@ -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*/
index fb94241..40345bb 100644 (file)
@@ -169,8 +169,8 @@ irig_init()
        /*
          * Just zero the data arrays
          */
        /*
          * 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.
 
        /*
          * Initialize fudge factors to default.
@@ -250,7 +250,7 @@ struct peer *peer;
                            emalloc(sizeof(struct irigunit));
                }
        }
                            emalloc(sizeof(struct irigunit));
                }
        }
-       bzero((char *) irig, sizeof(struct irigunit));
+       memset((char *) irig, 0, sizeof(struct irigunit));
 
        irigunits[unit] = irig;
 
 
        irigunits[unit] = irig;
 
@@ -276,7 +276,7 @@ struct peer *peer;
        peer->rootdispersion = 0;
        peer->stratum = stratumtouse[unit];
        if (stratumtouse[unit] <= 1)
        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;
        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)
                                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);
                        }
                                else
                                        peer->refid = htonl(IRIGHSREFID);
                        }
index 0fa996c..3307129 100644 (file)
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
 #include <termios.h>
 #include <termios.h>
+#endif
+#ifdef STREAM
 #include <stropts.h>
 #if defined(LEITCHCLK)
 #include <sys/clkdefs.h>
 #include <stropts.h>
 #if defined(LEITCHCLK)
 #include <sys/clkdefs.h>
@@ -142,8 +144,8 @@ struct      refclock refclock_leitch = {
 static void
 leitch_init()
 {
 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];
        }
 
        leitch = &leitchunits[unit];
-       bzero((char*)leitch,sizeof(*leitch));
+       memset((char*)leitch, 0, sizeof(*leitch));
 
 #if defined(HAVE_SYSV_TTYS)
        /*
 
 #if defined(HAVE_SYSV_TTYS)
        /*
@@ -293,9 +295,9 @@ leitch_start(unit, peer)
         }
     }
 #endif /* HAVE_SYSV_TTYS */
         }
     }
 #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.
         *
         * 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;
         }
                    "leitch_start: tcflush(%s): %m", leitchdev);
                 goto screwed;
         }
+    }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
 #if defined(LEITCHCLK)
 #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)
 #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 /* LEITCHPPS */
-    }
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
index 0925a7d..1323ca9 100644 (file)
@@ -100,8 +100,8 @@ local_init()
        /*
         * Just zero the data arrays
         */
        /*
         * 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));
                }
        }
                        lcl = (struct lclunit *)emalloc(sizeof(struct lclunit));
                }
        }
-       bzero((char *)lcl, sizeof(struct lclunit));
+       memset((char *)lcl, 0, sizeof(struct lclunit));
        lclunits[unit] = lcl;
 
        /*
        lclunits[unit] = lcl;
 
        /*
@@ -166,7 +166,7 @@ local_start(unit, peer)
        peer->rootdispersion = LCLROOTDISPERSION;
        peer->stratum = (u_char)unit;
        if (unit <= 1)
        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;
        else
                peer->refid = htonl(LCLHSREFID);
        unitinuse[unit] = 1;
index 699ff0d..b301bc2 100644 (file)
@@ -379,8 +379,8 @@ static void msfees_init()
 {
        register int i;
        /* Just zero the data arrays */
 {
        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);
 
        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));
        }
                }                       /* 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 */
        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. */
        /* 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;
        }
 
                goto screwed;
        }
 
@@ -559,18 +558,21 @@ static int msfees_start(unit, peer)
        peer->stratum   = stratumtouse[unit];
        peer->rootdelay = 0;    /* ++++ */
        peer->rootdispersion = 0;       /* ++++ */
        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);
        unitinuse[unit] = 1;
        syslog(LOG_ERR, "ees clock: %s OK on %d", eesdev, unit);
-       return 1;
+       return (1);
 
 screwed:
 
 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;
 
        /* 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,
 
        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) {
                                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;
                                        if (unit>0 && unit<10)
                                                ((char *)&peer->refid)[3] =
                                                        '0' + unit;
index 3d98d10..3c0d097 100644 (file)
@@ -65,8 +65,10 @@ static char rcsid[] =
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
 #include <termios.h>
 #include <termios.h>
+#endif
+#if defined(STREAM)
 #include <stropts.h>
 #if defined(MX4200CLK)
 #include <sys/clkdefs.h>
 #include <stropts.h>
 #if defined(MX4200CLK)
 #include <sys/clkdefs.h>
@@ -260,8 +262,8 @@ mx4200_init()
        /*
         * Just zero the data arrays
         */
        /*
         * 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.
 
        /*
         * Initialize fudge factors to default.
@@ -368,9 +370,9 @@ mx4200_start(unit, peer)
         }
     }
 #endif /* HAVE_SYSV_TTYS */
         }
     }
 #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.
         *
         * 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;
         }
                    "mx4200_start: tcflush(%s): %m", mx4200dev);
                 goto screwed;
         }
+    }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
 #if defined(MX4200CLK)
 #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)
 #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 /* MX4200PPS */
-    }
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
 #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;
 
        /*
        mx4200units[unit] = mx4200;
 
        /*
@@ -508,7 +512,7 @@ mx4200_start(unit, peer)
        peer->rootdispersion = 0;
        peer->stratum = stratumtouse[unit];
        if (stratumtouse[unit] <= 1)
        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;
        else
                peer->refid = htonl(MX4200HSREFID);
        unitinuse[unit] = 1;
@@ -697,7 +701,7 @@ mx4200_receive(rbufp)
        if (n <= 1)
                return;
        mx4200->lencode = n;
        if (n <= 1)
                return;
        mx4200->lencode = n;
-       bcopy(dpt, mx4200->lastcode, n);
+       memmove(mx4200->lastcode, dpt, n);
 
        /*
         * We expect to see something like:
 
        /*
         * 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)
                                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);
                        }
                                else
                                        peer->refid = htonl(MX4200HSREFID);
                        }
@@ -1111,7 +1115,7 @@ mx4200_buginfo(unit, bug)
                return;
        mx4200 = mx4200units[unit];
 
                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)
        bug->nvalues = 10;
        bug->ntimes = 2;
        if (mx4200->lasttime != 0)
@@ -1207,7 +1211,7 @@ mx4200_parse(buf, jt, validp, leapsecp)
        char *cp;
 
        cp = buf;
        char *cp;
 
        cp = buf;
-       bzero((char *)jt, sizeof(*jt));
+       memset((char *)jt, 0, sizeof(*jt));
 
        if ((cp = strchr(cp, ',')) == NULL)
                return ("no rec-type");
 
        if ((cp = strchr(cp, ',')) == NULL)
                return ("no rec-type");
index 4dee7aa..73be84d 100644 (file)
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
 #include <termios.h>
 #include <termios.h>
+#endif
+#if defined(STREAM)
 #include <stropts.h>
 #if defined(OMEGACLK)
 #include <sys/clkdefs.h>
 #include <stropts.h>
 #if defined(OMEGACLK)
 #include <sys/clkdefs.h>
@@ -224,8 +226,8 @@ omega_init()
        /*
         * Just zero the data arrays
         */
        /*
         * 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.
 
        /*
         * Initialize fudge factors to default.
@@ -299,9 +301,9 @@ omega_start(unit, peer)
         }
     }
 #endif /* HAVE_SYSV_TTYS */
         }
     }
 #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.
         *
         * 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;
         }
                    "omega_start: tcflush(%s): %m", omegadev);
                 goto screwed;
         }
+    }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
 #if defined(OMEGACLK)
 #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)
 #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 /* OMEGAPPS */
-    }
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
@@ -412,7 +416,7 @@ omega_start(unit, peer)
                            emalloc(sizeof(struct omegaunit));
                }
        }
                            emalloc(sizeof(struct omegaunit));
                }
        }
-       bzero((char *)omega, sizeof(struct omegaunit));
+       memset((char *)omega, 0, sizeof(struct omegaunit));
        omegaunits[unit] = omega;
 
        /*
        omegaunits[unit] = omega;
 
        /*
@@ -440,7 +444,7 @@ omega_start(unit, peer)
        peer->rootdispersion = 0;
        peer->stratum = stratumtouse[unit];
        if (stratumtouse[unit] <= 1)
        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;
        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)
                                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);
                        }
                                else
                                        peer->refid = htonl(OMEGAHSREFID);
                        }
index 9e34d6e..69e4837 100644 (file)
@@ -1,8 +1,8 @@
 #if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS))
 /*
 #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
  *
  *
  * 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!)
  *
  * 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,
  * Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
  *
  * This program is distributed in the hope that it will be useful,
  *                      backward compatibilty only)
  *  PPS                      - supply loopfilter with PPS samples (if configured)
  *  PPSPPS            - notify loopfilter of PPS file descriptor
  *                      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
  */
 
 /*
  */
 
 /*
 #include <sys/errno.h>
 extern int errno;
 
 #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" */
 /* #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>
 #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
 #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
 #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__)
 #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
 
 /**===========================================================================
 #endif
 
 /**===========================================================================
@@ -231,6 +243,7 @@ struct parseunit
    * clock specific configuration
    */
   l_fp                basedelay;        /* clock local phase offset */
    * clock specific configuration
    */
   l_fp                basedelay;        /* clock local phase offset */
+  l_fp                ppsdelay;         /* clock local pps phase offset */
 
   /*
    * clock state handling/reporting
 
   /*
    * 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_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 */
 
 #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 */
   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 */
   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_DATA,
     DCFPZF535_ROOTDELAY,
     DCFPZF535_BASEDELAY,
+    NO_PPSDELAY,
     DCF_P_ID,
     DCFPZF535_DESCRIPTION,
     NO_FORMAT,
     DCF_P_ID,
     DCFPZF535_DESCRIPTION,
     NO_FORMAT,
@@ -522,6 +538,7 @@ static struct clockinfo
     NO_DATA,
     DCFPZF535OCXO_ROOTDELAY,
     DCFPZF535OCXO_BASEDELAY,
     NO_DATA,
     DCFPZF535OCXO_ROOTDELAY,
     DCFPZF535OCXO_BASEDELAY,
+    NO_PPSDELAY,
     DCF_P_ID,
     DCFPZF535OCXO_DESCRIPTION,
     NO_FORMAT,
     DCF_P_ID,
     DCFPZF535OCXO_DESCRIPTION,
     NO_FORMAT,
@@ -540,6 +557,7 @@ static struct clockinfo
     NO_DATA,
     DCFUA31_ROOTDELAY,
     DCFUA31_BASEDELAY,
     NO_DATA,
     DCFUA31_ROOTDELAY,
     DCFUA31_BASEDELAY,
+    NO_PPSDELAY,
     DCF_A_ID,
     DCFUA31_DESCRIPTION,
     NO_FORMAT,
     DCF_A_ID,
     DCFUA31_DESCRIPTION,
     NO_FORMAT,
@@ -558,6 +576,7 @@ static struct clockinfo
     NO_DATA,
     DCF7000_ROOTDELAY,
     DCF7000_BASEDELAY,
     NO_DATA,
     DCF7000_ROOTDELAY,
     DCF7000_BASEDELAY,
+    NO_PPSDELAY,
     DCF_A_ID,
     DCF7000_DESCRIPTION,
     NO_FORMAT,
     DCF_A_ID,
     DCF7000_DESCRIPTION,
     NO_FORMAT,
@@ -576,6 +595,7 @@ static struct clockinfo
     WSDCF_DATA,
     WSDCF_ROOTDELAY,
     WSDCF_BASEDELAY,
     WSDCF_DATA,
     WSDCF_ROOTDELAY,
     WSDCF_BASEDELAY,
+    NO_PPSDELAY,
     DCF_A_ID,
     WSDCF_DESCRIPTION,
     WSDCF_FORMAT,
     DCF_A_ID,
     WSDCF_DESCRIPTION,
     WSDCF_FORMAT,
@@ -594,6 +614,7 @@ static struct clockinfo
     NO_DATA,
     RAWDCF_ROOTDELAY,
     CONRAD_BASEDELAY,
     NO_DATA,
     RAWDCF_ROOTDELAY,
     CONRAD_BASEDELAY,
+    NO_PPSDELAY,
     DCF_A_ID,
     CONRAD_DESCRIPTION,
     RAWDCF_FORMAT,
     DCF_A_ID,
     CONRAD_DESCRIPTION,
     RAWDCF_FORMAT,
@@ -612,6 +633,7 @@ static struct clockinfo
     NO_DATA,
     RAWDCF_ROOTDELAY,
     TIMEBRICK_BASEDELAY,
     NO_DATA,
     RAWDCF_ROOTDELAY,
     TIMEBRICK_BASEDELAY,
+    NO_PPSDELAY,
     DCF_A_ID,
     TIMEBRICK_DESCRIPTION,
     RAWDCF_FORMAT,
     DCF_A_ID,
     TIMEBRICK_DESCRIPTION,
     RAWDCF_FORMAT,
@@ -630,6 +652,7 @@ static struct clockinfo
     GPS166_DATA,
     GPS166_ROOTDELAY,
     GPS166_BASEDELAY,
     GPS166_DATA,
     GPS166_ROOTDELAY,
     GPS166_BASEDELAY,
+    NO_PPSDELAY,
     GPS166_ID,
     GPS166_DESCRIPTION,
     GPS166_FORMAT,
     GPS166_ID,
     GPS166_DESCRIPTION,
     GPS166_FORMAT,
@@ -648,6 +671,7 @@ static struct clockinfo
     TRIMBLESV6_DATA,
     TRIMBLESV6_ROOTDELAY,
     TRIMBLESV6_BASEDELAY,
     TRIMBLESV6_DATA,
     TRIMBLESV6_ROOTDELAY,
     TRIMBLESV6_BASEDELAY,
+    NO_PPSDELAY,
     TRIMBLESV6_ID,
     TRIMBLESV6_DESCRIPTION,
     TRIMBLESV6_FORMAT,
     TRIMBLESV6_ID,
     TRIMBLESV6_DESCRIPTION,
     TRIMBLESV6_FORMAT,
@@ -1055,7 +1079,9 @@ stream_receive(rbufp)
       parse_event(parse, CEVNT_BADREPLY);
       return;
     }
       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
 
   /*
    * switch time stamp world - be sure to normalize small usec field
@@ -1996,7 +2022,7 @@ cparse_statistics(peer)
 static void
 parse_init()
 {
 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;
 {
   u_int unit;
   int fd232, i;
-#ifdef STREAM
+#ifdef HAVE_TERMIOS
   struct termios tm;           /* NEEDED FOR A LONG TIME ! */
 #endif
 #ifdef HAVE_SYSV_TTYS
   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;
 
   /*
   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->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)
   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);
        
   else
     peer->refid = htonl(PARSEHSREFID);
        
@@ -2220,7 +2249,7 @@ parse_start(sysunit, peer)
   else
     {
 #ifndef _PC_VDISABLE
   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 ! */
 #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->badformat     = out->baddata    = 0;
       out->timereset     = 0;
       out->currentstatus = out->lastevent = CEVNT_NOMINAL;
+      out->kv_list       = (struct ctl_var *)0;
     }
 
   if (unit >= MAXUNITS)
     }
 
   if (unit >= MAXUNITS)
@@ -2567,14 +2597,16 @@ parse_control(unit, in, out)
 
       if (in->haveflags & CLK_HAVETIME2)
        {
 
       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)
        }
 
       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);
        }
              else
                parse->peer->refid = htonl(PARSEHSREFID);
        }
@@ -2607,19 +2639,21 @@ parse_control(unit, in, out)
   if (out)
     {
       register unsigned LONG sum = 0;
   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;
 
       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;
 
       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;
 
 
       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 */
                */
               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-().
       /*
        * 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 = '+';
        }
 
          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
        {
       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))
        }
 
       if (!PARSE_GETTIMECODE(parse, &tmpctl))
@@ -2693,27 +2736,24 @@ parse_control(unit, in, out)
        }
       else
        {
        }
       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);
 
          /*
           * 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)
          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);
                    tmpctl.parsegettc.parse_buffer, tmpctl.parsegettc.parse_count - 1);
-         strcat(outstatus,">");
+
          parse->badformat += tmpctl.parsegettc.parse_badformat;
        }
        
          parse->badformat += tmpctl.parsegettc.parse_badformat;
        }
        
@@ -2725,16 +2765,20 @@ parse_control(unit, in, out)
        }
       else
        {
        }
       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
        */
 
        }
 
       /*
        * 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++)
        {
 
       for (i = 0; i <= CEVNT_MAX; i++)
        {
@@ -2757,18 +2801,27 @@ parse_control(unit, in, out)
 
          if (stime)
            {
 
          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;
                       (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;
 
       out->lencode       = strlen(outstatus);
       out->lastcode      = outstatus;
@@ -3074,6 +3127,8 @@ parse_process(parse, parsetime)
        */
       offset = parsetime->parse_ptime.fp;
 
        */
       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) &&
       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))
     {
       /*
   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
        (void) pps_sample(&off);
     }
-#endif /* PPS || PPSCLK || PPSPPS */
+#endif /* PPS || PPSCLK || PPSPPS || PARSEPPS */
 
   /*
    * ready, unless the machine wants a sample
 
   /*
    * 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));
   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;
       
   
       pt = (poll_timer_t *)parse->localdata;
       
@@ -3309,7 +3364,7 @@ static int
 trimble_init(parse)
   struct parseunit *parse;
 {
 trimble_init(parse)
   struct parseunit *parse;
 {
-#ifdef STREAM
+#ifdef HAVE_TERMIOS
   struct termios tm;
 #endif
 #ifdef HAVE_SYSV_TTYS
   struct termios tm;
 #endif
 #ifdef HAVE_SYSV_TTYS
@@ -3341,6 +3396,18 @@ trimble_init(parse)
  * History:
  *
  * refclock_parse.c,v
  * 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
  *
  * Revision 3.41  1993/11/27  18:44:37  kardel
  * can't trust GPS166 on unsync
  *
index e72ac8b..4b8909a 100644 (file)
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
 #include <termios.h>
 #include <termios.h>
+#endif
+#if defined(STREAM)
 #include <stropts.h>
 #if defined(PSTCLK)
 #include <sys/clkdefs.h>
 #include <stropts.h>
 #if defined(PSTCLK)
 #include <sys/clkdefs.h>
@@ -435,8 +437,8 @@ pst_init()
        /*
         * Just zero the data arrays
         */
        /*
         * 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.
 
        /*
         * Initialize fudge factors to default.
@@ -513,9 +515,9 @@ pst_start(unit, peer)
         }
     }
 #endif /* HAVE_SYSV_TTYS */
         }
     }
 #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.
         *
         * 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;
         }
                    "pst_start: tcflush(%s): %m", pstdev);
                 goto screwed;
         }
+    }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
 #if defined(PSTCLK)
 #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)
 #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 /* PSTPPS */
-    }
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
@@ -625,7 +629,7 @@ pst_start(unit, peer)
                        pst = (struct pstunit *)emalloc(sizeof(struct pstunit));
                }
        }
                        pst = (struct pstunit *)emalloc(sizeof(struct pstunit));
                }
        }
-       bzero((char *)pst, sizeof(struct pstunit));
+       memset((char *)pst, 0, sizeof(struct pstunit));
        pstunits[unit] = pst;
 
        /*
        pstunits[unit] = pst;
 
        /*
@@ -658,7 +662,7 @@ pst_start(unit, peer)
        peer->rootdispersion = 0;
        peer->stratum = stratumtouse[unit];
        if (stratumtouse[unit] <= 1)
        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;
        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)
         */
        if (stratumtouse[pst->unit] <= 1) {
                if (pst->station >= 0)
-                       bcopy(WWVREFID, (char *)&pst->peer->refid, 4);
+                       memmove((char *)&pst->peer->refid, WWVREFID, 4);
                else
                else
-                       bcopy(WWVHREFID, (char *)&pst->peer->refid, 4);
+                       memmove((char *)&pst->peer->refid, WWVHREFID, 4);
        }
 
        /*
        }
 
        /*
index 5988180..54d9f3c 100644 (file)
@@ -130,8 +130,8 @@ tpro_init()
        /*
         * Just zero the data arrays
         */
        /*
         * 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.
 
        /*
         * Initialize fudge factors to default.
@@ -200,7 +200,7 @@ tpro_start(unit, peer)
                            emalloc(sizeof(struct tprounit));
                }
        }
                            emalloc(sizeof(struct tprounit));
                }
        }
-       bzero((char *)tpro, sizeof(struct tprounit));
+       memset((char *)tpro, 0, sizeof(struct tprounit));
        tprounits[unit] = tpro;
 
        /*
        tprounits[unit] = tpro;
 
        /*
@@ -225,7 +225,7 @@ tpro_start(unit, peer)
        peer->rootdispersion = 0;
        peer->stratum = stratumtouse[unit];
        if (stratumtouse[unit] <= 1)
        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;
        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)
                                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);
                        }
                                else
                                        peer->refid = htonl(TPROHSREFID);
                        }
index 602eee0..9b2563a 100644 (file)
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
 #include <termio.h>
 #endif /* HAVE_SYSV_TTYS */
 
-#if defined(STREAM)
+#if defined(HAVE_TERMIOS)
 #include <termios.h>
 #include <termios.h>
+#endif
+#if defined(STREAM)
 #include <stropts.h>
 #if defined(WWVBCLK)
 #include <sys/clkdefs.h>
 #include <stropts.h>
 #if defined(WWVBCLK)
 #include <sys/clkdefs.h>
@@ -217,8 +219,8 @@ wwvb_init()
        /*
         * Just zero the data arrays
         */
        /*
         * 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.
 
        /*
         * Initialize fudge factors to default.
@@ -290,9 +292,9 @@ wwvb_start(unit, peer)
         }
     }
 #endif /* HAVE_SYSV_TTYS */
         }
     }
 #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.
         *
         * 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;
         }
                    "wwvb_start: tcflush(%s): %m", wwvbdev);
                 goto screwed;
         }
+    }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
 #if defined(WWVBCLK)
 #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)
 #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 /* WWVBPPS */
-    }
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
 #endif /* STREAM */
 #if defined(HAVE_BSD_TTYS)
        /*
@@ -403,7 +407,7 @@ wwvb_start(unit, peer)
                            emalloc(sizeof(struct wwvbunit));
                }
        }
                            emalloc(sizeof(struct wwvbunit));
                }
        }
-       bzero((char *)wwvb, sizeof(struct wwvbunit));
+       memset((char *)wwvb, 0, sizeof(struct wwvbunit));
        wwvbunits[unit] = wwvb;
 
        /*
        wwvbunits[unit] = wwvb;
 
        /*
@@ -431,7 +435,7 @@ wwvb_start(unit, peer)
        peer->rootdispersion = 0;
        peer->stratum = stratumtouse[unit];
        if (stratumtouse[unit] <= 1)
        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;
        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)
                                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);
                        }
                                else
                                        peer->refid = htonl(WWVBHSREFID);
                        }
index c5fdf72..001bd77 100644 (file)
@@ -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 *));
 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 **));
 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;
 {
        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];
 
        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':
                switch (c) {
                case 'c':
-                       ADDCMD(optarg);
+                       ADDCMD(ntp_optarg);
                        break;
                case 'd':
                        ++debug;
                        break;
                case 'd':
                        ++debug;
@@ -261,11 +261,11 @@ char *argv[];
                    progname);
                exit(2);
        }
                    progname);
                exit(2);
        }
-       if (optind == argc) {
+       if (ntp_optind == argc) {
                ADDHOST(DEFHOST);
        } else {
                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
        }
 
        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 */
        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:
        FD_ZERO(&fds);
 
 again:
@@ -600,7 +600,7 @@ again:
         */
        if ((datap + datasize) > (pktdata + pktdatasize))
                growpktdata();
         */
        if ((datap + datasize) > (pktdata + pktdatasize))
                growpktdata();
-       bcopy((char *)rpkt.data, datap, datasize);
+       memmove(datap, (char *)rpkt.data, datasize);
        datap += datasize;
        if (firstpkt) {
                firstpkt = 0;
        datap += datasize;
        if (firstpkt) {
                firstpkt = 0;
@@ -634,7 +634,7 @@ sendrequest(implcode, reqcode, auth, qitems, qsize, qdata)
        struct req_pkt qpkt;
        int datasize;
 
        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;
 
        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) {
 
        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 {
                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) {
                }
                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;
                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;
 
                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);
                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
  * 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;
 helpsort(t1, t2)
        const void *t1;
        const void *t2;
@@ -1207,7 +1207,7 @@ helpsort(name1, name2)
         char **name1;
         char **name2;
 {
         char **name1;
         char **name2;
 {
-#endif /* sgi */
+#endif /* sgi || bsdi */
         return strcmp(*name1, *name2);
 }
 
         return strcmp(*name1, *name2);
 }
 
index 26f7e91..55483fa 100644 (file)
@@ -442,7 +442,7 @@ printpeer(pp, fp)
        
        if (pp->stratum <= 1) {
                junk[4] = 0;
        
        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);
                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;
            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);
                str = junk;
        } else {
                str = numtoa(is->refid);
@@ -2192,7 +2192,7 @@ fudge(pcmd, fp)
 
 
        err = 0;
 
 
        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")) {
        fudgedata.clockadr = pcmd->argval[0].netnum;
 
        if (STREQ(pcmd->argval[1].string, "time1")) {
index cf0d850..ee88b1f 100644 (file)
@@ -148,7 +148,7 @@ main(argc, argv)
        int errflg = 0;
        char *cp;
        FILE *in;
        int errflg = 0;
        char *cp;
        FILE *in;
-       extern int optind;
+       extern int ntp_optind;
 
        progname = argv[0];
 
 
        progname = argv[0];
 
@@ -180,7 +180,7 @@ main(argc, argv)
 
        syslog(LOG_NOTICE, Version);
 
 
        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;
                switch (c) {
                case 'd':
                        ++debug;
@@ -192,20 +192,20 @@ main(argc, argv)
                        errflg++;
                        break;
                }
                        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);
        }
 
                (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);
        }
 
                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
 
        /*
         * 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);
 
        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;
 
        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
                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.
         */
         * 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);
        }
 
                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 */
        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
         */
        /*
         * 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 */
 
        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));
        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);
        reqpkt.keyid = htonl(req_keyid);
 
        auth1crypt(req_keyid, (U_LONG *)&reqpkt, REQ_LEN_NOMAC);