MFV r358616:

Update ntp-4.2.8p13 --> 4.2.8p14.

The advisory can be found at:
http://support.ntp.org/bin/view/Main/SecurityNotice#\
March_2020_ntp_4_2_8p14_NTP_Rele

No CVEs have been documented yet.

MFC after:	now
Security:	http://support.ntp.org/bin/view/Main/NtpBug3610
		http://support.ntp.org/bin/view/Main/NtpBug3596
		http://support.ntp.org/bin/view/Main/NtpBug3592
This commit is contained in:
Cy Schubert 2020-03-04 21:45:12 +00:00
commit 2d4e511ca2
243 changed files with 13004 additions and 5877 deletions

View File

@ -3,7 +3,7 @@ This file is automatically generated from html/copyright.html
jpg "Clone me," says Dolly sheepishly.
Last update: 2-Jan-2017 11:58 UTC
Last update: 4-Feb-2020 23:47 UTC
__________________________________________________________________
The following copyright notice applies to all files collectively called
@ -32,7 +32,7 @@ This file is automatically generated from html/copyright.html
Burnicki is:
***********************************************************************
* *
* Copyright (c) Network Time Foundation 2011-2017 *
* Copyright (c) Network Time Foundation 2011-2020 *
* *
* All Rights Reserved *
* *

View File

@ -1,3 +1,99 @@
---
(4.2.8p14) 2020/03/03 Released by Harlan Stenn <stenn@ntp.org>
* [Sec 3610] process_control() should bail earlier on short packets. stenn@
- Reported by Philippe Antoine
* [Sec 3596] Highly predictable timestamp attack. <stenn@ntp.org>
- Reported by Miroslav Lichvar
* [Sec 3592] DoS attack on client ntpd <perlinger@ntp.org>
- Reported by Miroslav Lichvar
* [Bug 3637] Emit the version of ntpd in saveconfig. stenn@
* [Bug 3636] NMEA: combine time/date from multiple sentences <perlinger@ntp.org>
* [Bug 3635] Make leapsecond file hash check optional <perlinger@ntp.org>
* [Bug 3634] Typo in discipline.html, reported by Jason Harrison. stenn@
* [Bug 3628] raw DCF decoding - improve robustness with Zeller's congruence
- implement Zeller's congruence in libparse and libntp <perlinger@ntp.org>
* [Bug 3627] SIGSEGV on FreeBSD-12 with stack limit and stack gap <perlinger@ntp.org>
- integrated patch by Cy Schubert
* [Bug 3620] memory leak in ntpq sysinfo <perlinger@ntp.org>
- applied patch by Gerry Garvey
* [Bug 3619] Honour drefid setting in cooked mode and sysinfo <perlinger@ntp.org>
- applied patch by Gerry Garvey
* [Bug 3617] Add support for ACE III and Copernicus II receivers <perlinger@ntp.org>
- integrated patch by Richard Steedman
* [Bug 3615] accelerate refclock startup <perlinger@ntp.org>
* [Bug 3613] Propagate noselect to mobilized pool servers <stenn@ntp.org>
- Reported by Martin Burnicki
* [Bug 3612] Use-of-uninitialized-value in receive function <perlinger@ntp.org>
- Reported by Philippe Antoine
* [Bug 3611] NMEA time interpreted incorrectly <perlinger@ntp.org>
- officially document new "trust date" mode bit for NMEA driver
- restore the (previously undocumented) "trust date" feature lost with [bug 3577]
* [Bug 3609] Fixing wrong falseticker in case of non-statistic jitter <perlinger@ntp.org>
- mostly based on a patch by Michael Haardt, implementing 'fudge minjitter'
* [Bug 3608] libparse fails to compile on S11.4SRU13 and later <perlinger@ntp.org>
- removed ffs() and fls() prototypes as per Brian Utterback
* [Bug 3604] Wrong param byte order passing into record_raw_stats() in
ntp_io.c <perlinger@ntp.org>
- fixed byte and paramter order as suggested by wei6410@sina.com
* [Bug 3601] Tests fail to link on platforms with ntp_cv_gc_sections_runs=no <perlinger@ntp.org>
* [Bug 3599] Build fails on linux-m68k due to alignment issues <perlinger@ntp.org>
- added padding as suggested by John Paul Adrian Glaubitz
* [Bug 3594] ntpd discards messages coming through nmead <perlinger@ntp.org>
* [Bug 3593] ntpd discards silently nmea messages after the 5th string <perlinger@ntp.org>
* [Bug 3590] Update refclock_oncore.c to the new GPS date API <perlinger@ntp.org>
* [Bug 3585] Unity tests mix buffered and unbuffered output <perlinger@ntp.org>
- stdout+stderr are set to line buffered during test setup now
* [Bug 3583] synchronization error <perlinger@ntp.org>
- set clock to base date if system time is before that limit
* [Bug 3582] gpsdjson refclock fudgetime1 adjustment is doubled <perlinger@ntp.org>
* [Bug 3580] Possible bug ntpq-subs (NULL dereference in dogetassoc) <perlinger@ntp.org>
- Reported by Paulo Neves
* [Bug 3577] Update refclock_zyfer.c to the new GPS date API <perlinger@ntp.org>
- also updates for refclock_nmea.c and refclock_jupiter.c
* [Bug 3576] New GPS date function API <perlinger@ntp.org>
* [Bug 3573] nptdate: missleading error message <perlinger@ntp.org>
* [Bug 3570] NMEA driver docs: talker ID not mentioned, typo <perlinger@ntp.org>
* [Bug 3569] cleanup MOD_NANO/STA_NANO handling for 'ntpadjtimex()' <perlinger@ntp.org>
- sidekick: service port resolution in 'ntpdate'
* [Bug 3550] Reproducible build: Respect SOURCE_DATE_EPOCH <perlinger@ntp.org>
- applied patch by Douglas Royds
* [Bug 3542] ntpdc monlist parameters cannot be set <perlinger@ntp.org>
* [Bug 3533] ntpdc peer_info ipv6 issues <perlinger@ntp.org>
- applied patch by Gerry Garvey
* [Bug 3531] make check: test-decodenetnum fails <perlinger@ntp.org>
- try to harden 'decodenetnum()' against 'getaddrinfo()' errors
- fix wrong cond-compile tests in unit tests
* [Bug 3517] Reducing build noise <perlinger@ntp.org>
* [Bug 3516] Require tooling from this decade <perlinger@ntp.org>
- patch by Philipp Prindeville
* [Bug 3515] Refactor ntpdmain() dispatcher loop and group common code <perlinger@ntp.org>
- patch by Philipp Prindeville
* [Bug 3511] Get rid of AC_LANG_SOURCE() warnings <perlinger@ntp.org>
- patch by Philipp Prindeville
* [Bug 3510] Flatten out the #ifdef nesting in ntpdmain() <perlinger@ntp.org>
- partial application of patch by Philipp Prindeville
* [Bug 3491] Signed values of LFP datatypes should always display a sign
- applied patch by Gerry Garvey & fixed unit tests <perlinger@ntp.org>
* [Bug 3490] Patch to support Trimble Resolution Receivers <perlinger@ntp.org>
- applied (modified) patch by Richard Steedman
* [Bug 3473] RefID of refclocks should always be text format <perlinger@ntp.org>
- applied patch by Gerry Garvey (with minor formatting changes)
* [Bug 3132] Building 4.2.8p8 with disabled local libopts fails <perlinger@ntp.org>
- applied patch by Miroslav Lichvar
* [Bug 3094] ntpd trying to listen for broadcasts on a completely ipv6 network
<perlinger@ntp.org>
* [Bug 2420] ntpd doesn't run and exits with retval 0 when invalid user
is specified with -u <perlinger@ntp.org>
- monitor daemon child startup & propagate exit codes
* [Bug 1433] runtime check whether the kernel really supports capabilities
- (modified) patch by Kurt Roeckx <perlinger@ntp.org>
* Clean up sntp/networking.c:sendpkt() error message. <stenn@ntp.org>
* Provide more detail on unrecognized config file parser tokens. <stenn@ntp.org>
* Startup log improvements. <stenn@ntp.org>
* Update the copyright year.
* html/confopt.html: cleanup. <stenn@ntp.org>
---
(4.2.8p13) 2019/03/07 Released by Harlan Stenn <stenn@ntp.org>

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,111 @@
---
NTP 4.2.8p14 (Harlan Stenn <stenn@ntp.org>, 2020 Mar 03)
Focus: Security, Bug fixes, enhancements.
Severity: MEDIUM
This release fixes three vulnerabilities: a bug that causes causes an ntpd
instance that is explicitly configured to override the default and allow
ntpdc (mode 7) connections to be made to a server to read some uninitialized
memory; fixes the case where an unmonitored ntpd using an unauthenticated
association to its servers may be susceptible to a forged packet DoS attack;
and fixes an attack against a client instance that uses a single
unauthenticated time source. It also fixes 46 other bugs and addresses
4 other issues.
* [Sec 3610] process_control() should bail earlier on short packets. stenn@
- Reported by Philippe Antoine
* [Sec 3596] Highly predictable timestamp attack. <stenn@ntp.org>
- Reported by Miroslav Lichvar
* [Sec 3592] DoS attack on client ntpd <perlinger@ntp.org>
- Reported by Miroslav Lichvar
* [Bug 3637] Emit the version of ntpd in saveconfig. stenn@
* [Bug 3636] NMEA: combine time/date from multiple sentences <perlinger@ntp.org>
* [Bug 3635] Make leapsecond file hash check optional <perlinger@ntp.org>
* [Bug 3634] Typo in discipline.html, reported by Jason Harrison. stenn@
* [Bug 3628] raw DCF decoding - improve robustness with Zeller's congruence
- implement Zeller's congruence in libparse and libntp <perlinger@ntp.org>
* [Bug 3627] SIGSEGV on FreeBSD-12 with stack limit and stack gap <perlinger@ntp.org>
- integrated patch by Cy Schubert
* [Bug 3620] memory leak in ntpq sysinfo <perlinger@ntp.org>
- applied patch by Gerry Garvey
* [Bug 3619] Honour drefid setting in cooked mode and sysinfo <perlinger@ntp.org>
- applied patch by Gerry Garvey
* [Bug 3617] Add support for ACE III and Copernicus II receivers <perlinger@ntp.org>
- integrated patch by Richard Steedman
* [Bug 3615] accelerate refclock startup <perlinger@ntp.org>
* [Bug 3613] Propagate noselect to mobilized pool servers <stenn@ntp.org>
- Reported by Martin Burnicki
* [Bug 3612] Use-of-uninitialized-value in receive function <perlinger@ntp.org>
- Reported by Philippe Antoine
* [Bug 3611] NMEA time interpreted incorrectly <perlinger@ntp.org>
- officially document new "trust date" mode bit for NMEA driver
- restore the (previously undocumented) "trust date" feature lost with [bug 3577]
* [Bug 3609] Fixing wrong falseticker in case of non-statistic jitter <perlinger@ntp.org>
- mostly based on a patch by Michael Haardt, implementing 'fudge minjitter'
* [Bug 3608] libparse fails to compile on S11.4SRU13 and later <perlinger@ntp.org>
- removed ffs() and fls() prototypes as per Brian Utterback
* [Bug 3604] Wrong param byte order passing into record_raw_stats() in
ntp_io.c <perlinger@ntp.org>
- fixed byte and paramter order as suggested by wei6410@sina.com
* [Bug 3601] Tests fail to link on platforms with ntp_cv_gc_sections_runs=no <perlinger@ntp.org>
* [Bug 3599] Build fails on linux-m68k due to alignment issues <perlinger@ntp.org>
- added padding as suggested by John Paul Adrian Glaubitz
* [Bug 3594] ntpd discards messages coming through nmead <perlinger@ntp.org>
* [Bug 3593] ntpd discards silently nmea messages after the 5th string <perlinger@ntp.org>
* [Bug 3590] Update refclock_oncore.c to the new GPS date API <perlinger@ntp.org>
* [Bug 3585] Unity tests mix buffered and unbuffered output <perlinger@ntp.org>
- stdout+stderr are set to line buffered during test setup now
* [Bug 3583] synchronization error <perlinger@ntp.org>
- set clock to base date if system time is before that limit
* [Bug 3582] gpsdjson refclock fudgetime1 adjustment is doubled <perlinger@ntp.org>
* [Bug 3580] Possible bug ntpq-subs (NULL dereference in dogetassoc) <perlinger@ntp.org>
- Reported by Paulo Neves
* [Bug 3577] Update refclock_zyfer.c to the new GPS date API <perlinger@ntp.org>
- also updates for refclock_nmea.c and refclock_jupiter.c
* [Bug 3576] New GPS date function API <perlinger@ntp.org>
* [Bug 3573] nptdate: missleading error message <perlinger@ntp.org>
* [Bug 3570] NMEA driver docs: talker ID not mentioned, typo <perlinger@ntp.org>
* [Bug 3569] cleanup MOD_NANO/STA_NANO handling for 'ntpadjtimex()' <perlinger@ntp.org>
- sidekick: service port resolution in 'ntpdate'
* [Bug 3550] Reproducible build: Respect SOURCE_DATE_EPOCH <perlinger@ntp.org>
- applied patch by Douglas Royds
* [Bug 3542] ntpdc monlist parameters cannot be set <perlinger@ntp.org>
* [Bug 3533] ntpdc peer_info ipv6 issues <perlinger@ntp.org>
- applied patch by Gerry Garvey
* [Bug 3531] make check: test-decodenetnum fails <perlinger@ntp.org>
- try to harden 'decodenetnum()' against 'getaddrinfo()' errors
- fix wrong cond-compile tests in unit tests
* [Bug 3517] Reducing build noise <perlinger@ntp.org>
* [Bug 3516] Require tooling from this decade <perlinger@ntp.org>
- patch by Philipp Prindeville
* [Bug 3515] Refactor ntpdmain() dispatcher loop and group common code <perlinger@ntp.org>
- patch by Philipp Prindeville
* [Bug 3511] Get rid of AC_LANG_SOURCE() warnings <perlinger@ntp.org>
- patch by Philipp Prindeville
* [Bug 3510] Flatten out the #ifdef nesting in ntpdmain() <perlinger@ntp.org>
- partial application of patch by Philipp Prindeville
* [Bug 3491] Signed values of LFP datatypes should always display a sign
- applied patch by Gerry Garvey & fixed unit tests <perlinger@ntp.org>
* [Bug 3490] Patch to support Trimble Resolution Receivers <perlinger@ntp.org>
- applied (modified) patch by Richard Steedman
* [Bug 3473] RefID of refclocks should always be text format <perlinger@ntp.org>
- applied patch by Gerry Garvey (with minor formatting changes)
* [Bug 3132] Building 4.2.8p8 with disabled local libopts fails <perlinger@ntp.org>
- applied patch by Miroslav Lichvar
* [Bug 3094] ntpd trying to listen for broadcasts on a completely ipv6 network
<perlinger@ntp.org>
* [Bug 2420] ntpd doesn't run and exits with retval 0 when invalid user
is specified with -u <perlinger@ntp.org>
- monitor daemon child startup & propagate exit codes
* [Bug 1433] runtime check whether the kernel really supports capabilities
- (modified) patch by Kurt Roeckx <perlinger@ntp.org>
* Clean up sntp/networking.c:sendpkt() error message. <stenn@ntp.org>
* Provide more detail on unrecognized config file parser tokens. <stenn@ntp.org>
* Startup log improvements. <stenn@ntp.org>
* Update the copyright year.
---
NTP 4.2.8p13 (Harlan Stenn <stenn@ntp.org>, 2019 Mar 07)

View File

@ -1215,6 +1215,9 @@
/* Define if C99-compliant `vsnprintf' is available. */
#undef HAVE_VSNPRINTF
/* Define to 1 if you have the `waitpid' function. */
#undef HAVE_WAITPID
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H

43
contrib/ntp/configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for ntp 4.2.8p13.
# Generated by GNU Autoconf 2.69 for ntp 4.2.8p14.
#
# Report bugs to <http://bugs.ntp.org./>.
#
@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='ntp'
PACKAGE_TARNAME='ntp'
PACKAGE_VERSION='4.2.8p13'
PACKAGE_STRING='ntp 4.2.8p13'
PACKAGE_VERSION='4.2.8p14'
PACKAGE_STRING='ntp 4.2.8p14'
PACKAGE_BUGREPORT='http://bugs.ntp.org./'
PACKAGE_URL='http://www.ntp.org./'
@ -1617,7 +1617,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures ntp 4.2.8p13 to adapt to many kinds of systems.
\`configure' configures ntp 4.2.8p14 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1687,7 +1687,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of ntp 4.2.8p13:";;
short | recursive ) echo "Configuration of ntp 4.2.8p14:";;
esac
cat <<\_ACEOF
@ -1930,7 +1930,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
ntp configure 4.2.8p13
ntp configure 4.2.8p14
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -2639,7 +2639,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by ntp $as_me 4.2.8p13, which was
It was created by ntp $as_me 4.2.8p14, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -3640,7 +3640,7 @@ fi
# Define the identity of the package.
PACKAGE='ntp'
VERSION='4.2.8p13'
VERSION='4.2.8p14'
cat >>confdefs.h <<_ACEOF
@ -26091,6 +26091,17 @@ fi
done
for ac_func in waitpid
do :
ac_fn_c_check_func "$LINENO" "waitpid" "ac_cv_func_waitpid"
if test "x$ac_cv_func_waitpid" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_WAITPID 1
_ACEOF
fi
done
case "$host" in
*-convex-*)
for ac_header in /sys/sync/queue.h /sys/sync/sema.h
@ -33331,6 +33342,10 @@ case "$ntp_ept:$cross:$host" in
no:0:*-*-solaris*) ;;
*) ntp_test_ntp_restrict="yes" ;;
esac
case "$ntp_cv_gc_sections_runs" in
no) ntp_test_ntp_restrict="no" ;;
* ) ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_test_ntp_restrict" >&5
$as_echo "$ntp_test_ntp_restrict" >&6; }
if test x$ntp_test_ntp_restrict = xyes; then
@ -33350,6 +33365,10 @@ case "$ntp_ept:$cross:$host" in
no:0:*-*-solaris*) ;;
*) ntp_test_ntp_scanner="yes" ;;
esac
case "$ntp_cv_gc_sections_runs" in
no) ntp_test_ntp_scanner="no" ;;
* ) ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_test_ntp_scanner" >&5
$as_echo "$ntp_test_ntp_scanner" >&6; }
if test x$ntp_test_ntp_scanner = xyes; then
@ -33369,6 +33388,10 @@ case "$ntp_ept:$cross:$host" in
no:0:*-*-solaris*) ;;
*) ntp_test_ntp_signd="yes" ;;
esac
case "$ntp_cv_gc_sections_runs" in
no) ntp_test_ntp_signd="no" ;;
* ) ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_test_ntp_signd" >&5
$as_echo "$ntp_test_ntp_signd" >&6; }
if test x$ntp_test_ntp_signd = xyes; then
@ -34151,7 +34174,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by ntp $as_me 4.2.8p13, which was
This file was extended by ntp $as_me 4.2.8p14, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -34218,7 +34241,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
ntp config.status 4.2.8p13
ntp config.status 4.2.8p14
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@ -1,7 +1,7 @@
dnl NTP top-level configure.ac -*- Autoconf -*-
dnl
m4_include([sntp/m4/version.m4])
AC_PREREQ([2.61])
AC_PREREQ([2.68])
AC_INIT(
[ntp],
[VERSION_NUMBER],
@ -42,13 +42,10 @@ ntp_configure_cache_version=20120806
NTP_CACHEVERSION([main], [$ntp_configure_cache_version])
AM_INIT_AUTOMAKE([1.10 foreign -Wall -Wno-gnu])
AM_INIT_AUTOMAKE([1.15 foreign -Wall -Wno-gnu])
AM_SILENT_RULES([yes])
dnl AM_SILENT_RULES req. automake 1.11. [yes] defaults V=0
m4_ifdef(
[AM_SILENT_RULES],
[AM_SILENT_RULES([yes])]
)
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
dnl the 'build' machine is where we run configure and compile
@ -382,6 +379,7 @@ case "$host" in
esac
AC_CHECK_HEADERS([sys/stat.h sys/stream.h stropts.h sys/stropts.h sys/syssgi.h])
AC_CHECK_HEADERS([sys/systune.h sys/termios.h sys/tpro.h sys/wait.h])
AC_CHECK_FUNCS([waitpid])
case "$host" in
*-convex-*)
AC_CHECK_HEADERS([/sys/sync/queue.h /sys/sync/sema.h])

View File

@ -55,8 +55,10 @@ the <a href="accopt.html">Access Control Support</a> page.</p>
</dl>
</dd>
<dt id="restrict"><tt>restrict [-4 | -6] default [ippeerlimit <i>num</i>]
[<i>flag</i>][...]<br> restrict source [ippeerlimit <i>num</i>]
[<i>flag</i>][...]<br> restrict <i>address</i> [mask <i>mask</i>]
[<i>flag</i>][...]</tt></dt>
<dt><tt>restrict source [ippeerlimit <i>num</i>]
[<i>flag</i>][...]</tt></dt>
<dt><tt>restrict <i>address</i> [mask <i>mask</i>]
[ippeerlimit <i>num</i>] [<i>flag</i>][...]</tt></dt>
<dd>The <tt><i>address</i></tt> argument expressed in IPv4 or IPv6 numeric
address form is the address of a host or network. Alternatively,
@ -168,6 +170,9 @@ the <a href="accopt.html">Access Control Support</a> page.</p>
UDP port (123). A restrict line containing <tt>ntpport</tt> is
considered more specific than one with the same address and mask,
but lacking <tt>ntpport</tt>.</dd>
<dt><tt>serverresponse fuzz</tt></dt>
<dd>When reponding to server requests, fuzz the low order bits of
the <tt>reftime</tt>.</dd>
<dt><tt>version</tt></dt>
<dd>Deny packets that do not match the current NTP version.</dd>
</dl>

View File

@ -10,7 +10,7 @@
<h3>Reference Clock Commands and Options</h3>
<img src="pic/stack1a.jpg" alt="gif" align="left">Master Time Facility at the <a href="http://www.eecis.udel.edu/%7emills/lab.html">UDel Internet Research Laboratory</a>
<p>Last update:
<!-- #BeginDate format:En2m -->11-Sep-2010 05:55<!-- #EndDate -->
<!-- #BeginDate format:En2m -->26-Sep-2019 06:34<!-- #EndDate -->
UTC</p>
<br clear="left">
<h4>Related Links</h4>
@ -50,6 +50,22 @@
<dd>Specifies an ASCII string of from one to four characters which defines the reference identifier used by the driver. This string overrides the default identifier ordinarily assigned by the driver itself.</dd>
<dt><tt>flag1 flag2 flag3 flag4</tt></dt>
<dd>These four flags are used for customizing the clock driver. The interpretation of these values, and whether they are used at all, is a function of the particular driver. However, by convention <tt>flag4</tt> is used to enable recording monitoring data to the <tt>clockstats</tt> file configured with the <tt>filegen</tt> command. Additional information on the <tt>filegen</tt> command is on the <a href="monopt.html">Monitoring Options</a> page.</dd>
<dt><tt>minjitter <i>secs</i></tt></dt>
<dd>If the source has a jitter that cannot be sensibly estimated, because
it is not statistic jitter, the source will be detected as falseticker
sooner or later. This has been observed e.g. with the serial data of
certain GPS receivers. Enforcing a minimal jitter value avoids a too
low estimation, keeping the clock in the zoo while still detecting
higher jitter.
</dd><dd> Note: this changes the refclock samples and ends up in the
clock dispersion, not the clock jitter, despite being called jitter. To
see the modified values, check the NTP clock variable "filtdisp", not
"jitter".
</dd><dd>The falseticker problem can also be avoided by increasing <tt>tos
mindist</tt>, which extends the intersection interval, but that affects
the root dispersion and is intended for the case of multiple reference
clocks with reliable jitter that do not intersect otherwise.
</dd>
</dl>
</dd>
</dl>

View File

@ -13,7 +13,7 @@
Walt Kelly</a>
<p>The chicken is getting configuration advice.</p>
<p>Last update:
<!-- #BeginDate format:En2m -->24-Jul-2018 07:27<!-- #EndDate -->
<!-- #BeginDate format:En2m -->13-Feb-2020 10:08<!-- #EndDate -->
UTC</p>
<br clear="left">
<h4>Related Links</h4>
@ -33,12 +33,12 @@ Walt Kelly</a>
support for the IPv6 address family is generated in addition to the default IPv4 address family. IPv6 addresses can be identified by the presence of colons &quot;:&quot; in the address field. IPv6 addresses can be used almost everywhere where IPv4 addresses can be used, with the exception of reference clock addresses, which are always IPv4. Note that in contexts where a host name is expected, a <tt>-4</tt> qualifier preceding the host name forces DNS resolution to the IPv4 namespace, while a <tt>-6</tt> qualifier forces DNS resolution to the IPv6 namespace.</p>
<h4 id="command">Server Commands</h4>
<p>Unless noted otherwise, further information about these commands is on the <a href="assoc.html">Association Management</a> page.</p><dl>
<dt id="server"><tt>server <i>address</i> [options ...]</tt><br>
<tt>peer <i>address</i> [options ...]</tt><br>
<tt>broadcast <i>address</i> [options ...]</tt><br>
<tt>manycastclient <i>address</i> [options ...]</tt><br>
<tt>pool <i>address</i> [options ...]</tt><br>
<tt>unpeer [<i>address</i> | <i>associd</i>]</tt></dt>
<dt id="server"><tt>server <i>address</i> [options ...]</tt></dt>
<dt><tt>peer <i>address</i> [options ...]</tt></dt>
<dt><tt>broadcast <i>address</i> [options ...]</tt></dt>
<dt><tt>manycastclient <i>address</i> [options ...]</tt></dt>
<dt><tt>pool <i>address</i> [options ...]</tt></dt>
<dt><tt>unpeer [<i>address</i> | <i>associd</i>]</tt></dt>
<dd>These commands specify the remote server name or address to be used and the mode in which to operate. The <i>address</i> can be either a DNS name or a IPv4 or IPv6 address in standard notation. In general, multiple commands of each type can be used for different server and peer addresses or multicast groups.
<dl>
<dt><tt>server</tt></dt>
@ -67,8 +67,14 @@ Walt Kelly</a>
<dt><tt>ident</tt> <em><tt>group</tt></em></dt>
<dd>Specify the group name for the association. See the <a href="autokey.html">Autokey Public-Key Authentication</a> page for further information.</dd>
<dt><tt>key</tt> <i><tt>key</tt></i></dt>
<dd>Send and receive packets authenticated by the symmetric key scheme described in the <a href="authentic.html">Authentication Support</a> page. The <i><tt>key</tt></i> specifies the key identifier with values from 1 to 65535, inclusive. This option is mutually exclusive with the <tt>autokey</tt> option.</dd> <dt><tt>minpoll <i>minpoll<br>
</i></tt><tt>maxpoll <i>maxpoll</i></tt></dt>
<dd>Send and receive packets authenticated by the symmetric key scheme
described in the <a href="authentic.html">Authentication Support</a>
page. The <i><tt>key</tt></i> specifies the key identifier with values
from 1 to 65535, inclusive. This option is mutually exclusive with
the <tt>autokey</tt>
option.</dd>
<dt><tt>minpoll <i>minpoll</i></tt></dt>
<dt><tt>maxpoll <i>maxpoll</i></tt></dt>
<dd>These options specify the minimum and maximum poll intervals for NTP messages, in seconds as a power of two. The maximum poll interval defaults to 10 (1024 s), but can be increased by the <tt>maxpoll</tt> option to an upper limit of 17 (36 hr). The minimum poll interval defaults to 6 (64 s), but can be decreased by the <tt>minpoll</tt> option to a lower limit of 3 (8 s). Additional information about this option is on the <a href="poll.html">Poll Program</a> page.</dd>
<dt><tt>mode <i>option</i></tt></dt>
<dd>Pass the <tt><i>option</i></tt> to a reference clock driver, where <tt><i>option</i></tt> is an integer in the range from 0 to 255, inclusive. This option is valid only with type r addresses.</dd>
@ -87,6 +93,13 @@ Walt Kelly</a>
outgoing NTP packets. Versions 1-4 are the choices, with version 4 the default.</dd>
<dt><tt>xleave</tt></dt>
<dd>Operate in interleaved mode (symmetric and broadcast modes only). Further information is on the <a href="xleave.html">NTP Interleaved Modes</a> page.</dd>
<dt><tt>xmtnonce</tt></dt>
<dd>Allowed in the server and pool modes, this flag causes the
client to put a random number nonce in the transmit timestamp of
its outgoing packet. Since the server will reply copying the
incoming transmit timestamp to the outgoing origin timestamp, this
flag provides extra security for the loopback test, at the expense
of the server having no idea what time the client thinks it is.</dd>
</dl>
<h4 id="aux">Auxiliary Commands</h4>
<dl>

View File

@ -3,14 +3,13 @@
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Copyright Notice</title>
<!-- Changed by: Harlan Stenn, 10-Mar-2014 -->
<link href="scripts/style.css" type="text/css" rel="stylesheet">
</head>
<body>
<h3>Copyright Notice</h3>
<img src="pic/sheepb.jpg" alt="jpg" align="left"> "Clone me," says Dolly sheepishly.
<p>Last update:
<!-- #BeginDate format:En2m -->2-Jan-2017 11:58<!-- #EndDate -->
<!-- #BeginDate format:En2m -->4-Feb-2020 23:47<!-- #EndDate -->
UTC</p>
<br clear="left">
</p>
@ -39,7 +38,7 @@
<pre>
***********************************************************************
* *
* Copyright (c) Network Time Foundation 2011-2017 *
* Copyright (c) Network Time Foundation 2011-2020 *
* *
* All Rights Reserved *
* *

View File

@ -4,12 +4,13 @@
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Clock Discipline Algorithm</title>
<!-- Changed by: stenn, 03-Jan-2020 -->
<link href="scripts/style.css" type="text/css" rel="stylesheet">
</head>
<body>
<h3>Clock Discipline Algorithm</h3>
<p>Last update:
<!-- #BeginDate format:En2m -->10-Mar-2014 05:03<!-- #EndDate -->
<!-- #BeginDate format:En2m -->3-Jan-2020 02:12<!-- #EndDate -->
UTC</p>
<h4>Table of Contents</h4>
<ul>
@ -20,29 +21,29 @@
</ul>
<hr>
<h4 id="intro">General Overview</h4>
<p>At the heart of the NTP specification and reference implementation is the clock discipline algorithm, which is best described as an adaptive parameter, hybrid phase/frequency-lock feedback loop. It is an intricately crafted algorithm that automatically adapts for optimum performance while minimizing network overhead. Operation is in two modes, phase-lock loop (PLL), which is used at poll intervals below the Allan intercept, by default 2048 s, and frequency-lock loop (FLL), which is used above that.</p>
<p>At the heart of the NTP specification and reference implementation is the clock discipline algorithm, which is best described as an adaptive parameter, hybrid phase/frequency-lock feedback loop. It is an intricately crafted algorithm that automatically adapts for optimum performance while minimizing network overhead. Operation is in two modes, phase-lock loop (PLL), which is used at poll intervals below the Allan intercept, by default 2048 s, and frequency-lock loop (FLL), which is used above that.</p>
<div align="center"> <img src="pic/discipline.gif" alt="gif">
<p>Figure 1. Clock Discipline Algorithm</p>
</div>
<h4 id="pll">Clock Discipline Operations</h4>
<p>A block diagram of the clock discipline is shown in Figure 1. The timestamp of a reference clock or remote server is compared with the timestamp of the system clock, represented as a variable frequency oscillator (VFO), to produce a raw offset sample <em>V<sub>d</sub></em>. Offset samples are processed by the clock filter to produce a filtered update <em>V<sub>s</sub></em>. The loop filter implements a type-2 proportional-integrator controller (PIC). The PIC can minimize errors in both time and frequency using predictors <em>x</em> and <em>y</em>, respectively. The clock adjust process samples these predictors once each second for the daemon discipline or once each tick interrupt for the kernel discipline to produce the system clock update <em>V<sub>c</sub></em>.</p>
<p>In PLL mode the frequency predictor is an integral of the offset over past updates, while the phase predictor is the offset amortized over time in order to avoid setting the clock backward. In FLL mode the phase predictor is not used, while the frequency predictor is similar to the NIST <em>lockclock</em> algorithm. In this algorithm, the frequency predictor is computed as a fraction of the current offset divided by the time since the last update in order to minimize the offset at the next update.</p>
<p>The discipline response in PLL mode is determined by the <em>time constant</em>, which results in a &quot;stiffness&quot; depending on the jitter of the available sources and the wander of the system clock oscillator. The scaled time constant is also used as the poll interval described on the <a href="poll.html">Poll Program</a> page. However, in NTP symmetric mode, each peer manages its own poll interval and the two might not be the same. In such cases either peer uses the minimum of its own poll interval and that of the other peer, which is included in the NTP packet header.</p>
<p>A block diagram of the clock discipline is shown in Figure 1. The timestamp of a reference clock or remote server is compared with the timestamp of the system clock, represented as a variable frequency oscillator (VFO), to produce a raw offset sample <em>V<sub>d</sub></em>. Offset samples are processed by the clock filter to produce a filtered update <em>V<sub>s</sub></em>. The loop filter implements a type-2 proportional-integrator controller (PIC). The PIC can minimize errors in both time and frequency using predictors <em>x</em> and <em>y</em>, respectively. The clock adjust process samples these predictors once each second for the daemon discipline or once each tick interrupt for the kernel discipline to produce the system clock update <em>V<sub>c</sub></em>.</p>
<p>In PLL mode the frequency predictor is an integral of the offset over past updates, while the phase predictor is the offset amortized over time in order to avoid setting the clock backward. In FLL mode the phase predictor is not used, while the frequency predictor is similar to the NIST <em>lockclock</em> algorithm. In this algorithm, the frequency predictor is computed as a fraction of the current offset divided by the time since the last update in order to minimize the offset at the next update.</p>
<p>The discipline response in PLL mode is determined by the <em>time constant</em>, which results in a &quot;stiffness&quot; depending on the jitter of the available sources and the wander of the system clock oscillator. The scaled time constant is also used as the poll interval described on the <a href="poll.html">Poll Program</a> page. However, in NTP symmetric mode, each peer manages its own poll interval and the two might not be the same. In such cases either peer uses the minimum of its own poll interval and that of the other peer, which is included in the NTP packet header.</p>
<h4 id="loop">Loop Dynamics</h4>
<p> It is necessary to verify that the clock discipline algorithm is stable and satisfies the Nyquist criterion, which requires that the sampling rate be at least twice the bandwidth. In this case the bandwidth can be approximated by the reciprocal of the time constant. In the NTP specification and reference implementation, time constants and poll intervals are expressed as exponents of 2. By construction, the time constant exponent is five times the poll interval exponent. Thus, the default poll exponent of 6 corresponds to a poll interval of 64 s and a time constant of 2048 s. A change in the poll interval changes the time constant by a corresponding amount.. The Nyquist criterion requires the sample interval to be not more than half the time constant or 1024 s. The clock filter guarantees at least one sample in eight poll intervals, so the sample interval is not more than 512 s. This would be described as oversampling by a factor of two. Finally, the PLL parameters have been chosen for a damping factor of 2, which results in a much faster risetime than with critical damping, but results in modest overshoot of 6 percent.</p>
<p> It is important to understand how the dynamics of the PLL are affected by the time constant and poll interval. At the default poll interval of 64 s and a step offset change of 100 ms, the time response crosses zero in about 50 min and overshoots about 6 ms, as per design. Ordinarily, a step correction would causes a temporary frequency surge of about 5 PPM, which along with the overshoot slowly dissipates over a few hours.</p>
<p>However, the clock state machine used with the discipline algorithm avoids this transient at startup. It does this using a previously saved frequency file, if present, or by measuring the oscillator frequency, if not. It then quickly amortizes the residual offset at startup without affecting the oscillator frequency. In this way the offset error is less than 0.5 ms within 5 min, if the file is present, and within 10 min if not. See the <a href="clock.html">Clock State Machine</a> page for further details.</p>
<p>Since the PLL is linear, the response with different offset step amplitudes and poll intervals has the same characteristic shape, but scaled differently in amplitude and time. The response scales exactly with step amplitude, so that the response to a 10-ms step has the same shape as at 64 s, but with amplitude compressed by one-tenth. The response scales exactly with poll interval, so that response at a poll interval of 8 s has the same shape as at 64 s, but with time compressed by one-eighth.</p>
<p>The optimum time constant, and thus the poll interval, depends on the network time jitter and the oscillator frequency wander. Errors due to jitter decrease as the time constant increases, while errors due to wander decrease as the time constant decreases. For typical Internet paths, the two error characteristics intersect at a point called the <em>Allan intercept</em>, which represents the optimum time constant. With a compromise Allan intercept of 2048 s, the optimum poll interval is about 64 s, which corresponds to a compromise poll exponent of 6. For fast LANs with modern computers, the Allan intercept is somewhat lower at around 512 s, so a compromise poll exponent of 4 (16 s) is appropriate. An intricate, heuristic algorithm is used to manage the actual poll interval within a specified range. Details are on the <a href="poll.html">Poll Program</a> page.</p>
<p>In the NTPv4 specification and reference implementation a state machine is used to manage the system clock under exceptional conditions, as when the daemon is first started or when encountering severe network congestion. In extreme cases not likely to be encountered in normal operation, the system time can be stepped forward or backward more than 128 ms. Further details are on the <a href="clock.html">Clock State Machine</a> page.</p>
<p> It is necessary to verify that the clock discipline algorithm is stable and satisfies the Nyquist criterion, which requires that the sampling rate be at least twice the bandwidth. In this case the bandwidth can be approximated by the reciprocal of the time constant. In the NTP specification and reference implementation, time constants and poll intervals are expressed as exponents of 2. By construction, the time constant exponent is five times the poll interval exponent. Thus, the default poll exponent of 6 corresponds to a poll interval of 64 s and a time constant of 2048 s. A change in the poll interval changes the time constant by a corresponding amount.. The Nyquist criterion requires the sample interval to be not more than half the time constant or 1024 s. The clock filter guarantees at least one sample in eight poll intervals, so the sample interval is not more than 512 s. This would be described as oversampling by a factor of two. Finally, the PLL parameters have been chosen for a damping factor of 2, which results in a much faster risetime than with critical damping, but results in modest overshoot of 6 percent.</p>
<p> It is important to understand how the dynamics of the PLL are affected by the time constant and poll interval. At the default poll interval of 64 s and a step offset change of 100 ms, the time response crosses zero in about 50 min and overshoots about 6 ms, as per design. Ordinarily, a step correction would causes a temporary frequency surge of about 5 PPM, which along with the overshoot slowly dissipates over a few hours.</p>
<p>However, the clock state machine used with the discipline algorithm avoids this transient at startup. It does this using a previously saved frequency file, if present, or by measuring the oscillator frequency, if not. It then quickly amortizes the residual offset at startup without affecting the oscillator frequency. In this way the offset error is less than 0.5 ms within 5 min, if the file is present, and within 10 min if not. See the <a href="clock.html">Clock State Machine</a> page for further details.</p>
<p>Since the PLL is linear, the response with different offset step amplitudes and poll intervals has the same characteristic shape, but scaled differently in amplitude and time. The response scales exactly with step amplitude, so that the response to a 10-ms step has the same shape as at 64 s, but with amplitude compressed by one-tenth. The response scales exactly with poll interval, so that response at a poll interval of 8 s has the same shape as at 64 s, but with time compressed by one-eighth.</p>
<p>The optimum time constant, and thus the poll interval, depends on the network time jitter and the oscillator frequency wander. Errors due to jitter decrease as the time constant increases, while errors due to wander decrease as the time constant decreases. For typical Internet paths, the two error characteristics intersect at a point called the <em>Allan intercept</em>, which represents the optimum time constant. With a compromise Allan intercept of 2048 s, the optimum poll interval is about 64 s, which corresponds to a compromise poll exponent of 6. For fast LANs with modern computers, the Allan intercept is somewhat lower at around 512 s, so a compromise poll exponent of 4 (16 s) is appropriate. An intricate, heuristic algorithm is used to manage the actual poll interval within a specified range. Details are on the <a href="poll.html">Poll Program</a> page.</p>
<p>In the NTPv4 specification and reference implementation a state machine is used to manage the system clock under exceptional conditions, as when the daemon is first started or when encountering severe network congestion. In extreme cases not likely to be encountered in normal operation, the system time can be stepped forward or backward more than 128 ms. Further details are on the <a href="clock.html">Clock State Machine</a> page.</p>
<h4 id="house">Clock Initialization and Management</h4>
<p>If left running continuously, an NTP client on a fast LAN in a home or office environment can maintain synchronization nominally within one millisecond. When the ambient temperature variations are less than a degree Celsius, the clock oscillator frequency is disciplined to within one part per million (PPM), even when the clock oscillator native frequency offset is 100 PPM or more.</p>
<p> For laptops and portable devices when the power is turned off, the battery backup clock offset error can increase as much as one second per day. When power is restored after several hours or days, the clock offset and oscillator frequency errors must be resolved by the clock discipline algorithm, but this can take several hours without specific provisions.</p>
<p> The provisions described in this section insure that, in all but pathological situations, the startup transient is suppressed to within nominal levels in no more than five minutes after a warm start or ten minutes after a cold start. Following is a summary of these provisions. A detailed discussion of these provisions is on the <a href="clock.html">Clock State Machine</a> page.</p>
<p> The reference implementation measures the clock oscillator frequency and updates a frequency file at intervals of one hour or more, depending on the measured frequency wander. This design is intended to minimize write cycles in NVRAM that might be used in a laptop or portable device. In a warm start, the frequency is initialized from this file, which avoids a possibly lengthy convergence time. In a cold start when no frequency file is available, the reference implementation first measures the oscillator frequency over a five-min interval. This generally results in a residual frequency error less than 1 PPM. The measurement interval can be changed using the <tt>stepout</tt> option of the <a href="miscopt.html#tinker"><tt>tinker</tt></a> command.</p>
<p>In order to reduce the clock offset error at restart, the reference implementation mext disables oscillator frequency discipline and enables clock offset discipline with a small time constant. This is designed to quickly reduce the clock offset error without causing a frequency surge. This configuration is continued for an interval of five-min, after which the clock offset error is usually no more than a millisecond. The measurement interval can be changed using the <tt>stepout</tt> option of the <a href="miscopt.html#tinker"><tt>tinker</tt></a> command.</p>
<p>Another concern at restart is the time necessary for the select and cluster algorithms to refine and validate the initial clock offset estimate. Normally, this takes several updates before setting the system clock. As the default minimum poll interval in most configurations is about one minute, it can take several minutes before setting the system clock. The <tt>iburst</tt> option of the <a href="confopt.html#burst"><tt>server</tt></a> command changes the behavior at restart and is recommended for client/server configurations. When this option is enabled, the client sends a volley of six requests at intervals of two seconds. This usually insures a reliable estimate is available in about ten seconds before setting the clock. Once this initial volley is complete, the procedures described above are executed.</p>
<p>As a result of the above considerations, when a backup source, such as the local clock driver, ACTS modem driver or orphan mode is included in the system configuration, it may happen that one or more of them are selectable before one or more of the regular sources are selectable. When backup sources are included in the configuration, the reference implementation waits an interval of several minutes without regular sources before switching to backup sources. This is generally enough to avoid startup transients due to premature switching to backup sources. The interval can be changed using the <tt>orphanwait</tt> option of the <a href="miscopt.html#tos"><tt>tos</tt></a> command.</p>
<p>If left running continuously, an NTP client on a fast LAN in a home or office environment can maintain synchronization nominally within one millisecond. When the ambient temperature variations are less than a degree Celsius, the clock oscillator frequency is disciplined to within one part per million (PPM), even when the clock oscillator native frequency offset is 100 PPM or more.</p>
<p> For laptops and portable devices when the power is turned off, the battery backup clock offset error can increase as much as one second per day. When power is restored after several hours or days, the clock offset and oscillator frequency errors must be resolved by the clock discipline algorithm, but this can take several hours without specific provisions.</p>
<p> The provisions described in this section insure that, in all but pathological situations, the startup transient is suppressed to within nominal levels in no more than five minutes after a warm start or ten minutes after a cold start. Following is a summary of these provisions. A detailed discussion of these provisions is on the <a href="clock.html">Clock State Machine</a> page.</p>
<p> The reference implementation measures the clock oscillator frequency and updates a frequency file at intervals of one hour or more, depending on the measured frequency wander. This design is intended to minimize write cycles in NVRAM that might be used in a laptop or portable device. In a warm start, the frequency is initialized from this file, which avoids a possibly lengthy convergence time. In a cold start when no frequency file is available, the reference implementation first measures the oscillator frequency over a five-min interval. This generally results in a residual frequency error less than 1 PPM. The measurement interval can be changed using the <tt>stepout</tt> option of the <a href="miscopt.html#tinker"><tt>tinker</tt></a> command.</p>
<p>In order to reduce the clock offset error at restart, the reference implementation next disables oscillator frequency discipline and enables clock offset discipline with a small time constant. This is designed to quickly reduce the clock offset error without causing a frequency surge. This configuration is continued for an interval of five-min, after which the clock offset error is usually no more than a millisecond. The measurement interval can be changed using the <tt>stepout</tt> option of the <a href="miscopt.html#tinker"><tt>tinker</tt></a> command.</p>
<p>Another concern at restart is the time necessary for the select and cluster algorithms to refine and validate the initial clock offset estimate. Normally, this takes several updates before setting the system clock. As the default minimum poll interval in most configurations is about one minute, it can take several minutes before setting the system clock. The <tt>iburst</tt> option of the <a href="confopt.html#burst"><tt>server</tt></a> command changes the behavior at restart and is recommended for client/server configurations. When this option is enabled, the client sends a volley of six requests at intervals of two seconds. This usually insures a reliable estimate is available in about ten seconds before setting the clock. Once this initial volley is complete, the procedures described above are executed.</p>
<p>As a result of the above considerations, when a backup source, such as the local clock driver, ACTS modem driver or orphan mode is included in the system configuration, it may happen that one or more of them are selectable before one or more of the regular sources are selectable. When backup sources are included in the configuration, the reference implementation waits an interval of several minutes without regular sources before switching to backup sources. This is generally enough to avoid startup transients due to premature switching to backup sources. The interval can be changed using the <tt>orphanwait</tt> option of the <a href="miscopt.html#tos"><tt>tos</tt></a> command.</p>
<hr>
<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
</body>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Generic NMEA GPS Receiver</title>
<!-- Changed by: Harlan &, 31-Mar-2014 -->
<!-- Changed by: Pearly &, 04-Feb-2019 -->
<link href="scripts/style.css" type="text/css" rel="stylesheet">
<style type="text/css">
table.dlstable { font-size:85%; }
@ -13,7 +13,7 @@
<body>
<h3>Generic NMEA GPS Receiver</h3>
<p>Last update:
<!-- #BeginDate format:En2m -->31-Mar-2014 03:55<!-- #EndDate -->
<!-- #BeginDate format:En2m -->13-Jan-2020 07:12<!-- #EndDate -->
UTC</p>
<hr>
<h4>Synopsis</h4>
@ -41,6 +41,9 @@
second insertion in UTC.&nbsp; To avoid problems mixing UTC and GPS
timescales, the driver disables processing of UTC sentences
once <tt>$GPZDG</tt> is received.
<br>
<strong>Caveat:</strong> Please see <a href="#talkerids">Talker
IDs</a> when using non-GPS or multi-system receivers.
</p>
<p>
The driver expects the receiver to be set up to transmit at least one
@ -80,7 +83,14 @@
</tr><tr>
<td class="ttf">$GPZDG,GPSTIME,DD,MM,YYYY,AA.BB,V*CS&lt;cr&gt;&lt;lf&gt;</td>
<td>Accord</td>
</tr>
</tr><tr>
</tr><tr>
<td class="ttf">$PGRMF,gpsWk,gpsTow,DATE,UTC,LEAPS,LAT,LAT_REF,LON,LON_REF,TYPE,MODE,SPD,HDOP,TDOP*CS&lt;cr&gt;&lt;lf&gt;</td>
<td>Garmin</td>
</tr><tr>
<td class="ttf">$PUBX,04,UTC,DATE,utcTow,utcWk,LEAPS,clkBias,clkDrift,tpGran,*CS&lt;cr&gt;&lt;lf&gt;</td>
<td>UBLOX</td>
</tr>
</tbody></table></p>
<p><table class="dlstable" border="1">
@ -91,59 +101,17 @@
</tr>
<tr>
<td class="ttf">UTC</td>
<td>Time of day on UTC timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.fff])</td>
</tr><tr>
<td class="ttf">POS_STAT</td>
<td>Position status. (A = Data valid, V = Data invalid)</td>
</tr><tr>
<td class="ttf">LAT</td>
<td>Latitude (llll.ll)</td>
</tr><tr>
<td class="ttf">LAT_REF</td>
<td>Latitude direction. (N = North, S = South)</td>
</tr><tr>
<td class="ttf">LON</td>
<td>Longitude (yyyyy.yy)</td>
</tr><tr>
<td class="ttf">LON_REF</td>
<td>Longitude direction (E = East, W = West)</td>
</tr><tr>
<td class="ttf">SPD</td>
<td>Speed over ground. (knots) (x.x)</td>
</tr><tr>
<td class="ttf">HDG</td>
<td>Heading/track made good (degrees True) (x.x)</td>
</tr><tr>
<td class="ttf">DATE</td>
<td>Date (ddmmyy)</td>
</tr><tr>
<td class="ttf">MAG_VAR</td>
<td>Magnetic variation (degrees) (x.x)</td>
</tr><tr>
<td class="ttf">MAG_REF</td>
<td>Magnetic variation (E = East, W = West)</td>
</tr><tr>
<td class="ttf">FIX_MODE</td>
<td>Position Fix Mode (0 = Invalid, &gt;0 = Valid)</td>
</tr><tr>
<td class="ttf">SAT_USED</td>
<td>Number of Satellites used in solution</td>
</tr><tr>
<td class="ttf">HDOP</td>
<td>Horizontal Dilution of Precision</td>
</tr><tr>
<td class="ttf">ALT</td>
<td>Antenna Altitude</td>
</tr><tr>
<td class="ttf">ALT_UNIT</td>
<td>Altitude Units (Metres/Feet)</td>
</tr><tr>
<td class="ttf">GEO</td>
<td>Geoid/Elipsoid separation</td>
<td class="ttf">DATE</td>
<td>Date (ddmmyy)</td>
</tr><tr>
<td class="ttf">G_UNIT</td>
<td>Geoid units (M/F)</td>
<td class="ttf">DD</td>
<td>Day of the month (1-31)</td>
</tr><tr>
<td class="ttf">D_AGE</td>
<td>Age of last DGPS Fix</td>
@ -151,17 +119,77 @@
<td class="ttf">D_REF</td>
<td>Reference ID of DGPS station</td>
</tr><tr>
<td class="ttf">GPSTIME</td>
<td>Time of day on GPS timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.f])</td>
<td class="ttf">FIX_MODE</td>
<td>Position Fix Mode (0 = Invalid, &gt;0 = Valid)</td>
</tr><tr>
<td class="ttf">DD</td>
<td>Day of the month (1-31)</td>
<td class="ttf">GEO</td>
<td>Geoid/Elipsoid separation</td>
</tr><tr>
<td class="ttf">GPSTIME</td>
<td>Time of day on GPS timescale. Hours, minutes and seconds [fraction (opt.)] (hhmmss[.f])</td>
</tr><tr>
<td class="ttf">gpsTow</td>
<td>GPS week time, seconds since start of GPS week (0..604799)</td>
</tr><tr>
<td class="ttf">gpsWk</td>
<td>Week number in the GPS time scale (may exceed 1024)</td>
</tr><tr>
<td class="ttf">G_UNIT</td>
<td>Geoid units (M/F)</td>
</tr><tr>
<td class="ttf">HDG</td>
<td>Heading/track made good (degrees True) (x.x)</td>
</tr><tr>
<td class="ttf">HDOP</td>
<td>Horizontal Dilution of Precision</td>
</tr><tr>
<td class="ttf">LAT</td>
<td>Latitude (llll.ll)</td>
</tr><tr>
<td class="ttf">LAT_REF</td>
<td>Latitude direction (N = North, S = South)</td>
</tr><tr>
<td class="ttf">LEAPS</td>
<td>Leap seconds or difference between GPS time scale and UTC</td>
</tr><tr>
<td class="ttf">LON</td>
<td>Longitude (yyyyy.yy)</td>
</tr><tr>
<td class="ttf">LON_REF</td>
<td>Longitude direction (E = East, W = West)</td>
</tr><tr>
<td class="ttf">MAG_REF</td>
<td>Magnetic variation (E = East, W = West)</td>
</tr><tr>
<td class="ttf">MAG_VAR</td>
<td>Magnetic variation (degrees) (x.x)</td>
</tr><tr>
<td class="ttf">MM</td>
<td>Month of the year (1-12)</td>
</tr><tr>
<td class="ttf">POS_STAT</td>
<td>Position status. (A = Data valid, V = Data invalid)</td>
</tr><tr>
<td class="ttf">SAT_USED</td>
<td>Number of Satellites used in solution</td>
</tr><tr>
<td class="ttf">SPD</td>
<td>Speed over ground. (knots) (x.x)</td>
</tr><tr>
<td class="ttf">UTC</td>
<td>Time of day on UTC timescale. Hours, minutes and seconds [fraction (opt.)] (hhmmss[.fff])</td>
</tr><tr>
<td class="ttf">YYYY</td>
<td>Year</td>
</tr><tr>
<td class="ttf">WEEK</td>
<td>GPS week (0-1023)</td>
</tr><tr>
<td class="ttf">WSEC</td>
<td>Seconds since start of week (0-604799)</td>
</tr><tr>
<td class="ttf">LEAP</td>
<td>GPS leap seconds, that is, seconds ahead of UTC</td>
</tr><tr>
<td class="ttf">AA.BB</td>
<td>Denotes the signal strength (should be &lt; 05.00)</td>
@ -181,6 +209,36 @@
</tbody></table></p>
<h4><a name="talkerids"/>NMEA Talker IDs</h4>
<p>
GNSS receivers use a distinct talker ID for the GNSS they
process. Receivers capable of tracking different systems at the same time
can emit <tt>$GPRMC</tt> (GPS), <tt>$GLRMC</tt> (GLONASS),
<tt>$GARMC</tt> (Galileo), <tt>$GNRMC</tt> (generic/combined) and others
all in one data stream.
</p><p>
The driver supports this to a certain degree by ignoring the
talker ID on the standard sentences RMC, GLL, GGA, ZDA and ZDG. (It
possibly should not do that on the latter, but for now, that's the way
it is.) So whenever <tt>$GPRMC</tt> is mentioned in this document,
substitute any possible talker ID your receiver might emit -- it will
still match.
</p><p>
This approach has a drawback. It is easy to use for single-system
receivers, but it cannot separate the data streams for multi-system
receiver modules. It is therefore undefined which GNSS actually
provides the data, and this can lead to strange behavior. This is
especially true if the different GNSS provide very different signal
quality to the receiver; the driver is not able to cherry-pick the best
source and might actually end up in using the worst available. It is
therefore recommended to set up such a receiver to either use just a
single GNSS (which would defeat its purpose) or to emit only the
combined data, which usually has the <tt>GN</tt> talker ID defined by
the NMEA standard.
<p>
<h4>The 'mode' byte</h4>
<p>
@ -202,7 +260,7 @@
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
<td>process <tt>$GPMRC</tt></td>
<td>process <tt>$GPRMC</tt></td>
</tr><tr>
<td align="center">1</td>
<td align="center">2</td>
@ -259,9 +317,14 @@
<td align="center">0x100</td>
<td>process <tt>$PGRMF</tt></td>
</tr><tr>
<td align="center">9-15</td>
<td align="center">9</td>
<td align="center">512</td>
<td align="center">0x200</td>
<td>process <tt>$PUBX,04</tt></td>
</tr><tr>
<td align="center">10-15</td>
<td align="center"></td>
<td align="center">0xFE00</td>
<td align="center">0xFC00</td>
<td>reserved - leave 0</td>
</tr><tr>
<td align="center">16</td>
@ -269,6 +332,24 @@
<td align="center">0x10000</td>
<td>Append extra statistics to the clockstats line.
Details below.</td>
</tr><tr>
<td align="center">17</td>
<td align="center">131072</td>
<td align="center">0x20000</td>
<td>"Silent PPS" mode. Use the PPS channel (if enabled with
fudge flag 1) to get precise receive time stamps.
Do <em>not</em> set the PPS flag in the clock status, so the
clock is not considered as PPS peer.
</td>
</tr><tr>
<td align="center">18</td>
<td align="center">262144</td>
<td align="center">0x40000</td>
<td>Trust the date delivered via NMEA. Do this only if
you <em>really</em> trust the receiver!
See <a href="#datetrust">below</a>. <strong>Caveat:</strong>
This (hitherto undocumented) bit has moved!
</td>
</tr>
</tbody></table>
@ -291,7 +372,7 @@
</li></ul>
The driver uses 4800 bits per second by default, but faster bitrates can
be selected using bits 4 to 6 of the mode field.
<p></p>
</p>
<p>
<strong>Caveat:</strong> Using higher line speeds does not necessarily
@ -306,6 +387,29 @@
linespeed of 4800 bps or 9600 bps.
</p>
<h4><a name="datetrust"/>About distrusting NMEA date stamps</h4>
<p>
Trusting the calendar dates delivered via NMEA is a risky thing, and by
default these dates are handled with a huge dose of skepticism. Many
receivers deliver a correct calendar date for a period of just 1024 weeks,
with a starting point baked somewhere into their firmware. Beyond that,
they warp back to the begin of their era and simply provide wrong date
information. To battle this widely observed effect, the date delivered is
by default reduced to GPS time again and then (re-)mapped according to the
base date, either the implicit value or the value set via "tos basedate".
If the receiver can <em>really</em> be trusted to deliver the right date
(which is not impossible, just more expensive for the manufacturer), then
mode bit 18 can be used to bypass the era mapping. Setting this bit is
not needed under most circumstances, and setting it with an unreliable
receiver can have severe effects. Handle with care.
</p><p>
<strong>Note:</strong> This functionality was available for some time as
undocumented feature, with a different bit value. It was moved in the
process of becoming officially acknowledged to avoid excessive scattering
of the mode bit mask.
</p>
<h4>Monitor Data</h4>
<p>The last GPS sentence that is accepted or rejected is written to the

View File

@ -11,7 +11,7 @@
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<h1><font size="+2">Trimble Palisade and Thunderbolt Receivers</font>
<p>Last update:
<!-- #BeginDate format:En2m -->21-Oct-2010 23:44<!-- #EndDate -->
<!-- #BeginDate format:En2m -->13-Sep-2019 08:07<!-- #EndDate -->
UTC</p>
<hr>
</h1>
@ -69,13 +69,28 @@
</td>
<td><b>9600 baud, 8-bits, 1-stop, no parity</b></td>
</tr>
<tr>
<td>
<div align="right">
<tt><font size="+1">Serial I/O (Copernicus II):</font></tt></div>
</td>
<td><b>38400 baud, 8-bits, 1-stop, no parity</b></td>
</tr>
</table>
<h2><font size="+1">Description</font></h2>
The <b>refclock_palisade</b> driver supports <a href="http://www.trimble.com/products/ntp">Trimble Navigation's Palisade Smart Antenna GPS receiver</a>.<br>
Additional software and information about the Palisade GPS is available from: <a href="http://www.trimble.com/oem/ntp">http://www.trimble.com/oem/ntp</a>.<br>
Latest NTP driver source, executables and documentation is maintained at: <a href="ftp://ftp.trimble.com/pub/ntp">ftp://ftp.trimble.com/pub/ntp</a>
<p>This documentation describes version 7.12 of the GPS Firmware and version 2.46 (July 15, 1999) and later, of the driver source.<br>&nbsp;</p>
<p>This documentation describes version 7.12 of the GPS Firmware and version 2.46 (July 15, 1999) and later, of the driver source.</p>
<p>This documentation describes version 1 of the Thunderbolt Receiver Firmware, no tests have been made on further firmwares, please read "Notes on the Thunderbolt Receiver's Firmware" at the end of this documentation for more information.</p>
<p>This driver also supports the following receivers:</p>
<blockquote>
<p>Endrun Technologies Praecis NTP server with GPS</p>
<p>Trimble Acutime Gold smart antenna</p>
<p>Trimble Resolution family</p>
<p>Trimble ACE III</p>
<p>Trimble Copernicus II</p>
</blockquote>
<h2><font size="+1">Operating System Compatibility</font></h2>
The Palisade driver has been tested on the following software and hardware platforms:<br>&nbsp;
<center>
@ -118,7 +133,7 @@
</tr>
</table>
</center><P>
<b>Attention</b>: Thunderbolt Receiver has not being tested on the previous software and hardware plataforms.
<b>Attention</b>: Other receiver types have not being tested on the previous software and hardware plataforms.
<h2><font size="+1">GPS Receiver</font></h2>
The Palisade GPS receiver is an 8-channel smart antenna, housing the GPS receiver, antenna and interface in a single unit, and is designed for rooftop deployment in static timing applications.
<p>Palisade generates a PPS synchronized to UTC within +/- 100 ns.&nbsp; The Palisade's external event input with 40 nanosecond resolution is utilized by the Palisade NTP driver for asynchronous precision time transfer.</p>
@ -232,7 +247,41 @@
<tt># and set flag2 to turn off event polling.</tt><br>
<tt><a href="#flag2">fudge 127.127.29.0 flag2 1</a></tt><br>
<tt>#------------------------------------------------------------------------------</tt><br>&nbsp;</p>
Currently the Thunderbolt mode doesn't support event polling, the reasons are explained on the "Notes on the Thunderbolt Receiver's Firmware" section at the end of this documentation.
<h4>Resolution NTP Configuration file</h4>
<tt>#------------------------------------------------------------------------------</tt>
<p>Configuration without event polling:<br>
<tt>#------------------------------------------------------------------------------</tt><br>
<tt># The Primary reference</tt><br>
<tt>server 127.127.29.0 mode 5 # Trimble Resolution GPS (Stratum 1).</tt><br>
<tt># Set packet delay</tt><br>
<tt><a href="#time1">fudge 127.127.29.0 time1 0.410</a></tt><br>
<tt># and set flag2 to turn off event polling.</tt><br>
<tt><a href="#flag2">fudge 127.127.29.0 flag2 1</a></tt><br>
<tt>#------------------------------------------------------------------------------</tt><br>&nbsp;</p>
<h4>ACE III NTP Configuration file</h4>
<tt>#------------------------------------------------------------------------------</tt>
<p>Configuration with event polling:<br>
<tt>#------------------------------------------------------------------------------</tt><br>
<tt># The Primary reference</tt><br>
<tt>server 127.127.29.0 mode 6 # Trimble ACE III GPS (Stratum 1).</tt><br>
<tt># Set packet delay</tt><br>
<tt><a href="#time1">fudge 127.127.29.0 time1 0.720</a></tt><br>
<tt>#------------------------------------------------------------------------------</tt><br>&nbsp;</p>
<h4>Copernicus II NTP Configuration file</h4>
<tt>#------------------------------------------------------------------------------</tt>
<p>Configuration without event polling:<br>
<tt>#------------------------------------------------------------------------------</tt><br>
<tt># The Primary reference</tt><br>
<tt>server 127.127.29.0 mode 7 # Trimble Copernicus II GPS (Stratum 1).</tt><br>
<tt># Set packet delay</tt><br>
<tt><a href="#time1">fudge 127.127.29.0 time1 0.240</a></tt><br>
<tt># and set flag2 to turn off event polling.</tt><br>
<tt><a href="#flag2">fudge 127.127.29.0 flag2 1</a></tt><br>
<tt>#------------------------------------------------------------------------------</tt><br>&nbsp;</p>
Currently the Thunderbolt mode doesn't support event polling, the reasons are explained on the "Notes on the Thunderbolt Receiver's Firmware" section at the end of this documentation. The Resolution and Copernicus II modes require event polling to be disabled whereas the ACE III requires polling to be enabled.
<h2><a name="TimeTransfer"></a><font size="+1">Time Transfer and Polling</font></h2>
Time transfer to the NTP host is performed via the Palisade's comprehensive time packet output. The time packets are output once per second, and whenever an event timestamp is requested.
<p>The driver requests an event time stamp at the end of each polling interval, by pulsing the RTS (request to send) line on the serial port. The Palisade GPS responds with a time stamped event packet.</p>
@ -269,7 +318,16 @@
<h2><font size="+1">Mode Parameter</font></h2>
<dl>
<dt><tt><font size="+1">mode <i>number</i></font></tt>
<dd>The mode parameter to the server command specifies the specific hardware this driver is for. The default is 0 for a normal Trimble Palisade. The other options are <b>1</b> for an <b>Endrun Praecis</b> in Trimble emulation mode, and <b>2</b> for the <b>Trimble Thunderbolt</b> GPS Disciplined Clock Receiver.
<dd>
The mode parameter to the server command specifies the specific hardware this driver is for. The default is 0 for a normal Trimble Palisade. The other options are:
<blockquote>
<p><b>1</b> for an <b>Endrun Praecis</b> in Trimble emulation mode</p>
<p><b>2</b> for the <b>Trimble Thunderbolt</b> GPS Disciplined Clock Receiver</p>
<p><b>3</b> for the <b>Acutime Gold</b> smart antenna</p>
<p><b>5</b> for <b>Trimble Resolution</b> devices</p>
<p><b>6</b> for the <b>Trimble ACE III</b> board</p>
<p><b>7</b> for the <b>Trimble Copernicus II</b> device</p>
</blockquote>
</dl>
<h2><font size="+1">DEFINEs</font></h2>
The following constants are defined in the driver source code. These defines may be modified to improve performance or adapt to new operating systems.<br>&nbsp;
@ -290,16 +348,16 @@
<td>Accuracy of time transfer</td>
<td>1 microsecond</td>
</tr>
<tr>
<td>CURRENT_UTC</td>
<td>Valid GPS - UTC offset</td>
<td>13</td>
</tr>
<tr>
<td>SPEED232</td>
<td>Host RS-232 baud rate</td>
<td>B9600</td>
</tr>
<tr>
<td>SPEED232COP</td>
<td>Host RS-232 baud rate (Copernicus II mode)</td>
<td>B38400</td>
</tr>
<tr>
<td>TRMB_MINPOLL&nbsp;</td>
<td>Minimum polling interval</td>

View File

@ -10,7 +10,7 @@
<img src="pic/boom3.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
<p>We have three, now looking for more.</p>
<p>Last update:
<!-- #BeginDate format:En2m -->14-Oct-2017 08:34<!-- #EndDate -->
<!-- #BeginDate format:En2m -->11-Feb-2020 14:00<!-- #EndDate -->
UTC</p>
<br clear="left">
<h4>Related Links</h4>
@ -63,8 +63,9 @@
<dd>This command allows additional configuration commands to be included from a separate file. Include files may be nested to a depth of five; upon reaching the end of any include file, command processing resumes in the previous configuration file. This option is useful for sites that run <tt>ntpd</tt> on multiple hosts, with (mostly) common options (e.g., a restriction list).</dd>
<dt id="interface"><tt>interface [listen | ignore | drop] [all | ipv4 | ipv6 | wildcard | <i>name</i> | <i>address</i>[/<i>prefixlen</i>]]</tt></dt>
<dd>This command controls which network addresses <tt>ntpd</tt> opens, and whether input is dropped without processing. The first parameter determines the action for addresses which match the second parameter. That parameter specifies a class of addresses, or a specific interface name, or an address. In the address case, <tt><i>prefixlen</i></tt> determines how many bits must match for this rule to apply. <tt>ignore</tt> prevents opening matching addresses, <tt>drop</tt> causes <tt>ntpd</tt> to open the address and drop all received packets without examination. Multiple <tt>interface</tt> commands can be used. The last rule which matches a particular address determines the action for it. <tt>interface</tt> commands are disabled if any <a href="ntpd.html#--interface"><tt>-I</tt></a>, <a href="ntpd.html#--interface"><tt>--interface</tt></a>, <a href="ntpd.html#--novirtualips"><tt>-L</tt></a>, or <a href="ntpd.html#--novirtualips"><tt>--novirtualips</tt></a> command-line options are used. If none of those options are used and no <tt>interface</tt> actions are specified in the configuration file, all available network addresses are opened. The <tt>nic</tt> command is an alias for <tt>interface</tt>.</dd>
<dt id="leapfile"><tt>leapfile <i>leapfile</i></tt></dt>
<dd>This command loads the IERS leapseconds file and initializes the leapsecond values for the next leapsecond time, expiration time and TAI offset. The file can be obtained directly from the IERS at <a href="https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list">https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list</a> or <a href="ftp://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list">ftp://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list</a>.</dd>
<dt id="leapfile"><tt>leapfile <i>leapfile</i> [checkhash|ignorehash]</tt></dt>
<dd>This command loads the IERS leapseconds file and initializes the leapsecond values for the next leapsecond time, expiration time and TAI offset. The file can be obtained directly from the IERS at <a href="https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list">https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list</a> or <a href="ftp://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list">ftp://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list</a>.
<tt>ignorehash</tt> instructs <tt>ntpd</tt> to ignore the hash signature on the file, <tt>checkhash</tt> (which is the default when omitted) needs a hash line in the file to be valid. Files without any hash signature are lodaed in both cases.</dd>
<dd>The <i>leapfile</i> is scanned when <tt>ntpd</tt> processes the <tt>leapfile</tt> directive or when <tt>ntpd</tt> detects that <i>leapfile</i> has changed. <tt>ntpd</tt> checks once a day to see if the <i>leapfile</i> has changed.</dd>
<dd>While not strictly a security function, the Autokey protocol provides means to securely retrieve the current or updated leapsecond values from a server.</dd>
<dt id="leapsmearinterval"><tt>leapsmearinterval <i>seconds</i></tt></dt>
@ -108,6 +109,24 @@
For the ACTS modem driver (type 18), the arguments consist of a maximum of 10 telephone numbers used to dial USNO, NIST or European time services.
For the JJY driver (type 40 mode 100 - 180), the argument is one telephone number used to dial the telephone JJY service.
The Hayes command ATDT&nbsp;is normally prepended to the number, which can contain other modem control codes as well.</dd>
<dt id="pollskewlist"
><tt>pollskewlist</tt> <tt>[</tt><i>poll</i> <i>value</i><tt>
| </tt><i>value</i><tt>]</tt> <tt>...</tt> <tt>[default </tt><i>value</i><tt>
| </tt><i>value</i><tt>]</tt></dt>
<dd>Enable skewing of our poll requests to our servers.
<i>poll</i>
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.</dd>
<dt id="reset"><tt>reset [allpeers] [auth] [ctl] [io] [mem] [sys] [timer]</tt></dt>
<dd>Reset one or more groups of counters maintained by ntpd and exposed by <tt>ntpq</tt> and <tt>ntpdc</tt>.</dd>
<dt id="rlimit"><tt>rlimit [memlock <i>Nmegabytes</i> | stacksize <i>N4kPages</i> | filenum <i>Nfiledescriptors</i>]</tt></dt>
@ -147,12 +166,16 @@
<dd>Specifies the stepout threshold in seconds. The default without this command is 300 s. Since this option also affects the training and startup intervals, it should not be set less than the default. Further details are on the <a href="clock.html">Clock State Machine</a> page.</dd>
</dl>
</dd>
<dt id="tos"><tt>tos [basedate <i>date<i> | bcpollbstep <i>poll-gate</i> | beacon <i>beacon</i> | ceiling <i>ceiling</i> | cohort {0 | 1} | floor <i>floor</i> | maxclock <i>maxclock </i>| maxdist <i>maxdist</i> | minclock <i>minclock</i> | mindist <i>mindist </i>| minsane <i>minsane</i> | orphan <i>stratum</i> | orphanwait <em>delay</em>]</tt></dt>
<dt id="tos"><tt>tos [basedate <i>date</i> | bcpollbstep <i>poll-gate</i> | beacon <i>beacon</i> | ceiling <i>ceiling</i> | cohort {0 | 1} | floor <i>floor</i> | maxclock <i>maxclock </i>| maxdist <i>maxdist</i> | minclock <i>minclock</i> | mindist <i>mindist </i>| minsane <i>minsane</i> | orphan <i>stratum</i> | orphanwait <em>delay</em>]</tt></dt>
<dd>This command alters certain system variables used by the the clock selection and clustering algorithms. The default values of these variables have been carefully optimized for a wide range of network speeds and reliability expectations. Very rarely is it necessary to change the default values; but, some folks can't resist twisting the knobs. It can be used to select the quality and quantity of peers used to synchronize the system clock and is most useful in dynamic server discovery schemes. The options are as follows:</dd>
<dd>
<dl>
<dt><tt>basedate <i>date</i></tt></dt>
<dd>Set NTP era anchor. <tt><i>date</i></tt> is either a date in ISO8601 format (<i>YYYY-MM-DD<i>) or an integer giving the days since 1900-01-01, the start of the NTP epoch. <tt>ntpd</tt> will clamp the system time to an era starting with the begin of this this day (00:00:00Z), covering a range of 2<sup>32</sup> seconds or roughly 136 years. The default is the begin of the UNIX epoch, 1970-01-01.</dd>
<dd>Set NTP and GPS era anchor. <tt><i>date</i></tt> is either a date in ISO8601 format (<i>YYYY-MM-DD</i>) or an integer giving the days since 1900-01-01, the start of the NTP epoch. <tt>ntpd</tt> will clamp the system time to an era starting with the begin of this this day (00:00:00Z), covering a range of 2<sup>32</sup> seconds or roughly 136 years. The lowest accepted value is effectively 1970-01-02.<br>
The GPS era base is the next Sunday on or following the base date, but obviously not before 1980-01-06. GPS time stamps are mapped into the 1024 weeks following the GPS base.<br>
The default value is derived from the repository or build time stamp, minus 11 days. 1970-01-02 was chosen as lower bound so the <em>local</em> time is always after 1970-01-01,00:00. Some systems get into trouble if this is not the case.<p>
<b><u>ATTENTION:</u></b> If the system clock is before the effective (implied or specific) basedate, the system clock will be set to the base date once and immediately when <tt>ntpd</tt> starts. This helps systems that have lost time completely to recover. Though not noticeable under normal conditions, it <em>can</em> happen. Check the logs if starting <tt>ntpd</tt> causes sudden clock moves.
</dd>
<dt><tt>bcpollbstep <i>poll-gate</i></tt></dt>
<dd>This option will cause the client to delay believing backward time steps from a broadcast server for <tt>bcpollbstep</tt> poll intervals. NTP Broadcast networks are expected to be trusted, and if the server's time gets stepped backwards then it's desireable that the clients follow this change as soon as possible. However, in spite of various protections built-in to the broadcast protocol, it is possible that an attacker could perform a carefully-constructed replay attack and cause clients to erroneously step their clocks backward. If the risk of a successful broadcast replay attack is greater than the risk of the clients being out of sync in the event that there is a backward step on the broadcast time servers, this option may be used to cause the clients to delay beliveving backward time steps until <i>poll-gate</i> consecutive polls have been received. The default is 0, which means the client will accept these steps upon receipt. Any value from 0 to 4 can be specified.</dd>
<dt><tt>beacon <i>beacon</i></tt></dt>

View File

@ -25,6 +25,7 @@ noinst_HEADERS = \
ntp.h \
ntp_assert.h \
ntp_calendar.h \
ntp_calgps.h \
ntp_cmdargs.h \
ntp_config.h \
ntp_control.h \
@ -46,6 +47,7 @@ noinst_HEADERS = \
ntp_md5.h \
ntp_net.h \
ntp_proto.h \
ntp_psl.h \
ntp_random.h \
ntp_refclock.h \
ntp_request.h \
@ -76,6 +78,7 @@ noinst_HEADERS = \
timespecops.h \
timetoa.h \
timevalops.h \
timexsup.h \
trimble.h \
vint64ops.h \
$(NULL)

View File

@ -511,6 +511,7 @@ noinst_HEADERS = \
ntp.h \
ntp_assert.h \
ntp_calendar.h \
ntp_calgps.h \
ntp_cmdargs.h \
ntp_config.h \
ntp_control.h \
@ -532,6 +533,7 @@ noinst_HEADERS = \
ntp_md5.h \
ntp_net.h \
ntp_proto.h \
ntp_psl.h \
ntp_random.h \
ntp_refclock.h \
ntp_request.h \
@ -562,6 +564,7 @@ noinst_HEADERS = \
timespecops.h \
timetoa.h \
timevalops.h \
timexsup.h \
trimble.h \
vint64ops.h \
$(NULL)

View File

@ -359,6 +359,7 @@ struct peer {
l_fp aorg; /* origin timestamp */
l_fp borg; /* alternate origin timestamp */
l_fp bxmt; /* most recent broadcast transmit timestamp */
l_fp nonce; /* Value of nonce we sent as the xmt stamp */
double offset; /* peer clock offset */
double delay; /* peer roundtrip delay */
double jitter; /* peer jitter (squares) */
@ -466,6 +467,7 @@ struct peer {
# define FLAG_ASSOC 0x8000 /* autokey request */
#endif /* OPENSSL */
#define FLAG_TSTAMP_PPS 0x10000 /* PPS source provides absolute timestamp */
#define FLAG_LOOPNONCE 0x20000 /* Use a nonce for the loopback test */
/*
* Definitions for the clear() routine. We use memset() to clear
@ -841,6 +843,7 @@ struct restrict_u_tag {
u_short rflags; /* restrict (accesslist) flags */
u_short mflags; /* match flags */
short ippeerlimit; /* IP peer limit */
int srvfuzrftpoll; /* server response: fuzz reftime */
u_long expire; /* valid until time */
union { /* variant starting here */
res_addr4 v4;
@ -885,13 +888,16 @@ char *build_rflags(u_short rflags);
#define RES_MSSNTP 0x1000 /* enable MS-SNTP authentication */
#define RES_FLAKE 0x2000 /* flakeway - drop 10% */
#define RES_NOMRULIST 0x4000 /* mode 6 mrulist denied */
#define RES_UNUSED 0x8000 /* Unused flag bits */
#define RES_SRVRSPFUZ 0x8000 /* Server response: fuzz */
#define RES_UNUSED 0x0000 /* Unused flag bits (none left) */
#define RES_ALLFLAGS (RES_FLAGS | RES_NOQUERY | \
RES_NOMODIFY | RES_NOTRAP | \
RES_LPTRAP | RES_KOD | \
RES_MSSNTP | RES_FLAKE | \
RES_NOMRULIST)
RES_NOMRULIST | RES_SRVRSPFUZ )
/*
* Match flags (mflags)

View File

@ -19,6 +19,8 @@ struct calendar {
uint8_t second; /* second of minute */
uint8_t weekday; /* 0..7, 0=Sunday */
};
typedef struct calendar TCivilDate;
typedef struct calendar const TcCivilDate;
/* ISO week calendar date */
struct isodate {
@ -29,6 +31,8 @@ struct isodate {
uint8_t minute; /* minute of hour */
uint8_t second; /* second of minute */
};
typedef struct isodate TIsoDate;
typedef struct isodate const TcIsoDate;
/* general split representation */
typedef struct {
@ -109,6 +113,7 @@ extern systime_func_ptr ntpcal_set_timefunc(systime_func_ptr);
extern const char * const months[12];
extern const char * const daynames[7];
extern char * ntpcal_iso8601std(char*, size_t, struct calendar const*);
extern void caljulian (uint32_t, struct calendar *);
extern uint32_t caltontp (const struct calendar *);
@ -151,6 +156,13 @@ ntpcal_ntp_to_ntp(uint32_t /* ntp */, const time_t * /* pivot */);
extern ntpcal_split
ntpcal_daysplit(const vint64 *);
/*
* Split a time stamp in seconds into elapsed weeks and elapsed seconds
* since start of week.
*/
extern ntpcal_split
ntpcal_weeksplit(const vint64 *);
/*
* Merge a number of days and a number of seconds into seconds,
* expressed in 64 bits to avoid overflow.
@ -158,6 +170,13 @@ ntpcal_daysplit(const vint64 *);
extern vint64
ntpcal_dayjoin(int32_t /* days */, int32_t /* seconds */);
/*
* Merge a number of weeks and a number of seconds into seconds,
* expressed in 64 bits to avoid overflow.
*/
extern vint64
ntpcal_weekjoin(int32_t /* weeks */, int32_t /* seconds */);
/* Get the number of leap years since epoch for the number of elapsed
* full years
*/
@ -431,7 +450,7 @@ basedate_expand_gpsweek(unsigned short weekno);
/*
* Start day of the GPS epoch. This is the Rata Die of 1980-01-06
*/
#define DAY_GPS_STARTS 722819
#define DAY_GPS_STARTS 722820
/*
* Difference between UN*X and NTP epoch (25567).
@ -467,6 +486,56 @@ basedate_expand_gpsweek(unsigned short weekno);
*/
#define GREGORIAN_CYCLE_WEEKS (GREGORIAN_CYCLE_DAYS / 7)
#define is_leapyear(y) (!((y) % 4) && !(!((y) % 100) && (y) % 400))
/*
* Is a Greogorian calendar year a leap year? The obvious solution is to
* test the expression
*
* (y % 4 == 0) && ((y % 100 != 0) || (y % 400 == 0))
*
* This needs (in theory) 2 true divisions -- most compilers check the
* (mod 4) condition by doing a bit test. Some compilers have been
* even observed to partially fuse the (mod 100) and (mod 400) test,
* but there is an alternative formula that gives the compiler even
* better chances:
*
* (y % 4 == 0) && ((y % 16 == 0) || (y % 25 != 0))
*
* The order of checks is chosen so that the shorcut evaluation can fix
* the result as soon as possible. And the compiler has to do only one
* true division here -- the (mod 4) and (mod 16) can be done with
* direct bit tests. *If* the compiler chooses to do so.
*
* The deduction is as follows: rewrite the standard formula as
* (y % 4 == 0) && ((y % 4*25 != 0) || (y % 16*25 == 0))
*
* then split the congruences:
* (y % 4 == 0) && ((y % 4 != 0 || y % 25 != 0) || (y % 16 == 0 && y % 25 == 0))
*
* eliminate the 1st inner term, as it is provably false:
* (y % 4 == 0) && (y % 25 != 0 || (y % 16 == 0 && y % 25 == 0))
*
* Use the distributive laws on the second major group:
* (y % 4 == 0) && ((y % 25 != 0 || y % 16 == 0) && (y % 25 != 0 || y % 25 == 0))
*
* Eliminate the constant term, reorder, and voila:
*/
static inline int
is_leapyear(int32_t y) {
return !(y % 4) && (!(y % 16) || (y % 25));
}
/* The (mod 4) test eliminates 3/4 (or 12/16) of all values.
* The (mod 16) test eliminates another 1/16 of all values.
* 3/16 of all values reach the final division.
* Assuming that the true division is the most costly operation, this
* sequence should give most bang for the buck.
*/
/* misc */
extern int u32mod7(uint32_t x);
extern int i32mod7(int32_t x);
extern uint32_t i32fmod(int32_t x, uint32_t d);
extern int32_t ntpcal_expand_century(uint32_t y, uint32_t m, uint32_t d, uint32_t wd);
#endif

View File

@ -0,0 +1,151 @@
/*
* ntp_calgps.h - calendar for GPS/GNSS based clocks
*
* Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
* The contents of 'html/copyright.html' apply.
*
* --------------------------------------------------------------------
*
* This module implements stuff often used with GPS/GNSS receivers
*/
#ifndef NTP_CALGPS_H
#define NTP_CALGPS_H
#include <time.h>
#include "ntp_types.h"
#include "ntp_fp.h"
#include "ntp_calendar.h"
/* GPS week calendar (extended weeks)
* We use weeks based on 1899-31-12, which was the last Sunday before
* the begin of the NTP epoch. (Which is equivalent to saying 1900-01-01
* was a Monday...)
*
* We simply pre-calculate the offsets and cycle shifts for the real GPS
* calendar, which starts at 1980-01-06, to simplyfy some expressions.
*
* This has a fringe benefit that should not be overlooked: Since week zero
* is around 1900, and we should never have to deal with dates before
* 1970 or 1980, a week number of zero can be easily used to indicate
* an invalid week time stamp.
*/
#define GPSNTP_WSHIFT 4175 /* weeks 1899-31-12 --> 1980-01-06 */
#define GPSNTP_WCYCLE 79 /* above, modulo 1024 */
#define GPSNTP_DSHIFT 1 /* day number of 1900-01-01 in week */
struct gpsdatum {
uint32_t weeks; /* weeks since GPS epoch */
int32_t wsecs; /* seconds since week start */
uint32_t frac; /* fractional seconds */
};
typedef struct gpsdatum TGpsDatum;
typedef struct gpsdatum const TcGpsDatum;
/* NTP date/time in split representation */
struct ntpdatum {
uint32_t days; /* since NTP epoch */
int32_t secs; /* since midnight, denorm is ok */
uint32_t frac; /* fractional seconds */
};
typedef struct ntpdatum TNtpDatum;
typedef struct ntpdatum const TcNtpDatum;
/*
* GPS week/sec calendar functions
*
* see the implementation for details, especially the
* 'gpscal_from_weektime{1,2}()'
*/
extern TGpsDatum
gpscal_fix_gps_era(TcGpsDatum *);
extern void
gpscal_add_offset(TGpsDatum *datum, l_fp offset);
extern TGpsDatum
gpscal_from_calendar_ex(TcCivilDate*, l_fp fofs, int/*BOOL*/ warp);
static inline TGpsDatum
gpscal_from_calendar(TcCivilDate *pCiv, l_fp fofs) {
return gpscal_from_calendar_ex(pCiv, fofs, TRUE);
}
extern TGpsDatum /* see source for semantic of the 'fofs' value! */
gpscal_from_gpsweek(uint16_t w, int32_t s, l_fp fofs);
extern TGpsDatum
gpscal_from_weektime1(int32_t wsecs, l_fp fofs, l_fp pivot);
extern TGpsDatum
gpscal_from_weektime2(int32_t wsecs, l_fp fofs, TcGpsDatum *pivot);
extern void
gpscal_to_calendar(TCivilDate*, TcGpsDatum*);
extern TGpsDatum
gpscal_from_gpsntp(TcNtpDatum*);
extern l_fp
ntpfp_from_gpsdatum(TcGpsDatum *);
/*
* NTP day/sec calendar functions
*
* see the implementation for details, especially the
* 'gpscal_from_daytime{1,2}()'
*/
extern TNtpDatum
gpsntp_fix_gps_era(TcNtpDatum *);
extern void
gpsntp_add_offset(TNtpDatum *datum, l_fp offset);
extern TNtpDatum
gpsntp_from_calendar_ex(TcCivilDate*, l_fp fofs, int/*BOOL*/ warp);
static inline TNtpDatum
gpsntp_from_calendar(TcCivilDate * pCiv, l_fp fofs) {
return gpsntp_from_calendar_ex(pCiv, fofs, TRUE);
}
extern TNtpDatum
gpsntp_from_daytime1_ex(TcCivilDate *dt, l_fp fofs, l_fp pivot, int/*BOOL*/ warp);
static inline TNtpDatum
gpsntp_from_daytime1(TcCivilDate *dt, l_fp fofs, l_fp pivot) {
return gpsntp_from_daytime1_ex(dt, fofs, pivot, TRUE);
}
extern TNtpDatum
gpsntp_from_daytime2_ex(TcCivilDate *dt, l_fp fofs, TcNtpDatum *pivot, int/*BOOL*/ warp);
static inline TNtpDatum
gpsntp_from_daytime2(TcCivilDate *dt, l_fp fofs, TcNtpDatum *pivot) {
return gpsntp_from_daytime2_ex(dt, fofs, pivot, TRUE);
}
extern TNtpDatum
gpsntp_from_gpscal_ex(TcGpsDatum*, int/*BOOL*/ warp);
static inline TNtpDatum
gpsntp_from_gpscal(TcGpsDatum *wd) {
return gpsntp_from_gpscal_ex(wd, FALSE);
}
extern void
gpsntp_to_calendar(TCivilDate*, TcNtpDatum*);
extern l_fp
ntpfp_from_ntpdatum(TcNtpDatum*);
/*
* Some helpers
*/
/* apply fudge to time stamp: *SUBTRACT* the given offset from an l_fp*/
extern l_fp
ntpfp_with_fudge(l_fp lfp, double ofs);
#endif /*!defined(NTP_CALGPS_H)*/

View File

@ -6,6 +6,7 @@
#endif /* HAVE_SYS_RESOURCE_H */
#include "ntp_machine.h"
#include "ntp_psl.h"
#include "ntpsim.h"
@ -68,12 +69,13 @@ struct attr_val_tag {
attr_val * link;
int attr;
int type; /* T_String, T_Integer, ... */
int flag; /* auxiliary flags */
union val {
int i;
u_int u;
int_range r;
double d;
char * s;
double d; /* T_Double */
int i; /* T_Integer */
int_range r; /* T_Intrange */
char * s; /* T_String */
u_int u; /* T_U_int */
} value;
};
@ -110,9 +112,10 @@ struct restrict_node_tag {
restrict_node * link;
address_node * addr;
address_node * mask;
int_fifo * flag_tok_fifo;
attr_val_fifo * flag_tok_fifo;
int line_no;
short ippeerlimit;
short srvfuzrft;
};
typedef DECL_FIFO_ANCHOR(restrict_node) restrict_fifo;
@ -246,6 +249,7 @@ struct config_tree_tag {
attr_val_fifo * vars;
nic_rule_fifo * nic_rules;
int_fifo * reset_counters;
attr_val_fifo * pollskewlist;
sim_fifo * sim_details;
int mdnstries;
@ -272,6 +276,23 @@ typedef struct settrap_parms_tag {
} settrap_parms;
/*
* Poll Skew List
*/
psl_item psl[17-3+1]; /* values for polls 3-17 */
/* To simplify the runtime code we */
/* don't want to have to special-case */
/* dealing with a default */
/*
** Data Minimization Items
*/
/* Serverresponse fuzz reftime: stored in 'restrict' fifos */
/* get text from T_ tokens */
const char * token_name(int token);
@ -298,9 +319,9 @@ address_node *create_address_node(char *addr, int type);
void destroy_address_node(address_node *my_node);
attr_val *create_attr_dval(int attr, double value);
attr_val *create_attr_ival(int attr, int value);
attr_val *create_attr_uval(int attr, u_int value);
attr_val *create_attr_rangeval(int attr, int first, int last);
attr_val *create_attr_rval(int attr, int first, int last);
attr_val *create_attr_sval(int attr, const char *s);
attr_val *create_attr_uval(int attr, u_int value);
void destroy_attr_val(attr_val *node);
filegen_node *create_filegen_node(int filegen_token,
attr_val_fifo *options);
@ -308,7 +329,7 @@ string_node *create_string_node(char *str);
restrict_node *create_restrict_node(address_node *addr,
address_node *mask,
short ippeerlimit,
int_fifo *flags, int line_no);
attr_val_fifo *flags, int line_no);
int_node *create_int_node(int val);
addr_opts_node *create_addr_opts_node(address_node *addr,
attr_val_fifo *options);

View File

@ -1,3 +1,5 @@
#ifndef NTP_CONTROL_H
#define NTP_CONTROL_H
/*
* ntp_control.h - definitions related to NTP mode 6 control messages
*/
@ -190,3 +192,5 @@ extern struct ctl_trap ctl_traps[CTL_MAXTRAPS];
#define IFSTATS_FIELDS 12
#define RESLIST_FIELDS 4
#endif /* NTP_CONTROL_H */

View File

@ -344,8 +344,8 @@ typedef u_int32 u_fp;
/*
* Prototypes
*/
extern char * dofptoa (u_fp, int, short, int);
extern char * dolfptoa (u_int32, u_int32, int, short, int);
extern char * dofptoa (u_fp, char, short, int);
extern char * dolfptoa (u_int32, u_int32, char, short, int);
extern int atolfp (const char *, l_fp *);
extern int buftvtots (const char *, l_fp *);

View File

@ -84,7 +84,7 @@ typedef enum {
extern int qos;
SOCKET move_fd(SOCKET fd);
isc_boolean_t get_broadcastclient_flag(void);
/*isc_boolean_t get_broadcastclient_flag(void);*/
extern void sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *);
extern void add_nic_rule(nic_rule_match match_type,
const char *if_name, int prefixlen,

View File

@ -0,0 +1,17 @@
#ifndef NTP_PSL_H
#define NTP_PSL_H
/*
* Poll Skew List Item
*/
typedef struct psl_item_tag {
int sub; /* int or short? unsigned is OK, but why? */
int qty; /* int or short? unsigned is OK, but why? */
int msk; /* int or short? unsigned is OK */
} psl_item;
int get_pollskew(int, psl_item *);
#endif /* !defined(NTP_PSL_H) */

View File

@ -14,11 +14,6 @@
#include "recvbuff.h"
#define SAMPLE(x) pp->coderecv = (pp->coderecv + 1) % MAXSTAGE; \
pp->filter[pp->coderecv] = (x); \
if (pp->coderecv == pp->codeproc) \
pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
/*
* Macros to determine the clock type and unit numbers from a
* 127.127.t.u address
@ -54,6 +49,7 @@ extern struct clktype clktypes[];
#define CLK_HAVEFLAG2 0x20
#define CLK_HAVEFLAG3 0x40
#define CLK_HAVEFLAG4 0x80
#define CLK_HAVEMINJIT 0x100
/*
* Constant for disabling event reporting in
@ -68,7 +64,7 @@ extern struct clktype clktypes[];
struct refclockstat {
u_char type; /* clock type */
u_char flags; /* clock flags */
u_char haveflags; /* bit array of valid flags */
u_short haveflags; /* bit array of valid flags */
u_short lencode; /* length of last timecode */
const char *p_lastcode; /* last timecode received */
u_int32 polls; /* transmit polls */
@ -77,6 +73,7 @@ struct refclockstat {
u_int32 baddata; /* invalid data timecode received */
u_int32 timereset; /* driver resets */
const char *clockdesc; /* ASCII description */
double fudgeminjitter; /* configure fudge minjitter */
double fudgetime1; /* configure fudge time1 */
double fudgetime2; /* configure fudge time2 */
int32 fudgeval1; /* configure fudge value1 */
@ -133,13 +130,12 @@ extern HANDLE WaitableIoEventHandle;
* Structure interface between the reference clock support
* ntp_refclock.c and the driver utility routines
*/
#define MAXSTAGE 60 /* max median filter stages */
#define MAXSTAGE 64 /* max median filter stages */
#define NSTAGE 5 /* default median filter stages */
#define BMAX 128 /* max timecode length */
#define GMT 0 /* I hope nobody sees this */
#define MAXDIAL 60 /* max length of modem dial strings */
struct refclockproc {
void * unitptr; /* pointer to unit structure */
struct refclock * conf; /* refclock_conf[type] */
@ -148,6 +144,7 @@ struct refclockproc {
u_char currentstatus; /* clock status */
u_char lastevent; /* last exception event */
u_char type; /* clock type */
u_char inpoll; /* waiting for 'refclock_receive()' */
const char *clockdesc; /* clock description */
u_long nextaction; /* local activity timeout */
void (*action)(struct peer *); /* timeout callback */
@ -162,8 +159,8 @@ struct refclockproc {
int second; /* second of minute */
long nsec; /* nanosecond of second */
u_long yearstart; /* beginning of year */
int coderecv; /* put pointer */
int codeproc; /* get pointer */
u_int coderecv; /* put pointer */
u_int codeproc; /* get pointer */
l_fp lastref; /* reference timestamp */
l_fp lastrec; /* receive timestamp */
double offset; /* mean offset */
@ -176,6 +173,7 @@ struct refclockproc {
*/
double fudgetime1; /* fudge time1 */
double fudgetime2; /* fudge time2 */
double fudgeminjitter; /* manually set lower bound for jitter */
u_char stratum; /* server stratum */
u_int32 refid; /* reference identifier */
u_char sloppyclockflag; /* fudge flags */
@ -229,12 +227,29 @@ extern int refclock_process(struct refclockproc *);
extern int refclock_process_f(struct refclockproc *, double);
extern void refclock_process_offset(struct refclockproc *, l_fp,
l_fp, double);
extern int refclock_samples_avail(struct refclockproc const *);
extern int refclock_samples_expire(struct refclockproc *, int);
extern void refclock_report (struct peer *, int);
extern int refclock_gtlin (struct recvbuf *, char *, int, l_fp *);
extern int refclock_gtraw (struct recvbuf *, char *, int, l_fp *);
extern int indicate_refclock_packet(struct refclockio *,
struct recvbuf *);
extern void process_refclock_packet(struct recvbuf *);
/* save string as la_code, size==(size_t)-1 ==> ASCIIZ string */
extern void refclock_save_lcode(
struct refclockproc *, char const *, size_t);
/* format data into la_code */
extern void refclock_format_lcode(
struct refclockproc *, char const *, ...);
extern void refclock_vformat_lcode(
struct refclockproc *, char const *, va_list);
struct refclock_atom;
extern int refclock_ppsaugment(
const struct refclock_atom*, l_fp *rcvtime ,
double rcvfudge, double ppsfudge);
#endif /* REFCLOCK */
#endif /* NTP_REFCLOCK_H */

View File

@ -670,8 +670,10 @@ struct conf_restrict {
u_int32 addr; /* match address */
u_int32 mask; /* match mask */
short ippeerlimit; /* ip peer limit */
u_short flags; /* restrict flags */
int srvfuzrft; /* server response fuzz reftime: poll */
u_short flags; /* restrict flags XXX: OLD size and name */
u_short mflags; /* match flags */
short unused1; /* (unused) padding for v6_flag */
u_int v6_flag; /* is this v6 or not */
struct in6_addr addr6; /* match address (v6) */
struct in6_addr mask6; /* match mask (v6) */

View File

@ -159,7 +159,7 @@ extern const char * modetoa (size_t);
extern const char * eventstr (int);
extern const char * ceventstr (int);
extern const char * res_match_flags(u_short);
extern const char * res_access_flags(u_short);
extern const char * res_access_flags(u_int32);
#ifdef KERNEL_PLL
extern const char * k_st_flags (u_int32);
#endif

View File

@ -83,4 +83,7 @@ do { \
msyslog msl_args; \
} while (FALSE)
extern int change_iobufs(int how);
/* how: 0->unbuffered, 1->linebuffer, 2->full */
#endif /* NTP_SYSLOG_H */

View File

@ -232,7 +232,7 @@ extern double sys_mindisp;
extern double sys_maxdist;
extern char *sys_ident; /* identity scheme */
extern void poll_update (struct peer *, u_char);
extern void poll_update (struct peer *, u_char, u_char);
extern void clear (struct peer *);
extern void clock_filter (struct peer *, double, double, double);
@ -282,7 +282,7 @@ extern u_char sys_automax; /* session key timeout */
/* ntp_util.c */
extern void init_util (void);
extern void write_stats (void);
extern void stats_config (int, const char *);
extern void stats_config (int, const char *, int optflag);
extern void record_peer_stats (sockaddr_u *, int, double, double, double, double);
extern void record_proto_stats (char *);
extern void record_loop_stats (double, double, double, double, int);
@ -568,7 +568,7 @@ extern char *group; /* group to switch to */
extern const char *chrootdir; /* directory to chroot() to */
#endif
#ifdef HAVE_WORKING_FORK
extern int waitsync_fd_to_close; /* -w/--wait-sync */
extern int daemon_pipe[2]; /* startup monitoring */
#endif
/* ntservice.c */

View File

@ -56,68 +56,11 @@
/* predicate: returns TRUE if the nanoseconds are out-of-bounds */
#define timespec_isdenormal(x) (!timespec_isnormal(x))
/* conversion between l_fp fractions and nanoseconds */
#ifdef HAVE_U_INT64
# define FTOTVN(tsf) \
((int32) \
(((u_int64)(tsf) * NANOSECONDS + 0x80000000) >> 32))
# define TVNTOF(tvu) \
((u_int32) \
((((u_int64)(tvu) << 32) + NANOSECONDS / 2) / \
NANOSECONDS))
#else
# define NSECFRAC (FRAC / NANOSECONDS)
# define FTOTVN(tsf) \
((int32)((tsf) / NSECFRAC + 0.5))
# define TVNTOF(tvu) \
((u_int32)((tvu) * NSECFRAC + 0.5))
#endif
/* make sure nanoseconds are in nominal range */
static inline struct timespec
normalize_tspec(
struct timespec x
)
{
#if SIZEOF_LONG > 4
long z;
/*
* tv_nsec is of type 'long', and on a 64-bit machine using only
* loops becomes prohibitive once the upper 32 bits get
* involved. On the other hand, division by constant should be
* fast enough; so we do a division of the nanoseconds in that
* case. The floor adjustment step follows with the standard
* normalisation loops. And labs() is intentionally not used
* here: it has implementation-defined behaviour when applied
* to LONG_MIN.
*/
if (x.tv_nsec < -3l * NANOSECONDS ||
x.tv_nsec > 3l * NANOSECONDS) {
z = x.tv_nsec / NANOSECONDS;
x.tv_nsec -= z * NANOSECONDS;
x.tv_sec += z;
}
#endif
/* since 10**9 is close to 2**32, we don't divide but do a
* normalisation in a loop; this takes 3 steps max, and should
* outperform a division even if the mul-by-inverse trick is
* employed. */
if (x.tv_nsec < 0)
do {
x.tv_nsec += NANOSECONDS;
x.tv_sec--;
} while (x.tv_nsec < 0);
else if (x.tv_nsec >= NANOSECONDS)
do {
x.tv_nsec -= NANOSECONDS;
x.tv_sec++;
} while (x.tv_nsec >= NANOSECONDS);
return x;
}
extern struct timespec normalize_tspec(struct timespec x);
/* x = a + b */
static inline struct timespec
@ -196,45 +139,13 @@ neg_tspec(
}
/* x = abs(a) */
static inline struct timespec
abs_tspec(
struct timespec a
)
{
struct timespec c;
c = normalize_tspec(a);
if (c.tv_sec < 0) {
if (c.tv_nsec != 0) {
c.tv_sec = -c.tv_sec - 1;
c.tv_nsec = NANOSECONDS - c.tv_nsec;
} else {
c.tv_sec = -c.tv_sec;
}
}
return c;
}
struct timespec abs_tspec(struct timespec a);
/*
* compare previously-normalised a and b
* return 1 / 0 / -1 if a < / == / > b
*/
static inline int
cmp_tspec(
struct timespec a,
struct timespec b
)
{
int r;
r = (a.tv_sec > b.tv_sec) - (a.tv_sec < b.tv_sec);
if (0 == r)
r = (a.tv_nsec > b.tv_nsec) -
(a.tv_nsec < b.tv_nsec);
return r;
}
extern int cmp_tspec(struct timespec a, struct timespec b);
/*
* compare possibly-denormal a and b
@ -253,19 +164,7 @@ cmp_tspec_denorm(
* test previously-normalised a
* return 1 / 0 / -1 if a < / == / > 0
*/
static inline int
test_tspec(
struct timespec a
)
{
int r;
r = (a.tv_sec > 0) - (a.tv_sec < 0);
if (r == 0)
r = (a.tv_nsec > 0);
return r;
}
extern int test_tspec(struct timespec a);
/*
* test possibly-denormal a
@ -293,20 +192,7 @@ tspectoa(
*/
/* convert from timespec duration to l_fp duration */
static inline l_fp
tspec_intv_to_lfp(
struct timespec x
)
{
struct timespec v;
l_fp y;
v = normalize_tspec(x);
y.l_uf = TVNTOF(v.tv_nsec);
y.l_i = (int32)v.tv_sec;
return y;
}
extern l_fp tspec_intv_to_lfp(struct timespec x);
/* x must be UN*X epoch, output will be in NTP epoch */
static inline l_fp
@ -323,71 +209,14 @@ tspec_stamp_to_lfp(
}
/* convert from l_fp type, relative signed/unsigned and absolute */
static inline struct timespec
lfp_intv_to_tspec(
l_fp x
)
{
struct timespec out;
l_fp absx;
int neg;
neg = L_ISNEG(&x);
absx = x;
if (neg) {
L_NEG(&absx);
}
out.tv_nsec = FTOTVN(absx.l_uf);
out.tv_sec = absx.l_i;
if (neg) {
out.tv_sec = -out.tv_sec;
out.tv_nsec = -out.tv_nsec;
out = normalize_tspec(out);
}
return out;
}
static inline struct timespec
lfp_uintv_to_tspec(
l_fp x
)
{
struct timespec out;
out.tv_nsec = FTOTVN(x.l_uf);
out.tv_sec = x.l_ui;
return out;
}
extern struct timespec lfp_intv_to_tspec(l_fp x);
extern struct timespec lfp_uintv_to_tspec(l_fp x);
/*
* absolute (timestamp) conversion. Input is time in NTP epoch, output
* is in UN*X epoch. The NTP time stamp will be expanded around the
* pivot time *p or the current time, if p is NULL.
*/
static inline struct timespec
lfp_stamp_to_tspec(
l_fp x,
const time_t * p
)
{
struct timespec out;
vint64 sec;
sec = ntpcal_ntp_to_time(x.l_ui, p);
out.tv_nsec = FTOTVN(x.l_uf);
/* copying a vint64 to a time_t needs some care... */
#if SIZEOF_TIME_T <= 4
out.tv_sec = (time_t)sec.d_s.lo;
#elif defined(HAVE_INT64)
out.tv_sec = (time_t)sec.q_s;
#else
out.tv_sec = ((time_t)sec.d_s.hi << 32) | sec.d_s.lo;
#endif
return out;
}
extern struct timespec lfp_stamp_to_tspec(l_fp x, const time_t *pivot);
#endif /* TIMESPECOPS_H */

View File

@ -0,0 +1,42 @@
/*
* timexsup.h - 'struct timex' support functions
*
* Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
* The contents of 'html/copyright.html' apply.
*/
#ifndef TIMEXSUP_H
#define TIMEXSUP_H
/* convert a 'long' time value (in usec or nsec) into seconds, expressed
* as a 'double'. If 'STA_NANO' is not defined, this will always convert
* from usec. ('STA_NANO' is Linux specific at the time of this
* writing.)
*
* If 'STA_NANO' is defined, it will be checked in 'status' to decide
* which time base (usec or nsec) applies for this conversion.
*/
extern double dbl_from_var_long(long lval, int status);
/* convert a 'long' time value in usec into seconds, expressed as
* 'double'. This function is there for pure symmetry right now -- it
* just casts and scales without any additional bells and whistles.
*/
extern double dbl_from_usec_long(long lval);
/* If MOD_NANO is defined, set the MOD_NANO bit in '*modes' and
* calculate the time stamp in nsec; otherwise, calculate the result in
* usec.
*
* Applies proper bounds checks and saturation on LONG_MAX/LONG_MIN to
* avoid undefined behaviour.
*/
extern long var_long_from_dbl(double dval, unsigned int *modes);
/* convert a 'double' time value (in seconds) into usec with proper
* bounds check and range clamp.
*/
extern long usec_long_from_dbl(double dval);
#endif
/* -*- that's all folks -*- */

View File

@ -81,6 +81,7 @@ libntp_a_SRCS = \
msyslog.c \
netof.c \
ntp_calendar.c \
ntp_calgps.c \
ntp_crypto_rnd.c \
ntp_intres.c \
ntp_libopts.c \
@ -104,8 +105,10 @@ libntp_a_SRCS = \
strdup.c \
strl_obsd.c \
syssignal.c \
timespecops.c \
timetoa.c \
timevalops.c \
timexsup.c \
uglydate.c \
vint64ops.c \
work_fork.c \

View File

@ -154,13 +154,14 @@ am__libntp_a_SOURCES_DIST = systime.c a_md5encrypt.c adjtime.c \
hextoint.c hextolfp.c humandate.c icom.c iosignal.c \
is_ip_address.c lib_strbuf.c libssl_compat.c machines.c \
mktime.c modetoa.c mstolfp.c msyslog.c netof.c ntp_calendar.c \
ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c ntp_lineedit.c \
ntp_random.c ntp_rfc2553.c ntp_worker.c numtoa.c numtohost.c \
octtoint.c prettydate.c refidsmear.c recvbuff.c refnumtoa.c \
snprintf.c socket.c socktoa.c socktohost.c ssl_init.c \
statestr.c strdup.c strl_obsd.c syssignal.c timetoa.c \
timevalops.c uglydate.c vint64ops.c work_fork.c work_thread.c \
xsbprintf.c ymd2yd.c $(srcdir)/../lib/isc/assertions.c \
ntp_calgps.c ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c \
ntp_lineedit.c ntp_random.c ntp_rfc2553.c ntp_worker.c \
numtoa.c numtohost.c octtoint.c prettydate.c refidsmear.c \
recvbuff.c refnumtoa.c snprintf.c socket.c socktoa.c \
socktohost.c ssl_init.c statestr.c strdup.c strl_obsd.c \
syssignal.c timespecops.c timetoa.c timevalops.c timexsup.c \
uglydate.c vint64ops.c work_fork.c work_thread.c xsbprintf.c \
ymd2yd.c $(srcdir)/../lib/isc/assertions.c \
$(srcdir)/../lib/isc/buffer.c \
$(srcdir)/../lib/isc/backtrace-emptytbl.c \
$(srcdir)/../lib/isc/backtrace.c \
@ -213,7 +214,7 @@ am__objects_4 = a_md5encrypt.$(OBJEXT) adjtime.$(OBJEXT) \
is_ip_address.$(OBJEXT) lib_strbuf.$(OBJEXT) \
libssl_compat.$(OBJEXT) machines.$(OBJEXT) mktime.$(OBJEXT) \
modetoa.$(OBJEXT) mstolfp.$(OBJEXT) msyslog.$(OBJEXT) \
netof.$(OBJEXT) ntp_calendar.$(OBJEXT) \
netof.$(OBJEXT) ntp_calendar.$(OBJEXT) ntp_calgps.$(OBJEXT) \
ntp_crypto_rnd.$(OBJEXT) ntp_intres.$(OBJEXT) \
ntp_libopts.$(OBJEXT) ntp_lineedit.$(OBJEXT) \
ntp_random.$(OBJEXT) ntp_rfc2553.$(OBJEXT) \
@ -222,10 +223,11 @@ am__objects_4 = a_md5encrypt.$(OBJEXT) adjtime.$(OBJEXT) \
recvbuff.$(OBJEXT) refnumtoa.$(OBJEXT) snprintf.$(OBJEXT) \
socket.$(OBJEXT) socktoa.$(OBJEXT) socktohost.$(OBJEXT) \
ssl_init.$(OBJEXT) statestr.$(OBJEXT) strdup.$(OBJEXT) \
strl_obsd.$(OBJEXT) syssignal.$(OBJEXT) timetoa.$(OBJEXT) \
timevalops.$(OBJEXT) uglydate.$(OBJEXT) vint64ops.$(OBJEXT) \
work_fork.$(OBJEXT) work_thread.$(OBJEXT) xsbprintf.$(OBJEXT) \
ymd2yd.$(OBJEXT) $(am__objects_3) $(am__objects_1)
strl_obsd.$(OBJEXT) syssignal.$(OBJEXT) timespecops.$(OBJEXT) \
timetoa.$(OBJEXT) timevalops.$(OBJEXT) timexsup.$(OBJEXT) \
uglydate.$(OBJEXT) vint64ops.$(OBJEXT) work_fork.$(OBJEXT) \
work_thread.$(OBJEXT) xsbprintf.$(OBJEXT) ymd2yd.$(OBJEXT) \
$(am__objects_3) $(am__objects_1)
am_libntp_a_OBJECTS = systime.$(OBJEXT) $(am__objects_4)
libntp_a_OBJECTS = $(am_libntp_a_OBJECTS)
libntpsim_a_AR = $(AR) $(ARFLAGS)
@ -238,13 +240,14 @@ am__libntpsim_a_SOURCES_DIST = systime_s.c a_md5encrypt.c adjtime.c \
hextoint.c hextolfp.c humandate.c icom.c iosignal.c \
is_ip_address.c lib_strbuf.c libssl_compat.c machines.c \
mktime.c modetoa.c mstolfp.c msyslog.c netof.c ntp_calendar.c \
ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c ntp_lineedit.c \
ntp_random.c ntp_rfc2553.c ntp_worker.c numtoa.c numtohost.c \
octtoint.c prettydate.c refidsmear.c recvbuff.c refnumtoa.c \
snprintf.c socket.c socktoa.c socktohost.c ssl_init.c \
statestr.c strdup.c strl_obsd.c syssignal.c timetoa.c \
timevalops.c uglydate.c vint64ops.c work_fork.c work_thread.c \
xsbprintf.c ymd2yd.c $(srcdir)/../lib/isc/assertions.c \
ntp_calgps.c ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c \
ntp_lineedit.c ntp_random.c ntp_rfc2553.c ntp_worker.c \
numtoa.c numtohost.c octtoint.c prettydate.c refidsmear.c \
recvbuff.c refnumtoa.c snprintf.c socket.c socktoa.c \
socktohost.c ssl_init.c statestr.c strdup.c strl_obsd.c \
syssignal.c timespecops.c timetoa.c timevalops.c timexsup.c \
uglydate.c vint64ops.c work_fork.c work_thread.c xsbprintf.c \
ymd2yd.c $(srcdir)/../lib/isc/assertions.c \
$(srcdir)/../lib/isc/buffer.c \
$(srcdir)/../lib/isc/backtrace-emptytbl.c \
$(srcdir)/../lib/isc/backtrace.c \
@ -675,6 +678,7 @@ libntp_a_SRCS = \
msyslog.c \
netof.c \
ntp_calendar.c \
ntp_calgps.c \
ntp_crypto_rnd.c \
ntp_intres.c \
ntp_libopts.c \
@ -698,8 +702,10 @@ libntp_a_SRCS = \
strdup.c \
strl_obsd.c \
syssignal.c \
timespecops.c \
timetoa.c \
timevalops.c \
timexsup.c \
uglydate.c \
vint64ops.c \
work_fork.c \
@ -834,6 +840,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netof.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netscope.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_calendar.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_calgps.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_crypto_rnd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_intres.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_libopts.Po@am__quote@
@ -870,8 +877,10 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/task.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timespecops.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timetoa.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timevalops.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timexsup.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsmemcmp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uglydate.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vint64ops.Po@am__quote@

View File

@ -15,6 +15,19 @@
#include "ntp_stdlib.h"
#include "ntp_assert.h"
#define PORTSTR(x) _PORTSTR(x)
#define _PORTSTR(x) #x
static int
isnumstr(
const char *s
)
{
while (*s >= '0' && *s <= '9')
++s;
return !*s;
}
/*
* decodenetnum convert text IP address and port to sockaddr_u
*
@ -26,22 +39,25 @@ decodenetnum(
sockaddr_u *netnum
)
{
static const char * const servicename = "ntp";
static const char * const serviceport = PORTSTR(NTP_PORT);
struct addrinfo hints, *ai = NULL;
int err;
u_short port;
const char *cp;
const char *host_str;
const char *port_str;
char *pp;
char *np;
char name[80];
char nbuf[80];
REQUIRE(num != NULL);
if (strlen(num) >= sizeof(name)) {
return 0;
if (strlen(num) >= sizeof(nbuf)) {
printf("length error\n");
return FALSE;
}
port_str = NULL;
port_str = servicename;
if ('[' != num[0]) {
/*
* to distinguish IPv6 embedded colons from a port
@ -50,37 +66,53 @@ decodenetnum(
*/
pp = strchr(num, ':');
if (NULL == pp)
cp = num; /* no colons */
host_str = num; /* no colons */
else if (NULL != strchr(pp + 1, ':'))
cp = num; /* two or more colons */
host_str = num; /* two or more colons */
else { /* one colon */
strlcpy(name, num, sizeof(name));
cp = name;
pp = strchr(cp, ':');
strlcpy(nbuf, num, sizeof(nbuf));
host_str = nbuf;
pp = strchr(nbuf, ':');
*pp = '\0';
port_str = pp + 1;
}
} else {
cp = num + 1;
np = name;
while (*cp && ']' != *cp)
*np++ = *cp++;
host_str = np = nbuf;
while (*++num && ']' != *num)
*np++ = *num;
*np = 0;
if (']' == cp[0] && ':' == cp[1] && '\0' != cp[2])
port_str = &cp[2];
cp = name;
if (']' == num[0] && ':' == num[1] && '\0' != num[2])
port_str = &num[2];
}
if ( ! *host_str)
return FALSE;
if ( ! *port_str)
port_str = servicename;
ZERO(hints);
hints.ai_flags = Z_AI_NUMERICHOST;
err = getaddrinfo(cp, "ntp", &hints, &ai);
hints.ai_flags |= Z_AI_NUMERICHOST;
if (isnumstr(port_str))
hints.ai_flags |= Z_AI_NUMERICSERV;
err = getaddrinfo(host_str, port_str, &hints, &ai);
/* retry with default service name if the service lookup failed */
if (err == EAI_SERVICE && strcmp(port_str, servicename)) {
hints.ai_flags &= ~Z_AI_NUMERICSERV;
port_str = servicename;
err = getaddrinfo(host_str, port_str, &hints, &ai);
}
/* retry another time with default service port if the service lookup failed */
if (err == EAI_SERVICE && strcmp(port_str, serviceport)) {
hints.ai_flags |= Z_AI_NUMERICSERV;
port_str = serviceport;
err = getaddrinfo(host_str, port_str, &hints, &ai);
}
if (err != 0)
return 0;
return FALSE;
INSIST(ai->ai_addrlen <= sizeof(*netnum));
ZERO(*netnum);
memcpy(netnum, ai->ai_addr, ai->ai_addrlen);
freeaddrinfo(ai);
if (NULL == port_str || 1 != sscanf(port_str, "%hu", &port))
port = NTP_PORT;
SET_PORT(netnum, port);
return 1;
return TRUE;
}

View File

@ -12,7 +12,7 @@
char *
dofptoa(
u_fp fpv,
int neg,
char sign,
short ndec,
int msec
)
@ -106,8 +106,8 @@ dofptoa(
* Copy it into the buffer, asciizing as we go.
*/
bp = buf;
if (neg)
*bp++ = '-';
if (sign)
*bp++ = sign;
while (cp < cpend) {
if (cp == cpdec)
@ -135,7 +135,7 @@ fptoa(
plusfp = (u_fp)fpv;
}
return dofptoa(plusfp, neg, ndec, FALSE);
return dofptoa(plusfp, (neg?'-':0), ndec, FALSE);
}
@ -155,5 +155,5 @@ fptoms(
plusfp = (u_fp)fpv;
}
return dofptoa(plusfp, neg, ndec, TRUE);
return dofptoa(plusfp, (neg?'-':0), ndec, TRUE);
}

View File

@ -13,7 +13,7 @@ char *
dolfptoa(
u_int32 fpi,
u_int32 fpv,
int neg,
char sign,
short ndec,
int msec
)
@ -120,8 +120,8 @@ dolfptoa(
cp = cpdec - 1;
bp = buf;
if (neg)
*bp++ = '-';
if (sign)
*bp++ = sign;
while (cp < cpend) {
if (cp == cpdec)
*bp++ = '.';
@ -150,7 +150,7 @@ mfptoa(
M_NEG(fpi, fpf);
}
return dolfptoa(fpi, fpf, isneg, ndec, FALSE);
return dolfptoa(fpi, fpf, (isneg?'-':'+'), ndec, FALSE);
}
@ -168,7 +168,7 @@ mfptoms(
M_NEG(fpi, fpf);
}
return dolfptoa(fpi, fpf, isneg, ndec, TRUE);
return dolfptoa(fpi, fpf, (isneg?'-':'+'), ndec, TRUE);
}

View File

@ -22,7 +22,7 @@ mstolfp(
/*
* We understand numbers of the form:
*
* [spaces][-][digits][.][digits][spaces|\n|\0]
* [spaces][-|+][digits][.][digits][spaces|\n|\0]
*
* This is one enormous hack. Since I didn't feel like
* rewriting the decoding routine for milliseconds, what
@ -35,9 +35,8 @@ mstolfp(
while (isspace((unsigned char)*cp))
cp++;
if (*cp == '-') {
*bp++ = '-';
cp++;
if (*cp == '-' || *cp == '+') {
*bp++ = *cp++;
}
if (*cp != '.' && !isdigit((unsigned char)*cp))

View File

@ -582,3 +582,41 @@ setup_logfile(
msyslog(LOG_ERR, "Cannot reopen log file %s, %m",
syslog_fname);
}
/* Helper for unit tests, where stdout + stderr are piped to the same
* stream. This works moderately reliable only if both streams are
* unbuffered or line buffered. Unfortunately stdout can be fully
* buffered on pipes or files...
*/
int
change_iobufs(
int how
)
{
int retv = 0;
# ifdef HAVE_SETVBUF
int mode;
switch (how) {
case 0 : mode = _IONBF; break; /* no buffering */
case 1 : mode = _IOLBF; break; /* line buffering */
case 2 : mode = _IOFBF; break; /* full buffering */
default: mode = _IOLBF; break; /* line buffering */
}
retv = 1;
if (setvbuf(stdout, NULL, mode, BUFSIZ) != 0)
retv = -1;
if (setvbuf(stderr, NULL, mode, BUFSIZ) != 0)
retv = -1;
# else
UNUSED_ARG(how);
# endif
return retv;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,634 @@
/*
* ntp_calgps.c - calendar for GPS/GNSS based clocks
*
* Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
* The contents of 'html/copyright.html' apply.
*
* --------------------------------------------------------------------
*
* This module implements stuff often used with GPS/GNSS receivers
*/
#include <config.h>
#include <sys/types.h>
#include "ntp_types.h"
#include "ntp_calendar.h"
#include "ntp_calgps.h"
#include "ntp_stdlib.h"
#include "ntp_unixtime.h"
#include "ntp_fp.h"
#include "ntpd.h"
#include "vint64ops.h"
/* ====================================================================
* misc. helpers -- might go elsewhere sometime?
* ====================================================================
*/
l_fp
ntpfp_with_fudge(
l_fp lfp,
double ofs
)
{
l_fp fpo;
/* calculate 'lfp - ofs' as '(l_fp)(-ofs) + lfp': negating a
* double is cheap, as it only flips one bit...
*/
ofs = -ofs;
DTOLFP(ofs, &fpo);
L_ADD(&fpo, &lfp);
return fpo;
}
/* ====================================================================
* GPS calendar functions
* ====================================================================
*/
/* --------------------------------------------------------------------
* normalization functions for day/time and week/time representations.
* Since we only use moderate offsets (leap second corrections and
* alike) it does not really pay off to do a floor-corrected division
* here. We use compare/decrement/increment loops instead.
* --------------------------------------------------------------------
*/
static void
_norm_ntp_datum(
TNtpDatum * datum
)
{
static const int32_t limit = SECSPERDAY;
if (datum->secs >= limit) {
do
++datum->days;
while ((datum->secs -= limit) >= limit);
} else if (datum->secs < 0) {
do
--datum->days;
while ((datum->secs += limit) < 0);
}
}
static void
_norm_gps_datum(
TGpsDatum * datum
)
{
static const int32_t limit = 7 * SECSPERDAY;
if (datum->wsecs >= limit) {
do
++datum->weeks;
while ((datum->wsecs -= limit) >= limit);
} else if (datum->wsecs < 0) {
do
--datum->weeks;
while ((datum->wsecs += limit) < 0);
}
}
/* --------------------------------------------------------------------
* Add an offset to a day/time and week/time representation.
*
* !!Attention!! the offset should be small, compared to the time period
* (either a day or a week).
* --------------------------------------------------------------------
*/
void
gpsntp_add_offset(
TNtpDatum * datum,
l_fp offset
)
{
/* fraction can be added easily */
datum->frac += offset.l_uf;
datum->secs += (datum->frac < offset.l_uf);
/* avoid integer overflow on the seconds */
if (offset.l_ui >= INT32_MAX)
datum->secs -= (int32_t)~offset.l_ui + 1;
else
datum->secs += (int32_t)offset.l_ui;
_norm_ntp_datum(datum);
}
void
gpscal_add_offset(
TGpsDatum * datum,
l_fp offset
)
{
/* fraction can be added easily */
datum->frac += offset.l_uf;
datum->wsecs += (datum->frac < offset.l_uf);
/* avoid integer overflow on the seconds */
if (offset.l_ui >= INT32_MAX)
datum->wsecs -= (int32_t)~offset.l_ui + 1;
else
datum->wsecs += (int32_t)offset.l_ui;
_norm_gps_datum(datum);
}
/* -------------------------------------------------------------------
* API functions civil calendar and NTP datum
* -------------------------------------------------------------------
*/
static TNtpDatum
_gpsntp_fix_gps_era(
TcNtpDatum * in
)
{
/* force result in basedate era
*
* When calculating this directly in days, we have to execute a
* real modulus calculation, since we're obviously not doing a
* modulus by a power of 2. Executing this as true floor mod
* needs some care and is done under explicit usage of one's
* complement and masking to get mostly branchless code.
*/
static uint32_t const clen = 7*1024;
uint32_t base, days, sign;
TNtpDatum out = *in;
/* Get base in NTP day scale. No overflows here. */
base = (basedate_get_gpsweek() + GPSNTP_WSHIFT) * 7
- GPSNTP_DSHIFT;
days = out.days;
sign = (uint32_t)-(days < base);
days = sign ^ (days - base);
days %= clen;
days = base + (sign & clen) + (sign ^ days);
out.days = days;
return out;
}
TNtpDatum
gpsntp_fix_gps_era(
TcNtpDatum * in
)
{
TNtpDatum out = *in;
_norm_ntp_datum(&out);
return _gpsntp_fix_gps_era(&out);
}
/* ----------------------------------------------------------------- */
static TNtpDatum
_gpsntp_from_daytime(
TcCivilDate * jd,
l_fp fofs,
TcNtpDatum * pivot,
int warp
)
{
static const int32_t shift = SECSPERDAY / 2;
TNtpDatum retv;
/* set result based on pivot -- ops order is important here */
ZERO(retv);
retv.secs = ntpcal_date_to_daysec(jd);
gpsntp_add_offset(&retv, fofs); /* result is normalized */
retv.days = pivot->days;
/* Manual periodic extension without division: */
if (pivot->secs < shift) {
int32_t lim = pivot->secs + shift;
retv.days -= (retv.secs > lim ||
(retv.secs == lim && retv.frac >= pivot->frac));
} else {
int32_t lim = pivot->secs - shift;
retv.days += (retv.secs < lim ||
(retv.secs == lim && retv.frac < pivot->frac));
}
return warp ? _gpsntp_fix_gps_era(&retv) : retv;
}
/* -----------------------------------------------------------------
* Given the time-of-day part of a civil datum and an additional
* (fractional) offset, calculate a full time stamp around a given pivot
* time so that the difference between the pivot and the resulting time
* stamp is less or equal to 12 hours absolute.
*/
TNtpDatum
gpsntp_from_daytime2_ex(
TcCivilDate * jd,
l_fp fofs,
TcNtpDatum * pivot,
int/*BOOL*/ warp
)
{
TNtpDatum dpiv = *pivot;
_norm_ntp_datum(&dpiv);
return _gpsntp_from_daytime(jd, fofs, &dpiv, warp);
}
/* -----------------------------------------------------------------
* This works similar to 'gpsntp_from_daytime1()' and actually even uses
* it, but the pivot is calculated from the pivot given as 'l_fp' in NTP
* time scale. This is in turn expanded around the current system time,
* and the resulting absolute pivot is then used to calculate the full
* NTP time stamp.
*/
TNtpDatum
gpsntp_from_daytime1_ex(
TcCivilDate * jd,
l_fp fofs,
l_fp pivot,
int/*BOOL*/ warp
)
{
vint64 pvi64;
TNtpDatum dpiv;
ntpcal_split split;
pvi64 = ntpcal_ntp_to_ntp(pivot.l_ui, NULL);
split = ntpcal_daysplit(&pvi64);
dpiv.days = split.hi;
dpiv.secs = split.lo;
dpiv.frac = pivot.l_uf;
return _gpsntp_from_daytime(jd, fofs, &dpiv, warp);
}
/* -----------------------------------------------------------------
* Given a calendar date, zap it into a GPS time format and then convert
* that one into the NTP time scale.
*/
TNtpDatum
gpsntp_from_calendar_ex(
TcCivilDate * jd,
l_fp fofs,
int/*BOOL*/ warp
)
{
TGpsDatum gps;
gps = gpscal_from_calendar_ex(jd, fofs, warp);
return gpsntp_from_gpscal_ex(&gps, FALSE);
}
/* -----------------------------------------------------------------
* create a civil calendar datum from a NTP date representation
*/
void
gpsntp_to_calendar(
TCivilDate * cd,
TcNtpDatum * nd
)
{
memset(cd, 0, sizeof(*cd));
ntpcal_rd_to_date(
cd,
nd->days + DAY_NTP_STARTS + ntpcal_daysec_to_date(
cd, nd->secs));
}
/* -----------------------------------------------------------------
* get day/tod representation from week/tow datum
*/
TNtpDatum
gpsntp_from_gpscal_ex(
TcGpsDatum * gd,
int/*BOOL*/ warp
)
{
TNtpDatum retv;
vint64 ts64;
ntpcal_split split;
TGpsDatum date = *gd;
if (warp) {
uint32_t base = basedate_get_gpsweek() + GPSNTP_WSHIFT;
_norm_gps_datum(&date);
date.weeks = ((date.weeks - base) & 1023u) + base;
}
ts64 = ntpcal_weekjoin(date.weeks, date.wsecs);
ts64 = subv64u32(&ts64, (GPSNTP_DSHIFT * SECSPERDAY));
split = ntpcal_daysplit(&ts64);
retv.frac = gd->frac;
retv.secs = split.lo;
retv.days = split.hi;
return retv;
}
/* -----------------------------------------------------------------
* get LFP from ntp datum
*/
l_fp
ntpfp_from_ntpdatum(
TcNtpDatum * nd
)
{
l_fp retv;
retv.l_uf = nd->frac;
retv.l_ui = nd->days * (uint32_t)SECSPERDAY
+ nd->secs;
return retv;
}
/* -------------------------------------------------------------------
* API functions GPS week calendar
*
* Here we use a calendar base of 1899-12-31, so the NTP epoch has
* { 0, 86400.0 } in this representation.
* -------------------------------------------------------------------
*/
static TGpsDatum
_gpscal_fix_gps_era(
TcGpsDatum * in
)
{
/* force result in basedate era
*
* This is based on calculating the modulus to a power of two,
* so signed integer overflow does not affect the result. Which
* in turn makes for a very compact calculation...
*/
uint32_t base, week;
TGpsDatum out = *in;
week = out.weeks;
base = basedate_get_gpsweek() + GPSNTP_WSHIFT;
week = base + ((week - base) & (GPSWEEKS - 1));
out.weeks = week;
return out;
}
TGpsDatum
gpscal_fix_gps_era(
TcGpsDatum * in
)
{
TGpsDatum out = *in;
_norm_gps_datum(&out);
return _gpscal_fix_gps_era(&out);
}
/* -----------------------------------------------------------------
* Given a calendar date, zap it into a GPS time format and the do a
* proper era mapping in the GPS time scale, based on the GPS base date,
* if so requested.
*
* This function also augments the century if just a 2-digit year
* (0..99) is provided on input.
*
* This is a fail-safe against GPS receivers with an unknown starting
* point for their internal calendar calculation and therefore
* unpredictable (but reproducible!) rollover behavior. While there
* *are* receivers that create a full date in the proper way, many
* others just don't. The overall damage is minimized by simply not
* trusting the era mapping of the receiver and doing the era assignment
* with a configurable base date *inside* ntpd.
*/
TGpsDatum
gpscal_from_calendar_ex(
TcCivilDate * jd,
l_fp fofs,
int/*BOOL*/ warp
)
{
/* (-DAY_GPS_STARTS) (mod 7*1024) -- complement of cycle shift */
static const uint32_t s_compl_shift =
(7 * 1024) - DAY_GPS_STARTS % (7 * 1024);
TGpsDatum gps;
TCivilDate cal;
int32_t days, week;
/* if needed, convert from 2-digit year to full year
* !!NOTE!! works only between 1980 and 2079!
*/
cal = *jd;
if (cal.year < 80)
cal.year += 2000;
else if (cal.year < 100)
cal.year += 1900;
/* get RDN from date, possibly adjusting the century */
again: if (cal.month && cal.monthday) { /* use Y/M/D civil date */
days = ntpcal_date_to_rd(&cal);
} else { /* using Y/DoY date */
days = ntpcal_year_to_ystart(cal.year)
+ (int32_t)cal.yearday
- 1; /* both RDN and yearday start with '1'. */
}
/* Rebase to days after the GPS epoch. 'days' is positive here,
* but it might be less than the GPS epoch start. Depending on
* the input, we have to do different things to get the desired
* result. (Since we want to remap the era anyway, we only have
* to retain congruential identities....)
*/
if (days >= DAY_GPS_STARTS) {
/* simply shift to days since GPS epoch */
days -= DAY_GPS_STARTS;
} else if (jd->year < 100) {
/* Two-digit year on input: add another century and
* retry. This can happen only if the century expansion
* yielded a date between 1980-01-01 and 1980-01-05,
* both inclusive. We have at most one retry here.
*/
cal.year += 100;
goto again;
} else {
/* A very bad date before the GPS epoch. There's not
* much we can do, except to add the complement of
* DAY_GPS_STARTS % (7 * 1024) here, that is, use a
* congruential identity: Add the complement instead of
* subtracting the value gives a value with the same
* modulus. But of course, now we MUST to go through a
* cycle fix... because the date was obviously wrong!
*/
warp = TRUE;
days += s_compl_shift;
}
/* Splitting to weeks is simple now: */
week = days / 7;
days -= week * 7;
/* re-base on start of NTP with weeks mapped to 1024 weeks
* starting with the GPS base day set in the calendar.
*/
gps.weeks = week + GPSNTP_WSHIFT;
gps.wsecs = days * SECSPERDAY + ntpcal_date_to_daysec(&cal);
gps.frac = 0;
gpscal_add_offset(&gps, fofs);
return warp ? _gpscal_fix_gps_era(&gps) : gps;
}
/* -----------------------------------------------------------------
* get civil date from week/tow representation
*/
void
gpscal_to_calendar(
TCivilDate * cd,
TcGpsDatum * wd
)
{
TNtpDatum nd;
memset(cd, 0, sizeof(*cd));
nd = gpsntp_from_gpscal_ex(wd, FALSE);
gpsntp_to_calendar(cd, &nd);
}
/* -----------------------------------------------------------------
* Given the week and seconds in week, as well as the fraction/offset
* (which should/could include the leap seconds offset), unfold the
* weeks (which are assumed to have just 10 bits) into expanded weeks
* based on the GPS base date derived from the build date (default) or
* set by the configuration.
*
* !NOTE! This function takes RAW GPS weeks, aligned to the GPS start
* (1980-01-06) on input. The output weeks will be aligned to NTPD's
* week calendar start (1899-12-31)!
*/
TGpsDatum
gpscal_from_gpsweek(
uint16_t week,
int32_t secs,
l_fp fofs
)
{
TGpsDatum retv;
retv.frac = 0;
retv.wsecs = secs;
retv.weeks = week + GPSNTP_WSHIFT;
gpscal_add_offset(&retv, fofs);
return _gpscal_fix_gps_era(&retv);
}
/* -----------------------------------------------------------------
* internal work horse for time-of-week expansion
*/
static TGpsDatum
_gpscal_from_weektime(
int32_t wsecs,
l_fp fofs,
TcGpsDatum * pivot
)
{
static const int32_t shift = SECSPERWEEK / 2;
TGpsDatum retv;
/* set result based on pivot -- ops order is important here */
ZERO(retv);
retv.wsecs = wsecs;
gpscal_add_offset(&retv, fofs); /* result is normalized */
retv.weeks = pivot->weeks;
/* Manual periodic extension without division: */
if (pivot->wsecs < shift) {
int32_t lim = pivot->wsecs + shift;
retv.weeks -= (retv.wsecs > lim ||
(retv.wsecs == lim && retv.frac >= pivot->frac));
} else {
int32_t lim = pivot->wsecs - shift;
retv.weeks += (retv.wsecs < lim ||
(retv.wsecs == lim && retv.frac < pivot->frac));
}
return _gpscal_fix_gps_era(&retv);
}
/* -----------------------------------------------------------------
* expand a time-of-week around a pivot given as week datum
*/
TGpsDatum
gpscal_from_weektime2(
int32_t wsecs,
l_fp fofs,
TcGpsDatum * pivot
)
{
TGpsDatum wpiv = * pivot;
_norm_gps_datum(&wpiv);
return _gpscal_from_weektime(wsecs, fofs, &wpiv);
}
/* -----------------------------------------------------------------
* epand a time-of-week around an pivot given as LFP, which in turn
* is expanded around the current system time and then converted
* into a week datum.
*/
TGpsDatum
gpscal_from_weektime1(
int32_t wsecs,
l_fp fofs,
l_fp pivot
)
{
vint64 pvi64;
TGpsDatum wpiv;
ntpcal_split split;
/* get 64-bit pivot in NTP epoch */
pvi64 = ntpcal_ntp_to_ntp(pivot.l_ui, NULL);
/* convert to weeks since 1899-12-31 and seconds in week */
pvi64 = addv64u32(&pvi64, (GPSNTP_DSHIFT * SECSPERDAY));
split = ntpcal_weeksplit(&pvi64);
wpiv.weeks = split.hi;
wpiv.wsecs = split.lo;
wpiv.frac = pivot.l_uf;
return _gpscal_from_weektime(wsecs, fofs, &wpiv);
}
/* -----------------------------------------------------------------
* get week/tow representation from day/tod datum
*/
TGpsDatum
gpscal_from_gpsntp(
TcNtpDatum * gd
)
{
TGpsDatum retv;
vint64 ts64;
ntpcal_split split;
ts64 = ntpcal_dayjoin(gd->days, gd->secs);
ts64 = addv64u32(&ts64, (GPSNTP_DSHIFT * SECSPERDAY));
split = ntpcal_weeksplit(&ts64);
retv.frac = gd->frac;
retv.wsecs = split.lo;
retv.weeks = split.hi;
return retv;
}
/* -----------------------------------------------------------------
* convert week/tow to LFP stamp
*/
l_fp
ntpfp_from_gpsdatum(
TcGpsDatum * gd
)
{
l_fp retv;
retv.l_uf = gd->frac;
retv.l_ui = gd->weeks * (uint32_t)SECSPERWEEK
+ (uint32_t)gd->wsecs
- (uint32_t)SECSPERDAY * GPSNTP_DSHIFT;
return retv;
}
/* -*-EOF-*- */

View File

@ -226,7 +226,6 @@ get_full_recv_buffer(void)
LOCK();
#ifdef HAVE_SIGNALED_IO
/*
* make sure there are free buffers when we
* wander off to do lengthy packet processing with
@ -241,7 +240,6 @@ get_full_recv_buffer(void)
*/
create_buffers(RECV_INC);
}
#endif
/*
* try to grab a full buffer

View File

@ -181,16 +181,23 @@ static const struct codestring res_access_bits[] = {
{ RES_IGNORE, "ignore", 0 },
{ RES_DONTSERVE, "noserve", "serve" },
{ RES_DONTTRUST, "notrust", "trust" },
{ RES_NOQUERY, "noquery", "query" },
{ RES_NOMODIFY, "nomodify", 0 },
{ RES_VERSION, "version", 0 },
{ RES_NOPEER, "nopeer", "peer" },
{ RES_NOEPEER, "noepeer", "epeer" },
{ RES_LIMITED, "limited", 0 },
{ RES_NOQUERY, "noquery", "query" },
{ RES_NOMODIFY, "nomodify", 0 },
{ RES_NOTRAP, "notrap", "trap" },
{ RES_LPTRAP, "lptrap", 0 },
{ RES_LIMITED, "limited", 0 },
{ RES_VERSION, "version", 0 },
{ RES_KOD, "kod", 0 },
{ RES_MSSNTP, "mssntp", 0 },
{ RES_FLAKE, "flake", 0 },
{ RES_NOMRULIST, "nomrulist", 0 },
{ RES_SRVRSPFUZ, "serverresponse fuzz", 0 },
/* not used with getcode(), no terminating entry needed */
};
@ -418,7 +425,7 @@ res_match_flags(
const char *
res_access_flags(
u_short af
u_int32 af
)
{
return decode_bitflags(af, " ", res_access_bits,

View File

@ -619,12 +619,11 @@ clamp_systime(void)
{
#if SIZEOF_TIME_T > 4
struct timeval timetv, tvlast;
struct timeval tvbase, tvlast;
struct timespec timets;
uint32_t tdiff;
timetv.tv_sec = basedate_get_erabase();
tvbase.tv_sec = basedate_get_erabase();
tvbase.tv_usec = 0;
/* ---> time-critical path starts ---> */
@ -636,28 +635,24 @@ clamp_systime(void)
tvlast.tv_usec -= 1000000;
tvlast.tv_sec += 1;
}
timetv.tv_usec = tvlast.tv_usec;
tdiff = (uint32_t)(tvlast.tv_sec & UINT32_MAX) -
(uint32_t)(timetv.tv_sec & UINT32_MAX);
timetv.tv_sec += tdiff;
if (timetv.tv_sec != tvlast.tv_sec) {
if (tvbase.tv_sec > tvlast.tv_sec) {
/* now set new system time */
if (ntp_set_tod(&timetv, NULL) != 0) {
if (ntp_set_tod(&tvbase, NULL) != 0) {
msyslog(LOG_ERR, "clamp-systime: %m");
return FALSE;
}
} else {
msyslog(LOG_INFO,
"clamp-systime: clock (%s) in allowed range",
tv_fmt_libbuf(&timetv));
tv_fmt_libbuf(&tvlast));
return FALSE;
}
/* <--- time-critical path ended with 'ntp_set_tod()' <--- */
sys_residual = 0;
lamport_violated = (timetv.tv_sec < tvlast.tv_sec);
lamport_violated = (tvbase.tv_sec < tvlast.tv_sec);
if (step_callback)
(*step_callback)();
@ -668,15 +663,16 @@ clamp_systime(void)
_clear_adjtime();
# endif
update_uwtmp(timetv, tvlast);
update_uwtmp(tvbase, tvlast);
msyslog(LOG_WARNING,
"clamp-systime: clock stepped from %s to %s!",
tv_fmt_libbuf(&tvlast), tv_fmt_libbuf(&timetv));
tv_fmt_libbuf(&tvlast), tv_fmt_libbuf(&tvbase));
return TRUE;
#else
return 0;
return FALSE;
#endif
}

View File

@ -0,0 +1,233 @@
/*
* timespecops.c -- calculations on 'struct timespec' values
*
* Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
* The contents of 'html/copyright.html' apply.
*
*/
#include "config.h"
#include <sys/types.h>
#include <stdio.h>
#include <math.h>
#include "ntp.h"
#include "timetoa.h"
#include "timespecops.h"
/* nanoseconds per second */
#define NANOSECONDS 1000000000
/* conversion between l_fp fractions and nanoseconds */
#ifdef HAVE_U_INT64
# define FTOTVN(tsf) \
((int32) \
(((u_int64)(tsf) * NANOSECONDS + 0x80000000) >> 32))
# define TVNTOF(tvu) \
((u_int32) \
((((u_int64)(tvu) << 32) + NANOSECONDS / 2) / \
NANOSECONDS))
#else
# define NSECFRAC (FRAC / NANOSECONDS)
# define FTOTVN(tsf) \
((int32)((tsf) / NSECFRAC + 0.5))
# define TVNTOF(tvu) \
((u_int32)((tvu) * NSECFRAC + 0.5))
#endif
/* make sure nanoseconds are in nominal range */
struct timespec
normalize_tspec(
struct timespec x
)
{
#if SIZEOF_LONG > 4
long z;
/*
* tv_nsec is of type 'long', and on a 64-bit machine using only
* loops becomes prohibitive once the upper 32 bits get
* involved. On the other hand, division by constant should be
* fast enough; so we do a division of the nanoseconds in that
* case. The floor adjustment step follows with the standard
* normalisation loops. And labs() is intentionally not used
* here: it has implementation-defined behaviour when applied
* to LONG_MIN.
*/
if (x.tv_nsec < -3l * NANOSECONDS ||
x.tv_nsec > 3l * NANOSECONDS) {
z = x.tv_nsec / NANOSECONDS;
x.tv_nsec -= z * NANOSECONDS;
x.tv_sec += z;
}
#endif
/* since 10**9 is close to 2**32, we don't divide but do a
* normalisation in a loop; this takes 3 steps max, and should
* outperform a division even if the mul-by-inverse trick is
* employed. */
if (x.tv_nsec < 0)
do {
x.tv_nsec += NANOSECONDS;
x.tv_sec--;
} while (x.tv_nsec < 0);
else if (x.tv_nsec >= NANOSECONDS)
do {
x.tv_nsec -= NANOSECONDS;
x.tv_sec++;
} while (x.tv_nsec >= NANOSECONDS);
return x;
}
/* x = abs(a) */
struct timespec
abs_tspec(
struct timespec a
)
{
struct timespec c;
c = normalize_tspec(a);
if (c.tv_sec < 0) {
if (c.tv_nsec != 0) {
c.tv_sec = -c.tv_sec - 1;
c.tv_nsec = NANOSECONDS - c.tv_nsec;
} else {
c.tv_sec = -c.tv_sec;
}
}
return c;
}
/*
* compare previously-normalised a and b
* return 1 / 0 / -1 if a < / == / > b
*/
int
cmp_tspec(
struct timespec a,
struct timespec b
)
{
int r;
r = (a.tv_sec > b.tv_sec) - (a.tv_sec < b.tv_sec);
if (0 == r)
r = (a.tv_nsec > b.tv_nsec) -
(a.tv_nsec < b.tv_nsec);
return r;
}
/*
* test previously-normalised a
* return 1 / 0 / -1 if a < / == / > 0
*/
int
test_tspec(
struct timespec a
)
{
int r;
r = (a.tv_sec > 0) - (a.tv_sec < 0);
if (r == 0)
r = (a.tv_nsec > 0);
return r;
}
/*
* convert to l_fp type, relative and absolute
*/
/* convert from timespec duration to l_fp duration */
l_fp
tspec_intv_to_lfp(
struct timespec x
)
{
struct timespec v;
l_fp y;
v = normalize_tspec(x);
y.l_uf = TVNTOF(v.tv_nsec);
y.l_i = (int32)v.tv_sec;
return y;
}
/* convert from l_fp type, relative signed/unsigned and absolute */
struct timespec
lfp_intv_to_tspec(
l_fp x
)
{
struct timespec out;
l_fp absx;
int neg;
neg = L_ISNEG(&x);
absx = x;
if (neg) {
L_NEG(&absx);
}
out.tv_nsec = FTOTVN(absx.l_uf);
out.tv_sec = absx.l_i;
if (neg) {
out.tv_sec = -out.tv_sec;
out.tv_nsec = -out.tv_nsec;
out = normalize_tspec(out);
}
return out;
}
struct timespec
lfp_uintv_to_tspec(
l_fp x
)
{
struct timespec out;
out.tv_nsec = FTOTVN(x.l_uf);
out.tv_sec = x.l_ui;
return out;
}
/*
* absolute (timestamp) conversion. Input is time in NTP epoch, output
* is in UN*X epoch. The NTP time stamp will be expanded around the
* pivot time *p or the current time, if p is NULL.
*/
struct timespec
lfp_stamp_to_tspec(
l_fp x,
const time_t * p
)
{
struct timespec out;
vint64 sec;
sec = ntpcal_ntp_to_time(x.l_ui, p);
out.tv_nsec = FTOTVN(x.l_uf);
/* copying a vint64 to a time_t needs some care... */
#if SIZEOF_TIME_T <= 4
out.tv_sec = (time_t)sec.d_s.lo;
#elif defined(HAVE_INT64)
out.tv_sec = (time_t)sec.q_s;
#else
out.tv_sec = ((time_t)sec.d_s.hi << 32) | sec.d_s.lo;
#endif
return out;
}
/* -*-EOF-*- */

View File

@ -0,0 +1,83 @@
/*
* timexsup.c - 'struct timex' support functions
*
* Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
* The contents of 'html/copyright.html' apply.
*/
#include "config.h"
#include "timexsup.h"
#include <limits.h>
#include <math.h>
#ifdef HAVE_SYS_TIMEX_H
# include <sys/timex.h>
#endif
#if defined(MOD_NANO) != defined(STA_NANO)
# warning inconsistent definitions of MOD_NANO vs STA_NANO
#endif
static long
clamp_rounded(
double dval
)
{
/* round */
dval = floor(dval + 0.5);
/* clamp / saturate */
if (dval >= LONG_MAX)
return LONG_MAX;
if (dval <= LONG_MIN)
return LONG_MIN;
return (long)dval;
}
double
dbl_from_var_long(
long lval,
int status
)
{
#ifdef STA_NANO
if (status & STA_NANO)
return (double)lval * 1e-9;
#else
(void)status;
#endif
return (double)lval * 1e-6;
}
double
dbl_from_usec_long(
long lval
)
{
return (double)lval * 1e-6;
}
long
var_long_from_dbl(
double dval,
unsigned int * modes
)
{
#ifdef MOD_NANO
*modes |= MOD_NANO;
dval *= 1e+9;
#else
(void)modes;
dval *= 1e+6;
#endif
return clamp_rounded(dval);
}
long
usec_long_from_dbl(
double dval
)
{
return clamp_rounded(dval * 1e+6);
}

View File

@ -164,9 +164,11 @@ parse: $(parsesolaris_OBJECTS) libparse_kernel.a ../libntp/libntp.a
parsesolaris.o: sys/systm.h
# [Bug3608] Solaris has inconsistent definitions of ffs() and fls(). Drop the
# ones from 'systm.h'.
sys/systm.h:
-mkdir sys
sed -e '/ffs(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
sed -e '/f[fl]s(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
## check-libparse is invoked by ntpd/Makefile.am
check-libparse: $(noinst_LIBRARIES)

View File

@ -1000,9 +1000,11 @@ parse: $(parsesolaris_OBJECTS) libparse_kernel.a ../libntp/libntp.a
parsesolaris.o: sys/systm.h
# [Bug3608] Solaris has inconsistent definitions of ffs() and fls(). Drop the
# ones from 'systm.h'.
sys/systm.h:
-mkdir sys
sed -e '/ffs(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
sed -e '/f[fl]s(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
check-libparse: $(noinst_LIBRARIES)
@: do-nothing action to avoid default SCCS get

View File

@ -220,6 +220,58 @@ pcheck(
return psum;
}
static int/*BOOL*/
zeller_expand(
clocktime_t *clock_time,
unsigned int wd
)
{
unsigned int y = (unsigned int)clock_time->year;
unsigned int m = (unsigned int)clock_time->month - 1u;
unsigned int d = (unsigned int)clock_time->day - 1u;
unsigned int c;
/* Check basic constraints first. */
if ((y >= 100u) || (m >= 12u) || (d >= 31u) || (--wd >= 7u))
return FALSE;
/* Get weekday of date in 1st century by a variation on Zeller's
* congruence. All operands are non-negative, and the month
* formula is adjusted to use a divider of 32, so we can do a
* shift instead of a 'true' division:
*/
if ((m += 10u) >= 12u) /* shift base to 0000-03-01 */
m -= 12u;
else if (--y >= 100u)
y += 100;
d += y + (y >> 2) + 2u; /* year-related share */
d += (m * 83u + 16u) >> 5; /* month-related share */
/* The next step combines the exact division by modular inverse
* with the (mod 7) step in such way that no true division and
* only one multiplication is needed. The multiplier is
* M <- ceil((3*8)/7 * 2**29)
* and combines multiplication by invmod(5, 7) -> 3 and modulus
* by 7 transformation to (mod 8) in one step.
* Note that 252 == 0 (mod 7) and that 'd' is less than 185,
* so the number to invert and reduce is strictly positive. In
* the end, 'c' is number of centuries since start of a great
* cycle and must be in [0..3] or we had bad input.
*/
c = (((252u + wd - d) * 0x6db6db6eU) >> 29) & 7u;
if (c >= 4)
return FALSE;
/* undo calendar base shift now */
if ((m > 9u) && (++y >= 100u)) {
y -= 100u;
c = (c + 1u) & 3u;
}
/* combine year with centuries & map to [1970..2369] */
y += (c * 100u);
clock_time->year = (int)y + ((y < 370u) ? 2000 : 1600);
return TRUE;
}
static u_long
convert_rawdcf(
unsigned char *buffer,
@ -288,6 +340,9 @@ convert_rawdcf(
clock_time->year = ext_bf(buffer, DCF_Y10, dcfprm->zerobits);
clock_time->year = TIMES10(clock_time->year) + ext_bf(buffer, DCF_Y1, dcfprm->zerobits);
if (!zeller_expand(clock_time, ext_bf(buffer, DCF_DW, dcfprm->zerobits)))
return CVT_FAIL|CVT_BADFMT;
switch (ext_bf(buffer, DCF_Z, dcfprm->zerobits))
{
case DCF_Z_MET:

View File

@ -25,7 +25,7 @@ if SAVECONFIG_ENABLED
if NTP_CROSSCOMPILE
CHECK_SAVECONFIG=
else
CHECK_SAVECONFIG= check-saveconfig
CHECK_SAVECONFIG= check-saveconfig check-pslsaveconfig
endif
else !SAVECONFIG_ENABLED
CHECK_SAVECONFIG=
@ -110,9 +110,20 @@ DISTCLEANFILES = \
$(NULL)
CLEANFILES = \
check-psl0 \
check-psl1 \
check-psl2 \
check-pslsaveconfig \
check-saveconfig \
compsave.conf \
compsave.conf+ \
k-g-u-submake \
psl0save.conf \
psl0save.conf+ \
psl1save.conf \
psl1save.conf+ \
psl2save.conf \
psl2save.conf+ \
$(EXTRA_PROGRAMS) \
$(NULL)
@ -147,6 +158,9 @@ EXTRA_DIST = \
ntpd.html \
ntpd.texi \
ntpdbase-opts.def \
psl0.conf \
psl1.conf \
psl2.conf \
refclock_msfees.c \
$(B_S_DIST) \
$(NULL)
@ -345,13 +359,13 @@ $(srcdir)/invoke-ntp.keys.menu: $(srcdir)/invoke-ntp.keys.texi
$(srcdir)/invoke-ntp.keys.texi: $(srcdir)/ntp.keys.def $(std_def_list)
$(run_ag) -Tagtexi-file.tpl -DLEVEL=section ntp.keys.def
$(srcdir)/ntp.conf.html: $(srcdir)/ntp.conf.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntp.conf.html: $(srcdir)/ntp.conf.texi $(srcdir)/invoke-ntp.conf.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.conf.html ntp.conf.texi || true )
$(srcdir)/ntp.keys.html: $(srcdir)/ntp.keys.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntp.keys.html: $(srcdir)/ntp.keys.texi $(srcdir)/invoke-ntp.keys.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.keys.html ntp.keys.texi || true )
$(srcdir)/ntpd.html: $(srcdir)/ntpd.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntpd.html: $(srcdir)/ntpd.texi $(srcdir)/invoke-ntpd.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntpd.html ntpd.texi || true )
###
@ -413,13 +427,41 @@ $(srcdir)/invoke-ntpd.texi: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def
$(PROGRAMS): $(LDADD)
compsave.conf: ntpd complete.conf
./ntpd --configfile complete.conf --saveconfigquit $@
check-saveconfig: complete.conf compsave.conf
-diff -u complete.conf compsave.conf
cmp complete.conf compsave.conf && echo stamp > $@
compsave.conf: ntpd complete.conf
./ntpd --configfile complete.conf --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-pslsaveconfig: check-psl0 check-psl1 check-psl2
echo stamp > $@
check-psl0: psl0.conf psl0save.conf
-diff -u $< psl0save.conf
cmp $< psl0save.conf && echo stamp > $@
psl0save.conf: psl0.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-psl1: psl1.conf psl1save.conf
-diff -u $< psl1save.conf
cmp $< psl1save.conf && echo stamp > $@
psl1save.conf: psl1.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-psl2: psl2.conf psl2save.conf
-diff -u $< psl2save.conf
cmp $< psl2save.conf && echo stamp > $@
psl2save.conf: psl2.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
../libntp/libntpsim.a:
cd ../libntp && $(MAKE) $(AM_MAKEFLAGS) libntpsim.a

View File

@ -615,7 +615,7 @@ AM_LDFLAGS = $(LDFLAGS_NTP) $(NTP_HARD_LDFLAGS)
# LDADD might need RESLIB and ADJLIB.
LDADD = version.o libntpd.a $(LIBPARSE)
AM_YFLAGS = -d -t -r all
@NTP_CROSSCOMPILE_FALSE@@SAVECONFIG_ENABLED_TRUE@CHECK_SAVECONFIG = check-saveconfig
@NTP_CROSSCOMPILE_FALSE@@SAVECONFIG_ENABLED_TRUE@CHECK_SAVECONFIG = check-saveconfig check-pslsaveconfig
@NTP_CROSSCOMPILE_TRUE@@SAVECONFIG_ENABLED_TRUE@CHECK_SAVECONFIG =
@SAVECONFIG_ENABLED_FALSE@CHECK_SAVECONFIG =
@VPATH_HACK_FALSE@VPHACK =
@ -667,8 +667,11 @@ DISTCLEANFILES = \
$(man_MANS) \
$(NULL)
CLEANFILES = check-saveconfig compsave.conf k-g-u-submake \
$(EXTRA_PROGRAMS) $(NULL) check-libopts check-libntp .deps-ver
CLEANFILES = check-psl0 check-psl1 check-psl2 check-pslsaveconfig \
check-saveconfig compsave.conf compsave.conf+ k-g-u-submake \
psl0save.conf psl0save.conf+ psl1save.conf psl1save.conf+ \
psl2save.conf psl2save.conf+ $(EXTRA_PROGRAMS) $(NULL) \
check-libopts check-libntp .deps-ver
EXTRA_DIST = \
complete.conf.in \
invoke-ntp.conf.menu \
@ -700,6 +703,9 @@ EXTRA_DIST = \
ntpd.html \
ntpd.texi \
ntpdbase-opts.def \
psl0.conf \
psl1.conf \
psl2.conf \
refclock_msfees.c \
$(B_S_DIST) \
$(NULL)
@ -1743,13 +1749,13 @@ $(srcdir)/invoke-ntp.keys.menu: $(srcdir)/invoke-ntp.keys.texi
$(srcdir)/invoke-ntp.keys.texi: $(srcdir)/ntp.keys.def $(std_def_list)
$(run_ag) -Tagtexi-file.tpl -DLEVEL=section ntp.keys.def
$(srcdir)/ntp.conf.html: $(srcdir)/ntp.conf.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntp.conf.html: $(srcdir)/ntp.conf.texi $(srcdir)/invoke-ntp.conf.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.conf.html ntp.conf.texi || true )
$(srcdir)/ntp.keys.html: $(srcdir)/ntp.keys.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntp.keys.html: $(srcdir)/ntp.keys.texi $(srcdir)/invoke-ntp.keys.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.keys.html ntp.keys.texi || true )
$(srcdir)/ntpd.html: $(srcdir)/ntpd.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntpd.html: $(srcdir)/ntpd.texi $(srcdir)/invoke-ntpd.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntpd.html ntpd.texi || true )
###
@ -1811,13 +1817,41 @@ $(srcdir)/invoke-ntpd.texi: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def
$(PROGRAMS): $(LDADD)
compsave.conf: ntpd complete.conf
./ntpd --configfile complete.conf --saveconfigquit $@
check-saveconfig: complete.conf compsave.conf
-diff -u complete.conf compsave.conf
cmp complete.conf compsave.conf && echo stamp > $@
compsave.conf: ntpd complete.conf
./ntpd --configfile complete.conf --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-pslsaveconfig: check-psl0 check-psl1 check-psl2
echo stamp > $@
check-psl0: psl0.conf psl0save.conf
-diff -u $< psl0save.conf
cmp $< psl0save.conf && echo stamp > $@
psl0save.conf: psl0.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-psl1: psl1.conf psl1save.conf
-diff -u $< psl1save.conf
cmp $< psl1save.conf && echo stamp > $@
psl1save.conf: psl1.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-psl2: psl2.conf psl2save.conf
-diff -u $< psl2save.conf
cmp $< psl2save.conf && echo stamp > $@
psl2save.conf: psl2.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
../libntp/libntpsim.a:
cd ../libntp && $(MAKE) $(AM_MAKEFLAGS) libntpsim.a

View File

@ -71,7 +71,7 @@ getCmdOpts(
}
if (HAVE_OPT( DRIFTFILE ))
stats_config(STATS_FREQ_FILE, OPT_ARG( DRIFTFILE ));
stats_config(STATS_FREQ_FILE, OPT_ARG( DRIFTFILE ), 0);
if (HAVE_OPT( PANICGATE ))
allow_panic = TRUE;
@ -90,7 +90,7 @@ getCmdOpts(
getauthkeys(OPT_ARG( KEYFILE ));
if (HAVE_OPT( PIDFILE ))
stats_config(STATS_PID_FILE, OPT_ARG( PIDFILE ));
stats_config(STATS_PID_FILE, OPT_ARG( PIDFILE ), 0);
if (HAVE_OPT( QUIT ))
mode_ntpdate = TRUE;
@ -110,7 +110,7 @@ getCmdOpts(
} while (0);
if (HAVE_OPT( STATSDIR ))
stats_config(STATS_STATSDIR, OPT_ARG( STATSDIR ));
stats_config(STATS_STATSDIR, OPT_ARG( STATSDIR ), 0);
if (HAVE_OPT( TRUSTEDKEY )) {
int ct = STACKCT_OPT( TRUSTEDKEY );

View File

@ -1,7 +1,8 @@
saveconfigdir "/etc/ntp/conf"
driftfile "/etc/ntp.drift" 1e-7
driftfile "/etc/ntp.drift"
logfile "/var/log/ntp.log"
leapfile "/etc/ntp.leapseconds"
leapfile "/etc/ntp.leapseconds" ignorehash
leapfile "/etc/ntp.leapseconds" checkhash
@HAVE_LEAPSMEARINTERVAL@
nonvolatile 1e-7
ident "udent"
@ -31,14 +32,14 @@ rlimit@HAVE_RLIMIT_MEMLOCK@@HAVE_RLIMIT_STACK@
tinker allan 1500 dispersion 15 freq 0 huffpuff 7200 panic 1000 step 0.128 stepout 900 tick 0.01
broadcastclient
server 127.127.1.0 mode 4294967295 prefer true
fudge 127.127.1.0 time1 0 time2 1.1 stratum 7 refid Abcd
fudge 127.127.1.0 time1 0 time2 1.1 stratum 7 refid Abcd minjitter 0.2
pool 0.north-america.pool.ntp.org. iburst preempt
server 1.north-america.pool.ntp.org. iburst
server -4 2.north-america.pool.ntp.org. minpoll 6 maxpoll 10 iburst
server -6 ntp.davehart.net. minpoll 6 maxpoll 10 version 5 burst iburst
peer -6 davehart.broker.freenet6.net. ident "autokey-group" xleave autokey
peer -4 192.168.192.168 key 1 noselect
server [fe80::123%1]
server [fe80::123%1] xmtnonce
broadcast 192.168.192.255
manycastclient 224.0.1.1
manycastclient ff05::101
@ -46,6 +47,7 @@ manycastserver 224.0.1.1 ff05::101
multicastclient 224.0.1.1 ff05::101
mru maxage 64 mindepth 600 initalloc 600 initmem 16 incalloc 99 incmem 4 maxdepth 1024 maxmem 4096
discard minimum 1 average 3 monitor 3000
pollskewlist 3 1|2 4 3|4 default 6|7
restrict default ippeerlimit -1
restrict default ippeerlimit 0 nomodify limited kod noserve nomrulist
restrict source ippeerlimit 1
@ -53,6 +55,7 @@ restrict source ippeerlimit 2 nomodify limited kod
restrict trusted.host.name.example.com. ippeerlimit -1 nomodify
restrict [fe80::1] mask [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff] ippeerlimit -1
restrict 127.0.0.1 mask 255.255.255.255 ippeerlimit -1
restrict 127.0.0.2 ippeerlimit -1 serverresponse fuzz
restrict ::1 ippeerlimit -1
interface drop ipv6
interface ignore ipv4

View File

@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntp.conf.texi)
#
# It has been AutoGen-ed February 20, 2019 at 09:56:39 AM by AutoGen 5.18.5
# It has been AutoGen-ed March 3, 2020 at 05:40:57 PM by AutoGen 5.18.5
# From the definitions ntp.conf.def
# and the template file agtexi-file.tpl
@end ignore
@ -134,8 +134,8 @@ qualifier forces DNS resolution to the IPv6 namespace.
See IPv6 references for the
equivalent classes for that address family.
@table @asis
@item @code{pool} @kbd{address} @code{[@code{burst}]} @code{[@code{iburst}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]}
@item @code{server} @kbd{address} @code{[@code{key} @kbd{key} @kbd{|} @code{autokey}]} @code{[@code{burst}]} @code{[@code{iburst}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]} @code{[@code{true}]}
@item @code{pool} @kbd{address} @code{[@code{burst}]} @code{[@code{iburst}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]} @code{[@code{xmtnonce}]}
@item @code{server} @kbd{address} @code{[@code{key} @kbd{key} @kbd{|} @code{autokey}]} @code{[@code{burst}]} @code{[@code{iburst}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]} @code{[@code{true}]} @code{[@code{xmtnonce}]}
@item @code{peer} @kbd{address} @code{[@code{key} @kbd{key} @kbd{|} @code{autokey}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]} @code{[@code{true}]} @code{[@code{xleave}]}
@item @code{broadcast} @kbd{address} @code{[@code{key} @kbd{key} @kbd{|} @code{autokey}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{ttl} @kbd{ttl}]} @code{[@code{xleave}]}
@item @code{manycastclient} @kbd{address} @code{[@code{key} @kbd{key} @kbd{|} @code{autokey}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]} @code{[@code{ttl} @kbd{ttl}]}
@ -305,9 +305,6 @@ Marks the server as unused, except for display purposes.
The server is discarded by the selection algroithm.
@item @code{preempt}
Says the association can be preempted.
@item @code{true}
Marks the server as a truechimer.
Use this option only for testing.
@item @code{prefer}
Marks the server as preferred.
All other things being equal,
@ -321,7 +318,8 @@ provided in
@file{/usr/share/doc/ntp})
for further information.
@item @code{true}
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
@emph{only}
be used while testing an association.
@ -349,6 +347,13 @@ Valid in
and
@code{broadcast}
modes only, this flag enables interleave mode.
@item @code{xmtnonce}
Valid only for
@code{server}
and
@code{pool}
modes, this flag puts a random number in the packet's transmit timestamp.
@end table
@subsubsection Auxiliary Commands
@table @asis
@ -1622,6 +1627,10 @@ The
@code{ntpport}
is considered more specific and
is sorted later in the list.
@item @code{serverresponse fuzz}
When reponding to server requests,
fuzz the low order bits of the
@code{reftime}.
@item @code{version}
Deny packets that do not match the current NTP version.
@end table
@ -2766,6 +2775,21 @@ For the JJY driver (type 40 mode 100 - 180), the argument is
one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
@item @code{pollskewlist} @code{[@kbd{poll} @kbd{value} | @kbd{value}]} @kbd{...} @code{[@code{default} @kbd{value} | @kbd{value}]}
Enable skewing of our poll requests to our servers.
@kbd{poll}
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
@item @code{reset} @code{[@code{allpeers}]} @code{[@code{auth}]} @code{[@code{ctl}]} @code{[@code{io}]} @code{[@code{mem}]} @code{[@code{sys}]} @code{[@code{timer}]}
Reset one or more groups of counters maintained by
@code{ntpd}

View File

@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntp.keys.texi)
#
# It has been AutoGen-ed February 20, 2019 at 09:56:41 AM by AutoGen 5.18.5
# It has been AutoGen-ed March 3, 2020 at 05:40:59 PM by AutoGen 5.18.5
# From the definitions ntp.keys.def
# and the template file agtexi-file.tpl
@end ignore

View File

@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntpd.texi)
#
# It has been AutoGen-ed February 20, 2019 at 09:56:42 AM by AutoGen 5.18.5
# It has been AutoGen-ed March 3, 2020 at 05:41:00 PM by AutoGen 5.18.5
# From the definitions ntpd-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@ -142,7 +142,7 @@ with a status code of 0.
@exampleindent 0
@example
ntpd - NTP daemon program - Ver. 4.2.8p13
ntpd - NTP daemon program - Ver. 4.2.8p14
Usage: ntpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
[ <server1> ... <serverN> ]
Flg Arg Option-Name Description

View File

@ -1 +1 @@
* Generated 2018-01-14 03:53:33 UTC diff_ignore_line
* Generated 2020-02-13 08:56:28 UTC diff_ignore_line

View File

@ -43,6 +43,7 @@ struct key_tok ntp_keywords[] = {
{ "broadcast", T_Broadcast, FOLLBY_STRING },
{ "broadcastclient", T_Broadcastclient, FOLLBY_TOKEN },
{ "broadcastdelay", T_Broadcastdelay, FOLLBY_TOKEN },
{ "checkhash", T_Checkhash, FOLLBY_TOKEN },
{ "ctl", T_Ctl, FOLLBY_TOKEN },
{ "disable", T_Disable, FOLLBY_TOKEN },
{ "driftfile", T_Driftfile, FOLLBY_STRING },
@ -51,6 +52,7 @@ struct key_tok ntp_keywords[] = {
{ "end", T_End, FOLLBY_TOKEN },
{ "filegen", T_Filegen, FOLLBY_TOKEN },
{ "fudge", T_Fudge, FOLLBY_STRING },
{ "ignorehash", T_Ignorehash, FOLLBY_TOKEN },
{ "io", T_Io, FOLLBY_TOKEN },
{ "includefile", T_Includefile, FOLLBY_STRING },
{ "leapfile", T_Leapfile, FOLLBY_STRING },
@ -64,12 +66,16 @@ struct key_tok ntp_keywords[] = {
{ "peer", T_Peer, FOLLBY_STRING },
{ "phone", T_Phone, FOLLBY_STRINGS_TO_EOC },
{ "pidfile", T_Pidfile, FOLLBY_STRING },
{ "pollskewlist", T_PollSkewList, FOLLBY_TOKEN },
{ "pool", T_Pool, FOLLBY_STRING },
{ "discard", T_Discard, FOLLBY_TOKEN },
{ "reset", T_Reset, FOLLBY_TOKEN },
{ "restrict", T_Restrict, FOLLBY_TOKEN },
{ "rlimit", T_Rlimit, FOLLBY_TOKEN },
{ "server", T_Server, FOLLBY_STRING },
{ "serverresponse", T_Serverresponse, FOLLBY_TOKEN },
{ "fuzz", T_Fuzz, FOLLBY_TOKEN },
{ "poll", T_Poll, FOLLBY_TOKEN },
{ "setvar", T_Setvar, FOLLBY_STRING },
{ "statistics", T_Statistics, FOLLBY_TOKEN },
{ "statsdir", T_Statsdir, FOLLBY_STRING },
@ -81,6 +87,7 @@ struct key_tok ntp_keywords[] = {
{ "trap", T_Trap, FOLLBY_STRING },
{ "unconfig", T_Unconfig, FOLLBY_STRING },
{ "unpeer", T_Unpeer, FOLLBY_STRING },
{ "xmtnonce", T_Xmtnonce, FOLLBY_TOKEN },
/* authentication_command */
{ "controlkey", T_ControlKey, FOLLBY_TOKEN },
{ "crypto", T_Crypto, FOLLBY_TOKEN },
@ -199,6 +206,7 @@ struct key_tok ntp_keywords[] = {
{ "stratum", T_Stratum, FOLLBY_TOKEN },
{ "time1", T_Time1, FOLLBY_TOKEN },
{ "time2", T_Time2, FOLLBY_TOKEN },
{ "minjitter", T_Minjitter, FOLLBY_TOKEN },
/* system_option */
{ "auth", T_Auth, FOLLBY_TOKEN },
{ "bclient", T_Bclient, FOLLBY_TOKEN },

View File

@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
.TH ntp.conf 5man "20 Feb 2019" "4.2.8p13" "File Formats"
.TH ntp.conf 5man "03 Mar 2020" "4.2.8p14" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:43 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:02 PM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agman-cmd.tpl
.SH NAME
@ -161,9 +161,9 @@ qualifier forces DNS resolution to the IPv6 namespace.
See IPv6 references for the
equivalent classes for that address family.
.TP 7
.NOP \f\*[B-Font]pool\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]]
.NOP \f\*[B-Font]pool\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]xmtnonce\f[]]
.TP 7
.NOP \f\*[B-Font]server\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]]
.NOP \f\*[B-Font]server\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]] [\f\*[B-Font]xmtnonce\f[]]
.TP 7
.NOP \f\*[B-Font]peer\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]] [\f\*[B-Font]xleave\f[]]
.TP 7
@ -352,10 +352,6 @@ The server is discarded by the selection algroithm.
.NOP \f\*[B-Font]preempt\f[]
Says the association can be preempted.
.TP 7
.NOP \f\*[B-Font]true\f[]
Marks the server as a truechimer.
Use this option only for testing.
.TP 7
.NOP \f\*[B-Font]prefer\f[]
Marks the server as preferred.
All other things being equal,
@ -370,7 +366,8 @@ provided in
for further information.
.TP 7
.NOP \f\*[B-Font]true\f[]
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
\fIonly\f[]
be used while testing an association.
@ -401,6 +398,13 @@ Valid in
and
\f\*[B-Font]broadcast\f[]
modes only, this flag enables interleave mode.
.TP 7
.NOP \f\*[B-Font]xmtnonce\f[]
Valid only for
\f\*[B-Font]server\f[]
and
\f\*[B-Font]pool\f[]
modes, this flag puts a random number in the packet's transmit timestamp.
.PP
.SS Auxiliary Commands
.TP 7
@ -1838,6 +1842,11 @@ The
is considered more specific and
is sorted later in the list.
.TP 7
.NOP \f\*[B-Font]serverresponse fuzz\f[]
When reponding to server requests,
fuzz the low order bits of the
\f\*[B-Font]reftime\f[].
.TP 7
.NOP \f\*[B-Font]version\f[]
Deny packets that do not match the current NTP version.
.RE
@ -3092,6 +3101,22 @@ one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
.TP 7
.NOP \f\*[B-Font]pollskewlist\f[] [\f\*[I-Font]poll\f[] \f\*[I-Font]value\f[] | \f\*[I-Font]value\f[]] \f\*[I-Font]...\f[] [\f\*[B-Font]default\f[] \f\*[I-Font]value\f[] | \f\*[I-Font]value\f[]]
Enable skewing of our poll requests to our servers.
\f\*[I-Font]poll\f[]
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.TP 7
.NOP \f\*[B-Font]reset\f[] [\f\*[B-Font]allpeers\f[]] [\f\*[B-Font]auth\f[]] [\f\*[B-Font]ctl\f[]] [\f\*[B-Font]io\f[]] [\f\*[B-Font]mem\f[]] [\f\*[B-Font]sys\f[]] [\f\*[B-Font]timer\f[]]
Reset one or more groups of counters maintained by
\f\*[B-Font]ntpd\f[]
@ -3424,7 +3449,7 @@ RFC5905
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH BUGS
The syntax checking is not picky; some combinations of

View File

@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTP_CONF 5mdoc File Formats
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:34 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:53 PM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@ -144,6 +144,7 @@ equivalent classes for that address family.
.Op Cm prefer
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm xmtnonce
.Xc
.It Xo Ic server Ar address
.Op Cm key Ar key \&| Cm autokey
@ -154,6 +155,7 @@ equivalent classes for that address family.
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm true
.Op Cm xmtnonce
.Xc
.It Xo Ic peer Ar address
.Op Cm key Ar key \&| Cm autokey
@ -346,9 +348,6 @@ Marks the server as unused, except for display purposes.
The server is discarded by the selection algroithm.
.It Cm preempt
Says the association can be preempted.
.It Cm true
Marks the server as a truechimer.
Use this option only for testing.
.It Cm prefer
Marks the server as preferred.
All other things being equal,
@ -362,7 +361,8 @@ provided in
.Pa /usr/share/doc/ntp )
for further information.
.It Cm true
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
.Em only
be used while testing an association.
@ -390,6 +390,12 @@ Valid in
and
.Cm broadcast
modes only, this flag enables interleave mode.
.It Cm xmtnonce
Valid only for
.Cm server
and
.Cm pool
modes, this flag puts a random number in the packet's transmit timestamp.
.El
.Ss Auxiliary Commands
.Bl -tag -width indent
@ -1694,6 +1700,10 @@ The
.Cm ntpport
is considered more specific and
is sorted later in the list.
.It Ic "serverresponse fuzz"
When reponding to server requests,
fuzz the low order bits of the
.Cm reftime .
.It Cm version
Deny packets that do not match the current NTP version.
.El
@ -2919,6 +2929,31 @@ For the JJY driver (type 40 mode 100 \- 180), the argument is
one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
.It Xo Cm pollskewlist
.Oo
.Ar poll
.Ar value | value
.Oc
.Ar ...
.Oo
.Cm default
.Ar value | value
.Oc
.Xc
Enable skewing of our poll requests to our servers.
.Ar poll
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one\-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.It Xo Ic reset
.Oo
.Ic allpeers
@ -3255,7 +3290,7 @@ A snapshot of this documentation is available in HTML format in
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh BUGS
The syntax checking is not picky; some combinations of

View File

@ -146,6 +146,7 @@ equivalent classes for that address family.
.Op Cm prefer
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm xmtnonce
.Xc
.It Xo Ic server Ar address
.Op Cm key Ar key \&| Cm autokey
@ -156,6 +157,7 @@ equivalent classes for that address family.
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm true
.Op Cm xmtnonce
.Xc
.It Xo Ic peer Ar address
.Op Cm key Ar key \&| Cm autokey
@ -348,9 +350,6 @@ Marks the server as unused, except for display purposes.
The server is discarded by the selection algroithm.
.It Cm preempt
Says the association can be preempted.
.It Cm true
Marks the server as a truechimer.
Use this option only for testing.
.It Cm prefer
Marks the server as preferred.
All other things being equal,
@ -364,7 +363,8 @@ provided in
.Pa /usr/share/doc/ntp )
for further information.
.It Cm true
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
.Em only
be used while testing an association.
@ -392,6 +392,13 @@ Valid in
and
.Cm broadcast
modes only, this flag enables interleave mode.
.It Cm xmtnonce
Valid only for
.Cm server
and
.Cm pool
modes, this flag puts a random number in the packet's transmit timestamp.
.El
.Ss Auxiliary Commands
.Bl -tag -width indent
@ -1696,6 +1703,10 @@ The
.Cm ntpport
is considered more specific and
is sorted later in the list.
.It Ic "serverresponse fuzz"
When reponding to server requests,
fuzz the low order bits of the
.Cm reftime .
.It Cm version
Deny packets that do not match the current NTP version.
.El
@ -2921,6 +2932,31 @@ For the JJY driver (type 40 mode 100 - 180), the argument is
one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
.It Xo Cm pollskewlist
.Oo
.Ar poll
.Ar value | value
.Oc
.Ar ...
.Oo
.Cm default
.Ar value | value
.Oc
.Xc
Enable skewing of our poll requests to our servers.
.Ar poll
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.It Xo Ic reset
.Oo
.Ic allpeers

View File

@ -61,7 +61,7 @@ Next: <a href="#ntp_002econf-Description" accesskey="n" rel="next">ntp.conf Desc
<p>This document describes the configuration file for the NTP Project&rsquo;s
<code>ntpd</code> program.
</p>
<p>This document applies to version 4.2.8p13 of <code>ntp.conf</code>.
<p>This document applies to version 4.2.8p14 of <code>ntp.conf</code>.
</p>
<a name="SEC_Overview"></a>
<h2 class="shortcontents-heading">Short Table of Contents</h2>
@ -257,8 +257,8 @@ qualifier forces DNS resolution to the IPv6 namespace.
See IPv6 references for the
equivalent classes for that address family.
</p><dl compact="compact">
<dt><code>pool</code> <kbd>address</kbd> <code>[<code>burst</code>]</code> <code>[<code>iburst</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code></dt>
<dt><code>server</code> <kbd>address</kbd> <code>[<code>key</code> <kbd>key</kbd> <kbd>|</kbd> <code>autokey</code>]</code> <code>[<code>burst</code>]</code> <code>[<code>iburst</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code> <code>[<code>true</code>]</code></dt>
<dt><code>pool</code> <kbd>address</kbd> <code>[<code>burst</code>]</code> <code>[<code>iburst</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code> <code>[<code>xmtnonce</code>]</code></dt>
<dt><code>server</code> <kbd>address</kbd> <code>[<code>key</code> <kbd>key</kbd> <kbd>|</kbd> <code>autokey</code>]</code> <code>[<code>burst</code>]</code> <code>[<code>iburst</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code> <code>[<code>true</code>]</code> <code>[<code>xmtnonce</code>]</code></dt>
<dt><code>peer</code> <kbd>address</kbd> <code>[<code>key</code> <kbd>key</kbd> <kbd>|</kbd> <code>autokey</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code> <code>[<code>true</code>]</code> <code>[<code>xleave</code>]</code></dt>
<dt><code>broadcast</code> <kbd>address</kbd> <code>[<code>key</code> <kbd>key</kbd> <kbd>|</kbd> <code>autokey</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>ttl</code> <kbd>ttl</kbd>]</code> <code>[<code>xleave</code>]</code></dt>
<dt><code>manycastclient</code> <kbd>address</kbd> <code>[<code>key</code> <kbd>key</kbd> <kbd>|</kbd> <code>autokey</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code> <code>[<code>ttl</code> <kbd>ttl</kbd>]</code></dt>
@ -440,10 +440,6 @@ The server is discarded by the selection algroithm.
<dt><code>preempt</code></dt>
<dd><p>Says the association can be preempted.
</p></dd>
<dt><code>true</code></dt>
<dd><p>Marks the server as a truechimer.
Use this option only for testing.
</p></dd>
<dt><code>prefer</code></dt>
<dd><p>Marks the server as preferred.
All other things being equal,
@ -458,7 +454,8 @@ provided in
for further information.
</p></dd>
<dt><code>true</code></dt>
<dd><p>Forces the association to always survive the selection and clustering algorithms.
<dd><p>Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
<em>only</em>
be used while testing an association.
@ -490,6 +487,14 @@ and
<code>broadcast</code>
modes only, this flag enables interleave mode.
</p></dd>
<dt><code>xmtnonce</code></dt>
<dd><p>Valid only for
<code>server</code>
and
<code>pool</code>
modes, this flag puts a random number in the packet&rsquo;s transmit timestamp.
</p>
</dd>
</dl>
<a name="Auxiliary-Commands"></a>
<h4 class="subsubsection">1.1.1.2 Auxiliary Commands</h4>
@ -1862,6 +1867,11 @@ The
is considered more specific and
is sorted later in the list.
</p></dd>
<dt><code>serverresponse fuzz</code></dt>
<dd><p>When reponding to server requests,
fuzz the low order bits of the
<code>reftime</code>.
</p></dd>
<dt><code>version</code></dt>
<dd><p>Deny packets that do not match the current NTP version.
</p></dd>
@ -3077,6 +3087,22 @@ one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
</p></dd>
<dt><code>pollskewlist</code> <code>[<kbd>poll</kbd> <kbd>value</kbd> | <kbd>value</kbd>]</code> <kbd>...</kbd> <code>[<code>default</code> <kbd>value</kbd> | <kbd>value</kbd>]</code></dt>
<dd><p>Enable skewing of our poll requests to our servers.
<kbd>poll</kbd>
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
</p></dd>
<dt><code>reset</code> <code>[<code>allpeers</code>]</code> <code>[<code>auth</code>]</code> <code>[<code>ctl</code>]</code> <code>[<code>io</code>]</code> <code>[<code>mem</code>]</code> <code>[<code>sys</code>]</code> <code>[<code>timer</code>]</code></dt>
<dd><p>Reset one or more groups of counters maintained by
<code>ntpd</code>

View File

@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
.TH ntp.conf 5 "20 Feb 2019" "4.2.8p13" "File Formats"
.TH ntp.conf 5 "03 Mar 2020" "4.2.8p14" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:43 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:02 PM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agman-cmd.tpl
.SH NAME
@ -161,9 +161,9 @@ qualifier forces DNS resolution to the IPv6 namespace.
See IPv6 references for the
equivalent classes for that address family.
.TP 7
.NOP \f\*[B-Font]pool\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]]
.NOP \f\*[B-Font]pool\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]xmtnonce\f[]]
.TP 7
.NOP \f\*[B-Font]server\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]]
.NOP \f\*[B-Font]server\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]] [\f\*[B-Font]xmtnonce\f[]]
.TP 7
.NOP \f\*[B-Font]peer\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]] [\f\*[B-Font]xleave\f[]]
.TP 7
@ -352,10 +352,6 @@ The server is discarded by the selection algroithm.
.NOP \f\*[B-Font]preempt\f[]
Says the association can be preempted.
.TP 7
.NOP \f\*[B-Font]true\f[]
Marks the server as a truechimer.
Use this option only for testing.
.TP 7
.NOP \f\*[B-Font]prefer\f[]
Marks the server as preferred.
All other things being equal,
@ -370,7 +366,8 @@ provided in
for further information.
.TP 7
.NOP \f\*[B-Font]true\f[]
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
\fIonly\f[]
be used while testing an association.
@ -401,6 +398,13 @@ Valid in
and
\f\*[B-Font]broadcast\f[]
modes only, this flag enables interleave mode.
.TP 7
.NOP \f\*[B-Font]xmtnonce\f[]
Valid only for
\f\*[B-Font]server\f[]
and
\f\*[B-Font]pool\f[]
modes, this flag puts a random number in the packet's transmit timestamp.
.PP
.SS Auxiliary Commands
.TP 7
@ -1838,6 +1842,11 @@ The
is considered more specific and
is sorted later in the list.
.TP 7
.NOP \f\*[B-Font]serverresponse fuzz\f[]
When reponding to server requests,
fuzz the low order bits of the
\f\*[B-Font]reftime\f[].
.TP 7
.NOP \f\*[B-Font]version\f[]
Deny packets that do not match the current NTP version.
.RE
@ -3092,6 +3101,22 @@ one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
.TP 7
.NOP \f\*[B-Font]pollskewlist\f[] [\f\*[I-Font]poll\f[] \f\*[I-Font]value\f[] | \f\*[I-Font]value\f[]] \f\*[I-Font]...\f[] [\f\*[B-Font]default\f[] \f\*[I-Font]value\f[] | \f\*[I-Font]value\f[]]
Enable skewing of our poll requests to our servers.
\f\*[I-Font]poll\f[]
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.TP 7
.NOP \f\*[B-Font]reset\f[] [\f\*[B-Font]allpeers\f[]] [\f\*[B-Font]auth\f[]] [\f\*[B-Font]ctl\f[]] [\f\*[B-Font]io\f[]] [\f\*[B-Font]mem\f[]] [\f\*[B-Font]sys\f[]] [\f\*[B-Font]timer\f[]]
Reset one or more groups of counters maintained by
\f\*[B-Font]ntpd\f[]
@ -3424,7 +3449,7 @@ RFC5905
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH BUGS
The syntax checking is not picky; some combinations of

View File

@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTP_CONF 5 File Formats
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:34 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:53 PM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@ -144,6 +144,7 @@ equivalent classes for that address family.
.Op Cm prefer
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm xmtnonce
.Xc
.It Xo Ic server Ar address
.Op Cm key Ar key \&| Cm autokey
@ -154,6 +155,7 @@ equivalent classes for that address family.
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm true
.Op Cm xmtnonce
.Xc
.It Xo Ic peer Ar address
.Op Cm key Ar key \&| Cm autokey
@ -346,9 +348,6 @@ Marks the server as unused, except for display purposes.
The server is discarded by the selection algroithm.
.It Cm preempt
Says the association can be preempted.
.It Cm true
Marks the server as a truechimer.
Use this option only for testing.
.It Cm prefer
Marks the server as preferred.
All other things being equal,
@ -362,7 +361,8 @@ provided in
.Pa /usr/share/doc/ntp )
for further information.
.It Cm true
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
.Em only
be used while testing an association.
@ -390,6 +390,12 @@ Valid in
and
.Cm broadcast
modes only, this flag enables interleave mode.
.It Cm xmtnonce
Valid only for
.Cm server
and
.Cm pool
modes, this flag puts a random number in the packet's transmit timestamp.
.El
.Ss Auxiliary Commands
.Bl -tag -width indent
@ -1694,6 +1700,10 @@ The
.Cm ntpport
is considered more specific and
is sorted later in the list.
.It Ic "serverresponse fuzz"
When reponding to server requests,
fuzz the low order bits of the
.Cm reftime .
.It Cm version
Deny packets that do not match the current NTP version.
.El
@ -2919,6 +2929,31 @@ For the JJY driver (type 40 mode 100 \- 180), the argument is
one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
.It Xo Cm pollskewlist
.Oo
.Ar poll
.Ar value | value
.Oc
.Ar ...
.Oo
.Cm default
.Ar value | value
.Oc
.Xc
Enable skewing of our poll requests to our servers.
.Ar poll
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one\-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.It Xo Ic reset
.Oo
.Ic allpeers
@ -3255,7 +3290,7 @@ A snapshot of this documentation is available in HTML format in
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh BUGS
The syntax checking is not picky; some combinations of

View File

@ -1,8 +1,8 @@
.TH ntp.keys 5man "20 Feb 2019" "4.2.8p13" "File Formats"
.TH ntp.keys 5man "03 Mar 2020" "4.2.8p14" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (ntp.man)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:44 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:04 PM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agman-file.tpl
.Sh NAME
@ -176,7 +176,7 @@ the default name of the configuration file
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH "BUGS"
Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org

View File

@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTP_KEYS 5mdoc File Formats
.Os FreeBSD 11.2-RELEASE_SI
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:35 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:54 PM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agmdoc-file.tpl
.Sh NAME
@ -163,7 +163,7 @@ it to autogen\-users@lists.sourceforge.net. Thank you.
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh "BUGS"
Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org

View File

@ -61,7 +61,7 @@ Next: <a href="#ntp_002ekeys-Description" accesskey="n" rel="next">ntp.keys Desc
<p>This document describes the symmetric key file for the NTP Project&rsquo;s
<code>ntpd</code> program.
</p>
<p>This document applies to version 4.2.8p13 of <code>ntp.keys</code>.
<p>This document applies to version 4.2.8p14 of <code>ntp.keys</code>.
</p>
<a name="SEC_Overview"></a>
<h2 class="shortcontents-heading">Short Table of Contents</h2>

View File

@ -1,8 +1,8 @@
.TH ntp.keys 5 "20 Feb 2019" "4.2.8p13" "File Formats"
.TH ntp.keys 5 "03 Mar 2020" "4.2.8p14" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (ntp.man)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:44 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:04 PM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agman-file.tpl
.Sh NAME
@ -176,7 +176,7 @@ the default name of the configuration file
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH "BUGS"
Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org

View File

@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTP_KEYS 5 File Formats
.Os FreeBSD 11.2-RELEASE_SI
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:35 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:54 PM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agmdoc-file.tpl
.Sh NAME
@ -163,7 +163,7 @@ it to autogen\-users@lists.sourceforge.net. Thank you.
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh "BUGS"
Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org

View File

@ -29,6 +29,7 @@
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#include <time.h>
#include <isc/net.h>
#include <isc/result.h>
@ -148,7 +149,7 @@ typedef struct peer_resolved_ctx_tag {
*/
extern int yydebug; /* ntp_parser.c (.y) */
config_tree cfgt; /* Parser output stored here */
struct config_tree_tag *cfg_tree_history; /* History of configs */
config_tree *cfg_tree_history; /* History of configs */
char * sys_phone[MAXPHONE] = {NULL}; /* ACTS phone numbers */
char default_keysdir[] = NTP_KEYSDIR;
char * keysdir = default_keysdir; /* crypto keys directory */
@ -324,6 +325,7 @@ static void config_ntpdsim(config_tree *);
static void config_ntpd(config_tree *, int/*BOOL*/ input_from_file);
static void config_other_modes(config_tree *);
static void config_auth(config_tree *);
static void attrtopsl(int poll, attr_val *avp);
static void config_access(config_tree *);
static void config_mdnstries(config_tree *);
static void config_phone(config_tree *);
@ -500,6 +502,13 @@ dump_all_config_trees(
{
config_tree * cfg_ptr;
int return_value;
time_t now = time(NULL);
struct tm tm = *localtime(&now);
fprintf(df, "#NTF:D %04d%02d%02d@%02d:%02d:%02d\n",
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
fprintf(df, "#NTF:V %s\n", Version);
return_value = 0;
for (cfg_ptr = cfg_tree_history;
@ -531,7 +540,6 @@ dump_config_tree(
setvar_node *setv_node;
nic_rule_node *rule_node;
int_node *i_n;
int_node *flag_tok_fifo;
int_node *counter_set;
string_node *str_node;
@ -591,6 +599,11 @@ dump_config_tree(
atrv = atrv->link;
fprintf(df, " %s\n",
normal_dtoa(atrv->value.d));
} else if (T_Leapfile == atrv->attr) {
fputs((atrv->flag
? " checkhash\n"
: " ignorehash\n"),
df);
} else {
fprintf(df, "\n");
}
@ -925,6 +938,21 @@ dump_config_tree(
fprintf(df, "\n");
}
atrv = HEAD_PFIFO(ptree->pollskewlist);
if (atrv != NULL) {
fprintf(df, "pollskewlist");
for ( ; atrv != NULL; atrv = atrv->link) {
if (-1 == atrv->attr) {
fprintf(df, " default");
} else {
fprintf(df, " %d", atrv->attr);
}
fprintf(df, " %d|%d",
atrv->value.r.first, atrv->value.r.last);
}
fprintf(df, "\n");
}
for (rest_node = HEAD_PFIFO(ptree->restrict_opts);
rest_node != NULL;
rest_node = rest_node->link) {
@ -933,9 +961,10 @@ dump_config_tree(
if (NULL == rest_node->addr) {
s = "default";
/* Don't need to set is_default=1 here */
flag_tok_fifo = HEAD_PFIFO(rest_node->flag_tok_fifo);
for ( ; flag_tok_fifo != NULL; flag_tok_fifo = flag_tok_fifo->link) {
if (T_Source == flag_tok_fifo->i) {
atrv = HEAD_PFIFO(rest_node->flag_tok_fifo);
for ( ; atrv != NULL; atrv = atrv->link) {
if ( T_Integer == atrv->type
&& T_Source == atrv->attr) {
s = "source";
break;
}
@ -967,11 +996,34 @@ dump_config_tree(
fprintf(df, " mask %s",
rest_node->mask->address);
fprintf(df, " ippeerlimit %d", rest_node->ippeerlimit);
flag_tok_fifo = HEAD_PFIFO(rest_node->flag_tok_fifo);
for ( ; flag_tok_fifo != NULL; flag_tok_fifo = flag_tok_fifo->link)
if (T_Source != flag_tok_fifo->i)
fprintf(df, " %s", keyword(flag_tok_fifo->i));
fprintf(df, "\n");
atrv = HEAD_PFIFO(rest_node->flag_tok_fifo);
for ( ; atrv != NULL; atrv = atrv->link) {
if ( T_Integer == atrv->type
&& T_Source != atrv->attr) {
fprintf(df, " %s", keyword(atrv->attr));
}
}
fprintf(df, "\n");
/**/
#if 0
msyslog(LOG_INFO, "Dumping flag_tok_fifo:");
atrv = HEAD_PFIFO(rest_node->flag_tok_fifo);
for ( ; atrv != NULL; atrv = atrv->link) {
msyslog(LOG_INFO, "- flag_tok_fifo: flags: %08x", atrv->flag);
switch(atrv->type) {
case T_Integer:
msyslog(LOG_INFO, "- T_Integer: attr <%s>/%d, value %d",
keyword(atrv->attr), atrv->attr, atrv->value.i);
break;
default:
msyslog(LOG_INFO, "- Other: attr <%s>/%d, value ???",
keyword(atrv->attr), atrv->attr);
break;
}
}
#endif
/**/
}
rule_node = HEAD_PFIFO(ptree->nic_rules);
@ -1053,7 +1105,6 @@ dump_config_tree(
#endif /* SAVECONFIG */
/* generic fifo routines for structs linked by 1st member */
void *
append_gen_fifo(
@ -1191,7 +1242,7 @@ create_attr_uval(
attr_val *
create_attr_rangeval(
create_attr_rval(
int attr,
int first,
int last
@ -1480,8 +1531,8 @@ create_restrict_node(
address_node * addr,
address_node * mask,
short ippeerlimit,
int_fifo * flag_tok_fifo,
int line_no
attr_val_fifo * flag_tok_fifo,
int nline
)
{
restrict_node *my_node;
@ -1491,7 +1542,7 @@ create_restrict_node(
my_node->mask = mask;
my_node->ippeerlimit = ippeerlimit;
my_node->flag_tok_fifo = flag_tok_fifo;
my_node->line_no = line_no;
my_node->line_no = nline;
return my_node;
}
@ -1507,7 +1558,7 @@ destroy_restrict_node(
*/
destroy_address_node(my_node->addr);
destroy_address_node(my_node->mask);
destroy_int_fifo(my_node->flag_tok_fifo);
destroy_attr_val_fifo(my_node->flag_tok_fifo);
free(my_node);
}
@ -2307,7 +2358,7 @@ config_monitor(
/* Set the statistics directory */
if (ptree->stats_dir)
stats_config(STATS_STATSDIR, ptree->stats_dir);
stats_config(STATS_STATSDIR, ptree->stats_dir, 0);
/* NOTE:
* Calling filegen_get is brain dead. Doing a string
@ -2472,7 +2523,6 @@ config_access(
static int warned_signd;
attr_val * my_opt;
restrict_node * my_node;
int_node * curr_tok_fifo;
sockaddr_u addr;
sockaddr_u mask;
struct addrinfo hints;
@ -2484,6 +2534,9 @@ config_access(
u_short mflags;
short ippeerlimit;
int range_err;
psl_item my_psl_item;
attr_val * atrv;
attr_val * dflt_psl_atr;
const char * signd_warning =
#ifdef HAVE_NTP_SIGND
"MS-SNTP signd operations currently block ntpd degrading service to all clients.";
@ -2599,25 +2652,24 @@ config_access(
}
}
/* Configure the restrict options */
/* Configure each line of restrict options */
my_node = HEAD_PFIFO(ptree->restrict_opts);
for (; my_node != NULL; my_node = my_node->link) {
/* Grab the ippeerlmit */
ippeerlimit = my_node->ippeerlimit;
DPRINTF(1, ("config_access: top-level node %p: ippeerlimit %d\n", my_node, ippeerlimit));
/* Parse the flags */
rflags = 0;
mflags = 0;
curr_tok_fifo = HEAD_PFIFO(my_node->flag_tok_fifo);
for (; curr_tok_fifo != NULL; curr_tok_fifo = curr_tok_fifo->link) {
switch (curr_tok_fifo->i) {
my_opt = HEAD_PFIFO(my_node->flag_tok_fifo);
for (; my_opt != NULL; my_opt = my_opt->link) {
switch (my_opt->attr) {
default:
fatal_error("config_access: flag-type-token=%d", curr_tok_fifo->i);
fatal_error("config_access: Unknown flag-type-token=%s/%d", keyword(my_opt->attr), my_opt->attr);
case T_Ntpport:
mflags |= RESM_NTPONLY;
@ -2639,10 +2691,6 @@ DPRINTF(1, ("config_access: top-level node %p: ippeerlimit %d\n", my_node, ippee
rflags |= RES_KOD;
break;
case T_Mssntp:
rflags |= RES_MSSNTP;
break;
case T_Limited:
rflags |= RES_LIMITED;
break;
@ -2651,6 +2699,10 @@ DPRINTF(1, ("config_access: top-level node %p: ippeerlimit %d\n", my_node, ippee
rflags |= RES_LPTRAP;
break;
case T_Mssntp:
rflags |= RES_MSSNTP;
break;
case T_Nomodify:
rflags |= RES_NOMODIFY;
break;
@ -2683,6 +2735,10 @@ DPRINTF(1, ("config_access: top-level node %p: ippeerlimit %d\n", my_node, ippee
rflags |= RES_DONTTRUST;
break;
case T_ServerresponseFuzz:
rflags |= RES_SRVRSPFUZ;
break;
case T_Version:
rflags |= RES_VERSION;
break;
@ -2822,10 +2878,171 @@ DPRINTF(1, ("config_access: top-level node %p: ippeerlimit %d\n", my_node, ippee
if (ai_list != NULL)
freeaddrinfo(ai_list);
}
/* Deal with the Poll Skew List */
ZERO(psl);
ZERO(my_psl_item);
/*
* First, find the last default pollskewlist item.
* There should only be one of these with the current grammar,
* but better safe than sorry.
*/
dflt_psl_atr = NULL;
atrv = HEAD_PFIFO(ptree->pollskewlist);
for ( ; atrv != NULL; atrv = atrv->link) {
switch (atrv->attr) {
case -1: /* default */
dflt_psl_atr = atrv;
break;
case 3: /* Fall through */
case 4: /* Fall through */
case 5: /* Fall through */
case 6: /* Fall through */
case 7: /* Fall through */
case 8: /* Fall through */
case 9: /* Fall through */
case 10: /* Fall through */
case 11: /* Fall through */
case 12: /* Fall through */
case 13: /* Fall through */
case 14: /* Fall through */
case 15: /* Fall through */
case 16: /* Fall through */
case 17:
/* ignore */
break;
default:
msyslog(LOG_ERR,
"config_access: default PSL scan: ignoring unexpected poll value %d",
atrv->attr);
break;
}
}
/* If we have a nonzero default, initialize the PSL */
if ( dflt_psl_atr
&& ( 0 != dflt_psl_atr->value.r.first
|| 0 != dflt_psl_atr->value.r.last)) {
int i;
for (i = 3; i <= 17; ++i) {
attrtopsl(i, dflt_psl_atr);
}
}
/* Finally, update the PSL with any explicit entries */
atrv = HEAD_PFIFO(ptree->pollskewlist);
for ( ; atrv != NULL; atrv = atrv->link) {
switch (atrv->attr) {
case -1: /* default */
/* Ignore */
break;
case 3: /* Fall through */
case 4: /* Fall through */
case 5: /* Fall through */
case 6: /* Fall through */
case 7: /* Fall through */
case 8: /* Fall through */
case 9: /* Fall through */
case 10: /* Fall through */
case 11: /* Fall through */
case 12: /* Fall through */
case 13: /* Fall through */
case 14: /* Fall through */
case 15: /* Fall through */
case 16: /* Fall through */
case 17:
attrtopsl(atrv->attr, atrv);
break;
default:
break; /* Ignore - we reported this above */
}
}
#if 0
int p;
msyslog(LOG_INFO, "Dumping PSL:");
for (p = 3; p <= 17; ++p) {
psl_item psi;
if (0 == get_pollskew(p, &psi)) {
msyslog(LOG_INFO, "poll %d: sub %d, qty %d, msk %d",
p, psi.sub, psi.qty, psi.msk);
} else {
msyslog(LOG_ERR, "Dumping PSL: get_pollskew(%d) failed!", p);
}
}
#endif
}
void
attrtopsl(int poll, attr_val *avp)
{
DEBUG_INSIST((poll - 3) < sizeof psl);
if (poll < 3 || poll > 17) {
msyslog(LOG_ERR, "attrtopsl(%d, ...): Poll value is out of range - ignoring", poll);
} else {
int pao = poll - 3; /* poll array offset */
int lower = avp->value.r.first; /* a positive number */
int upper = avp->value.r.last;
int psmax = 1 << (poll - 1);
int qmsk;
if (lower > psmax) {
msyslog(LOG_WARNING, "attrtopsl: default: poll %d lower bound reduced from %d to %d",
poll, lower, psmax);
lower = psmax;
}
if (upper > psmax) {
msyslog(LOG_WARNING, "attrtopsl: default: poll %d upper bound reduced from %d to %d",
poll, upper, psmax);
upper = psmax;
}
psl[pao].sub = lower;
psl[pao].qty = lower + upper;
qmsk = 1;
while (qmsk < (lower + upper)) {
qmsk <<= 1;
qmsk |= 1;
};
psl[pao].msk = qmsk;
}
return;
}
#endif /* !SIM */
int
get_pollskew(
int p,
psl_item *rv
)
{
DEBUG_INSIST(3 <= p && 17 >= p);
if (3 <= p && 17 >= p) {
*rv = psl[p - 3];
return 0;
} else {
msyslog(LOG_ERR, "get_pollskew(%d): poll is not between 3 and 17!", p);
return -1;
}
/* NOTREACHED */
}
#ifdef FREE_CFG_T
static void
free_config_access(
@ -3644,6 +3861,13 @@ config_fudge(
/* Parse all the options to the fudge command */
ZERO(clock_stat);
/* some things are not necessarily cleared by ZERO...*/
clock_stat.fudgeminjitter = 0.0;
clock_stat.fudgetime1 = 0.0;
clock_stat.fudgetime2 = 0.0;
clock_stat.p_lastcode = NULL;
clock_stat.clockdesc = NULL;
clock_stat.kv_list = NULL;
curr_opt = HEAD_PFIFO(curr_fudge->options);
for (; curr_opt != NULL; curr_opt = curr_opt->link) {
switch (curr_opt->attr) {
@ -3665,10 +3889,9 @@ config_fudge(
case T_Refid:
clock_stat.haveflags |= CLK_HAVEVAL2;
clock_stat.fudgeval2 = 0;
memcpy(&clock_stat.fudgeval2,
curr_opt->value.s,
min(strlen(curr_opt->value.s), 4));
/* strncpy() does exactly what we want here: */
strncpy((char*)&clock_stat.fudgeval2,
curr_opt->value.s, 4);
break;
case T_Flag1:
@ -3703,6 +3926,11 @@ config_fudge(
clock_stat.flags &= ~CLK_FLAG4;
break;
case T_Minjitter:
clock_stat.haveflags |= CLK_HAVEMINJIT;
clock_stat.fudgeminjitter = curr_opt->value.d;
break;
default:
msyslog(LOG_ERR,
"Unexpected fudge flag %s (%d) for %s",
@ -3757,7 +3985,7 @@ config_vars(
stats_drift_file = 0;
msyslog(LOG_INFO, "config: driftfile disabled");
} else
stats_config(STATS_FREQ_FILE, curr_var->value.s);
stats_config(STATS_FREQ_FILE, curr_var->value.s, 0);
break;
case T_Dscp:
@ -3775,7 +4003,7 @@ config_vars(
break;
case T_Leapfile:
stats_config(STATS_LEAP_FILE, curr_var->value.s);
stats_config(STATS_LEAP_FILE, curr_var->value.s, curr_var->flag);
break;
#ifdef LEAP_SMEAR
@ -3786,7 +4014,7 @@ config_vars(
#endif
case T_Pidfile:
stats_config(STATS_PID_FILE, curr_var->value.s);
stats_config(STATS_PID_FILE, curr_var->value.s, 0);
break;
case T_Logfile:
@ -3866,9 +4094,9 @@ is_sane_resolved_address(
return 0;
}
/*
* Shouldn't be able to specify multicast
* address for server/peer!
* and unicast address for manycastclient!
* Shouldn't be able to specify:
* - multicast address for server/peer!
* - unicast address for manycastclient!
*/
if ((T_Server == hmode || T_Peer == hmode || T_Pool == hmode)
&& IS_MCAST(peeraddr)) {
@ -3928,9 +4156,12 @@ peerflag_bits(
{
int peerflags;
attr_val *option;
int hmode;
DEBUG_INSIST(pn);
/* translate peerflags options to bits */
peerflags = 0;
hmode = pn->host_mode;
option = HEAD_PFIFO(pn->peerflags);
for (; option != NULL; option = option->link) {
switch (option->value.i) {
@ -3969,6 +4200,12 @@ peerflag_bits(
case T_Xleave:
peerflags |= FLAG_XLEAVE;
break;
case T_Xmtnonce:
if ( MODE_CLIENT == hmode ) {
peerflags |= FLAG_LOOPNONCE;
}
break;
}
}
@ -5278,7 +5515,9 @@ ntp_rlimit(
char *
build_iflags(u_int32 iflags)
build_iflags(
u_int32 iflags
)
{
static char ifs[1024];
@ -5351,7 +5590,9 @@ build_iflags(u_int32 iflags)
char *
build_mflags(u_short mflags)
build_mflags(
u_short mflags
)
{
static char mfs[1024];
@ -5379,7 +5620,9 @@ build_mflags(u_short mflags)
char *
build_rflags(u_short rflags)
build_rflags(
u_short rflags
)
{
static char rfs[1024];
@ -5455,6 +5698,11 @@ build_rflags(u_short rflags)
appendstr(rfs, sizeof rfs, "notrust");
}
if (rflags & RES_SRVRSPFUZ) {
rflags &= ~RES_SRVRSPFUZ;
appendstr(rfs, sizeof rfs, "srvrspfuz");
}
if (rflags & RES_VERSION) {
rflags &= ~RES_VERSION;
appendstr(rfs, sizeof rfs, "version");

View File

@ -28,6 +28,8 @@
#include "ntp_leapsec.h"
#include "ntp_md5.h" /* provides OpenSSL digest API */
#include "lib_strbuf.h"
#include "timexsup.h"
#include <rc_cmdlength.h>
#ifdef KERNEL_PLL
# include "ntp_syscall.h"
@ -327,7 +329,8 @@ static const struct ctl_proc control_codes[] = {
#define CC_FLAGS 11
#define CC_DEVICE 12
#define CC_VARLIST 13
#define CC_MAXCODE CC_VARLIST
#define CC_FUDGEMINJIT 14
#define CC_MAXCODE CC_FUDGEMINJIT
/*
* System variable values. The array can be indexed by the variable
@ -625,7 +628,8 @@ static const struct ctl_var clock_var[] = {
{ CC_FLAGS, RO, "flags" }, /* 11 */
{ CC_DEVICE, RO, "device" }, /* 12 */
{ CC_VARLIST, RO, "clock_var_list" }, /* 13 */
{ 0, EOV, "" } /* 14 */
{ CC_FUDGEMINJIT, RO, "minjitter" }, /* 14 */
{ 0, EOV, "" } /* 15 */
};
@ -640,6 +644,7 @@ static const u_char def_clock_var[] = {
CC_NOREPLY,
CC_BADFORMAT,
CC_BADDATA,
CC_FUDGEMINJIT,
CC_FUDGETIME1,
CC_FUDGETIME2,
CC_FUDGEVAL1,
@ -1187,15 +1192,21 @@ process_control(
pkt = (struct ntp_control *)&rbufp->recv_pkt;
/*
* If the length is less than required for the header, or
* it is a response or a fragment, ignore this.
* If the length is less than required for the header,
* ignore it.
*/
if (rbufp->recv_length < (int)CTL_HEADER_LEN
|| (CTL_RESPONSE | CTL_MORE | CTL_ERROR) & pkt->r_m_e_op
if (rbufp->recv_length < (int)CTL_HEADER_LEN) {
DPRINTF(1, ("Short control packet\n"));
numctltooshort++;
return;
}
/*
* If this packet is a response or a fragment, ignore it.
*/
if ( (CTL_RESPONSE | CTL_MORE | CTL_ERROR) & pkt->r_m_e_op
|| pkt->offset != 0) {
DPRINTF(1, ("invalid format in control packet\n"));
if (rbufp->recv_length < (int)CTL_HEADER_LEN)
numctltooshort++;
if (CTL_RESPONSE & pkt->r_m_e_op)
numctlinputresp++;
if (CTL_MORE & pkt->r_m_e_op)
@ -1206,6 +1217,7 @@ process_control(
numctlbadoffset++;
return;
}
res_version = PKT_VERSION(pkt->li_vn_mode);
if (res_version > NTP_VERSION || res_version < NTP_OLDVERSION) {
DPRINTF(1, ("unknown version %d in control packet\n",
@ -1910,15 +1922,6 @@ ctl_putsys(
static struct timex ntx;
static u_long ntp_adjtime_time;
static const double to_ms_usec =
1.0e-3; /* usec to msec */
static const double to_ms_nusec =
# ifdef STA_NANO
1.0e-6; /* nsec to msec */
# else
to_ms_usec;
# endif
/*
* CS_K_* variables depend on up-to-date output of ntp_adjtime()
*/
@ -2321,7 +2324,8 @@ ctl_putsys(
case CS_K_OFFSET:
CTL_IF_KERNLOOP(
ctl_putdblf,
(sys_var[varid].text, 0, -1, to_ms_nusec * ntx.offset)
(sys_var[varid].text, 0, -1,
1000 * dbl_from_var_long(ntx.offset, ntx.status))
);
break;
@ -2336,7 +2340,7 @@ ctl_putsys(
CTL_IF_KERNLOOP(
ctl_putdblf,
(sys_var[varid].text, 0, 6,
to_ms_usec * ntx.maxerror)
1000 * dbl_from_usec_long(ntx.maxerror))
);
break;
@ -2344,7 +2348,7 @@ ctl_putsys(
CTL_IF_KERNLOOP(
ctl_putdblf,
(sys_var[varid].text, 0, 6,
to_ms_usec * ntx.esterror)
1000 * dbl_from_usec_long(ntx.esterror))
);
break;
@ -2368,7 +2372,7 @@ ctl_putsys(
CTL_IF_KERNLOOP(
ctl_putdblf,
(sys_var[varid].text, 0, 6,
to_ms_usec * ntx.precision)
1000 * dbl_from_var_long(ntx.precision, ntx.status))
);
break;
@ -2396,7 +2400,8 @@ ctl_putsys(
case CS_K_PPS_JITTER:
CTL_IF_KERNPPS(
ctl_putdbl,
(sys_var[varid].text, to_ms_nusec * ntx.jitter)
(sys_var[varid].text,
1000 * dbl_from_var_long(ntx.jitter, ntx.status))
);
break;
@ -2965,14 +2970,9 @@ ctl_putclock(
break;
case CC_FUDGEVAL2:
if (mustput || (pcs->haveflags & CLK_HAVEVAL2)) {
if (pcs->fudgeval1 > 1)
ctl_putadr(clock_var[id].text,
pcs->fudgeval2, NULL);
else
ctl_putrefid(clock_var[id].text,
pcs->fudgeval2);
}
/* RefID of clocks are always text even if stratum is fudged */
if (mustput || (pcs->haveflags & CLK_HAVEVAL2))
ctl_putrefid(clock_var[id].text, pcs->fudgeval2);
break;
case CC_FLAGS:
@ -3045,6 +3045,16 @@ ctl_putclock(
*s = '\0';
ctl_putdata(buf, (unsigned)(s - buf), 0);
break;
case CC_FUDGEMINJIT:
if (mustput || (pcs->haveflags & CLK_HAVEMINJIT))
ctl_putdbl(clock_var[id].text,
pcs->fudgeminjitter * 1e3);
break;
default:
break;
}
}
#endif

View File

@ -177,7 +177,7 @@ endpt * any_interface; /* wildcard ipv4 interface */
endpt * any6_interface; /* wildcard ipv6 interface */
endpt * loopback_interface; /* loopback ipv4 interface */
isc_boolean_t broadcast_client_enabled; /* is broadcast client enabled */
static isc_boolean_t broadcast_client_enabled; /* is broadcast client enabled */
u_int sys_ifnum; /* next .ifnum to assign */
int ninterfaces; /* Total number of interfaces */
@ -2011,10 +2011,7 @@ update_interfaces(
*/
refresh_all_peerinterfaces();
if (broadcast_client_enabled)
io_setbclient();
if (sys_bclient)
if (broadcast_client_enabled || sys_bclient)
io_setbclient();
#ifdef MCAST
@ -2343,11 +2340,12 @@ socket_broadcast_disable(
/*
* return the broadcast client flag value
*/
isc_boolean_t
/*isc_boolean_t
get_broadcastclient_flag(void)
{
return (broadcast_client_enabled);
}
*/
/*
* Check to see if the address is a multicast address
@ -2605,32 +2603,38 @@ void
io_setbclient(void)
{
#ifdef OPEN_BCAST_SOCKET
struct interface * interf;
unsigned int nif;
endpt * ep;
unsigned int nif, ni4, ni6;
nif = 0;
nif = ni4 = ni6 = 0;
set_reuseaddr(1);
for (interf = ep_list;
interf != NULL;
interf = interf->elink) {
if (interf->flags & (INT_WILDCARD | INT_LOOPBACK))
for (ep = ep_list; ep != NULL; ep = ep->elink) {
/* count IPv6 vs IPv4 interfaces. Needed later to decide
* if we should log an error or not.
*/
switch (ep->family) {
case AF_INET : ++ni4; break;
case AF_INET6: ++ni6; break;
default : break;
}
if (ep->flags & (INT_WILDCARD | INT_LOOPBACK))
continue;
/* use only allowed addresses */
if (interf->ignore_packets)
if (ep->ignore_packets)
continue;
/* Need a broadcast-capable interface */
if (!(interf->flags & INT_BROADCAST))
if (!(ep->flags & INT_BROADCAST))
continue;
/* Only IPv4 addresses are valid for broadcast */
REQUIRE(IS_IPV4(&interf->bcast));
REQUIRE(IS_IPV4(&ep->bcast));
/* Do we already have the broadcast address open? */
if (interf->flags & INT_BCASTOPEN) {
if (ep->flags & INT_BCASTOPEN) {
/*
* account for already open interfaces to avoid
* misleading warning below
@ -2642,19 +2646,19 @@ io_setbclient(void)
/*
* Try to open the broadcast address
*/
interf->family = AF_INET;
interf->bfd = open_socket(&interf->bcast, 1, 0, interf);
ep->family = AF_INET;
ep->bfd = open_socket(&ep->bcast, 1, 0, ep);
/*
* If we succeeded then we use it otherwise enable
* broadcast on the interface address
*/
if (interf->bfd != INVALID_SOCKET) {
if (ep->bfd != INVALID_SOCKET) {
nif++;
interf->flags |= INT_BCASTOPEN;
ep->flags |= INT_BCASTOPEN;
msyslog(LOG_INFO,
"Listen for broadcasts to %s on interface #%d %s",
stoa(&interf->bcast), interf->ifnum, interf->name);
stoa(&ep->bcast), ep->ifnum, ep->name);
} else switch (errno) {
/* Silently ignore EADDRINUSE as we probably
* opened the socket already for an address in
@ -2668,8 +2672,8 @@ io_setbclient(void)
* regular socket, it's quite useless to try this
* again.
*/
if (interf->fd != INVALID_SOCKET) {
interf->flags |= INT_BCASTOPEN;
if (ep->fd != INVALID_SOCKET) {
ep->flags |= INT_BCASTOPEN;
nif++;
}
# endif
@ -2678,7 +2682,7 @@ io_setbclient(void)
default:
msyslog(LOG_INFO,
"failed to listen for broadcasts to %s on interface #%d %s",
stoa(&interf->bcast), interf->ifnum, interf->name);
stoa(&ep->bcast), ep->ifnum, ep->name);
break;
}
}
@ -2688,8 +2692,14 @@ io_setbclient(void)
DPRINTF(1, ("io_setbclient: listening to %d broadcast addresses\n", nif));
} else {
broadcast_client_enabled = ISC_FALSE;
msyslog(LOG_ERR,
"Unable to listen for broadcasts, no broadcast interfaces available");
/* This is expected when having only IPv6 interfaces
* and no IPv4 interfaces at all. We suppress the error
* log in that case... everything else should work!
*/
if (ni4 && !ni6) {
msyslog(LOG_ERR,
"Unable to listen for broadcasts, no broadcast interfaces available");
}
}
#else
msyslog(LOG_ERR,
@ -3134,7 +3144,8 @@ sendpkt(
int rc;
u_char cttl;
l_fp fp_zero = { { 0 }, 0 };
l_fp org, rec, xmt;
ismcast = IS_MCAST(dest);
if (!ismcast)
src = ep;
@ -3219,11 +3230,14 @@ sendpkt(
} while (ismcast && src != NULL);
/* HMS: pkt->rootdisp is usually random here */
NTOHL_FP(&pkt->org, &org);
NTOHL_FP(&pkt->rec, &rec);
NTOHL_FP(&pkt->xmt, &xmt);
record_raw_stats(src ? &src->sin : NULL, dest,
&pkt->org, &pkt->rec, &pkt->xmt, &fp_zero,
PKT_MODE(pkt->li_vn_mode),
PKT_VERSION(pkt->li_vn_mode),
&org, &rec, &xmt, &fp_zero,
PKT_LEAP(pkt->li_vn_mode),
PKT_VERSION(pkt->li_vn_mode),
PKT_MODE(pkt->li_vn_mode),
pkt->stratum,
pkt->ppoll, pkt->precision,
pkt->rootdelay, pkt->rootdisp, pkt->refid,

File diff suppressed because it is too large Load Diff

View File

@ -422,7 +422,8 @@ int/*BOOL*/
leapsec_load_stream(
FILE * ifp ,
const char * fname,
int/*BOOL*/ logall)
int/*BOOL*/ logall,
int/*BOOL*/ vhash)
{
leap_table_t *pt;
int rcheck;
@ -430,36 +431,37 @@ leapsec_load_stream(
if (NULL == fname)
fname = "<unknown>";
rcheck = leapsec_validate((leapsec_reader)getc, ifp);
if (logall)
switch (rcheck)
{
case LSVALID_GOODHASH:
msyslog(LOG_NOTICE, "%s ('%s'): good hash signature",
logPrefix, fname);
break;
case LSVALID_NOHASH:
msyslog(LOG_ERR, "%s ('%s'): no hash signature",
logPrefix, fname);
break;
case LSVALID_BADHASH:
msyslog(LOG_ERR, "%s ('%s'): signature mismatch",
logPrefix, fname);
break;
case LSVALID_BADFORMAT:
msyslog(LOG_ERR, "%s ('%s'): malformed hash signature",
logPrefix, fname);
break;
default:
msyslog(LOG_ERR, "%s ('%s'): unknown error code %d",
logPrefix, fname, rcheck);
break;
}
if (rcheck < 0)
return FALSE;
rewind(ifp);
if (vhash) {
rcheck = leapsec_validate((leapsec_reader)getc, ifp);
if (logall)
switch (rcheck)
{
case LSVALID_GOODHASH:
msyslog(LOG_NOTICE, "%s ('%s'): good hash signature",
logPrefix, fname);
break;
case LSVALID_NOHASH:
msyslog(LOG_ERR, "%s ('%s'): no hash signature",
logPrefix, fname);
break;
case LSVALID_BADHASH:
msyslog(LOG_ERR, "%s ('%s'): signature mismatch",
logPrefix, fname);
break;
case LSVALID_BADFORMAT:
msyslog(LOG_ERR, "%s ('%s'): malformed hash signature",
logPrefix, fname);
break;
default:
msyslog(LOG_ERR, "%s ('%s'): unknown error code %d",
logPrefix, fname, rcheck);
break;
}
if (rcheck < 0)
return FALSE;
rewind(ifp);
}
pt = leapsec_get_table(TRUE);
if (!leapsec_load(pt, (leapsec_reader)getc, ifp, TRUE)) {
switch (errno) {
@ -498,7 +500,8 @@ leapsec_load_file(
const char * fname,
struct stat * sb_old,
int/*BOOL*/ force,
int/*BOOL*/ logall)
int/*BOOL*/ logall,
int/*BOOL*/ vhash)
{
FILE * fp;
struct stat sb_new;
@ -551,7 +554,7 @@ leapsec_load_file(
return FALSE;
}
rc = leapsec_load_stream(fp, fname, logall);
rc = leapsec_load_stream(fp, fname, logall, vhash);
fclose(fp);
return rc;
}

View File

@ -174,7 +174,7 @@ extern void leapsec_dump(const leap_table_t*, leapsec_dumper func, void *farg);
* around the generic load function, 'leapsec_load()'.
*/
extern int/*BOOL*/ leapsec_load_stream(FILE * fp, const char * fname,
int/*BOOL*/logall);
int/*BOOL*/logall, int/*BOOL*/vhash);
/* Read a leap second file from file. It checks that the file exists and
* (if 'force' is not applied) the ctime/mtime has changed since the
@ -184,7 +184,8 @@ extern int/*BOOL*/ leapsec_load_stream(FILE * fp, const char * fname,
* otherwise. Uses 'leapsec_load_stream()' internally.
*/
extern int/*BOOL*/ leapsec_load_file(const char * fname, struct stat * sb,
int/*BOOL*/force, int/*BOOL*/logall);
int/*BOOL*/force, int/*BOOL*/logall,
int/*BOOL*/vhash);
/* Get the current leap data signature. This consists of the last
* ransition, the table expiration, and the total TAI difference at the

View File

@ -15,6 +15,7 @@
#include "ntp_io.h"
#include "ntp_unixtime.h"
#include "ntp_stdlib.h"
#include "timexsup.h"
#include <limits.h>
#include <stdio.h>
@ -167,6 +168,9 @@ u_char sys_poll; /* time constant/poll (log2 s) */
int tc_counter; /* jiggle counter */
double last_offset; /* last offset (s) */
u_int tc_twinlo; /* TC step down not before this time */
u_int tc_twinhi; /* TC step up not before this time */
/*
* Huff-n'-puff filter variables
*/
@ -761,30 +765,21 @@ local_clock(
if (ext_enable) {
ntv.modes = MOD_STATUS;
} else {
#ifdef STA_NANO
ntv.modes = MOD_BITS | MOD_NANO;
#else /* STA_NANO */
ntv.modes = MOD_BITS;
#endif /* STA_NANO */
if (clock_offset < 0)
dtemp = -.5;
else
dtemp = .5;
ntv.offset = var_long_from_dbl(
clock_offset, &ntv.modes);
#ifdef STA_NANO
ntv.offset = (int32)(clock_offset * 1e9 +
dtemp);
ntv.constant = sys_poll;
#else /* STA_NANO */
ntv.offset = (int32)(clock_offset * 1e6 +
dtemp);
ntv.constant = sys_poll - 4;
#endif /* STA_NANO */
if (ntv.constant < 0)
ntv.constant = 0;
ntv.esterror = (u_int32)(clock_jitter * 1e6);
ntv.maxerror = (u_int32)((sys_rootdelay / 2 +
sys_rootdisp) * 1e6);
ntv.esterror = usec_long_from_dbl(
clock_jitter);
ntv.maxerror = usec_long_from_dbl(
sys_rootdelay / 2 + sys_rootdisp);
ntv.status = STA_PLL;
/*
@ -823,22 +818,15 @@ local_clock(
ntp_adjtime_error_handler(__func__, &ntv, ntp_adj_ret, errno, hardpps_enable, 0, __LINE__ - 1);
}
pll_status = ntv.status;
#ifdef STA_NANO
clock_offset = ntv.offset / 1e9;
#else /* STA_NANO */
clock_offset = ntv.offset / 1e6;
#endif /* STA_NANO */
clock_offset = dbl_from_var_long(ntv.offset, ntv.status);
clock_frequency = FREQTOD(ntv.freq);
/*
* If the kernel PPS is lit, monitor its performance.
*/
if (ntv.status & STA_PPSTIME) {
#ifdef STA_NANO
clock_jitter = ntv.jitter / 1e9;
#else /* STA_NANO */
clock_jitter = ntv.jitter / 1e6;
#endif /* STA_NANO */
clock_jitter = dbl_from_var_long(
ntv.jitter, ntv.status);
}
#if defined(STA_NANO) && NTP_API == 4
@ -888,34 +876,52 @@ local_clock(
* increased, otherwise it is decreased. A bit of hysteresis
* helps calm the dance. Works best using burst mode. Don't
* fiddle with the poll during the startup clamp period.
* [Bug 3615] also observe time gates to avoid eager stepping
*/
if (freq_cnt > 0) {
tc_counter = 0;
tc_twinlo = current_time;
tc_twinhi = current_time;
} else if (fabs(clock_offset) < CLOCK_PGATE * clock_jitter) {
tc_counter += sys_poll;
if (tc_counter > CLOCK_LIMIT) {
tc_counter = CLOCK_LIMIT;
if (sys_poll < peer->maxpoll) {
tc_counter = 0;
sys_poll++;
}
if (sys_poll < peer->maxpoll)
sys_poll += (current_time >= tc_twinhi);
}
} else {
tc_counter -= sys_poll << 1;
if (tc_counter < -CLOCK_LIMIT) {
tc_counter = -CLOCK_LIMIT;
if (sys_poll > peer->minpoll) {
tc_counter = 0;
sys_poll--;
}
if (sys_poll > peer->minpoll)
sys_poll -= (current_time >= tc_twinlo);
}
}
/*
* If the time constant has changed, update the poll variables.
*
* [bug 3615] also set new time gates
* The time limit for stepping down will be half the TC interval
* or 60 secs from now, whatever is bigger, and the step up time
* limit will be half the TC interval after the step down limit.
*
* The 'sys_poll' value affects the servo loop gain, and
* overshooting sys_poll slows it down unnecessarily. Stepping
* down too fast also has bad effects.
*
* The 'tc_counter' dance itself is something that *should*
* happen *once* every (1 << sys_poll) seconds, I think, but
* that's not how it works right now, and adding time guards
* seems the least intrusive way to handle this.
*/
if (osys_poll != sys_poll)
poll_update(peer, sys_poll);
if (osys_poll != sys_poll) {
u_int deadband = 1u << (sys_poll - 1);
tc_counter = 0;
tc_twinlo = current_time + max(deadband, 60);
tc_twinhi = tc_twinlo + deadband;
poll_update(peer, sys_poll, 0);
}
/*
* Yibbidy, yibbbidy, yibbidy; that'h all folks.

File diff suppressed because it is too large Load Diff

View File

@ -30,8 +30,8 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_YY_NTP_PARSER_H_INCLUDED
# define YY_YY_NTP_PARSER_H_INCLUDED
#ifndef YY_YY__NTPD_NTP_PARSER_H_INCLUDED
# define YY_YY__NTPD_NTP_PARSER_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
@ -64,187 +64,196 @@ extern int yydebug;
T_Burst = 274,
T_Calibrate = 275,
T_Ceiling = 276,
T_Clockstats = 277,
T_Cohort = 278,
T_ControlKey = 279,
T_Crypto = 280,
T_Cryptostats = 281,
T_Ctl = 282,
T_Day = 283,
T_Default = 284,
T_Digest = 285,
T_Disable = 286,
T_Discard = 287,
T_Dispersion = 288,
T_Double = 289,
T_Driftfile = 290,
T_Drop = 291,
T_Dscp = 292,
T_Ellipsis = 293,
T_Enable = 294,
T_End = 295,
T_Epeer = 296,
T_False = 297,
T_File = 298,
T_Filegen = 299,
T_Filenum = 300,
T_Flag1 = 301,
T_Flag2 = 302,
T_Flag3 = 303,
T_Flag4 = 304,
T_Flake = 305,
T_Floor = 306,
T_Freq = 307,
T_Fudge = 308,
T_Host = 309,
T_Huffpuff = 310,
T_Iburst = 311,
T_Ident = 312,
T_Ignore = 313,
T_Incalloc = 314,
T_Incmem = 315,
T_Initalloc = 316,
T_Initmem = 317,
T_Includefile = 318,
T_Integer = 319,
T_Interface = 320,
T_Intrange = 321,
T_Io = 322,
T_Ippeerlimit = 323,
T_Ipv4 = 324,
T_Ipv4_flag = 325,
T_Ipv6 = 326,
T_Ipv6_flag = 327,
T_Kernel = 328,
T_Key = 329,
T_Keys = 330,
T_Keysdir = 331,
T_Kod = 332,
T_Mssntp = 333,
T_Leapfile = 334,
T_Leapsmearinterval = 335,
T_Limited = 336,
T_Link = 337,
T_Listen = 338,
T_Logconfig = 339,
T_Logfile = 340,
T_Loopstats = 341,
T_Lowpriotrap = 342,
T_Manycastclient = 343,
T_Manycastserver = 344,
T_Mask = 345,
T_Maxage = 346,
T_Maxclock = 347,
T_Maxdepth = 348,
T_Maxdist = 349,
T_Maxmem = 350,
T_Maxpoll = 351,
T_Mdnstries = 352,
T_Mem = 353,
T_Memlock = 354,
T_Minclock = 355,
T_Mindepth = 356,
T_Mindist = 357,
T_Minimum = 358,
T_Minpoll = 359,
T_Minsane = 360,
T_Mode = 361,
T_Mode7 = 362,
T_Monitor = 363,
T_Month = 364,
T_Mru = 365,
T_Multicastclient = 366,
T_Nic = 367,
T_Nolink = 368,
T_Nomodify = 369,
T_Nomrulist = 370,
T_None = 371,
T_Nonvolatile = 372,
T_Noepeer = 373,
T_Nopeer = 374,
T_Noquery = 375,
T_Noselect = 376,
T_Noserve = 377,
T_Notrap = 378,
T_Notrust = 379,
T_Ntp = 380,
T_Ntpport = 381,
T_NtpSignDsocket = 382,
T_Orphan = 383,
T_Orphanwait = 384,
T_PCEdigest = 385,
T_Panic = 386,
T_Peer = 387,
T_Peerstats = 388,
T_Phone = 389,
T_Pid = 390,
T_Pidfile = 391,
T_Pool = 392,
T_Port = 393,
T_Preempt = 394,
T_Prefer = 395,
T_Protostats = 396,
T_Pw = 397,
T_Randfile = 398,
T_Rawstats = 399,
T_Refid = 400,
T_Requestkey = 401,
T_Reset = 402,
T_Restrict = 403,
T_Revoke = 404,
T_Rlimit = 405,
T_Saveconfigdir = 406,
T_Server = 407,
T_Setvar = 408,
T_Source = 409,
T_Stacksize = 410,
T_Statistics = 411,
T_Stats = 412,
T_Statsdir = 413,
T_Step = 414,
T_Stepback = 415,
T_Stepfwd = 416,
T_Stepout = 417,
T_Stratum = 418,
T_String = 419,
T_Sys = 420,
T_Sysstats = 421,
T_Tick = 422,
T_Time1 = 423,
T_Time2 = 424,
T_Timer = 425,
T_Timingstats = 426,
T_Tinker = 427,
T_Tos = 428,
T_Trap = 429,
T_True = 430,
T_Trustedkey = 431,
T_Ttl = 432,
T_Type = 433,
T_U_int = 434,
T_UEcrypto = 435,
T_UEcryptonak = 436,
T_UEdigest = 437,
T_Unconfig = 438,
T_Unpeer = 439,
T_Version = 440,
T_WanderThreshold = 441,
T_Week = 442,
T_Wildcard = 443,
T_Xleave = 444,
T_Year = 445,
T_Flag = 446,
T_EOC = 447,
T_Simulate = 448,
T_Beep_Delay = 449,
T_Sim_Duration = 450,
T_Server_Offset = 451,
T_Duration = 452,
T_Freq_Offset = 453,
T_Wander = 454,
T_Jitter = 455,
T_Prop_Delay = 456,
T_Proc_Delay = 457
T_Checkhash = 277,
T_Clockstats = 278,
T_Cohort = 279,
T_ControlKey = 280,
T_Crypto = 281,
T_Cryptostats = 282,
T_Ctl = 283,
T_Day = 284,
T_Default = 285,
T_Digest = 286,
T_Disable = 287,
T_Discard = 288,
T_Dispersion = 289,
T_Double = 290,
T_Driftfile = 291,
T_Drop = 292,
T_Dscp = 293,
T_Ellipsis = 294,
T_Enable = 295,
T_End = 296,
T_Epeer = 297,
T_False = 298,
T_File = 299,
T_Filegen = 300,
T_Filenum = 301,
T_Flag1 = 302,
T_Flag2 = 303,
T_Flag3 = 304,
T_Flag4 = 305,
T_Flake = 306,
T_Floor = 307,
T_Freq = 308,
T_Fudge = 309,
T_Fuzz = 310,
T_Host = 311,
T_Huffpuff = 312,
T_Iburst = 313,
T_Ident = 314,
T_Ignore = 315,
T_Ignorehash = 316,
T_Incalloc = 317,
T_Incmem = 318,
T_Initalloc = 319,
T_Initmem = 320,
T_Includefile = 321,
T_Integer = 322,
T_Interface = 323,
T_Intrange = 324,
T_Io = 325,
T_Ippeerlimit = 326,
T_Ipv4 = 327,
T_Ipv4_flag = 328,
T_Ipv6 = 329,
T_Ipv6_flag = 330,
T_Kernel = 331,
T_Key = 332,
T_Keys = 333,
T_Keysdir = 334,
T_Kod = 335,
T_Leapfile = 336,
T_Leapsmearinterval = 337,
T_Limited = 338,
T_Link = 339,
T_Listen = 340,
T_Logconfig = 341,
T_Logfile = 342,
T_Loopstats = 343,
T_Lowpriotrap = 344,
T_Manycastclient = 345,
T_Manycastserver = 346,
T_Mask = 347,
T_Maxage = 348,
T_Maxclock = 349,
T_Maxdepth = 350,
T_Maxdist = 351,
T_Maxmem = 352,
T_Maxpoll = 353,
T_Mdnstries = 354,
T_Mem = 355,
T_Memlock = 356,
T_Minclock = 357,
T_Mindepth = 358,
T_Mindist = 359,
T_Minimum = 360,
T_Minjitter = 361,
T_Minpoll = 362,
T_Minsane = 363,
T_Mode = 364,
T_Mode7 = 365,
T_Monitor = 366,
T_Month = 367,
T_Mru = 368,
T_Mssntp = 369,
T_Multicastclient = 370,
T_Nic = 371,
T_Nolink = 372,
T_Nomodify = 373,
T_Nomrulist = 374,
T_None = 375,
T_Nonvolatile = 376,
T_Noepeer = 377,
T_Nopeer = 378,
T_Noquery = 379,
T_Noselect = 380,
T_Noserve = 381,
T_Notrap = 382,
T_Notrust = 383,
T_Ntp = 384,
T_Ntpport = 385,
T_NtpSignDsocket = 386,
T_Orphan = 387,
T_Orphanwait = 388,
T_PCEdigest = 389,
T_Panic = 390,
T_Peer = 391,
T_Peerstats = 392,
T_Phone = 393,
T_Pid = 394,
T_Pidfile = 395,
T_Poll = 396,
T_PollSkewList = 397,
T_Pool = 398,
T_Port = 399,
T_Preempt = 400,
T_Prefer = 401,
T_Protostats = 402,
T_Pw = 403,
T_Randfile = 404,
T_Rawstats = 405,
T_Refid = 406,
T_Requestkey = 407,
T_Reset = 408,
T_Restrict = 409,
T_Revoke = 410,
T_Rlimit = 411,
T_Saveconfigdir = 412,
T_Server = 413,
T_Serverresponse = 414,
T_ServerresponseFuzz = 415,
T_Setvar = 416,
T_Source = 417,
T_Stacksize = 418,
T_Statistics = 419,
T_Stats = 420,
T_Statsdir = 421,
T_Step = 422,
T_Stepback = 423,
T_Stepfwd = 424,
T_Stepout = 425,
T_Stratum = 426,
T_String = 427,
T_Sys = 428,
T_Sysstats = 429,
T_Tick = 430,
T_Time1 = 431,
T_Time2 = 432,
T_Timer = 433,
T_Timingstats = 434,
T_Tinker = 435,
T_Tos = 436,
T_Trap = 437,
T_True = 438,
T_Trustedkey = 439,
T_Ttl = 440,
T_Type = 441,
T_U_int = 442,
T_UEcrypto = 443,
T_UEcryptonak = 444,
T_UEdigest = 445,
T_Unconfig = 446,
T_Unpeer = 447,
T_Version = 448,
T_WanderThreshold = 449,
T_Week = 450,
T_Wildcard = 451,
T_Xleave = 452,
T_Xmtnonce = 453,
T_Year = 454,
T_Flag = 455,
T_EOC = 456,
T_Simulate = 457,
T_Beep_Delay = 458,
T_Sim_Duration = 459,
T_Server_Offset = 460,
T_Duration = 461,
T_Freq_Offset = 462,
T_Wander = 463,
T_Jitter = 464,
T_Prop_Delay = 465,
T_Proc_Delay = 466
};
#endif
/* Tokens. */
@ -267,194 +276,203 @@ extern int yydebug;
#define T_Burst 274
#define T_Calibrate 275
#define T_Ceiling 276
#define T_Clockstats 277
#define T_Cohort 278
#define T_ControlKey 279
#define T_Crypto 280
#define T_Cryptostats 281
#define T_Ctl 282
#define T_Day 283
#define T_Default 284
#define T_Digest 285
#define T_Disable 286
#define T_Discard 287
#define T_Dispersion 288
#define T_Double 289
#define T_Driftfile 290
#define T_Drop 291
#define T_Dscp 292
#define T_Ellipsis 293
#define T_Enable 294
#define T_End 295
#define T_Epeer 296
#define T_False 297
#define T_File 298
#define T_Filegen 299
#define T_Filenum 300
#define T_Flag1 301
#define T_Flag2 302
#define T_Flag3 303
#define T_Flag4 304
#define T_Flake 305
#define T_Floor 306
#define T_Freq 307
#define T_Fudge 308
#define T_Host 309
#define T_Huffpuff 310
#define T_Iburst 311
#define T_Ident 312
#define T_Ignore 313
#define T_Incalloc 314
#define T_Incmem 315
#define T_Initalloc 316
#define T_Initmem 317
#define T_Includefile 318
#define T_Integer 319
#define T_Interface 320
#define T_Intrange 321
#define T_Io 322
#define T_Ippeerlimit 323
#define T_Ipv4 324
#define T_Ipv4_flag 325
#define T_Ipv6 326
#define T_Ipv6_flag 327
#define T_Kernel 328
#define T_Key 329
#define T_Keys 330
#define T_Keysdir 331
#define T_Kod 332
#define T_Mssntp 333
#define T_Leapfile 334
#define T_Leapsmearinterval 335
#define T_Limited 336
#define T_Link 337
#define T_Listen 338
#define T_Logconfig 339
#define T_Logfile 340
#define T_Loopstats 341
#define T_Lowpriotrap 342
#define T_Manycastclient 343
#define T_Manycastserver 344
#define T_Mask 345
#define T_Maxage 346
#define T_Maxclock 347
#define T_Maxdepth 348
#define T_Maxdist 349
#define T_Maxmem 350
#define T_Maxpoll 351
#define T_Mdnstries 352
#define T_Mem 353
#define T_Memlock 354
#define T_Minclock 355
#define T_Mindepth 356
#define T_Mindist 357
#define T_Minimum 358
#define T_Minpoll 359
#define T_Minsane 360
#define T_Mode 361
#define T_Mode7 362
#define T_Monitor 363
#define T_Month 364
#define T_Mru 365
#define T_Multicastclient 366
#define T_Nic 367
#define T_Nolink 368
#define T_Nomodify 369
#define T_Nomrulist 370
#define T_None 371
#define T_Nonvolatile 372
#define T_Noepeer 373
#define T_Nopeer 374
#define T_Noquery 375
#define T_Noselect 376
#define T_Noserve 377
#define T_Notrap 378
#define T_Notrust 379
#define T_Ntp 380
#define T_Ntpport 381
#define T_NtpSignDsocket 382
#define T_Orphan 383
#define T_Orphanwait 384
#define T_PCEdigest 385
#define T_Panic 386
#define T_Peer 387
#define T_Peerstats 388
#define T_Phone 389
#define T_Pid 390
#define T_Pidfile 391
#define T_Pool 392
#define T_Port 393
#define T_Preempt 394
#define T_Prefer 395
#define T_Protostats 396
#define T_Pw 397
#define T_Randfile 398
#define T_Rawstats 399
#define T_Refid 400
#define T_Requestkey 401
#define T_Reset 402
#define T_Restrict 403
#define T_Revoke 404
#define T_Rlimit 405
#define T_Saveconfigdir 406
#define T_Server 407
#define T_Setvar 408
#define T_Source 409
#define T_Stacksize 410
#define T_Statistics 411
#define T_Stats 412
#define T_Statsdir 413
#define T_Step 414
#define T_Stepback 415
#define T_Stepfwd 416
#define T_Stepout 417
#define T_Stratum 418
#define T_String 419
#define T_Sys 420
#define T_Sysstats 421
#define T_Tick 422
#define T_Time1 423
#define T_Time2 424
#define T_Timer 425
#define T_Timingstats 426
#define T_Tinker 427
#define T_Tos 428
#define T_Trap 429
#define T_True 430
#define T_Trustedkey 431
#define T_Ttl 432
#define T_Type 433
#define T_U_int 434
#define T_UEcrypto 435
#define T_UEcryptonak 436
#define T_UEdigest 437
#define T_Unconfig 438
#define T_Unpeer 439
#define T_Version 440
#define T_WanderThreshold 441
#define T_Week 442
#define T_Wildcard 443
#define T_Xleave 444
#define T_Year 445
#define T_Flag 446
#define T_EOC 447
#define T_Simulate 448
#define T_Beep_Delay 449
#define T_Sim_Duration 450
#define T_Server_Offset 451
#define T_Duration 452
#define T_Freq_Offset 453
#define T_Wander 454
#define T_Jitter 455
#define T_Prop_Delay 456
#define T_Proc_Delay 457
#define T_Checkhash 277
#define T_Clockstats 278
#define T_Cohort 279
#define T_ControlKey 280
#define T_Crypto 281
#define T_Cryptostats 282
#define T_Ctl 283
#define T_Day 284
#define T_Default 285
#define T_Digest 286
#define T_Disable 287
#define T_Discard 288
#define T_Dispersion 289
#define T_Double 290
#define T_Driftfile 291
#define T_Drop 292
#define T_Dscp 293
#define T_Ellipsis 294
#define T_Enable 295
#define T_End 296
#define T_Epeer 297
#define T_False 298
#define T_File 299
#define T_Filegen 300
#define T_Filenum 301
#define T_Flag1 302
#define T_Flag2 303
#define T_Flag3 304
#define T_Flag4 305
#define T_Flake 306
#define T_Floor 307
#define T_Freq 308
#define T_Fudge 309
#define T_Fuzz 310
#define T_Host 311
#define T_Huffpuff 312
#define T_Iburst 313
#define T_Ident 314
#define T_Ignore 315
#define T_Ignorehash 316
#define T_Incalloc 317
#define T_Incmem 318
#define T_Initalloc 319
#define T_Initmem 320
#define T_Includefile 321
#define T_Integer 322
#define T_Interface 323
#define T_Intrange 324
#define T_Io 325
#define T_Ippeerlimit 326
#define T_Ipv4 327
#define T_Ipv4_flag 328
#define T_Ipv6 329
#define T_Ipv6_flag 330
#define T_Kernel 331
#define T_Key 332
#define T_Keys 333
#define T_Keysdir 334
#define T_Kod 335
#define T_Leapfile 336
#define T_Leapsmearinterval 337
#define T_Limited 338
#define T_Link 339
#define T_Listen 340
#define T_Logconfig 341
#define T_Logfile 342
#define T_Loopstats 343
#define T_Lowpriotrap 344
#define T_Manycastclient 345
#define T_Manycastserver 346
#define T_Mask 347
#define T_Maxage 348
#define T_Maxclock 349
#define T_Maxdepth 350
#define T_Maxdist 351
#define T_Maxmem 352
#define T_Maxpoll 353
#define T_Mdnstries 354
#define T_Mem 355
#define T_Memlock 356
#define T_Minclock 357
#define T_Mindepth 358
#define T_Mindist 359
#define T_Minimum 360
#define T_Minjitter 361
#define T_Minpoll 362
#define T_Minsane 363
#define T_Mode 364
#define T_Mode7 365
#define T_Monitor 366
#define T_Month 367
#define T_Mru 368
#define T_Mssntp 369
#define T_Multicastclient 370
#define T_Nic 371
#define T_Nolink 372
#define T_Nomodify 373
#define T_Nomrulist 374
#define T_None 375
#define T_Nonvolatile 376
#define T_Noepeer 377
#define T_Nopeer 378
#define T_Noquery 379
#define T_Noselect 380
#define T_Noserve 381
#define T_Notrap 382
#define T_Notrust 383
#define T_Ntp 384
#define T_Ntpport 385
#define T_NtpSignDsocket 386
#define T_Orphan 387
#define T_Orphanwait 388
#define T_PCEdigest 389
#define T_Panic 390
#define T_Peer 391
#define T_Peerstats 392
#define T_Phone 393
#define T_Pid 394
#define T_Pidfile 395
#define T_Poll 396
#define T_PollSkewList 397
#define T_Pool 398
#define T_Port 399
#define T_Preempt 400
#define T_Prefer 401
#define T_Protostats 402
#define T_Pw 403
#define T_Randfile 404
#define T_Rawstats 405
#define T_Refid 406
#define T_Requestkey 407
#define T_Reset 408
#define T_Restrict 409
#define T_Revoke 410
#define T_Rlimit 411
#define T_Saveconfigdir 412
#define T_Server 413
#define T_Serverresponse 414
#define T_ServerresponseFuzz 415
#define T_Setvar 416
#define T_Source 417
#define T_Stacksize 418
#define T_Statistics 419
#define T_Stats 420
#define T_Statsdir 421
#define T_Step 422
#define T_Stepback 423
#define T_Stepfwd 424
#define T_Stepout 425
#define T_Stratum 426
#define T_String 427
#define T_Sys 428
#define T_Sysstats 429
#define T_Tick 430
#define T_Time1 431
#define T_Time2 432
#define T_Timer 433
#define T_Timingstats 434
#define T_Tinker 435
#define T_Tos 436
#define T_Trap 437
#define T_True 438
#define T_Trustedkey 439
#define T_Ttl 440
#define T_Type 441
#define T_U_int 442
#define T_UEcrypto 443
#define T_UEcryptonak 444
#define T_UEdigest 445
#define T_Unconfig 446
#define T_Unpeer 447
#define T_Version 448
#define T_WanderThreshold 449
#define T_Week 450
#define T_Wildcard 451
#define T_Xleave 452
#define T_Xmtnonce 453
#define T_Year 454
#define T_Flag 455
#define T_EOC 456
#define T_Simulate 457
#define T_Beep_Delay 458
#define T_Sim_Duration 459
#define T_Server_Offset 460
#define T_Duration 461
#define T_Freq_Offset 462
#define T_Wander 463
#define T_Jitter 464
#define T_Prop_Delay 465
#define T_Proc_Delay 466
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 52 "ntp_parser.y" /* yacc.c:1909 */
#line 52 "../../ntpd/ntp_parser.y" /* yacc.c:1909 */
char * String;
double Double;
@ -473,7 +491,7 @@ union YYSTYPE
script_info * Sim_script;
script_info_fifo * Sim_script_fifo;
#line 477 "ntp_parser.h" /* yacc.c:1909 */
#line 495 "../../ntpd/ntp_parser.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
@ -486,4 +504,4 @@ extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_NTP_PARSER_H_INCLUDED */
#endif /* !YY_YY__NTPD_NTP_PARSER_H_INCLUDED */

View File

@ -844,11 +844,13 @@ newpeer(
return NULL;
}
#if 0
DPRINTF(1, ("newpeer(%s) found no existing and %d other associations\n",
(hostname)
? hostname
: stoa(srcadr),
ip_count));
#endif
/* Check ippeerlimit wrt ip_count */
if (ippeerlimit > -1) {

View File

@ -15,6 +15,7 @@
#include "ntp_control.h"
#include "ntp_string.h"
#include "ntp_leapsec.h"
#include "ntp_psl.h"
#include "refidsmear.h"
#include "lib_strbuf.h"
@ -31,6 +32,13 @@
# define BDELAY_DEFAULT (-0.050)
#endif
#define SRVFUZ_SHIFT 6 /* 64 seconds */
#define SRVRSP_FUZZ(x) \
do { \
x.l_uf &= 0; \
x.l_ui &= ~((1 << SRVFUZ_SHIFT) - 1U); \
} while(0)
/*
* This macro defines the authentication state. If x is 1 authentication
* is required; otherwise it is optional.
@ -78,6 +86,11 @@ nak_error_codes {
*/
#define POOL_SOLICIT_WINDOW 8
/*
* flag bits propagated from pool to individual peers
*/
#define POOL_FLAG_PMASK (FLAG_IBURST | FLAG_NOSELECT)
/*
* peer_select groups statistics for a peer used by clock_select() and
* clock_cluster().
@ -97,10 +110,16 @@ u_char sys_leap; /* system leap indicator, use set_sys_leap() to change this */
u_char xmt_leap; /* leap indicator sent in client requests, set up by set_sys_leap() */
u_char sys_stratum; /* system stratum */
s_char sys_precision; /* local clock precision (log2 s) */
double sys_rootdelay; /* roundtrip delay to primary source */
double sys_rootdisp; /* dispersion to primary source */
double sys_rootdelay; /* roundtrip delay to root (primary source) */
double sys_rootdisp; /* dispersion to root (primary source) */
double prev_rootdisp; /* previous root dispersion */
double p2_rootdisp; /* previous previous root dispersion */
u_int32 sys_refid; /* reference id (network byte order) */
l_fp sys_reftime; /* last update time */
l_fp prev_reftime; /* previous sys_reftime */
l_fp p2_reftime; /* previous previous sys_reftime */
u_long prev_time; /* "current_time" when saved prev_time */
u_long p2_time; /* previous prev_time */
struct peer *sys_peer; /* current peer */
#ifdef LEAP_SMEAR
@ -337,11 +356,18 @@ valid_NAK(
/*
* The ORIGIN must match, or this cannot be a valid NAK, either.
*/
if (FLAG_LOOPNONCE & peer->flags) {
myorg = &peer->nonce;
} else {
if (peer->flip > 0) {
myorg = &peer->borg;
} else {
myorg = &peer->aorg;
}
}
NTOHL_FP(&rpkt->org, &p_org);
if (peer->flip > 0)
myorg = &peer->borg;
else
myorg = &peer->aorg;
if (L_ISZERO(&p_org) ||
L_ISZERO( myorg) ||
@ -387,7 +413,7 @@ transmit(
*/
if (peer->cast_flags & (MDF_BCAST | MDF_MCAST)) {
peer->outdate = current_time;
poll_update(peer, hpoll);
poll_update(peer, hpoll, 0);
if (sys_leap != LEAP_NOTINSYNC)
peer_xmit(peer);
return;
@ -408,7 +434,7 @@ transmit(
*/
if (peer->cast_flags & MDF_ACAST) {
peer->outdate = current_time;
poll_update(peer, hpoll);
poll_update(peer, hpoll, 0);
if (peer->unreach > sys_beacon) {
peer->unreach = 0;
peer->ttl = 0;
@ -437,7 +463,7 @@ transmit(
*/
if (peer->cast_flags & MDF_POOL) {
peer->outdate = current_time;
poll_update(peer, hpoll);
poll_update(peer, hpoll, 0);
if ( (peer_associations <= 2 * sys_maxclock)
&& ( peer_associations < sys_maxclock
|| sys_survivors < sys_minclock))
@ -549,7 +575,7 @@ transmit(
/*
* Do not transmit if in broadcast client mode.
*/
poll_update(peer, hpoll);
poll_update(peer, hpoll, (peer->hmode == MODE_CLIENT));
if (peer->hmode != MODE_BCLIENT)
peer_xmit(peer);
@ -640,31 +666,20 @@ receive(
*/
/*
* Bogus port check is before anything, since it probably
* reveals a clogging attack.
* reveals a clogging attack. Likewise the mimimum packet size
* of 2 bytes (for mode 6/7) must be checked first.
*/
sys_received++;
if (0 == SRCPORT(&rbufp->recv_srcadr)) {
if (0 == SRCPORT(&rbufp->recv_srcadr) || rbufp->recv_length < 2) {
sys_badlength++;
return; /* bogus port */
return; /* bogus port / length */
}
restrictions(&rbufp->recv_srcadr, &r4a);
restrict_mask = r4a.rflags;
pkt = &rbufp->recv_pkt;
hisversion = PKT_VERSION(pkt->li_vn_mode);
hisleap = PKT_LEAP(pkt->li_vn_mode);
hismode = (int)PKT_MODE(pkt->li_vn_mode);
hisstratum = PKT_TO_STRATUM(pkt->stratum);
DPRINTF(1, ("receive: at %ld %s<-%s ippeerlimit %d mode %d iflags %s restrict %s org %#010x.%08x xmt %#010x.%08x\n",
current_time, stoa(&rbufp->dstadr->sin),
stoa(&rbufp->recv_srcadr), r4a.ippeerlimit, hismode,
build_iflags(rbufp->dstadr->flags),
build_rflags(restrict_mask),
ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),
ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)));
/* See basic mode and broadcast checks, below */
INSIST(0 != hisstratum);
if (restrict_mask & RES_IGNORE) {
DPRINTF(2, ("receive: drop: RES_IGNORE\n"));
@ -696,6 +711,30 @@ receive(
return; /* no time serve */
}
/* If we arrive here, we should have a standard NTP packet. We
* check that the minimum size is available and fetch some more
* items from the packet once we can be sure they are indeed
* there.
*/
if (rbufp->recv_length < LEN_PKT_NOMAC) {
sys_badlength++;
return; /* bogus length */
}
hisleap = PKT_LEAP(pkt->li_vn_mode);
hisstratum = PKT_TO_STRATUM(pkt->stratum);
INSIST(0 != hisstratum); /* paranoia check PKT_TO_STRATUM result */
DPRINTF(1, ("receive: at %ld %s<-%s ippeerlimit %d mode %d iflags %s "
"restrict %s org %#010x.%08x xmt %#010x.%08x\n",
current_time, stoa(&rbufp->dstadr->sin),
stoa(&rbufp->recv_srcadr), r4a.ippeerlimit, hismode,
build_iflags(rbufp->dstadr->flags),
build_rflags(restrict_mask),
ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),
ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)));
/*
* This is for testing. If restricted drop ten percent of
* surviving packets.
@ -888,12 +927,13 @@ receive(
}
return; /* rate exceeded */
}
if (hismode == MODE_CLIENT)
if (hismode == MODE_CLIENT) {
fast_xmit(rbufp, MODE_SERVER, skeyid,
restrict_mask);
else
} else {
fast_xmit(rbufp, MODE_ACTIVE, skeyid,
restrict_mask);
}
return; /* rate exceeded */
}
restrict_mask &= ~RES_KOD;
@ -1250,9 +1290,11 @@ receive(
if (AUTH(restrict_mask & RES_DONTTRUST,
is_authentic)) {
/* Bug 3596: Do we want to fuzz the reftime? */
fast_xmit(rbufp, MODE_SERVER, skeyid,
restrict_mask);
} else if (is_authentic == AUTH_ERROR) {
/* Bug 3596: Do we want to fuzz the reftime? */
fast_xmit(rbufp, MODE_SERVER, 0,
restrict_mask);
sys_badauth++;
@ -1318,6 +1360,7 @@ receive(
pkt->refid,
rbufp->recv_length - MIN_V4_PKT_LEN, (u_char *)&pkt->exten);
/* Bug 3596: Do we want to fuzz the reftime? */
fast_xmit(rbufp, MODE_SERVER, skeyid,
restrict_mask);
}
@ -1386,8 +1429,8 @@ receive(
peer = newpeer(&rbufp->recv_srcadr, NULL, rbufp->dstadr,
r4a.ippeerlimit, MODE_CLIENT, hisversion,
peer2->minpoll, peer2->maxpoll,
FLAG_PREEMPT | (FLAG_IBURST & peer2->flags),
MDF_UCAST | MDF_UCLNT, 0, skeyid, sys_ident);
(FLAG_PREEMPT | (POOL_FLAG_PMASK & peer2->flags)),
(MDF_UCAST | MDF_UCLNT), 0, skeyid, sys_ident);
if (NULL == peer) {
DPRINTF(2, ("receive: AM_MANYCAST drop: duplicate\n"));
sys_declined++;
@ -1858,7 +1901,9 @@ receive(
* packet is a replay. This prevents the bad guys from replaying
* the most recent packet, authenticated or not.
*/
} else if (L_ISEQU(&peer->xmt, &p_xmt)) {
} else if ( ((FLAG_LOOPNONCE & peer->flags) && L_ISEQU(&peer->nonce, &p_xmt))
|| (!(FLAG_LOOPNONCE & peer->flags) && L_ISEQU(&peer->xmt, &p_xmt))
) {
DPRINTF(2, ("receive: drop: Duplicate xmit\n"));
peer->flash |= TEST1; /* duplicate */
peer->oldpkt++;
@ -1958,6 +2003,10 @@ receive(
* We have earlier asserted that hisstratum cannot be 0.
* If hisstratum is STRATUM_UNSPEC, it means he's not sync'd.
*/
/* XXX: FLAG_LOOPNONCE */
DEBUG_INSIST(0 == (FLAG_LOOPNONCE & peer->flags));
} else if (peer->flip == 0) {
if (0) {
} else if (L_ISZERO(&p_org)) {
@ -1967,6 +2016,7 @@ receive(
msyslog(LOG_INFO,
"receive: BUG 3361: Clearing peer->aorg ");
L_CLR(&peer->aorg);
/* Clear peer->nonce, too? */
#endif
/**/
switch (hismode) {
@ -2020,6 +2070,7 @@ receive(
}
} else {
L_CLR(&peer->aorg);
/* XXX: FLAG_LOOPNONCE */
}
/*
@ -2193,7 +2244,7 @@ receive(
peer->minpoll = peer->ppoll;
peer->burst = peer->retry = 0;
peer->throttle = (NTP_SHIFT + 1) * (1 << peer->minpoll);
poll_update(peer, pkt->ppoll);
poll_update(peer, pkt->ppoll, 0);
return; /* kiss-o'-death */
}
if (kissCode != NOKISS) {
@ -2383,9 +2434,17 @@ receive(
/*
* The dance is complete and the flash bits have been lit. Toss
* the packet over the fence for processing, which may light up
* more flashers.
* more flashers. Leave if the packet is not good.
*/
process_packet(peer, pkt, rbufp->recv_length);
if (peer->flash & PKT_TEST_MASK)
return;
/* [bug 3592] Update poll. Ideally this should not happen in a
* receive branch, but too much is going on here... at least we
* do it only if the packet was good!
*/
poll_update(peer, peer->hpoll, (peer->hmode == MODE_CLIENT));
/*
* In interleaved mode update the state variables. Also adjust the
@ -2465,7 +2524,10 @@ process_packet(
peer->seldisptoolarge++;
DPRINTF(1, ("packet: flash header %04x\n",
peer->flash));
poll_update(peer, peer->hpoll); /* ppoll updated? */
/* ppoll updated? */
/* XXX: Fuzz the poll? */
poll_update(peer, peer->hpoll, (peer->hmode == MODE_CLIENT));
return;
}
@ -2509,7 +2571,7 @@ process_packet(
if (peer->burst > 0)
peer->nextdate = current_time;
}
poll_update(peer, peer->hpoll);
poll_update(peer, peer->hpoll, (peer->hmode == MODE_CLIENT));
/**/
@ -2776,7 +2838,7 @@ clock_update(
sys_poll = peer->minpoll;
if (sys_poll > peer->maxpoll)
sys_poll = peer->maxpoll;
poll_update(peer, sys_poll);
poll_update(peer, sys_poll, 0);
sys_stratum = min(peer->stratum + 1, STRATUM_UNSPEC);
if ( peer->stratum == STRATUM_REFCLOCK
|| peer->stratum == STRATUM_UNSPEC)
@ -2807,11 +2869,21 @@ clock_update(
+ clock_phi * (current_time - peer->update)
+ fabs(sys_offset);
p2_rootdisp = prev_rootdisp;
prev_rootdisp = sys_rootdisp;
if (dtemp > sys_mindisp)
sys_rootdisp = dtemp;
else
sys_rootdisp = sys_mindisp;
sys_rootdelay = peer->delay + peer->rootdelay;
p2_reftime = prev_reftime;
p2_time = prev_time;
prev_reftime = sys_reftime;
prev_time = current_time + 64 + (rand() & 0x3f); /* 64-127 s */
sys_reftime = peer->dst;
DPRINTF(1, ("clock_update: at %lu sample %lu associd %d\n",
@ -2856,7 +2928,11 @@ clock_update(
sys_stratum = STRATUM_UNSPEC;
memcpy(&sys_refid, "STEP", 4);
sys_rootdelay = 0;
p2_rootdisp = 0;
prev_rootdisp = 0;
sys_rootdisp = 0;
L_CLR(&p2_reftime); /* Should we clear p2_reftime? */
L_CLR(&prev_reftime); /* Should we clear prev_reftime? */
L_CLR(&sys_reftime);
sys_jitter = LOGTOD(sys_precision);
leapsec_reset_frame();
@ -2883,9 +2959,10 @@ clock_update(
* first clock sync, send them home satisfied.
*/
#ifdef HAVE_WORKING_FORK
if (waitsync_fd_to_close != -1) {
close(waitsync_fd_to_close);
waitsync_fd_to_close = -1;
if (daemon_pipe[1] != -1) {
write(daemon_pipe[1], "S\n", 2);
close(daemon_pipe[1]);
daemon_pipe[1] = -1;
DPRINTF(1, ("notified parent --wait-sync is done\n"));
}
#endif /* HAVE_WORKING_FORK */
@ -2930,10 +3007,11 @@ clock_update(
void
poll_update(
struct peer *peer, /* peer structure pointer */
u_char mpoll
u_char mpoll,
u_char skewpoll
)
{
u_long next, utemp;
u_long next, utemp, limit;
u_char hpoll;
/*
@ -2977,6 +3055,15 @@ poll_update(
*/
utemp = current_time + max(peer->throttle - (NTP_SHIFT - 1) *
(1 << peer->minpoll), ntp_minpkt);
/*[Bug 3592] avoid unlimited postpone of next poll */
limit = (2u << hpoll);
if (limit > 64)
limit -= (limit >> 2);
limit += peer->outdate;
if (limit < current_time)
limit = current_time;
if (peer->burst > 0) {
if (peer->nextdate > current_time)
return;
@ -3022,6 +3109,29 @@ poll_update(
next = ((0x1000UL | (ntp_random() & 0x0ff)) <<
hpoll) >> 12;
next += peer->outdate;
/* XXX: bug3596: Deal with poll skew list? */
if (skewpoll) {
psl_item psi;
if (0 == get_pollskew(hpoll, &psi)) {
int sub = psi.sub;
int qty = psi.qty;
int msk = psi.msk;
int val;
if ( 0 != sub
|| 0 != qty) {
do {
val = ntp_random() & msk;
} while (val > qty);
next -= sub;
next += val;
}
} else {
/* get_pollskew() already logged this */
}
}
if (next > utemp)
peer->nextdate = next;
else
@ -3029,6 +3139,13 @@ poll_update(
if (peer->throttle > (1 << peer->minpoll))
peer->nextdate += ntp_minpkt;
}
/*[Bug 3592] avoid unlimited postpone of next poll */
if (peer->nextdate > limit) {
DPRINTF(1, ("poll_update: clamp reached; limit %lu next %lu\n",
limit, peer->nextdate));
peer->nextdate = limit;
}
DPRINTF(2, ("poll_update: at %lu %s poll %d burst %d retry %d head %d early %lu next %lu\n",
current_time, ntoa(&peer->srcadr), peer->hpoll,
peer->burst, peer->retry, peer->throttle,
@ -3953,6 +4070,7 @@ peer_xmit(
xpkt.refid = sys_refid;
xpkt.rootdelay = HTONS_FP(DTOFP(sys_rootdelay));
xpkt.rootdisp = HTONS_FP(DTOUFP(sys_rootdisp));
/* Use sys_reftime for peer exchanges */
HTONL_FP(&sys_reftime, &xpkt.reftime);
HTONL_FP(&peer->rec, &xpkt.org);
HTONL_FP(&peer->dst, &xpkt.rec);
@ -4377,7 +4495,7 @@ leap_smear_add_offs(
static void
fast_xmit(
struct recvbuf *rbufp, /* receive packet pointer */
int xmode, /* receive mode */
int xmode, /* receive mode */ /* XXX: HMS: really? */
keyid_t xkeyid, /* transmit key ID */
int flags /* restrict mask */
)
@ -4408,8 +4526,8 @@ fast_xmit(
/*
* If this is a kiss-o'-death (KoD) packet, show leap
* unsynchronized, stratum zero, reference ID the four-character
* kiss code and system root delay. Note we don't reveal the
* local time, so these packets can't be used for
* kiss code and (???) system root delay. Note we don't reveal
* the local time, so these packets can't be used for
* synchronization.
*/
if (flags & RES_KOD) {
@ -4431,18 +4549,23 @@ fast_xmit(
* This is a normal packet. Use the system variables.
*/
} else {
double this_rootdisp;
l_fp this_ref_time;
#ifdef LEAP_SMEAR
/*
* Make copies of the variables which can be affected by smearing.
*/
l_fp this_ref_time;
l_fp this_recv_time;
#endif
/*
* If we are inside the leap smear interval we add the current smear offset to
* the packet receive time, to the packet transmit time, and eventually to the
* reftime to make sure the reftime isn't later than the transmit/receive times.
* If we are inside the leap smear interval we add
* the current smear offset to:
* - the packet receive time,
* - the packet transmit time,
* - and eventually to the reftime to make sure the
* reftime isn't later than the transmit/receive times.
*/
xpkt.li_vn_mode = PKT_LI_VN_MODE(xmt_leap,
PKT_VERSION(rpkt->li_vn_mode), xmode);
@ -4452,25 +4575,77 @@ fast_xmit(
xpkt.precision = sys_precision;
xpkt.refid = sys_refid;
xpkt.rootdelay = HTONS_FP(DTOFP(sys_rootdelay));
xpkt.rootdisp = HTONS_FP(DTOUFP(sys_rootdisp));
/*
** Server Response Fuzzing
**
** Which values do we want to use for reftime and rootdisp?
*/
if ( MODE_SERVER == xmode
&& RES_SRVRSPFUZ & flags) {
if (current_time < p2_time) {
this_ref_time = p2_reftime;
this_rootdisp = p2_rootdisp;
} else if (current_time < prev_time) {
this_ref_time = prev_reftime;
this_rootdisp = prev_rootdisp;
} else {
this_ref_time = sys_reftime;
this_rootdisp = sys_rootdisp;
}
SRVRSP_FUZZ(this_ref_time);
} else {
this_ref_time = sys_reftime;
this_rootdisp = sys_rootdisp;
}
/*
** ROOT DISPERSION
*/
xpkt.rootdisp = HTONS_FP(DTOUFP(this_rootdisp));
/*
** REFTIME
*/
#ifdef LEAP_SMEAR
this_ref_time = sys_reftime;
if (leap_smear.in_progress) {
/* adjust the reftime by the same amount as the
* leap smear, as we don't want to risk the
* reftime being later than the transmit time.
*/
leap_smear_add_offs(&this_ref_time, NULL);
}
#endif
HTONL_FP(&this_ref_time, &xpkt.reftime);
/*
** REFID
*/
#ifdef LEAP_SMEAR
if (leap_smear.in_progress) {
xpkt.refid = convertLFPToRefID(leap_smear.offset);
DPRINTF(2, ("fast_xmit: leap_smear.in_progress: refid %8x, smear %s\n",
ntohl(xpkt.refid),
lfptoa(&leap_smear.offset, 8)
));
}
HTONL_FP(&this_ref_time, &xpkt.reftime);
#else
HTONL_FP(&sys_reftime, &xpkt.reftime);
#endif
/*
** ORIGIN
*/
xpkt.org = rpkt->xmt;
/*
** RECEIVE
*/
#ifdef LEAP_SMEAR
this_recv_time = rbufp->recv_time;
if (leap_smear.in_progress)
@ -4480,6 +4655,10 @@ fast_xmit(
HTONL_FP(&rbufp->recv_time, &xpkt.rec);
#endif
/*
** TRANSMIT
*/
get_systime(&xmt_tx);
#ifdef LEAP_SMEAR
if (leap_smear.in_progress)
@ -4580,10 +4759,11 @@ pool_xmit(
struct interface * lcladr;
sockaddr_u * rmtadr;
r4addr r4a;
int restrict_mask;
u_short restrict_mask;
struct peer * p;
l_fp xmt_tx;
DEBUG_REQUIRE(pool);
if (NULL == pool->ai) {
if (pool->addrs != NULL) {
/* free() is used with copy_addrinfo_list() */
@ -4635,10 +4815,28 @@ pool_xmit(
xpkt.refid = sys_refid;
xpkt.rootdelay = HTONS_FP(DTOFP(sys_rootdelay));
xpkt.rootdisp = HTONS_FP(DTOUFP(sys_rootdisp));
/* Bug 3596: What are the pros/cons of using sys_reftime here? */
HTONL_FP(&sys_reftime, &xpkt.reftime);
/* HMS: the following is better done after the ntp_random() calls */
get_systime(&xmt_tx);
pool->aorg = xmt_tx;
HTONL_FP(&xmt_tx, &xpkt.xmt);
if (FLAG_LOOPNONCE & pool->flags) {
l_fp nonce;
do {
nonce.l_ui = ntp_random();
} while (0 == nonce.l_ui);
do {
nonce.l_uf = ntp_random();
} while (0 == nonce.l_uf);
pool->nonce = nonce;
HTONL_FP(&nonce, &xpkt.xmt);
} else {
L_CLR(&pool->nonce);
HTONL_FP(&xmt_tx, &xpkt.xmt);
}
sendpkt(rmtadr, lcladr,
sys_ttl[(pool->ttl >= sys_ttlmax) ? sys_ttlmax : pool->ttl],
&xpkt, LEN_PKT_NOMAC);

View File

@ -12,6 +12,7 @@
#include "ntp_refclock.h"
#include "ntp_stdlib.h"
#include "ntp_assert.h"
#include "timespecops.h"
#include <stdio.h>
@ -66,10 +67,81 @@ int cal_enable; /* enable refclock calibrate */
/*
* Forward declarations
*/
static int refclock_cmpl_fp (const void *, const void *);
static int refclock_sample (struct refclockproc *);
static int refclock_ioctl(int, u_int);
static int refclock_cmpl_fp (const void *, const void *);
static int refclock_sample (struct refclockproc *);
static int refclock_ioctl(int, u_int);
static void refclock_checkburst(struct peer *, struct refclockproc *);
/* circular buffer functions
*
* circular buffer management comes in two flovours:
* for powers of two, and all others.
*/
#if MAXSTAGE & (MAXSTAGE - 1)
static void clk_add_sample(
struct refclockproc * const pp,
double sv
)
{
pp->coderecv = (pp->coderecv + 1) % MAXSTAGE;
if (pp->coderecv == pp->codeproc)
pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
pp->filter[pp->coderecv] = sv;
}
static double clk_pop_sample(
struct refclockproc * const pp
)
{
if (pp->coderecv == pp->codeproc)
return 0; /* Maybe a NaN would be better? */
pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
return pp->filter[pp->codeproc];
}
static inline u_int clk_cnt_sample(
struct refclockproc * const pp
)
{
u_int retv = pp->coderecv - pp->codeproc;
if (retv > MAXSTAGE)
retv += MAXSTAGE;
return retv;
}
#else
static inline void clk_add_sample(
struct refclockproc * const pp,
double sv
)
{
pp->coderecv = (pp->coderecv + 1) & (MAXSTAGE - 1);
if (pp->coderecv == pp->codeproc)
pp->codeproc = (pp->codeproc + 1) & (MAXSTAGE - 1);
pp->filter[pp->coderecv] = sv;
}
static inline double clk_pop_sample(
struct refclockproc * const pp
)
{
if (pp->coderecv == pp->codeproc)
return 0; /* Maybe a NaN would be better? */
pp->codeproc = (pp->codeproc + 1) & (MAXSTAGE - 1);
return pp->filter[pp->codeproc];
}
static inline u_int clk_cnt_sample(
struct refclockproc * const pp
)
{
return (pp->coderecv - pp->codeproc) & (MAXSTAGE - 1);
}
#endif
/*
* refclock_report - note the occurance of an event
@ -328,9 +400,10 @@ refclock_transmit(
} else {
peer->burst--;
}
peer->procptr->inpoll = TRUE;
if (refclock_conf[clktype]->clock_poll != noentry)
(refclock_conf[clktype]->clock_poll)(unit, peer);
poll_update(peer, peer->hpoll);
poll_update(peer, peer->hpoll, 0);
}
@ -353,6 +426,65 @@ refclock_cmpl_fp(
return 0;
}
/*
* Get number of available samples
*/
int
refclock_samples_avail(
struct refclockproc const * pp
)
{
u_int na;
# if MAXSTAGE & (MAXSTAGE - 1)
na = pp->coderecv - pp->codeproc;
if (na > MAXSTAGE)
na += MAXSTAGE;
# else
na = (pp->coderecv - pp->codeproc) & (MAXSTAGE - 1);
# endif
return na;
}
/*
* Expire (remove) samples from the tail (oldest samples removed)
*
* Returns number of samples deleted
*/
int
refclock_samples_expire(
struct refclockproc * pp,
int nd
)
{
u_int na;
if (nd <= 0)
return 0;
# if MAXSTAGE & (MAXSTAGE - 1)
na = pp->coderecv - pp->codeproc;
if (na > MAXSTAGE)
na += MAXSTAGE;
if ((u_int)nd < na)
nd = na;
pp->codeproc = (pp->codeproc + nd) % MAXSTAGE;
# else
na = (pp->coderecv - pp->codeproc) & (MAXSTAGE - 1);
if ((u_int)nd > na)
nd = (int)na;
pp->codeproc = (pp->codeproc + nd) & (MAXSTAGE - 1);
# endif
return nd;
}
/*
* refclock_process_offset - update median filter
@ -376,7 +508,8 @@ refclock_process_offset(
lftemp = lasttim;
L_SUB(&lftemp, &lastrec);
LFPTOD(&lftemp, doffset);
SAMPLE(doffset + fudge);
clk_add_sample(pp, doffset + fudge);
refclock_checkburst(pp->io.srcclock, pp);
}
@ -388,7 +521,7 @@ refclock_process_offset(
* seconds and milliseconds/microseconds to internal timestamp format,
* then constructs a new entry in the median filter circular buffer.
* Return success (1) if the data are correct and consistent with the
* converntional calendar.
* conventional calendar.
*
* Important for PPS users: Normally, the pp->lastrec is set to the
* system time when the on-time character is received and the pp->year,
@ -409,7 +542,7 @@ refclock_process_f(
* seconds and milliseconds/microseconds of the timecode. Use
* clocktime() for the aggregate seconds and the msec/usec for
* the fraction, when present. Note that this code relies on the
* filesystem time for the years and does not use the years of
* file system time for the years and does not use the years of
* the timecode.
*/
if (!clocktime(pp->day, pp->hour, pp->minute, pp->second, GMT,
@ -457,11 +590,8 @@ refclock_sample(
* anything if the buffer is empty.
*/
n = 0;
while (pp->codeproc != pp->coderecv) {
pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
off[n] = pp->filter[pp->codeproc];
n++;
}
while (pp->codeproc != pp->coderecv)
off[n++] = clk_pop_sample(pp);
if (n == 0)
return (0);
@ -494,6 +624,20 @@ refclock_sample(
}
pp->offset /= m;
pp->jitter = max(SQRT(pp->jitter / m), LOGTOD(sys_precision));
/*
* If the source has a jitter that cannot be estimated, because
* it is not statistic jitter, the source will be detected as
* falseticker sooner or later. Enforcing a minimal jitter value
* avoids a too low estimation while still detecting higher jitter.
*
* Note that this changes the refclock samples and ends up in the
* clock dispersion, not the clock jitter, despite being called
* jitter. To see the modified values, check the NTP clock variable
* "filtdisp", not "jitter".
*/
pp->jitter = max(pp->jitter, pp->fudgeminjitter);
#ifdef DEBUG
if (debug)
printf(
@ -532,6 +676,7 @@ refclock_receive(
* filter.
*/
pp = peer->procptr;
pp->inpoll = FALSE;
peer->leap = pp->leap;
if (peer->leap == LEAP_NOTINSYNC)
return;
@ -542,7 +687,7 @@ refclock_receive(
report_event(PEVNT_REACH, peer, NULL);
peer->timereachable = current_time;
}
peer->reach |= 1;
peer->reach = (peer->reach << (peer->reach & 1)) | 1;
peer->reftime = pp->lastref;
peer->aorg = pp->lastrec;
peer->rootdisp = pp->disp;
@ -1080,6 +1225,8 @@ refclock_control(
pp->sloppyclockflag &= ~CLK_FLAG4;
pp->sloppyclockflag |= in->flags & CLK_FLAG4;
}
if (in->haveflags & CLK_HAVEMINJIT)
pp->fudgeminjitter = in->fudgeminjitter;
}
/*
@ -1104,6 +1251,9 @@ refclock_control(
out->haveflags |= CLK_HAVEFLAG3;
if (CLK_FLAG4 & out->flags)
out->haveflags |= CLK_HAVEFLAG4;
out->fudgeminjitter = pp->fudgeminjitter;
if (0.0 != out->fudgeminjitter)
out->haveflags |= CLK_HAVEMINJIT;
out->timereset = current_time - pp->timestarted;
out->polls = pp->polls;
@ -1367,7 +1517,8 @@ refclock_pps(
*/
pp->lastrec.l_ui = (u_int32)ap->ts.tv_sec + JAN_1970;
pp->lastrec.l_uf = (u_int32)(dtemp * FRAC);
SAMPLE(dcorr);
clk_add_sample(pp, dcorr);
refclock_checkburst(peer, pp);
#ifdef DEBUG
if (debug > 1)
@ -1377,4 +1528,245 @@ refclock_pps(
return (1);
}
#endif /* HAVE_PPSAPI */
/*
* -------------------------------------------------------------------
* refclock_ppsaugment(...) -- correlate with PPS edge
*
* This function is used to correlate a receive time stamp with a PPS
* edge time stamp. It applies the necessary fudges and then tries to
* move the receive time stamp to the corresponding edge. This can warp
* into future, if a transmission delay of more than 500ms is not
* compensated with a corresponding fudge time2 value, because then the
* next PPS edge is nearer than the last. (Similiar to what the PPS ATOM
* driver does, but we deal with full time stamps here, not just phase
* shift information.) Likewise, a negative fudge time2 value must be
* used if the reference time stamp correlates with the *following* PPS
* pulse.
*
* Note that the receive time fudge value only needs to move the receive
* stamp near a PPS edge but that close proximity is not required;
* +/-100ms precision should be enough. But since the fudge value will
* probably also be used to compensate the transmission delay when no
* PPS edge can be related to the time stamp, it's best to get it as
* close as possible.
*
* It should also be noted that the typical use case is matching to the
* preceeding edge, as most units relate their sentences to the current
* second.
*
* The function returns FALSE if there is no correlation possible, TRUE
* otherwise. Reason for failures are:
*
* - no PPS/ATOM unit given
* - PPS stamp is stale (that is, the difference between the PPS stamp
* and the corrected time stamp would exceed two seconds)
* - The phase difference is too close to 0.5, and the decision wether
* to move up or down is too sensitive to noise.
*
* On output, the receive time stamp is updated with the 'fixed' receive
* time.
* -------------------------------------------------------------------
*/
int/*BOOL*/
refclock_ppsaugment(
const struct refclock_atom * ap , /* for PPS io */
l_fp * rcvtime ,
double rcvfudge, /* i/o read fudge */
double ppsfudge /* pps fudge */
)
{
l_fp delta[1];
#ifdef HAVE_PPSAPI
pps_info_t pps_info;
struct timespec timeout;
l_fp stamp[1];
uint32_t phase;
static const uint32_t s_plim_hi = UINT32_C(1932735284);
static const uint32_t s_plim_lo = UINT32_C(2362232013);
/* fixup receive time in case we have to bail out early */
DTOLFP(rcvfudge, delta);
L_SUB(rcvtime, delta);
if (NULL == ap)
return FALSE;
ZERO(timeout);
ZERO(pps_info);
/* fetch PPS stamp from ATOM block */
if (time_pps_fetch(ap->handle, PPS_TSFMT_TSPEC,
&pps_info, &timeout) < 0)
return FALSE; /* can't get time stamps */
/* get last active PPS edge before receive */
if (ap->pps_params.mode & PPS_CAPTUREASSERT)
timeout = pps_info.assert_timestamp;
else if (ap->pps_params.mode & PPS_CAPTURECLEAR)
timeout = pps_info.clear_timestamp;
else
return FALSE; /* WHICH edge, please?!? */
/* convert PPS stamp to l_fp and apply fudge */
*stamp = tspec_stamp_to_lfp(timeout);
DTOLFP(ppsfudge, delta);
L_SUB(stamp, delta);
/* Get difference between PPS stamp (--> yield) and receive time
* (--> base)
*/
*delta = *stamp;
L_SUB(delta, rcvtime);
/* check if either the PPS or the STAMP is stale in relation
* to each other. Bail if it is so...
*/
phase = delta->l_ui;
if (phase >= 2 && phase < (uint32_t)-2)
return FALSE; /* PPS is stale, don't use it */
/* If the phase is too close to 0.5, the decision whether to
* move up or down is becoming noise sensitive. That is, we
* might amplify usec noise between samples into seconds with a
* simple threshold. This can be solved by a Schmitt Trigger
* characteristic, but that would also require additional state
* where we could remember previous decisions. Easier to play
* dead duck and wait for the conditions to become clear.
*/
phase = delta->l_uf;
if (phase > s_plim_hi && phase < s_plim_lo)
return FALSE; /* we're in the noise lock gap */
/* sign-extend fraction into seconds */
delta->l_ui = UINT32_C(0) - ((phase >> 31) & 1);
/* add it up now */
L_ADD(rcvtime, delta);
return TRUE;
# else /* have no PPS support at all */
/* just fixup receive time and fail */
UNUSED_ARG(ap);
UNUSED_ARG(ppsfudge);
DTOLFP(rcvfudge, delta);
L_SUB(rcvtime, delta);
return FALSE;
# endif
}
/*
* -------------------------------------------------------------------
* check if it makes sense to schedule an 'early' poll to get the clock
* up fast after start or longer signal dropout.
*/
static void
refclock_checkburst(
struct peer * peer,
struct refclockproc * pp
)
{
uint32_t limit; /* when we should poll */
u_int needs; /* needed number of samples */
/* Paranoia: stop here if peer and clockproc don't match up.
* And when a poll is actually pending, we don't have to do
* anything, either. Likewise if the reach mask is full, of
* course, and if the filter has stabilized.
*/
if (pp->inpoll || (peer->procptr != pp) ||
((peer->reach == 0xFF) && (peer->disp <= MAXDISTANCE)))
return;
/* If the next poll is soon enough, bail out, too: */
limit = current_time + 1;
if (peer->nextdate <= limit)
return;
/* Derive the number of samples needed from the popcount of the
* reach mask. With less samples available, we break away.
*/
needs = peer->reach;
needs -= (needs >> 1) & 0x55;
needs = (needs & 0x33) + ((needs >> 2) & 0x33);
needs = (needs + (needs >> 4)) & 0x0F;
if (needs > 6)
needs = 6;
else if (needs < 3)
needs = 3;
if (clk_cnt_sample(pp) < needs)
return;
/* Get serious. Reduce the poll to minimum and schedule early.
* (Changing the peer poll is probably in vain, as it will be
* re-adjusted, but maybe some time the hint will work...)
*/
peer->hpoll = peer->minpoll;
peer->nextdate = limit;
}
/*
* -------------------------------------------------------------------
* Save the last timecode string, making sure it's properly truncated
* if necessary and NUL terminated in any case.
*/
void
refclock_save_lcode(
struct refclockproc * pp,
char const * tc,
size_t len
)
{
if (len == (size_t)-1)
len = strnlen(tc, sizeof(pp->a_lastcode) - 1);
else if (len >= sizeof(pp->a_lastcode))
len = sizeof(pp->a_lastcode) - 1;
pp->lencode = (u_short)len;
memcpy(pp->a_lastcode, tc, len);
pp->a_lastcode[len] = '\0';
}
/* format data into a_lastcode */
void
refclock_vformat_lcode(
struct refclockproc * pp,
char const * fmt,
va_list va
)
{
long len;
len = vsnprintf(pp->a_lastcode, sizeof(pp->a_lastcode), fmt, va);
if (len <= 0)
len = 0;
else if (len >= sizeof(pp->a_lastcode))
len = sizeof(pp->a_lastcode) - 1;
pp->lencode = (u_short)len;
pp->a_lastcode[len] = '\0';
/* !note! the NUL byte is needed in case vsnprintf() really fails */
}
void
refclock_format_lcode(
struct refclockproc * pp,
char const * fmt,
...
)
{
va_list va;
va_start(va, fmt);
refclock_vformat_lcode(pp, fmt, va);
va_end(va);
}
#endif /* REFCLOCK */

View File

@ -841,7 +841,7 @@ peer_info (
pp = findexistingpeer(&addr, NULL, NULL, -1, 0, NULL);
if (NULL == pp)
continue;
if (IS_IPV6(srcadr)) {
if (IS_IPV6(&pp->srcadr)) {
if (pp->dstadr)
ip->dstadr6 =
(MDF_BCAST == pp->cast_flags)
@ -1819,7 +1819,7 @@ do_restrict(
bad = 0;
while (items-- > 0 && !bad) {
memcpy(&cr, datap, item_sz);
cr.flags = ntohs(cr.flags);
cr.flags = ntohs(cr.flags); /* XXX */
cr.mflags = ntohs(cr.mflags);
if (~RESM_NTPONLY & cr.mflags)
bad |= 1;
@ -1854,7 +1854,7 @@ do_restrict(
while (items-- > 0) {
memcpy(&cr, datap, item_sz);
cr.flags = ntohs(cr.flags);
cr.flags = ntohs(cr.flags); /* XXX: size */
cr.mflags = ntohs(cr.mflags);
cr.ippeerlimit = ntohs(cr.ippeerlimit);
if (client_v6_capable && cr.v6_flag) {

View File

@ -96,7 +96,7 @@ static restrict_u restrict_def6;
* "restrict source ..." enabled knob and restriction bits.
*/
static int restrict_source_enabled;
static u_short restrict_source_rflags;
static u_int32 restrict_source_rflags;
static u_short restrict_source_mflags;
static short restrict_source_ippeerlimit;
@ -141,7 +141,7 @@ dump_restrict(
inet_ntop(AF_INET, &sia, as, sizeof as);
inet_ntop(AF_INET, &sim, ms, sizeof ms);
}
mprintf("restrict node at %p: %s/%s count %d, rflags %05x, mflags %05x, ippeerlimit %d, expire %lu, next %p\n",
mprintf("restrict node at %p: %s/%s count %d, rflags %08x, mflags %04x, ippeerlimit %d, expire %lu, next %p\n",
res, as, ms, res->count, res->rflags, res->mflags,
res->ippeerlimit, res->expire, res->link);
return;
@ -154,8 +154,6 @@ dump_restrict(
void
dump_restricts(void)
{
int defaultv4_done = 0;
int defaultv6_done = 0;
restrict_u * res;
restrict_u * next;
@ -570,6 +568,7 @@ restrictions(
r4a->rflags = match->rflags;
r4a->ippeerlimit = match->ippeerlimit;
}
return;
}
@ -795,8 +794,8 @@ restrict_source(
return;
hack_restrict(RESTRICT_FLAGS, addr, &onesmask,
restrict_source_ippeerlimit, restrict_source_mflags,
restrict_source_rflags, expire);
restrict_source_ippeerlimit,
restrict_source_mflags, restrict_source_rflags, expire);
DPRINTF(1, ("restrict_source: %s host restriction added\n",
stoa(addr)));
}

View File

@ -73,17 +73,26 @@ keyword(
{
size_t i;
const char *text;
static char sbuf[64];
i = token - LOWEST_KEYWORD_ID;
if (i < COUNTOF(keyword_text))
text = keyword_text[i];
else
text = NULL;
switch (token) {
case T_ServerresponseFuzz:
text = "serverresponse fuzz";
break;
return (text != NULL)
? text
: "(keyword not found)";
default:
if (i < COUNTOF(keyword_text)) {
text = keyword_text[i];
} else {
snprintf(sbuf, sizeof sbuf,
"(keyword #%u not found)", token);
text = sbuf;
}
}
return text;
}

View File

@ -58,6 +58,7 @@ static char *key_file_name; /* keys file name */
static char *leapfile_name; /* leapseconds file name */
static struct stat leapfile_stat; /* leapseconds file stat() buffer */
static int /*BOOL*/have_leapfile = FALSE;
static int /*BOOL*/chck_leaphash = TRUE;
char *stats_drift_file; /* frequency file name */
static char *stats_temp_file; /* temp frequency file name */
static double wander_resid; /* last frequency update */
@ -87,7 +88,7 @@ static FILEGEN timingstats;
/*
* This controls whether stats are written to the fileset. Provided
* so that ntpdc can turn off stats when the file system fills up.
* so that ntpdc can turn off stats when the file system fills up.
*/
int stats_control;
@ -103,7 +104,7 @@ static void record_sys_stats(void);
void ntpd_time_stepped(void);
static void check_leap_expiration(int, uint32_t, const time_t*);
/*
/*
* Prototypes
*/
#ifdef DEBUG
@ -287,15 +288,15 @@ write_stats(void)
/* atomic */
#ifdef SYS_WINNT
if (_unlink(stats_drift_file)) /* rename semantics differ under NT */
msyslog(LOG_WARNING,
"Unable to remove prior drift file %s, %m",
msyslog(LOG_WARNING,
"Unable to remove prior drift file %s, %m",
stats_drift_file);
#endif /* SYS_WINNT */
#ifndef NO_RENAME
if (rename(stats_temp_file, stats_drift_file))
msyslog(LOG_WARNING,
"Unable to rename temp drift file %s to %s, %m",
msyslog(LOG_WARNING,
"Unable to rename temp drift file %s to %s, %m",
stats_temp_file, stats_drift_file);
#else
/* we have no rename NFS of ftp in use */
@ -329,7 +330,8 @@ write_stats(void)
void
stats_config(
int item,
const char *invalue /* only one type so far */
const char *invalue, /* only one type so far */
int optflag
)
{
FILE *fp;
@ -385,7 +387,7 @@ stats_config(
} else {
value = newvalue;
}
#else
#else
value = invalue;
#endif /* SYS_WINNT */
@ -399,7 +401,7 @@ stats_config(
break;
stats_drift_file = erealloc(stats_drift_file, len + 1);
stats_temp_file = erealloc(stats_temp_file,
stats_temp_file = erealloc(stats_temp_file,
len + sizeof(".TEMP"));
memcpy(stats_drift_file, value, (size_t)(len+1));
memcpy(stats_temp_file, value, (size_t)len);
@ -414,7 +416,7 @@ stats_config(
if (fscanf(fp, "%lf", &old_drift) != 1) {
msyslog(LOG_ERR,
"format error frequency file %s",
"format error frequency file %s",
stats_drift_file);
fclose(fp);
break;
@ -483,9 +485,11 @@ stats_config(
leapfile_name = erealloc(leapfile_name, len + 1);
memcpy(leapfile_name, value, len + 1);
chck_leaphash = optflag;
if (leapsec_load_file(
leapfile_name, &leapfile_stat, TRUE, TRUE))
leapfile_name, &leapfile_stat,
TRUE, TRUE, chck_leaphash))
{
leap_signature_t lsig;
@ -892,11 +896,11 @@ check_leap_file(
/* just do nothing if there is no leap file */
if ( ! (leapfile_name && *leapfile_name))
return;
/* try to load leapfile, force it if no leapfile loaded yet */
if (leapsec_load_file(
leapfile_name, &leapfile_stat,
!have_leapfile, is_daily_check))
!have_leapfile, is_daily_check, chck_leaphash))
have_leapfile = TRUE;
else if (!have_leapfile)
return;
@ -921,7 +925,7 @@ check_leap_expiration(
* level and frequency (once/hour or once/day, depending on the
* state.
*/
rc = leapsec_daystolive(ntptime, systime);
rc = leapsec_daystolive(ntptime, systime);
if (rc == 0) {
msyslog(LOG_WARNING,
"%s ('%s'): will expire in less than one day",
@ -929,7 +933,7 @@ check_leap_expiration(
} else if (is_daily_check && rc < 28) {
if (rc < 0)
msyslog(LOG_ERR,
"%s ('%s'): expired less than %d day%s ago",
"%s ('%s'): expired %d day%s ago",
logPrefix, leapfile_name, -rc, (rc == -1 ? "" : "s"));
else
msyslog(LOG_WARNING,
@ -952,7 +956,7 @@ getauthkeys(
len = strlen(keyfile);
if (!len)
return;
#ifndef SYS_WINNT
key_file_name = erealloc(key_file_name, len + 1);
memcpy(key_file_name, keyfile, len + 1);

View File

@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpd-opts.c)
*
* It has been AutoGen-ed February 20, 2019 at 09:56:15 AM by AutoGen 5.18.5
* It has been AutoGen-ed March 3, 2020 at 05:40:30 PM by AutoGen 5.18.5
* From the definitions ntpd-opts.def
* and the template file options
*
@ -18,7 +18,7 @@
* The ntpd program is copyrighted and licensed
* under the following terms:
*
* Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.
* Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation, all rights reserved.
* This is free software. It is licensed for use, modification and
* redistribution under the terms of the NTP License, copies of which
* can be seen at:
@ -75,8 +75,8 @@ extern FILE * option_usage_fp;
* static const strings for ntpd options
*/
static char const ntpd_opt_strs[3132] =
/* 0 */ "ntpd 4.2.8p13\n"
"Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.\n"
/* 0 */ "ntpd 4.2.8p14\n"
"Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation, all rights reserved.\n"
"This is free software. It is licensed for use, modification and\n"
"redistribution under the terms of the NTP License, copies of which\n"
"can be seen at:\n"
@ -205,12 +205,12 @@ static char const ntpd_opt_strs[3132] =
/* 2901 */ "output version information and exit\0"
/* 2937 */ "version\0"
/* 2945 */ "NTPD\0"
/* 2950 */ "ntpd - NTP daemon program - Ver. 4.2.8p13\n"
/* 2950 */ "ntpd - NTP daemon program - Ver. 4.2.8p14\n"
"Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n"
"\t\t[ <server1> ... <serverN> ]\n\0"
/* 3082 */ "http://bugs.ntp.org, bugs@ntp.org\0"
/* 3116 */ "\n\0"
/* 3118 */ "ntpd 4.2.8p13";
/* 3118 */ "ntpd 4.2.8p14";
/**
* ipv4 option description with
@ -1529,8 +1529,8 @@ static void bogus_function(void) {
translate option names.
*/
/* referenced via ntpdOptions.pzCopyright */
puts(_("ntpd 4.2.8p13\n\
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.\n\
puts(_("ntpd 4.2.8p14\n\
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation, all rights reserved.\n\
This is free software. It is licensed for use, modification and\n\
redistribution under the terms of the NTP License, copies of which\n\
can be seen at:\n"));
@ -1670,7 +1670,7 @@ implied warranty.\n"));
puts(_("output version information and exit"));
/* referenced via ntpdOptions.pzUsageTitle */
puts(_("ntpd - NTP daemon program - Ver. 4.2.8p13\n\
puts(_("ntpd - NTP daemon program - Ver. 4.2.8p14\n\
Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
\t\t[ <server1> ... <serverN> ]\n"));
@ -1678,7 +1678,7 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
puts(_("\n"));
/* referenced via ntpdOptions.pzFullVersion */
puts(_("ntpd 4.2.8p13"));
puts(_("ntpd 4.2.8p14"));
/* referenced via ntpdOptions.pzFullUsage */
puts(_("<<<NOT-FOUND>>>"));

View File

@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpd-opts.h)
*
* It has been AutoGen-ed February 20, 2019 at 09:56:15 AM by AutoGen 5.18.5
* It has been AutoGen-ed March 3, 2020 at 05:40:30 PM by AutoGen 5.18.5
* From the definitions ntpd-opts.def
* and the template file options
*
@ -18,7 +18,7 @@
* The ntpd program is copyrighted and licensed
* under the following terms:
*
* Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.
* Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation, all rights reserved.
* This is free software. It is licensed for use, modification and
* redistribution under the terms of the NTP License, copies of which
* can be seen at:
@ -106,9 +106,9 @@ typedef enum {
/** count of all options for ntpd */
#define OPTION_CT 38
/** ntpd version */
#define NTPD_VERSION "4.2.8p13"
#define NTPD_VERSION "4.2.8p14"
/** Full ntpd version text */
#define NTPD_FULL_VERSION "ntpd 4.2.8p13"
#define NTPD_FULL_VERSION "ntpd 4.2.8p14"
/**
* Interface defines for all options. Replace "n" with the UPPER_CASED

View File

@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
.TH ntpd 1ntpdman "20 Feb 2019" "4.2.8p13" "User Commands"
.TH ntpd 1ntpdman "03 Mar 2020" "4.2.8p14" "User Commands"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:46 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:05 PM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
@ -979,7 +979,7 @@ RFC5908
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH BUGS
The

View File

@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTPD 1ntpdmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:37 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:55 PM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@ -886,7 +886,7 @@ A snapshot of this documentation is available in HTML format in
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh BUGS
The

View File

@ -45,6 +45,9 @@
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#include <stdio.h>
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
@ -82,6 +85,10 @@
# include <sys/mman.h>
#endif
#ifdef HAVE_SYSEXITS_H
# include <sysexits.h>
#endif
#ifdef HAVE_TERMIOS_H
# include <termios.h>
#endif
@ -154,6 +161,21 @@
DNSServiceRef mdns;
#endif
/* In case 'sysexits.h' is unavailable, define some exit codes here: */
#ifndef EX_SOFTWARE
# define EX_SOFTWARE 70
#endif
#ifndef EX_OSERR
# define EX_OSERR 71
#endif
#ifndef EX_IOERR
# define EX_IOERR 74
#endif
#ifndef EX_PROTOCOL
#define EX_PROTOCOL 76
#endif
#ifdef HAVE_SETPGRP_0
# define ntp_setpgrp(x, y) setpgrp()
#else
@ -192,6 +214,10 @@ int mdnsreg = FALSE;
int mdnstries = 5;
#endif /* HAVE_DNSREGISTRATION */
#ifdef HAVE_LINUX_CAPABILITIES
int have_caps; /* runtime check whether capabilities work */
#endif /* HAVE_LINUX_CAPABILITIES */
#ifdef HAVE_DROPROOT
int droproot;
int root_dropped;
@ -205,7 +231,7 @@ struct passwd *pw;
#endif /* HAVE_DROPROOT */
#ifdef HAVE_WORKING_FORK
int waitsync_fd_to_close = -1; /* -w/--wait-sync */
int daemon_pipe[2] = { -1, -1 };
#endif
/*
@ -235,7 +261,8 @@ static RETSIGTYPE finish (int);
#endif
#if !defined(SIM) && defined(HAVE_WORKING_FORK)
static int wait_child_sync_if (int, long);
static int wait_child_sync_if (int, unsigned long);
static int wait_child_exit_if (pid_t, int);
#endif
#if !defined(SIM) && !defined(SYS_WINNT)
@ -402,18 +429,16 @@ main(
return ntpsim(argc, argv);
}
#else /* !SIM follows */
#ifdef NO_MAIN_ALLOWED
#elif defined(NO_MAIN_ALLOWED)
CALL(ntpd,"ntpd",ntpdmain);
#else /* !NO_MAIN_ALLOWED follows */
#ifndef SYS_WINNT
#elif !defined(SYS_WINNT)
int
main(
int argc,
char *argv[]
)
{
#ifdef __FreeBSD__
# ifdef __FreeBSD__
{
/*
* We Must disable ASLR stack gap on FreeBSD to avoid a
@ -424,12 +449,10 @@ main(
pid_t my_pid = getpid();
procctl(P_PID, my_pid, PROC_STACKGAP_CTL, &aslr_var);
}
#endif
# endif
return ntpdmain(argc, argv);
}
#endif /* !SYS_WINNT */
#endif /* !NO_MAIN_ALLOWED */
#endif /* !SIM */
#ifdef _AIX
/*
@ -560,13 +583,13 @@ set_process_priority(void)
# ifdef HAVE_WORKING_FORK
static void
detach_from_terminal(
int pipe_fds[2],
int pipe[2],
long wait_sync,
const char *logfilename
)
{
int rc;
int exit_code;
pid_t cpid;
int exit_code;
# if !defined(HAVE_SETSID) && !defined (HAVE_SETPGID) && defined(TIOCNOTTY)
int fid;
# endif
@ -574,16 +597,28 @@ detach_from_terminal(
struct sigaction sa;
# endif
rc = fork();
if (-1 == rc) {
exit_code = (errno) ? errno : -1;
msyslog(LOG_ERR, "fork: %m");
exit(exit_code);
}
if (rc > 0) {
cpid = fork();
if (0 != cpid) {
/* parent */
exit_code = wait_child_sync_if(pipe_fds[0],
wait_sync);
if (-1 == cpid) {
msyslog(LOG_ERR, "fork: %m");
exit_code = EX_OSERR;
} else {
close(pipe[1]);
pipe[1] = -1;
exit_code = wait_child_sync_if(
pipe[0], wait_sync);
DPRINTF(1, ("sync_if: rc=%d\n", exit_code));
if (exit_code <= 0) {
/* probe daemon exit code -- wait for
* child process if we have an unexpected
* EOF on the monitor pipe.
*/
exit_code = wait_child_exit_if(
cpid, (exit_code < 0));
DPRINTF(1, ("exit_if: rc=%d\n", exit_code));
}
}
exit(exit_code);
}
@ -598,7 +633,8 @@ detach_from_terminal(
syslog_file = NULL;
syslogit = TRUE;
}
close_all_except(waitsync_fd_to_close);
close_all_except(pipe[1]);
pipe[0] = -1;
INSIST(0 == open("/dev/null", 0) && 1 == dup2(0, 1) \
&& 2 == dup2(0, 2));
@ -805,9 +841,6 @@ ntpdmain(
# endif
# if defined(HAVE_WORKING_FORK)
long wait_sync = 0;
int pipe_fds[2];
int rc;
int exit_code;
# endif /* HAVE_WORKING_FORK*/
# ifdef SCO5_CLOCK
int fd;
@ -873,9 +906,16 @@ ntpdmain(
" %s", saved_argv[i]);
cp += strlen(cp);
}
msyslog(LOG_INFO, "%s", buf);
msyslog(LOG_NOTICE, "%s", buf);
}
msyslog(LOG_NOTICE, "----------------------------------------------------");
msyslog(LOG_NOTICE, "ntp-4 is maintained by Network Time Foundation,");
msyslog(LOG_NOTICE, "Inc. (NTF), a non-profit 501(c)(3) public-benefit");
msyslog(LOG_NOTICE, "corporation. Support and training for ntp-4 are");
msyslog(LOG_NOTICE, "available at https://www.nwtime.org/support");
msyslog(LOG_NOTICE, "----------------------------------------------------");
/*
* Install trap handlers to log errors and assertion failures.
* Default handlers print to stderr which doesn't work if detached.
@ -950,27 +990,24 @@ ntpdmain(
# endif
# ifdef HAVE_WORKING_FORK
/* make sure the FDs are initialised */
pipe_fds[0] = -1;
pipe_fds[1] = -1;
do { /* 'loop' once */
if (!HAVE_OPT( WAIT_SYNC ))
break;
/* make sure the FDs are initialised
*
* note: if WAIT_SYNC is requested, we *have* to fork. This will
* overide any '-n' (nofork) or '-d' (debug) option presented on
* the command line!
*/
if (HAVE_OPT(WAIT_SYNC)) {
wait_sync = OPT_VALUE_WAIT_SYNC;
if (wait_sync <= 0) {
if (wait_sync <= 0)
wait_sync = 0;
break;
}
/* -w requires a fork() even with debug > 0 */
nofork = FALSE;
if (pipe(pipe_fds)) {
exit_code = (errno) ? errno : -1;
msyslog(LOG_ERR,
"Pipe creation failed for --wait-sync: %m");
exit(exit_code);
}
waitsync_fd_to_close = pipe_fds[1];
} while (0); /* 'loop' once */
else
nofork = FALSE;
}
if ( !nofork && pipe(daemon_pipe)) {
msyslog(LOG_ERR,
"Pipe creation failed for --wait-sync/daemon: %m");
exit(EX_OSERR);
}
# endif /* HAVE_WORKING_FORK */
init_lib();
@ -996,12 +1033,11 @@ ntpdmain(
/*
* Detach us from the terminal. May need an #ifndef GIZMO.
*/
if (!nofork) {
# ifdef HAVE_WORKING_FORK
detach_from_terminal(pipe_fds, wait_sync, logfilename);
# endif /* HAVE_WORKING_FORK */
if (!nofork) {
detach_from_terminal(daemon_pipe, wait_sync, logfilename);
}
# endif /* HAVE_WORKING_FORK */
# ifdef SCO5_CLOCK
/*
@ -1146,12 +1182,33 @@ ntpdmain(
report_event(EVNT_SYSRESTART, NULL, NULL);
initializing = FALSE;
# ifdef HAVE_DROPROOT
if (droproot) {
# ifdef HAVE_LINUX_CAPABILITIES
{
/* Check that setting capabilities actually works; we might be
* run on a kernel with disabled capabilities. We must not
* drop privileges in this case.
*/
cap_t caps;
caps = cap_from_text("cap_sys_time,cap_setuid,cap_setgid,cap_sys_chroot,cap_net_bind_service=pe");
if ( ! caps) {
msyslog( LOG_ERR, "cap_from_text() failed: %m" );
exit(-1);
}
have_caps = (cap_set_proc(caps) == 0);
cap_free(caps); /* caps not NULL here! */
}
# endif /* HAVE_LINUX_CAPABILITIES */
#ifdef NEED_EARLY_FORK
# ifdef HAVE_DROPROOT
# ifdef HAVE_LINUX_CAPABILITIES
if (droproot && have_caps) {
# else
if (droproot) {
# endif /*HAVE_LINUX_CAPABILITIES*/
# ifdef NEED_EARLY_FORK
fork_nonchroot_worker();
#endif
# endif
/* Drop super-user privileges and chroot now if the OS supports this */
@ -1387,28 +1444,28 @@ int scmp_sc[] = {
}
#endif /* LIBSECCOMP and KERN_SECCOMP */
#ifdef SYS_WINNT
#if defined(SYS_WINNT)
ntservice_isup();
#endif
# ifdef HAVE_IO_COMPLETION_PORT
for (;;) {
#if !defined(SIM) && defined(SIGDIE1)
if (signalled)
finish_safe(signo);
#endif
GetReceivedBuffers();
# else /* normal I/O */
#elif defined(HAVE_WORKING_FORK)
if (daemon_pipe[1] != -1) {
write(daemon_pipe[1], "R\n", 2);
}
#endif /* HAVE_WORKING_FORK */
# ifndef HAVE_IO_COMPLETION_PORT
BLOCK_IO_AND_ALARM();
was_alarmed = FALSE;
# endif
for (;;) {
#if !defined(SIM) && defined(SIGDIE1)
if (signalled)
finish_safe(signo);
#endif
#endif
# ifdef HAVE_IO_COMPLETION_PORT
GetReceivedBuffers();
# else /* normal I/O */
if (alarm_flag) { /* alarmed? */
was_alarmed = TRUE;
alarm_flag = FALSE;
@ -1573,26 +1630,30 @@ finish(
* wait_child_sync_if - implements parent side of -w/--wait-sync
*/
# ifdef HAVE_WORKING_FORK
static int
wait_child_sync_if(
int pipe_read_fd,
long wait_sync
int pipe_read_fd,
unsigned long wait_sync
)
{
int rc;
int exit_code;
char ch;
time_t wait_end_time;
time_t cur_time;
time_t wait_rem;
fd_set readset;
struct timeval wtimeout;
if (0 == wait_sync)
return 0;
/* we wait a bit for the child in *any* case, because on failure
* of the child we have to get and inspect the exit code!
*/
wait_end_time = time(NULL);
if (wait_sync)
wait_end_time += wait_sync;
else
wait_end_time += 30;
/* waitsync_fd_to_close used solely by child */
close(waitsync_fd_to_close);
wait_end_time = time(NULL) + wait_sync;
do {
cur_time = time(NULL);
wait_rem = (wait_end_time > cur_time)
@ -1607,10 +1668,9 @@ wait_child_sync_if(
if (-1 == rc) {
if (EINTR == errno)
continue;
exit_code = (errno) ? errno : -1;
msyslog(LOG_ERR,
"--wait-sync select failed: %m");
return exit_code;
"daemon startup: select failed: %m");
return EX_IOERR;
}
if (0 == rc) {
/*
@ -1627,16 +1687,70 @@ wait_child_sync_if(
NULL, &wtimeout);
if (0 == rc) /* select() timeout */
break;
else /* readable */
}
rc = read(pipe_read_fd, &ch, 1);
if (rc == 0) {
DPRINTF(2, ("daemon control: got EOF\n"));
return -1; /* unexpected EOF, check daemon */
} else if (rc == 1) {
DPRINTF(2, ("daemon control: got '%c'\n",
(ch >= ' ' ? ch : '.')));
if (ch == 'R' && !wait_sync)
return 0;
} else /* readable */
return 0;
if (ch == 'S' && wait_sync)
return 0;
} else {
DPRINTF(2, ("daemon control: read 1 char failed: %s\n",
strerror(errno)));
return EX_IOERR;
}
} while (wait_rem > 0);
fprintf(stderr, "%s: -w/--wait-sync %ld timed out.\n",
progname, wait_sync);
return ETIMEDOUT;
if (wait_sync) {
fprintf(stderr, "%s: -w/--wait-sync %ld timed out.\n",
progname, wait_sync);
return EX_PROTOCOL;
} else {
fprintf(stderr, "%s: daemon startup monitoring timed out.\n",
progname);
return 0;
}
}
static int
wait_child_exit_if(
pid_t cpid,
int blocking
)
{
# ifdef HAVE_WAITPID
int rc = 0;
int wstatus;
if (cpid == waitpid(cpid, &wstatus, (blocking ? 0 : WNOHANG))) {
DPRINTF(1, ("child (pid=%d) dead now\n", cpid));
if (WIFEXITED(wstatus)) {
rc = WEXITSTATUS(wstatus);
msyslog(LOG_ERR, "daemon child exited with code %d",
rc);
} else if (WIFSIGNALED(wstatus)) {
rc = EX_SOFTWARE;
msyslog(LOG_ERR, "daemon child died with signal %d",
WTERMSIG(wstatus));
} else {
rc = EX_SOFTWARE;
msyslog(LOG_ERR, "daemon child died with unknown cause");
}
} else {
DPRINTF(1, ("child (pid=%d) still alive\n", cpid));
}
return rc;
# else
UNUSED_ARG(cpid);
return 0;
# endif
}
# endif /* HAVE_WORKING_FORK */

View File

@ -67,7 +67,7 @@ The program can operate in any of several modes, including client/server,
symmetric and broadcast modes, and with both symmetric-key and public-key
cryptography.
</p>
<p>This document applies to version 4.2.8p13 of <code>ntpd</code>.
<p>This document applies to version 4.2.8p14 of <code>ntpd</code>.
</p>
<a name="SEC_Overview"></a>
<h2 class="shortcontents-heading">Short Table of Contents</h2>
@ -309,7 +309,7 @@ used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p12
<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p14
Usage: ntpd [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... \
[ &lt;server1&gt; ... &lt;serverN&gt; ]
Flg Arg Option-Name Description
@ -331,7 +331,7 @@ Usage: ntpd [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ].
-g no panicgate Allow the first adjustment to be Big
- may appear multiple times
-G no force-step-once Step any initial offset correction.
-i Str jaildir Jail directory
-i --- jaildir built without --enable-clockctl or --enable-linuxcaps or --enable-solarisprivs
-I Str interface Listen on an interface name or address
- may appear multiple times
-k Str keyfile path to symmetric keys
@ -354,7 +354,7 @@ Usage: ntpd [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ].
-s Str statsdir Statistics file location
-t Str trustedkey Trusted key number
- may appear multiple times
-u Str user Run as userid (or userid:groupid)
-u --- user built without --enable-clockctl or --enable-linuxcaps or --enable-solarisprivs
-U Num updateinterval interval in seconds between scans for new or dropped interfaces
Str var make ARG an ntp variable (RW)
- may appear multiple times

View File

@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
.TH ntpd @NTPD_MS@ "20 Feb 2019" "4.2.8p13" "User Commands"
.TH ntpd @NTPD_MS@ "03 Mar 2020" "4.2.8p14" "User Commands"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:46 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:05 PM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
@ -979,7 +979,7 @@ RFC5908
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH BUGS
The

View File

@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTPD @NTPD_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:37 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:55 PM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@ -886,7 +886,7 @@ A snapshot of this documentation is available in HTML format in
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh BUGS
The

View File

@ -0,0 +1 @@
pollskewlist default 0|0

View File

@ -0,0 +1 @@
pollskewlist default 4|4

View File

@ -0,0 +1 @@
pollskewlist 3 3|3 4 4|4 default 5|5

View File

@ -949,7 +949,7 @@ add_clock_sample(
pp->lastref = stamp;
if (pp->coderecv == pp->codeproc)
refclock_report(peer, CEVNT_NOMINAL);
refclock_process_offset(pp, stamp, recvt, pp->fudgetime1);
refclock_process_offset(pp, stamp, recvt, 0.0);
}
/* ------------------------------------------------------------------ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -162,6 +162,7 @@
#include "ntp_unixtime.h"
#include "ntp_refclock.h"
#include "ntp_calendar.h"
#include "ntp_calgps.h"
#include "ntp_stdlib.h"
#include <stdio.h>
@ -388,6 +389,7 @@ static void oncore_set_traim (struct instance *);
static void oncore_shmem_get_3D (struct instance *);
static void oncore_ss (struct instance *);
static int oncore_wait_almanac (struct instance *);
static void oncore_feed_clockproc (struct instance *);
static void oncore_msg_any (struct instance *, u_char *, size_t, int);
static void oncore_msg_Adef (struct instance *, u_char *, size_t);
@ -1872,12 +1874,16 @@ oncore_get_timestamp(
/* and some things I dont understand (magic ntp things) */
#if 1
oncore_feed_clockproc(instance);
#else
if (!refclock_process(instance->pp)) {
refclock_report(instance->peer, CEVNT_BADTIME);
refclock_report(peer, CEVNT_BADTIME);
peer->flags &= ~FLAG_PPS; /* problem - clear PPS FLAG */
return;
}
#endif
oncore_log(instance, LOG_INFO, Msg); /* this is long message above */
instance->pollcnt = 2;
@ -4036,6 +4042,52 @@ oncore_wait_almanac(
}
static void
oncore_feed_clockproc(
struct instance * instance
)
{
struct peer * const peer = instance->peer;
struct refclockproc * const pp = instance->pp;
TCivilDate cd; /* calendar date + time */
TGpsDatum gd; /* GPS datum, remapped into NTP epoch */
l_fp fp; /* the reference time in NTP format */
if (pp->year >= 1980) {
/* There are oncore receivers that run in a fixed
* (possibly shifted) GPS era and fold back into that
* era on every GPS week rollover.
*
* We do not trust the date we get and remap to a GPS
* era defined by the GPS base date (derived from the
* build time stamp or a 'tos basedate' config option.
*/
ZERO(fp); /* has a zero to begin with */
ZERO(cd); /* month == monthday == 0 -> use year+yearday */
cd.year = pp->year;
cd.yearday = pp->day;
cd.hour = pp->hour;
cd.minute = pp->minute;
cd.second = pp->second;
/* the magic happens in the next line: */
gd = gpscal_from_calendar(&cd, fp); /* fp should be zero here */
/* To avoid the trouble the day-of-year calculations in
* 'refclock_process()' can cause we feed the time
* stamps we have now directly. This also saves us two
* full calendar calendar conversion cycles.
*/
fp = ntpfp_from_gpsdatum(&gd);
refclock_process_offset(pp, fp, pp->lastrec, pp->fudgetime1);
} else {
/* This is obviously a bad date/time... */
refclock_report(peer, CEVNT_BADDATE);
peer->flags &= ~FLAG_PPS; /* problem - clear PPS FLAG */
return;
}
}
static void
oncore_log (

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