summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/util
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/util')
-rw-r--r--contrib/ntp/util/Makefile.am9
-rw-r--r--contrib/ntp/util/Makefile.in384
-rw-r--r--contrib/ntp/util/hist.c10
-rw-r--r--contrib/ntp/util/jitter.c3
-rw-r--r--contrib/ntp/util/kern.c1
-rw-r--r--contrib/ntp/util/ntp-genkeys.c1042
-rw-r--r--contrib/ntp/util/ntptime.c69
-rw-r--r--contrib/ntp/util/precision.c5
-rw-r--r--contrib/ntp/util/tickadj.c8
-rw-r--r--contrib/ntp/util/timetrim.c10
10 files changed, 1327 insertions, 214 deletions
diff --git a/contrib/ntp/util/Makefile.am b/contrib/ntp/util/Makefile.am
index 4d70318..d9a85f3 100644
--- a/contrib/ntp/util/Makefile.am
+++ b/contrib/ntp/util/Makefile.am
@@ -1,10 +1,13 @@
#AUTOMAKE_OPTIONS = ../ansi2knr no-dependencies
AUTOMAKE_OPTIONS = ansi2knr
-bin_PROGRAMS = @MAKE_TICKADJ@ @MAKE_NTPTIME@
+bin_PROGRAMS = @MAKE_NTPTIME@ @MAKE_TICKADJ@ @MAKE_TIMETRIM@ ntp-genkeys
EXTRA_PROGRAMS = byteorder hist jitter kern longsize ntptime \
-precision tickadj testrs6000 timetrim sht
+precision sht testrs6000 tickadj timetrim
-INCLUDES = -I$(top_srcdir)/include
+ntp_genkeys_LDADD = ../ntpd/ntp_config$U.o ../libntp/libntp.a $(LIBRSAREF)
+ntp_genkeys_DEPENDENCIES = ../ntpd/ntp_config$U.o ../libntp/libntp.a $(LIBRSAREF)
+
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/librsaref
# LDADD might need RESLIB and ADJLIB
LDADD = ../libntp/libntp.a
#EXTRA_DIST = README TAGS
diff --git a/contrib/ntp/util/Makefile.in b/contrib/ntp/util/Makefile.in
index bf37e56..c10e3a0 100644
--- a/contrib/ntp/util/Makefile.in
+++ b/contrib/ntp/util/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,190 +91,192 @@ 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 = ../ansi2knr no-dependencies
AUTOMAKE_OPTIONS = ansi2knr
-bin_PROGRAMS = @MAKE_TICKADJ@ @MAKE_NTPTIME@
+bin_PROGRAMS = @MAKE_NTPTIME@ @MAKE_TICKADJ@ @MAKE_TIMETRIM@ ntp-genkeys
EXTRA_PROGRAMS = byteorder hist jitter kern longsize ntptime \
-precision tickadj testrs6000 timetrim sht
+precision sht testrs6000 tickadj timetrim
+
+ntp_genkeys_LDADD = ../ntpd/ntp_config$U.o ../libntp/libntp.a $(LIBRSAREF)
+ntp_genkeys_DEPENDENCIES = ../ntpd/ntp_config$U.o ../libntp/libntp.a $(LIBRSAREF)
-INCLUDES = -I$(top_srcdir)/include
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/librsaref
# LDADD might need RESLIB and ADJLIB
LDADD = ../libntp/libntp.a
#EXTRA_DIST = README TAGS
EXTRA_DIST =
ETAGS_ARGS = Makefile.am
+EXEEXT =
+OBJEXT = o
subdir = util
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../config.h
-CONFIG_CLEAN_FILES =
-PROGRAMS = $(bin_PROGRAMS)
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+EXTRA_PROGRAMS = byteorder$(EXEEXT) hist$(EXEEXT) jitter$(EXEEXT) \
+kern$(EXEEXT) longsize$(EXEEXT) ntptime$(EXEEXT) precision$(EXEEXT) \
+sht$(EXEEXT) testrs6000$(EXEEXT) tickadj$(EXEEXT) timetrim$(EXEEXT)
+bin_PROGRAMS = @MAKE_NTPTIME@ @MAKE_TICKADJ@ @MAKE_TIMETRIM@ \
+ntp-genkeys$(EXEEXT)
+PROGRAMS = $(bin_PROGRAMS)
-DEFS = @DEFS@ -I. -I$(srcdir) -I..
+DEFS = @DEFS@ -I. -I$(srcdir) -I$(top_builddir)
CPPFLAGS = @CPPFLAGS@
LIBS = @LIBS@
ANSI2KNR = @ANSI2KNR@
byteorder_SOURCES = byteorder.c
-byteorder_OBJECTS = byteorder$U.o
+byteorder_OBJECTS = byteorder$U.$(OBJEXT)
byteorder_LDADD = $(LDADD)
-byteorder_DEPENDENCIES = ../libntp/libntp.a
+byteorder_DEPENDENCIES = ../libntp/libntp.a
byteorder_LDFLAGS =
hist_SOURCES = hist.c
-hist_OBJECTS = hist$U.o
+hist_OBJECTS = hist$U.$(OBJEXT)
hist_LDADD = $(LDADD)
-hist_DEPENDENCIES = ../libntp/libntp.a
+hist_DEPENDENCIES = ../libntp/libntp.a
hist_LDFLAGS =
jitter_SOURCES = jitter.c
-jitter_OBJECTS = jitter$U.o
+jitter_OBJECTS = jitter$U.$(OBJEXT)
jitter_LDADD = $(LDADD)
-jitter_DEPENDENCIES = ../libntp/libntp.a
+jitter_DEPENDENCIES = ../libntp/libntp.a
jitter_LDFLAGS =
kern_SOURCES = kern.c
-kern_OBJECTS = kern$U.o
+kern_OBJECTS = kern$U.$(OBJEXT)
kern_LDADD = $(LDADD)
-kern_DEPENDENCIES = ../libntp/libntp.a
+kern_DEPENDENCIES = ../libntp/libntp.a
kern_LDFLAGS =
longsize_SOURCES = longsize.c
-longsize_OBJECTS = longsize$U.o
+longsize_OBJECTS = longsize$U.$(OBJEXT)
longsize_LDADD = $(LDADD)
-longsize_DEPENDENCIES = ../libntp/libntp.a
+longsize_DEPENDENCIES = ../libntp/libntp.a
longsize_LDFLAGS =
+ntp_genkeys_SOURCES = ntp-genkeys.c
+ntp_genkeys_OBJECTS = ntp-genkeys$U.$(OBJEXT)
+ntp_genkeys_LDFLAGS =
ntptime_SOURCES = ntptime.c
-ntptime_OBJECTS = ntptime$U.o
+ntptime_OBJECTS = ntptime$U.$(OBJEXT)
ntptime_LDADD = $(LDADD)
-ntptime_DEPENDENCIES = ../libntp/libntp.a
+ntptime_DEPENDENCIES = ../libntp/libntp.a
ntptime_LDFLAGS =
precision_SOURCES = precision.c
-precision_OBJECTS = precision$U.o
+precision_OBJECTS = precision$U.$(OBJEXT)
precision_LDADD = $(LDADD)
-precision_DEPENDENCIES = ../libntp/libntp.a
+precision_DEPENDENCIES = ../libntp/libntp.a
precision_LDFLAGS =
sht_SOURCES = sht.c
-sht_OBJECTS = sht$U.o
+sht_OBJECTS = sht$U.$(OBJEXT)
sht_LDADD = $(LDADD)
-sht_DEPENDENCIES = ../libntp/libntp.a
+sht_DEPENDENCIES = ../libntp/libntp.a
sht_LDFLAGS =
testrs6000_SOURCES = testrs6000.c
-testrs6000_OBJECTS = testrs6000$U.o
+testrs6000_OBJECTS = testrs6000$U.$(OBJEXT)
testrs6000_LDADD = $(LDADD)
-testrs6000_DEPENDENCIES = ../libntp/libntp.a
+testrs6000_DEPENDENCIES = ../libntp/libntp.a
testrs6000_LDFLAGS =
tickadj_SOURCES = tickadj.c
-tickadj_OBJECTS = tickadj$U.o
+tickadj_OBJECTS = tickadj$U.$(OBJEXT)
tickadj_LDADD = $(LDADD)
-tickadj_DEPENDENCIES = ../libntp/libntp.a
+tickadj_DEPENDENCIES = ../libntp/libntp.a
tickadj_LDFLAGS =
timetrim_SOURCES = timetrim.c
-timetrim_OBJECTS = timetrim$U.o
+timetrim_OBJECTS = timetrim$U.$(OBJEXT)
timetrim_LDADD = $(LDADD)
-timetrim_DEPENDENCIES = ../libntp/libntp.a
+timetrim_DEPENDENCIES = ../libntp/libntp.a
timetrim_LDFLAGS =
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-DIST_SOURCES = byteorder.c hist.c jitter.c kern.c longsize.c ntptime.c \
-precision.c sht.c testrs6000.c tickadj.c timetrim.c
-DIST_COMMON = README Makefile.am Makefile.in ansi2knr.1 ansi2knr.c
-
-
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-
-GZIP_ENV = --best
+DIST_SOURCES = byteorder.c hist.c jitter.c kern.c longsize.c \
+ntp-genkeys.c ntptime.c precision.c sht.c testrs6000.c tickadj.c \
+timetrim.c
depcomp = $(SHELL) $(top_srcdir)/depcomp
-DEP_FILES = @AMDEP@ $(DEPDIR)/byteorder$U.Po $(DEPDIR)/hist$U.Po \
-$(DEPDIR)/jitter$U.Po $(DEPDIR)/kern$U.Po $(DEPDIR)/longsize$U.Po \
-$(DEPDIR)/ntptime$U.Po $(DEPDIR)/precision$U.Po $(DEPDIR)/sht$U.Po \
-$(DEPDIR)/testrs6000$U.Po $(DEPDIR)/tickadj$U.Po \
-$(DEPDIR)/timetrim$U.Po
-SOURCES = byteorder.c hist.c jitter.c kern.c longsize.c ntptime.c precision.c sht.c testrs6000.c tickadj.c timetrim.c
-OBJECTS = byteorder$U.o hist$U.o jitter$U.o kern$U.o longsize$U.o ntptime$U.o precision$U.o sht$U.o testrs6000$U.o tickadj$U.o timetrim$U.o
-
-all: all-redirect
-.SUFFIXES:
-.SUFFIXES: .c .o
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
- cd $(top_srcdir) && $(AUTOMAKE) --gnu util/Makefile
-
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
- cd $(top_builddir) \
- && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+@AMDEP@DEP_FILES = $(DEPDIR)/byteorder$U.Po $(DEPDIR)/hist$U.Po \
+@AMDEP@ $(DEPDIR)/jitter$U.Po $(DEPDIR)/kern$U.Po \
+@AMDEP@ $(DEPDIR)/longsize$U.Po $(DEPDIR)/ntp-genkeys$U.Po \
+@AMDEP@ $(DEPDIR)/ntptime$U.Po $(DEPDIR)/precision$U.Po \
+@AMDEP@ $(DEPDIR)/sht$U.Po $(DEPDIR)/testrs6000$U.Po \
+@AMDEP@ $(DEPDIR)/tickadj$U.Po $(DEPDIR)/timetrim$U.Po
+DIST_COMMON = README Makefile.am Makefile.in ansi2knr.1 ansi2knr.c
+SOURCES = byteorder.c hist.c jitter.c kern.c longsize.c ntp-genkeys.c ntptime.c precision.c sht.c testrs6000.c tickadj.c timetrim.c
+OBJECTS = byteorder$U.$(OBJEXT) hist$U.$(OBJEXT) jitter$U.$(OBJEXT) kern$U.$(OBJEXT) longsize$U.$(OBJEXT) ntp-genkeys$U.$(OBJEXT) ntptime$U.$(OBJEXT) precision$U.$(OBJEXT) sht$U.$(OBJEXT) testrs6000$U.$(OBJEXT) tickadj$U.$(OBJEXT) timetrim$U.$(OBJEXT)
-mostlyclean-binPROGRAMS:
-
-clean-binPROGRAMS:
- -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+all: all-am
-distclean-binPROGRAMS:
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
-maintainer-clean-binPROGRAMS:
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu util/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) && \
+ CONFIG_HEADERS= CONFIG_LINKS= \
+ CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \
- f="`echo $$p|sed -e 's/$(EXEEXT)$$//' -e '$(transform)' -e 's/$$/$(EXEEXT)/'`"; \
- echo " $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/$$f"; \
- $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/$$f; \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f"; \
+ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
- f="`echo $$p|sed -e 's/$(EXEEXT)$$//' -e '$(transform)' -e 's/$$/$(EXEEXT)/'`"; \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
rm -f $(DESTDIR)$(bindir)/$$f; \
done
-mostlyclean-compile:
- -rm -f *.o core *.core
+clean-binPROGRAMS:
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
-clean-compile:
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT) core *.core
distclean-compile:
-rm -f *.tab.c
-maintainer-clean-compile:
-
-mostlyclean-krextra:
-
clean-krextra:
-rm -f ansi2knr
-
-distclean-krextra:
-
-maintainer-clean-krextra:
-ansi2knr: ansi2knr.o
- $(LINK) ansi2knr.o $(LIBS)
-ansi2knr.o: $(CONFIG_HEADER)
+ansi2knr: ansi2knr.$(OBJEXT)
+ $(LINK) ansi2knr.$(OBJEXT) $(LIBS)
+ansi2knr.$(OBJEXT): $(CONFIG_HEADER)
mostlyclean-kr:
-rm -f *_.c
-clean-kr:
-
-distclean-kr:
-
-maintainer-clean-kr:
-
byteorder: $(byteorder_OBJECTS) $(byteorder_DEPENDENCIES)
@rm -f byteorder
$(LINK) $(byteorder_LDFLAGS) $(byteorder_OBJECTS) $(byteorder_LDADD) $(LIBS)
@@ -290,6 +297,10 @@ longsize: $(longsize_OBJECTS) $(longsize_DEPENDENCIES)
@rm -f longsize
$(LINK) $(longsize_LDFLAGS) $(longsize_OBJECTS) $(longsize_LDADD) $(LIBS)
+ntp-genkeys: $(ntp_genkeys_OBJECTS) $(ntp_genkeys_DEPENDENCIES)
+ @rm -f ntp-genkeys
+ $(LINK) $(ntp_genkeys_LDFLAGS) $(ntp_genkeys_OBJECTS) $(ntp_genkeys_LDADD) $(LIBS)
+
ntptime: $(ntptime_OBJECTS) $(ntptime_DEPENDENCIES)
@rm -f ntptime
$(LINK) $(ntptime_LDFLAGS) $(ntptime_OBJECTS) $(ntptime_LDADD) $(LIBS)
@@ -323,6 +334,8 @@ kern_.c: kern.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/kern.c; then echo $(srcdir)/kern.c; else echo kern.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > kern_.c
longsize_.c: longsize.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/longsize.c; then echo $(srcdir)/longsize.c; else echo longsize.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > longsize_.c
+ntp-genkeys_.c: ntp-genkeys.c $(ANSI2KNR)
+ $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp-genkeys.c; then echo $(srcdir)/ntp-genkeys.c; else echo ntp-genkeys.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > ntp-genkeys_.c
ntptime_.c: ntptime.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntptime.c; then echo $(srcdir)/ntptime.c; else echo ntptime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > ntptime_.c
precision_.c: precision.c $(ANSI2KNR)
@@ -335,8 +348,10 @@ tickadj_.c: tickadj.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tickadj.c; then echo $(srcdir)/tickadj.c; else echo tickadj.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > tickadj_.c
timetrim_.c: timetrim.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/timetrim.c; then echo $(srcdir)/timetrim.c; else echo timetrim.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > timetrim_.c
-byteorder_.o hist_.o jitter_.o kern_.o longsize_.o ntptime_.o \
-precision_.o sht_.o testrs6000_.o tickadj_.o timetrim_.o : $(ANSI2KNR)
+byteorder_.$(OBJEXT) hist_.$(OBJEXT) jitter_.$(OBJEXT) kern_.$(OBJEXT) \
+longsize_.$(OBJEXT) ntp-genkeys_.$(OBJEXT) ntptime_.$(OBJEXT) \
+precision_.$(OBJEXT) sht_.$(OBJEXT) testrs6000_.$(OBJEXT) \
+tickadj_.$(OBJEXT) timetrim_.$(OBJEXT) : $(ANSI2KNR)
tags: TAGS
@@ -347,9 +362,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`; \
@@ -362,84 +377,82 @@ 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:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-distdir: $(DISTFILES)
- @for file in $(DISTFILES); do \
- d=$(srcdir); \
- if test -d $$d/$$file; then \
- cp -pR $$d/$$file $(distdir); \
- else \
- test -f $(distdir)/$$file \
- || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
- || cp -p $$d/$$file $(distdir)/$$file || :; \
- fi; \
- done
-
-@AMDEP@include $(DEPDIR)/byteorder$U.Po
-@AMDEP@include $(DEPDIR)/hist$U.Po
-@AMDEP@include $(DEPDIR)/jitter$U.Po
-@AMDEP@include $(DEPDIR)/kern$U.Po
-@AMDEP@include $(DEPDIR)/longsize$U.Po
-@AMDEP@include $(DEPDIR)/ntptime$U.Po
-@AMDEP@include $(DEPDIR)/precision$U.Po
-@AMDEP@include $(DEPDIR)/sht$U.Po
-@AMDEP@include $(DEPDIR)/testrs6000$U.Po
-@AMDEP@include $(DEPDIR)/tickadj$U.Po
-@AMDEP@include $(DEPDIR)/timetrim$U.Po
-
-mostlyclean-depend:
-
-clean-depend:
+@AMDEP@@_am_include@ $(DEPDIR)/byteorder$U.Po
+@AMDEP@@_am_include@ $(DEPDIR)/hist$U.Po
+@AMDEP@@_am_include@ $(DEPDIR)/jitter$U.Po
+@AMDEP@@_am_include@ $(DEPDIR)/kern$U.Po
+@AMDEP@@_am_include@ $(DEPDIR)/longsize$U.Po
+@AMDEP@@_am_include@ $(DEPDIR)/ntp-genkeys$U.Po
+@AMDEP@@_am_include@ $(DEPDIR)/ntptime$U.Po
+@AMDEP@@_am_include@ $(DEPDIR)/precision$U.Po
+@AMDEP@@_am_include@ $(DEPDIR)/sht$U.Po
+@AMDEP@@_am_include@ $(DEPDIR)/testrs6000$U.Po
+@AMDEP@@_am_include@ $(DEPDIR)/tickadj$U.Po
+@AMDEP@@_am_include@ $(DEPDIR)/timetrim$U.Po
distclean-depend:
-rm -rf $(DEPDIR)
-maintainer-clean-depend:
-
@AMDEP@CCDEPMODE = @CCDEPMODE@
.c.o:
@AMDEP@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- $(COMPILE) -c -o $@ $<
+ $(COMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$<
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
+.c.obj:
+@AMDEP@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ $(COMPILE) -c -o $@ `cygpath -w $<`
+
+
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+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) \
+ || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
check-am: all-am
check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am: install-binPROGRAMS
-install-exec: install-exec-am
+all-am: Makefile $(ANSI2KNR) $(PROGRAMS)
-install-data-am:
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+
+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-binPROGRAMS
-uninstall: uninstall-am
-all-am: Makefile $(ANSI2KNR) $(PROGRAMS)
-all-redirect: all-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
-installdirs:
- $(mkinstalldirs) $(DESTDIR)$(bindir)
+installcheck: installcheck-am
+
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ INSTALL_PROGRAM_ENV='$(INSTALL_STRIP_PROGRAM_ENV)' install
mostlyclean-generic:
@@ -450,47 +463,56 @@ 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-binPROGRAMS mostlyclean-compile \
- mostlyclean-krextra mostlyclean-kr mostlyclean-tags \
- mostlyclean-depend mostlyclean-generic
+clean: clean-am
-mostlyclean: mostlyclean-am
+clean-am: clean-binPROGRAMS clean-generic clean-krextra mostlyclean-am
-clean-am: clean-binPROGRAMS clean-compile clean-krextra clean-kr \
- clean-tags clean-depend clean-generic mostlyclean-am
+distclean: distclean-am
-clean: clean-am
+distclean-am: clean-am distclean-compile distclean-depend \
+ distclean-generic distclean-tags
-distclean-am: distclean-binPROGRAMS distclean-compile distclean-krextra \
- distclean-kr distclean-tags distclean-depend \
- distclean-generic clean-am
+dvi:
-distclean: distclean-am
+dvi-am:
-maintainer-clean-am: maintainer-clean-binPROGRAMS \
- maintainer-clean-compile maintainer-clean-krextra \
- maintainer-clean-kr maintainer-clean-tags \
- maintainer-clean-depend 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-binPROGRAMS
+
+install-info:
+
+install-man:
+
+installcheck-am:
maintainer-clean: maintainer-clean-am
-.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
-maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
-mostlyclean-compile distclean-compile clean-compile \
-maintainer-clean-compile mostlyclean-krextra distclean-krextra \
-clean-krextra maintainer-clean-krextra mostlyclean-kr distclean-kr \
-clean-kr maintainer-clean-kr tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir mostlyclean-depend \
-distclean-depend clean-depend maintainer-clean-depend 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-compile mostlyclean-generic mostlyclean-kr
+
+uninstall-am: uninstall-binPROGRAMS
+
+.PHONY: all all-am check check-am clean clean-binPROGRAMS clean-generic \
+ clean-krextra distclean distclean-compile distclean-depend \
+ distclean-generic distclean-tags distdir dvi dvi-am info \
+ info-am install install-am install-binPROGRAMS 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-compile mostlyclean-generic \
+ mostlyclean-kr tags uninstall uninstall-am \
+ uninstall-binPROGRAMS
../libntp/libntp.a:
diff --git a/contrib/ntp/util/hist.c b/contrib/ntp/util/hist.c
index ee4e93a..b02d73f 100644
--- a/contrib/ntp/util/hist.c
+++ b/contrib/ntp/util/hist.c
@@ -8,14 +8,14 @@
*/
#ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
#endif
-#include <sys/time.h>
-#include <stdio.h>
-#include <stdlib.h>
#include "ntp_types.h"
+#include <stdio.h>
+#include <stdlib.h>
+
#define NBUF 100001 /* size of basic histogram */
#define NSRT 20000 /* size of overflow histogram */
#define NCNT (600 * 1000000) /* sample interval (us) */
@@ -79,7 +79,7 @@ main(
}
if (n == 0)
return;
- qsort((char *)ovfl, (int)n, sizeof(long), col);
+ qsort((char *)ovfl, (size_t)n, sizeof(long), col);
w = 0;
j = 0;
for (i = 0; i < n; i++) {
diff --git a/contrib/ntp/util/jitter.c b/contrib/ntp/util/jitter.c
index 79f4757..462fe12 100644
--- a/contrib/ntp/util/jitter.c
+++ b/contrib/ntp/util/jitter.c
@@ -6,8 +6,9 @@
* analysis. From this you can determine the jitter and if the clock ever
* runs backwards.
*/
-#include <sys/time.h>
+
#include <stdio.h>
+#include <sys/time.h>
#define NBUF 20002
diff --git a/contrib/ntp/util/kern.c b/contrib/ntp/util/kern.c
index 37d9257..b193d6f 100644
--- a/contrib/ntp/util/kern.c
+++ b/contrib/ntp/util/kern.c
@@ -3,6 +3,7 @@
* actual code segments from modified kernel distributions for SunOS,
* Ultrix and OSF/1 kernels. These segments do not use any licensed code.
*/
+
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/contrib/ntp/util/ntp-genkeys.c b/contrib/ntp/util/ntp-genkeys.c
new file mode 100644
index 0000000..fd85121
--- /dev/null
+++ b/contrib/ntp/util/ntp-genkeys.c
@@ -0,0 +1,1042 @@
+/*
+ * Program to generate MD5 and RSA keys for NTP clients and servers
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_NETINFO
+#include <netinfo/ni.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_stdlib.h"
+#include "ntp_string.h"
+#include "ntp_filegen.h"
+#include "ntp_unixtime.h"
+#include "ntp_config.h"
+#include "ntp_cmdargs.h"
+
+#include <stdio.h>
+#include <unistd.h>
+#include <limits.h> /* PATH_MAX */
+#include <sys/stat.h>
+
+#ifdef PUBKEY
+# include "ntp_crypto.h"
+#endif
+
+#ifndef PATH_MAX
+# ifdef _POSIX_PATH_MAX
+# define PATH_MAX _POSIX_PATH_MAX
+# else
+# define PATH_MAX 255
+# endif
+#endif
+
+/*
+ * Cryptodefines
+ */
+#define MAXKEYLEN 1024 /* maximum encoded key length */
+#define MODULUSLEN 512 /* length of RSA modulus */
+#define PRIMELEN 512 /* length of D_H prime, generator */
+
+/*
+ * This program generates (up to) four files:
+ *
+ * ntp.keys containing the DES/MD5 private keys,
+ * ntpkey containing the RSA private key,
+ * ntpkey_HOST containing the RSA public key
+ * where HOST is the DNS name of the generating machine,
+ * ntpkey_dh containing the parameters for the Diffie-Hellman
+ * key-agreement algorithm.
+ *
+ * The files contain cryptographic values generated by the algorithms of
+ * the rsaref20 package and are in printable ASCII format. Since the
+ * algorythms are seeded by the system clock, each run of this program
+ * will produce a different outcome. There are no options or frills of
+ * any sort, although a number of options would seem to be appropriate.
+ * Waving this program in the breeze will no doubt bring a cast of
+ * thousands to wiggle the options this way and that for various useful
+ * purposes.
+ *
+ * The names of all files begin with "ntp" and end with an extension
+ * consisting of the seconds value of the current NTP timestamp, which
+ * appears in the form ".*". This provides a way to distinguish between
+ * key generations, since the host name and timestamp can be fetched by
+ * a client during operation.
+ *
+ * The ntp.keys.* file contains 16 MD5 keys. Each key consists of 16
+ * characters randomized over the ASCII 95-character printing subset.
+ * The file is read by the daemon at the location specified by the keys
+ * configuration file command and made visible only to root. An
+ * additional key consisting of a easily remembered password should be
+ * added by hand for use with the ntpdc program. The file must be
+ * distributed by secure means to other servers and clients sharing the
+ * same security compartment.
+ *
+ * The key identifiers for MD5 and DES keys must be less than 65536,
+ * although this program uses only the identifiers from 1 to 16. The key
+ * identifier for each association is specified as the key argument in
+ * the server or peer configuration file command.
+ *
+ * The ntpkey.* file contains the RSA private key. It is read by the
+ * daemon at the location specified by the private argument of the
+ * crypto configuration file command and made visible only to root.
+ * This file is useful only to the machine that generated it and never
+ * shared with any other daemon or application program.
+ *
+ * The ntpkey_host.* file contains the RSA public key, where host is the
+ * DNS name of the host that generated it. The file is read by the
+ * daemon at the location specified by the public argument to the server
+ * or peer configuration file command. This file can be widely
+ * distributed and stored without using secure means, since the data are
+ * public values.
+ *
+ * The ntp_dh.* file contains two Diffie-Hellman parameters, the prime
+ * modulus and the generator. The file is read by the daemon at the
+ * location specified by the dhparams argument of the crypto
+ * configuration file command. This file can be widely distributed and
+ * stored without using secure means, since the data are public values.
+ *
+ * The file formats all begin with two lines. The first line contains
+ * the file name and decimal timestamp, while the second contains the
+ * readable datestamp. Lines beginning with # are considered comments
+ * and ignored by the daemon. In the ntp.keys.* file, the next 16 lines
+ * contain the MD5 keys in order. In the ntpkey.* and ntpkey_host.*
+ * files, the next line contains the modulus length in bits followed by
+ * the key as a PEM encoded string. In the ntpkey_dh.* file, the next
+ * line contains the prime length in bytes followed by the prime as a
+ * PEM encoded string, and the next and final line contains the
+ * generator length in bytes followed by the generator as a PEM encoded
+ * string.
+ *
+ * Note: See the file ./source/rsaref.h in the rsaref20 package for
+ * explanation of return values, if necessary.
+ */
+
+
+extern char *config_file;
+
+#ifdef HAVE_NETINFO
+extern struct netinfo_config_state *config_netinfo;
+extern int check_netinfo;
+#endif /* HAVE_NETINFO */
+
+#ifdef SYS_WINNT
+char *alt_config_file;
+LPTSTR temp;
+char config_file_storage[PATH_MAX];
+char alt_config_file_storage[PATH_MAX];
+#endif /* SYS_WINNT */
+
+int make_dh = 0; /* Make D-H parameter file? */
+int make_md5 = 0; /* Make MD5 keyfile? */
+int make_rsa = 0; /* Make RSA pair? */
+int force = 0; /* Force the installation? */
+int here = 0; /* Put the files here (curdir)? */
+int nosymlinks = 0; /* Just create the (timestamped) files? */
+int memorex = 0; /* Are we live? */
+int trash = 0; /* Trash old files? */
+int errflag = 0;
+
+char *f1_keysdir = NTP_KEYSDIR;
+
+char *f1_keys; /* Visible MD5 key file name */
+char *f2_keys; /* timestamped */
+char *f3_keys; /* previous filename */
+
+char *f1_publickey;
+char *f2_publickey;
+char *f3_publickey;
+
+char *f1_privatekey;
+char *f2_privatekey;
+char *f3_privatekey;
+
+char *f1_dhparms;
+char *f2_dhparms;
+char *f3_dhparms;
+
+
+/* Stubs and hacks so we can link with ntp_config.o */
+u_long sys_automax; /* maximum session key lifetime */
+int sys_bclient; /* we set our time to broadcasts */
+int sys_manycastserver; /* 1 => respond to manycast client pkts */
+u_long client_limit_period;
+char * req_file; /* name of the file with configuration info */
+keyid_t ctl_auth_keyid; /* keyid used for authenticating write requests */
+struct interface *any_interface; /* default interface */
+keyid_t info_auth_keyid; /* keyid used to authenticate requests */
+u_long current_time; /* current time (s) */
+const char *Version = ""; /* version declaration */
+keyid_t req_keyid; /* request keyid */
+u_long client_limit;
+u_long client_limit_period;
+l_fp sys_revoketime;
+u_long sys_revoke; /* keys revoke timeout */
+volatile int debug = 0; /* debugging flag */
+u_char sys_minpoll; /* min poll interval (log2 s) */
+
+void snifflink P((const char *, char **));
+int filep P((const char *));
+FILE *newfile P((const char *, const char *, mode_t, const char *));
+void cleanlinks P((const char *, const char *, const char *));
+
+struct peer *
+peer_config(
+ struct sockaddr_in *srcadr,
+ struct interface *dstadr,
+ int hmode,
+ int version,
+ int minpoll,
+ int maxpoll,
+ u_int flags,
+ int ttl,
+ keyid_t key,
+ u_char *keystr
+ )
+{
+ if (debug > 1) printf("peer_config...\n");
+ return 0;
+}
+
+
+void
+set_sys_var(
+ char *data,
+ u_long size,
+ int def
+ )
+{
+ if (debug > 1) printf("set_sys_var...\n");
+ return;
+}
+
+
+void
+ntp_intres (void)
+{
+ if (debug > 1) printf("ntp_intres...\n");
+ return;
+}
+
+
+int
+ctlsettrap(
+ struct sockaddr_in *raddr,
+ struct interface *linter,
+ int traptype,
+ int version
+ )
+{
+ if (debug > 1) printf("ctlsettrap...\n");
+ return 0;
+}
+
+
+#ifdef PUBKEY
+void
+crypto_config(
+ int item, /* configuration item */
+ char *cp /* file name */
+ )
+{
+ switch (item) {
+ case CRYPTO_CONF_DH:
+ if (debug > 0) printf("crypto_config: DH/<%d> <%s>\n", item, cp);
+ f1_dhparms = strdup(cp);
+ break;
+ case CRYPTO_CONF_PRIV:
+ if (debug > 0) printf("crypto_config: PRIVATEKEY/<%d> <%s>\n", item, cp);
+ f1_privatekey = strdup(cp);
+ break;
+ case CRYPTO_CONF_PUBL:
+ if (debug > 0) printf("crypto_config: PUBLICKEY/<%d> <%s>\n", item, cp);
+ f1_publickey = strdup(cp);
+ break;
+ default:
+ if (debug > 1) printf("crypto_config: <%d> <%s>\n", item, cp);
+ break;
+ }
+ return;
+}
+#endif
+
+
+struct interface *
+findinterface(
+ struct sockaddr_in *addr
+ )
+{
+ if (debug > 1) printf("findinterface...\n");
+ return 0;
+}
+
+
+void
+refclock_control(
+ struct sockaddr_in *srcadr,
+ struct refclockstat *in,
+ struct refclockstat *out
+ )
+{
+ if (debug > 1) printf("refclock_control...\n");
+ return;
+}
+
+
+void
+loop_config(
+ int item,
+ double freq
+ )
+{
+ if (debug > 1) printf("loop_config...\n");
+ return;
+}
+
+
+void
+filegen_config(
+ FILEGEN *gen,
+ char *basename,
+ u_int type,
+ u_int flag
+ )
+{
+ if (debug > 1) printf("filegen_config...\n");
+ return;
+}
+
+
+void
+stats_config(
+ int item,
+ char *invalue /* only one type so far */
+ )
+{
+ if (debug > 1) printf("stats_config...\n");
+ return;
+}
+
+
+void
+hack_restrict(
+ int op,
+ struct sockaddr_in *resaddr,
+ struct sockaddr_in *resmask,
+ int mflags,
+ int flags
+ )
+{
+ if (debug > 1) printf("hack_restrict...\n");
+ return;
+}
+
+
+void
+kill_asyncio (void)
+{
+ if (debug > 1) printf("kill_asyncio...\n");
+ return;
+}
+
+
+void
+proto_config(
+ int item,
+ u_long value,
+ double dvalue
+ )
+{
+ if (debug > 1) printf("proto_config...\n");
+ return;
+}
+
+void
+getauthkeys(
+ char *keyfile
+ )
+{
+ if (debug > 0) printf("getauthkeys: got <%s>\n", keyfile);
+ f1_keys = strdup(keyfile);
+ return;
+}
+
+
+FILEGEN *
+filegen_get(
+ char *name
+ )
+{
+ if (debug > 1) printf("filegen_get...\n");
+ return 0;
+}
+
+
+/* End of stubs and hacks */
+
+
+static void
+usage(
+ void
+ )
+{
+ printf("Usage: %s [ -c ntp.conf ] [ -g {d,m,r} ] [ -k key_file ]\n",
+ progname);
+ printf(" [ -d ] [ -f ] [ -h ] [ -l ] [ -n ] [ -t ]\n");
+ printf(" where:\n");
+ printf(" -c /etc/ntp.conf Location of ntp.conf file\n");
+ printf(" -d enable debug messages (can be used multiple times)\n");
+ printf(" -f force installation of generated keys.\n");
+ printf(" -g d Generate D-H parameter file\n");
+ printf(" -g m Generate MD5 key file\n");
+ printf(" -g r Generate RSA keys\n");
+ printf(" -g dmr (Can be combined)\n");
+ printf(" -h Build keys here (current directory). Implies -l\n");
+ printf(" -k key_file Location of key file\n");
+ printf(" -l Don't make the symlinks\n");
+ printf(" -n Don't actually do anything, just say what would be done\n");
+ printf(" -t Trash the (old) files at the end of symlink\n");
+
+ exit(1);
+}
+
+
+void
+getCmdOpts (
+ int argc,
+ char *argv[]
+ )
+{
+ int i;
+
+ while ((i = ntp_getopt(argc, argv, "c:dfg:hlnt")) != EOF)
+ switch (i) {
+ case 'c':
+ config_file = ntp_optarg;
+#ifdef HAVE_NETINFO
+ check_netinfo = 0;
+#endif
+ break;
+ case 'd':
+ ++debug;
+ break;
+ case 'f':
+ ++force;
+ break;
+ case 'g':
+ while (*ntp_optarg) {
+ switch (*ntp_optarg) {
+ case 'd':
+ ++make_dh;
+ break;
+ case 'm':
+ ++make_md5;
+ break;
+ case 'r':
+ ++make_rsa;
+ break;
+ default:
+ ++errflag;
+ break;
+ }
+ ++ntp_optarg;
+ }
+ break;
+ case 'h':
+ ++here;
+ ++nosymlinks;
+ break;
+ case 'l':
+ ++nosymlinks;
+ break;
+ case 'n':
+ ++memorex;
+ break;
+ case 't':
+ ++trash;
+ break;
+ case '?':
+ ++errflag;
+ break;
+ }
+
+ if (errflag)
+ usage();
+
+ /* If no file type was specified, make them all. */
+ if (!(make_dh | make_md5 | make_rsa)) {
+ ++make_dh;
+ ++make_md5;
+ ++make_rsa;
+ }
+}
+
+
+void
+snifflink(
+ const char *file,
+ char **linkdata
+ )
+{
+#ifdef HAVE_READLINK
+ char buf[PATH_MAX];
+ int rc;
+
+ if (!file)
+ return;
+
+ rc = readlink(file, buf, sizeof buf);
+ if (-1 == rc) {
+ switch (errno) {
+ case EINVAL: /* Fall thru */
+ case ENOENT:
+ return;
+ }
+ fprintf(stderr, "%s: readlink(%s) failed: (%d) %s\n",
+ progname, file, errno, strerror(errno));
+ exit(1);
+ }
+ buf[rc] = '\0';
+ *linkdata = strdup(buf);
+ /* XXX: make sure linkdata is not 0... */
+#endif /* not HAVE_READLINK */
+ return;
+}
+
+
+int
+filep(
+ const char *fn
+ )
+{
+ struct stat sb;
+
+ if (-1 == stat(fn, &sb)) {
+ if (ENOENT == errno)
+ return 0;
+ fprintf(stderr, "stat(%s) failed: %s\n",
+ fn, strerror(errno));
+ exit(1);
+ }
+ return 1;
+}
+
+
+FILE *
+newfile(
+ const char *f1, /* Visible file */
+ const char *f2, /* New timestamped file name */
+ mode_t fmask, /* umask for new timestamped file */
+ const char *f3 /* Previous symlink target */
+ )
+{
+ FILE *fp;
+ char fb[PATH_MAX];
+ char *cp;
+
+ if (debug > 1) printf("newfile(%s,%s,%0o,%s)\n", f1, f2,
+ (unsigned)fmask, f3 ? f3 : "NULL");
+ /*
+ If:
+ - no symlink support, or
+ - there is no old symlink (!f3)
+ - - file = dirname(f1) / f2
+ Otherwise:
+ - If ('/' == *f3)
+ - - file = dirname(f3) / f2
+ - else
+ - - file = dirname(f1) / dirname(f3) / f2
+ fopen(file)
+ print any error message/bail
+ return FILE
+ */
+
+ if (here)
+ snprintf(fb, sizeof fb, "%s", f2);
+ else {
+ if (
+#ifdef HAVE_READLINK
+ !f3
+#else
+ 1
+#endif
+ ) {
+ /* file = dirname(f1) / f2 */
+ snprintf(fb, sizeof fb, "%s", f1);
+ cp = strrchr(fb, '/');
+ if (cp) {
+ *cp = 0;
+ }
+ snprintf(fb, sizeof fb, "%s/%s", fb, f2);
+ if (debug > 1) printf("case 1: file is <%s>\n", fb);
+ } else {
+ /*
+ - If ('/' == *f3)
+ - - file = dirname(f3) / f2
+ - else
+ - - file = dirname(f1) / dirname(f3) / f2
+ */
+ if ('/' != *f3) {
+ snprintf(fb, sizeof fb, "%s", f1);
+ cp = strrchr(fb, '/');
+ if (cp) {
+ ++cp;
+ *cp = 0;
+ }
+ if (debug > 1)
+ printf("case 2: file is <%s>\n", fb);
+ } else {
+ *fb = 0;
+ }
+ snprintf(fb, sizeof fb, "%s%s", fb, f3);
+ cp = strrchr(fb, '/');
+ if (cp) {
+ *cp = 0;
+ }
+ snprintf(fb, sizeof fb, "%s/%s", fb, f2);
+ if (debug > 1) printf("case 3: file is <%s>\n", fb);
+ }
+ }
+
+ /*
+ fopen(file)
+ print any error message/bail
+ return FILE
+ */
+ if (memorex) {
+ printf("Would write file <%s>\n", fb);
+ fp = NULL;
+ } else {
+ mode_t omask;
+
+ omask = umask(fmask);
+ fp = fopen(fb, "w");
+ (void) umask(omask);
+ if (fp == NULL) {
+ perror(fb);
+ exit(1);
+ }
+ }
+ return fp;
+}
+
+void
+cleanlinks(
+ const char *f1, /* Visible file */
+ const char *f2, /* New timestamped file name */
+ const char *f3 /* Previous symlink target */
+ )
+{
+#ifdef HAVE_READLINK
+ char *cp;
+ char fb[PATH_MAX];
+
+ /*
+ Just return if nosymlinks.
+ unlink f1
+ file = dirname(f3) / f2
+ symlink file, f1
+ If trash:
+ - if f3 begins with a /, unlink it
+ - else, unlink dirname(f1) / f3
+ */
+#endif /* HAVE_READLINK */
+
+ if (nosymlinks)
+ return;
+
+ if (memorex)
+ printf("Would unlink(%s)\n", f1);
+ else if (unlink(f1)) {
+ if (errno != ENOENT) {
+ fprintf(stderr, "unlink(%s) failed: %s\n", f1,
+ strerror(errno));
+ return;
+ }
+ }
+ /* file = dirname(f3) / f2 */
+ if (f3) {
+ snprintf(fb, sizeof fb, "%s", f3);
+ cp = strrchr(fb, '/');
+ if (cp) {
+ ++cp;
+ *cp = 0;
+ } else {
+ *fb = 0;
+ }
+ } else {
+ *fb = 0;
+ }
+ snprintf(fb, sizeof fb, "%s%s", fb, f2);
+ if (debug > 1) printf("cleanlinks 1: file is <%s>\n", fb);
+
+ if (memorex)
+ printf("Would symlink <%s> -> <%s>\n", f1, fb);
+ else if (symlink(fb, f1)) {
+ fprintf(stderr, "symlink(%s,%s) failed: %s\n", fb, f1,
+ strerror(errno));
+ return;
+ }
+
+ /*
+ If trash:
+ - if f3 begins with a /, unlink it
+ - else, unlink dirname(f1) / f3
+ */
+ if (trash && f3) {
+ if ('/' == *f3) {
+ if (memorex)
+ printf("Would unlink(%s)\n", f3);
+ else if (unlink(f3)) {
+ if (errno != ENOENT) {
+ fprintf(stderr, "unlink(%s) failed: %s\n", f3,
+ strerror(errno));
+ return;
+ }
+ }
+ } else {
+ snprintf(fb, sizeof fb, "%s", f1);
+ cp = strrchr(fb, '/');
+ if (cp) {
+ *cp = 0;
+ }
+ snprintf(fb, sizeof fb, "%s/%s", fb, f3);
+ if (debug > 1)
+ printf("cleanlinks 2: file is <%s>\n", fb);
+ if (memorex)
+ printf("Would unlink(%s)\n", fb);
+ else if (unlink(fb)) {
+ if (errno != ENOENT) {
+ fprintf(stderr, "unlink(%s) failed: %s\n", fb,
+ strerror(errno));
+ return;
+ }
+ }
+ }
+ }
+
+ return;
+}
+
+
+int
+main(
+ int argc,
+ char *argv[]
+ )
+{
+#ifdef PUBKEY
+ R_RSA_PRIVATE_KEY rsaref_private; /* RSA private key */
+ R_RSA_PUBLIC_KEY rsaref_public; /* RSA public key */
+ R_RSA_PROTO_KEY protokey; /* RSA prototype key */
+ R_DH_PARAMS dh_params; /* Diffie-Hellman parameters */
+ R_RANDOM_STRUCT randomstr; /* random structure */
+ int rval; /* return value */
+ u_char encoded_key[MAXKEYLEN]; /* encoded PEM string buffer */
+ u_int modulus; /* modulus length */
+ u_int len;
+#endif /* PUBKEY */
+ struct timeval tv; /* initialization vector */
+ u_long ntptime; /* NTP timestamp */
+ char hostname[256]; /* DNS host name */
+ u_char md5key[17]; /* generated MD5 key */
+ FILE *str; /* file handle */
+ u_int temp;
+ int i, j;
+ mode_t std_mask; /* Standard mask */
+ mode_t sec_mask = 077; /* Secure mask */
+ char pathbuf[PATH_MAX];
+
+ gethostname(hostname, sizeof(hostname));
+ gettimeofday(&tv, 0);
+ ntptime = tv.tv_sec + JAN_1970;
+
+ /* Initialize config_file */
+ getconfig(argc, argv); /* ntpd/ntp_config.c */
+
+ if (!f1_keysdir) {
+ /* Shouldn't happen... */
+ f1_keysdir = "PATH_KEYSDIR";
+ }
+ if (*f1_keysdir != '/') {
+ fprintf(stderr,
+ "%s: keysdir path <%s> doesn't begin with a /\n",
+ progname, f1_keysdir);
+ exit(1);
+ }
+
+ if (!f2_keys) {
+ snprintf(pathbuf, sizeof pathbuf, "ntp.keys.%lu",
+ ntptime);
+ f2_keys = strdup(pathbuf);
+ }
+ if (!f1_keys) {
+ snprintf(pathbuf, sizeof pathbuf, "%s/ntp.keys",
+ f1_keysdir);
+ f1_keys = strdup(pathbuf);
+ }
+ if (*f1_keys != '/') {
+ fprintf(stderr,
+ "%s: keys path <%s> doesn't begin with a /\n",
+ progname, f1_keys);
+ exit(1);
+ }
+ snifflink(f1_keys, &f3_keys);
+
+ if (!f2_publickey) {
+ snprintf(pathbuf, sizeof pathbuf, "ntpkey_%s.%lu",
+ hostname, ntptime);
+ f2_publickey = strdup(pathbuf);
+ }
+ if (!f1_publickey) {
+ snprintf(pathbuf, sizeof pathbuf, "%s/ntpkey_%s",
+ f1_keysdir, hostname);
+ f1_publickey = strdup(pathbuf);
+ }
+ if (*f1_publickey != '/') {
+ fprintf(stderr,
+ "%s: publickey path <%s> doesn't begin with a /\n",
+ progname, f1_publickey);
+ exit(1);
+ }
+ snifflink(f1_publickey, &f3_publickey);
+
+ if (!f2_privatekey) {
+ snprintf(pathbuf, sizeof pathbuf, "ntpkey.%lu",
+ ntptime);
+ f2_privatekey = strdup(pathbuf);
+ }
+ if (!f1_privatekey) {
+ snprintf(pathbuf, sizeof pathbuf, "%s/ntpkey",
+ f1_keysdir);
+ f1_privatekey = strdup(pathbuf);
+ }
+ if (*f1_privatekey != '/') {
+ fprintf(stderr,
+ "%s: privatekey path <%s> doesn't begin with a /\n",
+ progname, f1_privatekey);
+ exit(1);
+ }
+ snifflink(f1_privatekey, &f3_privatekey);
+
+ if (!f2_dhparms) {
+ snprintf(pathbuf, sizeof pathbuf, "ntpkey_dh.%lu",
+ ntptime);
+ f2_dhparms = strdup(pathbuf);
+ }
+ if (!f1_dhparms) {
+ snprintf(pathbuf, sizeof pathbuf, "%s/ntpkey_dh",
+ f1_keysdir);
+ f1_dhparms = strdup(pathbuf);
+ }
+ if (*f1_dhparms != '/') {
+ fprintf(stderr,
+ "%s: dhparms path <%s> doesn't begin with a /\n",
+ progname, f1_dhparms);
+ exit(1);
+ }
+ snifflink(f1_dhparms, &f3_dhparms);
+
+ if (debug > 1) {
+ printf("After config:\n");
+ printf("keysdir = <%s>\n", f1_keysdir? f1_keysdir: "");
+ printf("keys = <%s> -> <%s>\n"
+ , f1_keys? f1_keys: ""
+ , f2_keys? f2_keys: ""
+ );
+ printf(" old = <%s>\n", f3_keys? f3_keys: "");
+ printf("publickey = <%s> -> <%s>\n"
+ , f1_publickey? f1_publickey: ""
+ , f2_publickey? f2_publickey: ""
+ );
+ printf(" old = <%s>\n", f3_publickey? f3_publickey: "");
+ printf("privatekey = <%s> -> <%s>\n"
+ , f1_privatekey? f1_privatekey: ""
+ , f2_privatekey? f2_privatekey: ""
+ );
+ printf(" old = <%s>\n", f3_privatekey? f3_privatekey: "");
+ printf("dhparms = <%s> -> <%s>\n"
+ , f1_dhparms? f1_dhparms: ""
+ , f2_dhparms? f2_dhparms: ""
+ );
+ printf(" old = <%s>\n", f3_dhparms? f3_dhparms: "");
+ }
+
+ /*
+ for each file we're going to install:
+ - make the new timestamped file
+ - if (!nosymlinks)
+ - - remove any old link
+ - - make the link
+ - - if (trash)
+ - - - remove the old file
+ */
+
+ std_mask = umask(sec_mask); /* Get the standard mask */
+ (void) umask(std_mask);
+
+ if (make_md5 && (force || !filep(f1_keys))) {
+ /*
+ * Generate 16 random MD5 keys.
+ */
+ printf("Generating MD5 key file...\n");
+ str = newfile(f1_keys, f2_keys, sec_mask, f3_keys);
+ if (!memorex) {
+ srandom((u_int)tv.tv_usec);
+ fprintf(str, "# MD5 key file %s\n# %s", f2_keys,
+ ctime((const time_t *) &tv.tv_sec));
+ for (i = 1; i <= 16; i++) {
+ for (j = 0; j < 16; j++) {
+ while (1) {
+ temp = random() & 0xff;
+ /*
+ ** Harlan says Karnaugh maps
+ ** are not his friend, and
+ ** compilers can optimize
+ ** this most easily.
+ */
+ if (temp == '#')
+ continue;
+ if (temp > 0x20 && temp < 0x7f)
+ break;
+ }
+ md5key[j] = (u_char)temp;
+ }
+ md5key[16] = 0;
+ fprintf(str, "%2d M %16s # MD5 key\n",
+ i, md5key);
+ }
+ }
+ if (str) fclose(str);
+ cleanlinks(f1_keys, f2_keys, f3_keys);
+ }
+
+#ifdef PUBKEY
+ if (make_rsa && (force || !filep(f1_publickey)
+ || !filep(f1_privatekey))) {
+ /*
+ * Roll the RSA public/private key pair.
+ */
+ printf("Generating RSA public/private key pair (%d bits)...\n",
+ MODULUSLEN);
+ if (!memorex) {
+ protokey.bits = MODULUSLEN;
+ protokey.useFermat4 = 1;
+ R_RandomInit(&randomstr);
+ R_GetRandomBytesNeeded(&len, &randomstr);
+ for (i = 0; i < len; i++) {
+ temp = random();
+ R_RandomUpdate(&randomstr, (u_char *)&temp, 1);
+ }
+ rval = R_GeneratePEMKeys(&rsaref_public,
+ &rsaref_private, &protokey,
+ &randomstr);
+ if (rval) {
+ printf("R_GeneratePEMKeys error %x\n", rval);
+ return (-1);
+ }
+ }
+
+ /*
+ * Generate the file "ntpkey.*" containing the RSA
+ * private key in printable ASCII format.
+ */
+ str = newfile(f1_privatekey, f2_privatekey, sec_mask,
+ f3_privatekey);
+ if (!memorex) {
+ len = sizeof(rsaref_private)
+ - sizeof(rsaref_private.bits);
+ modulus = (u_int32)rsaref_private.bits;
+ fprintf(str, "# RSA private key file %s\n# %s",
+ f2_privatekey, ctime(&tv.tv_sec));
+ R_EncodePEMBlock(encoded_key, &temp,
+ (u_char *)rsaref_private.modulus,
+ len);
+ encoded_key[temp] = '\0';
+ fprintf(str, "%d %s\n", modulus, encoded_key);
+ }
+ if (str) fclose(str);
+ cleanlinks(f1_privatekey, f2_privatekey, f3_privatekey);
+
+ /*
+ * Generate the file "ntpkey_host.*" containing the RSA
+ * public key in printable ASCII format.
+ */
+ str = newfile(f1_publickey, f2_publickey, std_mask,
+ f3_publickey);
+ if (!memorex) {
+ len = sizeof(rsaref_public)
+ - sizeof(rsaref_public.bits);
+ modulus = (u_int32)rsaref_public.bits;
+ fprintf(str, "# RSA public key file %s\n# %s",
+ f2_publickey, ctime(&tv.tv_sec));
+ R_EncodePEMBlock(encoded_key, &temp,
+ (u_char *)rsaref_public.modulus, len);
+ encoded_key[temp] = '\0';
+ fprintf(str, "%d %s\n", modulus, encoded_key);
+ }
+ if (str) fclose(str);
+ cleanlinks(f1_publickey, f2_publickey, f3_publickey);
+ }
+#endif /* PUBKEY */
+
+#ifdef PUBKEY
+ if (make_dh && (force || !filep(f1_dhparms))) {
+ /*
+ * Roll the prime and generator for the Diffie-Hellman key
+ * agreement algorithm.
+ */
+ printf("Generating Diffie-Hellman parameters (%d bits)...\n",
+ PRIMELEN);
+ str = newfile(f1_dhparms, f2_dhparms, std_mask, f3_dhparms);
+
+ if (!memorex) {
+ R_RandomInit(&randomstr);
+ R_GetRandomBytesNeeded(&len, &randomstr);
+ for (i = 0; i < len; i++) {
+ temp = random();
+ R_RandomUpdate(&randomstr, (u_char *)&temp, 1);
+ }
+
+ /*
+ * Generate the file "ntpkey_dh.*" containing the
+ * Diffie-Hellman prime and generator in printable
+ * ASCII format.
+ */
+ len = DH_PRIME_LEN(PRIMELEN);
+ dh_params.prime = (u_char *)malloc(len);
+ dh_params.generator = (u_char *)malloc(len);
+ rval = R_GenerateDHParams(&dh_params, PRIMELEN,
+ PRIMELEN / 2, &randomstr);
+ if (rval) {
+ printf("R_GenerateDHParams error %x\n", rval);
+ return (-1);
+ }
+
+ fprintf(str,
+ "# Diffie-Hellman parameter file %s\n# %s",
+ f2_dhparms, ctime(&tv.tv_sec));
+ R_EncodePEMBlock(encoded_key, &temp,
+ (u_char *)dh_params.prime,
+ dh_params.primeLen);
+ encoded_key[temp] = '\0';
+ fprintf(str, "%d %s\n", dh_params.primeLen,
+ encoded_key);
+ R_EncodePEMBlock(encoded_key, &temp,
+ (u_char *)dh_params.generator,
+ dh_params.generatorLen);
+ encoded_key[temp] = '\0';
+ fprintf(str, "%d %s\n", dh_params.generatorLen,
+ encoded_key);
+ }
+ if (str) fclose(str);
+ cleanlinks(f1_dhparms, f2_dhparms, f3_dhparms);
+ }
+#endif /* PUBKEY */
+
+ return (0);
+}
diff --git a/contrib/ntp/util/ntptime.c b/contrib/ntp/util/ntptime.c
index 1a6f2f3..81bd2be 100644
--- a/contrib/ntp/util/ntptime.c
+++ b/contrib/ntp/util/ntptime.c
@@ -9,28 +9,28 @@
* For more information, see the README.kern file in the doc directory
* of the xntp3 distribution.
*/
+
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/time.h>
-#include <signal.h>
-#include <setjmp.h>
-
#include "ntp_fp.h"
#include "ntp_unixtime.h"
#include "ntp_syscall.h"
#include "ntp_stdlib.h"
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+#include <setjmp.h>
+
#ifdef NTP_SYSCALLS_STD
# ifndef SYS_DECOSF1
# define BADCALL -1 /* this is supposed to be a bad syscall */
# endif /* SYS_DECOSF1 */
#endif
-#ifdef HAVE_TV_NSEC_IN_NTPTIMEVAL
+#ifdef HAVE_STRUCT_NTPTIMEVAL_TIME_TV_NSEC
#define tv_frac_sec tv_nsec
#else
#define tv_frac_sec tv_usec
@@ -68,7 +68,7 @@ static volatile int pll_control; /* (0) daemon, (1) kernel loop */
static volatile int status; /* most recent status bits */
static volatile int flash; /* most recent ntp_adjtime() bits */
char* progname;
-static char optargs[] = "cde:f:hm:o:rs:t:";
+static char optargs[] = "MNT:cde:f:hm:o:rs:t:";
int
main(
@@ -100,6 +100,24 @@ main(
memset((char *)&ntx, 0, sizeof(ntx));
progname = argv[0];
while ((c = ntp_getopt(argc, argv, optargs)) != EOF) switch (c) {
+#ifdef MOD_MICRO
+ case 'M':
+ ntx.modes |= MOD_MICRO;
+ break;
+#endif
+#ifdef MOD_NANO
+ case 'N':
+ ntx.modes |= MOD_NANO;
+ break;
+#endif
+#ifdef NTP_API
+# if NTP_API > 3
+ case 'T':
+ ntx.modes = MOD_TAI;
+ ntx.constant = atoi(ntp_optarg);
+ break;
+# endif
+#endif
case 'c':
cost++;
break;
@@ -128,7 +146,7 @@ main(
case 's':
ntx.modes |= MOD_STATUS;
ntx.status = atoi(ntp_optarg);
- if (ntx.status < 0 || ntx.status > 4) errflg++;
+ if (ntx.status < 0 || ntx.status >= 0x100) errflg++;
break;
case 't':
ntx.modes |= MOD_TIMECONST;
@@ -140,6 +158,7 @@ main(
if (errflg || (ntp_optind != argc)) {
(void) fprintf(stderr,
"usage: %s [-%s]\n\n\
+%s%s%s\
-c display the time taken to call ntp_gettime (us)\n\
-e esterror estimate of the error (us)\n\
-f frequency Frequency error (-500 .. 500) (ppm)\n\
@@ -149,7 +168,27 @@ main(
-r print the unix and NTP time raw\n\
-l leap Set the leap bits\n\
-t timeconstant log2 of PLL time constant (0 .. %d)\n",
- progname, optargs, MAXTC);
+ progname, optargs,
+#ifdef MOD_MICRO
+"-M switch to microsecond mode\n",
+#else
+"",
+#endif
+#ifdef MOD_NANO
+"-N switch to nanosecond mode\n",
+#else
+"",
+#endif
+#ifdef NTP_API
+# if NTP_API > 3
+"-T tai_offset set TAI offset\n",
+# else
+"",
+# endif
+#else
+"",
+#endif
+ MAXTC);
exit(2);
}
@@ -258,12 +297,18 @@ main(
ts.l_uf &= ts_mask;
printf(" time %s, (.%0*d),\n",
prettydate(&ts), fdigits, (int) time_frac);
- printf(" maximum error %lu us, estimated error %lu us.\n",
+ printf(" maximum error %lu us, estimated error %lu us",
(u_long)ntv.maxerror, (u_long)ntv.esterror);
- if (rawtime) printf(" ntptime=%x.%x unixtime=%x.%0*d %s",
+ if (rawtime)
+ printf(" ntptime=%x.%x unixtime=%x.%0*d %s",
(unsigned int) ts.l_ui, (unsigned int) ts.l_uf,
(int) ntv.time.tv_sec, fdigits, (int) time_frac,
ctime((const time_t *) &ntv.time.tv_sec));
+#if NTP_API > 3
+ printf(", TAI offset %d\n", ntv.tai);
+#else
+ printf("\n");
+#endif /* NTP_API */
}
status = ntp_adjtime(&ntx);
if (status < 0)
diff --git a/contrib/ntp/util/precision.c b/contrib/ntp/util/precision.c
index 0fd3c3a..b1516b3 100644
--- a/contrib/ntp/util/precision.c
+++ b/contrib/ntp/util/precision.c
@@ -1,8 +1,7 @@
-#include <sys/types.h>
-#include <sys/time.h>
-#include <stdio.h>
#include "ntp_unixtime.h"
+#include <stdio.h>
+
#define DEFAULT_SYS_PRECISION -99
int default_get_resolution();
diff --git a/contrib/ntp/util/tickadj.c b/contrib/ntp/util/tickadj.c
index 5ac8121..4f524b1 100644
--- a/contrib/ntp/util/tickadj.c
+++ b/contrib/ntp/util/tickadj.c
@@ -13,15 +13,14 @@
# include <config.h>
#endif
+#include "ntp_types.h"
+#include "l_stdlib.h"
+
#include <stdio.h>
-#include <sys/types.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
-#include "ntp_types.h"
-#include "l_stdlib.h"
-
#ifdef HAVE___ADJTIMEX /* Linux */
#include <sys/timex.h>
@@ -178,7 +177,6 @@ main(
#ifdef NLIST_STRUCT
# include <nlist.h>
#else /* not NLIST_STRUCT */ /* was defined(SYS_AUX3) || defined(SYS_AUX2) */
-# include <sys/time.h>
# include <sys/resource.h>
# include <sys/file.h>
# include <a.out.h>
diff --git a/contrib/ntp/util/timetrim.c b/contrib/ntp/util/timetrim.c
index 4397b56..8f0a9ba 100644
--- a/contrib/ntp/util/timetrim.c
+++ b/contrib/ntp/util/timetrim.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <ctype.h>
+#include <stdlib.h>
#ifdef HAVE_SYS_SYSSGI_H
# include <sys/syssgi.h>
#endif
@@ -43,11 +44,11 @@ main(
)
{
char *rem;
- int c, incremental = 0, ntpunits = 0;
+ int incremental = 0, ntpunits = 0;
long timetrim;
- double value, strtod();
+ double value;
- while (--argc && **++argv == '-' && isalpha(argv[0][1])) {
+ while (--argc && **++argv == '-' && isalpha((int)argv[0][1])) {
switch (argv[0][1]) {
case 'i':
incremental++;
@@ -68,7 +69,7 @@ main(
if (argc == 0) {
if (ntpunits)
- fprintf(stdout, "%0.5lf\n", SGITONTP(timetrim));
+ fprintf(stdout, "%0.5f\n", SGITONTP(timetrim));
else
fprintf(stdout, "%ld\n", timetrim);
} else if (argc != 1) {
@@ -91,5 +92,6 @@ main(
exit(2);
}
}
+ return 0;
}
#endif
OpenPOWER on IntegriCloud