mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-18 00:21:25 +01:00
xntp 3.3p from Delaware
This commit is contained in:
parent
b9eb1bdbc4
commit
a7b3b2eb36
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/ntpd/dist/; revision=1328
@ -1,6 +1,6 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (c) David L. Mills 1992, 1993, 1994 *
|
||||
* 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 *
|
||||
@ -55,4 +55,4 @@
|
||||
* 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)
|
||||
*/
|
||||
*/
|
||||
|
@ -114,6 +114,10 @@ DEFS_LOCAL= $(DEFS_OPT) #GREEN -DREFCLOCK #TEST -DPPSPPS -DKERNEL_PLL
|
||||
# by default when using the "make makeconfig" script and greenhorn
|
||||
# configuraiton.
|
||||
#
|
||||
# Define -DTRAK for a 8810 GPS Receiver with Buffered RS-232-C Interface
|
||||
# Module. The driver supports both the CLK and PPS modes. It should work
|
||||
# in all systems with a serial port.
|
||||
#
|
||||
# Define -DPST for a PST/Traconex 1020 WWV/H receiver. The driver
|
||||
# supports both the CLK and PPS modes. It should work in all systems
|
||||
# with a serial port.
|
||||
|
@ -144,7 +144,7 @@ xntpres/xntpres: lib/libntp.a xntpres/Makefile FRC
|
||||
@echo '###' creating XNTPRES utility
|
||||
@cd xntpres && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)"
|
||||
|
||||
util/tickadj: util/Makefile FRC
|
||||
util/tickadj: util/Makefile lib/libntp.a FRC
|
||||
@echo
|
||||
@echo '###' creating TICKADJ utility
|
||||
@cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)"
|
||||
@ -162,7 +162,7 @@ parse/libparse.a: parse/*.c parse/Makefile parse/util/Makefile lib/libntp.a
|
||||
FRC:
|
||||
|
||||
savebin:
|
||||
@test -d bin || mkdir bin
|
||||
-@test -d bin || mkdir bin
|
||||
@echo
|
||||
@echo '### saving $(TARGETS) $(OPTTARG) in bin'
|
||||
-@for f in $(TARGETS) $(OPTTARG); \
|
||||
|
@ -1 +1 @@
|
||||
version=3.3c (beta)
|
||||
version=3.3p (beta)
|
||||
|
@ -38,13 +38,13 @@ SOURCE= authcert.c authspeed.c keyparity.c makeIPFP.c makePC1.c \
|
||||
all: $(PROGRAM)
|
||||
|
||||
authcert: $(CRTOBJS) $(LIB)
|
||||
$(CC) $(COPTS) -o $@ $(CRTOBJS) $(LIB)
|
||||
$(CC) $(COPTS) -o $@ $(CRTOBJS) $(LIB) $(COMPAT) $(RESLIB)
|
||||
|
||||
authspeed: $(SPDOBJS) $(LIB)
|
||||
$(CC) $(COPTS) -o $@ $(SPDOBJS) $(LIB) $(COMPAT) $(RESLIB)
|
||||
|
||||
keyparity: $(PAROBJS) $(LIB)
|
||||
$(CC) $(COPTS) -o $@ $(PAROBJS) $(LIB)
|
||||
$(CC) $(COPTS) -o $@ $(PAROBJS) $(LIB) $(COMPAT) $(RESLIB)
|
||||
|
||||
makeIPFP: $(IFPOBJS)
|
||||
$(CC) $(COPTS) -o $@ $(IFPOBJS)
|
||||
@ -68,7 +68,7 @@ unixcert: $(UNXBJS)
|
||||
$(CC) $(COPTS) -o $@ $(UNXBJS)
|
||||
|
||||
md5: $(MD5OBJS)
|
||||
$(CC) $(COPTS) -o $@ $(MD5OBJS) $(LIB)
|
||||
$(CC) $(COPTS) -o $@ $(MD5OBJS) $(LIB) $(COMPAT) $(RESLIB)
|
||||
|
||||
tags:
|
||||
ctags *.c *.h
|
||||
|
1
usr.sbin/xntpd/compilers/hpux-adj.cc
Normal file
1
usr.sbin/xntpd/compilers/hpux-adj.cc
Normal file
@ -0,0 +1 @@
|
||||
COMPILER=cc +O1
|
1
usr.sbin/xntpd/compilers/hpux-adj.gcc
Normal file
1
usr.sbin/xntpd/compilers/hpux-adj.gcc
Normal file
@ -0,0 +1 @@
|
||||
COMPILER=gcc -O2
|
@ -1,2 +1 @@
|
||||
COMPILER=cc
|
||||
COPTS=+O1
|
||||
COMPILER=cc +O1
|
||||
|
@ -1,2 +1 @@
|
||||
COMPILER=gcc
|
||||
COPTS=-O2
|
||||
COMPILER=gcc -O2
|
||||
|
2
usr.sbin/xntpd/compilers/irix4.cc
Normal file
2
usr.sbin/xntpd/compilers/irix4.cc
Normal file
@ -0,0 +1,2 @@
|
||||
COMPILER= cc -cckr
|
||||
COPTS= -O2
|
@ -1,2 +1,2 @@
|
||||
COMPILER= gcc -DUSE_PROTOTYPES -Wall
|
||||
COPTS= -O6 -finline-functions -fomit-frame-pointer
|
||||
COPTS= -O2 -finline-functions -fomit-frame-pointer
|
||||
|
190
usr.sbin/xntpd/conf/Config.plain
Normal file
190
usr.sbin/xntpd/conf/Config.plain
Normal file
@ -0,0 +1,190 @@
|
||||
# This is the local configure file (distribution version).
|
||||
# You must modify it to fit your particular configuration
|
||||
# and name it Config.local
|
||||
# The following configuratiions can be auto-generated:
|
||||
#
|
||||
# make Config.local.green
|
||||
# make a Config.local that supports a local clock
|
||||
# (i.e. allow fallback to use of the CPU's own clock)
|
||||
# make Config.local.NO.clock
|
||||
# make a Config.local that supports no clocks
|
||||
#
|
||||
#
|
||||
# NOTE TO GREENHORNS
|
||||
#
|
||||
# For plug-'n-play and no radios or other complicated gadgetry,
|
||||
# use "make Config.local.green" as above.
|
||||
#
|
||||
# Following defines can be set in the DEFS_OPT= define:
|
||||
#
|
||||
# The flag -DDEBUG includes some debugging code. To use this, include
|
||||
# the define and start the daemon with one or more -d flags, depending
|
||||
# on your calibration of pearannoya. The daemon will not detach your
|
||||
# terminal in this case. Judicious use of grep will reduce the speaker
|
||||
# volume to bearable levels.
|
||||
#
|
||||
# To change the location of the configuration file, use a
|
||||
# -DCONFIG_FILE=\\"/local/etc/ntp.conf\\" or something similar.
|
||||
#
|
||||
# The -DSYSLOG_FILE defines allows logging messages that are normally
|
||||
# reported via syslof() in a file. The file name can be configured using
|
||||
# the configuration line "logfile <filename>" in CONFIG_FILE.
|
||||
#
|
||||
# There are three serial port system software interfaces, each of
|
||||
# which is peculiar to one or more Unix versions. Define
|
||||
# -DHAVE_SYSV_TTYS for basic System V compatibility; define -DSTREAM
|
||||
# for POSIX compatibility including System V Streams, and
|
||||
# HAVE_BSD_TTYS for 4.3bsd compatibility. Only one of these three
|
||||
# should be defined. If none are defined, HAVE_BSD_TTYS is assumed.
|
||||
# Usually these defines are already set correctly.
|
||||
#
|
||||
DEFS_OPT=-DDEBUG
|
||||
|
||||
#
|
||||
# The DEFS_LOCAL define picks up all flags from DEFS_OPT (do not delete that)
|
||||
# and one of the following:
|
||||
#
|
||||
# The flag -DREFCLOCK causes the basic reference clock support to be
|
||||
# compiled into the daemon. If you set this you may also want to
|
||||
# configure the particular clock drivers you want in the CLOCKDEFS= line
|
||||
# below. This flag affects xntpd only. This define is included by
|
||||
# default when using the "make makeconfig" script.
|
||||
#
|
||||
# The next two sets of defines are meaningful only when radio clock
|
||||
# drivers or special 1-pps signals are to be used. For systems without
|
||||
# these features, these delicious complexities can be avoided. Ordinarily,
|
||||
# the "make makeconfig" script figures out which ones to use, but your
|
||||
# mileage may vary.
|
||||
#
|
||||
# There are three ways to utilize external 1-pps signals. Define
|
||||
# -DPPS to include just the pps routine, such as used by the DCF77(PARSE)
|
||||
# clock driver. Define -DPPSCLK to include a serial device driver
|
||||
# which avoids much of the jitter due to upper level port
|
||||
# processing. This requires a dedicated serial port and either the
|
||||
# tty_clock line discipline or tty_clk_streams module, both of
|
||||
# which are in the ./kernel directory. Define -DPPSCD to include a
|
||||
# special driver which intercepts carrier-detect transitions
|
||||
# generated by the pps signal. This requires a nondedicated serial
|
||||
# port and the ppsclock streams module in the ./kernel directory.
|
||||
# Only one of these three flags should be defined.
|
||||
#
|
||||
# The flag KERNEL_PLL causes code to be compiled for a special feature of
|
||||
# the kernel that (a) implements the phase-lock loop and (b) provides
|
||||
# a user interface to learn time, maximum error and estimated error.
|
||||
# See the file README.kern in the doc directory for further info.
|
||||
# This code is activated only if the relevant kernel features have
|
||||
# been configured; it does not affect operation of unmodified kernels.
|
||||
# To compile it, however, requires a few header files from the
|
||||
# special distribution.
|
||||
#
|
||||
# Note: following line must always start with DEFS_LOCAL= $(DEFS_OPT)
|
||||
DEFS_LOCAL= $(DEFS_OPT) -DREFCLOCK -DKERNEL_PLL
|
||||
|
||||
#
|
||||
# Radio clock support definitions (these only make sense if -DREFCLOCK
|
||||
# used), which is normally the case. Note that a configuration can include
|
||||
# no clocks, more than one type of clock and even multiple clocks of the
|
||||
# same type.
|
||||
#
|
||||
# For most radio clocks operating with serial ports, accuracy can
|
||||
# be considerably improved through use of the tty_clk line
|
||||
# discipline or tty_clk_STREAMS streams module found in the
|
||||
# ./kernel directory. These gizmos capture a timestamp upon
|
||||
# occurrence of an intercept character and stuff it in the data
|
||||
# stream for the clock driver to munch. To select this mode,
|
||||
# postfix the driver name with the string CLK; that is, WWVB
|
||||
# becomes WWVBCLK. If more than one clock is in use, the CLK
|
||||
# postfix can be used with any or all of them.
|
||||
#
|
||||
# Alternatively, for the best accuracy, use the ppsclock streams
|
||||
# module in the ./ppsclock directory to steal the carrier-detect
|
||||
# transition and capture a precision timestamp. At present this
|
||||
# works only with SunOS 4.1.1 or later. To select this mode,
|
||||
# postfix the driver name with the string PPS; that is, AS2201
|
||||
# becomes AS2201PPS. If more than one clock is in use, the PPS
|
||||
# postfix should be used with only one of them. If any PPS
|
||||
# postfix is defined, the -DPPSPPS define should be used on the
|
||||
# DEFS above.
|
||||
#
|
||||
# Define -DLOCAL_CLOCK for a local pseudo-clock to masquerade as a
|
||||
# reference clock for those subnets without access to the real thing.
|
||||
# Works in all systems and requires no hardware support. This is defined
|
||||
# by default when using the "make makeconfig" script and greenhorn
|
||||
# configuraiton.
|
||||
#
|
||||
# Define -DPST for a PST/Traconex 1020 WWV/H receiver. The driver
|
||||
# supports both the CLK and PPS modes. It should work in all systems
|
||||
# with a serial port.
|
||||
#
|
||||
# Define -DWWVB for a Spectracom 8170 or Netclock/2 WWVB receiver. It
|
||||
# should work in all systems with a serial port. The driver supports
|
||||
# both the CLK and PPS modes if the requisite kernel support is installed.
|
||||
#
|
||||
# Define -DCHU for a special CHU receiver using an ordinary shortwave
|
||||
# radio. This requires the chu_clk line discipline or chu_clk_STREAMS
|
||||
# module in the ./kernel directory. At present, this driver works only
|
||||
# on SunOS4.1.x; operation in other systems has not been confirmed.
|
||||
# Construction details for a suitable modem can be found in the ./gadget
|
||||
# directory. The driver supports # neither the CLK nor PPS modes.
|
||||
#
|
||||
# Define -DPARSE for a DCF77/GPS(GENERIC) receiver. For best performance
|
||||
# this requires a special parsestreams STREAMS (SunOS 4.x) module in the
|
||||
# ./parse directory. Define -DPARSEPPS for PPS support via the
|
||||
# DCF77/GPS (GENERIC) receiver; also, define -DPPS in the DEFS above.
|
||||
# Define: -DCLOCK_MEINBERG for Meinberg clocks
|
||||
# -DCLOCK_SCHMID for Schmid receivers
|
||||
# -DCLOCK_DCF7000 for ELV DCF7000
|
||||
# -DCLOCK_RAWDCF for simple receivers (100/200ms pulses on Rx)
|
||||
# -DCLOCK_TRIMSV6 for Trimble SV6 GPS receiver
|
||||
#
|
||||
# Define -DMX4200PPS for a Magnavox 4200 GPS receiver. At present, this
|
||||
# driver works only on SunOS4.1.x with CPU serial ports only. The PPS
|
||||
# mode is required.
|
||||
#
|
||||
# Define -DAS2201 for an Austron 2200A or 2201A GPS receiver. It should
|
||||
# work in all systems with a serial port. The driver does not support the
|
||||
# CLK mode, but does support the PPS mode. If the radio is connected to
|
||||
# more than one machine, the PPS mode is required.
|
||||
#
|
||||
# Define -DGOES for a Kinemetrics/TrueTime 468-DC GOES receiver. This
|
||||
# driver is known to work with some other TrueTime products as well,
|
||||
# including the GPS-DC GPS receiver. It should work in all systems with
|
||||
# a serial port. The driver does not support the CLK mode, but does
|
||||
# support the PPS mode.
|
||||
#
|
||||
# Define -DOMEGA for a Kinemetrics/TrueTime OM-DC OMEGA receiver. It
|
||||
# should work in all systems with a serial port. The driver does not
|
||||
# support the CLK mode, but does support the PPS mode.
|
||||
#
|
||||
# Define -DTPRO for a KSI/Odetics TPRO-S IRIG-B timecode reader. This
|
||||
# requires the SunOS interface driver available from KSI. The driver
|
||||
# supports neither the CLK nor PPS modes.
|
||||
#
|
||||
# Define -DLEITCH for a Leitch CSD 5300 Master Clock System Driver for
|
||||
# the HP 5061B Cesium Clock. It should work in all systems with a serial
|
||||
# port. The driver does not support the CLK mode, but does support the
|
||||
# PPS mode.
|
||||
#
|
||||
# Define -DMSFEESPPS for an EES M201 MSF receiver. It currently only works
|
||||
# under SunOS 4.x with the PPSCD (ppsclock) STREAMS module, but the RCS
|
||||
# files on cl.cam.ac.uk still has support for CLK and CBREAK modes.
|
||||
#
|
||||
# Define -DIRIG for a IRIG-B timecode timecode using the audio codec of
|
||||
# the Sun SPARCstations. This requires a modified BSD audio driver and
|
||||
# exclusive access to the audio port. A memo describing how it works and
|
||||
# how to install the driver is in the README.irig file in the ./doc
|
||||
# directory.
|
||||
#
|
||||
# Note: The following defines result in compilation of all the above radio
|
||||
# clocks. This works on a Sun 4.1.x system which has tty_clk, chu_clk and
|
||||
# ppsclock STREAMS modules installed. If the trailing CLK and PPS suffixes
|
||||
# are removed and the IRIG, PARSE* and CLOCK* deleted, all of the rest compile
|
||||
# under Ultrix 4.2a/3. If the MX4200 is removed, all the rest compile on a DEC
|
||||
# OSF/1 Alpha.
|
||||
#
|
||||
CLOCKDEFS= -DLOCAL_CLOCK -DCHU -DGOES -DOMEGA -DPST -DWWVB -DLEITCH
|
||||
|
||||
#
|
||||
# Directory into which binaries should be installed (default /usr/local)
|
||||
#
|
||||
BINDIR= /usr/local/bin
|
File diff suppressed because it is too large
Load Diff
@ -785,7 +785,7 @@ configuration functionality (though the only thing you can currently do
|
||||
with mode-6 messages is set the leap-second warning bits) and the ntpq
|
||||
program provides generic support for the latter. The leap bits that can be
|
||||
set in the leap_warning variable (up to one month ahead) and in the
|
||||
leap_indication variable have a slighly different encoding than the
|
||||
leap_indication variable have a slightly different encoding than the
|
||||
usual interpretation:
|
||||
|
||||
Value Action
|
||||
|
@ -20,13 +20,13 @@
|
||||
'''
|
||||
''' Set up \*(-- to give an unbreakable dash;
|
||||
''' string Tr holds user defined translation string.
|
||||
''' Bell System Logo is used as a dummy character.
|
||||
''' Greek uppercase omega is used as a dummy character.
|
||||
'''
|
||||
.tr \(bs-|\(bv\*(Tr
|
||||
.tr \(*W-|\(bv\*(Tr
|
||||
.ie n \{\
|
||||
.ds -- \(bs-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
|
||||
.ds -- \(*W-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
.ds L" ""
|
||||
.ds R" ""
|
||||
.ds L' '
|
||||
|
@ -20,13 +20,13 @@
|
||||
'''
|
||||
''' Set up \*(-- to give an unbreakable dash;
|
||||
''' string Tr holds user defined translation string.
|
||||
''' Bell System Logo is used as a dummy character.
|
||||
''' Greek uppercase omega is used as a dummy character.
|
||||
'''
|
||||
.tr \(bs-|\(bv\*(Tr
|
||||
.tr \(*W-|\(bv\*(Tr
|
||||
.ie n \{\
|
||||
.ds -- \(bs-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
|
||||
.ds -- \(*W-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
.ds L" ""
|
||||
.ds R" ""
|
||||
.ds L' '
|
||||
|
@ -20,13 +20,13 @@
|
||||
'''
|
||||
''' Set up \*(-- to give an unbreakable dash;
|
||||
''' string Tr holds user defined translation string.
|
||||
''' Bell System Logo is used as a dummy character.
|
||||
''' Greek uppercase omega is used as a dummy character.
|
||||
'''
|
||||
.tr \(bs-|\(bv\*(Tr
|
||||
.tr \(*W-|\(bv\*(Tr
|
||||
.ie n \{\
|
||||
.ds -- \(bs-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
|
||||
.ds -- \(*W-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
.ds L" ""
|
||||
.ds R" ""
|
||||
.ds L' '
|
||||
|
@ -20,13 +20,13 @@
|
||||
'''
|
||||
''' Set up \*(-- to give an unbreakable dash;
|
||||
''' string Tr holds user defined translation string.
|
||||
''' Bell System Logo is used as a dummy character.
|
||||
''' Greek uppercase omega is used as a dummy character.
|
||||
'''
|
||||
.tr \(bs-|\(bv\*(Tr
|
||||
.tr \(*W-|\(bv\*(Tr
|
||||
.ie n \{\
|
||||
.ds -- \(bs-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
|
||||
.ds -- \(*W-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
.ds L" ""
|
||||
.ds R" ""
|
||||
.ds L' '
|
||||
|
@ -20,13 +20,13 @@
|
||||
'''
|
||||
''' Set up \*(-- to give an unbreakable dash;
|
||||
''' string Tr holds user defined translation string.
|
||||
''' Bell System Logo is used as a dummy character.
|
||||
''' Greek uppercase omega is used as a dummy character.
|
||||
'''
|
||||
.tr \(bs-|\(bv\*(Tr
|
||||
.tr \(*W-|\(bv\*(Tr
|
||||
.ie n \{\
|
||||
.ds -- \(bs-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
|
||||
.ds -- \(*W-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
.ds L" ""
|
||||
.ds R" ""
|
||||
.ds L' '
|
||||
@ -374,7 +374,8 @@ facility will be disabled.
|
||||
Certain changes can be made to the
|
||||
.I xntpd
|
||||
server via mode 6 control messages, in particular the setting of
|
||||
leap second indications in a server with a radio clock. The
|
||||
leap second indications in a server with a radio clock.
|
||||
The
|
||||
.B controlkey
|
||||
statement specifies an encription key number to be used for authenticating
|
||||
such messages. Omitting this statement will cause control messages
|
||||
@ -446,6 +447,22 @@ useful as future synchronization partners.
|
||||
.Ip notrust 10
|
||||
Treat these hosts normally in other respects, but never use them as
|
||||
synchronization sources.
|
||||
.Ip limited 10
|
||||
These hosts are subject to limitation of number of clients from the
|
||||
same net. Net in this context refers to the IP notion of net (class A,
|
||||
class B, class C, etc.). Only the first \*(L"client_limit\*(R" hosts
|
||||
that have shown up at the server and that have been active during the
|
||||
last \*(L"client_limit_period\*(R" seconds are accepted. Requests from
|
||||
other clients from the same net are rejected. Only time request
|
||||
packets are taken into account. \*(L"Private\*(R", \*(L"control\*(R",
|
||||
and \*(L"broadcast\*(R" packets are not subject to client limitation
|
||||
and therefore are not contributing to client count. History of clients
|
||||
is kept using the monitoring capability of
|
||||
.IR xntpd .
|
||||
Thus, monitoring is active as long as there is a restriction entry
|
||||
with the \*(L"limited\*(R" flag. The default value for
|
||||
\*(L"client_limit\*(R" is 3. The default value for
|
||||
\*(L"client_limit_period\*(R" is 3600 seconds.
|
||||
.Ip ntpport 10
|
||||
This is actually a match algorithm modifier, rather than a restriction
|
||||
flag. Its presence causes the restriction entry to be matched only if
|
||||
@ -469,6 +486,21 @@ broken remote time servers from affecting your own, it should not be
|
||||
considered an alternative to the standard NTP authentication facility. Source
|
||||
address based restrictions are easily circumvented by a determined cracker.
|
||||
.PP
|
||||
.B clientlimit
|
||||
.I limit
|
||||
.PP
|
||||
Sets \*(L"client_limit\*(R" to \*(L"limit\*(R", allows configuration
|
||||
of client limitation policy. This variable defines the number of
|
||||
clients from the same network that are allowed to use the server.
|
||||
.PP
|
||||
.B clientperiod
|
||||
.I period
|
||||
.PP
|
||||
Sets \*(L"client_limit_period\*(R", allows configuration of client
|
||||
limitation policy. This variable specifies the number
|
||||
of seconds after which a client is considered inactive and thus no
|
||||
longer is counted for client limit restriction.
|
||||
.PP
|
||||
.B trap
|
||||
.I host_address
|
||||
[
|
||||
@ -1370,6 +1402,31 @@ If flag2 is set, then leaphold is set.
|
||||
If flag3 is set, then the sample information is dumped.
|
||||
If flag4 is set, then the input data is smoothed, and all data
|
||||
points are used.
|
||||
.PP
|
||||
.SH VARIABLES
|
||||
Most variables used by the NTP protocol can be examined with the xntpdc
|
||||
(mode 7 messages) and the ntpq (mode 6 messages). Currently very few variables
|
||||
can be modified via mode 6 messages. These variables are either created with the
|
||||
.I setvar
|
||||
directive or the leap warning variables. The leap warning bits that can be
|
||||
set in the
|
||||
.B leapwarning
|
||||
variable (up to one month ahead). Both, the
|
||||
.B leapwarning and in the
|
||||
.B leapindication
|
||||
variable, have a slightly different encoding than the usual
|
||||
.B leap
|
||||
bits interpretation:
|
||||
.P
|
||||
.Ip 00 8
|
||||
The daemon passes the leap bits of its synchronisation source (usual mode of
|
||||
operation).
|
||||
.Ip 01/10 8
|
||||
A leap second is added/deleted (operator forced leap second).
|
||||
.Ip 11 8
|
||||
Leap information from the sychronisation source is ignored (thus LEAP_NOWARNING
|
||||
is passed on).
|
||||
.PP
|
||||
.SH FILES
|
||||
.Ip /etc/ntp.conf 20
|
||||
the default name of the configuration file
|
||||
|
@ -20,13 +20,13 @@
|
||||
'''
|
||||
''' Set up \*(-- to give an unbreakable dash;
|
||||
''' string Tr holds user defined translation string.
|
||||
''' Bell System Logo is used as a dummy character.
|
||||
''' Greek uppercase omega is used as a dummy character.
|
||||
'''
|
||||
.tr \(bs-|\(bv\*(Tr
|
||||
.tr \(*W-|\(bv\*(Tr
|
||||
.ie n \{\
|
||||
.ds -- \(bs-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
|
||||
.ds -- \(*W-
|
||||
.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
.ds L" ""
|
||||
.ds R" ""
|
||||
.ds L' '
|
||||
@ -539,6 +539,17 @@ requests) from the source. Time service is not affected.
|
||||
Ignore all NTP mode 7 packets which attempt to modify the state of the
|
||||
server (i.e. run time reconfiguration). Queries which return information
|
||||
are permitted.
|
||||
.Ip notrap 10
|
||||
Decline to provide mode 6 control message trap service to matching
|
||||
hosts. The trap service is a subsystem of the mode 6 control message
|
||||
protocol which is intended for use by remote event logging programs.
|
||||
.Ip lowpriotrap 10
|
||||
Declare traps set by matching hosts to be low priority. The number
|
||||
of traps a server can maintain is limited (the current limit is 3).
|
||||
Traps are usually assigned on a first come, first served basis, with
|
||||
later trap requestors being denied service. This flag modifies the
|
||||
assignment algorithm by allowing low priority traps to be overridden
|
||||
by later requests for normal priority traps.
|
||||
.Ip noserve 10
|
||||
Ignore NTP packets whose mode is other than 7. In effect, time service is
|
||||
denied, though queries may still be permitted.
|
||||
@ -549,6 +560,23 @@ useful as future synchronization partners.
|
||||
.Ip notrust 10
|
||||
Treat these hosts normally in other respects, but never use them as
|
||||
synchronization sources.
|
||||
.Ip limited 10
|
||||
These hosts are subject to limitation of number of clients from the
|
||||
same net. Net in this context refers to the IP notion of net (class A,
|
||||
class B, class C, etc.). Only the first \*(L"client_limit\*(R" hosts
|
||||
that have shown up at the server and that have been active during the
|
||||
last \*(L"client_limit_period\*(R" seconds are accepted. Requests from
|
||||
other clients from the same net are rejected. Only time request
|
||||
packets are taken into account. \*(L"Private\*(R", \*(L"control\*(R",
|
||||
and \*(L"broadcast\*(R" packets are not subject to client limitation
|
||||
and therefore are not contributing to client count. History of clients
|
||||
is kept using the monitoring capability of
|
||||
.IR xntpd.
|
||||
Thus, monitoring is active as long as there is a restriction entry
|
||||
with the \*(L"limited\*(R" flag. The default value for
|
||||
\*(L"client_limit\*(R" is 3. The default value for
|
||||
\*(L"client_limit_period\*(R" is 3600 seconds. Currently both
|
||||
variables are not runtime configurable.
|
||||
.Ip ntpport 10
|
||||
This is actually a match algorithm modifier, rather than a restriction
|
||||
flag. Its presence causes the restriction entry to be matched only if
|
||||
|
@ -1,59 +1,63 @@
|
||||
Last update: Sun Mar 13 15:05:31 PST 1994
|
||||
|
||||
This file hopefully describes the whatever and however of how to get xntp
|
||||
running on hpux 8.0 and later s300, s700, and s800.
|
||||
running on hpux 7.0 and later s300. s400, s700, and s800.
|
||||
|
||||
First off, all the standard disclaimers hold here ... HP doesn't have anthing
|
||||
to do with this stuff. I fool with it in my spare time because we use it and
|
||||
because I like to. We just happen to have a lot of HP machines around here :-)
|
||||
Xntp has been in use here for several months and has a fair amount of mileage
|
||||
Xntpd has been in use here for several years and has a fair amount of mileage
|
||||
on various HP platforms within the company. I can't really guarantee bug fixes
|
||||
but I'd certainly like to hear about bugs and I won't hestitate to look at
|
||||
any fixes sent to me.
|
||||
|
||||
Now lets talk OS. If you don't have 8.0 or later, pretty much hang it up now.
|
||||
This stuff has run here on 8.0 s300, s700, and s800. Its possible that it
|
||||
runs on 7.0 but I have not tried v3 code on 7.0 at all.
|
||||
Now lets talk OS. If you don't have 7.0 or later, pretty much hang it up now.
|
||||
This stuff has run here on pretty much everything from 8.0 upward on s300,
|
||||
s700, and s800. It is known to run on 7.0 s300/s400 but all reports are
|
||||
from the field and not my personal experience.
|
||||
|
||||
[Note that recent reports state that this release does in fact run on HP
|
||||
300 and 400 boxes, which run 7.0 - Ed.]
|
||||
If you are lucky enough to have a s300 or s400 with 9.03, then you no longer
|
||||
have to worry about adjtimed as HP-UX now has adjtime(2). The rest of you
|
||||
will have to wait on 10.0 which will have adjtime(2) and a supported though
|
||||
a bit older version of xntpd.
|
||||
|
||||
Next, let me explain a bit about how this stuff works on HP-UX since we don't
|
||||
Next, let me explain a bit about how this stuff works on HP-UX's that do not
|
||||
have adjtime(2). The directory adjtime contains libadjtime.a and the adjtimed
|
||||
daemon. Instead of the adjtime(2) system call, we use a library routine to
|
||||
talk to adjtimed thru message queues. Adjtimed munges into /dev/kmem and
|
||||
causes the clock to skew properly as needed. PLEASE NOTE that the adjtime
|
||||
code provided here is NOT a general replacement for adjtime(2) ... use of
|
||||
this adjtime(3)/adjtimed(8) other than here may yield very odd results.
|
||||
this adjtime(3)/adjtimed(8) other than with xntpd may yield very odd results.
|
||||
|
||||
What to do to get this stuff running ?
|
||||
|
||||
* cd ..
|
||||
* Say "make makeconfig"
|
||||
* If you are running an OS less than 10.0 or do not have a s300/s400
|
||||
with 9.03 or better
|
||||
-> cd machines
|
||||
-> vi hpux
|
||||
-> (change -DSYS_HPUX=? to match whatever you are running [7,8,9])
|
||||
-> cd ..
|
||||
|
||||
* cd ..
|
||||
* Say "make", sit back for a few minutes.
|
||||
* Say "make makeconfig"
|
||||
|
||||
* Say "make", sit back for a few minutes.
|
||||
|
||||
* cd authstuff
|
||||
* Say "./authcert < certdata" and check the output. Every line should
|
||||
end with "OK" ... if not, we got trouble.
|
||||
* Now try "./authspeed auth.samplekeys". What we want to
|
||||
remember here is the "authentication delay in CPU time"
|
||||
* cd ..
|
||||
|
||||
* cd ..
|
||||
* Now we need to install this stuff ... make install will not work
|
||||
unless you have replaced the SYSV install command with a BSD
|
||||
compatible version. So ... the simplest thing to do is run
|
||||
make -n install and do manually what it would have done.
|
||||
* Say "make install"
|
||||
|
||||
* I'd suggest reading the xntp docs about now :-) ... seriously !!
|
||||
|
||||
* Check out the docs and the stuff in xntp/conf and build a config
|
||||
file ... put it in /usr/local/etc/xntp.conf (or where ever you
|
||||
defined the config file to be in Config). One thing we have
|
||||
added to this version of xntpd is a way to select config files
|
||||
if you are sharing /usr/local thru NFS or whatever. If the
|
||||
file /usr/local/etc/xntp.conf happens to be a directory, the files
|
||||
in that directory are searched until a match is found. The rules
|
||||
for a match are:
|
||||
* One thing I have added to this version of xntpd is a way to select
|
||||
config files if you are sharing /usr/local thru NFS or whatever.
|
||||
If the file /usr/local/etc/xntp.conf happens to be a directory, the
|
||||
files in that directory are searched until a match is found. The
|
||||
rules for a match are:
|
||||
|
||||
1. Our hostname
|
||||
2. default.<machine id> (as in default.375 or default.850)
|
||||
@ -73,4 +77,16 @@ Possible problems ?
|
||||
* On some 320's and 835's we have had to run adjtimed with "-p 45" or
|
||||
so to get rid of syslog messages about "last adjust did not finish".
|
||||
|
||||
* At 9.0, there is a problem with DIAGMON (patch available from the
|
||||
response center) which causes it to delete the message queue that
|
||||
adjtimed/xntpd use to communicate. (see next note for result)
|
||||
|
||||
* Xntpd has been known to get really ticked off when adjtime() fails
|
||||
which is usually only while running the emulation code on HP-UX.
|
||||
When it gets mad, it usually jumps the clock into never never land.
|
||||
Possible reasons for this are adjtimed being killed or just never
|
||||
started or adjtimed being completely swapped out on a really busy
|
||||
machine (newer adjtimed try to lock themselves in memory to prevent
|
||||
this one).
|
||||
|
||||
Anything else ... just drop me a line at ken@sdd.hp.com
|
||||
|
@ -1,29 +1,9 @@
|
||||
|
||||
Requirements: kernel 0.99.14 or newer, libc 4.5 or newer
|
||||
Requirements: kernel 0.99.14y or newer, libc 4.5.21 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.
|
||||
With this configuration, xntp should build an run right out of the box
|
||||
(see generic hints for how-to). 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)
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
If you are running Solaris 2.0, you should upgrade to a later version of
|
||||
Solaris immediately.
|
||||
If you are running Solaris 2.1, you should use Config.solaris2.1
|
||||
If you are running Solaris 2.2 or later, you should use Config.solaris2.2
|
||||
If you are running Solaris 2.1 or later, all should be fine (i hope)
|
||||
|
||||
Solaris 2.1 contains fairly traditional clock code, with tick and tickadj.
|
||||
Solaris 2.2 and later contains completely re-written clock code to provide
|
||||
|
@ -346,7 +346,7 @@ struct peer {
|
||||
*/
|
||||
#define REFCLK_NONE 0 /* unknown or missing */
|
||||
#define REFCLK_LOCALCLOCK 1 /* external (e.g., ACTS) */
|
||||
#define REFCLK_WWV_HEATH 2 /* Heath GC-1000 WWV/H */
|
||||
#define REFCLK_GPS_TRAK 2 /* TRAK 8810 GPS Receiver */
|
||||
#define REFCLK_WWV_PST 3 /* PST/Traconex 1020 WWV/H */
|
||||
#define REFCLK_WWVB_SPECTRACOM 4 /* Spectracom 8170/Netclock WWVB */
|
||||
#define REFCLK_GOES_TRUETIME 5 /* TrueTime 468-DC GOES */
|
||||
@ -612,6 +612,9 @@ struct mon_data {
|
||||
struct mon_data *hash_prev; /* previous structure in hash list */
|
||||
struct mon_data *mru_next; /* next structure in MRU list */
|
||||
struct mon_data *mru_prev; /* previous structure in MRU list */
|
||||
struct mon_data *fifo_next; /* next structure in FIFO list */
|
||||
struct mon_data *fifo_prev; /* previous structure in FIFO list */
|
||||
U_LONG lastdrop; /* last time dropped due to RES_LIMIT*/
|
||||
U_LONG lasttime; /* last time data updated */
|
||||
U_LONG firsttime; /* time structure initialized */
|
||||
U_LONG count; /* count we have seen */
|
||||
@ -621,7 +624,12 @@ struct mon_data {
|
||||
u_char version; /* version of incoming packet */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Values used with mon_enabled to indicate reason for enabling monitoring
|
||||
*/
|
||||
#define MON_OFF 0x00 /* no monitoring */
|
||||
#define MON_ON 0x01 /* monitoring explicitly enabled */
|
||||
#define MON_RES 0x02 /* implicit monitoring for RES_LIMITED */
|
||||
/*
|
||||
* Structure used for restrictlist entries
|
||||
*/
|
||||
@ -645,10 +653,11 @@ struct restrictlist {
|
||||
#define RES_NOPEER 0x20 /* don't allocate memory resources */
|
||||
#define RES_NOTRAP 0x40 /* don't allow him to set traps */
|
||||
#define RES_LPTRAP 0x80 /* traps set by him are low priority */
|
||||
#define RES_LIMITED 0x100 /* limit per net number of clients */
|
||||
|
||||
#define RES_ALLFLAGS \
|
||||
(RES_IGNORE|RES_DONTSERVE|RES_DONTTRUST|RES_NOQUERY\
|
||||
|RES_NOMODIFY|RES_NOPEER|RES_NOTRAP|RES_LPTRAP)
|
||||
|RES_NOMODIFY|RES_NOPEER|RES_NOTRAP|RES_LPTRAP|RES_LIMITED)
|
||||
|
||||
/*
|
||||
* Match flags
|
||||
|
@ -44,11 +44,16 @@ Signaled IO - Signled IO defines.
|
||||
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.
|
||||
It is defined if you define STREAMS.
|
||||
|
||||
We do not put these defines in the ntp_machine.h as some systems
|
||||
offer multiple interfaces and refclock configuration likes to
|
||||
peek into the configuration defines for tty model restrictions.
|
||||
Thus all tty definitions should be in the files in the machines directory.
|
||||
|
||||
HAVE_TERMIOS - Use POSIX termios.h
|
||||
HAVE_SYSV_TTYS - Use SYSV termio.h
|
||||
HAVE_BSD_TTYS - Use BSD stty.h
|
||||
HAVE_TERMIOS - Use POSIX termios.h
|
||||
|
||||
THIS MAKES PORTS TO NEW SYSTEMS EASY - You only have to wory about
|
||||
kernel mucking.
|
||||
@ -274,7 +279,6 @@ in this file.
|
||||
#ifndef STR_SYSTEM
|
||||
#define STR_SYSTEM "UNIX/Ultrix"
|
||||
#endif
|
||||
#define HAVE_TERMIOS
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -297,9 +301,9 @@ in this file.
|
||||
#define FORCE_NTPDATE_STEP
|
||||
#define RETSIGTYPE void
|
||||
#define HAVE_ATT_SETPGRP
|
||||
#define HAVE_BSD_TTYS
|
||||
#define LOG_NTP LOG_LOCAL1
|
||||
#define HAVE_SIGNALED_IO
|
||||
#define NTP_NEED_BOPS
|
||||
#ifndef STR_SYSTEM
|
||||
#define STR_SYSTEM "UNIX/AUX"
|
||||
#endif
|
||||
@ -309,6 +313,7 @@ in this file.
|
||||
* Next
|
||||
*/
|
||||
#if defined(SYS_NEXT)
|
||||
#define RETSIGTYPE void
|
||||
#define DOSYNCTODR
|
||||
#define HAVE_READKMEM
|
||||
#define HAVE_BSD_NICE
|
||||
@ -329,8 +334,12 @@ in this file.
|
||||
#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 RETSIGTYPE void
|
||||
#if (SYS_HPUX < 9)
|
||||
#define HAVE_NO_NICE /* HPUX uses rtprio instead */
|
||||
#else
|
||||
#define HAVE_BSD_NICE /* new at 9.X */
|
||||
#endif
|
||||
#if (SYS_HPUX < 10)
|
||||
#define NOKMEM
|
||||
#else
|
||||
@ -352,8 +361,6 @@ in this file.
|
||||
#ifndef STR_SYSTEM
|
||||
#define STR_SYSTEM "UNIX/BSDI"
|
||||
#endif
|
||||
#define HAVE_BSD_TTYS
|
||||
#define HAVE_TERMIOS
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -441,9 +448,6 @@ in this file.
|
||||
*/
|
||||
#if defined(SYS_PTX)
|
||||
#define NO_SIGNED_CHAR_DECL
|
||||
#ifndef HAVE_SYSV_TTYS
|
||||
#define HAVE_SYSV_TTYS
|
||||
#endif
|
||||
#define STREAMS_TLI
|
||||
#define HAVE_ATT_SETPGRP
|
||||
#define HAVE_SIGNALED_IO
|
||||
@ -458,6 +462,7 @@ in this file.
|
||||
#define HAVE_READKMEM
|
||||
#define UDP_WILDCARD_DELIVERY
|
||||
#define NTP_POSIX_SOURCE
|
||||
#define memmove(x, y, z) memcpy(x, y, z)
|
||||
struct timezone { int __0; }; /* unused placebo */
|
||||
/*
|
||||
* no comment !@!
|
||||
@ -527,7 +532,6 @@ typedef unsigned long u_long;
|
||||
#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
|
||||
@ -565,6 +569,20 @@ typedef unsigned long u_long;
|
||||
ERROR You_must_define_one_of_the_HAVE_xx_NICE_defines
|
||||
#endif
|
||||
|
||||
/*
|
||||
* use only one tty model - no use in initialising
|
||||
* a tty in three ways
|
||||
* HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
|
||||
*/
|
||||
#ifdef HAVE_TERMIOS
|
||||
#undef HAVE_BSD_TTYS
|
||||
#undef HAVE_SYSV_TTYS
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYSV_TTYS
|
||||
#undef HAVE_BSD_TTYS
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SYSV_TTYS) \
|
||||
&& !defined(HAVE_BSD_TTYS) \
|
||||
&& !defined(HAVE_TERMIOS)
|
||||
|
@ -429,6 +429,24 @@ struct info_sys_stats {
|
||||
U_LONG processed; /* packets processed */
|
||||
U_LONG badauth; /* packets dropped because of authorization */
|
||||
U_LONG wanderhold;
|
||||
U_LONG limitrejected; /* rejected because of client limitation */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* System stats - old version
|
||||
*/
|
||||
struct old_info_sys_stats {
|
||||
U_LONG timeup; /* time we have been up and running */
|
||||
U_LONG timereset; /* time since these were last cleared */
|
||||
U_LONG badstratum; /* packets claiming an invalid stratum */
|
||||
U_LONG oldversionpkt; /* old version packets received */
|
||||
U_LONG newversionpkt; /* new version packets received */
|
||||
U_LONG unknownversion; /* don't know version packets */
|
||||
U_LONG badlength; /* packets with bad length */
|
||||
U_LONG processed; /* packets processed */
|
||||
U_LONG badauth; /* packets dropped because of authorization */
|
||||
U_LONG wanderhold;
|
||||
};
|
||||
|
||||
|
||||
@ -546,6 +564,7 @@ struct conf_restrict {
|
||||
struct info_monitor {
|
||||
U_LONG lasttime; /* last packet from this host */
|
||||
U_LONG firsttime; /* first time we received a packet */
|
||||
U_LONG lastdrop; /* last time we rejected a packet due to client limitation policy */
|
||||
U_LONG count; /* count of packets received */
|
||||
U_LONG addr; /* host address */
|
||||
u_short port; /* port number of last reception */
|
||||
@ -553,6 +572,18 @@ struct info_monitor {
|
||||
u_char version; /* version number of last packet */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure used for returning monitor data (old format
|
||||
*/
|
||||
struct old_info_monitor {
|
||||
U_LONG lasttime; /* last packet from this host */
|
||||
U_LONG firsttime; /* first time we received a packet */
|
||||
U_LONG count; /* count of packets received */
|
||||
U_LONG addr; /* host address */
|
||||
u_short port; /* port number of last reception */
|
||||
u_char mode; /* mode of last packet */
|
||||
u_char version; /* version number of last packet */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure used for passing indication of flags to clear
|
||||
|
@ -79,6 +79,7 @@ extern char * inttoa P((LONG));
|
||||
extern char * mfptoa P((U_LONG, U_LONG, int));
|
||||
extern char * mfptoms P((U_LONG, U_LONG, int));
|
||||
extern char * modetoa P((int));
|
||||
extern U_LONG netof P((U_LONG));
|
||||
extern char * numtoa P((U_LONG));
|
||||
extern char * numtohost P((U_LONG));
|
||||
extern int octtoint P((const char *, U_LONG *));
|
||||
|
@ -1,6 +1,6 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* Copyright (c) David L. Mills 1993 *
|
||||
* Copyright (c) David L. Mills 1993, 1994 *
|
||||
* *
|
||||
* Permission to use, copy, modify, and distribute this software and its *
|
||||
* documentation for any purpose and without fee is hereby granted, provided *
|
||||
@ -17,11 +17,13 @@
|
||||
/*
|
||||
* Modification history timex.h
|
||||
*
|
||||
* 28 Nov 93 David L. Mills
|
||||
* Adjusted parameters to improve stability and increase poll interval
|
||||
* 20 Feb 94 David L. Mills
|
||||
* Revised status codes and structures for external clock and PPS
|
||||
* signal discipline.
|
||||
*
|
||||
* 10 Oct 93 Torsten Duwe
|
||||
* Changed to ntp_timex.h (#ifdef'd HAVE_SYS_TIMEX_H)
|
||||
* 28 Nov 93 David L. Mills
|
||||
* Adjusted parameters to improve stability and increase poll
|
||||
* interval.
|
||||
*
|
||||
* 17 Sep 93 David L. Mills
|
||||
* Created file
|
||||
@ -41,7 +43,7 @@
|
||||
* int syscall(SYS_ntp_gettime, tptr)
|
||||
*
|
||||
* int SYS_ntp_gettime defined in syscall.h header file
|
||||
* struct ntptimeval *tptr pointer to ntptimeval structure
|
||||
* struct ntptimeval *tptr pointer to ntptimeval structure
|
||||
*
|
||||
* NAME
|
||||
* ntp_adjtime - NTP daemon application interface
|
||||
@ -55,55 +57,43 @@
|
||||
* struct timex *tptr pointer to timex structure
|
||||
*
|
||||
*/
|
||||
#ifndef _NTP_TIMEX_H
|
||||
#define _NTP_TIMEX_H
|
||||
|
||||
/*
|
||||
* Include system timex.h (if appropriate)
|
||||
*/
|
||||
#ifdef HAVE_SYS_TIMEX_H
|
||||
#include <sys/timex.h>
|
||||
#else /* provide definitions */
|
||||
#include <sys/syscall.h>
|
||||
|
||||
extern int syscall P((int, void *, ...));
|
||||
|
||||
#define ntp_gettime(t) syscall(SYS_ntp_gettime, (t))
|
||||
#define ntp_adjtime(t) syscall(SYS_ntp_adjtime, (t))
|
||||
|
||||
/*
|
||||
* The following defines establish the engineering parameters of the PLL
|
||||
* model. The HZ variable establishes the timer interrupt frequency, 100 Hz
|
||||
* for the SunOS kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the
|
||||
* OSF/1 kernel. The SHIFT_HZ define expresses the same value as the
|
||||
* nearest power of two in order to avoid hardware multiply operations.
|
||||
* model. The hz variable is defined in the kernel build environment. It
|
||||
* establishes the timer interrupt frequency, 100 Hz for the SunOS
|
||||
* kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the OSF/1
|
||||
* kernel. The SHIFT_HZ define expresses the same value as the nearest
|
||||
* power of two in order to avoid hardware multiply operations.
|
||||
*/
|
||||
#define SHIFT_HZ 7 /* log2(HZ) */
|
||||
#define SHIFT_HZ 7 /* log2(hz) */
|
||||
|
||||
/*
|
||||
* The SHIFT_KG and SHIFT_KF defines establish the damping of the PLL
|
||||
* and are chosen by analysis for a slightly underdamped convergence
|
||||
* characteristic. The MAXTC define establishes the maximum time constant
|
||||
* of the PLL. With the parameters given and the default time constant of
|
||||
* zero, the PLL will converge in about 15 minutes.
|
||||
* characteristic. The MAXTC define establishes the maximum time
|
||||
* constant of the PLL. With the parameters given and the minimum time
|
||||
* constant of zero, the PLL will converge in about 15 minutes.
|
||||
*/
|
||||
#define SHIFT_KG 6 /* shift for phase increment */
|
||||
#define SHIFT_KF 16 /* shift for frequency increment */
|
||||
#define SHIFT_KG 6 /* phase factor (shift) */
|
||||
#define SHIFT_KF 16 /* frequency factor (shift) */
|
||||
#define MAXTC 6 /* maximum time constant (shift) */
|
||||
|
||||
/*
|
||||
* The SHIFT_SCALE define establishes the decimal point of the time_phase
|
||||
* variable which serves as a an extension to the low-order bits of the
|
||||
* system clock variable. The SHIFT_UPDATE define establishes the decimal
|
||||
* point of the time_offset variable which represents the current offset
|
||||
* with respect to standard time. The SHIFT_USEC define represents 1 us in
|
||||
* external units (shift), while the FINEUSEC define represents 1 us in
|
||||
* internal units.
|
||||
* SHIFT_SCALE defines the scaling (shift) of the time_phase variable,
|
||||
* which serves as a an extension to the low-order bits of the system
|
||||
* clock variable time.tv_usec. SHIFT_UPDATE defines the scaling (shift)
|
||||
* of the time_offset variable, which represents the current time offset
|
||||
* with respect to standard time. SHIFT_USEC defines the scaling (shift)
|
||||
* of the time_freq and time_tolerance variables, which represent the
|
||||
* current frequency offset and frequency tolerance. FINEUSEC is 1 us in
|
||||
* SHIFT_UPDATE units of the time_phase variable.
|
||||
*/
|
||||
#define SHIFT_SCALE 23 /* shift for phase scale factor */
|
||||
#define SHIFT_UPDATE (SHIFT_KG + MAXTC) /* shift for offset scale factor */
|
||||
#define SHIFT_USEC 16 /* shift for 1 us in external units */
|
||||
#define FINEUSEC (1 << SHIFT_SCALE) /* 1 us in internal units */
|
||||
#define SHIFT_SCALE 23 /* phase scale (shift) */
|
||||
#define SHIFT_UPDATE (SHIFT_KG + MAXTC) /* time offset scale (shift) */
|
||||
#define SHIFT_USEC 16 /* frequency offset scale (shift) */
|
||||
#define FINEUSEC (1 << SHIFT_SCALE) /* 1 us in phase units */
|
||||
|
||||
/*
|
||||
* Mode codes (timex.mode)
|
||||
@ -122,8 +112,8 @@ extern int syscall P((int, void *, ...));
|
||||
#define TIME_INS 1 /* insert leap second */
|
||||
#define TIME_DEL 2 /* delete leap second */
|
||||
#define TIME_OOP 3 /* leap second in progress */
|
||||
#define TIME_BAD 4 /* clock not synchronized */
|
||||
|
||||
#define TIME_BAD 4 /* kernel clock not synchronized */
|
||||
#define TIME_ERR 5 /* external clock not synchronized */
|
||||
/*
|
||||
* NTP user interface - used to read kernel clock values
|
||||
* Note: maximum error = NTP synch distance = dispersion + delay / 2;
|
||||
@ -131,8 +121,8 @@ extern int syscall P((int, void *, ...));
|
||||
*/
|
||||
struct ntptimeval {
|
||||
struct timeval time; /* current time */
|
||||
long maxerror; /* maximum error (usec) */
|
||||
long esterror; /* estimated error (usec) */
|
||||
long maxerror; /* maximum error (us) */
|
||||
long esterror; /* estimated error (us) */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -140,19 +130,25 @@ struct ntptimeval {
|
||||
*/
|
||||
struct timex {
|
||||
int mode; /* mode selector */
|
||||
long offset; /* time offset (usec) */
|
||||
long offset; /* time offset (us) */
|
||||
long frequency; /* frequency offset (scaled ppm) */
|
||||
long maxerror; /* maximum error (usec) */
|
||||
long esterror; /* estimated error (usec) */
|
||||
long maxerror; /* maximum error (us) */
|
||||
long esterror; /* estimated error (us) */
|
||||
int status; /* clock command/status */
|
||||
long time_constant; /* pll time constant */
|
||||
long precision; /* clock precision (usec) (read only) */
|
||||
long tolerance; /* clock frequency tolerance (ppm)
|
||||
* (read only)
|
||||
*/
|
||||
long precision; /* clock precision (us) (read only) */
|
||||
long tolerance; /* clock frequency tolerance (scaled
|
||||
* ppm) (read only) */
|
||||
/*
|
||||
* The following read-only structure members are implemented
|
||||
* only if the PPS signal discipline is configured in the
|
||||
* kernel.
|
||||
*/
|
||||
long ybar; /* frequency estimate (scaled ppm) */
|
||||
long disp; /* dispersion estimate (scaled ppm) */
|
||||
int shift; /* interval duration (s) (shift) */
|
||||
long calcnt; /* calibration intervals */
|
||||
long jitcnt; /* jitter limit exceeded */
|
||||
long discnt; /* dispersion limit exceeded */
|
||||
|
||||
};
|
||||
|
||||
#endif /* HAVE_SYS_TIMEX_H */
|
||||
|
||||
#endif /* _NTP_TIMEX_H */
|
||||
|
||||
|
@ -93,8 +93,8 @@ extern int pps_sample P((l_fp *));
|
||||
|
||||
/* ntp_monitor.c */
|
||||
extern void init_mon P((void));
|
||||
extern void mon_start P((void));
|
||||
extern void mon_stop P((void));
|
||||
extern void mon_start P((int));
|
||||
extern void mon_stop P((int));
|
||||
extern void monitor P((struct recvbuf *));
|
||||
|
||||
/* ntp_peer.c */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/include/parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/include/parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp
|
||||
*
|
||||
* parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp
|
||||
* parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp
|
||||
*
|
||||
* Copyright (c) 1989,1990,1991,1992,1993,1994
|
||||
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
|
||||
@ -15,7 +15,7 @@
|
||||
#ifndef __PARSE_H__
|
||||
#define __PARSE_H__
|
||||
#if !(defined(lint) || defined(__GNUC__))
|
||||
static char parsehrcsid[]="parse.h,v 3.13 1994/01/25 19:04:21 kardel Exp FAU";
|
||||
static char parsehrcsid[]="parse.h,v 3.17 1994/03/03 09:27:20 kardel Exp";
|
||||
#endif
|
||||
|
||||
#include "ntp_types.h"
|
||||
@ -81,35 +81,55 @@ extern int debug;
|
||||
/*
|
||||
* state flags
|
||||
*/
|
||||
#define PARSEB_ANNOUNCE 0x0001 /* switch time zone warning (DST switch) */
|
||||
#define PARSEB_POWERUP 0x0002 /* no synchronisation */
|
||||
#define PARSEB_NOSYNC 0x0004 /* timecode currently not confirmed */
|
||||
#define PARSEB_DST 0x0008 /* DST in effect */
|
||||
#define PARSEB_UTC 0x0010 /* UTC time */
|
||||
#define PARSEB_LEAP 0x0020 /* LEAP warning (1 hour prior to occurence) */
|
||||
#define PARSEB_ALTERNATE 0x0040 /* alternate antenna used */
|
||||
#define PARSEB_POSITION 0x0080 /* position available */
|
||||
#define PARSEB_LEAPSECOND 0x0100 /* actual leap second */
|
||||
#define PARSEB_POWERUP 0x00000001 /* no synchronisation */
|
||||
#define PARSEB_NOSYNC 0x00000002 /* timecode currently not confirmed */
|
||||
|
||||
#define PARSEB_S_LEAP 0x0200 /* supports LEAP */
|
||||
#define PARSEB_S_ANTENNA 0x0400 /* supports antenna information */
|
||||
#define PARSEB_S_PPS 0x0800 /* supports PPS time stamping */
|
||||
#define PARSEB_S_POSITION 0x1000 /* supports position information (GPS) */
|
||||
/*
|
||||
* time zone information
|
||||
*/
|
||||
#define PARSEB_ANNOUNCE 0x00000010 /* switch time zone warning (DST switch) */
|
||||
#define PARSEB_DST 0x00000020 /* DST in effect */
|
||||
#define PARSEB_UTC 0x00000040 /* UTC time */
|
||||
|
||||
#define PARSEB_TIMECODE 0x2000 /* valid time code sample */
|
||||
#define PARSEB_PPS 0x4000 /* valid PPS sample */
|
||||
/*
|
||||
* leap information
|
||||
*/
|
||||
#define PARSEB_LEAPDEL 0x00000100 /* LEAP deletion warning */
|
||||
#define PARSEB_LEAPADD 0x00000200 /* LEAP addition warning */
|
||||
#define PARSEB_LEAPS 0x00000300 /* LEAP warnings */
|
||||
#define PARSEB_LEAPSECOND 0x00000400 /* actual leap second */
|
||||
/*
|
||||
* optional status information
|
||||
*/
|
||||
#define PARSEB_ALTERNATE 0x00001000 /* alternate antenna used */
|
||||
#define PARSEB_POSITION 0x00002000 /* position available */
|
||||
|
||||
/*
|
||||
* feature information
|
||||
*/
|
||||
#define PARSEB_S_LEAP 0x00010000 /* supports LEAP */
|
||||
#define PARSEB_S_ANTENNA 0x00020000 /* supports antenna information */
|
||||
#define PARSEB_S_PPS 0x00040000 /* supports PPS time stamping */
|
||||
#define PARSEB_S_POSITION 0x00080000 /* supports position information (GPS) */
|
||||
|
||||
/*
|
||||
* time stamp availality
|
||||
*/
|
||||
#define PARSEB_TIMECODE 0x10000000 /* valid time code sample */
|
||||
#define PARSEB_PPS 0x20000000 /* valid PPS sample */
|
||||
|
||||
#define PARSE_TCINFO (PARSEB_ANNOUNCE|PARSEB_POWERUP|PARSEB_NOSYNC|PARSEB_DST|\
|
||||
PARSEB_UTC|PARSEB_LEAP|PARSEB_ALTERNATE|PARSEB_S_LEAP|\
|
||||
PARSEB_UTC|PARSEB_LEAPS|PARSEB_ALTERNATE|PARSEB_S_LEAP|\
|
||||
PARSEB_S_LOCATION|PARSEB_TIMECODE)
|
||||
|
||||
#define PARSE_POWERUP(x) ((x) & PARSEB_POWERUP)
|
||||
#define PARSE_NOSYNC(x) (((x) & (PARSEB_POWERUP|PARSEB_NOSYNC)) == PARSEB_NOSYNC)
|
||||
#define PARSE_SYNC(x) (((x) & (PARSEB_POWERUP|PARSEB_NOSYNC)) == 0)
|
||||
#define PARSE_ANNOUNCE(x) ((x) & PARSEB_ANNOUNCE)
|
||||
#define PARSE_DST(x) ((x) & PARSEB_DST)
|
||||
#define PARSE_POWERUP(x) ((x) & PARSEB_POWERUP)
|
||||
#define PARSE_NOSYNC(x) (((x) & (PARSEB_POWERUP|PARSEB_NOSYNC)) == PARSEB_NOSYNC)
|
||||
#define PARSE_SYNC(x) (((x) & (PARSEB_POWERUP|PARSEB_NOSYNC)) == 0)
|
||||
#define PARSE_ANNOUNCE(x) ((x) & PARSEB_ANNOUNCE)
|
||||
#define PARSE_DST(x) ((x) & PARSEB_DST)
|
||||
#define PARSE_UTC(x) ((x) & PARSEB_UTC)
|
||||
#define PARSE_LEAP(x) (PARSE_SYNC(x) && ((x) & PARSEB_LEAP))
|
||||
#define PARSE_LEAPADD(x) (PARSE_SYNC(x) && (((x) & PARSEB_LEAPS) == PARSEB_LEAPADD))
|
||||
#define PARSE_LEAPDEL(x) (PARSE_SYNC(x) && (((x) & PARSEB_LEAPS) == PARSEB_LEAPDEL))
|
||||
#define PARSE_ALTERNATE(x) ((x) & PARSEB_ALTERNATE)
|
||||
#define PARSE_LEAPSECOND(x) (PARSE_SYNC(x) && ((x) & PARSEB_LEAP_SECOND))
|
||||
|
||||
@ -118,9 +138,9 @@ extern int debug;
|
||||
#define PARSE_S_PPS(x) ((x) & PARSEB_S_PPS)
|
||||
#define PARSE_S_POSITION(x) ((x) & PARSEB_S_POSITION)
|
||||
|
||||
#define PARSE_TIMECODE(x) ((x) & PARSEB_TIMECODE)
|
||||
#define PARSE_TIMECODE(x) ((x) & PARSEB_TIMECODE)
|
||||
#define PARSE_PPS(x) ((x) & PARSEB_PPS)
|
||||
#define PARSE_POSITION(x) ((x) & PARSEB_POSITION)
|
||||
#define PARSE_POSITION(x) ((x) & PARSEB_POSITION)
|
||||
|
||||
/*
|
||||
* operation flags - some are also fudge flags
|
||||
@ -281,6 +301,7 @@ struct clocktime /* clock time broken up from time code */
|
||||
LONG second;
|
||||
LONG usecond;
|
||||
LONG utcoffset; /* in seconds */
|
||||
time_t utctime; /* the actual time - alternative to date/time */
|
||||
LONG flags; /* current clock status */
|
||||
};
|
||||
|
||||
@ -365,6 +386,9 @@ extern unsigned LONG pps_simple P((parse_t *, int status, timestamp_t *));
|
||||
* History:
|
||||
*
|
||||
* parse.h,v
|
||||
* Revision 3.17 1994/03/03 09:27:20 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
* Revision 3.13 1994/01/25 19:04:21 kardel
|
||||
* 94/01/23 reconcilation
|
||||
*
|
||||
|
@ -31,7 +31,7 @@ SOURCE= atoint.c atolfp.c atouint.c auth12crypt.c authdecrypt.c authdes.c \
|
||||
uglydate.c uinttoa.c utvtoa.c machines.c clocktypes.c \
|
||||
md5.c a_md5encrypt.c a_md5decrypt.c \
|
||||
a_md512crypt.c decodenetnum.c systime.c msyslog.c syssignal.c \
|
||||
findconfig.c
|
||||
findconfig.c netof.c
|
||||
|
||||
OBJS= atoint.o atolfp.o atouint.o auth12crypt.o authdecrypt.o authdes.o \
|
||||
authencrypt.o authkeys.o authparity.o authreadkeys.o authusekey.o \
|
||||
@ -44,12 +44,12 @@ OBJS= atoint.o atolfp.o atouint.o auth12crypt.o authdecrypt.o authdes.o \
|
||||
uglydate.o uinttoa.o utvtoa.o machines.o clocktypes.o \
|
||||
md5.o a_md5encrypt.o a_md5decrypt.o \
|
||||
a_md512crypt.o decodenetnum.o systime.o msyslog.o syssignal.o \
|
||||
findconfig.o
|
||||
findconfig.o netof.o
|
||||
|
||||
$(LIBNAME).a: $(OBJS)
|
||||
ar rv $@ $?
|
||||
-rm -f $?
|
||||
@if ( hp-pa || hp-mc680x0 ) > /dev/null 2>&1; then \
|
||||
@if ( ../scripts/hpadjtime.sh ) > /dev/null 2>&1; then \
|
||||
( cd ../adjtime && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" ) && ar rv $@ ../adjtime/adjtime.o; \
|
||||
else \
|
||||
:; \
|
||||
|
@ -11,7 +11,7 @@
|
||||
struct clktype clktypes[] = {
|
||||
{ REFCLK_NONE, "unspecified type (0)", "UNKNOWN" },
|
||||
{ REFCLK_LOCALCLOCK, "local clock synchronization (1)", "LOCAL" },
|
||||
{ REFCLK_WWV_HEATH, "Heathkit WWV clock (2)", "WWV_HEATH" },
|
||||
{ REFCLK_GPS_TRAK, "TRAK 8810 GPS Receiver (2)", "GPS_TRAK" },
|
||||
{ REFCLK_WWV_PST, "Precision Standard Time WWV clock (3)", "WWV_PST" },
|
||||
{ REFCLK_WWVB_SPECTRACOM, "Spectracom WWVB clock (4)", "WWVB_SPEC" },
|
||||
{ REFCLK_GOES_TRUETIME, "True Time GPS/GOES clock (5)", "GPS_GOES_TRUE" },
|
||||
|
25
usr.sbin/xntpd/lib/netof.c
Normal file
25
usr.sbin/xntpd/lib/netof.c
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* netof - return the net address part of an ip address
|
||||
* (zero out host part)
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
U_LONG
|
||||
netof(num)
|
||||
U_LONG num;
|
||||
{
|
||||
register U_LONG netnum;
|
||||
|
||||
netnum = num;
|
||||
|
||||
if(IN_CLASSC(netnum))
|
||||
netnum &= IN_CLASSC_NET;
|
||||
else if (IN_CLASSB(netnum))
|
||||
netnum &= IN_CLASSB_NET;
|
||||
else /* treat als other like class A */
|
||||
netnum &= IN_CLASSA_NET;
|
||||
return netnum;
|
||||
}
|
@ -47,12 +47,13 @@ extern int debug;
|
||||
* We also remember the clock precision we computed from the kernel in
|
||||
* case someone asks us.
|
||||
*/
|
||||
LONG sys_clock;
|
||||
|
||||
LONG adj_precision; /* adj precision in usec (tickadj) */
|
||||
LONG tvu_maxslew; /* maximum adjust doable in 1<<CLOCK_ADJ sec (usec) */
|
||||
|
||||
U_LONG tsf_maxslew; /* same as above, as LONG format */
|
||||
|
||||
LONG sys_clock;
|
||||
l_fp sys_clock_offset; /* correction for current system time */
|
||||
|
||||
/*
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= true # ar does the work of ranlib under System V
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSYS_AUX2
|
||||
DEFS= -DSYS_AUX2 -DHAVE_BSD_TTYS
|
||||
AUTHDEFS= -DDES -DMD5 -DFASTMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= true # ar does the work of ranlib under System V
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSYS_AUX3
|
||||
DEFS= -DSYS_AUX3 -DHAVE_BSD_TTYS
|
||||
AUTHDEFS= -DDES -DMD5 -DFASTMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL=-DREFCLOCK
|
||||
DEFS= -DSYS_BSDI
|
||||
DEFS= -DSYS_BSDI -DHAVE_TERMIOS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS= -lkvm
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL=-DREFCLOCK
|
||||
DEFS= -DSYS_CONVEXOS10
|
||||
DEFS= -DSYS_CONVEXOS10 -DHAVE_BSD_TTYS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
RESLIB=
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL=-DREFCLOCK
|
||||
DEFS= -DSYS_CONVEXOS9
|
||||
DEFS= -DSYS_CONVEXOS9 -DHAVE_BSD_TTYS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
RESLIB=
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSTREAM -DSYS_DECOSF1
|
||||
DEFS= -DSTREAM -DSYS_DECOSF1 -DHAVE_TERMIOS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,7 +1,7 @@
|
||||
SHELL= /bin/sh
|
||||
RANLIB= ls # ar does the work of ranlib under System V
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSYS_SVR4
|
||||
DEFS= -DSYS_SVR4 -DHAVE_TERMIOS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSYS_DOMAINOS -D_INCLUDE_BSD_SOURCE -D_INCLUDE_XOPEN_SOURCE -D_INCLUDE_POSIX_SOURCE
|
||||
DEFS= -DSYS_DOMAINOS -D_INCLUDE_BSD_SOURCE -D_INCLUDE_XOPEN_SOURCE -D_INCLUDE_POSIX_SOURCE -DHAVE_BSD_TTYS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
8
usr.sbin/xntpd/machines/hpux-adj
Normal file
8
usr.sbin/xntpd/machines/hpux-adj
Normal file
@ -0,0 +1,8 @@
|
||||
SHELL= /bin/sh
|
||||
RANLIB= ls # ar does the work of ranlib under System V
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DHAVE_TERMIOS -DSYS_HPUX=10
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
COPTS=
|
||||
INSTALL=$(TOP)scripts/install.sh
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSYS_I386
|
||||
DEFS= -DSYS_I386 -DHAVE_BSD_TTYS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,7 +1,7 @@
|
||||
SHELL= /bin/sh
|
||||
RANLIB= ls # ar does the work of ranlib under System V
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSYS_SVR4 -DSTREAMS_TLI
|
||||
DEFS= -DSYS_SVR4 -DSTREAMS_TLI -DHAVE_TERMIOS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,7 +1,7 @@
|
||||
#RANLIB= ranlib
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS=
|
||||
AUTHDEFS= -DDES -DMD5 -DSYS_MIPS
|
||||
DEFS= -DSYS_MIPS -DHAVE_BSD_TTYS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS= -lmld
|
||||
RESLIB=
|
||||
|
@ -1,5 +1,5 @@
|
||||
RANLIB= ranlib -c -s
|
||||
DEFS= -DSYS_NEXT
|
||||
DEFS= -DSYS_NEXT -DHAVE_BSD_TTYS
|
||||
AUTHDEFS= -DDES -DMD5 -DFAST_MD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DHAVE_READ_KMEM -DSYS_SEQUENT
|
||||
DEFS= -DHAVE_READ_KMEM -DSYS_SEQUENT -DHAVE_BSD_TTYS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= :
|
||||
DEFS_LOCAL=-DREFCLOCK
|
||||
DEFS= -DSYS_SINIXM
|
||||
DEFS= -DSYS_SINIXM -DHAVE_TERMIOS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSYS_SONY
|
||||
DEFS= -DSYS_SONY -DHAVE_TERMIOS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS= -lmld
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSYS_SUNOS4
|
||||
DEFS= -DSYS_SUNOS4 -DHAVE_BSD_TTYS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS= -lkvm
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= :
|
||||
DEFS_LOCAL=-DREFCLOCK
|
||||
DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS -DNTP_POSIX_SOURCE
|
||||
DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= :
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS -DADJTIME_IS_ACCURATE -DNTP_POSIX_SOURCE
|
||||
DEFS= -DSTREAM -DSOLARIS -DSYS_SOLARIS -DADJTIME_IS_ACCURATE
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,6 +1,6 @@
|
||||
SHELL= /bin/sh
|
||||
RANLIB= ls # ar does the work of ranlib under System V
|
||||
DEFS= -DSYS_SVR4 -DSTREAMS_TLI
|
||||
DEFS= -DSYS_SVR4 -DSTREAMS_TLI -DHAVE_TERMIOS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS=
|
||||
DAEMONLIBS= -lnet -lnsl -lsocket -lelf
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSYS_ULTRIX
|
||||
DEFS= -DSYS_ULTRIX -DHAVE_TERMIOS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSYS_ULTRIX -DNTP_POSIX_SOURCE -DHAVE_SIGNALED_IO
|
||||
DEFS= -DSYS_ULTRIX -DNTP_POSIX_SOURCE -DHAVE_SIGNALED_IO -DHAVE_TERMIOS
|
||||
AUTHDEFS= -DDES -DMD5
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
|
@ -1,6 +1,6 @@
|
||||
RANLIB= ranlib
|
||||
DEFS_LOCAL= -DREFCLOCK
|
||||
DEFS= -DSYS_VAX
|
||||
DEFS= -DSYS_VAX -DHAVE_BSD_TTYS
|
||||
CLOCKDEFS= -DLOCAL_CLOCK
|
||||
DAEMONLIBS=
|
||||
RESLIB=
|
||||
|
@ -40,7 +40,7 @@ mparsestreams.o.$(KARCH): parsestreams.c microtime.o ../lib/libntp.a libparse_ke
|
||||
rm -f parsestreams.o
|
||||
|
||||
parsestreams.o: parsestreams.o.$(KARCH)
|
||||
@echo "--- You may load parsestreams.o.$(KARCH) via 'modload parsestreams.o.$(KARCH)' into the kernel"
|
||||
@echo "--- You may load parsestreams.o.$(KARCH) via 'modload parsestreams.o' (put in e.g. /sys/<karch>/OBJ) into the kernel"
|
||||
|
||||
parsestreams.o.$(KARCH): parsestreams.c ../lib/libntp.a libparse_kernel.a ../include/parse.h ../include/sys/parsestreams.h
|
||||
cc -c $(DEFS) -I../include parsestreams.c
|
||||
|
212
usr.sbin/xntpd/parse/README.new_clocks
Normal file
212
usr.sbin/xntpd/parse/README.new_clocks
Normal file
@ -0,0 +1,212 @@
|
||||
Here is an attempt to sketch out what you need to do in order to
|
||||
add another clock to the parse driver:
|
||||
|
||||
Prerequisites:
|
||||
- Does the system you want the clock connect to have
|
||||
termio.h or termios.h ? (You need that for the parse driver)
|
||||
|
||||
What to do:
|
||||
|
||||
Make a conversion module (parse/clk_*.c)
|
||||
|
||||
- What ist the time code format ?
|
||||
- find year, month, day, hour, minute, second, status (synchronised or
|
||||
not), possibly time zone information (you need to give the offset to UTC)
|
||||
You will have to convert the data from a string into a struct clocktime:
|
||||
struct clocktime /* clock time broken up from time code */
|
||||
{
|
||||
LONG day;
|
||||
LONG month;
|
||||
LONG year;
|
||||
LONG hour;
|
||||
LONG minute;
|
||||
LONG second;
|
||||
LONG usecond;
|
||||
LONG utcoffset; /* in seconds */
|
||||
time_t utcoffset; /* true utc time instead of date/time */
|
||||
LONG flags; /* current clock status */
|
||||
};
|
||||
|
||||
Conversion is usually simple and straight forward. For the flags following
|
||||
values can be OR'ed together:
|
||||
|
||||
PARSEB_ANNOUNCE switch time zone warning (informational only)
|
||||
PARSEB_POWERUP no synchronisation - clock confused (must set then)
|
||||
PARSEB_NOSYNC timecode currently not confirmed (must set then)
|
||||
usually on reception error when there is still a
|
||||
chance the the generated time is still ok.
|
||||
|
||||
PARSEB_DST DST in effect (informational only)
|
||||
PARSEB_UTC timecode contains UTC time (informational only)
|
||||
PARSEB_LEAPADD LEAP addition warning (prior to leap happening - must set when imminent)
|
||||
also used for time code that do not encode the
|
||||
direction (as this is currently the default).
|
||||
PARSEB_LEAPDEL LEAP deletion warning (prior to leap happening - must set when imminent)
|
||||
PARSEB_ALTERNATE backup transmitter (informational only)
|
||||
PARSEB_POSITION geographic position available (informational only)
|
||||
PARSEB_LEAPSECOND actual leap second (this time code is the leap
|
||||
second - informational only)
|
||||
|
||||
These are feature flags denoting items that are supported by the clock:
|
||||
PARSEB_S_LEAP supports LEAP - might set PARSEB_LEAP
|
||||
PARSEB_S_ANTENNA supports ANTENNA - might set PARSEB_ALTERNATE
|
||||
PARSEB_S_PPS supports PPS time stamping
|
||||
PARSEB_S_POSITION supports position information (GPS)
|
||||
|
||||
If the utctime field is non zero this value will be take as
|
||||
time code value. This allows for conversion routines that
|
||||
already have the utc time value. The utctime field gives the seconds
|
||||
since Jan 1st 1970, 0:00:00. The useconds field gives the respective
|
||||
usec value. The fields for date and time (down to second resolution)
|
||||
will be ignored.
|
||||
|
||||
Conversion is done in the cvt_* routine in parse/clk_*.c files. look in
|
||||
them for examples. The basic structure is:
|
||||
|
||||
struct clockformat <yourclock>_format = {
|
||||
lots of fields for you to fill out (see below)
|
||||
};
|
||||
|
||||
static cvt_<yourclock>()
|
||||
...
|
||||
{
|
||||
if (<I do not recognize my time code>) {
|
||||
return CVT_NONE;
|
||||
} else {
|
||||
if (<conversion into clockformat is ok>) {
|
||||
<set all necessary flags>;
|
||||
return CVT_OK;
|
||||
} else {
|
||||
return CVT_FAIL|CVT_BADFMT;
|
||||
}
|
||||
}
|
||||
|
||||
The struct clockformat is the interface to the rest of the parse
|
||||
driver - it holds all information necessary for finding the
|
||||
clock message and doing the appropriate time stamping.
|
||||
|
||||
struct clockformat
|
||||
{
|
||||
unsigned LONG (*convert)();
|
||||
/* conversion routine - your routine - cvt_<yourclock> */
|
||||
void (*syncevt)();
|
||||
/* routine for handling RS232 sync events (time stamps) - usually sync_simple */
|
||||
unsigned LONG (*syncpps)();
|
||||
/* PPS input routine - usually pps_simple */
|
||||
unsigned LONG (*synth)();
|
||||
/* time code synthesizer - usually not used - (LONG (*)())0 */
|
||||
void *data;
|
||||
/* local parameters - any parameters/data/configuration info your conversion
|
||||
routine might need */
|
||||
char *name;
|
||||
/* clock format name - Name of the time code */
|
||||
unsigned short length;
|
||||
/* maximum length of data packet for your clock format */
|
||||
unsigned LONG flags;
|
||||
/* information for the parser what to look for */
|
||||
struct timeval timeout;
|
||||
/* buffer restart after timeout (us) - some clocks preceede new data by
|
||||
a longer period of silence - unsually not used */
|
||||
unsigned char startsym;
|
||||
/* start symbol - character at the beginning of the clock data */
|
||||
unsigned char endsym;
|
||||
/* end symbol - character at the end of the clock data */
|
||||
unsigned char syncsym;
|
||||
/* sync symbol - character that is "on time" - where the time stamp should be taken */
|
||||
};
|
||||
|
||||
The flags:
|
||||
F_START use startsym to find the beginning of the clock data
|
||||
F_END use endsym to find the end of the clock data
|
||||
SYNC_TIMEOUT packet restart after timeout in timeout field
|
||||
SYNC_START packet start is sync event (time stamp at paket start)
|
||||
SYNC_END packet end is sync event (time stamp at paket end)
|
||||
SYNC_CHAR special character (syncsym) is sync event
|
||||
SYNC_ONE PPS synchronize on 'ONE' transition
|
||||
SYNC_ZERO PPS synchronize on 'ZERO' transition
|
||||
SYNC_SYNTHESIZE generate intermediate time stamps (very special case!)
|
||||
CVT_FIXEDONLY convert only in fixed configuration - (data format not
|
||||
suitable for auto-configuration)
|
||||
|
||||
|
||||
The above should have given you some hints on how to build a clk_*.c
|
||||
file with the time code conversion. See the examples and pick a clock
|
||||
closest to yours and tweak the code to match your clock.
|
||||
|
||||
In order to make your clk_*.c file usable a reference to the clockformat
|
||||
structure must be put into parse_conf.c.
|
||||
|
||||
TTY setup and initialisation/configuration will be done in
|
||||
xntpd/refclock_parse.c
|
||||
|
||||
- Find out the exact tty settings for your clock (baud rate, parity,
|
||||
stop bits, character size, ...) and note them in terms of
|
||||
termio*.h c_cflag macros.
|
||||
|
||||
- in xntpd/refclock_parse.c fill out a new the struct clockinfo element
|
||||
(that allocates a new "IP" address - see comments)
|
||||
(see all the other clocks for example)
|
||||
struct clockinfo
|
||||
{
|
||||
U_LONG cl_flags; /* operation flags (io modes) */
|
||||
PARSE_F_NOPOLLONLY always do async io - read whenever input comes
|
||||
PARSE_F_POLLONLY never do async io - only read when expecting data
|
||||
PARSE_F_PPSPPS use loopfilter PPS code (CIOGETEV)
|
||||
PARSE_F_PPSONSECOND PPS pulses are on second
|
||||
usually flags stay 0 as they are used only for special setups
|
||||
|
||||
void (*cl_poll)(); /* active poll routine */
|
||||
The routine to call when the clock needs data sent to it in order to
|
||||
get a time code from the clock (e.g. Trimble clock)
|
||||
int (*cl_init)(); /* active poll init routine */
|
||||
The routine to call for very special initializations.
|
||||
void (*cl_end)(); /* active poll end routine */
|
||||
The routine to call to undo any special initialisation (free memory/timers)
|
||||
void *cl_data; /* local data area for "poll" mechanism */
|
||||
local data for polling routines
|
||||
u_fp cl_rootdelay; /* rootdelay */
|
||||
NTP rottdelay estimate (usually 0)
|
||||
U_LONG cl_basedelay; /* current offset - unsigned l_fp fractional par
|
||||
time (fraction) by which the RS232 time code is delayed from the actual time.
|
||||
t */
|
||||
U_LONG cl_ppsdelay; /* current PPS offset - unsigned l_fp fractional
|
||||
time (fraction) by which the PPS time stamp is delayed (usually 0)
|
||||
part */
|
||||
char *cl_id; /* ID code (usually "DCF") */
|
||||
Refclock id - (max 4 chars)
|
||||
char *cl_description; /* device name */
|
||||
Name of this device.
|
||||
char *cl_format; /* fixed format */
|
||||
If the data format cann not ne detected automatically this is the name
|
||||
as in clk_*.c clockformat.
|
||||
u_char cl_type; /* clock type (ntp control) */
|
||||
Type if clock as in clock status word (ntp control messages) - usually 0
|
||||
U_LONG cl_maxunsync; /* time to trust oscillator after loosing synch
|
||||
*/
|
||||
seconds a clock can be trusted after loosing synchronisation.
|
||||
|
||||
U_LONG cl_cflag; /* terminal io flags */
|
||||
U_LONG cl_iflag; /* terminal io flags */
|
||||
U_LONG cl_oflag; /* terminal io flags */
|
||||
U_LONG cl_lflag; /* terminal io flags */
|
||||
termio*.h tty modes.
|
||||
} clockinfo[] = {
|
||||
...,<other clocks>,...
|
||||
{ < your parameters> },
|
||||
};
|
||||
|
||||
|
||||
Well, this is very sketchy, i know. But I hope it helps a little bit.
|
||||
The best way is to look which clock comes closest to your and tweak that
|
||||
code.
|
||||
Two sorts of clocks are used with parse. Clocks that automatically send
|
||||
their time code (once a second) do not need entries in the poll routines because
|
||||
they send the data all the time. The second sort are the clocks that need a
|
||||
command sent to them in order to reply with a time code (like the Trimble
|
||||
clock).
|
||||
|
||||
For questions: kardel@informatik.uni-erlangen.de. Please include
|
||||
an exact description on how your clock works. (initialisation,
|
||||
TTY modes, strings to be sent to it, responses received from the clock).
|
||||
|
||||
Frank Kardel
|
263
usr.sbin/xntpd/parse/README.parse_clocks
Normal file
263
usr.sbin/xntpd/parse/README.parse_clocks
Normal file
@ -0,0 +1,263 @@
|
||||
The parse driver currently supports several clocks with different
|
||||
query mechanisms. In order for you to find a sample that might be
|
||||
similar to a clock you might want to integrate into parse i'll sum
|
||||
up the major features of the clocks (this information is distributed
|
||||
in the parse/clk_*.c and xntpd/refclock_parse.c files).
|
||||
|
||||
---
|
||||
Meinberg: 127.127.8. 0- 3 (PZF535TCXO)
|
||||
127.127.8. 4- 7 (PZF535OCXO)
|
||||
127.127.8. 8-11 (DCFUA31)
|
||||
127.127.8.28-31 (GPS166)
|
||||
Meinberg: start=<STX>, end=<ETX>, sync on start
|
||||
pattern="\2D: . . ;T: ;U: . . ; \3"
|
||||
pattern="\2 . . ; ; : : ; \3"
|
||||
pattern="\2 . . ; ; : : ; : ; ; . . "
|
||||
|
||||
Meinberg is a german manufacturer of time code receivers. Those clocks
|
||||
have a pretty common output format in the stock version. In order to
|
||||
support NTP Meinberg was so kind to produce some special versions of
|
||||
the firmware for the use with NTP. So, if you are going to use a
|
||||
Meinberg clock please ask whether there is a special Uni Erlangen
|
||||
version.
|
||||
|
||||
General characteristics:
|
||||
Meinberg clocks primarily output pulse per second and a describing
|
||||
ASCII string. This string can be produced in two modes. either upon
|
||||
the reception of a question mark or every second. NTP uses the latter
|
||||
mechanism. The DCF77 variants have a pretty good relationship between
|
||||
RS232 time code and the PPS signal while the GPS receiver has no fixed
|
||||
timeing between the datagram and the pulse (you need to use PPS with
|
||||
GPS!) on DCF77 you might get away without the PPS signal.
|
||||
|
||||
The preferred tty setting for Meinberg is:
|
||||
CFLAG (B9600|CS7|PARENB|CREAD|HUPCL)
|
||||
IFLAG (IGNBRK|IGNPAR|ISTRIP)
|
||||
OFLAG 0
|
||||
LFLAG 0
|
||||
|
||||
The clock is run at datagram once per second.
|
||||
Stock dataformat is:
|
||||
|
||||
<STX>D:<dd>.<mm>.<yy>;T:<w>;U:<hh>:<mm>:<ss>;<S><F><D><A><ETX>
|
||||
pos: 0 00 00 0 00 0 11 111 1 111 12 2 22 2 22 2 2 2 3 3 3
|
||||
1 23 45 6 78 9 01 234 5 678 90 1 23 4 56 7 8 9 0 1 2
|
||||
|
||||
<STX> = '\002' ASCII start of text
|
||||
<ETX> = '\003' ASCII end of text
|
||||
<dd>,<mm>,<yy> = day, month, year(2 digits!!)
|
||||
<w> = day of week (sunday= 0)
|
||||
<hh>,<mm>,<ss> = hour, minute, second
|
||||
<S> = '#' if never synced since powerup else ' ' for DCF U/A 31
|
||||
'#' if not PZF sychronisation available else ' ' for PZF 535
|
||||
<F> = '*' if time comes from internal quartz else ' '
|
||||
<D> = 'S' if daylight saving time is active else ' '
|
||||
<A> = '!' during the hour preceeding an daylight saving time
|
||||
start/end change
|
||||
|
||||
For the university of Erlangen a special format was implemented to support
|
||||
LEAP announcement and anouncement of alternate antenna.
|
||||
|
||||
Version for UNI-ERLANGEN Software is: PZFUERL V4.6 (Meinberg)
|
||||
|
||||
The use of this software release (or higher) is *ABSOLUTELY*
|
||||
recommended (ask for PZFUERL version as some minor HW fixes have
|
||||
been introduced) due to the LEAP second support and UTC indication.
|
||||
The standard timecode does not indicate when the timecode is in
|
||||
UTC (by front panel configuration) thus we have no chance to find
|
||||
the correct utc offset. For the standard format do not ever use
|
||||
UTC display as this is not detectable in the time code !!!
|
||||
|
||||
<STX><dd>.<mm>.<yy>; <w>; <hh>:<mm>:<ss>; <U><S><F><D><A><L><R><ETX>
|
||||
pos: 0 00 0 00 0 00 11 1 11 11 1 11 2 22 22 2 2 2 2 2 3 3 3
|
||||
1 23 4 56 7 89 01 2 34 56 7 89 0 12 34 5 6 7 8 9 0 1 2
|
||||
<STX> = '\002' ASCII start of text
|
||||
<ETX> = '\003' ASCII end of text
|
||||
<dd>,<mm>,<yy> = day, month, year(2 digits!!)
|
||||
<w> = day of week (sunday= 0)
|
||||
<hh>,<mm>,<ss> = hour, minute, second
|
||||
<U> = 'U' UTC time display
|
||||
<S> = '#' if never synced since powerup else ' ' for DCF U/A 31
|
||||
'#' if not PZF sychronisation available else ' ' for PZF 535
|
||||
<F> = '*' if time comes from internal quartz else ' '
|
||||
<D> = 'S' if daylight saving time is active else ' '
|
||||
<A> = '!' during the hour preceeding an daylight saving time
|
||||
start/end change
|
||||
<L> = 'A' LEAP second announcement
|
||||
<R> = 'R' alternate antenna
|
||||
|
||||
Meinberg GPS166 receiver
|
||||
|
||||
You must get the Uni-Erlangen firmware for the GPS receiver support
|
||||
to work to full satisfaction !
|
||||
|
||||
<STX><dd>.<mm>.<yy>; <w>; <hh>:<mm>:<ss>; <+/-><00:00>; <U><S><F><D><A><L><R><L>; <position...><ETX>
|
||||
*
|
||||
000000000111111111122222222223333333333444444444455555555556666666
|
||||
123456789012345678901234567890123456789012345678901234567890123456
|
||||
\x0209.07.93; 5; 08:48:26; +00:00; ; 49.5736N 11.0280E 373m\x03
|
||||
*
|
||||
|
||||
<STX> = '\002' ASCII start of text
|
||||
<ETX> = '\003' ASCII end of text
|
||||
<dd>,<mm>,<yy> = day, month, year(2 digits!!)
|
||||
<w> = day of week (sunday= 0)
|
||||
<hh>,<mm>,<ss> = hour, minute, second
|
||||
<+/->,<00:00> = offset to UTC
|
||||
<S> = '#' if never synced since powerup else ' ' for DCF U/A 31
|
||||
'#' if not PZF sychronisation available else ' ' for PZF 535
|
||||
<U> = 'U' UTC time display
|
||||
<F> = '*' if time comes from internal quartz else ' '
|
||||
<D> = 'S' if daylight saving time is active else ' '
|
||||
<A> = '!' during the hour preceeding an daylight saving time
|
||||
start/end change
|
||||
<L> = 'A' LEAP second announcement
|
||||
<R> = 'R' alternate antenna (reminiscent of PZF535) usually ' '
|
||||
<L> = 'L' on 23:59:60
|
||||
|
||||
|
||||
For the Meinberg parse look into clock_meinberg.c
|
||||
|
||||
---
|
||||
RAWDCF: 127.127.8.20-23 (Conrad receiver module - delay 210ms)
|
||||
127.127.8.24-27 (FAU receiver - delay 258ms)
|
||||
RAWDCF: end=TIMEOUT>1.5s, sync each char (any char),generate psuedo time
|
||||
codes, fixed format
|
||||
|
||||
direct DCF77 code input
|
||||
In Europe it is relatively easy/cheap the receive the german time code
|
||||
transmitter DCF77. The simplest version to process its signal is to
|
||||
feed the 100/200ms pulse of the demodulated AM signal via a level
|
||||
converter to an RS232 port at 50Baud. parse/clk_rawdcf.c holds all
|
||||
necessary decoding logic for the time code which is transmitted each
|
||||
minute for one minute. A bit of the time code is sent once a second.
|
||||
|
||||
The preferred tty setting is:
|
||||
CFLAG (B50|CS8|CREAD|CLOCAL)
|
||||
IFLAG 0
|
||||
OFLAG 0
|
||||
LFLAG 0
|
||||
|
||||
DCF77 raw time code
|
||||
|
||||
From "Zur Zeit", Physikalisch-Technische Bundesanstalt (PTB), Braunschweig
|
||||
und Berlin, Maerz 1989
|
||||
|
||||
Timecode transmission:
|
||||
AM:
|
||||
time marks are send every second except for the second before the
|
||||
next minute mark
|
||||
time marks consist of a reduction of transmitter power to 25%
|
||||
of the nominal level
|
||||
the falling edge is the time indication (on time)
|
||||
time marks of a 100ms duration constitute a logical 0
|
||||
time marks of a 200ms duration constitute a logical 1
|
||||
FM:
|
||||
see the spec. (basically a (non-)inverted psuedo random phase shift)
|
||||
|
||||
Encoding:
|
||||
Second Contents
|
||||
0 - 10 AM: free, FM: 0
|
||||
11 - 14 free
|
||||
15 R - alternate antenna
|
||||
16 A1 - expect zone change (1 hour before)
|
||||
17 - 18 Z1,Z2 - time zone
|
||||
0 0 illegal
|
||||
0 1 MEZ (MET)
|
||||
1 0 MESZ (MED, MET DST)
|
||||
1 1 illegal
|
||||
19 A2 - expect leap insertion/deletion (1 hour before)
|
||||
20 S - start of time code (1)
|
||||
21 - 24 M1 - BCD (lsb first) Minutes
|
||||
25 - 27 M10 - BCD (lsb first) 10 Minutes
|
||||
28 P1 - Minute Parity (even)
|
||||
29 - 32 H1 - BCD (lsb first) Hours
|
||||
33 - 34 H10 - BCD (lsb first) 10 Hours
|
||||
35 P2 - Hour Parity (even)
|
||||
36 - 39 D1 - BCD (lsb first) Days
|
||||
40 - 41 D10 - BCD (lsb first) 10 Days
|
||||
42 - 44 DW - BCD (lsb first) day of week (1: Monday -> 7: Sunday)
|
||||
45 - 49 MO - BCD (lsb first) Month
|
||||
50 MO0 - 10 Months
|
||||
51 - 53 Y1 - BCD (lsb first) Years
|
||||
54 - 57 Y10 - BCD (lsb first) 10 Years
|
||||
58 P3 - Date Parity (even)
|
||||
59 - usually missing (minute indication), except for leap insertion
|
||||
|
||||
---
|
||||
Schmid clock: 127.127.8.16-19
|
||||
Schmid clock: needs poll, binary input, end='\xFC', sync start
|
||||
|
||||
The Schmid clock is a DCF77 receiver that sends a binary
|
||||
time code at the reception of a flag byte. The contents
|
||||
if the flag byte determined the time code format. The
|
||||
binary time code is delimited by the byte 0xFC.
|
||||
|
||||
TTY setup is:
|
||||
CFLAG (B1200|CS8|CREAD|CLOCAL)
|
||||
IFLAG 0
|
||||
OFLAG 0
|
||||
LFLAG 0
|
||||
|
||||
The command to Schmid's DCF77 clock is a single byte; each bit
|
||||
allows the user to select some part of the time string, as follows (the
|
||||
output for the lsb is sent first).
|
||||
|
||||
Bit 0: time in MEZ, 4 bytes *binary, not BCD*; hh.mm.ss.tenths
|
||||
Bit 1: date 3 bytes *binary, not BCD: dd.mm.yy
|
||||
Bit 2: week day, 1 byte (unused here)
|
||||
Bit 3: time zone, 1 byte, 0=MET, 1=MEST. (unused here)
|
||||
Bit 4: clock status, 1 byte, 0=time invalid,
|
||||
1=time from crystal backup,
|
||||
3=time from DCF77
|
||||
Bit 5: transmitter status, 1 byte,
|
||||
bit 0: backup antenna
|
||||
bit 1: time zone change within 1h
|
||||
bit 3,2: TZ 01=MEST, 10=MET
|
||||
bit 4: leap second will be
|
||||
added within one hour
|
||||
bits 5-7: Zero
|
||||
Bit 6: time in backup mode, units of 5 minutes (unused here)
|
||||
|
||||
|
||||
---
|
||||
Trimble SV6: 127.127.8.32-35
|
||||
Trimble SV6: needs poll, ascii timecode, start='>', end='<',
|
||||
query='>QTM<', eol='<'
|
||||
|
||||
Trimble SV6 is a GPS receiver with PPS output. It needs to be polled.
|
||||
It also need a special tty mode setup (EOL='<').
|
||||
|
||||
TTY setup is:
|
||||
CFLAG (B4800|CS8|CREAD)
|
||||
IFLAG (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON)
|
||||
OFLAG (OPOST|ONLCR)
|
||||
LFLAG (ICANON|ECHOK)
|
||||
|
||||
Special flags are:
|
||||
PARSE_F_PPSPPS - use CIOGETEV for PPS time stamping
|
||||
PARSE_F_PPSONSECOND - the time code is not related to
|
||||
the PPS pulse (so use the time code
|
||||
only for the second epoch)
|
||||
|
||||
Timecode
|
||||
0000000000111111111122222222223333333 / char
|
||||
0123456789012345678901234567890123456 \ posn
|
||||
>RTMhhmmssdddDDMMYYYYoodnnvrrrrr;*xx< Actual
|
||||
----33445566600112222BB7__-_____--99- Parse
|
||||
>RTM 1 ;* <", Check
|
||||
|
||||
---
|
||||
ELV DCF7000: 127.127.8.12-15
|
||||
ELV DCF7000: end='\r', pattern=" - - - - - - - \r"
|
||||
|
||||
The ELV DCF7000 is a cheap DCF77 receiver sending each second
|
||||
a time code (though not very precise!) delimited by '`r'
|
||||
|
||||
Timecode
|
||||
YY-MM-DD-HH-MM-SS-FF\r
|
||||
|
||||
FF&0x1 - DST
|
||||
FF&0x2 - DST switch warning
|
||||
FF&0x4 - unsynchronised
|
||||
|
@ -1,8 +1,8 @@
|
||||
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_DCF7000)
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/parse/clk_dcf7000.c,v 3.10 1994/01/25 19:05:07 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/parse/clk_dcf7000.c,v 3.11 1994/02/02 17:45:14 kardel Exp
|
||||
*
|
||||
* clk_dcf7000.c,v 3.10 1994/01/25 19:05:07 kardel Exp
|
||||
* clk_dcf7000.c,v 3.11 1994/02/02 17:45:14 kardel Exp
|
||||
*
|
||||
* ELV DCF7000 module
|
||||
*
|
||||
@ -121,6 +121,9 @@ cvt_dcf7000(buffer, size, format, clock)
|
||||
* History:
|
||||
*
|
||||
* clk_dcf7000.c,v
|
||||
* Revision 3.11 1994/02/02 17:45:14 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
* Revision 3.6 1993/10/09 15:01:27 kardel
|
||||
* file structure unified
|
||||
*
|
||||
|
@ -1,8 +1,8 @@
|
||||
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_MEINBERG)
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.11 1994/01/25 19:05:10 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/parse/clk_meinberg.c,v 3.14 1994/02/20 13:04:37 kardel Exp
|
||||
*
|
||||
* clk_meinberg.c,v 3.11 1994/01/25 19:05:10 kardel Exp
|
||||
* clk_meinberg.c,v 3.14 1994/02/20 13:04:37 kardel Exp
|
||||
*
|
||||
* Meinberg clock support
|
||||
*
|
||||
@ -284,8 +284,13 @@ cvt_meinberg(buffer, size, format, clock)
|
||||
clock->flags |= PARSEB_S_LEAP;
|
||||
clock->flags |= PARSEB_S_ANTENNA;
|
||||
|
||||
/*
|
||||
* DCF77 does not encode the direction -
|
||||
* so we take the current default -
|
||||
* earth slowing down
|
||||
*/
|
||||
if (f[4] == 'A')
|
||||
clock->flags |= PARSEB_LEAP;
|
||||
clock->flags |= PARSEB_LEAPADD;
|
||||
|
||||
if (f[5] == 'R')
|
||||
clock->flags |= PARSEB_ALTERNATE;
|
||||
@ -394,9 +399,12 @@ cvt_mgps(buffer, size, format, clock)
|
||||
|
||||
/*
|
||||
* oncoming leap second
|
||||
* data format does not (yet) specify whether
|
||||
* to add or to delete a second - thus we
|
||||
* pick the current default
|
||||
*/
|
||||
if (f[5] == 'A')
|
||||
clock->flags |= PARSEB_LEAP;
|
||||
clock->flags |= PARSEB_LEAPADD;
|
||||
|
||||
/*
|
||||
* this is the leap second
|
||||
@ -414,6 +422,12 @@ cvt_mgps(buffer, size, format, clock)
|
||||
* History:
|
||||
*
|
||||
* clk_meinberg.c,v
|
||||
* Revision 3.14 1994/02/20 13:04:37 kardel
|
||||
* parse add/delete second support
|
||||
*
|
||||
* Revision 3.13 1994/02/02 17:45:21 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
* Revision 3.11 1994/01/25 19:05:10 kardel
|
||||
* 94/01/23 reconcilation
|
||||
*
|
||||
|
@ -1,8 +1,8 @@
|
||||
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RAWDCF)
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.9 1994/01/25 19:05:12 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/parse/clk_rawdcf.c,v 3.13 1994/03/10 19:00:43 kardel Exp
|
||||
*
|
||||
* clk_rawdcf.c,v 3.9 1994/01/25 19:05:12 kardel Exp
|
||||
* clk_rawdcf.c,v 3.13 1994/03/10 19:00:43 kardel Exp
|
||||
*
|
||||
* Raw DCF77 pulse clock support
|
||||
*
|
||||
@ -245,6 +245,7 @@ static unsigned LONG convert_rawdcf(buffer, size, dcfparam, clock)
|
||||
parseprintf(DD_RAWDCF,("parse: convert_rawdcf: parity check passed\n"));
|
||||
|
||||
clock->flags = PARSEB_S_ANTENNA|PARSEB_S_LEAP;
|
||||
clock->utctime= 0;
|
||||
clock->usecond= 0;
|
||||
clock->second = 0;
|
||||
clock->minute = ext_bf(buffer, DCF_M10, dcfparam->zerobits);
|
||||
@ -278,7 +279,7 @@ static unsigned LONG convert_rawdcf(buffer, size, dcfparam, clock)
|
||||
clock->flags |= PARSEB_ANNOUNCE;
|
||||
|
||||
if (ext_bf(buffer, DCF_A2, dcfparam->zerobits))
|
||||
clock->flags |= PARSEB_LEAP;
|
||||
clock->flags |= PARSEB_LEAPADD; /* default: DCF77 data format deficiency */
|
||||
|
||||
if (ext_bf(buffer, DCF_R, dcfparam->zerobits))
|
||||
clock->flags |= PARSEB_ALTERNATE;
|
||||
@ -529,6 +530,15 @@ static unsigned LONG snt_rawdcf(parseio, ptime)
|
||||
* History:
|
||||
*
|
||||
* clk_rawdcf.c,v
|
||||
* Revision 3.13 1994/03/10 19:00:43 kardel
|
||||
* clear utctime field to avoid confusion on synthesize time stamps
|
||||
*
|
||||
* Revision 3.12 1994/02/20 13:04:39 kardel
|
||||
* parse add/delete second support
|
||||
*
|
||||
* Revision 3.11 1994/02/02 17:45:23 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
* Revision 3.9 1994/01/25 19:05:12 kardel
|
||||
* 94/01/23 reconcilation
|
||||
*
|
||||
|
@ -1,8 +1,8 @@
|
||||
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_SCHMID)
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.10 1994/01/25 19:05:15 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/parse/clk_schmid.c,v 3.13 1994/02/20 13:04:41 kardel Exp
|
||||
*
|
||||
* clk_schmid.c,v 3.10 1994/01/25 19:05:15 kardel Exp
|
||||
* clk_schmid.c,v 3.13 1994/02/20 13:04:41 kardel Exp
|
||||
*
|
||||
* Schmid clock support
|
||||
*
|
||||
@ -152,7 +152,7 @@ cvt_schmid(buffer, size, format, clock)
|
||||
|
||||
if (buffer[8] & WS_LEAP)
|
||||
{
|
||||
clock->flags |= PARSEB_LEAP;
|
||||
clock->flags |= PARSEB_LEAPADD; /* default: DCF77 data format deficiency */
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,6 +168,12 @@ cvt_schmid(buffer, size, format, clock)
|
||||
* History:
|
||||
*
|
||||
* clk_schmid.c,v
|
||||
* Revision 3.13 1994/02/20 13:04:41 kardel
|
||||
* parse add/delete second support
|
||||
*
|
||||
* Revision 3.12 1994/02/02 17:45:25 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
* Revision 3.10 1994/01/25 19:05:15 kardel
|
||||
* 94/01/23 reconcilation
|
||||
*
|
||||
|
@ -1,6 +1,6 @@
|
||||
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_TRIMSV6)
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/parse/clk_trimble.c,v 3.7 1994/01/25 19:05:17 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/parse/clk_trimble.c,v 3.9 1994/02/02 17:45:27 kardel Exp
|
||||
*
|
||||
* Trimble SV6 clock support
|
||||
*/
|
||||
@ -106,6 +106,9 @@ cvt_trimsv6(buffer, size, format, clock)
|
||||
* History:
|
||||
*
|
||||
* clk_trimble.c,v
|
||||
* Revision 3.9 1994/02/02 17:45:27 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
* Revision 3.7 1994/01/25 19:05:17 kardel
|
||||
* 94/01/23 reconcilation
|
||||
*
|
||||
|
@ -1,8 +1,8 @@
|
||||
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS))
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.19 1994/01/25 19:05:20 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/parse/parse.c,v 3.22 1994/02/25 12:34:49 kardel Exp
|
||||
*
|
||||
* parse.c,v 3.19 1994/01/25 19:05:20 kardel Exp
|
||||
* parse.c,v 3.22 1994/02/25 12:34:49 kardel Exp
|
||||
*
|
||||
* Parser module for reference clock
|
||||
*
|
||||
@ -556,6 +556,9 @@ parse_to_unixtime(clock, cvtrtc)
|
||||
register int i;
|
||||
time_t t;
|
||||
|
||||
if (clock->utctime)
|
||||
return clock->utctime; /* if the conversion routine gets it right away - why not */
|
||||
|
||||
if (clock->year < 100)
|
||||
clock->year += 1900;
|
||||
|
||||
@ -628,6 +631,9 @@ parse_to_unixtime(clock, cvtrtc)
|
||||
t += clock->utcoffset; /* warp to UTC */
|
||||
|
||||
/* done */
|
||||
|
||||
clock->utctime = t; /* documentray only */
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
@ -890,6 +896,8 @@ timepacket(parseio)
|
||||
|
||||
if (parseio->parse_flags & PARSE_FIXED_FMT)
|
||||
{
|
||||
clock.utctime = 0;
|
||||
|
||||
switch ((cvtrtc = clockformats[format]->convert ? clockformats[format]->convert(parseio->parse_data, parseio->parse_index, clockformats[format]->data, &clock) : CVT_NONE) & CVT_MASK)
|
||||
{
|
||||
case CVT_FAIL:
|
||||
@ -941,6 +949,8 @@ timepacket(parseio)
|
||||
{
|
||||
do
|
||||
{
|
||||
clock.utctime = 0;
|
||||
|
||||
switch ((cvtrtc = (clockformats[format]->convert && !(clockformats[format]->flags & CVT_FIXEDONLY)) ?
|
||||
clockformats[format]->convert(parseio->parse_data, parseio->parse_index, clockformats[format]->data, &clock) :
|
||||
CVT_NONE) & CVT_MASK)
|
||||
@ -1148,6 +1158,12 @@ parse_setcs(dct, parse)
|
||||
* History:
|
||||
*
|
||||
* parse.c,v
|
||||
* Revision 3.22 1994/02/25 12:34:49 kardel
|
||||
* allow for converter generated utc times
|
||||
*
|
||||
* Revision 3.21 1994/02/02 17:45:30 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
* Revision 3.19 1994/01/25 19:05:20 kardel
|
||||
* 94/01/23 reconcilation
|
||||
*
|
||||
|
@ -1,8 +1,8 @@
|
||||
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS))
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/parse/parse_conf.c,v 3.13 1994/01/25 19:05:23 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/parse/parse_conf.c,v 3.15 1994/02/02 17:45:32 kardel Exp
|
||||
*
|
||||
* parse_conf.c,v 3.13 1994/01/25 19:05:23 kardel Exp
|
||||
* parse_conf.c,v 3.15 1994/02/02 17:45:32 kardel Exp
|
||||
*
|
||||
* Parser configuration module for reference clocks
|
||||
*
|
||||
@ -81,6 +81,9 @@ unsigned short nformats = sizeof(clockformats) / sizeof(clockformats[0]) - 1;
|
||||
* History:
|
||||
*
|
||||
* parse_conf.c,v
|
||||
* Revision 3.15 1994/02/02 17:45:32 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
* Revision 3.13 1994/01/25 19:05:23 kardel
|
||||
* 94/01/23 reconcilation
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/parse/parsesolaris.c,v 3.9 1994/01/25 19:05:26 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/parse/parsesolaris.c,v 3.15 1994/02/15 22:20:51 kardel Exp
|
||||
*
|
||||
* parsesolaris.c,v 3.9 1994/01/25 19:05:26 kardel Exp
|
||||
* parsesolaris.c,v 3.15 1994/02/15 22:20:51 kardel Exp
|
||||
*
|
||||
* STREAMS module for reference clocks
|
||||
* (SunOS5.x - not fully tested - buyer beware ! - OS KILLERS may still be
|
||||
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "parsesolaris.c,v 3.9 1994/01/25 19:05:26 kardel Exp";
|
||||
static char rcsid[] = "parsesolaris.c,v 3.15 1994/02/15 22:20:51 kardel Exp";
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -65,7 +65,7 @@ static struct fmodsw fmod_templ =
|
||||
{
|
||||
"parse", /* module name */
|
||||
&parseinfo, /* module information */
|
||||
0, /* not clean yet */
|
||||
D_NEW|D_MP|D_MTQPAIR, /* exclusive for q pair */
|
||||
/* lock ptr */
|
||||
};
|
||||
|
||||
@ -139,7 +139,7 @@ int Strcmp(s, t)
|
||||
/*ARGSUSED*/
|
||||
int _init(void)
|
||||
{
|
||||
static char revision[] = "3.9";
|
||||
static char revision[] = "3.15";
|
||||
char *s, *S, *t;
|
||||
|
||||
/*
|
||||
@ -413,6 +413,8 @@ static int parseopen(queue_t *q, dev_t *dev, int flag, int sflag, cred_t *credp)
|
||||
parse->parse_ppsclockev.tv.tv_usec = 0;
|
||||
parse->parse_ppsclockev.serial = 0;
|
||||
|
||||
qprocson(q);
|
||||
|
||||
parseprintf(DD_OPEN,("parse: OPEN - initializing io subsystem q=%x\n", q));
|
||||
|
||||
if (!parse_ioinit(&parse->parse_io))
|
||||
@ -420,6 +422,8 @@ static int parseopen(queue_t *q, dev_t *dev, int flag, int sflag, cred_t *credp)
|
||||
/*
|
||||
* ok guys - beat it
|
||||
*/
|
||||
qprocsoff(q);
|
||||
|
||||
kmem_free((caddr_t)parse, sizeof(parsestream_t));
|
||||
|
||||
parsebusy--;
|
||||
@ -441,7 +445,7 @@ static int parseopen(queue_t *q, dev_t *dev, int flag, int sflag, cred_t *credp)
|
||||
*/
|
||||
if (!notice)
|
||||
{
|
||||
printf("%s: Copyright (c) 1991-1993, Frank Kardel\n", modlstrmod.strmod_linkinfo);
|
||||
printf("%s: Copyright (c) 1991-1994, Frank Kardel\n", modlstrmod.strmod_linkinfo);
|
||||
notice = 1;
|
||||
}
|
||||
|
||||
@ -449,7 +453,12 @@ static int parseopen(queue_t *q, dev_t *dev, int flag, int sflag, cred_t *credp)
|
||||
}
|
||||
else
|
||||
{
|
||||
qprocsoff(q);
|
||||
|
||||
kmem_free((caddr_t)parse, sizeof(parsestream_t));
|
||||
|
||||
parsebusy--;
|
||||
|
||||
return EIO;
|
||||
}
|
||||
}
|
||||
@ -462,6 +471,8 @@ static int parseclose(queue_t *q, int flags)
|
||||
|
||||
parseprintf(DD_CLOSE,("parse: CLOSE\n"));
|
||||
|
||||
qprocsoff(q);
|
||||
|
||||
s = splhigh();
|
||||
|
||||
if (parse->parse_dqueue)
|
||||
@ -1179,6 +1190,18 @@ static void zs_xsisr(struct zscom *zs)
|
||||
* History:
|
||||
*
|
||||
* parsesolaris.c,v
|
||||
* Revision 3.15 1994/02/15 22:20:51 kardel
|
||||
* rcsid fixed
|
||||
*
|
||||
* Revision 3.14 1994/02/15 22:06:04 kardel
|
||||
* added qprocsx & flags for MT capability
|
||||
*
|
||||
* Revision 3.13 1994/02/13 19:16:47 kardel
|
||||
* updated verbose Copyright message
|
||||
*
|
||||
* Revision 3.12 1994/02/02 17:45:35 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
* Revision 3.9 1994/01/25 19:05:26 kardel
|
||||
* 94/01/23 reconcilation
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.12 1994/01/25 19:05:30 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/parse/parsestreams.c,v 3.19 1994/02/24 16:33:54 kardel Exp
|
||||
*
|
||||
* parsestreams.c,v 3.12 1994/01/25 19:05:30 kardel Exp
|
||||
* parsestreams.c,v 3.19 1994/02/24 16:33:54 kardel Exp
|
||||
*
|
||||
* STREAMS module for reference clocks
|
||||
* (SunOS4.x)
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "parsestreams.c,v 3.12 1994/01/25 19:05:30 kardel Exp";
|
||||
static char rcsid[] = "parsestreams.c,v 3.19 1994/02/24 16:33:54 kardel Exp";
|
||||
#endif
|
||||
|
||||
#include "sys/types.h"
|
||||
@ -195,7 +195,7 @@ int xxxinit(fc, vdp, vdi, vds)
|
||||
}
|
||||
else
|
||||
{
|
||||
static char revision[] = "3.12";
|
||||
static char revision[] = "3.19";
|
||||
char *s, *S, *t;
|
||||
|
||||
strncpy(ifm->f_name, mname, FMNAMESZ);
|
||||
@ -527,7 +527,7 @@ static int parseopen(q, dev, flag, sflag)
|
||||
*/
|
||||
if (!notice)
|
||||
{
|
||||
printf("%s: Copyright (c) 1991-1993, Frank Kardel\n", parsesync_vd.Drv_name);
|
||||
printf("%s: Copyright (c) 1991-1994, Frank Kardel\n", parsesync_vd.Drv_name);
|
||||
notice = 1;
|
||||
}
|
||||
|
||||
@ -535,6 +535,8 @@ static int parseopen(q, dev, flag, sflag)
|
||||
}
|
||||
else
|
||||
{
|
||||
kmem_free((caddr_t)parse, sizeof(parsestream_t));
|
||||
|
||||
#ifdef VDDRV
|
||||
parsebusy--;
|
||||
#endif
|
||||
@ -1074,6 +1076,11 @@ static void close_zs_linemon(q, my_q)
|
||||
|
||||
#define MAXDEPTH 50 /* maximum allowed stream crawl */
|
||||
|
||||
#ifdef PPS_SYNC
|
||||
extern hardpps();
|
||||
extern struct timeval time;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* take external status interrupt (only CD interests us)
|
||||
*/
|
||||
@ -1085,15 +1092,18 @@ static void zs_xsisr(zs)
|
||||
register queue_t *q;
|
||||
register unsigned char zsstatus;
|
||||
register int loopcheck;
|
||||
register unsigned char cdstate;
|
||||
register char *dname;
|
||||
#ifdef PPS_SYNC
|
||||
register int s;
|
||||
register long usec;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* pick up current state
|
||||
*/
|
||||
zsstatus = zsaddr->zscc_control;
|
||||
|
||||
if (za->za_rr0 ^ (cdstate = zsstatus & ZSRR0_CD))
|
||||
if ((za->za_rr0 ^ zsstatus) & (ZSRR0_CD|ZSRR0_SYNC))
|
||||
{
|
||||
timestamp_t cdevent;
|
||||
register int status;
|
||||
@ -1101,26 +1111,44 @@ static void zs_xsisr(zs)
|
||||
/*
|
||||
* CONDITIONAL external measurement support
|
||||
*/
|
||||
SET_LED(cdstate); /*
|
||||
SET_LED(zsstatus & (ZSRR0_CD|ZSRR0_SYNC)); /*
|
||||
* inconsistent with upper SET_LED, but this
|
||||
* is for oscilloscope business anyway and we
|
||||
* are just interested in edge delays in the
|
||||
* lower us range
|
||||
*/
|
||||
|
||||
#ifdef PPS_SYNC
|
||||
s = splclock();
|
||||
usec = time.tv_usec;
|
||||
#endif
|
||||
/*
|
||||
* time stamp
|
||||
*/
|
||||
uniqtime(&cdevent.tv);
|
||||
|
||||
TIMEVAL_USADD(&cdevent.tv, xsdelay);
|
||||
|
||||
q = za->za_ttycommon.t_readq;
|
||||
|
||||
#ifdef PPS_SYNC
|
||||
splx(s);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* logical state
|
||||
*/
|
||||
status = cd_invert ? cdstate == 0 : cdstate != 0;
|
||||
status = cd_invert ? (zsstatus & (ZSRR0_CD|ZSRR0_SYNC)) == 0 : (zsstatus & (ZSRR0_CD|ZSRR0_SYNC)) != 0;
|
||||
|
||||
#ifdef PPS_SYNC
|
||||
if (status)
|
||||
{
|
||||
usec = cdevent.tv.tv_usec - usec;
|
||||
if (usec < 0)
|
||||
usec += 1000000;
|
||||
|
||||
hardpps(&cdevent.tv, usec);
|
||||
}
|
||||
#endif
|
||||
|
||||
TIMEVAL_USADD(&cdevent.tv, xsdelay);
|
||||
|
||||
q = za->za_ttycommon.t_readq;
|
||||
|
||||
/*
|
||||
* ok - now the hard part - find ourself
|
||||
@ -1177,10 +1205,10 @@ static void zs_xsisr(zs)
|
||||
/*
|
||||
* only pretend that CD has been handled
|
||||
*/
|
||||
za->za_rr0 = za->za_rr0 & ~ZSRR0_CD | zsstatus & ZSRR0_CD;
|
||||
za->za_rr0 = za->za_rr0 & ~(ZSRR0_CD|ZSRR0_SYNC) | zsstatus & (ZSRR0_CD|ZSRR0_SYNC);
|
||||
ZSDELAY(2);
|
||||
|
||||
if (!((za->za_rr0 ^ zsstatus) & ~ZSRR0_CD))
|
||||
if (!((za->za_rr0 ^ zsstatus) & ~(ZSRR0_CD|ZSRR0_SYNC)))
|
||||
{
|
||||
/*
|
||||
* all done - kill status indication and return
|
||||
@ -1258,6 +1286,24 @@ static void zs_xsisr(zs)
|
||||
* History:
|
||||
*
|
||||
* parsestreams.c,v
|
||||
* Revision 3.19 1994/02/24 16:33:54 kardel
|
||||
* CD events can also be posted on sync flag
|
||||
*
|
||||
* Revision 3.18 1994/02/24 14:12:58 kardel
|
||||
* initial PPS_SYNC support version
|
||||
*
|
||||
* Revision 3.17 1994/02/20 15:18:02 kardel
|
||||
* rcs id cleanup
|
||||
*
|
||||
* Revision 3.16 1994/02/15 22:39:50 kardel
|
||||
* memory leak on open failure closed
|
||||
*
|
||||
* Revision 3.15 1994/02/13 19:16:50 kardel
|
||||
* updated verbose Copyright message
|
||||
*
|
||||
* Revision 3.14 1994/02/02 17:45:38 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
* Revision 3.12 1994/01/25 19:05:30 kardel
|
||||
* 94/01/23 reconcilation
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/kernel/parsetest.c,v 3.4 1993/03/17 17:16:57 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/parse/util/parsetest.c,v 3.13 1994/02/20 13:04:46 kardel Exp
|
||||
*
|
||||
* parsetest.c,v 3.10 1994/01/23 17:22:18 kardel Exp
|
||||
* parsetest.c,v 3.13 1994/02/20 13:04:46 kardel Exp
|
||||
*
|
||||
* Copyright (c) 1989,1990,1991,1992,1993,1994
|
||||
* Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
|
||||
@ -11,15 +11,11 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* parsetest.c,v
|
||||
* Revision 3.4 1993/03/17 17:16:57 kardel
|
||||
* DEC OSF/1 ALPHA Integration - 930314
|
||||
* Revision 3.13 1994/02/20 13:04:46 kardel
|
||||
* parse add/delete second support
|
||||
*
|
||||
* Revision 3.3 1993/01/18 09:24:33 kardel
|
||||
* updated copyright conditions in conjunction with
|
||||
* conditions set up in the COPYRIGHT file
|
||||
*
|
||||
* Revision 3.2 1993/01/17 13:43:00 kardel
|
||||
* 1993 initial update
|
||||
* Revision 3.12 1994/02/02 17:45:51 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
*/
|
||||
|
||||
@ -198,7 +194,7 @@ main(argc, argv)
|
||||
parsetime_t parsetime;
|
||||
struct strioctl strioc;
|
||||
|
||||
printf("parsetest.c,v 3.10 1994/01/23 17:22:18 kardel Exp\n");
|
||||
printf("parsetest.c,v 3.13 1994/02/20 13:04:46 kardel Exp\n");
|
||||
|
||||
while (ioctl(fd, I_POP, 0) == 0)
|
||||
;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.9 1994/01/25 19:05:45 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/parse/util/testdcf.c,v 3.11 1994/02/02 17:45:55 kardel Exp
|
||||
*
|
||||
* testdcf.c,v 3.9 1994/01/25 19:05:45 kardel Exp
|
||||
* testdcf.c,v 3.11 1994/02/02 17:45:55 kardel Exp
|
||||
*
|
||||
* simple DCF77 100/200ms pulse test program (via 50Baud serial line)
|
||||
*
|
||||
|
29
usr.sbin/xntpd/refclocks/rclk.TRAK
Normal file
29
usr.sbin/xntpd/refclocks/rclk.TRAK
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh -
|
||||
CMD="$1"
|
||||
shift;
|
||||
|
||||
. refclocks/setup
|
||||
|
||||
case "$CMD" in
|
||||
info)
|
||||
echo " TRAK - TRAK 8810 GPS station clock"
|
||||
;;
|
||||
check)
|
||||
if check "$RCONFIG" '$0 ~ /TRAK/'; then
|
||||
echo "TRAK - TRAK 8810 GPS station clock"
|
||||
fi
|
||||
;;
|
||||
config)
|
||||
if check "$REFCONF" '$0 ~ /TRAK/' ||
|
||||
( [ ! "$REFCONF" ] && query "Include TRAK 8810 GPS station clock (TRAK)" n); then
|
||||
if check "$PPSFEATURES" '$0 ~ /CD/' &&
|
||||
[ "$PPSOK" -eq 1 ] &&
|
||||
(check "$REFCONF" '$0 ~ /TRAKPPS/' ||
|
||||
( [ ! "$REFCONF" ] && query " Use TRAK for PPS" n)); then
|
||||
echo "-DTRAKPPS" >> $RCONFIG
|
||||
else
|
||||
echo "-DTRAK" >> $RCONFIG
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
@ -40,7 +40,11 @@ if [ -f /bin/uname -o -f /usr/bin/uname ]; then
|
||||
guess="ultrix"
|
||||
;;
|
||||
hp-ux) case "$3" in
|
||||
*.10.*) guess="hpux10+" ;;
|
||||
*.10.*) guess="hpux-adj" ;;
|
||||
*.09.03) case "$5" in
|
||||
9000/3*) guess="hpux-adj" ;;
|
||||
*) guess="hpux" ;;
|
||||
esac ;;
|
||||
*) guess="hpux" ;;
|
||||
esac
|
||||
;;
|
||||
|
@ -11,7 +11,7 @@ Guess.sh script to figure out what machine and operating system
|
||||
autoconf awesome script swiped from Jeff Johnson (who may have
|
||||
swiped it from GNU) which delves deep into the system
|
||||
files to reveal dark secrets necessary to port NTP to
|
||||
everything exceptt sewing machines. Unfinished work.
|
||||
everything except sewing machines. Unfinished work.
|
||||
|
||||
makeconfig.sh shell script that calles Guess.sh and then figures out
|
||||
what compiler is available, then builds the
|
||||
|
18
usr.sbin/xntpd/scripts/hpadjtime.sh
Normal file
18
usr.sbin/xntpd/scripts/hpadjtime.sh
Normal file
@ -0,0 +1,18 @@
|
||||
#! /bin/sh
|
||||
val=1
|
||||
if [ -f /bin/uname -o -f /usr/bin/uname ]; then
|
||||
set `uname -a | tr '[A-Z]' '[a-z]'`
|
||||
case "$1" in
|
||||
hp-ux) case "$3" in
|
||||
*.10.*) val=1 ;;
|
||||
*.09.03) case "$5" in
|
||||
9000/3*) val=1 ;;
|
||||
*) val=0 ;;
|
||||
esac ;;
|
||||
*) val=0 ;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
fi
|
||||
exit $val
|
@ -143,7 +143,8 @@ foreach $hostname (@ARGV)
|
||||
{
|
||||
chop;
|
||||
split;
|
||||
($host, $count, $mode, $version, $lasttime, $firsttime) = (@_[$[, $[+2 .. $[+6]);
|
||||
($host, $count, $mode, $version, $lasttime, $firsttime) =
|
||||
(@_[$[, $[+2 .. $[+4, $#_-1,$#_]);
|
||||
|
||||
$Seen{$host, $mode} = 1;
|
||||
|
||||
|
@ -15,27 +15,29 @@
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include "ntp_fp.h"
|
||||
#include "ntp_unixtime.h"
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
#ifndef SYS_DECOSF1
|
||||
#define BADCALL -1 /* this is supposed to be a bad syscall */
|
||||
#endif
|
||||
#endif /* SYS_DECOSF1 */
|
||||
|
||||
#ifdef KERNEL_PLL
|
||||
#include <sys/timex.h>
|
||||
#define ntp_gettime(t) syscall(SYS_ntp_gettime, (t))
|
||||
#define ntp_adjtime(t) syscall(SYS_ntp_adjtime, (t))
|
||||
#else /* KERNEL_PLL */
|
||||
#include "ntp_timex.h"
|
||||
|
||||
#ifdef KERNEL_PLL
|
||||
#ifndef SYS_ntp_adjtime
|
||||
#define SYS_ntp_adjtime NTP_SYSCALL_ADJ
|
||||
#endif
|
||||
#ifndef SYS_ntp_gettime
|
||||
#define SYS_ntp_gettime NTP_SYSCALL_GET
|
||||
#endif
|
||||
#endif /* KERNEL_PLL */
|
||||
#endif /* KERNEL_PLL */
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
extern int sigvec P((int, struct sigvec *, struct sigvec *));
|
||||
extern int syscall P((int, void *, ...));
|
||||
void pll_trap P((void));
|
||||
|
||||
static struct sigvec newsigsys; /* new sigvec status */
|
||||
@ -56,14 +58,14 @@ main(argc, argv)
|
||||
struct ntptimeval ntv;
|
||||
struct timex ntx, _ntx;
|
||||
int times[20];
|
||||
double ftemp;
|
||||
double ftemp, gtemp;
|
||||
l_fp ts;
|
||||
int c;
|
||||
int errflg = 0;
|
||||
int cost = 0;
|
||||
int rawtime = 0;
|
||||
|
||||
ntx.mode = 0;
|
||||
memset((char *)&ntx, 0, sizeof(ntx));
|
||||
progname = argv[0];
|
||||
while ((c = ntp_getopt(argc, argv, optargs)) != EOF) switch (c) {
|
||||
case 'c':
|
||||
@ -157,7 +159,7 @@ main(argc, argv)
|
||||
}
|
||||
}
|
||||
(void)ntp_gettime(&ntv);
|
||||
ntx.mode = 0; /* Ensure nothing is set */
|
||||
_ntx.mode = 0; /* Ensure nothing is set */
|
||||
(void)ntp_adjtime(&_ntx);
|
||||
if (pll_control < 0) {
|
||||
printf("NTP user interface routines are not configured in this kernel.\n");
|
||||
@ -191,13 +193,23 @@ main(argc, argv)
|
||||
printf("ntp_adjtime() returns code %d\n", status);
|
||||
ftemp = ntx.frequency;
|
||||
ftemp /= (1 << SHIFT_USEC);
|
||||
printf(" mode: %02x, offset: %ld usec, frequency: %6.3f ppm,\n",
|
||||
printf(" mode: %02x, offset: %ld usec, frequency:%8.3f ppm,\n",
|
||||
ntx.mode, ntx.offset, ftemp);
|
||||
printf(" confidence interval: %ld usec, estimated error: %ld usec,\n",
|
||||
ntx.maxerror, ntx.esterror);
|
||||
printf(" status: %d, time constant: %ld, precision: %ld usec, tolerance: %ld usec\n",
|
||||
ntx.status, ntx.time_constant, ntx.precision,
|
||||
ntx.tolerance);
|
||||
ftemp = ntx.tolerance;
|
||||
ftemp /= (1 << SHIFT_USEC);
|
||||
printf(" status: %d, time constant: %ld, precision: %ld usec, tolerance:%4.0f ppm\n",
|
||||
ntx.status, ntx.time_constant, ntx.precision, ftemp);
|
||||
if (ntx.shift == 0)
|
||||
return;
|
||||
ftemp = ntx.ybar;
|
||||
ftemp /= (1 << SHIFT_USEC);
|
||||
gtemp = ntx.disp;
|
||||
gtemp /= (1 << SHIFT_USEC);
|
||||
printf(" pps frequency%8.3f ppm, pps dispersion:%8.3f ppm, interval:%4d sec,\n intervals:%5ld, jitter exceeded:%4ld, dispersion exceeded:%4ld\n",
|
||||
ftemp, gtemp, 1 << ntx.shift, ntx.calcnt, ntx.jitcnt,
|
||||
ntx.discnt);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* tickadj.c,v 3.1 1993/07/06 01:11:05 jbj Exp
|
||||
/*
|
||||
* tickadj - read, and possibly modify, the kernel `tick' and
|
||||
* `tickadj' variables, as well as `dosynctodr'. Note that
|
||||
* this operates on the running kernel only. I'd like to be
|
||||
@ -6,6 +6,41 @@
|
||||
* mastered this yet.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef SYS_LINUX
|
||||
#include <sys/timex.h>
|
||||
|
||||
struct timex txc;
|
||||
|
||||
int
|
||||
main(int argc, char ** argv)
|
||||
{
|
||||
if (argc > 2)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [tick_value]\n", argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
else if (argc == 2)
|
||||
{
|
||||
if ( (txc.tick = atoi(argv[1])) < 1 )
|
||||
{
|
||||
fprintf(stderr, "Silly value for tick: %s\n", argv[1]);
|
||||
exit(-1);
|
||||
}
|
||||
txc.mode = ADJ_TICK;
|
||||
}
|
||||
else
|
||||
txc.mode = 0;
|
||||
|
||||
if (__adjtimex(&txc) < 0)
|
||||
perror("adjtimex");
|
||||
else
|
||||
printf("tick = %d\n", txc.tick);
|
||||
|
||||
return(0);
|
||||
}
|
||||
#else /* not Linux... kmem tweaking: */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
@ -353,6 +388,22 @@ getoffsets(filex, tick_off, tickadj_off, dosync_off, noprintf_off)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SYS_HPUX)
|
||||
#define X_TICKADJ 0
|
||||
#define X_TICK 1
|
||||
#define X_DEF
|
||||
static struct nlist nl[] =
|
||||
#ifdef hp9000s300
|
||||
{ {"_tickadj"},
|
||||
{"_old_tick"},
|
||||
#else
|
||||
{ {"tickadj"},
|
||||
{"old_tick"},
|
||||
#endif
|
||||
{""},
|
||||
};
|
||||
#endif
|
||||
|
||||
#if !defined(X_DEF)
|
||||
#define X_TICKADJ 0
|
||||
#define X_TICK 1
|
||||
@ -373,6 +424,7 @@ getoffsets(filex, tick_off, tickadj_off, dosync_off, noprintf_off)
|
||||
"/kernel/unix",
|
||||
"/386bsd",
|
||||
"/netbsd",
|
||||
"/hp-ux",
|
||||
NULL
|
||||
};
|
||||
struct stat stbuf;
|
||||
@ -513,3 +565,4 @@ readvar(fd, off, var)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
#endif /* not Linux */
|
||||
|
@ -34,7 +34,8 @@ SOURCE= ntp_config.c ntp_control.c ntp_io.c ntp_leap.c \
|
||||
refclock_wwvb.c refclock_goes.c refclock_mx4200.c \
|
||||
refclock_parse.c refclock_as2201.c refclock_omega.c \
|
||||
refclock_tpro.c refclock_leitch.c refclock_irig.c \
|
||||
refclock_msfees.c refclock_gpstm.c ntp_intres.c ntp_filegen.c
|
||||
refclock_msfees.c refclock_gpstm.c refclock_trak.c \
|
||||
ntp_intres.c ntp_filegen.c
|
||||
|
||||
OBJS= ntp_config.o ntp_control.o ntp_io.o ntp_leap.o \
|
||||
ntp_loopfilter.o ntp_monitor.o ntp_peer.o ntp_proto.o \
|
||||
@ -44,7 +45,8 @@ OBJS= ntp_config.o ntp_control.o ntp_io.o ntp_leap.o \
|
||||
refclock_wwvb.o refclock_goes.o refclock_mx4200.o \
|
||||
refclock_parse.o refclock_as2201.o refclock_omega.o \
|
||||
refclock_tpro.o refclock_leitch.o refclock_irig.o \
|
||||
refclock_msfees.o refclock_gpstm.o ntp_intres.o ntp_filegen.o
|
||||
refclock_msfees.o refclock_gpstm.o refclock_trak.o \
|
||||
ntp_intres.o ntp_filegen.o
|
||||
|
||||
all: $(PROGRAM)
|
||||
|
||||
@ -137,5 +139,8 @@ refclock_irig.o: refclock_irig.c
|
||||
refclock_msfees.o: refclock_msfees.c
|
||||
$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c
|
||||
|
||||
refclock_trak.o: refclock_trak.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
|
||||
|
@ -58,6 +58,7 @@
|
||||
* statsdir /var/NTP/
|
||||
* filegen peerstats [ file peerstats ] [ type day ] [ link ]
|
||||
* resolver /path/progname
|
||||
* netlimit integer
|
||||
*
|
||||
* And then some. See the manual page.
|
||||
*/
|
||||
@ -94,6 +95,8 @@
|
||||
#define CONFIG_PIDFILE 25
|
||||
#define CONFIG_LOGFILE 26
|
||||
#define CONFIG_SETVAR 27
|
||||
#define CONFIG_CLIENTLIMIT 28
|
||||
#define CONFIG_CLIENTPERIOD 29
|
||||
|
||||
#define CONF_MOD_VERSION 1
|
||||
#define CONF_MOD_KEY 2
|
||||
@ -114,6 +117,7 @@
|
||||
#define CONF_RES_NOTRAP 8
|
||||
#define CONF_RES_LPTRAP 9
|
||||
#define CONF_RES_NTPPORT 10
|
||||
#define CONF_RES_LIMITED 11
|
||||
|
||||
#define CONF_TRAP_PORT 1
|
||||
#define CONF_TRAP_INTERFACE 2
|
||||
@ -179,6 +183,8 @@ static struct keyword keywords[] = {
|
||||
{ "pidfile", CONFIG_PIDFILE },
|
||||
{ "logfile", CONFIG_LOGFILE },
|
||||
{ "setvar", CONFIG_SETVAR },
|
||||
{ "clientlimit", CONFIG_CLIENTLIMIT },
|
||||
{ "clientperiod", CONFIG_CLIENTPERIOD },
|
||||
{ "", CONFIG_UNKNOWN }
|
||||
};
|
||||
|
||||
@ -217,6 +223,7 @@ static struct keyword res_keywords[] = {
|
||||
{ "notrap", CONF_RES_NOTRAP },
|
||||
{ "lowpriotrap", CONF_RES_LPTRAP },
|
||||
{ "ntpport", CONF_RES_NTPPORT },
|
||||
{ "limited", CONF_RES_LIMITED },
|
||||
{ "", CONFIG_UNKNOWN }
|
||||
};
|
||||
|
||||
@ -817,9 +824,9 @@ getconfig(argc, argv)
|
||||
errflg = 0;
|
||||
if (ntokens >= 2) {
|
||||
if (STREQ(tokens[1], "yes"))
|
||||
mon_start();
|
||||
mon_start(MON_ON);
|
||||
else if (STREQ(tokens[1], "no"))
|
||||
mon_stop();
|
||||
mon_stop(MON_ON);
|
||||
else
|
||||
errflg++;
|
||||
} else {
|
||||
@ -965,6 +972,10 @@ getconfig(argc, argv)
|
||||
peerkey |= RESM_NTPONLY;
|
||||
break;
|
||||
|
||||
case CONF_RES_LIMITED:
|
||||
peerversion |= RES_LIMITED;
|
||||
break;
|
||||
|
||||
case CONFIG_UNKNOWN:
|
||||
errflg++;
|
||||
break;
|
||||
@ -1414,6 +1425,60 @@ getconfig(argc, argv)
|
||||
((((ntokens > 2) && !strcmp(tokens[2], "default"))) ? DEF : 0));
|
||||
}
|
||||
break;
|
||||
|
||||
case CONFIG_CLIENTLIMIT:
|
||||
if (ntokens < 2)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"no value for clientlimit command - line ignored");
|
||||
}
|
||||
else
|
||||
{
|
||||
U_LONG i;
|
||||
if (!atouint(tokens[1], &i) || !i)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"illegal value for clientlimit command - line ignored");
|
||||
}
|
||||
else
|
||||
{
|
||||
extern U_LONG client_limit;
|
||||
char bp[80];
|
||||
|
||||
sprintf(bp, "client_limit=%d", i);
|
||||
set_sys_var(bp, strlen(bp)+1, RO);
|
||||
|
||||
client_limit = i;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CONFIG_CLIENTPERIOD:
|
||||
if (ntokens < 2)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"no value for clientperiod command - line ignored");
|
||||
}
|
||||
else
|
||||
{
|
||||
U_LONG i;
|
||||
if (!atouint(tokens[1], &i) || i < 64)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"illegal value for clientperiod command - line ignored");
|
||||
}
|
||||
else
|
||||
{
|
||||
extern U_LONG client_limit_period;
|
||||
char bp[80];
|
||||
|
||||
sprintf(bp, "client_limit_period=%d", i);
|
||||
set_sys_var(bp, strlen(bp)+1, RO);
|
||||
|
||||
client_limit_period = i;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
(void) fclose(fp);
|
||||
|
@ -301,7 +301,7 @@ static char str_processor[] = STR_PROCESSOR;
|
||||
static u_char clocktypes[] = {
|
||||
CTL_SST_TS_NTP, /* REFCLK_NONE */
|
||||
CTL_SST_TS_UNSPEC, /* REFCLK_LOCALCLOCK */
|
||||
CTL_SST_TS_HF, /* REFCLK_WWV_HEATH */
|
||||
CTL_SST_TS_HF, /* REFCLK_GPS_TRAK */
|
||||
CTL_SST_TS_HF, /* REFCLK_WWV_PST */
|
||||
CTL_SST_TS_LF, /* REFCLK_WWVB_SPECTRACOM */
|
||||
CTL_SST_TS_UHF, /* REFCLK_GOES_TRUETIME */
|
||||
|
@ -9,9 +9,6 @@
|
||||
|
||||
#include "ntpd.h"
|
||||
#include "ntp_io.h"
|
||||
#if defined(KERNEL_PLL)
|
||||
#include "ntp_timex.h"
|
||||
#endif /* KERNEL_PLL */
|
||||
#include "ntp_unixtime.h"
|
||||
|
||||
#if defined(PPS) || defined(PPSCLK) || defined(PPSPPS)
|
||||
@ -46,11 +43,11 @@
|
||||
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
#ifdef KERNEL_PLL
|
||||
#ifndef SYS_ntp_adjtime
|
||||
#define SYS_ntp_adjtime NTP_SYSCALL_ADJ
|
||||
#endif
|
||||
#endif /* KERNEL_PLL */
|
||||
#ifdef KERNEL_PLL
|
||||
#include <sys/timex.h>
|
||||
#define ntp_gettime(t) syscall(SYS_ntp_gettime, (t))
|
||||
#define ntp_adjtime(t) syscall(SYS_ntp_adjtime, (t))
|
||||
#endif /* KERNEL_PLL */
|
||||
|
||||
/*
|
||||
* The loop filter is implemented in slavish adherence to the
|
||||
@ -158,8 +155,8 @@ static l_fp pps_delay; /* pps tuning offset */
|
||||
#define PPS_MAXUPDATE 600 /* seconds after which we disbelieve timecode */
|
||||
#define PPS_DEV "/dev/pps" /* pps port */
|
||||
#define PPS_FAC 3 /* pps shift (log2 trimmed samples) */
|
||||
#define NPPS 12 /* pps filter size (1<<PPS_FAC+2*PPS_TRIM) */
|
||||
#define PPS_TRIM 2 /* samples trimmed from median filter */
|
||||
#define PPS_TRIM 6 /* samples trimmed from median filter */
|
||||
#define NPPS ((1 << PPS_FAC) + 2 * PPS_TRIM) /* pps filter size */
|
||||
#define PPS_XCPT "\377" /* intercept character */
|
||||
|
||||
#if defined(PPSCLK)
|
||||
@ -167,6 +164,7 @@ static struct refclockio io; /* given to the I/O handler */
|
||||
static int pps_baud; /* baud rate of PPS line */
|
||||
#endif /* PPSCLK */
|
||||
static l_fp pps_offset; /* filtered pps offset */
|
||||
static u_fp pps_maxd; /* pps dispersion */
|
||||
static U_LONG pps_time; /* last pps sample time */
|
||||
static U_LONG nsamples; /* number of pps samples collected */
|
||||
static LONG samples[NPPS]; /* median filter for pps samples */
|
||||
@ -206,6 +204,7 @@ static void pps_receive P((struct recvbuf *));
|
||||
|
||||
#if defined(KERNEL_PLL)
|
||||
extern int sigvec P((int, struct sigvec *, struct sigvec *));
|
||||
extern int syscall P((int, void *, ...));
|
||||
void pll_trap P((void));
|
||||
|
||||
static struct sigvec sigsys; /* current sigvec status */
|
||||
@ -350,8 +349,8 @@ init_loopfilter()
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_BSD_TTYS */
|
||||
fdpps = fd232;
|
||||
#endif /* HPUXGADGET */
|
||||
fdpps = fd232;
|
||||
|
||||
/*
|
||||
* Insert in device list.
|
||||
@ -489,9 +488,10 @@ local_clock(fp_offset, peer)
|
||||
*/
|
||||
if (pps_control) {
|
||||
last_offset = pps_offset;
|
||||
sys_maxd = pps_maxd;
|
||||
sys_stratum = 1;
|
||||
sys_rootdelay = 0;
|
||||
sys_rootdispersion = sys_maxd;
|
||||
sys_rootdispersion = pps_maxd;
|
||||
}
|
||||
#endif /* PPS || PPSCLK || PPSPPS */
|
||||
|
||||
@ -522,8 +522,24 @@ local_clock(fp_offset, peer)
|
||||
ntv.maxerror = sys_rootdispersion + sys_rootdelay / 2;
|
||||
ntv.esterror = sys_rootdispersion;
|
||||
ntv.time_constant = time_constant;
|
||||
ntv.shift = 0;
|
||||
(void)ntp_adjtime(&ntv);
|
||||
drift_comp = ntv.frequency;
|
||||
if (ntv.shift != 0) {
|
||||
char buf[128];
|
||||
(void) sprintf(buf, "pps_freq=%s", fptoa(ntv.ybar, 3));
|
||||
set_sys_var(buf, strlen(buf)+1, RO|DEF);
|
||||
(void) sprintf(buf, "pps_disp=%s", fptoa(ntv.disp, 3));
|
||||
set_sys_var(buf, strlen(buf)+1, RO|DEF);
|
||||
(void) sprintf(buf, "pps_interval=%ld",1 << ntv.shift);
|
||||
set_sys_var(buf, strlen(buf)+1, RO);
|
||||
(void) sprintf(buf, "pps_intervals=%ld", ntv.calcnt);
|
||||
set_sys_var(buf, strlen(buf)+1, RO);
|
||||
(void) sprintf(buf, "pps_jitterexceeded=%ld", ntv.jitcnt);
|
||||
set_sys_var(buf, strlen(buf)+1, RO);
|
||||
(void) sprintf(buf, "pps_dispersionexceeded=%ld", ntv.discnt);
|
||||
set_sys_var(buf, strlen(buf)+1, RO);
|
||||
}
|
||||
#endif /* KERNEL_PLL */
|
||||
} else {
|
||||
if (offset < 0) {
|
||||
@ -725,6 +741,8 @@ loop_config(item, lfp_value, int_value)
|
||||
"loop_config: skew compensation %s too large",
|
||||
fptoa(tmp, 5));
|
||||
} else {
|
||||
char var[40];
|
||||
|
||||
drift_comp = tmp;
|
||||
|
||||
#if defined(KERNEL_PLL)
|
||||
@ -751,6 +769,10 @@ loop_config(item, lfp_value, int_value)
|
||||
syslog(LOG_NOTICE,
|
||||
"%susing kernel phase-lock loop",
|
||||
(pll_control) ? "" : "Not ");
|
||||
(void)sprintf(var, "kernel_pll=%s", pll_control ? "true" : "false");
|
||||
|
||||
set_sys_var(var, strlen(var)+1, RO);
|
||||
|
||||
#if DEBUG
|
||||
if (debug)
|
||||
printf("pll_control %d\n", pll_control);
|
||||
@ -873,6 +895,7 @@ int pps_sample(tsr)
|
||||
int i, j; /* temp ints */
|
||||
LONG sort[NPPS]; /* temp array for sorting */
|
||||
l_fp lftemp, ts; /* l_fp temps */
|
||||
u_fp utemp; /* u_fp temp */
|
||||
LONG ltemp; /* long temp */
|
||||
|
||||
/*
|
||||
@ -934,14 +957,21 @@ int pps_sample(tsr)
|
||||
}
|
||||
lftemp.l_i = 0;
|
||||
lftemp.l_f = sort[NPPS-1-PPS_TRIM] - sort[PPS_TRIM];
|
||||
sys_maxd = LFPTOFP(&lftemp);
|
||||
pps_maxd = LFPTOFP(&lftemp);
|
||||
lftemp.l_i = 0;
|
||||
lftemp.l_f = sort[NPPS-1] - sort[0];
|
||||
utemp = LFPTOFP(&lftemp);
|
||||
#ifdef DEBUG
|
||||
if (debug)
|
||||
printf("pps_filter: %s %s %s\n", lfptoa(&pps_delay, 6),
|
||||
lfptoa(&pps_offset, 6), lfptoa(&lftemp, 5));
|
||||
#endif /* DEBUG */
|
||||
record_peer_stats(&loopback_interface->sin, ctlsysstatus(), &pps_offset,
|
||||
sys_rootdelay, sys_rootdispersion);
|
||||
/*
|
||||
* Note the peerstats file will contain the gross dispersion in
|
||||
* the delay field. Temporaty hack.
|
||||
*/
|
||||
record_peer_stats(&loopback_interface->sin, ctlsysstatus(),
|
||||
&pps_offset, utemp, pps_maxd);
|
||||
return (0);
|
||||
}
|
||||
#endif /* PPS || PPSCLK || PPSPPS */
|
||||
|
@ -58,7 +58,7 @@
|
||||
static struct mon_data *mon_hash; /* Pointer to array of hash buckets */
|
||||
static int *mon_hash_count; /* Point to hash count stats keeper */
|
||||
struct mon_data mon_mru_list;
|
||||
|
||||
struct mon_data mon_fifo_list;
|
||||
/*
|
||||
* List of free structures structures, and counters of free and total
|
||||
* structures. The free structures are linked with the hash_next field.
|
||||
@ -93,7 +93,7 @@ init_mon()
|
||||
* Don't do much of anything here. We don't allocate memory
|
||||
* until someone explicitly starts us.
|
||||
*/
|
||||
mon_enabled = 0;
|
||||
mon_enabled = MON_OFF;
|
||||
mon_have_memory = 0;
|
||||
|
||||
mon_free_mem = 0;
|
||||
@ -103,6 +103,7 @@ init_mon()
|
||||
mon_hash = 0;
|
||||
mon_hash_count = 0;
|
||||
memset((char *)&mon_mru_list, 0, sizeof mon_mru_list);
|
||||
memset((char *)&mon_fifo_list, 0, sizeof mon_fifo_list);
|
||||
}
|
||||
|
||||
|
||||
@ -110,13 +111,18 @@ init_mon()
|
||||
* mon_start - start up the monitoring software
|
||||
*/
|
||||
void
|
||||
mon_start()
|
||||
mon_start(mode)
|
||||
int mode;
|
||||
{
|
||||
register struct mon_data *md;
|
||||
register int i;
|
||||
|
||||
if (mon_enabled)
|
||||
if (mon_enabled != MON_OFF) {
|
||||
mon_enabled |= mode;
|
||||
return;
|
||||
}
|
||||
if (mode == MON_OFF)
|
||||
return; /* Ooops.. */
|
||||
|
||||
if (!mon_have_memory) {
|
||||
mon_hash = (struct mon_data *)
|
||||
@ -142,7 +148,10 @@ mon_start()
|
||||
mon_mru_list.mru_next = &mon_mru_list;
|
||||
mon_mru_list.mru_prev = &mon_mru_list;
|
||||
|
||||
mon_enabled = 1;
|
||||
mon_fifo_list.fifo_next = &mon_fifo_list;
|
||||
mon_fifo_list.fifo_prev = &mon_fifo_list;
|
||||
|
||||
mon_enabled = mode;
|
||||
}
|
||||
|
||||
|
||||
@ -150,12 +159,19 @@ mon_start()
|
||||
* mon_stop - stop the monitoring software
|
||||
*/
|
||||
void
|
||||
mon_stop()
|
||||
mon_stop(mode)
|
||||
int mode;
|
||||
{
|
||||
register struct mon_data *md;
|
||||
register int i;
|
||||
|
||||
if (!mon_enabled)
|
||||
if (mon_enabled == MON_OFF)
|
||||
return;
|
||||
if ((mon_enabled & mode) == 0 || mode == MON_OFF)
|
||||
return;
|
||||
|
||||
mon_enabled &= ~mode;
|
||||
if (mon_enabled != MON_OFF)
|
||||
return;
|
||||
|
||||
/*
|
||||
@ -176,7 +192,8 @@ mon_stop()
|
||||
mon_mru_list.mru_next = &mon_mru_list;
|
||||
mon_mru_list.mru_prev = &mon_mru_list;
|
||||
|
||||
mon_enabled = 0;
|
||||
mon_fifo_list.fifo_next = &mon_fifo_list;
|
||||
mon_fifo_list.fifo_prev = &mon_fifo_list;
|
||||
}
|
||||
|
||||
|
||||
@ -194,7 +211,7 @@ monitor(rbufp)
|
||||
register int mode;
|
||||
register struct mon_data *mdhash;
|
||||
|
||||
if (!mon_enabled)
|
||||
if (mon_enabled == MON_OFF)
|
||||
return;
|
||||
|
||||
pkt = &rbufp->recv_pkt;
|
||||
@ -220,6 +237,7 @@ monitor(rbufp)
|
||||
md->mru_prev = &mon_mru_list;
|
||||
mon_mru_list.mru_next->mru_prev = md;
|
||||
mon_mru_list.mru_next = md;
|
||||
|
||||
return;
|
||||
}
|
||||
md = md->hash_next;
|
||||
@ -240,6 +258,12 @@ monitor(rbufp)
|
||||
md->hash_next->hash_prev = md->hash_prev;
|
||||
md->hash_prev->hash_next = md->hash_next;
|
||||
*(mon_hash_count + MON_HASH(md->rmtadr)) -= 1;
|
||||
/*
|
||||
* Get it from FIFO list
|
||||
*/
|
||||
md->fifo_prev->fifo_next = md->fifo_next;
|
||||
md->fifo_next->fifo_prev = md->fifo_prev;
|
||||
|
||||
} else {
|
||||
if (mon_free_mem == 0)
|
||||
mon_getmoremem();
|
||||
@ -252,6 +276,7 @@ monitor(rbufp)
|
||||
* Got one, initialize it
|
||||
*/
|
||||
md->lasttime = md->firsttime = current_time;
|
||||
md->lastdrop = 0;
|
||||
md->count = 1;
|
||||
md->rmtadr = netnum;
|
||||
md->rmtport = NSRCPORT(&rbufp->recv_srcadr);
|
||||
@ -260,7 +285,8 @@ monitor(rbufp)
|
||||
|
||||
/*
|
||||
* Shuffle him into the hash table, inserting him at the
|
||||
* end. Also put him on top of the MRU list.
|
||||
* end. Also put him on top of the MRU list
|
||||
* and at bottom of FIFO list
|
||||
*/
|
||||
mdhash = mon_hash + MON_HASH(netnum);
|
||||
md->hash_next = mdhash;
|
||||
@ -273,6 +299,11 @@ monitor(rbufp)
|
||||
md->mru_prev = &mon_mru_list;
|
||||
mon_mru_list.mru_next->mru_prev = md;
|
||||
mon_mru_list.mru_next = md;
|
||||
|
||||
md->fifo_prev = mon_fifo_list.fifo_prev;
|
||||
md->fifo_next = &mon_fifo_list;
|
||||
mon_fifo_list.fifo_prev->fifo_next = md;
|
||||
mon_fifo_list.fifo_prev = md;
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ l_fp sys_reftime; /* time we were last updated */
|
||||
l_fp sys_refskew; /* accumulated skew since last update */
|
||||
struct peer *sys_peer; /* our current peer */
|
||||
u_char sys_poll; /* log2 of desired system poll interval */
|
||||
LONG sys_clock; /* second part of current time */
|
||||
extern LONG sys_clock; /* second part of current time - now in systime.c */
|
||||
LONG sys_lastselect; /* sys_clock at last synch-dist update */
|
||||
|
||||
/*
|
||||
@ -49,6 +49,7 @@ U_LONG sys_badlength; /* packets with bad length */
|
||||
U_LONG sys_processed; /* packets processed */
|
||||
U_LONG sys_badauth; /* packets dropped because of authorization */
|
||||
U_LONG sys_wanderhold; /* sys_peer held to prevent wandering */
|
||||
U_LONG sys_limitrejected; /* pkts rejected due toclient count per net */
|
||||
|
||||
/*
|
||||
* Imported from ntp_timer.c
|
||||
@ -372,6 +373,21 @@ receive(rbufp)
|
||||
if (restrict & RES_DONTSERVE)
|
||||
return;
|
||||
|
||||
/*
|
||||
* See if we only accept limited number of clients
|
||||
* from the net this guy is from.
|
||||
* Note: the flag is determined dynamically within restrictions()
|
||||
*/
|
||||
if (restrict & RES_LIMITED) {
|
||||
extern U_LONG client_limit;
|
||||
|
||||
sys_limitrejected++;
|
||||
syslog(LOG_NOTICE,
|
||||
"rejected mode %d request from %s - per net client limit (%d) exceeded",
|
||||
PKT_MODE(pkt->li_vn_mode),
|
||||
ntoa(&rbufp->recv_srcadr), client_limit);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Dump anything with a putrid stratum. These will most likely
|
||||
* come from someone trying to poll us with ntpdc.
|
||||
@ -2165,4 +2181,5 @@ proto_clr_stats()
|
||||
sys_badauth = 0;
|
||||
sys_wanderhold = 0;
|
||||
sys_stattime = current_time;
|
||||
sys_limitrejected = 0;
|
||||
}
|
||||
|
@ -916,6 +916,7 @@ sys_stats(srcadr, inter, inpkt)
|
||||
extern U_LONG sys_processed;
|
||||
extern U_LONG sys_badauth;
|
||||
extern U_LONG sys_wanderhold;
|
||||
extern U_LONG sys_limitrejected;
|
||||
|
||||
ss = (struct info_sys_stats *)prepare_pkt(srcadr, inter, inpkt,
|
||||
sizeof(struct info_sys_stats));
|
||||
@ -930,7 +931,7 @@ sys_stats(srcadr, inter, inpkt)
|
||||
ss->processed = htonl(sys_processed);
|
||||
ss->badauth = htonl(sys_badauth);
|
||||
ss->wanderhold = htonl(sys_wanderhold);
|
||||
|
||||
ss->limitrejected = htonl(sys_limitrejected);
|
||||
(void) more_pkt();
|
||||
flush_pkt();
|
||||
}
|
||||
@ -1311,7 +1312,7 @@ do_monitor(srcadr, inter, inpkt)
|
||||
struct interface *inter;
|
||||
struct req_pkt *inpkt;
|
||||
{
|
||||
mon_start();
|
||||
mon_start(MON_ON);
|
||||
req_ack(srcadr, inter, inpkt, INFO_OKAY);
|
||||
}
|
||||
|
||||
@ -1325,7 +1326,7 @@ do_nomonitor(srcadr, inter, inpkt)
|
||||
struct interface *inter;
|
||||
struct req_pkt *inpkt;
|
||||
{
|
||||
mon_stop();
|
||||
mon_stop(MON_ON);
|
||||
req_ack(srcadr, inter, inpkt, INFO_OKAY);
|
||||
}
|
||||
|
||||
@ -1497,6 +1498,10 @@ mon_getlist(srcadr, inter, inpkt)
|
||||
md = md->mru_next) {
|
||||
im->lasttime = htonl(current_time - md->lasttime);
|
||||
im->firsttime = htonl(current_time - md->firsttime);
|
||||
if (md->lastdrop)
|
||||
im->lastdrop = htonl(current_time - md->lastdrop);
|
||||
else
|
||||
im->lastdrop = 0;
|
||||
im->count = htonl(md->count);
|
||||
im->addr = md->rmtadr;
|
||||
im->port = md->rmtport;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* ntp_restrict.c,v 3.1 1993/07/06 01:11:28 jbj Exp
|
||||
/*
|
||||
* ntp_restrict.c - find out what restrictions this host is running under
|
||||
*/
|
||||
#include <stdio.h>
|
||||
@ -59,6 +59,21 @@ U_LONG res_found;
|
||||
U_LONG res_not_found;
|
||||
U_LONG res_timereset;
|
||||
|
||||
/*
|
||||
* Parameters of the RES_LIMITED restriction option.
|
||||
* client_limit is the number of hosts allowed per source net
|
||||
* client_limit_period is the number of seconds after which an entry
|
||||
* is no longer considered for client limit determination
|
||||
*/
|
||||
U_LONG client_limit;
|
||||
U_LONG client_limit_period;
|
||||
/*
|
||||
* count number of restriction entries referring to RES_LIMITED
|
||||
* controls activation/deactivation of monitoring
|
||||
* (with respect ro RES_LIMITED control)
|
||||
*/
|
||||
U_LONG res_limited_refcnt;
|
||||
|
||||
/*
|
||||
* Our initial allocation of list entries.
|
||||
*/
|
||||
@ -69,6 +84,11 @@ static struct restrictlist resinit[INITRESLIST];
|
||||
*/
|
||||
extern U_LONG current_time;
|
||||
|
||||
/*
|
||||
* debug flag
|
||||
*/
|
||||
extern int debug;
|
||||
|
||||
/*
|
||||
* init_restrict - initialize the restriction data structures
|
||||
*/
|
||||
@ -76,6 +96,7 @@ void
|
||||
init_restrict()
|
||||
{
|
||||
register int i;
|
||||
char bp[80];
|
||||
|
||||
/*
|
||||
* Zero the list and put all but one on the free list
|
||||
@ -108,6 +129,18 @@ init_restrict()
|
||||
res_found = 0;
|
||||
res_not_found = 0;
|
||||
res_timereset = 0;
|
||||
|
||||
/*
|
||||
* set default values for RES_LIMIT functionality
|
||||
*/
|
||||
client_limit = 3;
|
||||
client_limit_period = 3600;
|
||||
res_limited_refcnt = 0;
|
||||
|
||||
sprintf(bp, "client_limit=%d", client_limit);
|
||||
set_sys_var(bp, strlen(bp)+1, RO);
|
||||
sprintf(bp, "client_limit_period=%d", client_limit_period);
|
||||
set_sys_var(bp, strlen(bp)+1, RO);
|
||||
}
|
||||
|
||||
|
||||
@ -150,6 +183,120 @@ restrictions(srcadr)
|
||||
else
|
||||
res_found++;
|
||||
|
||||
/*
|
||||
* The following implements limiting the number of clients
|
||||
* accepted from a given network. The notion of "same network"
|
||||
* is determined by the mask and addr fields of the restrict
|
||||
* list entry. The monitor mechanism has to be enabled for
|
||||
* collecting info on current clients.
|
||||
*
|
||||
* The policy is as follows:
|
||||
* - take the list of clients recorded
|
||||
* from the given "network" seen within the last
|
||||
* client_limit_period seconds
|
||||
* - if there are at most client_limit entries:
|
||||
* --> access allowed
|
||||
* - otherwise sort by time first seen
|
||||
* - current client among the first client_limit seen
|
||||
* hosts?
|
||||
* if yes: access allowed
|
||||
* else: eccess denied
|
||||
*/
|
||||
if (match->flags & RES_LIMITED) {
|
||||
int lcnt;
|
||||
struct mon_data *md, *this_client;
|
||||
extern int mon_enabled;
|
||||
extern struct mon_data mon_fifo_list, mon_mru_list;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug > 2)
|
||||
printf("limited clients check: %d clients, period %d seconds, net is 0x%X\n",
|
||||
client_limit, client_limit_period,
|
||||
netof(hostaddr));
|
||||
#endif /*DEBUG*/
|
||||
if (mon_enabled == MON_OFF) {
|
||||
#ifdef DEBUG
|
||||
if (debug > 4)
|
||||
printf("no limit - monitoring is off\n");
|
||||
#endif
|
||||
return (int)(match->flags & ~RES_LIMITED);
|
||||
}
|
||||
|
||||
/*
|
||||
* How nice, MRU list provides our current client as the
|
||||
* first entry in the list.
|
||||
* Monitoring was verified to be active above, thus we
|
||||
* know an entry for our client must exist, or some
|
||||
* brain dead set the memory limit for mon entries to ZERO!!!
|
||||
*/
|
||||
this_client = mon_mru_list.mru_next;
|
||||
|
||||
for (md = mon_fifo_list.fifo_next,lcnt = 0;
|
||||
md != &mon_fifo_list;
|
||||
md = md->fifo_next) {
|
||||
if ((current_time - md->lasttime)
|
||||
> client_limit_period) {
|
||||
#ifdef DEBUG
|
||||
if (debug > 5)
|
||||
printf("checking: %s: ignore: too old: %d\n",
|
||||
numtoa(md->rmtadr),
|
||||
current_time - md->lasttime);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
if (md->mode == MODE_BROADCAST ||
|
||||
md->mode == MODE_CONTROL ||
|
||||
md->mode == MODE_PRIVATE) {
|
||||
#ifdef DEBUG
|
||||
if (debug > 5)
|
||||
printf("checking: %s: ignore mode %d\n",
|
||||
numtoa(md->rmtadr),
|
||||
md->mode);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
if (netof(md->rmtadr) !=
|
||||
netof(hostaddr)) {
|
||||
#ifdef DEBUG
|
||||
if (debug > 5)
|
||||
printf("checking: %s: different net 0x%X\n",
|
||||
numtoa(md->rmtadr),
|
||||
netof(md->rmtadr));
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
lcnt++;
|
||||
if (lcnt > client_limit ||
|
||||
md->rmtadr == hostaddr) {
|
||||
#ifdef DEBUG
|
||||
if (debug > 5)
|
||||
printf("considering %s: found host\n",
|
||||
numtoa(md->rmtadr));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
if (debug > 5)
|
||||
printf("considering %s: same net\n",
|
||||
numtoa(md->rmtadr));
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (debug > 4)
|
||||
printf("this one is rank %d in list, limit is %d: %s\n",
|
||||
lcnt, client_limit,
|
||||
(lcnt <= client_limit) ? "ALLOW" : "REJECT");
|
||||
#endif
|
||||
if (lcnt <= client_limit) {
|
||||
this_client->lastdrop = 0;
|
||||
return (int)(match->flags & ~RES_LIMITED);
|
||||
} else {
|
||||
this_client->lastdrop = current_time;
|
||||
}
|
||||
}
|
||||
return (int)match->flags;
|
||||
}
|
||||
|
||||
@ -257,6 +404,10 @@ restrict(op, resaddr, resmask, mflags, flags)
|
||||
rlprev->next = rl;
|
||||
restrictcount++;
|
||||
}
|
||||
if ((rl->flags ^ (u_short)flags) & RES_LIMITED) {
|
||||
res_limited_refcnt++;
|
||||
mon_start(MON_RES); /* ensure data gets collected */
|
||||
}
|
||||
rl->flags |= (u_short)flags;
|
||||
break;
|
||||
|
||||
@ -265,8 +416,14 @@ restrict(op, resaddr, resmask, mflags, flags)
|
||||
* Remove some bits from the flags. If we didn't
|
||||
* find this one, just return.
|
||||
*/
|
||||
if (rl != 0)
|
||||
if (rl != 0) {
|
||||
if ((rl->flags ^ (u_short)flags) & RES_LIMITED) {
|
||||
res_limited_refcnt--;
|
||||
if (res_limited_refcnt == 0)
|
||||
mon_stop(MON_RES);
|
||||
}
|
||||
rl->flags &= (u_short)~flags;
|
||||
}
|
||||
break;
|
||||
|
||||
case RESTRICT_REMOVE:
|
||||
@ -280,6 +437,11 @@ restrict(op, resaddr, resmask, mflags, flags)
|
||||
&& !(rl->mflags & RESM_INTERFACE)) {
|
||||
rlprev->next = rl->next;
|
||||
restrictcount--;
|
||||
if (rl->flags & RES_LIMITED) {
|
||||
res_limited_refcnt--;
|
||||
if (res_limited_refcnt == 0)
|
||||
mon_stop(MON_RES);
|
||||
}
|
||||
memset((char *)rl, 0, sizeof(struct restrictlist));
|
||||
|
||||
rl->next = resfree;
|
||||
|
@ -556,13 +556,18 @@ clock_parms(tickadj, tick)
|
||||
#endif /* SOLARIS */
|
||||
|
||||
#ifdef SYS_LINUX
|
||||
/* XXX should look this up somewhere ! */
|
||||
#include <sys/timex.h>
|
||||
static void
|
||||
clock_parms(tickadj, tick)
|
||||
U_LONG *tickadj;
|
||||
U_LONG *tick;
|
||||
{
|
||||
*tickadj = (U_LONG)1;
|
||||
*tick = (U_LONG)10000;
|
||||
struct timex txc;
|
||||
|
||||
txc.mode = 0;
|
||||
__adjtimex(&txc);
|
||||
|
||||
*tickadj = (U_LONG)1; /* our adjtime is accurate */
|
||||
*tick = (U_LONG)txc.tick;
|
||||
}
|
||||
#endif /* SYS_LINUX */
|
||||
|
@ -28,8 +28,12 @@
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
#ifdef LOCK_PROCESS
|
||||
#ifdef SYS_SOLARIS
|
||||
#include <sys/mman.h>
|
||||
#else
|
||||
#include <sys/lock.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Signals we catch for debugging. If not debugging we ignore them.
|
||||
@ -139,7 +143,7 @@ main(argc, argv)
|
||||
(void) dup2(0, 1);
|
||||
(void) dup2(0, 2);
|
||||
#ifdef NTP_POSIX_SOURCE
|
||||
#if defined(SOLARIS) || defined(SYS_PTX) || defined(SYS_AUX3) || defined(SYS_AIX)
|
||||
#if defined(SOLARIS) || defined(SYS_PTX) || defined(SYS_AUX3) || defined(SYS_AIX) || defined(SYS_ULTRIX)
|
||||
(void) setsid();
|
||||
#else
|
||||
(void) setpgid(0, 0);
|
||||
@ -219,13 +223,23 @@ main(argc, argv)
|
||||
if (rtprio(0, 120) < 0)
|
||||
syslog(LOG_ERR, "rtprio() error: %m");
|
||||
#else
|
||||
#if defined(PROCLOCK) && defined(LOCK_PROCESS)
|
||||
#if defined(LOCK_PROCESS)
|
||||
#if defined(MCL_CURRENT) && defined(MCL_FUTURE)
|
||||
/*
|
||||
* lock the process into memory
|
||||
*/
|
||||
if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
|
||||
syslog(LOG_ERR, "mlockall(): %m");
|
||||
#else
|
||||
#if defined(PROCLOCK)
|
||||
/*
|
||||
* lock the process into memory
|
||||
*/
|
||||
if (plock(PROCLOCK) < 0)
|
||||
syslog(LOG_ERR, "plock(): %m");
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if defined(NTPD_PRIO) && NTPD_PRIO != 0
|
||||
/*
|
||||
* Set the priority.
|
||||
|
@ -598,6 +598,25 @@ chu_receive(rbufp)
|
||||
chu->responses++;
|
||||
chu->lastupdate = current_time;
|
||||
|
||||
/*
|
||||
* Just for fun, we can debug the whole frame if
|
||||
* we want.
|
||||
*/
|
||||
|
||||
#ifndef NO_CHU_DEBUG
|
||||
syslog(LOG_DEBUG, "CHU %s packet:", (chuc->chutype == CHU_YEAR)?
|
||||
"year":"time");
|
||||
for (i=0; i < NCHUCHARS; i++) {
|
||||
char c[64];
|
||||
|
||||
sprintf(c,"%c%c %s",hexstring[chuc->codechars[i]&0xf],
|
||||
hexstring[chuc->codechars[i]>>4],
|
||||
ctime(&(chuc->codetimes[i].tv_sec)));
|
||||
c[strlen(c)-1]=0; /* ctime() adds a damn \n */
|
||||
syslog(LOG_DEBUG, "%s .%06d", c, chuc->codetimes[i].tv_usec);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* At this point we're assured that both halves of the
|
||||
* data match because of what the kernel has done.
|
||||
|
@ -20,6 +20,12 @@ extern struct refclock refclock_local;
|
||||
#define refclock_local refclock_none
|
||||
#endif
|
||||
|
||||
#if defined(TRAK) || defined(TRAKCLK) || defined(TRAKPPS)
|
||||
extern struct refclock refclock_trak;
|
||||
#else
|
||||
#define refclock_trak refclock_none
|
||||
#endif
|
||||
|
||||
#if defined(PST) || defined(PSTCLK) || defined(PSTPPS)
|
||||
extern struct refclock refclock_pst;
|
||||
#else
|
||||
@ -107,7 +113,7 @@ extern struct refclock refclock_gpstm;
|
||||
struct refclock *refclock_conf[] = {
|
||||
&refclock_none, /* 0 REFCLK_NONE */
|
||||
&refclock_local, /* 1 REFCLK_LOCAL */
|
||||
&refclock_none, /* 2 REFCLK_WWV_HEATH */
|
||||
&refclock_trak, /* 2 REFCLK_GPS_TRAK */
|
||||
&refclock_pst, /* 3 REFCLK_WWV_PST */
|
||||
&refclock_wwvb, /* 4 REFCLK_WWVB_SPECTRACOM */
|
||||
&refclock_goes, /* 5 REFCLK_GOES_TRUETIME */
|
||||
|
@ -19,7 +19,7 @@
|
||||
* This driver supports the IRIG audio decoder. This clever gadget uses
|
||||
* a modified BSD audio driver for the Sun SPARCstation which provides
|
||||
* a timestamp, raw binary timecode, status byte and decoded ASCII
|
||||
# timecode. The data are represented in the structure:
|
||||
* timecode. The data are represented in the structure:
|
||||
*
|
||||
* struct irig_time {
|
||||
* struct timeval stamp; timestamp
|
||||
|
@ -1,8 +1,8 @@
|
||||
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS))
|
||||
/*
|
||||
* /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp
|
||||
* /src/NTP/REPOSITORY/v3/xntpd/refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp
|
||||
*
|
||||
* refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp
|
||||
* refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp
|
||||
*
|
||||
* generic reference clock driver for receivers
|
||||
*
|
||||
@ -129,7 +129,7 @@ CURRENTLY NO BSD TTY SUPPORT
|
||||
#include "parse.h"
|
||||
|
||||
#if !defined(NO_SCCSID) && !defined(lint) && !defined(__GNUC__)
|
||||
static char rcsid[]="refclock_parse.c,v 3.45 1994/01/25 19:06:27 kardel Exp";
|
||||
static char rcsid[]="refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp";
|
||||
#endif
|
||||
|
||||
/**===========================================================================
|
||||
@ -1653,7 +1653,8 @@ local_poll(parse)
|
||||
* done if no more characters are available
|
||||
*/
|
||||
FD_SET(fd, &fdmask);
|
||||
if (select(fd + 1, &fdmask, 0, 0, &null_time) == 0)
|
||||
if ((i == 0) &&
|
||||
(select(fd + 1, &fdmask, 0, 0, &null_time) == 0))
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1706,7 +1707,8 @@ parsestate(state, buffer)
|
||||
{ PARSEB_NOSYNC, "TIME CODE NOT CONFIRMED" },
|
||||
{ PARSEB_DST, "DST" },
|
||||
{ PARSEB_UTC, "UTC DISPLAY" },
|
||||
{ PARSEB_LEAP, "LEAP WARNING" },
|
||||
{ PARSEB_LEAPADD, "LEAP ADD WARNING" },
|
||||
{ PARSEB_LEAPDEL, "LEAP DELETE WARNING" },
|
||||
{ PARSEB_LEAPSECOND, "LEAP SECOND" },
|
||||
{ PARSEB_ALTERNATE,"ALTERNATE ANTENNA" },
|
||||
{ PARSEB_TIMECODE, "TIME CODE" },
|
||||
@ -2539,9 +2541,10 @@ static void
|
||||
parse_leap()
|
||||
{
|
||||
/*
|
||||
* PARSE does encode a leap warning... we are aware but not afraid of that
|
||||
* as long as we get a little help for the direction from the operator until
|
||||
* PARSE encodes the LEAP correction direction.
|
||||
* For timecodes that do not pass on the leap correction direction
|
||||
* the default PARSEB_LEAPADD must be used. It may then be modified
|
||||
* with a fudge flag (flag2).
|
||||
*/
|
||||
}
|
||||
|
||||
@ -2821,7 +2824,7 @@ parse_control(unit, in, out)
|
||||
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\"");
|
||||
sprintf(tt, "refclock_driver_version=\"refclock_parse.c,v 3.51 1994/03/03 09:49:54 kardel Exp\"");
|
||||
|
||||
out->lencode = strlen(outstatus);
|
||||
out->lastcode = outstatus;
|
||||
@ -3245,14 +3248,24 @@ parse_process(parse, parsetime)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PARSE_LEAP(parsetime->parse_state))
|
||||
if (PARSE_LEAPADD(parsetime->parse_state))
|
||||
{
|
||||
/*
|
||||
* we pick this state also for time code that pass leap warnings
|
||||
* without direction information (as earth is currently slowing
|
||||
* down).
|
||||
*/
|
||||
leap = (parse->flags & PARSE_LEAP_DELETE) ? LEAP_DELSECOND : LEAP_ADDSECOND;
|
||||
}
|
||||
else
|
||||
{
|
||||
leap = LEAP_NOWARNING;
|
||||
}
|
||||
if (PARSE_LEAPDEL(parsetime->parse_state))
|
||||
{
|
||||
leap = LEAP_DELSECOND;
|
||||
}
|
||||
else
|
||||
{
|
||||
leap = LEAP_NOWARNING;
|
||||
}
|
||||
}
|
||||
|
||||
refclock_receive(parse->peer, &off, 0, LFPTOFP(&dispersion), &reftime, &rectime, leap);
|
||||
@ -3396,6 +3409,15 @@ trimble_init(parse)
|
||||
* History:
|
||||
*
|
||||
* refclock_parse.c,v
|
||||
* Revision 3.49 1994/02/20 13:26:00 kardel
|
||||
* rcs id cleanup
|
||||
*
|
||||
* Revision 3.48 1994/02/20 13:04:56 kardel
|
||||
* parse add/delete second support
|
||||
*
|
||||
* Revision 3.47 1994/02/02 17:44:30 kardel
|
||||
* rcs ids fixed
|
||||
*
|
||||
* Revision 3.45 1994/01/25 19:06:27 kardel
|
||||
* 94/01/23 reconcilation
|
||||
*
|
||||
|
967
usr.sbin/xntpd/xntpd/refclock_trak.c
Normal file
967
usr.sbin/xntpd/xntpd/refclock_trak.c
Normal file
@ -0,0 +1,967 @@
|
||||
/*
|
||||
* refclock_trak.c - clock driver for the TRAK 8810 GPS STATION CLOCK
|
||||
* Tsuruoka Tomoaki Oct 30, 1993
|
||||
*
|
||||
*/
|
||||
#if defined(REFCLOCK) && (defined(TRAK) || defined(TRAKCLK) || defined(TRAKPPS))
|
||||
|
||||
#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"
|
||||
|
||||
#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(STREAM)
|
||||
#include <termios.h>
|
||||
#include <stropts.h>
|
||||
#if defined(TRAKCLK)
|
||||
#include <sys/clkdefs.h>
|
||||
#endif /* TRAKCLK */
|
||||
#endif /* STREAM */
|
||||
|
||||
#if defined (TRAKPPS)
|
||||
#include <sys/ppsclock.h>
|
||||
#endif /* TRAKPPS */
|
||||
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
/*
|
||||
* This driver supports the TRAK 8810 GPS Receiver with
|
||||
* Buffered RS-232-C Interface Module.
|
||||
*
|
||||
* Most of codes are copied from refclock_as2201.c, Thanks a lot.
|
||||
*
|
||||
* The program expects the radio responses once per seccond
|
||||
* ( by "rqts,u" command or panel control )
|
||||
* of the form "*RQTS U,ddd:hh:mm:ss.0,Q\r\n for UTC" where
|
||||
* ddd= day of year
|
||||
* hh= hours
|
||||
* mm= minutes
|
||||
* ss= seconds
|
||||
* Q= Quality byte. Q=0 Phase error > 20 us
|
||||
* Q=6 Pahse error < 20 us
|
||||
* > 10 us
|
||||
* Q=5 Pahse error < 10 us
|
||||
* > 1 us
|
||||
* Q=4 Pahse error < 1 us
|
||||
* > 100 ns
|
||||
* Q=3 Pahse error < 100 ns
|
||||
* > 10 ns
|
||||
* Q=2 Pahse error < 10 ns
|
||||
* (note that my clock almost stable at 1 us per 10 hours)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definitions
|
||||
*/
|
||||
#define MAXUNITS 4 /* max number of GPS units */
|
||||
#define GPS232 "/dev/gps%d" /* name of radio device */
|
||||
#define SPEED232 B9600 /* uart speed (9600 baud) */
|
||||
|
||||
/*
|
||||
* Radio interface parameters
|
||||
*/
|
||||
#define GPSPRECISION (-20) /* precision assumed (about 1 us) */
|
||||
#define GPSREFID "GPS" /* reference id */
|
||||
#define GPSDESCRIPTION "TRAK 8810 GPS station clock" /* who we are */
|
||||
#define GPSHSREFID 0x7f7f110a /* 127.127.17.10 refid hi strata */
|
||||
#define GMT 0 /* hour offset from Greenwich */
|
||||
#define NCODES 3 /* stages of median filter */
|
||||
#define LENTOC 25 /* *RQTS U,ddd:hh:mm:ss.0,Q datecode length */
|
||||
#define BMAX 100 /* timecode buffer length */
|
||||
#define CODEDIFF 0x20000000 /* 0.125 seconds as an l_fp fraction */
|
||||
|
||||
/*
|
||||
* Hack to avoid excercising the multiplier. I have no pride.
|
||||
*/
|
||||
#define MULBY10(x) (((x)<<3) + ((x)<<1))
|
||||
|
||||
/*
|
||||
* Imported from ntp_timer module
|
||||
*/
|
||||
extern U_LONG current_time; /* current time (s) */
|
||||
|
||||
/*
|
||||
* Imported from ntp_loopfilter module
|
||||
*/
|
||||
extern int fdpps; /* pps file descriptor */
|
||||
|
||||
/*
|
||||
* Imported from ntpd module
|
||||
*/
|
||||
extern int debug; /* global debug flag */
|
||||
|
||||
/*
|
||||
* GPS unit control structure.
|
||||
*/
|
||||
struct gpsunit {
|
||||
struct peer *peer; /* associated peer structure */
|
||||
struct refclockio io; /* given to the I/O handler */
|
||||
l_fp lastrec; /* last data receive time */
|
||||
l_fp lastref; /* last timecode time */
|
||||
l_fp offset[NCODES]; /* recent sample offsets */
|
||||
char lastcode[BMAX]; /* last timecode received */
|
||||
u_short polled; /* when polled, means a last sample */
|
||||
u_char lencode; /* length of last received ASCII string */
|
||||
U_LONG lasttime; /* last time clock heard from */
|
||||
#ifdef TRAKPPS
|
||||
U_LONG lastev; /* last ppsclock second */
|
||||
#endif /* TRAKPPS */
|
||||
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_short msec; /* milliseconds of second */
|
||||
u_char leap; /* leap indicators */
|
||||
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 gpsunit *gpsunits[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 fudgefactor[MAXUNITS];
|
||||
static u_char stratumtouse[MAXUNITS];
|
||||
static u_char sloppyclockflag[MAXUNITS];
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
static void trak_init P(());
|
||||
static int trak_start P((u_int, struct peer *));
|
||||
static void trak_shutdown P((int));
|
||||
static void trak_report_event P((struct gpsunit *, int));
|
||||
static void trak_receive P((struct recvbuf *));
|
||||
static char trak_process P((struct gpsunit *, l_fp *, u_fp *));
|
||||
static void trak_poll P((int unit, struct peer *));
|
||||
static void trak_control P((u_int, struct refclockstat *, struct refclockstat *));
|
||||
static void trak_buginfo P((int, struct refclockbug *));
|
||||
|
||||
/*
|
||||
* Transfer vector
|
||||
*/
|
||||
struct refclock refclock_trak = {
|
||||
trak_start, trak_shutdown, trak_poll,
|
||||
trak_control, trak_init, trak_buginfo, NOFLAGS
|
||||
};
|
||||
|
||||
/*
|
||||
* trak_init - initialize internal gps driver data
|
||||
*/
|
||||
static void
|
||||
trak_init()
|
||||
{
|
||||
register int i;
|
||||
/*
|
||||
* Just zero the data arrays
|
||||
*/
|
||||
bzero((char *)gpsunits, sizeof gpsunits);
|
||||
bzero((char *)unitinuse, sizeof unitinuse);
|
||||
|
||||
/*
|
||||
* Initialize fudge factors to default.
|
||||
*/
|
||||
for (i = 0; i < MAXUNITS; i++) {
|
||||
fudgefactor[i].l_ui = 0;
|
||||
fudgefactor[i].l_uf = 0;
|
||||
stratumtouse[i] = 0;
|
||||
sloppyclockflag[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* trak_start - open the GPS devices and initialize data for processing
|
||||
*/
|
||||
static int
|
||||
trak_start(unit, peer)
|
||||
u_int unit;
|
||||
struct peer *peer;
|
||||
{
|
||||
register struct gpsunit *gps;
|
||||
register int i;
|
||||
int fd232;
|
||||
char trakdev[20];
|
||||
#ifdef TRAKPPS
|
||||
struct ppsclockev ev;
|
||||
#endif /* TRAKPPS */
|
||||
|
||||
/*
|
||||
* Check configuration info
|
||||
*/
|
||||
if (unit >= MAXUNITS) {
|
||||
syslog(LOG_ERR, "trak_start: unit %d invalid", unit);
|
||||
return (0);
|
||||
}
|
||||
if (unitinuse[unit]) {
|
||||
syslog(LOG_ERR, "trak_start: unit %d in use", unit);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Open serial port
|
||||
*/
|
||||
(void) sprintf(trakdev, GPS232, unit);
|
||||
fd232 = open(trakdev, O_RDWR, 0777);
|
||||
if (fd232 == -1) {
|
||||
syslog(LOG_ERR, "trak_start: open of %s: %m", trakdev);
|
||||
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,
|
||||
"trak_start: ioctl(%s, TCGETA): %m", trakdev);
|
||||
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,
|
||||
"trak_start: ioctl(%s, TCSETA): %m", trakdev);
|
||||
goto screwed;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_SYSV_TTYS */
|
||||
#if defined(STREAM)
|
||||
/*
|
||||
* POSIX/STREAMS serial line parameters (termios interface)
|
||||
*
|
||||
* The TRAKCLK option provides timestamping at the driver level.
|
||||
* It requires the tty_clk streams module.
|
||||
*
|
||||
* The TRAKPPS 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,
|
||||
"trak_start: tcgetattr(%s): %m", trakdev);
|
||||
goto screwed;
|
||||
}
|
||||
ttyp->c_iflag = IGNBRK|IGNPAR;
|
||||
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,
|
||||
"trak_start: tcsetattr(%s): %m", trakdev);
|
||||
goto screwed;
|
||||
}
|
||||
if (tcflush(fd232, TCIOFLUSH) < 0) {
|
||||
syslog(LOG_ERR,
|
||||
"trak_start: tcflush(%s): %m", trakdev);
|
||||
goto screwed;
|
||||
}
|
||||
#if defined(TRAKCLK)
|
||||
if (ioctl(fd232, I_PUSH, "clk") < 0)
|
||||
syslog(LOG_ERR,
|
||||
"trak_start: ioctl(%s, I_PUSH, clk): %m", trakdev);
|
||||
if (ioctl(fd232, CLK_SETSTR, "*") < 0)
|
||||
syslog(LOG_ERR,
|
||||
"trak_start: ioctl(%s, CLK_SETSTR): %m", trakdev);
|
||||
#endif /* TRAKCLK */
|
||||
#if defined(TRAKPPS)
|
||||
if (ioctl(fd232, I_PUSH, "ppsclock") < 0)
|
||||
syslog(LOG_ERR,
|
||||
"trak_start: ioctl(%s, I_PUSH, ppsclock): %m", trakdev);
|
||||
else
|
||||
fdpps = fd232;
|
||||
#endif /* TRAKPPS */
|
||||
}
|
||||
#endif /* STREAM */
|
||||
#if defined(HAVE_BSD_TTYS)
|
||||
/*
|
||||
* 4.3bsd serial line parameters (sgttyb interface)
|
||||
*
|
||||
* The TRAKCLK option provides timestamping at the driver level.
|
||||
* It requires the tty_clk line discipline and 4.3bsd or later.
|
||||
*/
|
||||
{ struct sgttyb ttyb;
|
||||
#if defined(TRAKCLK)
|
||||
int ldisc = CLKLDISC;
|
||||
#endif /* TRAKCLK */
|
||||
|
||||
if (ioctl(fd232, TIOCGETP, &ttyb) < 0) {
|
||||
syslog(LOG_ERR,
|
||||
"trak_start: ioctl(%s, TIOCGETP): %m", trakdev);
|
||||
goto screwed;
|
||||
}
|
||||
ttyb.sg_ispeed = ttyb.sg_ospeed = SPEED232;
|
||||
#if defined(TRAKCLK)
|
||||
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 /* TRAKCLK */
|
||||
if (ioctl(fd232, TIOCSETP, &ttyb) < 0) {
|
||||
syslog(LOG_ERR,
|
||||
"trak_start: ioctl(%s, TIOCSETP): %m", trakdev);
|
||||
goto screwed;
|
||||
}
|
||||
#if defined(TRAKCLK)
|
||||
if (ioctl(fd232, TIOCSETD, &ldisc) < 0) {
|
||||
syslog(LOG_ERR,
|
||||
"trak_start: ioctl(%s, TIOCSETD): %m",trakdev);
|
||||
goto screwed;
|
||||
}
|
||||
#endif /* TRAKCLK */
|
||||
}
|
||||
#endif /* HAVE_BSD_TTYS */
|
||||
|
||||
/*
|
||||
* Allocate unit structure
|
||||
*/
|
||||
if (gpsunits[unit] != 0) {
|
||||
gps = gpsunits[unit]; /* The one we want is okay */
|
||||
} else {
|
||||
for (i = 0; i < MAXUNITS; i++) {
|
||||
if (!unitinuse[i] && gpsunits[i] != 0)
|
||||
break;
|
||||
}
|
||||
if (i < MAXUNITS) {
|
||||
/*
|
||||
* Reclaim this one
|
||||
*/
|
||||
gps = gpsunits[i];
|
||||
gpsunits[i] = 0;
|
||||
} else {
|
||||
gps = (struct gpsunit *)
|
||||
emalloc(sizeof(struct gpsunit));
|
||||
}
|
||||
}
|
||||
bzero((char *)gps, sizeof(struct gpsunit));
|
||||
gpsunits[unit] = gps;
|
||||
|
||||
/*
|
||||
* Set up the structures
|
||||
*/
|
||||
gps->peer = peer;
|
||||
gps->unit = (u_char)unit;
|
||||
gps->timestarted = current_time;
|
||||
|
||||
gps->io.clock_recv = trak_receive;
|
||||
gps->io.srcclock = (caddr_t)gps;
|
||||
gps->io.datalen = 0;
|
||||
gps->io.fd = fd232;
|
||||
#ifdef TRAKPPS
|
||||
if (ioctl(fd232, CIOGETEV, (caddr_t)&ev) < 0) {
|
||||
syslog(LOG_ERR,
|
||||
"trak_start: ioctl(%s, CIOGETEV): %m", trakdev);
|
||||
goto screwed;
|
||||
} else
|
||||
gps->lastev = ev.tv.tv_sec;
|
||||
#endif /* TRAKPPS */
|
||||
if (!io_addclock(&gps->io)) {
|
||||
goto screwed;
|
||||
}
|
||||
|
||||
/*
|
||||
* All done. Initialize a few random peer variables, then
|
||||
* return success. Note that root delay and root dispersion are
|
||||
* always zero for this clock.
|
||||
*/
|
||||
peer->precision = GPSPRECISION;
|
||||
peer->rootdelay = 0;
|
||||
peer->rootdispersion = 0;
|
||||
peer->stratum = stratumtouse[unit];
|
||||
if (stratumtouse[unit] <= 1)
|
||||
bcopy(GPSREFID, (char *)&peer->refid, 4);
|
||||
else
|
||||
peer->refid = htonl(GPSHSREFID);
|
||||
unitinuse[unit] = 1;
|
||||
/*
|
||||
* request to give time code
|
||||
*/
|
||||
{
|
||||
void gps_send();
|
||||
gps_send(gps,"\rRQTS,U\r");
|
||||
gps_send(gps,"SEL 00\r");
|
||||
}
|
||||
|
||||
return (1);
|
||||
|
||||
/*
|
||||
* Something broke; abandon ship.
|
||||
*/
|
||||
screwed:
|
||||
(void) close(fd232);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* trak_shutdown - shut down a GPS clock
|
||||
*/
|
||||
static void
|
||||
trak_shutdown(unit)
|
||||
int unit;
|
||||
{
|
||||
register struct gpsunit *gps;
|
||||
void gps_send();
|
||||
|
||||
if (unit >= MAXUNITS) {
|
||||
syslog(LOG_ERR, "trak_shutdown: unit %d invalid", unit);
|
||||
return;
|
||||
}
|
||||
if (!unitinuse[unit]) {
|
||||
syslog(LOG_ERR, "trak_shutdown: unit %d not in use", unit);
|
||||
return;
|
||||
}
|
||||
gps = gpsunits[unit];
|
||||
/*
|
||||
* request not to give time code any more
|
||||
*/
|
||||
gps_send(gps,"RQTX\r");
|
||||
/*
|
||||
* Tell the I/O module to turn us off. We're history.
|
||||
*/
|
||||
io_closeclock(&gps->io);
|
||||
|
||||
unitinuse[unit] = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* trak_report_event - note the occurance of an event
|
||||
*
|
||||
* This routine presently just remembers the report and logs it, but
|
||||
* does nothing heroic for the trap handler.
|
||||
*/
|
||||
static void
|
||||
trak_report_event(gps, code)
|
||||
struct gpsunit *gps;
|
||||
int code;
|
||||
{
|
||||
struct peer *peer;
|
||||
|
||||
peer = gps->peer;
|
||||
if (gps->status != (u_char)code) {
|
||||
gps->status = (u_char)code;
|
||||
if (code != CEVNT_NOMINAL)
|
||||
gps->lastevent = (u_char)code;
|
||||
syslog(LOG_INFO,
|
||||
"clock %s event %x\n", ntoa(&peer->srcadr), code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* trak_receive - receive data from the serial interface
|
||||
*/
|
||||
static void
|
||||
trak_receive(rbufp)
|
||||
struct recvbuf *rbufp;
|
||||
{
|
||||
register int i,cmdtype;
|
||||
register struct gpsunit *gps;
|
||||
|
||||
#if defined(TRAKPPS)
|
||||
struct ppsclockev ev;
|
||||
l_fp trtmp;
|
||||
#endif /* TRAKPPS */
|
||||
register u_char *dpt;
|
||||
register u_char *cp;
|
||||
register u_char *dpend;
|
||||
l_fp tstmp;
|
||||
u_fp dispersion;
|
||||
|
||||
/*
|
||||
* Get the clock this applies to and pointers to the data.
|
||||
* Edit the timecode to remove control chars and trashbits.
|
||||
*/
|
||||
gps = (struct gpsunit *)rbufp->recv_srcclock;
|
||||
dpt = (u_char *)&rbufp->recv_space;
|
||||
dpend = dpt + rbufp->recv_length;
|
||||
cp = (u_char *)gps->lastcode;
|
||||
|
||||
while (dpt < dpend) {
|
||||
#ifdef TRAKCLK /* prior to TRAKPPS due to timestamp */
|
||||
if ((*cp = 0x7f & *dpt++) != '*' ) cp++;
|
||||
else if (*cp == '*' ) { /* caught magic character */
|
||||
if ( dpend - dpt < 8) {
|
||||
/* short timestamp */
|
||||
if(debug) puts("gps: short timestamp.");
|
||||
return;
|
||||
}
|
||||
if (!buftvtots(dpt,&gps->lastrec)) {
|
||||
/* screwy timestamp */
|
||||
if(debug) puts("gps: screwy timestamp.");
|
||||
return;
|
||||
}
|
||||
dpt += 8;
|
||||
}
|
||||
#else
|
||||
#ifdef TRAKPPS
|
||||
if ((*cp = 0x7f & *dpt++) >= ' ') cp++;
|
||||
#else
|
||||
/* both are not specified */
|
||||
#endif /* TRAKPPS */
|
||||
#endif /* TRAKCLK */
|
||||
}
|
||||
*cp = '\0';
|
||||
gps->lencode = cp - (u_char *)gps->lastcode;
|
||||
if (gps->lencode == 0) return;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug)
|
||||
printf("gps: timecode %d %s\n",
|
||||
gps->lencode, gps->lastcode);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We check the timecode format and decode its contents. The
|
||||
* timecode has format *........RQTS U,ddd:hh:mm:ss.0,Q\r\n).
|
||||
* 012345678901234567890123
|
||||
*/
|
||||
cp = (u_char *)gps->lastcode;
|
||||
gps->leap = 0;
|
||||
cmdtype=0;
|
||||
if (strncmp(cp,"RQTS",4)==0) {
|
||||
cmdtype=1;
|
||||
cp += 7;
|
||||
}
|
||||
else if(strncmp(cp,"*RQTS",5)==0) {
|
||||
cmdtype=2;
|
||||
cp += 8;
|
||||
}
|
||||
else return;
|
||||
switch( cmdtype ) {
|
||||
case 1:
|
||||
case 2:
|
||||
/*
|
||||
* Check time code format of TRAK 8810
|
||||
*/
|
||||
if( !isdigit(cp[0]) ||
|
||||
!isdigit(cp[1]) ||
|
||||
!isdigit(cp[2]) ||
|
||||
cp[3] != ':' ||
|
||||
!isdigit(cp[4]) ||
|
||||
!isdigit(cp[5]) ||
|
||||
cp[6] != ':' ||
|
||||
!isdigit(cp[7]) ||
|
||||
!isdigit(cp[8]) ||
|
||||
cp[9] != ':' ||
|
||||
!isdigit(cp[10])||
|
||||
!isdigit(cp[11])) {
|
||||
gps->badformat++;
|
||||
trak_report_event(gps, CEVNT_BADREPLY);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert date and check values.
|
||||
*/
|
||||
gps->day = cp[0] - '0';
|
||||
gps->day = MULBY10(gps->day) + cp[1] - '0';
|
||||
gps->day = MULBY10(gps->day) + cp[2] - '0';
|
||||
if (gps->day < 1 || gps->day > 366) {
|
||||
gps->baddata++;
|
||||
trak_report_event(gps, CEVNT_BADDATE);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Convert time and check values.
|
||||
*/
|
||||
gps->hour = MULBY10(cp[4] - '0') + cp[5] - '0';
|
||||
gps->minute = MULBY10(cp[7] - '0') + cp[8] - '0';
|
||||
gps->second = MULBY10(cp[10] - '0') + cp[11] - '0';
|
||||
gps->msec = 0;
|
||||
if (gps->hour > 23 || gps->minute > 59 || gps->second > 59) {
|
||||
gps->baddata++;
|
||||
trak_report_event(gps, CEVNT_BADTIME);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test for synchronization
|
||||
*/
|
||||
/*
|
||||
switch( cp[15] ) {
|
||||
case '0':
|
||||
if(gps->peer->stratum == stratumtouse[gps->unit]) {
|
||||
gps->peer->stratum = 10 ;
|
||||
bzero(&gps->peer->refid,4);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(gps->peer->stratum != stratumtouse[gps->unit]) {
|
||||
gps->peer->stratum = stratumtouse[gps->unit] ;
|
||||
bcopy(GPSREFID,&gps->peer->refid,4);
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
gps->lasttime = current_time;
|
||||
|
||||
if (!gps->polled) return;
|
||||
|
||||
/*
|
||||
* Now, compute the reference time value. Use the heavy
|
||||
* machinery for the second, which presumably is the one which
|
||||
* occured at the last pps pulse and which was captured by the
|
||||
* loop_filter module. All we have to do here is present a
|
||||
* reasonable facsimile of the time at that pulse so the clock-
|
||||
* filter and selection machinery declares us truechimer. The
|
||||
* precision offset within the second is really tuned by the
|
||||
* loop_filter module. Note that this code does not yet know how
|
||||
* to do the years and relies on the clock-calendar chip for
|
||||
* sanity.
|
||||
*/
|
||||
|
||||
#if defined(TRAKPPS)
|
||||
|
||||
/*
|
||||
* timestamp must be greater than previous one.
|
||||
*/
|
||||
if (ioctl(fdpps, CIOGETEV, (caddr_t)&ev) >= 0) {
|
||||
ev.tv.tv_sec += (U_LONG)JAN_1970;
|
||||
TVTOTS(&ev.tv,&gps->lastrec);
|
||||
if (gps->lastev < ev.tv.tv_sec) {
|
||||
gps->lastev = ev.tv.tv_sec;
|
||||
} else { /* in case of 1-pps missing */
|
||||
gps->lastev = ev.tv.tv_sec;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
return; /* failed to get timestamp */
|
||||
#endif /* TRAKPPS */
|
||||
|
||||
if (!clocktime(gps->day, gps->hour, gps->minute,
|
||||
gps->second, GMT, gps->lastrec.l_ui,
|
||||
&gps->yearstart, &gps->lastref.l_ui)) {
|
||||
gps->baddata++;
|
||||
trak_report_event(gps, CEVNT_BADTIME);
|
||||
#ifdef DEBUG
|
||||
if(debug) printf("gps: bad date \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
MSUTOTSF(gps->msec, gps->lastref.l_uf);
|
||||
tstmp = gps->lastref;
|
||||
|
||||
L_SUB(&tstmp, &gps->lastrec);
|
||||
L_ADD(&tstmp, &(fudgefactor[gps->unit]));
|
||||
i = ((int)(gps->coderecv)) % NCODES;
|
||||
gps->offset[i] = tstmp;
|
||||
gps->coderecv++;
|
||||
#if DEBUG
|
||||
if (debug)
|
||||
printf("gps: times %s %s %s\n",
|
||||
ulfptoa(&gps->lastref, 6), ulfptoa(&gps->lastrec, 6),
|
||||
lfptoa(&tstmp, 6));
|
||||
#endif
|
||||
/* if( tstmp.l_ui != 0 ) return; something wrong */
|
||||
|
||||
/*
|
||||
* Process the samples in the median filter, add the fudge
|
||||
* factor and pass the offset and dispersion along. We use
|
||||
* lastref 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 (gps->coderecv < NCODES)
|
||||
return;
|
||||
if (!trak_process(gps, &tstmp, &dispersion)) {
|
||||
gps->baddata++;
|
||||
trak_report_event(gps, CEVNT_BADTIME);
|
||||
return;
|
||||
}
|
||||
refclock_receive(gps->peer, &tstmp, GMT, dispersion,
|
||||
&gps->lastrec, &gps->lastrec, gps->leap);
|
||||
/*
|
||||
* after all, clear polled flag
|
||||
*/
|
||||
gps->polled = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ==================================================================
|
||||
* gps_send(gps,cmd) Sends a command to the GPS receiver.
|
||||
* as gps_send(gps,"rqts,u\r");
|
||||
* ==================================================================
|
||||
*/
|
||||
static void
|
||||
gps_send(gps,cmd)
|
||||
struct gpsunit *gps;
|
||||
char *cmd;
|
||||
{
|
||||
if (write(gps->io.fd, cmd, strlen(cmd)) == -1) {
|
||||
syslog(LOG_ERR, "gps_send: unit %d: %m", gps->unit);
|
||||
trak_report_event(gps,CEVNT_FAULT);
|
||||
} else {
|
||||
gps->polls++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* trak_process - process a pile of samples from the clock
|
||||
*
|
||||
* This routine uses a three-stage median filter to calculate offset and
|
||||
* dispersion and reduce jitter. The dispersion is calculated as the
|
||||
* span of the filter (max - min).
|
||||
*/
|
||||
static char
|
||||
trak_process(gps, offset, dispersion)
|
||||
struct gpsunit *gps;
|
||||
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. 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 = gps->offset[i].l_ui;
|
||||
tmp_uf = gps->offset[i].l_uf;
|
||||
M_SUB(tmp_ui, tmp_uf, gps->offset[j].l_ui,
|
||||
gps->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gps->lasttime == 0)
|
||||
disp_tmp2 = NTP_MAXDISPERSE;
|
||||
else
|
||||
disp_tmp2 = current_time - gps->lasttime;
|
||||
if (not_median1 == 0) {
|
||||
if (not_median2 == 1)
|
||||
median = 2;
|
||||
else
|
||||
median = 1;
|
||||
} else {
|
||||
median = 0;
|
||||
}
|
||||
*offset = gps->offset[median];
|
||||
*dispersion = disp_tmp2;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* trak_poll - called by the transmit procedure
|
||||
*
|
||||
* We go to great pains to avoid changing state here, since there may be
|
||||
* more than one eavesdropper receiving the same timecode.
|
||||
*/
|
||||
static void
|
||||
trak_poll(unit, peer)
|
||||
int unit;
|
||||
struct peer *peer;
|
||||
{
|
||||
struct gpsunit *gps;
|
||||
|
||||
if (unit >= MAXUNITS) {
|
||||
syslog(LOG_ERR, "trak_poll: unit %d invalid", unit);
|
||||
return;
|
||||
}
|
||||
if (!unitinuse[unit]) {
|
||||
syslog(LOG_ERR, "trak_poll: unit %d not in use", unit);
|
||||
return;
|
||||
}
|
||||
gps = gpsunits[unit];
|
||||
if ((current_time - gps->lasttime) > 150)
|
||||
trak_report_event(gpsunits[unit], CEVNT_TIMEOUT);
|
||||
/*
|
||||
* usually trak_receive can get a timestamp every second
|
||||
*/
|
||||
#ifndef TRAKPPS && TRAKCLK
|
||||
gettstamp(&gps->lastrec);
|
||||
#endif
|
||||
gps->polls++;
|
||||
/*
|
||||
* may be polled every 64 seconds
|
||||
*/
|
||||
gps->polled = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* trak_control - set fudge factors, return statistics
|
||||
*/
|
||||
static void
|
||||
trak_control(unit, in, out)
|
||||
u_int unit;
|
||||
struct refclockstat *in;
|
||||
struct refclockstat *out;
|
||||
{
|
||||
register struct gpsunit *gps;
|
||||
|
||||
if (unit >= MAXUNITS) {
|
||||
syslog(LOG_ERR, "trak_control: unit %d invalid", unit);
|
||||
return;
|
||||
}
|
||||
|
||||
if (in != 0) {
|
||||
if (in->haveflags & CLK_HAVETIME1)
|
||||
fudgefactor[unit] = in->fudgetime1;
|
||||
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
|
||||
*/
|
||||
gps = gpsunits[unit];
|
||||
peer = gps->peer;
|
||||
peer->stratum = stratumtouse[unit];
|
||||
if (stratumtouse[unit] <= 1)
|
||||
bcopy(GPSREFID, (char *)&peer->refid,
|
||||
4);
|
||||
else
|
||||
peer->refid = htonl(GPSHSREFID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (out != 0) {
|
||||
out->type = REFCLK_GPS_TRAK;
|
||||
out->haveflags
|
||||
= CLK_HAVETIME1|CLK_HAVEVAL1|CLK_HAVEVAL2;
|
||||
out->clockdesc = GPSDESCRIPTION;
|
||||
out->fudgetime1 = fudgefactor[unit];
|
||||
out->fudgetime2.l_ui = 0;
|
||||
out->fudgetime2.l_uf = 0;
|
||||
out->fudgeval1 = (LONG)stratumtouse[unit];
|
||||
out->fudgeval2 = 0;
|
||||
out->flags = sloppyclockflag[unit];
|
||||
if (unitinuse[unit]) {
|
||||
gps = gpsunits[unit];
|
||||
out->lencode = LENTOC;
|
||||
out->timereset = current_time - gps->timestarted;
|
||||
out->polls = gps->polls;
|
||||
out->noresponse = gps->noreply;
|
||||
out->badformat = gps->badformat;
|
||||
out->baddata = gps->baddata;
|
||||
out->lastevent = gps->lastevent;
|
||||
out->currentstatus = gps->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* trak_buginfo - return clock dependent debugging info
|
||||
*/
|
||||
static void
|
||||
trak_buginfo(unit, bug)
|
||||
int unit;
|
||||
register struct refclockbug *bug;
|
||||
{
|
||||
register struct gpsunit *gps;
|
||||
|
||||
if (unit >= MAXUNITS) {
|
||||
syslog(LOG_ERR, "trak_buginfo: unit %d invalid", unit);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!unitinuse[unit])
|
||||
return;
|
||||
gps = gpsunits[unit];
|
||||
|
||||
bug->nvalues = 10;
|
||||
bug->ntimes = 5;
|
||||
if (gps->lasttime != 0)
|
||||
bug->values[0] = current_time - gps->lasttime;
|
||||
else
|
||||
bug->values[0] = 0;
|
||||
bug->values[1] = (U_LONG)gps->reason;
|
||||
bug->values[2] = (U_LONG)gps->year;
|
||||
bug->values[3] = (U_LONG)gps->day;
|
||||
bug->values[4] = (U_LONG)gps->hour;
|
||||
bug->values[5] = (U_LONG)gps->minute;
|
||||
bug->values[6] = (U_LONG)gps->second;
|
||||
bug->values[7] = (U_LONG)gps->msec;
|
||||
bug->values[8] = gps->noreply;
|
||||
bug->values[9] = gps->yearstart;
|
||||
bug->stimes = 0x1c;
|
||||
bug->times[0] = gps->lastref;
|
||||
bug->times[1] = gps->lastrec;
|
||||
bug->times[2] = gps->offset[0];
|
||||
bug->times[3] = gps->offset[1];
|
||||
bug->times[4] = gps->offset[2];
|
||||
}
|
||||
#endif
|
@ -598,8 +598,12 @@ again:
|
||||
/*
|
||||
* So far, so good. Copy this data into the output array.
|
||||
*/
|
||||
if ((datap + datasize) > (pktdata + pktdatasize))
|
||||
if ((datap + datasize) > (pktdata + pktdatasize)) {
|
||||
int offset = datap - pktdata;
|
||||
growpktdata();
|
||||
*rdata = pktdata; /* might have been realloced ! */
|
||||
datap = pktdata + offset;
|
||||
}
|
||||
memmove(datap, (char *)rpkt.data, datasize);
|
||||
datap += datasize;
|
||||
if (firstpkt) {
|
||||
|
@ -846,8 +846,12 @@ sysstats(pcmd, fp)
|
||||
if (!check1item(items, fp))
|
||||
return;
|
||||
|
||||
if (!checkitemsize(itemsize, sizeof(struct info_sys_stats)))
|
||||
if (itemsize != sizeof(struct info_sys_stats) &&
|
||||
itemsize != sizeof(struct old_info_sys_stats)) {
|
||||
/* issue warning according to new structure size */
|
||||
checkitemsize(itemsize, sizeof(struct info_sys_stats));
|
||||
return;
|
||||
}
|
||||
|
||||
(void) fprintf(fp, "system uptime: %d\n",
|
||||
ntohl(ss->timeup));
|
||||
@ -869,6 +873,11 @@ sysstats(pcmd, fp)
|
||||
ntohl(ss->badauth));
|
||||
(void) fprintf(fp, "wander hold downs: %d\n",
|
||||
ntohl(ss->wanderhold));
|
||||
if (itemsize != sizeof(struct info_sys_stats))
|
||||
return;
|
||||
|
||||
(void) fprintf(fp, "limitation rejects: %d\n",
|
||||
ntohl(ss->limitrejected));
|
||||
}
|
||||
|
||||
|
||||
@ -1243,6 +1252,7 @@ static struct resflags resflags[] = {
|
||||
{ "nopeer", RES_NOPEER },
|
||||
{ "notrap", RES_NOTRAP },
|
||||
{ "lptrap", RES_LPTRAP },
|
||||
{ "limited", RES_LIMITED },
|
||||
{ "", 0 }
|
||||
};
|
||||
|
||||
@ -1463,6 +1473,7 @@ monlist(pcmd, fp)
|
||||
FILE *fp;
|
||||
{
|
||||
struct info_monitor *ml;
|
||||
struct old_info_monitor *oml;
|
||||
int items;
|
||||
int itemsize;
|
||||
int res;
|
||||
@ -1476,23 +1487,49 @@ monlist(pcmd, fp)
|
||||
if (!checkitems(items, fp))
|
||||
return;
|
||||
|
||||
if (!checkitemsize(itemsize, sizeof(struct info_monitor)))
|
||||
return;
|
||||
if (itemsize == sizeof(struct info_monitor)) {
|
||||
|
||||
(void) fprintf(fp,
|
||||
" address port count mode version lasttime firsttime\n");
|
||||
(void) fprintf(fp,
|
||||
"=====================================================================\n");
|
||||
while (items > 0) {
|
||||
(void) fprintf(fp, "%-20.20s %5d %9d %4d %3d %9u %9u\n",
|
||||
nntohost(ml->addr),
|
||||
ntohs(ml->port),
|
||||
ntohl(ml->count),
|
||||
ml->mode, ml->version,
|
||||
ntohl(ml->lasttime),
|
||||
ntohl(ml->firsttime));
|
||||
ml++;
|
||||
items--;
|
||||
(void) fprintf(fp,
|
||||
" address port count mode version lastdrop lasttime firsttime\n");
|
||||
(void) fprintf(fp,
|
||||
"===============================================================================\n");
|
||||
while (items > 0) {
|
||||
(void) fprintf(fp, "%-20.20s %5d %9d %4d %3d %9u %9u %9u\n",
|
||||
nntohost(ml->addr),
|
||||
ntohs(ml->port),
|
||||
ntohl(ml->count),
|
||||
ml->mode,
|
||||
ml->version,
|
||||
ntohl(ml->lastdrop),
|
||||
ntohl(ml->lasttime),
|
||||
ntohl(ml->firsttime));
|
||||
ml++;
|
||||
items--;
|
||||
}
|
||||
} else {
|
||||
if (itemsize != sizeof(struct old_info_monitor)) {
|
||||
/* issue warning according to new info_monitor size */
|
||||
checkitemsize(itemsize, sizeof(struct info_monitor));
|
||||
return;
|
||||
}
|
||||
|
||||
oml = (struct old_info_monitor *)ml;
|
||||
(void) fprintf(fp,
|
||||
" address port count mode version lasttime firsttime\n");
|
||||
(void) fprintf(fp,
|
||||
"======================================================================\n");
|
||||
while (items > 0) {
|
||||
(void) fprintf(fp, "%-20.20s %5d %9d %4d %3d %9u %9u\n",
|
||||
nntohost(oml->addr),
|
||||
ntohs(oml->port),
|
||||
ntohl(oml->count),
|
||||
oml->mode,
|
||||
oml->version,
|
||||
ntohl(oml->lasttime),
|
||||
ntohl(oml->firsttime));
|
||||
oml++;
|
||||
items--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user