From b5b40f9e420899251189775800d9f74092925299 Mon Sep 17 00:00:00 2001 From: roberto Date: Fri, 28 Jan 2000 14:55:50 +0000 Subject: Virgin import of ntpd 4.0.99b --- contrib/ntp/ntpdate/Makefile.in | 108 +++++++++++++++++++++------------------- contrib/ntp/ntpdate/ntpdate.c | 104 ++++++++++++++++++++++---------------- 2 files changed, 118 insertions(+), 94 deletions(-) (limited to 'contrib/ntp/ntpdate') diff --git a/contrib/ntp/ntpdate/Makefile.in b/contrib/ntp/ntpdate/Makefile.in index 80d0232..c913235 100644 --- a/contrib/ntp/ntpdate/Makefile.in +++ b/contrib/ntp/ntpdate/Makefile.in @@ -63,15 +63,18 @@ host_alias = @host_alias@ host_triplet = @host@ target_alias = @target_alias@ target_triplet = @target@ +AMDEP = @AMDEP@ AMTAR = @AMTAR@ -AMTARFLAGS = @AMTARFLAGS@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CHUTEST = @CHUTEST@ CLKTEST = @CLKTEST@ CPP = @CPP@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ DCFD = @DCFD@ +DEPDIR = @DEPDIR@ LDFLAGS = @LDFLAGS@ LIBPARSE = @LIBPARSE@ LIBRSAREF = @LIBRSAREF@ @@ -93,6 +96,7 @@ RSAREF = @RSAREF@ TESTDCF = @TESTDCF@ U = @U@ VERSION = @VERSION@ +install_sh = @install_sh@ #AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies @@ -140,6 +144,9 @@ DIST_COMMON = README $(noinst_HEADERS) Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) GZIP_ENV = --best +depcomp = $(SHELL) $(top_srcdir)/depcomp +DEP_FILES = @AMDEP@ $(DEPDIR)/ntpdate$U.Po \ +$(DEPDIR)/ntptime_config$U.Po $(DEPDIR)/ntptimeset$U.Po SOURCES = ntpdate.c $(ntptimeset_SOURCES) OBJECTS = ntpdate$U.o $(am_ntptimeset_OBJECTS) @@ -147,9 +154,9 @@ all: all-redirect .SUFFIXES: .SUFFIXES: .c .o $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps ntpdate/Makefile + cd $(top_srcdir) && $(AUTOMAKE) --gnu ntpdate/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -182,9 +189,6 @@ uninstall-binPROGRAMS: rm -f $(DESTDIR)$(bindir)/$$f; \ done -.c.o: - $(COMPILE) -c $< - mostlyclean-compile: -rm -f *.o core *.core @@ -209,13 +213,10 @@ clean-kr: distclean-kr: maintainer-clean-kr: -ntpdate$U.o: ntpdate: $(ntpdate_OBJECTS) $(ntpdate_DEPENDENCIES) @rm -f ntpdate $(LINK) $(ntpdate_LDFLAGS) $(ntpdate_OBJECTS) $(ntpdate_LDADD) $(LIBS) -ntptimeset$U.o: -ntptime_config$U.o: ntptimeset: $(ntptimeset_OBJECTS) $(ntptimeset_DEPENDENCIES) @rm -f ntptimeset @@ -230,23 +231,27 @@ ntpdate_.o ntptime_config_.o ntptimeset_.o : $(ANSI2KNR) tags: TAGS -ID: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - ${AWK:-awk} ' { files[$$0] = 1; } \ +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(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; }'`; \ - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $$unique $(LISP) + mkid -f$$here/ID $$unique $(LISP) -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - ${AWK:-awk} ' { files[$$0] = 1; } \ + list='$(SOURCES) $(HEADERS) $(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 "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) mostlyclean-tags: @@ -263,35 +268,34 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ + cp -pR $$d/$$file $(distdir); \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done -ntpdate.o: ntpdate.c ../config.h ../include/ntp_fp.h \ - ../include/ntp_types.h ../include/ntp_machine.h \ - ../include/ntp_proto.h ../include/ntp.h ../include/ntp_io.h \ - ../include/ntp_unixtime.h ntpdate.h ../include/ntp_malloc.h \ - ../include/ntp_string.h ../include/ntp_syslog.h \ - ../include/ntp_select.h ../include/ntp_stdlib.h \ - ../include/l_stdlib.h ../include/recvbuff.h -ntptime_config.o: ntptime_config.c ../config.h ../include/ntp_fp.h \ - ../include/ntp_types.h ../include/ntp_machine.h \ - ../include/ntp_proto.h ../include/ntp.h ../include/ntp_io.h \ - ../include/ntp_unixtime.h ../include/ntp_filegen.h ntpdate.h \ - ../include/ntp_malloc.h ../include/ntp_syslog.h \ - ../include/ntp_stdlib.h ../include/ntp_string.h \ - ../include/l_stdlib.h -ntptimeset.o: ntptimeset.c ../config.h ../include/ntp_fp.h \ - ../include/ntp_types.h ../include/ntp_machine.h \ - ../include/ntp_proto.h ../include/ntp.h ../include/ntp_io.h \ - ../include/iosignal.h ../include/ntp_refclock.h \ - ../include/recvbuff.h ../include/ntp_unixtime.h ntpdate.h \ - ../include/ntp_malloc.h ../include/ntp_string.h \ - ../include/ntp_syslog.h ../include/ntp_select.h \ - ../include/ntp_stdlib.h ../include/l_stdlib.h + +@AMDEP@include $(DEPDIR)/ntpdate$U.Po +@AMDEP@include $(DEPDIR)/ntptime_config$U.Po +@AMDEP@include $(DEPDIR)/ntptimeset$U.Po + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf $(DEPDIR) + +maintainer-clean-depend: + +@AMDEP@CCDEPMODE = @CCDEPMODE@ + +.c.o: +@AMDEP@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c -o $@ $< info-am: info: info-am @@ -330,25 +334,28 @@ distclean-generic: -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: + -rm -f Makefile.in mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ - mostlyclean-kr mostlyclean-tags mostlyclean-generic + mostlyclean-kr mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-binPROGRAMS clean-compile clean-kr clean-tags \ - clean-generic mostlyclean-am + clean-depend clean-generic mostlyclean-am clean: clean-am distclean-am: distclean-binPROGRAMS distclean-compile distclean-kr \ - distclean-tags distclean-generic clean-am + distclean-tags distclean-depend distclean-generic \ + clean-am distclean: distclean-am maintainer-clean-am: maintainer-clean-binPROGRAMS \ maintainer-clean-compile maintainer-clean-kr \ - maintainer-clean-tags maintainer-clean-generic \ - distclean-am + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." @@ -359,8 +366,9 @@ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile mostlyclean-kr distclean-kr clean-kr \ maintainer-clean-kr tags mostlyclean-tags distclean-tags clean-tags \ -maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \ -installcheck-am installcheck install-exec-am install-exec \ +maintainer-clean-tags distdir mostlyclean-depend distclean-depend \ +clean-depend maintainer-clean-depend info-am info dvi-am dvi check \ +check-am installcheck-am installcheck install-exec-am install-exec \ install-data-am install-data install-am install uninstall-am uninstall \ all-redirect all-am all install-strip installdirs mostlyclean-generic \ distclean-generic clean-generic maintainer-clean-generic clean \ diff --git a/contrib/ntp/ntpdate/ntpdate.c b/contrib/ntp/ntpdate/ntpdate.c index 023b649..e79b73e 100644 --- a/contrib/ntp/ntpdate/ntpdate.c +++ b/contrib/ntp/ntpdate/ntpdate.c @@ -142,9 +142,8 @@ char *progname; */ int sys_samples = DEFSAMPLES; /* number of samples/server */ u_long sys_timeout = DEFTIMEOUT; /* timeout time, in TIMER_HZ units */ -struct server **sys_servers; /* the server list */ +struct server *sys_servers; /* the server list */ int sys_numservers = 0; /* number of servers to poll */ -int sys_maxservers = 0; /* max number of servers to deal with */ int sys_authenticate = 0; /* true when authenticating */ u_int32 sys_authkey = 0; /* set to authentication key in use */ u_long sys_authdelay = 0; /* authentication delay */ @@ -256,7 +255,6 @@ void clear_globals() * Systemwide parameters and flags */ sys_numservers = 0; /* number of servers to poll */ - sys_maxservers = 0; /* max number of servers to deal with */ sys_authenticate = 0; /* true when authenticating */ sys_authkey = 0; /* set to authentication key in use */ sys_authdelay = 0; /* authentication delay */ @@ -472,13 +470,9 @@ ntpdatemain ( /* * Add servers we are going to be polling */ - sys_maxservers = argc - ntp_optind; #ifdef HAVE_NETINFO - if ((netinfoservers = getnetinfoservers())) - sys_maxservers += netinfoservers->ni_namelist_len; + inetinfoservers = getnetinfoservers(); #endif - sys_servers = (struct server **) - emalloc(sys_maxservers * sizeof(struct server *)); for ( ; ntp_optind < argc; ntp_optind++) addserver(argv[ntp_optind]); @@ -1025,8 +1019,7 @@ clock_select(void) * NTP_MAXLIST of them. */ nlist = 0; /* none yet */ - for (n = 0; n < sys_numservers; n++) { - server = sys_servers[n]; + for (server = sys_servers; server != NULL; server = server->next_server) { if (server->delay == 0) continue; /* no data */ if (server->stratum > NTP_INFIN) @@ -1201,18 +1194,17 @@ clock_select(void) static int clock_adjust(void) { - register int i; - register struct server *server; + register struct server *sp, *server; s_fp absoffset; int dostep; - for (i = 0; i < sys_numservers; i++) - clock_filter(sys_servers[i]); + for (sp = sys_servers; sp != NULL; sp = sp->next_server) + clock_filter(sp); server = clock_select(); if (debug || simple_query) { - for (i = 0; i < sys_numservers; i++) - printserver(sys_servers[i], stdout); + for (sp = sys_servers; sp != NULL; sp = sp->next_server) + printserver(sp, stdout); } if (server == 0) { @@ -1275,21 +1267,6 @@ addserver( { register struct server *server; u_int32 netnum; - static int toomany = 0; - - if (sys_numservers >= sys_maxservers) { - if (!toomany) { - /* - * This is actually a `can't happen' now. Leave - * the error message in anyway, though - */ - toomany = 1; - msyslog(LOG_ERR, - "too many servers (> %d) specified, remainder not used", - sys_maxservers); - } - return; - } if (!getnetnum(serv, &netnum)) { msyslog(LOG_ERR, "can't find host %s\n", serv); @@ -1303,8 +1280,16 @@ addserver( server->srcadr.sin_addr.s_addr = netnum; server->srcadr.sin_port = htons(NTP_PORT); - sys_servers[sys_numservers++] = server; - server->event_time = sys_numservers; + server->event_time = ++sys_numservers; + if (sys_servers == NULL) + sys_servers = server; + else { + struct server *sp; + + for (sp = sys_servers; sp->next_server != NULL; + sp = sp->next_server) ; + sp->next_server = server; + } } @@ -1316,18 +1301,47 @@ findserver( struct sockaddr_in *addr ) { - register int i; register u_int32 netnum; + struct server *server; + struct server *mc_server; + mc_server = NULL; if (htons(addr->sin_port) != NTP_PORT) return 0; netnum = addr->sin_addr.s_addr; - for (i = 0; i < sys_numservers; i++) { - if (netnum == sys_servers[i]->srcadr.sin_addr.s_addr) - return sys_servers[i]; + for (server = sys_servers; server != NULL; + server = server->next_server) { + register u_int32 servnum; + + servnum = server->srcadr.sin_addr.s_addr; + if (netnum == servnum) + return server; + if (IN_MULTICAST(ntohl(servnum))) + mc_server = server; + } + + if (mc_server != NULL) { + struct server *sp; + + if (mc_server->event_time != 0) { + mc_server->event_time = 0; + complete_servers++; + } + server = (struct server *)emalloc(sizeof(struct server)); + memset((char *)server, 0, sizeof(struct server)); + + server->srcadr.sin_family = AF_INET; + server->srcadr.sin_addr.s_addr = netnum; + server->srcadr.sin_port = htons(NTP_PORT); + + server->event_time = ++sys_numservers; + for (sp = sys_servers; sp->next_server != NULL; + sp = sp->next_server) ; + sp->next_server = server; + transmit(server); } - return 0; + return NULL; } @@ -1337,7 +1351,7 @@ findserver( void timer(void) { - register int i; + struct server *server; /* * Bump the current idea of the time @@ -1349,10 +1363,11 @@ timer(void) * who's event timers have expired. Give these to * the transmit routine. */ - for (i = 0; i < sys_numservers; i++) { - if (sys_servers[i]->event_time != 0 - && sys_servers[i]->event_time <= current_time) - transmit(sys_servers[i]); + for (server = sys_servers; server != NULL; + server = server->next_server) { + if (server->event_time != 0 + && server->event_time <= current_time) + transmit(server); } } @@ -1826,7 +1841,8 @@ l_step_systime( isneg = 0; if (ftmp.l_ui >= 3) { /* Step it and slew - we might win */ - n = step_systime(ts); + LFPTOD(ts, dtemp); + n = step_systime(dtemp); if (!n) return n; if (isneg) -- cgit v1.1