diff options
Diffstat (limited to 'contrib/ntp/libntp')
72 files changed, 10349 insertions, 0 deletions
diff --git a/contrib/ntp/libntp/Makefile.am b/contrib/ntp/libntp/Makefile.am new file mode 100644 index 0000000..932f87b --- /dev/null +++ b/contrib/ntp/libntp/Makefile.am @@ -0,0 +1,38 @@ +#AUTOMAKE_OPTIONS = ../ansi2knr no-dependencies +AUTOMAKE_OPTIONS = ../util/ansi2knr +noinst_LIBRARIES = libntp.a @MAKE_LIBNTPSIM@ +EXTRA_LIBRARIES = libntpsim.a +libntp_a_SRCS = a_md5encrypt.c adjtime.c atoint.c atolfp.c atouint.c \ + audio.c authkeys.c authreadkeys.c authusekey.c buftvtots.c \ + caljulian.c caltontp.c calyearstart.c clocktime.c \ + clocktypes.c decodenetnum.c dofptoa.c dolfptoa.c emalloc.c \ + findconfig.c fptoa.c fptoms.c getopt.c hextoint.c \ + hextolfp.c humandate.c icom.c inttoa.c iosignal.c \ + lib_strbuf.c machines.c md5c.c memmove.c mfptoa.c \ + mfptoms.c mktime.c modetoa.c mstolfp.c msutotsf.c msyslog.c netof.c \ + ntp_rfc2553.c numtoa.c numtohost.c octtoint.c prettydate.c \ + ntp_random.c recvbuff.c refnumtoa.c snprintf.c socktoa.c socktohost.c \ + statestr.c strdup.c strerror.c strstr.c \ + syssignal.c tsftomsu.c tstotv.c tvtoa.c tvtots.c \ + uglydate.c uinttoa.c utvtoa.c ymd2yd.c \ + $(srcdir)/../libisc/assertions.c $(srcdir)/../libisc/error.c \ + $(srcdir)/../libisc/interfaceiter.c $(srcdir)/../libisc/lib.c \ + $(srcdir)/../libisc/mem.c $(srcdir)/../libisc/msgcat.c \ + $(srcdir)/../libisc/net.c $(srcdir)/../libisc/isc_strerror.c \ + $(srcdir)/../libisc/inet_ntop.c \ + $(srcdir)/../libisc/inet_pton.c \ + $(srcdir)/../libisc/netaddr.c $(srcdir)/../libisc/sockaddr.c \ + $(srcdir)/../libisc/netscope.c +libntp_a_SOURCES = systime.c $(libntp_a_SRCS) +libntpsim_a_SOURCES = systime_s.c $(libntp_a_SRCS) +EXTRA_libntp_a_SOURCES = adjtimex.c +INCLUDES = -I$(top_srcdir)/include -I../include +ETAGS_ARGS = Makefile.am + +noinst_HEADERS = lib_strbuf.h + +../include/des.h: + touch ../include/des.h + +EXTRA_DIST = README + diff --git a/contrib/ntp/libntp/Makefile.in b/contrib/ntp/libntp/Makefile.in new file mode 100644 index 0000000..802ba71 --- /dev/null +++ b/contrib/ntp/libntp/Makefile.in @@ -0,0 +1,1190 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# 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. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +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 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +ANSI2KNR = ../util/ansi2knr +subdir = libntp +DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +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 = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libntp_a_AR = $(AR) $(ARFLAGS) +libntp_a_LIBADD = +am__objects_1 = a_md5encrypt$U.$(OBJEXT) adjtime$U.$(OBJEXT) \ + atoint$U.$(OBJEXT) atolfp$U.$(OBJEXT) atouint$U.$(OBJEXT) \ + audio$U.$(OBJEXT) authkeys$U.$(OBJEXT) \ + authreadkeys$U.$(OBJEXT) authusekey$U.$(OBJEXT) \ + buftvtots$U.$(OBJEXT) caljulian$U.$(OBJEXT) \ + caltontp$U.$(OBJEXT) calyearstart$U.$(OBJEXT) \ + clocktime$U.$(OBJEXT) clocktypes$U.$(OBJEXT) \ + decodenetnum$U.$(OBJEXT) dofptoa$U.$(OBJEXT) \ + dolfptoa$U.$(OBJEXT) emalloc$U.$(OBJEXT) \ + findconfig$U.$(OBJEXT) fptoa$U.$(OBJEXT) fptoms$U.$(OBJEXT) \ + getopt$U.$(OBJEXT) hextoint$U.$(OBJEXT) hextolfp$U.$(OBJEXT) \ + humandate$U.$(OBJEXT) icom$U.$(OBJEXT) inttoa$U.$(OBJEXT) \ + iosignal$U.$(OBJEXT) lib_strbuf$U.$(OBJEXT) \ + machines$U.$(OBJEXT) md5c$U.$(OBJEXT) memmove$U.$(OBJEXT) \ + mfptoa$U.$(OBJEXT) mfptoms$U.$(OBJEXT) mktime$U.$(OBJEXT) \ + modetoa$U.$(OBJEXT) mstolfp$U.$(OBJEXT) msutotsf$U.$(OBJEXT) \ + msyslog$U.$(OBJEXT) netof$U.$(OBJEXT) ntp_rfc2553$U.$(OBJEXT) \ + numtoa$U.$(OBJEXT) numtohost$U.$(OBJEXT) octtoint$U.$(OBJEXT) \ + prettydate$U.$(OBJEXT) ntp_random$U.$(OBJEXT) \ + recvbuff$U.$(OBJEXT) refnumtoa$U.$(OBJEXT) \ + snprintf$U.$(OBJEXT) socktoa$U.$(OBJEXT) \ + socktohost$U.$(OBJEXT) statestr$U.$(OBJEXT) strdup$U.$(OBJEXT) \ + strerror$U.$(OBJEXT) strstr$U.$(OBJEXT) syssignal$U.$(OBJEXT) \ + tsftomsu$U.$(OBJEXT) tstotv$U.$(OBJEXT) tvtoa$U.$(OBJEXT) \ + tvtots$U.$(OBJEXT) uglydate$U.$(OBJEXT) uinttoa$U.$(OBJEXT) \ + utvtoa$U.$(OBJEXT) ymd2yd$U.$(OBJEXT) assertions$U.$(OBJEXT) \ + error$U.$(OBJEXT) interfaceiter$U.$(OBJEXT) lib$U.$(OBJEXT) \ + mem$U.$(OBJEXT) msgcat$U.$(OBJEXT) net$U.$(OBJEXT) \ + isc_strerror$U.$(OBJEXT) inet_ntop$U.$(OBJEXT) \ + inet_pton$U.$(OBJEXT) netaddr$U.$(OBJEXT) sockaddr$U.$(OBJEXT) \ + netscope$U.$(OBJEXT) +am_libntp_a_OBJECTS = systime$U.$(OBJEXT) $(am__objects_1) +libntp_a_OBJECTS = $(am_libntp_a_OBJECTS) +libntpsim_a_AR = $(AR) $(ARFLAGS) +libntpsim_a_LIBADD = +am_libntpsim_a_OBJECTS = systime_s$U.$(OBJEXT) $(am__objects_1) +libntpsim_a_OBJECTS = $(am_libntpsim_a_OBJECTS) +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 = $(libntp_a_SOURCES) $(EXTRA_libntp_a_SOURCES) \ + $(libntpsim_a_SOURCES) +DIST_SOURCES = $(libntp_a_SOURCES) $(EXTRA_libntp_a_SOURCES) \ + $(libntpsim_a_SOURCES) +HEADERS = $(noinst_HEADERS) +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@ +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@ +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_PARSEKMODULE = @MAKE_PARSEKMODULE@ +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@ +OPENSSL_LIB = @OPENSSL_LIB@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_PERL = @PATH_PERL@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PATH_SH = @PATH_SH@ +PROPDELAY = @PROPDELAY@ +RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +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@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +subdirs = @subdirs@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ + +#AUTOMAKE_OPTIONS = ../ansi2knr no-dependencies +AUTOMAKE_OPTIONS = ../util/ansi2knr +noinst_LIBRARIES = libntp.a @MAKE_LIBNTPSIM@ +EXTRA_LIBRARIES = libntpsim.a +libntp_a_SRCS = a_md5encrypt.c adjtime.c atoint.c atolfp.c atouint.c \ + audio.c authkeys.c authreadkeys.c authusekey.c buftvtots.c \ + caljulian.c caltontp.c calyearstart.c clocktime.c \ + clocktypes.c decodenetnum.c dofptoa.c dolfptoa.c emalloc.c \ + findconfig.c fptoa.c fptoms.c getopt.c hextoint.c \ + hextolfp.c humandate.c icom.c inttoa.c iosignal.c \ + lib_strbuf.c machines.c md5c.c memmove.c mfptoa.c \ + mfptoms.c mktime.c modetoa.c mstolfp.c msutotsf.c msyslog.c netof.c \ + ntp_rfc2553.c numtoa.c numtohost.c octtoint.c prettydate.c \ + ntp_random.c recvbuff.c refnumtoa.c snprintf.c socktoa.c socktohost.c \ + statestr.c strdup.c strerror.c strstr.c \ + syssignal.c tsftomsu.c tstotv.c tvtoa.c tvtots.c \ + uglydate.c uinttoa.c utvtoa.c ymd2yd.c \ + $(srcdir)/../libisc/assertions.c $(srcdir)/../libisc/error.c \ + $(srcdir)/../libisc/interfaceiter.c $(srcdir)/../libisc/lib.c \ + $(srcdir)/../libisc/mem.c $(srcdir)/../libisc/msgcat.c \ + $(srcdir)/../libisc/net.c $(srcdir)/../libisc/isc_strerror.c \ + $(srcdir)/../libisc/inet_ntop.c \ + $(srcdir)/../libisc/inet_pton.c \ + $(srcdir)/../libisc/netaddr.c $(srcdir)/../libisc/sockaddr.c \ + $(srcdir)/../libisc/netscope.c + +libntp_a_SOURCES = systime.c $(libntp_a_SRCS) +libntpsim_a_SOURCES = systime_s.c $(libntp_a_SRCS) +EXTRA_libntp_a_SOURCES = adjtimex.c +INCLUDES = -I$(top_srcdir)/include -I../include +ETAGS_ARGS = Makefile.am +noinst_HEADERS = lib_strbuf.h +EXTRA_DIST = README +all: all-am + +.SUFFIXES: +.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 libntp/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libntp/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 + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libntp.a: $(libntp_a_OBJECTS) $(libntp_a_DEPENDENCIES) + -rm -f libntp.a + $(libntp_a_AR) libntp.a $(libntp_a_OBJECTS) $(libntp_a_LIBADD) + $(RANLIB) libntp.a +libntpsim.a: $(libntpsim_a_OBJECTS) $(libntpsim_a_DEPENDENCIES) + -rm -f libntpsim.a + $(libntpsim_a_AR) libntpsim.a $(libntpsim_a_OBJECTS) $(libntpsim_a_LIBADD) + $(RANLIB) libntpsim.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c +../util/ansi2knr: + cd ../util && $(MAKE) $(AM_MAKEFLAGS) ansi2knr + +mostlyclean-kr: + -test "$U" = "" || rm -f *_.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_md5encrypt$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adjtime$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adjtimex$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assertions$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atoint$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atolfp$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atouint$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/authkeys$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/authreadkeys$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/authusekey$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buftvtots$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caljulian$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caltontp$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/calyearstart$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clocktime$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clocktypes$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decodenetnum$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dofptoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dolfptoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emalloc$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/findconfig$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fptoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fptoms$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hextoint$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hextolfp$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/humandate$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/icom$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_ntop$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_pton$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interfaceiter$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inttoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iosignal$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isc_strerror$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib_strbuf$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/machines$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5c$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memmove$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfptoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfptoms$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modetoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msgcat$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mstolfp$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msutotsf$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msyslog$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netaddr$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netof$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netscope$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_random$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_rfc2553$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numtoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numtohost$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/octtoint$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prettydate$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/recvbuff$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refnumtoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snprintf$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockaddr$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socktoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socktohost$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/statestr$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strdup$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strstr$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syssignal$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/systime$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/systime_s$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsftomsu$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tstotv$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tvtoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tvtots$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uglydate$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uinttoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utvtoa$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ymd2yd$U.Po@am__quote@ + +.c.o: +@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@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@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@ 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 $@ $< + +assertions_.o: assertions_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT assertions_.o -MD -MP -MF "$(DEPDIR)/assertions_.Tpo" -c -o assertions_.o `test -f 'assertions_.c' || echo '$(srcdir)/'`assertions_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/assertions_.Tpo" "$(DEPDIR)/assertions_.Po"; else rm -f "$(DEPDIR)/assertions_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='assertions_.c' object='assertions_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o assertions_.o `test -f 'assertions_.c' || echo '$(srcdir)/'`assertions_.c + +assertions_.obj: assertions_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT assertions_.obj -MD -MP -MF "$(DEPDIR)/assertions_.Tpo" -c -o assertions_.obj `if test -f 'assertions_.c'; then $(CYGPATH_W) 'assertions_.c'; else $(CYGPATH_W) '$(srcdir)/assertions_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/assertions_.Tpo" "$(DEPDIR)/assertions_.Po"; else rm -f "$(DEPDIR)/assertions_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='assertions_.c' object='assertions_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o assertions_.obj `if test -f 'assertions_.c'; then $(CYGPATH_W) 'assertions_.c'; else $(CYGPATH_W) '$(srcdir)/assertions_.c'; fi` + +assertions.o: $(srcdir)/../libisc/assertions.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT assertions.o -MD -MP -MF "$(DEPDIR)/assertions.Tpo" -c -o assertions.o `test -f '$(srcdir)/../libisc/assertions.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/assertions.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/assertions.Tpo" "$(DEPDIR)/assertions.Po"; else rm -f "$(DEPDIR)/assertions.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/assertions.c' object='assertions.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o assertions.o `test -f '$(srcdir)/../libisc/assertions.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/assertions.c + +assertions.obj: $(srcdir)/../libisc/assertions.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT assertions.obj -MD -MP -MF "$(DEPDIR)/assertions.Tpo" -c -o assertions.obj `if test -f '$(srcdir)/../libisc/assertions.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/assertions.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/assertions.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/assertions.Tpo" "$(DEPDIR)/assertions.Po"; else rm -f "$(DEPDIR)/assertions.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/assertions.c' object='assertions.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o assertions.obj `if test -f '$(srcdir)/../libisc/assertions.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/assertions.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/assertions.c'; fi` + +error_.o: error_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error_.o -MD -MP -MF "$(DEPDIR)/error_.Tpo" -c -o error_.o `test -f 'error_.c' || echo '$(srcdir)/'`error_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/error_.Tpo" "$(DEPDIR)/error_.Po"; else rm -f "$(DEPDIR)/error_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='error_.c' object='error_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error_.o `test -f 'error_.c' || echo '$(srcdir)/'`error_.c + +error_.obj: error_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error_.obj -MD -MP -MF "$(DEPDIR)/error_.Tpo" -c -o error_.obj `if test -f 'error_.c'; then $(CYGPATH_W) 'error_.c'; else $(CYGPATH_W) '$(srcdir)/error_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/error_.Tpo" "$(DEPDIR)/error_.Po"; else rm -f "$(DEPDIR)/error_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='error_.c' object='error_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error_.obj `if test -f 'error_.c'; then $(CYGPATH_W) 'error_.c'; else $(CYGPATH_W) '$(srcdir)/error_.c'; fi` + +error.o: $(srcdir)/../libisc/error.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error.o -MD -MP -MF "$(DEPDIR)/error.Tpo" -c -o error.o `test -f '$(srcdir)/../libisc/error.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/error.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/error.Tpo" "$(DEPDIR)/error.Po"; else rm -f "$(DEPDIR)/error.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/error.c' object='error.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error.o `test -f '$(srcdir)/../libisc/error.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/error.c + +error.obj: $(srcdir)/../libisc/error.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error.obj -MD -MP -MF "$(DEPDIR)/error.Tpo" -c -o error.obj `if test -f '$(srcdir)/../libisc/error.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/error.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/error.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/error.Tpo" "$(DEPDIR)/error.Po"; else rm -f "$(DEPDIR)/error.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/error.c' object='error.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error.obj `if test -f '$(srcdir)/../libisc/error.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/error.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/error.c'; fi` + +interfaceiter_.o: interfaceiter_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interfaceiter_.o -MD -MP -MF "$(DEPDIR)/interfaceiter_.Tpo" -c -o interfaceiter_.o `test -f 'interfaceiter_.c' || echo '$(srcdir)/'`interfaceiter_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/interfaceiter_.Tpo" "$(DEPDIR)/interfaceiter_.Po"; else rm -f "$(DEPDIR)/interfaceiter_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='interfaceiter_.c' object='interfaceiter_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interfaceiter_.o `test -f 'interfaceiter_.c' || echo '$(srcdir)/'`interfaceiter_.c + +interfaceiter_.obj: interfaceiter_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interfaceiter_.obj -MD -MP -MF "$(DEPDIR)/interfaceiter_.Tpo" -c -o interfaceiter_.obj `if test -f 'interfaceiter_.c'; then $(CYGPATH_W) 'interfaceiter_.c'; else $(CYGPATH_W) '$(srcdir)/interfaceiter_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/interfaceiter_.Tpo" "$(DEPDIR)/interfaceiter_.Po"; else rm -f "$(DEPDIR)/interfaceiter_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='interfaceiter_.c' object='interfaceiter_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interfaceiter_.obj `if test -f 'interfaceiter_.c'; then $(CYGPATH_W) 'interfaceiter_.c'; else $(CYGPATH_W) '$(srcdir)/interfaceiter_.c'; fi` + +interfaceiter.o: $(srcdir)/../libisc/interfaceiter.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interfaceiter.o -MD -MP -MF "$(DEPDIR)/interfaceiter.Tpo" -c -o interfaceiter.o `test -f '$(srcdir)/../libisc/interfaceiter.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/interfaceiter.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/interfaceiter.Tpo" "$(DEPDIR)/interfaceiter.Po"; else rm -f "$(DEPDIR)/interfaceiter.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/interfaceiter.c' object='interfaceiter.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interfaceiter.o `test -f '$(srcdir)/../libisc/interfaceiter.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/interfaceiter.c + +interfaceiter.obj: $(srcdir)/../libisc/interfaceiter.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interfaceiter.obj -MD -MP -MF "$(DEPDIR)/interfaceiter.Tpo" -c -o interfaceiter.obj `if test -f '$(srcdir)/../libisc/interfaceiter.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/interfaceiter.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/interfaceiter.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/interfaceiter.Tpo" "$(DEPDIR)/interfaceiter.Po"; else rm -f "$(DEPDIR)/interfaceiter.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/interfaceiter.c' object='interfaceiter.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interfaceiter.obj `if test -f '$(srcdir)/../libisc/interfaceiter.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/interfaceiter.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/interfaceiter.c'; fi` + +lib_.o: lib_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib_.o -MD -MP -MF "$(DEPDIR)/lib_.Tpo" -c -o lib_.o `test -f 'lib_.c' || echo '$(srcdir)/'`lib_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lib_.Tpo" "$(DEPDIR)/lib_.Po"; else rm -f "$(DEPDIR)/lib_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='lib_.c' object='lib_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib_.o `test -f 'lib_.c' || echo '$(srcdir)/'`lib_.c + +lib_.obj: lib_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib_.obj -MD -MP -MF "$(DEPDIR)/lib_.Tpo" -c -o lib_.obj `if test -f 'lib_.c'; then $(CYGPATH_W) 'lib_.c'; else $(CYGPATH_W) '$(srcdir)/lib_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lib_.Tpo" "$(DEPDIR)/lib_.Po"; else rm -f "$(DEPDIR)/lib_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='lib_.c' object='lib_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib_.obj `if test -f 'lib_.c'; then $(CYGPATH_W) 'lib_.c'; else $(CYGPATH_W) '$(srcdir)/lib_.c'; fi` + +lib.o: $(srcdir)/../libisc/lib.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib.o -MD -MP -MF "$(DEPDIR)/lib.Tpo" -c -o lib.o `test -f '$(srcdir)/../libisc/lib.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/lib.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lib.Tpo" "$(DEPDIR)/lib.Po"; else rm -f "$(DEPDIR)/lib.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/lib.c' object='lib.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib.o `test -f '$(srcdir)/../libisc/lib.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/lib.c + +lib.obj: $(srcdir)/../libisc/lib.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib.obj -MD -MP -MF "$(DEPDIR)/lib.Tpo" -c -o lib.obj `if test -f '$(srcdir)/../libisc/lib.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/lib.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/lib.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lib.Tpo" "$(DEPDIR)/lib.Po"; else rm -f "$(DEPDIR)/lib.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/lib.c' object='lib.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib.obj `if test -f '$(srcdir)/../libisc/lib.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/lib.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/lib.c'; fi` + +mem_.o: mem_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mem_.o -MD -MP -MF "$(DEPDIR)/mem_.Tpo" -c -o mem_.o `test -f 'mem_.c' || echo '$(srcdir)/'`mem_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mem_.Tpo" "$(DEPDIR)/mem_.Po"; else rm -f "$(DEPDIR)/mem_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mem_.c' object='mem_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mem_.o `test -f 'mem_.c' || echo '$(srcdir)/'`mem_.c + +mem_.obj: mem_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mem_.obj -MD -MP -MF "$(DEPDIR)/mem_.Tpo" -c -o mem_.obj `if test -f 'mem_.c'; then $(CYGPATH_W) 'mem_.c'; else $(CYGPATH_W) '$(srcdir)/mem_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mem_.Tpo" "$(DEPDIR)/mem_.Po"; else rm -f "$(DEPDIR)/mem_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mem_.c' object='mem_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mem_.obj `if test -f 'mem_.c'; then $(CYGPATH_W) 'mem_.c'; else $(CYGPATH_W) '$(srcdir)/mem_.c'; fi` + +mem.o: $(srcdir)/../libisc/mem.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mem.o -MD -MP -MF "$(DEPDIR)/mem.Tpo" -c -o mem.o `test -f '$(srcdir)/../libisc/mem.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/mem.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mem.Tpo" "$(DEPDIR)/mem.Po"; else rm -f "$(DEPDIR)/mem.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/mem.c' object='mem.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mem.o `test -f '$(srcdir)/../libisc/mem.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/mem.c + +mem.obj: $(srcdir)/../libisc/mem.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mem.obj -MD -MP -MF "$(DEPDIR)/mem.Tpo" -c -o mem.obj `if test -f '$(srcdir)/../libisc/mem.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/mem.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/mem.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mem.Tpo" "$(DEPDIR)/mem.Po"; else rm -f "$(DEPDIR)/mem.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/mem.c' object='mem.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mem.obj `if test -f '$(srcdir)/../libisc/mem.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/mem.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/mem.c'; fi` + +msgcat_.o: msgcat_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msgcat_.o -MD -MP -MF "$(DEPDIR)/msgcat_.Tpo" -c -o msgcat_.o `test -f 'msgcat_.c' || echo '$(srcdir)/'`msgcat_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/msgcat_.Tpo" "$(DEPDIR)/msgcat_.Po"; else rm -f "$(DEPDIR)/msgcat_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='msgcat_.c' object='msgcat_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msgcat_.o `test -f 'msgcat_.c' || echo '$(srcdir)/'`msgcat_.c + +msgcat_.obj: msgcat_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msgcat_.obj -MD -MP -MF "$(DEPDIR)/msgcat_.Tpo" -c -o msgcat_.obj `if test -f 'msgcat_.c'; then $(CYGPATH_W) 'msgcat_.c'; else $(CYGPATH_W) '$(srcdir)/msgcat_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/msgcat_.Tpo" "$(DEPDIR)/msgcat_.Po"; else rm -f "$(DEPDIR)/msgcat_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='msgcat_.c' object='msgcat_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msgcat_.obj `if test -f 'msgcat_.c'; then $(CYGPATH_W) 'msgcat_.c'; else $(CYGPATH_W) '$(srcdir)/msgcat_.c'; fi` + +msgcat.o: $(srcdir)/../libisc/msgcat.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msgcat.o -MD -MP -MF "$(DEPDIR)/msgcat.Tpo" -c -o msgcat.o `test -f '$(srcdir)/../libisc/msgcat.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/msgcat.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/msgcat.Tpo" "$(DEPDIR)/msgcat.Po"; else rm -f "$(DEPDIR)/msgcat.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/msgcat.c' object='msgcat.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msgcat.o `test -f '$(srcdir)/../libisc/msgcat.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/msgcat.c + +msgcat.obj: $(srcdir)/../libisc/msgcat.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msgcat.obj -MD -MP -MF "$(DEPDIR)/msgcat.Tpo" -c -o msgcat.obj `if test -f '$(srcdir)/../libisc/msgcat.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/msgcat.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/msgcat.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/msgcat.Tpo" "$(DEPDIR)/msgcat.Po"; else rm -f "$(DEPDIR)/msgcat.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/msgcat.c' object='msgcat.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msgcat.obj `if test -f '$(srcdir)/../libisc/msgcat.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/msgcat.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/msgcat.c'; fi` + +net_.o: net_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net_.o -MD -MP -MF "$(DEPDIR)/net_.Tpo" -c -o net_.o `test -f 'net_.c' || echo '$(srcdir)/'`net_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/net_.Tpo" "$(DEPDIR)/net_.Po"; else rm -f "$(DEPDIR)/net_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='net_.c' object='net_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net_.o `test -f 'net_.c' || echo '$(srcdir)/'`net_.c + +net_.obj: net_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net_.obj -MD -MP -MF "$(DEPDIR)/net_.Tpo" -c -o net_.obj `if test -f 'net_.c'; then $(CYGPATH_W) 'net_.c'; else $(CYGPATH_W) '$(srcdir)/net_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/net_.Tpo" "$(DEPDIR)/net_.Po"; else rm -f "$(DEPDIR)/net_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='net_.c' object='net_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net_.obj `if test -f 'net_.c'; then $(CYGPATH_W) 'net_.c'; else $(CYGPATH_W) '$(srcdir)/net_.c'; fi` + +net.o: $(srcdir)/../libisc/net.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net.o -MD -MP -MF "$(DEPDIR)/net.Tpo" -c -o net.o `test -f '$(srcdir)/../libisc/net.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/net.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/net.Tpo" "$(DEPDIR)/net.Po"; else rm -f "$(DEPDIR)/net.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/net.c' object='net.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net.o `test -f '$(srcdir)/../libisc/net.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/net.c + +net.obj: $(srcdir)/../libisc/net.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net.obj -MD -MP -MF "$(DEPDIR)/net.Tpo" -c -o net.obj `if test -f '$(srcdir)/../libisc/net.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/net.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/net.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/net.Tpo" "$(DEPDIR)/net.Po"; else rm -f "$(DEPDIR)/net.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/net.c' object='net.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net.obj `if test -f '$(srcdir)/../libisc/net.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/net.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/net.c'; fi` + +isc_strerror_.o: isc_strerror_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT isc_strerror_.o -MD -MP -MF "$(DEPDIR)/isc_strerror_.Tpo" -c -o isc_strerror_.o `test -f 'isc_strerror_.c' || echo '$(srcdir)/'`isc_strerror_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/isc_strerror_.Tpo" "$(DEPDIR)/isc_strerror_.Po"; else rm -f "$(DEPDIR)/isc_strerror_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='isc_strerror_.c' object='isc_strerror_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o isc_strerror_.o `test -f 'isc_strerror_.c' || echo '$(srcdir)/'`isc_strerror_.c + +isc_strerror_.obj: isc_strerror_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT isc_strerror_.obj -MD -MP -MF "$(DEPDIR)/isc_strerror_.Tpo" -c -o isc_strerror_.obj `if test -f 'isc_strerror_.c'; then $(CYGPATH_W) 'isc_strerror_.c'; else $(CYGPATH_W) '$(srcdir)/isc_strerror_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/isc_strerror_.Tpo" "$(DEPDIR)/isc_strerror_.Po"; else rm -f "$(DEPDIR)/isc_strerror_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='isc_strerror_.c' object='isc_strerror_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o isc_strerror_.obj `if test -f 'isc_strerror_.c'; then $(CYGPATH_W) 'isc_strerror_.c'; else $(CYGPATH_W) '$(srcdir)/isc_strerror_.c'; fi` + +isc_strerror.o: $(srcdir)/../libisc/isc_strerror.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT isc_strerror.o -MD -MP -MF "$(DEPDIR)/isc_strerror.Tpo" -c -o isc_strerror.o `test -f '$(srcdir)/../libisc/isc_strerror.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/isc_strerror.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/isc_strerror.Tpo" "$(DEPDIR)/isc_strerror.Po"; else rm -f "$(DEPDIR)/isc_strerror.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/isc_strerror.c' object='isc_strerror.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o isc_strerror.o `test -f '$(srcdir)/../libisc/isc_strerror.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/isc_strerror.c + +isc_strerror.obj: $(srcdir)/../libisc/isc_strerror.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT isc_strerror.obj -MD -MP -MF "$(DEPDIR)/isc_strerror.Tpo" -c -o isc_strerror.obj `if test -f '$(srcdir)/../libisc/isc_strerror.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/isc_strerror.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/isc_strerror.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/isc_strerror.Tpo" "$(DEPDIR)/isc_strerror.Po"; else rm -f "$(DEPDIR)/isc_strerror.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/isc_strerror.c' object='isc_strerror.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o isc_strerror.obj `if test -f '$(srcdir)/../libisc/isc_strerror.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/isc_strerror.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/isc_strerror.c'; fi` + +inet_ntop_.o: inet_ntop_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_ntop_.o -MD -MP -MF "$(DEPDIR)/inet_ntop_.Tpo" -c -o inet_ntop_.o `test -f 'inet_ntop_.c' || echo '$(srcdir)/'`inet_ntop_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/inet_ntop_.Tpo" "$(DEPDIR)/inet_ntop_.Po"; else rm -f "$(DEPDIR)/inet_ntop_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='inet_ntop_.c' object='inet_ntop_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_ntop_.o `test -f 'inet_ntop_.c' || echo '$(srcdir)/'`inet_ntop_.c + +inet_ntop_.obj: inet_ntop_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_ntop_.obj -MD -MP -MF "$(DEPDIR)/inet_ntop_.Tpo" -c -o inet_ntop_.obj `if test -f 'inet_ntop_.c'; then $(CYGPATH_W) 'inet_ntop_.c'; else $(CYGPATH_W) '$(srcdir)/inet_ntop_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/inet_ntop_.Tpo" "$(DEPDIR)/inet_ntop_.Po"; else rm -f "$(DEPDIR)/inet_ntop_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='inet_ntop_.c' object='inet_ntop_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_ntop_.obj `if test -f 'inet_ntop_.c'; then $(CYGPATH_W) 'inet_ntop_.c'; else $(CYGPATH_W) '$(srcdir)/inet_ntop_.c'; fi` + +inet_ntop.o: $(srcdir)/../libisc/inet_ntop.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_ntop.o -MD -MP -MF "$(DEPDIR)/inet_ntop.Tpo" -c -o inet_ntop.o `test -f '$(srcdir)/../libisc/inet_ntop.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/inet_ntop.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/inet_ntop.Tpo" "$(DEPDIR)/inet_ntop.Po"; else rm -f "$(DEPDIR)/inet_ntop.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/inet_ntop.c' object='inet_ntop.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_ntop.o `test -f '$(srcdir)/../libisc/inet_ntop.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/inet_ntop.c + +inet_ntop.obj: $(srcdir)/../libisc/inet_ntop.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_ntop.obj -MD -MP -MF "$(DEPDIR)/inet_ntop.Tpo" -c -o inet_ntop.obj `if test -f '$(srcdir)/../libisc/inet_ntop.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/inet_ntop.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/inet_ntop.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/inet_ntop.Tpo" "$(DEPDIR)/inet_ntop.Po"; else rm -f "$(DEPDIR)/inet_ntop.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/inet_ntop.c' object='inet_ntop.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_ntop.obj `if test -f '$(srcdir)/../libisc/inet_ntop.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/inet_ntop.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/inet_ntop.c'; fi` + +inet_pton_.o: inet_pton_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_pton_.o -MD -MP -MF "$(DEPDIR)/inet_pton_.Tpo" -c -o inet_pton_.o `test -f 'inet_pton_.c' || echo '$(srcdir)/'`inet_pton_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/inet_pton_.Tpo" "$(DEPDIR)/inet_pton_.Po"; else rm -f "$(DEPDIR)/inet_pton_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='inet_pton_.c' object='inet_pton_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_pton_.o `test -f 'inet_pton_.c' || echo '$(srcdir)/'`inet_pton_.c + +inet_pton_.obj: inet_pton_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_pton_.obj -MD -MP -MF "$(DEPDIR)/inet_pton_.Tpo" -c -o inet_pton_.obj `if test -f 'inet_pton_.c'; then $(CYGPATH_W) 'inet_pton_.c'; else $(CYGPATH_W) '$(srcdir)/inet_pton_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/inet_pton_.Tpo" "$(DEPDIR)/inet_pton_.Po"; else rm -f "$(DEPDIR)/inet_pton_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='inet_pton_.c' object='inet_pton_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_pton_.obj `if test -f 'inet_pton_.c'; then $(CYGPATH_W) 'inet_pton_.c'; else $(CYGPATH_W) '$(srcdir)/inet_pton_.c'; fi` + +inet_pton.o: $(srcdir)/../libisc/inet_pton.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_pton.o -MD -MP -MF "$(DEPDIR)/inet_pton.Tpo" -c -o inet_pton.o `test -f '$(srcdir)/../libisc/inet_pton.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/inet_pton.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/inet_pton.Tpo" "$(DEPDIR)/inet_pton.Po"; else rm -f "$(DEPDIR)/inet_pton.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/inet_pton.c' object='inet_pton.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_pton.o `test -f '$(srcdir)/../libisc/inet_pton.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/inet_pton.c + +inet_pton.obj: $(srcdir)/../libisc/inet_pton.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_pton.obj -MD -MP -MF "$(DEPDIR)/inet_pton.Tpo" -c -o inet_pton.obj `if test -f '$(srcdir)/../libisc/inet_pton.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/inet_pton.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/inet_pton.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/inet_pton.Tpo" "$(DEPDIR)/inet_pton.Po"; else rm -f "$(DEPDIR)/inet_pton.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/inet_pton.c' object='inet_pton.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_pton.obj `if test -f '$(srcdir)/../libisc/inet_pton.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/inet_pton.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/inet_pton.c'; fi` + +netaddr_.o: netaddr_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netaddr_.o -MD -MP -MF "$(DEPDIR)/netaddr_.Tpo" -c -o netaddr_.o `test -f 'netaddr_.c' || echo '$(srcdir)/'`netaddr_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/netaddr_.Tpo" "$(DEPDIR)/netaddr_.Po"; else rm -f "$(DEPDIR)/netaddr_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='netaddr_.c' object='netaddr_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netaddr_.o `test -f 'netaddr_.c' || echo '$(srcdir)/'`netaddr_.c + +netaddr_.obj: netaddr_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netaddr_.obj -MD -MP -MF "$(DEPDIR)/netaddr_.Tpo" -c -o netaddr_.obj `if test -f 'netaddr_.c'; then $(CYGPATH_W) 'netaddr_.c'; else $(CYGPATH_W) '$(srcdir)/netaddr_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/netaddr_.Tpo" "$(DEPDIR)/netaddr_.Po"; else rm -f "$(DEPDIR)/netaddr_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='netaddr_.c' object='netaddr_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netaddr_.obj `if test -f 'netaddr_.c'; then $(CYGPATH_W) 'netaddr_.c'; else $(CYGPATH_W) '$(srcdir)/netaddr_.c'; fi` + +netaddr.o: $(srcdir)/../libisc/netaddr.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netaddr.o -MD -MP -MF "$(DEPDIR)/netaddr.Tpo" -c -o netaddr.o `test -f '$(srcdir)/../libisc/netaddr.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/netaddr.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/netaddr.Tpo" "$(DEPDIR)/netaddr.Po"; else rm -f "$(DEPDIR)/netaddr.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/netaddr.c' object='netaddr.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netaddr.o `test -f '$(srcdir)/../libisc/netaddr.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/netaddr.c + +netaddr.obj: $(srcdir)/../libisc/netaddr.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netaddr.obj -MD -MP -MF "$(DEPDIR)/netaddr.Tpo" -c -o netaddr.obj `if test -f '$(srcdir)/../libisc/netaddr.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/netaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/netaddr.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/netaddr.Tpo" "$(DEPDIR)/netaddr.Po"; else rm -f "$(DEPDIR)/netaddr.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/netaddr.c' object='netaddr.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netaddr.obj `if test -f '$(srcdir)/../libisc/netaddr.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/netaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/netaddr.c'; fi` + +sockaddr_.o: sockaddr_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sockaddr_.o -MD -MP -MF "$(DEPDIR)/sockaddr_.Tpo" -c -o sockaddr_.o `test -f 'sockaddr_.c' || echo '$(srcdir)/'`sockaddr_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/sockaddr_.Tpo" "$(DEPDIR)/sockaddr_.Po"; else rm -f "$(DEPDIR)/sockaddr_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sockaddr_.c' object='sockaddr_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sockaddr_.o `test -f 'sockaddr_.c' || echo '$(srcdir)/'`sockaddr_.c + +sockaddr_.obj: sockaddr_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sockaddr_.obj -MD -MP -MF "$(DEPDIR)/sockaddr_.Tpo" -c -o sockaddr_.obj `if test -f 'sockaddr_.c'; then $(CYGPATH_W) 'sockaddr_.c'; else $(CYGPATH_W) '$(srcdir)/sockaddr_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/sockaddr_.Tpo" "$(DEPDIR)/sockaddr_.Po"; else rm -f "$(DEPDIR)/sockaddr_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sockaddr_.c' object='sockaddr_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sockaddr_.obj `if test -f 'sockaddr_.c'; then $(CYGPATH_W) 'sockaddr_.c'; else $(CYGPATH_W) '$(srcdir)/sockaddr_.c'; fi` + +sockaddr.o: $(srcdir)/../libisc/sockaddr.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sockaddr.o -MD -MP -MF "$(DEPDIR)/sockaddr.Tpo" -c -o sockaddr.o `test -f '$(srcdir)/../libisc/sockaddr.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/sockaddr.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/sockaddr.Tpo" "$(DEPDIR)/sockaddr.Po"; else rm -f "$(DEPDIR)/sockaddr.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/sockaddr.c' object='sockaddr.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sockaddr.o `test -f '$(srcdir)/../libisc/sockaddr.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/sockaddr.c + +sockaddr.obj: $(srcdir)/../libisc/sockaddr.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sockaddr.obj -MD -MP -MF "$(DEPDIR)/sockaddr.Tpo" -c -o sockaddr.obj `if test -f '$(srcdir)/../libisc/sockaddr.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/sockaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/sockaddr.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/sockaddr.Tpo" "$(DEPDIR)/sockaddr.Po"; else rm -f "$(DEPDIR)/sockaddr.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/sockaddr.c' object='sockaddr.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sockaddr.obj `if test -f '$(srcdir)/../libisc/sockaddr.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/sockaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/sockaddr.c'; fi` + +netscope_.o: netscope_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netscope_.o -MD -MP -MF "$(DEPDIR)/netscope_.Tpo" -c -o netscope_.o `test -f 'netscope_.c' || echo '$(srcdir)/'`netscope_.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/netscope_.Tpo" "$(DEPDIR)/netscope_.Po"; else rm -f "$(DEPDIR)/netscope_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='netscope_.c' object='netscope_.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netscope_.o `test -f 'netscope_.c' || echo '$(srcdir)/'`netscope_.c + +netscope_.obj: netscope_.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netscope_.obj -MD -MP -MF "$(DEPDIR)/netscope_.Tpo" -c -o netscope_.obj `if test -f 'netscope_.c'; then $(CYGPATH_W) 'netscope_.c'; else $(CYGPATH_W) '$(srcdir)/netscope_.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/netscope_.Tpo" "$(DEPDIR)/netscope_.Po"; else rm -f "$(DEPDIR)/netscope_.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='netscope_.c' object='netscope_.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netscope_.obj `if test -f 'netscope_.c'; then $(CYGPATH_W) 'netscope_.c'; else $(CYGPATH_W) '$(srcdir)/netscope_.c'; fi` + +netscope.o: $(srcdir)/../libisc/netscope.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netscope.o -MD -MP -MF "$(DEPDIR)/netscope.Tpo" -c -o netscope.o `test -f '$(srcdir)/../libisc/netscope.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/netscope.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/netscope.Tpo" "$(DEPDIR)/netscope.Po"; else rm -f "$(DEPDIR)/netscope.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/netscope.c' object='netscope.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netscope.o `test -f '$(srcdir)/../libisc/netscope.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/netscope.c + +netscope.obj: $(srcdir)/../libisc/netscope.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netscope.obj -MD -MP -MF "$(DEPDIR)/netscope.Tpo" -c -o netscope.obj `if test -f '$(srcdir)/../libisc/netscope.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/netscope.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/netscope.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/netscope.Tpo" "$(DEPDIR)/netscope.Po"; else rm -f "$(DEPDIR)/netscope.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/netscope.c' object='netscope.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netscope.obj `if test -f '$(srcdir)/../libisc/netscope.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/netscope.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/netscope.c'; fi` +a_md5encrypt_.c: a_md5encrypt.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/a_md5encrypt.c; then echo $(srcdir)/a_md5encrypt.c; else echo a_md5encrypt.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +adjtime_.c: adjtime.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/adjtime.c; then echo $(srcdir)/adjtime.c; else echo adjtime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +adjtimex_.c: adjtimex.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/adjtimex.c; then echo $(srcdir)/adjtimex.c; else echo adjtimex.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +assertions_.c: $(srcdir)/../libisc/assertions.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/assertions.c; then echo $(srcdir)/$(srcdir)/../libisc/assertions.c; else echo $(srcdir)/../libisc/assertions.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +atoint_.c: atoint.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/atoint.c; then echo $(srcdir)/atoint.c; else echo atoint.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +atolfp_.c: atolfp.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/atolfp.c; then echo $(srcdir)/atolfp.c; else echo atolfp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +atouint_.c: atouint.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/atouint.c; then echo $(srcdir)/atouint.c; else echo atouint.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +audio_.c: audio.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/audio.c; then echo $(srcdir)/audio.c; else echo audio.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +authkeys_.c: authkeys.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/authkeys.c; then echo $(srcdir)/authkeys.c; else echo authkeys.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +authreadkeys_.c: authreadkeys.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/authreadkeys.c; then echo $(srcdir)/authreadkeys.c; else echo authreadkeys.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +authusekey_.c: authusekey.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/authusekey.c; then echo $(srcdir)/authusekey.c; else echo authusekey.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +buftvtots_.c: buftvtots.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/buftvtots.c; then echo $(srcdir)/buftvtots.c; else echo buftvtots.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +caljulian_.c: caljulian.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/caljulian.c; then echo $(srcdir)/caljulian.c; else echo caljulian.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +caltontp_.c: caltontp.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/caltontp.c; then echo $(srcdir)/caltontp.c; else echo caltontp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +calyearstart_.c: calyearstart.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/calyearstart.c; then echo $(srcdir)/calyearstart.c; else echo calyearstart.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +clocktime_.c: clocktime.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clocktime.c; then echo $(srcdir)/clocktime.c; else echo clocktime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +clocktypes_.c: clocktypes.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clocktypes.c; then echo $(srcdir)/clocktypes.c; else echo clocktypes.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +decodenetnum_.c: decodenetnum.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/decodenetnum.c; then echo $(srcdir)/decodenetnum.c; else echo decodenetnum.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +dofptoa_.c: dofptoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dofptoa.c; then echo $(srcdir)/dofptoa.c; else echo dofptoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +dolfptoa_.c: dolfptoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dolfptoa.c; then echo $(srcdir)/dolfptoa.c; else echo dolfptoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +emalloc_.c: emalloc.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/emalloc.c; then echo $(srcdir)/emalloc.c; else echo emalloc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +error_.c: $(srcdir)/../libisc/error.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/error.c; then echo $(srcdir)/$(srcdir)/../libisc/error.c; else echo $(srcdir)/../libisc/error.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +findconfig_.c: findconfig.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/findconfig.c; then echo $(srcdir)/findconfig.c; else echo findconfig.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +fptoa_.c: fptoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/fptoa.c; then echo $(srcdir)/fptoa.c; else echo fptoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +fptoms_.c: fptoms.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/fptoms.c; then echo $(srcdir)/fptoms.c; else echo fptoms.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +getopt_.c: getopt.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/getopt.c; then echo $(srcdir)/getopt.c; else echo getopt.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +hextoint_.c: hextoint.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/hextoint.c; then echo $(srcdir)/hextoint.c; else echo hextoint.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +hextolfp_.c: hextolfp.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/hextolfp.c; then echo $(srcdir)/hextolfp.c; else echo hextolfp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +humandate_.c: humandate.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/humandate.c; then echo $(srcdir)/humandate.c; else echo humandate.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +icom_.c: icom.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/icom.c; then echo $(srcdir)/icom.c; else echo icom.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +inet_ntop_.c: $(srcdir)/../libisc/inet_ntop.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/inet_ntop.c; then echo $(srcdir)/$(srcdir)/../libisc/inet_ntop.c; else echo $(srcdir)/../libisc/inet_ntop.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +inet_pton_.c: $(srcdir)/../libisc/inet_pton.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/inet_pton.c; then echo $(srcdir)/$(srcdir)/../libisc/inet_pton.c; else echo $(srcdir)/../libisc/inet_pton.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +interfaceiter_.c: $(srcdir)/../libisc/interfaceiter.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/interfaceiter.c; then echo $(srcdir)/$(srcdir)/../libisc/interfaceiter.c; else echo $(srcdir)/../libisc/interfaceiter.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +inttoa_.c: inttoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/inttoa.c; then echo $(srcdir)/inttoa.c; else echo inttoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +iosignal_.c: iosignal.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/iosignal.c; then echo $(srcdir)/iosignal.c; else echo iosignal.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +isc_strerror_.c: $(srcdir)/../libisc/isc_strerror.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/isc_strerror.c; then echo $(srcdir)/$(srcdir)/../libisc/isc_strerror.c; else echo $(srcdir)/../libisc/isc_strerror.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +lib_.c: $(srcdir)/../libisc/lib.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/lib.c; then echo $(srcdir)/$(srcdir)/../libisc/lib.c; else echo $(srcdir)/../libisc/lib.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +lib_strbuf_.c: lib_strbuf.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/lib_strbuf.c; then echo $(srcdir)/lib_strbuf.c; else echo lib_strbuf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +machines_.c: machines.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/machines.c; then echo $(srcdir)/machines.c; else echo machines.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +md5c_.c: md5c.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/md5c.c; then echo $(srcdir)/md5c.c; else echo md5c.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +mem_.c: $(srcdir)/../libisc/mem.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/mem.c; then echo $(srcdir)/$(srcdir)/../libisc/mem.c; else echo $(srcdir)/../libisc/mem.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +memmove_.c: memmove.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/memmove.c; then echo $(srcdir)/memmove.c; else echo memmove.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +mfptoa_.c: mfptoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mfptoa.c; then echo $(srcdir)/mfptoa.c; else echo mfptoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +mfptoms_.c: mfptoms.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mfptoms.c; then echo $(srcdir)/mfptoms.c; else echo mfptoms.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +mktime_.c: mktime.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mktime.c; then echo $(srcdir)/mktime.c; else echo mktime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +modetoa_.c: modetoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/modetoa.c; then echo $(srcdir)/modetoa.c; else echo modetoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +msgcat_.c: $(srcdir)/../libisc/msgcat.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/msgcat.c; then echo $(srcdir)/$(srcdir)/../libisc/msgcat.c; else echo $(srcdir)/../libisc/msgcat.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +mstolfp_.c: mstolfp.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mstolfp.c; then echo $(srcdir)/mstolfp.c; else echo mstolfp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +msutotsf_.c: msutotsf.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/msutotsf.c; then echo $(srcdir)/msutotsf.c; else echo msutotsf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +msyslog_.c: msyslog.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/msyslog.c; then echo $(srcdir)/msyslog.c; else echo msyslog.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +net_.c: $(srcdir)/../libisc/net.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/net.c; then echo $(srcdir)/$(srcdir)/../libisc/net.c; else echo $(srcdir)/../libisc/net.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +netaddr_.c: $(srcdir)/../libisc/netaddr.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/netaddr.c; then echo $(srcdir)/$(srcdir)/../libisc/netaddr.c; else echo $(srcdir)/../libisc/netaddr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +netof_.c: netof.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/netof.c; then echo $(srcdir)/netof.c; else echo netof.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +netscope_.c: $(srcdir)/../libisc/netscope.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/netscope.c; then echo $(srcdir)/$(srcdir)/../libisc/netscope.c; else echo $(srcdir)/../libisc/netscope.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +ntp_random_.c: ntp_random.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_random.c; then echo $(srcdir)/ntp_random.c; else echo ntp_random.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +ntp_rfc2553_.c: ntp_rfc2553.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_rfc2553.c; then echo $(srcdir)/ntp_rfc2553.c; else echo ntp_rfc2553.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +numtoa_.c: numtoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/numtoa.c; then echo $(srcdir)/numtoa.c; else echo numtoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +numtohost_.c: numtohost.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/numtohost.c; then echo $(srcdir)/numtohost.c; else echo numtohost.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +octtoint_.c: octtoint.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/octtoint.c; then echo $(srcdir)/octtoint.c; else echo octtoint.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +prettydate_.c: prettydate.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/prettydate.c; then echo $(srcdir)/prettydate.c; else echo prettydate.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +recvbuff_.c: recvbuff.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/recvbuff.c; then echo $(srcdir)/recvbuff.c; else echo recvbuff.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +refnumtoa_.c: refnumtoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refnumtoa.c; then echo $(srcdir)/refnumtoa.c; else echo refnumtoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +snprintf_.c: snprintf.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/snprintf.c; then echo $(srcdir)/snprintf.c; else echo snprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +sockaddr_.c: $(srcdir)/../libisc/sockaddr.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/sockaddr.c; then echo $(srcdir)/$(srcdir)/../libisc/sockaddr.c; else echo $(srcdir)/../libisc/sockaddr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +socktoa_.c: socktoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/socktoa.c; then echo $(srcdir)/socktoa.c; else echo socktoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +socktohost_.c: socktohost.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/socktohost.c; then echo $(srcdir)/socktohost.c; else echo socktohost.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +statestr_.c: statestr.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/statestr.c; then echo $(srcdir)/statestr.c; else echo statestr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +strdup_.c: strdup.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strdup.c; then echo $(srcdir)/strdup.c; else echo strdup.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +strerror_.c: strerror.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strerror.c; then echo $(srcdir)/strerror.c; else echo strerror.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +strstr_.c: strstr.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strstr.c; then echo $(srcdir)/strstr.c; else echo strstr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +syssignal_.c: syssignal.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/syssignal.c; then echo $(srcdir)/syssignal.c; else echo syssignal.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +systime_.c: systime.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/systime.c; then echo $(srcdir)/systime.c; else echo systime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +systime_s_.c: systime_s.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/systime_s.c; then echo $(srcdir)/systime_s.c; else echo systime_s.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +tsftomsu_.c: tsftomsu.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tsftomsu.c; then echo $(srcdir)/tsftomsu.c; else echo tsftomsu.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +tstotv_.c: tstotv.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tstotv.c; then echo $(srcdir)/tstotv.c; else echo tstotv.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +tvtoa_.c: tvtoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tvtoa.c; then echo $(srcdir)/tvtoa.c; else echo tvtoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +tvtots_.c: tvtots.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tvtots.c; then echo $(srcdir)/tvtots.c; else echo tvtots.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +uglydate_.c: uglydate.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/uglydate.c; then echo $(srcdir)/uglydate.c; else echo uglydate.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +uinttoa_.c: uinttoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/uinttoa.c; then echo $(srcdir)/uinttoa.c; else echo uinttoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +utvtoa_.c: utvtoa.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/utvtoa.c; then echo $(srcdir)/utvtoa.c; else echo utvtoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +ymd2yd_.c: ymd2yd.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ymd2yd.c; then echo $(srcdir)/ymd2yd.c; else echo ymd2yd.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +a_md5encrypt_.$(OBJEXT) a_md5encrypt_.lo adjtime_.$(OBJEXT) \ +adjtime_.lo adjtimex_.$(OBJEXT) adjtimex_.lo assertions_.$(OBJEXT) \ +assertions_.lo atoint_.$(OBJEXT) atoint_.lo atolfp_.$(OBJEXT) \ +atolfp_.lo atouint_.$(OBJEXT) atouint_.lo audio_.$(OBJEXT) audio_.lo \ +authkeys_.$(OBJEXT) authkeys_.lo authreadkeys_.$(OBJEXT) \ +authreadkeys_.lo authusekey_.$(OBJEXT) authusekey_.lo \ +buftvtots_.$(OBJEXT) buftvtots_.lo caljulian_.$(OBJEXT) caljulian_.lo \ +caltontp_.$(OBJEXT) caltontp_.lo calyearstart_.$(OBJEXT) \ +calyearstart_.lo clocktime_.$(OBJEXT) clocktime_.lo \ +clocktypes_.$(OBJEXT) clocktypes_.lo decodenetnum_.$(OBJEXT) \ +decodenetnum_.lo dofptoa_.$(OBJEXT) dofptoa_.lo dolfptoa_.$(OBJEXT) \ +dolfptoa_.lo emalloc_.$(OBJEXT) emalloc_.lo error_.$(OBJEXT) error_.lo \ +findconfig_.$(OBJEXT) findconfig_.lo fptoa_.$(OBJEXT) fptoa_.lo \ +fptoms_.$(OBJEXT) fptoms_.lo getopt_.$(OBJEXT) getopt_.lo \ +hextoint_.$(OBJEXT) hextoint_.lo hextolfp_.$(OBJEXT) hextolfp_.lo \ +humandate_.$(OBJEXT) humandate_.lo icom_.$(OBJEXT) icom_.lo \ +inet_ntop_.$(OBJEXT) inet_ntop_.lo inet_pton_.$(OBJEXT) inet_pton_.lo \ +interfaceiter_.$(OBJEXT) interfaceiter_.lo inttoa_.$(OBJEXT) \ +inttoa_.lo iosignal_.$(OBJEXT) iosignal_.lo isc_strerror_.$(OBJEXT) \ +isc_strerror_.lo lib_.$(OBJEXT) lib_.lo lib_strbuf_.$(OBJEXT) \ +lib_strbuf_.lo machines_.$(OBJEXT) machines_.lo md5c_.$(OBJEXT) \ +md5c_.lo mem_.$(OBJEXT) mem_.lo memmove_.$(OBJEXT) memmove_.lo \ +mfptoa_.$(OBJEXT) mfptoa_.lo mfptoms_.$(OBJEXT) mfptoms_.lo \ +mktime_.$(OBJEXT) mktime_.lo modetoa_.$(OBJEXT) modetoa_.lo \ +msgcat_.$(OBJEXT) msgcat_.lo mstolfp_.$(OBJEXT) mstolfp_.lo \ +msutotsf_.$(OBJEXT) msutotsf_.lo msyslog_.$(OBJEXT) msyslog_.lo \ +net_.$(OBJEXT) net_.lo netaddr_.$(OBJEXT) netaddr_.lo netof_.$(OBJEXT) \ +netof_.lo netscope_.$(OBJEXT) netscope_.lo ntp_random_.$(OBJEXT) \ +ntp_random_.lo ntp_rfc2553_.$(OBJEXT) ntp_rfc2553_.lo \ +numtoa_.$(OBJEXT) numtoa_.lo numtohost_.$(OBJEXT) numtohost_.lo \ +octtoint_.$(OBJEXT) octtoint_.lo prettydate_.$(OBJEXT) prettydate_.lo \ +recvbuff_.$(OBJEXT) recvbuff_.lo refnumtoa_.$(OBJEXT) refnumtoa_.lo \ +snprintf_.$(OBJEXT) snprintf_.lo sockaddr_.$(OBJEXT) sockaddr_.lo \ +socktoa_.$(OBJEXT) socktoa_.lo socktohost_.$(OBJEXT) socktohost_.lo \ +statestr_.$(OBJEXT) statestr_.lo strdup_.$(OBJEXT) strdup_.lo \ +strerror_.$(OBJEXT) strerror_.lo strstr_.$(OBJEXT) strstr_.lo \ +syssignal_.$(OBJEXT) syssignal_.lo systime_.$(OBJEXT) systime_.lo \ +systime_s_.$(OBJEXT) systime_s_.lo tsftomsu_.$(OBJEXT) tsftomsu_.lo \ +tstotv_.$(OBJEXT) tstotv_.lo tvtoa_.$(OBJEXT) tvtoa_.lo \ +tvtots_.$(OBJEXT) tvtots_.lo uglydate_.$(OBJEXT) uglydate_.lo \ +uinttoa_.$(OBJEXT) uinttoa_.lo utvtoa_.$(OBJEXT) utvtoa_.lo \ +ymd2yd_.$(OBJEXT) ymd2yd_.lo : $(ANSI2KNR) + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + 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) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -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." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +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-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am 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 maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-kr \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + + +../include/des.h: + touch ../include/des.h +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/contrib/ntp/libntp/README b/contrib/ntp/libntp/README new file mode 100644 index 0000000..fac7185 --- /dev/null +++ b/contrib/ntp/libntp/README @@ -0,0 +1,5 @@ +README file for directory ./libntp of the NTP Version 4 distribution + +This directory contains the sources for the NTP library used by most +programs in this distribution. See the README and RELNOTES files in the +parent directory for directions on how to make this library. diff --git a/contrib/ntp/libntp/a_md5encrypt.c b/contrib/ntp/libntp/a_md5encrypt.c new file mode 100644 index 0000000..e1ea37c --- /dev/null +++ b/contrib/ntp/libntp/a_md5encrypt.c @@ -0,0 +1,104 @@ +/* + * MD5 interface for rsaref2.0 + * + * These routines implement an interface for the RSA Laboratories + * implementation of the Message Digest 5 (MD5) algorithm. This + * algorithm is included in the rsaref2.0 package available from RSA in + * the US and foreign countries. Further information is available at + * www.rsa.com. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "ntp_fp.h" +#include "ntp_string.h" +#include "ntp_stdlib.h" + +/* Disable the openssl md5 includes, because they'd clash with ours. */ +/* #define NO_MD5 */ +/* #define OPENSSL_NO_MD5 */ +#undef OPENSSL + +#include "ntp.h" +#include "global.h" +#include "ntp_md5.h" + +/* + * MD5authencrypt - generate MD5 message authenticator + * + * Returns length of authenticator field. + */ +int +MD5authencrypt( + u_char *key, /* key pointer */ + u_int32 *pkt, /* packet pointer */ + int length /* packet length */ + ) +{ + MD5_CTX md5; + u_char digest[16]; + + /* + * MD5 with key identifier concatenated with packet. + */ + MD5Init(&md5); + MD5Update(&md5, key, (u_int)cache_keylen); + MD5Update(&md5, (u_char *)pkt, (u_int)length); + MD5Final(digest, &md5); + memmove((u_char *)pkt + length + 4, digest, 16); + return (16 + 4); +} + + +/* + * MD5authdecrypt - verify MD5 message authenticator + * + * Returns one if authenticator valid, zero if invalid. + */ +int +MD5authdecrypt( + u_char *key, /* key pointer */ + u_int32 *pkt, /* packet pointer */ + int length, /* packet length */ + int size /* MAC size */ + ) +{ + MD5_CTX md5; + u_char digest[16]; + + /* + * MD5 with key identifier concatenated with packet. + */ + MD5Init(&md5); + MD5Update(&md5, key, (u_int)cache_keylen); + MD5Update(&md5, (u_char *)pkt, (u_int)length); + MD5Final(digest, &md5); + if (size != 16 + 4) + return (0); + return (!memcmp(digest, (char *)pkt + length + 4, 16)); +} + +/* + * Calculate the reference id from the address. If it is an IPv4 + * address, use it as is. If it is an IPv6 address, do a md5 on + * it and use the bottom 4 bytes. + */ +u_int32 +addr2refid(struct sockaddr_storage *addr) +{ + MD5_CTX md5; + u_char digest[16]; + u_int32 addr_refid; + + if (addr->ss_family == AF_INET) + return (GET_INADDR(*addr)); + + MD5Init(&md5); + MD5Update(&md5, (u_char *)&GET_INADDR6(*addr), + sizeof(struct in6_addr)); + MD5Final(digest, &md5); + memcpy(&addr_refid, digest, 4); + return (addr_refid); +} diff --git a/contrib/ntp/libntp/adjtime.c b/contrib/ntp/libntp/adjtime.c new file mode 100644 index 0000000..a8e6580 --- /dev/null +++ b/contrib/ntp/libntp/adjtime.c @@ -0,0 +1,386 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef MPE +/* + * MPE lacks adjtime(), so we define our own. But note that time slewing has + * a sub-second accuracy bug documented in SR 5003462838 which prevents ntpd + * from being able to maintain clock synch. Because of the bug, this adjtime() + * implementation as used by ntpd has a side-effect of screwing up the hardware + * PDC clock, which will need to be reset with a reboot. + * + * This problem affects all versions of MPE at the time of this writing (when + * MPE/iX 7.0 is the most current). It only causes bad things to happen when + * doing continuous clock synchronization with ntpd; note that you CAN run ntpd + * with "disable ntp" in ntp.conf if you wish to provide a time server. + * + * The one-time clock adjustment functionality of ntpdate and ntp_timeset can + * be used without screwing up the PDC clock. + * + */ +#include <time.h> + +int adjtime(struct timeval *delta, struct timeval *olddelta); + +int adjtime(struct timeval *delta, struct timeval *olddelta) + +{ +/* Documented, supported MPE system intrinsics. */ + +extern void GETPRIVMODE(void); +extern void GETUSERMODE(void); + +/* Undocumented, unsupported MPE internal functions. */ + +extern long long current_correction_usecs(void); +extern long long get_time(void); +extern void get_time_change_info(long long *, char *, char *); +extern long long pdc_time(int *); +extern void set_time_correction(long long, int, int); +extern long long ticks_to_micro(long long); + +long long big_sec, big_usec, new_correction = 0LL; +long long prev_correction; + +if (delta != NULL) { + /* Adjustment required. Convert delta to 64-bit microseconds. */ + big_sec = (long)delta->tv_sec; + big_usec = delta->tv_usec; + new_correction = (big_sec * 1000000LL) + big_usec; +} + +GETPRIVMODE(); + +/* Determine how much of a previous correction (if any) we're interrupting. */ +prev_correction = current_correction_usecs(); + +if (delta != NULL) { + /* Adjustment required. */ + +#if 0 + /* Speculative code disabled until bug SR 5003462838 is fixed. This bug + prevents accurate time slewing, and indeed renders ntpd inoperable. */ + + if (prev_correction != 0LL) { + /* A previous adjustment did not complete. Since the PDC UTC clock was + immediately jumped at the start of the previous adjustment, we must + explicitly reset it to the value of the MPE local time clock minus the + time zone offset. */ + + char pwf_since_boot, recover_pwf_time; + long long offset_ticks, offset_usecs, pdc_usecs_current, pdc_usecs_wanted; + int hpe_status; + + get_time_change_info(&offset_ticks, &pwf_since_boot, &recover_pwf_time); + offset_usecs = ticks_to_micro(offset_ticks); + pdc_usecs_wanted = get_time() - offset_usecs; + pdc_usecs_current = pdc_time(&hpe_status); + if (hpe_status == 0) + /* Force new PDC time by starting an extra correction. */ + set_time_correction(pdc_usecs_wanted - pdc_usecs_current,0,1); + } +#endif /* 0 */ + + /* Immediately jump the PDC time to the new value, and then initiate a + gradual MPE time correction slew. */ + set_time_correction(new_correction,0,1); +} + +GETUSERMODE(); + +if (olddelta != NULL) { + /* Caller wants to know remaining amount of previous correction. */ + (long)olddelta->tv_sec = prev_correction / 1000000LL; + olddelta->tv_usec = prev_correction % 1000000LL; +} + +return 0; +} +#endif /* MPE */ + +#ifdef NEED_HPUX_ADJTIME +/*************************************************************************/ +/* (c) Copyright Tai Jin, 1988. All Rights Reserved. */ +/* Hewlett-Packard Laboratories. */ +/* */ +/* Permission is hereby granted for unlimited modification, use, and */ +/* distribution. This software is made available with no warranty of */ +/* any kind, express or implied. This copyright notice must remain */ +/* intact in all versions of this software. */ +/* */ +/* The author would appreciate it if any bug fixes and enhancements were */ +/* to be sent back to him for incorporation into future versions of this */ +/* software. Please send changes to tai@iag.hp.com or ken@sdd.hp.com. */ +/*************************************************************************/ + +/* + * Revision history + * + * 9 Jul 94 David L. Mills, Unibergity of Delabunch + * Implemented variable threshold to limit age of + * corrections; reformatted code for readability. + */ + +#ifndef lint +static char RCSid[] = "adjtime.c,v 3.1 1993/07/06 01:04:42 jbj Exp"; +#endif + +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/msg.h> +#include <time.h> +#include <signal.h> +#include "adjtime.h" + +#define abs(x) ((x) < 0 ? -(x) : (x)) + +/* + * The following paramters are appropriate for an NTP adjustment + * interval of one second. + */ +#define ADJ_THRESH 200 /* initial threshold */ +#define ADJ_DELTA 4 /* threshold decrement */ + +static long adjthresh; /* adjustment threshold */ +static long saveup; /* corrections accumulator */ + +/* + * clear_adjtime - reset accumulator and threshold variables + */ +void +_clear_adjtime(void) +{ + saveup = 0; + adjthresh = ADJ_THRESH; +} + +/* + * adjtime - hp-ux copout of the standard Unix adjtime() system call + */ +int +adjtime( + register struct timeval *delta, + register struct timeval *olddelta + ) +{ + struct timeval newdelta; + + /* + * Corrections greater than one second are done immediately. + */ + if (delta->tv_sec) { + adjthresh = ADJ_THRESH; + saveup = 0; + return(_adjtime(delta, olddelta)); + } + + /* + * Corrections less than one second are accumulated until + * tripping a threshold, which is initially set at ADJ_THESH and + * reduced in ADJ_DELTA steps to zero. The idea here is to + * introduce large corrections quickly, while making sure that + * small corrections are introduced without excessive delay. The + * idea comes from the ARPAnet routing update algorithm. + */ + saveup += delta->tv_usec; + if (abs(saveup) >= adjthresh) { + adjthresh = ADJ_THRESH; + newdelta.tv_sec = 0; + newdelta.tv_usec = saveup; + saveup = 0; + return(_adjtime(&newdelta, olddelta)); + } else { + adjthresh -= ADJ_DELTA; + } + + /* + * While nobody uses it, return the residual before correction, + * as per Unix convention. + */ + if (olddelta) + olddelta->tv_sec = olddelta->tv_usec = 0; + return(0); +} + +/* + * _adjtime - does the actual work + */ +int +_adjtime( + register struct timeval *delta, + register struct timeval *olddelta + ) +{ + register int mqid; + MsgBuf msg; + register MsgBuf *msgp = &msg; + + /* + * Get the key to the adjtime message queue (note that we must + * get it every time because the queue might have been removed + * and recreated) + */ + if ((mqid = msgget(KEY, 0)) == -1) + return (-1); + msgp->msgb.mtype = CLIENT; + msgp->msgb.tv = *delta; + if (olddelta) + msgp->msgb.code = DELTA2; + else + msgp->msgb.code = DELTA1; + + /* + * Tickle adjtimed and snatch residual, if indicated. Lots of + * fanatic error checking here. + */ + if (msgsnd(mqid, &msgp->msgp, MSGSIZE, 0) == -1) + return (-1); + if (olddelta) { + if (msgrcv(mqid, &msgp->msgp, MSGSIZE, SERVER, 0) == -1) + return (-1); + *olddelta = msgp->msgb.tv; + } + return (0); +} + +#else +# if NEED_QNX_ADJTIME +/* + * Emulate adjtime() using QNX ClockAdjust(). + * Chris Burghart <burghart@atd.ucar.edu>, 11/2001 + * Miroslaw Pabich <miroslaw_pabich@o2.pl>, 09/2005 + * + * This is an implementation of adjtime() for QNX. + * ClockAdjust() is used to tweak the system clock for about + * 1 second period until the desired delta is achieved. + * Time correction slew is limited to reasonable value. + * Internal rounding and relative errors are reduced. + */ +# include <sys/neutrino.h> +# include <sys/time.h> + +# include <ntp_stdlib.h> + +/* + * Time correction slew limit. QNX is a hard real-time system, + * so don't adjust system clock too fast. + */ +#define CORR_SLEW_LIMIT 0.02 /* [s/s] */ + +/* + * Period of system clock adjustment. It should be equal to adjtime + * execution period (1s). If slightly less than 1s (0.95-0.99), then olddelta + * residual error (introduced by execution period jitter) will be reduced. + */ +#define ADJUST_PERIOD 0.97 /* [s] */ + +int +adjtime (struct timeval *delta, struct timeval *olddelta) +{ + double delta_nsec; + double delta_nsec_old; + struct _clockadjust adj; + struct _clockadjust oldadj; + + /* + * How many nanoseconds are we adjusting? + */ + if (delta != NULL) + delta_nsec = 1e9 * (long)delta->tv_sec + 1e3 * delta->tv_usec; + else + delta_nsec = 0; + + /* + * Build the adjust structure and call ClockAdjust() + */ + if (delta_nsec != 0) + { + struct _clockperiod period; + long count; + long increment; + long increment_limit; + int isneg = 0; + + /* + * Convert to absolute value for future processing + */ + if (delta_nsec < 0) + { + isneg = 1; + delta_nsec = -delta_nsec; + } + + /* + * Get the current clock period (nanoseconds) + */ + if (ClockPeriod (CLOCK_REALTIME, 0, &period, 0) < 0) + return -1; + + /* + * Compute count and nanoseconds increment + */ + count = 1e9 * ADJUST_PERIOD / period.nsec; + increment = delta_nsec / count + .5; + /* Reduce relative error */ + if (count > increment + 1) + { + increment = 1 + (long)((delta_nsec - 1) / count); + count = delta_nsec / increment + .5; + } + + /* + * Limit the adjust increment to appropriate value + */ + increment_limit = CORR_SLEW_LIMIT * period.nsec; + if (increment > increment_limit) + { + increment = increment_limit; + count = delta_nsec / increment + .5; + /* Reduce relative error */ + if (increment > count + 1) + { + count = 1 + (long)((delta_nsec - 1) / increment); + increment = delta_nsec / count + .5; + } + } + + adj.tick_nsec_inc = isneg ? -increment : increment; + adj.tick_count = count; + } + else + { + adj.tick_nsec_inc = 0; + adj.tick_count = 0; + } + + if (ClockAdjust (CLOCK_REALTIME, &adj, &oldadj) < 0) + return -1; + + /* + * Build olddelta + */ + delta_nsec_old = (double)oldadj.tick_count * oldadj.tick_nsec_inc; + if (olddelta != NULL) + { + if (delta_nsec_old != 0) + { + /* Reduce rounding error */ + delta_nsec_old += (delta_nsec_old < 0) ? -500 : 500; + olddelta->tv_sec = delta_nsec_old / 1e9; + olddelta->tv_usec = (long)(delta_nsec_old - 1e9 + * (long)olddelta->tv_sec) / 1000; + } + else + { + olddelta->tv_sec = 0; + olddelta->tv_usec = 0; + } + } + + return 0; +} +# else /* no special adjtime() needed */ +int adjtime_bs; +# endif +#endif diff --git a/contrib/ntp/libntp/adjtimex.c b/contrib/ntp/libntp/adjtimex.c new file mode 100644 index 0000000..03e9d79 --- /dev/null +++ b/contrib/ntp/libntp/adjtimex.c @@ -0,0 +1,15 @@ +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +_sccsid:.asciz "11/19/91 ULTRIX @(#)adjtime.c 6.1" +#endif not lint + +#include "SYS.h" + +SYSCALL(adjtimex) + ret + diff --git a/contrib/ntp/libntp/atoint.c b/contrib/ntp/libntp/atoint.c new file mode 100644 index 0000000..46cd96d --- /dev/null +++ b/contrib/ntp/libntp/atoint.c @@ -0,0 +1,50 @@ +/* + * atoint - convert an ascii string to a signed long, with error checking + */ +#include <sys/types.h> +#include <ctype.h> + +#include "ntp_types.h" +#include "ntp_stdlib.h" + +int +atoint( + const char *str, + long *ival + ) +{ + register long u; + register const char *cp; + register int isneg; + register int oflow_digit; + + cp = str; + + if (*cp == '-') { + cp++; + isneg = 1; + oflow_digit = '8'; + } else { + isneg = 0; + oflow_digit = '7'; + } + + if (*cp == '\0') + return 0; + + u = 0; + while (*cp != '\0') { + if (!isdigit((int)*cp)) + return 0; + if (u > 214748364 || (u == 214748364 && *cp > oflow_digit)) + return 0; /* overflow */ + u = (u << 3) + (u << 1); + u += *cp++ - '0'; /* ascii dependent */ + } + + if (isneg) + *ival = -u; + else + *ival = u; + return 1; +} diff --git a/contrib/ntp/libntp/atolfp.c b/contrib/ntp/libntp/atolfp.c new file mode 100644 index 0000000..ff50947 --- /dev/null +++ b/contrib/ntp/libntp/atolfp.c @@ -0,0 +1,118 @@ +/* + * atolfp - convert an ascii string to an l_fp number + */ +#include <stdio.h> +#include <ctype.h> + +#include "ntp_fp.h" +#include "ntp_string.h" + +/* + * Powers of 10 + */ +static u_long ten_to_the_n[10] = { + 0, + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000, +}; + + +int +atolfp( + const char *str, + l_fp *lfp + ) +{ + register const char *cp; + register u_long dec_i; + register u_long dec_f; + char *ind; + int ndec; + int isneg; + static const char *digits = "0123456789"; + + isneg = 0; + dec_i = dec_f = 0; + ndec = 0; + cp = str; + + /* + * We understand numbers of the form: + * + * [spaces][-|+][digits][.][digits][spaces|\n|\0] + */ + while (isspace((int)*cp)) + cp++; + + if (*cp == '-') { + cp++; + isneg = 1; + } + + if (*cp == '+') + cp++; + + if (*cp != '.' && !isdigit((int)*cp)) + return 0; + + while (*cp != '\0' && (ind = strchr(digits, *cp)) != NULL) { + dec_i = (dec_i << 3) + (dec_i << 1); /* multiply by 10 */ + dec_i += (ind - digits); + cp++; + } + + if (*cp != '\0' && !isspace((int)*cp)) { + if (*cp++ != '.') + return 0; + + while (ndec < 9 && *cp != '\0' + && (ind = strchr(digits, *cp)) != NULL) { + ndec++; + dec_f = (dec_f << 3) + (dec_f << 1); /* *10 */ + dec_f += (ind - digits); + cp++; + } + + while (isdigit((int)*cp)) + cp++; + + if (*cp != '\0' && !isspace((int)*cp)) + return 0; + } + + if (ndec > 0) { + register u_long tmp; + register u_long bit; + register u_long ten_fact; + + ten_fact = ten_to_the_n[ndec]; + + tmp = 0; + bit = 0x80000000; + while (bit != 0) { + dec_f <<= 1; + if (dec_f >= ten_fact) { + tmp |= bit; + dec_f -= ten_fact; + } + bit >>= 1; + } + if ((dec_f << 1) > ten_fact) + tmp++; + dec_f = tmp; + } + + if (isneg) + M_NEG(dec_i, dec_f); + + lfp->l_ui = dec_i; + lfp->l_uf = dec_f; + return 1; +} diff --git a/contrib/ntp/libntp/atouint.c b/contrib/ntp/libntp/atouint.c new file mode 100644 index 0000000..c25e3a0 --- /dev/null +++ b/contrib/ntp/libntp/atouint.c @@ -0,0 +1,35 @@ +/* + * atouint - convert an ascii string to an unsigned long, with error checking + */ +#include <sys/types.h> +#include <ctype.h> + +#include "ntp_types.h" +#include "ntp_stdlib.h" + +int +atouint( + const char *str, + u_long *uval + ) +{ + register u_long u; + register const char *cp; + + cp = str; + if (*cp == '\0') + return 0; + + u = 0; + while (*cp != '\0') { + if (!isdigit((int)*cp)) + return 0; + if (u > 429496729 || (u == 429496729 && *cp >= '6')) + return 0; /* overflow */ + u = (u << 3) + (u << 1); + u += *cp++ - '0'; /* ascii dependent */ + } + + *uval = u; + return 1; +} diff --git a/contrib/ntp/libntp/audio.c b/contrib/ntp/libntp/audio.c new file mode 100644 index 0000000..8d2f7c2 --- /dev/null +++ b/contrib/ntp/libntp/audio.c @@ -0,0 +1,496 @@ +/* + * audio.c - audio interface for reference clock audio drivers + */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if defined(HAVE_SYS_AUDIOIO_H) || defined(HAVE_SUN_AUDIOIO_H) || \ + defined(HAVE_SYS_SOUNDCARD_H) || defined(HAVE_MACHINE_SOUNDCARD_H) + +#include "audio.h" +#include "ntp_stdlib.h" +#include "ntp_syslog.h" +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif +#include <stdio.h> +#include "ntp_string.h" + +#ifdef HAVE_SYS_AUDIOIO_H +# include <sys/audioio.h> +#endif /* HAVE_SYS_AUDIOIO_H */ + +#ifdef HAVE_SUN_AUDIOIO_H +# include <sys/ioccom.h> +# include <sun/audioio.h> +#endif /* HAVE_SUN_AUDIOIO_H */ + +#ifdef HAVE_SYS_IOCTL_H +# include <sys/ioctl.h> +#endif /* HAVE_SYS_IOCTL_H */ + +#include <fcntl.h> + +#ifdef HAVE_MACHINE_SOUNDCARD_H +# include <machine/soundcard.h> +# define PCM_STYLE_SOUND +#else +# ifdef HAVE_SYS_SOUNDCARD_H +# include <sys/soundcard.h> +# define PCM_STYLE_SOUND +# endif +#endif + +#ifdef PCM_STYLE_SOUND +# include <ctype.h> +#endif + +/* + * Global variables + */ +#ifdef HAVE_SYS_AUDIOIO_H +static struct audio_device device; /* audio device ident */ +#endif /* HAVE_SYS_AUDIOIO_H */ +#ifdef PCM_STYLE_SOUND +# define INIT_FILE "/etc/ntp.audio" +int agc = SOUND_MIXER_WRITE_RECLEV; /* or IGAIN or LINE */ +int monitor = SOUND_MIXER_WRITE_VOLUME; /* or OGAIN */ +int devmask = 0; +int recmask = 0; +char cf_c_dev[100], cf_i_dev[100], cf_agc[100], cf_monitor[100]; + +const char *m_names[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES; +#else /* not PCM_STYLE_SOUND */ +static struct audio_info info; /* audio device info */ +#endif /* not PCM_STYLE_SOUND */ +static int ctl_fd; /* audio control file descriptor */ + +#ifdef PCM_STYLE_SOUND +static void audio_config_read P((int, char **, char **)); +static int mixer_name P((const char *, int)); + + +int +mixer_name( + const char *m_name, + int m_mask + ) +{ + int i; + + for (i = 0; i < SOUND_MIXER_NRDEVICES; ++i) + if (((1 << i) & m_mask) + && !strcmp(m_names[i], m_name)) + break; + + return (SOUND_MIXER_NRDEVICES == i) + ? -1 + : i + ; +} + + +/* + * Check: + * + * /etc/ntp.audio# where # is the unit number + * /etc/ntp.audio.# where # is the unit number + * /etc/ntp.audio + * + * for contents of the form: + * + * idev /dev/input_device + * cdev /dev/control_device + * agc pcm_input_device {igain,line,line1,...} + * monitor pcm_monitor_device {ogain,...} + * + * The device names for the "agc" and "monitor" keywords + * can be found by running either the "mixer" program or the + * util/audio-pcm program. + * + * Great hunks of this subroutine were swiped from refclock_oncore.c + */ +static void +audio_config_read( + int unit, + char **c_dev, /* Control device */ + char **i_dev /* input device */ + ) +{ + FILE *fd; + char device[20], line[100], ab[100]; + + sprintf(device, "%s%d", INIT_FILE, unit); + if ((fd = fopen(device, "r")) == NULL) { + printf("audio_config_read: <%s> NO\n", device); + sprintf(device, "%s.%d", INIT_FILE, unit); + if ((fd = fopen(device, "r")) == NULL) { + printf("audio_config_read: <%s> NO\n", device); + sprintf(device, "%s.%d", INIT_FILE, unit); + if ((fd = fopen(device, "r")) == NULL) { + printf("audio_config_read: <%s> NO\n", device); + return; + } + } + } + printf("audio_config_read: reading <%s>\n", device); + while (fgets(line, sizeof line, fd)) { + char *cp, *cc, *ca; + int i; + + /* Remove comments */ + if ((cp = strchr(line, '#'))) + *cp = '\0'; + + /* Remove any trailing spaces */ + for (i = strlen(line); + i > 0 && isascii((int)line[i - 1]) && isspace((int)line[i - 1]); + ) + line[--i] = '\0'; + + /* Remove leading space */ + for (cc = line; *cc && isascii((int)*cc) && isspace((int)*cc); cc++) + continue; + + /* Stop if nothing left */ + if (!*cc) + continue; + + /* Uppercase the command and find the arg */ + for (ca = cc; *ca; ca++) { + if (isascii((int)*ca)) { + if (islower((int)*ca)) { + *ca = toupper(*ca); + } else if (isspace((int)*ca) || (*ca == '=')) + break; + } + } + + /* Remove space (and possible =) leading the arg */ + for (; *ca && isascii((int)*ca) && (isspace((int)*ca) || (*ca == '=')); ca++) + continue; + + if (!strncmp(cc, "IDEV", (size_t) 4)) { + sscanf(ca, "%s", ab); + strcpy(cf_i_dev, ab); + printf("idev <%s>\n", ab); + } else if (!strncmp(cc, "CDEV", (size_t) 4)) { + sscanf(ca, "%s", ab); + strcpy(cf_c_dev, ab); + printf("cdev <%s>\n", ab); + } else if (!strncmp(cc, "AGC", (size_t) 3)) { + sscanf(ca, "%s", ab); + strcpy(cf_agc, ab); + printf("agc <%s> %d\n", ab, i); + } else if (!strncmp(cc, "MONITOR", (size_t) 7)) { + sscanf(ca, "%s", ab); + strcpy(cf_monitor, ab); + printf("monitor <%s> %d\n", ab, mixer_name(ab, -1)); + } + } + fclose(fd); + return; +} +#endif /* PCM_STYLE_SOUND */ + +/* + * audio_init - open and initialize audio device + * + * This code works with SunOS 4.x, Solaris 2.x, and PCM; however, it is + * believed generic and applicable to other systems with a minor twid + * or two. All it does is open the device, set the buffer size (Solaris + * only), preset the gain and set the input port. It assumes that the + * codec sample rate (8000 Hz), precision (8 bits), number of channels + * (1) and encoding (ITU-T G.711 mu-law companded) have been set by + * default. + */ +int +audio_init( + char *dname, /* device name */ + int bufsiz, /* buffer size */ + int unit /* device unit (0-3) */ + ) +{ +#ifdef PCM_STYLE_SOUND +# define ACTL_DEV "/dev/mixer%d" + char actl_dev[30]; +# ifdef HAVE_STRUCT_SND_SIZE + struct snd_size s_size; +# endif +# ifdef AIOGFMT + snd_chan_param s_c_p; +# endif +#endif + int fd; + int rval; + char *actl = +#ifdef PCM_STYLE_SOUND + actl_dev +#else + "/dev/audioctl" +#endif + ; + +#ifdef PCM_STYLE_SOUND + (void)sprintf(actl_dev, ACTL_DEV, unit); + + audio_config_read(unit, &actl, &dname); + /* If we have values for cf_c_dev or cf_i_dev, use them. */ + if (*cf_c_dev) + actl = cf_c_dev; + if (*cf_i_dev) + dname = cf_i_dev; +#endif + + /* + * Open audio device. Do not complain if not there. + */ + fd = open(dname, O_RDWR | O_NONBLOCK, 0777); + if (fd < 0) + return (fd); + + /* + * Open audio control device. + */ + ctl_fd = open(actl, O_RDWR); + if (ctl_fd < 0) { + msyslog(LOG_ERR, "audio_init: invalid control device <%s>\n", actl); + close(fd); + return(ctl_fd); + } + + /* + * Set audio device parameters. + */ +#ifdef PCM_STYLE_SOUND + printf("audio_init: <%s> bufsiz %d\n", dname, bufsiz); + rval = fd; + +# ifdef HAVE_STRUCT_SND_SIZE + if (ioctl(fd, AIOGSIZE, &s_size) == -1) + printf("audio_init: AIOGSIZE: %s\n", strerror(errno)); + else + printf("audio_init: orig: play_size %d, rec_size %d\n", + s_size.play_size, s_size.rec_size); + + s_size.play_size = s_size.rec_size = bufsiz; + printf("audio_init: want: play_size %d, rec_size %d\n", + s_size.play_size, s_size.rec_size); + + if (ioctl(fd, AIOSSIZE, &s_size) == -1) + printf("audio_init: AIOSSIZE: %s\n", strerror(errno)); + else + printf("audio_init: set: play_size %d, rec_size %d\n", + s_size.play_size, s_size.rec_size); +# endif /* HAVE_STRUCT_SND_SIZE */ + +# ifdef SNDCTL_DSP_SETFRAGMENT + { + int tmp = (16 << 16) + 6; /* 16 fragments, each 2^6 bytes */ + if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &tmp) == -1) + printf("audio_init: SNDCTL_DSP_SETFRAGMENT: %s\n", + strerror(errno)); + } +# endif /* SNDCTL_DSP_SETFRAGMENT */ + +# ifdef AIOGFMT + if (ioctl(fd, AIOGFMT, &s_c_p) == -1) + printf("audio_init: AIOGFMT: %s\n", strerror(errno)); + else + printf("audio_init: play_rate %lu, rec_rate %lu, play_format %#lx, rec_format %#lx\n", + s_c_p.play_rate, s_c_p.rec_rate, s_c_p.play_format, s_c_p.rec_format); +# endif + + /* Grab the device and record masks */ + + if (ioctl(ctl_fd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1) + printf("SOUND_MIXER_READ_DEVMASK: %s\n", strerror(errno)); + if (ioctl(ctl_fd, SOUND_MIXER_READ_RECMASK, &recmask) == -1) + printf("SOUND_MIXER_READ_RECMASK: %s\n", strerror(errno)); + + /* validate and set any specified config file stuff */ + if (*cf_agc) { + int i; + + i = mixer_name(cf_agc, devmask); + if (i >= 0) + agc = MIXER_WRITE(i); + else + printf("input %s not in recmask %#x\n", + cf_agc, recmask); + } + + if (*cf_monitor) { + int i; + + /* devmask */ + i = mixer_name(cf_monitor, devmask); + if (i >= 0) + monitor = MIXER_WRITE(i); + else + printf("monitor %s not in devmask %#x\n", + cf_monitor, devmask); + } + +#else /* not PCM_STYLE_SOUND */ + AUDIO_INITINFO(&info); + info.play.gain = AUDIO_MAX_GAIN; + info.play.port = AUDIO_SPEAKER; +# ifdef HAVE_SYS_AUDIOIO_H + info.record.buffer_size = bufsiz; +# endif /* HAVE_SYS_AUDIOIO_H */ + rval = ioctl(ctl_fd, (int)AUDIO_SETINFO, (char *)&info); + if (rval < 0) { + msyslog(LOG_ERR, "audio: invalid control device parameters\n"); + close(ctl_fd); + close(fd); + return(rval); + } + rval = fd; +#endif /* not PCM_STYLE_SOUND */ + return (rval); +} + + +/* + * audio_gain - adjust codec gains and port + */ +int +audio_gain( + int gain, /* volume level (gain) 0-255 */ + int mongain, /* input to output mix (monitor gain) 0-255 */ + int port /* selected I/O port: 1 mic/2 line in */ + ) +{ + int rval; + static int o_mongain = -1; + static int o_port = -1; + +#ifdef PCM_STYLE_SOUND + int l, r; + + rval = 0; + + r = l = 100 * gain / 255; /* Normalize to 0-100 */ +# ifdef DEBUG + if (debug > 1) + printf("audio_gain: gain %d/%d\n", gain, l); +# endif + /* figure out what channel(s) to use. just nuke right for now. */ + r = 0 ; /* setting to zero nicely mutes the channel */ + + l |= r << 8; + if ( cf_agc ) + rval = ioctl(ctl_fd, agc, &l); + else + if (port == 2) { + rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_LINE, &l); + } else { + rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_MIC, &l); + } + if (rval == -1) { + printf("audio_gain: agc write: %s\n", strerror(errno)); + return (rval); + } + + if (o_mongain != mongain) { + r = l = 100 * mongain / 255; /* Normalize to 0-100 */ +# ifdef DEBUG + if (debug > 1) + printf("audio_gain: mongain %d/%d\n", mongain, l); +# endif + l |= r << 8; + if ( cf_monitor ) + rval = ioctl(ctl_fd, monitor, &l ); + else + rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_VOLUME, &l); + if (rval == -1) { + printf("audio_gain: mongain write: %s\n", + strerror(errno)); + return (rval); + } + o_mongain = mongain; + } + + if (o_port != port) { +# ifdef DEBUG + if (debug > 1) + printf("audio_gain: port %d\n", port); +# endif + l = (1 << ((port == 2) ? SOUND_MIXER_LINE : SOUND_MIXER_MIC)); + rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_RECSRC, &l); + if (rval == -1) { + printf("SOUND_MIXER_WRITE_RECSRC: %s\n", + strerror(errno)); + return (rval); + } +# ifdef DEBUG + if (debug > 1) { + if (ioctl(ctl_fd, SOUND_MIXER_READ_RECSRC, &l) == -1) + printf("SOUND_MIXER_WRITE_RECSRC: %s\n", + strerror(errno)); + else + printf("audio_gain: recsrc is %d\n", l); + } +# endif + o_port = port; + } +#else /* not PCM_STYLE_SOUND */ + ioctl(ctl_fd, (int)AUDIO_GETINFO, (char *)&info); + info.record.encoding = AUDIO_ENCODING_ULAW; + info.record.error = 0; + info.record.gain = gain; + if (o_mongain != mongain) + o_mongain = info.monitor_gain = mongain; + if (o_port != port) + o_port = info.record.port = port; + rval = ioctl(ctl_fd, (int)AUDIO_SETINFO, (char *)&info); + if (rval < 0) { + msyslog(LOG_ERR, "audio_gain: %m"); + return (rval); + } + rval = info.record.error; +#endif /* not PCM_STYLE_SOUND */ + return (rval); +} + + +/* + * audio_show - display audio parameters + * + * This code doesn't really do anything, except satisfy curiousity and + * verify the ioctl's work. + */ +void +audio_show(void) +{ +#ifdef PCM_STYLE_SOUND + int recsrc = 0; + + printf("audio_show: ctl_fd %d\n", ctl_fd); + if (ioctl(ctl_fd, SOUND_MIXER_READ_RECSRC, &recsrc) == -1) + printf("SOUND_MIXER_READ_RECSRC: %s\n", strerror(errno)); + +#else /* not PCM_STYLE_SOUND */ +# ifdef HAVE_SYS_AUDIOIO_H + ioctl(ctl_fd, (int)AUDIO_GETDEV, &device); + printf("audio: name %s, version %s, config %s\n", + device.name, device.version, device.config); +# endif /* HAVE_SYS_AUDIOIO_H */ + ioctl(ctl_fd, (int)AUDIO_GETINFO, (char *)&info); + printf( + "audio: rate %d, chan %d, prec %d, code %d, gain %d, mon %d, port %d\n", + info.record.sample_rate, info.record.channels, + info.record.precision, info.record.encoding, + info.record.gain, info.monitor_gain, info.record.port); + printf( + "audio: samples %d, eof %d, pause %d, error %d, waiting %d, balance %d\n", + info.record.samples, info.record.eof, + info.record.pause, info.record.error, + info.record.waiting, info.record.balance); +#endif /* not PCM_STYLE_SOUND */ +} +#else +int audio_bs; +#endif /* HAVE_{SYS_AUDIOIO,SUN_AUDIOIO,MACHINE_SOUNDCARD,SYS_SOUNDCARD}_H */ diff --git a/contrib/ntp/libntp/authkeys.c b/contrib/ntp/libntp/authkeys.c new file mode 100644 index 0000000..1c95444 --- /dev/null +++ b/contrib/ntp/libntp/authkeys.c @@ -0,0 +1,488 @@ +/* + * authkeys.c - routines to manage the storage of authentication keys + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> + +#include "ntp_types.h" +#include "ntp_fp.h" +#include "ntp.h" +#include "ntpd.h" +#include "ntp_string.h" +#include "ntp_malloc.h" +#include "ntp_stdlib.h" + +/* + * Structure to store keys in in the hash table. + */ +struct savekey { + struct savekey *next; + union { + long bogon; /* Make sure nonempty */ + u_char MD5_key[32]; /* MD5 key */ + } k; + keyid_t keyid; /* key identifier */ + u_short flags; /* flags that wave */ + u_long lifetime; /* remaining lifetime */ + int keylen; /* key length */ +}; + +#define KEY_TRUSTED 0x001 /* this key is trusted */ +#define KEY_MD5 0x200 /* this is a MD5 type key */ + +/* + * The hash table. This is indexed by the low order bits of the + * keyid. We make this fairly big for potentially busy servers. + */ +#define HASHSIZE 64 +#define HASHMASK ((HASHSIZE)-1) +#define KEYHASH(keyid) ((keyid) & HASHMASK) + +struct savekey *key_hash[HASHSIZE]; + +u_long authkeynotfound; /* keys not found */ +u_long authkeylookups; /* calls to lookup keys */ +u_long authnumkeys; /* number of active keys */ +u_long authkeyexpired; /* key lifetime expirations */ +u_long authkeyuncached; /* cache misses */ +u_long authnokey; /* calls to encrypt with no key */ +u_long authencryptions; /* calls to encrypt */ +u_long authdecryptions; /* calls to decrypt */ + +/* + * Storage for free key structures. We malloc() such things but + * never free them. + */ +struct savekey *authfreekeys; +int authnumfreekeys; + +#define MEMINC 12 /* number of new free ones to get */ + +/* + * The key cache. We cache the last key we looked at here. + */ +keyid_t cache_keyid; /* key identifier */ +u_char *cache_key; /* key pointer */ +u_int cache_keylen; /* key length */ +u_short cache_flags; /* flags that wave */ + + +/* + * init_auth - initialize internal data + */ +void +init_auth(void) +{ + /* + * Initialize hash table and free list + */ + memset((char *)key_hash, 0, sizeof key_hash); +} + + +/* + * auth_findkey - find a key in the hash table + */ +struct savekey * +auth_findkey( + keyid_t keyno + ) +{ + struct savekey *sk; + + sk = key_hash[KEYHASH(keyno)]; + while (sk != 0) { + if (keyno == sk->keyid) + return (sk); + + sk = sk->next; + } + return (0); +} + + +/* + * auth_havekey - return one if the key is known + */ +int +auth_havekey( + keyid_t keyno + ) +{ + struct savekey *sk; + + if (keyno == 0 || (keyno == cache_keyid)) + return (1); + + sk = key_hash[KEYHASH(keyno)]; + while (sk != 0) { + if (keyno == sk->keyid) + return (1); + + sk = sk->next; + } + return (0); +} + + +/* + * authhavekey - return one and cache the key, if known and trusted. + */ +int +authhavekey( + keyid_t keyno + ) +{ + struct savekey *sk; + + authkeylookups++; + if (keyno == 0 || keyno == cache_keyid) + return (1); + + authkeyuncached++; + sk = key_hash[KEYHASH(keyno)]; + while (sk != 0) { + if (keyno == sk->keyid) + break; + sk = sk->next; + } + if (sk == 0) { + authkeynotfound++; + return (0); + } else if (!(sk->flags & KEY_TRUSTED)) { + authnokey++; + return (0); + } + cache_keyid = sk->keyid; + cache_flags = sk->flags; + if (sk->flags & KEY_MD5) { + cache_key = sk->k.MD5_key; + cache_keylen = sk->keylen; + return (1); + } + return (0); +} + + +/* + * auth_moremem - get some more free key structures + */ +int +auth_moremem(void) +{ + struct savekey *sk; + int i; + + sk = (struct savekey *)calloc(MEMINC, sizeof(struct savekey)); + if (sk == 0) + return (0); + + for (i = MEMINC; i > 0; i--) { + sk->next = authfreekeys; + authfreekeys = sk++; + } + authnumfreekeys += MEMINC; + return (authnumfreekeys); +} + + +/* + * authtrust - declare a key to be trusted/untrusted + */ +void +authtrust( + keyid_t keyno, + u_long trust + ) +{ + struct savekey *sk; + +#ifdef DEBUG + if (debug > 2) + printf("authtrust: keyid %08x life %lu\n", keyno, trust); +#endif + sk = key_hash[KEYHASH(keyno)]; + while (sk != 0) { + if (keyno == sk->keyid) + break; + sk = sk->next; + } + + if (sk == 0 && !trust) + return; + + if (sk != 0) { + if (cache_keyid == keyno) { + cache_flags = 0; + cache_keyid = 0; + } + + if (trust > 0) { + sk->flags |= KEY_TRUSTED; + if (trust > 1) + sk->lifetime = current_time + trust; + else + sk->lifetime = 0; + return; + } + + sk->flags &= ~KEY_TRUSTED; { + struct savekey *skp; + + skp = key_hash[KEYHASH(keyno)]; + if (skp == sk) { + key_hash[KEYHASH(keyno)] = sk->next; + } else { + while (skp->next != sk) + skp = skp->next; + skp->next = sk->next; + } + authnumkeys--; + + sk->next = authfreekeys; + authfreekeys = sk; + authnumfreekeys++; + } + return; + } + + if (authnumfreekeys == 0) + if (auth_moremem() == 0) + return; + + sk = authfreekeys; + authfreekeys = sk->next; + authnumfreekeys--; + + sk->keyid = keyno; + sk->flags = KEY_TRUSTED; + sk->next = key_hash[KEYHASH(keyno)]; + key_hash[KEYHASH(keyno)] = sk; + authnumkeys++; + return; +} + + +/* + * authistrusted - determine whether a key is trusted + */ +int +authistrusted( + keyid_t keyno + ) +{ + struct savekey *sk; + + if (keyno == cache_keyid) + return ((cache_flags & KEY_TRUSTED) != 0); + + authkeyuncached++; + sk = key_hash[KEYHASH(keyno)]; + while (sk != 0) { + if (keyno == sk->keyid) + break; + sk = sk->next; + } + if (sk == 0) { + authkeynotfound++; + return (0); + } else if (!(sk->flags & KEY_TRUSTED)) { + authkeynotfound++; + return (0); + } + return (1); +} + + +void +MD5auth_setkey( + keyid_t keyno, + const u_char *key, + const int len + ) +{ + struct savekey *sk; + + /* + * See if we already have the key. If so just stick in the + * new value. + */ + sk = key_hash[KEYHASH(keyno)]; + while (sk != 0) { + if (keyno == sk->keyid) { + strncpy((char *)sk->k.MD5_key, (const char *)key, + sizeof(sk->k.MD5_key)); + if ((sk->keylen = len) > sizeof(sk->k.MD5_key)) + sk->keylen = sizeof(sk->k.MD5_key); + + sk->flags |= KEY_MD5; + if (cache_keyid == keyno) { + cache_flags = 0; + cache_keyid = 0; + } + return; + } + sk = sk->next; + } + + /* + * Need to allocate new structure. Do it. + */ + if (authnumfreekeys == 0) { + if (auth_moremem() == 0) + return; + } + + sk = authfreekeys; + authfreekeys = sk->next; + authnumfreekeys--; + + strncpy((char *)sk->k.MD5_key, (const char *)key, + sizeof(sk->k.MD5_key)); + if ((sk->keylen = len) > sizeof(sk->k.MD5_key)) + sk->keylen = sizeof(sk->k.MD5_key); + + sk->keyid = keyno; + sk->flags = KEY_MD5; + sk->lifetime = 0; + sk->next = key_hash[KEYHASH(keyno)]; + key_hash[KEYHASH(keyno)] = sk; + authnumkeys++; + return; +} + +/* + * auth_delkeys - delete all known keys, in preparation for rereading + * the keys file (presumably) + */ +void +auth_delkeys(void) +{ + struct savekey *sk; + struct savekey **skp; + int i; + + for (i = 0; i < HASHSIZE; i++) { + skp = &(key_hash[i]); + sk = key_hash[i]; + /* + * Leave autokey keys alone. + */ + while (sk != 0 && sk->keyid <= NTP_MAXKEY) { + /* + * Don't lose info as to which keys are trusted. + */ + if (sk->flags & KEY_TRUSTED) { + skp = &(sk->next); + memset(&sk->k, 0, sizeof(sk->k)); + sk->lifetime = 0; + sk->keylen = 0; + sk = sk->next; + } else { + *skp = sk->next; + authnumkeys--; + sk->next = authfreekeys; + authfreekeys = sk; + authnumfreekeys++; + sk = *skp; + } + } + } +} + +/* + * auth_agekeys - delete keys whose lifetimes have expired + */ +void +auth_agekeys(void) +{ + struct savekey *sk; + struct savekey *skp; + int i; + + for (i = 0; i < HASHSIZE; i++) { + sk = skp = key_hash[i]; + while (sk != 0) { + skp = sk->next; + if (sk->lifetime > 0 && current_time > + sk->lifetime) { + authtrust(sk->keyid, 0); + authkeyexpired++; + } + sk = skp; + } + } +#ifdef DEBUG + if (debug) + printf("auth_agekeys: at %lu keys %lu expired %lu\n", + current_time, authnumkeys, authkeyexpired); +#endif +} + +/* + * authencrypt - generate message authenticator + * + * Returns length of authenticator field, zero if key not found. + */ +int +authencrypt( + keyid_t keyno, + u_int32 *pkt, + int length + ) +{ + + /* + * A zero key identifier means the sender has not verified + * the last message was correctly authenticated. The MAC + * consists of a single word with value zero. + */ + authencryptions++; + pkt[length / 4] = htonl(keyno); + if (keyno == 0) { + return (4); + } + if (!authhavekey(keyno)) + return (0); + + if (cache_flags & KEY_MD5) + return (MD5authencrypt(cache_key, pkt, length)); + + return (0); +} + +/* + * authdecrypt - verify message authenticator + * + * Returns one if authenticator valid, zero if invalid or key not found. + */ +int +authdecrypt( + keyid_t keyno, + u_int32 *pkt, + int length, + int size + ) +{ + + /* + * A zero key identifier means the sender has not verified + * the last message was correctly authenticated. Nevertheless, + * the authenticator itself is considered valid. + */ + authdecryptions++; + if (keyno == 0) + return (0); + + if (!authhavekey(keyno) || size < 4) + return (0); + + if (cache_flags & KEY_MD5) + return (MD5authdecrypt(cache_key, pkt, length, size)); + + return (0); +} diff --git a/contrib/ntp/libntp/authreadkeys.c b/contrib/ntp/libntp/authreadkeys.c new file mode 100644 index 0000000..22020f3 --- /dev/null +++ b/contrib/ntp/libntp/authreadkeys.c @@ -0,0 +1,162 @@ +/* + * authreadkeys.c - routines to support the reading of the key file + */ +#include <stdio.h> +#include <ctype.h> + +#include "ntp_fp.h" +#include "ntp.h" +#include "ntp_syslog.h" +#include "ntp_stdlib.h" + +/* + * Arbitrary long string of ASCII characters. + */ +#define KEY_TYPE_MD5 4 + +/* Forwards */ +static char *nexttok P((char **)); + +/* + * nexttok - basic internal tokenizing routine + */ +static char * +nexttok( + char **str + ) +{ + register char *cp; + char *starttok; + + cp = *str; + + /* + * Space past white space + */ + while (*cp == ' ' || *cp == '\t') + cp++; + + /* + * Save this and space to end of token + */ + starttok = cp; + while (*cp != '\0' && *cp != '\n' && *cp != ' ' + && *cp != '\t' && *cp != '#') + cp++; + + /* + * If token length is zero return an error, else set end of + * token to zero and return start. + */ + if (starttok == cp) + return 0; + + if (*cp == ' ' || *cp == '\t') + *cp++ = '\0'; + else + *cp = '\0'; + + *str = cp; + return starttok; +} + + +/* + * authreadkeys - (re)read keys from a file. + */ +int +authreadkeys( + const char *file + ) +{ + FILE *fp; + char *line; + char *token; + u_long keyno; + int keytype; + char buf[512]; /* lots of room for line */ + + /* + * Open file. Complain and return if it can't be opened. + */ + fp = fopen(file, "r"); + if (fp == NULL) { + msyslog(LOG_ERR, "can't open key file %s: %m", file); + return 0; + } + + /* + * Remove all existing keys + */ + auth_delkeys(); + + /* + * Now read lines from the file, looking for key entries + */ + while ((line = fgets(buf, sizeof buf, fp)) != NULL) { + token = nexttok(&line); + if (token == 0) + continue; + + /* + * First is key number. See if it is okay. + */ + keyno = atoi(token); + if (keyno == 0) { + msyslog(LOG_ERR, + "cannot change keyid 0, key entry `%s' ignored", + token); + continue; + } + + if (keyno > NTP_MAXKEY) { + msyslog(LOG_ERR, + "keyid's > %d reserved for autokey, key entry `%s' ignored", + NTP_MAXKEY, token); + continue; + } + + /* + * Next is keytype. See if that is all right. + */ + token = nexttok(&line); + if (token == 0) { + msyslog(LOG_ERR, + "no key type for key number %ld, entry ignored", + keyno); + continue; + } + switch (*token) { + case 'M': + case 'm': + keytype = KEY_TYPE_MD5; break; + default: + msyslog(LOG_ERR, + "invalid key type for key number %ld, entry ignored", + keyno); + continue; + } + + /* + * Finally, get key and insert it + */ + token = nexttok(&line); + if (token == 0) { + msyslog(LOG_ERR, + "no key for number %ld entry, entry ignored", + keyno); + } else { + switch(keytype) { + case KEY_TYPE_MD5: + if (!authusekey(keyno, keytype, + (u_char *)token)) + msyslog(LOG_ERR, + "format/parity error for MD5 key %ld, not used", + keyno); + break; + } + } + } + (void) fclose(fp); + return 1; +} diff --git a/contrib/ntp/libntp/authusekey.c b/contrib/ntp/libntp/authusekey.c new file mode 100644 index 0000000..40dd373 --- /dev/null +++ b/contrib/ntp/libntp/authusekey.c @@ -0,0 +1,47 @@ +/* + * authusekey - decode a key from ascii and use it + */ +#include <stdio.h> +#include <ctype.h> + +#include "ntp_types.h" +#include "ntp_string.h" +#include "ntp_stdlib.h" + +/* + * Types of ascii representations for keys. "Standard" means a 64 bit + * hex number in NBS format, i.e. with the low order bit of each byte + * a parity bit. "NTP" means a 64 bit key in NTP format, with the + * high order bit of each byte a parity bit. "Ascii" means a 1-to-8 + * character string whose ascii representation is used as the key. + */ + +#define KEY_TYPE_MD5 4 + +int +authusekey( + keyid_t keyno, + int keytype, + const u_char *str + ) +{ + const u_char *cp; + int len; + + cp = str; + len = strlen((const char *)cp); + if (len == 0) + return 0; + + switch(keytype) { + case KEY_TYPE_MD5: + MD5auth_setkey(keyno, str, (int)strlen((const char *)str)); + break; + + default: + /* Oh, well */ + return 0; + } + + return 1; +} diff --git a/contrib/ntp/libntp/buftvtots.c b/contrib/ntp/libntp/buftvtots.c new file mode 100644 index 0000000..bfceb35 --- /dev/null +++ b/contrib/ntp/libntp/buftvtots.c @@ -0,0 +1,35 @@ +/* + * buftvtots - pull a Unix-format (struct timeval) time stamp out of + * an octet stream and convert it to a l_fp time stamp. + * This is useful when using the clock line discipline. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include "ntp_fp.h" +#include "ntp_string.h" +#include "ntp_unixtime.h" + +int +buftvtots( + const char *bufp, + l_fp *ts + ) +{ + struct timeval tv; + + /* + * copy to adhere to alignment restrictions + */ + memcpy(&tv, bufp, sizeof(tv)); + + /* + * and use it + */ + ts->l_ui = tv.tv_sec + (u_long)JAN_1970; + if (tv.tv_usec > 999999) + return 0; + TVUTOTSF(tv.tv_usec, ts->l_uf); + return 1; +} diff --git a/contrib/ntp/libntp/caljulian.c b/contrib/ntp/libntp/caljulian.c new file mode 100644 index 0000000..71123df --- /dev/null +++ b/contrib/ntp/libntp/caljulian.c @@ -0,0 +1,146 @@ +/* + * caljulian - determine the Julian date from an NTP time. + */ +#include <sys/types.h> + +#include "ntp_types.h" +#include "ntp_calendar.h" +#include "ntp_stdlib.h" +#include "ntp_fp.h" + +#if 0 +/* + * calmonthtab - days-in-the-month table + */ +static u_short calmonthtab[11] = { + JAN, + FEB, + MAR, + APR, + MAY, + JUN, + JUL, + AUG, + SEP, + OCT, + NOV +}; + +void +caljulian( + u_long ntptime, + register struct calendar *jt + ) +{ + u_long ntp_day; + u_long minutes; + /* + * Absolute, zero-adjusted Christian era day, starting from the + * mythical day 12/1/1 BC + */ + u_long acez_day; + + u_long d400; /* Days into a Gregorian cycle */ + u_long d100; /* Days into a normal century */ + u_long d4; /* Days into a 4-year cycle */ + u_long n400; /* # of Gregorian cycles */ + u_long n100; /* # of normal centuries */ + u_long n4; /* # of 4-year cycles */ + u_long n1; /* # of years into a leap year */ + /* cycle */ + + /* + * Do the easy stuff first: take care of hh:mm:ss, ignoring leap + * seconds + */ + jt->second = (u_char)(ntptime % SECSPERMIN); + minutes = ntptime / SECSPERMIN; + jt->minute = (u_char)(minutes % MINSPERHR); + jt->hour = (u_char)((minutes / MINSPERHR) % HRSPERDAY); + + /* + * Find the day past 1900/01/01 00:00 UTC + */ + ntp_day = ntptime / SECSPERDAY; + acez_day = DAY_NTP_STARTS + ntp_day - 1; + n400 = acez_day/GREGORIAN_CYCLE_DAYS; + d400 = acez_day%GREGORIAN_CYCLE_DAYS; + n100 = d400 / GREGORIAN_NORMAL_CENTURY_DAYS; + d100 = d400 % GREGORIAN_NORMAL_CENTURY_DAYS; + n4 = d100 / GREGORIAN_NORMAL_LEAP_CYCLE_DAYS; + d4 = d100 % GREGORIAN_NORMAL_LEAP_CYCLE_DAYS; + n1 = d4 / DAYSPERYEAR; + + /* + * Calculate the year and year-of-day + */ + jt->yearday = (u_short)(1 + d4%DAYSPERYEAR); + jt->year = (u_short)(400*n400 + 100*n100 + n4*4 + n1); + + if (n100 == 4 || n1 == 4) + { + /* + * If the cycle year ever comes out to 4, it must be December 31st + * of a leap year. + */ + jt->month = 12; + jt->monthday = 31; + jt->yearday = 366; + } + else + { + /* + * Else, search forwards through the months to get the right month + * and date. + */ + int monthday; + + jt->year++; + monthday = jt->yearday; + + for (jt->month=0;jt->month<11; jt->month++) + { + int t; + + t = monthday - calmonthtab[jt->month]; + if (jt->month == 1 && is_leapyear(jt->year)) + t--; + + if (t > 0) + monthday = t; + else + break; + } + jt->month++; + jt->monthday = (u_char) monthday; + } +} +#else + +/* Updated 2003-12-30 TMa + + Uses common code with the *prettydate functions to convert an ntp + seconds count into a calendar date. + Will handle ntp epoch wraparound as long as the underlying os/library + does so for the unix epoch, i.e. works after 2038. +*/ + +void +caljulian( + u_long ntptime, + register struct calendar *jt + ) +{ + struct tm *tm; + + tm = ntp2unix_tm(ntptime, 0); + + jt->hour = (u_char) tm->tm_hour; + jt->minute = (u_char) tm->tm_min; + jt->month = (u_char) (tm->tm_mon + 1); + jt->monthday = (u_char) tm->tm_mday; + jt->second = (u_char) tm->tm_sec; + jt->year = (u_short) (tm->tm_year + 1900); + jt->yearday = (u_short) (tm->tm_yday + 1); /* Assumes tm_yday starts with day 0! */ +} +#endif diff --git a/contrib/ntp/libntp/caltontp.c b/contrib/ntp/libntp/caltontp.c new file mode 100644 index 0000000..9ec1064 --- /dev/null +++ b/contrib/ntp/libntp/caltontp.c @@ -0,0 +1,42 @@ +/* + * caltontp - convert a date to an NTP time + */ +#include <sys/types.h> + +#include "ntp_types.h" +#include "ntp_calendar.h" +#include "ntp_stdlib.h" + +u_long +caltontp( + register const struct calendar *jt + ) +{ + u_long ace_days; /* absolute Christian Era days */ + u_long ntp_days; + int prior_years; + u_long ntp_time; + + /* + * First convert today's date to absolute days past 12/1/1 BC + */ + prior_years = jt->year-1; + ace_days = jt->yearday /* days this year */ + +(DAYSPERYEAR*prior_years) /* plus days in previous years */ + +(prior_years/4) /* plus prior years's leap days */ + -(prior_years/100) /* minus leapless century years */ + +(prior_years/400); /* plus leapful Gregorian yrs */ + + /* + * Subtract out 1/1/1900, the beginning of the NTP epoch + */ + ntp_days = ace_days - DAY_NTP_STARTS; + + /* + * Do the obvious: + */ + ntp_time = + ntp_days*SECSPERDAY+SECSPERMIN*(MINSPERHR*jt->hour + jt->minute); + + return ntp_time; +} diff --git a/contrib/ntp/libntp/calyearstart.c b/contrib/ntp/libntp/calyearstart.c new file mode 100644 index 0000000..0f7ca4f --- /dev/null +++ b/contrib/ntp/libntp/calyearstart.c @@ -0,0 +1,22 @@ +/* + * calyearstart - determine the NTP time at midnight of January 1 in + * the year of the given date. + */ +#include <sys/types.h> + +#include "ntp_types.h" +#include "ntp_calendar.h" +#include "ntp_stdlib.h" + +u_long +calyearstart(u_long ntp_time) +{ + struct calendar jt; + + caljulian(ntp_time,&jt); + jt.yearday = 1; + jt.monthday = 1; + jt.month = 1; + jt.hour = jt.minute = jt.second = 0; + return caltontp(&jt); +} diff --git a/contrib/ntp/libntp/clocktime.c b/contrib/ntp/libntp/clocktime.c new file mode 100644 index 0000000..371859c --- /dev/null +++ b/contrib/ntp/libntp/clocktime.c @@ -0,0 +1,132 @@ +/* + * clocktime - compute the NTP date from a day of year, hour, minute + * and second. + */ +#include "ntp_fp.h" +#include "ntp_unixtime.h" +#include "ntp_stdlib.h" + +/* + * Hacks to avoid excercising the multiplier. I have no pride. + */ +#define MULBY10(x) (((x)<<3) + ((x)<<1)) +#define MULBY60(x) (((x)<<6) - ((x)<<2)) /* watch overflow */ +#define MULBY24(x) (((x)<<4) + ((x)<<3)) + +/* + * Two days, in seconds. + */ +#define TWODAYS (2*24*60*60) + +/* + * We demand that the time be within CLOSETIME seconds of the receive + * time stamp. This is about 4 hours, which hopefully should be + * wide enough to collect most data, while close enough to keep things + * from getting confused. + */ +#define CLOSETIME (4*60*60) + + +int +clocktime( + int yday, + int hour, + int minute, + int second, + int tzoff, + u_long rec_ui, + u_long *yearstart, + u_int32 *ts_ui + ) +{ + register long tmp; + register u_long date; + register u_long yst; + + /* + * Compute the offset into the year in seconds. Note that + * this could come out to be a negative number. + */ + tmp = (long)(MULBY24((yday-1)) + hour + tzoff); + tmp = MULBY60(tmp) + (long)minute; + tmp = MULBY60(tmp) + (long)second; + + /* + * Initialize yearstart, if necessary. + */ + yst = *yearstart; + if (yst == 0) { + yst = calyearstart(rec_ui); + *yearstart = yst; + } + + /* + * Now the fun begins. We demand that the received clock time + * be within CLOSETIME of the receive timestamp, but + * there is uncertainty about the year the timestamp is in. + * Use the current year start for the first check, this should + * work most of the time. + */ + date = (u_long)(tmp + (long)yst); + if (date < (rec_ui + CLOSETIME) && + date > (rec_ui - CLOSETIME)) { + *ts_ui = date; + return 1; + } + + /* + * Trouble. Next check is to see if the year rolled over and, if + * so, try again with the new year's start. + */ + yst = calyearstart(rec_ui); + if (yst != *yearstart) { + date = (u_long)((long)yst + tmp); + *ts_ui = date; + if (date < (rec_ui + CLOSETIME) && + date > (rec_ui - CLOSETIME)) { + *yearstart = yst; + return 1; + } + } + + /* + * Here we know the year start matches the current system + * time. One remaining possibility is that the time code + * is in the year previous to that of the system time. This + * is only worth checking if the receive timestamp is less + * than a couple of days into the new year. + */ + if ((rec_ui - yst) < TWODAYS) { + yst = calyearstart(yst - TWODAYS); + if (yst != *yearstart) { + date = (u_long)(tmp + (long)yst); + if (date < (rec_ui + CLOSETIME) && + date > (rec_ui - CLOSETIME)) { + *yearstart = yst; + *ts_ui = date; + return 1; + } + } + } + + /* + * One last possibility is that the time stamp is in the year + * following the year the system is in. Try this one before + * giving up. + */ + yst = calyearstart(rec_ui + TWODAYS); + if (yst != *yearstart) { + date = (u_long)((long)yst + tmp); + if (date < (rec_ui + CLOSETIME) && + date > (rec_ui - CLOSETIME)) { + *yearstart = yst; + *ts_ui = date; + return 1; + } + } + + /* + * Give it up. + */ + return 0; +} diff --git a/contrib/ntp/libntp/clocktypes.c b/contrib/ntp/libntp/clocktypes.c new file mode 100644 index 0000000..d7dc4ee --- /dev/null +++ b/contrib/ntp/libntp/clocktypes.c @@ -0,0 +1,118 @@ +/* + * Data for pretty printing clock types + */ +#include <stdio.h> + +#include "ntp_fp.h" +#include "ntp.h" +#include "lib_strbuf.h" +#include "ntp_refclock.h" +#include "ntp_stdlib.h" + +struct clktype clktypes[] = { + { REFCLK_NONE, "unspecified type (0)", + "UNKNOWN" }, + { REFCLK_LOCALCLOCK, "Undisciplined local clock (1)", + "LOCAL" }, + { REFCLK_GPS_TRAK, "TRAK 8810 GPS Receiver (2)", + "GPS_TRAK" }, + { REFCLK_WWV_PST, "PSTI/Traconex WWV/WWVH Receiver (3)", + "WWV_PST" }, + { REFCLK_SPECTRACOM, "Spectracom (generic) Receivers (4)", + "SPECTRACOM" }, + { REFCLK_TRUETIME, "TrueTime (generic) Receivers (5)", + "TRUETIME" }, + { REFCLK_IRIG_AUDIO, "IRIG Audio Decoder (6)", + "IRIG_AUDIO" }, + { REFCLK_CHU_AUDIO, "CHU Audio Demodulator/Decoder (7)", + "CHU_AUDIO" }, + { REFCLK_PARSE, "Generic reference clock driver (8)", + "GENERIC" }, + { REFCLK_GPS_MX4200, "Magnavox MX4200 GPS Receiver (9)", + "GPS_MX4200" }, + { REFCLK_GPS_AS2201, "Austron 2201A GPS Receiver (10)", + "GPS_AS2201" }, + { REFCLK_GPS_ARBITER, "Arbiter 1088A/B GPS Receiver (11)", + "GPS_ARBITER" }, + { REFCLK_IRIG_TPRO, "KSI/Odetics TPRO/S IRIG Interface (12)", + "IRIG_TPRO" }, + { REFCLK_ATOM_LEITCH, "Leitch CSD 5300 Master Clock Controller (13)", + "ATOM_LEITCH" }, + { REFCLK_MSF_EES, "EES M201 MSF Receiver (14)", + "MSF_EES" }, + { REFCLK_NONE, "not used (15)", + "NOT_USED" }, + { REFCLK_IRIG_BANCOMM, "Bancomm GPS/IRIG Receiver (16)", + "GPS_BANC" }, + { REFCLK_GPS_DATUM, "Datum Precision Time System (17)", + "GPS_DATUM" }, + { REFCLK_ACTS, "Automated Computer Time Service (18)", + "ACTS_MODEM" }, + { REFCLK_WWV_HEATH, "Heath WWV/WWVH Receiver (19)", + "WWV_HEATH" }, + { REFCLK_GPS_NMEA, "Generic NMEA GPS Receiver (20)", + "GPS_NMEA" }, + { REFCLK_GPS_VME, "TrueTime GPS-VME Interface (21)", + "GPS_VME" }, + { REFCLK_ATOM_PPS, "PPS Clock Discipline (22)", + "PPS" }, + { REFCLK_NONE, "not used (23)", + "NOT_USED" }, + { REFCLK_NONE, "not used (24)", + "NOT_USED" }, + { REFCLK_NONE, "not used (25)", + "NOT_USED" }, + { REFCLK_GPS_HP, "HP 58503A GPS Time & Frequency Receiver (26)", + "GPS_HP" }, + { REFCLK_ARCRON_MSF, "ARCRON MSF (and DCF77) Receiver (27)", + "MSF_ARCRON" }, + { REFCLK_SHM, "Clock attached thru shared Memory (28)", + "SHM" }, + { REFCLK_PALISADE, "Trimble Navigation Palisade GPS (29)", + "GPS_PALISADE" }, + { REFCLK_ONCORE, "Motorola UT Oncore GPS (30)", + "GPS_ONCORE" }, + { REFCLK_GPS_JUPITER, "Rockwell Jupiter GPS (31)", + "GPS_JUPITER" }, + { REFCLK_CHRONOLOG, "Chrono-log K (32)", + "CHRONOLOG" }, + { REFCLK_DUMBCLOCK, "Dumb generic hh:mm:ss local clock (33)", + "DUMBCLOCK" }, + { REFCLK_ULINK, "Ultralink M320 WWVB receiver (34)", + "ULINK_M320"}, + { REFCLK_PCF, "Conrad parallel port radio clock (35)", + "PCF"}, + { REFCLK_WWV_AUDIO, "WWV/H Audio Demodulator/Decoder (36)", + "WWV_AUDIO"}, + { REFCLK_FG, "Forum Graphic GPS Dating Station (37)", + "GPS_FG"}, + { REFCLK_HOPF_SERIAL, "hopf Elektronic serial line receiver (38)", + "HOPF_S"}, + { REFCLK_HOPF_PCI, "hopf Elektronic PCI receiver (39)", + "HOPF_P"}, + { REFCLK_JJY, "JJY receiver (40)", + "JJY"}, + { REFCLK_TT560, "TrueTime 560 IRIG-B decoder (41)", + "TT_IRIG"}, + { REFCLK_ZYFER, "Zyfer GPStarplus receiver (42)", + "GPS_ZYFER" }, + { REFCLK_RIPENCC, "RIPE NCC Trimble driver (43)", + "GPS_RIPENCC" }, + { REFCLK_NEOCLOCK4X, "NeoClock4X DCF77 / TDF receiver (44)", + "NEOCLK4X"}, + { -1, "", "" } +}; + +const char * +clockname( + int num + ) +{ + register struct clktype *clk; + + for (clk = clktypes; clk->code != -1; clk++) { + if (num == clk->code) + return (clk->abbrev); + } + return (NULL); +} diff --git a/contrib/ntp/libntp/decodenetnum.c b/contrib/ntp/libntp/decodenetnum.c new file mode 100644 index 0000000..746c855 --- /dev/null +++ b/contrib/ntp/libntp/decodenetnum.c @@ -0,0 +1,39 @@ +/* + * decodenetnum - return a net number (this is crude, but careful) + */ +#include <sys/types.h> +#include <ctype.h> +#include <sys/socket.h> +#include <netinet/in.h> + +#include "ntp_stdlib.h" + +int +decodenetnum( + const char *num, + struct sockaddr_storage *netnum + ) +{ + struct addrinfo hints, *ai = NULL; + register int err, i; + register const char *cp; + char name[80]; + + cp = num; + + if (*cp == '[') { + cp++; + for (i = 0; *cp != ']'; cp++, i++) + name[i] = *cp; + name[i] = '\0'; + num = name; + } + memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_flags = AI_NUMERICHOST; + err = getaddrinfo(num, NULL, &hints, &ai); + if (err != 0) + return 0; + memcpy(netnum, (struct sockaddr_storage *)ai->ai_addr, ai->ai_addrlen); + freeaddrinfo(ai); + return 1; +} diff --git a/contrib/ntp/libntp/dofptoa.c b/contrib/ntp/libntp/dofptoa.c new file mode 100644 index 0000000..0f96909 --- /dev/null +++ b/contrib/ntp/libntp/dofptoa.c @@ -0,0 +1,118 @@ +/* + * dofptoa - do the grunge work to convert an fp number to ascii + */ +#include <stdio.h> + +#include "ntp_fp.h" +#include "lib_strbuf.h" +#include "ntp_string.h" +#include "ntp_stdlib.h" + +char * +dofptoa( + u_fp fpv, + int neg, + short ndec, + int msec + ) +{ + register u_char *cp, *cpend; + register u_long val; + register short dec; + u_char cbuf[12]; + u_char *cpdec; + char *buf; + char *bp; + + /* + * Get a string buffer before starting + */ + LIB_GETBUF(buf); + + /* + * Zero out the buffer + */ + memset((char *)cbuf, 0, sizeof cbuf); + + /* + * Set the pointers to point at the first + * decimal place. Get a local copy of the value. + */ + cp = cpend = &cbuf[5]; + val = fpv; + + /* + * If we have to, decode the integral part + */ + if (!(val & 0xffff0000)) + cp--; + else { + register u_short sv = (u_short)(val >> 16); + register u_short tmp; + register u_short ten = 10; + + do { + tmp = sv; + sv = (u_short) (sv/ten); + *(--cp) = (u_char)(tmp - ((sv<<3) + (sv<<1))); + } while (sv != 0); + } + + /* + * Figure out how much of the fraction to do + */ + if (msec) { + dec = (short)(ndec + 3); + if (dec < 3) + dec = 3; + cpdec = &cbuf[8]; + } else { + dec = ndec; + cpdec = cpend; + } + + if (dec > 6) + dec = 6; + + if (dec > 0) { + do { + val &= 0xffff; + val = (val << 3) + (val << 1); + *cpend++ = (u_char)(val >> 16); + } while (--dec > 0); + } + + if (val & 0x8000) { + register u_char *tp; + /* + * Round it. Ick. + */ + tp = cpend; + *(--tp) += 1; + while (*tp >= 10) { + *tp = 0; + *(--tp) += 1; + } + } + + /* + * Remove leading zeroes if necessary + */ + while (cp < (cpdec -1) && *cp == 0) + cp++; + + /* + * Copy it into the buffer, asciizing as we go. + */ + bp = buf; + if (neg) + *bp++ = '-'; + + while (cp < cpend) { + if (cp == cpdec) + *bp++ = '.'; + *bp++ = (char)(*cp++ + '0'); + } + *bp = '\0'; + return buf; +} diff --git a/contrib/ntp/libntp/dolfptoa.c b/contrib/ntp/libntp/dolfptoa.c new file mode 100644 index 0000000..f68679c --- /dev/null +++ b/contrib/ntp/libntp/dolfptoa.c @@ -0,0 +1,173 @@ +/* + * dolfptoa - do the grunge work of converting an l_fp number to decimal + */ +#include <stdio.h> + +#include "ntp_fp.h" +#include "lib_strbuf.h" +#include "ntp_string.h" +#include "ntp_stdlib.h" + +char * +dolfptoa( + u_long fpi, + u_long fpv, + int neg, + short ndec, + int msec + ) +{ + register u_char *cp, *cpend; + register u_long lwork; + register int dec; + u_char cbuf[24]; + u_char *cpdec; + char *buf; + char *bp; + + /* + * Get a string buffer before starting + */ + LIB_GETBUF(buf); + + /* + * Zero the character buffer + */ + memset((char *) cbuf, 0, sizeof(cbuf)); + + /* + * safeguard against sign extensions and other mishaps on 64 bit platforms + * the code following is designed for and only for 32-bit inputs and + * only 32-bit worth of input are supplied. + */ + fpi &= 0xffffffff; + fpv &= 0xffffffff; + + /* + * Work on the integral part. This is biased by what I know + * compiles fairly well for a 68000. + */ + cp = cpend = &cbuf[10]; + lwork = fpi; + if (lwork & 0xffff0000) { + register u_long lten = 10; + register u_long ltmp; + + do { + ltmp = lwork; + lwork /= lten; + ltmp -= (lwork << 3) + (lwork << 1); + if (cp < cbuf) abort(); /* rather die a horrible death than trash the memory */ + *--cp = (u_char)ltmp; + } while (lwork & 0xffff0000); + } + if (lwork != 0) { + register u_short sten = 10; + register u_short stmp; + register u_short swork = (u_short)lwork; + + do { + stmp = swork; + swork = (u_short) (swork/sten); + stmp = (u_short)(stmp - ((swork<<3) + (swork<<1))); + if (cp < cbuf) abort(); /* rather die a horrible death than trash the memory */ + *--cp = (u_char)stmp; + } while (swork != 0); + } + + /* + * Done that, now deal with the problem of the fraction. First + * determine the number of decimal places. + */ + if (msec) { + dec = ndec + 3; + if (dec < 3) + dec = 3; + cpdec = &cbuf[13]; + } else { + dec = ndec; + if (dec < 0) + dec = 0; + cpdec = &cbuf[10]; + } + if (dec > 12) + dec = 12; + + /* + * If there's a fraction to deal with, do so. + */ + if (fpv != 0) { + l_fp work; + + work.l_ui = 0; + work.l_uf = fpv; + while (dec > 0) { + l_fp ftmp; + + dec--; + /* + * The scheme here is to multiply the + * fraction (0.1234...) by ten. This moves + * a junk of BCD into the units part. + * record that and iterate. + */ + work.l_ui = 0; + L_LSHIFT(&work); + ftmp = work; + L_LSHIFT(&work); + L_LSHIFT(&work); + L_ADD(&work, &ftmp); + *cpend++ = (u_char)work.l_ui; + if (work.l_uf == 0) + break; + if (cpend > (cbuf + sizeof(cbuf))) abort(); /* rather die a horrible death than trash the memory */ + } + + /* + * Rounding is rotten + */ + if (work.l_uf & 0x80000000) { + register u_char *tp = cpend; + + *(--tp) += 1; + while (*tp >= 10) { + *tp = 0; + *(--tp) += 1; + }; + if (tp < cp) + cp = tp; + } + } + cpend += dec; + + + /* + * We've now got the fraction in cbuf[], with cp pointing at + * the first character, cpend pointing past the last, and + * cpdec pointing at the first character past the decimal. + * Remove leading zeros, then format the number into the + * buffer. + */ + while (cp < cpdec) { + if (*cp != 0) + break; + cp++; + } + if (cp == cpdec) + --cp; + + bp = buf; + if (neg) + *bp++ = '-'; + while (cp < cpend) { + if (cp == cpdec) + *bp++ = '.'; + *bp++ = (char)(*cp++ + '0'); /* ascii dependent? */ + } + *bp = '\0'; + + /* + * Done! + */ + return buf; +} diff --git a/contrib/ntp/libntp/emalloc.c b/contrib/ntp/libntp/emalloc.c new file mode 100644 index 0000000..2fe4c38 --- /dev/null +++ b/contrib/ntp/libntp/emalloc.c @@ -0,0 +1,48 @@ +/* + * emalloc - return new memory obtained from the system. Belch if none. + */ +#include "ntp_types.h" +#include "ntp_malloc.h" +#include "ntp_syslog.h" +#include "ntp_stdlib.h" + +#if defined SYS_WINNT && defined DEBUG +#include <crtdbg.h> +#endif + +#if defined SYS_WINNT && defined DEBUG + +void * +debug_emalloc( + u_int size, + char *filename, + int line + ) +{ + char *mem; + + if ((mem = (char *)_malloc_dbg(size, _NORMAL_BLOCK, filename, line)) == 0) { + msyslog(LOG_ERR, "Exiting: No more memory!"); + exit(1); + } + return mem; +} + +#else + +void * +emalloc( + u_int size + ) +{ + char *mem; + + if ((mem = (char *)malloc(size)) == 0) { + msyslog(LOG_ERR, "Exiting: No more memory!"); + exit(1); + } + return mem; +} + + +#endif diff --git a/contrib/ntp/libntp/findconfig.c b/contrib/ntp/libntp/findconfig.c new file mode 100644 index 0000000..ecf6a4b --- /dev/null +++ b/contrib/ntp/libntp/findconfig.c @@ -0,0 +1,72 @@ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef NEED_HPUX_FINDCONFIG +#include <string.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/utsname.h> +#include <unistd.h> + +const char * +FindConfig( + const char *base + ) +{ + static char result[BUFSIZ]; + char hostname[BUFSIZ], *cp; + struct stat sbuf; + struct utsname unamebuf; + + /* All keyed by initial target being a directory */ + (void) strcpy(result, base); + if (stat(result, &sbuf) == 0) { + if (S_ISDIR(sbuf.st_mode)) { + + /* First choice is my hostname */ + if (gethostname(hostname, BUFSIZ) >= 0) { + (void) sprintf(result, "%s/%s", base, hostname); + if (stat(result, &sbuf) == 0) { + goto outahere; + } else { + + /* Second choice is of form default.835 */ + (void) uname(&unamebuf); + if (strncmp(unamebuf.machine, "9000/", 5) == 0) + cp = unamebuf.machine + 5; + else + cp = unamebuf.machine; + (void) sprintf(result, "%s/default.%s", base, cp); + if (stat(result, &sbuf) == 0) { + goto outahere; + } else { + + /* Last choice is just default */ + (void) sprintf(result, "%s/default", base); + if (stat(result, &sbuf) == 0) { + goto outahere; + } else { + (void) strcpy(result, "/not/found"); + } + } + } + } + } + } + outahere: + return(result); +} +#else +#include "ntp_stdlib.h" + +const char * +FindConfig( + const char *base + ) +{ + return base; +} +#endif diff --git a/contrib/ntp/libntp/fptoa.c b/contrib/ntp/libntp/fptoa.c new file mode 100644 index 0000000..025ad21 --- /dev/null +++ b/contrib/ntp/libntp/fptoa.c @@ -0,0 +1,25 @@ +/* + * fptoa - return an asciized representation of an s_fp number + */ +#include "ntp_fp.h" +#include "ntp_stdlib.h" + +char * +fptoa( + s_fp fpv, + short ndec + ) +{ + u_fp plusfp; + int neg; + + if (fpv < 0) { + plusfp = (u_fp)(-fpv); + neg = 1; + } else { + plusfp = (u_fp)fpv; + neg = 0; + } + + return dofptoa(plusfp, neg, ndec, 0); +} diff --git a/contrib/ntp/libntp/fptoms.c b/contrib/ntp/libntp/fptoms.c new file mode 100644 index 0000000..0bfca55 --- /dev/null +++ b/contrib/ntp/libntp/fptoms.c @@ -0,0 +1,24 @@ +/* + * fptoms - return an asciized s_fp number in milliseconds + */ +#include "ntp_fp.h" + +char * +fptoms( + s_fp fpv, + short ndec + ) +{ + u_fp plusfp; + int neg; + + if (fpv < 0) { + plusfp = (u_fp)(-fpv); + neg = 1; + } else { + plusfp = (u_fp)fpv; + neg = 0; + } + + return dofptoa(plusfp, neg, ndec, 1); +} diff --git a/contrib/ntp/libntp/getopt.c b/contrib/ntp/libntp/getopt.c new file mode 100644 index 0000000..7b344f0 --- /dev/null +++ b/contrib/ntp/libntp/getopt.c @@ -0,0 +1,107 @@ +/* + * getopt - get option letter from argv + * + * This is a version of the public domain getopt() implementation by + * Henry Spencer, changed for 4.3BSD compatibility (in addition to System V). + * It allows rescanning of an option list by setting optind to 0 before + * calling, which is why we use it even if the system has its own (in fact, + * this one has a unique name so as not to conflict with the system's). + * Thanks to Dennis Ferguson for the appropriate modifications. + * + * This file is in the Public Domain. + */ + +/*LINTLIBRARY*/ + +#include <stdio.h> + +#include "ntp_stdlib.h" + +#ifdef lint +#undef putc +#define putc fputc +#endif /* lint */ + +char *ntp_optarg; /* Global argument pointer. */ +int ntp_optind = 0; /* Global argv index. */ +int ntp_opterr = 1; /* for compatibility, should error be printed? */ +int ntp_optopt; /* for compatibility, option character checked */ + +static char *scan = NULL; /* Private scan pointer. */ +static const char *prog = "amnesia"; + +/* + * Print message about a bad option. + */ +static int +badopt( + const char *mess, + int ch + ) +{ + if (ntp_opterr) { + fputs(prog, stderr); + fputs(mess, stderr); + (void) putc(ch, stderr); + (void) putc('\n', stderr); + } + return ('?'); +} + +int +ntp_getopt( + int argc, + char *argv[], + const char *optstring + ) +{ + register char c; + register const char *place; + + prog = argv[0]; + ntp_optarg = NULL; + + if (ntp_optind == 0) { + scan = NULL; + ntp_optind++; + } + + if (scan == NULL || *scan == '\0') { + if (ntp_optind >= argc + || argv[ntp_optind][0] != '-' + || argv[ntp_optind][1] == '\0') { + return (EOF); + } + if (argv[ntp_optind][1] == '-' + && argv[ntp_optind][2] == '\0') { + ntp_optind++; + return (EOF); + } + + scan = argv[ntp_optind++]+1; + } + + c = *scan++; + ntp_optopt = c & 0377; + for (place = optstring; place != NULL && *place != '\0'; ++place) + if (*place == c) + break; + + if (place == NULL || *place == '\0' || c == ':' || c == '?') { + return (badopt(": unknown option -", c)); + } + + place++; + if (*place == ':') { + if (*scan != '\0') { + ntp_optarg = scan; + scan = NULL; + } else if (ntp_optind >= argc) { + return (badopt(": option requires argument -", c)); + } else { + ntp_optarg = argv[ntp_optind++]; + } + } + + return (c & 0377); +} diff --git a/contrib/ntp/libntp/hextoint.c b/contrib/ntp/libntp/hextoint.c new file mode 100644 index 0000000..0d774eb --- /dev/null +++ b/contrib/ntp/libntp/hextoint.c @@ -0,0 +1,39 @@ +/* + * hextoint - convert an ascii string in hex to an unsigned + * long, with error checking + */ +#include <ctype.h> + +#include "ntp_stdlib.h" + +int +hextoint( + const char *str, + u_long *ival + ) +{ + register u_long u; + register const char *cp; + + cp = str; + + if (*cp == '\0') + return 0; + + u = 0; + while (*cp != '\0') { + if (!isxdigit((int)*cp)) + return 0; + if (u >= 0x10000000) + return 0; /* overflow */ + u <<= 4; + if (*cp <= '9') /* very ascii dependent */ + u += *cp++ - '0'; + else if (*cp >= 'a') + u += *cp++ - 'a' + 10; + else + u += *cp++ - 'A' + 10; + } + *ival = u; + return 1; +} diff --git a/contrib/ntp/libntp/hextolfp.c b/contrib/ntp/libntp/hextolfp.c new file mode 100644 index 0000000..d0b6243 --- /dev/null +++ b/contrib/ntp/libntp/hextolfp.c @@ -0,0 +1,67 @@ +/* + * hextolfp - convert an ascii hex string to an l_fp number + */ +#include <stdio.h> +#include <ctype.h> + +#include "ntp_fp.h" +#include "ntp_string.h" +#include "ntp_stdlib.h" + +int +hextolfp( + const char *str, + l_fp *lfp + ) +{ + register const char *cp; + register const char *cpstart; + register u_long dec_i; + register u_long dec_f; + char *ind = NULL; + static const char *digits = "0123456789abcdefABCDEF"; + + dec_i = dec_f = 0; + cp = str; + + /* + * We understand numbers of the form: + * + * [spaces]8_hex_digits[.]8_hex_digits[spaces|\n|\0] + */ + while (isspace((int)*cp)) + cp++; + + cpstart = cp; + while (*cp != '\0' && (cp - cpstart) < 8 && + (ind = strchr(digits, *cp)) != NULL) { + dec_i = dec_i << 4; /* multiply by 16 */ + dec_i += ((ind - digits) > 15) ? (ind - digits) - 6 + : (ind - digits); + cp++; + } + + if ((cp - cpstart) < 8 || ind == NULL) + return 0; + if (*cp == '.') + cp++; + + cpstart = cp; + while (*cp != '\0' && (cp - cpstart) < 8 && + (ind = strchr(digits, *cp)) != NULL) { + dec_f = dec_f << 4; /* multiply by 16 */ + dec_f += ((ind - digits) > 15) ? (ind - digits) - 6 + : (ind - digits); + cp++; + } + + if ((cp - cpstart) < 8 || ind == NULL) + return 0; + + if (*cp != '\0' && !isspace((int)*cp)) + return 0; + + lfp->l_ui = dec_i; + lfp->l_uf = dec_f; + return 1; +} diff --git a/contrib/ntp/libntp/humandate.c b/contrib/ntp/libntp/humandate.c new file mode 100644 index 0000000..630c871 --- /dev/null +++ b/contrib/ntp/libntp/humandate.c @@ -0,0 +1,62 @@ +/* + * humandate - convert an NTP (or the current) time to something readable + */ +#include <stdio.h> +#include "ntp_fp.h" +#include "ntp_unixtime.h" /* includes <sys/time.h> and <time.h> */ +#include "lib_strbuf.h" +#include "ntp_stdlib.h" + +static const char *months[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" +}; +static const char *days[] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" +}; + +char * +humandate( + u_long ntptime + ) +{ + char *bp; + struct tm *tm; + + tm = ntp2unix_tm(ntptime, 1); + + if (!tm) + return "--- --- -- ---- --:--:--"; + + LIB_GETBUF(bp); + + (void) sprintf(bp, "%s, %s %2d %4d %2d:%02d:%02d", + days[tm->tm_wday], months[tm->tm_mon], tm->tm_mday, + 1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); + + return bp; +} + + +/* This is used in msyslog.c; we don't want to clutter up the log with + the year and day of the week, etc.; just the minimal date and time. */ + +char * +humanlogtime(void) +{ + char *bp; + time_t cursec = time((time_t *) 0); + struct tm *tm; + + tm = localtime(&cursec); + if (!tm) + return "-- --- --:--:--"; + + LIB_GETBUF(bp); + + (void) sprintf(bp, "%2d %s %02d:%02d:%02d", + tm->tm_mday, months[tm->tm_mon], + tm->tm_hour, tm->tm_min, tm->tm_sec); + + return bp; +} diff --git a/contrib/ntp/libntp/icom.c b/contrib/ntp/libntp/icom.c new file mode 100644 index 0000000..280667e --- /dev/null +++ b/contrib/ntp/libntp/icom.c @@ -0,0 +1,325 @@ +/* + * Program to control ICOM radios + * + * This is a ripoff of the utility routines in the ICOM software + * distribution. The only function provided is to load the radio + * frequency. All other parameters must be manually set before use. + */ +#include "icom.h" +#include <unistd.h> +#include <stdio.h> +#include <fcntl.h> +#include <errno.h> + +#include "ntp_tty.h" +#include "l_stdlib.h" + +/* + * Scraps + */ +#define BMAX 50 /* max command length */ +#define DICOM /dev/icom/ /* ICOM port link */ + +/* + * FSA definitions + */ +#define S_IDLE 0 /* idle */ +#define S_HDR 1 /* header */ +#define S_TX 2 /* address */ +#define S_DATA 3 /* data */ +#define S_ERROR 4 /* error */ + +/* + * Local function prototypes + */ +static void doublefreq P((double, u_char *, int)); +static int sndpkt P((int, int, u_char *, u_char *)); +static int sndoctet P((int, int)); +static int rcvoctet P((int)); + +/* + * Local variables + */ +static int flags; /* trace flags */ +static int state; /* fsa state */ + + +/* + * icom_freq(fd, ident, freq) - load radio frequency + */ +int +icom_freq( /* returns 0 (ok), EIO (error) */ + int fd, /* file descriptor */ + int ident, /* ICOM radio identifier */ + double freq /* frequency (MHz) */ + ) +{ + u_char cmd[BMAX], rsp[BMAX]; + int temp; + cmd[0] = V_SFREQ; + if (ident == IC735) + temp = 4; + else + temp = 5; + doublefreq(freq * 1e6, &cmd[1], temp); + temp = sndpkt(fd, ident, cmd, rsp); + if (temp < 1 || rsp[0] != ACK) + return (EIO); + return (0); +} + + +/* + * doublefreq(freq, y, len) - double to ICOM frequency with padding + */ +static void +doublefreq( /* returns void */ + double freq, /* frequency */ + u_char *x, /* radio frequency */ + int len /* length (octets) */ + ) +{ + int i; + char s1[11]; + char *y; + + sprintf(s1, " %10.0f", freq); + y = s1 + 10; + i = 0; + while (*y != ' ') { + x[i] = *y-- & 0x0f; + x[i] = x[i] | ((*y-- & 0x0f) << 4); + i++; + } + for (; i < len; i++) + x[i] = 0; + x[i] = FI; +} + + +/* + * Packet routines + * + * These routines send a packet and receive the response. If an error + * (collision) occurs on transmit, the packet is resent. If an error + * occurs on receive (timeout), all input to the terminating FI is + * discarded and the packet is resent. If the maximum number of retries + * is not exceeded, the program returns the number of octets in the user + * buffer; otherwise, it returns zero. + * + * ICOM frame format + * + * Frames begin with a two-octet preamble PR-PR followyd by the + * transceiver address RE, controller address TX, control code CN, zero + * or more data octets DA (depending on command), and terminator FI. + * Since the bus is bidirectional, every octet output is echoed on + * input. Every valid frame sent is answered with a frame in the same + * format, but with the RE and TX fields interchanged. The CN field is + * set to NAK if an error has occurred. Otherwise, the data are returned + * in this and following DA octets. If no data are returned, the CN + * octet is set to ACK. + * + * +------+------+------+------+------+--//--+------+ + * | PR | PR | RE | TX | CN | DA | FI | + * +------+------+------+------+------+--//--+------+ + */ +/* + * icom_open() - open and initialize serial interface + * + * This routine opens the serial interface for raw transmission; that + * is, character-at-a-time, no stripping, checking or monkeying with the + * bits. For Unix, an input operation ends either with the receipt of a + * character or a 0.5-s timeout. + */ +int +icom_init( + char *device, /* device name/link */ + int speed, /* line speed */ + int trace /* trace flags */ ) +{ + TTY ttyb; + int fd; + + flags = trace; + fd = open(device, O_RDWR, 0777); + if (fd < 0) + return (fd); + + tcgetattr(fd, &ttyb); + ttyb.c_iflag = 0; /* input modes */ + ttyb.c_oflag = 0; /* output modes */ + ttyb.c_cflag = IBAUD|CS8|CREAD|CLOCAL; /* control modes */ + ttyb.c_lflag = 0; /* local modes */ + ttyb.c_cc[VMIN] = 0; /* min chars */ + ttyb.c_cc[VTIME] = 5; /* receive timeout */ + cfsetispeed(&ttyb, (u_int)speed); + cfsetospeed(&ttyb, (u_int)speed); + tcsetattr(fd, TCSANOW, &ttyb); + return (fd); +} + + +/* + * sndpkt(r, x, y) - send packet and receive response + * + * This routine sends a command frame, which consists of all except the + * preamble octets PR-PR. It then listens for the response frame and + * returns the payload to the caller. The routine checks for correct + * response header format; that is, the length of the response vector + * returned to the caller must be at least 2 and the RE and TX octets + * must be interchanged; otherwise, the operation is retried up to + * the number of times specified in a global variable. + * + * The trace function, which is enabled by the P_TRACE bit of the global + * flags variable, prints all characters received or echoed on the bus + * preceded by a T (transmit) or R (receive). The P_ERMSG bit of the + * flags variable enables printing of bus error messages. + * + * Note that the first octet sent is a PAD in order to allow time for + * the radio to flush its receive buffer after sending the previous + * response. Even with this precaution, some of the older radios + * occasionally fail to receive a command and it has to be sent again. + */ +static int +sndpkt( /* returns octet count */ + int fd, /* file descriptor */ + int r, /* radio address */ + u_char *cmd, /* command vector */ + u_char *rsp /* response vector */ + ) +{ + int i, j, temp; + + (void)tcflush(fd, TCIOFLUSH); + for (i = 0; i < RETRY; i++) { + state = S_IDLE; + + /* + * Transmit packet. + */ + if (flags & P_TRACE) + printf("icom T:"); + sndoctet(fd, PAD); /* send header */ + sndoctet(fd, PR); + sndoctet(fd, PR); + sndoctet(fd, r); + sndoctet(fd, TX); + for (j = 0; j < BMAX; j++) { /* send body */ + if (sndoctet(fd, cmd[j]) == FI) + break; + } + while (rcvoctet(fd) != FI); /* purge echos */ + if (cmd[0] == V_FREQT || cmd[0] == V_MODET) + return (0); /* shortcut for broadcast */ + + /* + * Receive packet. First, delete all characters + * preceeding a PR, then discard all PRs. Check that the + * RE and TX fields are correctly interchanged, then + * copy the remaining data and FI to the user buffer. + */ + if (flags & P_TRACE) + printf("\nicom R:"); + j = 0; + while ((temp = rcvoctet(fd)) != FI) { + switch (state) { + + case S_IDLE: + if (temp != PR) + continue; + state = S_HDR; + break; + + case S_HDR: + if (temp == PR) { + continue; + } else if (temp != TX) { + if (flags & P_ERMSG) + printf( + "icom: TX error\n"); + state = S_ERROR; + } + state = S_TX; + break; + + case S_TX: + if (temp != r) { + if (flags & P_ERMSG) + printf( + "icom: RE error\n"); + state = S_ERROR; + } + state = S_DATA; + break; + + case S_DATA: + if (j >= BMAX ) { + if (flags & P_ERMSG) + printf( + "icom: buffer overrun\n"); + state = S_ERROR; + j = 0; + } + rsp[j++] = (u_char)temp; + break; + + case S_ERROR: + break; + } + } + if (flags & P_TRACE) + printf("\n"); + if (j > 0) { + rsp[j++] = FI; + return (j); + } + } + if (flags & P_ERMSG) + printf("icom: retries exceeded\n"); + return (0); +} + + +/* + * Interface routines + * + * These routines read and write octets on the bus. In case of receive + * timeout a FI code is returned. In case of output collision (echo + * does not match octet sent), the remainder of the collision frame + * (including the trailing FI) is discarded. + */ +/* + * sndoctet(fd, x) - send octet + */ +static int +sndoctet( /* returns octet */ + int fd, /* file descriptor */ + int x /* octet */ + ) +{ + u_char y; + + y = (u_char)x; + write(fd, &y, 1); + return (x); +} + + +/* + * rcvoctet(fd) - receive octet + */ +static int +rcvoctet( /* returns octet */ + int fd /* file descriptor */ + ) +{ + u_char y; + + if (read(fd, &y, 1) < 1) + y = FI; /* come here if timeout */ + if (flags & P_TRACE && y != PAD) + printf(" %02x", y); + return (y); +} + +/* end program */ diff --git a/contrib/ntp/libntp/inttoa.c b/contrib/ntp/libntp/inttoa.c new file mode 100644 index 0000000..f270733 --- /dev/null +++ b/contrib/ntp/libntp/inttoa.c @@ -0,0 +1,20 @@ +/* + * inttoa - return an asciized signed integer + */ +#include <stdio.h> + +#include "lib_strbuf.h" +#include "ntp_stdlib.h" + +char * +inttoa( + long ival + ) +{ + register char *buf; + + LIB_GETBUF(buf); + + (void) sprintf(buf, "%ld", (long)ival); + return buf; +} diff --git a/contrib/ntp/libntp/iosignal.c b/contrib/ntp/libntp/iosignal.c new file mode 100644 index 0000000..19a6e96 --- /dev/null +++ b/contrib/ntp/libntp/iosignal.c @@ -0,0 +1,557 @@ +/* + * iosignal.c - input/output routines for ntpd. The socket-opening code + * was shamelessly stolen from ntpd. + */ + +/* + * [Bug 158] + * Do the #includes differently, as under some versions of Linux + * sys/param.h has a #undef CONFIG_PHONE line in it. + * + * As we have ~40 CONFIG_ variables, I don't feel like renaming them + * every time somebody adds a new macro to some system header. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> +#include <signal.h> +#ifdef HAVE_SYS_PARAM_H +# include <sys/param.h> +#endif /* HAVE_SYS_PARAM_H */ +#ifdef HAVE_SYS_IOCTL_H +# include <sys/ioctl.h> +#endif + +#include <arpa/inet.h> + +#if _BSDI_VERSION >= 199510 +# include <ifaddrs.h> +#endif + +# ifdef __QNXNTO__ +# include <fcntl.h> +# include <unix.h> +# define FNDELAY O_NDELAY +# endif + +#include "ntp_machine.h" +#include "ntpd.h" +#include "ntp_io.h" +#include "ntp_if.h" +#include "ntp_stdlib.h" +#include "iosignal.h" + +#if defined(HAVE_SIGNALED_IO) +static int sigio_block_count = 0; +# if defined(HAVE_SIGACTION) +/* + * If sigaction() is used for signal handling and a signal is + * pending then the kernel blocks the signal before it calls + * the signal handler. + * + * The variable below is used to take care that the SIGIO signal + * is not unintentionally unblocked inside the sigio_handler() + * if the handler executes a piece of code that is normally + * bracketed by BLOCKIO()/UNBLOCKIO() calls. + */ +static int sigio_handler_active = 0; +# endif +extern void input_handler P((l_fp *)); + +/* + * SIGPOLL and SIGIO ROUTINES. + */ + + /* + * Some systems (MOST) define SIGPOLL == SIGIO, others SIGIO == SIGPOLL, and + * a few have separate SIGIO and SIGPOLL signals. This code checks for the + * SIGIO == SIGPOLL case at compile time. + * Do not define USE_SIGPOLL or USE_SIGIO. + * these are interal only to iosignal.c! + */ +# if defined(USE_SIGPOLL) +# undef USE_SIGPOLL +# endif +# if defined(USE_SIGIO) +# undef USE_SIGIO +# endif + +# if defined(USE_TTY_SIGPOLL) || defined(USE_UDP_SIGPOLL) +# define USE_SIGPOLL +# endif + +# if !defined(USE_TTY_SIGPOLL) || !defined(USE_UDP_SIGPOLL) +# define USE_SIGIO +# endif + +# if defined(USE_SIGIO) && defined(USE_SIGPOLL) +# if SIGIO == SIGPOLL +# define USE_SIGIO +# undef USE_SIGPOLL +# endif /* SIGIO == SIGPOLL */ +# endif /* USE_SIGIO && USE_SIGIO */ + + +/* + * TTY initialization routines. + */ +int +init_clock_sig( + struct refclockio *rio + ) +{ +# ifdef USE_TTY_SIGPOLL + { + /* DO NOT ATTEMPT TO MAKE CLOCK-FD A CTTY: not portable, unreliable */ + if (ioctl(rio->fd, I_SETSIG, S_INPUT) < 0) + { + msyslog(LOG_ERR, + "init_clock_sig: ioctl(I_SETSIG, S_INPUT) failed: %m"); + return 1; + } + return 0; + } +# else + /* + * Special cases first! + */ + /* Was: defined(SYS_HPUX) */ +# if defined(FIOSSAIOOWN) && defined(FIOSNBIO) && defined(FIOSSAIOSTAT) +#define CLOCK_DONE + { + int pgrp, on = 1; + + /* DO NOT ATTEMPT TO MAKE CLOCK-FD A CTTY: not portable, unreliable */ + pgrp = getpid(); + if (ioctl(rio->fd, FIOSSAIOOWN, (char *)&pgrp) == -1) + { + msyslog(LOG_ERR, "ioctl(FIOSSAIOOWN) fails for clock I/O: %m"); + exit(1); + /*NOTREACHED*/ + } + + /* + * set non-blocking, async I/O on the descriptor + */ + if (ioctl(rio->fd, FIOSNBIO, (char *)&on) == -1) + { + msyslog(LOG_ERR, "ioctl(FIOSNBIO) fails for clock I/O: %m"); + exit(1); + /*NOTREACHED*/ + } + + if (ioctl(rio->fd, FIOSSAIOSTAT, (char *)&on) == -1) + { + msyslog(LOG_ERR, "ioctl(FIOSSAIOSTAT) fails for clock I/O: %m"); + exit(1); + /*NOTREACHED*/ + } + return 0; + } +# endif /* SYS_HPUX: FIOSSAIOOWN && FIOSNBIO && FIOSSAIOSTAT */ + /* Was: defined(SYS_AIX) && !defined(_BSD) */ +# if !defined(_BSD) && defined(_AIX) && defined(FIOASYNC) && defined(FIOSETOWN) + /* + * SYSV compatibility mode under AIX. + */ +#define CLOCK_DONE + { + int pgrp, on = 1; + + /* DO NOT ATTEMPT TO MAKE CLOCK-FD A CTTY: not portable, unreliable */ + if (ioctl(rio->fd, FIOASYNC, (char *)&on) == -1) + { + msyslog(LOG_ERR, "ioctl(FIOASYNC) fails for clock I/O: %m"); + return 1; + } + pgrp = -getpid(); + if (ioctl(rio->fd, FIOSETOWN, (char*)&pgrp) == -1) + { + msyslog(LOG_ERR, "ioctl(FIOSETOWN) fails for clock I/O: %m"); + return 1; + } + + if (fcntl(rio->fd, F_SETFL, FNDELAY|FASYNC) < 0) + { + msyslog(LOG_ERR, "fcntl(FNDELAY|FASYNC) fails for clock I/O: %m"); + return 1; + } + return 0; + } +# endif /* AIX && !BSD: !_BSD && FIOASYNC && FIOSETOWN */ +# ifndef CLOCK_DONE + { + /* DO NOT ATTEMPT TO MAKE CLOCK-FD A CTTY: not portable, unreliable */ +# if defined(TIOCSCTTY) && defined(USE_FSETOWNCTTY) + /* + * there are, however, always exceptions to the rules + * one is, that OSF accepts SETOWN on TTY fd's only, iff they are + * CTTYs. SunOS and HPUX do not semm to have this restriction. + * another question is: how can you do multiple SIGIO from several + * ttys (as they all should be CTTYs), wondering... + * + * kd 95-07-16 + */ + if (ioctl(rio->fd, TIOCSCTTY, 0) == -1) + { + msyslog(LOG_ERR, "ioctl(TIOCSCTTY, 0) fails for clock I/O: %m"); + return 1; + } +# endif /* TIOCSCTTY && USE_FSETOWNCTTY */ + + if (fcntl(rio->fd, F_SETOWN, getpid()) == -1) + { + msyslog(LOG_ERR, "fcntl(F_SETOWN) fails for clock I/O: %m"); + return 1; + } + + if (fcntl(rio->fd, F_SETFL, FNDELAY|FASYNC) < 0) + { + msyslog(LOG_ERR, + "fcntl(FNDELAY|FASYNC) fails for clock I/O: %m"); + return 1; + } + return 0; + } +# endif /* CLOCK_DONE */ +# endif /* !USE_TTY_SIGPOLL */ +} + + + +void +init_socket_sig( + int fd + ) +{ +# ifdef USE_UDP_SIGPOLL + { + if (ioctl(fd, I_SETSIG, S_INPUT) < 0) + { + msyslog(LOG_ERR, + "init_socket_sig: ioctl(I_SETSIG, S_INPUT) failed: %m"); + exit(1); + } + } +# else /* USE_UDP_SIGPOLL */ + { + int pgrp; +# ifdef FIOASYNC + int on = 1; +# endif + +# if defined(FIOASYNC) + if (ioctl(fd, FIOASYNC, (char *)&on) == -1) + { + msyslog(LOG_ERR, "ioctl(FIOASYNC) fails: %m"); + exit(1); + /*NOTREACHED*/ + } +# elif defined(FASYNC) + { + int flags; + + if ((flags = fcntl(fd, F_GETFL, 0)) == -1) + { + msyslog(LOG_ERR, "fcntl(F_GETFL) fails: %m"); + exit(1); + /*NOTREACHED*/ + } + if (fcntl(fd, F_SETFL, flags|FASYNC) < 0) + { + msyslog(LOG_ERR, "fcntl(...|FASYNC) fails: %m"); + exit(1); + /*NOTREACHED*/ + } + } +# else +# include "Bletch: Need asynchronous I/O!" +# endif + +# ifdef UDP_BACKWARDS_SETOWN + pgrp = -getpid(); +# else + pgrp = getpid(); +# endif + +# if defined(SIOCSPGRP) + if (ioctl(fd, SIOCSPGRP, (char *)&pgrp) == -1) + { + msyslog(LOG_ERR, "ioctl(SIOCSPGRP) fails: %m"); + exit(1); + /*NOTREACHED*/ + } +# elif defined(FIOSETOWN) + if (ioctl(fd, FIOSETOWN, (char*)&pgrp) == -1) + { + msyslog(LOG_ERR, "ioctl(FIOSETOWN) fails: %m"); + exit(1); + /*NOTREACHED*/ + } +# elif defined(F_SETOWN) + if (fcntl(fd, F_SETOWN, pgrp) == -1) + { + msyslog(LOG_ERR, "fcntl(F_SETOWN) fails: %m"); + exit(1); + /*NOTREACHED*/ + } +# else +# include "Bletch: Need to set process(group) to receive SIG(IO|POLL)" +# endif + } +# endif /* USE_UDP_SIGPOLL */ +} + +RETSIGTYPE +sigio_handler( + int sig + ) +{ + int saved_errno = errno; + l_fp ts; + + get_systime(&ts); + +# if defined(HAVE_SIGACTION) + sigio_handler_active++; + if (sigio_handler_active != 1) /* This should never happen! */ + msyslog(LOG_ERR, "sigio_handler: sigio_handler_active != 1"); +# endif + + (void)input_handler(&ts); + +# if defined(HAVE_SIGACTION) + sigio_handler_active--; + if (sigio_handler_active != 0) /* This should never happen! */ + msyslog(LOG_ERR, "sigio_handler: sigio_handler_active != 0"); +# endif + + errno = saved_errno; +} + +/* + * Signal support routines. + */ +# ifdef HAVE_SIGACTION +void +set_signal(void) +{ +# ifdef USE_SIGIO + (void) signal_no_reset(SIGIO, sigio_handler); +# endif +# ifdef USE_SIGPOLL + (void) signal_no_reset(SIGPOLL, sigio_handler); +# endif +} + +void +block_io_and_alarm(void) +{ + sigset_t set; + + if (sigemptyset(&set)) + msyslog(LOG_ERR, "block_io_and_alarm: sigemptyset() failed: %m"); +# if defined(USE_SIGIO) + if (sigaddset(&set, SIGIO)) + msyslog(LOG_ERR, "block_io_and_alarm: sigaddset(SIGIO) failed: %m"); +# endif +# if defined(USE_SIGPOLL) + if (sigaddset(&set, SIGPOLL)) + msyslog(LOG_ERR, "block_io_and_alarm: sigaddset(SIGPOLL) failed: %m"); +# endif + if (sigaddset(&set, SIGALRM)) + msyslog(LOG_ERR, "block_io_and_alarm: sigaddset(SIGALRM) failed: %m"); + + if (sigprocmask(SIG_BLOCK, &set, NULL)) + msyslog(LOG_ERR, "block_io_and_alarm: sigprocmask() failed: %m"); +} + +void +block_sigio(void) +{ + if ( sigio_handler_active == 0 ) /* not called from within signal handler */ + { + sigset_t set; + + ++sigio_block_count; + if (sigio_block_count > 1) + msyslog(LOG_INFO, "block_sigio: sigio_block_count > 1"); + if (sigio_block_count < 1) + msyslog(LOG_INFO, "block_sigio: sigio_block_count < 1"); + + if (sigemptyset(&set)) + msyslog(LOG_ERR, "block_sigio: sigemptyset() failed: %m"); +# if defined(USE_SIGIO) + if (sigaddset(&set, SIGIO)) + msyslog(LOG_ERR, "block_sigio: sigaddset(SIGIO) failed: %m"); +# endif +# if defined(USE_SIGPOLL) + if (sigaddset(&set, SIGPOLL)) + msyslog(LOG_ERR, "block_sigio: sigaddset(SIGPOLL) failed: %m"); +# endif + + if (sigprocmask(SIG_BLOCK, &set, NULL)) + msyslog(LOG_ERR, "block_sigio: sigprocmask() failed: %m"); + } +} + +void +unblock_io_and_alarm(void) +{ + sigset_t unset; + + if (sigemptyset(&unset)) + msyslog(LOG_ERR, "unblock_io_and_alarm: sigemptyset() failed: %m"); + +# if defined(USE_SIGIO) + if (sigaddset(&unset, SIGIO)) + msyslog(LOG_ERR, "unblock_io_and_alarm: sigaddset(SIGIO) failed: %m"); +# endif +# if defined(USE_SIGPOLL) + if (sigaddset(&unset, SIGPOLL)) + msyslog(LOG_ERR, "unblock_io_and_alarm: sigaddset(SIGPOLL) failed: %m"); +# endif + if (sigaddset(&unset, SIGALRM)) + msyslog(LOG_ERR, "unblock_io_and_alarm: sigaddset(SIGALRM) failed: %m"); + + if (sigprocmask(SIG_UNBLOCK, &unset, NULL)) + msyslog(LOG_ERR, "unblock_io_and_alarm: sigprocmask() failed: %m"); +} + +void +unblock_sigio(void) +{ + if ( sigio_handler_active == 0 ) /* not called from within signal handler */ + { + sigset_t unset; + + --sigio_block_count; + if (sigio_block_count > 0) + msyslog(LOG_INFO, "unblock_sigio: sigio_block_count > 0"); + if (sigio_block_count < 0) + msyslog(LOG_INFO, "unblock_sigio: sigio_block_count < 0"); + + if (sigemptyset(&unset)) + msyslog(LOG_ERR, "unblock_sigio: sigemptyset() failed: %m"); + +# if defined(USE_SIGIO) + if (sigaddset(&unset, SIGIO)) + msyslog(LOG_ERR, "unblock_sigio: sigaddset(SIGIO) failed: %m"); +# endif +# if defined(USE_SIGPOLL) + if (sigaddset(&unset, SIGPOLL)) + msyslog(LOG_ERR, "unblock_sigio: sigaddset(SIGPOLL) failed: %m"); +# endif + + if (sigprocmask(SIG_UNBLOCK, &unset, NULL)) + msyslog(LOG_ERR, "unblock_sigio: sigprocmask() failed: %m"); + } +} + +void +wait_for_signal(void) +{ + sigset_t old; + + if (sigprocmask(SIG_UNBLOCK, NULL, &old)) + msyslog(LOG_ERR, "wait_for_signal: sigprocmask() failed: %m"); + +# if defined(USE_SIGIO) + if (sigdelset(&old, SIGIO)) + msyslog(LOG_ERR, "wait_for_signal: sigdelset(SIGIO) failed: %m"); +# endif +# if defined(USE_SIGPOLL) + if (sigdelset(&old, SIGPOLL)) + msyslog(LOG_ERR, "wait_for_signal: sigdelset(SIGPOLL) failed: %m"); +# endif + if (sigdelset(&old, SIGALRM)) + msyslog(LOG_ERR, "wait_for_signal: sigdelset(SIGALRM) failed: %m"); + + if (sigsuspend(&old) && (errno != EINTR)) + msyslog(LOG_ERR, "wait_for_signal: sigsuspend() failed: %m"); +} + +# else /* !HAVE_SIGACTION */ +/* + * Must be an old bsd system. + * We assume there is no SIGPOLL. + */ + +void +block_io_and_alarm(void) +{ + int mask; + + mask = sigmask(SIGIO) | sigmask(SIGALRM); + if (sigblock(mask)) + msyslog(LOG_ERR, "block_io_and_alarm: sigblock() failed: %m"); +} + +void +block_sigio(void) +{ + int mask; + + ++sigio_block_count; + if (sigio_block_count > 1) + msyslog(LOG_INFO, "block_sigio: sigio_block_count > 1"); + if (sigio_block_count < 1) + msyslog(LOG_INFO, "block_sigio: sigio_block_count < 1"); + + mask = sigmask(SIGIO); + if (sigblock(mask)) + msyslog(LOG_ERR, "block_sigio: sigblock() failed: %m"); +} + +void +set_signal(void) +{ + (void) signal_no_reset(SIGIO, sigio_handler); +} + +void +unblock_io_and_alarm(void) +{ + int mask, omask; + + mask = sigmask(SIGIO) | sigmask(SIGALRM); + omask = sigblock(0); + omask &= ~mask; + (void) sigsetmask(omask); +} + +void +unblock_sigio(void) +{ + int mask, omask; + + --sigio_block_count; + if (sigio_block_count > 0) + msyslog(LOG_INFO, "unblock_sigio: sigio_block_count > 0"); + if (sigio_block_count < 0) + msyslog(LOG_INFO, "unblock_sigio: sigio_block_count < 0"); + mask = sigmask(SIGIO); + omask = sigblock(0); + omask &= ~mask; + (void) sigsetmask(omask); +} + +void +wait_for_signal(void) +{ + int mask, omask; + + mask = sigmask(SIGIO) | sigmask(SIGALRM); + omask = sigblock(0); + omask &= ~mask; + if (sigpause(omask) && (errno != EINTR)) + msyslog(LOG_ERR, "wait_for_signal: sigspause() failed: %m"); +} + +# endif /* HAVE_SIGACTION */ +#else +int NotAnEmptyCompilationUnit; +#endif diff --git a/contrib/ntp/libntp/lib_strbuf.c b/contrib/ntp/libntp/lib_strbuf.c new file mode 100644 index 0000000..315070f --- /dev/null +++ b/contrib/ntp/libntp/lib_strbuf.c @@ -0,0 +1,23 @@ +/* + * lib_strbuf - library string storage + */ + +#include "ntp_stdlib.h" +#include "lib_strbuf.h" + +/* + * Storage declarations + */ +char lib_stringbuf[LIB_NUMBUFS][LIB_BUFLENGTH]; +int lib_nextbuf; +int lib_inited = 0; + +/* + * initialization routine. Might be needed if the code is ROMized. + */ +void +init_lib(void) +{ + lib_nextbuf = 0; + lib_inited = 1; +} diff --git a/contrib/ntp/libntp/lib_strbuf.h b/contrib/ntp/libntp/lib_strbuf.h new file mode 100644 index 0000000..5aa0eb0 --- /dev/null +++ b/contrib/ntp/libntp/lib_strbuf.h @@ -0,0 +1,28 @@ +/* + * lib_strbuf.h - definitions for routines which use the common string buffers + */ + +#include <ntp_types.h> + +/* + * Sizes of things + */ +#define LIB_NUMBUFS 200 +#define LIB_BUFLENGTH 80 + +/* + * Macro to get a pointer to the next buffer + */ +#define LIB_GETBUF(buf) \ + do { \ + if (!lib_inited) \ + init_lib(); \ + buf = &lib_stringbuf[lib_nextbuf][0]; \ + if (++lib_nextbuf >= LIB_NUMBUFS) \ + lib_nextbuf = 0; \ + memset(buf, 0, LIB_BUFLENGTH); \ + } while (0) + +extern char lib_stringbuf[LIB_NUMBUFS][LIB_BUFLENGTH]; +extern int lib_nextbuf; +extern int lib_inited; diff --git a/contrib/ntp/libntp/machines.c b/contrib/ntp/libntp/machines.c new file mode 100644 index 0000000..c8e4e07 --- /dev/null +++ b/contrib/ntp/libntp/machines.c @@ -0,0 +1,527 @@ +/* machines.c - provide special support for peculiar architectures + * + * Real bummers unite ! + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ntp_machine.h" +#include "ntp_syslog.h" +#include "ntp_stdlib.h" +#include "ntp_unixtime.h" + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef SYS_WINNT +int _getch(void); /* Declare the one function rather than include conio.h */ +#else + +#ifdef SYS_VXWORKS +#include "taskLib.h" +#include "sysLib.h" +#include "time.h" +#include "ntp_syslog.h" + +/* some translations to the world of vxWorkings -casey */ +/* first some netdb type things */ +#include "ioLib.h" +#include <socket.h> +int h_errno; + +struct hostent *gethostbyname(char *name) + { + struct hostent *host1; + h_errno = 0; /* we are always successful!!! */ + host1 = (struct hostent *) malloc (sizeof(struct hostent)); + host1->h_name = name; + host1->h_addrtype = AF_INET; + host1->h_aliases = name; + host1->h_length = 4; + host1->h_addr_list[0] = (char *)hostGetByName (name); + host1->h_addr_list[1] = NULL; + return host1; + } + +struct hostent *gethostbyaddr(char *name, int size, int addr_type) + { + struct hostent *host1; + h_errno = 0; /* we are always successful!!! */ + host1 = (struct hostent *) malloc (sizeof(struct hostent)); + host1->h_name = name; + host1->h_addrtype = AF_INET; + host1->h_aliases = name; + host1->h_length = 4; + host1->h_addr_list = NULL; + return host1; + } + +struct servent *getservbyname (char *name, char *type) + { + struct servent *serv1; + serv1 = (struct servent *) malloc (sizeof(struct servent)); + serv1->s_name = "ntp"; /* official service name */ + serv1->s_aliases = NULL; /* alias list */ + serv1->s_port = 123; /* port # */ + serv1->s_proto = "udp"; /* protocol to use */ + return serv1; + } + +/* second + * vxworks thinks it has insomnia + * we have to sleep for number of seconds + */ + +#define CLKRATE sysClkRateGet() + +/* I am not sure how valid the granularity is - it is from G. Eger's port */ +#define CLK_GRANULARITY 1 /* Granularity of system clock in usec */ + /* Used to round down # usecs/tick */ + /* On a VCOM-100, PIT gets 8 MHz clk, */ + /* & it prescales by 32, thus 4 usec */ + /* on mv167, granularity is 1usec anyway*/ + /* To defeat rounding, set to 1 */ +#define USECS_PER_SEC MILLION /* Microseconds per second */ +#define TICK (((USECS_PER_SEC / CLKRATE) / CLK_GRANULARITY) * CLK_GRANULARITY) + +/* emulate unix sleep + * casey + */ +void sleep(int seconds) + { + taskDelay(seconds*TICK); + } +/* emulate unix alarm + * that pauses and calls SIGALRM after the seconds are up... + * so ... taskDelay() fudged for seconds should amount to the same thing. + * casey + */ +void alarm (int seconds) + { + sleep(seconds); + } + +#endif /* SYS_VXWORKS */ + +#ifdef SYS_PTX /* Does PTX still need this? */ +/*#include <sys/types.h> */ +#include <sys/procstats.h> + +int +gettimeofday( + struct timeval *tvp + ) +{ + /* + * hi, this is Sequents sneak path to get to a clock + * this is also the most logical syscall for such a function + */ + return (get_process_stats(tvp, PS_SELF, (struct procstats *) 0, + (struct procstats *) 0)); +} +#endif /* SYS_PTX */ + +#ifdef MPE +/* This is a substitute for bind() that if called for an AF_INET socket +port less than 1024, GETPRIVMODE() and GETUSERMODE() calls will be done. */ + +#undef bind +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <sys/un.h> + +extern void GETPRIVMODE(void); +extern void GETUSERMODE(void); + +int __ntp_mpe_bind(int s, void *addr, int addrlen); + +int __ntp_mpe_bind(int s, void *addr, int addrlen) { + int priv = 0; + int result; + +if (addrlen == sizeof(struct sockaddr_in)) { /* AF_INET */ + if (((struct sockaddr_in *)addr)->sin_port > 0 && + ((struct sockaddr_in *)addr)->sin_port < 1024) { + priv = 1; + GETPRIVMODE(); + } +/* ((struct sockaddr_in *)addr)->sin_addr.s_addr = 0; */ + result = bind(s,addr,addrlen); + if (priv == 1) GETUSERMODE(); +} else /* AF_UNIX */ + result = bind(s,addr,addrlen); + +return result; +} + +/* + * MPE stupidly requires sfcntl() to be used on sockets instead of fcntl(), + * so we define a wrapper to analyze the file descriptor and call the correct + * function. + */ + +#undef fcntl +#include <errno.h> +#include <fcntl.h> + +int __ntp_mpe_fcntl(int fd, int cmd, int arg); + +int __ntp_mpe_fcntl(int fd, int cmd, int arg) { + int len; + struct sockaddr sa; + + extern int sfcntl(int, int, int); + + len = sizeof sa; + if (getsockname(fd, &sa, &len) == -1) { + if (errno == EAFNOSUPPORT) /* AF_UNIX socket */ + return sfcntl(fd, cmd, arg); + if (errno == ENOTSOCK) /* file or pipe */ + return fcntl(fd, cmd, arg); + return (-1); /* unknown getsockname() failure */ + } else /* AF_INET socket */ + return sfcntl(fd, cmd, arg); +} + +/* + * Setitimer emulation support. Note that we implement this using alarm(), + * and since alarm() only delivers one signal, we must re-enable the alarm + * by enabling our own SIGALRM setitimer_mpe_handler routine to be called + * before the real handler routine and re-enable the alarm at that time. + * + * Note that this solution assumes that sigaction(SIGALRM) is called before + * calling setitimer(). If it should ever to become necessary to support + * sigaction(SIGALRM) after calling setitimer(), it will be necessary to trap + * those sigaction() calls. + */ + +#include <limits.h> +#include <signal.h> + +/* + * Some global data that needs to be shared between setitimer() and + * setitimer_mpe_handler(). + */ + +struct { + unsigned long current_msec; /* current alarm() value in effect */ + unsigned long interval_msec; /* next alarm() value from setitimer */ + unsigned long value_msec; /* first alarm() value from setitimer */ + struct itimerval current_itimerval; /* current itimerval in effect */ + struct sigaction oldact; /* SIGALRM state saved by setitimer */ +} setitimer_mpe_ctx = { 0, 0, 0 }; + +/* + * Undocumented, unsupported function to do alarm() in milliseconds. + */ + +extern unsigned int px_alarm(unsigned long, int *); + +/* + * The SIGALRM handler routine enabled by setitimer(). Re-enable the alarm or + * restore the original SIGALRM setting if no more alarms are needed. Then + * call the original SIGALRM handler (if any). + */ + +static RETSIGTYPE setitimer_mpe_handler(int sig) +{ +int alarm_hpe_status; + +/* Update the new current alarm value */ + +setitimer_mpe_ctx.current_msec = setitimer_mpe_ctx.interval_msec; + +if (setitimer_mpe_ctx.interval_msec > 0) { + /* Additional intervals needed; re-arm the alarm timer */ + px_alarm(setitimer_mpe_ctx.interval_msec,&alarm_hpe_status); +} else { + /* No more intervals, so restore previous original SIGALRM handler */ + sigaction(SIGALRM, &setitimer_mpe_ctx.oldact, NULL); +} + +/* Call the original SIGALRM handler if it is a function and not just a flag */ + +if (setitimer_mpe_ctx.oldact.sa_handler != SIG_DFL && + setitimer_mpe_ctx.oldact.sa_handler != SIG_ERR && + setitimer_mpe_ctx.oldact.sa_handler != SIG_IGN) + (*setitimer_mpe_ctx.oldact.sa_handler)(SIGALRM); + +} + +/* + * Our implementation of setitimer(). + */ + +int +setitimer(int which, struct itimerval *value, + struct itimerval *ovalue) +{ + +int alarm_hpe_status; +unsigned long remaining_msec, value_msec, interval_msec; +struct sigaction newact; + +/* + * Convert the initial interval to milliseconds + */ + +if (value->it_value.tv_sec > (UINT_MAX / 1000)) + value_msec = UINT_MAX; +else + value_msec = value->it_value.tv_sec * 1000; + +value_msec += value->it_value.tv_usec / 1000; + +/* + * Convert the reset interval to milliseconds + */ + +if (value->it_interval.tv_sec > (UINT_MAX / 1000)) + interval_msec = UINT_MAX; +else + interval_msec = value->it_interval.tv_sec * 1000; + +interval_msec += value->it_interval.tv_usec / 1000; + +if (value_msec > 0 && interval_msec > 0) { + /* + * We'll be starting an interval timer that will be repeating, so we need to + * insert our own SIGALRM signal handler to schedule the repeats. + */ + + /* Read the current SIGALRM action */ + + if (sigaction(SIGALRM, NULL, &setitimer_mpe_ctx.oldact) < 0) { + fprintf(stderr,"MPE setitimer old handler failed, errno=%d\n",errno); + return -1; + } + + /* Initialize the new action to call our SIGALRM handler instead */ + + newact.sa_handler = &setitimer_mpe_handler; + newact.sa_mask = setitimer_mpe_ctx.oldact.sa_mask; + newact.sa_flags = setitimer_mpe_ctx.oldact.sa_flags; + + if (sigaction(SIGALRM, &newact, NULL) < 0) { + fprintf(stderr,"MPE setitimer new handler failed, errno=%d\n",errno); + return -1; + } +} + +/* + * Return previous itimerval if desired + */ + +if (ovalue != NULL) *ovalue = setitimer_mpe_ctx.current_itimerval; + +/* + * Save current parameters for later usage + */ + +setitimer_mpe_ctx.current_itimerval = *value; +setitimer_mpe_ctx.current_msec = value_msec; +setitimer_mpe_ctx.value_msec = value_msec; +setitimer_mpe_ctx.interval_msec = interval_msec; + +/* + * Schedule the first alarm + */ + +remaining_msec = px_alarm(value_msec, &alarm_hpe_status); +if (alarm_hpe_status == 0) + return (0); +else + return (-1); +} + +/* + * MPE lacks gettimeofday(), so we define our own. + */ + +int gettimeofday(struct timeval *tvp) + +{ +/* Documented, supported MPE functions. */ +extern void GETPRIVMODE(void); +extern void GETUSERMODE(void); + +/* Undocumented, unsupported MPE functions. */ +extern long long get_time(void); +extern void get_time_change_info(long long *, char *, char *); +extern long long ticks_to_micro(long long); + +char pwf_since_boot, recover_pwf_time; +long long mpetime, offset_ticks, offset_usec; + +GETPRIVMODE(); +mpetime = get_time(); /* MPE local time usecs since Jan 1 1970 */ +get_time_change_info(&offset_ticks, &pwf_since_boot, &recover_pwf_time); +offset_usec = ticks_to_micro(offset_ticks); /* UTC offset usecs */ +GETUSERMODE(); + +mpetime = mpetime - offset_usec; /* Convert from local time to UTC */ +tvp->tv_sec = mpetime / 1000000LL; +tvp->tv_usec = mpetime % 1000000LL; + +return 0; +} + +/* + * MPE lacks settimeofday(), so we define our own. + */ + +#define HAVE_SETTIMEOFDAY + +int settimeofday(struct timeval *tvp) + +{ +/* Documented, supported MPE functions. */ +extern void GETPRIVMODE(void); +extern void GETUSERMODE(void); + +/* Undocumented, unsupported MPE functions. */ +extern void get_time_change_info(long long *, char *, char *); +extern void initialize_system_time(long long, int); +extern void set_time_correction(long long, int, int); +extern long long ticks_to_micro(long long); + +char pwf_since_boot, recover_pwf_time; +long long big_sec, big_usec, mpetime, offset_ticks, offset_usec; + +big_sec = tvp->tv_sec; +big_usec = tvp->tv_usec; +mpetime = (big_sec * 1000000LL) + big_usec; /* Desired UTC microseconds */ + +GETPRIVMODE(); +set_time_correction(0LL,0,0); /* Cancel previous time correction, if any */ +get_time_change_info(&offset_ticks, &pwf_since_boot, &recover_pwf_time); +offset_usec = ticks_to_micro(offset_ticks); /* UTC offset microseconds */ +mpetime = mpetime + offset_usec; /* Convert from UTC to local time */ +initialize_system_time(mpetime,1); +GETUSERMODE(); + +return 0; +} +#endif /* MPE */ + +const char *set_tod_using = "UNKNOWN"; + +int +ntp_set_tod( + struct timeval *tvp, + void *tzp + ) +{ + int rc = -1; + +#ifdef DEBUG + if (debug) + printf("In ntp_set_tod\n"); +#endif + +#ifdef HAVE_CLOCK_SETTIME + if (rc) { + struct timespec ts; + + set_tod_using = "clock_settime"; + /* Convert timeval to timespec */ + ts.tv_sec = tvp->tv_sec; + ts.tv_nsec = 1000 * tvp->tv_usec; + + errno = 0; + rc = clock_settime(CLOCK_REALTIME, &ts); +#ifdef DEBUG + if (debug) { + printf("ntp_set_tod: %s: %d: %s\n", + set_tod_using, rc, strerror(errno)); + } +#endif + } +#endif /* HAVE_CLOCK_SETTIME */ +#ifdef HAVE_SETTIMEOFDAY + if (rc) { + struct timeval adjtv; + + set_tod_using = "settimeofday"; + /* + * Some broken systems don't reset adjtime() when the + * clock is stepped. + */ + adjtv.tv_sec = adjtv.tv_usec = 0; + adjtime(&adjtv, NULL); + errno = 0; + rc = SETTIMEOFDAY(tvp, tzp); +#ifdef DEBUG + if (debug) { + printf("ntp_set_tod: %s: %d: %s\n", + set_tod_using, rc, strerror(errno)); + } +#endif + } +#endif /* HAVE_SETTIMEOFDAY */ +#ifdef HAVE_STIME + if (rc) { + long tp = tvp->tv_sec; + + set_tod_using = "stime"; + errno = 0; + rc = stime(&tp); /* lie as bad as SysVR4 */ +#ifdef DEBUG + if (debug) { + printf("ntp_set_tod: %s: %d: %s\n", + set_tod_using, rc, strerror(errno)); + } +#endif + } +#endif /* HAVE_STIME */ + if (rc) + set_tod_using = "Failed!"; +#ifdef DEBUG + if (debug) { + printf("ntp_set_tod: Final result: %s: %d: %s\n", + set_tod_using, rc, strerror(errno)); + } +#endif + return rc; +} + +#endif /* not SYS_WINNT */ + +#if defined (SYS_WINNT) || defined (SYS_VXWORKS) || defined(MPE) +/* getpass is used in ntpq.c and ntpdc.c */ + +char * +getpass(const char * prompt) +{ + int c, i; + static char password[32]; + + fprintf(stderr, "%s", prompt); + fflush(stderr); + + for (i=0; i<sizeof(password)-1 && ((c=_getch())!='\n' && c!='\r'); i++) { + password[i] = (char) c; + } + password[i] = '\0'; + + return password; +} +#endif /* SYS_WINNT */ + +#if !defined(HAVE_MEMSET) +void +ntp_memset( + char *a, + int x, + int c + ) +{ + while (c-- > 0) + *a++ = (char) x; +} +#endif /*POSIX*/ diff --git a/contrib/ntp/libntp/md5c.c b/contrib/ntp/libntp/md5c.c new file mode 100644 index 0000000..07eec6c --- /dev/null +++ b/contrib/ntp/libntp/md5c.c @@ -0,0 +1,354 @@ +/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +#include "global.h" +#ifndef HAVE_MD5INIT +#include "ntp_md5.h" + +/* Constants for MD5Transform routine. + */ +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + +static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64])); +static void Encode PROTO_LIST + ((unsigned char *, UINT4 *, unsigned int)); +static void Decode PROTO_LIST + ((UINT4 *, unsigned char *, unsigned int)); +static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int)); +static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int)); + +static unsigned char PADDING[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* F, G, H and I are basic MD5 functions. + */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) ((y) ^ ((x) | (~z))) + +/* ROTATE_LEFT rotates x left n bits. + */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. + Rotation is separate from addition to prevent recomputation. + */ +#define FF(a, b, c, d, x, s, ac) { \ + (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define GG(a, b, c, d, x, s, ac) { \ + (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define HH(a, b, c, d, x, s, ac) { \ + (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define II(a, b, c, d, x, s, ac) { \ + (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } + +/* MD5 initialization. Begins an MD5 operation, writing a new context. + */ +void +MD5Init( + MD5_CTX *context /* context */ + ) +{ + context->count[0] = context->count[1] = 0; + + /* Load magic initialization constants. + */ + context->state[0] = 0x67452301; + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->state[3] = 0x10325476; +} + +/* MD5 block update operation. Continues an MD5 message-digest + operation, processing another message block, and updating the + context. + */ +void +MD5Update ( + MD5_CTX *context, /* context */ + unsigned char *input, /* input block */ + unsigned int inputLen /* length of input block */ + ) +{ + unsigned int i, idx, partLen; + + /* Compute number of bytes mod 64 */ + idx = (unsigned int)((context->count[0] >> 3) & 0x3F); + + /* Update number of bits */ + if ((context->count[0] += ((UINT4)inputLen << 3)) + < ((UINT4)inputLen << 3)) + context->count[1]++; + context->count[1] += ((UINT4)inputLen >> 29); + + partLen = 64 - idx; + + /* Transform as many times as possible. + */ + if (inputLen >= partLen) { + MD5_memcpy + ((POINTER)&context->buffer[idx], (POINTER)input, partLen); + MD5Transform (context->state, context->buffer); + + for (i = partLen; i + 63 < inputLen; i += 64) + MD5Transform (context->state, &input[i]); + + idx = 0; + } + else + i = 0; + + /* Buffer remaining input */ + MD5_memcpy + ((POINTER)&context->buffer[idx], (POINTER)&input[i], + inputLen-i); +} + +/* MD5 finalization. Ends an MD5 message-digest operation, writing the + the message digest and zeroizing the context. + */ +void +MD5Final ( + unsigned char digest[16], /* message digest */ + MD5_CTX *context /* context */ + ) +{ + unsigned char bits[8]; + unsigned int idx, padLen; + + /* Save number of bits */ + Encode (bits, context->count, 8); + + /* Pad out to 56 mod 64. + */ + idx = (unsigned int)((context->count[0] >> 3) & 0x3f); + padLen = (idx < 56) ? (56 - idx) : (120 - idx); + MD5Update (context, PADDING, padLen); + + /* Append length (before padding) */ + MD5Update (context, bits, 8); + + /* Store state in digest */ + Encode (digest, context->state, 16); + + /* Zeroize sensitive information. + */ + MD5_memset ((POINTER)context, 0, sizeof (*context)); +} + +/* MD5 basic transformation. Transforms state based on block. + */ +static void +MD5Transform ( + UINT4 state[4], + unsigned char block[64] + ) +{ + UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + + Decode (x, block, 64); + + /* Round 1 */ + FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ + FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ + FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ + FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ + FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ + FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ + FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ + FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ + FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ + FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ + FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ + FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ + FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ + FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ + FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ + FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ + + /* Round 2 */ + GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ + GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ + GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ + GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ + GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ + GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ + GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ + GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ + GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ + GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ + GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ + GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ + GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ + GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ + GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ + GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ + + /* Round 3 */ + HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ + HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ + HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ + HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ + HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ + HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ + HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ + HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ + HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ + HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ + HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ + HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ + HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ + HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ + HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ + HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ + + /* Round 4 */ + II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ + II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ + II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ + II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ + II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ + II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ + II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ + II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ + II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ + II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ + II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ + II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ + II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ + II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ + II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ + II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + + /* Zeroize sensitive information. + */ + MD5_memset ((POINTER)x, 0, sizeof (x)); +} + +/* Encodes input (UINT4) into output (unsigned char). Assumes len is + a multiple of 4. + */ +static void +Encode ( + unsigned char *output, + UINT4 *input, + unsigned int len + ) +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) { + output[j] = (unsigned char)(input[i] & 0xff); + output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); + output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); + output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); + } +} + +/* Decodes input (unsigned char) into output (UINT4). Assumes len is + a multiple of 4. + */ +static void +Decode ( + UINT4 *output, + unsigned char *input, + unsigned int len + ) +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | + (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); +} + +/* Note: Replace "for loop" with standard memcpy if possible. + */ +static void +MD5_memcpy ( + POINTER output, + POINTER input, + unsigned int len + ) +{ + unsigned int i; + + for (i = 0; i < len; i++) + output[i] = input[i]; +} + +/* Note: Replace "for loop" with standard memset if possible. + */ +static void +MD5_memset ( + POINTER output, + int value, + unsigned int len + ) +{ + unsigned int i; + + for (i = 0; i < len; i++) + ((char *)output)[i] = (char)value; +} +#else +int md5_bs; +#endif diff --git a/contrib/ntp/libntp/memmove.c b/contrib/ntp/libntp/memmove.c new file mode 100644 index 0000000..8ccc4b1 --- /dev/null +++ b/contrib/ntp/libntp/memmove.c @@ -0,0 +1,140 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifndef HAVE_MEMMOVE +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#include <string.h> + +#include "l_stdlib.h" + +/* + * sizeof(word) MUST BE A POWER OF TWO + * SO THAT wmask BELOW IS ALL ONES + */ +typedef int word; /* "word" used for optimal copy speed */ + +#define wsize sizeof(word) +#define wmask (wsize - 1) + +/* + * Copy a block of memory, handling overlap. + * This is the routine that actually implements + * (the portable versions of) bcopy, memcpy, and memmove. + */ +void * +memmove( + void *dst0, + const void *src0, + register size_t length + ) +{ + register char *dst = dst0; + register const char *src = src0; + register size_t t; + + if (length == 0 || dst == src) /* nothing to do */ + goto done; + + /* + * Macros: loop-t-times; and loop-t-times, t>0 + */ +#define TLOOP(s) if (t) TLOOP1(s) +#define TLOOP1(s) do { s; } while (--t) + + if ((unsigned long)dst < (unsigned long)src) { + /* + * Copy forward. + */ + t = (int)src; /* only need low bits */ + if ((t | (int)dst) & wmask) { + /* + * Try to align operands. This cannot be done + * unless the low bits match. + */ + if ((t ^ (int)dst) & wmask || length < wsize) + t = length; + else + t = wsize - (t & wmask); + length -= t; + TLOOP1(*dst++ = *src++); + } + /* + * Copy whole words, then mop up any trailing bytes. + */ + t = length / wsize; + TLOOP(*(word *)dst = *(const word *)src; src += wsize; + dst += wsize); + t = length & wmask; + TLOOP(*dst++ = *src++); + } else { + /* + * Copy backwards. Otherwise essentially the same. + * Alignment works as before, except that it takes + * (t&wmask) bytes to align, not wsize-(t&wmask). + */ + src += length; + dst += length; + t = (int)src; + if ((t | (int)dst) & wmask) { + if ((t ^ (int)dst) & wmask || length <= wsize) + t = length; + else + t &= wmask; + length -= t; + TLOOP1(*--dst = *--src); + } + t = length / wsize; + TLOOP(src -= wsize; dst -= wsize; + *(word *)dst = *(const word *)src); + t = length & wmask; + TLOOP(*--dst = *--src); + } + done: + return (dst0); +} +#else +int memmove_bs; +#endif diff --git a/contrib/ntp/libntp/mfptoa.c b/contrib/ntp/libntp/mfptoa.c new file mode 100644 index 0000000..6450b2c --- /dev/null +++ b/contrib/ntp/libntp/mfptoa.c @@ -0,0 +1,23 @@ +/* + * mfptoa - Return an asciized representation of a signed long fp number + */ +#include "ntp_fp.h" +#include "ntp_stdlib.h" + +char * +mfptoa( + u_long fpi, + u_long fpf, + short ndec + ) +{ + int isneg; + + if (M_ISNEG(fpi, fpf)) { + isneg = 1; + M_NEG(fpi, fpf); + } else + isneg = 0; + + return dolfptoa(fpi, fpf, isneg, ndec, 0); +} diff --git a/contrib/ntp/libntp/mfptoms.c b/contrib/ntp/libntp/mfptoms.c new file mode 100644 index 0000000..d2bfd71 --- /dev/null +++ b/contrib/ntp/libntp/mfptoms.c @@ -0,0 +1,23 @@ +/* + * mfptoms - Return an asciized signed long fp number in milliseconds + */ +#include "ntp_fp.h" +#include "ntp_stdlib.h" + +char * +mfptoms( + u_long fpi, + u_long fpf, + short ndec + ) +{ + int isneg; + + if (M_ISNEG(fpi, fpf)) { + isneg = 1; + M_NEG(fpi, fpf); + } else + isneg = 0; + + return dolfptoa(fpi, fpf, isneg, ndec, 1); +} diff --git a/contrib/ntp/libntp/mktime.c b/contrib/ntp/libntp/mktime.c new file mode 100644 index 0000000..91be600 --- /dev/null +++ b/contrib/ntp/libntp/mktime.c @@ -0,0 +1,303 @@ +/* + * Copyright (c) 1987, 1989 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Arthur David Olson of the National Cancer Institute. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ + +/*static char *sccsid = "from: @(#)ctime.c 5.26 (Berkeley) 2/23/91";*/ + +/* + * This implementation of mktime is lifted straight from the NetBSD (BSD 4.4) + * version. I modified it slightly to divorce it from the internals of the + * ctime library. Thus this version can't use details of the internal + * timezone state file to figure out strange unnormalized struct tm values, + * as might result from someone doing date math on the tm struct then passing + * it to mktime. + * + * It just does as well as it can at normalizing the tm input, then does a + * binary search of the time space using the system's localtime() function. + * + * The original binary search was defective in that it didn't consider the + * setting of tm_isdst when comparing tm values, causing the search to be + * flubbed for times near the dst/standard time changeover. The original + * code seems to make up for this by grubbing through the timezone info + * whenever the binary search barfed. Since I don't have that luxury in + * portable code, I have to take care of tm_isdst in the comparison routine. + * This requires knowing how many minutes offset dst is from standard time. + * + * So, if you live somewhere in the world where dst is not 60 minutes offset, + * and your vendor doesn't supply mktime(), you'll have to edit this variable + * by hand. Sorry about that. + */ + +#include "ntp_machine.h" + +#if !defined(HAVE_MKTIME) || !defined(HAVE_TIMEGM) + +#ifndef DSTMINUTES +#define DSTMINUTES 60 +#endif + +#define FALSE 0 +#define TRUE 1 + +/* some constants from tzfile.h */ +#define SECSPERMIN 60 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) +#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) +#define MONSPERYEAR 12 +#define TM_YEAR_BASE 1900 +#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) + +static int mon_lengths[2][MONSPERYEAR] = { + { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, + { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } +}; + +static int year_lengths[2] = { + DAYSPERNYEAR, DAYSPERLYEAR +}; + +/* +** Adapted from code provided by Robert Elz, who writes: +** The "best" way to do mktime I think is based on an idea of Bob +** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now). +** It does a binary search of the time_t space. Since time_t's are +** just 32 bits, its a max of 32 iterations (even at 64 bits it +** would still be very reasonable). +*/ + +#ifndef WRONG +#define WRONG (-1) +#endif /* !defined WRONG */ + +static void +normalize( + int * tensptr, + int * unitsptr, + int base + ) +{ + if (*unitsptr >= base) { + *tensptr += *unitsptr / base; + *unitsptr %= base; + } else if (*unitsptr < 0) { + --*tensptr; + *unitsptr += base; + if (*unitsptr < 0) { + *tensptr -= 1 + (-*unitsptr) / base; + *unitsptr = base - (-*unitsptr) % base; + } + } +} + +static struct tm * +mkdst( + struct tm * tmp + ) +{ + /* jds */ + static struct tm tmbuf; + + tmbuf = *tmp; + tmbuf.tm_isdst = 1; + tmbuf.tm_min += DSTMINUTES; + normalize(&tmbuf.tm_hour, &tmbuf.tm_min, MINSPERHOUR); + return &tmbuf; +} + +static int +tmcomp( + register struct tm * atmp, + register struct tm * btmp + ) +{ + register int result; + + /* compare down to the same day */ + + if ((result = (atmp->tm_year - btmp->tm_year)) == 0 && + (result = (atmp->tm_mon - btmp->tm_mon)) == 0) + result = (atmp->tm_mday - btmp->tm_mday); + + if(result != 0) + return result; + + /* get rid of one-sided dst bias */ + + if(atmp->tm_isdst == 1 && !btmp->tm_isdst) + btmp = mkdst(btmp); + else if(btmp->tm_isdst == 1 && !atmp->tm_isdst) + atmp = mkdst(atmp); + + /* compare the rest of the way */ + + if ((result = (atmp->tm_hour - btmp->tm_hour)) == 0 && + (result = (atmp->tm_min - btmp->tm_min)) == 0) + result = atmp->tm_sec - btmp->tm_sec; + return result; +} + + +static time_t +time2( + struct tm * tmp, + int * okayp, + int usezn + ) +{ + register int dir; + register int bits; + register int i; + register int saved_seconds; + time_t t; + struct tm yourtm, mytm; + + *okayp = FALSE; + yourtm = *tmp; + if (yourtm.tm_sec >= SECSPERMIN + 2 || yourtm.tm_sec < 0) + normalize(&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN); + normalize(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR); + normalize(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY); + normalize(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR); + while (yourtm.tm_mday <= 0) { + --yourtm.tm_year; + yourtm.tm_mday += + year_lengths[isleap(yourtm.tm_year + TM_YEAR_BASE)]; + } + for ( ; ; ) { + i = mon_lengths[isleap(yourtm.tm_year + + TM_YEAR_BASE)][yourtm.tm_mon]; + if (yourtm.tm_mday <= i) + break; + yourtm.tm_mday -= i; + if (++yourtm.tm_mon >= MONSPERYEAR) { + yourtm.tm_mon = 0; + ++yourtm.tm_year; + } + } + saved_seconds = yourtm.tm_sec; + yourtm.tm_sec = 0; + /* + ** Calculate the number of magnitude bits in a time_t + ** (this works regardless of whether time_t is + ** signed or unsigned, though lint complains if unsigned). + */ + for (bits = 0, t = 1; t > 0; ++bits, t <<= 1) + ; + /* + ** If time_t is signed, then 0 is the median value, + ** if time_t is unsigned, then 1 << bits is median. + */ + t = (t < 0) ? 0 : ((time_t) 1 << bits); + for ( ; ; ) { + if (usezn) + mytm = *localtime(&t); + else + mytm = *gmtime(&t); + dir = tmcomp(&mytm, &yourtm); + if (dir != 0) { + if (bits-- < 0) + return WRONG; + if (bits < 0) + --t; + else if (dir > 0) + t -= (time_t) 1 << bits; + else t += (time_t) 1 << bits; + continue; + } + if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst) + break; + + return WRONG; + } + t += saved_seconds; + if (usezn) + *tmp = *localtime(&t); + else + *tmp = *gmtime(&t); + *okayp = TRUE; + return t; +} +#else +int mktime_bs; +#endif /* !HAVE_MKTIME || !HAVE_TIMEGM */ + +#ifndef HAVE_MKTIME +static time_t +time1( + struct tm * tmp + ) +{ + register time_t t; + int okay; + + if (tmp->tm_isdst > 1) + tmp->tm_isdst = 1; + t = time2(tmp, &okay, 1); + if (okay || tmp->tm_isdst < 0) + return t; + + return WRONG; +} + +time_t +mktime( + struct tm * tmp + ) +{ + return time1(tmp); +} +#endif /* !HAVE_MKTIME */ + +#ifndef HAVE_TIMEGM +time_t +timegm( + struct tm * tmp + ) +{ + register time_t t; + int okay; + + tmp->tm_isdst = 0; + t = time2(tmp, &okay, 0); + if (okay || tmp->tm_isdst < 0) + return t; + + return WRONG; +} +#endif /* !HAVE_TIMEGM */ diff --git a/contrib/ntp/libntp/modetoa.c b/contrib/ntp/libntp/modetoa.c new file mode 100644 index 0000000..405aef8 --- /dev/null +++ b/contrib/ntp/libntp/modetoa.c @@ -0,0 +1,34 @@ +/* + * modetoa - return an asciized mode + */ +#include <stdio.h> + +#include "lib_strbuf.h" +#include "ntp_stdlib.h" + +const char * +modetoa( + int mode + ) +{ + char *bp; + static const char *modestrings[] = { + "unspec", + "sym_active", + "sym_passive", + "client", + "server", + "broadcast", + "control", + "private", + "bclient", + }; + + if (mode < 0 || mode >= (sizeof modestrings)/sizeof(char *)) { + LIB_GETBUF(bp); + (void)sprintf(bp, "mode#%d", mode); + return bp; + } + + return modestrings[mode]; +} diff --git a/contrib/ntp/libntp/mstolfp.c b/contrib/ntp/libntp/mstolfp.c new file mode 100644 index 0000000..e4e909d --- /dev/null +++ b/contrib/ntp/libntp/mstolfp.c @@ -0,0 +1,100 @@ +/* + * mstolfp - convert an ascii string in milliseconds to an l_fp number + */ +#include <stdio.h> +#include <ctype.h> + +#include "ntp_fp.h" +#include "ntp_stdlib.h" + +int +mstolfp( + const char *str, + l_fp *lfp + ) +{ + register const char *cp; + register char *bp; + register const char *cpdec; + char buf[100]; + + /* + * We understand numbers of the form: + * + * [spaces][-][digits][.][digits][spaces|\n|\0] + * + * This is one enormous hack. Since I didn't feel like + * rewriting the decoding routine for milliseconds, what + * is essentially done here is to make a copy of the string + * with the decimal moved over three places so the seconds + * decoding routine can be used. + */ + bp = buf; + cp = str; + while (isspace((int)*cp)) + cp++; + + if (*cp == '-') { + *bp++ = '-'; + cp++; + } + + if (*cp != '.' && !isdigit((int)*cp)) + return 0; + + + /* + * Search forward for the decimal point or the end of the string. + */ + cpdec = cp; + while (isdigit((int)*cpdec)) + cpdec++; + + /* + * Found something. If we have more than three digits copy the + * excess over, else insert a leading 0. + */ + if ((cpdec - cp) > 3) { + do { + *bp++ = (char)*cp++; + } while ((cpdec - cp) > 3); + } else { + *bp++ = '0'; + } + + /* + * Stick the decimal in. If we've got less than three digits in + * front of the millisecond decimal we insert the appropriate number + * of zeros. + */ + *bp++ = '.'; + if ((cpdec - cp) < 3) { + register int i = 3 - (cpdec - cp); + + do { + *bp++ = '0'; + } while (--i > 0); + } + + /* + * Copy the remainder up to the millisecond decimal. If cpdec + * is pointing at a decimal point, copy in the trailing number too. + */ + while (cp < cpdec) + *bp++ = (char)*cp++; + + if (*cp == '.') { + cp++; + while (isdigit((int)*cp)) + *bp++ = (char)*cp++; + } + *bp = '\0'; + + /* + * Check to make sure the string is properly terminated. If + * so, give the buffer to the decoding routine. + */ + if (*cp != '\0' && !isspace((int)*cp)) + return 0; + return atolfp(buf, lfp); +} diff --git a/contrib/ntp/libntp/msutotsf.c b/contrib/ntp/libntp/msutotsf.c new file mode 100644 index 0000000..eb3babe --- /dev/null +++ b/contrib/ntp/libntp/msutotsf.c @@ -0,0 +1,35 @@ +/* + * msutotsf - tables for converting from a subsecond millisecond value + * to a time stamp fraction. + */ +#include <sys/types.h> + +#include "ntp_types.h" + +/* + * Index each of these tables with five bits of the (less than) 10 + * bit millisecond value. Note that the tables are rounded (not + * truncated). The error in the result will thus be +-1 low order + * bit in the time stamp fraction. + */ +u_long msutotsflo[32] = { + 0x00000000, 0x00418937, 0x0083126f, 0x00c49ba6, + 0x010624dd, 0x0147ae14, 0x0189374c, 0x01cac083, + 0x020c49ba, 0x024dd2f2, 0x028f5c29, 0x02d0e560, + 0x03126e98, 0x0353f7cf, 0x03958106, 0x03d70a3d, + 0x04189375, 0x045a1cac, 0x049ba5e3, 0x04dd2f1b, + 0x051eb852, 0x05604189, 0x05a1cac1, 0x05e353f8, + 0x0624dd2f, 0x06666666, 0x06a7ef9e, 0x06e978d5, + 0x072b020c, 0x076c8b44, 0x07ae147b, 0x07ef9db2 +}; + +u_long msutotsfhi[32] = { + 0x00000000, 0x083126e9, 0x10624dd3, 0x189374bc, + 0x20c49ba6, 0x28f5c28f, 0x3126e979, 0x39581062, + 0x4189374c, 0x49ba5e35, 0x51eb851f, 0x5a1cac08, + 0x624dd2f2, 0x6a7ef9db, 0x72b020c5, 0x7ae147ae, + 0x83126e98, 0x8b439581, 0x9374bc6a, 0x9ba5e354, + 0xa3d70a3d, 0xac083127, 0xb4395810, 0xbc6a7efa, + 0xc49ba5e3, 0xcccccccd, 0xd4fdf3b6, 0xdd2f1aa0, + 0xe5604189, 0xed916873, 0xf5c28f5c, 0xfdf3b646 +}; diff --git a/contrib/ntp/libntp/msyslog.c b/contrib/ntp/libntp/msyslog.c new file mode 100644 index 0000000..fe4d979 --- /dev/null +++ b/contrib/ntp/libntp/msyslog.c @@ -0,0 +1,206 @@ +/* + * msyslog - either send a message to the terminal or print it on + * the standard output. + * + * Converted to use varargs, much better ... jks + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif + +#include <stdio.h> + +#include "ntp_types.h" +#include "ntp_string.h" +#include "ntp_syslog.h" +#include "ntp_stdlib.h" + +#ifdef SYS_WINNT +# include <stdarg.h> +# include "..\ports\winnt\libntp\messages.h" +#endif + +int syslogit = 1; + +FILE *syslog_file = NULL; + +u_long ntp_syslogmask = ~ (u_long) 0; + +#ifdef SYS_WINNT +static char separator = '\\'; +#else +static char separator = '/'; +#endif /* SYS_WINNT */ +extern char *progname; + +/* Declare the local functions */ +void addto_syslog P((int, char *)); +void format_errmsg P((char *, int, const char *, int)); + + +/* + * This routine adds the contents of a buffer to the log + */ +void +addto_syslog(int level, char * buf) +{ + char *prog; + FILE *out_file = syslog_file; + +#if !defined(VMS) && !defined (SYS_VXWORKS) + if (syslogit) + syslog(level, "%s", buf); + else +#endif /* VMS && SYS_VXWORKS*/ + { + out_file = syslog_file ? syslog_file: level <= LOG_ERR ? stderr : stdout; + /* syslog() provides the timestamp, so if we're not using + syslog, we must provide it. */ + prog = strrchr(progname, separator); + if (prog == NULL) + prog = progname; + else + prog++; + (void) fprintf(out_file, "%s ", humanlogtime ()); + (void) fprintf(out_file, "%s[%d]: %s", prog, (int)getpid(), buf); + fflush (out_file); + } +#if DEBUG + if (debug && out_file != stdout && out_file != stderr) + printf("addto_syslog: %s\n", buf); +#endif +} +void +format_errmsg(char *nfmt, int lennfmt, const char *fmt, int errval) +{ + register char c; + register char *n; + register const char *f; + + char *err; + + n = nfmt; + f = fmt; + while ((c = *f++) != '\0' && n < (nfmt+lennfmt - 2)) { + if (c != '%') { + *n++ = c; + continue; + } + if ((c = *f++) != 'm') { + *n++ = '%'; + *n++ = c; + continue; + } + err = 0; + err = strerror(errval); + /* Make sure we have enough space for the error message */ + if ((n + strlen(err)) < (nfmt + lennfmt -2)) { + strcpy(n, err); + n += strlen(err); + } + } +#if !defined(VMS) + if (!syslogit) +#endif /* VMS */ + *n++ = '\n'; + *n = '\0'; +} + +/* + * The externally called functions are defined here + * but share the internal function above to fetch + * any error message strings, This is done so that we can + * have two different functions to perform the logging + * since Windows gets it's error information from different + * places depending on whether or not it's network I/O. + * msyslog() is for general use while netsyslog() is for + * network I/O functions. They are virtually identical + * in implementation. + */ + +#if defined(__STDC__) || defined(HAVE_STDARG_H) +void msyslog(int level, const char *fmt, ...) +#else /* defined(__STDC__) || defined(HAVE_STDARG_H) */ + /*VARARGS*/ + void msyslog(va_alist) + va_dcl +#endif /* defined(__STDC__) || defined(HAVE_STDARG_H) */ +{ +#if defined(__STDC__) || defined(HAVE_STDARG_H) +#else + int level; + const char *fmt; +#endif + va_list ap; + char buf[1025], nfmt[256]; + + /* + * Save the error value as soon as possible + */ +#ifdef SYS_WINNT + int errval = GetLastError(); +#else + int errval = errno; +#endif + +#if defined(__STDC__) || defined(HAVE_STDARG_H) + va_start(ap, fmt); +#else + va_start(ap); + + level = va_arg(ap, int); + fmt = va_arg(ap, char *); +#endif + format_errmsg(nfmt, sizeof(nfmt), fmt, errval); + + vsnprintf(buf, sizeof(buf), nfmt, ap); + addto_syslog(level, buf); + va_end(ap); +} +#if defined(__STDC__) || defined(HAVE_STDARG_H) +void netsyslog(int level, const char *fmt, ...) +#else /* defined(__STDC__) || defined(HAVE_STDARG_H) */ + /*VARARGS*/ + void netsyslog(va_alist) + va_dcl +#endif /* defined(__STDC__) || defined(HAVE_STDARG_H) */ +{ +#if defined(__STDC__) || defined(HAVE_STDARG_H) +#else + int level; + const char *fmt; +#endif + va_list ap; + char buf[1025], nfmt[256]; + + /* + * Save the error value as soon as possible + */ +#ifdef SYS_WINNT + int errval = WSAGetLastError(); +#else + int errval = errno; +#endif + +#if defined(__STDC__) || defined(HAVE_STDARG_H) + va_start(ap, fmt); +#else + va_start(ap); + + level = va_arg(ap, int); + fmt = va_arg(ap, char *); +#endif + format_errmsg(nfmt, sizeof(nfmt), fmt, errval); + + vsnprintf(buf, sizeof(buf), nfmt, ap); + addto_syslog(level, buf); + va_end(ap); +} diff --git a/contrib/ntp/libntp/netof.c b/contrib/ntp/libntp/netof.c new file mode 100644 index 0000000..fd57568 --- /dev/null +++ b/contrib/ntp/libntp/netof.c @@ -0,0 +1,48 @@ +/* + * netof - return the net address part of an ip address in a sockaddr_storage structure + * (zero out host part) + */ +#include <stdio.h> + +#include "ntp_fp.h" +#include "ntp_stdlib.h" +#include "ntp.h" + +#define NUM_NETOF_BUFS 10 +static struct sockaddr_storage ssbuf[NUM_NETOF_BUFS]; +static int next_ssbuf = 0; + +struct sockaddr_storage* +netof( + struct sockaddr_storage* hostaddr + ) +{ + register u_int32 netnum; + struct sockaddr_storage *netaddr; + + netaddr = &ssbuf[next_ssbuf++]; + if (next_ssbuf == NUM_NETOF_BUFS) + next_ssbuf = 0; + memcpy(netaddr, hostaddr, sizeof(struct sockaddr_storage)); + + if(netaddr->ss_family == AF_INET) { + netnum = ((struct sockaddr_in*)netaddr)->sin_addr.s_addr; + + /* + * We live in a modern CIDR world where the basement nets, which + * used to be class A, are now probably associated with each + * host address. So, for class-A nets, all bits are significant. + */ + if(IN_CLASSC(netnum)) + netnum &= IN_CLASSC_NET; + else if (IN_CLASSB(netnum)) + netnum &= IN_CLASSB_NET; + ((struct sockaddr_in*)netaddr)->sin_addr.s_addr = netnum; + } + else if(netaddr->ss_family == AF_INET6) { + /* Here we put 0 at the local link address so we get net address */ + memset(&((struct sockaddr_in6*)netaddr)->sin6_addr.s6_addr[8], 0, 8*sizeof(u_char)); + } + + return netaddr; +} diff --git a/contrib/ntp/libntp/ntp_random.c b/contrib/ntp/libntp/ntp_random.c new file mode 100644 index 0000000..700b4ee --- /dev/null +++ b/contrib/ntp/libntp/ntp_random.c @@ -0,0 +1,485 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/lib/libc/stdlib/random.c,v 1.4.2.2 1999/09/05 11:16:45 peter Exp $ + * + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)random.c 8.2 (Berkeley) 5/19/95"; +#endif /* LIBC_SCCS and not lint */ + +#include "config.h" +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif +#include <stdio.h> + +#include <ntp_types.h> +#include <ntp_random.h> +#include <ntp_unixtime.h> + +/* + * random.c: + * + * An improved random number generation package. In addition to the standard + * rand()/srand() like interface, this package also has a special state info + * interface. The initstate() routine is called with a seed, an array of + * bytes, and a count of how many bytes are being passed in; this array is + * then initialized to contain information for random number generation with + * that much state information. Good sizes for the amount of state + * information are 32, 64, 128, and 256 bytes. The state can be switched by + * calling the setstate() routine with the same array as was initiallized + * with initstate(). By default, the package runs with 128 bytes of state + * information and generates far better random numbers than a linear + * congruential generator. If the amount of state information is less than + * 32 bytes, a simple linear congruential R.N.G. is used. + * + * Internally, the state information is treated as an array of longs; the + * zeroeth element of the array is the type of R.N.G. being used (small + * integer); the remainder of the array is the state information for the + * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of + * state information, which will allow a degree seven polynomial. (Note: + * the zeroeth word of state information also has some other information + * stored in it -- see setstate() for details). + * + * The random number generation technique is a linear feedback shift register + * approach, employing trinomials (since there are fewer terms to sum up that + * way). In this approach, the least significant bit of all the numbers in + * the state table will act as a linear feedback shift register, and will + * have period 2^deg - 1 (where deg is the degree of the polynomial being + * used, assuming that the polynomial is irreducible and primitive). The + * higher order bits will have longer periods, since their values are also + * influenced by pseudo-random carries out of the lower bits. The total + * period of the generator is approximately deg*(2**deg - 1); thus doubling + * the amount of state information has a vast influence on the period of the + * generator. Note: the deg*(2**deg - 1) is an approximation only good for + * large deg, when the period of the shift register is the dominant factor. + * With deg equal to seven, the period is actually much longer than the + * 7*(2**7 - 1) predicted by this formula. + * + * Modified 28 December 1994 by Jacob S. Rosenberg. + * The following changes have been made: + * All references to the type u_int have been changed to unsigned long. + * All references to type int have been changed to type long. Other + * cleanups have been made as well. A warning for both initstate and + * setstate has been inserted to the effect that on Sparc platforms + * the 'arg_state' variable must be forced to begin on word boundaries. + * This can be easily done by casting a long integer array to char *. + * The overall logic has been left STRICTLY alone. This software was + * tested on both a VAX and Sun SpacsStation with exactly the same + * results. The new version and the original give IDENTICAL results. + * The new version is somewhat faster than the original. As the + * documentation says: "By default, the package runs with 128 bytes of + * state information and generates far better random numbers than a linear + * congruential generator. If the amount of state information is less than + * 32 bytes, a simple linear congruential R.N.G. is used." For a buffer of + * 128 bytes, this new version runs about 19 percent faster and for a 16 + * byte buffer it is about 5 percent faster. + */ + +/* + * For each of the currently supported random number generators, we have a + * break value on the amount of state information (you need at least this + * many bytes of state info to support this random number generator), a degree + * for the polynomial (actually a trinomial) that the R.N.G. is based on, and + * the separation between the two lower order coefficients of the trinomial. + */ +#define TYPE_0 0 /* linear congruential */ +#define BREAK_0 8 +#define DEG_0 0 +#define SEP_0 0 + +#define TYPE_1 1 /* x**7 + x**3 + 1 */ +#define BREAK_1 32 +#define DEG_1 7 +#define SEP_1 3 + +#define TYPE_2 2 /* x**15 + x + 1 */ +#define BREAK_2 64 +#define DEG_2 15 +#define SEP_2 1 + +#define TYPE_3 3 /* x**31 + x**3 + 1 */ +#define BREAK_3 128 +#define DEG_3 31 +#define SEP_3 3 + +#define TYPE_4 4 /* x**63 + x + 1 */ +#define BREAK_4 256 +#define DEG_4 63 +#define SEP_4 1 + +/* + * Array versions of the above information to make code run faster -- + * relies on fact that TYPE_i == i. + */ +#define MAX_TYPES 5 /* max number of types above */ + +static long degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; +static long seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; + +/* + * Initially, everything is set up as if from: + * + * initstate(1, randtbl, 128); + * + * Note that this initialization takes advantage of the fact that srandom() + * advances the front and rear pointers 10*rand_deg times, and hence the + * rear pointer which starts at 0 will also end up at zero; thus the zeroeth + * element of the state information, which contains info about the current + * position of the rear pointer is just + * + * MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3. + */ + +static long randtbl[DEG_3 + 1] = { + TYPE_3, +#ifdef USE_WEAK_SEEDING +/* Historic implementation compatibility */ +/* The random sequences do not vary much with the seed */ + 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 0xde3b81e0, 0xdf0a6fb5, + 0xf103bc02, 0x48f340fb, 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd, + 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, 0xda672e2a, 0x1588ca88, + 0xe369735d, 0x904f35f7, 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc, + 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 0xf5ad9d0e, 0x8999220b, + 0x27fb47b9, +#else /* !USE_WEAK_SEEDING */ + 0x991539b1, 0x16a5bce3, 0x6774a4cd, 0x3e01511e, 0x4e508aaa, 0x61048c05, + 0xf5500617, 0x846b7115, 0x6a19892c, 0x896a97af, 0xdb48f936, 0x14898454, + 0x37ffd106, 0xb58bff9c, 0x59e17104, 0xcf918a49, 0x09378c83, 0x52c7a471, + 0x8d293ea9, 0x1f4fc301, 0xc3db71be, 0x39b44e1c, 0xf8a44ef9, 0x4c8b80b1, + 0x19edc328, 0x87bf4bdd, 0xc9b240e5, 0xe9ee4b1b, 0x4382aee7, 0x535b6b41, + 0xf3bec5da +#endif /* !USE_WEAK_SEEDING */ +}; + +/* + * fptr and rptr are two pointers into the state info, a front and a rear + * pointer. These two pointers are always rand_sep places aparts, as they + * cycle cyclically through the state information. (Yes, this does mean we + * could get away with just one pointer, but the code for random() is more + * efficient this way). The pointers are left positioned as they would be + * from the call + * + * initstate(1, randtbl, 128); + * + * (The position of the rear pointer, rptr, is really 0 (as explained above + * in the initialization of randtbl) because the state table pointer is set + * to point to randtbl[1] (as explained below). + */ +static long *fptr = &randtbl[SEP_3 + 1]; +static long *rptr = &randtbl[1]; + +/* + * The following things are the pointer to the state information table, the + * type of the current generator, the degree of the current polynomial being + * used, and the separation between the two pointers. Note that for efficiency + * of random(), we remember the first location of the state information, not + * the zeroeth. Hence it is valid to access state[-1], which is used to + * store the type of the R.N.G. Also, we remember the last location, since + * this is more efficient than indexing every time to find the address of + * the last element to see if the front and rear pointers have wrapped. + */ +static long *state = &randtbl[1]; +static long rand_type = TYPE_3; +static long rand_deg = DEG_3; +static long rand_sep = SEP_3; +static long *end_ptr = &randtbl[DEG_3 + 1]; + +static inline long good_rand P((long)); + +static inline long +good_rand ( + register long x + ) +{ +#ifdef USE_WEAK_SEEDING +/* + * Historic implementation compatibility. + * The random sequences do not vary much with the seed, + * even with overflowing. + */ + return (1103515245 * x + 12345); +#else /* !USE_WEAK_SEEDING */ +/* + * Compute x = (7^5 * x) mod (2^31 - 1) + * wihout overflowing 31 bits: + * (2^31 - 1) = 127773 * (7^5) + 2836 + * From "Random number generators: good ones are hard to find", + * Park and Miller, Communications of the ACM, vol. 31, no. 10, + * October 1988, p. 1195. + */ + register long hi, lo; + + hi = x / 127773; + lo = x % 127773; + x = 16807 * lo - 2836 * hi; + if (x <= 0) + x += 0x7fffffff; + return (x); +#endif /* !USE_WEAK_SEEDING */ +} + +/* + * srandom: + * + * Initialize the random number generator based on the given seed. If the + * type is the trivial no-state-information type, just remember the seed. + * Otherwise, initializes state[] based on the given "seed" via a linear + * congruential generator. Then, the pointers are set to known locations + * that are exactly rand_sep places apart. Lastly, it cycles the state + * information a given number of times to get rid of any initial dependencies + * introduced by the L.C.R.N.G. Note that the initialization of randtbl[] + * for default usage relies on values produced by this routine. + */ +void +ntp_srandom( + unsigned long x + ) +{ + register long i; + + if (rand_type == TYPE_0) + state[0] = x; + else { + state[0] = x; + for (i = 1; i < rand_deg; i++) + state[i] = good_rand(state[i - 1]); + fptr = &state[rand_sep]; + rptr = &state[0]; + for (i = 0; i < 10 * rand_deg; i++) + (void)ntp_random(); + } +} + +/* + * srandomdev: + * + * Many programs choose the seed value in a totally predictable manner. + * This often causes problems. We seed the generator using the much more + * secure urandom(4) interface. Note that this particular seeding + * procedure can generate states which are impossible to reproduce by + * calling srandom() with any value, since the succeeding terms in the + * state buffer are no longer derived from the LC algorithm applied to + * a fixed seed. + */ +#ifdef NEED_SRANDOMDEV +void +ntp_srandomdev( void ) +{ + struct timeval tv; + unsigned long junk; /* Purposely used uninitialized */ + + GETTIMEOFDAY(&tv, NULL); + ntp_srandom(getpid() ^ tv.tv_sec ^ tv.tv_usec ^ junk); + return; +} +#endif + +/* + * initstate: + * + * Initialize the state information in the given array of n bytes for future + * random number generation. Based on the number of bytes we are given, and + * the break values for the different R.N.G.'s, we choose the best (largest) + * one we can and set things up for it. srandom() is then called to + * initialize the state information. + * + * Note that on return from srandom(), we set state[-1] to be the type + * multiplexed with the current value of the rear pointer; this is so + * successive calls to initstate() won't lose this information and will be + * able to restart with setstate(). + * + * Note: the first thing we do is save the current state, if any, just like + * setstate() so that it doesn't matter when initstate is called. + * + * Returns a pointer to the old state. + * + * Note: The Sparc platform requires that arg_state begin on a long + * word boundary; otherwise a bus error will occur. Even so, lint will + * complain about mis-alignment, but you should disregard these messages. + */ +char * +ntp_initstate( + unsigned long seed, /* seed for R.N.G. */ + char *arg_state, /* pointer to state array */ + long n /* # bytes of state info */ + ) +{ + register char *ostate = (char *)(&state[-1]); + register long *long_arg_state = (long *) arg_state; + + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = MAX_TYPES * (rptr - state) + rand_type; + if (n < BREAK_0) { + (void)fprintf(stderr, + "random: not enough state (%ld bytes); ignored.\n", n); + return(0); + } + if (n < BREAK_1) { + rand_type = TYPE_0; + rand_deg = DEG_0; + rand_sep = SEP_0; + } else if (n < BREAK_2) { + rand_type = TYPE_1; + rand_deg = DEG_1; + rand_sep = SEP_1; + } else if (n < BREAK_3) { + rand_type = TYPE_2; + rand_deg = DEG_2; + rand_sep = SEP_2; + } else if (n < BREAK_4) { + rand_type = TYPE_3; + rand_deg = DEG_3; + rand_sep = SEP_3; + } else { + rand_type = TYPE_4; + rand_deg = DEG_4; + rand_sep = SEP_4; + } + state = (long *) (long_arg_state + 1); /* first location */ + end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */ + ntp_srandom(seed); + if (rand_type == TYPE_0) + long_arg_state[0] = rand_type; + else + long_arg_state[0] = MAX_TYPES * (rptr - state) + rand_type; + return(ostate); +} + +/* + * setstate: + * + * Restore the state from the given state array. + * + * Note: it is important that we also remember the locations of the pointers + * in the current state information, and restore the locations of the pointers + * from the old state information. This is done by multiplexing the pointer + * location into the zeroeth word of the state information. + * + * Note that due to the order in which things are done, it is OK to call + * setstate() with the same state as the current state. + * + * Returns a pointer to the old state information. + * + * Note: The Sparc platform requires that arg_state begin on a long + * word boundary; otherwise a bus error will occur. Even so, lint will + * complain about mis-alignment, but you should disregard these messages. + */ +char * +ntp_setstate( + char *arg_state /* pointer to state array */ + ) +{ + register long *new_state = (long *) arg_state; + register long type = new_state[0] % MAX_TYPES; + register long rear = new_state[0] / MAX_TYPES; + char *ostate = (char *)(&state[-1]); + + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = MAX_TYPES * (rptr - state) + rand_type; + switch(type) { + case TYPE_0: + case TYPE_1: + case TYPE_2: + case TYPE_3: + case TYPE_4: + rand_type = type; + rand_deg = degrees[type]; + rand_sep = seps[type]; + break; + default: + (void)fprintf(stderr, + "random: state info corrupted; not changed.\n"); + } + state = (long *) (new_state + 1); + if (rand_type != TYPE_0) { + rptr = &state[rear]; + fptr = &state[(rear + rand_sep) % rand_deg]; + } + end_ptr = &state[rand_deg]; /* set end_ptr too */ + return(ostate); +} + +/* + * random: + * + * If we are using the trivial TYPE_0 R.N.G., just do the old linear + * congruential bit. Otherwise, we do our fancy trinomial stuff, which is + * the same in all the other cases due to all the global variables that have + * been set up. The basic operation is to add the number at the rear pointer + * into the one at the front pointer. Then both pointers are advanced to + * the next location cyclically in the table. The value returned is the sum + * generated, reduced to 31 bits by throwing away the "least random" low bit. + * + * Note: the code takes advantage of the fact that both the front and + * rear pointers can't wrap on the same call by not testing the rear + * pointer if the front one has wrapped. + * + * Returns a 31-bit random number. + */ +long +ntp_random( void ) +{ + register long i; + register long *f, *r; + + if (rand_type == TYPE_0) { + i = state[0]; + state[0] = i = (good_rand(i)) & 0x7fffffff; + } else { + /* + * Use local variables rather than static variables for speed. + */ + f = fptr; r = rptr; + *f += *r; + i = (*f >> 1) & 0x7fffffff; /* chucking least random bit */ + if (++f >= end_ptr) { + f = state; + ++r; + } + else if (++r >= end_ptr) { + r = state; + } + + fptr = f; rptr = r; + } + return(i); +} diff --git a/contrib/ntp/libntp/ntp_rfc2553.c b/contrib/ntp/libntp/ntp_rfc2553.c new file mode 100644 index 0000000..017ef83 --- /dev/null +++ b/contrib/ntp/libntp/ntp_rfc2553.c @@ -0,0 +1,443 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +/* + * Compatability shims with the rfc2553 API to simplify ntp. + */ + +#include <config.h> + +#include <sys/types.h> +#include <ctype.h> +#include <sys/socket.h> +#include <isc/net.h> +#ifdef HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif +#include "ntp_rfc2553.h" + +#include "ntpd.h" +#include "ntp_malloc.h" +#include "ntp_stdlib.h" +#include "ntp_string.h" + +#ifndef ISC_PLATFORM_HAVEIPV6 + +static char *ai_errlist[] = { + "Success", + "Address family for hostname not supported", /* EAI_ADDRFAMILY */ + "Temporary failure in name resolution", /* EAI_AGAIN */ + "Invalid value for ai_flags", /* EAI_BADFLAGS */ + "Non-recoverable failure in name resolution", /* EAI_FAIL */ + "ai_family not supported", /* EAI_FAMILY */ + "Memory allocation failure", /* EAI_MEMORY */ + "No address associated with hostname", /* EAI_NODATA */ + "hostname nor servname provided, or not known", /* EAI_NONAME */ + "servname not supported for ai_socktype", /* EAI_SERVICE */ + "ai_socktype not supported", /* EAI_SOCKTYPE */ + "System error returned in errno", /* EAI_SYSTEM */ + "Invalid value for hints", /* EAI_BADHINTS */ + "Resolved protocol is unknown", /* EAI_PROTOCOL */ + "Unknown error", /* EAI_MAX */ +}; + +/* + * Local declaration + */ +int +DNSlookup_name( + const char *name, + int ai_family, + struct hostent **Addresses +); + +#ifndef SYS_WINNT +/* + * Encapsulate gethostbyname to control the error code + */ +int +DNSlookup_name( + const char *name, + int ai_family, + struct hostent **Addresses +) +{ + *Addresses = gethostbyname(name); + return (h_errno); +} +#endif + +static int do_nodename P((const char *nodename, struct addrinfo *ai, + const struct addrinfo *hints)); + +int +getaddrinfo (const char *nodename, const char *servname, + const struct addrinfo *hints, struct addrinfo **res) +{ + int rval; + struct servent *sp; + struct addrinfo *ai = NULL; + int port; + const char *proto = NULL; + int family, socktype, flags, protocol; + + + /* + * If no name is provide just return an error + */ + if (nodename == NULL && servname == NULL) + return (EAI_NONAME); + + ai = calloc(sizeof(struct addrinfo), 1); + if (ai == NULL) + return (EAI_MEMORY); + + /* + * Copy default values from hints, if available + */ + if (hints != NULL) { + ai->ai_flags = hints->ai_flags; + ai->ai_family = hints->ai_family; + ai->ai_socktype = hints->ai_socktype; + ai->ai_protocol = hints->ai_protocol; + + family = hints->ai_family; + socktype = hints->ai_socktype; + protocol = hints->ai_protocol; + flags = hints->ai_flags; + + switch (family) { + case AF_UNSPEC: + switch (hints->ai_socktype) { + case SOCK_STREAM: + proto = "tcp"; + break; + case SOCK_DGRAM: + proto = "udp"; + break; + } + break; + case AF_INET: + case AF_INET6: + switch (hints->ai_socktype) { + case 0: + break; + case SOCK_STREAM: + proto = "tcp"; + break; + case SOCK_DGRAM: + proto = "udp"; + break; + case SOCK_RAW: + break; + default: + return (EAI_SOCKTYPE); + } + break; +#ifdef AF_LOCAL + case AF_LOCAL: + switch (hints->ai_socktype) { + case 0: + break; + case SOCK_STREAM: + break; + case SOCK_DGRAM: + break; + default: + return (EAI_SOCKTYPE); + } + break; +#endif + default: + return (EAI_FAMILY); + } + } else { + protocol = 0; + family = 0; + socktype = 0; + flags = 0; + } + + rval = do_nodename(nodename, ai, hints); + if (rval != 0) { + freeaddrinfo(ai); + return (rval); + } + + /* + * First, look up the service name (port) if it was + * requested. If the socket type wasn't specified, then + * try and figure it out. + */ + if (servname != NULL) { + char *e; + + port = strtol(servname, &e, 10); + if (*e == '\0') { + if (socktype == 0) + return (EAI_SOCKTYPE); + if (port < 0 || port > 65535) + return (EAI_SERVICE); + port = htons((unsigned short) port); + } else { + sp = getservbyname(servname, proto); + if (sp == NULL) + return (EAI_SERVICE); + port = sp->s_port; + if (socktype == 0) { + if (strcmp(sp->s_proto, "tcp") == 0) + socktype = SOCK_STREAM; + else if (strcmp(sp->s_proto, "udp") == 0) + socktype = SOCK_DGRAM; + } + } + } else + port = 0; + + /* + * + * Set up the port number + */ + if (ai->ai_family == AF_INET) + ((struct sockaddr_in *)ai->ai_addr)->sin_port = (unsigned short) port; + else if (ai->ai_family == AF_INET6) + ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = (unsigned short) port; + *res = ai; + return (0); +} + +void +freeaddrinfo(struct addrinfo *ai) +{ + if (ai->ai_canonname != NULL) + { + free(ai->ai_canonname); + ai->ai_canonname = NULL; + } + if (ai->ai_addr != NULL) + { + free(ai->ai_addr); + ai->ai_addr = NULL; + } + free(ai); + ai = NULL; +} + +int +getnameinfo (const struct sockaddr *sa, u_int salen, char *host, + size_t hostlen, char *serv, size_t servlen, int flags) +{ + struct hostent *hp; + int namelen; + + if (sa->sa_family != AF_INET) + return (EAI_FAMILY); + hp = gethostbyaddr( + (const char *)&((const struct sockaddr_in *)sa)->sin_addr, + 4, AF_INET); + if (hp == NULL) { + if (h_errno == TRY_AGAIN) + return (EAI_AGAIN); + else + return (EAI_FAIL); + } + if (host != NULL && hostlen > 0) { + /* + * Don't exceed buffer + */ + namelen = min(strlen(hp->h_name), hostlen - 1); + if (namelen > 0) { + strncpy(host, hp->h_name, namelen); + host[namelen] = '\0'; + } + } + return (0); +} + +char * +gai_strerror(int ecode) +{ + if (ecode < 0 || ecode > EAI_MAX) + ecode = EAI_MAX; + return ai_errlist[ecode]; +} + +static int +do_nodename( + const char *nodename, + struct addrinfo *ai, + const struct addrinfo *hints) +{ + struct hostent *hp = NULL; + struct sockaddr_in *sockin; + struct sockaddr_in6 *sockin6; + int errval; + + ai->ai_addr = calloc(sizeof(struct sockaddr_storage), 1); + if (ai->ai_addr == NULL) + return (EAI_MEMORY); + + /* + * For an empty node name just use the wildcard. + * NOTE: We need to assume that the address family is + * set elsewhere so that we can set the appropriate wildcard + */ + if (nodename == NULL) { + ai->ai_addrlen = sizeof(struct sockaddr_storage); + if (ai->ai_family == AF_INET) + { + sockin = (struct sockaddr_in *)ai->ai_addr; + sockin->sin_family = (short) ai->ai_family; + sockin->sin_addr.s_addr = htonl(INADDR_ANY); + } + else + { + sockin6 = (struct sockaddr_in6 *)ai->ai_addr; + sockin6->sin6_family = (short) ai->ai_family; + /* + * we have already zeroed out the address + * so we don't actually need to do this + * This assignment is causing problems so + * we don't do what this would do. + sockin6->sin6_addr = in6addr_any; + */ + } +#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR + ai->ai_addr->sa_len = SOCKLEN(ai->ai_addr); +#endif + + return (0); + } + + /* + * See if we have an IPv6 address + */ + if(strchr(nodename, ':') != NULL) { + if (inet_pton(AF_INET6, nodename, + &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr) == 1) { + ((struct sockaddr_in6 *)ai->ai_addr)->sin6_family = AF_INET6; + ai->ai_family = AF_INET6; + ai->ai_addrlen = sizeof(struct sockaddr_in6); + return (0); + } + } + + /* + * See if we have an IPv4 address + */ + if (inet_pton(AF_INET, nodename, + &((struct sockaddr_in *)ai->ai_addr)->sin_addr) == 1) { + ((struct sockaddr *)ai->ai_addr)->sa_family = AF_INET; + ai->ai_family = AF_INET; + ai->ai_addrlen = sizeof(struct sockaddr_in); + return (0); + } + + /* + * If the numeric host flag is set, don't attempt resolution + */ + if (hints != NULL && (hints->ai_flags & AI_NUMERICHOST)) + return (EAI_NONAME); + + /* + * Look for a name + */ + + errval = DNSlookup_name(nodename, AF_INET, &hp); + + if (hp == NULL) { + if (errval == TRY_AGAIN || errval == EAI_AGAIN) + return (EAI_AGAIN); + else if (errval == EAI_NONAME) { + if (inet_pton(AF_INET, nodename, + &((struct sockaddr_in *)ai->ai_addr)->sin_addr) == 1) { + ((struct sockaddr *)ai->ai_addr)->sa_family = AF_INET; + ai->ai_family = AF_INET; + ai->ai_addrlen = sizeof(struct sockaddr_in); + return (0); + } + return (errval); + } + else + { + return (errval); + } + } + ai->ai_family = hp->h_addrtype; + ai->ai_addrlen = sizeof(struct sockaddr); + sockin = (struct sockaddr_in *)ai->ai_addr; + memcpy(&sockin->sin_addr, hp->h_addr, hp->h_length); + ai->ai_addr->sa_family = hp->h_addrtype; +#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR + ai->ai_addr->sa_len = sizeof(struct sockaddr); +#endif + if (hints != NULL && hints->ai_flags & AI_CANONNAME) { + ai->ai_canonname = malloc(strlen(hp->h_name) + 1); + if (ai->ai_canonname == NULL) + return (EAI_MEMORY); + strcpy(ai->ai_canonname, hp->h_name); + } + return (0); +} + +#endif /* !ISC_PLATFORM_HAVEIPV6 */ diff --git a/contrib/ntp/libntp/numtoa.c b/contrib/ntp/libntp/numtoa.c new file mode 100644 index 0000000..de95118 --- /dev/null +++ b/contrib/ntp/libntp/numtoa.c @@ -0,0 +1,24 @@ +/* + * numtoa - return asciized network numbers store in local array space + */ +#include <stdio.h> + +#include "ntp_fp.h" +#include "lib_strbuf.h" +#include "ntp_stdlib.h" + +char * +numtoa( + u_int32 num + ) +{ + register u_int32 netnum; + register char *buf; + + netnum = ntohl(num); + LIB_GETBUF(buf); + (void) sprintf(buf, "%lu.%lu.%lu.%lu", ((u_long)netnum >> 24) & 0xff, + ((u_long)netnum >> 16) & 0xff, ((u_long)netnum >> 8) & 0xff, + (u_long)netnum & 0xff); + return buf; +} diff --git a/contrib/ntp/libntp/numtohost.c b/contrib/ntp/libntp/numtohost.c new file mode 100644 index 0000000..dd51c5d --- /dev/null +++ b/contrib/ntp/libntp/numtohost.c @@ -0,0 +1,38 @@ +/* + * numtohost - convert network number to host name. + */ + +#include "ntp_fp.h" +#include "ntp_stdlib.h" +#include "lib_strbuf.h" + +#define LOOPBACKNET 0x7f000000 +#define LOOPBACKHOST 0x7f000001 +#define LOOPBACKNETMASK 0xff000000 + +char * +numtohost( + u_int32 netnum + ) +{ + char *bp; + struct hostent *hp; + + /* + * This is really gross, but saves lots of hanging looking for + * hostnames for the radio clocks. Don't bother looking up + * addresses on the loopback network except for the loopback + * host itself. + */ + if ((((ntohl(netnum) & LOOPBACKNETMASK) == LOOPBACKNET) + && (ntohl(netnum) != LOOPBACKHOST)) + || ((hp = gethostbyaddr((char *)&netnum, sizeof netnum, AF_INET)) + == 0)) + return numtoa(netnum); + + LIB_GETBUF(bp); + + bp[LIB_BUFLENGTH-1] = '\0'; + (void) strncpy(bp, hp->h_name, LIB_BUFLENGTH-1); + return bp; +} diff --git a/contrib/ntp/libntp/octtoint.c b/contrib/ntp/libntp/octtoint.c new file mode 100644 index 0000000..f792b2b --- /dev/null +++ b/contrib/ntp/libntp/octtoint.c @@ -0,0 +1,35 @@ +/* + * octtoint - convert an ascii string in octal to an unsigned + * long, with error checking + */ +#include <stdio.h> +#include <ctype.h> + +#include "ntp_stdlib.h" + +int +octtoint( + const char *str, + u_long *ival + ) +{ + register u_long u; + register const char *cp; + + cp = str; + + if (*cp == '\0') + return 0; + + u = 0; + while (*cp != '\0') { + if (!isdigit((int)*cp) || *cp == '8' || *cp == '9') + return 0; + if (u >= 0x20000000) + return 0; /* overflow */ + u <<= 3; + u += *cp++ - '0'; /* ascii dependent */ + } + *ival = u; + return 1; +} diff --git a/contrib/ntp/libntp/prettydate.c b/contrib/ntp/libntp/prettydate.c new file mode 100644 index 0000000..55adf64 --- /dev/null +++ b/contrib/ntp/libntp/prettydate.c @@ -0,0 +1,132 @@ +/* + * prettydate - convert a time stamp to something readable + */ +#include <stdio.h> + +#include "ntp_fp.h" +#include "ntp_unixtime.h" /* includes <sys/time.h> */ +#include "lib_strbuf.h" +#include "ntp_stdlib.h" + +static const char *months[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" +}; + +static const char *days[] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" +}; + +/* Helper function to handle possible wraparound of the ntp epoch. + + Works by assuming that the localtime/gmtime library functions + have been updated so that they work +*/ + +#define MAX_EPOCH_NR 1000 + +struct tm * +ntp2unix_tm( + u_long ntp, int local + ) +{ + time_t t, curr; + struct tm *tm; + int curr_year, epoch_nr; + + /* First get the current year: */ + curr = time(NULL); + tm = local ? localtime(&curr) : gmtime(&curr); + if (!tm) return NULL; + + curr_year = 1900 + tm->tm_year; + + /* Convert the ntp timestamp to a unix utc seconds count: */ + t = (time_t) ntp - JAN_1970; + + /* Check that the ntp timestamp is not before a 136 year window centered + around the current year: + + Failsafe in case of an infinite loop: + Allow up to 1000 epochs of 136 years each! + */ + for (epoch_nr = 0; epoch_nr < MAX_EPOCH_NR; epoch_nr++) { + tm = local ? localtime(&t) : gmtime(&t); + +#if SIZEOF_TIME_T < 4 +# include "Bletch: sizeof(time_t) < 4!" +#endif + +#if SIZEOF_TIME_T == 4 + /* If 32 bits, then year is 1970-2038, so no sense looking */ + epoch_nr = MAX_EPOCH_NR; +#else /* SIZEOF_TIME_T > 4 */ + /* Check that the resulting year is in the correct epoch: */ + if (1900 + tm->tm_year > curr_year - 68) break; + + /* Epoch wraparound: Add 2^32 seconds! */ + t += (time_t) 65536 << 16; +#endif /* SIZEOF_TIME_T > 4 */ + } + return tm; +} + +char * +prettydate( + l_fp *ts + ) +{ + char *bp; + struct tm *tm; + time_t sec; + u_long msec; + + LIB_GETBUF(bp); + + sec = ts->l_ui; + msec = ts->l_uf / 4294967; /* fract / (2 ** 32 / 1000) */ + + tm = ntp2unix_tm(sec, 1); + if (!tm) { + (void) sprintf(bp, "%08lx.%08lx --- --- -- ---- --:--:--", + (u_long)ts->l_ui, (u_long)ts->l_uf); + } + else { + (void) sprintf(bp, "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03lu", + (u_long)ts->l_ui, (u_long)ts->l_uf, days[tm->tm_wday], + months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year, + tm->tm_hour,tm->tm_min, tm->tm_sec, msec); + } + + return bp; +} + +char * +gmprettydate( + l_fp *ts + ) +{ + char *bp; + struct tm *tm; + time_t sec; + u_long msec; + + LIB_GETBUF(bp); + + sec = ts->l_ui; + msec = ts->l_uf / 4294967; /* fract / (2 ** 32 / 1000) */ + + tm = ntp2unix_tm(sec, 0); + if (!tm) { + (void) sprintf(bp, "%08lx.%08lx --- --- -- ---- --:--:--", + (u_long)ts->l_ui, (u_long)ts->l_uf); + } + else { + (void) sprintf(bp, "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03lu", + (u_long)ts->l_ui, (u_long)ts->l_uf, days[tm->tm_wday], + months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year, + tm->tm_hour,tm->tm_min, tm->tm_sec, msec); + } + + return bp; +} diff --git a/contrib/ntp/libntp/recvbuff.c b/contrib/ntp/libntp/recvbuff.c new file mode 100644 index 0000000..6665686 --- /dev/null +++ b/contrib/ntp/libntp/recvbuff.c @@ -0,0 +1,246 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> +#include "ntp_machine.h" +#include "ntp_fp.h" +#include "ntp_syslog.h" +#include "ntp_stdlib.h" +#include "ntp_io.h" +#include "recvbuff.h" +#include "iosignal.h" + +#include <isc/list.h> +/* + * Memory allocation + */ +static u_long volatile full_recvbufs; /* number of recvbufs on fulllist */ +static u_long volatile free_recvbufs; /* number of recvbufs on freelist */ +static u_long volatile total_recvbufs; /* total recvbufs currently in use */ +static u_long volatile lowater_adds; /* number of times we have added memory */ +static u_long volatile buffer_shortfall;/* number of missed free receive buffers + between replenishments */ + +static ISC_LIST(recvbuf_t) full_recv_list; /* Currently used recv buffers */ +static ISC_LIST(recvbuf_t) free_recv_list; /* Currently unused buffers */ + +#if defined(SYS_WINNT) + +/* + * For Windows we need to set up a lock to manipulate the + * recv buffers to prevent corruption. We keep it lock for as + * short a time as possible + */ +static CRITICAL_SECTION RecvLock; +# define LOCK() EnterCriticalSection(&RecvLock) +# define UNLOCK() LeaveCriticalSection(&RecvLock) +#else +# define LOCK() +# define UNLOCK() +#endif + +u_long +free_recvbuffs (void) +{ + return free_recvbufs; +} + +u_long +full_recvbuffs (void) +{ + return full_recvbufs; +} + +u_long +total_recvbuffs (void) +{ + return total_recvbufs; +} + +u_long +lowater_additions(void) +{ + return lowater_adds; +} + +static void +initialise_buffer(recvbuf_t *buff) +{ + memset((char *) buff, 0, sizeof(recvbuf_t)); + +#if defined SYS_WINNT + buff->wsabuff.len = RX_BUFF_SIZE; + buff->wsabuff.buf = (char *) buff->recv_buffer; +#endif +} + +static void +create_buffers(int nbufs) +{ + register recvbuf_t *bufp; + int i, abuf; + + abuf = nbufs + buffer_shortfall; + buffer_shortfall = 0; + + bufp = (recvbuf_t *) emalloc(abuf*sizeof(recvbuf_t)); + + for (i = 0; i < abuf; i++) + { + memset((char *) bufp, 0, sizeof(recvbuf_t)); + ISC_LIST_APPEND(free_recv_list, bufp, link); + bufp++; + free_recvbufs++; + total_recvbufs++; + } + lowater_adds++; +} + +void +init_recvbuff(int nbufs) +{ + + /* + * Init buffer free list and stat counters + */ + ISC_LIST_INIT(full_recv_list); + ISC_LIST_INIT(free_recv_list); + free_recvbufs = total_recvbufs = 0; + full_recvbufs = lowater_adds = 0; + + create_buffers(nbufs); + +#if defined(SYS_WINNT) + InitializeCriticalSection(&RecvLock); +#endif + +} + +/* + * freerecvbuf - make a single recvbuf available for reuse + */ +void +freerecvbuf(recvbuf_t *rb) +{ + if (rb == NULL) { + msyslog(LOG_ERR, "freerecvbuff received NULL buffer"); + return; + } + + LOCK(); + (rb->used)--; + if (rb->used != 0) + msyslog(LOG_ERR, "******** freerecvbuff non-zero usage: %d *******", rb->used); + ISC_LIST_APPEND(free_recv_list, rb, link); +#if defined SYS_WINNT + rb->wsabuff.len = RX_BUFF_SIZE; + rb->wsabuff.buf = (char *) rb->recv_buffer; +#endif + free_recvbufs++; + UNLOCK(); +} + + +void +add_full_recv_buffer(recvbuf_t *rb) +{ + if (rb == NULL) { + msyslog(LOG_ERR, "add_full_recv_buffer received NULL buffer"); + return; + } + LOCK(); + ISC_LIST_APPEND(full_recv_list, rb, link); + full_recvbufs++; + UNLOCK(); +} + +recvbuf_t * +get_free_recv_buffer(void) +{ + recvbuf_t * buffer = NULL; + LOCK(); + buffer = ISC_LIST_HEAD(free_recv_list); + if (buffer != NULL) + { + ISC_LIST_DEQUEUE(free_recv_list, buffer, link); + free_recvbufs--; + initialise_buffer(buffer); + (buffer->used)++; + } + else + { + buffer_shortfall++; + } + UNLOCK(); + return (buffer); +} + +#ifdef HAVE_IO_COMPLETION_PORT +recvbuf_t * +get_free_recv_buffer_alloc(void) +{ + recvbuf_t * buffer = get_free_recv_buffer(); + if (buffer == NULL) + { + create_buffers(RECV_INC); + buffer = get_free_recv_buffer(); + } + return (buffer); +} +#endif + +recvbuf_t * +get_full_recv_buffer(void) +{ + recvbuf_t *rbuf; + LOCK(); + +#ifdef HAVE_SIGNALED_IO + /* + * make sure there are free buffers when we + * wander off to do lengthy paket processing with + * any buffer we grab from the full list. + * + * fixes malloc() interrupted by SIGIO risk + * (Bug 889) + */ + rbuf = ISC_LIST_HEAD(free_recv_list); + if (rbuf == NULL || buffer_shortfall > 0) { + /* + * try to get us some more buffers + */ + create_buffers(RECV_INC); + } +#endif + + /* + * try to grab a full buffer + */ + rbuf = ISC_LIST_HEAD(full_recv_list); + if (rbuf != NULL) + { + ISC_LIST_DEQUEUE(full_recv_list, rbuf, link); + --full_recvbufs; + } + else + { + /* + * Make sure we reset the full count to 0 + */ + full_recvbufs = 0; + } + UNLOCK(); + return (rbuf); +} + +/* + * Checks to see if there are buffers to process + */ +isc_boolean_t has_full_recv_buffer(void) +{ + if (ISC_LIST_HEAD(full_recv_list) != NULL) + return (ISC_TRUE); + else + return (ISC_FALSE); +} diff --git a/contrib/ntp/libntp/refnumtoa.c b/contrib/ntp/libntp/refnumtoa.c new file mode 100644 index 0000000..7c5d96e --- /dev/null +++ b/contrib/ntp/libntp/refnumtoa.c @@ -0,0 +1,36 @@ +/* + * refnumtoa - return asciized refclock addresses stored in local array space + */ +#include <stdio.h> + +#include "ntp_fp.h" +#include "lib_strbuf.h" +#include "ntp_stdlib.h" + +char * +refnumtoa( + struct sockaddr_storage* num + ) +{ + register u_int32 netnum; + register char *buf; + register const char *rclock; + + LIB_GETBUF(buf); + + if(num->ss_family == AF_INET) { + netnum = ntohl(((struct sockaddr_in*)num)->sin_addr.s_addr); + rclock = clockname((int)((u_long)netnum >> 8) & 0xff); + + if (rclock != NULL) + (void)sprintf(buf, "%s(%lu)", rclock, (u_long)netnum & 0xff); + else + (void)sprintf(buf, "REFCLK(%lu,%lu)", + ((u_long)netnum >> 8) & 0xff, (u_long)netnum & 0xff); + + } + else { + (void)sprintf(buf, "refclock address type not implemented yet, use IPv4 refclock address."); + } + return buf; +} diff --git a/contrib/ntp/libntp/snprintf.c b/contrib/ntp/libntp/snprintf.c new file mode 100644 index 0000000..7588b84 --- /dev/null +++ b/contrib/ntp/libntp/snprintf.c @@ -0,0 +1,62 @@ +#include <config.h> + +#if !HAVE_SNPRINTF +#include <sys/types.h> + +#ifdef __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif +#include <stdio.h> + +#include "l_stdlib.h" + +#ifdef __STDC__ +int snprintf(char *str, size_t n, const char *fmt, ...) +#else +int snprintf(str, n, fmt, va_alist) + char *str; + size_t n; + const char *fmt; + va_dcl +#endif +{ + va_list ap; + int rval; +#ifdef VSPRINTF_CHARSTAR + char *rp; +#endif +#ifdef __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif +#ifdef VSPRINTF_CHARSTAR + rp = vsprintf(str, fmt, ap); + va_end(ap); + return (strlen(rp)); +#else + rval = vsprintf(str, fmt, ap); + va_end(ap); + return (rval); +#endif +} + +int +vsnprintf( + char *str, + size_t n, + const char *fmt, + va_list ap + ) +{ +#ifdef VSPRINTF_CHARSTAR + return (strlen(vsprintf(str, fmt, ap))); +#else + return (vsprintf(str, fmt, ap)); +#endif +} +#else +int snprintf_bs; +#endif diff --git a/contrib/ntp/libntp/socktoa.c b/contrib/ntp/libntp/socktoa.c new file mode 100644 index 0000000..fb41b22 --- /dev/null +++ b/contrib/ntp/libntp/socktoa.c @@ -0,0 +1,56 @@ +/* + * socktoa - return a numeric host name from a sockaddr_storage structure + */ + +#include <config.h> + +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> + +#include <arpa/inet.h> + +#ifdef ISC_PLATFORM_NEEDNTOP +#include <isc/net.h> +#endif + +#include <stdio.h> + +#include "ntp_fp.h" +#include "lib_strbuf.h" +#include "ntp_stdlib.h" +#include "ntp.h" + +char * +socktoa( + struct sockaddr_storage* sock + ) +{ + register char *buffer; + + LIB_GETBUF(buffer); + + if (sock == NULL) + strcpy(buffer, "null"); + else + { + + switch(sock->ss_family) { + + default: + case AF_INET : + inet_ntop(AF_INET, &GET_INADDR(*sock), buffer, + LIB_BUFLENGTH); + break; + + case AF_INET6 : + inet_ntop(AF_INET6, &GET_INADDR6(*sock), buffer, + LIB_BUFLENGTH); +#if 0 + default: + strcpy(buffer, "unknown"); +#endif + } + } + return buffer; +} diff --git a/contrib/ntp/libntp/socktohost.c b/contrib/ntp/libntp/socktohost.c new file mode 100644 index 0000000..7aafdc7 --- /dev/null +++ b/contrib/ntp/libntp/socktohost.c @@ -0,0 +1,31 @@ +/* + * socktoa - return a numeric host name from a sockaddr_storage structure + */ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> + +#include <arpa/inet.h> + +#include <stdio.h> + +#include "ntp_fp.h" +#include "lib_strbuf.h" +#include "ntp_stdlib.h" +#include "ntp.h" + + +char * +socktohost( + struct sockaddr_storage* sock + ) +{ + register char *buffer; + + LIB_GETBUF(buffer); + if (getnameinfo((struct sockaddr *)sock, SOCKLEN(sock), buffer, + LIB_BUFLENGTH /* NI_MAXHOST*/, NULL, 0, 0)) + return stoa(sock); + + return buffer; +} diff --git a/contrib/ntp/libntp/statestr.c b/contrib/ntp/libntp/statestr.c new file mode 100644 index 0000000..85552b3 --- /dev/null +++ b/contrib/ntp/libntp/statestr.c @@ -0,0 +1,305 @@ +/* + * pretty printing of status information + */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <stdio.h> +#include "ntp_stdlib.h" +#include "ntp_fp.h" +#include "ntp.h" +#include "lib_strbuf.h" +#include "ntp_refclock.h" +#include "ntp_control.h" +#include "ntp_string.h" + +/* + * Structure for turning various constants into a readable string. + */ +struct codestring { + int code; + const char *string; +}; + +/* + * Leap values + */ +static +struct codestring leap_codes[] = { + { LEAP_NOWARNING, "leap_none" }, + { LEAP_ADDSECOND, "leap_add_sec" }, + { LEAP_DELSECOND, "leap_del_sec" }, + { LEAP_NOTINSYNC, "sync_alarm" }, + { -1, "leap" } +}; + +/* + * Clock source + */ +static +struct codestring sync_codes[] = { + { CTL_SST_TS_UNSPEC, "sync_unspec" }, + { CTL_SST_TS_ATOM, "sync_atomic" }, + { CTL_SST_TS_LF, "sync_lf_clock" }, + { CTL_SST_TS_HF, "sync_hf_clock" }, + { CTL_SST_TS_UHF, "sync_uhf_clock" }, + { CTL_SST_TS_LOCAL, "sync_local_proto" }, + { CTL_SST_TS_NTP, "sync_ntp" }, + { CTL_SST_TS_UDPTIME, "sync_udp/time" }, + { CTL_SST_TS_WRSTWTCH, "sync_wristwatch" }, + { CTL_SST_TS_TELEPHONE, "sync_telephone" }, + { -1, "sync" } +}; + + +/* + * Peer selection + */ +static +struct codestring select_codes[] = { + { CTL_PST_SEL_REJECT, "selreject" }, + { CTL_PST_SEL_SANE, "sel_falsetick" }, + { CTL_PST_SEL_CORRECT, "sel_excess" }, + { CTL_PST_SEL_SELCAND, "sel_outlyer" }, + { CTL_PST_SEL_SYNCCAND, "sel_candidat" }, + { CTL_PST_SEL_DISTSYSPEER, "sel_selected" }, + { CTL_PST_SEL_SYSPEER, "sel_sys.peer" }, + { CTL_PST_SEL_PPS, "sel_pps.peer" }, + { -1, "sel" } +}; + + +/* + * Clock status + */ +static +struct codestring clock_codes[] = { + { CTL_CLK_OKAY, "clk_okay" }, + { CTL_CLK_NOREPLY, "clk_noreply" }, + { CTL_CLK_BADFORMAT, "clk_badformat" }, + { CTL_CLK_FAULT, "clk_fault" }, + { CTL_CLK_PROPAGATION, "clk_badsignal" }, + { CTL_CLK_BADDATE, "clk_baddate" }, + { CTL_CLK_BADTIME, "clk_badtime" }, + { -1, "clk" } +}; + + +/* + * System Events + */ +static +struct codestring sys_codes[] = { + { EVNT_UNSPEC, "event_unspec" }, + { EVNT_SYSRESTART, "event_restart" }, + { EVNT_SYSFAULT, "event_fault" }, + { EVNT_SYNCCHG, "event_sync_chg" }, + { EVNT_PEERSTCHG, "event_peer/strat_chg" }, + { EVNT_CLOCKRESET, "event_clock_reset" }, + { EVNT_BADDATETIM, "event_bad_date" }, + { EVNT_CLOCKEXCPT, "event_clock_excptn" }, + { -1, "event" } +}; + +/* + * Peer events + */ +static +struct codestring peer_codes[] = { + { EVNT_UNSPEC, "event_unspec" }, + { EVNT_PEERIPERR & ~PEER_EVENT, "event_ip_err" }, + { EVNT_PEERAUTH & ~PEER_EVENT, "event_authen" }, + { EVNT_UNREACH & ~PEER_EVENT, "event_unreach" }, + { EVNT_REACH & ~PEER_EVENT, "event_reach" }, + { EVNT_PEERCLOCK & ~PEER_EVENT, "event_peer_clock" }, +#if 0 + { EVNT_PEERSTRAT & ~PEER_EVENT, "event_stratum_chg" }, +#endif + { -1, "event" } +}; + +#ifdef OPENSSL +/* + * Crypto events + */ +static +struct codestring crypto_codes[] = { + { XEVNT_OK & ~CRPT_EVENT, "success" }, + { XEVNT_LEN & ~CRPT_EVENT, "bad_field_format_or_length" }, + { XEVNT_TSP & ~CRPT_EVENT, "bad_timestamp" }, + { XEVNT_FSP & ~CRPT_EVENT, "bad_filestamp" }, + { XEVNT_PUB & ~CRPT_EVENT, "bad_or_missing_public_key" }, + { XEVNT_MD & ~CRPT_EVENT, "unsupported_digest_type" }, + { XEVNT_KEY & ~CRPT_EVENT, "unsupported_identity_type" }, + { XEVNT_SGL & ~CRPT_EVENT, "bad_signature_length" }, + { XEVNT_SIG & ~CRPT_EVENT, "signature_not_verified" }, + { XEVNT_VFY & ~CRPT_EVENT, "certificate_not_verified" }, + { XEVNT_PER & ~CRPT_EVENT, "host certificate_expired" }, + { XEVNT_CKY & ~CRPT_EVENT, "bad_or_missing_cookie" }, + { XEVNT_DAT & ~CRPT_EVENT, "bad_or_missing_leapsecond_table" }, + { XEVNT_CRT & ~CRPT_EVENT, "bad_or_missing_certificate" }, + { XEVNT_ID & ~CRPT_EVENT, "bad_or_missing_group_key" }, + { XEVNT_ERR & ~CRPT_EVENT, "protocol_error" }, + { XEVNT_SRV & ~CRPT_EVENT, "server certificate expired" }, + { -1, "crypto" } +}; +#endif /* OPENSSL */ + +/* Forwards */ +static const char *getcode P((int, struct codestring *)); +static const char *getevents P((int)); + +/* + * getcode - return string corresponding to code + */ +static const char * +getcode( + int code, + struct codestring *codetab + ) +{ + static char buf[30]; + + while (codetab->code != -1) { + if (codetab->code == code) + return codetab->string; + codetab++; + } + (void) sprintf(buf, "%s_%d", codetab->string, code); + return buf; +} + +/* + * getevents - return a descriptive string for the event count + */ +static const char * +getevents( + int cnt + ) +{ + static char buf[20]; + + if (cnt == 0) + return "no events"; + (void) sprintf(buf, "%d event%s", cnt, (cnt==1) ? "" : "s"); + return buf; +} + +/* + * statustoa - return a descriptive string for a peer status + */ +char * +statustoa( + int type, + int st + ) +{ + char *cb; + u_char pst; + + LIB_GETBUF(cb); + + switch (type) { + case TYPE_SYS: + (void)strcpy(cb, getcode(CTL_SYS_LI(st), leap_codes)); + (void)strcat(cb, ", "); + (void)strcat(cb, getcode(CTL_SYS_SOURCE(st) & ~CTL_SST_TS_PPS, sync_codes)); + if (CTL_SYS_SOURCE(st) & CTL_SST_TS_PPS) + (void)strcat(cb, "/PPS"); + (void)strcat(cb, ", "); + (void)strcat(cb, getevents(CTL_SYS_NEVNT(st))); + (void)strcat(cb, ", "); + (void)strcat(cb, getcode(CTL_SYS_EVENT(st), sys_codes)); + break; + + case TYPE_PEER: + /* + * Handcraft the bits + */ + pst = (u_char) CTL_PEER_STATVAL(st); + if (!(pst & CTL_PST_REACH)) { + (void)strcpy(cb, "unreach"); + } else { + (void)strcpy(cb, "reach"); + + } + if (pst & CTL_PST_CONFIG) + (void)strcat(cb, ", conf"); + if (pst & CTL_PST_AUTHENABLE) { + if (!(pst & CTL_PST_REACH) || (pst & CTL_PST_AUTHENTIC)) + (void)strcat(cb, ", auth"); + else + (void)strcat(cb, ", unauth"); + } + + /* + * Now the codes + */ + if ((pst & 0x7) != CTL_PST_SEL_REJECT) { + (void)strcat(cb, ", "); + (void)strcat(cb, getcode(pst & 0x7, select_codes)); + } + (void)strcat(cb, ", "); + (void)strcat(cb, getevents(CTL_PEER_NEVNT(st))); + if (CTL_PEER_EVENT(st) != EVNT_UNSPEC) { + (void)strcat(cb, ", "); + (void)strcat(cb, getcode(CTL_PEER_EVENT(st), + peer_codes)); + } + break; + + case TYPE_CLOCK: + (void)strcpy(cb, getcode(((st)>>8) & 0xff, clock_codes)); + (void)strcat(cb, ", last_"); + (void)strcat(cb, getcode((st) & 0xff, clock_codes)); + break; + } + return cb; +} + +const char * +eventstr( + int num + ) +{ + if (num & PEER_EVENT) + return (getcode(num & ~PEER_EVENT, peer_codes)); +#ifdef OPENSSL + else if (num & CRPT_EVENT) + return (getcode(num & ~CRPT_EVENT, crypto_codes)); +#endif /* OPENSSL */ + else + return (getcode(num, sys_codes)); +} + +const char * +ceventstr( + int num + ) +{ + return getcode(num, clock_codes); +} + +const char * +sysstatstr( + int status + ) +{ + return statustoa(TYPE_SYS, status); +} + +const char * +peerstatstr( + int status + ) +{ + return statustoa(TYPE_PEER, status); +} + +const char * +clockstatstr( + int status + ) +{ + return statustoa(TYPE_CLOCK, status); +} diff --git a/contrib/ntp/libntp/strdup.c b/contrib/ntp/libntp/strdup.c new file mode 100644 index 0000000..2e26ba7 --- /dev/null +++ b/contrib/ntp/libntp/strdup.c @@ -0,0 +1,28 @@ +#include "ntp_malloc.h" + +#if !HAVE_STRDUP + +#define NULL 0 + +char *strdup(const char *s); + +char * +strdup( + const char *s + ) +{ + char *cp; + + if (s) { + cp = (char *) malloc((unsigned) (strlen(s)+1)); + if (cp) { + (void) strcpy(cp, s); + } + } else { + cp = (char *) NULL; + } + return(cp); +} +#else +int strdup_bs; +#endif diff --git a/contrib/ntp/libntp/strerror.c b/contrib/ntp/libntp/strerror.c new file mode 100644 index 0000000..9d8ae8e --- /dev/null +++ b/contrib/ntp/libntp/strerror.c @@ -0,0 +1,48 @@ +#include <config.h> + +#if !HAVE_STRERROR +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char sccsid[] = "@(#)strerror.c 5.1 (Berkeley) 4/9/89"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> + +#include <stdio.h> +#include <string.h> + +#include "l_stdlib.h" + +char * +strerror( + int errnum + ) +{ + extern int sys_nerr; + extern char *sys_errlist[]; + static char ebuf[20]; + + if ((unsigned int)errnum < sys_nerr) + return(sys_errlist[errnum]); + (void)sprintf(ebuf, "Unknown error: %d", errnum); + return(ebuf); +} +#else +int strerror_bs; +#endif diff --git a/contrib/ntp/libntp/strstr.c b/contrib/ntp/libntp/strstr.c new file mode 100644 index 0000000..a4deb87 --- /dev/null +++ b/contrib/ntp/libntp/strstr.c @@ -0,0 +1,52 @@ +#include <config.h> + +#if !HAVE_STRSTR + +/* + * Amanda, The Advanced Maryland Automatic Network Disk Archiver + * Copyright (c) 1991-1998 University of Maryland at College Park + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of U.M. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. U.M. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: James da Silva, Systems Design and Analysis Group + * Computer Science Department + * University of Maryland at College Park + */ +/* + * $Id$ + * + * replacement for missing ANSI-C strstr function + */ + +char *strstr(a, b) +char *a, *b; +{ + int alen, blen, i; + + alen = strlen(a); + blen = strlen(b); + + for(i=0; i <= alen-blen; i++, a++) + if(strncmp(a, b, blen) == 0) return a; + + return NULL; +} +#else +int strstr_bs; +#endif diff --git a/contrib/ntp/libntp/syssignal.c b/contrib/ntp/libntp/syssignal.c new file mode 100644 index 0000000..6ec4c4c --- /dev/null +++ b/contrib/ntp/libntp/syssignal.c @@ -0,0 +1,133 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> +#include <sys/types.h> +#include <signal.h> + +#include "ntp_syslog.h" +#include "ntp_stdlib.h" + +#ifdef HAVE_SIGACTION + +void +signal_no_reset( +#if defined(__STDC__) || defined(HAVE_STDARG_H) + int sig, + void (*func) (int) +#else + sig, func +#endif + ) +#if defined(__STDC__) || defined(HAVE_STDARG_H) +#else + int sig; + void (*func) P((int)); +#endif +{ + int n; + struct sigaction vec; + + vec.sa_handler = func; + sigemptyset(&vec.sa_mask); +#if 0 +#ifdef SA_RESTART + vec.sa_flags = SA_RESTART; +#else + vec.sa_flags = 0; +#endif +#else + vec.sa_flags = 0; +#endif + +#ifdef SA_RESTART +/* Added for PPS clocks on Solaris 7 which get EINTR errors */ +# ifdef SIGPOLL + if (sig == SIGPOLL) vec.sa_flags = SA_RESTART; +# endif +# ifdef SIGIO + if (sig == SIGIO) vec.sa_flags = SA_RESTART; +# endif +#endif + + while (1) + { + struct sigaction ovec; + + n = sigaction(sig, &vec, &ovec); + if (n == -1 && errno == EINTR) continue; + if (ovec.sa_flags +#ifdef SA_RESTART + && ovec.sa_flags != SA_RESTART +#endif + ) + msyslog(LOG_DEBUG, "signal_no_reset: signal %d had flags %x", + sig, ovec.sa_flags); + break; + } + if (n == -1) { + perror("sigaction"); + exit(1); + } +} + +#elif HAVE_SIGVEC + +void +signal_no_reset( + int sig, + RETSIGTYPE (*func) (int) + ) +{ + struct sigvec sv; + int n; + + bzero((char *) &sv, sizeof(sv)); + sv.sv_handler = func; + n = sigvec(sig, &sv, (struct sigvec *)NULL); + if (n == -1) { + perror("sigvec"); + exit(1); + } +} + +#elif HAVE_SIGSET + +void +signal_no_reset( + int sig, + RETSIGTYPE (*func) (int) + ) +{ + int n; + + n = sigset(sig, func); + if (n == -1) { + perror("sigset"); + exit(1); + } +} + +#else + +/* Beware! This implementation resets the signal to SIG_DFL */ +void +signal_no_reset( + int sig, + RETSIGTYPE (*func) (int) + ) +{ +#ifdef SIG_ERR + if (SIG_ERR == signal(sig, func)) { +#else + int n; + n = signal(sig, func); + if (n == -1) { +#endif + perror("signal"); + exit(1); + } +} + +#endif diff --git a/contrib/ntp/libntp/systime.c b/contrib/ntp/libntp/systime.c new file mode 100644 index 0000000..4539b5f --- /dev/null +++ b/contrib/ntp/libntp/systime.c @@ -0,0 +1,542 @@ +/* + * systime -- routines to fiddle a UNIX clock. + * + * ATTENTION: Get approval from Dave Mills on all changes to this file! + * + */ +#include "ntp_machine.h" +#include "ntp_fp.h" +#include "ntp_syslog.h" +#include "ntp_unixtime.h" +#include "ntp_stdlib.h" +#include "ntp_random.h" +#include "ntpd.h" /* for sys_precision */ + +#ifdef SIM +# include "ntpsim.h" +#endif /*SIM */ + +#ifdef HAVE_SYS_PARAM_H +# include <sys/param.h> +#endif +#ifdef HAVE_UTMP_H +# include <utmp.h> +#endif /* HAVE_UTMP_H */ +#ifdef HAVE_UTMPX_H +# include <utmpx.h> +#endif /* HAVE_UTMPX_H */ + +/* + * These routines (get_systime, step_systime, adj_systime) implement an + * interface between the system independent NTP clock and the Unix + * system clock in various architectures and operating systems. + * + * Time is a precious quantity in these routines and every effort is + * made to minimize errors by always rounding toward zero and amortizing + * adjustment residues. By default the adjustment quantum is 1 us for + * the usual Unix tickadj() system call, but this can be increased if + * necessary by the tick configuration command. For instance, when the + * adjtime() quantum is a clock tick for a 100-Hz clock, the quantum + * should be 10 ms. + */ +#if defined RELIANTUNIX_CLOCK || defined SCO5_CLOCK +double sys_tick = 10e-3; /* 10 ms tickadj() */ +#else +double sys_tick = 1e-6; /* 1 us tickadj() */ +#endif +double sys_residual = 0; /* adjustment residue (s) */ + +#ifndef SIM + +/* + * 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. + * The bottom is only two bits down, so no need for fuzz. + * Some systems don't have that level of precision, however... + */ +# 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. + * Add in unbiased random fuzz beneath the microsecond. + */ + GETTIMEOFDAY(&tv, NULL); + now->l_i = tv.tv_sec + JAN_1970; + dtemp = tv.tv_usec / 1e6; + +#endif /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */ + + /* + * ntp_random() produces 31 bits (always nonnegative). + * This bit is done only after the precision has been + * determined. + */ + if (sys_precision != 0) + dtemp += (ntp_random() / FRAC - .5) / (1 << + -sys_precision); + + /* + * Renormalize to seconds past 1900 and fraction. + */ + dtemp += sys_residual; + if (dtemp >= 1) { + dtemp -= 1; + now->l_i++; + } else if (dtemp < 0) { + dtemp += 1; + now->l_i--; + } + dtemp *= FRAC; + now->l_uf = (u_int32)dtemp; +} + + +/* + * adj_systime - adjust system time by the argument. + */ +#if !defined SYS_WINNT +int /* 0 okay, 1 error */ +adj_systime( + double now /* adjustment (s) */ + ) +{ + struct timeval adjtv; /* new adjustment */ + struct timeval oadjtv; /* residual adjustment */ + double dtemp; + long ticks; + int isneg = 0; + + /* + * Most Unix adjtime() implementations adjust the system clock + * in microsecond quanta, but some adjust in 10-ms quanta. We + * carefully round the adjustment to the nearest quantum, then + * adjust in quanta and keep the residue for later. + */ + dtemp = now + sys_residual; + if (dtemp < 0) { + isneg = 1; + dtemp = -dtemp; + } + adjtv.tv_sec = (long)dtemp; + dtemp -= adjtv.tv_sec; + ticks = (long)(dtemp / sys_tick + .5); + adjtv.tv_usec = (long)(ticks * sys_tick * 1e6); + dtemp -= adjtv.tv_usec / 1e6; + sys_residual = dtemp; + + /* + * Convert to signed seconds and microseconds for the Unix + * adjtime() system call. Note we purposely lose the adjtime() + * leftover. + */ + if (isneg) { + adjtv.tv_sec = -adjtv.tv_sec; + adjtv.tv_usec = -adjtv.tv_usec; + sys_residual = -sys_residual; + } + if (adjtv.tv_sec != 0 || adjtv.tv_usec != 0) { + if (adjtime(&adjtv, &oadjtv) < 0) { + msyslog(LOG_ERR, "adj_systime: %m"); + return (0); + } + } + return (1); +} +#endif + + +/* + * step_systime - step the system clock. + */ +int +step_systime( + double now + ) +{ + struct timeval timetv, adjtv, oldtimetv; + int isneg = 0; + double dtemp; +#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETCLOCK) + struct timespec ts; +#endif + + dtemp = sys_residual + now; + if (dtemp < 0) { + isneg = 1; + dtemp = - dtemp; + adjtv.tv_sec = (int32)dtemp; + adjtv.tv_usec = (u_int32)((dtemp - + (double)adjtv.tv_sec) * 1e6 + .5); + } else { + adjtv.tv_sec = (int32)dtemp; + adjtv.tv_usec = (u_int32)((dtemp - + (double)adjtv.tv_sec) * 1e6 + .5); + } +#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETCLOCK) +# ifdef HAVE_CLOCK_GETTIME + (void) clock_gettime(CLOCK_REALTIME, &ts); +# else + (void) getclock(TIMEOFDAY, &ts); +# endif + timetv.tv_sec = ts.tv_sec; + timetv.tv_usec = ts.tv_nsec / 1000; +#else /* not HAVE_GETCLOCK */ + (void) GETTIMEOFDAY(&timetv, (struct timezone *)0); +#endif /* not HAVE_GETCLOCK */ + + oldtimetv = timetv; + +#ifdef DEBUG + if (debug) + printf("step_systime: step %.6f residual %.6f\n", now, sys_residual); +#endif + if (isneg) { + timetv.tv_sec -= adjtv.tv_sec; + timetv.tv_usec -= adjtv.tv_usec; + if (timetv.tv_usec < 0) { + timetv.tv_sec--; + timetv.tv_usec += 1000000; + } + } else { + timetv.tv_sec += adjtv.tv_sec; + timetv.tv_usec += adjtv.tv_usec; + if (timetv.tv_usec >= 1000000) { + timetv.tv_sec++; + timetv.tv_usec -= 1000000; + } + } + if (ntp_set_tod(&timetv, NULL) != 0) { + msyslog(LOG_ERR, "step-systime: %m"); + return (0); + } + sys_residual = 0; + +#ifdef NEED_HPUX_ADJTIME + /* + * CHECKME: is this correct when called by ntpdate????? + */ + _clear_adjtime(); +#endif + + /* + * FreeBSD, for example, has: + * struct utmp { + * char ut_line[UT_LINESIZE]; + * char ut_name[UT_NAMESIZE]; + * char ut_host[UT_HOSTSIZE]; + * long ut_time; + * }; + * and appends line="|", name="date", host="", time for the OLD + * and appends line="{", name="date", host="", time for the NEW + * to _PATH_WTMP . + * + * Some OSes have utmp, some have utmpx. + */ + + /* + * Write old and new time entries in utmp and wtmp if step + * adjustment is greater than one second. + * + * This might become even Uglier... + */ + if (oldtimetv.tv_sec != timetv.tv_sec) + { +#ifdef HAVE_UTMP_H + struct utmp ut; +#endif +#ifdef HAVE_UTMPX_H + struct utmpx utx; +#endif + +#ifdef HAVE_UTMP_H + memset((char *)&ut, 0, sizeof(ut)); +#endif +#ifdef HAVE_UTMPX_H + memset((char *)&utx, 0, sizeof(utx)); +#endif + + /* UTMP */ + +#ifdef UPDATE_UTMP +# ifdef HAVE_PUTUTLINE + ut.ut_type = OLD_TIME; + (void)strcpy(ut.ut_line, OTIME_MSG); + ut.ut_time = oldtimetv.tv_sec; + pututline(&ut); + setutent(); + ut.ut_type = NEW_TIME; + (void)strcpy(ut.ut_line, NTIME_MSG); + ut.ut_time = timetv.tv_sec; + pututline(&ut); + endutent(); +# else /* not HAVE_PUTUTLINE */ +# endif /* not HAVE_PUTUTLINE */ +#endif /* UPDATE_UTMP */ + + /* UTMPX */ + +#ifdef UPDATE_UTMPX +# ifdef HAVE_PUTUTXLINE + utx.ut_type = OLD_TIME; + (void)strcpy(utx.ut_line, OTIME_MSG); + utx.ut_tv = oldtimetv; + pututxline(&utx); + setutxent(); + utx.ut_type = NEW_TIME; + (void)strcpy(utx.ut_line, NTIME_MSG); + utx.ut_tv = timetv; + pututxline(&utx); + endutxent(); +# else /* not HAVE_PUTUTXLINE */ +# endif /* not HAVE_PUTUTXLINE */ +#endif /* UPDATE_UTMPX */ + + /* WTMP */ + +#ifdef UPDATE_WTMP +# ifdef HAVE_PUTUTLINE + utmpname(WTMP_FILE); + ut.ut_type = OLD_TIME; + (void)strcpy(ut.ut_line, OTIME_MSG); + ut.ut_time = oldtimetv.tv_sec; + pututline(&ut); + ut.ut_type = NEW_TIME; + (void)strcpy(ut.ut_line, NTIME_MSG); + ut.ut_time = timetv.tv_sec; + pututline(&ut); + endutent(); +# else /* not HAVE_PUTUTLINE */ +# endif /* not HAVE_PUTUTLINE */ +#endif /* UPDATE_WTMP */ + + /* WTMPX */ + +#ifdef UPDATE_WTMPX +# ifdef HAVE_PUTUTXLINE + utx.ut_type = OLD_TIME; + utx.ut_tv = oldtimetv; + (void)strcpy(utx.ut_line, OTIME_MSG); +# ifdef HAVE_UPDWTMPX + updwtmpx(WTMPX_FILE, &utx); +# else /* not HAVE_UPDWTMPX */ +# endif /* not HAVE_UPDWTMPX */ +# else /* not HAVE_PUTUTXLINE */ +# endif /* not HAVE_PUTUTXLINE */ +# ifdef HAVE_PUTUTXLINE + utx.ut_type = NEW_TIME; + utx.ut_tv = timetv; + (void)strcpy(utx.ut_line, NTIME_MSG); +# ifdef HAVE_UPDWTMPX + updwtmpx(WTMPX_FILE, &utx); +# else /* not HAVE_UPDWTMPX */ +# endif /* not HAVE_UPDWTMPX */ +# else /* not HAVE_PUTUTXLINE */ +# endif /* not HAVE_PUTUTXLINE */ +#endif /* UPDATE_WTMPX */ + + } + return (1); +} + +#else /* SIM */ +/* + * Clock routines for the simulator - Harish Nair, with help + */ +/* + * get_systime - return the system time in NTP timestamp format + */ +void +get_systime( + l_fp *now /* current system time in l_fp */ ) +{ + /* + * To fool the code that determines the local clock precision, + * we advance the clock a minimum of 200 nanoseconds on every + * clock read. This is appropriate for a typical modern machine + * with nanosecond clocks. Note we make no attempt here to + * simulate reading error, since the error is so small. This may + * change when the need comes to implement picosecond clocks. + */ + if (ntp_node.ntp_time == ntp_node.last_time) + ntp_node.ntp_time += 200e-9; + ntp_node.last_time = ntp_node.ntp_time; + DTOLFP(ntp_node.ntp_time, now); +} + + +/* + * adj_systime - advance or retard the system clock exactly like the + * real thng. + */ +int /* always succeeds */ +adj_systime( + double now /* time adjustment (s) */ + ) +{ + struct timeval adjtv; /* new adjustment */ + double dtemp; + long ticks; + int isneg = 0; + + /* + * Most Unix adjtime() implementations adjust the system clock + * in microsecond quanta, but some adjust in 10-ms quanta. We + * carefully round the adjustment to the nearest quantum, then + * adjust in quanta and keep the residue for later. + */ + dtemp = now + sys_residual; + if (dtemp < 0) { + isneg = 1; + dtemp = -dtemp; + } + adjtv.tv_sec = (long)dtemp; + dtemp -= adjtv.tv_sec; + ticks = (long)(dtemp / sys_tick + .5); + adjtv.tv_usec = (long)(ticks * sys_tick * 1e6); + dtemp -= adjtv.tv_usec / 1e6; + sys_residual = dtemp; + + /* + * Convert to signed seconds and microseconds for the Unix + * adjtime() system call. Note we purposely lose the adjtime() + * leftover. + */ + if (isneg) { + adjtv.tv_sec = -adjtv.tv_sec; + adjtv.tv_usec = -adjtv.tv_usec; + sys_residual = -sys_residual; + } + ntp_node.adj = now; + return (1); +} + + +/* + * step_systime - step the system clock. We are religious here. + */ +int /* always succeeds */ +step_systime( + double now /* step adjustment (s) */ + ) +{ +#ifdef DEBUG + if (debug) + printf("step_systime: time %.6f adj %.6f\n", + ntp_node.ntp_time, now); +#endif + ntp_node.ntp_time += now; + return (1); +} + +/* + * node_clock - update the clocks + */ +int /* always succeeds */ +node_clock( + Node *n, /* global node pointer */ + double t /* node time */ + ) +{ + double dtemp; + + /* + * Advance client clock (ntp_time). Advance server clock + * (clk_time) adjusted for systematic and random frequency + * errors. The random error is a random walk computed as the + * integral of samples from a Gaussian distribution. + */ + dtemp = t - n->ntp_time; + n->time = t; + n->ntp_time += dtemp; + n->ferr += gauss(0, dtemp * n->fnse); + n->clk_time += dtemp * (1 + n->ferr); + + /* + * Perform the adjtime() function. If the adjustment completed + * in the previous interval, amortize the entire amount; if not, + * carry the leftover to the next interval. + */ + dtemp *= n->slew; + if (dtemp < fabs(n->adj)) { + if (n->adj < 0) { + n->adj += dtemp; + n->ntp_time -= dtemp; + } else { + n->adj -= dtemp; + n->ntp_time += dtemp; + } + } else { + n->ntp_time += n->adj; + n->adj = 0; + } + return (0); +} + + +/* + * gauss() - returns samples from a gaussion distribution + */ +double /* Gaussian sample */ +gauss( + double m, /* sample mean */ + double s /* sample standard deviation (sigma) */ + ) +{ + double q1, q2; + + /* + * Roll a sample from a Gaussian distribution with mean m and + * standard deviation s. For m = 0, s = 1, mean(y) = 0, + * std(y) = 1. + */ + if (s == 0) + return (m); + while ((q1 = drand48()) == 0); + q2 = drand48(); + return (m + s * sqrt(-2. * log(q1)) * cos(2. * PI * q2)); +} + + +/* + * poisson() - returns samples from a network delay distribution + */ +double /* delay sample (s) */ +poisson( + double m, /* fixed propagation delay (s) */ + double s /* exponential parameter (mu) */ + ) +{ + double q1; + + /* + * Roll a sample from a composite distribution with propagation + * delay m and exponential distribution time with parameter s. + * For m = 0, s = 1, mean(y) = std(y) = 1. + */ + if (s == 0) + return (m); + while ((q1 = drand48()) == 0); + return (m - s * log(q1 * s)); +} +#endif /* SIM */ diff --git a/contrib/ntp/libntp/systime_s.c b/contrib/ntp/libntp/systime_s.c new file mode 100644 index 0000000..8762122 --- /dev/null +++ b/contrib/ntp/libntp/systime_s.c @@ -0,0 +1,2 @@ +#define SIM +#include "systime.c" diff --git a/contrib/ntp/libntp/tsftomsu.c b/contrib/ntp/libntp/tsftomsu.c new file mode 100644 index 0000000..5926aab --- /dev/null +++ b/contrib/ntp/libntp/tsftomsu.c @@ -0,0 +1,38 @@ +/* + * tsftomsu - convert from a time stamp fraction to milliseconds + */ +#include "ntp_fp.h" +#include "ntp_stdlib.h" + +int +tsftomsu( + u_long tsf, + int round + ) +{ + register long val_ui, val_uf; + register long tmp_ui, tmp_uf; + register int i; + + /* + * Essentially, multiply by 10 three times in l_fp form. + * The integral part is the milliseconds. + */ + val_ui = 0; + val_uf = tsf; + for (i = 3; i > 0; i--) { + M_LSHIFT(val_ui, val_uf); + tmp_ui = val_ui; + tmp_uf = val_uf; + M_LSHIFT(val_ui, val_uf); + M_LSHIFT(val_ui, val_uf); + M_ADD(val_ui, val_uf, tmp_ui, tmp_uf); + } + + /* + * Round the value if need be, then return it. + */ + if (round && (val_uf & 0x80000000)) + val_ui++; + return (int)val_ui; +} diff --git a/contrib/ntp/libntp/tstotv.c b/contrib/ntp/libntp/tstotv.c new file mode 100644 index 0000000..be4bdd4 --- /dev/null +++ b/contrib/ntp/libntp/tstotv.c @@ -0,0 +1,135 @@ +/* + * tstotv - tables for converting from NTP time stamps to struct timeval + */ + +#include "ntp_types.h" + +/* + * Tables to convert from a time stamp fraction to usecs. Note that + * the units of these tables are actually (usec<<3). We carry three + * guard bits so that the result can be properly truncated (or rounded) + * to be correct to the least significant bit. + * + * These tables are rounded. + */ + +long tstoushi[256] = { + 0x000000, 0x007a12, 0x00f424, 0x016e36, + 0x01e848, 0x02625a, 0x02dc6c, 0x03567e, + 0x03d090, 0x044aa2, 0x04c4b4, 0x053ec6, + 0x05b8d8, 0x0632ea, 0x06acfc, 0x07270e, + 0x07a120, 0x081b32, 0x089544, 0x090f56, + 0x098968, 0x0a037a, 0x0a7d8c, 0x0af79e, + 0x0b71b0, 0x0bebc2, 0x0c65d4, 0x0cdfe6, + 0x0d59f8, 0x0dd40a, 0x0e4e1c, 0x0ec82e, + 0x0f4240, 0x0fbc52, 0x103664, 0x10b076, + 0x112a88, 0x11a49a, 0x121eac, 0x1298be, + 0x1312d0, 0x138ce2, 0x1406f4, 0x148106, + 0x14fb18, 0x15752a, 0x15ef3c, 0x16694e, + 0x16e360, 0x175d72, 0x17d784, 0x185196, + 0x18cba8, 0x1945ba, 0x19bfcc, 0x1a39de, + 0x1ab3f0, 0x1b2e02, 0x1ba814, 0x1c2226, + 0x1c9c38, 0x1d164a, 0x1d905c, 0x1e0a6e, + 0x1e8480, 0x1efe92, 0x1f78a4, 0x1ff2b6, + 0x206cc8, 0x20e6da, 0x2160ec, 0x21dafe, + 0x225510, 0x22cf22, 0x234934, 0x23c346, + 0x243d58, 0x24b76a, 0x25317c, 0x25ab8e, + 0x2625a0, 0x269fb2, 0x2719c4, 0x2793d6, + 0x280de8, 0x2887fa, 0x29020c, 0x297c1e, + 0x29f630, 0x2a7042, 0x2aea54, 0x2b6466, + 0x2bde78, 0x2c588a, 0x2cd29c, 0x2d4cae, + 0x2dc6c0, 0x2e40d2, 0x2ebae4, 0x2f34f6, + 0x2faf08, 0x30291a, 0x30a32c, 0x311d3e, + 0x319750, 0x321162, 0x328b74, 0x330586, + 0x337f98, 0x33f9aa, 0x3473bc, 0x34edce, + 0x3567e0, 0x35e1f2, 0x365c04, 0x36d616, + 0x375028, 0x37ca3a, 0x38444c, 0x38be5e, + 0x393870, 0x39b282, 0x3a2c94, 0x3aa6a6, + 0x3b20b8, 0x3b9aca, 0x3c14dc, 0x3c8eee, + 0x3d0900, 0x3d8312, 0x3dfd24, 0x3e7736, + 0x3ef148, 0x3f6b5a, 0x3fe56c, 0x405f7e, + 0x40d990, 0x4153a2, 0x41cdb4, 0x4247c6, + 0x42c1d8, 0x433bea, 0x43b5fc, 0x44300e, + 0x44aa20, 0x452432, 0x459e44, 0x461856, + 0x469268, 0x470c7a, 0x47868c, 0x48009e, + 0x487ab0, 0x48f4c2, 0x496ed4, 0x49e8e6, + 0x4a62f8, 0x4add0a, 0x4b571c, 0x4bd12e, + 0x4c4b40, 0x4cc552, 0x4d3f64, 0x4db976, + 0x4e3388, 0x4ead9a, 0x4f27ac, 0x4fa1be, + 0x501bd0, 0x5095e2, 0x510ff4, 0x518a06, + 0x520418, 0x527e2a, 0x52f83c, 0x53724e, + 0x53ec60, 0x546672, 0x54e084, 0x555a96, + 0x55d4a8, 0x564eba, 0x56c8cc, 0x5742de, + 0x57bcf0, 0x583702, 0x58b114, 0x592b26, + 0x59a538, 0x5a1f4a, 0x5a995c, 0x5b136e, + 0x5b8d80, 0x5c0792, 0x5c81a4, 0x5cfbb6, + 0x5d75c8, 0x5defda, 0x5e69ec, 0x5ee3fe, + 0x5f5e10, 0x5fd822, 0x605234, 0x60cc46, + 0x614658, 0x61c06a, 0x623a7c, 0x62b48e, + 0x632ea0, 0x63a8b2, 0x6422c4, 0x649cd6, + 0x6516e8, 0x6590fa, 0x660b0c, 0x66851e, + 0x66ff30, 0x677942, 0x67f354, 0x686d66, + 0x68e778, 0x69618a, 0x69db9c, 0x6a55ae, + 0x6acfc0, 0x6b49d2, 0x6bc3e4, 0x6c3df6, + 0x6cb808, 0x6d321a, 0x6dac2c, 0x6e263e, + 0x6ea050, 0x6f1a62, 0x6f9474, 0x700e86, + 0x708898, 0x7102aa, 0x717cbc, 0x71f6ce, + 0x7270e0, 0x72eaf2, 0x736504, 0x73df16, + 0x745928, 0x74d33a, 0x754d4c, 0x75c75e, + 0x764170, 0x76bb82, 0x773594, 0x77afa6, + 0x7829b8, 0x78a3ca, 0x791ddc, 0x7997ee +}; + +long tstousmid[256] = { + 0x0000, 0x007a, 0x00f4, 0x016e, 0x01e8, 0x0262, 0x02dc, 0x0356, + 0x03d1, 0x044b, 0x04c5, 0x053f, 0x05b9, 0x0633, 0x06ad, 0x0727, + 0x07a1, 0x081b, 0x0895, 0x090f, 0x0989, 0x0a03, 0x0a7e, 0x0af8, + 0x0b72, 0x0bec, 0x0c66, 0x0ce0, 0x0d5a, 0x0dd4, 0x0e4e, 0x0ec8, + 0x0f42, 0x0fbc, 0x1036, 0x10b0, 0x112b, 0x11a5, 0x121f, 0x1299, + 0x1313, 0x138d, 0x1407, 0x1481, 0x14fb, 0x1575, 0x15ef, 0x1669, + 0x16e3, 0x175d, 0x17d8, 0x1852, 0x18cc, 0x1946, 0x19c0, 0x1a3a, + 0x1ab4, 0x1b2e, 0x1ba8, 0x1c22, 0x1c9c, 0x1d16, 0x1d90, 0x1e0a, + 0x1e84, 0x1eff, 0x1f79, 0x1ff3, 0x206d, 0x20e7, 0x2161, 0x21db, + 0x2255, 0x22cf, 0x2349, 0x23c3, 0x243d, 0x24b7, 0x2531, 0x25ac, + 0x2626, 0x26a0, 0x271a, 0x2794, 0x280e, 0x2888, 0x2902, 0x297c, + 0x29f6, 0x2a70, 0x2aea, 0x2b64, 0x2bde, 0x2c59, 0x2cd3, 0x2d4d, + 0x2dc7, 0x2e41, 0x2ebb, 0x2f35, 0x2faf, 0x3029, 0x30a3, 0x311d, + 0x3197, 0x3211, 0x328b, 0x3306, 0x3380, 0x33fa, 0x3474, 0x34ee, + 0x3568, 0x35e2, 0x365c, 0x36d6, 0x3750, 0x37ca, 0x3844, 0x38be, + 0x3938, 0x39b3, 0x3a2d, 0x3aa7, 0x3b21, 0x3b9b, 0x3c15, 0x3c8f, + 0x3d09, 0x3d83, 0x3dfd, 0x3e77, 0x3ef1, 0x3f6b, 0x3fe5, 0x405f, + 0x40da, 0x4154, 0x41ce, 0x4248, 0x42c2, 0x433c, 0x43b6, 0x4430, + 0x44aa, 0x4524, 0x459e, 0x4618, 0x4692, 0x470c, 0x4787, 0x4801, + 0x487b, 0x48f5, 0x496f, 0x49e9, 0x4a63, 0x4add, 0x4b57, 0x4bd1, + 0x4c4b, 0x4cc5, 0x4d3f, 0x4db9, 0x4e34, 0x4eae, 0x4f28, 0x4fa2, + 0x501c, 0x5096, 0x5110, 0x518a, 0x5204, 0x527e, 0x52f8, 0x5372, + 0x53ec, 0x5466, 0x54e1, 0x555b, 0x55d5, 0x564f, 0x56c9, 0x5743, + 0x57bd, 0x5837, 0x58b1, 0x592b, 0x59a5, 0x5a1f, 0x5a99, 0x5b13, + 0x5b8d, 0x5c08, 0x5c82, 0x5cfc, 0x5d76, 0x5df0, 0x5e6a, 0x5ee4, + 0x5f5e, 0x5fd8, 0x6052, 0x60cc, 0x6146, 0x61c0, 0x623a, 0x62b5, + 0x632f, 0x63a9, 0x6423, 0x649d, 0x6517, 0x6591, 0x660b, 0x6685, + 0x66ff, 0x6779, 0x67f3, 0x686d, 0x68e7, 0x6962, 0x69dc, 0x6a56, + 0x6ad0, 0x6b4a, 0x6bc4, 0x6c3e, 0x6cb8, 0x6d32, 0x6dac, 0x6e26, + 0x6ea0, 0x6f1a, 0x6f94, 0x700f, 0x7089, 0x7103, 0x717d, 0x71f7, + 0x7271, 0x72eb, 0x7365, 0x73df, 0x7459, 0x74d3, 0x754d, 0x75c7, + 0x7641, 0x76bc, 0x7736, 0x77b0, 0x782a, 0x78a4, 0x791e, 0x7998 +}; + +long tstouslo[128] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, + 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, + 0x1f, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, + 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, + 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x33, 0x34, + 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, + 0x45, 0x46, 0x47, 0x48, 0x48, 0x49, 0x4a, 0x4b, + 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, + 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, + 0x5c, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, + 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x71, + 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79 +}; diff --git a/contrib/ntp/libntp/tvtoa.c b/contrib/ntp/libntp/tvtoa.c new file mode 100644 index 0000000..19d4a94 --- /dev/null +++ b/contrib/ntp/libntp/tvtoa.c @@ -0,0 +1,39 @@ +/* + * tvtoa - return an asciized representation of a struct timeval + */ + +#include "lib_strbuf.h" + +#if defined(VMS) +# include "ntp_fp.h" +#endif /* VMS */ +#include "ntp_stdlib.h" +#include "ntp_unixtime.h" + +#include <stdio.h> + +char * +tvtoa( + const struct timeval *tv + ) +{ + register char *buf; + register u_long sec; + register u_long usec; + register int isneg; + + if (tv->tv_sec < 0 || tv->tv_usec < 0) { + sec = -tv->tv_sec; + usec = -tv->tv_usec; + isneg = 1; + } else { + sec = tv->tv_sec; + usec = tv->tv_usec; + isneg = 0; + } + + LIB_GETBUF(buf); + + (void) sprintf(buf, "%s%lu.%06lu", (isneg?"-":""), sec, usec); + return buf; +} diff --git a/contrib/ntp/libntp/tvtots.c b/contrib/ntp/libntp/tvtots.c new file mode 100644 index 0000000..0bd2b69 --- /dev/null +++ b/contrib/ntp/libntp/tvtots.c @@ -0,0 +1,159 @@ +/* + * tvtots - tables for converting from Unix struct timeval's to + * NTP time stamp format. + */ +#include <sys/types.h> + +#include "ntp_types.h" + +/* + * Tables to calculate time stamp fractions from usecs. The entries + * in these tables are offset into using each of the two low order + * bytes plus the next 4 bits in a usec value (from a struct timeval). + * These are summed to produce the time stamp fraction. + * + * Note that these tables are rounded (not truncated) to the nearest + * low order bit in the fraction. The timestamp computed should be + * +- 1.5 low order bits. + */ + +u_long ustotslo[256] = { + 0x00000000, 0x000010c7, 0x0000218e, 0x00003255, + 0x0000431c, 0x000053e3, 0x000064aa, 0x00007571, + 0x00008638, 0x000096ff, 0x0000a7c6, 0x0000b88d, + 0x0000c954, 0x0000da1b, 0x0000eae2, 0x0000fba9, + 0x00010c6f, 0x00011d36, 0x00012dfd, 0x00013ec4, + 0x00014f8b, 0x00016052, 0x00017119, 0x000181e0, + 0x000192a7, 0x0001a36e, 0x0001b435, 0x0001c4fc, + 0x0001d5c3, 0x0001e68a, 0x0001f751, 0x00020818, + 0x000218df, 0x000229a6, 0x00023a6d, 0x00024b34, + 0x00025bfb, 0x00026cc2, 0x00027d89, 0x00028e50, + 0x00029f17, 0x0002afde, 0x0002c0a5, 0x0002d16c, + 0x0002e233, 0x0002f2fa, 0x000303c0, 0x00031487, + 0x0003254e, 0x00033615, 0x000346dc, 0x000357a3, + 0x0003686a, 0x00037931, 0x000389f8, 0x00039abf, + 0x0003ab86, 0x0003bc4d, 0x0003cd14, 0x0003dddb, + 0x0003eea2, 0x0003ff69, 0x00041030, 0x000420f7, + 0x000431be, 0x00044285, 0x0004534c, 0x00046413, + 0x000474da, 0x000485a1, 0x00049668, 0x0004a72f, + 0x0004b7f6, 0x0004c8bd, 0x0004d984, 0x0004ea4b, + 0x0004fb12, 0x00050bd8, 0x00051c9f, 0x00052d66, + 0x00053e2d, 0x00054ef4, 0x00055fbb, 0x00057082, + 0x00058149, 0x00059210, 0x0005a2d7, 0x0005b39e, + 0x0005c465, 0x0005d52c, 0x0005e5f3, 0x0005f6ba, + 0x00060781, 0x00061848, 0x0006290f, 0x000639d6, + 0x00064a9d, 0x00065b64, 0x00066c2b, 0x00067cf2, + 0x00068db9, 0x00069e80, 0x0006af47, 0x0006c00e, + 0x0006d0d5, 0x0006e19c, 0x0006f263, 0x00070329, + 0x000713f0, 0x000724b7, 0x0007357e, 0x00074645, + 0x0007570c, 0x000767d3, 0x0007789a, 0x00078961, + 0x00079a28, 0x0007aaef, 0x0007bbb6, 0x0007cc7d, + 0x0007dd44, 0x0007ee0b, 0x0007fed2, 0x00080f99, + 0x00082060, 0x00083127, 0x000841ee, 0x000852b5, + 0x0008637c, 0x00087443, 0x0008850a, 0x000895d1, + 0x0008a698, 0x0008b75f, 0x0008c826, 0x0008d8ed, + 0x0008e9b4, 0x0008fa7b, 0x00090b41, 0x00091c08, + 0x00092ccf, 0x00093d96, 0x00094e5d, 0x00095f24, + 0x00096feb, 0x000980b2, 0x00099179, 0x0009a240, + 0x0009b307, 0x0009c3ce, 0x0009d495, 0x0009e55c, + 0x0009f623, 0x000a06ea, 0x000a17b1, 0x000a2878, + 0x000a393f, 0x000a4a06, 0x000a5acd, 0x000a6b94, + 0x000a7c5b, 0x000a8d22, 0x000a9de9, 0x000aaeb0, + 0x000abf77, 0x000ad03e, 0x000ae105, 0x000af1cc, + 0x000b0292, 0x000b1359, 0x000b2420, 0x000b34e7, + 0x000b45ae, 0x000b5675, 0x000b673c, 0x000b7803, + 0x000b88ca, 0x000b9991, 0x000baa58, 0x000bbb1f, + 0x000bcbe6, 0x000bdcad, 0x000bed74, 0x000bfe3b, + 0x000c0f02, 0x000c1fc9, 0x000c3090, 0x000c4157, + 0x000c521e, 0x000c62e5, 0x000c73ac, 0x000c8473, + 0x000c953a, 0x000ca601, 0x000cb6c8, 0x000cc78f, + 0x000cd856, 0x000ce91d, 0x000cf9e4, 0x000d0aaa, + 0x000d1b71, 0x000d2c38, 0x000d3cff, 0x000d4dc6, + 0x000d5e8d, 0x000d6f54, 0x000d801b, 0x000d90e2, + 0x000da1a9, 0x000db270, 0x000dc337, 0x000dd3fe, + 0x000de4c5, 0x000df58c, 0x000e0653, 0x000e171a, + 0x000e27e1, 0x000e38a8, 0x000e496f, 0x000e5a36, + 0x000e6afd, 0x000e7bc4, 0x000e8c8b, 0x000e9d52, + 0x000eae19, 0x000ebee0, 0x000ecfa7, 0x000ee06e, + 0x000ef135, 0x000f01fb, 0x000f12c2, 0x000f2389, + 0x000f3450, 0x000f4517, 0x000f55de, 0x000f66a5, + 0x000f776c, 0x000f8833, 0x000f98fa, 0x000fa9c1, + 0x000fba88, 0x000fcb4f, 0x000fdc16, 0x000fecdd, + 0x000ffda4, 0x00100e6b, 0x00101f32, 0x00102ff9, + 0x001040c0, 0x00105187, 0x0010624e, 0x00107315, + 0x001083dc, 0x001094a3, 0x0010a56a, 0x0010b631, +}; + +u_long ustotsmid[256] = { + 0x00000000, 0x0010c6f8, 0x00218def, 0x003254e7, + 0x00431bde, 0x0053e2d6, 0x0064a9ce, 0x007570c5, + 0x008637bd, 0x0096feb4, 0x00a7c5ac, 0x00b88ca4, + 0x00c9539b, 0x00da1a93, 0x00eae18a, 0x00fba882, + 0x010c6f7a, 0x011d3671, 0x012dfd69, 0x013ec460, + 0x014f8b58, 0x01605250, 0x01711947, 0x0181e03f, + 0x0192a736, 0x01a36e2e, 0x01b43526, 0x01c4fc1d, + 0x01d5c315, 0x01e68a0c, 0x01f75104, 0x020817fc, + 0x0218def3, 0x0229a5eb, 0x023a6ce3, 0x024b33da, + 0x025bfad2, 0x026cc1c9, 0x027d88c1, 0x028e4fb9, + 0x029f16b0, 0x02afdda8, 0x02c0a49f, 0x02d16b97, + 0x02e2328f, 0x02f2f986, 0x0303c07e, 0x03148775, + 0x03254e6d, 0x03361565, 0x0346dc5c, 0x0357a354, + 0x03686a4b, 0x03793143, 0x0389f83b, 0x039abf32, + 0x03ab862a, 0x03bc4d21, 0x03cd1419, 0x03dddb11, + 0x03eea208, 0x03ff6900, 0x04102ff7, 0x0420f6ef, + 0x0431bde7, 0x044284de, 0x04534bd6, 0x046412cd, + 0x0474d9c5, 0x0485a0bd, 0x049667b4, 0x04a72eac, + 0x04b7f5a3, 0x04c8bc9b, 0x04d98393, 0x04ea4a8a, + 0x04fb1182, 0x050bd879, 0x051c9f71, 0x052d6669, + 0x053e2d60, 0x054ef458, 0x055fbb4f, 0x05708247, + 0x0581493f, 0x05921036, 0x05a2d72e, 0x05b39e25, + 0x05c4651d, 0x05d52c15, 0x05e5f30c, 0x05f6ba04, + 0x060780fb, 0x061847f3, 0x06290eeb, 0x0639d5e2, + 0x064a9cda, 0x065b63d2, 0x066c2ac9, 0x067cf1c1, + 0x068db8b8, 0x069e7fb0, 0x06af46a8, 0x06c00d9f, + 0x06d0d497, 0x06e19b8e, 0x06f26286, 0x0703297e, + 0x0713f075, 0x0724b76d, 0x07357e64, 0x0746455c, + 0x07570c54, 0x0767d34b, 0x07789a43, 0x0789613a, + 0x079a2832, 0x07aaef2a, 0x07bbb621, 0x07cc7d19, + 0x07dd4410, 0x07ee0b08, 0x07fed200, 0x080f98f7, + 0x08205fef, 0x083126e6, 0x0841edde, 0x0852b4d6, + 0x08637bcd, 0x087442c5, 0x088509bc, 0x0895d0b4, + 0x08a697ac, 0x08b75ea3, 0x08c8259b, 0x08d8ec92, + 0x08e9b38a, 0x08fa7a82, 0x090b4179, 0x091c0871, + 0x092ccf68, 0x093d9660, 0x094e5d58, 0x095f244f, + 0x096feb47, 0x0980b23e, 0x09917936, 0x09a2402e, + 0x09b30725, 0x09c3ce1d, 0x09d49514, 0x09e55c0c, + 0x09f62304, 0x0a06e9fb, 0x0a17b0f3, 0x0a2877ea, + 0x0a393ee2, 0x0a4a05da, 0x0a5accd1, 0x0a6b93c9, + 0x0a7c5ac1, 0x0a8d21b8, 0x0a9de8b0, 0x0aaeafa7, + 0x0abf769f, 0x0ad03d97, 0x0ae1048e, 0x0af1cb86, + 0x0b02927d, 0x0b135975, 0x0b24206d, 0x0b34e764, + 0x0b45ae5c, 0x0b567553, 0x0b673c4b, 0x0b780343, + 0x0b88ca3a, 0x0b999132, 0x0baa5829, 0x0bbb1f21, + 0x0bcbe619, 0x0bdcad10, 0x0bed7408, 0x0bfe3aff, + 0x0c0f01f7, 0x0c1fc8ef, 0x0c308fe6, 0x0c4156de, + 0x0c521dd5, 0x0c62e4cd, 0x0c73abc5, 0x0c8472bc, + 0x0c9539b4, 0x0ca600ab, 0x0cb6c7a3, 0x0cc78e9b, + 0x0cd85592, 0x0ce91c8a, 0x0cf9e381, 0x0d0aaa79, + 0x0d1b7171, 0x0d2c3868, 0x0d3cff60, 0x0d4dc657, + 0x0d5e8d4f, 0x0d6f5447, 0x0d801b3e, 0x0d90e236, + 0x0da1a92d, 0x0db27025, 0x0dc3371d, 0x0dd3fe14, + 0x0de4c50c, 0x0df58c03, 0x0e0652fb, 0x0e1719f3, + 0x0e27e0ea, 0x0e38a7e2, 0x0e496ed9, 0x0e5a35d1, + 0x0e6afcc9, 0x0e7bc3c0, 0x0e8c8ab8, 0x0e9d51b0, + 0x0eae18a7, 0x0ebedf9f, 0x0ecfa696, 0x0ee06d8e, + 0x0ef13486, 0x0f01fb7d, 0x0f12c275, 0x0f23896c, + 0x0f345064, 0x0f45175c, 0x0f55de53, 0x0f66a54b, + 0x0f776c42, 0x0f88333a, 0x0f98fa32, 0x0fa9c129, + 0x0fba8821, 0x0fcb4f18, 0x0fdc1610, 0x0fecdd08, + 0x0ffda3ff, 0x100e6af7, 0x101f31ee, 0x102ff8e6, + 0x1040bfde, 0x105186d5, 0x10624dcd, 0x107314c4, + 0x1083dbbc, 0x1094a2b4, 0x10a569ab, 0x10b630a3, +}; + +u_long ustotshi[16] = { + 0x00000000, 0x10c6f79a, 0x218def35, 0x3254e6cf, + 0x431bde6a, 0x53e2d604, 0x64a9cd9f, 0x7570c539, + 0x8637bcd3, 0x96feb46e, 0xa7c5ac08, 0xb88ca3a3, + 0xc9539b3d, 0xda1a92d7, 0xeae18a72, 0xfba8820c, +}; diff --git a/contrib/ntp/libntp/uglydate.c b/contrib/ntp/libntp/uglydate.c new file mode 100644 index 0000000..676a5fd --- /dev/null +++ b/contrib/ntp/libntp/uglydate.c @@ -0,0 +1,48 @@ +/* + * uglydate - convert a time stamp to something barely readable + * The string returned is 37 characters long. + */ +#include <stdio.h> + +#include "ntp_fp.h" +#include "ntp_unixtime.h" +#include "lib_strbuf.h" +#include "ntp_stdlib.h" + + +char * +uglydate( + l_fp *ts + ) +{ + char *bp; + char *timep; + struct tm *tm; + time_t sec; + long msec; + int year; + + timep = ulfptoa(ts, 6); /* returns max 17 characters */ + LIB_GETBUF(bp); + sec = ts->l_ui - JAN_1970; + msec = ts->l_uf / 4294967; /* fract / (2**32/1000) */ + tm = gmtime(&sec); + if (ts->l_ui == 0) { + /* + * Probably not a real good thing to do. Oh, well. + */ + year = 0; + tm->tm_yday = 0; + tm->tm_hour = 0; + tm->tm_min = 0; + tm->tm_sec = 0; + } else { + year = tm->tm_year; + while (year >= 100) + year -= 100; + } + (void) sprintf(bp, "%17s %02d:%03d:%02d:%02d:%02d.%03ld", + timep, year, tm->tm_yday, tm->tm_hour, tm->tm_min, + tm->tm_sec, msec); + return bp; +} diff --git a/contrib/ntp/libntp/uinttoa.c b/contrib/ntp/libntp/uinttoa.c new file mode 100644 index 0000000..be48ea5 --- /dev/null +++ b/contrib/ntp/libntp/uinttoa.c @@ -0,0 +1,20 @@ +/* + * uinttoa - return an asciized unsigned integer + */ +#include <stdio.h> + +#include "lib_strbuf.h" +#include "ntp_stdlib.h" + +char * +uinttoa( + u_long uval + ) +{ + register char *buf; + + LIB_GETBUF(buf); + + (void) sprintf(buf, "%lu", (u_long)uval); + return buf; +} diff --git a/contrib/ntp/libntp/utvtoa.c b/contrib/ntp/libntp/utvtoa.c new file mode 100644 index 0000000..a441c49 --- /dev/null +++ b/contrib/ntp/libntp/utvtoa.c @@ -0,0 +1,26 @@ +/* + * utvtoa - return an asciized representation of an unsigned struct timeval + */ +#include <stdio.h> + +#include "lib_strbuf.h" + +#if defined(VMS) +# include "ntp_fp.h" +#endif +#include "ntp_stdlib.h" +#include "ntp_unixtime.h" + +char * +utvtoa( + const struct timeval *tv + ) +{ + register char *buf; + + LIB_GETBUF(buf); + + (void) sprintf(buf, "%lu.%06lu", (u_long)tv->tv_sec, + (u_long)tv->tv_usec); + return buf; +} diff --git a/contrib/ntp/libntp/ymd2yd.c b/contrib/ntp/libntp/ymd2yd.c new file mode 100644 index 0000000..796ce40 --- /dev/null +++ b/contrib/ntp/libntp/ymd2yd.c @@ -0,0 +1,37 @@ +/* + * ymd2yd - compute the date in the year from y/m/d + */ + +#include "ntp_fp.h" +#include "ntp_unixtime.h" +#include "ntp_stdlib.h" + +/* + * Tables to compute the day of year from yyyymmdd timecode. + * Viva la leap. + */ +static int day1tab[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; +static int day2tab[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + +int +ymd2yd( + int y, + int m, + int d + ) +{ + int i, *t; + + if (m < 1 || m > 12 || d < 1) + return (-1); + + if (((y%4 == 0) && (y%100 != 0)) || (y%400 == 0)) + t = day2tab; /* leap year */ + else + t = day1tab; /* not a leap year */ + if (d > t[m - 1]) + return (-1); + for (i = 0; i < m - 1; i++) + d += t[i]; + return d; +} |