diff options
Diffstat (limited to 'contrib/ntp/util')
-rw-r--r-- | contrib/ntp/util/Makefile.am | 39 | ||||
-rw-r--r-- | contrib/ntp/util/Makefile.in | 538 | ||||
-rw-r--r-- | contrib/ntp/util/ansi2knr.c | 2 | ||||
-rw-r--r-- | contrib/ntp/util/hist.c | 29 | ||||
-rw-r--r-- | contrib/ntp/util/jitter.c | 108 | ||||
-rw-r--r-- | contrib/ntp/util/jitter.h | 412 | ||||
-rw-r--r-- | contrib/ntp/util/ntp-keygen-opts.c | 1044 | ||||
-rw-r--r-- | contrib/ntp/util/ntp-keygen-opts.def | 209 | ||||
-rw-r--r-- | contrib/ntp/util/ntp-keygen-opts.h | 318 | ||||
-rw-r--r-- | contrib/ntp/util/ntp-keygen-opts.menu | 1 | ||||
-rw-r--r-- | contrib/ntp/util/ntp-keygen-opts.texi | 364 | ||||
-rw-r--r-- | contrib/ntp/util/ntp-keygen.1 | 176 | ||||
-rw-r--r-- | contrib/ntp/util/ntp-keygen.c | 246 | ||||
-rw-r--r-- | contrib/ntp/util/ntptime.c | 4 | ||||
-rw-r--r-- | contrib/ntp/util/tg.c | 652 |
15 files changed, 3721 insertions, 421 deletions
diff --git a/contrib/ntp/util/Makefile.am b/contrib/ntp/util/Makefile.am index 8f1ba9e9ea98..f73121f52bbb 100644 --- a/contrib/ntp/util/Makefile.am +++ b/contrib/ntp/util/Makefile.am @@ -1,16 +1,43 @@ #AUTOMAKE_OPTIONS = ../ansi2knr no-dependencies AUTOMAKE_OPTIONS= ansi2knr -bin_PROGRAMS= @MAKE_NTPTIME@ @MAKE_TICKADJ@ @MAKE_TIMETRIM@ @MAKE_NTP_KEYGEN@ + +bin_PROGRAMS= @MAKE_NTPTIME@ @MAKE_TICKADJ@ @MAKE_TIMETRIM@ \ + ntp-keygen EXTRA_PROGRAMS= audio-pcm byteorder hist jitter kern longsize \ - ntp-keygen ntptime pps-api precision sht testrs6000 tickadj timetrim + ntptime pps-api precision sht testrs6000 tg tickadj timetrim -INCLUDES= -I$(top_srcdir)/include +AM_CPPFLAGS= -I$(top_srcdir)/include $(LIBOPTS_CFLAGS) # LDADD might need RESLIB and ADJLIB LDADD= ../libntp/libntp.a -ntp_keygen_LDADD= @LCRYPTO@ -#EXTRA_DIST= README TAGS -EXTRA_DIST= +ntp_keygen_SOURCES = ntp-keygen.c ntp-keygen-opts.c ntp-keygen-opts.h +ntp_keygen_LDADD= @LCRYPTO@ $(LIBOPTS_LDADD) ../libntp/libntp.a + ETAGS_ARGS= Makefile.am +#EXTRA_DIST= README TAGS +EXTRA_DIST= ntp-keygen-opts.def ntp-keygen.1 ntp-keygen-opts.texi ntp-keygen-opts.menu +BUILT_SOURCES= ntp-keygen-opts.c ntp-keygen-opts.h ntp-keygen.1 \ + ntp-keygen-opts.texi ntp-keygen-opts.menu +man_MANS= ntp-keygen.1 +run_ag= cd $(srcdir) && autogen -L ../include --writable +std_def_list= $(top_srcdir)/include/debug-opt.def \ + $(top_srcdir)/include/autogen-version.def \ + $(top_srcdir)/include/copyright.def \ + $(top_srcdir)/include/homerc.def \ + $(top_srcdir)/include/version.def + +$(srcdir)/ntp-keygen-opts.h: $(srcdir)/ntp-keygen-opts.c +$(srcdir)/ntp-keygen-opts.c: $(srcdir)/ntp-keygen-opts.def $(std_def_list) + $(run_ag) ntp-keygen-opts.def + +$(srcdir)/ntp-keygen.1: $(srcdir)/ntp-keygen-opts.def $(std_def_list) + $(run_ag) -Tagman1.tpl -bntp-keygen ntp-keygen-opts.def + +$(srcdir)/ntp-keygen-opts.texi $(srcdir)/ntp-keygen-opts.menu: $(srcdir)/ntp-keygen-opts.def $(std_def_list) + $(run_ag) -Taginfo.tpl -DLEVEL=section ntp-keygen-opts.def + + +jitter_SOURCES= jitter.c jitter.h +jitter_LDADD= ../libntp/libntp.a: cd ../libntp && $(MAKE) diff --git a/contrib/ntp/util/Makefile.in b/contrib/ntp/util/Makefile.in index 50b3042bdbdd..4c511d74e563 100644 --- a/contrib/ntp/util/Makefile.in +++ b/contrib/ntp/util/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.7.7 from Makefile.am. +# Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 -# Free Software Foundation, Inc. +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 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. @@ -21,7 +21,6 @@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. - am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 @@ -37,16 +36,125 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -target_triplet = @target@ +ANSI2KNR = @ANSI2KNR@ +bin_PROGRAMS = @MAKE_NTPTIME@ @MAKE_TICKADJ@ @MAKE_TIMETRIM@ \ + ntp-keygen$(EXEEXT) +EXTRA_PROGRAMS = audio-pcm$(EXEEXT) byteorder$(EXEEXT) hist$(EXEEXT) \ + jitter$(EXEEXT) kern$(EXEEXT) longsize$(EXEEXT) \ + ntptime$(EXEEXT) pps-api$(EXEEXT) precision$(EXEEXT) \ + sht$(EXEEXT) testrs6000$(EXEEXT) tg$(EXEEXT) tickadj$(EXEEXT) \ + timetrim$(EXEEXT) +subdir = util +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + ansi2knr.1 ansi2knr.c +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ + $(top_srcdir)/m4/define_dir.m4 \ + $(top_srcdir)/m4/hs_ulong_const.m4 \ + $(top_srcdir)/m4/os_cflags.m4 $(top_srcdir)/version.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +audio_pcm_SOURCES = audio-pcm.c +audio_pcm_OBJECTS = audio-pcm$U.$(OBJEXT) +audio_pcm_LDADD = $(LDADD) +audio_pcm_DEPENDENCIES = ../libntp/libntp.a +byteorder_SOURCES = byteorder.c +byteorder_OBJECTS = byteorder$U.$(OBJEXT) +byteorder_LDADD = $(LDADD) +byteorder_DEPENDENCIES = ../libntp/libntp.a +hist_SOURCES = hist.c +hist_OBJECTS = hist$U.$(OBJEXT) +hist_LDADD = $(LDADD) +hist_DEPENDENCIES = ../libntp/libntp.a +am_jitter_OBJECTS = jitter$U.$(OBJEXT) +jitter_OBJECTS = $(am_jitter_OBJECTS) +jitter_DEPENDENCIES = +kern_SOURCES = kern.c +kern_OBJECTS = kern$U.$(OBJEXT) +kern_LDADD = $(LDADD) +kern_DEPENDENCIES = ../libntp/libntp.a +longsize_SOURCES = longsize.c +longsize_OBJECTS = longsize$U.$(OBJEXT) +longsize_LDADD = $(LDADD) +longsize_DEPENDENCIES = ../libntp/libntp.a +am_ntp_keygen_OBJECTS = ntp-keygen$U.$(OBJEXT) \ + ntp-keygen-opts$U.$(OBJEXT) +ntp_keygen_OBJECTS = $(am_ntp_keygen_OBJECTS) +am__DEPENDENCIES_1 = +ntp_keygen_DEPENDENCIES = $(am__DEPENDENCIES_1) ../libntp/libntp.a +ntptime_SOURCES = ntptime.c +ntptime_OBJECTS = ntptime$U.$(OBJEXT) +ntptime_LDADD = $(LDADD) +ntptime_DEPENDENCIES = ../libntp/libntp.a +pps_api_SOURCES = pps-api.c +pps_api_OBJECTS = pps-api$U.$(OBJEXT) +pps_api_LDADD = $(LDADD) +pps_api_DEPENDENCIES = ../libntp/libntp.a +precision_SOURCES = precision.c +precision_OBJECTS = precision$U.$(OBJEXT) +precision_LDADD = $(LDADD) +precision_DEPENDENCIES = ../libntp/libntp.a +sht_SOURCES = sht.c +sht_OBJECTS = sht$U.$(OBJEXT) +sht_LDADD = $(LDADD) +sht_DEPENDENCIES = ../libntp/libntp.a +testrs6000_SOURCES = testrs6000.c +testrs6000_OBJECTS = testrs6000$U.$(OBJEXT) +testrs6000_LDADD = $(LDADD) +testrs6000_DEPENDENCIES = ../libntp/libntp.a +tg_SOURCES = tg.c +tg_OBJECTS = tg$U.$(OBJEXT) +tg_LDADD = $(LDADD) +tg_DEPENDENCIES = ../libntp/libntp.a +tickadj_SOURCES = tickadj.c +tickadj_OBJECTS = tickadj$U.$(OBJEXT) +tickadj_LDADD = $(LDADD) +tickadj_DEPENDENCIES = ../libntp/libntp.a +timetrim_SOURCES = timetrim.c +timetrim_OBJECTS = timetrim$U.$(OBJEXT) +timetrim_LDADD = $(LDADD) +timetrim_DEPENDENCIES = ../libntp/libntp.a +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = audio-pcm.c byteorder.c hist.c $(jitter_SOURCES) kern.c \ + longsize.c $(ntp_keygen_SOURCES) ntptime.c pps-api.c \ + precision.c sht.c testrs6000.c tg.c tickadj.c timetrim.c +DIST_SOURCES = audio-pcm.c byteorder.c hist.c $(jitter_SOURCES) kern.c \ + longsize.c $(ntp_keygen_SOURCES) ntptime.c pps-api.c \ + precision.c sht.c testrs6000.c tg.c tickadj.c timetrim.c +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man_MANS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ +AR = @AR@ ARLIB_DIR = @ARLIB_DIR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BINSUBDIR = @BINSUBDIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -54,10 +162,15 @@ CHUTEST = @CHUTEST@ CLKTEST = @CLKTEST@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DCFD = @DCFD@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -65,30 +178,39 @@ EF_LIBS = @EF_LIBS@ EF_PROGS = @EF_PROGS@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ INSTALL_DATA = @INSTALL_DATA@ +INSTALL_LIBOPTS_FALSE = @INSTALL_LIBOPTS_FALSE@ +INSTALL_LIBOPTS_TRUE = @INSTALL_LIBOPTS_TRUE@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LCRYPTO = @LCRYPTO@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ LIBPARSE = @LIBPARSE@ LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ +MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@ MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@ MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@ MAKE_LIBPARSE = @MAKE_LIBPARSE@ MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@ MAKE_NTPDSIM = @MAKE_NTPDSIM@ MAKE_NTPTIME = @MAKE_NTPTIME@ -MAKE_NTP_KEYGEN = @MAKE_NTP_KEYGEN@ MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@ -MAKE_SNTP = @MAKE_SNTP@ MAKE_TICKADJ = @MAKE_TICKADJ@ MAKE_TIMETRIM = @MAKE_TIMETRIM@ +NEED_LIBOPTS_FALSE = @NEED_LIBOPTS_FALSE@ +NEED_LIBOPTS_TRUE = @NEED_LIBOPTS_TRUE@ OBJEXT = @OBJEXT@ OPENSSL = @OPENSSL@ OPENSSL_INC = @OPENSSL_INC@ @@ -111,14 +233,21 @@ STRIP = @STRIP@ TESTDCF = @TESTDCF@ U = @U@ VERSION = @VERSION@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -139,6 +268,7 @@ libdir = @libdir@ libexecdir = @libexecdir@ localstatedir = @localstatedir@ mandir = @mandir@ +mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ prefix = @prefix@ program_transform_name = @program_transform_name@ @@ -146,153 +276,76 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ subdirs = @subdirs@ sysconfdir = @sysconfdir@ -target = @target@ target_alias = @target_alias@ -target_cpu = @target_cpu@ -target_os = @target_os@ -target_vendor = @target_vendor@ #AUTOMAKE_OPTIONS = ../ansi2knr no-dependencies AUTOMAKE_OPTIONS = ansi2knr -bin_PROGRAMS = @MAKE_NTPTIME@ @MAKE_TICKADJ@ @MAKE_TIMETRIM@ @MAKE_NTP_KEYGEN@ -EXTRA_PROGRAMS = audio-pcm byteorder hist jitter kern longsize \ - ntp-keygen ntptime pps-api precision sht testrs6000 tickadj timetrim - - -INCLUDES = -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include $(LIBOPTS_CFLAGS) # LDADD might need RESLIB and ADJLIB LDADD = ../libntp/libntp.a -ntp_keygen_LDADD = @LCRYPTO@ -#EXTRA_DIST= README TAGS -EXTRA_DIST = +ntp_keygen_SOURCES = ntp-keygen.c ntp-keygen-opts.c ntp-keygen-opts.h +ntp_keygen_LDADD = @LCRYPTO@ $(LIBOPTS_LDADD) ../libntp/libntp.a ETAGS_ARGS = Makefile.am -subdir = util -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -EXTRA_PROGRAMS = audio-pcm$(EXEEXT) byteorder$(EXEEXT) hist$(EXEEXT) \ - jitter$(EXEEXT) kern$(EXEEXT) longsize$(EXEEXT) \ - ntp-keygen$(EXEEXT) ntptime$(EXEEXT) pps-api$(EXEEXT) \ - precision$(EXEEXT) sht$(EXEEXT) testrs6000$(EXEEXT) \ - tickadj$(EXEEXT) timetrim$(EXEEXT) -bin_PROGRAMS = @MAKE_NTPTIME@ @MAKE_TICKADJ@ @MAKE_TIMETRIM@ \ - @MAKE_NTP_KEYGEN@ -PROGRAMS = $(bin_PROGRAMS) - -audio_pcm_SOURCES = audio-pcm.c -audio_pcm_OBJECTS = audio-pcm$U.$(OBJEXT) -audio_pcm_LDADD = $(LDADD) -audio_pcm_DEPENDENCIES = ../libntp/libntp.a -audio_pcm_LDFLAGS = -byteorder_SOURCES = byteorder.c -byteorder_OBJECTS = byteorder$U.$(OBJEXT) -byteorder_LDADD = $(LDADD) -byteorder_DEPENDENCIES = ../libntp/libntp.a -byteorder_LDFLAGS = -hist_SOURCES = hist.c -hist_OBJECTS = hist$U.$(OBJEXT) -hist_LDADD = $(LDADD) -hist_DEPENDENCIES = ../libntp/libntp.a -hist_LDFLAGS = -jitter_SOURCES = jitter.c -jitter_OBJECTS = jitter$U.$(OBJEXT) -jitter_LDADD = $(LDADD) -jitter_DEPENDENCIES = ../libntp/libntp.a -jitter_LDFLAGS = -kern_SOURCES = kern.c -kern_OBJECTS = kern$U.$(OBJEXT) -kern_LDADD = $(LDADD) -kern_DEPENDENCIES = ../libntp/libntp.a -kern_LDFLAGS = -longsize_SOURCES = longsize.c -longsize_OBJECTS = longsize$U.$(OBJEXT) -longsize_LDADD = $(LDADD) -longsize_DEPENDENCIES = ../libntp/libntp.a -longsize_LDFLAGS = -ntp_keygen_SOURCES = ntp-keygen.c -ntp_keygen_OBJECTS = ntp-keygen$U.$(OBJEXT) -ntp_keygen_DEPENDENCIES = -ntp_keygen_LDFLAGS = -ntptime_SOURCES = ntptime.c -ntptime_OBJECTS = ntptime$U.$(OBJEXT) -ntptime_LDADD = $(LDADD) -ntptime_DEPENDENCIES = ../libntp/libntp.a -ntptime_LDFLAGS = -pps_api_SOURCES = pps-api.c -pps_api_OBJECTS = pps-api$U.$(OBJEXT) -pps_api_LDADD = $(LDADD) -pps_api_DEPENDENCIES = ../libntp/libntp.a -pps_api_LDFLAGS = -precision_SOURCES = precision.c -precision_OBJECTS = precision$U.$(OBJEXT) -precision_LDADD = $(LDADD) -precision_DEPENDENCIES = ../libntp/libntp.a -precision_LDFLAGS = -sht_SOURCES = sht.c -sht_OBJECTS = sht$U.$(OBJEXT) -sht_LDADD = $(LDADD) -sht_DEPENDENCIES = ../libntp/libntp.a -sht_LDFLAGS = -testrs6000_SOURCES = testrs6000.c -testrs6000_OBJECTS = testrs6000$U.$(OBJEXT) -testrs6000_LDADD = $(LDADD) -testrs6000_DEPENDENCIES = ../libntp/libntp.a -testrs6000_LDFLAGS = -tickadj_SOURCES = tickadj.c -tickadj_OBJECTS = tickadj$U.$(OBJEXT) -tickadj_LDADD = $(LDADD) -tickadj_DEPENDENCIES = ../libntp/libntp.a -tickadj_LDFLAGS = -timetrim_SOURCES = timetrim.c -timetrim_OBJECTS = timetrim$U.$(OBJEXT) -timetrim_LDADD = $(LDADD) -timetrim_DEPENDENCIES = ../libntp/libntp.a -timetrim_LDFLAGS = - -DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/audio-pcm$U.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/byteorder$U.Po ./$(DEPDIR)/hist$U.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/jitter$U.Po ./$(DEPDIR)/kern$U.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/longsize$U.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/ntp-keygen$U.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/ntptime$U.Po ./$(DEPDIR)/pps-api$U.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/precision$U.Po ./$(DEPDIR)/sht$U.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/testrs6000$U.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/tickadj$U.Po ./$(DEPDIR)/timetrim$U.Po -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -DIST_SOURCES = audio-pcm.c byteorder.c hist.c jitter.c kern.c longsize.c \ - ntp-keygen.c ntptime.c pps-api.c precision.c sht.c testrs6000.c \ - tickadj.c timetrim.c -DIST_COMMON = README $(srcdir)/Makefile.in Makefile.am ansi2knr.1 \ - ansi2knr.c -SOURCES = audio-pcm.c byteorder.c hist.c jitter.c kern.c longsize.c ntp-keygen.c ntptime.c pps-api.c precision.c sht.c testrs6000.c tickadj.c timetrim.c - -all: all-am +#EXTRA_DIST= README TAGS +EXTRA_DIST = ntp-keygen-opts.def ntp-keygen.1 ntp-keygen-opts.texi ntp-keygen-opts.menu +BUILT_SOURCES = ntp-keygen-opts.c ntp-keygen-opts.h ntp-keygen.1 \ + ntp-keygen-opts.texi ntp-keygen-opts.menu + +man_MANS = ntp-keygen.1 +run_ag = cd $(srcdir) && autogen -L ../include --writable +std_def_list = $(top_srcdir)/include/debug-opt.def \ + $(top_srcdir)/include/autogen-version.def \ + $(top_srcdir)/include/copyright.def \ + $(top_srcdir)/include/homerc.def \ + $(top_srcdir)/include/version.def + +jitter_SOURCES = jitter.c jitter.h +jitter_LDADD = +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: -.SUFFIXES: .c .o .obj -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign util/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu util/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) -binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) + $(AUTOMAKE) --foreign util/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(bindir) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ + || test -f $$p1 \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \ - $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done @@ -300,12 +353,16 @@ uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ - rm -f $(DESTDIR)$(bindir)/$$f; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: - -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done audio-pcm$(EXEEXT): $(audio_pcm_OBJECTS) $(audio_pcm_DEPENDENCIES) @rm -f audio-pcm$(EXEEXT) $(LINK) $(audio_pcm_LDFLAGS) $(audio_pcm_OBJECTS) $(audio_pcm_LDADD) $(LIBS) @@ -342,6 +399,9 @@ sht$(EXEEXT): $(sht_OBJECTS) $(sht_DEPENDENCIES) testrs6000$(EXEEXT): $(testrs6000_OBJECTS) $(testrs6000_DEPENDENCIES) @rm -f testrs6000$(EXEEXT) $(LINK) $(testrs6000_LDFLAGS) $(testrs6000_OBJECTS) $(testrs6000_LDADD) $(LIBS) +tg$(EXEEXT): $(tg_OBJECTS) $(tg_DEPENDENCIES) + @rm -f tg$(EXEEXT) + $(LINK) $(tg_LDFLAGS) $(tg_OBJECTS) $(tg_LDADD) $(LIBS) tickadj$(EXEEXT): $(tickadj_OBJECTS) $(tickadj_DEPENDENCIES) @rm -f tickadj$(EXEEXT) $(LINK) $(tickadj_LDFLAGS) $(tickadj_OBJECTS) $(tickadj_LDADD) $(LIBS) @@ -350,12 +410,10 @@ timetrim$(EXEEXT): $(timetrim_OBJECTS) $(timetrim_DEPENDENCIES) $(LINK) $(timetrim_LDFLAGS) $(timetrim_OBJECTS) $(timetrim_LDADD) $(LIBS) mostlyclean-compile: - -rm -f *.$(OBJEXT) core *.core + -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c - -ANSI2KNR = @ANSI2KNR@ ansi2knr: ansi2knr.$(OBJEXT) $(LINK) ansi2knr.$(OBJEXT) $(LIBS) ansi2knr.$(OBJEXT): $(CONFIG_HEADER) @@ -373,35 +431,36 @@ mostlyclean-kr: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kern$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/longsize$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp-keygen$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp-keygen-opts$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntptime$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pps-api$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/precision$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sht$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testrs6000$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tg$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tickadj$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timetrim$U.Po@am__quote@ .c.o: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ -@am__fastdepCC_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ -@am__fastdepCC_TRUE@ fi +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ -@am__fastdepCC_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ -@am__fastdepCC_TRUE@ fi +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< audio-pcm_.c: audio-pcm.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/audio-pcm.c; then echo $(srcdir)/audio-pcm.c; else echo audio-pcm.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ byteorder_.c: byteorder.c $(ANSI2KNR) @@ -416,6 +475,8 @@ longsize_.c: longsize.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(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) > $@ || rm -f $@ ntp-keygen_.c: ntp-keygen.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp-keygen.c; then echo $(srcdir)/ntp-keygen.c; else echo ntp-keygen.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +ntp-keygen-opts_.c: ntp-keygen-opts.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp-keygen-opts.c; then echo $(srcdir)/ntp-keygen-opts.c; else echo ntp-keygen-opts.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ ntptime_.c: ntptime.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(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) > $@ || rm -f $@ pps-api_.c: pps-api.c $(ANSI2KNR) @@ -426,24 +487,76 @@ sht_.c: sht.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/sht.c; then echo $(srcdir)/sht.c; else echo sht.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ testrs6000_.c: testrs6000.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/testrs6000.c; then echo $(srcdir)/testrs6000.c; else echo testrs6000.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +tg_.c: tg.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tg.c; then echo $(srcdir)/tg.c; else echo tg.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ tickadj_.c: tickadj.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(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) > $@ || rm -f $@ timetrim_.c: timetrim.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(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) > $@ || rm -f $@ -audio-pcm_.$(OBJEXT) byteorder_.$(OBJEXT) hist_.$(OBJEXT) \ -jitter_.$(OBJEXT) kern_.$(OBJEXT) longsize_.$(OBJEXT) \ -ntp-keygen_.$(OBJEXT) ntptime_.$(OBJEXT) pps-api_.$(OBJEXT) \ -precision_.$(OBJEXT) sht_.$(OBJEXT) testrs6000_.$(OBJEXT) \ -tickadj_.$(OBJEXT) timetrim_.$(OBJEXT) : $(ANSI2KNR) +audio-pcm_.$(OBJEXT) audio-pcm_.lo byteorder_.$(OBJEXT) byteorder_.lo \ +hist_.$(OBJEXT) hist_.lo jitter_.$(OBJEXT) jitter_.lo kern_.$(OBJEXT) \ +kern_.lo longsize_.$(OBJEXT) longsize_.lo ntp-keygen_.$(OBJEXT) \ +ntp-keygen_.lo ntp-keygen-opts_.$(OBJEXT) ntp-keygen-opts_.lo \ +ntptime_.$(OBJEXT) ntptime_.lo pps-api_.$(OBJEXT) pps-api_.lo \ +precision_.$(OBJEXT) precision_.lo sht_.$(OBJEXT) sht_.lo \ +testrs6000_.$(OBJEXT) testrs6000_.lo tg_.$(OBJEXT) tg_.lo \ +tickadj_.$(OBJEXT) tickadj_.lo timetrim_.$(OBJEXT) timetrim_.lo : \ +$(ANSI2KNR) + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool uninstall-info-am: - -ETAGS = etags -ETAGSFLAGS = - -CTAGS = ctags -CTAGSFLAGS = - -tags: TAGS +install-man1: $(man1_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)" + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \ + done +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \ + rm -f "$(DESTDIR)$(man1dir)/$$inst"; \ + done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -453,6 +566,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique +tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) @@ -464,10 +578,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$tags$$unique" \ - || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique - + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) @@ -490,10 +605,6 @@ GTAGS: distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) - -top_distdir = .. -distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ @@ -507,7 +618,7 @@ distdir: $(DISTFILES) dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ - $(mkinstalldirs) "$(distdir)$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ @@ -523,12 +634,15 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: check-am -all-am: Makefile $(ANSI2KNR) $(PROGRAMS) - +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(ANSI2KNR) $(PROGRAMS) $(MANS) installdirs: - $(mkinstalldirs) $(DESTDIR)$(bindir) -install: install-am + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -539,7 +653,7 @@ install-am: all-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - INSTALL_STRIP_FLAG=-s \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: @@ -547,49 +661,52 @@ mostlyclean-generic: clean-generic: distclean-generic: - -rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am -clean-am: clean-binPROGRAMS clean-generic clean-krextra mostlyclean-am +clean-am: clean-binPROGRAMS clean-generic clean-krextra clean-libtool \ + mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile - distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags + distclean-libtool distclean-tags dvi: dvi-am dvi-am: +html: html-am + info: info-am info-am: -install-data-am: +install-data-am: install-man install-exec-am: install-binPROGRAMS install-info: install-info-am -install-man: +install-man: install-man1 installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile - maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am -mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr +mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \ + mostlyclean-libtool pdf: pdf-am @@ -599,19 +716,34 @@ ps: ps-am ps-am: -uninstall-am: uninstall-binPROGRAMS uninstall-info-am +uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man + +uninstall-man: uninstall-man1 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic clean-krextra ctags distclean distclean-compile \ - distclean-generic distclean-tags distdir dvi dvi-am info \ - info-am install install-am install-binPROGRAMS install-data \ + clean-generic clean-krextra clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ install-data-am install-exec install-exec-am install-info \ - install-info-am install-man install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ + install-info-am install-man install-man1 install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-kr pdf pdf-am ps ps-am tags \ - uninstall uninstall-am uninstall-binPROGRAMS uninstall-info-am + mostlyclean-generic mostlyclean-kr mostlyclean-libtool pdf \ + pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-info-am uninstall-man \ + uninstall-man1 + + +$(srcdir)/ntp-keygen-opts.h: $(srcdir)/ntp-keygen-opts.c +$(srcdir)/ntp-keygen-opts.c: $(srcdir)/ntp-keygen-opts.def $(std_def_list) + $(run_ag) ntp-keygen-opts.def + +$(srcdir)/ntp-keygen.1: $(srcdir)/ntp-keygen-opts.def $(std_def_list) + $(run_ag) -Tagman1.tpl -bntp-keygen ntp-keygen-opts.def +$(srcdir)/ntp-keygen-opts.texi $(srcdir)/ntp-keygen-opts.menu: $(srcdir)/ntp-keygen-opts.def $(std_def_list) + $(run_ag) -Taginfo.tpl -DLEVEL=section ntp-keygen-opts.def ../libntp/libntp.a: cd ../libntp && $(MAKE) diff --git a/contrib/ntp/util/ansi2knr.c b/contrib/ntp/util/ansi2knr.c index 1b32b068ab0b..a042674d5c1b 100644 --- a/contrib/ntp/util/ansi2knr.c +++ b/contrib/ntp/util/ansi2knr.c @@ -64,7 +64,7 @@ program under the GPL. lpd 2000-04-12 backs out Eggert's changes because of bugs: - concatlits didn't declare the type of its bufend argument; - - concatlits didn't't recognize when it was inside a comment; + - concatlits didn't recognize when it was inside a comment; - scanstring could scan backward past the beginning of the string; when - the check for \ + newline in scanstring was unnecessary. diff --git a/contrib/ntp/util/hist.c b/contrib/ntp/util/hist.c index c9763ce1975c..9453b6c0dca4 100644 --- a/contrib/ntp/util/hist.c +++ b/contrib/ntp/util/hist.c @@ -7,24 +7,20 @@ * runs backwards. */ -#if 0 #ifdef HAVE_CONFIG_H # include <config.h> #endif #include "ntp_types.h" -#endif #include <stdio.h> #include <stdlib.h> -#include <time.h> #define NBUF 100001 /* size of basic histogram */ #define NSRT 20000 /* size of overflow histogram */ #define NCNT (600 * 1000000) /* sample interval (us) */ -extern int col(hrtime_t *, hrtime_t *); -extern hrtime_t gethrtime(void); +int col P((long *, long *)); int main( @@ -32,8 +28,10 @@ main( char *argv[] ) { + struct timeval ts, tr, tp; + struct timezone tzp; int i, j, n; - hrtime_t t, u, v, w, gtod[NBUF], ovfl[NSRT]; + long t, u, v, w, gtod[NBUF], ovfl[NSRT]; /* * Force pages into memory @@ -47,10 +45,12 @@ main( * Construct histogram */ n = 0; - t = gethrtime(); + gettimeofday(&ts, &tzp); + t = ts.tv_sec * 1000000 + ts.tv_usec; v = t; while (1) { - u = gethirestime(); + gettimeofday(&tr, &tzp); + u = tr.tv_sec * 1000000 + tr.tv_usec; if (u - v > NCNT) break; w = u - t; @@ -66,6 +66,7 @@ main( } else { gtod[w]++; } + ts = tr; t = u; } @@ -78,7 +79,13 @@ main( } if (n == 0) return; - qsort((char *)ovfl, (size_t)n, sizeof(hrtime_t), col); + qsort( +#ifdef QSORT_USES_VOID_P + (void *) +#else + (char *) +#endif + ovfl, (size_t)n, sizeof(long), col); w = 0; j = 0; for (i = 0; i < n; i++) { @@ -98,8 +105,8 @@ main( int col( - hrtime_t *x, - hrtime_t *y + long *x, + long *y ) { return (*x - *y); diff --git a/contrib/ntp/util/jitter.c b/contrib/ntp/util/jitter.c index 462fe126c9d1..dda26551ec9a 100644 --- a/contrib/ntp/util/jitter.c +++ b/contrib/ntp/util/jitter.c @@ -1,16 +1,31 @@ /* * This program can be used to calibrate the clock reading jitter of a * particular CPU and operating system. It first tickles every element - * of an array, in order to force pages into memory, then repeatedly calls - * gettimeofday() and, finally, writes out the time values for later - * analysis. From this you can determine the jitter and if the clock ever - * runs backwards. + * of an array, in order to force pages into memory, then repeatedly + * reads the system clock and, finally, writes out the time values for + * later analysis. From this you can determine the jitter and if the + * clock ever runs backwards. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <stdio.h> #include <sys/time.h> +#include <stdlib.h> +#include "jitter.h" + +#define NBUF 80002 +#define FRAC 4294967296. /* a bbbbillion */ +#define JAN_1970 2208988800UL /* Unix base epoch */ +#define CLOCK_GETTIME /* Solaris hires clock */ -#define NBUF 20002 +int debug; +char progname[10]; +double sys_residual; +double average; +void sys_gettime(l_fp *); int main( @@ -18,11 +33,9 @@ main( char *argv[] ) { - struct timeval ts, tr; - struct timezone tzp; - long temp, j, i, gtod[NBUF]; - - gettimeofday(&ts, &tzp); + l_fp tr; + int i, j; + double dtemp, gtod[NBUF]; /* * Force pages into memory @@ -34,19 +47,18 @@ main( * Construct gtod array */ for (i = 0; i < NBUF; i ++) { - gettimeofday(&tr, &tzp); - gtod[i] = (tr.tv_sec - ts.tv_sec) * 1000000 + tr.tv_usec; + get_systime(&tr); + LFPTOD(&tr, gtod[i]); } /* - * Write out gtod array for later processing with S + * Write out gtod array for later processing with Matlab */ + average = 0; for (i = 0; i < NBUF - 2; i++) { - /* - printf("%lu\n", gtod[i]); - */ gtod[i] = gtod[i + 1] - gtod[i]; - printf("%lu\n", gtod[i]); + printf("%13.9f\n", gtod[i]); + average += gtod[i]; } /* @@ -55,17 +67,71 @@ main( for (i = 0; i < NBUF - 2; i++) { for (j = 0; j <= i; j++) { if (gtod[j] > gtod[i]) { - temp = gtod[j]; + dtemp = gtod[j]; gtod[j] = gtod[i]; - gtod[i] = temp; + gtod[i] = dtemp; } } } + average = average / (NBUF - 2); + fprintf(stderr, "Average %13.9f\n", average); fprintf(stderr, "First rank\n"); for (i = 0; i < 10; i++) - fprintf(stderr, "%10ld%10ld\n", i, gtod[i]); + fprintf(stderr, "%2d %13.9f\n", i, gtod[i]); fprintf(stderr, "Last rank\n"); for (i = NBUF - 12; i < NBUF - 2; i++) - fprintf(stderr, "%10ld%10ld\n", i, gtod[i]); + fprintf(stderr, "%2d %13.9f\n", i, gtod[i]); exit(0); } + + +/* + * get_systime - return system time in NTP timestamp format. + */ +void +get_systime( + l_fp *now /* system time */ + ) +{ + double dtemp; + +#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETCLOCK) + struct timespec ts; /* seconds and nanoseconds */ + + /* + * Convert Unix clock from seconds and nanoseconds to seconds. + */ +# ifdef HAVE_CLOCK_GETTIME + clock_gettime(CLOCK_REALTIME, &ts); +# else + getclock(TIMEOFDAY, &ts); +# endif + now->l_i = ts.tv_sec + JAN_1970; + dtemp = ts.tv_nsec / 1e9; + +#else /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */ + struct timeval tv; /* seconds and microseconds */ + + /* + * Convert Unix clock from seconds and microseconds to seconds. + */ + gettimeofday(&tv, NULL); + now->l_i = tv.tv_sec + JAN_1970; + dtemp = tv.tv_usec / 1e6; + +#endif /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */ + + /* + * Renormalize to seconds past 1900 and fraction. + */ + dtemp += sys_residual; + if (dtemp >= 1) { + dtemp -= 1; + now->l_i++; + } else if (dtemp < -1) { + dtemp += 1; + now->l_i--; + } + dtemp *= FRAC; + now->l_uf = (u_int32)dtemp; +} diff --git a/contrib/ntp/util/jitter.h b/contrib/ntp/util/jitter.h new file mode 100644 index 000000000000..d0fba44b4bb3 --- /dev/null +++ b/contrib/ntp/util/jitter.h @@ -0,0 +1,412 @@ +/* + * ntp_types.h - defines how int32 and u_int32 are treated. + * For 64 bit systems like the DEC Alpha, they have to be defined + * as int and u_int. + * For 32 bit systems, define them as long and u_long + */ +#define SIZEOF_INT 4 + +/* + * Set up for prototyping + */ +#ifndef P +#if defined(__STDC__) || defined(HAVE_PROTOTYPES) +#define P(x) x +#else /* not __STDC__ and not HAVE_PROTOTYPES */ +#define P(x) () +#endif /* not __STDC__ and HAVE_PROTOTYPES */ +#endif /* P */ + +/* + * VMS DECC (v4.1), {u_char,u_short,u_long} are only in SOCKET.H, + * and u_int isn't defined anywhere + */ +#if defined(VMS) +#include <socket.h> +typedef unsigned int u_int; +/* + * Note: VMS DECC has long == int (even on __alpha), + * so the distinction below doesn't matter + */ +#endif /* VMS */ + +#if (SIZEOF_INT == 4) +# ifndef int32 +# define int32 int +# endif +# ifndef u_int32 +# define u_int32 unsigned int +# endif +#else /* not sizeof(int) == 4 */ +# if (SIZEOF_LONG == 4) +# else /* not sizeof(long) == 4 */ +# ifndef int32 +# define int32 long +# endif +# ifndef u_int32 +# define u_int32 unsigned long +# endif +# endif /* not sizeof(long) == 4 */ +# 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 */ + +/* + * NTP uses two fixed point formats. The first (l_fp) is the "long" + * format and is 64 bits long with the decimal between bits 31 and 32. + * This is used for time stamps in the NTP packet header (in network + * byte order) and for internal computations of offsets (in local host + * byte order). We use the same structure for both signed and unsigned + * values, which is a big hack but saves rewriting all the operators + * twice. Just to confuse this, we also sometimes just carry the + * fractional part in calculations, in both signed and unsigned forms. + * Anyway, an l_fp looks like: + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Integral Part | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Fractional Part | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ +typedef struct { + union { + u_int32 Xl_ui; + int32 Xl_i; + } Ul_i; + union { + u_int32 Xl_uf; + int32 Xl_f; + } Ul_f; +} l_fp; + +#define l_ui Ul_i.Xl_ui /* unsigned integral part */ +#define l_i Ul_i.Xl_i /* signed integral part */ +#define l_uf Ul_f.Xl_uf /* unsigned fractional part */ +#define l_f Ul_f.Xl_f /* signed fractional part */ + +/* + * Fractional precision (of an l_fp) is actually the number of + * bits in a long. + */ +#define FRACTION_PREC (32) + + +/* + * The second fixed point format is 32 bits, with the decimal between + * bits 15 and 16. There is a signed version (s_fp) and an unsigned + * version (u_fp). This is used to represent synchronizing distance + * and synchronizing dispersion in the NTP packet header (again, in + * network byte order) and internally to hold both distance and + * dispersion values (in local byte order). In network byte order + * it looks like: + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Integer Part | Fraction Part | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ +typedef int32 s_fp; +typedef u_int32 u_fp; + +/* + * A unit second in fp format. Actually 2**(half_the_bits_in_a_long) + */ +#define FP_SECOND (0x10000) + +/* + * Byte order conversions + */ +#define HTONS_FP(x) (htonl(x)) +#define HTONL_FP(h, n) do { (n)->l_ui = htonl((h)->l_ui); \ + (n)->l_uf = htonl((h)->l_uf); } while (0) +#define NTOHS_FP(x) (ntohl(x)) +#define NTOHL_FP(n, h) do { (h)->l_ui = ntohl((n)->l_ui); \ + (h)->l_uf = ntohl((n)->l_uf); } while (0) +#define NTOHL_MFP(ni, nf, hi, hf) \ + do { (hi) = ntohl(ni); (hf) = ntohl(nf); } while (0) +#define HTONL_MFP(hi, hf, ni, nf) \ + do { (ni) = ntohl(hi); (nf) = ntohl(hf); } while (0) + +/* funny ones. Converts ts fractions to net order ts */ +#define HTONL_UF(uf, nts) \ + do { (nts)->l_ui = 0; (nts)->l_uf = htonl(uf); } while (0) +#define HTONL_F(f, nts) do { (nts)->l_uf = htonl(f); \ + if ((f) & 0x80000000) \ + (nts)->l_i = -1; \ + else \ + (nts)->l_i = 0; \ + } while (0) + +/* + * Conversions between the two fixed point types + */ +#define MFPTOFP(x_i, x_f) (((x_i) >= 0x00010000) ? 0x7fffffff : \ + (((x_i) <= -0x00010000) ? 0x80000000 : \ + (((x_i)<<16) | (((x_f)>>16)&0xffff)))) +#define LFPTOFP(v) MFPTOFP((v)->l_i, (v)->l_f) + +#define UFPTOLFP(x, v) ((v)->l_ui = (u_fp)(x)>>16, (v)->l_uf = (x)<<16) +#define FPTOLFP(x, v) (UFPTOLFP((x), (v)), (x) < 0 ? (v)->l_ui -= 0x10000 : 0) + +#define MAXLFP(v) ((v)->l_ui = 0x7fffffff, (v)->l_uf = 0xffffffff) +#define MINLFP(v) ((v)->l_ui = 0x80000000, (v)->l_uf = 0) + +/* + * Primitive operations on long fixed point values. If these are + * reminiscent of assembler op codes it's only because some may + * be replaced by inline assembler for particular machines someday. + * These are the (kind of inefficient) run-anywhere versions. + */ +#define M_NEG(v_i, v_f) /* v = -v */ \ + do { \ + if ((v_f) == 0) \ + (v_i) = -((s_fp)(v_i)); \ + else { \ + (v_f) = -((s_fp)(v_f)); \ + (v_i) = ~(v_i); \ + } \ + } while(0) + +#define M_NEGM(r_i, r_f, a_i, a_f) /* r = -a */ \ + do { \ + if ((a_f) == 0) { \ + (r_f) = 0; \ + (r_i) = -(a_i); \ + } else { \ + (r_f) = -(a_f); \ + (r_i) = ~(a_i); \ + } \ + } while(0) + +#define M_ADD(r_i, r_f, a_i, a_f) /* r += a */ \ + do { \ + register u_int32 lo_tmp; \ + register u_int32 hi_tmp; \ + \ + lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \ + hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \ + if (lo_tmp & 0x10000) \ + hi_tmp++; \ + (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \ + \ + (r_i) += (a_i); \ + if (hi_tmp & 0x10000) \ + (r_i)++; \ + } while (0) + +#define M_ADD3(r_ovr, r_i, r_f, a_ovr, a_i, a_f) /* r += a, three word */ \ + do { \ + register u_int32 lo_tmp; \ + register u_int32 hi_tmp; \ + \ + lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \ + hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \ + if (lo_tmp & 0x10000) \ + hi_tmp++; \ + (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \ + \ + lo_tmp = ((r_i) & 0xffff) + ((a_i) & 0xffff); \ + if (hi_tmp & 0x10000) \ + lo_tmp++; \ + hi_tmp = (((r_i) >> 16) & 0xffff) + (((a_i) >> 16) & 0xffff); \ + if (lo_tmp & 0x10000) \ + hi_tmp++; \ + (r_i) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \ + \ + (r_ovr) += (a_ovr); \ + if (hi_tmp & 0x10000) \ + (r_ovr)++; \ + } while (0) + +#define M_SUB(r_i, r_f, a_i, a_f) /* r -= a */ \ + do { \ + register u_int32 lo_tmp; \ + register u_int32 hi_tmp; \ + \ + if ((a_f) == 0) { \ + (r_i) -= (a_i); \ + } else { \ + lo_tmp = ((r_f) & 0xffff) + ((-((s_fp)(a_f))) & 0xffff); \ + hi_tmp = (((r_f) >> 16) & 0xffff) \ + + (((-((s_fp)(a_f))) >> 16) & 0xffff); \ + if (lo_tmp & 0x10000) \ + hi_tmp++; \ + (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \ + \ + (r_i) += ~(a_i); \ + if (hi_tmp & 0x10000) \ + (r_i)++; \ + } \ + } while (0) + +#define M_RSHIFTU(v_i, v_f) /* v >>= 1, v is unsigned */ \ + do { \ + (v_f) = (u_int32)(v_f) >> 1; \ + if ((v_i) & 01) \ + (v_f) |= 0x80000000; \ + (v_i) = (u_int32)(v_i) >> 1; \ + } while (0) + +#define M_RSHIFT(v_i, v_f) /* v >>= 1, v is signed */ \ + do { \ + (v_f) = (u_int32)(v_f) >> 1; \ + if ((v_i) & 01) \ + (v_f) |= 0x80000000; \ + if ((v_i) & 0x80000000) \ + (v_i) = ((v_i) >> 1) | 0x80000000; \ + else \ + (v_i) = (v_i) >> 1; \ + } while (0) + +#define M_LSHIFT(v_i, v_f) /* v <<= 1 */ \ + do { \ + (v_i) <<= 1; \ + if ((v_f) & 0x80000000) \ + (v_i) |= 0x1; \ + (v_f) <<= 1; \ + } while (0) + +#define M_LSHIFT3(v_ovr, v_i, v_f) /* v <<= 1, with overflow */ \ + do { \ + (v_ovr) <<= 1; \ + if ((v_i) & 0x80000000) \ + (v_ovr) |= 0x1; \ + (v_i) <<= 1; \ + if ((v_f) & 0x80000000) \ + (v_i) |= 0x1; \ + (v_f) <<= 1; \ + } while (0) + +#define M_ADDUF(r_i, r_f, uf) /* r += uf, uf is u_int32 fraction */ \ + M_ADD((r_i), (r_f), 0, (uf)) /* let optimizer worry about it */ + +#define M_SUBUF(r_i, r_f, uf) /* r -= uf, uf is u_int32 fraction */ \ + M_SUB((r_i), (r_f), 0, (uf)) /* let optimizer worry about it */ + +#define M_ADDF(r_i, r_f, f) /* r += f, f is a int32 fraction */ \ + do { \ + if ((f) > 0) \ + M_ADD((r_i), (r_f), 0, (f)); \ + else if ((f) < 0) \ + M_ADD((r_i), (r_f), (-1), (f));\ + } while(0) + +#define M_ISNEG(v_i, v_f) /* v < 0 */ \ + (((v_i) & 0x80000000) != 0) + +#define M_ISHIS(a_i, a_f, b_i, b_f) /* a >= b unsigned */ \ + (((u_int32)(a_i)) > ((u_int32)(b_i)) || \ + ((a_i) == (b_i) && ((u_int32)(a_f)) >= ((u_int32)(b_f)))) + +#define M_ISGEQ(a_i, a_f, b_i, b_f) /* a >= b signed */ \ + (((int32)(a_i)) > ((int32)(b_i)) || \ + ((a_i) == (b_i) && ((u_int32)(a_f)) >= ((u_int32)(b_f)))) + +#define M_ISEQU(a_i, a_f, b_i, b_f) /* a == b unsigned */ \ + ((a_i) == (b_i) && (a_f) == (b_f)) + +/* + * Operations on the long fp format + */ +#define L_ADD(r, a) M_ADD((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf) +#define L_SUB(r, a) M_SUB((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf) +#define L_NEG(v) M_NEG((v)->l_ui, (v)->l_uf) +#define L_ADDUF(r, uf) M_ADDUF((r)->l_ui, (r)->l_uf, (uf)) +#define L_SUBUF(r, uf) M_SUBUF((r)->l_ui, (r)->l_uf, (uf)) +#define L_ADDF(r, f) M_ADDF((r)->l_ui, (r)->l_uf, (f)) +#define L_RSHIFT(v) M_RSHIFT((v)->l_i, (v)->l_uf) +#define L_RSHIFTU(v) M_RSHIFT((v)->l_ui, (v)->l_uf) +#define L_LSHIFT(v) M_LSHIFT((v)->l_ui, (v)->l_uf) +#define L_CLR(v) ((v)->l_ui = (v)->l_uf = 0) + +#define L_ISNEG(v) (((v)->l_ui & 0x80000000) != 0) +#define L_ISZERO(v) ((v)->l_ui == 0 && (v)->l_uf == 0) +#define L_ISHIS(a, b) ((a)->l_ui > (b)->l_ui || \ + ((a)->l_ui == (b)->l_ui && (a)->l_uf >= (b)->l_uf)) +#define L_ISGEQ(a, b) ((a)->l_i > (b)->l_i || \ + ((a)->l_i == (b)->l_i && (a)->l_uf >= (b)->l_uf)) +#define L_ISEQU(a, b) M_ISEQU((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf) + +/* + * s_fp/double and u_fp/double conversions + */ +#define FRIC 65536. /* 2^16 as a double */ +#define DTOFP(r) ((s_fp)((r) * FRIC)) +#define DTOUFP(r) ((u_fp)((r) * FRIC)) +#define FPTOD(r) ((double)(r) / FRIC) + +/* + * l_fp/double conversions + */ +#define FRAC 4294967296. /* 2^32 as a double */ +#define M_DTOLFP(d, r_i, r_uf) /* double to l_fp */ \ + do { \ + register double d_tmp; \ + \ + d_tmp = (d); \ + if (d_tmp < 0) { \ + d_tmp = -d_tmp; \ + (r_i) = (int32)(d_tmp); \ + (r_uf) = (u_int32)(((d_tmp) - (double)(r_i)) * FRAC); \ + M_NEG((r_i), (r_uf)); \ + } else { \ + (r_i) = (int32)(d_tmp); \ + (r_uf) = (u_int32)(((d_tmp) - (double)(r_i)) * FRAC); \ + } \ + } while (0) +#define M_LFPTOD(r_i, r_uf, d) /* l_fp to double */ \ + do { \ + register l_fp l_tmp; \ + \ + l_tmp.l_i = (r_i); \ + l_tmp.l_f = (r_uf); \ + if (l_tmp.l_i < 0) { \ + M_NEG(l_tmp.l_i, l_tmp.l_uf); \ + (d) = -((double)l_tmp.l_i + ((double)l_tmp.l_uf) / FRAC); \ + } else { \ + (d) = (double)l_tmp.l_i + ((double)l_tmp.l_uf) / FRAC; \ + } \ + } while (0) +#define DTOLFP(d, v) M_DTOLFP((d), (v)->l_ui, (v)->l_uf) +#define LFPTOD(v, d) M_LFPTOD((v)->l_ui, (v)->l_uf, (d)) + +/* + * Prototypes + */ +#if 0 +extern char * dofptoa P((u_fp, int, short, int)); +extern char * dolfptoa P((u_long, u_long, int, short, int)); +#endif + +extern int atolfp P((const char *, l_fp *)); +extern int buftvtots P((const char *, l_fp *)); +extern char * fptoa P((s_fp, short)); +extern char * fptoms P((s_fp, short)); +extern int hextolfp P((const char *, l_fp *)); +extern void gpstolfp P((int, int, unsigned long, l_fp *)); +extern int mstolfp P((const char *, l_fp *)); +extern char * prettydate P((l_fp *)); +extern char * gmprettydate P((l_fp *)); +extern char * uglydate P((l_fp *)); +extern void mfp_mul P((int32 *, u_int32 *, int32, u_int32, int32, u_int32)); + +extern void get_systime P((l_fp *)); +extern int step_systime P((double)); +extern int adj_systime P((double)); + +#define lfptoa(_fpv, _ndec) mfptoa((_fpv)->l_ui, (_fpv)->l_uf, (_ndec)) +#define lfptoms(_fpv, _ndec) mfptoms((_fpv)->l_ui, (_fpv)->l_uf, (_ndec)) + +#define ufptoa(_fpv, _ndec) dofptoa((_fpv), 0, (_ndec), 0) +#define ufptoms(_fpv, _ndec) dofptoa((_fpv), 0, (_ndec), 1) +#define ulfptoa(_fpv, _ndec) dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 0) +#define ulfptoms(_fpv, _ndec) dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 1) +#define umfptoa(_fpi, _fpf, _ndec) dolfptoa((_fpi), (_fpf), 0, (_ndec), 0) diff --git a/contrib/ntp/util/ntp-keygen-opts.c b/contrib/ntp/util/ntp-keygen-opts.c new file mode 100644 index 000000000000..edc9c5b41d5d --- /dev/null +++ b/contrib/ntp/util/ntp-keygen-opts.c @@ -0,0 +1,1044 @@ +/* + * EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.c) + * + * It has been AutoGen-ed Sunday August 17, 2008 at 05:27:33 AM EDT + * From the definitions ntp-keygen-opts.def + * and the template file options + * + * Generated from AutoOpts 29:0:4 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This source file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * ntp-keygen author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * ntp-keygen copyright 1970-2008 David L. Mills and/or others - all rights reserved + * + * see html/copyright.html + */ + + +#include <limits.h> +#include <stdio.h> +#define OPTION_CODE_COMPILE 1 +#include "ntp-keygen-opts.h" + +#ifdef __cplusplus +extern "C" { +#endif +tSCC zCopyright[] = + "ntp-keygen copyright (c) 1970-2008 David L. Mills and/or others, all rights reserved"; +tSCC zCopyrightNotice[] = + +/* extracted from ../include/copyright.def near line 8 */ +"see html/copyright.html"; +extern tUsageProc optionUsage; + +/* + * global included definitions + */ +#include <stdlib.h> +#ifdef __windows + extern int atoi(const char*); +#else +# include <stdlib.h> +#endif + +#ifndef NULL +# define NULL 0 +#endif +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif +/* + * Certificate option description: + */ +#ifdef OPENSSL +tSCC zCertificateText[] = + "certificate scheme"; +tSCC zCertificate_NAME[] = "CERTIFICATE"; +tSCC zCertificate_Name[] = "certificate"; +#define CERTIFICATE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Certificate */ +#define VALUE_OPT_CERTIFICATE NO_EQUIVALENT +#define CERTIFICATE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zCertificateText NULL +#define zCertificate_NAME NULL +#define zCertificate_Name NULL +#endif /* OPENSSL */ + +/* + * Debug_Level option description: + */ +#ifdef DEBUG +tSCC zDebug_LevelText[] = + "Increase output debug message level"; +tSCC zDebug_Level_NAME[] = "DEBUG_LEVEL"; +tSCC zDebug_Level_Name[] = "debug-level"; +#define DEBUG_LEVEL_FLAGS (OPTST_DISABLED) + +#else /* disable Debug_Level */ +#define VALUE_OPT_DEBUG_LEVEL NO_EQUIVALENT +#define DEBUG_LEVEL_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zDebug_LevelText NULL +#define zDebug_Level_NAME NULL +#define zDebug_Level_Name NULL +#endif /* DEBUG */ + +/* + * Set_Debug_Level option description: + */ +#ifdef DEBUG +tSCC zSet_Debug_LevelText[] = + "Set the output debug message level"; +tSCC zSet_Debug_Level_NAME[] = "SET_DEBUG_LEVEL"; +tSCC zSet_Debug_Level_Name[] = "set-debug-level"; +#define SET_DEBUG_LEVEL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Set_Debug_Level */ +#define VALUE_OPT_SET_DEBUG_LEVEL NO_EQUIVALENT +#define SET_DEBUG_LEVEL_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zSet_Debug_LevelText NULL +#define zSet_Debug_Level_NAME NULL +#define zSet_Debug_Level_Name NULL +#endif /* DEBUG */ + +/* + * Id_Key option description: + */ +#ifdef OPENSSL +tSCC zId_KeyText[] = + "Write identity keys"; +tSCC zId_Key_NAME[] = "ID_KEY"; +tSCC zId_Key_Name[] = "id-key"; +#define ID_KEY_FLAGS (OPTST_DISABLED) + +#else /* disable Id_Key */ +#define VALUE_OPT_ID_KEY NO_EQUIVALENT +#define ID_KEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zId_KeyText NULL +#define zId_Key_NAME NULL +#define zId_Key_Name NULL +#endif /* OPENSSL */ + +/* + * Gq_Params option description: + */ +#ifdef OPENSSL +tSCC zGq_ParamsText[] = + "Generate GQ parameters and keys"; +tSCC zGq_Params_NAME[] = "GQ_PARAMS"; +tSCC zGq_Params_Name[] = "gq-params"; +#define GQ_PARAMS_FLAGS (OPTST_DISABLED) + +#else /* disable Gq_Params */ +#define VALUE_OPT_GQ_PARAMS NO_EQUIVALENT +#define GQ_PARAMS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zGq_ParamsText NULL +#define zGq_Params_NAME NULL +#define zGq_Params_Name NULL +#endif /* OPENSSL */ + +/* + * Gq_Keys option description: + */ +#ifdef OPENSSL +tSCC zGq_KeysText[] = + "update GQ keys"; +tSCC zGq_Keys_NAME[] = "GQ_KEYS"; +tSCC zGq_Keys_Name[] = "gq-keys"; +#define GQ_KEYS_FLAGS (OPTST_DISABLED) + +#else /* disable Gq_Keys */ +#define VALUE_OPT_GQ_KEYS NO_EQUIVALENT +#define GQ_KEYS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zGq_KeysText NULL +#define zGq_Keys_NAME NULL +#define zGq_Keys_Name NULL +#endif /* OPENSSL */ + +/* + * Host_Key option description: + */ +#ifdef OPENSSL +tSCC zHost_KeyText[] = + "generate RSA host key"; +tSCC zHost_Key_NAME[] = "HOST_KEY"; +tSCC zHost_Key_Name[] = "host-key"; +#define HOST_KEY_FLAGS (OPTST_DISABLED) + +#else /* disable Host_Key */ +#define VALUE_OPT_HOST_KEY NO_EQUIVALENT +#define HOST_KEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zHost_KeyText NULL +#define zHost_Key_NAME NULL +#define zHost_Key_Name NULL +#endif /* OPENSSL */ + +/* + * Iffkey option description: + */ +#ifdef OPENSSL +tSCC zIffkeyText[] = + "generate IFF parameters"; +tSCC zIffkey_NAME[] = "IFFKEY"; +tSCC zIffkey_Name[] = "iffkey"; +#define IFFKEY_FLAGS (OPTST_DISABLED) + +#else /* disable Iffkey */ +#define VALUE_OPT_IFFKEY NO_EQUIVALENT +#define IFFKEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zIffkeyText NULL +#define zIffkey_NAME NULL +#define zIffkey_Name NULL +#endif /* OPENSSL */ + +/* + * Issuer_Name option description: + */ +#ifdef OPENSSL +tSCC zIssuer_NameText[] = + "set issuer name"; +tSCC zIssuer_Name_NAME[] = "ISSUER_NAME"; +tSCC zIssuer_Name_Name[] = "issuer-name"; +#define ISSUER_NAME_FLAGS (OPTST_DISABLED) + +#else /* disable Issuer_Name */ +#define VALUE_OPT_ISSUER_NAME NO_EQUIVALENT +#define ISSUER_NAME_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zIssuer_NameText NULL +#define zIssuer_Name_NAME NULL +#define zIssuer_Name_Name NULL +#endif /* OPENSSL */ + +/* + * Md5key option description: + */ +tSCC zMd5keyText[] = + "generate MD5 keys"; +tSCC zMd5key_NAME[] = "MD5KEY"; +tSCC zMd5key_Name[] = "md5key"; +#define MD5KEY_FLAGS (OPTST_DISABLED) + +/* + * Modulus option description: + */ +#ifdef OPENSSL +tSCC zModulusText[] = + "modulus"; +tSCC zModulus_NAME[] = "MODULUS"; +tSCC zModulus_Name[] = "modulus"; +#define MODULUS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +#else /* disable Modulus */ +#define VALUE_OPT_MODULUS NO_EQUIVALENT +#define MODULUS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zModulusText NULL +#define zModulus_NAME NULL +#define zModulus_Name NULL +#endif /* OPENSSL */ + +/* + * Pvt_Cert option description: + */ +#ifdef OPENSSL +tSCC zPvt_CertText[] = + "generate PC private certificate"; +tSCC zPvt_Cert_NAME[] = "PVT_CERT"; +tSCC zPvt_Cert_Name[] = "pvt-cert"; +#define PVT_CERT_FLAGS (OPTST_DISABLED) + +#else /* disable Pvt_Cert */ +#define VALUE_OPT_PVT_CERT NO_EQUIVALENT +#define PVT_CERT_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zPvt_CertText NULL +#define zPvt_Cert_NAME NULL +#define zPvt_Cert_Name NULL +#endif /* OPENSSL */ + +/* + * Pvt_Passwd option description: + */ +#ifdef OPENSSL +tSCC zPvt_PasswdText[] = + "output private password"; +tSCC zPvt_Passwd_NAME[] = "PVT_PASSWD"; +tSCC zPvt_Passwd_Name[] = "pvt-passwd"; +#define PVT_PASSWD_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Pvt_Passwd */ +#define VALUE_OPT_PVT_PASSWD NO_EQUIVALENT +#define PVT_PASSWD_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zPvt_PasswdText NULL +#define zPvt_Passwd_NAME NULL +#define zPvt_Passwd_Name NULL +#endif /* OPENSSL */ + +/* + * Get_Pvt_Passwd option description: + */ +#ifdef OPENSSL +tSCC zGet_Pvt_PasswdText[] = + "input private password"; +tSCC zGet_Pvt_Passwd_NAME[] = "GET_PVT_PASSWD"; +tSCC zGet_Pvt_Passwd_Name[] = "get-pvt-passwd"; +#define GET_PVT_PASSWD_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Get_Pvt_Passwd */ +#define VALUE_OPT_GET_PVT_PASSWD NO_EQUIVALENT +#define GET_PVT_PASSWD_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zGet_Pvt_PasswdText NULL +#define zGet_Pvt_Passwd_NAME NULL +#define zGet_Pvt_Passwd_Name NULL +#endif /* OPENSSL */ + +/* + * Sign_Key option description: + */ +#ifdef OPENSSL +tSCC zSign_KeyText[] = + "generate sign key (RSA or DSA)"; +tSCC zSign_Key_NAME[] = "SIGN_KEY"; +tSCC zSign_Key_Name[] = "sign-key"; +#define SIGN_KEY_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Sign_Key */ +#define VALUE_OPT_SIGN_KEY NO_EQUIVALENT +#define SIGN_KEY_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zSign_KeyText NULL +#define zSign_Key_NAME NULL +#define zSign_Key_Name NULL +#endif /* OPENSSL */ + +/* + * Subject_Name option description: + */ +#ifdef OPENSSL +tSCC zSubject_NameText[] = + "set subject name"; +tSCC zSubject_Name_NAME[] = "SUBJECT_NAME"; +tSCC zSubject_Name_Name[] = "subject-name"; +#define SUBJECT_NAME_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Subject_Name */ +#define VALUE_OPT_SUBJECT_NAME NO_EQUIVALENT +#define SUBJECT_NAME_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zSubject_NameText NULL +#define zSubject_Name_NAME NULL +#define zSubject_Name_Name NULL +#endif /* OPENSSL */ + +/* + * Trusted_Cert option description: + */ +#ifdef OPENSSL +tSCC zTrusted_CertText[] = + "trusted certificate (TC scheme)"; +tSCC zTrusted_Cert_NAME[] = "TRUSTED_CERT"; +tSCC zTrusted_Cert_Name[] = "trusted-cert"; +#define TRUSTED_CERT_FLAGS (OPTST_DISABLED) + +#else /* disable Trusted_Cert */ +#define VALUE_OPT_TRUSTED_CERT NO_EQUIVALENT +#define TRUSTED_CERT_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zTrusted_CertText NULL +#define zTrusted_Cert_NAME NULL +#define zTrusted_Cert_Name NULL +#endif /* OPENSSL */ + +/* + * Mv_Params option description: + */ +#ifdef OPENSSL +tSCC zMv_ParamsText[] = + "generate <num> MV parameters"; +tSCC zMv_Params_NAME[] = "MV_PARAMS"; +tSCC zMv_Params_Name[] = "mv-params"; +#define MV_PARAMS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +#else /* disable Mv_Params */ +#define VALUE_OPT_MV_PARAMS NO_EQUIVALENT +#define MV_PARAMS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zMv_ParamsText NULL +#define zMv_Params_NAME NULL +#define zMv_Params_Name NULL +#endif /* OPENSSL */ + +/* + * Mv_Keys option description: + */ +#ifdef OPENSSL +tSCC zMv_KeysText[] = + "update <num> MV keys"; +tSCC zMv_Keys_NAME[] = "MV_KEYS"; +tSCC zMv_Keys_Name[] = "mv-keys"; +#define MV_KEYS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +#else /* disable Mv_Keys */ +#define VALUE_OPT_MV_KEYS NO_EQUIVALENT +#define MV_KEYS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zMv_KeysText NULL +#define zMv_Keys_NAME NULL +#define zMv_Keys_Name NULL +#endif /* OPENSSL */ + +/* + * Help/More_Help/Version option descriptions: + */ +tSCC zHelpText[] = "Display usage information and exit"; +tSCC zHelp_Name[] = "help"; + +tSCC zMore_HelpText[] = "Extended usage information passed thru pager"; +tSCC zMore_Help_Name[] = "more-help"; + +tSCC zVersionText[] = "Output version information and exit"; +tSCC zVersion_Name[] = "version"; + +/* + * Save/Load_Opts option description: + */ +tSCC zSave_OptsText[] = "Save the option state to a config file"; +tSCC zSave_Opts_Name[] = "save-opts"; + +tSCC zLoad_OptsText[] = "Load options from a config file"; +tSCC zLoad_Opts_NAME[] = "LOAD_OPTS"; + +tSCC zNotLoad_Opts_Name[] = "no-load-opts"; +tSCC zNotLoad_Opts_Pfx[] = "no"; +#define zLoad_Opts_Name (zNotLoad_Opts_Name + 3) +/* + * Declare option callback procedures + */ +#ifdef DEBUG + static tOptProc doOptSet_Debug_Level; +#else /* not DEBUG */ +# define doOptSet_Debug_Level NULL +#endif /* def/not DEBUG */ +#ifdef OPENSSL + static tOptProc doOptModulus; +#else /* not OPENSSL */ +# define doOptModulus NULL +#endif /* def/not OPENSSL */ +#ifdef OPENSSL + extern tOptProc optionNumericVal; +#else /* not OPENSSL */ +# define optionNumericVal NULL +#endif /* def/not OPENSSL */ +#ifdef OPENSSL + extern tOptProc optionNumericVal; +#else /* not OPENSSL */ +# define optionNumericVal NULL +#endif /* def/not OPENSSL */ +#if defined(TEST_NTP_KEYGEN_OPTS) +/* + * Under test, omit argument processing, or call optionStackArg, + * if multiple copies are allowed. + */ +extern tOptProc + optionNumericVal, optionPagedUsage, optionVersionStderr; +static tOptProc + doOptModulus, doUsageOpt; + +/* + * #define map the "normal" callout procs to the test ones... + */ +#define SET_DEBUG_LEVEL_OPT_PROC optionStackArg + + +#else /* NOT defined TEST_NTP_KEYGEN_OPTS */ +/* + * When not under test, there are different procs to use + */ +extern tOptProc + optionPagedUsage, optionPrintVersion; +static tOptProc + doUsageOpt; + +/* + * #define map the "normal" callout procs + */ +#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level + +#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level +#endif /* defined(TEST_NTP_KEYGEN_OPTS) */ +#ifdef TEST_NTP_KEYGEN_OPTS +# define DOVERPROC optionVersionStderr +#else +# define DOVERPROC optionPrintVersion +#endif /* TEST_NTP_KEYGEN_OPTS */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Ntp_Keygen Option Descriptions. + */ +static tOptDesc optDesc[ OPTION_CT ] = { + { /* entry idx, value */ 0, VALUE_OPT_CERTIFICATE, + /* equiv idx, value */ 0, VALUE_OPT_CERTIFICATE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ CERTIFICATE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zCertificateText, zCertificate_NAME, zCertificate_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 1, VALUE_OPT_DEBUG_LEVEL, + /* equiv idx, value */ 1, VALUE_OPT_DEBUG_LEVEL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, NOLIMIT, 0, + /* opt state flags */ DEBUG_LEVEL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 2, VALUE_OPT_SET_DEBUG_LEVEL, + /* equiv idx, value */ 2, VALUE_OPT_SET_DEBUG_LEVEL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, NOLIMIT, 0, + /* opt state flags */ SET_DEBUG_LEVEL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ SET_DEBUG_LEVEL_OPT_PROC, + /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 3, VALUE_OPT_ID_KEY, + /* equiv idx, value */ 3, VALUE_OPT_ID_KEY, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ID_KEY_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zId_KeyText, zId_Key_NAME, zId_Key_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 4, VALUE_OPT_GQ_PARAMS, + /* equiv idx, value */ 4, VALUE_OPT_GQ_PARAMS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ GQ_PARAMS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zGq_ParamsText, zGq_Params_NAME, zGq_Params_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 5, VALUE_OPT_GQ_KEYS, + /* equiv idx, value */ 5, VALUE_OPT_GQ_KEYS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ GQ_KEYS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zGq_KeysText, zGq_Keys_NAME, zGq_Keys_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 6, VALUE_OPT_HOST_KEY, + /* equiv idx, value */ 6, VALUE_OPT_HOST_KEY, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ HOST_KEY_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zHost_KeyText, zHost_Key_NAME, zHost_Key_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 7, VALUE_OPT_IFFKEY, + /* equiv idx, value */ 7, VALUE_OPT_IFFKEY, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ IFFKEY_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zIffkeyText, zIffkey_NAME, zIffkey_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 8, VALUE_OPT_ISSUER_NAME, + /* equiv idx, value */ 8, VALUE_OPT_ISSUER_NAME, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ISSUER_NAME_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zIssuer_NameText, zIssuer_Name_NAME, zIssuer_Name_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 9, VALUE_OPT_MD5KEY, + /* equiv idx, value */ 9, VALUE_OPT_MD5KEY, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MD5KEY_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zMd5keyText, zMd5key_NAME, zMd5key_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 10, VALUE_OPT_MODULUS, + /* equiv idx, value */ 10, VALUE_OPT_MODULUS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MODULUS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptModulus, + /* desc, NAME, name */ zModulusText, zModulus_NAME, zModulus_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 11, VALUE_OPT_PVT_CERT, + /* equiv idx, value */ 11, VALUE_OPT_PVT_CERT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PVT_CERT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zPvt_CertText, zPvt_Cert_NAME, zPvt_Cert_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 12, VALUE_OPT_PVT_PASSWD, + /* equiv idx, value */ 12, VALUE_OPT_PVT_PASSWD, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PVT_PASSWD_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zPvt_PasswdText, zPvt_Passwd_NAME, zPvt_Passwd_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 13, VALUE_OPT_GET_PVT_PASSWD, + /* equiv idx, value */ 13, VALUE_OPT_GET_PVT_PASSWD, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ GET_PVT_PASSWD_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zGet_Pvt_PasswdText, zGet_Pvt_Passwd_NAME, zGet_Pvt_Passwd_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 14, VALUE_OPT_SIGN_KEY, + /* equiv idx, value */ 14, VALUE_OPT_SIGN_KEY, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SIGN_KEY_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSign_KeyText, zSign_Key_NAME, zSign_Key_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 15, VALUE_OPT_SUBJECT_NAME, + /* equiv idx, value */ 15, VALUE_OPT_SUBJECT_NAME, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SUBJECT_NAME_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSubject_NameText, zSubject_Name_NAME, zSubject_Name_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 16, VALUE_OPT_TRUSTED_CERT, + /* equiv idx, value */ 16, VALUE_OPT_TRUSTED_CERT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TRUSTED_CERT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zTrusted_CertText, zTrusted_Cert_NAME, zTrusted_Cert_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 17, VALUE_OPT_MV_PARAMS, + /* equiv idx, value */ 17, VALUE_OPT_MV_PARAMS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MV_PARAMS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zMv_ParamsText, zMv_Params_NAME, zMv_Params_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 18, VALUE_OPT_MV_KEYS, + /* equiv idx, value */ 18, VALUE_OPT_MV_KEYS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MV_KEYS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zMv_KeysText, zMv_Keys_NAME, zMv_Keys_Name, + /* disablement strs */ NULL, NULL }, + +#ifdef NO_OPTIONAL_OPT_ARGS +# define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT +#else +# define VERSION_OPT_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \ + OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT +#endif + + { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERSION_OPT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ DOVERPROC, + /* desc, NAME, name */ zVersionText, NULL, zVersion_Name, + /* disablement strs */ NULL, NULL }, + +#undef VERSION_OPT_FLAGS + + + { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doUsageOpt, + /* desc, NAME, name */ zHelpText, NULL, zHelp_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionPagedUsage, + /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) + | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, NOLIMIT, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \ + | OPTST_DISABLE_IMM, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionLoadOpt, + /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name, + /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx } +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Ntp_Keygen Option Environment + */ +tSCC zPROGNAME[] = "NTP_KEYGEN"; +tSCC zUsageTitle[] = +"ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.4p5\n\ +USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n"; +tSCC zRcName[] = ".ntprc"; +tSCC* apzHomeList[] = { + "$HOME", + ".", + NULL }; + +tSCC zBugsAddr[] = "http://bugs.ntp.isc.org, bugs@ntp.org"; +#define zExplain NULL +tSCC zDetail[] = "\n\ +If there is no new host key, look for an existing one.\n\ +If one is not found, create it.\n"; +tSCC zFullVersion[] = NTP_KEYGEN_FULL_VERSION; +/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 408 */ + +#if defined(ENABLE_NLS) +# define OPTPROC_BASE OPTPROC_TRANSLATE + static tOptionXlateProc translate_option_strings; +#else +# define OPTPROC_BASE OPTPROC_NONE +# define translate_option_strings NULL +#endif /* ENABLE_NLS */ + +tOptions ntp_keygenOptions = { + OPTIONS_STRUCT_VERSION, + 0, NULL, /* original argc + argv */ + ( OPTPROC_BASE + + OPTPROC_ERRSTOP + + OPTPROC_SHORTOPT + + OPTPROC_LONGOPT + + OPTPROC_NO_REQ_OPT + + OPTPROC_ENVIRON + + OPTPROC_NO_ARGS + + OPTPROC_HAS_IMMED ), + 0, NULL, /* current option index, current option */ + NULL, NULL, zPROGNAME, + zRcName, zCopyright, zCopyrightNotice, + zFullVersion, apzHomeList, zUsageTitle, + zExplain, zDetail, optDesc, + zBugsAddr, /* address to send bugs to */ + NULL, NULL, /* extensions/saved state */ + optionUsage, /* usage procedure */ + translate_option_strings, /* translation procedure */ + /* + * Indexes to special options + */ + { INDEX_OPT_MORE_HELP, + INDEX_OPT_SAVE_OPTS, + NO_EQUIVALENT /* index of '-#' option */, + NO_EQUIVALENT /* index of default opt */ + }, + 24 /* full option count */, 19 /* user option count */ +}; + +/* + * Create the static procedure(s) declared above. + */ +static void +doUsageOpt( + tOptions* pOptions, + tOptDesc* pOptDesc ) +{ + USAGE( EXIT_SUCCESS ); +} + +#if ! defined(TEST_NTP_KEYGEN_OPTS) + +/* * * * * * * + * + * For the set-debug-level option, when DEBUG is #define-d. + */ +#ifdef DEBUG +static void +doOptSet_Debug_Level( + tOptions* pOptions, + tOptDesc* pOptDesc ) +{ + /* extracted from ../include/debug-opt.def, line 29 */ +DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg ); +} +#endif /* defined DEBUG */ + +#endif /* defined(TEST_NTP_KEYGEN_OPTS) */ + +/* * * * * * * + * + * For the modulus option, when OPENSSL is #define-d. + */ +#ifdef OPENSSL +static void +doOptModulus( + tOptions* pOptions, + tOptDesc* pOptDesc ) +{ + static const struct {const int rmin, rmax;} rng[ 1 ] = { + { 256, 2048 } }; + int val; + int ix; + char const* pzIndent = "\t\t\t\t "; + extern FILE* option_usage_fp; + + if (pOptDesc == NULL) /* usage is requesting range list + option_usage_fp has already been set */ + goto emit_ranges; + + val = atoi( pOptDesc->optArg.argString ); + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == INT_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + option_usage_fp = stderr; + fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"), + pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString); + pzIndent = "\t"; + + emit_ranges: + fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"), + pzIndent, rng[0].rmin, rng[0].rmax ); + if (pOptDesc == NULL) + return; + + USAGE( EXIT_FAILURE ); + /* NOTREACHED */ + return; + + valid_return: + pOptDesc->optArg.argInt = val; +} +#endif /* defined OPENSSL */ + +/* extracted from /usr/local/gnu/share/autogen/optmain.tpl near line 92 */ + +#if defined(TEST_NTP_KEYGEN_OPTS) /* TEST MAIN PROCEDURE: */ + +int +main( int argc, char** argv ) +{ + int res = EXIT_SUCCESS; + (void)optionProcess( &ntp_keygenOptions, argc, argv ); + { + void optionPutShell( tOptions* ); + optionPutShell( &ntp_keygenOptions ); + } + return res; +} +#endif /* defined TEST_NTP_KEYGEN_OPTS */ +/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 514 */ + +#if ENABLE_NLS +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <autoopts/usage-txt.h> + +static char* AO_gettext( char const* pz ); +static void coerce_it(void** s); + +static char* +AO_gettext( char const* pz ) +{ + char* pzRes; + if (pz == NULL) + return NULL; + pzRes = _(pz); + if (pzRes == pz) + return pzRes; + pzRes = strdup( pzRes ); + if (pzRes == NULL) { + fputs( _("No memory for duping translated strings\n"), stderr ); + exit( EXIT_FAILURE ); + } + return pzRes; +} + +static void coerce_it(void** s) { *s = AO_gettext(*s); } +#define COERSION(_f) \ + coerce_it((void*)&(ntp_keygenOptions._f)) + +/* + * This invokes the translation code (e.g. gettext(3)). + */ +static void +translate_option_strings( void ) +{ + /* + * Guard against re-translation. It won't work. The strings will have + * been changed by the first pass through this code. One shot only. + */ + if (option_usage_text.field_ct == 0) + return; + /* + * Do the translations. The first pointer follows the field count field. + * The field count field is the size of a pointer. + */ + { + char** ppz = (char**)(void*)&(option_usage_text); + int ix = option_usage_text.field_ct; + + do { + ppz++; + *ppz = AO_gettext(*ppz); + } while (--ix > 0); + } + option_usage_text.field_ct = 0; + + { + tOptDesc* pOD = ntp_keygenOptions.pOptDesc; + int ix = ntp_keygenOptions.optCt; + + for (;;) { + pOD->pzText = AO_gettext(pOD->pzText); + pOD->pz_NAME = AO_gettext(pOD->pz_NAME); + pOD->pz_Name = AO_gettext(pOD->pz_Name); + pOD->pz_DisableName = AO_gettext(pOD->pz_DisableName); + pOD->pz_DisablePfx = AO_gettext(pOD->pz_DisablePfx); + if (--ix <= 0) + break; + pOD++; + } + } + COERSION(pzCopyright); + COERSION(pzCopyNotice); + COERSION(pzFullVersion); + COERSION(pzUsageTitle); + COERSION(pzExplain); + COERSION(pzDetail); +} + +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +/* ntp-keygen-opts.c ends here */ diff --git a/contrib/ntp/util/ntp-keygen-opts.def b/contrib/ntp/util/ntp-keygen-opts.def new file mode 100644 index 000000000000..1e5d988c2967 --- /dev/null +++ b/contrib/ntp/util/ntp-keygen-opts.def @@ -0,0 +1,209 @@ +/* -*- Mode: Text -*- */ + +autogen definitions options; + +#include copyright.def +#include homerc.def +#include autogen-version.def + +prog-name = "ntp-keygen"; +prog-title = "Create a NTP host key"; +package = ntp; + +test-main; + +include = '#include <stdlib.h>'; +#include version.def + +flag = { + name = certificate; + value = c; + arg-type = string; + arg-name = scheme; + ifdef = OPENSSL; + descrip = "certificate scheme"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +#include debug-opt.def + +flag = { + name = id-key; + value = e; + ifdef = OPENSSL; + descrip = "Write identity keys"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = gq-params; + value = G; + ifdef = OPENSSL; + descrip = "Generate GQ parameters and keys"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = gq-keys; + value = g; + ifdef = OPENSSL; + descrip = "update GQ keys"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = host-key; + value = H; + ifdef = OPENSSL; + descrip = "generate RSA host key"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = iffkey; + value = I; + ifdef = OPENSSL; + descrip = "generate IFF parameters"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = issuer-name; + value = i; + ifdef = OPENSSL; + descrip = "set issuer name"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = md5key; + value = M; + descrip = "generate MD5 keys"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = modulus; + value = m; + arg-type = number; + arg-name = modulus; + arg-range = '256->2048'; + ifdef = OPENSSL; + descrip = "modulus"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = pvt-cert; + value = P; + ifdef = OPENSSL; + descrip = "generate PC private certificate"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = pvt-passwd; + value = p; + ifdef = OPENSSL; + arg-type = string; + arg-name = passwd; + descrip = "output private password"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = get-pvt-passwd; + value = q; + ifdef = OPENSSL; + arg-type = string; + arg-name = passwd; + descrip = "input private password"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = sign-key; + value = S; + arg-type = string; + arg-name = sign; + ifdef = OPENSSL; + descrip = "generate sign key (RSA or DSA)"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = subject-name; + value = s; + arg-type = string; + arg-name = host; + ifdef = OPENSSL; + descrip = "set subject name"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = trusted-cert; + value = T; + ifdef = OPENSSL; + descrip = "trusted certificate (TC scheme)"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = mv-params; + value = V; + arg-type = number; + arg-name = num; + ifdef = OPENSSL; + descrip = "generate <num> MV parameters"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +flag = { + name = mv-keys; + value = v; + arg-type = number; + arg-name = num; + ifdef = OPENSSL; + descrip = "update <num> MV keys"; + doc = <<- _EndOfDoc_ + Just some descriptive text. + _EndOfDoc_; +}; + +detail = <<- _EODetail_ + If there is no new host key, look for an existing one. + If one is not found, create it. + _EODetail_; diff --git a/contrib/ntp/util/ntp-keygen-opts.h b/contrib/ntp/util/ntp-keygen-opts.h new file mode 100644 index 000000000000..a22a5e7fe64f --- /dev/null +++ b/contrib/ntp/util/ntp-keygen-opts.h @@ -0,0 +1,318 @@ +/* + * EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.h) + * + * It has been AutoGen-ed Sunday August 17, 2008 at 05:27:32 AM EDT + * From the definitions ntp-keygen-opts.def + * and the template file options + * + * Generated from AutoOpts 29:0:4 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This header file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * ntp-keygen author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * ntp-keygen copyright 1970-2008 David L. Mills and/or others - all rights reserved + * + * see html/copyright.html + */ +/* + * This file contains the programmatic interface to the Automated + * Options generated for the ntp-keygen program. + * These macros are documented in the AutoGen info file in the + * "AutoOpts" chapter. Please refer to that doc for usage help. + */ +#ifndef AUTOOPTS_NTP_KEYGEN_OPTS_H_GUARD +#define AUTOOPTS_NTP_KEYGEN_OPTS_H_GUARD +#include "config.h" +#include <autoopts/options.h> + +/* + * Ensure that the library used for compiling this generated header is at + * least as new as the version current when the header template was released + * (not counting patch version increments). Also ensure that the oldest + * tolerable version is at least as old as what was current when the header + * template was released. + */ +#define AO_TEMPLATE_VERSION 118784 +#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ + || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) +# error option template version mismatches autoopts/options.h header + Choke Me. +#endif + +/* + * Enumeration of each option: + */ +typedef enum { + INDEX_OPT_CERTIFICATE = 0, + INDEX_OPT_DEBUG_LEVEL = 1, + INDEX_OPT_SET_DEBUG_LEVEL = 2, + INDEX_OPT_ID_KEY = 3, + INDEX_OPT_GQ_PARAMS = 4, + INDEX_OPT_GQ_KEYS = 5, + INDEX_OPT_HOST_KEY = 6, + INDEX_OPT_IFFKEY = 7, + INDEX_OPT_ISSUER_NAME = 8, + INDEX_OPT_MD5KEY = 9, + INDEX_OPT_MODULUS = 10, + INDEX_OPT_PVT_CERT = 11, + INDEX_OPT_PVT_PASSWD = 12, + INDEX_OPT_GET_PVT_PASSWD = 13, + INDEX_OPT_SIGN_KEY = 14, + INDEX_OPT_SUBJECT_NAME = 15, + INDEX_OPT_TRUSTED_CERT = 16, + INDEX_OPT_MV_PARAMS = 17, + INDEX_OPT_MV_KEYS = 18, + INDEX_OPT_VERSION = 19, + INDEX_OPT_HELP = 20, + INDEX_OPT_MORE_HELP = 21, + INDEX_OPT_SAVE_OPTS = 22, + INDEX_OPT_LOAD_OPTS = 23 +} teOptIndex; + +#define OPTION_CT 24 +#define NTP_KEYGEN_VERSION "4.2.4p5" +#define NTP_KEYGEN_FULL_VERSION "ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.4p5" + +/* + * Interface defines for all options. Replace "n" with the UPPER_CASED + * option name (as in the teOptIndex enumeration above). + * e.g. HAVE_OPT( CERTIFICATE ) + */ +#define DESC(n) (ntp_keygenOptions.pOptDesc[INDEX_OPT_## n]) +#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) +#define OPT_ARG(n) (DESC(n).optArg.argString) +#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) +#define COUNT_OPT(n) (DESC(n).optOccCt) +#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) +#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) +#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) +#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) +#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) +#define CLEAR_OPT(n) STMTS( \ + DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ + if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \ + DESC(n).fOptState |= OPTST_DISABLED; \ + DESC(n).optCookie = NULL ) + +/* + * Make sure there are no #define name conflicts with the option names + */ +#ifndef NO_OPTION_NAME_WARNINGS +# ifdef CERTIFICATE +# warning undefining CERTIFICATE due to option name conflict +# undef CERTIFICATE +# endif +# ifdef DEBUG_LEVEL +# warning undefining DEBUG_LEVEL due to option name conflict +# undef DEBUG_LEVEL +# endif +# ifdef SET_DEBUG_LEVEL +# warning undefining SET_DEBUG_LEVEL due to option name conflict +# undef SET_DEBUG_LEVEL +# endif +# ifdef ID_KEY +# warning undefining ID_KEY due to option name conflict +# undef ID_KEY +# endif +# ifdef GQ_PARAMS +# warning undefining GQ_PARAMS due to option name conflict +# undef GQ_PARAMS +# endif +# ifdef GQ_KEYS +# warning undefining GQ_KEYS due to option name conflict +# undef GQ_KEYS +# endif +# ifdef HOST_KEY +# warning undefining HOST_KEY due to option name conflict +# undef HOST_KEY +# endif +# ifdef IFFKEY +# warning undefining IFFKEY due to option name conflict +# undef IFFKEY +# endif +# ifdef ISSUER_NAME +# warning undefining ISSUER_NAME due to option name conflict +# undef ISSUER_NAME +# endif +# ifdef MD5KEY +# warning undefining MD5KEY due to option name conflict +# undef MD5KEY +# endif +# ifdef MODULUS +# warning undefining MODULUS due to option name conflict +# undef MODULUS +# endif +# ifdef PVT_CERT +# warning undefining PVT_CERT due to option name conflict +# undef PVT_CERT +# endif +# ifdef PVT_PASSWD +# warning undefining PVT_PASSWD due to option name conflict +# undef PVT_PASSWD +# endif +# ifdef GET_PVT_PASSWD +# warning undefining GET_PVT_PASSWD due to option name conflict +# undef GET_PVT_PASSWD +# endif +# ifdef SIGN_KEY +# warning undefining SIGN_KEY due to option name conflict +# undef SIGN_KEY +# endif +# ifdef SUBJECT_NAME +# warning undefining SUBJECT_NAME due to option name conflict +# undef SUBJECT_NAME +# endif +# ifdef TRUSTED_CERT +# warning undefining TRUSTED_CERT due to option name conflict +# undef TRUSTED_CERT +# endif +# ifdef MV_PARAMS +# warning undefining MV_PARAMS due to option name conflict +# undef MV_PARAMS +# endif +# ifdef MV_KEYS +# warning undefining MV_KEYS due to option name conflict +# undef MV_KEYS +# endif +#else /* NO_OPTION_NAME_WARNINGS */ +# undef CERTIFICATE +# undef DEBUG_LEVEL +# undef SET_DEBUG_LEVEL +# undef ID_KEY +# undef GQ_PARAMS +# undef GQ_KEYS +# undef HOST_KEY +# undef IFFKEY +# undef ISSUER_NAME +# undef MD5KEY +# undef MODULUS +# undef PVT_CERT +# undef PVT_PASSWD +# undef GET_PVT_PASSWD +# undef SIGN_KEY +# undef SUBJECT_NAME +# undef TRUSTED_CERT +# undef MV_PARAMS +# undef MV_KEYS +#endif /* NO_OPTION_NAME_WARNINGS */ + +/* + * Interface defines for specific options. + */ +#ifdef OPENSSL +#define VALUE_OPT_CERTIFICATE 'c' +#endif /* OPENSSL */ +#ifdef DEBUG +#define VALUE_OPT_DEBUG_LEVEL 'd' +#endif /* DEBUG */ +#ifdef DEBUG +#define VALUE_OPT_SET_DEBUG_LEVEL 'D' +#endif /* DEBUG */ +#ifdef OPENSSL +#define VALUE_OPT_ID_KEY 'e' +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_GQ_PARAMS 'G' +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_GQ_KEYS 'g' +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_HOST_KEY 'H' +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_IFFKEY 'I' +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_ISSUER_NAME 'i' +#endif /* OPENSSL */ +#define VALUE_OPT_MD5KEY 'M' +#ifdef OPENSSL +#define VALUE_OPT_MODULUS 'm' +#define OPT_VALUE_MODULUS (DESC(MODULUS).optArg.argInt) +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_PVT_CERT 'P' +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_PVT_PASSWD 'p' +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_GET_PVT_PASSWD 'q' +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_SIGN_KEY 'S' +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_SUBJECT_NAME 's' +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_TRUSTED_CERT 'T' +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_MV_PARAMS 'V' +#define OPT_VALUE_MV_PARAMS (DESC(MV_PARAMS).optArg.argInt) +#endif /* OPENSSL */ +#ifdef OPENSSL +#define VALUE_OPT_MV_KEYS 'v' +#define OPT_VALUE_MV_KEYS (DESC(MV_KEYS).optArg.argInt) +#endif /* OPENSSL */ + +#define VALUE_OPT_VERSION 'v' +#define VALUE_OPT_HELP '?' +#define VALUE_OPT_MORE_HELP '!' +#define VALUE_OPT_SAVE_OPTS '>' +#define VALUE_OPT_LOAD_OPTS '<' +#define SET_OPT_SAVE_OPTS(a) STMTS( \ + DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(SAVE_OPTS).fOptState |= OPTST_SET; \ + DESC(SAVE_OPTS).optArg.argString = (char const*)(a) ) +/* + * Interface defines not associated with particular options + */ +#define ERRSKIP_OPTERR STMTS( ntp_keygenOptions.fOptSet &= ~OPTPROC_ERRSTOP ) +#define ERRSTOP_OPTERR STMTS( ntp_keygenOptions.fOptSet |= OPTPROC_ERRSTOP ) +#define RESTART_OPT(n) STMTS( \ + ntp_keygenOptions.curOptIdx = (n); \ + ntp_keygenOptions.pzCurOpt = NULL ) +#define START_OPT RESTART_OPT(1) +#define USAGE(c) (*ntp_keygenOptions.pUsageProc)( &ntp_keygenOptions, c ) +/* extracted from /usr/local/gnu/share/autogen/opthead.tpl near line 360 */ + +/* * * * * * + * + * Declare the ntp-keygen option descriptor. + */ +#ifdef __cplusplus +extern "C" { +#endif + +extern tOptions ntp_keygenOptions; + +#ifndef _ +# if ENABLE_NLS +# include <stdio.h> + static inline char* aoGetsText( char const* pz ) { + if (pz == NULL) return NULL; + return (char*)gettext( pz ); + } +# define _(s) aoGetsText(s) +# else /* ENABLE_NLS */ +# define _(s) s +# endif /* ENABLE_NLS */ +#endif + +#ifdef __cplusplus +} +#endif +#endif /* AUTOOPTS_NTP_KEYGEN_OPTS_H_GUARD */ +/* ntp-keygen-opts.h ends here */ diff --git a/contrib/ntp/util/ntp-keygen-opts.menu b/contrib/ntp/util/ntp-keygen-opts.menu new file mode 100644 index 000000000000..bc5cfe9e19d8 --- /dev/null +++ b/contrib/ntp/util/ntp-keygen-opts.menu @@ -0,0 +1 @@ +* ntp-keygen Invocation:: Invoking ntp-keygen diff --git a/contrib/ntp/util/ntp-keygen-opts.texi b/contrib/ntp/util/ntp-keygen-opts.texi new file mode 100644 index 000000000000..19b77f8095e5 --- /dev/null +++ b/contrib/ntp/util/ntp-keygen-opts.texi @@ -0,0 +1,364 @@ +@node ntp-keygen Invocation +@section Invoking ntp-keygen +@pindex ntp-keygen +@cindex Create a NTP host key +@ignore +# +# EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.texi) +# +# It has been AutoGen-ed Sunday August 17, 2008 at 05:27:34 AM EDT +# From the definitions ntp-keygen-opts.def +# and the template file aginfo.tpl +@end ignore +This program has no explanation. + +If there is no new host key, look for an existing one. +If one is not found, create it. + +This section was generated by @strong{AutoGen}, +the aginfo template and the option descriptions for the @command{ntp-keygen} program. It documents the ntp-keygen usage text and option meanings. + +This software is released under a specialized copyright license. + +@menu +* ntp-keygen usage:: ntp-keygen usage help (-?) +* ntp-keygen certificate:: certificate option (-c) +* ntp-keygen debug-level:: debug-level option (-d) +* ntp-keygen get-pvt-passwd:: get-pvt-passwd option (-q) +* ntp-keygen gq-keys:: gq-keys option (-g) +* ntp-keygen gq-params:: gq-params option (-G) +* ntp-keygen host-key:: host-key option (-H) +* ntp-keygen id-key:: id-key option (-e) +* ntp-keygen iffkey:: iffkey option (-I) +* ntp-keygen issuer-name:: issuer-name option (-i) +* ntp-keygen md5key:: md5key option (-M) +* ntp-keygen modulus:: modulus option (-m) +* ntp-keygen mv-keys:: mv-keys option (-v) +* ntp-keygen mv-params:: mv-params option (-V) +* ntp-keygen pvt-cert:: pvt-cert option (-P) +* ntp-keygen pvt-passwd:: pvt-passwd option (-p) +* ntp-keygen set-debug-level:: set-debug-level option (-D) +* ntp-keygen sign-key:: sign-key option (-S) +* ntp-keygen subject-name:: subject-name option (-s) +* ntp-keygen trusted-cert:: trusted-cert option (-T) +@end menu + +@node ntp-keygen usage +@subsection ntp-keygen usage help (-?) +@cindex ntp-keygen usage + +This is the automatically generated usage text for ntp-keygen: + +@exampleindent 0 +@example +Using OpenSSL version 90704f +ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.5p113 +USAGE: ntp-keygen [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... + Flg Arg Option-Name Description + -c Str certificate certificate scheme + -d no debug-level Increase output debug message level + - may appear multiple times + -D Str set-debug-level Set the output debug message level + - may appear multiple times + -e no id-key Write IFF or GQ identity keys + -G no gq-params Generate GQ parameters and keys + -H no host-key generate RSA host key + -I no iffkey generate IFF parameters + -i Str issuer-name set issuer name + -M no md5key generate MD5 keys + -m Num modulus modulus + it must lie in the range: 256 to 2048 + -P no pvt-cert generate PC private certificate + -p Str pvt-passwd output private password + -q Str get-pvt-passwd input private password + -S Str sign-key generate sign key (RSA or DSA) + -s Str subject-name set subject name + -T no trusted-cert trusted certificate (TC scheme) + -V Num mv-params generate <num> MV parameters + -v Num mv-keys update <num> MV keys + opt version Output version information and exit + -? no help Display usage information and exit + -! no more-help Extended usage information passed thru pager + -> opt save-opts Save the option state to a config file + -< Str load-opts Load options from a config file + - disabled as --no-load-opts + - may appear multiple times + +Options are specified by doubled hyphens and their name +or by a single hyphen and the flag character. + +The following option preset mechanisms are supported: + - reading file /users/stenn/.ntprc + - reading file /deacon/backroom/snaps/ntp-stable/util/.ntprc + - examining environment variables named NTP_KEYGEN_* + +If there is no new host key, look for an existing one. +If one is not found, create it. + +please send bug reports to: http://bugs.ntp.org, bugs@@ntp.org +@end example +@exampleindent 4 + +@node ntp-keygen certificate +@subsection certificate option (-c) +@cindex ntp-keygen-certificate + +This is the ``certificate scheme'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen debug-level +@subsection debug-level option (-d) +@cindex ntp-keygen-debug-level + +This is the ``increase output debug message level'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +may appear an unlimited number of times. +@item +must be compiled in by defining @code{DEBUG} during the compilation. +@end itemize + +Increase the debugging message output level. + +@node ntp-keygen set-debug-level +@subsection set-debug-level option (-D) +@cindex ntp-keygen-set-debug-level + +This is the ``set the output debug message level'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +may appear an unlimited number of times. +@item +must be compiled in by defining @code{DEBUG} during the compilation. +@end itemize + +Set the output debugging level. Can be supplied multiple times, +but each overrides the previous value(s). + +@node ntp-keygen id-key +@subsection id-key option (-e) +@cindex ntp-keygen-id-key + +This is the ``write identity keys'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen gq-params +@subsection gq-params option (-G) +@cindex ntp-keygen-gq-params + +This is the ``generate gq parameters and keys'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen gq-keys +@subsection gq-keys option (-g) +@cindex ntp-keygen-gq-keys + +This is the ``update gq keys'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen host-key +@subsection host-key option (-H) +@cindex ntp-keygen-host-key + +This is the ``generate rsa host key'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen iffkey +@subsection iffkey option (-I) +@cindex ntp-keygen-iffkey + +This is the ``generate iff parameters'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen issuer-name +@subsection issuer-name option (-i) +@cindex ntp-keygen-issuer-name + +This is the ``set issuer name'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen md5key +@subsection md5key option (-M) +@cindex ntp-keygen-md5key + +This is the ``generate md5 keys'' option. +Just some descriptive text. + +@node ntp-keygen modulus +@subsection modulus option (-m) +@cindex ntp-keygen-modulus + +This is the ``modulus'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen pvt-cert +@subsection pvt-cert option (-P) +@cindex ntp-keygen-pvt-cert + +This is the ``generate pc private certificate'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen pvt-passwd +@subsection pvt-passwd option (-p) +@cindex ntp-keygen-pvt-passwd + +This is the ``output private password'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen get-pvt-passwd +@subsection get-pvt-passwd option (-q) +@cindex ntp-keygen-get-pvt-passwd + +This is the ``input private password'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen sign-key +@subsection sign-key option (-S) +@cindex ntp-keygen-sign-key + +This is the ``generate sign key (rsa or dsa)'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen subject-name +@subsection subject-name option (-s) +@cindex ntp-keygen-subject-name + +This is the ``set subject name'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen trusted-cert +@subsection trusted-cert option (-T) +@cindex ntp-keygen-trusted-cert + +This is the ``trusted certificate (tc scheme)'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen mv-params +@subsection mv-params option (-V) +@cindex ntp-keygen-mv-params + +This is the ``generate <num> mv parameters'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. + +@node ntp-keygen mv-keys +@subsection mv-keys option (-v) +@cindex ntp-keygen-mv-keys + +This is the ``update <num> mv keys'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +must be compiled in by defining @code{OPENSSL} during the compilation. +@end itemize + +Just some descriptive text. diff --git a/contrib/ntp/util/ntp-keygen.1 b/contrib/ntp/util/ntp-keygen.1 new file mode 100644 index 000000000000..3bf7d0cd86d8 --- /dev/null +++ b/contrib/ntp/util/ntp-keygen.1 @@ -0,0 +1,176 @@ +.TH NTP-KEYGEN 1 2008-08-17 "(ntp 4.2.4p5)" "Programmer's Manual" +.\" EDIT THIS FILE WITH CAUTION (ntp-keygen.1) +.\" +.\" It has been AutoGen-ed Sunday August 17, 2008 at 05:27:34 AM EDT +.\" From the definitions ntp-keygen-opts.def +.\" and the template file agman1.tpl +.\" +.SH NAME +ntp-keygen \- Create a NTP host key +.SH SYNOPSIS +.B ntp-keygen +.\" Mixture of short (flag) options and long options +.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..." +.PP +All arguments must be options. +.SH "DESCRIPTION" +This manual page documents, briefly, the \fBntp-keygen\fP command. +If there is no new host key, look for an existing one. +If one is not found, create it. +.SH OPTIONS +.TP +.BR \-c " \fIscheme\fP, " \--certificate "=" \fIscheme\fP +certificate scheme. +.sp +Just some descriptive text. +.TP +.BR \-d ", " \--debug-level +Increase output debug message level. +This option may appear an unlimited number of times. +.sp +Increase the debugging message output level. +.TP +.BR \-D " \fIstring\fP, " \--set-debug-level "=" \fIstring\fP +Set the output debug message level. +This option may appear an unlimited number of times. +.sp +Set the output debugging level. Can be supplied multiple times, +but each overrides the previous value(s). +.TP +.BR \-e ", " \--id-key +Write identity keys. +.sp +Just some descriptive text. +.TP +.BR \-G ", " \--gq-params +Generate GQ parameters and keys. +.sp +Just some descriptive text. +.TP +.BR \-g ", " \--gq-keys +update GQ keys. +.sp +Just some descriptive text. +.TP +.BR \-H ", " \--host-key +generate RSA host key. +.sp +Just some descriptive text. +.TP +.BR \-I ", " \--iffkey +generate IFF parameters. +.sp +Just some descriptive text. +.TP +.BR \-i ", " \--issuer-name +set issuer name. +.sp +Just some descriptive text. +.TP +.BR \-M ", " \--md5key +generate MD5 keys. +.sp +Just some descriptive text. +.TP +.BR \-m " \fImodulus\fP, " \--modulus "=" \fImodulus\fP +modulus. +This option takes an integer number as its argument. +The value of \fImodulus\fP is constrained to being: +.in +4 +.nf +.na +in the range 256 through 2048 +.fi +.in -4 +.sp +Just some descriptive text. +.TP +.BR \-P ", " \--pvt-cert +generate PC private certificate. +.sp +Just some descriptive text. +.TP +.BR \-p " \fIpasswd\fP, " \--pvt-passwd "=" \fIpasswd\fP +output private password. +.sp +Just some descriptive text. +.TP +.BR \-q " \fIpasswd\fP, " \--get-pvt-passwd "=" \fIpasswd\fP +input private password. +.sp +Just some descriptive text. +.TP +.BR \-S " \fIsign\fP, " \--sign-key "=" \fIsign\fP +generate sign key (RSA or DSA). +.sp +Just some descriptive text. +.TP +.BR \-s " \fIhost\fP, " \--subject-name "=" \fIhost\fP +set subject name. +.sp +Just some descriptive text. +.TP +.BR \-T ", " \--trusted-cert +trusted certificate (TC scheme). +.sp +Just some descriptive text. +.TP +.BR \-V " \fInum\fP, " \--mv-params "=" \fInum\fP +generate <num> MV parameters. +This option takes an integer number as its argument. +.sp +Just some descriptive text. +.TP +.BR \-v " \fInum\fP, " \--mv-keys "=" \fInum\fP +update <num> MV keys. +This option takes an integer number as its argument. +.sp +Just some descriptive text. +.TP +.BR \-? , " \--help" +Display usage information and exit. +.TP +.BR \-! , " \--more-help" +Extended usage information passed thru pager. +.TP +.BR \-> " [\fIrcfile\fP]," " \--save-opts" "[=\fIrcfile\fP]" +Save the option state to \fIrcfile\fP. The default is the \fIlast\fP +configuration file listed in the \fBOPTION PRESETS\fP section, below. +.TP +.BR \-< " \fIrcfile\fP," " \--load-opts" "=\fIrcfile\fP," " \--no-load-opts" +Load options from \fIrcfile\fP. +The \fIno-load-opts\fP form will disable the loading +of earlier RC/INI files. \fI--no-load-opts\fP is handled early, +out of order. +.TP +.BR \-v " [{\fIv|c|n\fP}]," " \--version" "[=\fI{v|c|n}\fP]" +Output version of program and exit. The default mode is `v', a simple +version. The `c' mode will print copyright information and `n' will +print the full copyright notice. +.SH OPTION PRESETS +Any option that is not marked as \fInot presettable\fP may be preset +by loading values from configuration ("RC" or ".INI") file(s) and values from +environment variables named: +.nf + \fBNTP_KEYGEN_<option-name>\fP or \fBNTP_KEYGEN\fP +.fi +.aj +The environmental presets take precedence (are processed later than) +the configuration files. +The \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP". +If any of these are directories, then the file \fI.ntprc\fP +is searched for within those directories. +.SH AUTHOR +David L. Mills and/or others +.br +Please send bug reports to: http://bugs.ntp.isc.org, bugs@ntp.org + +.PP +.nf +.na +see html/copyright.html +.fi +.ad +.PP +This manual page was \fIAutoGen\fP-erated from the \fBntp-keygen\fP +option definitions. diff --git a/contrib/ntp/util/ntp-keygen.c b/contrib/ntp/util/ntp-keygen.c index 2d91652beeff..6c1451889551 100644 --- a/contrib/ntp/util/ntp-keygen.c +++ b/contrib/ntp/util/ntp-keygen.c @@ -96,8 +96,11 @@ # include <sys/types.h> #endif #include "ntp_types.h" +#include "ntp_random.h" #include "l_stdlib.h" +#include "ntp-keygen-opts.h" + #ifdef SYS_WINNT extern int ntp_getopt P((int, char **, const char *)); #define getopt ntp_getopt @@ -216,6 +219,7 @@ main( ) { struct timeval tv; /* initialization vector */ + int md5key = 0; /* generate MD5 keys */ #ifdef OPENSSL X509 *cert = NULL; /* X509 certificate */ EVP_PKEY *pkey_host = NULL; /* host key */ @@ -223,9 +227,6 @@ main( EVP_PKEY *pkey_iff = NULL; /* IFF parameters */ EVP_PKEY *pkey_gq = NULL; /* GQ parameters */ EVP_PKEY *pkey_mv = NULL; /* MV parameters */ -#endif - int md5key = 0; /* generate MD5 keys */ -#ifdef OPENSSL int hostkey = 0; /* generate RSA keys */ int iffkey = 0; /* generate IFF parameters */ int gqpar = 0; /* generate GQ parameters */ @@ -241,10 +242,10 @@ main( char *grpkey = NULL; /* identity extension */ int nid; /* X509 digest/signature scheme */ FILE *fstr = NULL; /* file handle */ - int iffsw = 0; /* IFF key switch */ + u_int temp; +#define iffsw HAVE_OPT(ID_KEY) #endif /* OPENSSL */ char hostbuf[MAXHOSTNAME + 1]; - u_int temp; #ifdef SYS_WINNT /* Initialize before OpenSSL checks */ @@ -254,7 +255,11 @@ main( #endif #ifdef OPENSSL - if (SSLeay() != OPENSSL_VERSION_NUMBER) { + /* + * OpenSSL version numbers: MNNFFPPS: major minor fix patch status + * We match major, minor, fix and status (not patch) + */ + if ((SSLeay() ^ OPENSSL_VERSION_NUMBER) & ~0xff0L) { fprintf(stderr, "OpenSSL version mismatch. Built against %lx, you have %lx\n", OPENSSL_VERSION_NUMBER, SSLeay()); @@ -282,190 +287,73 @@ main( #endif epoch = tv.tv_sec; rval = 0; - while ((temp = getopt(argc, argv, -#ifdef OPENSSL - "c:deGgHIi:Mm:nPp:q:S:s:TV:v:" -#else - "dM" -#endif - )) != -1) { - switch(temp) { -#ifdef OPENSSL - /* - * -c select public certificate type - */ - case 'c': - scheme = optarg; - continue; -#endif - - /* - * -d debug - */ - case 'd': - debug++; - continue; - -#ifdef OPENSSL - /* - * -e write identity keys - */ - case 'e': - iffsw++; - continue; -#endif + { + int optct = optionProcess(&ntp_keygenOptions, argc, argv); + argc -= optct; + argv += optct; + } #ifdef OPENSSL - /* - * -G generate GQ parameters and keys - */ - case 'G': - gqpar++; - continue; + if (HAVE_OPT( CERTIFICATE )) + scheme = OPT_ARG( CERTIFICATE ); #endif -#ifdef OPENSSL - /* - * -g update GQ keys - */ - case 'g': - gqkey++; - continue; -#endif + debug = DESC(DEBUG_LEVEL).optOccCt; #ifdef OPENSSL - /* - * -H generate host key (RSA) - */ - case 'H': - hostkey++; - continue; -#endif + if (HAVE_OPT( GQ_PARAMS )) + gqpar++; -#ifdef OPENSSL - /* - * -I generate IFF parameters - */ - case 'I': - iffkey++; - continue; -#endif + if (HAVE_OPT( GQ_KEYS )) + gqkey++; -#ifdef OPENSSL - /* - * -i set issuer name - */ - case 'i': - trustname = optarg; - continue; -#endif + if (HAVE_OPT( HOST_KEY )) + hostkey++; - /* - * -M generate MD5 keys - */ - case 'M': - md5key++; - continue; + if (HAVE_OPT( IFFKEY )) + iffkey++; -#ifdef OPENSSL - /* - * -m select modulus (256-2048) - */ - case 'm': - if (sscanf(optarg, "%d", &modulus) != 1) - fprintf(stderr, - "invalid option -m %s\n", optarg); - continue; + if (HAVE_OPT( ISSUER_NAME )) + trustname = OPT_ARG( ISSUER_NAME ); #endif -#ifdef OPENSSL - /* - * -P generate PC private certificate - */ - case 'P': - exten = EXT_KEY_PRIVATE; - continue; -#endif + if (HAVE_OPT( MD5KEY )) + md5key++; #ifdef OPENSSL - /* - * -p output private key password - */ - case 'p': - passwd2 = optarg; - continue; -#endif + if (HAVE_OPT( MODULUS )) + modulus = OPT_VALUE_MODULUS; -#ifdef OPENSSL - /* - * -q input private key password - */ - case 'q': - passwd1 = optarg; - continue; -#endif + if (HAVE_OPT( PVT_CERT )) + exten = EXT_KEY_PRIVATE; -#ifdef OPENSSL - /* - * -S generate sign key (RSA or DSA) - */ - case 'S': - sign = optarg; - continue; -#endif + if (HAVE_OPT( PVT_PASSWD )) + passwd2 = OPT_ARG( PVT_PASSWD ); -#ifdef OPENSSL - /* - * -s set subject name - */ - case 's': - hostname = optarg; - continue; -#endif + if (HAVE_OPT( GET_PVT_PASSWD )) + passwd1 = OPT_ARG( GET_PVT_PASSWD ); -#ifdef OPENSSL - /* - * -T trusted certificate (TC scheme) - */ - case 'T': - exten = EXT_KEY_TRUST; - continue; -#endif + if (HAVE_OPT( SIGN_KEY )) + sign = OPT_ARG( SIGN_KEY ); -#ifdef OPENSSL - /* - * -V <keys> generate MV parameters - */ - case 'V': - mvpar++; - if (sscanf(optarg, "%d", &nkeys) != 1) - fprintf(stderr, - "invalid option -V %s\n", optarg); - continue; -#endif + if (HAVE_OPT( SUBJECT_NAME )) + hostname = OPT_ARG( SUBJECT_NAME ); -#ifdef OPENSSL - /* - * -v <key> update MV keys - */ - case 'v': - mvkey++; - if (sscanf(optarg, "%d", &nkeys) != 1) - fprintf(stderr, - "invalid option -v %s\n", optarg); - continue; -#endif + if (HAVE_OPT( TRUSTED_CERT )) + exten = EXT_KEY_TRUST; - /* - * None of the above. - */ - default: - fprintf(stderr, "Option ignored\n"); - continue; - } + if (HAVE_OPT( MV_PARAMS )) { + mvpar++; + nkeys = OPT_VALUE_MV_PARAMS; } + if (HAVE_OPT( MV_KEYS )) { + mvkey++; + nkeys = OPT_VALUE_MV_KEYS; + } +#endif + if (passwd1 != NULL && passwd2 == NULL) passwd2 = passwd1; #ifdef OPENSSL @@ -512,7 +400,7 @@ main( * If there is no new host key, look for an existing one. If not * found, create it. */ - while (pkey_host == NULL && rval == 0 && !iffsw) { + while (pkey_host == NULL && rval == 0 && !HAVE_OPT(ID_KEY)) { sprintf(filename, "ntpkey_host_%s", hostname); if ((fstr = fopen(filename, "r")) != NULL) { pkey_host = PEM_read_PrivateKey(fstr, NULL, @@ -542,7 +430,7 @@ main( * found, use the host key instead. */ pkey = pkey_sign; - while (pkey_sign == NULL && rval == 0 && !iffsw) { + while (pkey_sign == NULL && rval == 0 && !HAVE_OPT(ID_KEY)) { sprintf(filename, "ntpkey_sign_%s", hostname); if ((fstr = fopen(filename, "r")) != NULL) { pkey_sign = PEM_read_PrivateKey(fstr, NULL, @@ -592,7 +480,7 @@ main( /* * If there is no new GQ file, look for an existing one. */ - if (pkey_gq == NULL && rval == 0 && !iffsw) { + if (pkey_gq == NULL && rval == 0 && !HAVE_OPT(ID_KEY)) { sprintf(filename, "ntpkey_gq_%s", hostname); if ((fstr = fopen(filename, "r")) != NULL) { pkey_gq = PEM_read_PrivateKey(fstr, NULL, NULL, @@ -624,7 +512,7 @@ main( /* * Generate a X509v3 certificate. */ - while (scheme == NULL && rval == 0 && !iffsw) { + while (scheme == NULL && rval == 0 && !HAVE_OPT(ID_KEY)) { sprintf(filename, "ntpkey_cert_%s", hostname); if ((fstr = fopen(filename, "r")) != NULL) { cert = PEM_read_X509(fstr, NULL, NULL, NULL); @@ -647,7 +535,7 @@ main( } scheme = "RSA-MD5"; } - if (pkey != NULL && rval == 0 && !iffsw) { + if (pkey != NULL && rval == 0 && !HAVE_OPT(ID_KEY)) { ectx = EVP_get_digestbyname(scheme); if (ectx == NULL) { fprintf(stderr, @@ -663,13 +551,17 @@ main( * Write the IFF client parameters and keys as a DSA private key * encoded in PEM. Note the private key is obscured. */ - if (pkey_iff != NULL && rval == 0 && iffsw) { + if (pkey_iff != NULL && rval == 0 && HAVE_OPT(ID_KEY)) { DSA *dsa; char *sptr; + char *tld; sptr = strrchr(filename, '.'); + tld = malloc(strlen(sptr)); /* we have an extra byte ... */ + strcpy(tld, 1+sptr); /* ... see? */ sprintf(filename, "ntpkey_IFFkey_%s.%s", trustname, - ++sptr); + tld); + free(tld); fprintf(stderr, "Writing new IFF key %s\n", filename); fprintf(stdout, "# %s\n# %s", filename, ctime(&epoch)); dsa = pkey_iff->pkey.dsa; @@ -746,11 +638,11 @@ gen_md5( fprintf(stderr, "Generating MD5 keys...\n"); str = fheader("MD5key", hostname); - srandom(epoch); + ntp_srandom(epoch); for (i = 1; i <= MD5KEYS; i++) { for (j = 0; j < 16; j++) { while (1) { - temp = random() & 0xff; + temp = ntp_random() & 0xff; if (temp == '#') continue; if (temp > 0x20 && temp < 0x7f) @@ -1742,8 +1634,8 @@ x509 ( ASN1_INTEGER_set(serial, epoch + JAN_1970); X509_set_serialNumber(cert, serial); ASN1_INTEGER_free(serial); - X509_gmtime_adj(X509_get_notBefore(cert), 0L); - X509_gmtime_adj(X509_get_notAfter(cert), YEAR); + X509_time_adj(X509_get_notBefore(cert), 0L, &epoch); + X509_time_adj(X509_get_notAfter(cert), YEAR, &epoch); subj = X509_get_subject_name(cert); X509_NAME_add_entry_by_txt(subj, "commonName", MBSTRING_ASC, (unsigned char *) hostname, strlen(hostname), -1, 0); diff --git a/contrib/ntp/util/ntptime.c b/contrib/ntp/util/ntptime.c index 51111bea6810..8f9d0c339e7c 100644 --- a/contrib/ntp/util/ntptime.c +++ b/contrib/ntp/util/ntptime.c @@ -401,8 +401,8 @@ sprintb( else (void)sprintf(buf, "0x%x", v); cp = buf + strlen(buf); - bits++; if (bits) { + bits++; *cp++ = ' '; *cp++ = '('; while ((i = *bits++) != 0) { @@ -433,7 +433,7 @@ timex_state( { static char buf[32]; - if (s >= 0 && s <= sizeof(timex_states) / sizeof(timex_states[0])) + if (s >= 0 && s < sizeof(timex_states) / sizeof(timex_states[0])) return (timex_states[s]); sprintf(buf, "TIME-#%d", s); return (buf); diff --git a/contrib/ntp/util/tg.c b/contrib/ntp/util/tg.c new file mode 100644 index 000000000000..aa3950d888bf --- /dev/null +++ b/contrib/ntp/util/tg.c @@ -0,0 +1,652 @@ +/* + * tg.c generate WWV or IRIG signals for test + */ +/* + * This program can generate audio signals that simulate the WWV/H + * broadcast timecode. Alternatively, it can generate the IRIG-B + * timecode commonly used to synchronize laboratory equipment. It is + * intended to test the WWV/H driver (refclock_wwv.c) and the IRIG + * driver (refclock_irig.c) in the NTP driver collection. + * + * Besides testing the drivers themselves, this program can be used to + * synchronize remote machines over audio transmission lines or program + * feeds. The program reads the time on the local machine and sets the + * initial epoch of the signal generator within one millisecond. + * Alernatively, the initial epoch can be set to an arbitrary time. This + * is useful when searching for bugs and testing for correct response to + * a leap second in UTC. Note however, the ultimate accuracy is limited + * by the intrinsic frequency error of the codec sample clock, which can + # reach well over 100 PPM. + * + * The default is to route generated signals to the line output + * jack; the s option on the command line routes these signals to the + * internal speaker as well. The v option controls the speaker volume + * over the range 0-255. The signal generator by default uses WWV + * format; the h option switches to WWVH format and the i option + * switches to IRIG-B format. + * + * Once started the program runs continuously. The default initial epoch + * for the signal generator is read from the computer system clock when + * the program starts. The y option specifies an alternate epoch using a + * string yydddhhmmss, where yy is the year of century, ddd the day of + * year, hh the hour of day and mm the minute of hour. For instance, + * 1946Z on 1 January 2006 is 060011946. The l option lights the leap + * warning bit in the WWV/H timecode, so is handy to check for correct + * behavior at the next leap second epoch. The remaining options are + * specified below under the Parse Options heading. Most of these are + * for testing. + * + * During operation the program displays the WWV/H timecode (9 digits) + * or IRIG timecode (20 digits) as each new string is constructed. The + * display is followed by the BCD binary bits as transmitted. Note that + * the transmissionorder is low-order first as the frame is processed + * left to right. For WWV/H The leap warning L preceeds the first bit. + * For IRIG the on-time marker M preceeds the first (units) bit, so its + * code is delayed one bit and the next digit (tens) needs only three + * bits. + * + * The program has been tested with the Sun Blade 1500 running Solaris + * 10, but not yet with other machines. It uses no special features and + * should be readily portable to other hardware and operating systems. + */ +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <sys/audio.h> +#include <math.h> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> +#include <unistd.h> + +#define SECOND 8000 /* one second of 125-us samples */ +#define BUFLNG 400 /* buffer size */ +#define DEVICE "/dev/audio" /* default audio device */ +#define WWV 0 /* WWV encoder */ +#define IRIG 1 /* IRIG-B encoder */ +#define OFF 0 /* zero amplitude */ +#define LOW 1 /* low amplitude */ +#define HIGH 2 /* high amplitude */ +#define DATA0 200 /* WWV/H 0 pulse */ +#define DATA1 500 /* WWV/H 1 pulse */ +#define PI 800 /* WWV/H PI pulse */ +#define M2 2 /* IRIG 0 pulse */ +#define M5 5 /* IRIG 1 pulse */ +#define M8 8 /* IRIG PI pulse */ + +/* + * Companded sine table amplitude 3000 units + */ +int c3000[] = {1, 48, 63, 70, 78, 82, 85, 89, 92, 94, /* 0-9 */ + 96, 98, 99, 100, 101, 101, 102, 103, 103, 103, /* 10-19 */ + 103, 103, 103, 103, 102, 101, 101, 100, 99, 98, /* 20-29 */ + 96, 94, 92, 89, 85, 82, 78, 70, 63, 48, /* 30-39 */ + 129, 176, 191, 198, 206, 210, 213, 217, 220, 222, /* 40-49 */ + 224, 226, 227, 228, 229, 229, 230, 231, 231, 231, /* 50-59 */ + 231, 231, 231, 231, 230, 229, 229, 228, 227, 226, /* 60-69 */ + 224, 222, 220, 217, 213, 210, 206, 198, 191, 176}; /* 70-79 */ +/* + * Companded sine table amplitude 6000 units + */ +int c6000[] = {1, 63, 78, 86, 93, 98, 101, 104, 107, 110, /* 0-9 */ + 112, 113, 115, 116, 117, 117, 118, 118, 119, 119, /* 10-19 */ + 119, 119, 119, 118, 118, 117, 117, 116, 115, 113, /* 20-29 */ + 112, 110, 107, 104, 101, 98, 93, 86, 78, 63, /* 30-39 */ + 129, 191, 206, 214, 221, 226, 229, 232, 235, 238, /* 40-49 */ + 240, 241, 243, 244, 245, 245, 246, 246, 247, 247, /* 50-59 */ + 247, 247, 247, 246, 246, 245, 245, 244, 243, 241, /* 60-69 */ + 240, 238, 235, 232, 229, 226, 221, 214, 206, 191}; /* 70-79 */ + +/* + * Decoder operations at the end of each second are driven by a state + * machine. The transition matrix consists of a dispatch table indexed + * by second number. Each entry in the table contains a case switch + * number and argument. + */ +struct progx { + int sw; /* case switch number */ + int arg; /* argument */ +}; + +/* + * Case switch numbers + */ +#define DATA 0 /* send data (0, 1, PI) */ +#define COEF 1 /* send BCD bit */ +#define DEC 2 /* decrement to next digit */ +#define MIN 3 /* minute pulse */ +#define LEAP 4 /* leap warning */ +#define DUT1 5 /* DUT1 bits */ +#define DST1 6 /* DST1 bit */ +#define DST2 7 /* DST2 bit */ + +/* + * WWV/H format (100-Hz, 9 digits, 1 m frame) + */ +struct progx progx[] = { + {MIN, 800}, /* 0 minute sync pulse */ + {DATA, DATA0}, /* 1 */ + {DST2, 0}, /* 2 DST2 */ + {LEAP, 0}, /* 3 leap warning */ + {COEF, 1}, /* 4 1 year units */ + {COEF, 2}, /* 5 2 */ + {COEF, 4}, /* 6 4 */ + {COEF, 8}, /* 7 8 */ + {DEC, DATA0}, /* 8 */ + {DATA, PI}, /* 9 p1 */ + {COEF, 1}, /* 10 1 minute units */ + {COEF, 2}, /* 11 2 */ + {COEF, 4}, /* 12 4 */ + {COEF, 8}, /* 13 8 */ + {DEC, DATA0}, /* 14 */ + {COEF, 1}, /* 15 10 minute tens */ + {COEF, 2}, /* 16 20 */ + {COEF, 4}, /* 17 40 */ + {COEF, 8}, /* 18 80 (not used) */ + {DEC, PI}, /* 19 p2 */ + {COEF, 1}, /* 20 1 hour units */ + {COEF, 2}, /* 21 2 */ + {COEF, 4}, /* 22 4 */ + {COEF, 8}, /* 23 8 */ + {DEC, DATA0}, /* 24 */ + {COEF, 1}, /* 25 10 hour tens */ + {COEF, 2}, /* 26 20 */ + {COEF, 4}, /* 27 40 (not used) */ + {COEF, 8}, /* 28 80 (not used) */ + {DEC, PI}, /* 29 p3 */ + {COEF, 1}, /* 30 1 day units */ + {COEF, 2}, /* 31 2 */ + {COEF, 4}, /* 32 4 */ + {COEF, 8}, /* 33 8 */ + {DEC, DATA0}, /* 34 not used */ + {COEF, 1}, /* 35 10 day tens */ + {COEF, 2}, /* 36 20 */ + {COEF, 4}, /* 37 40 */ + {COEF, 8}, /* 38 80 */ + {DEC, PI}, /* 39 p4 */ + {COEF, 1}, /* 40 100 day hundreds */ + {COEF, 2}, /* 41 200 */ + {COEF, 4}, /* 42 400 (not used) */ + {COEF, 8}, /* 43 800 (not used) */ + {DEC, DATA0}, /* 44 */ + {DATA, DATA0}, /* 45 */ + {DATA, DATA0}, /* 46 */ + {DATA, DATA0}, /* 47 */ + {DATA, DATA0}, /* 48 */ + {DATA, PI}, /* 49 p5 */ + {DUT1, 8}, /* 50 DUT1 sign */ + {COEF, 1}, /* 51 10 year tens */ + {COEF, 2}, /* 52 20 */ + {COEF, 4}, /* 53 40 */ + {COEF, 8}, /* 54 80 */ + {DST1, 0}, /* 55 DST1 */ + {DUT1, 1}, /* 56 0.1 DUT1 fraction */ + {DUT1, 2}, /* 57 0.2 */ + {DUT1, 4}, /* 58 0.4 */ + {DATA, PI}, /* 59 p6 */ + {DATA, DATA0}, /* 60 leap */ +}; + +/* + * IRIG format except first frame (1000 Hz, 20 digits, 1 s frame) + */ +struct progx progy[] = { + {COEF, 1}, /* 0 1 units */ + {COEF, 2}, /* 1 2 */ + {COEF, 4}, /* 2 4 */ + {COEF, 8}, /* 3 8 */ + {DEC, M2}, /* 4 im */ + {COEF, 1}, /* 5 10 tens */ + {COEF, 2}, /* 6 20 */ + {COEF, 4}, /* 7 40 */ + {COEF, 8}, /* 8 80 */ + {DEC, M8}, /* 9 pi */ +}; + +/* + * IRIG format first frame (1000 Hz, 20 digits, 1 s frame) + */ +struct progx progz[] = { + {MIN, M8}, /* 0 pi (second) */ + {COEF, 1}, /* 1 1 units */ + {COEF, 2}, /* 2 2 */ + {COEF, 4}, /* 3 4 */ + {COEF, 8}, /* 4 8 */ + {DEC, M2}, /* 5 im */ + {COEF, 1}, /* 6 10 tens */ + {COEF, 2}, /* 7 20 */ + {COEF, 4}, /* 8 40 */ + {DEC, M8}, /* 9 pi */ +}; + +/* + * Forward declarations + */ +void sec(int); /* send second */ +void digit(int); /* encode digit */ +void peep(int, int, int); /* send cycles */ +void delay(int); /* delay samples */ + +/* + * Global variables + */ +char buffer[BUFLNG]; /* output buffer */ +int bufcnt = 0; /* buffer counter */ +int second = 0; /* seconds counter */ +int fd; /* audio codec file descriptor */ +int tone = 1000; /* WWV sync frequency */ +int level = AUDIO_MAX_GAIN / 8; /* output level */ +int port = AUDIO_LINE_OUT; /* output port */ +int encode = WWV; /* encoder select */ +int leap = 0; /* leap indicator */ +int dst = 0; /* winter/summer time */ +int dut1 = 0; /* DUT1 correction (sign, magnitude) */ +int utc = 0; /* option epoch */ + +/* + * Main program + */ +int +main( + int argc, /* command line options */ + char **argv /* poiniter to list of tokens */ + ) +{ + struct timeval tv; /* system clock at startup */ + audio_info_t info; /* Sun audio structure */ + struct tm *tm = NULL; /* structure returned by gmtime */ + char device[50]; /* audio device */ + char code[100]; /* timecode */ + int rval, temp, arg, sw, ptr; + int minute, hour, day, year; + int i; + + /* + * Parse options + */ + strcpy(device, DEVICE); + year = 0; + while ((temp = getopt(argc, argv, "a:dhilsu:v:y:")) != -1) { + switch (temp) { + + case 'a': /* specify audio device (/dev/audio) */ + strcpy(device, optarg); + break; + + case 'd': /* set DST for summer (WWV/H only) */ + dst++; + break; + + case 'h': /* select WWVH sync frequency */ + tone = 1200; + break; + + case 'i': /* select irig format */ + encode = IRIG; + break; + + case 'l': /* set leap warning bit (WWV/H only) */ + leap++; + break; + + case 's': /* enable speaker */ + port |= AUDIO_SPEAKER; + break; + + case 'u': /* set DUT1 offset (-7 to +7) */ + sscanf(optarg, "%d", &dut1); + if (dut1 < 0) + dut1 = abs(dut1); + else + dut1 |= 0x8; + break; + + case 'v': /* set output level (0-255) */ + sscanf(optarg, "%d", &level); + break; + + case 'y': /* set initial date and time */ + sscanf(optarg, "%2d%3d%2d%2d", &year, &day, + &hour, &minute); + utc++; + break; + + defult: + printf("invalid option %c\n", temp); + break; + } + } + + /* + * Open audio device and set options + */ + fd = open("/dev/audio", O_WRONLY); + if (fd <= 0) { + printf("audio open %s\n", strerror(errno)); + exit(1); + } + rval = ioctl(fd, AUDIO_GETINFO, &info); + if (rval < 0) { + printf("audio control %s\n", strerror(errno)); + exit(0); + } + info.play.port = port; + info.play.gain = level; + info.play.sample_rate = SECOND; + info.play.channels = 1; + info.play.precision = 8; + info.play.encoding = AUDIO_ENCODING_ULAW; + printf("port %d gain %d rate %d chan %d prec %d encode %d\n", + info.play.port, info.play.gain, info.play.sample_rate, + info.play.channels, info.play.precision, + info.play.encoding); + ioctl(fd, AUDIO_SETINFO, &info); + + /* + * Unless specified otherwise, read the system clock and + * initialize the time. + */ + if (!utc) { + gettimeofday(&tv, NULL); + tm = gmtime(&tv.tv_sec); + minute = tm->tm_min; + hour = tm->tm_hour; + day = tm->tm_yday + 1; + year = tm->tm_year % 100; + second = tm->tm_sec; + + /* + * Delay the first second so the generator is accurately + * aligned with the system clock within one sample (125 + * microseconds ). + */ + delay(SECOND - tv.tv_usec * 8 / 1000); + } + memset(code, 0, sizeof(code)); + switch (encode) { + + /* + * For WWV/H and default time, carefully set the signal + * generator seconds number to agree with the current time. + */ + case WWV: + printf("year %d day %d time %02d:%02d:%02d tone %d\n", + year, day, hour, minute, second, tone); + sprintf(code, "%01d%03d%02d%02d%01d", year / 10, day, + hour, minute, year % 10); + printf("%s\n", code); + ptr = 8; + for (i = 0; i <= second; i++) { + if (progx[i].sw == DEC) + ptr--; + } + break; + + /* + * For IRIG the signal generator runs every second, so requires + * no additional alignment. + */ + case IRIG: + printf("sbs %x year %d day %d time %02d:%02d:%02d\n", + 0, year, day, hour, minute, second); + break; + } + + /* + * Run the signal generator to generate new timecode strings + * once per minute for WWV/H and once per second for IRIG. + */ + while(1) { + + /* + * Crank the state machine to propagate carries to the + * year of century. Note that we delayed up to one + * second for alignment after reading the time, so this + * is the next second. + */ + second = (second + 1) % 60; + if (second == 0) { + minute++; + if (minute >= 60) { + minute = 0; + hour++; + } + if (hour >= 24) { + hour = 0; + day++; + } + + /* + * At year rollover check for leap second. + */ + if (day >= (year & 0x3 ? 366 : 367)) { + if (leap) { + sec(DATA0); + printf("\nleap!"); + leap = 0; + } + day = 1; + year++; + } + if (encode == WWV) { + sprintf(code, "%01d%03d%02d%02d%01d", + year / 10, day, hour, minute, year % + 10); + printf("\n%s\n", code); + ptr = 8; + } + } + if (encode == IRIG) { + sprintf(code, "%04x%04d%06d%02d%02d%02d", 0, + year, day, hour, minute, second); + printf("%s\n", code); + ptr = 19; + } + + /* + * Generate data for the second + */ + switch(encode) { + + /* + * The IRIG second consists of 20 BCD digits of width- + * modulateod pulses at 2, 5 and 8 ms and modulated 50 + * percent on the 1000-Hz carrier. + */ + case IRIG: + for (i = 0; i < 100; i++) { + if (i < 10) { + sw = progz[i].sw; + arg = progz[i].arg; + } else { + sw = progy[i % 10].sw; + arg = progy[i % 10].arg; + } + switch(sw) { + + case COEF: /* send BCD bit */ + if (code[ptr] & arg) { + peep(M5, 1000, HIGH); + peep(M5, 1000, LOW); + printf("1"); + } else { + peep(M2, 1000, HIGH); + peep(M8, 1000, LOW); + printf("0"); + } + break; + + case DEC: /* send IM/PI bit */ + ptr--; + printf(" "); + peep(arg, 1000, HIGH); + peep(10 - arg, 1000, LOW); + break; + + case MIN: /* send data bit */ + peep(arg, 1000, HIGH); + peep(10 - arg, 1000, LOW); + printf("M "); + break; + } + if (ptr < 0) + break; + } + printf("\n"); + break; + + /* + * The WWV/H second consists of 9 BCD digits of width- + * modulateod pulses 200, 500 and 800 ms at 100-Hz. + */ + case WWV: + sw = progx[second].sw; + arg = progx[second].arg; + switch(sw) { + + case DATA: /* send data bit */ + sec(arg); + break; + + case COEF: /* send BCD bit */ + if (code[ptr] & arg) { + sec(DATA1); + printf("1"); + } else { + sec(DATA0); + printf("0"); + } + break; + + case LEAP: /* send leap bit */ + if (leap) { + sec(DATA1); + printf("L "); + } else { + sec(DATA0); + printf(" "); + } + break; + + case DEC: /* send data bit */ + ptr--; + sec(arg); + printf(" "); + break; + + case MIN: /* send minute sync */ + peep(arg, tone, HIGH); + peep(1000 - arg, tone, OFF); + break; + + case DUT1: /* send DUT1 bits */ + if (dut1 & arg) + sec(DATA1); + else + sec(DATA0); + break; + + case DST1: /* send DST1 bit */ + ptr--; + if (dst) + sec(DATA1); + else + sec(DATA0); + printf(" "); + break; + + case DST2: /* send DST2 bit */ + if (dst) + sec(DATA1); + else + sec(DATA0); + break; + } + } + } +} + + +/* + * Generate WWV/H 0 or 1 data pulse. + */ +void sec( + int code /* DATA0, DATA1, PI */ + ) +{ + /* + * The WWV data pulse begins with 5 ms of 1000 Hz follwed by a + * guard time of 25 ms. The data pulse is 170, 570 or 770 ms at + * 100 Hz corresponding to 0, 1 or position indicator (PI), + * respectively. Note the 100-Hz data pulses are transmitted 6 + * dB below the 1000-Hz sync pulses. Originally the data pulses + * were transmited 10 dB below the sync pulses, but the station + * engineers increased that to 6 dB because the Heath GC-1000 + * WWV/H radio clock worked much better. + */ + peep(5, tone, HIGH); /* send seconds tick */ + peep(25, tone, OFF); + peep(code - 30, 100, LOW); /* send data */ + peep(1000 - code, 100, OFF); +} + + +/* + * Generate cycles of 100 Hz or any multiple of 100 Hz. + */ +void peep( + int pulse, /* pulse length (ms) */ + int freq, /* frequency (Hz) */ + int amp /* amplitude */ + ) +{ + int increm; /* phase increment */ + int i, j; + + if (amp == OFF || freq == 0) + increm = 10; + else + increm = freq / 100; + j = 0; + for (i = 0 ; i < pulse * 8; i++) { + switch (amp) { + + case HIGH: + buffer[bufcnt++] = ~c6000[j]; + break; + + case LOW: + buffer[bufcnt++] = ~c3000[j]; + break; + + default: + buffer[bufcnt++] = ~0; + } + if (bufcnt >= BUFLNG) { + write(fd, buffer, BUFLNG); + bufcnt = 0; + } + j = (j + increm) % 80; + } +} + + +/* + * Delay for initial phasing + */ +void delay ( + int delay /* delay in samples */ + ) +{ + int samples; /* samples remaining */ + + samples = delay; + memset(buffer, 0, BUFLNG); + while (samples >= BUFLNG) { + write(fd, buffer, BUFLNG); + samples -= BUFLNG; + } + write(fd, buffer, samples); +} |