aboutsummaryrefslogtreecommitdiff
path: root/contrib/ntp/include
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/include')
-rw-r--r--contrib/ntp/include/Makefile.am7
-rw-r--r--contrib/ntp/include/Makefile.in167
-rw-r--r--contrib/ntp/include/audio.h2
-rw-r--r--contrib/ntp/include/global.h3
-rw-r--r--contrib/ntp/include/hopf6039.h144
-rw-r--r--contrib/ntp/include/l_stdlib.h9
-rw-r--r--contrib/ntp/include/ntp.h619
-rw-r--r--contrib/ntp/include/ntp_cmdargs.h4
-rw-r--r--contrib/ntp/include/ntp_config.h151
-rw-r--r--contrib/ntp/include/ntp_control.h41
-rw-r--r--contrib/ntp/include/ntp_crypto.h93
-rw-r--r--contrib/ntp/include/ntp_if.h6
-rw-r--r--contrib/ntp/include/ntp_machine.h19
-rw-r--r--contrib/ntp/include/ntp_proto.h2
-rw-r--r--contrib/ntp/include/ntp_refclock.h13
-rw-r--r--contrib/ntp/include/ntp_request.h45
-rw-r--r--contrib/ntp/include/ntp_stdlib.h37
-rw-r--r--contrib/ntp/include/ntp_syscall.h5
-rw-r--r--contrib/ntp/include/ntp_syslog.h7
-rw-r--r--contrib/ntp/include/ntp_tty.h68
-rw-r--r--contrib/ntp/include/ntp_types.h4
-rw-r--r--contrib/ntp/include/ntp_unixtime.h2
-rw-r--r--contrib/ntp/include/ntpd.h70
23 files changed, 1094 insertions, 424 deletions
diff --git a/contrib/ntp/include/Makefile.am b/contrib/ntp/include/Makefile.am
index d7f28f6155ab..44301eefe60b 100644
--- a/contrib/ntp/include/Makefile.am
+++ b/contrib/ntp/include/Makefile.am
@@ -5,11 +5,13 @@ ETAGS_ARGS = $(srcdir)/Makefile.am
noinst_HEADERS = \
adjtime.h \
+ audio.h \
ascii.h \
audio.h \
binio.h \
global.h \
gps.h \
+ hopf6039.h \
icom.h \
ieee754io.h \
iosignal.h \
@@ -20,7 +22,10 @@ noinst_HEADERS = \
ntif.h \
ntp.h \
ntp_calendar.h \
+ ntp_cmdargs.h \
+ ntp_config.h \
ntp_control.h \
+ ntp_crypto.h \
ntp_datum.h \
ntp_filegen.h \
ntp_fp.h \
@@ -36,6 +41,7 @@ noinst_HEADERS = \
ntp_string.h \
ntp_syscall.h \
ntp_syslog.h \
+ ntp_tty.h \
ntp_types.h \
ntp_unixtime.h \
ntpd.h \
@@ -44,3 +50,4 @@ noinst_HEADERS = \
recvbuff.h \
trimble.h
+
diff --git a/contrib/ntp/include/Makefile.in b/contrib/ntp/include/Makefile.in
index c1557c0604a3..e034ae1f9e7e 100644
--- a/contrib/ntp/include/Makefile.in
+++ b/contrib/ntp/include/Makefile.in
@@ -1,6 +1,7 @@
-# Makefile.in generated automatically by automake 1.4a from Makefile.am
+# Makefile.in generated automatically by automake 1.4e from Makefile.am.
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -31,8 +32,6 @@ mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
-DESTDIR =
-
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
@@ -48,7 +47,7 @@ INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_FLAG =
+INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
NORMAL_INSTALL = :
@@ -57,24 +56,30 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
+
build_alias = @build_alias@
build_triplet = @build@
host_alias = @host_alias@
host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
+
+@SET_MAKE@
AMDEP = @AMDEP@
AMTAR = @AMTAR@
+AUTOKEY = @AUTOKEY@
AWK = @AWK@
CC = @CC@
CFLAGS = @CFLAGS@
CHUTEST = @CHUTEST@
CLKTEST = @CLKTEST@
CPP = @CPP@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
DCFD = @DCFD@
DEPDIR = @DEPDIR@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INSTALL_STRIP_PROGRAM_ENV = @INSTALL_STRIP_PROGRAM_ENV@
LDFLAGS = @LDFLAGS@
LIBPARSE = @LIBPARSE@
LIBRSAREF = @LIBRSAREF@
@@ -86,16 +91,27 @@ MAKE_LIBPARSE = @MAKE_LIBPARSE@
MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
MAKE_LIBRSAREF = @MAKE_LIBRSAREF@
MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_NTP_GENKEYS = @MAKE_NTP_GENKEYS@
MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
PACKAGE = @PACKAGE@
+PATH_PERL = @PATH_PERL@
PATH_SH = @PATH_SH@
PROPDELAY = @PROPDELAY@
RANLIB = @RANLIB@
+RSADIR = @RSADIR@
+RSAOBJS = @RSAOBJS@
RSAREF = @RSAREF@
+RSASRCS = @RSASRCS@
+STRIP = @STRIP@
TESTDCF = @TESTDCF@
U = @U@
VERSION = @VERSION@
+_am_include = @_am_include@
install_sh = @install_sh@
#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
@@ -107,11 +123,13 @@ ETAGS_ARGS = $(srcdir)/Makefile.am
noinst_HEADERS = \
adjtime.h \
+ audio.h \
ascii.h \
audio.h \
binio.h \
global.h \
gps.h \
+ hopf6039.h \
icom.h \
ieee754io.h \
iosignal.h \
@@ -122,7 +140,10 @@ noinst_HEADERS = \
ntif.h \
ntp.h \
ntp_calendar.h \
+ ntp_cmdargs.h \
+ ntp_config.h \
ntp_control.h \
+ ntp_crypto.h \
ntp_datum.h \
ntp_filegen.h \
ntp_fp.h \
@@ -138,6 +159,7 @@ noinst_HEADERS = \
ntp_string.h \
ntp_syscall.h \
ntp_syslog.h \
+ ntp_tty.h \
ntp_types.h \
ntp_unixtime.h \
ntpd.h \
@@ -146,28 +168,29 @@ noinst_HEADERS = \
recvbuff.h \
trimble.h
+EXEEXT =
+OBJEXT = o
subdir = include
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../config.h
-CONFIG_CLEAN_FILES =
-DIST_SOURCES =
-HEADERS = $(noinst_HEADERS)
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+DIST_SOURCES =
+HEADERS = $(noinst_HEADERS)
-DIST_COMMON = README $(noinst_HEADERS) Makefile.am Makefile.in
+DIST_COMMON = README $(noinst_HEADERS) Makefile.am Makefile.in
+all: all-am
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-
-GZIP_ENV = --best
-all: all-redirect
.SUFFIXES:
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
- cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
- cd $(top_builddir) \
- && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu include/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) && \
+ CONFIG_HEADERS= CONFIG_LINKS= \
+ CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status
tags: TAGS
@@ -178,9 +201,9 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
- mkid -f$$here/ID $$unique $(LISP)
+ mkid -fID $$unique $(LISP)
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
@@ -193,53 +216,50 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| etags $(ETAGS_ARGS) $$tags $$unique $(LISP)
-mostlyclean-tags:
-
-clean-tags:
+GTAGS:
+ here=`CDPATH=: && cd $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $$here
distclean-tags:
-rm -f TAGS ID
-maintainer-clean-tags:
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pR $$d/$$file $(distdir); \
+ cp -pR $$d/$$file $(distdir) \
+ || exit 1; \
else \
test -f $(distdir)/$$file \
- || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
- || cp -p $$d/$$file $(distdir)/$$file || :; \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
fi; \
done
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
check-am: all-am
check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
-install-exec: install-exec-am
+all-am: Makefile $(HEADERS)
-install-data-am:
+installdirs:
+
+install: install-am
+install-exec: install-exec-am
install-data: install-data-am
+uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile $(HEADERS)
-all-redirect: all-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
-installdirs:
+installcheck: installcheck-am
+
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ INSTALL_PROGRAM_ENV='$(INSTALL_STRIP_PROGRAM_ENV)' install
mostlyclean-generic:
@@ -250,33 +270,50 @@ distclean-generic:
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
-rm -f Makefile.in
-mostlyclean-am: mostlyclean-tags mostlyclean-generic
+clean: clean-am
-mostlyclean: mostlyclean-am
+clean-am: clean-generic mostlyclean-am
-clean-am: clean-tags clean-generic mostlyclean-am
+distclean: distclean-am
-clean: clean-am
+distclean-am: clean-am distclean-generic distclean-tags
-distclean-am: distclean-tags distclean-generic clean-am
+dvi:
-distclean: distclean-am
+dvi-am:
-maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \
- distclean-am
- @echo "This command is intended for maintainers to use;"
- @echo "it deletes files that may require special tools to rebuild."
+info:
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info:
+
+install-man:
+
+installcheck-am:
maintainer-clean: maintainer-clean-am
-.PHONY: tags mostlyclean-tags distclean-tags clean-tags \
-maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
-installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all install-strip installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic
+
+.PHONY: all all-am check check-am clean clean-generic distclean \
+ distclean-generic distclean-tags distdir dvi dvi-am info \
+ info-am install install-am install-data install-data-am \
+ install-exec install-exec-am install-info install-man \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-generic tags uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/contrib/ntp/include/audio.h b/contrib/ntp/include/audio.h
index 284411c20d50..9f728ddbba6e 100644
--- a/contrib/ntp/include/audio.h
+++ b/contrib/ntp/include/audio.h
@@ -8,6 +8,6 @@
/*
* Function prototypes
*/
-int audio_init P((void));
+int audio_init P((char *));
int audio_gain P((int, int));
void audio_show P((void));
diff --git a/contrib/ntp/include/global.h b/contrib/ntp/include/global.h
index 469572454d4c..742f84cd9433 100644
--- a/contrib/ntp/include/global.h
+++ b/contrib/ntp/include/global.h
@@ -30,6 +30,9 @@ typedef unsigned short int UINT2;
/* UINT4 defines a four byte word */
typedef u_int32 UINT4; /* local modification */
+/* BYTE defines a unsigned character */
+typedef unsigned char BYTE; /* local modification for RSAEuro */
+
#ifndef NULL_PTR
#define NULL_PTR ((POINTER)0)
#endif
diff --git a/contrib/ntp/include/hopf6039.h b/contrib/ntp/include/hopf6039.h
new file mode 100644
index 000000000000..853209937b99
--- /dev/null
+++ b/contrib/ntp/include/hopf6039.h
@@ -0,0 +1,144 @@
+/****************************************************************************/
+/* hopf6039.h */
+/* hopf Elektronik 6039 PCI radio clock header */
+/* (c) 1999, 2000 Bernd Altmeier <altmeier@ATLSoft.de> */
+/* Rev. 1.00 Date 25.03.2000 */
+/* History: */
+/****************************************************************************/
+
+#ifndef _hopf6039_H_
+#define _hopf6039_H_
+
+#define HOPF_MAXVERSION 8
+#define HOPF_CNTR_MEM_LEN 0x7f
+#define HOPF_DATA_MEM_LEN 0x3ff /* this is our memory size */
+
+/* macros and definition for 32 to 16 to 8 bit conversion */
+
+typedef unsigned long DWORD;
+typedef unsigned char BYTE;
+typedef unsigned short WORD;
+
+#define LOWORD(l) ((WORD)(l))
+#define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
+#define LOBYTE(w) ((BYTE)(w))
+#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
+
+/* iocntl codes for driver access */
+
+#define HOPF_CLOCK_CMD_MASK 0xff000
+
+#define HOPF_CLOCK_GET_LOCAL 0x10000
+#define HOPF_CLOCK_GET_UTC 0x20000
+#define HOPF_CLOCK_GET_ANTENNA 0x30000
+#define HOPF_CLOCK_GET_DIFFERENCE 0x40000
+#define HOPF_CLOCK_GET_VERSION 0x50000
+#define HOPF_CLOCK_GET_POSITION 0x60000
+#define HOPF_CLOCK_GET_SATDATA 0x70000
+#define HOPF_CLOCK_GET_SYSTEMBYTE 0x80000
+#define HOPF_CLOCK_GET_IRIG 0x90000
+
+#define HOPF_CLOCK_SET_DIFFERENCE 0x01000
+#define HOPF_CLOCK_SET_ANTENNA 0x02000
+#define HOPF_CLOCK_SET_TIME 0x03000
+#define HOPF_CLOCK_SET_POSITION 0x04000
+#define HOPF_CLOCK_SET_SATMODE 0x05000
+#define HOPF_CLOCK_SET_SYSTEMBYTE 0x06000
+#define HOPF_CLOCK_SET_RESET 0x07000
+#define HOPF_CLOCK_SET_IRIG 0x08000
+
+/* clock command codes */
+
+#define HOPF_CLOCK_HARDRESET 0x00008000
+#define HOPF_CLOCK_SOFTRESET 0x00004000
+
+/* sat-information */
+
+typedef struct SatStat{
+ BYTE wVisible;
+ BYTE wMode;
+ BYTE wSat0;
+ BYTE wRat0;
+ BYTE wSat1;
+ BYTE wRat1;
+ BYTE wSat2;
+ BYTE wRat2;
+ BYTE wSat3;
+ BYTE wRat3;
+ BYTE wSat4;
+ BYTE wRat4;
+ BYTE wSat5;
+ BYTE wRat5;
+ BYTE wSat6;
+ BYTE wRat6;
+ BYTE wSat7;
+ BYTE wRat7;
+} SatStat;
+
+/* GPS position */
+
+typedef struct GPSPos { /* Position */
+ long wAltitude;
+ long wLongitude;
+ long wLatitude;
+} GPSPos;
+
+/* clock hardware version */
+
+typedef struct ClockVersion {
+ char cVersion[255]; /* Hardware Version like " DCF-RECEIVER, VERSION 01.01, DAT: 23.NOV.1999" */
+ char dVersion[255]; /* Driver Version */
+} ClockVersion;
+
+/* hopftime what you think */
+
+typedef struct HOPFTIME {
+ unsigned int wYear;
+ unsigned int wMonth;
+ unsigned int wDayOfWeek;
+ unsigned int wDay;
+ unsigned int wHour;
+ unsigned int wMinute;
+ unsigned int wSecond;
+ unsigned int wMilliseconds;
+ unsigned int wStatus;
+} HOPFTIME;
+
+/* DCF77 antenna alignment */
+
+typedef struct DcfAntenne {
+ BYTE bStatus;
+ BYTE bStatus1;
+ WORD wAntValue;
+} DcfAntenne;
+
+/* hopf PCI clock */
+
+typedef struct hopfCard {
+ char name[32];
+ unsigned irq;
+ unsigned long membase; /* without mmap */
+ unsigned int port;
+
+ int versionlen;
+ char versionbuf[1024];
+ char *version[HOPF_MAXVERSION];
+ char cardname[32];
+ int interrupt;
+ void *mbase; /* this will be our memory base address */
+
+} hopfCard;
+
+typedef struct cardparams {
+ unsigned int port;
+ unsigned irq;
+ int cardtype;
+ int cardnr;
+ unsigned int membase;
+} cardparams;
+
+
+#define WRITE_REGISTER 0x00
+#define READ_REGISTER 0x01
+
+#endif /* _hopf6039_H_ */
diff --git a/contrib/ntp/include/l_stdlib.h b/contrib/ntp/include/l_stdlib.h
index 949cf8ff4ad7..ca47af86e1f9 100644
--- a/contrib/ntp/include/l_stdlib.h
+++ b/contrib/ntp/include/l_stdlib.h
@@ -57,6 +57,10 @@ extern int cfsetospeed P((struct termios *, speed_t));
extern char * getpass P((const char *));
+#ifdef DECL_HSTRERROR_0
+extern const char * hstrerror P((int));
+#endif
+
#ifdef DECL_INET_NTOA_0
struct in_addr;
extern char * inet_ntoa P((struct in_addr));
@@ -136,6 +140,11 @@ struct sigvec;
extern int sigvec P((int, struct sigvec *, struct sigvec *));
#endif
+#ifndef HAVE_SNPRINTF
+/* PRINTFLIKE3 */
+extern int snprintf P((char *, size_t, const char *, ...));
+#endif
+
#ifdef DECL_SRAND48_0
extern void srand48 P((long));
#endif
diff --git a/contrib/ntp/include/ntp.h b/contrib/ntp/include/ntp.h
index f4d01de5df7a..f7ade0dd3824 100644
--- a/contrib/ntp/include/ntp.h
+++ b/contrib/ntp/include/ntp.h
@@ -8,58 +8,64 @@
#include "ntp_types.h"
#include <math.h>
- /* common definitions for Y2K repairs [ Y2KFixes */
-
- /* (this might better be put in ntp_calendar.h) */
-#define YEAR_BREAK 500 /* assume years < this are tm_year values: */
- /* Break < AnyFourDigitYear
- && Break > Anytm_yearYear */
-#define YEAR_PIVOT 98 /* 97/98: assume years < this are year 2000+ */
- /* FYI: official UNIX pivot year is 68/69 */
-
- /* Number of Days since (mythical) 1.BC Gregorian to 1 January of given year*/
-#define julian0(year) \
- ( \
- ( (year) * 365 ) + ( (year) > 0 \
- ? ( ((year)+3) / 4 - ((year-1) / 100) + ((year-1) / 400) ) \
- : 0 ) \
- )
-
- /* Number of days since start of NTP time to 1 January of given year */
-#define ntp0(year) ( julian0(year) - julian0(1900) )
-
- /* Number of days since start of UNIX time to 1 January of given year */
-#define unix0(year) ( julian0(year) - julian0(1970) )
-
- /* LEAP YEAR test for full 4-digit years (e.g, 1999, 2010) */
-#define isleap_4(y) /* a TRUE and PROPER leap year test */ \
- ((y)%4 == 0 && !((y)%100 == 0 && !(y%400 == 0)))
- /* NOTE: year 2000 TRULY IS A LEAP YEAR!!! */
-
- /* LEAP YEAR test for tm_year (struct tm) years (e.g, 99, 110) */
-#define isleap_tm(y) /* a TRUE and PROPER leap year test */ \
- ((y)%4 == 0 && !((y)%100 == 0 && !(((y)+1900)%400 == 0)))
-
- /* to convert simple two-digit years to tm_year style years:
- if ( year < YEAR_PIVOT ) year += 100;
-
- * to convert either two-digit OR tm_year years to four-digit years:
- if ( year < YEAR_PIVOT ) year += 100;
- if ( year < YEAR_BREAK ) year += 1900;
-
- CALL TO STANDARD:
- * As the Internet is an INTERNATIONAL network, it makes SENSE to use
- the international standard ISO 8601 to format dates and times.
- Basically this is yyyy-mm-dd for years and hh:mm:ss for times
- (joining the two togeather in computer readable media calls for
- yyyy-mm-ddThh:mm:ss, though yyyy-mm-dd hh:mm:ss is often used
- for human readable forms even though it is not not strictly
- valid ISO 8601). Standard time-zone offsets ([+-]hh:mm) are allowed.
- ghealton ] Y2KFixes */
+/*
+ * Calendar arithmetic - contributed by G. Healton
+ */
+#define YEAR_BREAK 500 /* years < this are tm_year values:
+ * Break < AnyFourDigitYear && Break >
+ * Anytm_yearYear */
+
+#define YEAR_PIVOT 98 /* 97/98: years < this are year 2000+
+ * FYI: official UNIX pivot year is
+ * 68/69 */
+
+/*
+ * Number of Days since 1 BC Gregorian to 1 January of given year
+ */
+#define julian0(year) (((year) * 365 ) + ((year) > 0 ? (((year) + 3) \
+ / 4 - ((year - 1) / 100) + ((year - 1) / \
+ 400)) : 0))
+
+/*
+ * Number of days since start of NTP time to 1 January of given year
+ */
+#define ntp0(year) (julian0(year) - julian0(1900))
+
+/*
+ * Number of days since start of UNIX time to 1 January of given year
+ */
+#define unix0(year) (julian0(year) - julian0(1970))
+
+/*
+ * LEAP YEAR test for full 4-digit years (e.g, 1999, 2010)
+ */
+#define isleap_4(y) ((y) % 4 == 0 && !((y) % 100 == 0 && !(y % \
+ 400 == 0)))
+
+/*
+ * LEAP YEAR test for tm_year (struct tm) years (e.g, 99, 110)
+ */
+#define isleap_tm(y) ((y) % 4 == 0 && !((y) % 100 == 0 && !(((y) \
+ + 1900) % 400 == 0)))
+
+/*
+ * to convert simple two-digit years to tm_year style years:
+ *
+ * if (year < YEAR_PIVOT)
+ * year += 100;
+ *
+ * to convert either two-digit OR tm_year years to four-digit years:
+ *
+ * if (year < YEAR_PIVOT)
+ * year += 100;
+ *
+ * if (year < YEAR_BREAK)
+ * year += 1900;
+ */
/*
* How to get signed characters. On machines where signed char works,
- * use it. On machines where signed char doesn't work, char had better
+ * use it. On machines where signed char doesn't work, char had better
* be signed.
*/
#ifdef NEED_S_CHAR_TYPEDEF
@@ -87,37 +93,34 @@ typedef char s_char;
#define NTP_VERSION ((u_char)4) /* current version number */
#define NTP_OLDVERSION ((u_char)1) /* oldest credible version */
#define NTP_PORT 123 /* included for sake of non-unix machines */
-#define NTP_MAXSTRATUM ((u_char)15) /* max stratum, infinity a la Bellman-Ford */
-#define NTP_MAXAGE 86400 /* one day in seconds */
#define NTP_UNREACH 16 /* poll interval backoff count */
#define NTP_MINDPOLL 6 /* log2 default min poll interval (64 s) */
#define NTP_MAXDPOLL 10 /* log2 default max poll interval (~17 m) */
#define NTP_MINPOLL 4 /* log2 min poll interval (16 s) */
#define NTP_MAXPOLL 17 /* log2 max poll interval (~4.5 h) */
#define NTP_MINCLOCK 3 /* minimum survivors */
-#define NTP_CANCLOCK 6 /* minimum candidates */
#define NTP_MAXCLOCK 10 /* maximum candidates */
-#define NTP_WINDOW 8 /* reachability register size */
#define NTP_SHIFT 8 /* 8 suitable for crystal time base */
#define NTP_MAXKEY 65535 /* maximum authentication key number */
-#define NTP_MAXSESSION 100 /* maximum entries on session key list */
-#define NTP_AUTOMAX 12 /* log2 default max session key lifetime */
+#define NTP_MAXSESSION 100 /* maximum session key list entries */
+#define NTP_AUTOMAX 13 /* log2 default max session key lifetime */
#define KEY_REVOKE 16 /* log2 default key revoke timeout */
#define NTP_FWEIGHT .5 /* clock filter weight */
-#define NTP_SWEIGHT .75 /* select weight */
-#define CLOCK_SGATE 10. /* popcorn spike gate */
+#define CLOCK_SGATE 4. /* popcorn spike gate */
#define BURST_INTERVAL1 4 /* first interburst interval (log2) */
#define BURST_INTERVAL2 1 /* succeeding interburst intervals (log2) */
-
+#define HUFFPUFF 900 /* huff-n'-puff sample interval (s) */
+
/*
- * Operations for jitter (variance) calculations (these use doubles).
- * Note that we carefully separate the jitter component from the dispersion
- * component (frequency error plus precision). The frequency error
- * component is computed as CLOCK_PHI times the difference between the epoch
- * of the time measurement and the reference time. The precision componen
- * is computed as the square root of the mean of the squares of a zero-
- * mean, uniform distribution of unit maximum amplitude. Whether this
- * makes statistical sense may be arguable.
+ * Operations for jitter calculations (these use doubles).
+ *
+ * Note that we carefully separate the jitter component from the
+ * dispersion component (frequency error plus precision). The frequency
+ * error component is computed as CLOCK_PHI times the difference between
+ * the epoch of the time measurement and the reference time. The
+ * precision componen is computed as the square root of the mean of the
+ * squares of a zero-mean, uniform distribution of unit maximum
+ * amplitude. Whether this makes statistical sense may be arguable.
*/
#define SQUARE(x) ((x) * (x))
#define SQRT(x) (sqrt(x))
@@ -130,16 +133,49 @@ typedef char s_char;
#define MINDISPERSE .01 /* min dispersion */
#define MAXDISTANCE 1. /* max root distance */
+#define EVENT_TIMEOUT 0 /* one second, that is */
+
+#ifdef AUTOKEY
/*
- * Loop filter parameters. See section 5.1 of the specification.
+ * The following structures are used in the autokey protocol.
*
- * Note that these are appropriate for a crystal time base. If your
- * system clock is line frequency controlled you should read the
- * specification for appropriate modifications.
+ * The autokey structure holds the values used to authenticate key IDs.
+ */
+struct autokey { /* network byte order */
+ tstamp_t tstamp; /* timestamp */
+ keyid_t key; /* key ID */
+ int32 seq; /* key number */
+ u_int32 siglen; /* signature length */
+ u_int32 pkt[1]; /* start of signature field */
+ u_char *sig; /* signature */
+};
+
+/*
+ * The cookie structure holds the current private value used to
+ * construct session keys.
*/
-#define CLOCK_PHI 15e-6 /* max frequency wander */
+struct cookie { /* network byte order */
+ tstamp_t tstamp; /* timestamp */
+ keyid_t key; /* key ID */
+ u_int32 siglen; /* signature length */
+ u_int32 pkt[1]; /* start of signature field */
+ u_char *sig; /* signature */
+};
-#define EVENT_TIMEOUT 0 /* one second, that is */
+/*
+ * The value structure holds variable length data such as public
+ * key, agreement parameters, public valule and leapsecond table.
+ */
+struct value { /* network byte order */
+ tstamp_t tstamp; /* timestamp */
+ tstamp_t fstamp; /* filestamp */
+ u_int32 vallen; /* value length */
+ u_int32 pkt[1]; /* start of value field */
+ u_char *ptr; /* data pointer */
+ u_int32 siglen; /* signature length */
+ u_char *sig; /* signature */
+};
+#endif /* AUTOKEY */
/*
* The interface structure is used to hold the addresses and socket
@@ -149,8 +185,8 @@ struct interface {
int fd; /* socket this is opened on */
int bfd; /* socket for receiving broadcasts */
struct sockaddr_in sin; /* interface address */
- struct sockaddr_in bcast; /* broadcast address */
- struct sockaddr_in mask; /* interface mask */
+ struct sockaddr_in bcast; /* broadcast address */
+ struct sockaddr_in mask; /* interface mask */
char name[8]; /* name of interface */
int flags; /* interface flags */
int last_ttl; /* last TTL specified */
@@ -168,7 +204,7 @@ struct interface {
#define INT_MULTICAST 8 /* multicasting enabled */
/*
- * Define flasher bits (tests 1 through 8 in packet procedure)
+ * Define flasher bits (tests 1 through 11 in packet procedure)
* These reveal the state at the last grumble from the peer and are
* most handy for diagnosing problems, even if not strictly a state
* variable in the spec. These are recorded in the peer structure.
@@ -176,102 +212,141 @@ struct interface {
#define TEST1 0x0001 /* duplicate packet received */
#define TEST2 0x0002 /* bogus packet received */
#define TEST3 0x0004 /* protocol unsynchronized */
-#define TEST4 0x0008 /* peer delay/dispersion bounds check */
-#define TEST5 0x0010 /* peer authentication failed */
+#define TEST4 0x0008 /* access denied */
+#define TEST5 0x0010 /* authentication failed */
#define TEST6 0x0020 /* peer clock unsynchronized */
#define TEST7 0x0040 /* peer stratum out of bounds */
-#define TEST8 0x0080 /* root delay/dispersion bounds check */
-#define TEST9 0x0100 /* peer not authenticated */
-#define TEST10 0x0200 /* access denied */
+#define TEST8 0x0080 /* root delay/dispersion bounds check */
+#define TEST9 0x0100 /* peer delay/dispersion bounds check */
+#define TEST10 0x0200 /* autokey failed */
+#define TEST11 0x0400 /* proventic not confirmed */
/*
- * The peer structure. Holds state information relating to the guys
- * we are peering with. Most of this stuff is from section 3.2 of the
+ * The peer structure. Holds state information relating to the guys
+ * we are peering with. Most of this stuff is from section 3.2 of the
* spec.
*/
struct peer {
- struct peer *next;
- struct peer *ass_next; /* link pointer in associd hash */
- struct sockaddr_in srcadr; /* address of remote host */
- struct interface *dstadr; /* pointer to address on local host */
- struct refclockproc *procptr; /* pointer to reference clock stuff */
- u_char leap; /* leap indicator */
- u_char hmode; /* association mode with this peer */
- u_char pmode; /* peer's association mode */
- u_char stratum; /* stratum of remote peer */
- s_char precision; /* peer's clock precision */
- u_char ppoll; /* peer poll interval */
- u_char hpoll; /* local host poll interval */
- u_char minpoll; /* min local host poll interval */
- u_char maxpoll; /* max local host poll interval */
- u_char burst; /* packets remaining in burst */
- u_char version; /* version number */
- u_int flags; /* peer flags */
- u_char cast_flags; /* flags MDF_?CAST */
- u_int flash; /* protocol error tally bits */
- u_char refclktype; /* reference clock type */
- u_char refclkunit; /* reference clock unit number */
- u_char sstclktype; /* clock type for system status word */
- u_int32 refid; /* peer reference ID */
- l_fp reftime; /* update epoch */
- u_long keyid; /* current key ID */
- u_long pkeyid; /* previous key ID (autokey) */
- u_long *keylist; /* session key identifier list */
- int keynumber; /* session key identifier number */
- u_short associd; /* association ID, a unique integer */
- u_char ttl; /* time to live (multicast) */
-
-/* **Start of clear-to-zero area.*** */
-/* Everything that is cleared to zero goes below here */
- u_char valid; /* valid counter */
-#define clear_to_zero valid
- double estbdelay; /* broadcast offset */
- u_char status; /* peer status */
- u_char pollsw; /* what it says */
- u_char reach; /* reachability, NTP_WINDOW bits */
- u_char unreach; /* unreachable count */
- u_short filter_nextpt; /* index into filter shift register */
- double filter_delay[NTP_SHIFT]; /* delay part of shift register */
- double filter_offset[NTP_SHIFT]; /* offset part of shift register */
- double filter_disp[NTP_SHIFT]; /* dispersion part of shift register */
- u_long filter_epoch[NTP_SHIFT]; /* epoch part of shift register */
- u_char filter_order[NTP_SHIFT]; /* we keep the filter sorted here */
- l_fp org; /* originate time stamp */
- l_fp rec; /* receive time stamp */
- l_fp xmt; /* transmit time stamp */
- double offset; /* peer clock offset */
- double delay; /* peer roundtrip delay */
- double variance; /* peer variance (jitter) */
- double disp; /* peer dispersion */
- double rootdelay; /* roundtrip delay to primary clock */
- double rootdispersion; /* dispersion to primary clock */
- u_long epoch; /* reference epoch */
-
-/* ***End of clear-to-zero area.*** */
-/* Everything that is cleared to zero goes above here */
- u_long update; /* receive epoch */
+ struct peer *next; /* pointer to next association */
+ struct peer *ass_next; /* link pointer in associd hash */
+ struct sockaddr_in srcadr; /* address of remote host */
+ struct interface *dstadr; /* pointer to address on local host */
+ associd_t associd; /* association ID */
+ u_char version; /* version number */
+ u_char hmode; /* local association mode */
+ u_char hpoll; /* local poll interval */
+ u_char kpoll; /* last poll interval */
+ u_char minpoll; /* min poll interval */
+ u_char maxpoll; /* max poll interval */
+ u_char burst; /* packets remaining in burst */
+ u_int flags; /* association flags */
+ u_char cast_flags; /* additional flags */
+ u_int flash; /* protocol error test tally bits */
+ u_char last_event; /* last peer error code */
+ u_char num_events; /* number of error events */
+ u_char ttlmax; /* max ttl/refclock mode */
+
+ /*
+ * Variables used by reference clock support
+ */
+ struct refclockproc *procptr; /* refclock structure pointer */
+ u_char refclktype; /* reference clock type */
+ u_char refclkunit; /* reference clock unit number */
+ u_char sstclktype; /* clock type for system status word */
+
+ /*
+ * Variables set by received packet
+ */
+ u_char leap; /* local leap indicator */
+ u_char pmode; /* remote association mode */
+ u_char stratum; /* remote stratum */
+ s_char precision; /* remote clock precision */
+ u_char ppoll; /* remote poll interval */
+ u_int32 refid; /* remote reference ID */
+ l_fp reftime; /* update epoch */
+
+ /*
+ * Variables used by authenticated client
+ */
+ keyid_t keyid; /* current key ID */
+#ifdef AUTOKEY
+#define clear_to_zero assoc
+ associd_t assoc; /* peer association ID */
+ u_int32 crypto; /* peer status word */
+#ifdef PUBKEY
+ struct value pubkey; /* public key */
+ struct value certif; /* certificate */
+ u_char *keystr; /* host name */
+#endif /* PUBKEY */
+ keyid_t pkeyid; /* previous key ID */
+ keyid_t hcookie; /* host cookie */
+ struct cookie pcookie; /* peer cookie */
+ struct autokey recauto; /* autokey */
+ u_int32 cmmd; /* peer command */
+ /*
+ * Variables used by authenticated server
+ */
+ keyid_t *keylist; /* session key ID list */
+ int keynumber; /* current key number */
+ struct autokey sndauto; /* autokey */
+#else /* AUTOKEY */
+#define clear_to_zero status
+#endif /* AUTOKEY */
+
+ /*
+ * Ephemeral state variables
+ */
+ u_char status; /* peer status */
+ u_char pollsw; /* what it says */
+ u_char ttl; /* ttl for manycast mode */
+ u_char reach; /* reachability register */
+ u_char unreach; /* unreachable count */
+ u_long epoch; /* reference epoch */
+ u_short filter_nextpt; /* index into filter shift register */
+ double filter_delay[NTP_SHIFT]; /* delay shift register */
+ double filter_offset[NTP_SHIFT]; /* offset shift register */
+ double filter_disp[NTP_SHIFT]; /* dispersion shift register */
+ u_long filter_epoch[NTP_SHIFT]; /* epoch shift register */
+ u_char filter_order[NTP_SHIFT]; /* filter sort index */
+ l_fp org; /* originate time stamp */
+ l_fp rec; /* receive time stamp */
+ l_fp xmt; /* transmit time stamp */
+ double offset; /* peer clock offset */
+ double delay; /* peer roundtrip delay */
+ double jitter; /* peer jitter (squares) */
+ double disp; /* peer dispersion */
+ double estbdelay; /* clock offset to broadcast server */
+
+ /*
+ * Variables set by received packet
+ */
+ double rootdelay; /* roundtrip delay to primary clock */
+ double rootdispersion; /* dispersion to primary clock */
+
+ /*
+ * End of clear-to-zero area
+ */
+ u_long update; /* receive epoch */
#define end_clear_to_zero update
- u_long outdate; /* send time last packet */
- u_long nextdate; /* send time next packet */
- u_long nextaction; /* peer local activity timeout (refclocks mainly) */
- void (*action) P((struct peer *));/* action timeout function */
+ u_long outdate; /* send time last packet */
+ u_long nextdate; /* send time next packet */
+ u_long nextaction; /* peer local activity timeout (refclocks mainly) */
+ void (*action) P((struct peer *)); /* action timeout function */
/*
- * statistic counters
+ * Statistic counters
*/
- u_long timereset; /* time stat counters were reset */
- u_long sent; /* number of updates sent */
- u_long received; /* number of frames received */
- u_long timereceived; /* last time a frame received */
- u_long timereachable; /* last reachable/unreachable event */
- u_long processed; /* processed by the protocol */
- u_long badauth; /* bad credentials detected */
- u_long bogusorg; /* rejected due to bogus origin */
- u_long oldpkt; /* rejected as duplicate packet */
- u_long seldisptoolarge; /* too much dispersion for selection */
- u_long selbroken; /* broken NTP detected in selection */
- u_long seltooold; /* too long since sync in selection */
- u_char last_event; /* set to code for last peer error */
- u_char num_events; /* num. of events which have occurred */
+ u_long timereset; /* time stat counters were reset */
+ u_long timereceived; /* last packet received time */
+ u_long timereachable; /* last reachable/unreachable time */
+
+ u_long sent; /* packets sent */
+ u_long received; /* packets received */
+ u_long processed; /* packets processed by the protocol */
+ u_long badauth; /* packets cryptosum failed */
+ u_long bogusorg; /* packets bogus origin */
+ u_long oldpkt; /* packets duplicate packet */
+ u_long seldisptoolarge; /* packets dispersion to large*/
+ u_long selbroken; /* not used */
};
/*
@@ -293,34 +368,33 @@ struct peer {
#define MODE_BROADCAST 5 /* broadcast mode */
#define MODE_CONTROL 6 /* control mode packet */
#define MODE_PRIVATE 7 /* implementation defined function */
-
-#define MODE_BCLIENT 8 /* a pseudo mode, used internally */
-#define MODE_MCLIENT 9 /* multicast mode, used internally */
+#define MODE_BCLIENT 8 /* broadcast client mode */
/*
* Values for peer.stratum, sys_stratum
*/
#define STRATUM_REFCLOCK ((u_char)0) /* stratum claimed by primary clock */
-#define STRATUM_PRIMARY ((u_char)1) /* host has a primary clock */
-#define STRATUM_INFIN ((u_char)NTP_MAXSTRATUM) /* infinity a la Bellman-Ford */
/* A stratum of 0 in the packet is mapped to 16 internally */
#define STRATUM_PKT_UNSPEC ((u_char)0) /* unspecified in packet */
-#define STRATUM_UNSPEC ((u_char)(NTP_MAXSTRATUM+(u_char)1)) /* unspecified */
+#define STRATUM_UNSPEC ((u_char)16) /* unspecified */
/*
* Values for peer.flags
*/
-#define FLAG_CONFIG 0x1 /* association was configured */
-#define FLAG_AUTHENABLE 0x2 /* this guy needs authentication */
-#define FLAG_MCAST1 0x4 /* multicast client/server mode */
-#define FLAG_MCAST2 0x8 /* multicast client mode */
-#define FLAG_AUTHENTIC 0x10 /* last message was authentic */
-#define FLAG_REFCLOCK 0x20 /* this is actually a reference clock */
-#define FLAG_SYSPEER 0x40 /* this is one of the selected peers */
-#define FLAG_PREFER 0x80 /* this is the preferred peer */
-#define FLAG_BURST 0x100 /* burst mode */
-#define FLAG_SKEY 0x200 /* autokey authentication */
-#define FLAG_NOSELECT 0x400 /* this is a "noselect" peer */
+#define FLAG_CONFIG 0x0001 /* association was configured */
+#define FLAG_AUTHENABLE 0x0002 /* authentication required */
+#define FLAG_AUTHENTIC 0x0004 /* last message was authentic */
+#define FLAG_SKEY 0x0008 /* autokey authentication */
+#define FLAG_MCAST 0x0010 /* multicast client mode */
+#define FLAG_REFCLOCK 0x0020 /* this is actually a reference clock */
+#define FLAG_SYSPEER 0x0040 /* this is one of the selected peers */
+#define FLAG_PREFER 0x0080 /* this is the preferred peer */
+#define FLAG_BURST 0x0100 /* burst mode */
+#define FLAG_IBURST 0x0200 /* initial burst mode */
+#define FLAG_NOSELECT 0x0400 /* this is a "noselect" peer */
+#define FLAG_AUTOKEY 0x0800 /* autokey confirmed */
+#define FLAG_ASSOC 0x1000 /* autokey reqeust */
+#define FLAG_PROVEN 0x2000 /* proventic confirmed */
/*
* Definitions for the clear() routine. We use memset() to clear
@@ -331,6 +405,11 @@ struct peer {
#define END_CLEAR_TO_ZERO(p) ((char *)&((p)->end_clear_to_zero))
#define LEN_CLEAR_TO_ZERO (END_CLEAR_TO_ZERO((struct peer *)0) \
- CLEAR_TO_ZERO((struct peer *)0))
+#define CRYPTO_TO_ZERO(p) ((char *)&((p)->clear_to_zero))
+#define END_CRYPTO_TO_ZERO(p) ((char *)&((p)->end_clear_to_zero))
+#define LEN_CRYPTO_TO_ZERO (END_CRYPTO_TO_ZERO((struct peer *)0) \
+ - CRYPTO_TO_ZERO((struct peer *)0))
+
/*
* Reference clock identifiers (for pps signal)
*/
@@ -376,7 +455,9 @@ struct peer {
#define REFCLK_PCF 35 /* Conrad parallel port radio clock */
#define REFCLK_WWV_AUDIO 36 /* WWV/H audio demodulator/decoder */
#define REFCLK_FG 37 /* Forum Graphic GPS */
-#define REFCLK_MAX 37 /* Grow as needed... */
+#define REFCLK_HOPF_SERIAL 38 /* hopf DCF77/GPS serial line receiver */
+#define REFCLK_HOPF_PCI 39 /* hopf DCF77/GPS PCI receiver */
+#define REFCLK_MAX 39 /* Grow as needed... */
/*
* We tell reference clocks from real peers by giving the reference
@@ -420,45 +501,46 @@ struct peer {
* and must be converted (except the mac, which isn't, really).
*/
struct pkt {
- u_char li_vn_mode; /* contains leap indicator, version and mode */
- u_char stratum; /* peer's stratum */
- u_char ppoll; /* the peer polling interval */
- s_char precision; /* peer clock precision */
- u_fp rootdelay; /* distance to primary clock */
- u_fp rootdispersion; /* clock dispersion */
- u_int32 refid; /* reference clock ID */
- l_fp reftime; /* time peer clock was last updated */
- l_fp org; /* originate time stamp */
- l_fp rec; /* receive time stamp */
- l_fp xmt; /* transmit time stamp */
-
-#define MIN_MAC_LEN (sizeof(u_int32) + 8) /* DES */
-#define MAX_MAC_LEN (sizeof(u_int32) + 16) /* MD5 */
+ u_char li_vn_mode; /* leap indicator, version and mode */
+ u_char stratum; /* peer stratum */
+ u_char ppoll; /* peer poll interval */
+ s_char precision; /* peer clock precision */
+ u_fp rootdelay; /* distance to primary clock */
+ u_fp rootdispersion; /* clock dispersion */
+ u_int32 refid; /* reference clock ID */
+ l_fp reftime; /* time peer clock was last updated */
+ l_fp org; /* originate time stamp */
+ l_fp rec; /* receive time stamp */
+ l_fp xmt; /* transmit time stamp */
+
+#define LEN_PKT_NOMAC 12 * sizeof(u_int32) /* min header length */
+#define LEN_PKT_MAC LEN_PKT_NOMAC + sizeof(u_int32)
+#define MIN_MAC_LEN 3 * sizeof(u_int32) /* DES */
+#define MAX_MAC_LEN 5 * sizeof(u_int32) /* MD5 */
/*
* The length of the packet less MAC must be a multiple of 64
- * bits. For normal private-key cryptography, the cryptosum
- * covers only the raw NTP header. For autokey cryptography,
- * the heade is incresed by 64 bits to contain the field length
- * and private value.
+ * with an RSA modulus and Diffie-Hellman prime of 64 octets
+ * and maximum host name of 128 octets, the maximum autokey
+ * command is 152 octets and maximum autokey response is 460
+ * octets. A packet can contain no more than one command and one
+ * response, so the maximum total extension field length is 672
+ * octets. But, to handle humungus certificates, the bank must
+ * be broke.
*/
- u_int32 keyid1; /* key identifier 1 */
- u_int32 keyid2; /* key identifier 2 */
- u_int32 keyid3; /* key identifier 3 */
- u_char mac[MAX_MAC_LEN]; /* mac */
+#ifdef AUTOKEY
+#ifdef PUBKEY
+ u_int32 exten[5000 / 4]; /* max extension field */
+#else
+ u_int32 exten[672 / 4]; /* max extension field */
+#endif /* PUBKEY */
+#else /* AUTOKEY */
+ u_int32 exten[1]; /* misused */
+#endif /* AUTOKEY */
+ u_char mac[MAX_MAC_LEN]; /* mac */
};
/*
- * Packets can come in two flavours, one with a mac and one without.
- */
-#define LEN_PKT_NOMAC (sizeof(struct pkt) - MAX_MAC_LEN - 3 * sizeof(u_int32))
-
-/*
- * Minimum size of packet with a MAC: has to include at least a key number.
- */
-#define LEN_PKT_MAC (LEN_PKT_NOMAC + sizeof(u_int32))
-
-/*
* Stuff for extracting things from li_vn_mode
*/
#define PKT_MODE(li_vn_mode) ((u_char)((li_vn_mode) & 0x7))
@@ -482,37 +564,42 @@ struct pkt {
#define STRATUM_TO_PKT(s) ((u_char)(((s) == (STRATUM_UNSPEC)) ?\
(STRATUM_PKT_UNSPEC) : (s)))
-
/*
- * Event codes. Used for reporting errors/events to the control module
+ * Event codes. Used for reporting errors/events to the control module
*/
-#define PEER_EVENT 0x80 /* this is a peer event */
+#define PEER_EVENT 0x80 /* this is a peer event */
-#define EVNT_UNSPEC 0
-#define EVNT_SYSRESTART 1
-#define EVNT_SYSFAULT 2
-#define EVNT_SYNCCHG 3
-#define EVNT_PEERSTCHG 4
-#define EVNT_CLOCKRESET 5
-#define EVNT_BADDATETIM 6
-#define EVNT_CLOCKEXCPT 7
+/*
+ * System event codes
+ */
+#define EVNT_UNSPEC 0 /* unspecified */
+#define EVNT_SYSRESTART 1 /* system restart */
+#define EVNT_SYSFAULT 2 /* wsystem or hardware fault */
+#define EVNT_SYNCCHG 3 /* new leap or synch change */
+#define EVNT_PEERSTCHG 4 /* new source or stratum */
+#define EVNT_CLOCKRESET 5 /* clock reset */
+#define EVNT_BADDATETIM 6 /* invalid time or date */
+#define EVNT_CLOCKEXCPT 7 /* reference clock exception */
-#define EVNT_PEERIPERR (1|PEER_EVENT)
-#define EVNT_PEERAUTH (2|PEER_EVENT)
-#define EVNT_UNREACH (3|PEER_EVENT)
-#define EVNT_REACH (4|PEER_EVENT)
-#define EVNT_PEERCLOCK (5|PEER_EVENT)
+/*
+ * Peer event codes
+ */
+#define EVNT_PEERIPERR (1 | PEER_EVENT) /* IP error */
+#define EVNT_PEERAUTH (2 | PEER_EVENT) /* authentication failure */
+#define EVNT_UNREACH (3 | PEER_EVENT) /* change to unreachable */
+#define EVNT_REACH (4 | PEER_EVENT) /* change to reachable */
+#define EVNT_PEERCLOCK (5 | PEER_EVENT) /* clock exception */
/*
* Clock event codes
*/
-#define CEVNT_NOMINAL 0
-#define CEVNT_TIMEOUT 1
-#define CEVNT_BADREPLY 2
-#define CEVNT_FAULT 3
-#define CEVNT_PROP 4
-#define CEVNT_BADDATE 5
-#define CEVNT_BADTIME 6
+#define CEVNT_NOMINAL 0 /* unspecified */
+#define CEVNT_TIMEOUT 1 /* poll timeout */
+#define CEVNT_BADREPLY 2 /* bad reply format */
+#define CEVNT_FAULT 3 /* hardware or software fault */
+#define CEVNT_PROP 4 /* propagation failure */
+#define CEVNT_BADDATE 5 /* bad date format or value */
+#define CEVNT_BADTIME 6 /* bad time format or value */
#define CEVNT_MAX CEVNT_BADTIME
/*
@@ -522,8 +609,8 @@ struct pkt {
/*
- * To speed lookups, peers are hashed by the low order bits of the remote
- * IP address. These definitions relate to that.
+ * To speed lookups, peers are hashed by the low order bits of the
+ * remote IP address. These definitions relate to that.
*/
#define HASH_SIZE 32
#define HASH_MASK (HASH_SIZE-1)
@@ -538,14 +625,11 @@ struct pkt {
* is shifted by EVENT_TIMEOUT and added to the base value.
*/
#if defined(HAVE_MRAND48)
-#define RANDOM (mrand48())
-#define SRANDOM(x) (srand48(x))
-#elif defined(HAVE_RANDOM)
-#define RANDOM (random())
-#define SRANDOM(x) (srandom(x))
+# define RANDOM (mrand48())
+# define SRANDOM(x) (srand48(x))
#else
-#define RANDOM (0)
-#define SRANDOM(x) (0)
+# define RANDOM (random())
+# define SRANDOM(x) (srandom(x))
#endif
#define RANDPOLL(x) ((1 << (x)) - 1 + (RANDOM & 0x3))
@@ -575,14 +659,21 @@ struct pkt {
#define PROTO_KERNEL 9
#define PROTO_MONITOR 10
#define PROTO_FILEGEN 11
+#define PROTO_PPS 12
+#define PROTO_CAL 13
/*
* Configuration items for the loop filter
*/
#define LOOP_DRIFTINIT 1 /* set initial frequency offset */
#define LOOP_DRIFTCOMP 2 /* set frequency offset */
-#define LOOP_PPSDELAY 3 /* set pps delay */
-#define LOOP_PPSBAUD 4 /* set pps baud rate */
+#define LOOP_MAX 3 /* set step offset */
+#define LOOP_PANIC 4 /* set panic offseet */
+#define LOOP_PHI 5 /* set dispersion rate */
+#define LOOP_MINSTEP 6 /* set step timeout */
+#define LOOP_MINPOLL 7 /* set min poll interval (log2 s) */
+#define LOOP_ALLAN 8 /* set minimum Allan intercept */
+#define LOOP_HUFFPUFF 9 /* set huff-n'-puff filter length */
/*
* Configuration items for the stats printer
@@ -598,6 +689,7 @@ struct pkt {
*/
#define DEFBROADDELAY 4e-3 /* default broadcast offset */
#define INADDR_NTP 0xe0000101 /* NTP multicast address 224.0.1.1 */
+
/*
* Structure used optionally for monitoring when this is turned on.
*/
@@ -619,11 +711,15 @@ struct mon_data {
u_char cast_flags; /* flags MDF_?CAST */
};
-#define MDF_UCAST 0x1 /* unicast packet */
-#define MDF_MCAST 0x2 /* multicast packet */
-#define MDF_BCAST 0x4 /* broadcast packet */
-#define MDF_LCAST 0x8 /* local packet */
-#define MDF_ACAST 0x10 /* manycast packet */
+/*
+ * Values for cast_flags
+ */
+#define MDF_UCAST 0x01 /* unicast */
+#define MDF_MCAST 0x02 /* multicast */
+#define MDF_BCAST 0x04 /* broadcast */
+#define MDF_LCAST 0x08 /* localcast */
+#define MDF_ACAST 0x10 /* manycast */
+#define MDF_BCLNT 0x20 /* broadcast client */
/*
* Values used with mon_enabled to indicate reason for enabling monitoring
@@ -646,19 +742,22 @@ struct restrictlist {
/*
* Access flags
*/
-#define RES_IGNORE 0x1 /* ignore if matched */
-#define RES_DONTSERVE 0x2 /* don't give him any time */
-#define RES_DONTTRUST 0x4 /* don't trust if matched */
-#define RES_NOQUERY 0x8 /* don't allow queries if matched */
-#define RES_NOMODIFY 0x10 /* don't allow him to modify server */
-#define RES_NOPEER 0x20 /* don't allocate memory resources */
-#define RES_NOTRAP 0x40 /* don't allow him to set traps */
-#define RES_LPTRAP 0x80 /* traps set by him are low priority */
+#define RES_IGNORE 0x001 /* ignore if matched */
+#define RES_DONTSERVE 0x002 /* don't give him any time */
+#define RES_DONTTRUST 0x004 /* don't trust if matched */
+#define RES_NOQUERY 0x008 /* don't allow queries if matched */
+#define RES_NOMODIFY 0x010 /* don't allow him to modify server */
+#define RES_NOPEER 0x020 /* don't allocate memory resources */
+#define RES_NOTRAP 0x040 /* don't allow him to set traps */
+#define RES_LPTRAP 0x080 /* traps set by him are low priority */
#define RES_LIMITED 0x100 /* limit per net number of clients */
+#define RES_VERSION 0x200 /* serve only current version */
+#define RES_DEMOBILIZE 0x400 /* demobilize association */
#define RES_ALLFLAGS \
- (RES_IGNORE|RES_DONTSERVE|RES_DONTTRUST|RES_NOQUERY\
- |RES_NOMODIFY|RES_NOPEER|RES_NOTRAP|RES_LPTRAP|RES_LIMITED)
+ (RES_IGNORE | RES_DONTSERVE | RES_DONTTRUST | RES_NOQUERY | \
+ RES_NOMODIFY | RES_NOPEER | RES_NOTRAP | RES_LPTRAP | \
+ RES_LIMITED | RES_VERSION | RES_DEMOBILIZE)
/*
* Match flags
diff --git a/contrib/ntp/include/ntp_cmdargs.h b/contrib/ntp/include/ntp_cmdargs.h
new file mode 100644
index 000000000000..e9ab9b1c29cc
--- /dev/null
+++ b/contrib/ntp/include/ntp_cmdargs.h
@@ -0,0 +1,4 @@
+#include "ntp_types.h"
+
+extern void getstartup P((int, char **));
+extern void getCmdOpts P((int, char **));
diff --git a/contrib/ntp/include/ntp_config.h b/contrib/ntp/include/ntp_config.h
new file mode 100644
index 000000000000..92f5cd116c1d
--- /dev/null
+++ b/contrib/ntp/include/ntp_config.h
@@ -0,0 +1,151 @@
+/*
+ * Configuration file name
+ */
+#ifndef CONFIG_FILE
+# ifndef SYS_WINNT
+# define CONFIG_FILE "/etc/ntp.conf"
+# else /* SYS_WINNT */
+# define CONFIG_FILE "%windir%\\system32\\drivers\\etc\\ntp.conf"
+# define ALT_CONFIG_FILE "%windir%\\ntp.conf"
+# endif /* SYS_WINNT */
+#endif /* not CONFIG_FILE */
+
+/*
+ * Types of entries we understand.
+ */
+#define CONFIG_UNKNOWN 0
+
+/*
+ * Command keywords
+ */
+#define CONFIG_PEER 1
+#define CONFIG_SERVER 2
+#define CONFIG_AUTOMAX 3
+#define CONFIG_DRIFTFILE 4
+#define CONFIG_BROADCAST 5
+#define CONFIG_BROADCASTCLIENT 6
+#define CONFIG_AUTHENTICATE 7
+#define CONFIG_KEYS 8
+#define CONFIG_REVOKE 9
+#define CONFIG_PPS 10
+#define CONFIG_RESTRICT 11
+#define CONFIG_BDELAY 12
+#define CONFIG_TRUSTEDKEY 13
+#define CONFIG_REQUESTKEY 14
+#define CONFIG_CONTROLKEY 15
+#define CONFIG_TRAP 16
+#define CONFIG_FUDGE 17
+#define CONFIG_TINKER 18
+#define CONFIG_STATSDIR 19
+#define CONFIG_FILEGEN 20
+#define CONFIG_STATISTICS 21
+#define CONFIG_PIDFILE 22
+#define CONFIG_SETVAR 23
+#define CONFIG_CLIENTLIMIT 24
+#define CONFIG_CLIENTPERIOD 25
+#define CONFIG_MULTICASTCLIENT 26
+#define CONFIG_ENABLE 27
+#define CONFIG_DISABLE 28
+#define CONFIG_PHONE 29
+#define CONFIG_LOGFILE 30
+#define CONFIG_LOGCONFIG 31
+#define CONFIG_MANYCASTCLIENT 32
+#define CONFIG_MANYCASTSERVER 33
+#ifdef PUBKEY
+#define CONFIG_CRYPTO 34
+#define CONFIG_KEYSDIR 35
+#endif /* PUBKEY */
+#define CONFIG_INCLUDEFILE 36
+
+/*
+ * "peer", "server", "broadcast" modifier keywords
+ */
+#define CONF_MOD_VERSION 1
+#define CONF_MOD_KEY 2
+#define CONF_MOD_MINPOLL 3
+#define CONF_MOD_MAXPOLL 4
+#define CONF_MOD_PREFER 5
+#define CONF_MOD_BURST 6
+#define CONF_MOD_IBURST 7
+#define CONF_MOD_SKEY 8
+#define CONF_MOD_TTL 9
+#define CONF_MOD_MODE 10
+#define CONF_MOD_NOSELECT 11
+#ifdef PUBKEY
+#define CONF_MOD_PUBLICKEY 12
+#endif /* PUBKEY */
+
+/*
+ * "restrict" modifier keywords
+ */
+#define CONF_RES_MASK 1
+#define CONF_RES_IGNORE 2
+#define CONF_RES_NOSERVE 3
+#define CONF_RES_NOTRUST 4
+#define CONF_RES_NOQUERY 5
+#define CONF_RES_NOMODIFY 6
+#define CONF_RES_NOPEER 7
+#define CONF_RES_NOTRAP 8
+#define CONF_RES_LPTRAP 9
+#define CONF_RES_NTPPORT 10
+#define CONF_RES_LIMITED 11
+#define CONF_RES_VERSION 12
+#define CONF_RES_DEMOBILIZE 13
+
+/*
+ * "trap" modifier keywords
+ */
+#define CONF_TRAP_PORT 1
+#define CONF_TRAP_INTERFACE 2
+
+/*
+ * "fudge" modifier keywords
+ */
+#define CONF_FDG_TIME1 1
+#define CONF_FDG_TIME2 2
+#define CONF_FDG_STRATUM 3
+#define CONF_FDG_REFID 4
+#define CONF_FDG_FLAG1 5
+#define CONF_FDG_FLAG2 6
+#define CONF_FDG_FLAG3 7
+#define CONF_FDG_FLAG4 8
+
+/*
+ * "filegen" modifier keywords
+ */
+#define CONF_FGEN_FILE 1
+#define CONF_FGEN_TYPE 2
+#define CONF_FGEN_FLAG_LINK 3
+#define CONF_FGEN_FLAG_NOLINK 4
+#define CONF_FGEN_FLAG_ENABLE 5
+#define CONF_FGEN_FLAG_DISABLE 6
+
+/*
+ * "pps" modifier keywords
+ */
+#define CONF_PPS_ASSERT 1
+#define CONF_PPS_CLEAR 2
+#define CONF_PPS_HARDPPS 3
+
+/*
+ * "tinker" modifier keywords
+ */
+#define CONF_CLOCK_MAX 1
+#define CONF_CLOCK_PANIC 2
+#define CONF_CLOCK_PHI 3
+#define CONF_CLOCK_MINSTEP 4
+#define CONF_CLOCK_MINPOLL 5
+#define CONF_CLOCK_ALLAN 6
+#define CONF_CLOCK_HUFFPUFF 7
+
+#ifdef PUBKEY
+/*
+ * "crypto" modifier keywords
+ */
+#define CONF_CRYPTO_DH 1
+#define CONF_CRYPTO_PRIVATEKEY 2
+#define CONF_CRYPTO_PUBLICKEY 3
+#define CONF_CRYPTO_LEAP 4
+#define CONF_CRYPTO_FLAGS 5
+#define CONF_CRYPTO_CERT 6
+#endif /* PUBKEY */
diff --git a/contrib/ntp/include/ntp_control.h b/contrib/ntp/include/ntp_control.h
index dbcc2c659ff3..e31a2fdde236 100644
--- a/contrib/ntp/include/ntp_control.h
+++ b/contrib/ntp/include/ntp_control.h
@@ -9,7 +9,7 @@ struct ntp_control {
u_char r_m_e_op; /* response, more, error, opcode */
u_short sequence; /* sequence number of request */
u_short status; /* status word for association */
- u_short associd; /* association ID */
+ associd_t associd; /* association ID */
u_short offset; /* offset of this batch of data */
u_short count; /* count of data in this packet */
u_char data[(480 + MAX_MAC_LEN)]; /* data + auth */
@@ -157,14 +157,26 @@ struct ntp_control {
#define CS_STATE 10
#define CS_OFFSET 11
#define CS_DRIFT 12
-#define CS_COMPLIANCE 13
+#define CS_JITTER 13
#define CS_CLOCK 14
#define CS_PROCESSOR 15
#define CS_SYSTEM 16
-#define CS_STABIL 17
-#define CS_VARLIST 18
-
+#define CS_VERSION 17
+#define CS_STABIL 18
+#define CS_VARLIST 19
+#ifdef PUBKEY
+#define CS_FLAGS 20
+#define CS_HOST 21
+#define CS_PUBLIC 22
+#define CS_CERTIF 23
+#define CS_DHPARAMS 24
+#define CS_REVTIME 25
+#define CS_LEAPTAB 26
+#define CS_TAI 27
+#define CS_MAXCODE CS_TAI
+#else
#define CS_MAXCODE CS_VARLIST
+#endif /* PUBKEY */
/*
* Peer variables we understand
@@ -204,10 +216,23 @@ struct ntp_control {
#define CP_SENT 33
#define CP_FILTERROR 34
#define CP_FLASH 35
-#define CP_DISP 36
-#define CP_VARLIST 37
-
+#define CP_TTL 36
+#define CP_TTLMAX 37
+#define CP_VARLIST 38
+#ifdef PUBKEY
+#define CP_FLAGS 39
+#define CP_HOST 40
+#define CP_PUBLIC 41
+#define CP_CERTIF 42
+#define CP_SESKEY 43
+#define CP_SASKEY 44
+#define CP_INITSEQ 45
+#define CP_INITKEY 46
+#define CP_INITTSP 47
+#define CP_MAXCODE CP_INITTSP
+#else
#define CP_MAXCODE CP_VARLIST
+#endif /* PUBKEY */
/*
* Clock variables we understand
diff --git a/contrib/ntp/include/ntp_crypto.h b/contrib/ntp/include/ntp_crypto.h
new file mode 100644
index 000000000000..a4e6d70d6577
--- /dev/null
+++ b/contrib/ntp/include/ntp_crypto.h
@@ -0,0 +1,93 @@
+/*
+ * ntp_crypto.h - definitions for cryptographic operations
+ */
+#ifdef AUTOKEY
+#include "global.h"
+#include "md5.h"
+#ifdef RSAREF
+#include "rsaref.h"
+#include "rsa.h"
+
+#define EVP_SignInit(a, b) R_SignInit(a, b)
+#define EVP_SignUpdate(a, b, c) R_SignUpdate(a, b, c);
+#define EVP_SignFinal(a, b, c, d) R_SignFinal(a, b, c, d);
+#define EVP_VerifyInit(a, b) R_VerifyInit(a, b)
+#define EVP_VerifyUpdate(a, b, c) R_VerifyUpdate(a, b, c);
+#define EVP_VerifyFinal(a, b, c, d) R_VerifyFinal(a, b, c, d);
+
+#endif /* RSAREF */
+
+/*
+ * Cryptostatus word
+ */
+#define CRYPTO_FLAG_ENAB 0x01 /* crypto enable */
+#define CRYPTO_FLAG_RSA 0x02 /* public/private keys */
+#define CRYPTO_FLAG_CERT 0x04 /* certificate */
+#define CRYPTO_FLAG_DH 0x08 /* agreement parameters */
+#define CRYPTO_FLAG_TAI 0x10 /* leapseconds table */
+
+/*
+ * Extension field definitions
+ */
+#define CRYPTO_VN 1 /* current protocol version number */
+
+#define CRYPTO_NULL ((CRYPTO_VN << 8) | 0) /* no operation */
+#define CRYPTO_STAT ((CRYPTO_VN << 8) | 1) /* status */
+#define CRYPTO_ASSOC ((CRYPTO_VN << 8) | 2) /* association ID */
+#define CRYPTO_AUTO ((CRYPTO_VN << 8) | 3) /* autokey values */
+#define CRYPTO_PRIV ((CRYPTO_VN << 8) | 4) /* cookie value */
+#define CRYPTO_DHPAR ((CRYPTO_VN << 8) | 5) /* agreement params */
+#define CRYPTO_DH ((CRYPTO_VN << 8) | 6) /* public value */
+#define CRYPTO_NAME ((CRYPTO_VN << 8) | 7) /* host name/pub key */
+#define CRYPTO_CERT ((CRYPTO_VN << 8) | 8) /* PKI certificate */
+#define CRYPTO_TAI ((CRYPTO_VN << 8) | 9) /* leapseconds table */
+#define CRYPTO_RESP 0x8000 /* response */
+#define CRYPTO_ERROR 0x4000 /* error */
+
+#ifdef PUBKEY
+/*
+ * Configuration codes
+ */
+#define CRYPTO_CONF_NONE 0 /* nothing doing */
+#define CRYPTO_CONF_FLAGS 1 /* initialize flags */
+#define CRYPTO_CONF_PRIV 2 /* load private key from file */
+#define CRYPTO_CONF_PUBL 3 /* load public key from file */
+#define CRYPTO_CONF_DH 4 /* load Diffie_Hellman pars from file */
+#define CRYPTO_CONF_LEAP 5 /* load leapsecond table */
+#define CRYPTO_CONF_KEYS 6 /* set keys directory path */
+#define CRYPTO_CONF_CERT 7 /* load PKI certificate from file */
+#endif /* PUBKEY */
+
+/*
+ * Function prototypes
+ */
+extern void crypto_recv P((struct peer *, struct recvbuf *));
+extern int crypto_xmit P((u_int32 *, int, u_int, keyid_t,
+ u_int));
+extern keyid_t session_key P((struct sockaddr_in *, struct
+ sockaddr_in *, keyid_t, keyid_t,
+ u_long));
+extern void make_keylist P((struct peer *, struct interface *));
+extern void key_expire P((struct peer *));
+extern void crypto_agree P((void));
+#ifdef PUBKEY
+extern void crypto_config P((int, char *));
+extern void crypto_setup P((void));
+extern int crypto_public P((struct peer *, u_char *, u_int));
+#endif /* PUBKEY */
+
+/*
+ * Cryptographic values
+ */
+extern u_int crypto_flags; /* status word */
+#ifdef PUBKEY
+extern R_DH_PARAMS dh_params;
+extern struct value host; /* host name/public key */
+extern struct value certif; /* certificate */
+extern struct value dhparam; /* agreement parameters */
+extern struct value dhpub; /* public value */
+extern struct value tai_leap; /* leapseconds table */
+extern u_int crypto_flags; /* status word */
+extern u_int sys_tai; /* current UTC offset from TAI */
+#endif /* PUBKEY */
+#endif /* AUTOKEY */
diff --git a/contrib/ntp/include/ntp_if.h b/contrib/ntp/include/ntp_if.h
index 0be015601234..91362d83106a 100644
--- a/contrib/ntp/include/ntp_if.h
+++ b/contrib/ntp/include/ntp_if.h
@@ -8,12 +8,6 @@
# include "/sys/sync/sema.h"
#endif
-/* was: defined(SYS_AIX) */
-#if defined(TIME_WITH_SYS_TIME)
-# include <sys/time.h>
-# include <time.h>
-#endif
-
/* was: (defined(SYS_SOLARIS) && !defined(bsd)) || defined(SYS_SUNOS4) */
/* was: defined(SYS_UNIXWARE1) */
#ifdef HAVE_SYS_SOCKIO_H
diff --git a/contrib/ntp/include/ntp_machine.h b/contrib/ntp/include/ntp_machine.h
index 4f7f345d8eba..d14f5c1d28b3 100644
--- a/contrib/ntp/include/ntp_machine.h
+++ b/contrib/ntp/include/ntp_machine.h
@@ -6,11 +6,18 @@
#define __ntp_machine
#ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
#endif
#include "ntp_proto.h"
@@ -235,18 +242,18 @@ typedef unsigned long u_long;
error "NT requires config.h to be included"
# endif /* HAVE_CONFIG_H) */
-#if defined SYS_WINNT
# define ifreq _INTERFACE_INFO
# define ifr_flags iiFlags
# define ifr_addr iiAddress.AddressIn
# define ifr_broadaddr iiBroadcastAddress.AddressIn
# define ifr_mask iiNetmask.AddressIn
-#endif /* SYS_WINNT */
# define isascii __isascii
# define isatty _isatty
# define mktemp _mktemp
-# define getpid GetCurrentProcessId
+# if 0
+# define getpid GetCurrentProcessId
+# endif
# include <windows.h>
# include <ws2tcpip.h>
# undef interface
diff --git a/contrib/ntp/include/ntp_proto.h b/contrib/ntp/include/ntp_proto.h
index 2a888c2cc257..e6e78553305b 100644
--- a/contrib/ntp/include/ntp_proto.h
+++ b/contrib/ntp/include/ntp_proto.h
@@ -5,4 +5,6 @@
#include <config.h>
#endif
+#define NTP_MAXFREQ 500e-6
+
#endif /* __ntp_proto_h */
diff --git a/contrib/ntp/include/ntp_refclock.h b/contrib/ntp/include/ntp_refclock.h
index fd1d0801d98e..3995e9a1af7d 100644
--- a/contrib/ntp/include/ntp_refclock.h
+++ b/contrib/ntp/include/ntp_refclock.h
@@ -29,12 +29,14 @@
#include <sys/modem.h>
#endif
+#if 0 /* If you need that, include ntp_io.h instead */
#if defined(STREAM)
#include <stropts.h>
-#if defined(CLK)
+#if defined(CLK) /* This is never defined, except perhaps by a system header file */
#include <sys/clkdefs.h>
#endif /* CLK */
#endif /* STREAM */
+#endif
#include "recvbuff.h"
@@ -42,10 +44,9 @@
#define BSD_TTYS
#endif /* SYSV_TTYS STREAM BSD_TTYS */
-#define SAMPLE(x) if ((pp->coderecv + 1) % MAXSTAGE != \
- pp->codeproc % MAXSTAGE) \
- pp->filter[pp->coderecv++ % MAXSTAGE] = \
- (x);
+#define SAMPLE(x) pp->filter[pp->coderecv++ % MAXSTAGE] = (x); \
+ if (pp->coderecv % MAXSTAGE == pp->codeproc % MAXSTAGE) \
+ pp->codeproc++;
/*
* Macros to determine the clock type and unit numbers from a
@@ -195,7 +196,7 @@ struct refclockproc {
l_fp lastrec; /* local timestamp */
double offset; /* mean offset */
double disp; /* sample dispersion */
- double variance; /* sample variance */
+ double jitter; /* jitter (mean squares) */
double filter[MAXSTAGE]; /* median filter */
/*
diff --git a/contrib/ntp/include/ntp_request.h b/contrib/ntp/include/ntp_request.h
index 87dba8815433..a64094a2d49c 100644
--- a/contrib/ntp/include/ntp_request.h
+++ b/contrib/ntp/include/ntp_request.h
@@ -111,6 +111,10 @@
/*
* A request packet. These are almost a fixed length.
*/
+
+#define MAXFILENAME 128 /* max key file name length */
+ /* NOTE: also in ntp.h */
+
struct req_pkt {
u_char rm_vn_mode; /* response, more, version, mode */
u_char auth_seq; /* key, sequence number */
@@ -118,9 +122,9 @@ struct req_pkt {
u_char request; /* request number */
u_short err_nitems; /* error code/number of data items */
u_short mbz_itemsize; /* item size */
- char data[32]; /* data area */
+ char data[MAXFILENAME + 16]; /* data area [32 prev](144 byte max) */
l_fp tstamp; /* time stamp, for authentication */
- u_int32 keyid; /* encryption key */
+ keyid_t keyid; /* encryption key */
char mac[MAX_MAC_LEN-sizeof(u_int32)]; /* (optional) 8 byte auth code */
};
@@ -257,7 +261,8 @@ struct resp_pkt {
#define REQ_GET_KERNEL 38 /* get kernel pll/pps information */
#define REQ_GET_CLKBUGINFO 39 /* get clock debugging info */
#define REQ_SET_PRECISION 41 /* (not used) */
-#define REQ_MON_GETLIST_1 42 /* return data collected by monitor v1 */
+#define REQ_MON_GETLIST_1 42 /* return collected v1 monitor data */
+#define REQ_HOSTNAME_ASSOCID 43 /* Here is a hostname + assoc_id */
/*
* Flags in the peer information returns
@@ -286,6 +291,7 @@ struct resp_pkt {
/*
* Peer list structure. Used to return raw lists of peers. It goes
* without saying that everything returned is in network byte order.
+ * Well, it *would* have gone without saying, but somebody said it.
*/
struct info_peer_list {
u_int32 address; /* address of peer */
@@ -330,14 +336,14 @@ struct info_peer {
u_char hpoll; /* peer.hpoll */
s_char precision; /* peer.precision */
u_char version; /* peer.version */
- u_char valid; /* peer.valid */
+ u_char unused8;
u_char reach; /* peer.reach */
u_char unreach; /* peer.unreach */
u_char flash; /* old peer.flash */
u_char ttl; /* peer.ttl */
u_short flash2; /* new peer.flash */
- u_short associd; /* association ID */
- u_int32 keyid; /* peer.keyid */
+ associd_t associd; /* association ID */
+ keyid_t keyid; /* peer.keyid */
u_int32 pkeyid; /* unused */
u_int32 refid; /* peer.refid */
u_int32 timer; /* peer.timer */
@@ -524,14 +530,16 @@ struct conf_peer {
u_char flags; /* flags for this request */
u_char ttl; /* time to live (multicast) or refclock mode */
u_short unused; /* unused */
- u_int32 keyid; /* key to use for this association */
+ keyid_t keyid; /* key to use for this association */
+ char keystr[MAXFILENAME]; /* public key file name*/
};
-#define CONF_FLAG_AUTHENABLE 0x1
-#define CONF_FLAG_PREFER 0x2
-#define CONF_FLAG_BURST 0x4
-#define CONF_FLAG_NOSELECT 0x8
-#define CONF_FLAG_SKEY 0x10
+#define CONF_FLAG_AUTHENABLE 0x01
+#define CONF_FLAG_PREFER 0x02
+#define CONF_FLAG_BURST 0x04
+#define CONF_FLAG_IBURST 0x08
+#define CONF_FLAG_NOSELECT 0x10
+#define CONF_FLAG_SKEY 0x20
/*
* Structure for passing peer deletion information. Currently
@@ -553,7 +561,7 @@ struct conf_sys_flags {
* System flags we can set/clear
*/
#define SYS_FLAG_BCLIENT 0x1
-#define SYS_FLAG_AUTHENTICATE 0x2
+#define SYS_FLAG_PPS 0x2
#define SYS_FLAG_NTP 0x4
#define SYS_FLAG_KERNEL 0x8
#define SYS_FLAG_MONITOR 0x10
@@ -788,3 +796,14 @@ struct info_kernel {
int32 errcnt;
int32 stbcnt;
};
+
+/*
+ * Info returned with IP -> hostname lookup
+ */
+/* 144 might need to become 32, matching data[] member of req_pkt */
+#define NTP_MAXHOSTNAME (32 - sizeof(u_int32) - sizeof(u_short))
+struct info_dns_assoc {
+ u_int32 peeraddr; /* peer address (HMS: being careful...) */
+ associd_t associd; /* association ID */
+ char hostname[NTP_MAXHOSTNAME]; /* hostname */
+};
diff --git a/contrib/ntp/include/ntp_stdlib.h b/contrib/ntp/include/ntp_stdlib.h
index 6a2a85221267..d10f67946dd8 100644
--- a/contrib/ntp/include/ntp_stdlib.h
+++ b/contrib/ntp/include/ntp_stdlib.h
@@ -32,25 +32,15 @@ extern void msyslog P((int, const char *, ...))
extern void msyslog P(());
#endif
-#if 0 /* HMS: These seem to be unused now */
-extern void auth_des P((u_long *, u_char *));
extern void auth_delkeys P((void));
-extern int auth_parity P((u_long *));
-extern void auth_setkey P((u_long, u_long *));
-extern void auth_subkeys P((u_long *, u_char *, u_char *));
-#endif
-
-extern void auth1crypt P((u_long, u_int32 *, int));
-extern int auth2crypt P((u_long, u_int32 *, int));
-extern void auth_delkeys P((void));
-extern int auth_havekey P((u_long));
-extern int authdecrypt P((u_long, u_int32 *, int, int));
-extern int authencrypt P((u_long, u_int32 *, int));
-extern int authhavekey P((u_long));
-extern int authistrusted P((u_long));
+extern int auth_havekey P((keyid_t));
+extern int authdecrypt P((keyid_t, u_int32 *, int, int));
+extern int authencrypt P((keyid_t, u_int32 *, int));
+extern int authhavekey P((keyid_t));
+extern int authistrusted P((keyid_t));
extern int authreadkeys P((const char *));
-extern void authtrust P((u_long, int));
-extern int authusekey P((u_long, int, const u_char *));
+extern void authtrust P((keyid_t, u_long));
+extern int authusekey P((keyid_t, int, const u_char *));
extern u_long calleapwhen P((u_long));
extern u_long calyearstart P((u_long));
@@ -66,25 +56,22 @@ extern int ntp_getopt P((int, char **, const char *));
extern void init_auth P((void));
extern void init_lib P((void));
extern void init_random P((void));
-extern struct savekey *auth_findkey P((u_long));
+extern struct savekey *auth_findkey P((keyid_t));
extern int auth_moremem P((void));
extern int ymd2yd P((int, int, int));
#ifdef DES
extern int DESauthdecrypt P((u_char *, u_int32 *, int, int));
extern int DESauthencrypt P((u_char *, u_int32 *, int));
-extern void DESauth_setkey P((u_long, const u_int32 *));
+extern void DESauth_setkey P((keyid_t, const u_int32 *));
extern void DESauth_subkeys P((const u_int32 *, u_char *, u_char *));
extern void DESauth_des P((u_int32 *, u_char *));
extern int DESauth_parity P((u_int32 *));
#endif /* DES */
-#ifdef MD5
extern int MD5authdecrypt P((u_char *, u_int32 *, int, int));
extern int MD5authencrypt P((u_char *, u_int32 *, int));
-extern void MD5auth_setkey P((u_long, const u_char *, const int));
-extern u_long session_key P((u_int32, u_int32, u_long, u_long));
-#endif /* MD5 */
+extern void MD5auth_setkey P((keyid_t, const u_char *, const int));
extern int atoint P((const char *, long *));
extern int atouint P((const char *, u_long *));
@@ -143,7 +130,7 @@ extern int authnumfreekeys;
/*
* The key cache. We cache the last key we looked at here.
*/
-extern u_long cache_keyid; /* key identifier */
+extern keyid_t cache_keyid; /* key identifier */
extern u_char * cache_key; /* key pointer */
extern u_int cache_keylen; /* key length */
@@ -166,7 +153,5 @@ extern HANDLE hServDoneEvent;
/* systime.c */
extern int systime_10ms_ticks; /* adj sysclock in 10ms increments */
-extern double sys_maxfreq; /* max frequency correction */
-
/* version.c */
extern const char *Version; /* version declaration */
diff --git a/contrib/ntp/include/ntp_syscall.h b/contrib/ntp/include/ntp_syscall.h
index ff649c9a10df..29dff91190da 100644
--- a/contrib/ntp/include/ntp_syscall.h
+++ b/contrib/ntp/include/ntp_syscall.h
@@ -36,6 +36,11 @@ ntp_gettime(
ntv->time = tntx.time;
ntv->maxerror = tntx.maxerror;
ntv->esterror = tntx.esterror;
+#ifdef NTP_API
+# if NTP_API > 3
+ ntv->tai = tntx.tai;
+# endif
+#endif
return(result);
}
# else /* !HAVE__ADJTIMEX */
diff --git a/contrib/ntp/include/ntp_syslog.h b/contrib/ntp/include/ntp_syslog.h
index 8e47c5673982..38021e251682 100644
--- a/contrib/ntp/include/ntp_syslog.h
+++ b/contrib/ntp/include/ntp_syslog.h
@@ -5,10 +5,6 @@
#ifndef NTP_SYSLOG_H
#define NTP_SYSLOG_H
-#ifdef GIZMO
-# include "gizmo_syslog.h"
-#else /* !GIZMO */
-
# ifdef VMS
extern void msyslog();
# else
@@ -16,11 +12,8 @@ extern void msyslog();
# include <syslog.h>
# endif
# endif /* VMS */
-
# include <stdio.h>
-#endif /* GIZMO */
-
extern int syslogit;
extern FILE *syslog_file;
diff --git a/contrib/ntp/include/ntp_tty.h b/contrib/ntp/include/ntp_tty.h
new file mode 100644
index 000000000000..3e12c8d3ea7f
--- /dev/null
+++ b/contrib/ntp/include/ntp_tty.h
@@ -0,0 +1,68 @@
+/*
+ * ntp_tty.h - header file for serial lines handling
+ */
+
+#ifndef NTP_TTY_H
+#define NTP_TTY_H
+
+#if defined(HAVE_BSD_TTYS)
+#include <sgtty.h>
+#define TTY struct sgttyb
+#endif /* HAVE_BSD_TTYS */
+
+#if defined(HAVE_SYSV_TTYS)
+#include <termio.h>
+#define TTY struct termio
+#ifndef tcsetattr
+#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)
+#endif
+#ifndef TCSANOW
+#define TCSANOW TCSETA
+#endif
+#ifndef TCIFLUSH
+#define TCIFLUSH 0
+#endif
+#ifndef TCOFLUSH
+#define TCOFLUSH 1
+#endif
+#ifndef TCIOFLUSH
+#define TCIOFLUSH 2
+#endif
+#ifndef tcflush
+#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)
+#endif
+#endif /* HAVE_SYSV_TTYS */
+
+#if defined(HAVE_TERMIOS)
+# ifdef TERMIOS_NEEDS__SVID3
+# define _SVID3
+# endif
+# include <termios.h>
+# ifdef TERMIOS_NEEDS__SVID3
+# undef _SVID3
+# endif
+#define TTY struct termios
+#endif
+
+#if defined(HAVE_SYS_MODEM_H)
+#include <sys/modem.h>
+#endif
+
+#if !defined(SYSV_TTYS) && !defined(STREAM) & !defined(BSD_TTYS)
+#define BSD_TTYS
+#endif /* SYSV_TTYS STREAM BSD_TTYS */
+
+/*
+ * Line discipline flags. These require line discipline or streams
+ * modules to be installed/loaded in the kernel. If specified, but not
+ * installed, the code runs as if unspecified.
+ */
+#define LDISC_STD 0x0 /* standard */
+#define LDISC_CLK 0x1 /* tty_clk \n intercept */
+#define LDISC_CLKPPS 0x2 /* tty_clk \377 intercept */
+#define LDISC_ACTS 0x4 /* tty_clk #* intercept */
+#define LDISC_CHU 0x8 /* depredated */
+#define LDISC_PPS 0x10 /* ppsclock, ppsapi */
+#define LDISC_RAW 0x20 /* raw binary */
+
+#endif /* NTP_TTY_H */
diff --git a/contrib/ntp/include/ntp_types.h b/contrib/ntp/include/ntp_types.h
index 820c72aeedd1..348e95ec162d 100644
--- a/contrib/ntp/include/ntp_types.h
+++ b/contrib/ntp/include/ntp_types.h
@@ -65,5 +65,9 @@ typedef unsigned int u_int;
# include "Bletch: what's 32 bits on this machine?"
#endif /* not sizeof(int) == 4 */
+typedef unsigned short associd_t; /* association ID */
+typedef u_int32 keyid_t; /* cryptographic key ID */
+typedef u_int32 tstamp_t; /* NTP seconds timestamp */
+
#endif /* _NTP_TYPES_ */
diff --git a/contrib/ntp/include/ntp_unixtime.h b/contrib/ntp/include/ntp_unixtime.h
index 9dd23f0e8eda..bdc080e6edd2 100644
--- a/contrib/ntp/include/ntp_unixtime.h
+++ b/contrib/ntp/include/ntp_unixtime.h
@@ -5,8 +5,6 @@
#include "ntp_types.h"
-#include <sys/time.h>
-
/* gettimeofday() takes two args in BSD and only one in SYSV */
# if defined(HAVE_SYS_TIMERS_H) && defined(HAVE_GETCLOCK)
# include <sys/timers.h>
diff --git a/contrib/ntp/include/ntpd.h b/contrib/ntp/include/ntpd.h
index 1a83d6eb0a6c..d3db2fbbd9b0 100644
--- a/contrib/ntp/include/ntpd.h
+++ b/contrib/ntp/include/ntpd.h
@@ -11,6 +11,7 @@
#include "recvbuff.h"
#define MAXINTERFACES 512
+#define MAXFILENAME 128 /* maximum length of a file name */
#ifdef SYS_WINNT
#define exit service_exit
@@ -25,7 +26,6 @@ void worker_thread (void *);
#endif /* SYS_WINNT */
/* ntp_config.c */
-extern void getstartup P((int, char **));
extern void getconfig P((int, char **));
/* ntp_config.c */
@@ -71,11 +71,13 @@ extern void set_var P((struct ctl_var **, const char *, unsigned long, int))
extern void set_sys_var P((char *, unsigned long, int));
/* ntp_intres.c */
+extern void ntp_res_name P((u_int32, u_short));
+extern void ntp_res_recv P((void));
extern void ntp_intres P((void));
/* ntp_io.c */
-extern struct interface *findbcastinter P((struct sockaddr_in *));
extern struct interface *findinterface P((struct sockaddr_in *));
+extern struct interface *findbcastinter P((struct sockaddr_in *));
extern void init_io P((void));
extern void input_handler P((l_fp *));
@@ -110,6 +112,7 @@ extern void init_loopfilter P((void));
extern int local_clock P((struct peer *, double, double));
extern void adj_host_clock P((void));
extern void loop_config P((int, double));
+extern void huffpuff P((void));
/* ntp_monitor.c */
extern void init_mon P((void));
@@ -121,23 +124,26 @@ extern void ntp_monitor P((struct recvbuf *));
extern void init_peer P((void));
extern struct peer *findexistingpeer P((struct sockaddr_in *, struct peer *, int));
extern struct peer *findpeer P((struct sockaddr_in *, struct interface *, int, int, int *));
-extern struct peer *findpeerbyassoc P((int));
-extern struct peer *newpeer P((struct sockaddr_in *, struct interface *, int, int, int, int, int, u_long));
+extern struct peer *findpeerbyassoc P((u_int));
+extern struct peer *newpeer P((struct sockaddr_in *, struct interface *, int, int, int, int, u_int, u_int, int, keyid_t));
extern void peer_all_reset P((void));
extern void peer_clr_stats P((void));
-extern struct peer *peer_config P((struct sockaddr_in *, struct interface *, int, int, int, int, int, int, u_long));
+extern struct peer *peer_config P((struct sockaddr_in *, struct interface *, int, int, int, int, u_int, int, keyid_t, u_char *));
extern void peer_reset P((struct peer *));
extern int peer_unconfig P((struct sockaddr_in *, struct interface *, int));
extern void unpeer P((struct peer *));
-extern void key_expire_all P((void));
-extern struct peer *findmanycastpeer P((l_fp *));
-extern void peer_config_manycast P((struct peer *, struct peer *));
+extern void clear_all P((void));
+#ifdef AUTOKEY
+extern void expire_all P((void));
+#endif /* AUTOKEY */
+extern struct peer *findmanycastpeer P((struct recvbuf *));
+extern void resetmanycast P((void));
/* ntp_proto.c */
extern void transmit P((struct peer *));
extern void receive P((struct recvbuf *));
extern void peer_clear P((struct peer *));
-extern int process_packet P((struct peer *, struct pkt *, l_fp *));
+extern void process_packet P((struct peer *, struct pkt *, l_fp *));
extern void clock_select P((void));
/*
@@ -176,13 +182,17 @@ extern void hack_restrict P((int, struct sockaddr_in *, struct sockaddr_in *, in
extern void init_timer P((void));
extern void timer P((void));
extern void timer_clr_stats P((void));
+#ifdef AUTOKEY
+extern char *sys_hostname;
+extern l_fp sys_revoketime;
+#endif /* AUTOKEY */
/* ntp_util.c */
extern void init_util P((void));
extern void hourly_stats P((void));
extern void stats_config P((int, char *));
extern void record_peer_stats P((struct sockaddr_in *, int, double, double, double, double));
-extern void record_loop_stats P((void));
+extern void record_loop_stats P((double, double, double, double, int));
extern void record_clock_stats P((struct sockaddr_in *, const char *));
extern void record_raw_stats P((struct sockaddr_in *, struct sockaddr_in *, l_fp *, l_fp *, l_fp *, l_fp *));
@@ -203,7 +213,7 @@ extern int config_priority;
struct ctl_trap;
extern struct ctl_trap ctl_trap[];
extern int num_ctl_traps;
-extern u_long ctl_auth_keyid; /* keyid used for authenticating write requests */
+extern keyid_t ctl_auth_keyid; /* keyid used for authenticating write requests */
/*
* Statistic counters to keep track of requests and responses.
@@ -225,7 +235,7 @@ extern u_long numctlbadop; /* bad op code found in packet */
extern u_long numasyncmsgs; /* number of async messages we've sent */
/* ntp_intres.c */
-extern u_long req_keyid; /* request keyid */
+extern keyid_t req_keyid; /* request keyid */
extern char * req_file; /* name of the file with configuration info */
/*
@@ -244,8 +254,8 @@ extern u_long io_timereset; /* time counters were reset */
/*
* Interface stuff
*/
-extern struct interface *any_interface; /* pointer to default interface */
-extern struct interface *loopback_interface; /* point to loopback interface */
+extern struct interface *any_interface; /* default interface */
+extern struct interface *loopback_interface; /* loopback interface */
/*
* File descriptor masks etc. for call to select
@@ -254,10 +264,16 @@ extern fd_set activefds;
extern int maxactivefd;
/* ntp_loopfilter.c */
-extern double drift_comp; /* clock frequency (ppm) */
-extern double clock_stability; /* clock stability (ppm) */
-extern double clock_max; /* max offset allowed before step (s) */
+extern double drift_comp; /* clock frequency (s/s) */
+extern double clock_stability; /* clock stability (s/s) */
+extern double clock_max; /* max offset before step (s) */
+extern double clock_panic; /* max offset before panic (s) */
+extern double clock_phi; /* dispersion rate (s/s) */
+extern double clock_minstep; /* step timeout (s) */
extern u_long pps_control; /* last pps sample time */
+#ifdef KERNEL_PLL
+extern int pll_status; /* status bits for kernel pll */
+#endif /* KERNEL_PLL */
/*
* Clock state machine control flags
@@ -265,21 +281,26 @@ extern u_long pps_control; /* last pps sample time */
extern int ntp_enable; /* clock discipline enabled */
extern int pll_control; /* kernel support available */
extern int kern_enable; /* kernel support enabled */
+extern int pps_enable; /* kernel PPS discipline enabled */
extern int ext_enable; /* external clock enabled */
-extern int pps_update; /* pps update valid */
-extern int allow_set_backward; /* step corrections allowed */
-extern int correct_any; /* corrections > 1000 s allowed */
+extern int cal_enable; /* refclock calibrate enable */
+extern int allow_step; /* allow step correction */
+extern int allow_panic; /* allow panic correction */
+extern int mode_ntpdate; /* exit on first clock set */
+extern int peer_ntpdate; /* count of ntpdate peers */
/*
* Clock state machine variables
*/
-extern u_char sys_poll; /* log2 of system poll interval */
+extern u_char sys_poll; /* system poll interval (log2 s) */
+extern u_char sys_minpoll; /* min system poll interval (log2 s) */
extern int state; /* clock discipline state */
extern int tc_counter; /* poll-adjust counter */
extern u_long last_time; /* time of last clock update (s) */
extern double last_offset; /* last clock offset (s) */
extern double allan_xpt; /* Allan intercept (s) */
-extern double sys_error; /* system standard error (s) */
+extern double sys_error; /* system RMS error (s) */
+extern double sys_jitter; /* system RMS jitter (s) */
/* ntp_monitor.c */
extern struct mon_data mon_mru_list;
@@ -317,6 +338,7 @@ extern double sys_rootdispersion; /* dispersion of system clock */
extern u_int32 sys_refid; /* reference source for local clock */
extern l_fp sys_reftime; /* time we were last updated */
extern struct peer *sys_peer; /* our current peer */
+extern struct peer *sys_prefer; /* our cherished peer */
extern u_long sys_automax; /* maximum session key lifetime */
/*
@@ -326,7 +348,7 @@ extern int sys_bclient; /* we set our time to broadcasts */
extern double sys_bdelay; /* broadcast client default delay */
extern int sys_authenticate; /* requre authentication for config */
extern l_fp sys_authdelay; /* authentication delay */
-extern u_long sys_private; /* private value for session seed */
+extern keyid_t sys_private; /* private value for session seed */
extern int sys_manycastserver; /* 1 => respond to manycast client pkts */
/*
@@ -350,7 +372,7 @@ extern int fdpps; /* pps file descriptor */
#endif
/* ntp_request.c */
-extern u_long info_auth_keyid; /* keyid used to authenticate requests */
+extern keyid_t info_auth_keyid; /* keyid used to authenticate requests */
/* ntp_restrict.c */
extern struct restrictlist *restrictlist; /* the restriction list */