diff options
Diffstat (limited to 'ntpd')
48 files changed, 10419 insertions, 5374 deletions
diff --git a/ntpd/Makefile.am b/ntpd/Makefile.am index 344ac8eb2ce7d..c94f7c09edf64 100644 --- a/ntpd/Makefile.am +++ b/ntpd/Makefile.am @@ -232,6 +232,7 @@ libntpd_a_SOURCES = \ ntp_timer.c \ ntp_util.c \ ppsapi_timepps.h \ + rc_cmdlength.c \ refclock_acts.c \ refclock_arbiter.c \ refclock_arc.c \ diff --git a/ntpd/Makefile.in b/ntpd/Makefile.in index 0eccb11c02523..47c59c6957944 100644 --- a/ntpd/Makefile.in +++ b/ntpd/Makefile.in @@ -1,9 +1,8 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# Copyright (C) 1994-2014 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. @@ -23,6 +22,61 @@ VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -43,11 +97,6 @@ build_triplet = @build@ host_triplet = @host@ EXTRA_PROGRAMS = check_y2k$(EXEEXT) keyword-gen$(EXEEXT) ntpd$(EXEEXT) \ ntpdsim$(EXEEXT) -DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(srcdir)/complete.conf.in \ - $(top_srcdir)/bincheck.mf $(top_srcdir)/check-libopts.mf \ - $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf \ - $(top_srcdir)/sntp/check-libntp.mf ntp_parser.c ntp_parser.h subdir = ntpd ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ @@ -79,6 +128,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ + $(top_srcdir)/sntp/m4/ntp_unitytest.m4 \ $(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \ $(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \ @@ -88,18 +138,18 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ + $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = complete.conf CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru -AM_V_AR = $(am__v_AR_$(V)) -am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY)) -am__v_AR_0 = @echo " AR " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ +AM_V_AR = $(am__v_AR_@AM_V@) +am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) +am__v_AR_0 = @echo " AR " $@; +am__v_AR_1 = libntpd_a_AR = $(AR) $(ARFLAGS) libntpd_a_LIBADD = am__objects_1 = @@ -109,28 +159,28 @@ am_libntpd_a_OBJECTS = cmd_args.$(OBJEXT) ntp_control.$(OBJEXT) \ ntp_monitor.$(OBJEXT) ntp_peer.$(OBJEXT) ntp_proto.$(OBJEXT) \ ntp_refclock.$(OBJEXT) ntp_request.$(OBJEXT) \ ntp_restrict.$(OBJEXT) ntp_signd.$(OBJEXT) ntp_timer.$(OBJEXT) \ - ntp_util.$(OBJEXT) refclock_acts.$(OBJEXT) \ - refclock_arbiter.$(OBJEXT) refclock_arc.$(OBJEXT) \ - refclock_as2201.$(OBJEXT) refclock_atom.$(OBJEXT) \ - refclock_bancomm.$(OBJEXT) refclock_chronolog.$(OBJEXT) \ - refclock_chu.$(OBJEXT) refclock_conf.$(OBJEXT) \ - refclock_datum.$(OBJEXT) refclock_dumbclock.$(OBJEXT) \ - refclock_fg.$(OBJEXT) refclock_gpsdjson.$(OBJEXT) \ - refclock_gpsvme.$(OBJEXT) refclock_heath.$(OBJEXT) \ - refclock_hopfser.$(OBJEXT) refclock_hopfpci.$(OBJEXT) \ - refclock_hpgps.$(OBJEXT) refclock_irig.$(OBJEXT) \ - refclock_jjy.$(OBJEXT) refclock_jupiter.$(OBJEXT) \ - refclock_leitch.$(OBJEXT) refclock_local.$(OBJEXT) \ - refclock_mx4200.$(OBJEXT) refclock_neoclock4x.$(OBJEXT) \ - refclock_nmea.$(OBJEXT) refclock_oncore.$(OBJEXT) \ - refclock_palisade.$(OBJEXT) refclock_parse.$(OBJEXT) \ - refclock_pcf.$(OBJEXT) refclock_pst.$(OBJEXT) \ - refclock_ripencc.$(OBJEXT) refclock_shm.$(OBJEXT) \ - refclock_tpro.$(OBJEXT) refclock_true.$(OBJEXT) \ - refclock_tt560.$(OBJEXT) refclock_ulink.$(OBJEXT) \ - refclock_wwv.$(OBJEXT) refclock_wwvb.$(OBJEXT) \ - refclock_zyfer.$(OBJEXT) refclock_tsyncpci.$(OBJEXT) \ - $(am__objects_1) + ntp_util.$(OBJEXT) rc_cmdlength.$(OBJEXT) \ + refclock_acts.$(OBJEXT) refclock_arbiter.$(OBJEXT) \ + refclock_arc.$(OBJEXT) refclock_as2201.$(OBJEXT) \ + refclock_atom.$(OBJEXT) refclock_bancomm.$(OBJEXT) \ + refclock_chronolog.$(OBJEXT) refclock_chu.$(OBJEXT) \ + refclock_conf.$(OBJEXT) refclock_datum.$(OBJEXT) \ + refclock_dumbclock.$(OBJEXT) refclock_fg.$(OBJEXT) \ + refclock_gpsdjson.$(OBJEXT) refclock_gpsvme.$(OBJEXT) \ + refclock_heath.$(OBJEXT) refclock_hopfser.$(OBJEXT) \ + refclock_hopfpci.$(OBJEXT) refclock_hpgps.$(OBJEXT) \ + refclock_irig.$(OBJEXT) refclock_jjy.$(OBJEXT) \ + refclock_jupiter.$(OBJEXT) refclock_leitch.$(OBJEXT) \ + refclock_local.$(OBJEXT) refclock_mx4200.$(OBJEXT) \ + refclock_neoclock4x.$(OBJEXT) refclock_nmea.$(OBJEXT) \ + refclock_oncore.$(OBJEXT) refclock_palisade.$(OBJEXT) \ + refclock_parse.$(OBJEXT) refclock_pcf.$(OBJEXT) \ + refclock_pst.$(OBJEXT) refclock_ripencc.$(OBJEXT) \ + refclock_shm.$(OBJEXT) refclock_tpro.$(OBJEXT) \ + refclock_true.$(OBJEXT) refclock_tt560.$(OBJEXT) \ + refclock_ulink.$(OBJEXT) refclock_wwv.$(OBJEXT) \ + refclock_wwvb.$(OBJEXT) refclock_zyfer.$(OBJEXT) \ + refclock_tsyncpci.$(OBJEXT) $(am__objects_1) libntpd_a_OBJECTS = $(am_libntpd_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libexecdir)" \ "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man1dir)" \ @@ -144,9 +194,10 @@ am__DEPENDENCIES_2 = version.o libntpd.a $(am__DEPENDENCIES_1) check_y2k_DEPENDENCIES = $(am__DEPENDENCIES_2) ../libntp/libntp.a \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -AM_V_lt = $(am__v_lt_$(V)) -am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent +am__v_lt_1 = keyword_gen_SOURCES = keyword-gen.c keyword_gen_OBJECTS = keyword-gen.$(OBJEXT) keyword_gen_DEPENDENCIES = ../libntp/libntp.a $(am__DEPENDENCIES_1) \ @@ -169,6 +220,18 @@ am_ntpdsim_OBJECTS = $(am__objects_2) ntpdsim-ntp_prio_q.$(OBJEXT) \ ntpdsim_OBJECTS = $(am_ntpdsim_OBJECTS) ntpdsim_DEPENDENCIES = $(am__DEPENDENCIES_2) ../libntp/libntpsim.a \ $(am__DEPENDENCIES_3) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/sntp/libevent/build-aux/depcomp am__depfiles_maybe = depfiles @@ -179,30 +242,37 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_$(V)) -am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) -am__v_CC_0 = @echo " CC " $@; +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_$(V)) -am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) -am__v_CCLD_0 = @echo " CCLD " $@; -YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +am__yacc_c2h = sed -e s/cc$$/hh/ -e s/cpp$$/hpp/ -e s/cxx$$/hxx/ \ + -e s/c++$$/h++/ -e s/c$$/h/ +YACCCOMPILE = $(YACC) $(AM_YFLAGS) $(YFLAGS) LTYACCCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS) -AM_V_YACC = $(am__v_YACC_$(V)) -am__v_YACC_ = $(am__v_YACC_$(AM_DEFAULT_VERBOSITY)) -am__v_YACC_0 = @echo " YACC " $@; + $(LIBTOOLFLAGS) --mode=compile $(YACC) $(AM_YFLAGS) $(YFLAGS) +AM_V_YACC = $(am__v_YACC_@AM_V@) +am__v_YACC_ = $(am__v_YACC_@AM_DEFAULT_V@) +am__v_YACC_0 = @echo " YACC " $@; +am__v_YACC_1 = YLWRAP = $(top_srcdir)/sntp/libevent/build-aux/ylwrap -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libntpd_a_SOURCES) check_y2k.c keyword-gen.c \ $(ntpd_SOURCES) $(ntpdsim_SOURCES) DIST_SOURCES = $(libntpd_a_SOURCES) check_y2k.c keyword-gen.c \ $(ntpd_SOURCES) $(ntpdsim_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -224,6 +294,12 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } man1dir = $(mandir)/man1 man5dir = $(mandir)/man5 man8dir = $(mandir)/man8 @@ -231,8 +307,32 @@ NROFF = nroff MANS = $(man1_MANS) $(man5_MANS) $(man8_MANS) $(man_MANS) DATA = $(html_DATA) $(noinst_DATA) HEADERS = $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/complete.conf.in \ + $(top_srcdir)/bincheck.mf $(top_srcdir)/check-libopts.mf \ + $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf \ + $(top_srcdir)/sntp/check-libntp.mf \ + $(top_srcdir)/sntp/libevent/build-aux/depcomp \ + $(top_srcdir)/sntp/libevent/build-aux/ylwrap ntp_parser.c \ + ntp_parser.h DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ @@ -283,6 +383,7 @@ GTEST_CXXFLAGS = @GTEST_CXXFLAGS@ GTEST_LDFLAGS = @GTEST_LDFLAGS@ GTEST_LIBS = @GTEST_LIBS@ HAVE_INLINE = @HAVE_INLINE@ +HAVE_LEAPSMEARINTERVAL = @HAVE_LEAPSMEARINTERVAL@ HAVE_RLIMIT_MEMLOCK = @HAVE_RLIMIT_MEMLOCK@ HAVE_RLIMIT_STACK = @HAVE_RLIMIT_STACK@ INSTALL = @INSTALL@ @@ -399,6 +500,7 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@ PATH_PERL = @PATH_PERL@ +PATH_RUBY = @PATH_RUBY@ PATH_SEPARATOR = @PATH_SEPARATOR@ PATH_TEST = @PATH_TEST@ PERLLIBDIR = @PERLLIBDIR@ @@ -675,6 +777,7 @@ libntpd_a_SOURCES = \ ntp_timer.c \ ntp_util.c \ ppsapi_timepps.h \ + rc_cmdlength.c \ refclock_acts.c \ refclock_arbiter.c \ refclock_arc.c \ @@ -739,7 +842,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/bincheck.mf $(top_sr echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ntpd/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign ntpd/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -748,6 +850,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; +$(top_srcdir)/bincheck.mf $(top_srcdir)/check-libopts.mf $(top_srcdir)/sntp/check-libntp.mf $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf $(am__empty): $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh @@ -762,20 +865,26 @@ complete.conf: $(top_builddir)/config.status $(srcdir)/complete.conf.in clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) -libntpd.a: $(libntpd_a_OBJECTS) $(libntpd_a_DEPENDENCIES) + +libntpd.a: $(libntpd_a_OBJECTS) $(libntpd_a_DEPENDENCIES) $(EXTRA_libntpd_a_DEPENDENCIES) $(AM_V_at)-rm -f libntpd.a $(AM_V_AR)$(libntpd_a_AR) libntpd.a $(libntpd_a_OBJECTS) $(libntpd_a_LIBADD) $(AM_V_at)$(RANLIB) libntpd.a install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p || test -f $$p1; \ - then echo "$$p"; echo "$$p"; else :; fi; \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ - sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ @@ -796,7 +905,8 @@ uninstall-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' `; \ + -e 's/$$/$(EXEEXT)/' \ + `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files @@ -820,14 +930,19 @@ clean-checkPROGRAMS: rm -f $$list install-libexecPROGRAMS: $(libexec_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(libexecdir)" || $(MKDIR_P) "$(DESTDIR)$(libexecdir)" @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ + fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p || test -f $$p1; \ - then echo "$$p"; echo "$$p"; else :; fi; \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ - sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ @@ -848,7 +963,8 @@ uninstall-libexecPROGRAMS: @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' `; \ + -e 's/$$/$(EXEEXT)/' \ + `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(libexecdir)" && rm -f $$files @@ -863,14 +979,19 @@ clean-libexecPROGRAMS: rm -f $$list install-sbinPROGRAMS: $(sbin_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)" @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \ + fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p || test -f $$p1; \ - then echo "$$p"; echo "$$p"; else :; fi; \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ - sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ @@ -891,7 +1012,8 @@ uninstall-sbinPROGRAMS: @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' `; \ + -e 's/$$/$(EXEEXT)/' \ + `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(sbindir)" && rm -f $$files @@ -904,21 +1026,23 @@ clean-sbinPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list -check_y2k$(EXEEXT): $(check_y2k_OBJECTS) $(check_y2k_DEPENDENCIES) + +check_y2k$(EXEEXT): $(check_y2k_OBJECTS) $(check_y2k_DEPENDENCIES) $(EXTRA_check_y2k_DEPENDENCIES) @rm -f check_y2k$(EXEEXT) $(AM_V_CCLD)$(LINK) $(check_y2k_OBJECTS) $(check_y2k_LDADD) $(LIBS) -keyword-gen$(EXEEXT): $(keyword_gen_OBJECTS) $(keyword_gen_DEPENDENCIES) + +keyword-gen$(EXEEXT): $(keyword_gen_OBJECTS) $(keyword_gen_DEPENDENCIES) $(EXTRA_keyword_gen_DEPENDENCIES) @rm -f keyword-gen$(EXEEXT) $(AM_V_CCLD)$(LINK) $(keyword_gen_OBJECTS) $(keyword_gen_LDADD) $(LIBS) ntp_parser.h: ntp_parser.c - @if test ! -f $@; then \ - rm -f ntp_parser.c; \ - $(MAKE) $(AM_MAKEFLAGS) ntp_parser.c; \ - else :; fi -ntpd$(EXEEXT): $(ntpd_OBJECTS) $(ntpd_DEPENDENCIES) + @if test ! -f $@; then rm -f ntp_parser.c; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) ntp_parser.c; else :; fi + +ntpd$(EXEEXT): $(ntpd_OBJECTS) $(ntpd_DEPENDENCIES) $(EXTRA_ntpd_DEPENDENCIES) @rm -f ntpd$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ntpd_OBJECTS) $(ntpd_LDADD) $(LIBS) -ntpdsim$(EXEEXT): $(ntpdsim_OBJECTS) $(ntpdsim_DEPENDENCIES) + +ntpdsim$(EXEEXT): $(ntpdsim_OBJECTS) $(ntpdsim_DEPENDENCIES) $(EXTRA_ntpdsim_DEPENDENCIES) @rm -f ntpdsim$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ntpdsim_OBJECTS) $(ntpdsim_LDADD) $(LIBS) @@ -959,6 +1083,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdsim-ntpd-opts.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdsim-ntpd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdsim-ntpsim.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rc_cmdlength.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_acts.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_arbiter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_arc.Po@am__quote@ @@ -1004,157 +1129,138 @@ distclean-compile: .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< ntpdsim-ntp_config.o: ntp_config.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_config.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_config.Tpo -c -o ntpdsim-ntp_config.o `test -f 'ntp_config.c' || echo '$(srcdir)/'`ntp_config.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntp_config.Tpo $(DEPDIR)/ntpdsim-ntp_config.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntp_config.c' object='ntpdsim-ntp_config.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntp_config.c' object='ntpdsim-ntp_config.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_config.o `test -f 'ntp_config.c' || echo '$(srcdir)/'`ntp_config.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_config.o `test -f 'ntp_config.c' || echo '$(srcdir)/'`ntp_config.c ntpdsim-ntp_config.obj: ntp_config.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_config.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_config.Tpo -c -o ntpdsim-ntp_config.obj `if test -f 'ntp_config.c'; then $(CYGPATH_W) 'ntp_config.c'; else $(CYGPATH_W) '$(srcdir)/ntp_config.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntp_config.Tpo $(DEPDIR)/ntpdsim-ntp_config.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntp_config.c' object='ntpdsim-ntp_config.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntp_config.c' object='ntpdsim-ntp_config.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_config.obj `if test -f 'ntp_config.c'; then $(CYGPATH_W) 'ntp_config.c'; else $(CYGPATH_W) '$(srcdir)/ntp_config.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_config.obj `if test -f 'ntp_config.c'; then $(CYGPATH_W) 'ntp_config.c'; else $(CYGPATH_W) '$(srcdir)/ntp_config.c'; fi` ntpdsim-ntp_io.o: ntp_io.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_io.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_io.Tpo -c -o ntpdsim-ntp_io.o `test -f 'ntp_io.c' || echo '$(srcdir)/'`ntp_io.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntp_io.Tpo $(DEPDIR)/ntpdsim-ntp_io.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntp_io.c' object='ntpdsim-ntp_io.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntp_io.c' object='ntpdsim-ntp_io.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_io.o `test -f 'ntp_io.c' || echo '$(srcdir)/'`ntp_io.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_io.o `test -f 'ntp_io.c' || echo '$(srcdir)/'`ntp_io.c ntpdsim-ntp_io.obj: ntp_io.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_io.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_io.Tpo -c -o ntpdsim-ntp_io.obj `if test -f 'ntp_io.c'; then $(CYGPATH_W) 'ntp_io.c'; else $(CYGPATH_W) '$(srcdir)/ntp_io.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntp_io.Tpo $(DEPDIR)/ntpdsim-ntp_io.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntp_io.c' object='ntpdsim-ntp_io.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntp_io.c' object='ntpdsim-ntp_io.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_io.obj `if test -f 'ntp_io.c'; then $(CYGPATH_W) 'ntp_io.c'; else $(CYGPATH_W) '$(srcdir)/ntp_io.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_io.obj `if test -f 'ntp_io.c'; then $(CYGPATH_W) 'ntp_io.c'; else $(CYGPATH_W) '$(srcdir)/ntp_io.c'; fi` ntpdsim-ntp_parser.o: ntp_parser.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_parser.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_parser.Tpo -c -o ntpdsim-ntp_parser.o `test -f 'ntp_parser.c' || echo '$(srcdir)/'`ntp_parser.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntp_parser.Tpo $(DEPDIR)/ntpdsim-ntp_parser.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntp_parser.c' object='ntpdsim-ntp_parser.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntp_parser.c' object='ntpdsim-ntp_parser.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_parser.o `test -f 'ntp_parser.c' || echo '$(srcdir)/'`ntp_parser.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_parser.o `test -f 'ntp_parser.c' || echo '$(srcdir)/'`ntp_parser.c ntpdsim-ntp_parser.obj: ntp_parser.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_parser.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_parser.Tpo -c -o ntpdsim-ntp_parser.obj `if test -f 'ntp_parser.c'; then $(CYGPATH_W) 'ntp_parser.c'; else $(CYGPATH_W) '$(srcdir)/ntp_parser.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntp_parser.Tpo $(DEPDIR)/ntpdsim-ntp_parser.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntp_parser.c' object='ntpdsim-ntp_parser.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntp_parser.c' object='ntpdsim-ntp_parser.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_parser.obj `if test -f 'ntp_parser.c'; then $(CYGPATH_W) 'ntp_parser.c'; else $(CYGPATH_W) '$(srcdir)/ntp_parser.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_parser.obj `if test -f 'ntp_parser.c'; then $(CYGPATH_W) 'ntp_parser.c'; else $(CYGPATH_W) '$(srcdir)/ntp_parser.c'; fi` ntpdsim-ntp_scanner.o: ntp_scanner.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_scanner.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_scanner.Tpo -c -o ntpdsim-ntp_scanner.o `test -f 'ntp_scanner.c' || echo '$(srcdir)/'`ntp_scanner.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntp_scanner.Tpo $(DEPDIR)/ntpdsim-ntp_scanner.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntp_scanner.c' object='ntpdsim-ntp_scanner.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntp_scanner.c' object='ntpdsim-ntp_scanner.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_scanner.o `test -f 'ntp_scanner.c' || echo '$(srcdir)/'`ntp_scanner.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_scanner.o `test -f 'ntp_scanner.c' || echo '$(srcdir)/'`ntp_scanner.c ntpdsim-ntp_scanner.obj: ntp_scanner.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_scanner.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_scanner.Tpo -c -o ntpdsim-ntp_scanner.obj `if test -f 'ntp_scanner.c'; then $(CYGPATH_W) 'ntp_scanner.c'; else $(CYGPATH_W) '$(srcdir)/ntp_scanner.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntp_scanner.Tpo $(DEPDIR)/ntpdsim-ntp_scanner.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntp_scanner.c' object='ntpdsim-ntp_scanner.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntp_scanner.c' object='ntpdsim-ntp_scanner.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_scanner.obj `if test -f 'ntp_scanner.c'; then $(CYGPATH_W) 'ntp_scanner.c'; else $(CYGPATH_W) '$(srcdir)/ntp_scanner.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_scanner.obj `if test -f 'ntp_scanner.c'; then $(CYGPATH_W) 'ntp_scanner.c'; else $(CYGPATH_W) '$(srcdir)/ntp_scanner.c'; fi` ntpdsim-ntpd.o: ntpd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpd.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntpd.Tpo -c -o ntpdsim-ntpd.o `test -f 'ntpd.c' || echo '$(srcdir)/'`ntpd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntpd.Tpo $(DEPDIR)/ntpdsim-ntpd.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntpd.c' object='ntpdsim-ntpd.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntpd.c' object='ntpdsim-ntpd.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd.o `test -f 'ntpd.c' || echo '$(srcdir)/'`ntpd.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd.o `test -f 'ntpd.c' || echo '$(srcdir)/'`ntpd.c ntpdsim-ntpd.obj: ntpd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpd.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntpd.Tpo -c -o ntpdsim-ntpd.obj `if test -f 'ntpd.c'; then $(CYGPATH_W) 'ntpd.c'; else $(CYGPATH_W) '$(srcdir)/ntpd.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntpd.Tpo $(DEPDIR)/ntpdsim-ntpd.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntpd.c' object='ntpdsim-ntpd.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntpd.c' object='ntpdsim-ntpd.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd.obj `if test -f 'ntpd.c'; then $(CYGPATH_W) 'ntpd.c'; else $(CYGPATH_W) '$(srcdir)/ntpd.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd.obj `if test -f 'ntpd.c'; then $(CYGPATH_W) 'ntpd.c'; else $(CYGPATH_W) '$(srcdir)/ntpd.c'; fi` ntpdsim-ntpd-opts.o: ntpd-opts.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpd-opts.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntpd-opts.Tpo -c -o ntpdsim-ntpd-opts.o `test -f 'ntpd-opts.c' || echo '$(srcdir)/'`ntpd-opts.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntpd-opts.Tpo $(DEPDIR)/ntpdsim-ntpd-opts.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntpd-opts.c' object='ntpdsim-ntpd-opts.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntpd-opts.c' object='ntpdsim-ntpd-opts.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd-opts.o `test -f 'ntpd-opts.c' || echo '$(srcdir)/'`ntpd-opts.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd-opts.o `test -f 'ntpd-opts.c' || echo '$(srcdir)/'`ntpd-opts.c ntpdsim-ntpd-opts.obj: ntpd-opts.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpd-opts.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntpd-opts.Tpo -c -o ntpdsim-ntpd-opts.obj `if test -f 'ntpd-opts.c'; then $(CYGPATH_W) 'ntpd-opts.c'; else $(CYGPATH_W) '$(srcdir)/ntpd-opts.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntpd-opts.Tpo $(DEPDIR)/ntpdsim-ntpd-opts.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntpd-opts.c' object='ntpdsim-ntpd-opts.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntpd-opts.c' object='ntpdsim-ntpd-opts.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd-opts.obj `if test -f 'ntpd-opts.c'; then $(CYGPATH_W) 'ntpd-opts.c'; else $(CYGPATH_W) '$(srcdir)/ntpd-opts.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd-opts.obj `if test -f 'ntpd-opts.c'; then $(CYGPATH_W) 'ntpd-opts.c'; else $(CYGPATH_W) '$(srcdir)/ntpd-opts.c'; fi` ntpdsim-ntp_prio_q.o: ntp_prio_q.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_prio_q.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_prio_q.Tpo -c -o ntpdsim-ntp_prio_q.o `test -f 'ntp_prio_q.c' || echo '$(srcdir)/'`ntp_prio_q.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntp_prio_q.Tpo $(DEPDIR)/ntpdsim-ntp_prio_q.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntp_prio_q.c' object='ntpdsim-ntp_prio_q.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntp_prio_q.c' object='ntpdsim-ntp_prio_q.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_prio_q.o `test -f 'ntp_prio_q.c' || echo '$(srcdir)/'`ntp_prio_q.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_prio_q.o `test -f 'ntp_prio_q.c' || echo '$(srcdir)/'`ntp_prio_q.c ntpdsim-ntp_prio_q.obj: ntp_prio_q.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_prio_q.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_prio_q.Tpo -c -o ntpdsim-ntp_prio_q.obj `if test -f 'ntp_prio_q.c'; then $(CYGPATH_W) 'ntp_prio_q.c'; else $(CYGPATH_W) '$(srcdir)/ntp_prio_q.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntp_prio_q.Tpo $(DEPDIR)/ntpdsim-ntp_prio_q.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntp_prio_q.c' object='ntpdsim-ntp_prio_q.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntp_prio_q.c' object='ntpdsim-ntp_prio_q.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_prio_q.obj `if test -f 'ntp_prio_q.c'; then $(CYGPATH_W) 'ntp_prio_q.c'; else $(CYGPATH_W) '$(srcdir)/ntp_prio_q.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_prio_q.obj `if test -f 'ntp_prio_q.c'; then $(CYGPATH_W) 'ntp_prio_q.c'; else $(CYGPATH_W) '$(srcdir)/ntp_prio_q.c'; fi` ntpdsim-ntpsim.o: ntpsim.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpsim.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntpsim.Tpo -c -o ntpdsim-ntpsim.o `test -f 'ntpsim.c' || echo '$(srcdir)/'`ntpsim.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntpsim.Tpo $(DEPDIR)/ntpdsim-ntpsim.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntpsim.c' object='ntpdsim-ntpsim.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntpsim.c' object='ntpdsim-ntpsim.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpsim.o `test -f 'ntpsim.c' || echo '$(srcdir)/'`ntpsim.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpsim.o `test -f 'ntpsim.c' || echo '$(srcdir)/'`ntpsim.c ntpdsim-ntpsim.obj: ntpsim.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpsim.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntpsim.Tpo -c -o ntpdsim-ntpsim.obj `if test -f 'ntpsim.c'; then $(CYGPATH_W) 'ntpsim.c'; else $(CYGPATH_W) '$(srcdir)/ntpsim.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ntpdsim-ntpsim.Tpo $(DEPDIR)/ntpdsim-ntpsim.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ntpsim.c' object='ntpdsim-ntpsim.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ntpsim.c' object='ntpdsim-ntpsim.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpsim.obj `if test -f 'ntpsim.c'; then $(CYGPATH_W) 'ntpsim.c'; else $(CYGPATH_W) '$(srcdir)/ntpsim.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntpdsim_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpsim.obj `if test -f 'ntpsim.c'; then $(CYGPATH_W) 'ntpsim.c'; else $(CYGPATH_W) '$(srcdir)/ntpsim.c'; fi` .y.c: - $(AM_V_YACC)$(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE) + $(AM_V_YACC)$(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h `echo $@ | $(am__yacc_c2h)` y.output $*.output -- $(YACCCOMPILE) mostlyclean-libtool: -rm -f *.lo @@ -1163,11 +1269,18 @@ clean-libtool: -rm -rf .libs _libs install-man1: $(man1_MANS) $(man_MANS) @$(NORMAL_INSTALL) - test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" - @list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \ - { for i in $$list; do echo "$$i"; done; \ - l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ - sed -n '/\.1[a-z]*$$/p'; \ + @list1='$(man1_MANS)'; \ + list2='$(man_MANS)'; \ + test -n "$(man1dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.1[a-z]*$$/p'; \ + fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ @@ -1196,16 +1309,21 @@ uninstall-man1: sed -n '/\.1[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - test -z "$$files" || { \ - echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(man1dir)" && rm -f $$files; } + dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-man5: $(man5_MANS) $(man_MANS) @$(NORMAL_INSTALL) - test -z "$(man5dir)" || $(MKDIR_P) "$(DESTDIR)$(man5dir)" - @list='$(man5_MANS)'; test -n "$(man5dir)" || exit 0; \ - { for i in $$list; do echo "$$i"; done; \ - l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ - sed -n '/\.5[a-z]*$$/p'; \ + @list1='$(man5_MANS)'; \ + list2='$(man_MANS)'; \ + test -n "$(man5dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.5[a-z]*$$/p'; \ + fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ @@ -1234,16 +1352,21 @@ uninstall-man5: sed -n '/\.5[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - test -z "$$files" || { \ - echo " ( cd '$(DESTDIR)$(man5dir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(man5dir)" && rm -f $$files; } + dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir) install-man8: $(man8_MANS) $(man_MANS) @$(NORMAL_INSTALL) - test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)" - @list='$(man8_MANS)'; test -n "$(man8dir)" || exit 0; \ - { for i in $$list; do echo "$$i"; done; \ - l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ - sed -n '/\.8[a-z]*$$/p'; \ + @list1='$(man8_MANS)'; \ + list2='$(man_MANS)'; \ + test -n "$(man8dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.8[a-z]*$$/p'; \ + fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ @@ -1272,13 +1395,14 @@ uninstall-man8: sed -n '/\.8[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - test -z "$$files" || { \ - echo " ( cd '$(DESTDIR)$(man8dir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(man8dir)" && rm -f $$files; } + dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir) install-htmlDATA: $(html_DATA) @$(NORMAL_INSTALL) - test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)" @list='$(html_DATA)'; test -n "$(htmldir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(htmldir)" || exit 1; \ + fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -1292,30 +1416,17 @@ uninstall-htmlDATA: @$(NORMAL_UNINSTALL) @list='$(html_DATA)'; test -n "$(htmldir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(htmldir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(htmldir)" && rm -f $$files - -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; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) + dir='$(DESTDIR)$(htmldir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ 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; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ + $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ @@ -1327,15 +1438,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $$unique; \ fi; \ fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - 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; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique @@ -1344,24 +1451,26 @@ GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) - @list='$(MANS)'; if test -n "$$list"; then \ - list=`for p in $$list; do \ - if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ - if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ - if test -n "$$list" && \ - grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ - echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ - grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ - echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ - echo " typically \`make maintainer-clean' will remove them" >&2; \ - exit 1; \ - else :; fi; \ - else :; fi @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -1412,10 +1521,15 @@ install-am: all-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 + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: @@ -1512,27 +1626,29 @@ uninstall-man: uninstall-man1 uninstall-man5 uninstall-man8 .MAKE: all check check-am install install-am install-exec-am \ install-strip -.PHONY: CTAGS GTAGS all all-am check check-am check-local clean \ +.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \ clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ clean-libexecPROGRAMS clean-libtool clean-noinstLIBRARIES \ - clean-sbinPROGRAMS ctags distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-binPROGRAMS install-data install-data-am \ - install-data-local install-dvi install-dvi-am install-exec \ - install-exec-am install-exec-hook install-html install-html-am \ - install-htmlDATA install-info install-info-am \ + clean-sbinPROGRAMS cscopelist-am ctags ctags-am distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-data-local install-dvi install-dvi-am \ + install-exec install-exec-am install-exec-hook install-html \ + install-html-am install-htmlDATA install-info install-info-am \ install-libexecPROGRAMS install-man install-man1 install-man5 \ install-man8 install-pdf install-pdf-am install-ps \ install-ps-am install-sbinPROGRAMS install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags uninstall uninstall-am uninstall-binPROGRAMS \ + tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-htmlDATA uninstall-libexecPROGRAMS uninstall-man \ uninstall-man1 uninstall-man5 uninstall-man8 \ uninstall-sbinPROGRAMS +.PRECIOUS: Makefile + vphack: test -e ntp_parser.c || ln -s $(srcdir)/ntp_parser.c . diff --git a/ntpd/complete.conf.in b/ntpd/complete.conf.in index a820094abb748..747a48f2f2a80 100644 --- a/ntpd/complete.conf.in +++ b/ntpd/complete.conf.in @@ -2,8 +2,10 @@ saveconfigdir "/etc/ntp/conf" driftfile "/etc/ntp.drift" 1e-7 logfile "/var/log/ntp.log" leapfile "/etc/ntp.leapseconds" +@HAVE_LEAPSMEARINTERVAL@ nonvolatile 1e-7 ident "udent" +dscp 46 logconfig =allall -allinfo -allevents -allstatistics -allstatus +allall -clockinfo -clockevents -clockstatistics -clockstatus +clockall -syncinfo -syncevents -syncstatistics -syncstatus +syncall -sysinfo -sysevents -sysstatistics -sysstatus +sysall statsdir "/etc/ntp/stats" statistics clockstats cryptostats loopstats peerstats protostats rawstats sysstats timingstats diff --git a/ntpd/invoke-ntp.conf.texi b/ntpd/invoke-ntp.conf.texi index 7151efb82e140..d7a9d13a2d994 100644 --- a/ntpd/invoke-ntp.conf.texi +++ b/ntpd/invoke-ntp.conf.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntp.conf.texi) # -# It has been AutoGen-ed April 7, 2015 at 04:25:50 AM by AutoGen 5.18.5pre4 +# It has been AutoGen-ed June 29, 2015 at 04:30:28 PM by AutoGen 5.18.5 # From the definitions ntp.conf.def # and the template file agtexi-file.tpl @end ignore @@ -2291,6 +2291,9 @@ This implies that must have write permission for the directory the drift file is located in, and that file system links, symbolic or otherwise, should be avoided. +@item @code{dscp} @kbd{value} +This option specifies the Differentiated Services Control Point (DSCP) value, +a 6-bit code. The default value is 46, signifying Expedited Forwarding. @item @code{enable} @code{[@code{auth} | @code{bclient} | @code{calibrate} | @code{kernel} | @code{mode7} | @code{monitor} | @code{ntp} | @code{stats}]} @item @code{disable} @code{[@code{auth} | @code{bclient} | @code{calibrate} | @code{kernel} | @code{mode7} | @code{monitor} | @code{ntp} | @code{stats}]} Provides a way to enable or disable various server options. @@ -2376,6 +2379,19 @@ This option is useful for sites that run @code{ntpd(1ntpdmdoc)} on multiple hosts, with (mostly) common options (e.g., a restriction list). +@item @code{leapsmearinterval} @kbd{seconds} +This EXPERIMENTAL option is only available if +@code{ntpd(1ntpdmdoc)} +was built with the +@code{--enable-leap-smear} +option to the +@code{configure} +script. +It specifies the interval over which a leap second correction will be applied. +Recommended values for this option are between +7200 (2 hours) and 86400 (24 hours). +.Sy DO NOT USE THIS OPTION ON PUBLIC-ACCESS SERVERS! +See http://bugs.ntp.org/2855 for more information. @item @code{logconfig} @kbd{configkeyword} This command controls the amount and type of output written to the system @@ -2570,11 +2586,11 @@ option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. @item @code{stacksize} @kbd{N4kPages} Specifies the maximum size of the process stack on systems with the -@item @code{filenum} @kbd{Nfiledescriptors} -Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. @code{mlockall()} function. Defaults to 50 4k pages (200 4k pages in OpenBSD). +@item @code{filenum} @kbd{Nfiledescriptors} +Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. @end table @item @code{trap} @kbd{host_address} @code{[@code{port} @kbd{port_number}]} @code{[@code{interface} @kbd{interface_address}]} This command configures a trap receiver at the given host diff --git a/ntpd/invoke-ntp.keys.texi b/ntpd/invoke-ntp.keys.texi index b0d494040e79e..622c4ffe03c25 100644 --- a/ntpd/invoke-ntp.keys.texi +++ b/ntpd/invoke-ntp.keys.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntp.keys.texi) # -# It has been AutoGen-ed April 7, 2015 at 04:25:52 AM by AutoGen 5.18.5pre4 +# It has been AutoGen-ed June 29, 2015 at 04:30:31 PM by AutoGen 5.18.5 # From the definitions ntp.keys.def # and the template file agtexi-file.tpl @end ignore diff --git a/ntpd/invoke-ntpd.texi b/ntpd/invoke-ntpd.texi index b6c69db8a1da9..6936dda91f046 100644 --- a/ntpd/invoke-ntpd.texi +++ b/ntpd/invoke-ntpd.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntpd.texi) # -# It has been AutoGen-ed April 7, 2015 at 04:25:54 AM by AutoGen 5.18.5pre4 +# It has been AutoGen-ed June 29, 2015 at 04:30:33 PM by AutoGen 5.18.5 # From the definitions ntpd-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -142,7 +142,7 @@ with a status code of 0. @exampleindent 0 @example -ntpd - NTP daemon program - Ver. 4.2.8p2 +ntpd - NTP daemon program - Ver. 4.2.8p3 Usage: ntpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \ [ <server1> ... <serverN> ] Flg Arg Option-Name Description diff --git a/ntpd/keyword-gen-utd b/ntpd/keyword-gen-utd index b9b59bd4739f1..467351b65e3a4 100644 --- a/ntpd/keyword-gen-utd +++ b/ntpd/keyword-gen-utd @@ -1 +1 @@ - * Generated 2015-03-16 09:05:44 UTC diff_ignore_line + * Generated 2015-06-25 03:57:00 UTC diff_ignore_line diff --git a/ntpd/keyword-gen.c b/ntpd/keyword-gen.c index 5872e2a5cc1f6..42e94973f81ee 100644 --- a/ntpd/keyword-gen.c +++ b/ntpd/keyword-gen.c @@ -46,6 +46,7 @@ struct key_tok ntp_keywords[] = { { "ctl", T_Ctl, FOLLBY_TOKEN }, { "disable", T_Disable, FOLLBY_TOKEN }, { "driftfile", T_Driftfile, FOLLBY_STRING }, +{ "dscp", T_Dscp, FOLLBY_TOKEN }, { "enable", T_Enable, FOLLBY_TOKEN }, { "end", T_End, FOLLBY_TOKEN }, { "filegen", T_Filegen, FOLLBY_TOKEN }, @@ -53,6 +54,7 @@ struct key_tok ntp_keywords[] = { { "io", T_Io, FOLLBY_TOKEN }, { "includefile", T_Includefile, FOLLBY_STRING }, { "leapfile", T_Leapfile, FOLLBY_STRING }, +{ "leapsmearinterval", T_Leapsmearinterval, FOLLBY_TOKEN }, { "logconfig", T_Logconfig, FOLLBY_STRINGS_TO_EOC }, { "logfile", T_Logfile, FOLLBY_STRING }, { "manycastclient", T_Manycastclient, FOLLBY_STRING }, @@ -333,12 +335,11 @@ generate_fsm(void) char *r; u_short initial_state; u_short this_state; - u_short prev_state; u_short state; u_short i; u_short token; - /* + /* * Sort ntp_keywords in alphabetical keyword order. This is * not necessary, but minimizes nonfunctional changes in the * generated finite state machine when keywords are modified. @@ -347,7 +348,7 @@ generate_fsm(void) sizeof(ntp_keywords[0]), compare_key_tok_text); /* - * To save space, reserve the state array entry matching each + * To save space, reserve the state array entry matching each * token number for its terminal state, so the token identifier * does not need to be stored in each state, but can be * recovered trivially. To mark the entry reserved, @@ -414,7 +415,7 @@ generate_fsm(void) } if (sst[i].finishes_token) { - snprintf(token_id_comment, + snprintf(token_id_comment, sizeof(token_id_comment), "%5d %-17s", i, symbname(sst[i].finishes_token)); if (i != sst[i].finishes_token) { @@ -442,7 +443,6 @@ generate_fsm(void) * spellings result in the same T_* value. */ prefix_len = 0; - prev_state = 0; this_state = i; do { for (state = 1; state < sst_highwater; state++) @@ -468,8 +468,8 @@ generate_fsm(void) snprintf(token_id_comment, sizeof(token_id_comment), "%5d %-17s", - i, (initial_state == i) - ? "[initial state]" + i, (initial_state == i) + ? "[initial state]" : prefix); } @@ -497,8 +497,8 @@ generate_fsm(void) */ static u_short create_scan_states( - char * text, - u_short token, + char * text, + u_short token, follby followedby, u_short prev_state ) @@ -512,7 +512,7 @@ create_scan_states( curr_char_s = prev_state; prev_char_s = 0; - /* Find the correct position to insert the state. + /* Find the correct position to insert the state. * All states should be in alphabetical order */ while (curr_char_s && (text[0] < sst[curr_char_s].ch)) { @@ -520,7 +520,7 @@ create_scan_states( curr_char_s = sst[curr_char_s].other_next_s; } - /* + /* * Check if a previously seen keyword has the same prefix as * the current keyword. If so, simply use the state for that * keyword as my_state, otherwise, allocate a new state. @@ -548,7 +548,7 @@ create_scan_states( exit(3); } /* Store the next character of the keyword */ - sst[my_state].ch = text[0]; + sst[my_state].ch = text[0]; sst[my_state].other_next_s = curr_char_s; sst[my_state].followedby = FOLLBY_NON_ACCEPTING; @@ -587,7 +587,7 @@ create_scan_states( return_state = my_state; } } else - sst[my_state].match_next_s = + sst[my_state].match_next_s = create_scan_states( &text[1], token, @@ -615,8 +615,8 @@ create_keyword_scanner(void) current_keyword = ntp_keywords[i].key; scanner = create_scan_states( - ntp_keywords[i].key, - ntp_keywords[i].token, + ntp_keywords[i].key, + ntp_keywords[i].token, ntp_keywords[i].followedby, scanner); } @@ -657,7 +657,7 @@ generate_token_text(void) if (i > 0) printf(","); printf("\n\t/* %-5d %5d %20s */\t\"%s\"", - id - lowest_id, id, symbname(id), + id - lowest_id, id, symbname(id), ntp_keywords[i].key); i++; id++; @@ -666,7 +666,7 @@ generate_token_text(void) printf("\n};\n\n"); } - + int compare_key_tok_id( const void *a1, @@ -749,7 +749,7 @@ symbname( } else { LIB_GETBUF(name); snprintf(name, LIB_BUFLENGTH, "%d", token); - } + } return name; } diff --git a/ntpd/ntp.conf.5man b/ntpd/ntp.conf.5man index f1ed4b298fd9c..14438bdc7da10 100644 --- a/ntpd/ntp.conf.5man +++ b/ntpd/ntp.conf.5man @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntp.conf 5man "07 Apr 2015" "4.2.8p2" "File Formats" +.TH ntp.conf 5man "29 Jun 2015" "4.2.8p3" "File Formats" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-gKaW.1/ag-tKaO91) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-R0aO7B/ag-30aG6B) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:25:37 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:16 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agman-cmd.tpl .SH NAME @@ -35,7 +35,7 @@ All arguments must be options. The \f\*[B-Font]ntp.conf\fP configuration file is read at initial startup by the -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] daemon in order to specify the synchronization sources, modes and other related information. Usually, it is installed in the @@ -307,7 +307,7 @@ This is designed to speed the initial synchronization acquisition with the \f\*[B-Font]server\f[] command and s addresses and when -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] is started with the \f\*[B-Font]\-q\f[] option. @@ -528,7 +528,7 @@ and \f\*[B-Font]disable\f[] commands and also by remote configuration commands sent by a -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] program running in another machine. If this flag is enabled, which is the default @@ -595,15 +595,15 @@ secure means beyond the scope of the NTP protocol itself. Besides the keys used for ordinary NTP associations, additional keys can be used as passwords for the -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] and -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] utility programs. .sp \n(Ppu .ne 2 When -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] is first started, it reads the key file specified in the \f\*[B-Font]keys\f[] configuration command and installs the keys @@ -617,17 +617,17 @@ allows, for instance, the installation of possibly several batches of keys and then activating or deactivating each batch remotely using -\fCntpdc\fR(1ntpdcmdoc)\f[]. +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[]. This also provides a revocation capability that can be used if a key becomes compromised. The \f\*[B-Font]requestkey\f[] command selects the key used as the password for the -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] utility, while the \f\*[B-Font]controlkey\f[] command selects the key used as the password for the -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] utility. .SS Public Key Cryptography NTPv4 supports the original NTPv3 symmetric key scheme @@ -674,7 +674,7 @@ page. The specific cryptographic environment used by Autokey servers and clients is determined by a set of files and soft links generated by the -\fCntp-keygen\fR(1ntpkeygenmdoc)\f[] +\fCntp-keygen\f[]\fR(1ntpkeygenmdoc)\f[] program. This includes a required host key file, required certificate file and optional sign key file, @@ -721,7 +721,7 @@ DNS compromise is essential. By convention, the name of an Autokey host is the name returned by the Unix -\fCgethostname\fR(2)\f[] +\fCgethostname\f[]\fR(2)\f[] system call or equivalent in other systems. By the system design model, there are no provisions to allow alternate names or aliases. @@ -821,7 +821,7 @@ If verification fails, Bob sends Cathy a thing called a crypto-NAK, which tells her something broke. She can see the evidence using the -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] program. .sp \n(Ppu .ne 2 @@ -846,7 +846,7 @@ with one server and no authentication with another might not be wise. .SS Key Management The cryptographic values used by the Autokey protocol are incorporated as a set of files generated by the -\fCntp-keygen\fR(1ntpkeygenmdoc)\f[] +\fCntp-keygen\f[]\fR(1ntpkeygenmdoc)\f[] utility program, including symmetric key, host key and public certificate files, as well as sign key, identity parameters and leapseconds files. @@ -855,9 +855,9 @@ certificate files can be generated by the OpenSSL utilities and certificates can be imported from public certificate authorities. Note that symmetric keys are necessary for the -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] and -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] utility programs. The remaining files are necessary only for the Autokey protocol. @@ -895,7 +895,7 @@ sent. .TP 7 .NOP \f\*[B-Font]controlkey\f[] \f\*[I-Font]key\f[] Specifies the key identifier to use with the -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] utility, which uses the standard protocol defined in RFC-1305. The @@ -984,10 +984,10 @@ not found, the host key is also the sign key. .NOP \f\*[B-Font]keys\f[] \f\*[I-Font]keyfile\f[] Specifies the complete path and location of the MD5 key file containing the keys and key identifiers used by -\fCntpd\fR(1ntpdmdoc)\f[], -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[], +\fCntpq\f[]\fR(1ntpqmdoc)\f[] and -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] when operating with symmetric key cryptography. This is the same operation as the \f\*[B-Font]\-k\f[] @@ -1001,10 +1001,10 @@ The default is .TP 7 .NOP \f\*[B-Font]requestkey\f[] \f\*[I-Font]key\f[] Specifies the key identifier to use with the -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] utility program, which uses a proprietary protocol specific to this implementation of -\fCntpd\fR(1ntpdmdoc)\f[]. +\fCntpd\f[]\fR(1ntpdmdoc)\f[]. The \f\*[I-Font]key\f[] argument is a key identifier @@ -1027,9 +1027,9 @@ for every message sent. Specifies the key identifiers which are trusted for the purposes of authenticating peers with symmetric key cryptography, as well as keys used by the -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] and -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] programs. The authentication procedures require that both the local and remote servers share the same key and key identifier for this @@ -1106,7 +1106,7 @@ The certificate is missing, corrupted or bogus. The identity key is missing, corrupt or bogus. .PP .SH Monitoring Support -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] includes a comprehensive monitoring facility suitable for continuous, long term recording of server and client timekeeping performance. @@ -1122,7 +1122,7 @@ directory of this distribution. Using these facilities and UNIX -\fCcron\fR(8)\f[] +\fCcron\f[]\fR(8)\f[] jobs, the data can be automatically summarized and archived for retrospective analysis. .SS Monitoring Commands @@ -1348,7 +1348,7 @@ produced.) .ne 2 Note that this command can be sent from the -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] program running at a remote location. .RS .TP 7 @@ -1422,7 +1422,7 @@ server. This type does not perform any changes to file set members during runtime, however it provides an easy way of separating files belonging to different -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] server incarnations. The set member filename is built by appending a \[oq]\&.\[cq] @@ -1432,7 +1432,7 @@ and \f\*[I-Font]filename\f[] strings, and appending the decimal representation of the process ID of the -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] server process. .TP 7 .NOP \f\*[B-Font]day\f[] @@ -1524,7 +1524,7 @@ Enables or disables the recording function. .PP .SH Access Control Support The -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] daemon implements a general purpose address/mask based restriction list. The list contains address/match entries sorted first @@ -1672,9 +1672,9 @@ may be specified: .TP 7 .NOP \f\*[B-Font]ignore\f[] Deny packets of all kinds, including -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] and -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] queries. .TP 7 .NOP \f\*[B-Font]kod\f[] @@ -1690,7 +1690,7 @@ Deny service if the packet spacing violates the lower limits specified in the discard command. A history of clients is kept using the monitoring capability of -\fCntpd\fR(1ntpdmdoc)\f[]. +\fCntpd\f[]\fR(1ntpdmdoc)\f[]. Thus, monitoring is always active as long as there is a restriction entry with the \f\*[B-Font]limited\f[] @@ -1709,9 +1709,9 @@ be overridden by later requests for normal priority traps. .TP 7 .NOP \f\*[B-Font]nomodify\f[] Deny -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] and -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] queries which attempt to modify the state of the server (i.e., run time reconfiguration). Queries which return @@ -1719,9 +1719,9 @@ information are permitted. .TP 7 .NOP \f\*[B-Font]noquery\f[] Deny -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] and -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] queries. Time service is not affected. .TP 7 @@ -1746,9 +1746,9 @@ directive. .TP 7 .NOP \f\*[B-Font]noserve\f[] Deny all packets except -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] and -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] queries. .TP 7 .NOP \f\*[B-Font]notrap\f[] @@ -2078,11 +2078,11 @@ re-associate accordingly. .ne 2 Some administrators prefer to avoid running -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] continuously and run either -\fCntpdate\fR(8)\f[] +\fCntpdate\f[]\fR(8)\f[] or -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] \f\*[B-Font]\-q\f[] as a cron job. In either case the servers must be @@ -2090,7 +2090,7 @@ configured in advance and the program fails if none are available when the cron job runs. A really slick application of manycast is with -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] \f\*[B-Font]\-q\f[]. The program wakes up, scans the local landscape looking for the usual suspects, selects the best from among @@ -2260,7 +2260,7 @@ hazardous. .ne 2 For the purposes of configuration, -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] treats reference clocks in a manner analogous to normal NTP peers as much as possible. @@ -2348,7 +2348,7 @@ command as well. The stratum number of a reference clock is by default zero. Since the -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] daemon adds one to the stratum of each peer, a primary server ordinarily displays an external stratum of one. @@ -2422,7 +2422,7 @@ It must immediately follow the command which configures the driver. Note that the same capability is possible at run time using the -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] program. The options are interpreted as follows: @@ -2564,11 +2564,15 @@ The file is updated by first writing the current drift value into a temporary file and then renaming this file to replace the old version. This implies that -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] must have write permission for the directory the drift file is located in, and that file system links, symbolic or otherwise, should be avoided. .TP 7 +.NOP \f\*[B-Font]dscp\f[] \f\*[I-Font]value\f[] +This option specifies the Differentiated Services Control Point (DSCP) value, +a 6-bit code. The default value is 46, signifying Expedited Forwarding. +.TP 7 .NOP \f\*[B-Font]enable\f[] [\f\*[B-Font]auth\f[] | \f\*[B-Font]bclient\f[] | \f\*[B-Font]calibrate\f[] | \f\*[B-Font]kernel\f[] | \f\*[B-Font]mode7\f[] | \f\*[B-Font]monitor\f[] | \f\*[B-Font]ntp\f[] | \f\*[B-Font]stats\f[]] .TP 7 .NOP \f\*[B-Font]disable\f[] [\f\*[B-Font]auth\f[] | \f\*[B-Font]bclient\f[] | \f\*[B-Font]calibrate\f[] | \f\*[B-Font]kernel\f[] | \f\*[B-Font]mode7\f[] | \f\*[B-Font]monitor\f[] | \f\*[B-Font]ntp\f[] | \f\*[B-Font]stats\f[]] @@ -2576,7 +2580,7 @@ Provides a way to enable or disable various server options. Flags not mentioned are unaffected. Note that all of these flags can be controlled remotely using the -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] utility program. .RS .TP 7 @@ -2613,21 +2617,21 @@ if support is available, otherwise .NOP \f\*[B-Font]mode7\f[] Enables processing of NTP mode 7 implementation-specific requests which are used by the deprecated -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] program. The default for this flag is disable. This flag is excluded from runtime configuration using -\fCntpq\fR(1ntpqmdoc)\f[]. +\fCntpq\f[]\fR(1ntpqmdoc)\f[]. The -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] program provides the same capabilities as -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] using standard mode 6 requests. .TP 7 .NOP \f\*[B-Font]monitor\f[] Enables the monitoring facility. See the -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] program and the \f\*[B-Font]monlist\f[] @@ -2661,14 +2665,28 @@ be nested to a depth of five; upon reaching the end of any include file, command processing resumes in the previous configuration file. This option is useful for sites that run -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] on multiple hosts, with (mostly) common options (e.g., a restriction list). .TP 7 +.NOP \f\*[B-Font]leapsmearinterval\f[] \f\*[I-Font]seconds\f[] +This EXPERIMENTAL option is only available if +\fCntpd\f[]\fR(1ntpdmdoc)\f[] +was built with the +\f\*[B-Font]\--enable-leap-smear\f[] +option to the +\f\*[B-Font]configure\f[] +script. +It specifies the interval over which a leap second correction will be applied. +Recommended values for this option are between +7200 (2 hours) and 86400 (24 hours). +.Sy DO NOT USE THIS OPTION ON PUBLIC-ACCESS SERVERS! +See http://bugs.ntp.org/2855 for more information. +.TP 7 .NOP \f\*[B-Font]logconfig\f[] \f\*[I-Font]configkeyword\f[] This command controls the amount and type of output written to the system -\fCsyslog\fR(3)\f[] +\fCsyslog\f[]\fR(3)\f[] facility or the alternate \f\*[B-Font]logfile\f[] log file. @@ -2683,14 +2701,14 @@ and where \[oq]=\[cq] sets the -\fCsyslog\fR(3)\f[] +\fCsyslog\f[]\fR(3)\f[] priority mask, \[oq]+\[cq] adds and \[oq]\-\[cq] removes messages. -\fCsyslog\fR(3)\f[] +\fCsyslog\f[]\fR(3)\f[] messages can be controlled in four classes (\f\*[B-Font]clock\f[], \f\*[B-Font]peer\f[], \f\*[B-Font]sys\f[] and \f\*[B-Font]sync\f[]). @@ -2728,7 +2746,7 @@ logconfig =syncstatus +sysevents .ne 2 This would just list the synchronizations state of -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] and the major system events. For a simple reference server, the following minimum message configuration could be useful: @@ -2749,7 +2767,7 @@ peers, system events and so on is suppressed. .NOP \f\*[B-Font]logfile\f[] \f\*[I-Font]logfile\f[] This command specifies the location of an alternate log file to be used instead of the default system -\fCsyslog\fR(3)\f[] +\fCsyslog\f[]\fR(3)\f[] facility. This is the same operation as the \-l command line option. .TP 7 @@ -2764,7 +2782,7 @@ is followed by the \f\*[B-Font]default\f[] keyword, the variable will be listed as part of the default system variables -(\fCntpq\fR(1ntpqmdoc)\f[] \f\*[B-Font]rv\f[] command)). +(\fCntpq\f[]\fR(1ntpqmdoc)\f[] \f\*[B-Font]rv\f[] command)). These additional variables serve informational purposes only. They are not related to the protocol @@ -2888,12 +2906,12 @@ The default is 32 megabytes. Setting this to zero will prevent any attemp to loc .TP 7 .NOP \f\*[B-Font]stacksize\f[] \f\*[I-Font]N4kPages\f[] Specifies the maximum size of the process stack on systems with the +\fBmlockall\f[]\fR()\f[] +function. +Defaults to 50 4k pages (200 4k pages in OpenBSD). .TP 7 .NOP \f\*[B-Font]filenum\f[] \f\*[I-Font]Nfiledescriptors\f[] Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. -\fBmlockall\fR()\f[] -function. -Defaults to 50 4k pages (200 4k pages in OpenBSD). .RE .TP 7 .NOP \f\*[B-Font]trap\f[] \f\*[I-Font]host_address\f[] [\f\*[B-Font]port\f[] \f\*[I-Font]port_number\f[]] [\f\*[B-Font]interface\f[] \f\*[I-Font]interface_address\f[]] @@ -2986,9 +3004,9 @@ libopts had an internal operational error. Please report it to autogen-users@lists.sourceforge.net. Thank you. .PP .SH "SEE ALSO" -\fCntpd\fR(1ntpdmdoc)\f[], -\fCntpdc\fR(1ntpdcmdoc)\f[], -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[], +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[], +\fCntpq\f[]\fR(1ntpqmdoc)\f[] .sp \n(Ppu .ne 2 diff --git a/ntpd/ntp.conf.5mdoc b/ntpd/ntp.conf.5mdoc index 1a52a1257c4e4..938acf6d6a13e 100644 --- a/ntpd/ntp.conf.5mdoc +++ b/ntpd/ntp.conf.5mdoc @@ -1,9 +1,9 @@ -.Dd April 7 2015 +.Dd June 29 2015 .Dt NTP_CONF 5mdoc File Formats .Os .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:25:57 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:36 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agmdoc-cmd.tpl .Sh NAME @@ -2386,6 +2386,9 @@ This implies that must have write permission for the directory the drift file is located in, and that file system links, symbolic or otherwise, should be avoided. +.It Ic dscp Ar value +This option specifies the Differentiated Services Control Point (DSCP) value, +a 6\-bit code. The default value is 46, signifying Expedited Forwarding. .It Xo Ic enable .Oo .Cm auth | Cm bclient | @@ -2485,6 +2488,19 @@ This option is useful for sites that run .Xr ntpd 1ntpdmdoc on multiple hosts, with (mostly) common options (e.g., a restriction list). +.It Ic leapsmearinterval Ar seconds +This EXPERIMENTAL option is only available if +.Xr ntpd 1ntpdmdoc +was built with the +.Cm \-\-enable\-leap\-smear +option to the +.Cm configure +script. +It specifies the interval over which a leap second correction will be applied. +Recommended values for this option are between +7200 (2 hours) and 86400 (24 hours). +.Sy DO NOT USE THIS OPTION ON PUBLIC\-ACCESS SERVERS! +See http://bugs.ntp.org/2855 for more information. .It Ic logconfig Ar configkeyword This command controls the amount and type of output written to the system @@ -2717,11 +2733,11 @@ option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. .It Cm stacksize Ar N4kPages Specifies the maximum size of the process stack on systems with the -.It Cm filenum Ar Nfiledescriptors -Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. .Fn mlockall function. Defaults to 50 4k pages (200 4k pages in OpenBSD). +.It Cm filenum Ar Nfiledescriptors +Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. .El .It Xo Ic trap Ar host_address .Op Cm port Ar port_number diff --git a/ntpd/ntp.conf.def b/ntpd/ntp.conf.def index e5c44b7565c77..7e09c03069464 100644 --- a/ntpd/ntp.conf.def +++ b/ntpd/ntp.conf.def @@ -2388,6 +2388,9 @@ This implies that must have write permission for the directory the drift file is located in, and that file system links, symbolic or otherwise, should be avoided. +.It Ic dscp Ar value +This option specifies the Differentiated Services Control Point (DSCP) value, +a 6-bit code. The default value is 46, signifying Expedited Forwarding. .It Xo Ic enable .Oo .Cm auth | Cm bclient | @@ -2487,6 +2490,19 @@ This option is useful for sites that run .Xr ntpd 1ntpdmdoc on multiple hosts, with (mostly) common options (e.g., a restriction list). +.It Ic leapsmearinterval Ar seconds +This EXPERIMENTAL option is only available if +.Xr ntpd 1ntpdmdoc +was built with the +.Cm --enable-leap-smear +option to the +.Cm configure +script. +It specifies the interval over which a leap second correction will be applied. +Recommended values for this option are between +7200 (2 hours) and 86400 (24 hours). +.Sy DO NOT USE THIS OPTION ON PUBLIC-ACCESS SERVERS! +See http://bugs.ntp.org/2855 for more information. .It Ic logconfig Ar configkeyword This command controls the amount and type of output written to the system @@ -2719,11 +2735,11 @@ option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. .It Cm stacksize Ar N4kPages Specifies the maximum size of the process stack on systems with the -.It Cm filenum Ar Nfiledescriptors -Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. .Fn mlockall function. Defaults to 50 4k pages (200 4k pages in OpenBSD). +.It Cm filenum Ar Nfiledescriptors +Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. .El .It Xo Ic trap Ar host_address .Op Cm port Ar port_number diff --git a/ntpd/ntp.conf.html b/ntpd/ntp.conf.html index 7ab25e3756f42..ad643556ea1f9 100644 --- a/ntpd/ntp.conf.html +++ b/ntpd/ntp.conf.html @@ -33,7 +33,7 @@ Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> <p>This document describes the configuration file for the NTP Project's <code>ntpd</code> program. - <p>This document applies to version 4.2.8p2 of <code>ntp.conf</code>. + <p>This document applies to version 4.2.8p3 of <code>ntp.conf</code>. <div class="shortcontents"> <h2>Short Contents</h2> @@ -2286,6 +2286,8 @@ This implies that must have write permission for the directory the drift file is located in, and that file system links, symbolic or otherwise, should be avoided. +<br><dt><code>dscp</code> <kbd>value</kbd><dd>This option specifies the Differentiated Services Control Point (DSCP) value, +a 6-bit code. The default value is 46, signifying Expedited Forwarding. <br><dt><code>enable</code> <code>[auth | bclient | calibrate | kernel | mode7 | monitor | ntp | stats]</code><br><dt><code>disable</code> <code>[auth | bclient | calibrate | kernel | mode7 | monitor | ntp | stats]</code><dd>Provides a way to enable or disable various server options. Flags not mentioned are unaffected. Note that all of these flags @@ -2360,6 +2362,18 @@ This option is useful for sites that run <code>ntpd(1ntpdmdoc)</code> on multiple hosts, with (mostly) common options (e.g., a restriction list). +<br><dt><code>leapsmearinterval</code> <kbd>seconds</kbd><dd>This EXPERIMENTAL option is only available if +<code>ntpd(1ntpdmdoc)</code> +was built with the +<code>--enable-leap-smear</code> +option to the +<code>configure</code> +script. +It specifies the interval over which a leap second correction will be applied. +Recommended values for this option are between +7200 (2 hours) and 86400 (24 hours). +.Sy DO NOT USE THIS OPTION ON PUBLIC-ACCESS SERVERS! +See http://bugs.ntp.org/2855 for more information. <br><dt><code>logconfig</code> <kbd>configkeyword</kbd><dd>This command controls the amount and type of output written to the system <code>syslog(3)</code> @@ -2539,10 +2553,10 @@ when dropping root (the option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. <br><dt><code>stacksize</code> <kbd>N4kPages</kbd><dd>Specifies the maximum size of the process stack on systems with the -<br><dt><code>filenum</code> <kbd>Nfiledescriptors</kbd><dd>Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. <code>mlockall()</code> function. Defaults to 50 4k pages (200 4k pages in OpenBSD). +<br><dt><code>filenum</code> <kbd>Nfiledescriptors</kbd><dd>Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. </dl> <br><dt><code>trap</code> <kbd>host_address</kbd> <code>[port </code><kbd>port_number</kbd><code>]</code> <code>[interface </code><kbd>interface_address</kbd><code>]</code><dd>This command configures a trap receiver at the given host address and port number for sending messages with the specified diff --git a/ntpd/ntp.conf.man.in b/ntpd/ntp.conf.man.in index 548151d334c75..ef9e14dfe770c 100644 --- a/ntpd/ntp.conf.man.in +++ b/ntpd/ntp.conf.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntp.conf 5 "07 Apr 2015" "4.2.8p2" "File Formats" +.TH ntp.conf 5 "29 Jun 2015" "4.2.8p3" "File Formats" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-gKaW.1/ag-tKaO91) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-R0aO7B/ag-30aG6B) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:25:37 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:16 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agman-cmd.tpl .SH NAME @@ -35,7 +35,7 @@ All arguments must be options. The \f\*[B-Font]ntp.conf\fP configuration file is read at initial startup by the -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] daemon in order to specify the synchronization sources, modes and other related information. Usually, it is installed in the @@ -307,7 +307,7 @@ This is designed to speed the initial synchronization acquisition with the \f\*[B-Font]server\f[] command and s addresses and when -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] is started with the \f\*[B-Font]\-q\f[] option. @@ -528,7 +528,7 @@ and \f\*[B-Font]disable\f[] commands and also by remote configuration commands sent by a -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] program running in another machine. If this flag is enabled, which is the default @@ -595,15 +595,15 @@ secure means beyond the scope of the NTP protocol itself. Besides the keys used for ordinary NTP associations, additional keys can be used as passwords for the -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] and -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] utility programs. .sp \n(Ppu .ne 2 When -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] is first started, it reads the key file specified in the \f\*[B-Font]keys\f[] configuration command and installs the keys @@ -617,17 +617,17 @@ allows, for instance, the installation of possibly several batches of keys and then activating or deactivating each batch remotely using -\fCntpdc\fR(@NTPDC_MS@)\f[]. +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[]. This also provides a revocation capability that can be used if a key becomes compromised. The \f\*[B-Font]requestkey\f[] command selects the key used as the password for the -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] utility, while the \f\*[B-Font]controlkey\f[] command selects the key used as the password for the -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] utility. .SS Public Key Cryptography NTPv4 supports the original NTPv3 symmetric key scheme @@ -674,7 +674,7 @@ page. The specific cryptographic environment used by Autokey servers and clients is determined by a set of files and soft links generated by the -\fCntp-keygen\fR(1ntpkeygenmdoc)\f[] +\fCntp-keygen\f[]\fR(1ntpkeygenmdoc)\f[] program. This includes a required host key file, required certificate file and optional sign key file, @@ -721,7 +721,7 @@ DNS compromise is essential. By convention, the name of an Autokey host is the name returned by the Unix -\fCgethostname\fR(2)\f[] +\fCgethostname\f[]\fR(2)\f[] system call or equivalent in other systems. By the system design model, there are no provisions to allow alternate names or aliases. @@ -821,7 +821,7 @@ If verification fails, Bob sends Cathy a thing called a crypto-NAK, which tells her something broke. She can see the evidence using the -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] program. .sp \n(Ppu .ne 2 @@ -846,7 +846,7 @@ with one server and no authentication with another might not be wise. .SS Key Management The cryptographic values used by the Autokey protocol are incorporated as a set of files generated by the -\fCntp-keygen\fR(1ntpkeygenmdoc)\f[] +\fCntp-keygen\f[]\fR(1ntpkeygenmdoc)\f[] utility program, including symmetric key, host key and public certificate files, as well as sign key, identity parameters and leapseconds files. @@ -855,9 +855,9 @@ certificate files can be generated by the OpenSSL utilities and certificates can be imported from public certificate authorities. Note that symmetric keys are necessary for the -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] and -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] utility programs. The remaining files are necessary only for the Autokey protocol. @@ -895,7 +895,7 @@ sent. .TP 7 .NOP \f\*[B-Font]controlkey\f[] \f\*[I-Font]key\f[] Specifies the key identifier to use with the -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] utility, which uses the standard protocol defined in RFC-1305. The @@ -984,10 +984,10 @@ not found, the host key is also the sign key. .NOP \f\*[B-Font]keys\f[] \f\*[I-Font]keyfile\f[] Specifies the complete path and location of the MD5 key file containing the keys and key identifiers used by -\fCntpd\fR(@NTPD_MS@)\f[], -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[], +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] and -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] when operating with symmetric key cryptography. This is the same operation as the \f\*[B-Font]\-k\f[] @@ -1001,10 +1001,10 @@ The default is .TP 7 .NOP \f\*[B-Font]requestkey\f[] \f\*[I-Font]key\f[] Specifies the key identifier to use with the -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] utility program, which uses a proprietary protocol specific to this implementation of -\fCntpd\fR(@NTPD_MS@)\f[]. +\fCntpd\f[]\fR(@NTPD_MS@)\f[]. The \f\*[I-Font]key\f[] argument is a key identifier @@ -1027,9 +1027,9 @@ for every message sent. Specifies the key identifiers which are trusted for the purposes of authenticating peers with symmetric key cryptography, as well as keys used by the -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] and -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] programs. The authentication procedures require that both the local and remote servers share the same key and key identifier for this @@ -1106,7 +1106,7 @@ The certificate is missing, corrupted or bogus. The identity key is missing, corrupt or bogus. .PP .SH Monitoring Support -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] includes a comprehensive monitoring facility suitable for continuous, long term recording of server and client timekeeping performance. @@ -1122,7 +1122,7 @@ directory of this distribution. Using these facilities and UNIX -\fCcron\fR(8)\f[] +\fCcron\f[]\fR(8)\f[] jobs, the data can be automatically summarized and archived for retrospective analysis. .SS Monitoring Commands @@ -1348,7 +1348,7 @@ produced.) .ne 2 Note that this command can be sent from the -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] program running at a remote location. .RS .TP 7 @@ -1422,7 +1422,7 @@ server. This type does not perform any changes to file set members during runtime, however it provides an easy way of separating files belonging to different -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] server incarnations. The set member filename is built by appending a \[oq]\&.\[cq] @@ -1432,7 +1432,7 @@ and \f\*[I-Font]filename\f[] strings, and appending the decimal representation of the process ID of the -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] server process. .TP 7 .NOP \f\*[B-Font]day\f[] @@ -1524,7 +1524,7 @@ Enables or disables the recording function. .PP .SH Access Control Support The -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] daemon implements a general purpose address/mask based restriction list. The list contains address/match entries sorted first @@ -1672,9 +1672,9 @@ may be specified: .TP 7 .NOP \f\*[B-Font]ignore\f[] Deny packets of all kinds, including -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] and -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] queries. .TP 7 .NOP \f\*[B-Font]kod\f[] @@ -1690,7 +1690,7 @@ Deny service if the packet spacing violates the lower limits specified in the discard command. A history of clients is kept using the monitoring capability of -\fCntpd\fR(@NTPD_MS@)\f[]. +\fCntpd\f[]\fR(@NTPD_MS@)\f[]. Thus, monitoring is always active as long as there is a restriction entry with the \f\*[B-Font]limited\f[] @@ -1709,9 +1709,9 @@ be overridden by later requests for normal priority traps. .TP 7 .NOP \f\*[B-Font]nomodify\f[] Deny -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] and -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] queries which attempt to modify the state of the server (i.e., run time reconfiguration). Queries which return @@ -1719,9 +1719,9 @@ information are permitted. .TP 7 .NOP \f\*[B-Font]noquery\f[] Deny -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] and -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] queries. Time service is not affected. .TP 7 @@ -1746,9 +1746,9 @@ directive. .TP 7 .NOP \f\*[B-Font]noserve\f[] Deny all packets except -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] and -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] queries. .TP 7 .NOP \f\*[B-Font]notrap\f[] @@ -2078,11 +2078,11 @@ re-associate accordingly. .ne 2 Some administrators prefer to avoid running -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] continuously and run either -\fCntpdate\fR(8)\f[] +\fCntpdate\f[]\fR(8)\f[] or -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] \f\*[B-Font]\-q\f[] as a cron job. In either case the servers must be @@ -2090,7 +2090,7 @@ configured in advance and the program fails if none are available when the cron job runs. A really slick application of manycast is with -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] \f\*[B-Font]\-q\f[]. The program wakes up, scans the local landscape looking for the usual suspects, selects the best from among @@ -2260,7 +2260,7 @@ hazardous. .ne 2 For the purposes of configuration, -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] treats reference clocks in a manner analogous to normal NTP peers as much as possible. @@ -2348,7 +2348,7 @@ command as well. The stratum number of a reference clock is by default zero. Since the -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] daemon adds one to the stratum of each peer, a primary server ordinarily displays an external stratum of one. @@ -2422,7 +2422,7 @@ It must immediately follow the command which configures the driver. Note that the same capability is possible at run time using the -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] program. The options are interpreted as follows: @@ -2564,11 +2564,15 @@ The file is updated by first writing the current drift value into a temporary file and then renaming this file to replace the old version. This implies that -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] must have write permission for the directory the drift file is located in, and that file system links, symbolic or otherwise, should be avoided. .TP 7 +.NOP \f\*[B-Font]dscp\f[] \f\*[I-Font]value\f[] +This option specifies the Differentiated Services Control Point (DSCP) value, +a 6-bit code. The default value is 46, signifying Expedited Forwarding. +.TP 7 .NOP \f\*[B-Font]enable\f[] [\f\*[B-Font]auth\f[] | \f\*[B-Font]bclient\f[] | \f\*[B-Font]calibrate\f[] | \f\*[B-Font]kernel\f[] | \f\*[B-Font]mode7\f[] | \f\*[B-Font]monitor\f[] | \f\*[B-Font]ntp\f[] | \f\*[B-Font]stats\f[]] .TP 7 .NOP \f\*[B-Font]disable\f[] [\f\*[B-Font]auth\f[] | \f\*[B-Font]bclient\f[] | \f\*[B-Font]calibrate\f[] | \f\*[B-Font]kernel\f[] | \f\*[B-Font]mode7\f[] | \f\*[B-Font]monitor\f[] | \f\*[B-Font]ntp\f[] | \f\*[B-Font]stats\f[]] @@ -2576,7 +2580,7 @@ Provides a way to enable or disable various server options. Flags not mentioned are unaffected. Note that all of these flags can be controlled remotely using the -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] utility program. .RS .TP 7 @@ -2613,21 +2617,21 @@ if support is available, otherwise .NOP \f\*[B-Font]mode7\f[] Enables processing of NTP mode 7 implementation-specific requests which are used by the deprecated -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] program. The default for this flag is disable. This flag is excluded from runtime configuration using -\fCntpq\fR(@NTPQ_MS@)\f[]. +\fCntpq\f[]\fR(@NTPQ_MS@)\f[]. The -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] program provides the same capabilities as -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] using standard mode 6 requests. .TP 7 .NOP \f\*[B-Font]monitor\f[] Enables the monitoring facility. See the -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] program and the \f\*[B-Font]monlist\f[] @@ -2661,14 +2665,28 @@ be nested to a depth of five; upon reaching the end of any include file, command processing resumes in the previous configuration file. This option is useful for sites that run -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] on multiple hosts, with (mostly) common options (e.g., a restriction list). .TP 7 +.NOP \f\*[B-Font]leapsmearinterval\f[] \f\*[I-Font]seconds\f[] +This EXPERIMENTAL option is only available if +\fCntpd\f[]\fR(@NTPD_MS@)\f[] +was built with the +\f\*[B-Font]\--enable-leap-smear\f[] +option to the +\f\*[B-Font]configure\f[] +script. +It specifies the interval over which a leap second correction will be applied. +Recommended values for this option are between +7200 (2 hours) and 86400 (24 hours). +.Sy DO NOT USE THIS OPTION ON PUBLIC-ACCESS SERVERS! +See http://bugs.ntp.org/2855 for more information. +.TP 7 .NOP \f\*[B-Font]logconfig\f[] \f\*[I-Font]configkeyword\f[] This command controls the amount and type of output written to the system -\fCsyslog\fR(3)\f[] +\fCsyslog\f[]\fR(3)\f[] facility or the alternate \f\*[B-Font]logfile\f[] log file. @@ -2683,14 +2701,14 @@ and where \[oq]=\[cq] sets the -\fCsyslog\fR(3)\f[] +\fCsyslog\f[]\fR(3)\f[] priority mask, \[oq]+\[cq] adds and \[oq]\-\[cq] removes messages. -\fCsyslog\fR(3)\f[] +\fCsyslog\f[]\fR(3)\f[] messages can be controlled in four classes (\f\*[B-Font]clock\f[], \f\*[B-Font]peer\f[], \f\*[B-Font]sys\f[] and \f\*[B-Font]sync\f[]). @@ -2728,7 +2746,7 @@ logconfig =syncstatus +sysevents .ne 2 This would just list the synchronizations state of -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] and the major system events. For a simple reference server, the following minimum message configuration could be useful: @@ -2749,7 +2767,7 @@ peers, system events and so on is suppressed. .NOP \f\*[B-Font]logfile\f[] \f\*[I-Font]logfile\f[] This command specifies the location of an alternate log file to be used instead of the default system -\fCsyslog\fR(3)\f[] +\fCsyslog\f[]\fR(3)\f[] facility. This is the same operation as the \-l command line option. .TP 7 @@ -2764,7 +2782,7 @@ is followed by the \f\*[B-Font]default\f[] keyword, the variable will be listed as part of the default system variables -(\fCntpq\fR(@NTPQ_MS@)\f[] \f\*[B-Font]rv\f[] command)). +(\fCntpq\f[]\fR(@NTPQ_MS@)\f[] \f\*[B-Font]rv\f[] command)). These additional variables serve informational purposes only. They are not related to the protocol @@ -2888,12 +2906,12 @@ The default is 32 megabytes. Setting this to zero will prevent any attemp to loc .TP 7 .NOP \f\*[B-Font]stacksize\f[] \f\*[I-Font]N4kPages\f[] Specifies the maximum size of the process stack on systems with the +\fBmlockall\f[]\fR()\f[] +function. +Defaults to 50 4k pages (200 4k pages in OpenBSD). .TP 7 .NOP \f\*[B-Font]filenum\f[] \f\*[I-Font]Nfiledescriptors\f[] Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. -\fBmlockall\fR()\f[] -function. -Defaults to 50 4k pages (200 4k pages in OpenBSD). .RE .TP 7 .NOP \f\*[B-Font]trap\f[] \f\*[I-Font]host_address\f[] [\f\*[B-Font]port\f[] \f\*[I-Font]port_number\f[]] [\f\*[B-Font]interface\f[] \f\*[I-Font]interface_address\f[]] @@ -2986,9 +3004,9 @@ libopts had an internal operational error. Please report it to autogen-users@lists.sourceforge.net. Thank you. .PP .SH "SEE ALSO" -\fCntpd\fR(@NTPD_MS@)\f[], -\fCntpdc\fR(@NTPDC_MS@)\f[], -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[], +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[], +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] .sp \n(Ppu .ne 2 diff --git a/ntpd/ntp.conf.mdoc.in b/ntpd/ntp.conf.mdoc.in index da935ed697ee3..93c638d6edff5 100644 --- a/ntpd/ntp.conf.mdoc.in +++ b/ntpd/ntp.conf.mdoc.in @@ -1,9 +1,9 @@ -.Dd April 7 2015 +.Dd June 29 2015 .Dt NTP_CONF 5 File Formats .Os .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:25:57 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:36 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agmdoc-cmd.tpl .Sh NAME @@ -2386,6 +2386,9 @@ This implies that must have write permission for the directory the drift file is located in, and that file system links, symbolic or otherwise, should be avoided. +.It Ic dscp Ar value +This option specifies the Differentiated Services Control Point (DSCP) value, +a 6\-bit code. The default value is 46, signifying Expedited Forwarding. .It Xo Ic enable .Oo .Cm auth | Cm bclient | @@ -2485,6 +2488,19 @@ This option is useful for sites that run .Xr ntpd @NTPD_MS@ on multiple hosts, with (mostly) common options (e.g., a restriction list). +.It Ic leapsmearinterval Ar seconds +This EXPERIMENTAL option is only available if +.Xr ntpd @NTPD_MS@ +was built with the +.Cm \-\-enable\-leap\-smear +option to the +.Cm configure +script. +It specifies the interval over which a leap second correction will be applied. +Recommended values for this option are between +7200 (2 hours) and 86400 (24 hours). +.Sy DO NOT USE THIS OPTION ON PUBLIC\-ACCESS SERVERS! +See http://bugs.ntp.org/2855 for more information. .It Ic logconfig Ar configkeyword This command controls the amount and type of output written to the system @@ -2717,11 +2733,11 @@ option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. .It Cm stacksize Ar N4kPages Specifies the maximum size of the process stack on systems with the -.It Cm filenum Ar Nfiledescriptors -Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. .Fn mlockall function. Defaults to 50 4k pages (200 4k pages in OpenBSD). +.It Cm filenum Ar Nfiledescriptors +Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. .El .It Xo Ic trap Ar host_address .Op Cm port Ar port_number diff --git a/ntpd/ntp.keys.5man b/ntpd/ntp.keys.5man index a505afb90dc62..63d4553852aeb 100644 --- a/ntpd/ntp.keys.5man +++ b/ntpd/ntp.keys.5man @@ -1,8 +1,8 @@ -.TH ntp.keys 5man "07 Apr 2015" "4.2.8p2" "File Formats" +.TH ntp.keys 5man "29 Jun 2015" "4.2.8p3" "File Formats" .\" .\" EDIT THIS FILE WITH CAUTION (ntp.man) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:25:42 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:21 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agman-file.tpl .Sh NAME @@ -40,12 +40,12 @@ This document describes the format of an NTP symmetric key file. For a description of the use of this type of file, see the "Authentication Support" section of the -\fCntp.conf\fR(5)\f[] +\fCntp.conf\f[]\fR(5)\f[] page. .sp \n(Ppu .ne 2 -\fCntpd\fR(8)\f[] +\fCntpd\f[]\fR(8)\f[] reads its keys from a file specified using the \f\*[B-Font]\-k\f[] command line option or the @@ -140,9 +140,9 @@ which is truncated as necessary. .ne 2 Note that the keys used by the -\fCntpq\fR(8)\f[] +\fCntpq\f[]\fR(8)\f[] and -\fCntpdc\fR(8)\f[] +\fCntpdc\f[]\fR(8)\f[] programs are checked against passwords requested by the programs and entered by hand, so it is generally appropriate to specify these keys in ASCII format. @@ -152,11 +152,11 @@ so it is generally appropriate to specify these keys in ASCII format. the default name of the configuration file .PP .SH "SEE ALSO" -\fCntp.conf\fR(5)\f[], -\fCntpd\fR(1ntpdmdoc)\f[], -\fCntpdate\fR(1ntpdatemdoc)\f[], -\fCntpdc\fR(1ntpdcmdoc)\f[], -\fCsntp\fR(1sntpmdoc)\f[] +\fCntp.conf\f[]\fR(5)\f[], +\fCntpd\f[]\fR(1ntpdmdoc)\f[], +\fCntpdate\f[]\fR(1ntpdatemdoc)\f[], +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[], +\fCsntp\f[]\fR(1sntpmdoc)\f[] .SH "AUTHORS" The University of Delaware and Network Time Foundation .SH "COPYRIGHT" diff --git a/ntpd/ntp.keys.5mdoc b/ntpd/ntp.keys.5mdoc index a7157ec4e3940..47e5f81d258a3 100644 --- a/ntpd/ntp.keys.5mdoc +++ b/ntpd/ntp.keys.5mdoc @@ -1,9 +1,9 @@ -.Dd April 7 2015 +.Dd June 29 2015 .Dt NTP_KEYS 5mdoc File Formats .Os SunOS 5.10 .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:26:00 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:39 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agmdoc-file.tpl .Sh NAME diff --git a/ntpd/ntp.keys.html b/ntpd/ntp.keys.html index 98a22ef0aedb7..f096f63fc8374 100644 --- a/ntpd/ntp.keys.html +++ b/ntpd/ntp.keys.html @@ -33,7 +33,7 @@ Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> <p>This document describes the symmetric key file for the NTP Project's <code>ntpd</code> program. - <p>This document applies to version 4.2.8p2 of <code>ntp.keys</code>. + <p>This document applies to version 4.2.8p3 of <code>ntp.keys</code>. <div class="shortcontents"> <h2>Short Contents</h2> diff --git a/ntpd/ntp.keys.man.in b/ntpd/ntp.keys.man.in index c7585afa16f3f..1080b91bf0ed8 100644 --- a/ntpd/ntp.keys.man.in +++ b/ntpd/ntp.keys.man.in @@ -1,8 +1,8 @@ -.TH ntp.keys 5 "07 Apr 2015" "4.2.8p2" "File Formats" +.TH ntp.keys 5 "29 Jun 2015" "4.2.8p3" "File Formats" .\" .\" EDIT THIS FILE WITH CAUTION (ntp.man) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:25:42 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:21 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agman-file.tpl .Sh NAME @@ -40,12 +40,12 @@ This document describes the format of an NTP symmetric key file. For a description of the use of this type of file, see the "Authentication Support" section of the -\fCntp.conf\fR(5)\f[] +\fCntp.conf\f[]\fR(5)\f[] page. .sp \n(Ppu .ne 2 -\fCntpd\fR(8)\f[] +\fCntpd\f[]\fR(8)\f[] reads its keys from a file specified using the \f\*[B-Font]\-k\f[] command line option or the @@ -140,9 +140,9 @@ which is truncated as necessary. .ne 2 Note that the keys used by the -\fCntpq\fR(8)\f[] +\fCntpq\f[]\fR(8)\f[] and -\fCntpdc\fR(8)\f[] +\fCntpdc\f[]\fR(8)\f[] programs are checked against passwords requested by the programs and entered by hand, so it is generally appropriate to specify these keys in ASCII format. @@ -152,11 +152,11 @@ so it is generally appropriate to specify these keys in ASCII format. the default name of the configuration file .PP .SH "SEE ALSO" -\fCntp.conf\fR(5)\f[], -\fCntpd\fR(@NTPD_MS@)\f[], -\fCntpdate\fR(@NTPDATE_MS@)\f[], -\fCntpdc\fR(@NTPDC_MS@)\f[], -\fCsntp\fR(@SNTP_MS@)\f[] +\fCntp.conf\f[]\fR(5)\f[], +\fCntpd\f[]\fR(@NTPD_MS@)\f[], +\fCntpdate\f[]\fR(@NTPDATE_MS@)\f[], +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[], +\fCsntp\f[]\fR(@SNTP_MS@)\f[] .SH "AUTHORS" The University of Delaware and Network Time Foundation .SH "COPYRIGHT" diff --git a/ntpd/ntp.keys.mdoc.in b/ntpd/ntp.keys.mdoc.in index e6590db72fbbe..6bd1c0987c2cf 100644 --- a/ntpd/ntp.keys.mdoc.in +++ b/ntpd/ntp.keys.mdoc.in @@ -1,9 +1,9 @@ -.Dd April 7 2015 +.Dd June 29 2015 .Dt NTP_KEYS 5 File Formats .Os SunOS 5.10 .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:26:00 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:39 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agmdoc-file.tpl .Sh NAME diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index a224579d1cce9..300773240c74b 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -54,9 +54,6 @@ #include "ntpd-opts.h" -/* Bison still(!) does not emit usable prototypes for the calling code */ -int yyparse (struct FILE_INFO *ip_file); - /* list of servers from command line for config_peers() */ int cmdline_server_count; char ** cmdline_servers; @@ -134,8 +131,6 @@ typedef struct peer_resolved_ctx_tag { * Definitions of things either imported from or exported to outside */ extern int yydebug; /* ntp_parser.c (.y) */ -int curr_include_level; /* The current include level */ -struct FILE_INFO *fp[MAXINCLUDELEVEL+1]; config_tree cfgt; /* Parser output stored here */ struct config_tree_tag *cfg_tree_history; /* History of configs */ char *sys_phone[MAXPHONE] = {NULL}; /* ACTS phone numbers */ @@ -181,11 +176,6 @@ struct netinfo_config_state { struct REMOTE_CONFIG_INFO remote_config; /* Remote configuration buffer and pointer info */ -int input_from_file = 1; /* A boolean flag, which when set, indicates that - the input is to be taken from the configuration - file, instead of the remote-configuration buffer - */ - int old_config_style = 1; /* A boolean flag, which when set, * indicates that the old configuration * format with a newline at the end of @@ -257,7 +247,7 @@ static void free_config_tree(config_tree *ptree); static void destroy_restrict_node(restrict_node *my_node); static int is_sane_resolved_address(sockaddr_u *peeraddr, int hmode); -static void save_and_apply_config_tree(void); +static void save_and_apply_config_tree(int/*BOOL*/ from_file); static void destroy_int_fifo(int_fifo *); #define FREE_INT_FIFO(pf) \ do { \ @@ -314,7 +304,7 @@ static sockaddr_u *get_next_address(address_node *addr); static void config_sim(config_tree *); static void config_ntpdsim(config_tree *); #else /* !SIM follows */ -static void config_ntpd(config_tree *); +static void config_ntpd(config_tree *, int/*BOOL*/ input_from_file); static void config_other_modes(config_tree *); static void config_auth(config_tree *); static void config_access(config_tree *); @@ -326,7 +316,7 @@ static void config_trap(config_tree *); static void config_fudge(config_tree *); static void config_peers(config_tree *); static void config_unpeers(config_tree *); -static void config_nic_rules(config_tree *); +static void config_nic_rules(config_tree *, int/*BOOL*/ input_from_file); static void config_reset_counters(config_tree *); static u_char get_correct_host_mode(int token); static int peerflag_bits(peer_node *); @@ -2751,7 +2741,8 @@ free_config_tinker( #ifndef SIM static void config_nic_rules( - config_tree *ptree + config_tree *ptree, + int/*BOOL*/ input_from_file ) { nic_rule_node * curr_node; @@ -3502,6 +3493,11 @@ config_vars( stats_config(STATS_FREQ_FILE, curr_var->value.s); break; + case T_Dscp: + /* DSCP is in the upper 6 bits of the IP TOS/DS field */ + qos = curr_var->value.i << 2; + break; + case T_Ident: sys_ident = curr_var->value.s; break; @@ -3515,6 +3511,13 @@ config_vars( stats_config(STATS_LEAP_FILE, curr_var->value.s); break; +#ifdef LEAP_SMEAR + case T_Leapsmearinterval: + leap_smear_intv = curr_var->value.i; + msyslog(LOG_INFO, "config: leap smear interval %i s", leap_smear_intv); + break; +#endif + case T_Pidfile: stats_config(STATS_PID_FILE, curr_var->value.s); break; @@ -4224,7 +4227,7 @@ config_sim( serv_info = HEAD_PFIFO(sim_n->servers); for (; serv_info != NULL; serv_info = serv_info->link) simulation.num_of_servers++; - simulation.servers = emalloc(simulation.num_of_servers * + simulation.servers = eallocarray(simulation.num_of_servers, sizeof(simulation.servers[0])); i = 0; @@ -4295,11 +4298,11 @@ free_config_sim( #ifndef SIM static void config_ntpd( - config_tree *ptree + config_tree *ptree, + int/*BOOL*/ input_from_files ) { - config_nic_rules(ptree); - io_open_sockets(); + config_nic_rules(ptree, input_from_files); config_monitor(ptree); config_auth(ptree); config_tos(ptree); @@ -4314,6 +4317,9 @@ config_ntpd( config_ttl(ptree); config_trap(ptree); config_vars(ptree); + + io_open_sockets(); + config_other_modes(ptree); config_peers(ptree); config_unpeers(ptree); @@ -4370,28 +4376,22 @@ config_remotely( sockaddr_u * remote_addr ) { - struct FILE_INFO remote_cuckoo; char origin[128]; snprintf(origin, sizeof(origin), "remote config from %s", stoa(remote_addr)); - ZERO(remote_cuckoo); - remote_cuckoo.fname = origin; - remote_cuckoo.line_no = 1; - remote_cuckoo.col_no = 1; - input_from_file = 0; - + lex_init_stack(origin, NULL); /* no checking needed... */ init_syntax_tree(&cfgt); - yyparse(&remote_cuckoo); + yyparse(); + lex_drop_stack(); + cfgt.source.attr = CONF_SOURCE_NTPQ; cfgt.timestamp = time(NULL); cfgt.source.value.s = estrdup(stoa(remote_addr)); DPRINTF(1, ("Finished Parsing!!\n")); - save_and_apply_config_tree(); - - input_from_file = 1; + save_and_apply_config_tree(FALSE); } @@ -4443,9 +4443,8 @@ getconfig( getCmdOpts(argc, argv); init_syntax_tree(&cfgt); - curr_include_level = 0; if ( - (fp[curr_include_level] = F_OPEN(FindConfig(config_file), "r")) == NULL + !lex_init_stack(FindConfig(config_file), "r") #ifdef HAVE_NETINFO /* If there is no config_file, try NetInfo. */ && check_netinfo && !(config_netinfo = get_netinfo_config()) @@ -4459,8 +4458,7 @@ getconfig( #else /* Under WinNT try alternate_config_file name, first NTP.CONF, then NTP.INI */ - if ((fp[curr_include_level] = F_OPEN(FindConfig(alt_config_file), "r")) == NULL) { - + if (!lex_init_stack(FindConfig(alt_config_file), "r")) { /* * Broadcast clients can sometimes run without * a configuration file. @@ -4480,17 +4478,15 @@ getconfig( #ifdef DEBUG yydebug = !!(debug >= 5); #endif - yyparse(fp[curr_include_level]); + yyparse(); + lex_drop_stack(); DPRINTF(1, ("Finished Parsing!!\n")); cfgt.source.attr = CONF_SOURCE_FILE; cfgt.timestamp = time(NULL); - save_and_apply_config_tree(); - - while (curr_include_level != -1) - FCLOSE(fp[curr_include_level--]); + save_and_apply_config_tree(TRUE); #ifdef HAVE_NETINFO if (config_netinfo) @@ -4500,7 +4496,7 @@ getconfig( void -save_and_apply_config_tree(void) +save_and_apply_config_tree(int/*BOOL*/ input_from_file) { config_tree *ptree; #ifndef SAVECONFIG @@ -4554,7 +4550,7 @@ save_and_apply_config_tree(void) */ #ifndef SIM - config_ntpd(ptree); + config_ntpd(ptree, input_from_file); #else config_ntpdsim(ptree); #endif @@ -4785,8 +4781,9 @@ gettokens_netinfo ( if (namelist.ni_namelist_len == 0) continue; config->val_list = - emalloc(sizeof(char*) * - (namelist.ni_namelist_len + 1)); + eallocarray( + (namelist.ni_namelist_len + 1), + sizeof(char*)); val_list = config->val_list; for (index = 0; @@ -4936,7 +4933,7 @@ ntp_rlimit( case RLIMIT_NOFILE: /* * For large systems the default file descriptor limit may - * not be enough. + * not be enough. */ DPRINTF(2, ("ntp_rlimit: NOFILE: %d %s\n", (int)(rl_value / rl_scale), rl_sstr)); @@ -4956,7 +4953,7 @@ ntp_rlimit( DPRINTF(2, ("ntp_rlimit: STACK: %d %s pages\n", (int)(rl_value / rl_scale), rl_sstr)); if (-1 == getrlimit(RLIMIT_STACK, &rl)) { - msyslog(LOG_ERR, "getrlimit() failed: %m"); + msyslog(LOG_ERR, "getrlimit(RLIMIT_STACK) failed: %m"); } else { if (rl_value > rl.rlim_max) { msyslog(LOG_WARNING, @@ -4965,9 +4962,10 @@ ntp_rlimit( (u_long)rl_value); rl_value = rl.rlim_max; } + rl.rlim_cur = rl_value; if (-1 == setrlimit(RLIMIT_STACK, &rl)) { msyslog(LOG_ERR, - "ntp_rlimit: Cannot adjust stack limit: %m"); + "ntp_rlimit: Cannot set RLIMIT_STACK: %m"); } } break; diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index aa9f78cb02909..89c2f00c11b44 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -32,6 +32,7 @@ # include "ntp_syscall.h" #endif +extern size_t remoteconfig_cmdlength( const char *src_buf, const char *src_end ); /* * Structure to hold request procedure information @@ -221,7 +222,9 @@ static const struct ctl_proc control_codes[] = { #define CS_TIMER_XMTS 87 #define CS_FUZZ 88 #define CS_WANDER_THRESH 89 -#define CS_MAX_NOAUTOKEY CS_WANDER_THRESH +#define CS_LEAPSMEARINTV 90 +#define CS_LEAPSMEAROFFS 91 +#define CS_MAX_NOAUTOKEY CS_LEAPSMEAROFFS #ifdef AUTOKEY #define CS_FLAGS (1 + CS_MAX_NOAUTOKEY) #define CS_HOST (2 + CS_MAX_NOAUTOKEY) @@ -417,6 +420,10 @@ static const struct ctl_var sys_var[] = { { CS_TIMER_XMTS, RO, "timer_xmts" }, /* 87 */ { CS_FUZZ, RO, "fuzz" }, /* 88 */ { CS_WANDER_THRESH, RO, "clk_wander_threshold" }, /* 89 */ +#ifdef LEAP_SMEAR + { CS_LEAPSMEARINTV, RO, "leapsmearinterval" }, /* 90 */ + { CS_LEAPSMEAROFFS, RO, "leapsmearoffset" }, /* 91 */ +#endif /* LEAP_SMEAR */ #ifdef AUTOKEY { CS_FLAGS, RO, "flags" }, /* 1 + CS_MAX_NOAUTOKEY */ { CS_HOST, RO, "host" }, /* 2 + CS_MAX_NOAUTOKEY */ @@ -459,6 +466,8 @@ static const u_char def_sys_var[] = { CS_TAI, CS_LEAPTAB, CS_LEAPEND, + CS_LEAPSMEARINTV, + CS_LEAPSMEAROFFS, #ifdef AUTOKEY CS_HOST, CS_IDENT, @@ -1972,6 +1981,19 @@ ctl_putsys( break; } +#ifdef LEAP_SMEAR + case CS_LEAPSMEARINTV: + if (leap_smear_intv > 0) + ctl_putuint(sys_var[CS_LEAPSMEARINTV].text, leap_smear_intv); + break; + + case CS_LEAPSMEAROFFS: + if (leap_smear_intv > 0) + ctl_putdbl(sys_var[CS_LEAPSMEAROFFS].text, + leap_smear.doffset * 1e3); + break; +#endif /* LEAP_SMEAR */ + case CS_RATE: ctl_putuint(sys_var[CS_RATE].text, ntp_minpoll); break; @@ -3281,6 +3303,7 @@ write_variables( ctl_flushpkt(0); } + /* * configure() processes ntpq :config/config-from-file, allowing * generic runtime reconfiguration. @@ -3292,7 +3315,6 @@ static void configure( { size_t data_count; int retval; - int replace_nl; /* I haven't yet implemented changes to an existing association. * Hence check if the association id is 0 @@ -3318,7 +3340,7 @@ static void configure( } /* Initialize the remote config buffer */ - data_count = reqend - reqpt; + data_count = remoteconfig_cmdlength(reqpt, reqend); if (data_count > sizeof(remote_config.buffer) - 2) { snprintf(remote_config.err_msg, @@ -3332,34 +3354,41 @@ static void configure( stoa(&rbufp->recv_srcadr)); return; } + /* Bug 2853 -- check if all characters were acceptable */ + if (data_count != (size_t)(reqend - reqpt)) { + snprintf(remote_config.err_msg, + sizeof(remote_config.err_msg), + "runtime configuration failed: request contains an unprintable character"); + ctl_putdata(remote_config.err_msg, + strlen(remote_config.err_msg), 0); + ctl_flushpkt(0); + msyslog(LOG_NOTICE, + "runtime config from %s rejected: request contains an unprintable character: %0x", + stoa(&rbufp->recv_srcadr), + reqpt[data_count]); + return; + } memcpy(remote_config.buffer, reqpt, data_count); - if (data_count > 0 - && '\n' != remote_config.buffer[data_count - 1]) - remote_config.buffer[data_count++] = '\n'; + /* The buffer has no trailing linefeed or NUL right now. For + * logging, we do not want a newline, so we do that first after + * adding the necessary NUL byte. + */ remote_config.buffer[data_count] = '\0'; - remote_config.pos = 0; - remote_config.err_pos = 0; - remote_config.no_errors = 0; - - /* do not include terminating newline in log */ - if (data_count > 0 - && '\n' == remote_config.buffer[data_count - 1]) { - remote_config.buffer[data_count - 1] = '\0'; - replace_nl = TRUE; - } else { - replace_nl = FALSE; - } - DPRINTF(1, ("Got Remote Configuration Command: %s\n", remote_config.buffer)); msyslog(LOG_NOTICE, "%s config: %s", stoa(&rbufp->recv_srcadr), remote_config.buffer); - if (replace_nl) - remote_config.buffer[data_count - 1] = '\n'; - + /* Now we have to make sure there is a NL/NUL sequence at the + * end of the buffer before we parse it. + */ + remote_config.buffer[data_count++] = '\n'; + remote_config.buffer[data_count] = '\0'; + remote_config.pos = 0; + remote_config.err_pos = 0; + remote_config.no_errors = 0; config_remotely(&rbufp->recv_srcadr); /* diff --git a/ntpd/ntp_crypto.c b/ntpd/ntp_crypto.c index 5795ae8dfdd79..45b2cdd00d313 100644 --- a/ntpd/ntp_crypto.c +++ b/ntpd/ntp_crypto.c @@ -316,8 +316,8 @@ make_keylist( */ tstamp = crypto_time(); if (peer->keylist == NULL) - peer->keylist = emalloc(sizeof(keyid_t) * - NTP_MAXSESSION); + peer->keylist = eallocarray(NTP_MAXSESSION, + sizeof(keyid_t)); /* * Generate an initial key ID which is unique and greater than @@ -380,16 +380,14 @@ make_keylist( EVP_SignUpdate(&ctx, (u_char *)vp, 12); EVP_SignUpdate(&ctx, vp->ptr, sizeof(struct autokey)); if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { - vp->siglen = htonl(sign_siglen); + NTP_INSIST(len <= sign_siglen); + vp->siglen = htonl(len); peer->flags |= FLAG_ASSOC; } } -#ifdef DEBUG - if (debug) - printf("make_keys: %d %08x %08x ts %u fs %u poll %d\n", + DPRINTF(1, ("make_keys: %d %08x %08x ts %u fs %u poll %d\n", peer->keynumber, keyid, cookie, ntohl(vp->tstamp), - ntohl(vp->fstamp), peer->hpoll); -#endif + ntohl(vp->fstamp), peer->hpoll)); return (XEVNT_OK); } @@ -456,13 +454,9 @@ crypto_recv( // HMS: Why pkt[1] instead of ep->associd ? associd = (associd_t)ntohl(pkt[1]); rval = XEVNT_OK; -#ifdef DEBUG - if (debug) - printf( - "crypto_recv: flags 0x%x ext offset %d len %u code 0x%x associd %d\n", + DPRINTF(1, ("crypto_recv: flags 0x%x ext offset %d len %u code 0x%x associd %d\n", peer->crypto, authlen, len, code >> 16, - associd); -#endif + associd)); /* * Check version number and field length. If bad, @@ -538,13 +532,9 @@ crypto_recv( rval = XEVNT_LEN; break; } -#ifdef DEBUG - if (debug) - printf( - "crypto_recv: ident host 0x%x %d server 0x%x %d\n", + DPRINTF(1, ("crypto_recv: ident host 0x%x %d server 0x%x %d\n", crypto_flags, peer->associd, fstamp, - peer->assoc); -#endif + peer->assoc)); temp32 = crypto_flags & CRYPTO_FLAG_MASK; /* @@ -617,10 +607,7 @@ crypto_recv( peer->assoc, peer->subject, OBJ_nid2ln(temp32)); record_crypto_stats(&peer->srcadr, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_recv: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_recv: %s\n", statstr)); break; /* @@ -678,10 +665,7 @@ crypto_recv( OBJ_nid2ln(temp32), temp32, ntohl(ep->fstamp)); record_crypto_stats(&peer->srcadr, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_recv: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_recv: %s\n", statstr)); break; /* @@ -718,10 +702,7 @@ crypto_recv( snprintf(statstr, sizeof(statstr), "iff %s fs %u", peer->issuer, ntohl(ep->fstamp)); record_crypto_stats(&peer->srcadr, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_recv: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_recv: %s\n", statstr)); break; /* @@ -759,10 +740,7 @@ crypto_recv( snprintf(statstr, sizeof(statstr), "gq %s fs %u", peer->issuer, ntohl(ep->fstamp)); record_crypto_stats(&peer->srcadr, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_recv: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_recv: %s\n", statstr)); break; /* @@ -799,10 +777,7 @@ crypto_recv( snprintf(statstr, sizeof(statstr), "mv %s fs %u", peer->issuer, ntohl(ep->fstamp)); record_crypto_stats(&peer->srcadr, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_recv: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_recv: %s\n", statstr)); break; @@ -868,10 +843,7 @@ crypto_recv( "cook %x ts %u fs %u", peer->pcookie, ntohl(ep->tstamp), ntohl(ep->fstamp)); record_crypto_stats(&peer->srcadr, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_recv: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_recv: %s\n", statstr)); break; /* @@ -930,10 +902,7 @@ crypto_recv( bp->key, ntohl(ep->tstamp), ntohl(ep->fstamp)); record_crypto_stats(&peer->srcadr, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_recv: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_recv: %s\n", statstr)); break; /* @@ -970,10 +939,7 @@ crypto_recv( OBJ_nid2ln(temp32), temp32, ntohl(ep->fstamp)); record_crypto_stats(&peer->srcadr, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_recv: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_recv: %s\n", statstr)); break; /* @@ -988,43 +954,32 @@ crypto_recv( * compare the value timestamps here, as they * can be updated by different servers. */ - if ((rval = crypto_verify(ep, NULL, peer)) != - XEVNT_OK) + rval = crypto_verify(ep, NULL, peer); + if ((rval != XEVNT_OK ) || + (vallen != 3*sizeof(uint32_t)) ) break; - /* - * If the packet leap values are more recent - * than the stored ones, install the new leap - * values and recompute the signatures. + /* Check if we can update the basic TAI offset + * for our current leap frame. This is a hack + * and ignores the time stamps in the autokey + * message. */ - if (leapsec_add_fix(ntohl(ep->pkt[0]), - ntohl(ep->pkt[1]), - ntohl(ep->pkt[2]), - NULL)) - { - leap_signature_t lsig; - - leapsec_getsig(&lsig); - tai_leap.tstamp = ep->tstamp; - tai_leap.fstamp = ep->fstamp; - tai_leap.vallen = ep->vallen; - crypto_update(); - mprintf_event(EVNT_TAI, peer, - "%d leap %s expire %s", lsig.taiof, - fstostr(lsig.ttime), - fstostr(lsig.etime)); - } + if (sys_leap != LEAP_NOTINSYNC) + leapsec_autokey_tai(ntohl(ep->pkt[0]), + rbufp->recv_time.l_ui, NULL); + tai_leap.tstamp = ep->tstamp; + tai_leap.fstamp = ep->fstamp; + crypto_update(); + mprintf_event(EVNT_TAI, peer, + "%d seconds", ntohl(ep->pkt[0])); peer->crypto |= CRYPTO_FLAG_LEAP; peer->flash &= ~TEST8; snprintf(statstr, sizeof(statstr), - "leap TAI offset %d at %u expire %u fs %u", - ntohl(ep->pkt[0]), ntohl(ep->pkt[1]), - ntohl(ep->pkt[2]), ntohl(ep->fstamp)); + "leap TAI offset %d at %u expire %u fs %u", + ntohl(ep->pkt[0]), ntohl(ep->pkt[1]), + ntohl(ep->pkt[2]), ntohl(ep->fstamp)); record_crypto_stats(&peer->srcadr, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_recv: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_recv: %s\n", statstr)); break; /* @@ -1073,10 +1028,7 @@ crypto_recv( "%04x %d %02x %s", htonl(ep->opcode), associd, rval, eventstr(rval)); record_crypto_stats(&peer->srcadr, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_recv: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_recv: %s\n", statstr)); return (rval); } authlen += (len + 3) / 4 * 4; @@ -1421,19 +1373,12 @@ crypto_xmit( "%04x %d %02x %s", opcode, associd, rval, eventstr(rval)); record_crypto_stats(srcadr_sin, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_xmit: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_xmit: %s\n", statstr)); if (!(opcode & CRYPTO_RESP)) return (0); } -#ifdef DEBUG - if (debug) - printf( - "crypto_xmit: flags 0x%x offset %d len %d code 0x%x associd %d\n", - crypto_flags, start, len, opcode >> 16, associd); -#endif + DPRINTF(1, ("crypto_xmit: flags 0x%x offset %d len %d code 0x%x associd %d\n", + crypto_flags, start, len, opcode >> 16, associd)); return (len); } @@ -1645,8 +1590,10 @@ crypto_encrypt( EVP_SignInit(&ctx, sign_digest); EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, vallen); - if (EVP_SignFinal(&ctx, vp->sig, &vallen, sign_pkey)) - vp->siglen = htonl(sign_siglen); + if (EVP_SignFinal(&ctx, vp->sig, &vallen, sign_pkey)) { + NTP_INSIST(vallen <= sign_siglen); + vp->siglen = htonl(vallen); + } return (XEVNT_OK); } @@ -1858,7 +1805,7 @@ crypto_update(void) char statstr[NTP_MAXSTRLEN]; /* statistics for filegen */ u_int32 *ptr; u_int len; - leap_signature_t lsig; + leap_result_t leap_data; hostval.tstamp = htonl(crypto_time()); if (hostval.tstamp == 0) @@ -1877,8 +1824,10 @@ crypto_update(void) EVP_SignInit(&ctx, sign_digest); EVP_SignUpdate(&ctx, (u_char *)&pubkey, 12); EVP_SignUpdate(&ctx, pubkey.ptr, ntohl(pubkey.vallen)); - if (EVP_SignFinal(&ctx, pubkey.sig, &len, sign_pkey)) - pubkey.siglen = htonl(sign_siglen); + if (EVP_SignFinal(&ctx, pubkey.sig, &len, sign_pkey)) { + NTP_INSIST(len <= sign_siglen); + pubkey.siglen = htonl(len); + } } /* @@ -1896,8 +1845,10 @@ crypto_update(void) EVP_SignUpdate(&ctx, (u_char *)&cp->cert, 12); EVP_SignUpdate(&ctx, cp->cert.ptr, ntohl(cp->cert.vallen)); - if (EVP_SignFinal(&ctx, cp->cert.sig, &len, sign_pkey)) - cp->cert.siglen = htonl(sign_siglen); + if (EVP_SignFinal(&ctx, cp->cert.sig, &len, sign_pkey)) { + NTP_INSIST(len <= sign_siglen); + cp->cert.siglen = htonl(len); + } } /* @@ -1906,33 +1857,86 @@ crypto_update(void) */ tai_leap.tstamp = hostval.tstamp; tai_leap.fstamp = hostval.fstamp; + + /* Get the leap second era. We might need a full lookup early + * after start, when the cache is not yet loaded. + */ + leapsec_frame(&leap_data); + if ( ! memcmp(&leap_data.ebase, &leap_data.ttime, sizeof(vint64))) { + time_t now = time(NULL); + uint32_t nowntp = (uint32_t)now + JAN_1970; + leapsec_query(&leap_data, nowntp, &now); + } + + /* Create the data block. The protocol does not work without. */ len = 3 * sizeof(u_int32); - if (tai_leap.ptr == NULL) + if (tai_leap.ptr == NULL || ntohl(tai_leap.vallen) != len) { + free(tai_leap.ptr); tai_leap.ptr = emalloc(len); - tai_leap.vallen = htonl(len); + tai_leap.vallen = htonl(len); + } ptr = (u_int32 *)tai_leap.ptr; - leapsec_getsig(&lsig); - ptr[0] = htonl(lsig.taiof); - ptr[1] = htonl(lsig.ttime); - ptr[2] = htonl(lsig.etime); + if (leap_data.tai_offs > 10) { + /* create a TAI / leap era block. The end time is a + * fake -- maybe we can do better. + */ + ptr[0] = htonl(leap_data.tai_offs); + ptr[1] = htonl(leap_data.ebase.d_s.lo); + if (leap_data.ttime.d_s.hi >= 0) + ptr[2] = htonl(leap_data.ttime.D_s.lo + 7*86400); + else + ptr[2] = htonl(leap_data.ebase.D_s.lo + 25*86400); + } else { + /* no leap era available */ + memset(ptr, 0, len); + } if (tai_leap.sig == NULL) tai_leap.sig = emalloc(sign_siglen); EVP_SignInit(&ctx, sign_digest); EVP_SignUpdate(&ctx, (u_char *)&tai_leap, 12); EVP_SignUpdate(&ctx, tai_leap.ptr, len); - if (EVP_SignFinal(&ctx, tai_leap.sig, &len, sign_pkey)) - tai_leap.siglen = htonl(sign_siglen); - if (lsig.ttime > 0) - crypto_flags |= CRYPTO_FLAG_TAI; + if (EVP_SignFinal(&ctx, tai_leap.sig, &len, sign_pkey)) { + NTP_INSIST(len <= sign_siglen); + tai_leap.siglen = htonl(len); + } + crypto_flags |= CRYPTO_FLAG_TAI; + snprintf(statstr, sizeof(statstr), "signature update ts %u", ntohl(hostval.tstamp)); record_crypto_stats(NULL, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_update: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_update: %s\n", statstr)); } +/* + * crypto_update_taichange - eventually trigger crypto_update + * + * This is called when a change in 'sys_tai' is detected. This will + * happen shortly after a leap second is detected, but unhappily also + * early after system start; also, the crypto stuff might be unused and + * an unguarded call to crypto_update() causes a crash. + * + * This function makes sure that there already *is* a valid crypto block + * for the use with autokey, and only calls 'crypto_update()' if it can + * succeed. + * + * Returns void (no errors) + */ +void +crypto_update_taichange(void) +{ + static const u_int len = 3 * sizeof(u_int32); + + /* check if the signing digest algo is available */ + if (sign_digest == NULL || sign_pkey == NULL) + return; + + /* check size of TAI extension block */ + if (tai_leap.ptr == NULL || ntohl(tai_leap.vallen) != len) + return; + + /* crypto_update should at least not crash here! */ + crypto_update(); +} /* * value_free - free value structure components. @@ -2164,8 +2168,10 @@ crypto_alice( EVP_SignInit(&ctx, sign_digest); EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); - if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) - vp->siglen = htonl(sign_siglen); + if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { + NTP_INSIST(len <= sign_siglen); + vp->siglen = htonl(len); + } return (XEVNT_OK); } @@ -2272,8 +2278,10 @@ crypto_bob( EVP_SignInit(&ctx, sign_digest); EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, vallen); - if (EVP_SignFinal(&ctx, vp->sig, &vallen, sign_pkey)) - vp->siglen = htonl(sign_siglen); + if (EVP_SignFinal(&ctx, vp->sig, &vallen, sign_pkey)) { + NTP_INSIST(vallen <= sign_siglen); + vp->siglen = htonl(vallen); + } return (XEVNT_OK); } @@ -2477,8 +2485,10 @@ crypto_alice2( EVP_SignInit(&ctx, sign_digest); EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); - if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) - vp->siglen = htonl(sign_siglen); + if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { + NTP_INSIST(len <= sign_siglen); + vp->siglen = htonl(len); + } return (XEVNT_OK); } @@ -2575,8 +2585,10 @@ crypto_bob2( EVP_SignInit(&ctx, sign_digest); EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); - if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) - vp->siglen = htonl(sign_siglen); + if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { + NTP_INSIST(len <= sign_siglen); + vp->siglen = htonl(len); + } return (XEVNT_OK); } @@ -2804,8 +2816,10 @@ crypto_alice3( EVP_SignInit(&ctx, sign_digest); EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); - if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) - vp->siglen = htonl(sign_siglen); + if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { + NTP_INSIST(len <= sign_siglen); + vp->siglen = htonl(len); + } return (XEVNT_OK); } @@ -2904,8 +2918,10 @@ crypto_bob3( EVP_SignInit(&ctx, sign_digest); EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); - if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) - vp->siglen = htonl(sign_siglen); + if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { + NTP_INSIST(len <= sign_siglen); + vp->siglen = htonl(len); + } return (XEVNT_OK); } @@ -3141,8 +3157,10 @@ cert_sign( EVP_SignInit(&ctx, sign_digest); EVP_SignUpdate(&ctx, (u_char *)vp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); - if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) - vp->siglen = htonl(sign_siglen); + if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { + NTP_INSIST(len <= sign_siglen); + vp->siglen = htonl(len); + } } #ifdef DEBUG if (debug > 1) @@ -3425,11 +3443,8 @@ cert_parse( ret->flags |= CERT_TRUST; else if (strcmp(pathbuf, "Private") == 0) ret->flags |= CERT_PRIV; -#if DEBUG - if (debug) - printf("cert_parse: %s: %s\n", - OBJ_nid2ln(temp), pathbuf); -#endif + DPRINTF(1, ("cert_parse: %s: %s\n", + OBJ_nid2ln(temp), pathbuf)); break; /* @@ -3440,12 +3455,10 @@ cert_parse( ret->grpkey = BN_bin2bn(&ext->value->data[2], ext->value->length - 2, NULL); /* fall through */ -#if DEBUG default: - if (debug) - printf("cert_parse: %s\n", - OBJ_nid2ln(temp)); -#endif + DPRINTF(1, ("cert_parse: %s\n", + OBJ_nid2ln(temp))); + break; } } if (strcmp(ret->subject, ret->issuer) == 0) { @@ -3630,9 +3643,9 @@ crypto_key( snprintf(statstr, sizeof(statstr), "%s mod %d", &linkname[2], EVP_PKEY_size(pkey) * 8); record_crypto_stats(addr, statstr); + + DPRINTF(1, ("crypto_key: %s\n", statstr)); #ifdef DEBUG - if (debug) - printf("crypto_key: %s\n", statstr); if (debug > 1) { if (pkey->type == EVP_PKEY_DSA) DSA_print_fp(stdout, pkey->pkey.dsa, 0); @@ -3747,10 +3760,7 @@ crypto_cert( snprintf(statstr, sizeof(statstr), "%s 0x%x len %lu", &linkname[2], ret->flags, len); record_crypto_stats(NULL, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_cert: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_cert: %s\n", statstr)); return (ret); } @@ -3820,12 +3830,8 @@ crypto_setup(void) get_systime(&seed); RAND_seed(&seed, sizeof(l_fp)); RAND_write_file(randfile); -#ifdef DEBUG - if (debug) - printf( - "crypto_setup: OpenSSL version %lx random seed file %s bytes read %d\n", - SSLeay(), randfile, bytes); -#endif + DPRINTF(1, ("crypto_setup: OpenSSL version %lx random seed file %s bytes read %d\n", + SSLeay(), randfile, bytes)); } /* @@ -3954,10 +3960,7 @@ crypto_setup(void) snprintf(statstr, sizeof(statstr), "setup 0x%x host %s %s", crypto_flags, hostname, OBJ_nid2ln(cinfo->nid)); record_crypto_stats(NULL, statstr); -#ifdef DEBUG - if (debug) - printf("crypto_setup: %s\n", statstr); -#endif + DPRINTF(1, ("crypto_setup: %s\n", statstr)); } @@ -3972,10 +3975,8 @@ crypto_config( { int nid; -#ifdef DEBUG - if (debug > 1) - printf("crypto_config: item %d %s\n", item, cp); -#endif + DPRINTF(1, ("crypto_config: item %d %s\n", item, cp)); + switch (item) { /* diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 1ee7098ae1643..a93733f824a26 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -73,6 +73,19 @@ extern int listen_to_virtual_ips; +#ifndef IPTOS_DSCP_EF +#define IPTOS_DSCP_EF 0xb8 +#endif +int qos = IPTOS_DSCP_EF; /* QoS RFC3246 */ + +#ifdef LEAP_SMEAR +/* TODO burnicki: This should be moved to ntp_timer.c, but if we do so + * we get a linker error. Since we're running out of time before the leap + * second occurs, we let it here where it just works. + */ +int leap_smear_intv; +#endif + /* * NIC rule entry */ @@ -2009,6 +2022,32 @@ update_interfaces( if (sys_bclient) io_setbclient(); + /* + * Check multicast interfaces and try to join multicast groups if + * not joined yet. + */ + for (ep = ep_list; ep != NULL; ep = ep->elink) { + remaddr_t *entry; + + if (!(INT_MCASTIF & ep->flags) || (INT_MCASTOPEN & ep->flags)) + continue; + + /* Find remote address that was linked to this interface */ + for (entry = remoteaddr_list; + entry != NULL; + entry = entry->link) { + if (entry->ep == ep) { + if (socket_multicast_enable(ep, &entry->addr)) { + msyslog(LOG_INFO, + "Joined %s socket to multicast group %s", + stoa(&ep->sin), + stoa(&entry->addr)); + } + break; + } + } + } + return new_interface_found; } @@ -2432,12 +2471,12 @@ socket_multicast_enable( IP_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq))) { - msyslog(LOG_ERR, + DPRINTF(2, ( "setsockopt IP_ADD_MEMBERSHIP failed: %m on socket %d, addr %s for %x / %x (%s)", iface->fd, stoa(&iface->sin), mreq.imr_multiaddr.s_addr, mreq.imr_interface.s_addr, - stoa(maddr)); + stoa(maddr))); return ISC_FALSE; } DPRINTF(4, ("Added IPv4 multicast membership on socket %d, addr %s for %x / %x (%s)\n", @@ -2462,10 +2501,10 @@ socket_multicast_enable( if (setsockopt(iface->fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *)&mreq6, sizeof(mreq6))) { - msyslog(LOG_ERR, + DPRINTF(2, ( "setsockopt IPV6_JOIN_GROUP failed: %m on socket %d, addr %s for interface %u (%s)", iface->fd, stoa(&iface->sin), - mreq6.ipv6mr_interface, stoa(maddr)); + mreq6.ipv6mr_interface, stoa(maddr))); return ISC_FALSE; } DPRINTF(4, ("Added IPv6 multicast group on socket %d, addr %s for interface %u (%s)\n", @@ -2767,11 +2806,6 @@ io_multicast_add( "Joined %s socket to multicast group %s", stoa(&ep->sin), stoa(addr)); - else - msyslog(LOG_ERR, - "Failed to join %s socket to multicast group %s", - stoa(&ep->sin), - stoa(addr)); } add_addr_to_list(addr, one_ep); @@ -2842,11 +2876,6 @@ open_socket( int on = 1; int off = 0; -#ifndef IPTOS_DSCP_EF -#define IPTOS_DSCP_EF 0xb8 -#endif - int qos = IPTOS_DSCP_EF; /* QoS RFC3246 */ - if (IS_IPV6(addr) && !ipv6_works) return INVALID_SOCKET; @@ -3576,7 +3605,7 @@ io_handler(void) else if (debug > 4) { msyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound); } else { - DPRINTF(1, ("select() returned %d: %m\n", nfound)); + DPRINTF(3, ("select() returned %d: %m\n", nfound)); } # endif /* DEBUG */ # else /* HAVE_SIGNALED_IO */ diff --git a/ntpd/ntp_keyword.h b/ntpd/ntp_keyword.h index 723793636b7e6..0a593f69dd21a 100644 --- a/ntpd/ntp_keyword.h +++ b/ntpd/ntp_keyword.h @@ -2,7 +2,7 @@ * ntp_keyword.h * * NOTE: edit this file with caution, it is generated by keyword-gen.c - * Generated 2015-03-16 09:05:44 UTC diff_ignore_line + * Generated 2015-06-25 03:57:00 UTC diff_ignore_line * */ #include "ntp_scanner.h" @@ -10,7 +10,7 @@ #define LOWEST_KEYWORD_ID 258 -const char * const keyword_text[189] = { +const char * const keyword_text[191] = { /* 0 258 T_Abbrev */ "abbrev", /* 1 259 T_Age */ "age", /* 2 260 T_All */ "all", @@ -43,173 +43,175 @@ const char * const keyword_text[189] = { /* 29 287 T_Double */ NULL, /* 30 288 T_Driftfile */ "driftfile", /* 31 289 T_Drop */ "drop", - /* 32 290 T_Ellipsis */ "...", - /* 33 291 T_Enable */ "enable", - /* 34 292 T_End */ "end", - /* 35 293 T_False */ NULL, - /* 36 294 T_File */ "file", - /* 37 295 T_Filegen */ "filegen", - /* 38 296 T_Filenum */ "filenum", - /* 39 297 T_Flag1 */ "flag1", - /* 40 298 T_Flag2 */ "flag2", - /* 41 299 T_Flag3 */ "flag3", - /* 42 300 T_Flag4 */ "flag4", - /* 43 301 T_Flake */ "flake", - /* 44 302 T_Floor */ "floor", - /* 45 303 T_Freq */ "freq", - /* 46 304 T_Fudge */ "fudge", - /* 47 305 T_Host */ "host", - /* 48 306 T_Huffpuff */ "huffpuff", - /* 49 307 T_Iburst */ "iburst", - /* 50 308 T_Ident */ "ident", - /* 51 309 T_Ignore */ "ignore", - /* 52 310 T_Incalloc */ "incalloc", - /* 53 311 T_Incmem */ "incmem", - /* 54 312 T_Initalloc */ "initalloc", - /* 55 313 T_Initmem */ "initmem", - /* 56 314 T_Includefile */ "includefile", - /* 57 315 T_Integer */ NULL, - /* 58 316 T_Interface */ "interface", - /* 59 317 T_Intrange */ NULL, - /* 60 318 T_Io */ "io", - /* 61 319 T_Ipv4 */ "ipv4", - /* 62 320 T_Ipv4_flag */ "-4", - /* 63 321 T_Ipv6 */ "ipv6", - /* 64 322 T_Ipv6_flag */ "-6", - /* 65 323 T_Kernel */ "kernel", - /* 66 324 T_Key */ "key", - /* 67 325 T_Keys */ "keys", - /* 68 326 T_Keysdir */ "keysdir", - /* 69 327 T_Kod */ "kod", - /* 70 328 T_Mssntp */ "mssntp", - /* 71 329 T_Leapfile */ "leapfile", - /* 72 330 T_Limited */ "limited", - /* 73 331 T_Link */ "link", - /* 74 332 T_Listen */ "listen", - /* 75 333 T_Logconfig */ "logconfig", - /* 76 334 T_Logfile */ "logfile", - /* 77 335 T_Loopstats */ "loopstats", - /* 78 336 T_Lowpriotrap */ "lowpriotrap", - /* 79 337 T_Manycastclient */ "manycastclient", - /* 80 338 T_Manycastserver */ "manycastserver", - /* 81 339 T_Mask */ "mask", - /* 82 340 T_Maxage */ "maxage", - /* 83 341 T_Maxclock */ "maxclock", - /* 84 342 T_Maxdepth */ "maxdepth", - /* 85 343 T_Maxdist */ "maxdist", - /* 86 344 T_Maxmem */ "maxmem", - /* 87 345 T_Maxpoll */ "maxpoll", - /* 88 346 T_Mdnstries */ "mdnstries", - /* 89 347 T_Mem */ "mem", - /* 90 348 T_Memlock */ "memlock", - /* 91 349 T_Minclock */ "minclock", - /* 92 350 T_Mindepth */ "mindepth", - /* 93 351 T_Mindist */ "mindist", - /* 94 352 T_Minimum */ "minimum", - /* 95 353 T_Minpoll */ "minpoll", - /* 96 354 T_Minsane */ "minsane", - /* 97 355 T_Mode */ "mode", - /* 98 356 T_Mode7 */ "mode7", - /* 99 357 T_Monitor */ "monitor", - /* 100 358 T_Month */ "month", - /* 101 359 T_Mru */ "mru", - /* 102 360 T_Multicastclient */ "multicastclient", - /* 103 361 T_Nic */ "nic", - /* 104 362 T_Nolink */ "nolink", - /* 105 363 T_Nomodify */ "nomodify", - /* 106 364 T_Nomrulist */ "nomrulist", - /* 107 365 T_None */ "none", - /* 108 366 T_Nonvolatile */ "nonvolatile", - /* 109 367 T_Nopeer */ "nopeer", - /* 110 368 T_Noquery */ "noquery", - /* 111 369 T_Noselect */ "noselect", - /* 112 370 T_Noserve */ "noserve", - /* 113 371 T_Notrap */ "notrap", - /* 114 372 T_Notrust */ "notrust", - /* 115 373 T_Ntp */ "ntp", - /* 116 374 T_Ntpport */ "ntpport", - /* 117 375 T_NtpSignDsocket */ "ntpsigndsocket", - /* 118 376 T_Orphan */ "orphan", - /* 119 377 T_Orphanwait */ "orphanwait", - /* 120 378 T_Panic */ "panic", - /* 121 379 T_Peer */ "peer", - /* 122 380 T_Peerstats */ "peerstats", - /* 123 381 T_Phone */ "phone", - /* 124 382 T_Pid */ "pid", - /* 125 383 T_Pidfile */ "pidfile", - /* 126 384 T_Pool */ "pool", - /* 127 385 T_Port */ "port", - /* 128 386 T_Preempt */ "preempt", - /* 129 387 T_Prefer */ "prefer", - /* 130 388 T_Protostats */ "protostats", - /* 131 389 T_Pw */ "pw", - /* 132 390 T_Randfile */ "randfile", - /* 133 391 T_Rawstats */ "rawstats", - /* 134 392 T_Refid */ "refid", - /* 135 393 T_Requestkey */ "requestkey", - /* 136 394 T_Reset */ "reset", - /* 137 395 T_Restrict */ "restrict", - /* 138 396 T_Revoke */ "revoke", - /* 139 397 T_Rlimit */ "rlimit", - /* 140 398 T_Saveconfigdir */ "saveconfigdir", - /* 141 399 T_Server */ "server", - /* 142 400 T_Setvar */ "setvar", - /* 143 401 T_Source */ "source", - /* 144 402 T_Stacksize */ "stacksize", - /* 145 403 T_Statistics */ "statistics", - /* 146 404 T_Stats */ "stats", - /* 147 405 T_Statsdir */ "statsdir", - /* 148 406 T_Step */ "step", - /* 149 407 T_Stepback */ "stepback", - /* 150 408 T_Stepfwd */ "stepfwd", - /* 151 409 T_Stepout */ "stepout", - /* 152 410 T_Stratum */ "stratum", - /* 153 411 T_String */ NULL, - /* 154 412 T_Sys */ "sys", - /* 155 413 T_Sysstats */ "sysstats", - /* 156 414 T_Tick */ "tick", - /* 157 415 T_Time1 */ "time1", - /* 158 416 T_Time2 */ "time2", - /* 159 417 T_Timer */ "timer", - /* 160 418 T_Timingstats */ "timingstats", - /* 161 419 T_Tinker */ "tinker", - /* 162 420 T_Tos */ "tos", - /* 163 421 T_Trap */ "trap", - /* 164 422 T_True */ "true", - /* 165 423 T_Trustedkey */ "trustedkey", - /* 166 424 T_Ttl */ "ttl", - /* 167 425 T_Type */ "type", - /* 168 426 T_U_int */ NULL, - /* 169 427 T_Unconfig */ "unconfig", - /* 170 428 T_Unpeer */ "unpeer", - /* 171 429 T_Version */ "version", - /* 172 430 T_WanderThreshold */ NULL, - /* 173 431 T_Week */ "week", - /* 174 432 T_Wildcard */ "wildcard", - /* 175 433 T_Xleave */ "xleave", - /* 176 434 T_Year */ "year", - /* 177 435 T_Flag */ NULL, - /* 178 436 T_EOC */ NULL, - /* 179 437 T_Simulate */ "simulate", - /* 180 438 T_Beep_Delay */ "beep_delay", - /* 181 439 T_Sim_Duration */ "simulation_duration", - /* 182 440 T_Server_Offset */ "server_offset", - /* 183 441 T_Duration */ "duration", - /* 184 442 T_Freq_Offset */ "freq_offset", - /* 185 443 T_Wander */ "wander", - /* 186 444 T_Jitter */ "jitter", - /* 187 445 T_Prop_Delay */ "prop_delay", - /* 188 446 T_Proc_Delay */ "proc_delay" + /* 32 290 T_Dscp */ "dscp", + /* 33 291 T_Ellipsis */ "...", + /* 34 292 T_Enable */ "enable", + /* 35 293 T_End */ "end", + /* 36 294 T_False */ NULL, + /* 37 295 T_File */ "file", + /* 38 296 T_Filegen */ "filegen", + /* 39 297 T_Filenum */ "filenum", + /* 40 298 T_Flag1 */ "flag1", + /* 41 299 T_Flag2 */ "flag2", + /* 42 300 T_Flag3 */ "flag3", + /* 43 301 T_Flag4 */ "flag4", + /* 44 302 T_Flake */ "flake", + /* 45 303 T_Floor */ "floor", + /* 46 304 T_Freq */ "freq", + /* 47 305 T_Fudge */ "fudge", + /* 48 306 T_Host */ "host", + /* 49 307 T_Huffpuff */ "huffpuff", + /* 50 308 T_Iburst */ "iburst", + /* 51 309 T_Ident */ "ident", + /* 52 310 T_Ignore */ "ignore", + /* 53 311 T_Incalloc */ "incalloc", + /* 54 312 T_Incmem */ "incmem", + /* 55 313 T_Initalloc */ "initalloc", + /* 56 314 T_Initmem */ "initmem", + /* 57 315 T_Includefile */ "includefile", + /* 58 316 T_Integer */ NULL, + /* 59 317 T_Interface */ "interface", + /* 60 318 T_Intrange */ NULL, + /* 61 319 T_Io */ "io", + /* 62 320 T_Ipv4 */ "ipv4", + /* 63 321 T_Ipv4_flag */ "-4", + /* 64 322 T_Ipv6 */ "ipv6", + /* 65 323 T_Ipv6_flag */ "-6", + /* 66 324 T_Kernel */ "kernel", + /* 67 325 T_Key */ "key", + /* 68 326 T_Keys */ "keys", + /* 69 327 T_Keysdir */ "keysdir", + /* 70 328 T_Kod */ "kod", + /* 71 329 T_Mssntp */ "mssntp", + /* 72 330 T_Leapfile */ "leapfile", + /* 73 331 T_Leapsmearinterval */ "leapsmearinterval", + /* 74 332 T_Limited */ "limited", + /* 75 333 T_Link */ "link", + /* 76 334 T_Listen */ "listen", + /* 77 335 T_Logconfig */ "logconfig", + /* 78 336 T_Logfile */ "logfile", + /* 79 337 T_Loopstats */ "loopstats", + /* 80 338 T_Lowpriotrap */ "lowpriotrap", + /* 81 339 T_Manycastclient */ "manycastclient", + /* 82 340 T_Manycastserver */ "manycastserver", + /* 83 341 T_Mask */ "mask", + /* 84 342 T_Maxage */ "maxage", + /* 85 343 T_Maxclock */ "maxclock", + /* 86 344 T_Maxdepth */ "maxdepth", + /* 87 345 T_Maxdist */ "maxdist", + /* 88 346 T_Maxmem */ "maxmem", + /* 89 347 T_Maxpoll */ "maxpoll", + /* 90 348 T_Mdnstries */ "mdnstries", + /* 91 349 T_Mem */ "mem", + /* 92 350 T_Memlock */ "memlock", + /* 93 351 T_Minclock */ "minclock", + /* 94 352 T_Mindepth */ "mindepth", + /* 95 353 T_Mindist */ "mindist", + /* 96 354 T_Minimum */ "minimum", + /* 97 355 T_Minpoll */ "minpoll", + /* 98 356 T_Minsane */ "minsane", + /* 99 357 T_Mode */ "mode", + /* 100 358 T_Mode7 */ "mode7", + /* 101 359 T_Monitor */ "monitor", + /* 102 360 T_Month */ "month", + /* 103 361 T_Mru */ "mru", + /* 104 362 T_Multicastclient */ "multicastclient", + /* 105 363 T_Nic */ "nic", + /* 106 364 T_Nolink */ "nolink", + /* 107 365 T_Nomodify */ "nomodify", + /* 108 366 T_Nomrulist */ "nomrulist", + /* 109 367 T_None */ "none", + /* 110 368 T_Nonvolatile */ "nonvolatile", + /* 111 369 T_Nopeer */ "nopeer", + /* 112 370 T_Noquery */ "noquery", + /* 113 371 T_Noselect */ "noselect", + /* 114 372 T_Noserve */ "noserve", + /* 115 373 T_Notrap */ "notrap", + /* 116 374 T_Notrust */ "notrust", + /* 117 375 T_Ntp */ "ntp", + /* 118 376 T_Ntpport */ "ntpport", + /* 119 377 T_NtpSignDsocket */ "ntpsigndsocket", + /* 120 378 T_Orphan */ "orphan", + /* 121 379 T_Orphanwait */ "orphanwait", + /* 122 380 T_Panic */ "panic", + /* 123 381 T_Peer */ "peer", + /* 124 382 T_Peerstats */ "peerstats", + /* 125 383 T_Phone */ "phone", + /* 126 384 T_Pid */ "pid", + /* 127 385 T_Pidfile */ "pidfile", + /* 128 386 T_Pool */ "pool", + /* 129 387 T_Port */ "port", + /* 130 388 T_Preempt */ "preempt", + /* 131 389 T_Prefer */ "prefer", + /* 132 390 T_Protostats */ "protostats", + /* 133 391 T_Pw */ "pw", + /* 134 392 T_Randfile */ "randfile", + /* 135 393 T_Rawstats */ "rawstats", + /* 136 394 T_Refid */ "refid", + /* 137 395 T_Requestkey */ "requestkey", + /* 138 396 T_Reset */ "reset", + /* 139 397 T_Restrict */ "restrict", + /* 140 398 T_Revoke */ "revoke", + /* 141 399 T_Rlimit */ "rlimit", + /* 142 400 T_Saveconfigdir */ "saveconfigdir", + /* 143 401 T_Server */ "server", + /* 144 402 T_Setvar */ "setvar", + /* 145 403 T_Source */ "source", + /* 146 404 T_Stacksize */ "stacksize", + /* 147 405 T_Statistics */ "statistics", + /* 148 406 T_Stats */ "stats", + /* 149 407 T_Statsdir */ "statsdir", + /* 150 408 T_Step */ "step", + /* 151 409 T_Stepback */ "stepback", + /* 152 410 T_Stepfwd */ "stepfwd", + /* 153 411 T_Stepout */ "stepout", + /* 154 412 T_Stratum */ "stratum", + /* 155 413 T_String */ NULL, + /* 156 414 T_Sys */ "sys", + /* 157 415 T_Sysstats */ "sysstats", + /* 158 416 T_Tick */ "tick", + /* 159 417 T_Time1 */ "time1", + /* 160 418 T_Time2 */ "time2", + /* 161 419 T_Timer */ "timer", + /* 162 420 T_Timingstats */ "timingstats", + /* 163 421 T_Tinker */ "tinker", + /* 164 422 T_Tos */ "tos", + /* 165 423 T_Trap */ "trap", + /* 166 424 T_True */ "true", + /* 167 425 T_Trustedkey */ "trustedkey", + /* 168 426 T_Ttl */ "ttl", + /* 169 427 T_Type */ "type", + /* 170 428 T_U_int */ NULL, + /* 171 429 T_Unconfig */ "unconfig", + /* 172 430 T_Unpeer */ "unpeer", + /* 173 431 T_Version */ "version", + /* 174 432 T_WanderThreshold */ NULL, + /* 175 433 T_Week */ "week", + /* 176 434 T_Wildcard */ "wildcard", + /* 177 435 T_Xleave */ "xleave", + /* 178 436 T_Year */ "year", + /* 179 437 T_Flag */ NULL, + /* 180 438 T_EOC */ NULL, + /* 181 439 T_Simulate */ "simulate", + /* 182 440 T_Beep_Delay */ "beep_delay", + /* 183 441 T_Sim_Duration */ "simulation_duration", + /* 184 442 T_Server_Offset */ "server_offset", + /* 185 443 T_Duration */ "duration", + /* 186 444 T_Freq_Offset */ "freq_offset", + /* 187 445 T_Wander */ "wander", + /* 188 446 T_Jitter */ "jitter", + /* 189 447 T_Prop_Delay */ "prop_delay", + /* 190 448 T_Proc_Delay */ "proc_delay" }; -#define SCANNER_INIT_S 837 +#define SCANNER_INIT_S 853 -const scan_state sst[840] = { +const scan_state sst[856] = { /*SS_T( ch, f-by, match, other ), */ 0, /* 0 */ - S_ST( '-', 3, 322, 0 ), /* 1 */ + S_ST( '-', 3, 323, 0 ), /* 1 */ S_ST( '.', 3, 3, 1 ), /* 2 */ - S_ST( '.', 3, 290, 0 ), /* 3 . */ + S_ST( '.', 3, 291, 0 ), /* 3 . */ S_ST( 'a', 3, 23, 2 ), /* 4 */ S_ST( 'b', 3, 6, 0 ), /* 5 a */ S_ST( 'b', 3, 7, 0 ), /* 6 ab */ @@ -250,7 +252,7 @@ const scan_state sst[840] = { S_ST( 'd', 3, 42, 0 ), /* 41 beep_ */ S_ST( 'e', 3, 43, 0 ), /* 42 beep_d */ S_ST( 'l', 3, 44, 0 ), /* 43 beep_de */ - S_ST( 'a', 3, 438, 0 ), /* 44 beep_del */ + S_ST( 'a', 3, 440, 0 ), /* 44 beep_del */ S_ST( 'r', 3, 46, 34 ), /* 45 b */ S_ST( 'o', 3, 47, 0 ), /* 46 br */ S_ST( 'a', 3, 48, 0 ), /* 47 bro */ @@ -311,7 +313,7 @@ const scan_state sst[840] = { S_ST( 'a', 3, 103, 0 ), /* 102 cryptost */ S_ST( 't', 3, 279, 0 ), /* 103 cryptosta */ S_ST( 't', 3, 280, 96 ), /* 104 c */ - S_ST( 'd', 3, 137, 64 ), /* 105 */ + S_ST( 'd', 3, 139, 64 ), /* 105 */ S_ST( 'a', 3, 281, 0 ), /* 106 d */ S_ST( 'e', 3, 108, 106 ), /* 107 d */ S_ST( 'f', 3, 109, 0 ), /* 108 de */ @@ -343,127 +345,127 @@ const scan_state sst[840] = { S_ST( 'i', 3, 135, 0 ), /* 134 driftf */ S_ST( 'l', 3, 288, 0 ), /* 135 driftfi */ S_ST( 'o', 3, 289, 130 ), /* 136 dr */ - S_ST( 'u', 3, 138, 129 ), /* 137 d */ - S_ST( 'r', 3, 139, 0 ), /* 138 du */ - S_ST( 'a', 3, 140, 0 ), /* 139 dur */ - S_ST( 't', 3, 141, 0 ), /* 140 dura */ - S_ST( 'i', 3, 142, 0 ), /* 141 durat */ - S_ST( 'o', 3, 441, 0 ), /* 142 durati */ - S_ST( 'e', 3, 144, 105 ), /* 143 */ - S_ST( 'n', 3, 292, 0 ), /* 144 e */ - S_ST( 'a', 3, 146, 0 ), /* 145 en */ - S_ST( 'b', 3, 147, 0 ), /* 146 ena */ - S_ST( 'l', 3, 291, 0 ), /* 147 enab */ - S_ST( 'f', 3, 169, 143 ), /* 148 */ - S_ST( 'i', 3, 150, 0 ), /* 149 f */ - S_ST( 'l', 3, 294, 0 ), /* 150 fi */ - S_ST( 'g', 3, 152, 0 ), /* 151 file */ - S_ST( 'e', 3, 295, 0 ), /* 152 fileg */ - S_ST( 'n', 3, 154, 151 ), /* 153 file */ - S_ST( 'u', 3, 296, 0 ), /* 154 filen */ - S_ST( 'l', 3, 159, 149 ), /* 155 f */ - S_ST( 'a', 3, 158, 0 ), /* 156 fl */ - S_ST( 'g', 3, 300, 0 ), /* 157 fla */ - S_ST( 'k', 3, 301, 157 ), /* 158 fla */ - S_ST( 'o', 3, 160, 156 ), /* 159 fl */ - S_ST( 'o', 3, 302, 0 ), /* 160 flo */ - S_ST( 'r', 3, 162, 155 ), /* 161 f */ - S_ST( 'e', 3, 303, 0 ), /* 162 fr */ - S_ST( '_', 3, 164, 0 ), /* 163 freq */ - S_ST( 'o', 3, 165, 0 ), /* 164 freq_ */ - S_ST( 'f', 3, 166, 0 ), /* 165 freq_o */ - S_ST( 'f', 3, 167, 0 ), /* 166 freq_of */ - S_ST( 's', 3, 168, 0 ), /* 167 freq_off */ - S_ST( 'e', 3, 442, 0 ), /* 168 freq_offs */ - S_ST( 'u', 3, 170, 161 ), /* 169 f */ - S_ST( 'd', 3, 171, 0 ), /* 170 fu */ - S_ST( 'g', 3, 304, 0 ), /* 171 fud */ - S_ST( 'h', 3, 175, 148 ), /* 172 */ - S_ST( 'o', 3, 174, 0 ), /* 173 h */ - S_ST( 's', 3, 305, 0 ), /* 174 ho */ - S_ST( 'u', 3, 176, 173 ), /* 175 h */ - S_ST( 'f', 3, 177, 0 ), /* 176 hu */ - S_ST( 'f', 3, 178, 0 ), /* 177 huf */ - S_ST( 'p', 3, 179, 0 ), /* 178 huff */ - S_ST( 'u', 3, 180, 0 ), /* 179 huffp */ - S_ST( 'f', 3, 306, 0 ), /* 180 huffpu */ - S_ST( 'i', 3, 222, 172 ), /* 181 */ - S_ST( 'b', 3, 183, 0 ), /* 182 i */ - S_ST( 'u', 3, 184, 0 ), /* 183 ib */ - S_ST( 'r', 3, 185, 0 ), /* 184 ibu */ - S_ST( 's', 3, 307, 0 ), /* 185 ibur */ - S_ST( 'd', 3, 187, 182 ), /* 186 i */ - S_ST( 'e', 3, 188, 0 ), /* 187 id */ - S_ST( 'n', 3, 308, 0 ), /* 188 ide */ - S_ST( 'g', 3, 190, 186 ), /* 189 i */ - S_ST( 'n', 3, 191, 0 ), /* 190 ig */ - S_ST( 'o', 3, 192, 0 ), /* 191 ign */ - S_ST( 'r', 3, 309, 0 ), /* 192 igno */ - S_ST( 'n', 3, 216, 189 ), /* 193 i */ - S_ST( 'c', 3, 206, 0 ), /* 194 in */ - S_ST( 'a', 3, 196, 0 ), /* 195 inc */ - S_ST( 'l', 3, 197, 0 ), /* 196 inca */ - S_ST( 'l', 3, 198, 0 ), /* 197 incal */ - S_ST( 'o', 3, 310, 0 ), /* 198 incall */ - S_ST( 'l', 3, 200, 195 ), /* 199 inc */ - S_ST( 'u', 3, 201, 0 ), /* 200 incl */ - S_ST( 'd', 3, 202, 0 ), /* 201 inclu */ - S_ST( 'e', 3, 203, 0 ), /* 202 includ */ - S_ST( 'f', 3, 204, 0 ), /* 203 include */ - S_ST( 'i', 3, 205, 0 ), /* 204 includef */ - S_ST( 'l', 3, 314, 0 ), /* 205 includefi */ - S_ST( 'm', 3, 207, 199 ), /* 206 inc */ - S_ST( 'e', 3, 311, 0 ), /* 207 incm */ - S_ST( 'i', 3, 209, 194 ), /* 208 in */ - S_ST( 't', 3, 214, 0 ), /* 209 ini */ - S_ST( 'a', 3, 211, 0 ), /* 210 init */ - S_ST( 'l', 3, 212, 0 ), /* 211 inita */ - S_ST( 'l', 3, 213, 0 ), /* 212 inital */ - S_ST( 'o', 3, 312, 0 ), /* 213 initall */ - S_ST( 'm', 3, 215, 210 ), /* 214 init */ - S_ST( 'e', 3, 313, 0 ), /* 215 initm */ - S_ST( 't', 3, 217, 208 ), /* 216 in */ - S_ST( 'e', 3, 218, 0 ), /* 217 int */ - S_ST( 'r', 3, 219, 0 ), /* 218 inte */ - S_ST( 'f', 3, 220, 0 ), /* 219 inter */ - S_ST( 'a', 3, 221, 0 ), /* 220 interf */ - S_ST( 'c', 3, 316, 0 ), /* 221 interfa */ - S_ST( 'p', 3, 223, 318 ), /* 222 i */ - S_ST( 'v', 3, 321, 0 ), /* 223 ip */ - S_ST( 'j', 3, 225, 181 ), /* 224 */ - S_ST( 'i', 3, 226, 0 ), /* 225 j */ - S_ST( 't', 3, 227, 0 ), /* 226 ji */ - S_ST( 't', 3, 228, 0 ), /* 227 jit */ - S_ST( 'e', 3, 444, 0 ), /* 228 jitt */ - S_ST( 'k', 3, 236, 224 ), /* 229 */ - S_ST( 'e', 3, 324, 0 ), /* 230 k */ - S_ST( 'r', 3, 232, 0 ), /* 231 ke */ - S_ST( 'n', 3, 233, 0 ), /* 232 ker */ - S_ST( 'e', 3, 323, 0 ), /* 233 kern */ - S_ST( 'd', 3, 235, 0 ), /* 234 keys */ - S_ST( 'i', 3, 326, 0 ), /* 235 keysd */ - S_ST( 'o', 3, 327, 230 ), /* 236 k */ - S_ST( 'l', 3, 253, 229 ), /* 237 */ - S_ST( 'e', 3, 239, 0 ), /* 238 l */ - S_ST( 'a', 3, 240, 0 ), /* 239 le */ - S_ST( 'p', 3, 241, 0 ), /* 240 lea */ - S_ST( 'f', 3, 242, 0 ), /* 241 leap */ - S_ST( 'i', 3, 243, 0 ), /* 242 leapf */ - S_ST( 'l', 3, 329, 0 ), /* 243 leapfi */ - S_ST( 'i', 3, 250, 238 ), /* 244 l */ - S_ST( 'm', 3, 246, 0 ), /* 245 li */ - S_ST( 'i', 3, 247, 0 ), /* 246 lim */ - S_ST( 't', 3, 248, 0 ), /* 247 limi */ - S_ST( 'e', 3, 330, 0 ), /* 248 limit */ - S_ST( 'n', 3, 331, 245 ), /* 249 li */ - S_ST( 's', 3, 251, 249 ), /* 250 li */ - S_ST( 't', 3, 252, 0 ), /* 251 lis */ - S_ST( 'e', 3, 332, 0 ), /* 252 list */ - S_ST( 'o', 3, 449, 244 ), /* 253 l */ - S_ST( 'g', 3, 315, 0 ), /* 254 lo */ - S_ST( 'c', 3, 256, 0 ), /* 255 log */ - S_ST( 'o', 3, 257, 0 ), /* 256 logc */ - S_ST( 'n', 3, 287, 0 ), /* 257 logco */ + S_ST( 's', 3, 138, 129 ), /* 137 d */ + S_ST( 'c', 3, 290, 0 ), /* 138 ds */ + S_ST( 'u', 3, 140, 137 ), /* 139 d */ + S_ST( 'r', 3, 141, 0 ), /* 140 du */ + S_ST( 'a', 3, 142, 0 ), /* 141 dur */ + S_ST( 't', 3, 143, 0 ), /* 142 dura */ + S_ST( 'i', 3, 144, 0 ), /* 143 durat */ + S_ST( 'o', 3, 443, 0 ), /* 144 durati */ + S_ST( 'e', 3, 146, 105 ), /* 145 */ + S_ST( 'n', 3, 293, 0 ), /* 146 e */ + S_ST( 'a', 3, 148, 0 ), /* 147 en */ + S_ST( 'b', 3, 149, 0 ), /* 148 ena */ + S_ST( 'l', 3, 292, 0 ), /* 149 enab */ + S_ST( 'f', 3, 171, 145 ), /* 150 */ + S_ST( 'i', 3, 152, 0 ), /* 151 f */ + S_ST( 'l', 3, 295, 0 ), /* 152 fi */ + S_ST( 'g', 3, 154, 0 ), /* 153 file */ + S_ST( 'e', 3, 296, 0 ), /* 154 fileg */ + S_ST( 'n', 3, 156, 153 ), /* 155 file */ + S_ST( 'u', 3, 297, 0 ), /* 156 filen */ + S_ST( 'l', 3, 161, 151 ), /* 157 f */ + S_ST( 'a', 3, 160, 0 ), /* 158 fl */ + S_ST( 'g', 3, 301, 0 ), /* 159 fla */ + S_ST( 'k', 3, 302, 159 ), /* 160 fla */ + S_ST( 'o', 3, 162, 158 ), /* 161 fl */ + S_ST( 'o', 3, 303, 0 ), /* 162 flo */ + S_ST( 'r', 3, 164, 157 ), /* 163 f */ + S_ST( 'e', 3, 304, 0 ), /* 164 fr */ + S_ST( '_', 3, 166, 0 ), /* 165 freq */ + S_ST( 'o', 3, 167, 0 ), /* 166 freq_ */ + S_ST( 'f', 3, 168, 0 ), /* 167 freq_o */ + S_ST( 'f', 3, 169, 0 ), /* 168 freq_of */ + S_ST( 's', 3, 170, 0 ), /* 169 freq_off */ + S_ST( 'e', 3, 444, 0 ), /* 170 freq_offs */ + S_ST( 'u', 3, 172, 163 ), /* 171 f */ + S_ST( 'd', 3, 173, 0 ), /* 172 fu */ + S_ST( 'g', 3, 305, 0 ), /* 173 fud */ + S_ST( 'h', 3, 177, 150 ), /* 174 */ + S_ST( 'o', 3, 176, 0 ), /* 175 h */ + S_ST( 's', 3, 306, 0 ), /* 176 ho */ + S_ST( 'u', 3, 178, 175 ), /* 177 h */ + S_ST( 'f', 3, 179, 0 ), /* 178 hu */ + S_ST( 'f', 3, 180, 0 ), /* 179 huf */ + S_ST( 'p', 3, 181, 0 ), /* 180 huff */ + S_ST( 'u', 3, 182, 0 ), /* 181 huffp */ + S_ST( 'f', 3, 307, 0 ), /* 182 huffpu */ + S_ST( 'i', 3, 224, 174 ), /* 183 */ + S_ST( 'b', 3, 185, 0 ), /* 184 i */ + S_ST( 'u', 3, 186, 0 ), /* 185 ib */ + S_ST( 'r', 3, 187, 0 ), /* 186 ibu */ + S_ST( 's', 3, 308, 0 ), /* 187 ibur */ + S_ST( 'd', 3, 189, 184 ), /* 188 i */ + S_ST( 'e', 3, 190, 0 ), /* 189 id */ + S_ST( 'n', 3, 309, 0 ), /* 190 ide */ + S_ST( 'g', 3, 192, 188 ), /* 191 i */ + S_ST( 'n', 3, 193, 0 ), /* 192 ig */ + S_ST( 'o', 3, 194, 0 ), /* 193 ign */ + S_ST( 'r', 3, 310, 0 ), /* 194 igno */ + S_ST( 'n', 3, 218, 191 ), /* 195 i */ + S_ST( 'c', 3, 208, 0 ), /* 196 in */ + S_ST( 'a', 3, 198, 0 ), /* 197 inc */ + S_ST( 'l', 3, 199, 0 ), /* 198 inca */ + S_ST( 'l', 3, 200, 0 ), /* 199 incal */ + S_ST( 'o', 3, 311, 0 ), /* 200 incall */ + S_ST( 'l', 3, 202, 197 ), /* 201 inc */ + S_ST( 'u', 3, 203, 0 ), /* 202 incl */ + S_ST( 'd', 3, 204, 0 ), /* 203 inclu */ + S_ST( 'e', 3, 205, 0 ), /* 204 includ */ + S_ST( 'f', 3, 206, 0 ), /* 205 include */ + S_ST( 'i', 3, 207, 0 ), /* 206 includef */ + S_ST( 'l', 3, 315, 0 ), /* 207 includefi */ + S_ST( 'm', 3, 209, 201 ), /* 208 inc */ + S_ST( 'e', 3, 312, 0 ), /* 209 incm */ + S_ST( 'i', 3, 211, 196 ), /* 210 in */ + S_ST( 't', 3, 216, 0 ), /* 211 ini */ + S_ST( 'a', 3, 213, 0 ), /* 212 init */ + S_ST( 'l', 3, 214, 0 ), /* 213 inita */ + S_ST( 'l', 3, 215, 0 ), /* 214 inital */ + S_ST( 'o', 3, 313, 0 ), /* 215 initall */ + S_ST( 'm', 3, 217, 212 ), /* 216 init */ + S_ST( 'e', 3, 314, 0 ), /* 217 initm */ + S_ST( 't', 3, 219, 210 ), /* 218 in */ + S_ST( 'e', 3, 220, 0 ), /* 219 int */ + S_ST( 'r', 3, 221, 0 ), /* 220 inte */ + S_ST( 'f', 3, 222, 0 ), /* 221 inter */ + S_ST( 'a', 3, 223, 0 ), /* 222 interf */ + S_ST( 'c', 3, 317, 0 ), /* 223 interfa */ + S_ST( 'p', 3, 225, 319 ), /* 224 i */ + S_ST( 'v', 3, 322, 0 ), /* 225 ip */ + S_ST( 'j', 3, 227, 183 ), /* 226 */ + S_ST( 'i', 3, 228, 0 ), /* 227 j */ + S_ST( 't', 3, 229, 0 ), /* 228 ji */ + S_ST( 't', 3, 230, 0 ), /* 229 jit */ + S_ST( 'e', 3, 446, 0 ), /* 230 jitt */ + S_ST( 'k', 3, 238, 226 ), /* 231 */ + S_ST( 'e', 3, 325, 0 ), /* 232 k */ + S_ST( 'r', 3, 234, 0 ), /* 233 ke */ + S_ST( 'n', 3, 235, 0 ), /* 234 ker */ + S_ST( 'e', 3, 324, 0 ), /* 235 kern */ + S_ST( 'd', 3, 237, 0 ), /* 236 keys */ + S_ST( 'i', 3, 327, 0 ), /* 237 keysd */ + S_ST( 'o', 3, 328, 232 ), /* 238 k */ + S_ST( 'l', 3, 449, 231 ), /* 239 */ + S_ST( 'e', 3, 241, 0 ), /* 240 l */ + S_ST( 'a', 3, 242, 0 ), /* 241 le */ + S_ST( 'p', 3, 246, 0 ), /* 242 lea */ + S_ST( 'f', 3, 244, 0 ), /* 243 leap */ + S_ST( 'i', 3, 245, 0 ), /* 244 leapf */ + S_ST( 'l', 3, 330, 0 ), /* 245 leapfi */ + S_ST( 's', 3, 247, 243 ), /* 246 leap */ + S_ST( 'm', 3, 248, 0 ), /* 247 leaps */ + S_ST( 'e', 3, 249, 0 ), /* 248 leapsm */ + S_ST( 'a', 3, 250, 0 ), /* 249 leapsme */ + S_ST( 'r', 3, 251, 0 ), /* 250 leapsmea */ + S_ST( 'i', 3, 252, 0 ), /* 251 leapsmear */ + S_ST( 'n', 3, 253, 0 ), /* 252 leapsmeari */ + S_ST( 't', 3, 254, 0 ), /* 253 leapsmearin */ + S_ST( 'e', 3, 255, 0 ), /* 254 leapsmearint */ + S_ST( 'r', 3, 256, 0 ), /* 255 leapsmearinte */ + S_ST( 'v', 3, 257, 0 ), /* 256 leapsmearinter */ + S_ST( 'a', 3, 331, 0 ), /* 257 leapsmearinterv */ S_ST( 'v', 1, 0, 0 ), /* 258 T_Abbrev */ S_ST( 'e', 0, 0, 0 ), /* 259 T_Age */ S_ST( 'l', 0, 12, 0 ), /* 260 T_All */ @@ -493,558 +495,574 @@ const scan_state sst[840] = { S_ST( 'e', 0, 0, 0 ), /* 284 T_Disable */ S_ST( 'd', 0, 0, 0 ), /* 285 T_Discard */ S_ST( 'n', 0, 0, 0 ), /* 286 T_Dispersion */ - S_ST( 'f', 3, 293, 0 ), /* 287 logcon */ + S_ST( 'i', 3, 432, 240 ), /* 287 l */ S_ST( 'e', 1, 0, 0 ), /* 288 T_Driftfile */ S_ST( 'p', 0, 0, 0 ), /* 289 T_Drop */ - S_ST( '.', 0, 0, 0 ), /* 290 T_Ellipsis */ - S_ST( 'e', 0, 0, 0 ), /* 291 T_Enable */ - S_ST( 'd', 0, 0, 145 ), /* 292 T_End */ - S_ST( 'i', 3, 333, 0 ), /* 293 logconf */ - S_ST( 'e', 1, 153, 0 ), /* 294 T_File */ - S_ST( 'n', 0, 0, 0 ), /* 295 T_Filegen */ - S_ST( 'm', 0, 0, 0 ), /* 296 T_Filenum */ - S_ST( '1', 0, 0, 0 ), /* 297 T_Flag1 */ - S_ST( '2', 0, 0, 297 ), /* 298 T_Flag2 */ - S_ST( '3', 0, 0, 298 ), /* 299 T_Flag3 */ - S_ST( '4', 0, 0, 299 ), /* 300 T_Flag4 */ - S_ST( 'e', 0, 0, 0 ), /* 301 T_Flake */ - S_ST( 'r', 0, 0, 0 ), /* 302 T_Floor */ - S_ST( 'q', 0, 163, 0 ), /* 303 T_Freq */ - S_ST( 'e', 1, 0, 0 ), /* 304 T_Fudge */ - S_ST( 't', 1, 0, 0 ), /* 305 T_Host */ - S_ST( 'f', 0, 0, 0 ), /* 306 T_Huffpuff */ - S_ST( 't', 0, 0, 0 ), /* 307 T_Iburst */ - S_ST( 't', 1, 0, 0 ), /* 308 T_Ident */ - S_ST( 'e', 0, 0, 0 ), /* 309 T_Ignore */ - S_ST( 'c', 0, 0, 0 ), /* 310 T_Incalloc */ - S_ST( 'm', 0, 0, 0 ), /* 311 T_Incmem */ - S_ST( 'c', 0, 0, 0 ), /* 312 T_Initalloc */ - S_ST( 'm', 0, 0, 0 ), /* 313 T_Initmem */ - S_ST( 'e', 1, 0, 0 ), /* 314 T_Includefile */ - S_ST( 'f', 3, 317, 255 ), /* 315 log */ - S_ST( 'e', 0, 0, 0 ), /* 316 T_Interface */ - S_ST( 'i', 3, 411, 0 ), /* 317 logf */ - S_ST( 'o', 0, 0, 193 ), /* 318 T_Io */ - S_ST( '4', 0, 0, 0 ), /* 319 T_Ipv4 */ - S_ST( '4', 0, 0, 0 ), /* 320 T_Ipv4_flag */ - S_ST( '6', 0, 0, 319 ), /* 321 T_Ipv6 */ - S_ST( '6', 0, 0, 320 ), /* 322 T_Ipv6_flag */ - S_ST( 'l', 0, 0, 0 ), /* 323 T_Kernel */ - S_ST( 'y', 0, 325, 231 ), /* 324 T_Key */ - S_ST( 's', 1, 234, 0 ), /* 325 T_Keys */ - S_ST( 'r', 1, 0, 0 ), /* 326 T_Keysdir */ - S_ST( 'd', 0, 0, 0 ), /* 327 T_Kod */ - S_ST( 'p', 0, 0, 0 ), /* 328 T_Mssntp */ - S_ST( 'e', 1, 0, 0 ), /* 329 T_Leapfile */ - S_ST( 'd', 0, 0, 0 ), /* 330 T_Limited */ - S_ST( 'k', 0, 0, 0 ), /* 331 T_Link */ - S_ST( 'n', 0, 0, 0 ), /* 332 T_Listen */ - S_ST( 'g', 2, 0, 0 ), /* 333 T_Logconfig */ - S_ST( 'e', 1, 0, 0 ), /* 334 T_Logfile */ - S_ST( 's', 0, 0, 0 ), /* 335 T_Loopstats */ - S_ST( 'p', 0, 0, 0 ), /* 336 T_Lowpriotrap */ - S_ST( 't', 1, 0, 0 ), /* 337 T_Manycastclient */ - S_ST( 'r', 2, 0, 0 ), /* 338 T_Manycastserver */ - S_ST( 'k', 0, 0, 0 ), /* 339 T_Mask */ - S_ST( 'e', 0, 0, 0 ), /* 340 T_Maxage */ - S_ST( 'k', 0, 0, 0 ), /* 341 T_Maxclock */ - S_ST( 'h', 0, 0, 0 ), /* 342 T_Maxdepth */ - S_ST( 't', 0, 0, 0 ), /* 343 T_Maxdist */ - S_ST( 'm', 0, 0, 0 ), /* 344 T_Maxmem */ - S_ST( 'l', 0, 0, 0 ), /* 345 T_Maxpoll */ - S_ST( 's', 0, 0, 0 ), /* 346 T_Mdnstries */ - S_ST( 'm', 0, 502, 0 ), /* 347 T_Mem */ - S_ST( 'k', 0, 0, 0 ), /* 348 T_Memlock */ - S_ST( 'k', 0, 0, 0 ), /* 349 T_Minclock */ - S_ST( 'h', 0, 0, 0 ), /* 350 T_Mindepth */ - S_ST( 't', 0, 0, 0 ), /* 351 T_Mindist */ - S_ST( 'm', 0, 0, 0 ), /* 352 T_Minimum */ - S_ST( 'l', 0, 0, 0 ), /* 353 T_Minpoll */ - S_ST( 'e', 0, 0, 0 ), /* 354 T_Minsane */ - S_ST( 'e', 0, 356, 0 ), /* 355 T_Mode */ - S_ST( '7', 0, 0, 0 ), /* 356 T_Mode7 */ - S_ST( 'r', 0, 0, 0 ), /* 357 T_Monitor */ - S_ST( 'h', 0, 0, 0 ), /* 358 T_Month */ - S_ST( 'u', 0, 0, 0 ), /* 359 T_Mru */ - S_ST( 't', 2, 0, 0 ), /* 360 T_Multicastclient */ - S_ST( 'c', 0, 0, 0 ), /* 361 T_Nic */ - S_ST( 'k', 0, 0, 0 ), /* 362 T_Nolink */ - S_ST( 'y', 0, 0, 0 ), /* 363 T_Nomodify */ - S_ST( 't', 0, 0, 0 ), /* 364 T_Nomrulist */ - S_ST( 'e', 0, 0, 0 ), /* 365 T_None */ - S_ST( 'e', 0, 0, 0 ), /* 366 T_Nonvolatile */ - S_ST( 'r', 0, 0, 0 ), /* 367 T_Nopeer */ - S_ST( 'y', 0, 0, 0 ), /* 368 T_Noquery */ - S_ST( 't', 0, 0, 0 ), /* 369 T_Noselect */ - S_ST( 'e', 0, 0, 0 ), /* 370 T_Noserve */ - S_ST( 'p', 0, 0, 0 ), /* 371 T_Notrap */ - S_ST( 't', 0, 0, 0 ), /* 372 T_Notrust */ - S_ST( 'p', 0, 598, 0 ), /* 373 T_Ntp */ - S_ST( 't', 0, 0, 0 ), /* 374 T_Ntpport */ - S_ST( 't', 1, 0, 0 ), /* 375 T_NtpSignDsocket */ - S_ST( 'n', 0, 613, 0 ), /* 376 T_Orphan */ - S_ST( 't', 0, 0, 0 ), /* 377 T_Orphanwait */ - S_ST( 'c', 0, 0, 0 ), /* 378 T_Panic */ - S_ST( 'r', 1, 622, 0 ), /* 379 T_Peer */ - S_ST( 's', 0, 0, 0 ), /* 380 T_Peerstats */ - S_ST( 'e', 2, 0, 0 ), /* 381 T_Phone */ - S_ST( 'd', 0, 630, 0 ), /* 382 T_Pid */ - S_ST( 'e', 1, 0, 0 ), /* 383 T_Pidfile */ - S_ST( 'l', 1, 0, 0 ), /* 384 T_Pool */ - S_ST( 't', 0, 0, 0 ), /* 385 T_Port */ - S_ST( 't', 0, 0, 0 ), /* 386 T_Preempt */ - S_ST( 'r', 0, 0, 0 ), /* 387 T_Prefer */ - S_ST( 's', 0, 0, 0 ), /* 388 T_Protostats */ - S_ST( 'w', 1, 0, 636 ), /* 389 T_Pw */ - S_ST( 'e', 1, 0, 0 ), /* 390 T_Randfile */ - S_ST( 's', 0, 0, 0 ), /* 391 T_Rawstats */ - S_ST( 'd', 1, 0, 0 ), /* 392 T_Refid */ - S_ST( 'y', 0, 0, 0 ), /* 393 T_Requestkey */ - S_ST( 't', 0, 0, 0 ), /* 394 T_Reset */ - S_ST( 't', 0, 0, 0 ), /* 395 T_Restrict */ - S_ST( 'e', 0, 0, 0 ), /* 396 T_Revoke */ - S_ST( 't', 0, 0, 0 ), /* 397 T_Rlimit */ - S_ST( 'r', 1, 0, 0 ), /* 398 T_Saveconfigdir */ - S_ST( 'r', 1, 713, 0 ), /* 399 T_Server */ - S_ST( 'r', 1, 0, 0 ), /* 400 T_Setvar */ - S_ST( 'e', 0, 0, 0 ), /* 401 T_Source */ - S_ST( 'e', 0, 0, 0 ), /* 402 T_Stacksize */ - S_ST( 's', 0, 0, 0 ), /* 403 T_Statistics */ - S_ST( 's', 0, 756, 751 ), /* 404 T_Stats */ - S_ST( 'r', 1, 0, 0 ), /* 405 T_Statsdir */ - S_ST( 'p', 0, 764, 0 ), /* 406 T_Step */ - S_ST( 'k', 0, 0, 0 ), /* 407 T_Stepback */ - S_ST( 'd', 0, 0, 0 ), /* 408 T_Stepfwd */ - S_ST( 't', 0, 0, 0 ), /* 409 T_Stepout */ - S_ST( 'm', 0, 0, 0 ), /* 410 T_Stratum */ - S_ST( 'l', 3, 334, 0 ), /* 411 logfi */ - S_ST( 's', 0, 771, 0 ), /* 412 T_Sys */ - S_ST( 's', 0, 0, 0 ), /* 413 T_Sysstats */ - S_ST( 'k', 0, 0, 0 ), /* 414 T_Tick */ - S_ST( '1', 0, 0, 0 ), /* 415 T_Time1 */ - S_ST( '2', 0, 0, 415 ), /* 416 T_Time2 */ - S_ST( 'r', 0, 0, 416 ), /* 417 T_Timer */ - S_ST( 's', 0, 0, 0 ), /* 418 T_Timingstats */ - S_ST( 'r', 0, 0, 0 ), /* 419 T_Tinker */ - S_ST( 's', 0, 0, 0 ), /* 420 T_Tos */ - S_ST( 'p', 1, 0, 0 ), /* 421 T_Trap */ - S_ST( 'e', 0, 0, 0 ), /* 422 T_True */ - S_ST( 'y', 0, 0, 0 ), /* 423 T_Trustedkey */ - S_ST( 'l', 0, 0, 0 ), /* 424 T_Ttl */ - S_ST( 'e', 0, 0, 0 ), /* 425 T_Type */ - S_ST( 'o', 3, 430, 254 ), /* 426 lo */ - S_ST( 'g', 1, 0, 0 ), /* 427 T_Unconfig */ - S_ST( 'r', 1, 0, 0 ), /* 428 T_Unpeer */ - S_ST( 'n', 0, 0, 0 ), /* 429 T_Version */ - S_ST( 'p', 3, 435, 0 ), /* 430 loo */ - S_ST( 'k', 0, 0, 0 ), /* 431 T_Week */ - S_ST( 'd', 0, 0, 0 ), /* 432 T_Wildcard */ - S_ST( 'e', 0, 0, 0 ), /* 433 T_Xleave */ - S_ST( 'r', 0, 0, 0 ), /* 434 T_Year */ - S_ST( 's', 3, 436, 0 ), /* 435 loop */ - S_ST( 't', 3, 447, 0 ), /* 436 loops */ - S_ST( 'e', 0, 0, 0 ), /* 437 T_Simulate */ - S_ST( 'y', 0, 0, 0 ), /* 438 T_Beep_Delay */ - S_ST( 'n', 0, 0, 0 ), /* 439 T_Sim_Duration */ - S_ST( 't', 0, 0, 0 ), /* 440 T_Server_Offset */ - S_ST( 'n', 0, 0, 0 ), /* 441 T_Duration */ - S_ST( 't', 0, 0, 0 ), /* 442 T_Freq_Offset */ - S_ST( 'r', 0, 0, 0 ), /* 443 T_Wander */ - S_ST( 'r', 0, 0, 0 ), /* 444 T_Jitter */ - S_ST( 'y', 0, 0, 0 ), /* 445 T_Prop_Delay */ - S_ST( 'y', 0, 0, 0 ), /* 446 T_Proc_Delay */ - S_ST( 'a', 3, 448, 0 ), /* 447 loopst */ - S_ST( 't', 3, 335, 0 ), /* 448 loopsta */ - S_ST( 'w', 3, 450, 426 ), /* 449 lo */ - S_ST( 'p', 3, 451, 0 ), /* 450 low */ - S_ST( 'r', 3, 452, 0 ), /* 451 lowp */ - S_ST( 'i', 3, 453, 0 ), /* 452 lowpr */ - S_ST( 'o', 3, 454, 0 ), /* 453 lowpri */ - S_ST( 't', 3, 455, 0 ), /* 454 lowprio */ - S_ST( 'r', 3, 456, 0 ), /* 455 lowpriot */ - S_ST( 'a', 3, 336, 0 ), /* 456 lowpriotr */ - S_ST( 'm', 3, 538, 237 ), /* 457 */ - S_ST( 'a', 3, 476, 0 ), /* 458 m */ - S_ST( 'n', 3, 460, 0 ), /* 459 ma */ - S_ST( 'y', 3, 461, 0 ), /* 460 man */ - S_ST( 'c', 3, 462, 0 ), /* 461 many */ - S_ST( 'a', 3, 463, 0 ), /* 462 manyc */ - S_ST( 's', 3, 464, 0 ), /* 463 manyca */ - S_ST( 't', 3, 470, 0 ), /* 464 manycas */ - S_ST( 'c', 3, 466, 0 ), /* 465 manycast */ - S_ST( 'l', 3, 467, 0 ), /* 466 manycastc */ - S_ST( 'i', 3, 468, 0 ), /* 467 manycastcl */ - S_ST( 'e', 3, 469, 0 ), /* 468 manycastcli */ - S_ST( 'n', 3, 337, 0 ), /* 469 manycastclie */ - S_ST( 's', 3, 471, 465 ), /* 470 manycast */ - S_ST( 'e', 3, 472, 0 ), /* 471 manycasts */ - S_ST( 'r', 3, 473, 0 ), /* 472 manycastse */ - S_ST( 'v', 3, 474, 0 ), /* 473 manycastser */ - S_ST( 'e', 3, 338, 0 ), /* 474 manycastserv */ - S_ST( 's', 3, 339, 459 ), /* 475 ma */ - S_ST( 'x', 3, 491, 475 ), /* 476 ma */ - S_ST( 'a', 3, 478, 0 ), /* 477 max */ - S_ST( 'g', 3, 340, 0 ), /* 478 maxa */ - S_ST( 'c', 3, 480, 477 ), /* 479 max */ - S_ST( 'l', 3, 481, 0 ), /* 480 maxc */ - S_ST( 'o', 3, 482, 0 ), /* 481 maxcl */ - S_ST( 'c', 3, 341, 0 ), /* 482 maxclo */ - S_ST( 'd', 3, 487, 479 ), /* 483 max */ - S_ST( 'e', 3, 485, 0 ), /* 484 maxd */ - S_ST( 'p', 3, 486, 0 ), /* 485 maxde */ - S_ST( 't', 3, 342, 0 ), /* 486 maxdep */ - S_ST( 'i', 3, 488, 484 ), /* 487 maxd */ - S_ST( 's', 3, 343, 0 ), /* 488 maxdi */ - S_ST( 'm', 3, 490, 483 ), /* 489 max */ - S_ST( 'e', 3, 344, 0 ), /* 490 maxm */ - S_ST( 'p', 3, 492, 489 ), /* 491 max */ - S_ST( 'o', 3, 493, 0 ), /* 492 maxp */ - S_ST( 'l', 3, 345, 0 ), /* 493 maxpo */ - S_ST( 'd', 3, 495, 458 ), /* 494 m */ - S_ST( 'n', 3, 496, 0 ), /* 495 md */ - S_ST( 's', 3, 497, 0 ), /* 496 mdn */ - S_ST( 't', 3, 498, 0 ), /* 497 mdns */ - S_ST( 'r', 3, 499, 0 ), /* 498 mdnst */ - S_ST( 'i', 3, 500, 0 ), /* 499 mdnstr */ - S_ST( 'e', 3, 346, 0 ), /* 500 mdnstri */ - S_ST( 'e', 3, 347, 494 ), /* 501 m */ - S_ST( 'l', 3, 503, 0 ), /* 502 mem */ - S_ST( 'o', 3, 504, 0 ), /* 503 meml */ - S_ST( 'c', 3, 348, 0 ), /* 504 memlo */ - S_ST( 'i', 3, 506, 501 ), /* 505 m */ - S_ST( 'n', 3, 523, 0 ), /* 506 mi */ - S_ST( 'c', 3, 508, 0 ), /* 507 min */ - S_ST( 'l', 3, 509, 0 ), /* 508 minc */ - S_ST( 'o', 3, 510, 0 ), /* 509 mincl */ - S_ST( 'c', 3, 349, 0 ), /* 510 minclo */ - S_ST( 'd', 3, 515, 507 ), /* 511 min */ - S_ST( 'e', 3, 513, 0 ), /* 512 mind */ - S_ST( 'p', 3, 514, 0 ), /* 513 minde */ - S_ST( 't', 3, 350, 0 ), /* 514 mindep */ - S_ST( 'i', 3, 516, 512 ), /* 515 mind */ - S_ST( 's', 3, 351, 0 ), /* 516 mindi */ - S_ST( 'i', 3, 518, 511 ), /* 517 min */ - S_ST( 'm', 3, 519, 0 ), /* 518 mini */ - S_ST( 'u', 3, 352, 0 ), /* 519 minim */ - S_ST( 'p', 3, 521, 517 ), /* 520 min */ - S_ST( 'o', 3, 522, 0 ), /* 521 minp */ - S_ST( 'l', 3, 353, 0 ), /* 522 minpo */ - S_ST( 's', 3, 524, 520 ), /* 523 min */ - S_ST( 'a', 3, 525, 0 ), /* 524 mins */ - S_ST( 'n', 3, 354, 0 ), /* 525 minsa */ - S_ST( 'o', 3, 528, 505 ), /* 526 m */ - S_ST( 'd', 3, 355, 0 ), /* 527 mo */ - S_ST( 'n', 3, 532, 527 ), /* 528 mo */ - S_ST( 'i', 3, 530, 0 ), /* 529 mon */ - S_ST( 't', 3, 531, 0 ), /* 530 moni */ - S_ST( 'o', 3, 357, 0 ), /* 531 monit */ - S_ST( 't', 3, 358, 529 ), /* 532 mon */ - S_ST( 'r', 3, 359, 526 ), /* 533 m */ - S_ST( 's', 3, 535, 533 ), /* 534 m */ - S_ST( 's', 3, 536, 0 ), /* 535 ms */ - S_ST( 'n', 3, 537, 0 ), /* 536 mss */ - S_ST( 't', 3, 328, 0 ), /* 537 mssn */ - S_ST( 'u', 3, 539, 534 ), /* 538 m */ - S_ST( 'l', 3, 540, 0 ), /* 539 mu */ - S_ST( 't', 3, 541, 0 ), /* 540 mul */ - S_ST( 'i', 3, 542, 0 ), /* 541 mult */ - S_ST( 'c', 3, 543, 0 ), /* 542 multi */ - S_ST( 'a', 3, 544, 0 ), /* 543 multic */ - S_ST( 's', 3, 545, 0 ), /* 544 multica */ - S_ST( 't', 3, 546, 0 ), /* 545 multicas */ - S_ST( 'c', 3, 547, 0 ), /* 546 multicast */ - S_ST( 'l', 3, 548, 0 ), /* 547 multicastc */ - S_ST( 'i', 3, 549, 0 ), /* 548 multicastcl */ - S_ST( 'e', 3, 550, 0 ), /* 549 multicastcli */ - S_ST( 'n', 3, 360, 0 ), /* 550 multicastclie */ - S_ST( 'n', 3, 594, 457 ), /* 551 */ - S_ST( 'i', 3, 361, 0 ), /* 552 n */ - S_ST( 'o', 3, 589, 552 ), /* 553 n */ - S_ST( 'l', 3, 555, 0 ), /* 554 no */ - S_ST( 'i', 3, 556, 0 ), /* 555 nol */ - S_ST( 'n', 3, 362, 0 ), /* 556 noli */ - S_ST( 'm', 3, 562, 554 ), /* 557 no */ - S_ST( 'o', 3, 559, 0 ), /* 558 nom */ - S_ST( 'd', 3, 560, 0 ), /* 559 nomo */ - S_ST( 'i', 3, 561, 0 ), /* 560 nomod */ - S_ST( 'f', 3, 363, 0 ), /* 561 nomodi */ - S_ST( 'r', 3, 563, 558 ), /* 562 nom */ - S_ST( 'u', 3, 564, 0 ), /* 563 nomr */ - S_ST( 'l', 3, 565, 0 ), /* 564 nomru */ - S_ST( 'i', 3, 566, 0 ), /* 565 nomrul */ - S_ST( 's', 3, 364, 0 ), /* 566 nomruli */ - S_ST( 'n', 3, 568, 557 ), /* 567 no */ - S_ST( 'v', 3, 569, 365 ), /* 568 non */ - S_ST( 'o', 3, 570, 0 ), /* 569 nonv */ - S_ST( 'l', 3, 571, 0 ), /* 570 nonvo */ - S_ST( 'a', 3, 572, 0 ), /* 571 nonvol */ - S_ST( 't', 3, 573, 0 ), /* 572 nonvola */ - S_ST( 'i', 3, 574, 0 ), /* 573 nonvolat */ - S_ST( 'l', 3, 366, 0 ), /* 574 nonvolati */ - S_ST( 'p', 3, 576, 567 ), /* 575 no */ - S_ST( 'e', 3, 577, 0 ), /* 576 nop */ - S_ST( 'e', 3, 367, 0 ), /* 577 nope */ - S_ST( 'q', 3, 579, 575 ), /* 578 no */ - S_ST( 'u', 3, 580, 0 ), /* 579 noq */ - S_ST( 'e', 3, 581, 0 ), /* 580 noqu */ - S_ST( 'r', 3, 368, 0 ), /* 581 noque */ - S_ST( 's', 3, 583, 578 ), /* 582 no */ - S_ST( 'e', 3, 587, 0 ), /* 583 nos */ - S_ST( 'l', 3, 585, 0 ), /* 584 nose */ - S_ST( 'e', 3, 586, 0 ), /* 585 nosel */ - S_ST( 'c', 3, 369, 0 ), /* 586 nosele */ - S_ST( 'r', 3, 588, 584 ), /* 587 nose */ - S_ST( 'v', 3, 370, 0 ), /* 588 noser */ - S_ST( 't', 3, 590, 582 ), /* 589 no */ - S_ST( 'r', 3, 592, 0 ), /* 590 not */ - S_ST( 'a', 3, 371, 0 ), /* 591 notr */ - S_ST( 'u', 3, 593, 591 ), /* 592 notr */ - S_ST( 's', 3, 372, 0 ), /* 593 notru */ - S_ST( 't', 3, 373, 553 ), /* 594 n */ - S_ST( 'p', 3, 596, 0 ), /* 595 ntp */ - S_ST( 'o', 3, 597, 0 ), /* 596 ntpp */ - S_ST( 'r', 3, 374, 0 ), /* 597 ntppo */ - S_ST( 's', 3, 599, 595 ), /* 598 ntp */ - S_ST( 'i', 3, 600, 0 ), /* 599 ntps */ - S_ST( 'g', 3, 601, 0 ), /* 600 ntpsi */ - S_ST( 'n', 3, 602, 0 ), /* 601 ntpsig */ - S_ST( 'd', 3, 603, 0 ), /* 602 ntpsign */ - S_ST( 's', 3, 604, 0 ), /* 603 ntpsignd */ - S_ST( 'o', 3, 605, 0 ), /* 604 ntpsignds */ - S_ST( 'c', 3, 606, 0 ), /* 605 ntpsigndso */ - S_ST( 'k', 3, 607, 0 ), /* 606 ntpsigndsoc */ - S_ST( 'e', 3, 375, 0 ), /* 607 ntpsigndsock */ - S_ST( 'o', 3, 609, 551 ), /* 608 */ - S_ST( 'r', 3, 610, 0 ), /* 609 o */ - S_ST( 'p', 3, 611, 0 ), /* 610 or */ - S_ST( 'h', 3, 612, 0 ), /* 611 orp */ - S_ST( 'a', 3, 376, 0 ), /* 612 orph */ - S_ST( 'w', 3, 614, 0 ), /* 613 orphan */ - S_ST( 'a', 3, 615, 0 ), /* 614 orphanw */ - S_ST( 'i', 3, 377, 0 ), /* 615 orphanwa */ - S_ST( 'p', 3, 389, 608 ), /* 616 */ - S_ST( 'a', 3, 618, 0 ), /* 617 p */ - S_ST( 'n', 3, 619, 0 ), /* 618 pa */ - S_ST( 'i', 3, 378, 0 ), /* 619 pan */ - S_ST( 'e', 3, 621, 617 ), /* 620 p */ - S_ST( 'e', 3, 379, 0 ), /* 621 pe */ - S_ST( 's', 3, 623, 0 ), /* 622 peer */ - S_ST( 't', 3, 624, 0 ), /* 623 peers */ - S_ST( 'a', 3, 625, 0 ), /* 624 peerst */ - S_ST( 't', 3, 380, 0 ), /* 625 peersta */ - S_ST( 'h', 3, 627, 620 ), /* 626 p */ - S_ST( 'o', 3, 628, 0 ), /* 627 ph */ - S_ST( 'n', 3, 381, 0 ), /* 628 pho */ - S_ST( 'i', 3, 382, 626 ), /* 629 p */ - S_ST( 'f', 3, 631, 0 ), /* 630 pid */ - S_ST( 'i', 3, 632, 0 ), /* 631 pidf */ - S_ST( 'l', 3, 383, 0 ), /* 632 pidfi */ - S_ST( 'o', 3, 635, 629 ), /* 633 p */ - S_ST( 'o', 3, 384, 0 ), /* 634 po */ - S_ST( 'r', 3, 385, 634 ), /* 635 po */ - S_ST( 'r', 3, 643, 633 ), /* 636 p */ - S_ST( 'e', 3, 641, 0 ), /* 637 pr */ - S_ST( 'e', 3, 639, 0 ), /* 638 pre */ - S_ST( 'm', 3, 640, 0 ), /* 639 pree */ - S_ST( 'p', 3, 386, 0 ), /* 640 preem */ - S_ST( 'f', 3, 642, 638 ), /* 641 pre */ - S_ST( 'e', 3, 387, 0 ), /* 642 pref */ - S_ST( 'o', 3, 656, 637 ), /* 643 pr */ - S_ST( 'c', 3, 645, 0 ), /* 644 pro */ - S_ST( '_', 3, 646, 0 ), /* 645 proc */ - S_ST( 'd', 3, 647, 0 ), /* 646 proc_ */ - S_ST( 'e', 3, 648, 0 ), /* 647 proc_d */ - S_ST( 'l', 3, 649, 0 ), /* 648 proc_de */ - S_ST( 'a', 3, 446, 0 ), /* 649 proc_del */ - S_ST( 'p', 3, 651, 644 ), /* 650 pro */ - S_ST( '_', 3, 652, 0 ), /* 651 prop */ - S_ST( 'd', 3, 653, 0 ), /* 652 prop_ */ - S_ST( 'e', 3, 654, 0 ), /* 653 prop_d */ - S_ST( 'l', 3, 655, 0 ), /* 654 prop_de */ - S_ST( 'a', 3, 445, 0 ), /* 655 prop_del */ - S_ST( 't', 3, 657, 650 ), /* 656 pro */ - S_ST( 'o', 3, 658, 0 ), /* 657 prot */ - S_ST( 's', 3, 659, 0 ), /* 658 proto */ - S_ST( 't', 3, 660, 0 ), /* 659 protos */ - S_ST( 'a', 3, 661, 0 ), /* 660 protost */ - S_ST( 't', 3, 388, 0 ), /* 661 protosta */ - S_ST( 'r', 3, 693, 616 ), /* 662 */ - S_ST( 'a', 3, 669, 0 ), /* 663 r */ - S_ST( 'n', 3, 665, 0 ), /* 664 ra */ - S_ST( 'd', 3, 666, 0 ), /* 665 ran */ - S_ST( 'f', 3, 667, 0 ), /* 666 rand */ - S_ST( 'i', 3, 668, 0 ), /* 667 randf */ - S_ST( 'l', 3, 390, 0 ), /* 668 randfi */ - S_ST( 'w', 3, 670, 664 ), /* 669 ra */ - S_ST( 's', 3, 671, 0 ), /* 670 raw */ - S_ST( 't', 3, 672, 0 ), /* 671 raws */ - S_ST( 'a', 3, 673, 0 ), /* 672 rawst */ - S_ST( 't', 3, 391, 0 ), /* 673 rawsta */ - S_ST( 'e', 3, 690, 663 ), /* 674 r */ - S_ST( 'f', 3, 676, 0 ), /* 675 re */ - S_ST( 'i', 3, 392, 0 ), /* 676 ref */ - S_ST( 'q', 3, 678, 675 ), /* 677 re */ - S_ST( 'u', 3, 679, 0 ), /* 678 req */ - S_ST( 'e', 3, 680, 0 ), /* 679 requ */ - S_ST( 's', 3, 681, 0 ), /* 680 reque */ - S_ST( 't', 3, 682, 0 ), /* 681 reques */ - S_ST( 'k', 3, 683, 0 ), /* 682 request */ - S_ST( 'e', 3, 393, 0 ), /* 683 requestk */ - S_ST( 's', 3, 686, 677 ), /* 684 re */ - S_ST( 'e', 3, 394, 0 ), /* 685 res */ - S_ST( 't', 3, 687, 685 ), /* 686 res */ - S_ST( 'r', 3, 688, 0 ), /* 687 rest */ - S_ST( 'i', 3, 689, 0 ), /* 688 restr */ - S_ST( 'c', 3, 395, 0 ), /* 689 restri */ - S_ST( 'v', 3, 691, 684 ), /* 690 re */ - S_ST( 'o', 3, 692, 0 ), /* 691 rev */ - S_ST( 'k', 3, 396, 0 ), /* 692 revo */ - S_ST( 'l', 3, 694, 674 ), /* 693 r */ - S_ST( 'i', 3, 695, 0 ), /* 694 rl */ - S_ST( 'm', 3, 696, 0 ), /* 695 rli */ - S_ST( 'i', 3, 397, 0 ), /* 696 rlim */ - S_ST( 's', 3, 770, 662 ), /* 697 */ - S_ST( 'a', 3, 699, 0 ), /* 698 s */ - S_ST( 'v', 3, 700, 0 ), /* 699 sa */ - S_ST( 'e', 3, 701, 0 ), /* 700 sav */ - S_ST( 'c', 3, 702, 0 ), /* 701 save */ - S_ST( 'o', 3, 703, 0 ), /* 702 savec */ - S_ST( 'n', 3, 704, 0 ), /* 703 saveco */ - S_ST( 'f', 3, 705, 0 ), /* 704 savecon */ - S_ST( 'i', 3, 706, 0 ), /* 705 saveconf */ - S_ST( 'g', 3, 707, 0 ), /* 706 saveconfi */ - S_ST( 'd', 3, 708, 0 ), /* 707 saveconfig */ - S_ST( 'i', 3, 398, 0 ), /* 708 saveconfigd */ - S_ST( 'e', 3, 719, 698 ), /* 709 s */ - S_ST( 'r', 3, 711, 0 ), /* 710 se */ - S_ST( 'v', 3, 712, 0 ), /* 711 ser */ - S_ST( 'e', 3, 399, 0 ), /* 712 serv */ - S_ST( '_', 3, 714, 0 ), /* 713 server */ - S_ST( 'o', 3, 715, 0 ), /* 714 server_ */ - S_ST( 'f', 3, 716, 0 ), /* 715 server_o */ - S_ST( 'f', 3, 717, 0 ), /* 716 server_of */ - S_ST( 's', 3, 718, 0 ), /* 717 server_off */ - S_ST( 'e', 3, 440, 0 ), /* 718 server_offs */ - S_ST( 't', 3, 720, 710 ), /* 719 se */ - S_ST( 'v', 3, 721, 0 ), /* 720 set */ - S_ST( 'a', 3, 400, 0 ), /* 721 setv */ - S_ST( 'i', 3, 723, 709 ), /* 722 s */ - S_ST( 'm', 3, 724, 0 ), /* 723 si */ - S_ST( 'u', 3, 725, 0 ), /* 724 sim */ - S_ST( 'l', 3, 726, 0 ), /* 725 simu */ - S_ST( 'a', 3, 727, 0 ), /* 726 simul */ - S_ST( 't', 3, 728, 0 ), /* 727 simula */ - S_ST( 'i', 3, 729, 437 ), /* 728 simulat */ - S_ST( 'o', 3, 730, 0 ), /* 729 simulati */ - S_ST( 'n', 3, 731, 0 ), /* 730 simulatio */ - S_ST( '_', 3, 732, 0 ), /* 731 simulation */ - S_ST( 'd', 3, 733, 0 ), /* 732 simulation_ */ - S_ST( 'u', 3, 734, 0 ), /* 733 simulation_d */ - S_ST( 'r', 3, 735, 0 ), /* 734 simulation_du */ - S_ST( 'a', 3, 736, 0 ), /* 735 simulation_dur */ - S_ST( 't', 3, 737, 0 ), /* 736 simulation_dura */ - S_ST( 'i', 3, 738, 0 ), /* 737 simulation_durat */ - S_ST( 'o', 3, 439, 0 ), /* 738 simulation_durati */ - S_ST( 'o', 3, 740, 722 ), /* 739 s */ - S_ST( 'u', 3, 741, 0 ), /* 740 so */ - S_ST( 'r', 3, 742, 0 ), /* 741 sou */ - S_ST( 'c', 3, 401, 0 ), /* 742 sour */ - S_ST( 't', 3, 766, 739 ), /* 743 s */ - S_ST( 'a', 3, 750, 0 ), /* 744 st */ - S_ST( 'c', 3, 746, 0 ), /* 745 sta */ - S_ST( 'k', 3, 747, 0 ), /* 746 stac */ - S_ST( 's', 3, 748, 0 ), /* 747 stack */ - S_ST( 'i', 3, 749, 0 ), /* 748 stacks */ - S_ST( 'z', 3, 402, 0 ), /* 749 stacksi */ - S_ST( 't', 3, 404, 745 ), /* 750 sta */ - S_ST( 'i', 3, 752, 0 ), /* 751 stat */ - S_ST( 's', 3, 753, 0 ), /* 752 stati */ - S_ST( 't', 3, 754, 0 ), /* 753 statis */ - S_ST( 'i', 3, 755, 0 ), /* 754 statist */ - S_ST( 'c', 3, 403, 0 ), /* 755 statisti */ - S_ST( 'd', 3, 757, 0 ), /* 756 stats */ - S_ST( 'i', 3, 405, 0 ), /* 757 statsd */ - S_ST( 'e', 3, 406, 744 ), /* 758 st */ - S_ST( 'b', 3, 760, 0 ), /* 759 step */ - S_ST( 'a', 3, 761, 0 ), /* 760 stepb */ - S_ST( 'c', 3, 407, 0 ), /* 761 stepba */ - S_ST( 'f', 3, 763, 759 ), /* 762 step */ - S_ST( 'w', 3, 408, 0 ), /* 763 stepf */ - S_ST( 'o', 3, 765, 762 ), /* 764 step */ - S_ST( 'u', 3, 409, 0 ), /* 765 stepo */ - S_ST( 'r', 3, 767, 758 ), /* 766 st */ - S_ST( 'a', 3, 768, 0 ), /* 767 str */ - S_ST( 't', 3, 769, 0 ), /* 768 stra */ - S_ST( 'u', 3, 410, 0 ), /* 769 strat */ - S_ST( 'y', 3, 412, 743 ), /* 770 s */ - S_ST( 's', 3, 772, 0 ), /* 771 sys */ - S_ST( 't', 3, 773, 0 ), /* 772 syss */ - S_ST( 'a', 3, 774, 0 ), /* 773 sysst */ - S_ST( 't', 3, 413, 0 ), /* 774 syssta */ - S_ST( 't', 3, 801, 697 ), /* 775 */ - S_ST( 'i', 3, 787, 0 ), /* 776 t */ - S_ST( 'c', 3, 414, 0 ), /* 777 ti */ - S_ST( 'm', 3, 780, 777 ), /* 778 ti */ - S_ST( 'e', 3, 417, 0 ), /* 779 tim */ - S_ST( 'i', 3, 781, 779 ), /* 780 tim */ - S_ST( 'n', 3, 782, 0 ), /* 781 timi */ - S_ST( 'g', 3, 783, 0 ), /* 782 timin */ - S_ST( 's', 3, 784, 0 ), /* 783 timing */ - S_ST( 't', 3, 785, 0 ), /* 784 timings */ - S_ST( 'a', 3, 786, 0 ), /* 785 timingst */ - S_ST( 't', 3, 418, 0 ), /* 786 timingsta */ - S_ST( 'n', 3, 788, 778 ), /* 787 ti */ - S_ST( 'k', 3, 789, 0 ), /* 788 tin */ - S_ST( 'e', 3, 419, 0 ), /* 789 tink */ - S_ST( 'o', 3, 420, 776 ), /* 790 t */ - S_ST( 'r', 3, 793, 790 ), /* 791 t */ - S_ST( 'a', 3, 421, 0 ), /* 792 tr */ - S_ST( 'u', 3, 794, 792 ), /* 793 tr */ - S_ST( 's', 3, 795, 422 ), /* 794 tru */ - S_ST( 't', 3, 796, 0 ), /* 795 trus */ - S_ST( 'e', 3, 797, 0 ), /* 796 trust */ - S_ST( 'd', 3, 798, 0 ), /* 797 truste */ - S_ST( 'k', 3, 799, 0 ), /* 798 trusted */ - S_ST( 'e', 3, 423, 0 ), /* 799 trustedk */ - S_ST( 't', 3, 424, 791 ), /* 800 t */ - S_ST( 'y', 3, 802, 800 ), /* 801 t */ - S_ST( 'p', 3, 425, 0 ), /* 802 ty */ - S_ST( 'u', 3, 804, 775 ), /* 803 */ - S_ST( 'n', 3, 810, 0 ), /* 804 u */ - S_ST( 'c', 3, 806, 0 ), /* 805 un */ - S_ST( 'o', 3, 807, 0 ), /* 806 unc */ - S_ST( 'n', 3, 808, 0 ), /* 807 unco */ - S_ST( 'f', 3, 809, 0 ), /* 808 uncon */ - S_ST( 'i', 3, 427, 0 ), /* 809 unconf */ - S_ST( 'p', 3, 811, 805 ), /* 810 un */ - S_ST( 'e', 3, 812, 0 ), /* 811 unp */ - S_ST( 'e', 3, 428, 0 ), /* 812 unpe */ - S_ST( 'v', 3, 814, 803 ), /* 813 */ - S_ST( 'e', 3, 815, 0 ), /* 814 v */ - S_ST( 'r', 3, 816, 0 ), /* 815 ve */ - S_ST( 's', 3, 817, 0 ), /* 816 ver */ - S_ST( 'i', 3, 818, 0 ), /* 817 vers */ - S_ST( 'o', 3, 429, 0 ), /* 818 versi */ - S_ST( 'w', 3, 826, 813 ), /* 819 */ - S_ST( 'a', 3, 821, 0 ), /* 820 w */ - S_ST( 'n', 3, 822, 0 ), /* 821 wa */ - S_ST( 'd', 3, 823, 0 ), /* 822 wan */ - S_ST( 'e', 3, 443, 0 ), /* 823 wand */ - S_ST( 'e', 3, 825, 820 ), /* 824 w */ - S_ST( 'e', 3, 431, 0 ), /* 825 we */ - S_ST( 'i', 3, 827, 824 ), /* 826 w */ - S_ST( 'l', 3, 828, 0 ), /* 827 wi */ - S_ST( 'd', 3, 829, 0 ), /* 828 wil */ - S_ST( 'c', 3, 830, 0 ), /* 829 wild */ - S_ST( 'a', 3, 831, 0 ), /* 830 wildc */ - S_ST( 'r', 3, 432, 0 ), /* 831 wildca */ - S_ST( 'x', 3, 833, 819 ), /* 832 */ - S_ST( 'l', 3, 834, 0 ), /* 833 x */ - S_ST( 'e', 3, 835, 0 ), /* 834 xl */ - S_ST( 'a', 3, 836, 0 ), /* 835 xle */ - S_ST( 'v', 3, 433, 0 ), /* 836 xlea */ - S_ST( 'y', 3, 838, 832 ), /* 837 [initial state] */ - S_ST( 'e', 3, 839, 0 ), /* 838 y */ - S_ST( 'a', 3, 434, 0 ) /* 839 ye */ + S_ST( 'p', 0, 0, 0 ), /* 290 T_Dscp */ + S_ST( '.', 0, 0, 0 ), /* 291 T_Ellipsis */ + S_ST( 'e', 0, 0, 0 ), /* 292 T_Enable */ + S_ST( 'd', 0, 0, 147 ), /* 293 T_End */ + S_ST( 'm', 3, 316, 0 ), /* 294 li */ + S_ST( 'e', 1, 155, 0 ), /* 295 T_File */ + S_ST( 'n', 0, 0, 0 ), /* 296 T_Filegen */ + S_ST( 'm', 0, 0, 0 ), /* 297 T_Filenum */ + S_ST( '1', 0, 0, 0 ), /* 298 T_Flag1 */ + S_ST( '2', 0, 0, 298 ), /* 299 T_Flag2 */ + S_ST( '3', 0, 0, 299 ), /* 300 T_Flag3 */ + S_ST( '4', 0, 0, 300 ), /* 301 T_Flag4 */ + S_ST( 'e', 0, 0, 0 ), /* 302 T_Flake */ + S_ST( 'r', 0, 0, 0 ), /* 303 T_Floor */ + S_ST( 'q', 0, 165, 0 ), /* 304 T_Freq */ + S_ST( 'e', 1, 0, 0 ), /* 305 T_Fudge */ + S_ST( 't', 1, 0, 0 ), /* 306 T_Host */ + S_ST( 'f', 0, 0, 0 ), /* 307 T_Huffpuff */ + S_ST( 't', 0, 0, 0 ), /* 308 T_Iburst */ + S_ST( 't', 1, 0, 0 ), /* 309 T_Ident */ + S_ST( 'e', 0, 0, 0 ), /* 310 T_Ignore */ + S_ST( 'c', 0, 0, 0 ), /* 311 T_Incalloc */ + S_ST( 'm', 0, 0, 0 ), /* 312 T_Incmem */ + S_ST( 'c', 0, 0, 0 ), /* 313 T_Initalloc */ + S_ST( 'm', 0, 0, 0 ), /* 314 T_Initmem */ + S_ST( 'e', 1, 0, 0 ), /* 315 T_Includefile */ + S_ST( 'i', 3, 318, 0 ), /* 316 lim */ + S_ST( 'e', 0, 0, 0 ), /* 317 T_Interface */ + S_ST( 't', 3, 413, 0 ), /* 318 limi */ + S_ST( 'o', 0, 0, 195 ), /* 319 T_Io */ + S_ST( '4', 0, 0, 0 ), /* 320 T_Ipv4 */ + S_ST( '4', 0, 0, 0 ), /* 321 T_Ipv4_flag */ + S_ST( '6', 0, 0, 320 ), /* 322 T_Ipv6 */ + S_ST( '6', 0, 0, 321 ), /* 323 T_Ipv6_flag */ + S_ST( 'l', 0, 0, 0 ), /* 324 T_Kernel */ + S_ST( 'y', 0, 326, 233 ), /* 325 T_Key */ + S_ST( 's', 1, 236, 0 ), /* 326 T_Keys */ + S_ST( 'r', 1, 0, 0 ), /* 327 T_Keysdir */ + S_ST( 'd', 0, 0, 0 ), /* 328 T_Kod */ + S_ST( 'p', 0, 0, 0 ), /* 329 T_Mssntp */ + S_ST( 'e', 1, 0, 0 ), /* 330 T_Leapfile */ + S_ST( 'l', 0, 0, 0 ), /* 331 T_Leapsmearinterval */ + S_ST( 'd', 0, 0, 0 ), /* 332 T_Limited */ + S_ST( 'k', 0, 0, 0 ), /* 333 T_Link */ + S_ST( 'n', 0, 0, 0 ), /* 334 T_Listen */ + S_ST( 'g', 2, 0, 0 ), /* 335 T_Logconfig */ + S_ST( 'e', 1, 0, 0 ), /* 336 T_Logfile */ + S_ST( 's', 0, 0, 0 ), /* 337 T_Loopstats */ + S_ST( 'p', 0, 0, 0 ), /* 338 T_Lowpriotrap */ + S_ST( 't', 1, 0, 0 ), /* 339 T_Manycastclient */ + S_ST( 'r', 2, 0, 0 ), /* 340 T_Manycastserver */ + S_ST( 'k', 0, 0, 0 ), /* 341 T_Mask */ + S_ST( 'e', 0, 0, 0 ), /* 342 T_Maxage */ + S_ST( 'k', 0, 0, 0 ), /* 343 T_Maxclock */ + S_ST( 'h', 0, 0, 0 ), /* 344 T_Maxdepth */ + S_ST( 't', 0, 0, 0 ), /* 345 T_Maxdist */ + S_ST( 'm', 0, 0, 0 ), /* 346 T_Maxmem */ + S_ST( 'l', 0, 0, 0 ), /* 347 T_Maxpoll */ + S_ST( 's', 0, 0, 0 ), /* 348 T_Mdnstries */ + S_ST( 'm', 0, 518, 0 ), /* 349 T_Mem */ + S_ST( 'k', 0, 0, 0 ), /* 350 T_Memlock */ + S_ST( 'k', 0, 0, 0 ), /* 351 T_Minclock */ + S_ST( 'h', 0, 0, 0 ), /* 352 T_Mindepth */ + S_ST( 't', 0, 0, 0 ), /* 353 T_Mindist */ + S_ST( 'm', 0, 0, 0 ), /* 354 T_Minimum */ + S_ST( 'l', 0, 0, 0 ), /* 355 T_Minpoll */ + S_ST( 'e', 0, 0, 0 ), /* 356 T_Minsane */ + S_ST( 'e', 0, 358, 0 ), /* 357 T_Mode */ + S_ST( '7', 0, 0, 0 ), /* 358 T_Mode7 */ + S_ST( 'r', 0, 0, 0 ), /* 359 T_Monitor */ + S_ST( 'h', 0, 0, 0 ), /* 360 T_Month */ + S_ST( 'u', 0, 0, 0 ), /* 361 T_Mru */ + S_ST( 't', 2, 0, 0 ), /* 362 T_Multicastclient */ + S_ST( 'c', 0, 0, 0 ), /* 363 T_Nic */ + S_ST( 'k', 0, 0, 0 ), /* 364 T_Nolink */ + S_ST( 'y', 0, 0, 0 ), /* 365 T_Nomodify */ + S_ST( 't', 0, 0, 0 ), /* 366 T_Nomrulist */ + S_ST( 'e', 0, 0, 0 ), /* 367 T_None */ + S_ST( 'e', 0, 0, 0 ), /* 368 T_Nonvolatile */ + S_ST( 'r', 0, 0, 0 ), /* 369 T_Nopeer */ + S_ST( 'y', 0, 0, 0 ), /* 370 T_Noquery */ + S_ST( 't', 0, 0, 0 ), /* 371 T_Noselect */ + S_ST( 'e', 0, 0, 0 ), /* 372 T_Noserve */ + S_ST( 'p', 0, 0, 0 ), /* 373 T_Notrap */ + S_ST( 't', 0, 0, 0 ), /* 374 T_Notrust */ + S_ST( 'p', 0, 614, 0 ), /* 375 T_Ntp */ + S_ST( 't', 0, 0, 0 ), /* 376 T_Ntpport */ + S_ST( 't', 1, 0, 0 ), /* 377 T_NtpSignDsocket */ + S_ST( 'n', 0, 629, 0 ), /* 378 T_Orphan */ + S_ST( 't', 0, 0, 0 ), /* 379 T_Orphanwait */ + S_ST( 'c', 0, 0, 0 ), /* 380 T_Panic */ + S_ST( 'r', 1, 638, 0 ), /* 381 T_Peer */ + S_ST( 's', 0, 0, 0 ), /* 382 T_Peerstats */ + S_ST( 'e', 2, 0, 0 ), /* 383 T_Phone */ + S_ST( 'd', 0, 646, 0 ), /* 384 T_Pid */ + S_ST( 'e', 1, 0, 0 ), /* 385 T_Pidfile */ + S_ST( 'l', 1, 0, 0 ), /* 386 T_Pool */ + S_ST( 't', 0, 0, 0 ), /* 387 T_Port */ + S_ST( 't', 0, 0, 0 ), /* 388 T_Preempt */ + S_ST( 'r', 0, 0, 0 ), /* 389 T_Prefer */ + S_ST( 's', 0, 0, 0 ), /* 390 T_Protostats */ + S_ST( 'w', 1, 0, 652 ), /* 391 T_Pw */ + S_ST( 'e', 1, 0, 0 ), /* 392 T_Randfile */ + S_ST( 's', 0, 0, 0 ), /* 393 T_Rawstats */ + S_ST( 'd', 1, 0, 0 ), /* 394 T_Refid */ + S_ST( 'y', 0, 0, 0 ), /* 395 T_Requestkey */ + S_ST( 't', 0, 0, 0 ), /* 396 T_Reset */ + S_ST( 't', 0, 0, 0 ), /* 397 T_Restrict */ + S_ST( 'e', 0, 0, 0 ), /* 398 T_Revoke */ + S_ST( 't', 0, 0, 0 ), /* 399 T_Rlimit */ + S_ST( 'r', 1, 0, 0 ), /* 400 T_Saveconfigdir */ + S_ST( 'r', 1, 729, 0 ), /* 401 T_Server */ + S_ST( 'r', 1, 0, 0 ), /* 402 T_Setvar */ + S_ST( 'e', 0, 0, 0 ), /* 403 T_Source */ + S_ST( 'e', 0, 0, 0 ), /* 404 T_Stacksize */ + S_ST( 's', 0, 0, 0 ), /* 405 T_Statistics */ + S_ST( 's', 0, 772, 767 ), /* 406 T_Stats */ + S_ST( 'r', 1, 0, 0 ), /* 407 T_Statsdir */ + S_ST( 'p', 0, 780, 0 ), /* 408 T_Step */ + S_ST( 'k', 0, 0, 0 ), /* 409 T_Stepback */ + S_ST( 'd', 0, 0, 0 ), /* 410 T_Stepfwd */ + S_ST( 't', 0, 0, 0 ), /* 411 T_Stepout */ + S_ST( 'm', 0, 0, 0 ), /* 412 T_Stratum */ + S_ST( 'e', 3, 332, 0 ), /* 413 limit */ + S_ST( 's', 0, 787, 0 ), /* 414 T_Sys */ + S_ST( 's', 0, 0, 0 ), /* 415 T_Sysstats */ + S_ST( 'k', 0, 0, 0 ), /* 416 T_Tick */ + S_ST( '1', 0, 0, 0 ), /* 417 T_Time1 */ + S_ST( '2', 0, 0, 417 ), /* 418 T_Time2 */ + S_ST( 'r', 0, 0, 418 ), /* 419 T_Timer */ + S_ST( 's', 0, 0, 0 ), /* 420 T_Timingstats */ + S_ST( 'r', 0, 0, 0 ), /* 421 T_Tinker */ + S_ST( 's', 0, 0, 0 ), /* 422 T_Tos */ + S_ST( 'p', 1, 0, 0 ), /* 423 T_Trap */ + S_ST( 'e', 0, 0, 0 ), /* 424 T_True */ + S_ST( 'y', 0, 0, 0 ), /* 425 T_Trustedkey */ + S_ST( 'l', 0, 0, 0 ), /* 426 T_Ttl */ + S_ST( 'e', 0, 0, 0 ), /* 427 T_Type */ + S_ST( 'n', 3, 333, 294 ), /* 428 li */ + S_ST( 'g', 1, 0, 0 ), /* 429 T_Unconfig */ + S_ST( 'r', 1, 0, 0 ), /* 430 T_Unpeer */ + S_ST( 'n', 0, 0, 0 ), /* 431 T_Version */ + S_ST( 's', 3, 437, 428 ), /* 432 li */ + S_ST( 'k', 0, 0, 0 ), /* 433 T_Week */ + S_ST( 'd', 0, 0, 0 ), /* 434 T_Wildcard */ + S_ST( 'e', 0, 0, 0 ), /* 435 T_Xleave */ + S_ST( 'r', 0, 0, 0 ), /* 436 T_Year */ + S_ST( 't', 3, 438, 0 ), /* 437 lis */ + S_ST( 'e', 3, 334, 0 ), /* 438 list */ + S_ST( 'e', 0, 0, 0 ), /* 439 T_Simulate */ + S_ST( 'y', 0, 0, 0 ), /* 440 T_Beep_Delay */ + S_ST( 'n', 0, 0, 0 ), /* 441 T_Sim_Duration */ + S_ST( 't', 0, 0, 0 ), /* 442 T_Server_Offset */ + S_ST( 'n', 0, 0, 0 ), /* 443 T_Duration */ + S_ST( 't', 0, 0, 0 ), /* 444 T_Freq_Offset */ + S_ST( 'r', 0, 0, 0 ), /* 445 T_Wander */ + S_ST( 'r', 0, 0, 0 ), /* 446 T_Jitter */ + S_ST( 'y', 0, 0, 0 ), /* 447 T_Prop_Delay */ + S_ST( 'y', 0, 0, 0 ), /* 448 T_Proc_Delay */ + S_ST( 'o', 3, 465, 287 ), /* 449 l */ + S_ST( 'g', 3, 456, 0 ), /* 450 lo */ + S_ST( 'c', 3, 452, 0 ), /* 451 log */ + S_ST( 'o', 3, 453, 0 ), /* 452 logc */ + S_ST( 'n', 3, 454, 0 ), /* 453 logco */ + S_ST( 'f', 3, 455, 0 ), /* 454 logcon */ + S_ST( 'i', 3, 335, 0 ), /* 455 logconf */ + S_ST( 'f', 3, 457, 451 ), /* 456 log */ + S_ST( 'i', 3, 458, 0 ), /* 457 logf */ + S_ST( 'l', 3, 336, 0 ), /* 458 logfi */ + S_ST( 'o', 3, 460, 450 ), /* 459 lo */ + S_ST( 'p', 3, 461, 0 ), /* 460 loo */ + S_ST( 's', 3, 462, 0 ), /* 461 loop */ + S_ST( 't', 3, 463, 0 ), /* 462 loops */ + S_ST( 'a', 3, 464, 0 ), /* 463 loopst */ + S_ST( 't', 3, 337, 0 ), /* 464 loopsta */ + S_ST( 'w', 3, 466, 459 ), /* 465 lo */ + S_ST( 'p', 3, 467, 0 ), /* 466 low */ + S_ST( 'r', 3, 468, 0 ), /* 467 lowp */ + S_ST( 'i', 3, 469, 0 ), /* 468 lowpr */ + S_ST( 'o', 3, 470, 0 ), /* 469 lowpri */ + S_ST( 't', 3, 471, 0 ), /* 470 lowprio */ + S_ST( 'r', 3, 472, 0 ), /* 471 lowpriot */ + S_ST( 'a', 3, 338, 0 ), /* 472 lowpriotr */ + S_ST( 'm', 3, 554, 239 ), /* 473 */ + S_ST( 'a', 3, 492, 0 ), /* 474 m */ + S_ST( 'n', 3, 476, 0 ), /* 475 ma */ + S_ST( 'y', 3, 477, 0 ), /* 476 man */ + S_ST( 'c', 3, 478, 0 ), /* 477 many */ + S_ST( 'a', 3, 479, 0 ), /* 478 manyc */ + S_ST( 's', 3, 480, 0 ), /* 479 manyca */ + S_ST( 't', 3, 486, 0 ), /* 480 manycas */ + S_ST( 'c', 3, 482, 0 ), /* 481 manycast */ + S_ST( 'l', 3, 483, 0 ), /* 482 manycastc */ + S_ST( 'i', 3, 484, 0 ), /* 483 manycastcl */ + S_ST( 'e', 3, 485, 0 ), /* 484 manycastcli */ + S_ST( 'n', 3, 339, 0 ), /* 485 manycastclie */ + S_ST( 's', 3, 487, 481 ), /* 486 manycast */ + S_ST( 'e', 3, 488, 0 ), /* 487 manycasts */ + S_ST( 'r', 3, 489, 0 ), /* 488 manycastse */ + S_ST( 'v', 3, 490, 0 ), /* 489 manycastser */ + S_ST( 'e', 3, 340, 0 ), /* 490 manycastserv */ + S_ST( 's', 3, 341, 475 ), /* 491 ma */ + S_ST( 'x', 3, 507, 491 ), /* 492 ma */ + S_ST( 'a', 3, 494, 0 ), /* 493 max */ + S_ST( 'g', 3, 342, 0 ), /* 494 maxa */ + S_ST( 'c', 3, 496, 493 ), /* 495 max */ + S_ST( 'l', 3, 497, 0 ), /* 496 maxc */ + S_ST( 'o', 3, 498, 0 ), /* 497 maxcl */ + S_ST( 'c', 3, 343, 0 ), /* 498 maxclo */ + S_ST( 'd', 3, 503, 495 ), /* 499 max */ + S_ST( 'e', 3, 501, 0 ), /* 500 maxd */ + S_ST( 'p', 3, 502, 0 ), /* 501 maxde */ + S_ST( 't', 3, 344, 0 ), /* 502 maxdep */ + S_ST( 'i', 3, 504, 500 ), /* 503 maxd */ + S_ST( 's', 3, 345, 0 ), /* 504 maxdi */ + S_ST( 'm', 3, 506, 499 ), /* 505 max */ + S_ST( 'e', 3, 346, 0 ), /* 506 maxm */ + S_ST( 'p', 3, 508, 505 ), /* 507 max */ + S_ST( 'o', 3, 509, 0 ), /* 508 maxp */ + S_ST( 'l', 3, 347, 0 ), /* 509 maxpo */ + S_ST( 'd', 3, 511, 474 ), /* 510 m */ + S_ST( 'n', 3, 512, 0 ), /* 511 md */ + S_ST( 's', 3, 513, 0 ), /* 512 mdn */ + S_ST( 't', 3, 514, 0 ), /* 513 mdns */ + S_ST( 'r', 3, 515, 0 ), /* 514 mdnst */ + S_ST( 'i', 3, 516, 0 ), /* 515 mdnstr */ + S_ST( 'e', 3, 348, 0 ), /* 516 mdnstri */ + S_ST( 'e', 3, 349, 510 ), /* 517 m */ + S_ST( 'l', 3, 519, 0 ), /* 518 mem */ + S_ST( 'o', 3, 520, 0 ), /* 519 meml */ + S_ST( 'c', 3, 350, 0 ), /* 520 memlo */ + S_ST( 'i', 3, 522, 517 ), /* 521 m */ + S_ST( 'n', 3, 539, 0 ), /* 522 mi */ + S_ST( 'c', 3, 524, 0 ), /* 523 min */ + S_ST( 'l', 3, 525, 0 ), /* 524 minc */ + S_ST( 'o', 3, 526, 0 ), /* 525 mincl */ + S_ST( 'c', 3, 351, 0 ), /* 526 minclo */ + S_ST( 'd', 3, 531, 523 ), /* 527 min */ + S_ST( 'e', 3, 529, 0 ), /* 528 mind */ + S_ST( 'p', 3, 530, 0 ), /* 529 minde */ + S_ST( 't', 3, 352, 0 ), /* 530 mindep */ + S_ST( 'i', 3, 532, 528 ), /* 531 mind */ + S_ST( 's', 3, 353, 0 ), /* 532 mindi */ + S_ST( 'i', 3, 534, 527 ), /* 533 min */ + S_ST( 'm', 3, 535, 0 ), /* 534 mini */ + S_ST( 'u', 3, 354, 0 ), /* 535 minim */ + S_ST( 'p', 3, 537, 533 ), /* 536 min */ + S_ST( 'o', 3, 538, 0 ), /* 537 minp */ + S_ST( 'l', 3, 355, 0 ), /* 538 minpo */ + S_ST( 's', 3, 540, 536 ), /* 539 min */ + S_ST( 'a', 3, 541, 0 ), /* 540 mins */ + S_ST( 'n', 3, 356, 0 ), /* 541 minsa */ + S_ST( 'o', 3, 544, 521 ), /* 542 m */ + S_ST( 'd', 3, 357, 0 ), /* 543 mo */ + S_ST( 'n', 3, 548, 543 ), /* 544 mo */ + S_ST( 'i', 3, 546, 0 ), /* 545 mon */ + S_ST( 't', 3, 547, 0 ), /* 546 moni */ + S_ST( 'o', 3, 359, 0 ), /* 547 monit */ + S_ST( 't', 3, 360, 545 ), /* 548 mon */ + S_ST( 'r', 3, 361, 542 ), /* 549 m */ + S_ST( 's', 3, 551, 549 ), /* 550 m */ + S_ST( 's', 3, 552, 0 ), /* 551 ms */ + S_ST( 'n', 3, 553, 0 ), /* 552 mss */ + S_ST( 't', 3, 329, 0 ), /* 553 mssn */ + S_ST( 'u', 3, 555, 550 ), /* 554 m */ + S_ST( 'l', 3, 556, 0 ), /* 555 mu */ + S_ST( 't', 3, 557, 0 ), /* 556 mul */ + S_ST( 'i', 3, 558, 0 ), /* 557 mult */ + S_ST( 'c', 3, 559, 0 ), /* 558 multi */ + S_ST( 'a', 3, 560, 0 ), /* 559 multic */ + S_ST( 's', 3, 561, 0 ), /* 560 multica */ + S_ST( 't', 3, 562, 0 ), /* 561 multicas */ + S_ST( 'c', 3, 563, 0 ), /* 562 multicast */ + S_ST( 'l', 3, 564, 0 ), /* 563 multicastc */ + S_ST( 'i', 3, 565, 0 ), /* 564 multicastcl */ + S_ST( 'e', 3, 566, 0 ), /* 565 multicastcli */ + S_ST( 'n', 3, 362, 0 ), /* 566 multicastclie */ + S_ST( 'n', 3, 610, 473 ), /* 567 */ + S_ST( 'i', 3, 363, 0 ), /* 568 n */ + S_ST( 'o', 3, 605, 568 ), /* 569 n */ + S_ST( 'l', 3, 571, 0 ), /* 570 no */ + S_ST( 'i', 3, 572, 0 ), /* 571 nol */ + S_ST( 'n', 3, 364, 0 ), /* 572 noli */ + S_ST( 'm', 3, 578, 570 ), /* 573 no */ + S_ST( 'o', 3, 575, 0 ), /* 574 nom */ + S_ST( 'd', 3, 576, 0 ), /* 575 nomo */ + S_ST( 'i', 3, 577, 0 ), /* 576 nomod */ + S_ST( 'f', 3, 365, 0 ), /* 577 nomodi */ + S_ST( 'r', 3, 579, 574 ), /* 578 nom */ + S_ST( 'u', 3, 580, 0 ), /* 579 nomr */ + S_ST( 'l', 3, 581, 0 ), /* 580 nomru */ + S_ST( 'i', 3, 582, 0 ), /* 581 nomrul */ + S_ST( 's', 3, 366, 0 ), /* 582 nomruli */ + S_ST( 'n', 3, 584, 573 ), /* 583 no */ + S_ST( 'v', 3, 585, 367 ), /* 584 non */ + S_ST( 'o', 3, 586, 0 ), /* 585 nonv */ + S_ST( 'l', 3, 587, 0 ), /* 586 nonvo */ + S_ST( 'a', 3, 588, 0 ), /* 587 nonvol */ + S_ST( 't', 3, 589, 0 ), /* 588 nonvola */ + S_ST( 'i', 3, 590, 0 ), /* 589 nonvolat */ + S_ST( 'l', 3, 368, 0 ), /* 590 nonvolati */ + S_ST( 'p', 3, 592, 583 ), /* 591 no */ + S_ST( 'e', 3, 593, 0 ), /* 592 nop */ + S_ST( 'e', 3, 369, 0 ), /* 593 nope */ + S_ST( 'q', 3, 595, 591 ), /* 594 no */ + S_ST( 'u', 3, 596, 0 ), /* 595 noq */ + S_ST( 'e', 3, 597, 0 ), /* 596 noqu */ + S_ST( 'r', 3, 370, 0 ), /* 597 noque */ + S_ST( 's', 3, 599, 594 ), /* 598 no */ + S_ST( 'e', 3, 603, 0 ), /* 599 nos */ + S_ST( 'l', 3, 601, 0 ), /* 600 nose */ + S_ST( 'e', 3, 602, 0 ), /* 601 nosel */ + S_ST( 'c', 3, 371, 0 ), /* 602 nosele */ + S_ST( 'r', 3, 604, 600 ), /* 603 nose */ + S_ST( 'v', 3, 372, 0 ), /* 604 noser */ + S_ST( 't', 3, 606, 598 ), /* 605 no */ + S_ST( 'r', 3, 608, 0 ), /* 606 not */ + S_ST( 'a', 3, 373, 0 ), /* 607 notr */ + S_ST( 'u', 3, 609, 607 ), /* 608 notr */ + S_ST( 's', 3, 374, 0 ), /* 609 notru */ + S_ST( 't', 3, 375, 569 ), /* 610 n */ + S_ST( 'p', 3, 612, 0 ), /* 611 ntp */ + S_ST( 'o', 3, 613, 0 ), /* 612 ntpp */ + S_ST( 'r', 3, 376, 0 ), /* 613 ntppo */ + S_ST( 's', 3, 615, 611 ), /* 614 ntp */ + S_ST( 'i', 3, 616, 0 ), /* 615 ntps */ + S_ST( 'g', 3, 617, 0 ), /* 616 ntpsi */ + S_ST( 'n', 3, 618, 0 ), /* 617 ntpsig */ + S_ST( 'd', 3, 619, 0 ), /* 618 ntpsign */ + S_ST( 's', 3, 620, 0 ), /* 619 ntpsignd */ + S_ST( 'o', 3, 621, 0 ), /* 620 ntpsignds */ + S_ST( 'c', 3, 622, 0 ), /* 621 ntpsigndso */ + S_ST( 'k', 3, 623, 0 ), /* 622 ntpsigndsoc */ + S_ST( 'e', 3, 377, 0 ), /* 623 ntpsigndsock */ + S_ST( 'o', 3, 625, 567 ), /* 624 */ + S_ST( 'r', 3, 626, 0 ), /* 625 o */ + S_ST( 'p', 3, 627, 0 ), /* 626 or */ + S_ST( 'h', 3, 628, 0 ), /* 627 orp */ + S_ST( 'a', 3, 378, 0 ), /* 628 orph */ + S_ST( 'w', 3, 630, 0 ), /* 629 orphan */ + S_ST( 'a', 3, 631, 0 ), /* 630 orphanw */ + S_ST( 'i', 3, 379, 0 ), /* 631 orphanwa */ + S_ST( 'p', 3, 391, 624 ), /* 632 */ + S_ST( 'a', 3, 634, 0 ), /* 633 p */ + S_ST( 'n', 3, 635, 0 ), /* 634 pa */ + S_ST( 'i', 3, 380, 0 ), /* 635 pan */ + S_ST( 'e', 3, 637, 633 ), /* 636 p */ + S_ST( 'e', 3, 381, 0 ), /* 637 pe */ + S_ST( 's', 3, 639, 0 ), /* 638 peer */ + S_ST( 't', 3, 640, 0 ), /* 639 peers */ + S_ST( 'a', 3, 641, 0 ), /* 640 peerst */ + S_ST( 't', 3, 382, 0 ), /* 641 peersta */ + S_ST( 'h', 3, 643, 636 ), /* 642 p */ + S_ST( 'o', 3, 644, 0 ), /* 643 ph */ + S_ST( 'n', 3, 383, 0 ), /* 644 pho */ + S_ST( 'i', 3, 384, 642 ), /* 645 p */ + S_ST( 'f', 3, 647, 0 ), /* 646 pid */ + S_ST( 'i', 3, 648, 0 ), /* 647 pidf */ + S_ST( 'l', 3, 385, 0 ), /* 648 pidfi */ + S_ST( 'o', 3, 651, 645 ), /* 649 p */ + S_ST( 'o', 3, 386, 0 ), /* 650 po */ + S_ST( 'r', 3, 387, 650 ), /* 651 po */ + S_ST( 'r', 3, 659, 649 ), /* 652 p */ + S_ST( 'e', 3, 657, 0 ), /* 653 pr */ + S_ST( 'e', 3, 655, 0 ), /* 654 pre */ + S_ST( 'm', 3, 656, 0 ), /* 655 pree */ + S_ST( 'p', 3, 388, 0 ), /* 656 preem */ + S_ST( 'f', 3, 658, 654 ), /* 657 pre */ + S_ST( 'e', 3, 389, 0 ), /* 658 pref */ + S_ST( 'o', 3, 672, 653 ), /* 659 pr */ + S_ST( 'c', 3, 661, 0 ), /* 660 pro */ + S_ST( '_', 3, 662, 0 ), /* 661 proc */ + S_ST( 'd', 3, 663, 0 ), /* 662 proc_ */ + S_ST( 'e', 3, 664, 0 ), /* 663 proc_d */ + S_ST( 'l', 3, 665, 0 ), /* 664 proc_de */ + S_ST( 'a', 3, 448, 0 ), /* 665 proc_del */ + S_ST( 'p', 3, 667, 660 ), /* 666 pro */ + S_ST( '_', 3, 668, 0 ), /* 667 prop */ + S_ST( 'd', 3, 669, 0 ), /* 668 prop_ */ + S_ST( 'e', 3, 670, 0 ), /* 669 prop_d */ + S_ST( 'l', 3, 671, 0 ), /* 670 prop_de */ + S_ST( 'a', 3, 447, 0 ), /* 671 prop_del */ + S_ST( 't', 3, 673, 666 ), /* 672 pro */ + S_ST( 'o', 3, 674, 0 ), /* 673 prot */ + S_ST( 's', 3, 675, 0 ), /* 674 proto */ + S_ST( 't', 3, 676, 0 ), /* 675 protos */ + S_ST( 'a', 3, 677, 0 ), /* 676 protost */ + S_ST( 't', 3, 390, 0 ), /* 677 protosta */ + S_ST( 'r', 3, 709, 632 ), /* 678 */ + S_ST( 'a', 3, 685, 0 ), /* 679 r */ + S_ST( 'n', 3, 681, 0 ), /* 680 ra */ + S_ST( 'd', 3, 682, 0 ), /* 681 ran */ + S_ST( 'f', 3, 683, 0 ), /* 682 rand */ + S_ST( 'i', 3, 684, 0 ), /* 683 randf */ + S_ST( 'l', 3, 392, 0 ), /* 684 randfi */ + S_ST( 'w', 3, 686, 680 ), /* 685 ra */ + S_ST( 's', 3, 687, 0 ), /* 686 raw */ + S_ST( 't', 3, 688, 0 ), /* 687 raws */ + S_ST( 'a', 3, 689, 0 ), /* 688 rawst */ + S_ST( 't', 3, 393, 0 ), /* 689 rawsta */ + S_ST( 'e', 3, 706, 679 ), /* 690 r */ + S_ST( 'f', 3, 692, 0 ), /* 691 re */ + S_ST( 'i', 3, 394, 0 ), /* 692 ref */ + S_ST( 'q', 3, 694, 691 ), /* 693 re */ + S_ST( 'u', 3, 695, 0 ), /* 694 req */ + S_ST( 'e', 3, 696, 0 ), /* 695 requ */ + S_ST( 's', 3, 697, 0 ), /* 696 reque */ + S_ST( 't', 3, 698, 0 ), /* 697 reques */ + S_ST( 'k', 3, 699, 0 ), /* 698 request */ + S_ST( 'e', 3, 395, 0 ), /* 699 requestk */ + S_ST( 's', 3, 702, 693 ), /* 700 re */ + S_ST( 'e', 3, 396, 0 ), /* 701 res */ + S_ST( 't', 3, 703, 701 ), /* 702 res */ + S_ST( 'r', 3, 704, 0 ), /* 703 rest */ + S_ST( 'i', 3, 705, 0 ), /* 704 restr */ + S_ST( 'c', 3, 397, 0 ), /* 705 restri */ + S_ST( 'v', 3, 707, 700 ), /* 706 re */ + S_ST( 'o', 3, 708, 0 ), /* 707 rev */ + S_ST( 'k', 3, 398, 0 ), /* 708 revo */ + S_ST( 'l', 3, 710, 690 ), /* 709 r */ + S_ST( 'i', 3, 711, 0 ), /* 710 rl */ + S_ST( 'm', 3, 712, 0 ), /* 711 rli */ + S_ST( 'i', 3, 399, 0 ), /* 712 rlim */ + S_ST( 's', 3, 786, 678 ), /* 713 */ + S_ST( 'a', 3, 715, 0 ), /* 714 s */ + S_ST( 'v', 3, 716, 0 ), /* 715 sa */ + S_ST( 'e', 3, 717, 0 ), /* 716 sav */ + S_ST( 'c', 3, 718, 0 ), /* 717 save */ + S_ST( 'o', 3, 719, 0 ), /* 718 savec */ + S_ST( 'n', 3, 720, 0 ), /* 719 saveco */ + S_ST( 'f', 3, 721, 0 ), /* 720 savecon */ + S_ST( 'i', 3, 722, 0 ), /* 721 saveconf */ + S_ST( 'g', 3, 723, 0 ), /* 722 saveconfi */ + S_ST( 'd', 3, 724, 0 ), /* 723 saveconfig */ + S_ST( 'i', 3, 400, 0 ), /* 724 saveconfigd */ + S_ST( 'e', 3, 735, 714 ), /* 725 s */ + S_ST( 'r', 3, 727, 0 ), /* 726 se */ + S_ST( 'v', 3, 728, 0 ), /* 727 ser */ + S_ST( 'e', 3, 401, 0 ), /* 728 serv */ + S_ST( '_', 3, 730, 0 ), /* 729 server */ + S_ST( 'o', 3, 731, 0 ), /* 730 server_ */ + S_ST( 'f', 3, 732, 0 ), /* 731 server_o */ + S_ST( 'f', 3, 733, 0 ), /* 732 server_of */ + S_ST( 's', 3, 734, 0 ), /* 733 server_off */ + S_ST( 'e', 3, 442, 0 ), /* 734 server_offs */ + S_ST( 't', 3, 736, 726 ), /* 735 se */ + S_ST( 'v', 3, 737, 0 ), /* 736 set */ + S_ST( 'a', 3, 402, 0 ), /* 737 setv */ + S_ST( 'i', 3, 739, 725 ), /* 738 s */ + S_ST( 'm', 3, 740, 0 ), /* 739 si */ + S_ST( 'u', 3, 741, 0 ), /* 740 sim */ + S_ST( 'l', 3, 742, 0 ), /* 741 simu */ + S_ST( 'a', 3, 743, 0 ), /* 742 simul */ + S_ST( 't', 3, 744, 0 ), /* 743 simula */ + S_ST( 'i', 3, 745, 439 ), /* 744 simulat */ + S_ST( 'o', 3, 746, 0 ), /* 745 simulati */ + S_ST( 'n', 3, 747, 0 ), /* 746 simulatio */ + S_ST( '_', 3, 748, 0 ), /* 747 simulation */ + S_ST( 'd', 3, 749, 0 ), /* 748 simulation_ */ + S_ST( 'u', 3, 750, 0 ), /* 749 simulation_d */ + S_ST( 'r', 3, 751, 0 ), /* 750 simulation_du */ + S_ST( 'a', 3, 752, 0 ), /* 751 simulation_dur */ + S_ST( 't', 3, 753, 0 ), /* 752 simulation_dura */ + S_ST( 'i', 3, 754, 0 ), /* 753 simulation_durat */ + S_ST( 'o', 3, 441, 0 ), /* 754 simulation_durati */ + S_ST( 'o', 3, 756, 738 ), /* 755 s */ + S_ST( 'u', 3, 757, 0 ), /* 756 so */ + S_ST( 'r', 3, 758, 0 ), /* 757 sou */ + S_ST( 'c', 3, 403, 0 ), /* 758 sour */ + S_ST( 't', 3, 782, 755 ), /* 759 s */ + S_ST( 'a', 3, 766, 0 ), /* 760 st */ + S_ST( 'c', 3, 762, 0 ), /* 761 sta */ + S_ST( 'k', 3, 763, 0 ), /* 762 stac */ + S_ST( 's', 3, 764, 0 ), /* 763 stack */ + S_ST( 'i', 3, 765, 0 ), /* 764 stacks */ + S_ST( 'z', 3, 404, 0 ), /* 765 stacksi */ + S_ST( 't', 3, 406, 761 ), /* 766 sta */ + S_ST( 'i', 3, 768, 0 ), /* 767 stat */ + S_ST( 's', 3, 769, 0 ), /* 768 stati */ + S_ST( 't', 3, 770, 0 ), /* 769 statis */ + S_ST( 'i', 3, 771, 0 ), /* 770 statist */ + S_ST( 'c', 3, 405, 0 ), /* 771 statisti */ + S_ST( 'd', 3, 773, 0 ), /* 772 stats */ + S_ST( 'i', 3, 407, 0 ), /* 773 statsd */ + S_ST( 'e', 3, 408, 760 ), /* 774 st */ + S_ST( 'b', 3, 776, 0 ), /* 775 step */ + S_ST( 'a', 3, 777, 0 ), /* 776 stepb */ + S_ST( 'c', 3, 409, 0 ), /* 777 stepba */ + S_ST( 'f', 3, 779, 775 ), /* 778 step */ + S_ST( 'w', 3, 410, 0 ), /* 779 stepf */ + S_ST( 'o', 3, 781, 778 ), /* 780 step */ + S_ST( 'u', 3, 411, 0 ), /* 781 stepo */ + S_ST( 'r', 3, 783, 774 ), /* 782 st */ + S_ST( 'a', 3, 784, 0 ), /* 783 str */ + S_ST( 't', 3, 785, 0 ), /* 784 stra */ + S_ST( 'u', 3, 412, 0 ), /* 785 strat */ + S_ST( 'y', 3, 414, 759 ), /* 786 s */ + S_ST( 's', 3, 788, 0 ), /* 787 sys */ + S_ST( 't', 3, 789, 0 ), /* 788 syss */ + S_ST( 'a', 3, 790, 0 ), /* 789 sysst */ + S_ST( 't', 3, 415, 0 ), /* 790 syssta */ + S_ST( 't', 3, 817, 713 ), /* 791 */ + S_ST( 'i', 3, 803, 0 ), /* 792 t */ + S_ST( 'c', 3, 416, 0 ), /* 793 ti */ + S_ST( 'm', 3, 796, 793 ), /* 794 ti */ + S_ST( 'e', 3, 419, 0 ), /* 795 tim */ + S_ST( 'i', 3, 797, 795 ), /* 796 tim */ + S_ST( 'n', 3, 798, 0 ), /* 797 timi */ + S_ST( 'g', 3, 799, 0 ), /* 798 timin */ + S_ST( 's', 3, 800, 0 ), /* 799 timing */ + S_ST( 't', 3, 801, 0 ), /* 800 timings */ + S_ST( 'a', 3, 802, 0 ), /* 801 timingst */ + S_ST( 't', 3, 420, 0 ), /* 802 timingsta */ + S_ST( 'n', 3, 804, 794 ), /* 803 ti */ + S_ST( 'k', 3, 805, 0 ), /* 804 tin */ + S_ST( 'e', 3, 421, 0 ), /* 805 tink */ + S_ST( 'o', 3, 422, 792 ), /* 806 t */ + S_ST( 'r', 3, 809, 806 ), /* 807 t */ + S_ST( 'a', 3, 423, 0 ), /* 808 tr */ + S_ST( 'u', 3, 810, 808 ), /* 809 tr */ + S_ST( 's', 3, 811, 424 ), /* 810 tru */ + S_ST( 't', 3, 812, 0 ), /* 811 trus */ + S_ST( 'e', 3, 813, 0 ), /* 812 trust */ + S_ST( 'd', 3, 814, 0 ), /* 813 truste */ + S_ST( 'k', 3, 815, 0 ), /* 814 trusted */ + S_ST( 'e', 3, 425, 0 ), /* 815 trustedk */ + S_ST( 't', 3, 426, 807 ), /* 816 t */ + S_ST( 'y', 3, 818, 816 ), /* 817 t */ + S_ST( 'p', 3, 427, 0 ), /* 818 ty */ + S_ST( 'u', 3, 820, 791 ), /* 819 */ + S_ST( 'n', 3, 826, 0 ), /* 820 u */ + S_ST( 'c', 3, 822, 0 ), /* 821 un */ + S_ST( 'o', 3, 823, 0 ), /* 822 unc */ + S_ST( 'n', 3, 824, 0 ), /* 823 unco */ + S_ST( 'f', 3, 825, 0 ), /* 824 uncon */ + S_ST( 'i', 3, 429, 0 ), /* 825 unconf */ + S_ST( 'p', 3, 827, 821 ), /* 826 un */ + S_ST( 'e', 3, 828, 0 ), /* 827 unp */ + S_ST( 'e', 3, 430, 0 ), /* 828 unpe */ + S_ST( 'v', 3, 830, 819 ), /* 829 */ + S_ST( 'e', 3, 831, 0 ), /* 830 v */ + S_ST( 'r', 3, 832, 0 ), /* 831 ve */ + S_ST( 's', 3, 833, 0 ), /* 832 ver */ + S_ST( 'i', 3, 834, 0 ), /* 833 vers */ + S_ST( 'o', 3, 431, 0 ), /* 834 versi */ + S_ST( 'w', 3, 842, 829 ), /* 835 */ + S_ST( 'a', 3, 837, 0 ), /* 836 w */ + S_ST( 'n', 3, 838, 0 ), /* 837 wa */ + S_ST( 'd', 3, 839, 0 ), /* 838 wan */ + S_ST( 'e', 3, 445, 0 ), /* 839 wand */ + S_ST( 'e', 3, 841, 836 ), /* 840 w */ + S_ST( 'e', 3, 433, 0 ), /* 841 we */ + S_ST( 'i', 3, 843, 840 ), /* 842 w */ + S_ST( 'l', 3, 844, 0 ), /* 843 wi */ + S_ST( 'd', 3, 845, 0 ), /* 844 wil */ + S_ST( 'c', 3, 846, 0 ), /* 845 wild */ + S_ST( 'a', 3, 847, 0 ), /* 846 wildc */ + S_ST( 'r', 3, 434, 0 ), /* 847 wildca */ + S_ST( 'x', 3, 849, 835 ), /* 848 */ + S_ST( 'l', 3, 850, 0 ), /* 849 x */ + S_ST( 'e', 3, 851, 0 ), /* 850 xl */ + S_ST( 'a', 3, 852, 0 ), /* 851 xle */ + S_ST( 'v', 3, 435, 0 ), /* 852 xlea */ + S_ST( 'y', 3, 854, 848 ), /* 853 [initial state] */ + S_ST( 'e', 3, 855, 0 ), /* 854 y */ + S_ST( 'a', 3, 436, 0 ) /* 855 ye */ }; diff --git a/ntpd/ntp_leapsec.c b/ntpd/ntp_leapsec.c index eeef89f3c6481..7a652f5cf6b99 100644 --- a/ntpd/ntp_leapsec.c +++ b/ntpd/ntp_leapsec.c @@ -89,11 +89,13 @@ static char * get_line(leapsec_reader, void*, char*, size_t); static char * skipws(const char*); static int parsefail(const char * cp, const char * ep); static void reload_limits(leap_table_t*, const vint64*); +static void fetch_leap_era(leap_era_t*, const leap_table_t*, + const vint64*); static int betweenu32(uint32_t, uint32_t, uint32_t); static void reset_times(leap_table_t*); static int leapsec_add(leap_table_t*, const vint64*, int); static int leapsec_raw(leap_table_t*, const vint64 *, int, int); -static char * lstostr(const vint64 * ts); +static const char * lstostr(const vint64 * ts); /* ===================================================================== * Get & Set the current leap table @@ -107,8 +109,17 @@ leapsec_get_table( leap_table_t *p1, *p2; p1 = _lptr; - p1 = &_ltab[p1 == &_ltab[1]]; - p2 = &_ltab[p1 == &_ltab[0]]; + if (p1 == &_ltab[0]) { + p2 = &_ltab[1]; + } else if (p1 == &_ltab[1]) { + p2 = &_ltab[0]; + } else { + p1 = &_ltab[0]; + p2 = &_ltab[1]; + reset_times(p1); + reset_times(p2); + _lptr = p1; + } if (alternate) { memcpy(p2, p1, sizeof(leap_table_t)); p1 = p2; @@ -178,10 +189,15 @@ leapsec_load( struct calendar build; leapsec_clear(pt); - if (use_build_limit && ntpcal_get_build_date(&build)) + if (use_build_limit && ntpcal_get_build_date(&build)) { + /* don't prune everything -- permit the last 10yrs + * before build. + */ + build.year -= 10; limit = ntpcal_date_to_ntp64(&build); - else + } else { memset(&limit, 0, sizeof(limit)); + } while (get_line(func, farg, linebuf, sizeof(linebuf))) { cp = linebuf; @@ -198,7 +214,7 @@ leapsec_load( pt->head.update = strtouv64(cp, &ep, 10); if (parsefail(cp, ep)) goto fail_read; - } + } } else if (isdigit((u_char)*cp)) { ttime = strtouv64(cp, &ep, 10); if (parsefail(cp, ep)) @@ -288,7 +304,7 @@ leapsec_query( * leap era frame. */ reload_limits(pt, &ts64); - } else if (ucmpv64(&ts64, &pt->head.dtime) >= 0) { + } else if (ucmpv64(&ts64, &pt->head.dtime) >= 0) { /* Boundary crossed in forward direction. This might * indicate a leap transition, so we prepare for that * case. @@ -296,32 +312,47 @@ leapsec_query( * Some operations below are actually NOPs in electric * mode, but having only one code path that works for * both modes is easier to maintain. + * + * There's another quirk we must keep looking out for: + * If we just stepped the clock, the step might have + * crossed a leap boundary. As with backward steps, we + * do not want to raise the 'fired' event in that case. + * So we raise the 'fired' event only if we're close to + * the transition and just reload the limits otherwise. */ - last = pt->head.ttime; - qr->warped = (int16_t)(last.D_s.lo - - pt->head.dtime.D_s.lo); - next = addv64i32(&ts64, qr->warped); - reload_limits(pt, &next); - fired = ucmpv64(&pt->head.ebase, &last) == 0; - if (fired) { - ts64 = next; - ts32 = next.D_s.lo; + last = addv64i32(&pt->head.dtime, 3); /* get boundary */ + if (ucmpv64(&ts64, &last) >= 0) { + /* that was likely a query after a step */ + reload_limits(pt, &ts64); } else { - qr->warped = 0; + /* close enough for deeper examination */ + last = pt->head.ttime; + qr->warped = (int16_t)(last.D_s.lo - + pt->head.dtime.D_s.lo); + next = addv64i32(&ts64, qr->warped); + reload_limits(pt, &next); + fired = ucmpv64(&pt->head.ebase, &last) == 0; + if (fired) { + ts64 = next; + ts32 = next.D_s.lo; + } else { + qr->warped = 0; + } } } qr->tai_offs = pt->head.this_tai; + qr->ebase = pt->head.ebase; + qr->ttime = pt->head.ttime; /* If before the next scheduling alert, we're done. */ if (ucmpv64(&ts64, &pt->head.stime) < 0) return fired; - /* now start to collect the remaing data */ + /* now start to collect the remaining data */ due32 = pt->head.dtime.D_s.lo; qr->tai_diff = pt->head.next_tai - pt->head.this_tai; - qr->ttime = pt->head.ttime; qr->ddist = due32 - ts32; qr->dynamic = pt->head.dynls; qr->proximity = LSPROX_SCHEDULE; @@ -329,7 +360,7 @@ leapsec_query( /* if not in the last day before transition, we're done. */ if (!betweenu32(due32 - SECSPERDAY, ts32, due32)) return fired; - + qr->proximity = LSPROX_ANNOUNCE; if (!betweenu32(due32 - 10, ts32, due32)) return fired; @@ -341,6 +372,22 @@ leapsec_query( /* ------------------------------------------------------------------ */ int/*BOOL*/ +leapsec_query_era( + leap_era_t * qr , + uint32_t ntpts, + const time_t * pivot) +{ + const leap_table_t * pt; + vint64 ts64; + + pt = leapsec_get_table(FALSE); + ts64 = ntpcal_ntp_to_ntp(ntpts, pivot); + fetch_leap_era(qr, pt, &ts64); + return TRUE; +} + +/* ------------------------------------------------------------------ */ +int/*BOOL*/ leapsec_frame( leap_result_t *qr) { @@ -348,15 +395,14 @@ leapsec_frame( memset(qr, 0, sizeof(leap_result_t)); pt = leapsec_get_table(FALSE); - if (ucmpv64(&pt->head.ttime, &pt->head.stime) <= 0) - return FALSE; qr->tai_offs = pt->head.this_tai; qr->tai_diff = pt->head.next_tai - pt->head.this_tai; + qr->ebase = pt->head.ebase; qr->ttime = pt->head.ttime; qr->dynamic = pt->head.dynls; - return TRUE; + return ucmpv64(&pt->head.ttime, &pt->head.stime) >= 0; } /* ------------------------------------------------------------------ */ @@ -392,7 +438,7 @@ leapsec_load_stream( msyslog(LOG_NOTICE, "%s ('%s'): good hash signature", logPrefix, fname); break; - + case LSVALID_NOHASH: msyslog(LOG_ERR, "%s ('%s'): no hash signature", logPrefix, fname); @@ -442,7 +488,7 @@ leapsec_load_stream( "%s ('%s'): loaded, expire=%s ofs=%d (no entries after build date)", logPrefix, fname, lstostr(&pt->head.expire), pt->head.base_tai); - + return leapsec_set_table(pt); } @@ -461,7 +507,7 @@ leapsec_load_file( /* just do nothing if there is no leap file */ if ( !(fname && *fname) ) return FALSE; - + /* try to stat the leapfile */ if (0 != stat(fname, &sb_new)) { if (logall) @@ -551,6 +597,7 @@ leapsec_daystolive( } /* ------------------------------------------------------------------ */ +#if 0 /* currently unused -- possibly revived later */ int/*BOOL*/ leapsec_add_fix( int total, @@ -566,7 +613,7 @@ leapsec_add_fix( time(&tpiv); pivot = &tpiv; } - + et64 = ntpcal_ntp_to_ntp(etime, pivot); tt64 = ntpcal_ntp_to_ntp(ttime, pivot); pt = leapsec_get_table(TRUE); @@ -583,6 +630,7 @@ leapsec_add_fix( return leapsec_set_table(pt); } +#endif /* ------------------------------------------------------------------ */ int/*BOOL*/ @@ -600,6 +648,71 @@ leapsec_add_dyn( && leapsec_set_table(pt)); } +/* ------------------------------------------------------------------ */ +int/*BOOL*/ +leapsec_autokey_tai( + int tai_offset, + uint32_t ntpnow , + const time_t * pivot ) +{ + leap_table_t * pt; + leap_era_t era; + vint64 now64; + int idx; + + (void)tai_offset; + pt = leapsec_get_table(FALSE); + + /* Bail out if the basic offset is not zero and the putative + * offset is bigger than 10s. That was in 1972 -- we don't want + * to go back that far! + */ + if (pt->head.base_tai != 0 || tai_offset < 10) + return FALSE; + + /* If there's already data in the table, check if an update is + * possible. Update is impossible if there are static entries + * (since this indicates a valid leapsecond file) or if we're + * too close to a leapsecond transition: We do not know on what + * side the transition the sender might have been, so we use a + * dead zone around the transition. + */ + + /* Check for static entries */ + for (idx = 0; idx != pt->head.size; idx++) + if ( ! pt->info[idx].dynls) + return FALSE; + + /* get the fulll time stamp and leap era for it */ + now64 = ntpcal_ntp_to_ntp(ntpnow, pivot); + fetch_leap_era(&era, pt, &now64); + + /* check the limits with 20s dead band */ + era.ebase = addv64i32(&era.ebase, 20); + if (ucmpv64(&now64, &era.ebase) < 0) + return FALSE; + + era.ttime = addv64i32(&era.ttime, -20); + if (ucmpv64(&now64, &era.ttime) > 0) + return FALSE; + + /* Here we can proceed. Calculate the delta update. */ + tai_offset -= era.taiof; + + /* Shift the header info offsets. */ + pt->head.base_tai += tai_offset; + pt->head.this_tai += tai_offset; + pt->head.next_tai += tai_offset; + + /* Shift table entry offsets (if any) */ + for (idx = 0; idx != pt->head.size; idx++) + pt->info[idx].taiof += tai_offset; + + /* claim success... */ + return TRUE; +} + + /* ===================================================================== * internal helpers */ @@ -630,15 +743,21 @@ add_range( const leap_info_t * pi) { /* If the table is full, make room by throwing out the oldest - * entry. But remember the accumulated leap seconds! + * entry. But remember the accumulated leap seconds! Likewise, + * assume a positive leap insertion if this is the first entry + * in the table. This is not necessarily the best of all ideas, + * but it helps a great deal if a system does not have a leap + * table and gets updated from an upstream server. */ - if (pt->head.size >= MAX_HIST) { + if (pt->head.size == 0) { + pt->head.base_tai = pi->taiof - 1; + } else if (pt->head.size >= MAX_HIST) { pt->head.size = MAX_HIST - 1; pt->head.base_tai = pt->info[pt->head.size].taiof; } /* make room in lower end and insert item */ - memmove(pt->info+1, pt->info, pt->head.size*sizeof(*pt->info)); + memmove(pt->info+1, pt->info, pt->head.size*sizeof(*pt->info)); pt->info[0] = *pi; pt->head.size++; @@ -670,7 +789,7 @@ get_line( { int ch; char *ptr; - + /* if we cannot even store the delimiter, declare failure */ if (buff == NULL || size == 0) return NULL; @@ -698,7 +817,7 @@ skipws( return (char*)noconst(ptr); } -/* [internal] check if a strtoXYZ ended at EOL or whistespace and +/* [internal] check if a strtoXYZ ended at EOL or whitespace and * converted something at all. Return TRUE if something went wrong. */ static int/*BOOL*/ @@ -758,7 +877,7 @@ reload_limits( pt->head.dtime = addv64i32( &pt->head.ttime, pt->head.next_tai - pt->head.this_tai); - + pt->head.stime = subv64u32( &pt->head.ttime, pt->info[idx].stime); @@ -771,6 +890,37 @@ reload_limits( } } +/* [internal] fetch the leap era for a given time stamp. + * This is a cut-down version the algorithm used to reload the table + * limits, but it does not update any global state and provides just the + * era information for a given time stamp. + */ +static void +fetch_leap_era( + leap_era_t * into, + const leap_table_t * pt , + const vint64 * ts ) +{ + int idx; + + /* Simple search loop, also works with empty table. */ + for (idx = 0; idx != pt->head.size; idx++) + if (ucmpv64(ts, &pt->info[idx].ttime) >= 0) + break; + /* fetch era data, keeping an eye on boundary conditions */ + if (idx >= pt->head.size) { + memset(&into->ebase, 0x00, sizeof(vint64)); + into->taiof = pt->head.base_tai; + } else { + into->ebase = pt->info[idx].ttime; + into->taiof = pt->info[idx].taiof; + } + if (--idx >= 0) + into->ttime = pt->info[idx].ttime; + else + memset(&into->ttime, 0xFF, sizeof(vint64)); +} + /* [internal] Take a time stamp and create a leap second frame for * it. This will schedule a leap second for the beginning of the next * month, midnight UTC. The 'insert' argument tells if a leap second is @@ -791,7 +941,7 @@ leapsec_add( struct calendar fts; leap_info_t li; - /* Check against the table expiration and the lates available + /* Check against the table expiration and the latest available * leap entry. Do not permit inserts, only appends, and only if * the extend the table beyond the expiration! */ @@ -843,10 +993,22 @@ leapsec_raw( struct calendar fts; leap_info_t li; - /* Check that we only extend the table. Paranoia rulez! */ - if (pt->head.size && ucmpv64(ttime, &pt->info[0].ttime) <= 0) { - errno = ERANGE; - return FALSE; + /* Check that we either extend the table or get a duplicate of + * the latest entry. The latter is a benevolent overwrite with + * identical data and could happen if we get an autokey message + * that extends the lifetime of the current leapsecond table. + * Otherwise paranoia rulez! + */ + if (pt->head.size) { + int cmp = ucmpv64(ttime, &pt->info[0].ttime); + if (cmp == 0) + cmp -= (taiof != pt->info[0].taiof); + if (cmp < 0) { + errno = ERANGE; + return FALSE; + } + if (cmp == 0) + return TRUE; } ntpcal_ntp64_to_date(&fts, ttime); @@ -856,7 +1018,7 @@ leapsec_raw( return FALSE; } fts.month--; /* was in range 1..12, no overflow here! */ - starttime = ntpcal_date_to_ntp64(&fts); + starttime = ntpcal_date_to_ntp64(&fts); li.ttime = *ttime; li.stime = ttime->D_s.lo - starttime.D_s.lo; li.taiof = (int16_t)taiof; @@ -947,7 +1109,7 @@ do_hash_data( isc_sha1_update( mdctx, text, sizeof(text)); } - + if (0 < tlen) isc_sha1_update(mdctx, text, tlen); } @@ -991,20 +1153,34 @@ leapsec_validate( /* * lstostr - prettyprint NTP seconds */ -static char * lstostr( +static const char * +lstostr( const vint64 * ts) { char * buf; struct calendar tm; LIB_GETBUF(buf); - ntpcal_ntp64_to_date(&tm, ts); - snprintf(buf, LIB_BUFLENGTH, "%04d-%02d-%02dT%02d:%02dZ", - tm.year, tm.month, tm.monthday, - tm.hour, tm.minute); + + if ( ! (ts->d_s.hi >= 0 && ntpcal_ntp64_to_date(&tm, ts) >= 0)) + snprintf(buf, LIB_BUFLENGTH, "%s", "9999-12-31T23:59:59Z"); + else + snprintf(buf, LIB_BUFLENGTH, "%04d-%02d-%02dT%02d:%02d:%02dZ", + tm.year, tm.month, tm.monthday, + tm.hour, tm.minute, tm.second); + return buf; } +/* reset the global state for unit tests */ +void +leapsec_ut_pristine(void) +{ + memset(_ltab, 0, sizeof(_ltab)); + _lptr = NULL; + _electric = 0; +} + /* -*- that's all folks! -*- */ diff --git a/ntpd/ntp_leapsec.h b/ntpd/ntp_leapsec.h index 75edcc4608f76..120b75fcbb3f1 100644 --- a/ntpd/ntp_leapsec.h +++ b/ntpd/ntp_leapsec.h @@ -61,16 +61,27 @@ extern int leapsec_validate(leapsec_reader, void*); */ extern int/*BOOL*/ leapsec_electric(int/*BOOL*/ on); +/* Query result for a leap era. This is the minimal stateless + * information available for a time stamp in UTC. + */ +struct leap_era { + vint64 ebase; /* era base (UTC of start) */ + vint64 ttime; /* era end (UTC of next leap second) */ + int16_t taiof; /* offset to TAI in this era */ +}; +typedef struct leap_era leap_era_t; /* Query result for a leap second schedule - * 'ttime' is the transition point in full time scale, but only if - * 'tai_diff' is not zero. Nominal UTC time when the next leap - * era starts. + * 'ebase' is the nominal UTC time when the current leap era + * started. (Era base time) + * 'ttime' is the next transition point in full time scale. (Nominal UTC + * time when the next leap era starts.) * 'ddist' is the distance to the transition, in clock seconds. * This is the distance to the due time, which is different * from the transition time if the mode is non-electric. * Only valid if 'tai_diff' is not zero. - * 'tai_offs' is the CURRENT distance from clock (UTC) to TAI. Always valid. + * 'tai_offs' is the CURRENT distance from clock (UTC) to TAI. Always + * valid. * 'tai_diff' is the change in TAI offset after the next leap * transition. Zero if nothing is pending or too far ahead. * 'warped' is set only once, when the the leap second occurred between @@ -79,8 +90,9 @@ extern int/*BOOL*/ leapsec_electric(int/*BOOL*/ on); * 'proximity' is a proximity warning. See definitions below. This is * more useful than an absolute difference to the leap second. * 'dynamic' != 0 if entry was requested by clock/peer - */ + */ struct leap_result { + vint64 ebase; vint64 ttime; uint32_t ddist; int16_t tai_offs; @@ -91,6 +103,15 @@ struct leap_result { }; typedef struct leap_result leap_result_t; +/* The leap signature is used in two distinct circumstances, and it has + * slightly different content in these cases: + * - it is used to indictae the time range covered by the leap second + * table, and then it contains the last transition, TAI offset after + * the final transition, and the expiration time. + * - it is used to query data for AUTOKEY updates, and then it contains + * the *current* TAI offset, the *next* transition time and the + * expiration time of the table. + */ struct leap_signature { uint32_t etime; /* expiration time */ uint32_t ttime; /* transition time */ @@ -99,6 +120,24 @@ struct leap_signature { typedef struct leap_signature leap_signature_t; +#ifdef LEAP_SMEAR + +struct leap_smear_info { + int enabled; /* not 0 if smearing is generally enabled */ + int in_progress; /* not 0 if smearing is in progress, i.e. the offset has been computed */ + int leap_occurred; /* not 0 if the leap second has already occurred, i.e., during the leap second */ + double doffset; /* the current smear offset as double */ + l_fp offset; /* the current smear offset */ + uint32_t t_offset; /* the current time for which a smear offset has been computed */ + long interval; /* smear interval, in [s], should be at least some hours */ + double intv_start; /* start time of the smear interval */ + double intv_end; /* end time of the smear interval */ +}; +typedef struct leap_smear_info leap_smear_info_t; + +#endif /* LEAP_SMEAR */ + + #define LSPROX_NOWARN 0 /* clear radar screen */ #define LSPROX_SCHEDULE 1 /* less than 1 month to target*/ #define LSPROX_ANNOUNCE 2 /* less than 1 day to target */ @@ -170,6 +209,7 @@ extern int32_t leapsec_daystolive(uint32_t when, const time_t * pivot); */ extern void leapsec_reset_frame(void); +#if 0 /* currently unused -- possibly revived later */ /* Given a transition time, the TAI offset valid after that and an * expiration time, try to establish a system leap transition. Only * works if the existing table is extended. On success, updates the @@ -177,6 +217,7 @@ extern void leapsec_reset_frame(void); */ extern int/*BOOL*/ leapsec_add_fix(int offset, uint32_t ttime, uint32_t etime, const time_t * pivot); +#endif /* Take a time stamp and create a leap second frame for it. This will * schedule a leap second for the beginning of the next month, midnight @@ -200,9 +241,15 @@ extern int/*BOOL*/ leapsec_add_dyn(int/*BOOL*/ insert, uint32_t ntp_now, * last and the current query. In that case, qr->warped contains the * required clock stepping, which is always zero in electric mode. */ -extern int/*BOOL*/ leapsec_query(leap_result_t *qr, uint32_t ntpts, +extern int/*BOOL*/ leapsec_query(leap_result_t * qr, uint32_t ntpts, const time_t * pivot); +/* For a given time stamp, fetch the data for the bracketing leap + * era. The time stamp is subject to NTP era unfolding. + */ +extern int/*BOOL*/ leapsec_query_era(leap_era_t * qr, uint32_t ntpts, + const time_t * pivot); + /* Get the current leap frame info. Returns TRUE if the result contains * useable data, FALSE if there is currently no leap second frame. * This merely replicates some results from a previous query, but since @@ -215,4 +262,15 @@ extern int/*BOOL*/ leapsec_query(leap_result_t *qr, uint32_t ntpts, */ extern int/*BOOL*/ leapsec_frame(leap_result_t *qr); + +/* Process a AUTOKEY TAI offset information. This *might* augment the + * current leap data table with the given TAI offset. + * Returns TRUE if action was taken, FALSE otherwise. + */ +extern int/*BOOL*/ leapsec_autokey_tai(int tai_offset, uint32_t ntpnow, + const time_t * pivot); + +/* reset global state for unit tests */ +extern void leapsec_ut_pristine(void); + #endif /* !defined(NTP_LEAPSEC_H) */ diff --git a/ntpd/ntp_loopfilter.c b/ntpd/ntp_loopfilter.c index e47f83b976a2e..cb183b934fc88 100644 --- a/ntpd/ntp_loopfilter.c +++ b/ntpd/ntp_loopfilter.c @@ -246,6 +246,8 @@ ntp_adjtime_error_handler( int line /* line number of ntp_adjtime call */ ) { + char des[1024] = ""; /* Decoded Error Status */ + switch (ret) { case -1: switch (saved_errno) { @@ -317,14 +319,88 @@ ntp_adjtime_error_handler( # warning TIME_WAIT is not defined #endif #ifdef TIME_ERROR +#if 0 + +from the reference implementation of ntp_gettime(): + + // Hardware or software error + if ((time_status & (STA_UNSYNC | STA_CLOCKERR)) + + /* + * PPS signal lost when either time or frequency synchronization + * requested + */ + || (time_status & (STA_PPSFREQ | STA_PPSTIME) + && !(time_status & STA_PPSSIGNAL)) + + /* + * PPS jitter exceeded when time synchronization requested + */ + || (time_status & STA_PPSTIME && + time_status & STA_PPSJITTER) + + /* + * PPS wander exceeded or calibration error when frequency + * synchronization requested + */ + || (time_status & STA_PPSFREQ && + time_status & (STA_PPSWANDER | STA_PPSERROR))) + return (TIME_ERROR); + +or, from ntp_adjtime(): + + if ( (time_status & (STA_UNSYNC | STA_CLOCKERR)) + || (time_status & (STA_PPSFREQ | STA_PPSTIME) + && !(time_status & STA_PPSSIGNAL)) + || (time_status & STA_PPSTIME + && time_status & STA_PPSJITTER) + || (time_status & STA_PPSFREQ + && time_status & (STA_PPSWANDER | STA_PPSERROR)) + ) + return (TIME_ERROR); +#endif + case TIME_ERROR: /* 5: unsynchronized, or loss of synchronization */ /* error (see status word) */ + + if (ptimex->status & STA_UNSYNC) + snprintf(des, sizeof(des), "%s%sClock Unsynchronized", + des, (*des) ? "; " : ""); + + if (ptimex->status & STA_CLOCKERR) + snprintf(des, sizeof(des), "%s%sClock Error", + des, (*des) ? "; " : ""); + + if (!(ptimex->status & STA_PPSSIGNAL) + && ptimex->status & STA_PPSFREQ) + snprintf(des, sizeof(des), "%s%sPPS Frequency Sync wanted but no PPS", + des, (*des) ? "; " : ""); + + if (!(ptimex->status & STA_PPSSIGNAL) + && ptimex->status & STA_PPSTIME) + snprintf(des, sizeof(des), "%s%sPPS Time Sync wanted but no PPS signal", + des, (*des) ? "; " : ""); + + if ( ptimex->status & STA_PPSTIME + && ptimex->status & STA_PPSJITTER) + snprintf(des, sizeof(des), "%s%sPPS Time Sync wanted but PPS Jitter exceeded", + des, (*des) ? "; " : ""); + + if ( ptimex->status & STA_PPSFREQ + && ptimex->status & STA_PPSWANDER) + snprintf(des, sizeof(des), "%s%sPPS Frequency Sync wanted but PPS Wander exceeded", + des, (*des) ? "; " : ""); + + if ( ptimex->status & STA_PPSFREQ + && ptimex->status & STA_PPSERROR) + snprintf(des, sizeof(des), "%s%sPPS Frequency Sync wanted but Calibration error detected", + des, (*des) ? "; " : ""); + if (pps_call && !(ptimex->status & STA_PPSSIGNAL)) report_event(EVNT_KERN, NULL, - "PPS no signal"); - errno = saved_errno; - DPRINTF(1, ("kernel loop status (%s) %d %m\n", - k_st_flags(ptimex->status), errno)); + "no PPS signal"); + DPRINTF(1, ("kernel loop status %#x (%s)\n", + ptimex->status, des)); /* * This code may be returned when ntp_adjtime() has just * been called for the first time, quite a while after @@ -339,15 +415,14 @@ ntp_adjtime_error_handler( * or ??? * msyslog(LOG_INFO, "kernel reports time synchronization lost"); */ - errno = saved_errno; /* may not be needed */ - msyslog(LOG_INFO, "kernel reports TIME_ERROR: %#x: %s %m", - ptimex->status, k_st_flags(ptimex->status)); + msyslog(LOG_INFO, "kernel reports TIME_ERROR: %#x: %s", + ptimex->status, des); break; #else # warning TIME_ERROR is not defined #endif default: - msyslog(LOG_NOTICE, "%s: %s line %d: unhandled return value %d from ntp_adjtime in %s at line %d", + msyslog(LOG_NOTICE, "%s: %s line %d: unhandled return value %d from ntp_adjtime() in %s at line %d", caller, file_name(), line, ret, __func__, __LINE__ diff --git a/ntpd/ntp_monitor.c b/ntpd/ntp_monitor.c index 1214e1d661c28..02fd757307dae 100644 --- a/ntpd/ntp_monitor.c +++ b/ntpd/ntp_monitor.c @@ -183,7 +183,7 @@ mon_getmoremem(void) : mru_incalloc; if (entries) { - chunk = emalloc(entries * sizeof(*chunk)); + chunk = eallocarray(entries, sizeof(*chunk)); mru_alloc += entries; for (chunk += entries; entries; entries--) mon_free_entry(--chunk); diff --git a/ntpd/ntp_parser.c b/ntpd/ntp_parser.c index 0cf55197ac6cd..d76ac33743861 100644 --- a/ntpd/ntp_parser.c +++ b/ntpd/ntp_parser.c @@ -1,19 +1,19 @@ -/* A Bison parser, made by GNU Bison 3.0.2. */ +/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. - + + Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -26,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.2" +#define YYBISON_VERSION "2.7.12-4996" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -62,7 +62,8 @@ /* Copy the first part of user declarations. */ -#line 14 "ntp_parser.y" /* yacc.c:339 */ +/* Line 371 of yacc.c */ +#line 11 "../../ntpd/ntp_parser.y" #ifdef HAVE_CONFIG_H # include <config.h> @@ -88,7 +89,7 @@ #define YYFREE free #define YYERROR_VERBOSE #define YYMAXDEPTH 1000 /* stop the madness sooner */ - void yyerror(struct FILE_INFO *ip_file, const char *msg); + void yyerror(const char *msg); #ifdef SIM # define ONLY_SIM(a) (a) @@ -96,13 +97,14 @@ # define ONLY_SIM(a) NULL #endif -#line 100 "ntp_parser.c" /* yacc.c:339 */ +/* Line 371 of yacc.c */ +#line 102 "ntp_parser.c" -# ifndef YY_NULLPTR +# ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# define YY_NULL nullptr # else -# define YY_NULLPTR 0 +# define YY_NULL 0 # endif # endif @@ -116,9 +118,9 @@ /* In a future release of Bison, this section will be replaced by #include "y.tab.h". */ -#ifndef YY_YY_Y_TAB_H_INCLUDED -# define YY_YY_Y_TAB_H_INCLUDED -/* Debug traces. */ +#ifndef YY_YY_NTP_PARSER_H_INCLUDED +# define YY_YY_NTP_PARSER_H_INCLUDED +/* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 #endif @@ -126,201 +128,204 @@ extern int yydebug; #endif -/* Token type. */ +/* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - enum yytokentype - { - T_Abbrev = 258, - T_Age = 259, - T_All = 260, - T_Allan = 261, - T_Allpeers = 262, - T_Auth = 263, - T_Autokey = 264, - T_Automax = 265, - T_Average = 266, - T_Bclient = 267, - T_Beacon = 268, - T_Broadcast = 269, - T_Broadcastclient = 270, - T_Broadcastdelay = 271, - T_Burst = 272, - T_Calibrate = 273, - T_Ceiling = 274, - T_Clockstats = 275, - T_Cohort = 276, - T_ControlKey = 277, - T_Crypto = 278, - T_Cryptostats = 279, - T_Ctl = 280, - T_Day = 281, - T_Default = 282, - T_Digest = 283, - T_Disable = 284, - T_Discard = 285, - T_Dispersion = 286, - T_Double = 287, - T_Driftfile = 288, - T_Drop = 289, - T_Ellipsis = 290, - T_Enable = 291, - T_End = 292, - T_False = 293, - T_File = 294, - T_Filegen = 295, - T_Filenum = 296, - T_Flag1 = 297, - T_Flag2 = 298, - T_Flag3 = 299, - T_Flag4 = 300, - T_Flake = 301, - T_Floor = 302, - T_Freq = 303, - T_Fudge = 304, - T_Host = 305, - T_Huffpuff = 306, - T_Iburst = 307, - T_Ident = 308, - T_Ignore = 309, - T_Incalloc = 310, - T_Incmem = 311, - T_Initalloc = 312, - T_Initmem = 313, - T_Includefile = 314, - T_Integer = 315, - T_Interface = 316, - T_Intrange = 317, - T_Io = 318, - T_Ipv4 = 319, - T_Ipv4_flag = 320, - T_Ipv6 = 321, - T_Ipv6_flag = 322, - T_Kernel = 323, - T_Key = 324, - T_Keys = 325, - T_Keysdir = 326, - T_Kod = 327, - T_Mssntp = 328, - T_Leapfile = 329, - T_Limited = 330, - T_Link = 331, - T_Listen = 332, - T_Logconfig = 333, - T_Logfile = 334, - T_Loopstats = 335, - T_Lowpriotrap = 336, - T_Manycastclient = 337, - T_Manycastserver = 338, - T_Mask = 339, - T_Maxage = 340, - T_Maxclock = 341, - T_Maxdepth = 342, - T_Maxdist = 343, - T_Maxmem = 344, - T_Maxpoll = 345, - T_Mdnstries = 346, - T_Mem = 347, - T_Memlock = 348, - T_Minclock = 349, - T_Mindepth = 350, - T_Mindist = 351, - T_Minimum = 352, - T_Minpoll = 353, - T_Minsane = 354, - T_Mode = 355, - T_Mode7 = 356, - T_Monitor = 357, - T_Month = 358, - T_Mru = 359, - T_Multicastclient = 360, - T_Nic = 361, - T_Nolink = 362, - T_Nomodify = 363, - T_Nomrulist = 364, - T_None = 365, - T_Nonvolatile = 366, - T_Nopeer = 367, - T_Noquery = 368, - T_Noselect = 369, - T_Noserve = 370, - T_Notrap = 371, - T_Notrust = 372, - T_Ntp = 373, - T_Ntpport = 374, - T_NtpSignDsocket = 375, - T_Orphan = 376, - T_Orphanwait = 377, - T_Panic = 378, - T_Peer = 379, - T_Peerstats = 380, - T_Phone = 381, - T_Pid = 382, - T_Pidfile = 383, - T_Pool = 384, - T_Port = 385, - T_Preempt = 386, - T_Prefer = 387, - T_Protostats = 388, - T_Pw = 389, - T_Randfile = 390, - T_Rawstats = 391, - T_Refid = 392, - T_Requestkey = 393, - T_Reset = 394, - T_Restrict = 395, - T_Revoke = 396, - T_Rlimit = 397, - T_Saveconfigdir = 398, - T_Server = 399, - T_Setvar = 400, - T_Source = 401, - T_Stacksize = 402, - T_Statistics = 403, - T_Stats = 404, - T_Statsdir = 405, - T_Step = 406, - T_Stepback = 407, - T_Stepfwd = 408, - T_Stepout = 409, - T_Stratum = 410, - T_String = 411, - T_Sys = 412, - T_Sysstats = 413, - T_Tick = 414, - T_Time1 = 415, - T_Time2 = 416, - T_Timer = 417, - T_Timingstats = 418, - T_Tinker = 419, - T_Tos = 420, - T_Trap = 421, - T_True = 422, - T_Trustedkey = 423, - T_Ttl = 424, - T_Type = 425, - T_U_int = 426, - T_Unconfig = 427, - T_Unpeer = 428, - T_Version = 429, - T_WanderThreshold = 430, - T_Week = 431, - T_Wildcard = 432, - T_Xleave = 433, - T_Year = 434, - T_Flag = 435, - T_EOC = 436, - T_Simulate = 437, - T_Beep_Delay = 438, - T_Sim_Duration = 439, - T_Server_Offset = 440, - T_Duration = 441, - T_Freq_Offset = 442, - T_Wander = 443, - T_Jitter = 444, - T_Prop_Delay = 445, - T_Proc_Delay = 446 - }; + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_Abbrev = 258, + T_Age = 259, + T_All = 260, + T_Allan = 261, + T_Allpeers = 262, + T_Auth = 263, + T_Autokey = 264, + T_Automax = 265, + T_Average = 266, + T_Bclient = 267, + T_Beacon = 268, + T_Broadcast = 269, + T_Broadcastclient = 270, + T_Broadcastdelay = 271, + T_Burst = 272, + T_Calibrate = 273, + T_Ceiling = 274, + T_Clockstats = 275, + T_Cohort = 276, + T_ControlKey = 277, + T_Crypto = 278, + T_Cryptostats = 279, + T_Ctl = 280, + T_Day = 281, + T_Default = 282, + T_Digest = 283, + T_Disable = 284, + T_Discard = 285, + T_Dispersion = 286, + T_Double = 287, + T_Driftfile = 288, + T_Drop = 289, + T_Dscp = 290, + T_Ellipsis = 291, + T_Enable = 292, + T_End = 293, + T_False = 294, + T_File = 295, + T_Filegen = 296, + T_Filenum = 297, + T_Flag1 = 298, + T_Flag2 = 299, + T_Flag3 = 300, + T_Flag4 = 301, + T_Flake = 302, + T_Floor = 303, + T_Freq = 304, + T_Fudge = 305, + T_Host = 306, + T_Huffpuff = 307, + T_Iburst = 308, + T_Ident = 309, + T_Ignore = 310, + T_Incalloc = 311, + T_Incmem = 312, + T_Initalloc = 313, + T_Initmem = 314, + T_Includefile = 315, + T_Integer = 316, + T_Interface = 317, + T_Intrange = 318, + T_Io = 319, + T_Ipv4 = 320, + T_Ipv4_flag = 321, + T_Ipv6 = 322, + T_Ipv6_flag = 323, + T_Kernel = 324, + T_Key = 325, + T_Keys = 326, + T_Keysdir = 327, + T_Kod = 328, + T_Mssntp = 329, + T_Leapfile = 330, + T_Leapsmearinterval = 331, + T_Limited = 332, + T_Link = 333, + T_Listen = 334, + T_Logconfig = 335, + T_Logfile = 336, + T_Loopstats = 337, + T_Lowpriotrap = 338, + T_Manycastclient = 339, + T_Manycastserver = 340, + T_Mask = 341, + T_Maxage = 342, + T_Maxclock = 343, + T_Maxdepth = 344, + T_Maxdist = 345, + T_Maxmem = 346, + T_Maxpoll = 347, + T_Mdnstries = 348, + T_Mem = 349, + T_Memlock = 350, + T_Minclock = 351, + T_Mindepth = 352, + T_Mindist = 353, + T_Minimum = 354, + T_Minpoll = 355, + T_Minsane = 356, + T_Mode = 357, + T_Mode7 = 358, + T_Monitor = 359, + T_Month = 360, + T_Mru = 361, + T_Multicastclient = 362, + T_Nic = 363, + T_Nolink = 364, + T_Nomodify = 365, + T_Nomrulist = 366, + T_None = 367, + T_Nonvolatile = 368, + T_Nopeer = 369, + T_Noquery = 370, + T_Noselect = 371, + T_Noserve = 372, + T_Notrap = 373, + T_Notrust = 374, + T_Ntp = 375, + T_Ntpport = 376, + T_NtpSignDsocket = 377, + T_Orphan = 378, + T_Orphanwait = 379, + T_Panic = 380, + T_Peer = 381, + T_Peerstats = 382, + T_Phone = 383, + T_Pid = 384, + T_Pidfile = 385, + T_Pool = 386, + T_Port = 387, + T_Preempt = 388, + T_Prefer = 389, + T_Protostats = 390, + T_Pw = 391, + T_Randfile = 392, + T_Rawstats = 393, + T_Refid = 394, + T_Requestkey = 395, + T_Reset = 396, + T_Restrict = 397, + T_Revoke = 398, + T_Rlimit = 399, + T_Saveconfigdir = 400, + T_Server = 401, + T_Setvar = 402, + T_Source = 403, + T_Stacksize = 404, + T_Statistics = 405, + T_Stats = 406, + T_Statsdir = 407, + T_Step = 408, + T_Stepback = 409, + T_Stepfwd = 410, + T_Stepout = 411, + T_Stratum = 412, + T_String = 413, + T_Sys = 414, + T_Sysstats = 415, + T_Tick = 416, + T_Time1 = 417, + T_Time2 = 418, + T_Timer = 419, + T_Timingstats = 420, + T_Tinker = 421, + T_Tos = 422, + T_Trap = 423, + T_True = 424, + T_Trustedkey = 425, + T_Ttl = 426, + T_Type = 427, + T_U_int = 428, + T_Unconfig = 429, + T_Unpeer = 430, + T_Version = 431, + T_WanderThreshold = 432, + T_Week = 433, + T_Wildcard = 434, + T_Xleave = 435, + T_Year = 436, + T_Flag = 437, + T_EOC = 438, + T_Simulate = 439, + T_Beep_Delay = 440, + T_Sim_Duration = 441, + T_Server_Offset = 442, + T_Duration = 443, + T_Freq_Offset = 444, + T_Wander = 445, + T_Jitter = 446, + T_Prop_Delay = 447, + T_Proc_Delay = 448 + }; #endif /* Tokens. */ #define T_Abbrev 258 @@ -355,170 +360,173 @@ extern int yydebug; #define T_Double 287 #define T_Driftfile 288 #define T_Drop 289 -#define T_Ellipsis 290 -#define T_Enable 291 -#define T_End 292 -#define T_False 293 -#define T_File 294 -#define T_Filegen 295 -#define T_Filenum 296 -#define T_Flag1 297 -#define T_Flag2 298 -#define T_Flag3 299 -#define T_Flag4 300 -#define T_Flake 301 -#define T_Floor 302 -#define T_Freq 303 -#define T_Fudge 304 -#define T_Host 305 -#define T_Huffpuff 306 -#define T_Iburst 307 -#define T_Ident 308 -#define T_Ignore 309 -#define T_Incalloc 310 -#define T_Incmem 311 -#define T_Initalloc 312 -#define T_Initmem 313 -#define T_Includefile 314 -#define T_Integer 315 -#define T_Interface 316 -#define T_Intrange 317 -#define T_Io 318 -#define T_Ipv4 319 -#define T_Ipv4_flag 320 -#define T_Ipv6 321 -#define T_Ipv6_flag 322 -#define T_Kernel 323 -#define T_Key 324 -#define T_Keys 325 -#define T_Keysdir 326 -#define T_Kod 327 -#define T_Mssntp 328 -#define T_Leapfile 329 -#define T_Limited 330 -#define T_Link 331 -#define T_Listen 332 -#define T_Logconfig 333 -#define T_Logfile 334 -#define T_Loopstats 335 -#define T_Lowpriotrap 336 -#define T_Manycastclient 337 -#define T_Manycastserver 338 -#define T_Mask 339 -#define T_Maxage 340 -#define T_Maxclock 341 -#define T_Maxdepth 342 -#define T_Maxdist 343 -#define T_Maxmem 344 -#define T_Maxpoll 345 -#define T_Mdnstries 346 -#define T_Mem 347 -#define T_Memlock 348 -#define T_Minclock 349 -#define T_Mindepth 350 -#define T_Mindist 351 -#define T_Minimum 352 -#define T_Minpoll 353 -#define T_Minsane 354 -#define T_Mode 355 -#define T_Mode7 356 -#define T_Monitor 357 -#define T_Month 358 -#define T_Mru 359 -#define T_Multicastclient 360 -#define T_Nic 361 -#define T_Nolink 362 -#define T_Nomodify 363 -#define T_Nomrulist 364 -#define T_None 365 -#define T_Nonvolatile 366 -#define T_Nopeer 367 -#define T_Noquery 368 -#define T_Noselect 369 -#define T_Noserve 370 -#define T_Notrap 371 -#define T_Notrust 372 -#define T_Ntp 373 -#define T_Ntpport 374 -#define T_NtpSignDsocket 375 -#define T_Orphan 376 -#define T_Orphanwait 377 -#define T_Panic 378 -#define T_Peer 379 -#define T_Peerstats 380 -#define T_Phone 381 -#define T_Pid 382 -#define T_Pidfile 383 -#define T_Pool 384 -#define T_Port 385 -#define T_Preempt 386 -#define T_Prefer 387 -#define T_Protostats 388 -#define T_Pw 389 -#define T_Randfile 390 -#define T_Rawstats 391 -#define T_Refid 392 -#define T_Requestkey 393 -#define T_Reset 394 -#define T_Restrict 395 -#define T_Revoke 396 -#define T_Rlimit 397 -#define T_Saveconfigdir 398 -#define T_Server 399 -#define T_Setvar 400 -#define T_Source 401 -#define T_Stacksize 402 -#define T_Statistics 403 -#define T_Stats 404 -#define T_Statsdir 405 -#define T_Step 406 -#define T_Stepback 407 -#define T_Stepfwd 408 -#define T_Stepout 409 -#define T_Stratum 410 -#define T_String 411 -#define T_Sys 412 -#define T_Sysstats 413 -#define T_Tick 414 -#define T_Time1 415 -#define T_Time2 416 -#define T_Timer 417 -#define T_Timingstats 418 -#define T_Tinker 419 -#define T_Tos 420 -#define T_Trap 421 -#define T_True 422 -#define T_Trustedkey 423 -#define T_Ttl 424 -#define T_Type 425 -#define T_U_int 426 -#define T_Unconfig 427 -#define T_Unpeer 428 -#define T_Version 429 -#define T_WanderThreshold 430 -#define T_Week 431 -#define T_Wildcard 432 -#define T_Xleave 433 -#define T_Year 434 -#define T_Flag 435 -#define T_EOC 436 -#define T_Simulate 437 -#define T_Beep_Delay 438 -#define T_Sim_Duration 439 -#define T_Server_Offset 440 -#define T_Duration 441 -#define T_Freq_Offset 442 -#define T_Wander 443 -#define T_Jitter 444 -#define T_Prop_Delay 445 -#define T_Proc_Delay 446 - -/* Value type. */ +#define T_Dscp 290 +#define T_Ellipsis 291 +#define T_Enable 292 +#define T_End 293 +#define T_False 294 +#define T_File 295 +#define T_Filegen 296 +#define T_Filenum 297 +#define T_Flag1 298 +#define T_Flag2 299 +#define T_Flag3 300 +#define T_Flag4 301 +#define T_Flake 302 +#define T_Floor 303 +#define T_Freq 304 +#define T_Fudge 305 +#define T_Host 306 +#define T_Huffpuff 307 +#define T_Iburst 308 +#define T_Ident 309 +#define T_Ignore 310 +#define T_Incalloc 311 +#define T_Incmem 312 +#define T_Initalloc 313 +#define T_Initmem 314 +#define T_Includefile 315 +#define T_Integer 316 +#define T_Interface 317 +#define T_Intrange 318 +#define T_Io 319 +#define T_Ipv4 320 +#define T_Ipv4_flag 321 +#define T_Ipv6 322 +#define T_Ipv6_flag 323 +#define T_Kernel 324 +#define T_Key 325 +#define T_Keys 326 +#define T_Keysdir 327 +#define T_Kod 328 +#define T_Mssntp 329 +#define T_Leapfile 330 +#define T_Leapsmearinterval 331 +#define T_Limited 332 +#define T_Link 333 +#define T_Listen 334 +#define T_Logconfig 335 +#define T_Logfile 336 +#define T_Loopstats 337 +#define T_Lowpriotrap 338 +#define T_Manycastclient 339 +#define T_Manycastserver 340 +#define T_Mask 341 +#define T_Maxage 342 +#define T_Maxclock 343 +#define T_Maxdepth 344 +#define T_Maxdist 345 +#define T_Maxmem 346 +#define T_Maxpoll 347 +#define T_Mdnstries 348 +#define T_Mem 349 +#define T_Memlock 350 +#define T_Minclock 351 +#define T_Mindepth 352 +#define T_Mindist 353 +#define T_Minimum 354 +#define T_Minpoll 355 +#define T_Minsane 356 +#define T_Mode 357 +#define T_Mode7 358 +#define T_Monitor 359 +#define T_Month 360 +#define T_Mru 361 +#define T_Multicastclient 362 +#define T_Nic 363 +#define T_Nolink 364 +#define T_Nomodify 365 +#define T_Nomrulist 366 +#define T_None 367 +#define T_Nonvolatile 368 +#define T_Nopeer 369 +#define T_Noquery 370 +#define T_Noselect 371 +#define T_Noserve 372 +#define T_Notrap 373 +#define T_Notrust 374 +#define T_Ntp 375 +#define T_Ntpport 376 +#define T_NtpSignDsocket 377 +#define T_Orphan 378 +#define T_Orphanwait 379 +#define T_Panic 380 +#define T_Peer 381 +#define T_Peerstats 382 +#define T_Phone 383 +#define T_Pid 384 +#define T_Pidfile 385 +#define T_Pool 386 +#define T_Port 387 +#define T_Preempt 388 +#define T_Prefer 389 +#define T_Protostats 390 +#define T_Pw 391 +#define T_Randfile 392 +#define T_Rawstats 393 +#define T_Refid 394 +#define T_Requestkey 395 +#define T_Reset 396 +#define T_Restrict 397 +#define T_Revoke 398 +#define T_Rlimit 399 +#define T_Saveconfigdir 400 +#define T_Server 401 +#define T_Setvar 402 +#define T_Source 403 +#define T_Stacksize 404 +#define T_Statistics 405 +#define T_Stats 406 +#define T_Statsdir 407 +#define T_Step 408 +#define T_Stepback 409 +#define T_Stepfwd 410 +#define T_Stepout 411 +#define T_Stratum 412 +#define T_String 413 +#define T_Sys 414 +#define T_Sysstats 415 +#define T_Tick 416 +#define T_Time1 417 +#define T_Time2 418 +#define T_Timer 419 +#define T_Timingstats 420 +#define T_Tinker 421 +#define T_Tos 422 +#define T_Trap 423 +#define T_True 424 +#define T_Trustedkey 425 +#define T_Ttl 426 +#define T_Type 427 +#define T_U_int 428 +#define T_Unconfig 429 +#define T_Unpeer 430 +#define T_Version 431 +#define T_WanderThreshold 432 +#define T_Week 433 +#define T_Wildcard 434 +#define T_Xleave 435 +#define T_Year 436 +#define T_Flag 437 +#define T_EOC 438 +#define T_Simulate 439 +#define T_Beep_Delay 440 +#define T_Sim_Duration 441 +#define T_Server_Offset 442 +#define T_Duration 443 +#define T_Freq_Offset 444 +#define T_Wander 445 +#define T_Jitter 446 +#define T_Prop_Delay 447 +#define T_Proc_Delay 448 + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE YYSTYPE; -union YYSTYPE +typedef union YYSTYPE { -#line 54 "ntp_parser.y" /* yacc.c:355 */ +/* Line 387 of yacc.c */ +#line 51 "../../ntpd/ntp_parser.y" char * String; double Double; @@ -537,22 +545,37 @@ union YYSTYPE script_info * Sim_script; script_info_fifo * Sim_script_fifo; -#line 541 "ntp_parser.c" /* yacc.c:355 */ -}; + +/* Line 387 of yacc.c */ +#line 551 "ntp_parser.c" +} YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif - extern YYSTYPE yylval; -int yyparse (struct FILE_INFO *ip_file); +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ -#endif /* !YY_YY_Y_TAB_H_INCLUDED */ +#endif /* !YY_YY_NTP_PARSER_H_INCLUDED */ /* Copy the second part of user declarations. */ -#line 556 "ntp_parser.c" /* yacc.c:358 */ +/* Line 390 of yacc.c */ +#line 579 "ntp_parser.c" #ifdef short # undef short @@ -566,8 +589,11 @@ typedef unsigned char yytype_uint8; #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; -#else +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; +#else +typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 @@ -587,7 +613,8 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -609,30 +636,11 @@ typedef short int yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif - -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - -#ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if (! defined __GNUC__ || __GNUC__ < 2 \ + || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) +# define __attribute__(Spec) /* empty */ # endif #endif @@ -643,26 +651,25 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(N) (N) #else -# define YY_INITIAL_VALUE(Value) Value -#endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; #endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ +{ + return yyi; +} #endif - #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -680,7 +687,8 @@ typedef short int yytype_int16; # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS @@ -692,8 +700,8 @@ typedef short int yytype_int16; # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's 'empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely @@ -709,7 +717,7 @@ typedef short int yytype_int16; # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) + && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -717,13 +725,15 @@ typedef short int yytype_int16; # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS +# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS +# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif @@ -733,7 +743,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -758,16 +768,16 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) #endif @@ -786,50 +796,48 @@ union yyalloc for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ - while (0) + while (YYID (0)) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 207 +#define YYFINAL 210 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 622 +#define YYLAST 647 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 197 +#define YYNTOKENS 199 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 104 +#define YYNNTS 105 /* YYNRULES -- Number of rules. */ -#define YYNRULES 310 -/* YYNSTATES -- Number of states. */ -#define YYNSTATES 415 +#define YYNRULES 313 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 419 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 446 +#define YYMAXUTOK 448 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) -/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 193, 194, 2, 2, 2, 2, 2, 2, 2, 2, + 195, 196, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 192, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 194, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 195, 2, 196, 2, 2, 2, 2, + 2, 2, 2, 197, 2, 198, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -861,45 +869,165 @@ static const yytype_uint8 yytranslate[] = 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, - 185, 186, 187, 188, 189, 190, 191 + 185, 186, 187, 188, 189, 190, 191, 192, 193 }; #if YYDEBUG - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 5, 9, 12, 15, 16, 18, 20, + 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 46, 48, 50, 52, 54, 56, 58, 61, 63, + 65, 67, 68, 71, 73, 75, 77, 79, 81, 83, + 85, 87, 89, 91, 93, 95, 98, 101, 103, 105, + 107, 109, 111, 113, 116, 118, 121, 123, 125, 127, + 130, 133, 136, 139, 142, 145, 148, 151, 154, 157, + 160, 163, 164, 167, 170, 173, 175, 177, 179, 181, + 183, 186, 189, 191, 194, 197, 200, 202, 204, 206, + 208, 210, 212, 214, 216, 218, 220, 223, 226, 230, + 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, + 252, 255, 258, 261, 263, 265, 267, 269, 271, 273, + 275, 277, 279, 281, 283, 285, 287, 290, 293, 297, + 303, 307, 312, 317, 321, 322, 325, 327, 329, 331, + 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, + 353, 355, 358, 360, 363, 365, 367, 369, 372, 374, + 377, 379, 381, 383, 385, 387, 389, 391, 393, 397, + 400, 402, 405, 408, 411, 414, 417, 419, 421, 423, + 425, 427, 429, 432, 435, 437, 440, 442, 444, 446, + 449, 452, 455, 457, 459, 461, 463, 465, 467, 469, + 471, 473, 475, 477, 480, 483, 485, 488, 490, 492, + 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, + 515, 518, 521, 524, 528, 530, 533, 536, 539, 542, + 546, 549, 551, 553, 555, 557, 559, 561, 563, 565, + 567, 569, 571, 574, 575, 580, 582, 583, 584, 587, + 590, 593, 596, 598, 600, 604, 608, 610, 612, 614, + 616, 618, 620, 622, 624, 626, 629, 632, 634, 636, + 638, 640, 642, 644, 646, 648, 651, 653, 656, 658, + 660, 662, 668, 671, 673, 676, 678, 680, 682, 684, + 686, 688, 694, 696, 700, 703, 707, 709, 711, 714, + 716, 722, 727, 731, 734, 736, 743, 747, 750, 754, + 756, 758, 760, 762 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int16 yyrhs[] = +{ + 200, 0, -1, 201, -1, 201, 202, 183, -1, 202, + 183, -1, 1, 183, -1, -1, 203, -1, 216, -1, + 218, -1, 219, -1, 228, -1, 236, -1, 223, -1, + 245, -1, 250, -1, 254, -1, 259, -1, 263, -1, + 290, -1, 204, 205, 208, -1, 146, -1, 131, -1, + 126, -1, 14, -1, 84, -1, 206, -1, 207, 158, + -1, 158, -1, 66, -1, 68, -1, -1, 208, 209, + -1, 210, -1, 212, -1, 214, -1, 211, -1, 9, + -1, 17, -1, 53, -1, 116, -1, 133, -1, 134, + -1, 169, -1, 180, -1, 213, 61, -1, 213, 173, + -1, 70, -1, 100, -1, 92, -1, 171, -1, 102, + -1, 176, -1, 215, 158, -1, 54, -1, 217, 205, + -1, 174, -1, 175, -1, 15, -1, 85, 287, -1, + 107, 287, -1, 93, 61, -1, 10, 61, -1, 22, + 61, -1, 23, 220, -1, 71, 158, -1, 72, 158, + -1, 140, 61, -1, 143, 61, -1, 170, 283, -1, + 122, 158, -1, -1, 220, 221, -1, 222, 158, -1, + 143, 61, -1, 51, -1, 54, -1, 136, -1, 137, + -1, 28, -1, 167, 224, -1, 224, 225, -1, 225, + -1, 226, 61, -1, 227, 289, -1, 21, 288, -1, + 19, -1, 48, -1, 123, -1, 124, -1, 101, -1, + 13, -1, 98, -1, 90, -1, 96, -1, 88, -1, + 150, 229, -1, 152, 158, -1, 41, 230, 231, -1, + 229, 230, -1, 230, -1, 20, -1, 24, -1, 82, + -1, 127, -1, 138, -1, 160, -1, 165, -1, 135, + -1, -1, 231, 232, -1, 40, 158, -1, 172, 235, + -1, 233, -1, 234, -1, 78, -1, 109, -1, 37, + -1, 29, -1, 112, -1, 129, -1, 26, -1, 178, + -1, 105, -1, 181, -1, 4, -1, 30, 239, -1, + 106, 242, -1, 142, 205, 237, -1, 142, 206, 86, + 206, 237, -1, 142, 27, 237, -1, 142, 66, 27, + 237, -1, 142, 68, 27, 237, -1, 142, 148, 237, + -1, -1, 237, 238, -1, 47, -1, 55, -1, 73, + -1, 74, -1, 77, -1, 83, -1, 110, -1, 111, + -1, 114, -1, 115, -1, 117, -1, 118, -1, 119, + -1, 121, -1, 176, -1, 239, 240, -1, 240, -1, + 241, 61, -1, 11, -1, 99, -1, 104, -1, 242, + 243, -1, 243, -1, 244, 61, -1, 56, -1, 57, + -1, 58, -1, 59, -1, 87, -1, 89, -1, 91, + -1, 97, -1, 50, 205, 246, -1, 246, 247, -1, + 247, -1, 248, 289, -1, 249, 288, -1, 157, 61, + -1, 3, 158, -1, 139, 158, -1, 162, -1, 163, + -1, 43, -1, 44, -1, 45, -1, 46, -1, 144, + 251, -1, 251, 252, -1, 252, -1, 253, 61, -1, + 95, -1, 149, -1, 42, -1, 37, 255, -1, 29, + 255, -1, 255, 256, -1, 256, -1, 257, -1, 258, + -1, 8, -1, 12, -1, 18, -1, 69, -1, 104, + -1, 120, -1, 103, -1, 151, -1, 166, 260, -1, + 260, 261, -1, 261, -1, 262, 289, -1, 6, -1, + 31, -1, 49, -1, 52, -1, 125, -1, 153, -1, + 154, -1, 155, -1, 156, -1, 161, -1, 275, -1, + 279, -1, 264, 289, -1, 265, 61, -1, 266, 158, + -1, 267, 158, -1, 60, 158, 202, -1, 38, -1, + 33, 268, -1, 80, 273, -1, 128, 286, -1, 147, + 269, -1, 168, 206, 271, -1, 171, 282, -1, 16, + -1, 113, -1, 161, -1, 35, -1, 76, -1, 54, + -1, 75, -1, 130, -1, 81, -1, 145, -1, 158, + -1, 158, 32, -1, -1, 158, 194, 158, 270, -1, + 27, -1, -1, -1, 271, 272, -1, 132, 61, -1, + 62, 206, -1, 273, 274, -1, 274, -1, 158, -1, + 276, 278, 277, -1, 276, 278, 158, -1, 62, -1, + 108, -1, 5, -1, 65, -1, 67, -1, 179, -1, + 79, -1, 55, -1, 34, -1, 141, 280, -1, 280, + 281, -1, 281, -1, 7, -1, 8, -1, 25, -1, + 64, -1, 94, -1, 159, -1, 164, -1, 282, 61, + -1, 61, -1, 283, 284, -1, 284, -1, 61, -1, + 285, -1, 195, 61, 36, 61, 196, -1, 286, 158, + -1, 158, -1, 287, 205, -1, 205, -1, 61, -1, + 169, -1, 39, -1, 61, -1, 32, -1, 291, 197, + 292, 295, 198, -1, 184, -1, 292, 293, 183, -1, + 293, 183, -1, 294, 194, 289, -1, 185, -1, 186, + -1, 295, 296, -1, 296, -1, 298, 197, 297, 299, + 198, -1, 187, 194, 289, 183, -1, 146, 194, 205, + -1, 299, 300, -1, 300, -1, 188, 194, 289, 197, + 301, 198, -1, 301, 302, 183, -1, 302, 183, -1, + 303, 194, 289, -1, 189, -1, 190, -1, 191, -1, + 192, -1, 193, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 366, 366, 370, 371, 372, 386, 387, 388, 389, - 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, - 407, 417, 418, 419, 420, 421, 425, 426, 431, 436, - 438, 444, 445, 453, 454, 455, 459, 464, 465, 466, - 467, 468, 469, 470, 471, 475, 477, 482, 483, 484, - 485, 486, 487, 491, 496, 505, 515, 516, 526, 528, - 530, 532, 543, 550, 552, 557, 559, 561, 563, 565, - 574, 580, 581, 589, 591, 603, 604, 605, 606, 607, - 616, 621, 626, 634, 636, 638, 643, 644, 645, 646, - 647, 648, 652, 653, 654, 655, 664, 666, 675, 685, - 690, 698, 699, 700, 701, 702, 703, 704, 705, 710, - 711, 719, 729, 738, 753, 758, 759, 763, 764, 768, - 769, 770, 771, 772, 773, 774, 783, 787, 791, 799, - 807, 815, 830, 845, 858, 859, 867, 868, 869, 870, - 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, - 881, 885, 890, 898, 903, 904, 905, 909, 914, 922, - 927, 928, 929, 930, 931, 932, 933, 934, 942, 952, - 957, 965, 967, 969, 971, 973, 978, 979, 983, 984, - 985, 986, 994, 999, 1004, 1012, 1017, 1018, 1019, 1028, - 1030, 1035, 1040, 1048, 1050, 1067, 1068, 1069, 1070, 1071, - 1072, 1076, 1077, 1085, 1090, 1095, 1103, 1108, 1109, 1110, - 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1126, 1127, 1128, - 1135, 1142, 1158, 1177, 1182, 1184, 1186, 1188, 1190, 1197, - 1202, 1203, 1204, 1208, 1209, 1210, 1214, 1215, 1219, 1226, - 1236, 1245, 1250, 1252, 1257, 1258, 1266, 1268, 1276, 1281, - 1289, 1314, 1321, 1331, 1332, 1336, 1337, 1338, 1339, 1343, - 1344, 1345, 1349, 1354, 1359, 1367, 1368, 1369, 1370, 1371, - 1372, 1373, 1383, 1388, 1396, 1401, 1409, 1411, 1415, 1420, - 1425, 1433, 1438, 1446, 1455, 1456, 1460, 1461, 1470, 1488, - 1492, 1497, 1505, 1510, 1511, 1515, 1520, 1528, 1533, 1538, - 1543, 1548, 1556, 1561, 1566, 1574, 1579, 1580, 1581, 1582, - 1583 + 0, 366, 366, 370, 371, 372, 387, 388, 389, 390, + 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, + 408, 418, 419, 420, 421, 422, 426, 427, 432, 437, + 439, 445, 446, 454, 455, 456, 460, 465, 466, 467, + 468, 469, 470, 471, 472, 476, 478, 483, 484, 485, + 486, 487, 488, 492, 497, 506, 516, 517, 527, 529, + 531, 533, 544, 551, 553, 558, 560, 562, 564, 566, + 575, 581, 582, 590, 592, 604, 605, 606, 607, 608, + 617, 622, 627, 635, 637, 639, 644, 645, 646, 647, + 648, 649, 653, 654, 655, 656, 665, 667, 676, 686, + 691, 699, 700, 701, 702, 703, 704, 705, 706, 711, + 712, 720, 730, 739, 754, 759, 760, 764, 765, 769, + 770, 771, 772, 773, 774, 775, 784, 788, 792, 800, + 808, 816, 831, 846, 859, 860, 868, 869, 870, 871, + 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, + 882, 886, 891, 899, 904, 905, 906, 910, 915, 923, + 928, 929, 930, 931, 932, 933, 934, 935, 943, 953, + 958, 966, 968, 970, 972, 974, 979, 980, 984, 985, + 986, 987, 995, 1000, 1005, 1013, 1018, 1019, 1020, 1029, + 1031, 1036, 1041, 1049, 1051, 1068, 1069, 1070, 1071, 1072, + 1073, 1077, 1078, 1086, 1091, 1096, 1104, 1109, 1110, 1111, + 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1127, 1128, 1129, + 1136, 1143, 1150, 1166, 1185, 1187, 1189, 1191, 1193, 1195, + 1202, 1207, 1208, 1209, 1213, 1217, 1226, 1227, 1228, 1232, + 1233, 1237, 1244, 1254, 1263, 1268, 1270, 1275, 1276, 1284, + 1286, 1294, 1299, 1307, 1332, 1339, 1349, 1350, 1354, 1355, + 1356, 1357, 1361, 1362, 1363, 1367, 1372, 1377, 1385, 1386, + 1387, 1388, 1389, 1390, 1391, 1401, 1406, 1414, 1419, 1427, + 1429, 1433, 1438, 1443, 1451, 1456, 1464, 1473, 1474, 1478, + 1479, 1488, 1506, 1510, 1515, 1523, 1528, 1529, 1533, 1538, + 1546, 1551, 1556, 1561, 1566, 1574, 1579, 1584, 1592, 1597, + 1598, 1599, 1600, 1601 }; #endif @@ -914,23 +1042,23 @@ static const char *const yytname[] = "T_Broadcastdelay", "T_Burst", "T_Calibrate", "T_Ceiling", "T_Clockstats", "T_Cohort", "T_ControlKey", "T_Crypto", "T_Cryptostats", "T_Ctl", "T_Day", "T_Default", "T_Digest", "T_Disable", "T_Discard", - "T_Dispersion", "T_Double", "T_Driftfile", "T_Drop", "T_Ellipsis", - "T_Enable", "T_End", "T_False", "T_File", "T_Filegen", "T_Filenum", - "T_Flag1", "T_Flag2", "T_Flag3", "T_Flag4", "T_Flake", "T_Floor", - "T_Freq", "T_Fudge", "T_Host", "T_Huffpuff", "T_Iburst", "T_Ident", - "T_Ignore", "T_Incalloc", "T_Incmem", "T_Initalloc", "T_Initmem", - "T_Includefile", "T_Integer", "T_Interface", "T_Intrange", "T_Io", - "T_Ipv4", "T_Ipv4_flag", "T_Ipv6", "T_Ipv6_flag", "T_Kernel", "T_Key", - "T_Keys", "T_Keysdir", "T_Kod", "T_Mssntp", "T_Leapfile", "T_Limited", - "T_Link", "T_Listen", "T_Logconfig", "T_Logfile", "T_Loopstats", - "T_Lowpriotrap", "T_Manycastclient", "T_Manycastserver", "T_Mask", - "T_Maxage", "T_Maxclock", "T_Maxdepth", "T_Maxdist", "T_Maxmem", - "T_Maxpoll", "T_Mdnstries", "T_Mem", "T_Memlock", "T_Minclock", - "T_Mindepth", "T_Mindist", "T_Minimum", "T_Minpoll", "T_Minsane", - "T_Mode", "T_Mode7", "T_Monitor", "T_Month", "T_Mru", - "T_Multicastclient", "T_Nic", "T_Nolink", "T_Nomodify", "T_Nomrulist", - "T_None", "T_Nonvolatile", "T_Nopeer", "T_Noquery", "T_Noselect", - "T_Noserve", "T_Notrap", "T_Notrust", "T_Ntp", "T_Ntpport", + "T_Dispersion", "T_Double", "T_Driftfile", "T_Drop", "T_Dscp", + "T_Ellipsis", "T_Enable", "T_End", "T_False", "T_File", "T_Filegen", + "T_Filenum", "T_Flag1", "T_Flag2", "T_Flag3", "T_Flag4", "T_Flake", + "T_Floor", "T_Freq", "T_Fudge", "T_Host", "T_Huffpuff", "T_Iburst", + "T_Ident", "T_Ignore", "T_Incalloc", "T_Incmem", "T_Initalloc", + "T_Initmem", "T_Includefile", "T_Integer", "T_Interface", "T_Intrange", + "T_Io", "T_Ipv4", "T_Ipv4_flag", "T_Ipv6", "T_Ipv6_flag", "T_Kernel", + "T_Key", "T_Keys", "T_Keysdir", "T_Kod", "T_Mssntp", "T_Leapfile", + "T_Leapsmearinterval", "T_Limited", "T_Link", "T_Listen", "T_Logconfig", + "T_Logfile", "T_Loopstats", "T_Lowpriotrap", "T_Manycastclient", + "T_Manycastserver", "T_Mask", "T_Maxage", "T_Maxclock", "T_Maxdepth", + "T_Maxdist", "T_Maxmem", "T_Maxpoll", "T_Mdnstries", "T_Mem", + "T_Memlock", "T_Minclock", "T_Mindepth", "T_Mindist", "T_Minimum", + "T_Minpoll", "T_Minsane", "T_Mode", "T_Mode7", "T_Monitor", "T_Month", + "T_Mru", "T_Multicastclient", "T_Nic", "T_Nolink", "T_Nomodify", + "T_Nomrulist", "T_None", "T_Nonvolatile", "T_Nopeer", "T_Noquery", + "T_Noselect", "T_Noserve", "T_Notrap", "T_Notrust", "T_Ntp", "T_Ntpport", "T_NtpSignDsocket", "T_Orphan", "T_Orphanwait", "T_Panic", "T_Peer", "T_Peerstats", "T_Phone", "T_Pid", "T_Pidfile", "T_Pool", "T_Port", "T_Preempt", "T_Prefer", "T_Protostats", "T_Pw", "T_Randfile", @@ -965,24 +1093,25 @@ static const char *const yytname[] = "system_option", "system_option_flag_keyword", "system_option_local_flag_keyword", "tinker_command", "tinker_option_list", "tinker_option", "tinker_option_keyword", - "miscellaneous_command", "misc_cmd_dbl_keyword", "misc_cmd_str_keyword", - "misc_cmd_str_lcl_keyword", "drift_parm", "variable_assign", - "t_default_or_zero", "trap_option_list", "trap_option", - "log_config_list", "log_config_command", "interface_command", - "interface_nic", "nic_rule_class", "nic_rule_action", "reset_command", - "counter_set_list", "counter_set_keyword", "integer_list", - "integer_list_range", "integer_list_range_elt", "integer_range", - "string_list", "address_list", "boolean", "number", "simulate_command", - "sim_conf_start", "sim_init_statement_list", "sim_init_statement", - "sim_init_keyword", "sim_server_list", "sim_server", "sim_server_offset", - "sim_server_name", "sim_act_list", "sim_act", "sim_act_stmt_list", - "sim_act_stmt", "sim_act_keyword", YY_NULLPTR + "miscellaneous_command", "misc_cmd_dbl_keyword", "misc_cmd_int_keyword", + "misc_cmd_str_keyword", "misc_cmd_str_lcl_keyword", "drift_parm", + "variable_assign", "t_default_or_zero", "trap_option_list", + "trap_option", "log_config_list", "log_config_command", + "interface_command", "interface_nic", "nic_rule_class", + "nic_rule_action", "reset_command", "counter_set_list", + "counter_set_keyword", "integer_list", "integer_list_range", + "integer_list_range_elt", "integer_range", "string_list", "address_list", + "boolean", "number", "simulate_command", "sim_conf_start", + "sim_init_statement_list", "sim_init_statement", "sim_init_keyword", + "sim_server_list", "sim_server", "sim_server_offset", "sim_server_name", + "sim_act_list", "sim_act", "sim_act_stmt_list", "sim_act_stmt", + "sim_act_keyword", YY_NULL }; #endif # ifdef YYPRINT -/* YYTOKNUM[NUM] -- (External) token number corresponding to the - (internal) symbol number NUM (which must be that of a token). */ +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, @@ -1004,372 +1133,48 @@ static const yytype_uint16 yytoknum[] = 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, - 445, 446, 61, 40, 41, 123, 125 + 445, 446, 447, 448, 61, 40, 41, 123, 125 }; # endif -#define YYPACT_NINF -182 - -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-182))) - -#define YYTABLE_NINF -7 - -#define yytable_value_is_error(Yytable_value) \ - 0 - - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -static const yytype_int16 yypact[] = -{ - 18, -161, -18, -182, -182, -182, -10, -182, 189, 11, - -103, 189, -182, 7, -49, -182, -100, -182, -97, -90, - -182, -84, -182, -182, -49, 13, 365, -49, -182, -182, - -81, -182, -80, -182, -182, 20, 86, 104, 21, -33, - -182, -182, -73, 7, -72, -182, 51, 500, -71, -54, - 26, -182, -182, -182, 90, 205, -83, -182, -49, -182, - -49, -182, -182, -182, -182, -182, -182, -182, -182, -182, - -182, -8, -65, -51, -182, -9, -182, -182, -91, -182, - -182, -182, -15, -182, -182, -182, -182, -182, -182, -182, - -182, 189, -182, -182, -182, -182, -182, -182, 11, -182, - 46, 85, -182, 189, -182, -182, -182, -182, -182, -182, - -182, -182, -182, -182, -182, -182, 92, -182, -35, 366, - -182, -182, -182, -84, -182, -182, -49, -182, -182, -182, - -182, -182, -182, -182, -182, -182, 365, -182, 68, -49, - -182, -182, -23, -182, -182, -182, -182, -182, -182, -182, - -182, 86, -182, -182, 114, 121, -182, -182, 67, -182, - -182, -182, -182, -33, -182, 93, -28, -182, 7, -182, - -182, -182, -182, -182, -182, -182, -182, -182, -182, -182, - -182, 51, -182, -8, -182, -182, -17, -182, -182, -182, - -182, -182, -182, -182, -182, 500, -182, 107, -8, -182, - -182, 112, -54, -182, -182, -182, 113, -182, 8, -182, - -182, -182, -182, -182, -182, -182, -182, -182, -182, -182, - -2, -147, -182, -182, -182, -182, -182, 128, -182, 25, - -182, -182, -182, -182, 116, 37, -182, -182, -182, -182, - 38, 135, -182, -182, 92, -182, -8, -17, -182, -182, - -182, -182, -182, -182, -182, -182, 445, -182, -182, 445, - 445, -71, -182, -182, 40, -182, -182, -182, -182, -182, - -182, -182, -182, -182, -182, -52, 163, -182, -182, -182, - 261, -182, -182, -182, -182, -182, -182, -182, -182, -114, - 27, 14, -182, -182, -182, -182, 55, -182, -182, 0, - -182, -182, -182, -182, -182, -182, -182, -182, -182, -182, - -182, -182, -182, -182, -182, -182, -182, -182, -182, -182, - -182, -182, -182, -182, -182, 445, 445, -182, 185, -71, - 153, -182, 156, -182, -182, -182, -182, -182, -182, -182, - -182, -182, -182, -182, -182, -182, -182, -182, -182, -182, - -182, -182, -53, -182, 61, 30, 43, -133, -182, 23, - -182, -8, -182, -182, -182, -182, -182, -182, -182, -182, - -182, 445, -182, -182, -182, -182, 32, -182, -182, -182, - -49, -182, -182, -182, 45, -182, -182, -182, 41, 50, - -8, 47, -157, -182, 56, -8, -182, -182, -182, 49, - 130, -182, -182, -182, -182, -182, 110, 59, 54, -182, - 70, -182, -8, -182, -182 -}; - - /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE does not specify something else to do. Zero - means the default is an error. */ -static const yytype_uint16 yydefact[] = -{ - 0, 0, 0, 24, 58, 230, 0, 71, 0, 0, - 240, 0, 223, 0, 0, 233, 0, 253, 0, 0, - 234, 0, 236, 25, 0, 0, 0, 0, 254, 231, - 0, 23, 0, 235, 22, 0, 0, 0, 0, 0, - 237, 21, 0, 0, 0, 232, 0, 0, 0, 0, - 0, 56, 57, 289, 0, 2, 0, 7, 0, 8, - 0, 9, 10, 13, 11, 12, 14, 15, 16, 17, - 18, 0, 0, 0, 217, 0, 218, 19, 0, 5, - 62, 63, 64, 195, 196, 197, 198, 201, 199, 200, - 202, 190, 192, 193, 194, 154, 155, 156, 126, 152, - 0, 238, 224, 189, 101, 102, 103, 104, 108, 105, - 106, 107, 109, 29, 30, 28, 0, 26, 0, 6, - 65, 66, 250, 225, 249, 282, 59, 61, 160, 161, - 162, 163, 164, 165, 166, 167, 127, 158, 0, 60, - 70, 280, 226, 67, 265, 266, 267, 268, 269, 270, - 271, 262, 264, 134, 29, 30, 134, 134, 26, 68, - 188, 186, 187, 182, 184, 0, 0, 227, 96, 100, - 97, 207, 208, 209, 210, 211, 212, 213, 214, 215, - 216, 203, 205, 0, 91, 86, 0, 87, 95, 93, - 94, 92, 90, 88, 89, 80, 82, 0, 0, 244, - 276, 0, 69, 275, 277, 273, 229, 1, 0, 4, - 31, 55, 287, 286, 219, 220, 221, 261, 260, 259, - 0, 0, 79, 75, 76, 77, 78, 0, 72, 0, - 191, 151, 153, 239, 98, 0, 178, 179, 180, 181, - 0, 0, 176, 177, 168, 170, 0, 0, 27, 222, - 248, 281, 157, 159, 279, 263, 130, 134, 134, 133, - 128, 0, 183, 185, 0, 99, 204, 206, 285, 283, - 284, 85, 81, 83, 84, 228, 0, 274, 272, 3, - 20, 255, 256, 257, 252, 258, 251, 293, 294, 0, - 0, 0, 74, 73, 118, 117, 0, 115, 116, 0, - 110, 113, 114, 174, 175, 173, 169, 171, 172, 136, - 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, - 147, 148, 149, 150, 135, 131, 132, 134, 243, 0, - 0, 245, 0, 37, 38, 39, 54, 47, 49, 48, - 51, 40, 41, 42, 43, 50, 52, 44, 32, 33, - 36, 34, 0, 35, 0, 0, 0, 0, 296, 0, - 291, 0, 111, 125, 121, 123, 119, 120, 122, 124, - 112, 129, 242, 241, 247, 246, 0, 45, 46, 53, - 0, 290, 288, 295, 0, 292, 278, 299, 0, 0, - 0, 0, 0, 301, 0, 0, 297, 300, 298, 0, - 0, 306, 307, 308, 309, 310, 0, 0, 0, 302, - 0, 304, 0, 303, 305 -}; - - /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -182, -182, -182, -45, -182, -182, -14, -36, -182, -182, - -182, -182, -182, -182, -182, -182, -182, -182, -182, -182, - -182, -182, -182, -182, -182, -182, 60, -182, -182, -182, - -182, -38, -182, -182, -182, -182, -182, -182, -142, -182, - -182, 134, -182, -182, 120, -182, -182, -182, 5, -182, - -182, -182, -182, 96, -182, -182, 250, -42, -182, -182, - -182, -182, 81, -182, -182, -182, -182, -182, -182, -182, - -182, -182, -182, -182, 140, -182, -182, -182, -182, -182, - -182, 117, -182, -182, 63, -182, -182, 240, 22, -181, - -182, -182, -182, -16, -182, -182, -86, -182, -182, -182, - -120, -182, -132, -182 -}; - - /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 54, 55, 56, 57, 58, 125, 117, 118, 280, - 348, 349, 350, 351, 352, 353, 354, 59, 60, 61, - 62, 82, 228, 229, 63, 195, 196, 197, 198, 64, - 168, 112, 234, 300, 301, 302, 370, 65, 256, 324, - 98, 99, 100, 136, 137, 138, 66, 244, 245, 246, - 247, 67, 163, 164, 165, 68, 91, 92, 93, 94, - 69, 181, 182, 183, 70, 71, 72, 73, 102, 167, - 373, 275, 331, 123, 124, 74, 75, 286, 220, 76, - 151, 152, 206, 202, 203, 204, 142, 126, 271, 214, - 77, 78, 289, 290, 291, 357, 358, 389, 359, 392, - 393, 406, 407, 408 -}; - - /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule whose - number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_int16 yytable[] = -{ - 116, 158, 267, 281, 363, 169, 200, 377, 160, 329, - 208, 355, 199, 222, 259, 260, 113, 274, 114, 1, - 79, 268, 95, 157, 212, 217, 364, 104, 2, 391, - 355, 105, 3, 4, 5, 223, 287, 288, 224, 396, - 6, 7, 80, 269, 210, 218, 211, 8, 9, 230, - 81, 10, 213, 101, 11, 12, 119, 171, 13, 120, - 161, 230, 282, 382, 283, 307, 121, 14, 219, 287, - 288, 15, 122, 127, 249, 140, 141, 16, 330, 17, - 143, 159, 172, 166, 170, 115, 205, 106, 18, 19, - 207, 215, 20, 144, 145, 235, 21, 22, 209, 173, - 23, 24, 174, 365, 221, 216, 232, 115, 96, 25, - 366, 146, 251, 97, 162, 325, 326, 233, 378, 225, - 226, 248, 26, 27, 28, 251, 227, 367, 253, 29, - 265, 153, 107, 254, 236, 237, 238, 239, 30, 201, - 108, 257, 31, 109, 32, 294, 33, 34, 258, 147, - 270, 261, 295, 263, 284, 296, 35, 36, 37, 38, - 39, 40, 41, 42, 264, 110, 43, 273, 44, 154, - 111, 155, 276, 278, 175, 285, 368, 45, 148, 369, - 385, 293, 46, 47, 48, 371, 49, 50, 292, 279, - 51, 52, 297, 303, 304, 305, 328, 83, 332, -6, - 53, 84, 176, 177, 178, 179, 361, 85, 360, 394, - 180, 362, 372, 375, 399, 2, 376, 379, 384, 3, - 4, 5, 380, 298, 381, 327, 386, 6, 7, 240, - 388, 414, 231, 390, 8, 9, 391, 398, 10, 395, - 411, 11, 12, 149, 400, 13, 412, 241, 150, 306, - 156, 413, 242, 243, 14, 272, 252, 86, 15, 262, - 115, 103, 266, 250, 16, 277, 17, 139, 255, 308, - 333, 383, 397, 356, 410, 18, 19, 0, 334, 20, - 0, 0, 0, 21, 22, 0, 299, 23, 24, 0, - 87, 88, 0, 374, 0, 0, 25, 401, 402, 403, - 404, 405, 0, 0, 0, 0, 409, 89, 0, 26, - 27, 28, 0, 335, 336, 0, 29, 401, 402, 403, - 404, 405, 0, 0, 0, 30, 0, 0, 0, 31, - 337, 32, 0, 33, 34, 0, 0, 0, 90, 0, - 0, 0, 0, 35, 36, 37, 38, 39, 40, 41, - 42, 338, 0, 43, 0, 44, 0, 0, 0, 339, - 0, 340, 0, 0, 45, 0, 387, 0, 0, 46, - 47, 48, 0, 49, 50, 341, 2, 51, 52, 0, - 3, 4, 5, 0, 0, 0, -6, 53, 6, 7, - 0, 0, 342, 343, 0, 8, 9, 0, 0, 10, - 0, 0, 11, 12, 0, 0, 13, 0, 0, 0, - 0, 0, 0, 0, 0, 14, 0, 0, 0, 15, - 128, 129, 130, 131, 0, 16, 0, 17, 344, 0, - 345, 0, 0, 0, 0, 346, 18, 19, 0, 347, - 20, 0, 0, 0, 21, 22, 0, 0, 23, 24, - 132, 0, 133, 0, 134, 0, 0, 25, 0, 0, - 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 26, 27, 28, 0, 0, 0, 0, 29, 0, 0, - 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, - 31, 309, 32, 0, 33, 34, 0, 0, 0, 310, - 0, 0, 0, 0, 35, 36, 37, 38, 39, 40, - 41, 42, 0, 184, 43, 0, 44, 311, 312, 185, - 313, 186, 0, 0, 0, 45, 314, 0, 0, 0, - 46, 47, 48, 0, 49, 50, 0, 0, 51, 52, - 0, 0, 0, 0, 0, 0, 0, 187, 53, 0, - 0, 0, 0, 315, 316, 0, 0, 317, 318, 0, - 319, 320, 321, 0, 322, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 188, 0, 189, 0, - 0, 0, 0, 0, 190, 0, 191, 0, 0, 192, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 323, - 0, 193, 194 -}; - -static const yytype_int16 yycheck[] = -{ - 14, 37, 183, 5, 4, 43, 60, 60, 41, 61, - 55, 144, 48, 28, 156, 157, 65, 198, 67, 1, - 181, 38, 11, 37, 32, 34, 26, 20, 10, 186, - 144, 24, 14, 15, 16, 50, 183, 184, 53, 196, - 22, 23, 60, 60, 58, 54, 60, 29, 30, 91, - 60, 33, 60, 156, 36, 37, 156, 6, 40, 156, - 93, 103, 64, 196, 66, 246, 156, 49, 77, 183, - 184, 53, 156, 60, 119, 156, 156, 59, 130, 61, - 60, 60, 31, 156, 156, 156, 60, 80, 70, 71, - 0, 156, 74, 7, 8, 3, 78, 79, 181, 48, - 82, 83, 51, 103, 195, 156, 60, 156, 97, 91, - 110, 25, 126, 102, 147, 257, 258, 32, 171, 134, - 135, 156, 104, 105, 106, 139, 141, 127, 60, 111, - 168, 27, 125, 156, 42, 43, 44, 45, 120, 193, - 133, 27, 124, 136, 126, 29, 128, 129, 27, 63, - 167, 84, 36, 60, 156, 39, 138, 139, 140, 141, - 142, 143, 144, 145, 192, 158, 148, 60, 150, 65, - 163, 67, 60, 60, 123, 177, 176, 159, 92, 179, - 361, 156, 164, 165, 166, 327, 168, 169, 60, 181, - 172, 173, 76, 156, 156, 60, 156, 8, 35, 181, - 182, 12, 151, 152, 153, 154, 192, 18, 181, 390, - 159, 156, 27, 60, 395, 10, 60, 156, 195, 14, - 15, 16, 192, 107, 181, 261, 194, 22, 23, 137, - 185, 412, 98, 192, 29, 30, 186, 181, 33, 192, - 181, 36, 37, 157, 195, 40, 192, 155, 162, 244, - 146, 181, 160, 161, 49, 195, 136, 68, 53, 163, - 156, 11, 181, 123, 59, 202, 61, 27, 151, 247, - 9, 357, 392, 289, 406, 70, 71, -1, 17, 74, - -1, -1, -1, 78, 79, -1, 170, 82, 83, -1, - 101, 102, -1, 329, -1, -1, 91, 187, 188, 189, - 190, 191, -1, -1, -1, -1, 196, 118, -1, 104, - 105, 106, -1, 52, 53, -1, 111, 187, 188, 189, - 190, 191, -1, -1, -1, 120, -1, -1, -1, 124, - 69, 126, -1, 128, 129, -1, -1, -1, 149, -1, - -1, -1, -1, 138, 139, 140, 141, 142, 143, 144, - 145, 90, -1, 148, -1, 150, -1, -1, -1, 98, - -1, 100, -1, -1, 159, -1, 380, -1, -1, 164, - 165, 166, -1, 168, 169, 114, 10, 172, 173, -1, - 14, 15, 16, -1, -1, -1, 181, 182, 22, 23, - -1, -1, 131, 132, -1, 29, 30, -1, -1, 33, - -1, -1, 36, 37, -1, -1, 40, -1, -1, -1, - -1, -1, -1, -1, -1, 49, -1, -1, -1, 53, - 55, 56, 57, 58, -1, 59, -1, 61, 167, -1, - 169, -1, -1, -1, -1, 174, 70, 71, -1, 178, - 74, -1, -1, -1, 78, 79, -1, -1, 82, 83, - 85, -1, 87, -1, 89, -1, -1, 91, -1, -1, - 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 104, 105, 106, -1, -1, -1, -1, 111, -1, -1, - -1, -1, -1, -1, -1, -1, 120, -1, -1, -1, - 124, 46, 126, -1, 128, 129, -1, -1, -1, 54, - -1, -1, -1, -1, 138, 139, 140, 141, 142, 143, - 144, 145, -1, 13, 148, -1, 150, 72, 73, 19, - 75, 21, -1, -1, -1, 159, 81, -1, -1, -1, - 164, 165, 166, -1, 168, 169, -1, -1, 172, 173, - -1, -1, -1, -1, -1, -1, -1, 47, 182, -1, - -1, -1, -1, 108, 109, -1, -1, 112, 113, -1, - 115, 116, 117, -1, 119, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 86, -1, 88, -1, - -1, -1, -1, -1, 94, -1, 96, -1, -1, 99, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 174, - -1, 121, 122 -}; - - /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint16 yystos[] = -{ - 0, 1, 10, 14, 15, 16, 22, 23, 29, 30, - 33, 36, 37, 40, 49, 53, 59, 61, 70, 71, - 74, 78, 79, 82, 83, 91, 104, 105, 106, 111, - 120, 124, 126, 128, 129, 138, 139, 140, 141, 142, - 143, 144, 145, 148, 150, 159, 164, 165, 166, 168, - 169, 172, 173, 182, 198, 199, 200, 201, 202, 214, - 215, 216, 217, 221, 226, 234, 243, 248, 252, 257, - 261, 262, 263, 264, 272, 273, 276, 287, 288, 181, - 60, 60, 218, 8, 12, 18, 68, 101, 102, 118, - 149, 253, 254, 255, 256, 11, 97, 102, 237, 238, - 239, 156, 265, 253, 20, 24, 80, 125, 133, 136, - 158, 163, 228, 65, 67, 156, 203, 204, 205, 156, - 156, 156, 156, 270, 271, 203, 284, 60, 55, 56, - 57, 58, 85, 87, 89, 95, 240, 241, 242, 284, - 156, 156, 283, 60, 7, 8, 25, 63, 92, 157, - 162, 277, 278, 27, 65, 67, 146, 203, 204, 60, - 41, 93, 147, 249, 250, 251, 156, 266, 227, 228, - 156, 6, 31, 48, 51, 123, 151, 152, 153, 154, - 159, 258, 259, 260, 13, 19, 21, 47, 86, 88, - 94, 96, 99, 121, 122, 222, 223, 224, 225, 204, - 60, 193, 280, 281, 282, 60, 279, 0, 200, 181, - 203, 203, 32, 60, 286, 156, 156, 34, 54, 77, - 275, 195, 28, 50, 53, 134, 135, 141, 219, 220, - 254, 238, 60, 32, 229, 3, 42, 43, 44, 45, - 137, 155, 160, 161, 244, 245, 246, 247, 156, 200, - 271, 203, 241, 60, 156, 278, 235, 27, 27, 235, - 235, 84, 250, 60, 192, 228, 259, 286, 38, 60, - 167, 285, 223, 60, 286, 268, 60, 281, 60, 181, - 206, 5, 64, 66, 156, 177, 274, 183, 184, 289, - 290, 291, 60, 156, 29, 36, 39, 76, 107, 170, - 230, 231, 232, 156, 156, 60, 245, 286, 285, 46, - 54, 72, 73, 75, 81, 108, 109, 112, 113, 115, - 116, 117, 119, 174, 236, 235, 235, 204, 156, 61, - 130, 269, 35, 9, 17, 52, 53, 69, 90, 98, - 100, 114, 131, 132, 167, 169, 174, 178, 207, 208, - 209, 210, 211, 212, 213, 144, 290, 292, 293, 295, - 181, 192, 156, 4, 26, 103, 110, 127, 176, 179, - 233, 235, 27, 267, 204, 60, 60, 60, 171, 156, - 192, 181, 196, 293, 195, 286, 194, 203, 185, 294, - 192, 186, 296, 297, 286, 192, 196, 297, 181, 286, - 195, 187, 188, 189, 190, 191, 298, 299, 300, 196, - 299, 181, 192, 181, 286 -}; - - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { - 0, 197, 198, 199, 199, 199, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 201, 202, 202, 202, 202, 202, 203, 203, 204, 205, - 205, 206, 206, 207, 207, 207, 208, 209, 209, 209, - 209, 209, 209, 209, 209, 210, 210, 211, 211, 211, - 211, 211, 211, 212, 213, 214, 215, 215, 216, 216, - 216, 216, 217, 217, 217, 217, 217, 217, 217, 217, - 217, 218, 218, 219, 219, 220, 220, 220, 220, 220, - 221, 222, 222, 223, 223, 223, 224, 224, 224, 224, - 224, 224, 225, 225, 225, 225, 226, 226, 226, 227, - 227, 228, 228, 228, 228, 228, 228, 228, 228, 229, - 229, 230, 230, 230, 230, 231, 231, 232, 232, 233, - 233, 233, 233, 233, 233, 233, 234, 234, 234, 234, - 234, 234, 234, 234, 235, 235, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 237, 237, 238, 239, 239, 239, 240, 240, 241, - 242, 242, 242, 242, 242, 242, 242, 242, 243, 244, - 244, 245, 245, 245, 245, 245, 246, 246, 247, 247, - 247, 247, 248, 249, 249, 250, 251, 251, 251, 252, - 252, 253, 253, 254, 254, 255, 255, 255, 255, 255, - 255, 256, 256, 257, 258, 258, 259, 260, 260, 260, - 260, 260, 260, 260, 260, 260, 260, 261, 261, 261, - 261, 261, 261, 261, 261, 261, 261, 261, 261, 261, - 262, 262, 262, 263, 263, 263, 264, 264, 265, 265, - 265, 266, 267, 267, 268, 268, 269, 269, 270, 270, - 271, 272, 272, 273, 273, 274, 274, 274, 274, 275, - 275, 275, 276, 277, 277, 278, 278, 278, 278, 278, - 278, 278, 279, 279, 280, 280, 281, 281, 282, 283, - 283, 284, 284, 285, 285, 285, 286, 286, 287, 288, - 289, 289, 290, 291, 291, 292, 292, 293, 294, 295, - 296, 296, 297, 298, 298, 299, 300, 300, 300, 300, - 300 + 0, 199, 200, 201, 201, 201, 202, 202, 202, 202, + 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, + 203, 204, 204, 204, 204, 204, 205, 205, 206, 207, + 207, 208, 208, 209, 209, 209, 210, 211, 211, 211, + 211, 211, 211, 211, 211, 212, 212, 213, 213, 213, + 213, 213, 213, 214, 215, 216, 217, 217, 218, 218, + 218, 218, 219, 219, 219, 219, 219, 219, 219, 219, + 219, 220, 220, 221, 221, 222, 222, 222, 222, 222, + 223, 224, 224, 225, 225, 225, 226, 226, 226, 226, + 226, 226, 227, 227, 227, 227, 228, 228, 228, 229, + 229, 230, 230, 230, 230, 230, 230, 230, 230, 231, + 231, 232, 232, 232, 232, 233, 233, 234, 234, 235, + 235, 235, 235, 235, 235, 235, 236, 236, 236, 236, + 236, 236, 236, 236, 237, 237, 238, 238, 238, 238, + 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, + 238, 239, 239, 240, 241, 241, 241, 242, 242, 243, + 244, 244, 244, 244, 244, 244, 244, 244, 245, 246, + 246, 247, 247, 247, 247, 247, 248, 248, 249, 249, + 249, 249, 250, 251, 251, 252, 253, 253, 253, 254, + 254, 255, 255, 256, 256, 257, 257, 257, 257, 257, + 257, 258, 258, 259, 260, 260, 261, 262, 262, 262, + 262, 262, 262, 262, 262, 262, 262, 263, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, + 263, 264, 264, 264, 265, 265, 266, 266, 266, 267, + 267, 268, 268, 268, 269, 270, 270, 271, 271, 272, + 272, 273, 273, 274, 275, 275, 276, 276, 277, 277, + 277, 277, 278, 278, 278, 279, 280, 280, 281, 281, + 281, 281, 281, 281, 281, 282, 282, 283, 283, 284, + 284, 285, 286, 286, 287, 287, 288, 288, 288, 289, + 289, 290, 291, 292, 292, 293, 294, 294, 295, 295, + 296, 297, 298, 299, 299, 300, 301, 301, 302, 303, + 303, 303, 303, 303 }; - /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 3, 2, 2, 0, 1, 1, 1, @@ -1394,28 +1199,368 @@ static const yytype_uint8 yyr2[] = 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 2, 2, 3, 1, 2, 2, 2, 2, 3, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 0, 4, 1, 0, 0, 2, 2, 2, 2, 1, - 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 1, 2, 1, 1, 1, 5, 2, - 1, 2, 1, 1, 1, 1, 1, 1, 5, 1, - 3, 2, 3, 1, 1, 2, 1, 5, 4, 3, - 2, 1, 6, 3, 2, 3, 1, 1, 1, 1, - 1 + 2, 2, 2, 3, 1, 2, 2, 2, 2, 3, + 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 0, 4, 1, 0, 0, 2, 2, + 2, 2, 1, 1, 3, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, + 1, 5, 2, 1, 2, 1, 1, 1, 1, 1, + 1, 5, 1, 3, 2, 3, 1, 1, 2, 1, + 5, 4, 3, 2, 1, 6, 3, 2, 3, 1, + 1, 1, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint16 yydefact[] = +{ + 0, 0, 0, 24, 58, 231, 0, 71, 0, 0, + 243, 234, 0, 224, 0, 0, 236, 0, 256, 0, + 0, 237, 235, 0, 239, 25, 0, 0, 0, 0, + 257, 232, 0, 23, 0, 238, 22, 0, 0, 0, + 0, 0, 240, 21, 0, 0, 0, 233, 0, 0, + 0, 0, 0, 56, 57, 292, 0, 2, 0, 7, + 0, 8, 0, 9, 10, 13, 11, 12, 14, 15, + 16, 17, 18, 0, 0, 0, 0, 217, 0, 218, + 19, 0, 5, 62, 63, 64, 195, 196, 197, 198, + 201, 199, 200, 202, 190, 192, 193, 194, 154, 155, + 156, 126, 152, 0, 241, 225, 189, 101, 102, 103, + 104, 108, 105, 106, 107, 109, 29, 30, 28, 0, + 26, 0, 6, 65, 66, 253, 226, 252, 285, 59, + 61, 160, 161, 162, 163, 164, 165, 166, 167, 127, + 158, 0, 60, 70, 283, 227, 67, 268, 269, 270, + 271, 272, 273, 274, 265, 267, 134, 29, 30, 134, + 134, 26, 68, 188, 186, 187, 182, 184, 0, 0, + 228, 96, 100, 97, 207, 208, 209, 210, 211, 212, + 213, 214, 215, 216, 203, 205, 0, 91, 86, 0, + 87, 95, 93, 94, 92, 90, 88, 89, 80, 82, + 0, 0, 247, 279, 0, 69, 278, 280, 276, 230, + 1, 0, 4, 31, 55, 290, 289, 219, 220, 221, + 222, 264, 263, 262, 0, 0, 79, 75, 76, 77, + 78, 0, 72, 0, 191, 151, 153, 242, 98, 0, + 178, 179, 180, 181, 0, 0, 176, 177, 168, 170, + 0, 0, 27, 223, 251, 284, 157, 159, 282, 266, + 130, 134, 134, 133, 128, 0, 183, 185, 0, 99, + 204, 206, 288, 286, 287, 85, 81, 83, 84, 229, + 0, 277, 275, 3, 20, 258, 259, 260, 255, 261, + 254, 296, 297, 0, 0, 0, 74, 73, 118, 117, + 0, 115, 116, 0, 110, 113, 114, 174, 175, 173, + 169, 171, 172, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 135, 131, + 132, 134, 246, 0, 0, 248, 0, 37, 38, 39, + 54, 47, 49, 48, 51, 40, 41, 42, 43, 50, + 52, 44, 32, 33, 36, 34, 0, 35, 0, 0, + 0, 0, 299, 0, 294, 0, 111, 125, 121, 123, + 119, 120, 122, 124, 112, 129, 245, 244, 250, 249, + 0, 45, 46, 53, 0, 293, 291, 298, 0, 295, + 281, 302, 0, 0, 0, 0, 0, 304, 0, 0, + 300, 303, 301, 0, 0, 309, 310, 311, 312, 313, + 0, 0, 0, 305, 0, 307, 0, 306, 308 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 56, 57, 58, 59, 60, 128, 120, 121, 284, + 352, 353, 354, 355, 356, 357, 358, 61, 62, 63, + 64, 85, 232, 233, 65, 198, 199, 200, 201, 66, + 171, 115, 238, 304, 305, 306, 374, 67, 260, 328, + 101, 102, 103, 139, 140, 141, 68, 248, 249, 250, + 251, 69, 166, 167, 168, 70, 94, 95, 96, 97, + 71, 184, 185, 186, 72, 73, 74, 75, 76, 105, + 170, 377, 279, 335, 126, 127, 77, 78, 290, 224, + 79, 154, 155, 209, 205, 206, 207, 145, 129, 275, + 217, 80, 81, 293, 294, 295, 361, 362, 393, 363, + 396, 397, 410, 411, 412 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -185 +static const yytype_int16 yypact[] = +{ + 78, -169, -34, -185, -185, -185, -29, -185, 17, 43, + -124, -185, 17, -185, -5, -27, -185, -121, -185, -112, + -110, -185, -185, -100, -185, -185, -27, 0, 116, -27, + -185, -185, -91, -185, -89, -185, -185, 11, 35, 30, + 13, 31, -185, -185, -83, -5, -78, -185, 186, 523, + -76, -56, 15, -185, -185, -185, 83, 244, -99, -185, + -27, -185, -27, -185, -185, -185, -185, -185, -185, -185, + -185, -185, -185, -12, 24, -71, -69, -185, -11, -185, + -185, -107, -185, -185, -185, 8, -185, -185, -185, -185, + -185, -185, -185, -185, 17, -185, -185, -185, -185, -185, + -185, 43, -185, 34, 59, -185, 17, -185, -185, -185, + -185, -185, -185, -185, -185, -185, -185, -185, -185, 7, + -185, -61, 407, -185, -185, -185, -100, -185, -185, -27, + -185, -185, -185, -185, -185, -185, -185, -185, -185, 116, + -185, 44, -27, -185, -185, -52, -185, -185, -185, -185, + -185, -185, -185, -185, 35, -185, -185, 85, 96, -185, + -185, 39, -185, -185, -185, -185, 31, -185, 75, -46, + -185, -5, -185, -185, -185, -185, -185, -185, -185, -185, + -185, -185, -185, -185, 186, -185, -12, -185, -185, -35, + -185, -185, -185, -185, -185, -185, -185, -185, 523, -185, + 82, -12, -185, -185, 91, -56, -185, -185, -185, 100, + -185, -26, -185, -185, -185, -185, -185, -185, -185, -185, + -185, -185, -185, -185, -2, -130, -185, -185, -185, -185, + -185, 105, -185, 9, -185, -185, -185, -185, -7, 18, + -185, -185, -185, -185, 25, 121, -185, -185, 7, -185, + -12, -35, -185, -185, -185, -185, -185, -185, -185, -185, + 391, -185, -185, 391, 391, -76, -185, -185, 29, -185, + -185, -185, -185, -185, -185, -185, -185, -185, -185, -51, + 153, -185, -185, -185, 464, -185, -185, -185, -185, -185, + -185, -185, -185, -82, 14, 1, -185, -185, -185, -185, + 38, -185, -185, 12, -185, -185, -185, -185, -185, -185, + -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, + -185, -185, -185, -185, -185, -185, -185, -185, -185, 391, + 391, -185, 171, -76, 140, -185, 141, -185, -185, -185, + -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, + -185, -185, -185, -185, -185, -185, -55, -185, 53, 20, + 33, -128, -185, 32, -185, -12, -185, -185, -185, -185, + -185, -185, -185, -185, -185, 391, -185, -185, -185, -185, + 16, -185, -185, -185, -27, -185, -185, -185, 46, -185, + -185, -185, 37, 48, -12, 40, -167, -185, 54, -12, + -185, -185, -185, 45, 79, -185, -185, -185, -185, -185, + 98, 57, 47, -185, 60, -185, -12, -185, -185 }; +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -185, -185, -185, -44, -185, -185, -15, -38, -185, -185, + -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, + -185, -185, -185, -185, -185, -185, 28, -185, -185, -185, + -185, -36, -185, -185, -185, -185, -185, -185, -152, -185, + -185, 146, -185, -185, 111, -185, -185, -185, 3, -185, + -185, -185, -185, 89, -185, -185, 245, -66, -185, -185, + -185, -185, 72, -185, -185, -185, -185, -185, -185, -185, + -185, -185, -185, -185, -185, 137, -185, -185, -185, -185, + -185, -185, 110, -185, -185, 70, -185, -185, 236, 27, + -184, -185, -185, -185, -17, -185, -185, -81, -185, -185, + -185, -113, -185, -126, -185 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -7 +static const yytype_int16 yytable[] = +{ + 119, 161, 271, 285, 272, 203, 381, 263, 264, 172, + 239, 333, 202, 211, 82, 107, 367, 278, 359, 108, + 215, 395, 298, 221, 160, 86, 273, 83, 234, 87, + 299, 400, 84, 300, 104, 88, 226, 122, 368, 116, + 234, 117, 147, 148, 222, 213, 123, 214, 124, 216, + 240, 241, 242, 243, 98, 291, 292, 156, 125, 227, + 149, 130, 228, 286, 359, 287, 311, 143, 223, 144, + 386, 301, 146, 163, 162, 169, 208, 109, 253, 1, + 173, 334, 118, 210, 212, 218, 89, 219, 2, 220, + 225, 237, 3, 4, 5, 236, 157, 252, 158, 150, + 6, 7, 302, 291, 292, 257, 258, 8, 9, 329, + 330, 10, 261, 11, 255, 12, 13, 369, 382, 14, + 90, 91, 110, 262, 370, 265, 164, 255, 15, 151, + 111, 118, 16, 112, 274, 269, 267, 92, 17, 204, + 18, 371, 99, 277, 229, 230, 244, 100, 268, 19, + 20, 231, 280, 21, 22, 113, 288, 283, 23, 24, + 114, 282, 25, 26, 245, 303, 296, 297, 93, 246, + 247, 27, 131, 132, 133, 134, 307, 289, 159, 375, + 165, 389, 309, 308, 28, 29, 30, 332, 118, 336, + 372, 31, 174, 373, 152, 365, 366, 364, 376, 153, + 32, 379, 380, 135, 33, 136, 34, 137, 35, 36, + 398, 383, 390, 138, 384, 403, 385, 175, 37, 38, + 39, 40, 41, 42, 43, 44, 276, 331, 45, 388, + 46, 394, 418, 392, 399, 176, 395, 402, 177, 47, + 415, 416, 404, 417, 48, 49, 50, 235, 51, 52, + 256, 310, 53, 54, 2, 266, 270, 106, 3, 4, + 5, -6, 55, 254, 259, 142, 6, 7, 405, 406, + 407, 408, 409, 8, 9, 281, 360, 10, 312, 11, + 387, 12, 13, 401, 414, 14, 0, 405, 406, 407, + 408, 409, 0, 0, 15, 378, 413, 0, 16, 0, + 0, 0, 0, 0, 17, 0, 18, 0, 0, 0, + 0, 178, 0, 0, 0, 19, 20, 0, 0, 21, + 22, 0, 0, 0, 23, 24, 0, 0, 25, 26, + 0, 0, 0, 0, 0, 0, 0, 27, 0, 179, + 180, 181, 182, 0, 0, 0, 0, 183, 0, 0, + 28, 29, 30, 0, 0, 0, 0, 31, 0, 0, + 0, 0, 0, 0, 0, 0, 32, 0, 0, 391, + 33, 0, 34, 0, 35, 36, 0, 0, 0, 0, + 0, 0, 0, 0, 37, 38, 39, 40, 41, 42, + 43, 44, 0, 0, 45, 0, 46, 0, 0, 0, + 0, 0, 0, 0, 0, 47, 0, 0, 0, 0, + 48, 49, 50, 0, 51, 52, 0, 2, 53, 54, + 0, 3, 4, 5, 0, 0, 0, -6, 55, 6, + 7, 0, 0, 0, 0, 0, 8, 9, 313, 0, + 10, 0, 11, 0, 12, 13, 314, 0, 14, 0, + 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, + 0, 16, 0, 0, 315, 316, 0, 17, 317, 18, + 0, 0, 0, 337, 318, 0, 0, 0, 19, 20, + 0, 338, 21, 22, 0, 0, 0, 23, 24, 0, + 0, 25, 26, 0, 0, 0, 0, 0, 0, 0, + 27, 319, 320, 0, 0, 321, 322, 0, 323, 324, + 325, 0, 326, 28, 29, 30, 0, 339, 340, 0, + 31, 0, 0, 0, 0, 0, 0, 0, 0, 32, + 0, 0, 0, 33, 341, 34, 187, 35, 36, 0, + 0, 0, 188, 0, 189, 0, 0, 37, 38, 39, + 40, 41, 42, 43, 44, 0, 342, 45, 0, 46, + 0, 0, 0, 0, 343, 0, 344, 327, 47, 0, + 0, 190, 0, 48, 49, 50, 0, 51, 52, 0, + 345, 53, 54, 0, 0, 0, 0, 0, 0, 0, + 0, 55, 0, 0, 0, 0, 0, 346, 347, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 191, 0, 192, 0, 0, 0, 0, 0, 193, + 0, 194, 0, 0, 195, 0, 0, 0, 0, 0, + 0, 0, 0, 348, 0, 349, 0, 0, 0, 0, + 350, 0, 0, 0, 351, 0, 196, 197 +}; + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-185))) + +#define yytable_value_is_error(Yytable_value) \ + YYID (0) -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 +static const yytype_int16 yycheck[] = +{ + 15, 39, 186, 5, 39, 61, 61, 159, 160, 45, + 3, 62, 50, 57, 183, 20, 4, 201, 146, 24, + 32, 188, 29, 34, 39, 8, 61, 61, 94, 12, + 37, 198, 61, 40, 158, 18, 28, 158, 26, 66, + 106, 68, 7, 8, 55, 60, 158, 62, 158, 61, + 43, 44, 45, 46, 11, 185, 186, 27, 158, 51, + 25, 61, 54, 65, 146, 67, 250, 158, 79, 158, + 198, 78, 61, 42, 61, 158, 61, 82, 122, 1, + 158, 132, 158, 0, 183, 61, 69, 158, 10, 158, + 197, 32, 14, 15, 16, 61, 66, 158, 68, 64, + 22, 23, 109, 185, 186, 61, 158, 29, 30, 261, + 262, 33, 27, 35, 129, 37, 38, 105, 173, 41, + 103, 104, 127, 27, 112, 86, 95, 142, 50, 94, + 135, 158, 54, 138, 169, 171, 61, 120, 60, 195, + 62, 129, 99, 61, 136, 137, 139, 104, 194, 71, + 72, 143, 61, 75, 76, 160, 158, 183, 80, 81, + 165, 61, 84, 85, 157, 172, 61, 158, 151, 162, + 163, 93, 56, 57, 58, 59, 158, 179, 148, 331, + 149, 365, 61, 158, 106, 107, 108, 158, 158, 36, + 178, 113, 6, 181, 159, 194, 158, 183, 27, 164, + 122, 61, 61, 87, 126, 89, 128, 91, 130, 131, + 394, 158, 196, 97, 194, 399, 183, 31, 140, 141, + 142, 143, 144, 145, 146, 147, 198, 265, 150, 197, + 152, 194, 416, 187, 194, 49, 188, 183, 52, 161, + 183, 194, 197, 183, 166, 167, 168, 101, 170, 171, + 139, 248, 174, 175, 10, 166, 184, 12, 14, 15, + 16, 183, 184, 126, 154, 29, 22, 23, 189, 190, + 191, 192, 193, 29, 30, 205, 293, 33, 251, 35, + 361, 37, 38, 396, 410, 41, -1, 189, 190, 191, + 192, 193, -1, -1, 50, 333, 198, -1, 54, -1, + -1, -1, -1, -1, 60, -1, 62, -1, -1, -1, + -1, 125, -1, -1, -1, 71, 72, -1, -1, 75, + 76, -1, -1, -1, 80, 81, -1, -1, 84, 85, + -1, -1, -1, -1, -1, -1, -1, 93, -1, 153, + 154, 155, 156, -1, -1, -1, -1, 161, -1, -1, + 106, 107, 108, -1, -1, -1, -1, 113, -1, -1, + -1, -1, -1, -1, -1, -1, 122, -1, -1, 384, + 126, -1, 128, -1, 130, 131, -1, -1, -1, -1, + -1, -1, -1, -1, 140, 141, 142, 143, 144, 145, + 146, 147, -1, -1, 150, -1, 152, -1, -1, -1, + -1, -1, -1, -1, -1, 161, -1, -1, -1, -1, + 166, 167, 168, -1, 170, 171, -1, 10, 174, 175, + -1, 14, 15, 16, -1, -1, -1, 183, 184, 22, + 23, -1, -1, -1, -1, -1, 29, 30, 47, -1, + 33, -1, 35, -1, 37, 38, 55, -1, 41, -1, + -1, -1, -1, -1, -1, -1, -1, 50, -1, -1, + -1, 54, -1, -1, 73, 74, -1, 60, 77, 62, + -1, -1, -1, 9, 83, -1, -1, -1, 71, 72, + -1, 17, 75, 76, -1, -1, -1, 80, 81, -1, + -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, + 93, 110, 111, -1, -1, 114, 115, -1, 117, 118, + 119, -1, 121, 106, 107, 108, -1, 53, 54, -1, + 113, -1, -1, -1, -1, -1, -1, -1, -1, 122, + -1, -1, -1, 126, 70, 128, 13, 130, 131, -1, + -1, -1, 19, -1, 21, -1, -1, 140, 141, 142, + 143, 144, 145, 146, 147, -1, 92, 150, -1, 152, + -1, -1, -1, -1, 100, -1, 102, 176, 161, -1, + -1, 48, -1, 166, 167, 168, -1, 170, 171, -1, + 116, 174, 175, -1, -1, -1, -1, -1, -1, -1, + -1, 184, -1, -1, -1, -1, -1, 133, 134, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 88, -1, 90, -1, -1, -1, -1, -1, 96, + -1, 98, -1, -1, 101, -1, -1, -1, -1, -1, + -1, -1, -1, 169, -1, 171, -1, -1, -1, -1, + 176, -1, -1, -1, 180, -1, 123, 124 +}; -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint16 yystos[] = +{ + 0, 1, 10, 14, 15, 16, 22, 23, 29, 30, + 33, 35, 37, 38, 41, 50, 54, 60, 62, 71, + 72, 75, 76, 80, 81, 84, 85, 93, 106, 107, + 108, 113, 122, 126, 128, 130, 131, 140, 141, 142, + 143, 144, 145, 146, 147, 150, 152, 161, 166, 167, + 168, 170, 171, 174, 175, 184, 200, 201, 202, 203, + 204, 216, 217, 218, 219, 223, 228, 236, 245, 250, + 254, 259, 263, 264, 265, 266, 267, 275, 276, 279, + 290, 291, 183, 61, 61, 220, 8, 12, 18, 69, + 103, 104, 120, 151, 255, 256, 257, 258, 11, 99, + 104, 239, 240, 241, 158, 268, 255, 20, 24, 82, + 127, 135, 138, 160, 165, 230, 66, 68, 158, 205, + 206, 207, 158, 158, 158, 158, 273, 274, 205, 287, + 61, 56, 57, 58, 59, 87, 89, 91, 97, 242, + 243, 244, 287, 158, 158, 286, 61, 7, 8, 25, + 64, 94, 159, 164, 280, 281, 27, 66, 68, 148, + 205, 206, 61, 42, 95, 149, 251, 252, 253, 158, + 269, 229, 230, 158, 6, 31, 49, 52, 125, 153, + 154, 155, 156, 161, 260, 261, 262, 13, 19, 21, + 48, 88, 90, 96, 98, 101, 123, 124, 224, 225, + 226, 227, 206, 61, 195, 283, 284, 285, 61, 282, + 0, 202, 183, 205, 205, 32, 61, 289, 61, 158, + 158, 34, 55, 79, 278, 197, 28, 51, 54, 136, + 137, 143, 221, 222, 256, 240, 61, 32, 231, 3, + 43, 44, 45, 46, 139, 157, 162, 163, 246, 247, + 248, 249, 158, 202, 274, 205, 243, 61, 158, 281, + 237, 27, 27, 237, 237, 86, 252, 61, 194, 230, + 261, 289, 39, 61, 169, 288, 225, 61, 289, 271, + 61, 284, 61, 183, 208, 5, 65, 67, 158, 179, + 277, 185, 186, 292, 293, 294, 61, 158, 29, 37, + 40, 78, 109, 172, 232, 233, 234, 158, 158, 61, + 247, 289, 288, 47, 55, 73, 74, 77, 83, 110, + 111, 114, 115, 117, 118, 119, 121, 176, 238, 237, + 237, 206, 158, 62, 132, 272, 36, 9, 17, 53, + 54, 70, 92, 100, 102, 116, 133, 134, 169, 171, + 176, 180, 209, 210, 211, 212, 213, 214, 215, 146, + 293, 295, 296, 298, 183, 194, 158, 4, 26, 105, + 112, 129, 178, 181, 235, 237, 27, 270, 206, 61, + 61, 61, 173, 158, 194, 183, 198, 296, 197, 289, + 196, 205, 187, 297, 194, 188, 299, 300, 289, 194, + 198, 300, 183, 289, 197, 189, 190, 191, 192, 193, + 301, 302, 303, 198, 302, 183, 194, 183, 289 +}; +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ + +#define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -1431,16 +1576,28 @@ do \ } \ else \ { \ - yyerror (ip_file, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) /* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif +/* YYLEX -- calling `yylex' with the right arguments. */ +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -1450,45 +1607,50 @@ while (0) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif - +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value, ip_file); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct FILE_INFO *ip_file) +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif { FILE *yyo = yyoutput; YYUSE (yyo); - YYUSE (ip_file); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); # endif YYUSE (yytype); } @@ -1498,13 +1660,24 @@ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvalue | Print this symbol on YYOUTPUT. | `--------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct FILE_INFO *ip_file) +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif { - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, ip_file); + yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); } @@ -1513,8 +1686,16 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, str | TOP (included). | `------------------------------------------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -1525,42 +1706,49 @@ yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, struct FILE_INFO *ip_file) +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; +#endif { - unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; + unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , ip_file); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); YYFPRINTF (stderr, "\n"); } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyssp, yyvsp, Rule, ip_file); \ -} while (0) +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -1574,7 +1762,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -1597,8 +1785,15 @@ int yydebug; # define yystrlen strlen # else /* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) @@ -1614,8 +1809,16 @@ yystrlen (const char *yystr) # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif { char *yyd = yydest; const char *yys = yysrc; @@ -1645,27 +1848,27 @@ yytnamerr (char *yyres, const char *yystr) char const *yyp = yystr; for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } do_not_strip_quotes: ; } @@ -1688,11 +1891,11 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; + const char *yyformat = YY_NULL; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1700,6 +1903,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, int yycount = 0; /* There are many possibilities here to consider: + - Assume YYFAIL is not used. It's too flawed to consider. See + <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html> + for details. YYERROR is fine as it does not invoke this + function. - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected @@ -1749,7 +1956,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; @@ -1816,18 +2023,26 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | Release the memory associated to this symbol. | `-----------------------------------------------*/ +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct FILE_INFO *ip_file) +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif { YYUSE (yyvaluep); - YYUSE (ip_file); + if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); - YY_IGNORE_MAYBE_UNINITIALIZED_END } @@ -1836,8 +2051,18 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct FILE_INFO * /* The lookahead symbol. */ int yychar; + +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + /* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; +YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); + /* Number of syntax errors so far. */ int yynerrs; @@ -1846,16 +2071,35 @@ int yynerrs; | yyparse. | `----------*/ +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else int -yyparse (struct FILE_INFO *ip_file) +yyparse () + +#endif +#endif { int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. + `yyss': related to states. + `yyvs': related to semantic values. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ @@ -1923,23 +2167,23 @@ yyparse (struct FILE_INFO *ip_file) #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE @@ -1947,22 +2191,22 @@ yyparse (struct FILE_INFO *ip_file) # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -1971,10 +2215,10 @@ yyparse (struct FILE_INFO *ip_file) yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -2003,7 +2247,7 @@ yybackup: if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); - yychar = yylex (ip_file); + yychar = YYLEX; } if (yychar <= YYEOF) @@ -2068,7 +2312,7 @@ yyreduce: yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: - '$$ = $1'. + `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison @@ -2082,1257 +2326,1277 @@ yyreduce: switch (yyn) { case 5: -#line 373 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 373 "../../ntpd/ntp_parser.y" { /* I will need to incorporate much more fine grained * error messages. The following should suffice for * the time being. */ - msyslog(LOG_ERR, + struct FILE_INFO * ip_ctx = lex_current(); + msyslog(LOG_ERR, "syntax error in %s line %d, column %d", - ip_file->fname, - ip_file->err_line_no, - ip_file->err_col_no); + ip_ctx->fname, + ip_ctx->errpos.nline, + ip_ctx->errpos.ncol); } -#line 2098 "ntp_parser.c" /* yacc.c:1646 */ break; case 20: -#line 408 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 409 "../../ntpd/ntp_parser.y" { peer_node *my_node; - my_node = create_peer_node((yyvsp[-2].Integer), (yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo)); + my_node = create_peer_node((yyvsp[(1) - (3)].Integer), (yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Attr_val_fifo)); APPEND_G_FIFO(cfgt.peers, my_node); } -#line 2109 "ntp_parser.c" /* yacc.c:1646 */ break; case 27: -#line 427 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Address_node) = create_address_node((yyvsp[0].String), (yyvsp[-1].Integer)); } -#line 2115 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 428 "../../ntpd/ntp_parser.y" + { (yyval.Address_node) = create_address_node((yyvsp[(2) - (2)].String), (yyvsp[(1) - (2)].Integer)); } break; case 28: -#line 432 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Address_node) = create_address_node((yyvsp[0].String), AF_UNSPEC); } -#line 2121 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 433 "../../ntpd/ntp_parser.y" + { (yyval.Address_node) = create_address_node((yyvsp[(1) - (1)].String), AF_UNSPEC); } break; case 29: -#line 437 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 438 "../../ntpd/ntp_parser.y" { (yyval.Integer) = AF_INET; } -#line 2127 "ntp_parser.c" /* yacc.c:1646 */ break; case 30: -#line 439 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 440 "../../ntpd/ntp_parser.y" { (yyval.Integer) = AF_INET6; } -#line 2133 "ntp_parser.c" /* yacc.c:1646 */ break; case 31: -#line 444 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 445 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; } -#line 2139 "ntp_parser.c" /* yacc.c:1646 */ break; case 32: -#line 446 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 447 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 2148 "ntp_parser.c" /* yacc.c:1646 */ break; case 36: -#line 460 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); } -#line 2154 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 461 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 45: -#line 476 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } -#line 2160 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 477 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 46: -#line 478 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_uval((yyvsp[-1].Integer), (yyvsp[0].Integer)); } -#line 2166 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 479 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_uval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 53: -#line 492 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); } -#line 2172 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 493 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } break; case 55: -#line 506 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 507 "../../ntpd/ntp_parser.y" { unpeer_node *my_node; - - my_node = create_unpeer_node((yyvsp[0].Address_node)); + + my_node = create_unpeer_node((yyvsp[(2) - (2)].Address_node)); if (my_node) APPEND_G_FIFO(cfgt.unpeers, my_node); } -#line 2184 "ntp_parser.c" /* yacc.c:1646 */ break; case 58: -#line 527 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 528 "../../ntpd/ntp_parser.y" { cfgt.broadcastclient = 1; } -#line 2190 "ntp_parser.c" /* yacc.c:1646 */ break; case 59: -#line 529 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.manycastserver, (yyvsp[0].Address_fifo)); } -#line 2196 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 530 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.manycastserver, (yyvsp[(2) - (2)].Address_fifo)); } break; case 60: -#line 531 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.multicastclient, (yyvsp[0].Address_fifo)); } -#line 2202 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 532 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.multicastclient, (yyvsp[(2) - (2)].Address_fifo)); } break; case 61: -#line 533 "ntp_parser.y" /* yacc.c:1646 */ - { cfgt.mdnstries = (yyvsp[0].Integer); } -#line 2208 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 534 "../../ntpd/ntp_parser.y" + { cfgt.mdnstries = (yyvsp[(2) - (2)].Integer); } break; case 62: -#line 544 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 545 "../../ntpd/ntp_parser.y" { attr_val *atrv; - - atrv = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); + + atrv = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); APPEND_G_FIFO(cfgt.vars, atrv); } -#line 2219 "ntp_parser.c" /* yacc.c:1646 */ break; case 63: -#line 551 "ntp_parser.y" /* yacc.c:1646 */ - { cfgt.auth.control_key = (yyvsp[0].Integer); } -#line 2225 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 552 "../../ntpd/ntp_parser.y" + { cfgt.auth.control_key = (yyvsp[(2) - (2)].Integer); } break; case 64: -#line 553 "ntp_parser.y" /* yacc.c:1646 */ - { +/* Line 1787 of yacc.c */ +#line 554 "../../ntpd/ntp_parser.y" + { cfgt.auth.cryptosw++; - CONCAT_G_FIFOS(cfgt.auth.crypto_cmd_list, (yyvsp[0].Attr_val_fifo)); + CONCAT_G_FIFOS(cfgt.auth.crypto_cmd_list, (yyvsp[(2) - (2)].Attr_val_fifo)); } -#line 2234 "ntp_parser.c" /* yacc.c:1646 */ break; case 65: -#line 558 "ntp_parser.y" /* yacc.c:1646 */ - { cfgt.auth.keys = (yyvsp[0].String); } -#line 2240 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 559 "../../ntpd/ntp_parser.y" + { cfgt.auth.keys = (yyvsp[(2) - (2)].String); } break; case 66: -#line 560 "ntp_parser.y" /* yacc.c:1646 */ - { cfgt.auth.keysdir = (yyvsp[0].String); } -#line 2246 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 561 "../../ntpd/ntp_parser.y" + { cfgt.auth.keysdir = (yyvsp[(2) - (2)].String); } break; case 67: -#line 562 "ntp_parser.y" /* yacc.c:1646 */ - { cfgt.auth.request_key = (yyvsp[0].Integer); } -#line 2252 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 563 "../../ntpd/ntp_parser.y" + { cfgt.auth.request_key = (yyvsp[(2) - (2)].Integer); } break; case 68: -#line 564 "ntp_parser.y" /* yacc.c:1646 */ - { cfgt.auth.revoke = (yyvsp[0].Integer); } -#line 2258 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 565 "../../ntpd/ntp_parser.y" + { cfgt.auth.revoke = (yyvsp[(2) - (2)].Integer); } break; case 69: -#line 566 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 567 "../../ntpd/ntp_parser.y" { - cfgt.auth.trusted_key_list = (yyvsp[0].Attr_val_fifo); + cfgt.auth.trusted_key_list = (yyvsp[(2) - (2)].Attr_val_fifo); // if (!cfgt.auth.trusted_key_list) // cfgt.auth.trusted_key_list = $2; // else // LINK_SLIST(cfgt.auth.trusted_key_list, $2, link); } -#line 2271 "ntp_parser.c" /* yacc.c:1646 */ break; case 70: -#line 575 "ntp_parser.y" /* yacc.c:1646 */ - { cfgt.auth.ntp_signd_socket = (yyvsp[0].String); } -#line 2277 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 576 "../../ntpd/ntp_parser.y" + { cfgt.auth.ntp_signd_socket = (yyvsp[(2) - (2)].String); } break; case 71: -#line 580 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 581 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; } -#line 2283 "ntp_parser.c" /* yacc.c:1646 */ break; case 72: -#line 582 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 583 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 2292 "ntp_parser.c" /* yacc.c:1646 */ break; case 73: -#line 590 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); } -#line 2298 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 591 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } break; case 74: -#line 592 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 593 "../../ntpd/ntp_parser.y" { (yyval.Attr_val) = NULL; - cfgt.auth.revoke = (yyvsp[0].Integer); + cfgt.auth.revoke = (yyvsp[(2) - (2)].Integer); msyslog(LOG_WARNING, "'crypto revoke %d' is deprecated, " "please use 'revoke %d' instead.", cfgt.auth.revoke, cfgt.auth.revoke); } -#line 2311 "ntp_parser.c" /* yacc.c:1646 */ break; case 80: -#line 617 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.orphan_cmds, (yyvsp[0].Attr_val_fifo)); } -#line 2317 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 618 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.orphan_cmds, (yyvsp[(2) - (2)].Attr_val_fifo)); } break; case 81: -#line 622 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 623 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 2326 "ntp_parser.c" /* yacc.c:1646 */ break; case 82: -#line 627 "ntp_parser.y" /* yacc.c:1646 */ - { +/* Line 1787 of yacc.c */ +#line 628 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); } -#line 2335 "ntp_parser.c" /* yacc.c:1646 */ break; case 83: -#line 635 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (double)(yyvsp[0].Integer)); } -#line 2341 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 636 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (double)(yyvsp[(2) - (2)].Integer)); } break; case 84: -#line 637 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); } -#line 2347 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 638 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 85: -#line 639 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (double)(yyvsp[0].Integer)); } -#line 2353 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 640 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (double)(yyvsp[(2) - (2)].Integer)); } break; case 96: -#line 665 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.stats_list, (yyvsp[0].Int_fifo)); } -#line 2359 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 666 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.stats_list, (yyvsp[(2) - (2)].Int_fifo)); } break; case 97: -#line 667 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 668 "../../ntpd/ntp_parser.y" { - if (input_from_file) { - cfgt.stats_dir = (yyvsp[0].String); + if (lex_from_file()) { + cfgt.stats_dir = (yyvsp[(2) - (2)].String); } else { - YYFREE((yyvsp[0].String)); - yyerror(ip_file, "statsdir remote configuration ignored"); + YYFREE((yyvsp[(2) - (2)].String)); + yyerror("statsdir remote configuration ignored"); } } -#line 2372 "ntp_parser.c" /* yacc.c:1646 */ break; case 98: -#line 676 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 677 "../../ntpd/ntp_parser.y" { filegen_node *fgn; - - fgn = create_filegen_node((yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo)); + + fgn = create_filegen_node((yyvsp[(2) - (3)].Integer), (yyvsp[(3) - (3)].Attr_val_fifo)); APPEND_G_FIFO(cfgt.filegen_opts, fgn); } -#line 2383 "ntp_parser.c" /* yacc.c:1646 */ break; case 99: -#line 686 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 687 "../../ntpd/ntp_parser.y" { - (yyval.Int_fifo) = (yyvsp[-1].Int_fifo); - APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); + (yyval.Int_fifo) = (yyvsp[(1) - (2)].Int_fifo); + APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(2) - (2)].Integer))); } -#line 2392 "ntp_parser.c" /* yacc.c:1646 */ break; case 100: -#line 691 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 692 "../../ntpd/ntp_parser.y" { (yyval.Int_fifo) = NULL; - APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); + APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(1) - (1)].Integer))); } -#line 2401 "ntp_parser.c" /* yacc.c:1646 */ break; case 109: -#line 710 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 711 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; } -#line 2407 "ntp_parser.c" /* yacc.c:1646 */ break; case 110: -#line 712 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 713 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 2416 "ntp_parser.c" /* yacc.c:1646 */ break; case 111: -#line 720 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 721 "../../ntpd/ntp_parser.y" { - if (input_from_file) { - (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); + if (lex_from_file()) { + (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } else { (yyval.Attr_val) = NULL; - YYFREE((yyvsp[0].String)); - yyerror(ip_file, "filegen file remote config ignored"); + YYFREE((yyvsp[(2) - (2)].String)); + yyerror("filegen file remote config ignored"); } } -#line 2430 "ntp_parser.c" /* yacc.c:1646 */ break; case 112: -#line 730 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 731 "../../ntpd/ntp_parser.y" { - if (input_from_file) { - (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); + if (lex_from_file()) { + (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } else { (yyval.Attr_val) = NULL; - yyerror(ip_file, "filegen type remote config ignored"); + yyerror("filegen type remote config ignored"); } } -#line 2443 "ntp_parser.c" /* yacc.c:1646 */ break; case 113: -#line 739 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 740 "../../ntpd/ntp_parser.y" { const char *err; - - if (input_from_file) { - (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); + + if (lex_from_file()) { + (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } else { (yyval.Attr_val) = NULL; - if (T_Link == (yyvsp[0].Integer)) + if (T_Link == (yyvsp[(1) - (1)].Integer)) err = "filegen link remote config ignored"; else err = "filegen nolink remote config ignored"; - yyerror(ip_file, err); + yyerror(err); } } -#line 2462 "ntp_parser.c" /* yacc.c:1646 */ break; case 114: -#line 754 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); } -#line 2468 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 755 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 126: -#line 784 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 785 "../../ntpd/ntp_parser.y" { - CONCAT_G_FIFOS(cfgt.discard_opts, (yyvsp[0].Attr_val_fifo)); + CONCAT_G_FIFOS(cfgt.discard_opts, (yyvsp[(2) - (2)].Attr_val_fifo)); } -#line 2476 "ntp_parser.c" /* yacc.c:1646 */ break; case 127: -#line 788 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 789 "../../ntpd/ntp_parser.y" { - CONCAT_G_FIFOS(cfgt.mru_opts, (yyvsp[0].Attr_val_fifo)); + CONCAT_G_FIFOS(cfgt.mru_opts, (yyvsp[(2) - (2)].Attr_val_fifo)); } -#line 2484 "ntp_parser.c" /* yacc.c:1646 */ break; case 128: -#line 792 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 793 "../../ntpd/ntp_parser.y" { restrict_node *rn; - rn = create_restrict_node((yyvsp[-1].Address_node), NULL, (yyvsp[0].Int_fifo), - ip_file->line_no); + rn = create_restrict_node((yyvsp[(2) - (3)].Address_node), NULL, (yyvsp[(3) - (3)].Int_fifo), + lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } -#line 2496 "ntp_parser.c" /* yacc.c:1646 */ break; case 129: -#line 800 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 801 "../../ntpd/ntp_parser.y" { restrict_node *rn; - rn = create_restrict_node((yyvsp[-3].Address_node), (yyvsp[-1].Address_node), (yyvsp[0].Int_fifo), - ip_file->line_no); + rn = create_restrict_node((yyvsp[(2) - (5)].Address_node), (yyvsp[(4) - (5)].Address_node), (yyvsp[(5) - (5)].Int_fifo), + lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } -#line 2508 "ntp_parser.c" /* yacc.c:1646 */ break; case 130: -#line 808 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 809 "../../ntpd/ntp_parser.y" { restrict_node *rn; - rn = create_restrict_node(NULL, NULL, (yyvsp[0].Int_fifo), - ip_file->line_no); + rn = create_restrict_node(NULL, NULL, (yyvsp[(3) - (3)].Int_fifo), + lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } -#line 2520 "ntp_parser.c" /* yacc.c:1646 */ break; case 131: -#line 816 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 817 "../../ntpd/ntp_parser.y" { restrict_node *rn; rn = create_restrict_node( create_address_node( - estrdup("0.0.0.0"), + estrdup("0.0.0.0"), AF_INET), create_address_node( - estrdup("0.0.0.0"), + estrdup("0.0.0.0"), AF_INET), - (yyvsp[0].Int_fifo), - ip_file->line_no); + (yyvsp[(4) - (4)].Int_fifo), + lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } -#line 2539 "ntp_parser.c" /* yacc.c:1646 */ break; case 132: -#line 831 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 832 "../../ntpd/ntp_parser.y" { restrict_node *rn; - + rn = create_restrict_node( create_address_node( - estrdup("::"), + estrdup("::"), AF_INET6), create_address_node( - estrdup("::"), + estrdup("::"), AF_INET6), - (yyvsp[0].Int_fifo), - ip_file->line_no); + (yyvsp[(4) - (4)].Int_fifo), + lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } -#line 2558 "ntp_parser.c" /* yacc.c:1646 */ break; case 133: -#line 846 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 847 "../../ntpd/ntp_parser.y" { restrict_node * rn; - APPEND_G_FIFO((yyvsp[0].Int_fifo), create_int_node((yyvsp[-1].Integer))); + APPEND_G_FIFO((yyvsp[(3) - (3)].Int_fifo), create_int_node((yyvsp[(2) - (3)].Integer))); rn = create_restrict_node( - NULL, NULL, (yyvsp[0].Int_fifo), ip_file->line_no); + NULL, NULL, (yyvsp[(3) - (3)].Int_fifo), lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } -#line 2571 "ntp_parser.c" /* yacc.c:1646 */ break; case 134: -#line 858 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 859 "../../ntpd/ntp_parser.y" { (yyval.Int_fifo) = NULL; } -#line 2577 "ntp_parser.c" /* yacc.c:1646 */ break; case 135: -#line 860 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 861 "../../ntpd/ntp_parser.y" { - (yyval.Int_fifo) = (yyvsp[-1].Int_fifo); - APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); + (yyval.Int_fifo) = (yyvsp[(1) - (2)].Int_fifo); + APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(2) - (2)].Integer))); } -#line 2586 "ntp_parser.c" /* yacc.c:1646 */ break; case 151: -#line 886 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 887 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 2595 "ntp_parser.c" /* yacc.c:1646 */ break; case 152: -#line 891 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 892 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); } -#line 2604 "ntp_parser.c" /* yacc.c:1646 */ break; case 153: -#line 899 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } -#line 2610 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 900 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 157: -#line 910 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 911 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 2619 "ntp_parser.c" /* yacc.c:1646 */ break; case 158: -#line 915 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 916 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); } -#line 2628 "ntp_parser.c" /* yacc.c:1646 */ break; case 159: -#line 923 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } -#line 2634 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 924 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 168: -#line 943 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 944 "../../ntpd/ntp_parser.y" { addr_opts_node *aon; - - aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo)); + + aon = create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Attr_val_fifo)); APPEND_G_FIFO(cfgt.fudge, aon); } -#line 2645 "ntp_parser.c" /* yacc.c:1646 */ break; case 169: -#line 953 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 954 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 2654 "ntp_parser.c" /* yacc.c:1646 */ break; case 170: -#line 958 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 959 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); } -#line 2663 "ntp_parser.c" /* yacc.c:1646 */ break; case 171: -#line 966 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); } -#line 2669 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 967 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 172: -#line 968 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } -#line 2675 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 969 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 173: -#line 970 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } -#line 2681 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 971 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 174: -#line 972 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); } -#line 2687 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 973 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } break; case 175: -#line 974 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); } -#line 2693 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 975 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } break; case 182: -#line 995 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.rlimit, (yyvsp[0].Attr_val_fifo)); } -#line 2699 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 996 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.rlimit, (yyvsp[(2) - (2)].Attr_val_fifo)); } break; case 183: -#line 1000 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1001 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 2708 "ntp_parser.c" /* yacc.c:1646 */ break; case 184: -#line 1005 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1006 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); } -#line 2717 "ntp_parser.c" /* yacc.c:1646 */ break; case 185: -#line 1013 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } -#line 2723 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1014 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; case 189: -#line 1029 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.enable_opts, (yyvsp[0].Attr_val_fifo)); } -#line 2729 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1030 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.enable_opts, (yyvsp[(2) - (2)].Attr_val_fifo)); } break; case 190: -#line 1031 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.disable_opts, (yyvsp[0].Attr_val_fifo)); } -#line 2735 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1032 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.disable_opts, (yyvsp[(2) - (2)].Attr_val_fifo)); } break; case 191: -#line 1036 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1037 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 2744 "ntp_parser.c" /* yacc.c:1646 */ break; case 192: -#line 1041 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1042 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); } -#line 2753 "ntp_parser.c" /* yacc.c:1646 */ break; case 193: -#line 1049 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); } -#line 2759 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1050 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } break; case 194: -#line 1051 "ntp_parser.y" /* yacc.c:1646 */ - { - if (input_from_file) { - (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); +/* Line 1787 of yacc.c */ +#line 1052 "../../ntpd/ntp_parser.y" + { + if (lex_from_file()) { + (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } else { char err_str[128]; - + (yyval.Attr_val) = NULL; snprintf(err_str, sizeof(err_str), "enable/disable %s remote configuration ignored", - keyword((yyvsp[0].Integer))); - yyerror(ip_file, err_str); + keyword((yyvsp[(1) - (1)].Integer))); + yyerror(err_str); } } -#line 2777 "ntp_parser.c" /* yacc.c:1646 */ break; case 203: -#line 1086 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.tinker, (yyvsp[0].Attr_val_fifo)); } -#line 2783 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1087 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.tinker, (yyvsp[(2) - (2)].Attr_val_fifo)); } break; case 204: -#line 1091 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1092 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 2792 "ntp_parser.c" /* yacc.c:1646 */ break; case 205: -#line 1096 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1097 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); } -#line 2801 "ntp_parser.c" /* yacc.c:1646 */ break; case 206: -#line 1104 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); } -#line 2807 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1105 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } break; case 219: -#line 1129 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1130 "../../ntpd/ntp_parser.y" { attr_val *av; - - av = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); + + av = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); APPEND_G_FIFO(cfgt.vars, av); } -#line 2818 "ntp_parser.c" /* yacc.c:1646 */ break; case 220: -#line 1136 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1137 "../../ntpd/ntp_parser.y" { attr_val *av; - - av = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); + + av = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); APPEND_G_FIFO(cfgt.vars, av); } -#line 2829 "ntp_parser.c" /* yacc.c:1646 */ break; case 221: -#line 1143 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1144 "../../ntpd/ntp_parser.y" + { + attr_val *av; + + av = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); + APPEND_G_FIFO(cfgt.vars, av); + } + break; + + case 222: +/* Line 1787 of yacc.c */ +#line 1151 "../../ntpd/ntp_parser.y" { char error_text[64]; attr_val *av; - if (input_from_file) { - av = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); + if (lex_from_file()) { + av = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); APPEND_G_FIFO(cfgt.vars, av); } else { - YYFREE((yyvsp[0].String)); + YYFREE((yyvsp[(2) - (2)].String)); snprintf(error_text, sizeof(error_text), "%s remote config ignored", - keyword((yyvsp[-1].Integer))); - yyerror(ip_file, error_text); + keyword((yyvsp[(1) - (2)].Integer))); + yyerror(error_text); } } -#line 2849 "ntp_parser.c" /* yacc.c:1646 */ break; - case 222: -#line 1159 "ntp_parser.y" /* yacc.c:1646 */ + case 223: +/* Line 1787 of yacc.c */ +#line 1167 "../../ntpd/ntp_parser.y" { - if (!input_from_file) { - yyerror(ip_file, "remote includefile ignored"); + if (!lex_from_file()) { + YYFREE((yyvsp[(2) - (3)].String)); /* avoid leak */ + yyerror("remote includefile ignored"); break; } - if (curr_include_level >= MAXINCLUDELEVEL) { + if (lex_level() > MAXINCLUDELEVEL) { fprintf(stderr, "getconfig: Maximum include file level exceeded.\n"); msyslog(LOG_ERR, "getconfig: Maximum include file level exceeded."); } else { - fp[curr_include_level + 1] = F_OPEN(FindConfig((yyvsp[-1].String)), "r"); - if (fp[curr_include_level + 1] == NULL) { - fprintf(stderr, "getconfig: Couldn't open <%s>\n", FindConfig((yyvsp[-1].String))); - msyslog(LOG_ERR, "getconfig: Couldn't open <%s>", FindConfig((yyvsp[-1].String))); - } else { - ip_file = fp[++curr_include_level]; + const char * path = FindConfig((yyvsp[(2) - (3)].String)); /* might return $2! */ + if (!lex_push_file(path, "r")) { + fprintf(stderr, "getconfig: Couldn't open <%s>\n", path); + msyslog(LOG_ERR, "getconfig: Couldn't open <%s>", path); } } + YYFREE((yyvsp[(2) - (3)].String)); /* avoid leak */ } -#line 2872 "ntp_parser.c" /* yacc.c:1646 */ - break; - - case 223: -#line 1178 "ntp_parser.y" /* yacc.c:1646 */ - { - while (curr_include_level != -1) - FCLOSE(fp[curr_include_level--]); - } -#line 2881 "ntp_parser.c" /* yacc.c:1646 */ break; case 224: -#line 1183 "ntp_parser.y" /* yacc.c:1646 */ - { /* see drift_parm below for actions */ } -#line 2887 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1186 "../../ntpd/ntp_parser.y" + { lex_flush_stack(); } break; case 225: -#line 1185 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.logconfig, (yyvsp[0].Attr_val_fifo)); } -#line 2893 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1188 "../../ntpd/ntp_parser.y" + { /* see drift_parm below for actions */ } break; case 226: -#line 1187 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.phone, (yyvsp[0].String_fifo)); } -#line 2899 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1190 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.logconfig, (yyvsp[(2) - (2)].Attr_val_fifo)); } break; case 227: -#line 1189 "ntp_parser.y" /* yacc.c:1646 */ - { APPEND_G_FIFO(cfgt.setvar, (yyvsp[0].Set_var)); } -#line 2905 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1192 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.phone, (yyvsp[(2) - (2)].String_fifo)); } break; case 228: -#line 1191 "ntp_parser.y" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 1194 "../../ntpd/ntp_parser.y" + { APPEND_G_FIFO(cfgt.setvar, (yyvsp[(2) - (2)].Set_var)); } + break; + + case 229: +/* Line 1787 of yacc.c */ +#line 1196 "../../ntpd/ntp_parser.y" { addr_opts_node *aon; - - aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo)); + + aon = create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Attr_val_fifo)); APPEND_G_FIFO(cfgt.trap, aon); } -#line 2916 "ntp_parser.c" /* yacc.c:1646 */ break; - case 229: -#line 1198 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.ttl, (yyvsp[0].Attr_val_fifo)); } -#line 2922 "ntp_parser.c" /* yacc.c:1646 */ + case 230: +/* Line 1787 of yacc.c */ +#line 1203 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.ttl, (yyvsp[(2) - (2)].Attr_val_fifo)); } + break; + + case 235: +/* Line 1787 of yacc.c */ +#line 1218 "../../ntpd/ntp_parser.y" + { +#ifndef LEAP_SMEAR + yyerror("Built without LEAP_SMEAR support."); +#endif + } break; - case 238: -#line 1220 "ntp_parser.y" /* yacc.c:1646 */ + case 241: +/* Line 1787 of yacc.c */ +#line 1238 "../../ntpd/ntp_parser.y" { attr_val *av; - - av = create_attr_sval(T_Driftfile, (yyvsp[0].String)); + + av = create_attr_sval(T_Driftfile, (yyvsp[(1) - (1)].String)); APPEND_G_FIFO(cfgt.vars, av); } -#line 2933 "ntp_parser.c" /* yacc.c:1646 */ break; - case 239: -#line 1227 "ntp_parser.y" /* yacc.c:1646 */ + case 242: +/* Line 1787 of yacc.c */ +#line 1245 "../../ntpd/ntp_parser.y" { attr_val *av; - - av = create_attr_sval(T_Driftfile, (yyvsp[-1].String)); + + av = create_attr_sval(T_Driftfile, (yyvsp[(1) - (2)].String)); APPEND_G_FIFO(cfgt.vars, av); - av = create_attr_dval(T_WanderThreshold, (yyvsp[0].Double)); + av = create_attr_dval(T_WanderThreshold, (yyvsp[(2) - (2)].Double)); APPEND_G_FIFO(cfgt.vars, av); } -#line 2946 "ntp_parser.c" /* yacc.c:1646 */ break; - case 240: -#line 1236 "ntp_parser.y" /* yacc.c:1646 */ + case 243: +/* Line 1787 of yacc.c */ +#line 1254 "../../ntpd/ntp_parser.y" { attr_val *av; - + av = create_attr_sval(T_Driftfile, ""); APPEND_G_FIFO(cfgt.vars, av); } -#line 2957 "ntp_parser.c" /* yacc.c:1646 */ break; - case 241: -#line 1246 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Set_var) = create_setvar_node((yyvsp[-3].String), (yyvsp[-1].String), (yyvsp[0].Integer)); } -#line 2963 "ntp_parser.c" /* yacc.c:1646 */ + case 244: +/* Line 1787 of yacc.c */ +#line 1264 "../../ntpd/ntp_parser.y" + { (yyval.Set_var) = create_setvar_node((yyvsp[(1) - (4)].String), (yyvsp[(3) - (4)].String), (yyvsp[(4) - (4)].Integer)); } break; - case 243: -#line 1252 "ntp_parser.y" /* yacc.c:1646 */ + case 246: +/* Line 1787 of yacc.c */ +#line 1270 "../../ntpd/ntp_parser.y" { (yyval.Integer) = 0; } -#line 2969 "ntp_parser.c" /* yacc.c:1646 */ break; - case 244: -#line 1257 "ntp_parser.y" /* yacc.c:1646 */ + case 247: +/* Line 1787 of yacc.c */ +#line 1275 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; } -#line 2975 "ntp_parser.c" /* yacc.c:1646 */ break; - case 245: -#line 1259 "ntp_parser.y" /* yacc.c:1646 */ + case 248: +/* Line 1787 of yacc.c */ +#line 1277 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 2984 "ntp_parser.c" /* yacc.c:1646 */ break; - case 246: -#line 1267 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } -#line 2990 "ntp_parser.c" /* yacc.c:1646 */ + case 249: +/* Line 1787 of yacc.c */ +#line 1285 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } break; - case 247: -#line 1269 "ntp_parser.y" /* yacc.c:1646 */ + case 250: +/* Line 1787 of yacc.c */ +#line 1287 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), estrdup((yyvsp[0].Address_node)->address)); - destroy_address_node((yyvsp[0].Address_node)); + (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), estrdup((yyvsp[(2) - (2)].Address_node)->address)); + destroy_address_node((yyvsp[(2) - (2)].Address_node)); } -#line 2999 "ntp_parser.c" /* yacc.c:1646 */ break; - case 248: -#line 1277 "ntp_parser.y" /* yacc.c:1646 */ + case 251: +/* Line 1787 of yacc.c */ +#line 1295 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 3008 "ntp_parser.c" /* yacc.c:1646 */ break; - case 249: -#line 1282 "ntp_parser.y" /* yacc.c:1646 */ + case 252: +/* Line 1787 of yacc.c */ +#line 1300 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); } -#line 3017 "ntp_parser.c" /* yacc.c:1646 */ break; - case 250: -#line 1290 "ntp_parser.y" /* yacc.c:1646 */ + case 253: +/* Line 1787 of yacc.c */ +#line 1308 "../../ntpd/ntp_parser.y" { char prefix; char * type; - - switch ((yyvsp[0].String)[0]) { - + + switch ((yyvsp[(1) - (1)].String)[0]) { + case '+': case '-': case '=': - prefix = (yyvsp[0].String)[0]; - type = (yyvsp[0].String) + 1; + prefix = (yyvsp[(1) - (1)].String)[0]; + type = (yyvsp[(1) - (1)].String) + 1; break; - + default: prefix = '='; - type = (yyvsp[0].String); - } - + type = (yyvsp[(1) - (1)].String); + } + (yyval.Attr_val) = create_attr_sval(prefix, estrdup(type)); - YYFREE((yyvsp[0].String)); + YYFREE((yyvsp[(1) - (1)].String)); } -#line 3043 "ntp_parser.c" /* yacc.c:1646 */ break; - case 251: -#line 1315 "ntp_parser.y" /* yacc.c:1646 */ + case 254: +/* Line 1787 of yacc.c */ +#line 1333 "../../ntpd/ntp_parser.y" { nic_rule_node *nrn; - - nrn = create_nic_rule_node((yyvsp[0].Integer), NULL, (yyvsp[-1].Integer)); + + nrn = create_nic_rule_node((yyvsp[(3) - (3)].Integer), NULL, (yyvsp[(2) - (3)].Integer)); APPEND_G_FIFO(cfgt.nic_rules, nrn); } -#line 3054 "ntp_parser.c" /* yacc.c:1646 */ break; - case 252: -#line 1322 "ntp_parser.y" /* yacc.c:1646 */ + case 255: +/* Line 1787 of yacc.c */ +#line 1340 "../../ntpd/ntp_parser.y" { nic_rule_node *nrn; - - nrn = create_nic_rule_node(0, (yyvsp[0].String), (yyvsp[-1].Integer)); + + nrn = create_nic_rule_node(0, (yyvsp[(3) - (3)].String), (yyvsp[(2) - (3)].Integer)); APPEND_G_FIFO(cfgt.nic_rules, nrn); } -#line 3065 "ntp_parser.c" /* yacc.c:1646 */ break; - case 262: -#line 1350 "ntp_parser.y" /* yacc.c:1646 */ - { CONCAT_G_FIFOS(cfgt.reset_counters, (yyvsp[0].Int_fifo)); } -#line 3071 "ntp_parser.c" /* yacc.c:1646 */ + case 265: +/* Line 1787 of yacc.c */ +#line 1368 "../../ntpd/ntp_parser.y" + { CONCAT_G_FIFOS(cfgt.reset_counters, (yyvsp[(2) - (2)].Int_fifo)); } break; - case 263: -#line 1355 "ntp_parser.y" /* yacc.c:1646 */ + case 266: +/* Line 1787 of yacc.c */ +#line 1373 "../../ntpd/ntp_parser.y" { - (yyval.Int_fifo) = (yyvsp[-1].Int_fifo); - APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); + (yyval.Int_fifo) = (yyvsp[(1) - (2)].Int_fifo); + APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(2) - (2)].Integer))); } -#line 3080 "ntp_parser.c" /* yacc.c:1646 */ break; - case 264: -#line 1360 "ntp_parser.y" /* yacc.c:1646 */ + case 267: +/* Line 1787 of yacc.c */ +#line 1378 "../../ntpd/ntp_parser.y" { (yyval.Int_fifo) = NULL; - APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); + APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(1) - (1)].Integer))); } -#line 3089 "ntp_parser.c" /* yacc.c:1646 */ break; - case 272: -#line 1384 "ntp_parser.y" /* yacc.c:1646 */ + case 275: +/* Line 1787 of yacc.c */ +#line 1402 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer))); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[(2) - (2)].Integer))); } -#line 3098 "ntp_parser.c" /* yacc.c:1646 */ break; - case 273: -#line 1389 "ntp_parser.y" /* yacc.c:1646 */ + case 276: +/* Line 1787 of yacc.c */ +#line 1407 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer))); + APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[(1) - (1)].Integer))); } -#line 3107 "ntp_parser.c" /* yacc.c:1646 */ break; - case 274: -#line 1397 "ntp_parser.y" /* yacc.c:1646 */ + case 277: +/* Line 1787 of yacc.c */ +#line 1415 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); } -#line 3116 "ntp_parser.c" /* yacc.c:1646 */ break; - case 275: -#line 1402 "ntp_parser.y" /* yacc.c:1646 */ + case 278: +/* Line 1787 of yacc.c */ +#line 1420 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); } -#line 3125 "ntp_parser.c" /* yacc.c:1646 */ break; - case 276: -#line 1410 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_ival('i', (yyvsp[0].Integer)); } -#line 3131 "ntp_parser.c" /* yacc.c:1646 */ + case 279: +/* Line 1787 of yacc.c */ +#line 1428 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_ival('i', (yyvsp[(1) - (1)].Integer)); } break; - case 278: -#line 1416 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_rangeval('-', (yyvsp[-3].Integer), (yyvsp[-1].Integer)); } -#line 3137 "ntp_parser.c" /* yacc.c:1646 */ + case 281: +/* Line 1787 of yacc.c */ +#line 1434 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_rangeval('-', (yyvsp[(2) - (5)].Integer), (yyvsp[(4) - (5)].Integer)); } break; - case 279: -#line 1421 "ntp_parser.y" /* yacc.c:1646 */ + case 282: +/* Line 1787 of yacc.c */ +#line 1439 "../../ntpd/ntp_parser.y" { - (yyval.String_fifo) = (yyvsp[-1].String_fifo); - APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String))); + (yyval.String_fifo) = (yyvsp[(1) - (2)].String_fifo); + APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[(2) - (2)].String))); } -#line 3146 "ntp_parser.c" /* yacc.c:1646 */ break; - case 280: -#line 1426 "ntp_parser.y" /* yacc.c:1646 */ + case 283: +/* Line 1787 of yacc.c */ +#line 1444 "../../ntpd/ntp_parser.y" { (yyval.String_fifo) = NULL; - APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String))); + APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[(1) - (1)].String))); } -#line 3155 "ntp_parser.c" /* yacc.c:1646 */ break; - case 281: -#line 1434 "ntp_parser.y" /* yacc.c:1646 */ + case 284: +/* Line 1787 of yacc.c */ +#line 1452 "../../ntpd/ntp_parser.y" { - (yyval.Address_fifo) = (yyvsp[-1].Address_fifo); - APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node)); + (yyval.Address_fifo) = (yyvsp[(1) - (2)].Address_fifo); + APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[(2) - (2)].Address_node)); } -#line 3164 "ntp_parser.c" /* yacc.c:1646 */ break; - case 282: -#line 1439 "ntp_parser.y" /* yacc.c:1646 */ + case 285: +/* Line 1787 of yacc.c */ +#line 1457 "../../ntpd/ntp_parser.y" { (yyval.Address_fifo) = NULL; - APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node)); + APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[(1) - (1)].Address_node)); } -#line 3173 "ntp_parser.c" /* yacc.c:1646 */ break; - case 283: -#line 1447 "ntp_parser.y" /* yacc.c:1646 */ + case 286: +/* Line 1787 of yacc.c */ +#line 1465 "../../ntpd/ntp_parser.y" { - if ((yyvsp[0].Integer) != 0 && (yyvsp[0].Integer) != 1) { - yyerror(ip_file, "Integer value is not boolean (0 or 1). Assuming 1"); + if ((yyvsp[(1) - (1)].Integer) != 0 && (yyvsp[(1) - (1)].Integer) != 1) { + yyerror("Integer value is not boolean (0 or 1). Assuming 1"); (yyval.Integer) = 1; } else { - (yyval.Integer) = (yyvsp[0].Integer); + (yyval.Integer) = (yyvsp[(1) - (1)].Integer); } } -#line 3186 "ntp_parser.c" /* yacc.c:1646 */ break; - case 284: -#line 1455 "ntp_parser.y" /* yacc.c:1646 */ + case 287: +/* Line 1787 of yacc.c */ +#line 1473 "../../ntpd/ntp_parser.y" { (yyval.Integer) = 1; } -#line 3192 "ntp_parser.c" /* yacc.c:1646 */ break; - case 285: -#line 1456 "ntp_parser.y" /* yacc.c:1646 */ + case 288: +/* Line 1787 of yacc.c */ +#line 1474 "../../ntpd/ntp_parser.y" { (yyval.Integer) = 0; } -#line 3198 "ntp_parser.c" /* yacc.c:1646 */ break; - case 286: -#line 1460 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Double) = (double)(yyvsp[0].Integer); } -#line 3204 "ntp_parser.c" /* yacc.c:1646 */ + case 289: +/* Line 1787 of yacc.c */ +#line 1478 "../../ntpd/ntp_parser.y" + { (yyval.Double) = (double)(yyvsp[(1) - (1)].Integer); } break; - case 288: -#line 1471 "ntp_parser.y" /* yacc.c:1646 */ + case 291: +/* Line 1787 of yacc.c */ +#line 1489 "../../ntpd/ntp_parser.y" { sim_node *sn; - - sn = create_sim_node((yyvsp[-2].Attr_val_fifo), (yyvsp[-1].Sim_server_fifo)); + + sn = create_sim_node((yyvsp[(3) - (5)].Attr_val_fifo), (yyvsp[(4) - (5)].Sim_server_fifo)); APPEND_G_FIFO(cfgt.sim_details, sn); /* Revert from ; to \n for end-of-command */ old_config_style = 1; } -#line 3218 "ntp_parser.c" /* yacc.c:1646 */ break; - case 289: -#line 1488 "ntp_parser.y" /* yacc.c:1646 */ + case 292: +/* Line 1787 of yacc.c */ +#line 1506 "../../ntpd/ntp_parser.y" { old_config_style = 0; } -#line 3224 "ntp_parser.c" /* yacc.c:1646 */ break; - case 290: -#line 1493 "ntp_parser.y" /* yacc.c:1646 */ + case 293: +/* Line 1787 of yacc.c */ +#line 1511 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (3)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (3)].Attr_val)); } -#line 3233 "ntp_parser.c" /* yacc.c:1646 */ break; - case 291: -#line 1498 "ntp_parser.y" /* yacc.c:1646 */ + case 294: +/* Line 1787 of yacc.c */ +#line 1516 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (2)].Attr_val)); } -#line 3242 "ntp_parser.c" /* yacc.c:1646 */ break; - case 292: -#line 1506 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); } -#line 3248 "ntp_parser.c" /* yacc.c:1646 */ + case 295: +/* Line 1787 of yacc.c */ +#line 1524 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); } break; - case 295: -#line 1516 "ntp_parser.y" /* yacc.c:1646 */ + case 298: +/* Line 1787 of yacc.c */ +#line 1534 "../../ntpd/ntp_parser.y" { - (yyval.Sim_server_fifo) = (yyvsp[-1].Sim_server_fifo); - APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server)); + (yyval.Sim_server_fifo) = (yyvsp[(1) - (2)].Sim_server_fifo); + APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[(2) - (2)].Sim_server)); } -#line 3257 "ntp_parser.c" /* yacc.c:1646 */ break; - case 296: -#line 1521 "ntp_parser.y" /* yacc.c:1646 */ + case 299: +/* Line 1787 of yacc.c */ +#line 1539 "../../ntpd/ntp_parser.y" { (yyval.Sim_server_fifo) = NULL; - APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server)); + APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[(1) - (1)].Sim_server)); } -#line 3266 "ntp_parser.c" /* yacc.c:1646 */ break; - case 297: -#line 1529 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Sim_server) = ONLY_SIM(create_sim_server((yyvsp[-4].Address_node), (yyvsp[-2].Double), (yyvsp[-1].Sim_script_fifo))); } -#line 3272 "ntp_parser.c" /* yacc.c:1646 */ + case 300: +/* Line 1787 of yacc.c */ +#line 1547 "../../ntpd/ntp_parser.y" + { (yyval.Sim_server) = ONLY_SIM(create_sim_server((yyvsp[(1) - (5)].Address_node), (yyvsp[(3) - (5)].Double), (yyvsp[(4) - (5)].Sim_script_fifo))); } break; - case 298: -#line 1534 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Double) = (yyvsp[-1].Double); } -#line 3278 "ntp_parser.c" /* yacc.c:1646 */ + case 301: +/* Line 1787 of yacc.c */ +#line 1552 "../../ntpd/ntp_parser.y" + { (yyval.Double) = (yyvsp[(3) - (4)].Double); } break; - case 299: -#line 1539 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Address_node) = (yyvsp[0].Address_node); } -#line 3284 "ntp_parser.c" /* yacc.c:1646 */ + case 302: +/* Line 1787 of yacc.c */ +#line 1557 "../../ntpd/ntp_parser.y" + { (yyval.Address_node) = (yyvsp[(3) - (3)].Address_node); } break; - case 300: -#line 1544 "ntp_parser.y" /* yacc.c:1646 */ + case 303: +/* Line 1787 of yacc.c */ +#line 1562 "../../ntpd/ntp_parser.y" { - (yyval.Sim_script_fifo) = (yyvsp[-1].Sim_script_fifo); - APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script)); + (yyval.Sim_script_fifo) = (yyvsp[(1) - (2)].Sim_script_fifo); + APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[(2) - (2)].Sim_script)); } -#line 3293 "ntp_parser.c" /* yacc.c:1646 */ break; - case 301: -#line 1549 "ntp_parser.y" /* yacc.c:1646 */ + case 304: +/* Line 1787 of yacc.c */ +#line 1567 "../../ntpd/ntp_parser.y" { (yyval.Sim_script_fifo) = NULL; - APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script)); + APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[(1) - (1)].Sim_script)); } -#line 3302 "ntp_parser.c" /* yacc.c:1646 */ break; - case 302: -#line 1557 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Sim_script) = ONLY_SIM(create_sim_script_info((yyvsp[-3].Double), (yyvsp[-1].Attr_val_fifo))); } -#line 3308 "ntp_parser.c" /* yacc.c:1646 */ + case 305: +/* Line 1787 of yacc.c */ +#line 1575 "../../ntpd/ntp_parser.y" + { (yyval.Sim_script) = ONLY_SIM(create_sim_script_info((yyvsp[(3) - (6)].Double), (yyvsp[(5) - (6)].Attr_val_fifo))); } break; - case 303: -#line 1562 "ntp_parser.y" /* yacc.c:1646 */ + case 306: +/* Line 1787 of yacc.c */ +#line 1580 "../../ntpd/ntp_parser.y" { - (yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[(1) - (3)].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (3)].Attr_val)); } -#line 3317 "ntp_parser.c" /* yacc.c:1646 */ break; - case 304: -#line 1567 "ntp_parser.y" /* yacc.c:1646 */ + case 307: +/* Line 1787 of yacc.c */ +#line 1585 "../../ntpd/ntp_parser.y" { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (2)].Attr_val)); } -#line 3326 "ntp_parser.c" /* yacc.c:1646 */ break; - case 305: -#line 1575 "ntp_parser.y" /* yacc.c:1646 */ - { (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); } -#line 3332 "ntp_parser.c" /* yacc.c:1646 */ + case 308: +/* Line 1787 of yacc.c */ +#line 1593 "../../ntpd/ntp_parser.y" + { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); } break; -#line 3336 "ntp_parser.c" /* yacc.c:1646 */ +/* Line 1787 of yacc.c */ +#line 3600 "ntp_parser.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -3354,7 +3618,7 @@ yyreduce: *++yyvsp = yyval; - /* Now 'shift' the result of the reduction. Determine what state + /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -3369,9 +3633,9 @@ yyreduce: goto yynewstate; -/*--------------------------------------. -| yyerrlab -- here on detecting error. | -`--------------------------------------*/ +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ @@ -3382,7 +3646,7 @@ yyerrlab: { ++yynerrs; #if ! YYERROR_VERBOSE - yyerror (ip_file, YY_("syntax error")); + yyerror (YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) @@ -3409,7 +3673,7 @@ yyerrlab: yymsgp = yymsg; } } - yyerror (ip_file, yymsgp); + yyerror (yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } @@ -3422,20 +3686,20 @@ yyerrlab: if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + error, discard it. */ if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } else - { - yydestruct ("Error: discarding", - yytoken, &yylval, ip_file); - yychar = YYEMPTY; - } + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } } /* Else will try to reuse lookahead token after shifting the error @@ -3454,7 +3718,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - /* Do not reclaim the symbols of the rule whose action triggered + /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; @@ -3467,29 +3731,29 @@ yyerrorlab: | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; yydestruct ("Error: popping", - yystos[yystate], yyvsp, ip_file); + yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -3526,7 +3790,7 @@ yyabortlab: | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: - yyerror (ip_file, YY_("memory exhausted")); + yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif @@ -3538,16 +3802,16 @@ yyreturn: user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, ip_file); + yytoken, &yylval); } - /* Do not reclaim the symbols of the rule whose action triggered + /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, ip_file); + yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow @@ -3558,33 +3822,34 @@ yyreturn: if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - return yyresult; + /* Make sure YYID is used. */ + return YYID (yyresult); } -#line 1586 "ntp_parser.y" /* yacc.c:1906 */ -void +/* Line 2050 of yacc.c */ +#line 1604 "../../ntpd/ntp_parser.y" + + +void yyerror( - struct FILE_INFO *ip_file, const char *msg ) { int retval; + struct FILE_INFO * ip_ctx; + + ip_ctx = lex_current(); + ip_ctx->errpos = ip_ctx->tokpos; - ip_file->err_line_no = ip_file->prev_token_line_no; - ip_file->err_col_no = ip_file->prev_token_col_no; - - msyslog(LOG_ERR, - "line %d column %d %s", - ip_file->err_line_no, - ip_file->err_col_no, - msg); - if (!input_from_file) { + msyslog(LOG_ERR, "line %d column %d %s", + ip_ctx->errpos.nline, ip_ctx->errpos.ncol, msg); + if (!lex_from_file()) { /* Save the error message in the correct buffer */ retval = snprintf(remote_config.err_msg + remote_config.err_pos, MAXLINE - remote_config.err_pos, "column %d %s", - ip_file->err_col_no, msg); + ip_ctx->errpos.ncol, msg); /* Increment the value of err_pos */ if (retval > 0) diff --git a/ntpd/ntp_parser.h b/ntpd/ntp_parser.h index 2804e544973cd..b474fc24113c4 100644 --- a/ntpd/ntp_parser.h +++ b/ntpd/ntp_parser.h @@ -1,19 +1,19 @@ -/* A Bison parser, made by GNU Bison 3.0.2. */ +/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. - + + Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -26,13 +26,13 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ #ifndef YY_YY_NTP_PARSER_H_INCLUDED # define YY_YY_NTP_PARSER_H_INCLUDED -/* Debug traces. */ +/* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 #endif @@ -40,201 +40,204 @@ extern int yydebug; #endif -/* Token type. */ +/* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - enum yytokentype - { - T_Abbrev = 258, - T_Age = 259, - T_All = 260, - T_Allan = 261, - T_Allpeers = 262, - T_Auth = 263, - T_Autokey = 264, - T_Automax = 265, - T_Average = 266, - T_Bclient = 267, - T_Beacon = 268, - T_Broadcast = 269, - T_Broadcastclient = 270, - T_Broadcastdelay = 271, - T_Burst = 272, - T_Calibrate = 273, - T_Ceiling = 274, - T_Clockstats = 275, - T_Cohort = 276, - T_ControlKey = 277, - T_Crypto = 278, - T_Cryptostats = 279, - T_Ctl = 280, - T_Day = 281, - T_Default = 282, - T_Digest = 283, - T_Disable = 284, - T_Discard = 285, - T_Dispersion = 286, - T_Double = 287, - T_Driftfile = 288, - T_Drop = 289, - T_Ellipsis = 290, - T_Enable = 291, - T_End = 292, - T_False = 293, - T_File = 294, - T_Filegen = 295, - T_Filenum = 296, - T_Flag1 = 297, - T_Flag2 = 298, - T_Flag3 = 299, - T_Flag4 = 300, - T_Flake = 301, - T_Floor = 302, - T_Freq = 303, - T_Fudge = 304, - T_Host = 305, - T_Huffpuff = 306, - T_Iburst = 307, - T_Ident = 308, - T_Ignore = 309, - T_Incalloc = 310, - T_Incmem = 311, - T_Initalloc = 312, - T_Initmem = 313, - T_Includefile = 314, - T_Integer = 315, - T_Interface = 316, - T_Intrange = 317, - T_Io = 318, - T_Ipv4 = 319, - T_Ipv4_flag = 320, - T_Ipv6 = 321, - T_Ipv6_flag = 322, - T_Kernel = 323, - T_Key = 324, - T_Keys = 325, - T_Keysdir = 326, - T_Kod = 327, - T_Mssntp = 328, - T_Leapfile = 329, - T_Limited = 330, - T_Link = 331, - T_Listen = 332, - T_Logconfig = 333, - T_Logfile = 334, - T_Loopstats = 335, - T_Lowpriotrap = 336, - T_Manycastclient = 337, - T_Manycastserver = 338, - T_Mask = 339, - T_Maxage = 340, - T_Maxclock = 341, - T_Maxdepth = 342, - T_Maxdist = 343, - T_Maxmem = 344, - T_Maxpoll = 345, - T_Mdnstries = 346, - T_Mem = 347, - T_Memlock = 348, - T_Minclock = 349, - T_Mindepth = 350, - T_Mindist = 351, - T_Minimum = 352, - T_Minpoll = 353, - T_Minsane = 354, - T_Mode = 355, - T_Mode7 = 356, - T_Monitor = 357, - T_Month = 358, - T_Mru = 359, - T_Multicastclient = 360, - T_Nic = 361, - T_Nolink = 362, - T_Nomodify = 363, - T_Nomrulist = 364, - T_None = 365, - T_Nonvolatile = 366, - T_Nopeer = 367, - T_Noquery = 368, - T_Noselect = 369, - T_Noserve = 370, - T_Notrap = 371, - T_Notrust = 372, - T_Ntp = 373, - T_Ntpport = 374, - T_NtpSignDsocket = 375, - T_Orphan = 376, - T_Orphanwait = 377, - T_Panic = 378, - T_Peer = 379, - T_Peerstats = 380, - T_Phone = 381, - T_Pid = 382, - T_Pidfile = 383, - T_Pool = 384, - T_Port = 385, - T_Preempt = 386, - T_Prefer = 387, - T_Protostats = 388, - T_Pw = 389, - T_Randfile = 390, - T_Rawstats = 391, - T_Refid = 392, - T_Requestkey = 393, - T_Reset = 394, - T_Restrict = 395, - T_Revoke = 396, - T_Rlimit = 397, - T_Saveconfigdir = 398, - T_Server = 399, - T_Setvar = 400, - T_Source = 401, - T_Stacksize = 402, - T_Statistics = 403, - T_Stats = 404, - T_Statsdir = 405, - T_Step = 406, - T_Stepback = 407, - T_Stepfwd = 408, - T_Stepout = 409, - T_Stratum = 410, - T_String = 411, - T_Sys = 412, - T_Sysstats = 413, - T_Tick = 414, - T_Time1 = 415, - T_Time2 = 416, - T_Timer = 417, - T_Timingstats = 418, - T_Tinker = 419, - T_Tos = 420, - T_Trap = 421, - T_True = 422, - T_Trustedkey = 423, - T_Ttl = 424, - T_Type = 425, - T_U_int = 426, - T_Unconfig = 427, - T_Unpeer = 428, - T_Version = 429, - T_WanderThreshold = 430, - T_Week = 431, - T_Wildcard = 432, - T_Xleave = 433, - T_Year = 434, - T_Flag = 435, - T_EOC = 436, - T_Simulate = 437, - T_Beep_Delay = 438, - T_Sim_Duration = 439, - T_Server_Offset = 440, - T_Duration = 441, - T_Freq_Offset = 442, - T_Wander = 443, - T_Jitter = 444, - T_Prop_Delay = 445, - T_Proc_Delay = 446 - }; + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_Abbrev = 258, + T_Age = 259, + T_All = 260, + T_Allan = 261, + T_Allpeers = 262, + T_Auth = 263, + T_Autokey = 264, + T_Automax = 265, + T_Average = 266, + T_Bclient = 267, + T_Beacon = 268, + T_Broadcast = 269, + T_Broadcastclient = 270, + T_Broadcastdelay = 271, + T_Burst = 272, + T_Calibrate = 273, + T_Ceiling = 274, + T_Clockstats = 275, + T_Cohort = 276, + T_ControlKey = 277, + T_Crypto = 278, + T_Cryptostats = 279, + T_Ctl = 280, + T_Day = 281, + T_Default = 282, + T_Digest = 283, + T_Disable = 284, + T_Discard = 285, + T_Dispersion = 286, + T_Double = 287, + T_Driftfile = 288, + T_Drop = 289, + T_Dscp = 290, + T_Ellipsis = 291, + T_Enable = 292, + T_End = 293, + T_False = 294, + T_File = 295, + T_Filegen = 296, + T_Filenum = 297, + T_Flag1 = 298, + T_Flag2 = 299, + T_Flag3 = 300, + T_Flag4 = 301, + T_Flake = 302, + T_Floor = 303, + T_Freq = 304, + T_Fudge = 305, + T_Host = 306, + T_Huffpuff = 307, + T_Iburst = 308, + T_Ident = 309, + T_Ignore = 310, + T_Incalloc = 311, + T_Incmem = 312, + T_Initalloc = 313, + T_Initmem = 314, + T_Includefile = 315, + T_Integer = 316, + T_Interface = 317, + T_Intrange = 318, + T_Io = 319, + T_Ipv4 = 320, + T_Ipv4_flag = 321, + T_Ipv6 = 322, + T_Ipv6_flag = 323, + T_Kernel = 324, + T_Key = 325, + T_Keys = 326, + T_Keysdir = 327, + T_Kod = 328, + T_Mssntp = 329, + T_Leapfile = 330, + T_Leapsmearinterval = 331, + T_Limited = 332, + T_Link = 333, + T_Listen = 334, + T_Logconfig = 335, + T_Logfile = 336, + T_Loopstats = 337, + T_Lowpriotrap = 338, + T_Manycastclient = 339, + T_Manycastserver = 340, + T_Mask = 341, + T_Maxage = 342, + T_Maxclock = 343, + T_Maxdepth = 344, + T_Maxdist = 345, + T_Maxmem = 346, + T_Maxpoll = 347, + T_Mdnstries = 348, + T_Mem = 349, + T_Memlock = 350, + T_Minclock = 351, + T_Mindepth = 352, + T_Mindist = 353, + T_Minimum = 354, + T_Minpoll = 355, + T_Minsane = 356, + T_Mode = 357, + T_Mode7 = 358, + T_Monitor = 359, + T_Month = 360, + T_Mru = 361, + T_Multicastclient = 362, + T_Nic = 363, + T_Nolink = 364, + T_Nomodify = 365, + T_Nomrulist = 366, + T_None = 367, + T_Nonvolatile = 368, + T_Nopeer = 369, + T_Noquery = 370, + T_Noselect = 371, + T_Noserve = 372, + T_Notrap = 373, + T_Notrust = 374, + T_Ntp = 375, + T_Ntpport = 376, + T_NtpSignDsocket = 377, + T_Orphan = 378, + T_Orphanwait = 379, + T_Panic = 380, + T_Peer = 381, + T_Peerstats = 382, + T_Phone = 383, + T_Pid = 384, + T_Pidfile = 385, + T_Pool = 386, + T_Port = 387, + T_Preempt = 388, + T_Prefer = 389, + T_Protostats = 390, + T_Pw = 391, + T_Randfile = 392, + T_Rawstats = 393, + T_Refid = 394, + T_Requestkey = 395, + T_Reset = 396, + T_Restrict = 397, + T_Revoke = 398, + T_Rlimit = 399, + T_Saveconfigdir = 400, + T_Server = 401, + T_Setvar = 402, + T_Source = 403, + T_Stacksize = 404, + T_Statistics = 405, + T_Stats = 406, + T_Statsdir = 407, + T_Step = 408, + T_Stepback = 409, + T_Stepfwd = 410, + T_Stepout = 411, + T_Stratum = 412, + T_String = 413, + T_Sys = 414, + T_Sysstats = 415, + T_Tick = 416, + T_Time1 = 417, + T_Time2 = 418, + T_Timer = 419, + T_Timingstats = 420, + T_Tinker = 421, + T_Tos = 422, + T_Trap = 423, + T_True = 424, + T_Trustedkey = 425, + T_Ttl = 426, + T_Type = 427, + T_U_int = 428, + T_Unconfig = 429, + T_Unpeer = 430, + T_Version = 431, + T_WanderThreshold = 432, + T_Week = 433, + T_Wildcard = 434, + T_Xleave = 435, + T_Year = 436, + T_Flag = 437, + T_EOC = 438, + T_Simulate = 439, + T_Beep_Delay = 440, + T_Sim_Duration = 441, + T_Server_Offset = 442, + T_Duration = 443, + T_Freq_Offset = 444, + T_Wander = 445, + T_Jitter = 446, + T_Prop_Delay = 447, + T_Proc_Delay = 448 + }; #endif /* Tokens. */ #define T_Abbrev 258 @@ -269,170 +272,173 @@ extern int yydebug; #define T_Double 287 #define T_Driftfile 288 #define T_Drop 289 -#define T_Ellipsis 290 -#define T_Enable 291 -#define T_End 292 -#define T_False 293 -#define T_File 294 -#define T_Filegen 295 -#define T_Filenum 296 -#define T_Flag1 297 -#define T_Flag2 298 -#define T_Flag3 299 -#define T_Flag4 300 -#define T_Flake 301 -#define T_Floor 302 -#define T_Freq 303 -#define T_Fudge 304 -#define T_Host 305 -#define T_Huffpuff 306 -#define T_Iburst 307 -#define T_Ident 308 -#define T_Ignore 309 -#define T_Incalloc 310 -#define T_Incmem 311 -#define T_Initalloc 312 -#define T_Initmem 313 -#define T_Includefile 314 -#define T_Integer 315 -#define T_Interface 316 -#define T_Intrange 317 -#define T_Io 318 -#define T_Ipv4 319 -#define T_Ipv4_flag 320 -#define T_Ipv6 321 -#define T_Ipv6_flag 322 -#define T_Kernel 323 -#define T_Key 324 -#define T_Keys 325 -#define T_Keysdir 326 -#define T_Kod 327 -#define T_Mssntp 328 -#define T_Leapfile 329 -#define T_Limited 330 -#define T_Link 331 -#define T_Listen 332 -#define T_Logconfig 333 -#define T_Logfile 334 -#define T_Loopstats 335 -#define T_Lowpriotrap 336 -#define T_Manycastclient 337 -#define T_Manycastserver 338 -#define T_Mask 339 -#define T_Maxage 340 -#define T_Maxclock 341 -#define T_Maxdepth 342 -#define T_Maxdist 343 -#define T_Maxmem 344 -#define T_Maxpoll 345 -#define T_Mdnstries 346 -#define T_Mem 347 -#define T_Memlock 348 -#define T_Minclock 349 -#define T_Mindepth 350 -#define T_Mindist 351 -#define T_Minimum 352 -#define T_Minpoll 353 -#define T_Minsane 354 -#define T_Mode 355 -#define T_Mode7 356 -#define T_Monitor 357 -#define T_Month 358 -#define T_Mru 359 -#define T_Multicastclient 360 -#define T_Nic 361 -#define T_Nolink 362 -#define T_Nomodify 363 -#define T_Nomrulist 364 -#define T_None 365 -#define T_Nonvolatile 366 -#define T_Nopeer 367 -#define T_Noquery 368 -#define T_Noselect 369 -#define T_Noserve 370 -#define T_Notrap 371 -#define T_Notrust 372 -#define T_Ntp 373 -#define T_Ntpport 374 -#define T_NtpSignDsocket 375 -#define T_Orphan 376 -#define T_Orphanwait 377 -#define T_Panic 378 -#define T_Peer 379 -#define T_Peerstats 380 -#define T_Phone 381 -#define T_Pid 382 -#define T_Pidfile 383 -#define T_Pool 384 -#define T_Port 385 -#define T_Preempt 386 -#define T_Prefer 387 -#define T_Protostats 388 -#define T_Pw 389 -#define T_Randfile 390 -#define T_Rawstats 391 -#define T_Refid 392 -#define T_Requestkey 393 -#define T_Reset 394 -#define T_Restrict 395 -#define T_Revoke 396 -#define T_Rlimit 397 -#define T_Saveconfigdir 398 -#define T_Server 399 -#define T_Setvar 400 -#define T_Source 401 -#define T_Stacksize 402 -#define T_Statistics 403 -#define T_Stats 404 -#define T_Statsdir 405 -#define T_Step 406 -#define T_Stepback 407 -#define T_Stepfwd 408 -#define T_Stepout 409 -#define T_Stratum 410 -#define T_String 411 -#define T_Sys 412 -#define T_Sysstats 413 -#define T_Tick 414 -#define T_Time1 415 -#define T_Time2 416 -#define T_Timer 417 -#define T_Timingstats 418 -#define T_Tinker 419 -#define T_Tos 420 -#define T_Trap 421 -#define T_True 422 -#define T_Trustedkey 423 -#define T_Ttl 424 -#define T_Type 425 -#define T_U_int 426 -#define T_Unconfig 427 -#define T_Unpeer 428 -#define T_Version 429 -#define T_WanderThreshold 430 -#define T_Week 431 -#define T_Wildcard 432 -#define T_Xleave 433 -#define T_Year 434 -#define T_Flag 435 -#define T_EOC 436 -#define T_Simulate 437 -#define T_Beep_Delay 438 -#define T_Sim_Duration 439 -#define T_Server_Offset 440 -#define T_Duration 441 -#define T_Freq_Offset 442 -#define T_Wander 443 -#define T_Jitter 444 -#define T_Prop_Delay 445 -#define T_Proc_Delay 446 +#define T_Dscp 290 +#define T_Ellipsis 291 +#define T_Enable 292 +#define T_End 293 +#define T_False 294 +#define T_File 295 +#define T_Filegen 296 +#define T_Filenum 297 +#define T_Flag1 298 +#define T_Flag2 299 +#define T_Flag3 300 +#define T_Flag4 301 +#define T_Flake 302 +#define T_Floor 303 +#define T_Freq 304 +#define T_Fudge 305 +#define T_Host 306 +#define T_Huffpuff 307 +#define T_Iburst 308 +#define T_Ident 309 +#define T_Ignore 310 +#define T_Incalloc 311 +#define T_Incmem 312 +#define T_Initalloc 313 +#define T_Initmem 314 +#define T_Includefile 315 +#define T_Integer 316 +#define T_Interface 317 +#define T_Intrange 318 +#define T_Io 319 +#define T_Ipv4 320 +#define T_Ipv4_flag 321 +#define T_Ipv6 322 +#define T_Ipv6_flag 323 +#define T_Kernel 324 +#define T_Key 325 +#define T_Keys 326 +#define T_Keysdir 327 +#define T_Kod 328 +#define T_Mssntp 329 +#define T_Leapfile 330 +#define T_Leapsmearinterval 331 +#define T_Limited 332 +#define T_Link 333 +#define T_Listen 334 +#define T_Logconfig 335 +#define T_Logfile 336 +#define T_Loopstats 337 +#define T_Lowpriotrap 338 +#define T_Manycastclient 339 +#define T_Manycastserver 340 +#define T_Mask 341 +#define T_Maxage 342 +#define T_Maxclock 343 +#define T_Maxdepth 344 +#define T_Maxdist 345 +#define T_Maxmem 346 +#define T_Maxpoll 347 +#define T_Mdnstries 348 +#define T_Mem 349 +#define T_Memlock 350 +#define T_Minclock 351 +#define T_Mindepth 352 +#define T_Mindist 353 +#define T_Minimum 354 +#define T_Minpoll 355 +#define T_Minsane 356 +#define T_Mode 357 +#define T_Mode7 358 +#define T_Monitor 359 +#define T_Month 360 +#define T_Mru 361 +#define T_Multicastclient 362 +#define T_Nic 363 +#define T_Nolink 364 +#define T_Nomodify 365 +#define T_Nomrulist 366 +#define T_None 367 +#define T_Nonvolatile 368 +#define T_Nopeer 369 +#define T_Noquery 370 +#define T_Noselect 371 +#define T_Noserve 372 +#define T_Notrap 373 +#define T_Notrust 374 +#define T_Ntp 375 +#define T_Ntpport 376 +#define T_NtpSignDsocket 377 +#define T_Orphan 378 +#define T_Orphanwait 379 +#define T_Panic 380 +#define T_Peer 381 +#define T_Peerstats 382 +#define T_Phone 383 +#define T_Pid 384 +#define T_Pidfile 385 +#define T_Pool 386 +#define T_Port 387 +#define T_Preempt 388 +#define T_Prefer 389 +#define T_Protostats 390 +#define T_Pw 391 +#define T_Randfile 392 +#define T_Rawstats 393 +#define T_Refid 394 +#define T_Requestkey 395 +#define T_Reset 396 +#define T_Restrict 397 +#define T_Revoke 398 +#define T_Rlimit 399 +#define T_Saveconfigdir 400 +#define T_Server 401 +#define T_Setvar 402 +#define T_Source 403 +#define T_Stacksize 404 +#define T_Statistics 405 +#define T_Stats 406 +#define T_Statsdir 407 +#define T_Step 408 +#define T_Stepback 409 +#define T_Stepfwd 410 +#define T_Stepout 411 +#define T_Stratum 412 +#define T_String 413 +#define T_Sys 414 +#define T_Sysstats 415 +#define T_Tick 416 +#define T_Time1 417 +#define T_Time2 418 +#define T_Timer 419 +#define T_Timingstats 420 +#define T_Tinker 421 +#define T_Tos 422 +#define T_Trap 423 +#define T_True 424 +#define T_Trustedkey 425 +#define T_Ttl 426 +#define T_Type 427 +#define T_U_int 428 +#define T_Unconfig 429 +#define T_Unpeer 430 +#define T_Version 431 +#define T_WanderThreshold 432 +#define T_Week 433 +#define T_Wildcard 434 +#define T_Xleave 435 +#define T_Year 436 +#define T_Flag 437 +#define T_EOC 438 +#define T_Simulate 439 +#define T_Beep_Delay 440 +#define T_Sim_Duration 441 +#define T_Server_Offset 442 +#define T_Duration 443 +#define T_Freq_Offset 444 +#define T_Wander 445 +#define T_Jitter 446 +#define T_Prop_Delay 447 +#define T_Proc_Delay 448 + + -/* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE YYSTYPE; -union YYSTYPE +typedef union YYSTYPE { -#line 54 "ntp_parser.y" /* yacc.c:1909 */ +/* Line 2053 of yacc.c */ +#line 51 "../../ntpd/ntp_parser.y" char * String; double Double; @@ -451,15 +457,29 @@ union YYSTYPE script_info * Sim_script; script_info_fifo * Sim_script_fifo; -#line 455 "ntp_parser.h" /* yacc.c:1909 */ -}; + +/* Line 2053 of yacc.c */ +#line 463 "ntp_parser.h" +} YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif - extern YYSTYPE yylval; -int yyparse (struct FILE_INFO *ip_file); +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ #endif /* !YY_YY_NTP_PARSER_H_INCLUDED */ diff --git a/ntpd/ntp_parser.y b/ntpd/ntp_parser.y index e878e794d269b..c9cd6c6dd27ee 100644 --- a/ntpd/ntp_parser.y +++ b/ntpd/ntp_parser.y @@ -8,9 +8,6 @@ * Copyright (c) 2006 */ -%parse-param {struct FILE_INFO *ip_file} -%lex-param {struct FILE_INFO *ip_file} - %{ #ifdef HAVE_CONFIG_H # include <config.h> @@ -36,7 +33,7 @@ #define YYFREE free #define YYERROR_VERBOSE #define YYMAXDEPTH 1000 /* stop the madness sooner */ - void yyerror(struct FILE_INFO *ip_file, const char *msg); + void yyerror(const char *msg); #ifdef SIM # define ONLY_SIM(a) (a) @@ -45,7 +42,7 @@ #endif %} -/* +/* * Enable generation of token names array even without YYDEBUG. * We access via token_name() defined below. */ @@ -103,6 +100,7 @@ %token <Double> T_Double /* not a token */ %token <Integer> T_Driftfile %token <Integer> T_Drop +%token <Integer> T_Dscp %token <Integer> T_Ellipsis /* "..." not "ellipsis" */ %token <Integer> T_Enable %token <Integer> T_End @@ -143,6 +141,7 @@ %token <Integer> T_Kod %token <Integer> T_Mssntp %token <Integer> T_Leapfile +%token <Integer> T_Leapsmearinterval %token <Integer> T_Limited %token <Integer> T_Link %token <Integer> T_Listen @@ -302,6 +301,7 @@ %type <Attr_val> log_config_command %type <Attr_val_fifo> log_config_list %type <Integer> misc_cmd_dbl_keyword +%type <Integer> misc_cmd_int_keyword %type <Integer> misc_cmd_str_keyword %type <Integer> misc_cmd_str_lcl_keyword %type <Attr_val> mru_option @@ -375,11 +375,12 @@ command_list * error messages. The following should suffice for * the time being. */ - msyslog(LOG_ERR, + struct FILE_INFO * ip_ctx = lex_current(); + msyslog(LOG_ERR, "syntax error in %s line %d, column %d", - ip_file->fname, - ip_file->err_line_no, - ip_file->err_col_no); + ip_ctx->fname, + ip_ctx->errpos.nline, + ip_ctx->errpos.ncol); } ; @@ -428,7 +429,7 @@ address ; ip_address - : T_String + : T_String { $$ = create_address_node($1, AF_UNSPEC); } ; @@ -442,7 +443,7 @@ address_fam option_list : /* empty list */ { $$ = NULL; } - | option_list option + | option_list option { $$ = $1; APPEND_G_FIFO($$, $2); @@ -505,18 +506,18 @@ unpeer_command : unpeer_keyword address { unpeer_node *my_node; - + my_node = create_unpeer_node($2); if (my_node) APPEND_G_FIFO(cfgt.unpeers, my_node); } - ; -unpeer_keyword + ; +unpeer_keyword : T_Unconfig | T_Unpeer ; - - + + /* Other Modes * (broadcastclient manycastserver multicastclient) * ------------------------------------------------ @@ -543,14 +544,14 @@ authentication_command : T_Automax T_Integer { attr_val *atrv; - + atrv = create_attr_ival($1, $2); APPEND_G_FIFO(cfgt.vars, atrv); } | T_ControlKey T_Integer { cfgt.auth.control_key = $2; } | T_Crypto crypto_command_list - { + { cfgt.auth.cryptosw++; CONCAT_G_FIFOS(cfgt.auth.crypto_cmd_list, $2); } @@ -624,7 +625,7 @@ tos_option_list APPEND_G_FIFO($$, $2); } | tos_option - { + { $$ = NULL; APPEND_G_FIFO($$, $1); } @@ -665,24 +666,24 @@ monitoring_command { CONCAT_G_FIFOS(cfgt.stats_list, $2); } | T_Statsdir T_String { - if (input_from_file) { + if (lex_from_file()) { cfgt.stats_dir = $2; } else { YYFREE($2); - yyerror(ip_file, "statsdir remote configuration ignored"); + yyerror("statsdir remote configuration ignored"); } } | T_Filegen stat filegen_option_list { filegen_node *fgn; - + fgn = create_filegen_node($2, $3); APPEND_G_FIFO(cfgt.filegen_opts, fgn); } ; stats_list - : stats_list stat + : stats_list stat { $$ = $1; APPEND_G_FIFO($$, create_int_node($2)); @@ -718,28 +719,28 @@ filegen_option_list filegen_option : T_File T_String { - if (input_from_file) { + if (lex_from_file()) { $$ = create_attr_sval($1, $2); } else { $$ = NULL; YYFREE($2); - yyerror(ip_file, "filegen file remote config ignored"); + yyerror("filegen file remote config ignored"); } } | T_Type filegen_type { - if (input_from_file) { + if (lex_from_file()) { $$ = create_attr_ival($1, $2); } else { $$ = NULL; - yyerror(ip_file, "filegen type remote config ignored"); + yyerror("filegen type remote config ignored"); } } | link_nolink { const char *err; - - if (input_from_file) { + + if (lex_from_file()) { $$ = create_attr_ival(T_Flag, $1); } else { $$ = NULL; @@ -747,7 +748,7 @@ filegen_option err = "filegen link remote config ignored"; else err = "filegen nolink remote config ignored"; - yyerror(ip_file, err); + yyerror(err); } } | enable_disable @@ -793,7 +794,7 @@ access_control_command restrict_node *rn; rn = create_restrict_node($2, NULL, $3, - ip_file->line_no); + lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } | T_Restrict ip_address T_Mask ip_address ac_flag_list @@ -801,7 +802,7 @@ access_control_command restrict_node *rn; rn = create_restrict_node($2, $4, $5, - ip_file->line_no); + lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } | T_Restrict T_Default ac_flag_list @@ -809,7 +810,7 @@ access_control_command restrict_node *rn; rn = create_restrict_node(NULL, NULL, $3, - ip_file->line_no); + lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } | T_Restrict T_Ipv4_flag T_Default ac_flag_list @@ -818,28 +819,28 @@ access_control_command rn = create_restrict_node( create_address_node( - estrdup("0.0.0.0"), + estrdup("0.0.0.0"), AF_INET), create_address_node( - estrdup("0.0.0.0"), + estrdup("0.0.0.0"), AF_INET), - $4, - ip_file->line_no); + $4, + lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } | T_Restrict T_Ipv6_flag T_Default ac_flag_list { restrict_node *rn; - + rn = create_restrict_node( create_address_node( - estrdup("::"), + estrdup("::"), AF_INET6), create_address_node( - estrdup("::"), + estrdup("::"), AF_INET6), - $4, - ip_file->line_no); + $4, + lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } | T_Restrict T_Source ac_flag_list @@ -848,7 +849,7 @@ access_control_command APPEND_G_FIFO($3, create_int_node($2)); rn = create_restrict_node( - NULL, NULL, $3, ip_file->line_no); + NULL, NULL, $3, lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } ; @@ -887,7 +888,7 @@ discard_option_list $$ = $1; APPEND_G_FIFO($$, $2); } - | discard_option + | discard_option { $$ = NULL; APPEND_G_FIFO($$, $1); @@ -911,7 +912,7 @@ mru_option_list $$ = $1; APPEND_G_FIFO($$, $2); } - | mru_option + | mru_option { $$ = NULL; APPEND_G_FIFO($$, $1); @@ -942,7 +943,7 @@ fudge_command : T_Fudge address fudge_factor_list { addr_opts_node *aon; - + aon = create_addr_opts_node($2, $3); APPEND_G_FIFO(cfgt.fudge, aon); } @@ -960,7 +961,7 @@ fudge_factor_list APPEND_G_FIFO($$, $1); } ; - + fudge_factor : fudge_factor_dbl_keyword number { $$ = create_attr_dval($1, $2); } @@ -1048,17 +1049,17 @@ system_option : system_option_flag_keyword { $$ = create_attr_ival(T_Flag, $1); } | system_option_local_flag_keyword - { - if (input_from_file) { + { + if (lex_from_file()) { $$ = create_attr_ival(T_Flag, $1); } else { char err_str[128]; - + $$ = NULL; snprintf(err_str, sizeof(err_str), "enable/disable %s remote configuration ignored", keyword($1)); - yyerror(ip_file, err_str); + yyerror(err_str); } } ; @@ -1128,14 +1129,21 @@ miscellaneous_command | misc_cmd_dbl_keyword number { attr_val *av; - + av = create_attr_dval($1, $2); APPEND_G_FIFO(cfgt.vars, av); } + | misc_cmd_int_keyword T_Integer + { + attr_val *av; + + av = create_attr_ival($1, $2); + APPEND_G_FIFO(cfgt.vars, av); + } | misc_cmd_str_keyword T_String { attr_val *av; - + av = create_attr_sval($1, $2); APPEND_G_FIFO(cfgt.vars, av); } @@ -1144,7 +1152,7 @@ miscellaneous_command char error_text[64]; attr_val *av; - if (input_from_file) { + if (lex_from_file()) { av = create_attr_sval($1, $2); APPEND_G_FIFO(cfgt.vars, av); } else { @@ -1152,33 +1160,30 @@ miscellaneous_command snprintf(error_text, sizeof(error_text), "%s remote config ignored", keyword($1)); - yyerror(ip_file, error_text); + yyerror(error_text); } } | T_Includefile T_String command { - if (!input_from_file) { - yyerror(ip_file, "remote includefile ignored"); + if (!lex_from_file()) { + YYFREE($2); /* avoid leak */ + yyerror("remote includefile ignored"); break; } - if (curr_include_level >= MAXINCLUDELEVEL) { + if (lex_level() > MAXINCLUDELEVEL) { fprintf(stderr, "getconfig: Maximum include file level exceeded.\n"); msyslog(LOG_ERR, "getconfig: Maximum include file level exceeded."); } else { - fp[curr_include_level + 1] = F_OPEN(FindConfig($2), "r"); - if (fp[curr_include_level + 1] == NULL) { - fprintf(stderr, "getconfig: Couldn't open <%s>\n", FindConfig($2)); - msyslog(LOG_ERR, "getconfig: Couldn't open <%s>", FindConfig($2)); - } else { - ip_file = fp[++curr_include_level]; + const char * path = FindConfig($2); /* might return $2! */ + if (!lex_push_file(path, "r")) { + fprintf(stderr, "getconfig: Couldn't open <%s>\n", path); + msyslog(LOG_ERR, "getconfig: Couldn't open <%s>", path); } } + YYFREE($2); /* avoid leak */ } | T_End - { - while (curr_include_level != -1) - FCLOSE(fp[curr_include_level--]); - } + { lex_flush_stack(); } | T_Driftfile drift_parm { /* see drift_parm below for actions */ } | T_Logconfig log_config_list @@ -1190,7 +1195,7 @@ miscellaneous_command | T_Trap ip_address trap_option_list { addr_opts_node *aon; - + aon = create_addr_opts_node($2, $3); APPEND_G_FIFO(cfgt.trap, aon); } @@ -1204,6 +1209,19 @@ misc_cmd_dbl_keyword | T_Tick ; +misc_cmd_int_keyword + : T_Dscp + ; + +misc_cmd_int_keyword + : T_Leapsmearinterval + { +#ifndef LEAP_SMEAR + yyerror("Built without LEAP_SMEAR support."); +#endif + } + ; + misc_cmd_str_keyword : T_Ident | T_Leapfile @@ -1219,14 +1237,14 @@ drift_parm : T_String { attr_val *av; - + av = create_attr_sval(T_Driftfile, $1); APPEND_G_FIFO(cfgt.vars, av); } | T_String T_Double { attr_val *av; - + av = create_attr_sval(T_Driftfile, $1); APPEND_G_FIFO(cfgt.vars, av); av = create_attr_dval(T_WanderThreshold, $2); @@ -1235,7 +1253,7 @@ drift_parm | /* Null driftfile, indicated by empty string "" */ { attr_val *av; - + av = create_attr_sval(T_Driftfile, ""); APPEND_G_FIFO(cfgt.vars, av); } @@ -1290,21 +1308,21 @@ log_config_command { char prefix; char * type; - + switch ($1[0]) { - + case '+': case '-': case '=': prefix = $1[0]; type = $1 + 1; break; - + default: prefix = '='; type = $1; - } - + } + $$ = create_attr_sval(prefix, estrdup(type)); YYFREE($1); } @@ -1314,14 +1332,14 @@ interface_command : interface_nic nic_rule_action nic_rule_class { nic_rule_node *nrn; - + nrn = create_nic_rule_node($3, NULL, $2); APPEND_G_FIFO(cfgt.nic_rules, nrn); } | interface_nic nic_rule_action T_String { nic_rule_node *nrn; - + nrn = create_nic_rule_node(0, $3, $2); APPEND_G_FIFO(cfgt.nic_rules, nrn); } @@ -1446,7 +1464,7 @@ boolean : T_Integer { if ($1 != 0 && $1 != 1) { - yyerror(ip_file, "Integer value is not boolean (0 or 1). Assuming 1"); + yyerror("Integer value is not boolean (0 or 1). Assuming 1"); $$ = 1; } else { $$ = $1; @@ -1470,7 +1488,7 @@ simulate_command : sim_conf_start '{' sim_init_statement_list sim_server_list '}' { sim_node *sn; - + sn = create_sim_node($3, $4); APPEND_G_FIFO(cfgt.sim_details, sn); @@ -1585,28 +1603,25 @@ sim_act_keyword %% -void +void yyerror( - struct FILE_INFO *ip_file, const char *msg ) { int retval; + struct FILE_INFO * ip_ctx; + + ip_ctx = lex_current(); + ip_ctx->errpos = ip_ctx->tokpos; - ip_file->err_line_no = ip_file->prev_token_line_no; - ip_file->err_col_no = ip_file->prev_token_col_no; - - msyslog(LOG_ERR, - "line %d column %d %s", - ip_file->err_line_no, - ip_file->err_col_no, - msg); - if (!input_from_file) { + msyslog(LOG_ERR, "line %d column %d %s", + ip_ctx->errpos.nline, ip_ctx->errpos.ncol, msg); + if (!lex_from_file()) { /* Save the error message in the correct buffer */ retval = snprintf(remote_config.err_msg + remote_config.err_pos, MAXLINE - remote_config.err_pos, "column %d %s", - ip_file->err_col_no, msg); + ip_ctx->errpos.ncol, msg); /* Increment the value of err_pos */ if (retval > 0) diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 577b5fb0af5a2..40624066746f5 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -14,6 +14,7 @@ #include "ntp_control.h" #include "ntp_string.h" #include "ntp_leapsec.h" +#include "refidsmear.h" #include <stdio.h> #ifdef HAVE_LIBSCF_H @@ -61,7 +62,8 @@ typedef struct peer_select_tag { * System variables are declared here. Unless specified otherwise, all * times are in seconds. */ -u_char sys_leap; /* system leap indicator */ +u_char sys_leap; /* system leap indicator, use set_sys_leap() to change this */ +u_char xmt_leap; /* leap indicator sent in client requests, set up by set_sys_leap() */ u_char sys_stratum; /* system stratum */ s_char sys_precision; /* local clock precision (log2 s) */ double sys_rootdelay; /* roundtrip delay to primary source */ @@ -70,6 +72,11 @@ u_int32 sys_refid; /* reference id (network byte order) */ l_fp sys_reftime; /* last update time */ struct peer *sys_peer; /* current peer */ +#ifdef LEAP_SMEAR +struct leap_smear_info leap_smear; +#endif +int leap_sec_in_progress; + /* * Rate controls. Leaky buckets are used to throttle the packet * transmission rates in order to protect busy servers such as at NIST @@ -151,6 +158,33 @@ void pool_name_resolved (int, int, void *, const char *, const struct addrinfo *); #endif /* WORKER */ +void +set_sys_leap(u_char new_sys_leap) { + sys_leap = new_sys_leap; + xmt_leap = sys_leap; + + /* + * Under certain conditions we send faked leap bits to clients, so + * eventually change xmt_leap below, but never change LEAP_NOTINSYNC. + */ + if (xmt_leap != LEAP_NOTINSYNC) { + if (leap_sec_in_progress) { + /* always send "not sync" */ + xmt_leap = LEAP_NOTINSYNC; + } +#ifdef LEAP_SMEAR + else { + /* + * If leap smear is enabled in general we must never send a leap second warning + * to clients, so make sure we only send "in sync". + */ + if (leap_smear.enabled) + xmt_leap = LEAP_NOWARNING; + } +#endif /* LEAP_SMEAR */ + } +} + /* * transmit - transmit procedure called by poll timeout @@ -1909,7 +1943,7 @@ clock_update( */ case 2: clear_all(); - sys_leap = LEAP_NOTINSYNC; + set_sys_leap(LEAP_NOTINSYNC); sys_stratum = STRATUM_UNSPEC; memcpy(&sys_refid, "STEP", 4); sys_rootdelay = 0; @@ -1930,7 +1964,7 @@ clock_update( * process. */ if (sys_leap == LEAP_NOTINSYNC) { - sys_leap = LEAP_NOWARNING; + set_sys_leap(LEAP_NOWARNING); #ifdef AUTOKEY if (crypto_flags) crypto_update(); @@ -2424,7 +2458,7 @@ clock_select(void) osys_peer = sys_peer; sys_survivors = 0; #ifdef LOCKCLOCK - sys_leap = LEAP_NOTINSYNC; + set_sys_leap(LEAP_NOTINSYNC); sys_stratum = STRATUM_UNSPEC; memcpy(&sys_refid, "DOWN", 4); #endif /* LOCKCLOCK */ @@ -3407,6 +3441,16 @@ peer_xmit( } +#ifdef LEAP_SMEAR + +static void +leap_smear_add_offs(l_fp *t, l_fp *t_recv) { + L_ADD(t, &leap_smear.offset); +} + +#endif /* LEAP_SMEAR */ + + /* * fast_xmit - Send packet for nonpersistent association. Note that * neither the source or destination can be a broadcast address. @@ -3468,18 +3512,60 @@ fast_xmit( * This is a normal packet. Use the system variables. */ } else { - xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap, +#ifdef LEAP_SMEAR + /* + * Make copies of the variables which can be affected by smearing. + */ + l_fp this_ref_time; + l_fp this_recv_time; +#endif + + /* + * If we are inside the leap smear interval we add the current smear offset to + * the packet receive time, to the packet transmit time, and eventually to the + * reftime to make sure the reftime isn't later than the transmit/receive times. + */ + xpkt.li_vn_mode = PKT_LI_VN_MODE(xmt_leap, PKT_VERSION(rpkt->li_vn_mode), xmode); + xpkt.stratum = STRATUM_TO_PKT(sys_stratum); xpkt.ppoll = max(rpkt->ppoll, ntp_minpoll); xpkt.precision = sys_precision; xpkt.refid = sys_refid; xpkt.rootdelay = HTONS_FP(DTOFP(sys_rootdelay)); xpkt.rootdisp = HTONS_FP(DTOUFP(sys_rootdisp)); + +#ifdef LEAP_SMEAR + this_ref_time = sys_reftime; + if (leap_smear.in_progress) { + leap_smear_add_offs(&this_ref_time, NULL); + xpkt.refid = convertLFPToRefID(leap_smear.offset); + DPRINTF(2, ("fast_xmit: leap_smear.in_progress: refid %8x, smear %s\n", + ntohl(xpkt.refid), + lfptoa(&leap_smear.offset, 8) + )); + } + HTONL_FP(&this_ref_time, &xpkt.reftime); +#else HTONL_FP(&sys_reftime, &xpkt.reftime); +#endif + xpkt.org = rpkt->xmt; + +#ifdef LEAP_SMEAR + this_recv_time = rbufp->recv_time; + if (leap_smear.in_progress) + leap_smear_add_offs(&this_recv_time, NULL); + HTONL_FP(&this_recv_time, &xpkt.rec); +#else HTONL_FP(&rbufp->recv_time, &xpkt.rec); +#endif + get_systime(&xmt_tx); +#ifdef LEAP_SMEAR + if (leap_smear.in_progress) + leap_smear_add_offs(&xmt_tx, &this_recv_time); +#endif HTONL_FP(&xmt_tx, &xpkt.xmt); } @@ -3988,7 +4074,7 @@ init_proto(void) * Fill in the sys_* stuff. Default is don't listen to * broadcasting, require authentication. */ - sys_leap = LEAP_NOTINSYNC; + set_sys_leap(LEAP_NOTINSYNC); sys_stratum = STRATUM_UNSPEC; memcpy(&sys_refid, "INIT", 4); sys_peer = NULL; @@ -4062,8 +4148,12 @@ proto_config( case PROTO_MONITOR: /* monitoring (monitor) */ if (value) mon_start(MON_ON); - else + else { mon_stop(MON_ON); + if (mon_enabled) + msyslog(LOG_WARNING, + "restrict: 'monitor' cannot be disabled while 'limited' is enabled"); + } break; case PROTO_NTP: /* NTP discipline (ntp) */ diff --git a/ntpd/ntp_scanner.c b/ntpd/ntp_scanner.c index a7c19922bd533..49adf6bfb767a 100644 --- a/ntpd/ntp_scanner.c +++ b/ntpd/ntp_scanner.c @@ -38,6 +38,7 @@ char yytext[MAX_LEXEME]; /* Buffer for storing the input text/lexeme */ u_int32 conf_file_sum; /* Simple sum of characters read */ +static struct FILE_INFO * lex_stack = NULL; @@ -86,153 +87,342 @@ keyword( } -/* FILE INTERFACE - * -------------- - * We define a couple of wrapper functions around the standard C fgetc - * and ungetc functions in order to include positional bookkeeping +/* FILE & STRING BUFFER INTERFACE + * ------------------------------ + * + * This set out as a couple of wrapper functions around the standard C + * fgetc and ungetc functions in order to include positional + * bookkeeping. Alas, this is no longer a good solution with nested + * input files and the possibility to send configuration commands via + * 'ntpdc' and 'ntpq'. + * + * Now there are a few functions to maintain a stack of nested input + * sources (though nesting is only allowd for disk files) and from the + * scanner / parser point of view there's no difference between both + * types of sources. + * + * The 'fgetc()' / 'ungetc()' replacements now operate on a FILE_INFO + * structure. Instead of trying different 'ungetc()' strategies for file + * and buffer based parsing, we keep the backup char in our own + * FILE_INFO structure. This is sufficient, as the parser does *not* + * jump around via 'seek' or the like, and there's no need to + * check/clear the backup store in other places than 'lex_getch()'. */ -struct FILE_INFO * -F_OPEN( +/* + * Allocate an info structure and attach it to a file. + * + * Note: When 'mode' is NULL, then the INFO block will be set up to + * contain a NULL file pointer, as suited for remote config command + * parsing. Otherwise having a NULL file pointer is considered an error, + * and a NULL info block pointer is returned to indicate failure! + * + * Note: We use a variable-sized structure to hold a copy of the file + * name (or, more proper, the input source description). This is more + * secure than keeping a reference to some other storage that might go + * out of scope. + */ +static struct FILE_INFO * +lex_open( const char *path, const char *mode ) { - struct FILE_INFO *my_info; - - my_info = emalloc(sizeof *my_info); - - my_info->line_no = 1; - my_info->col_no = 0; - my_info->prev_line_col_no = 0; - my_info->prev_token_col_no = 0; - my_info->fname = path; - - my_info->fd = fopen(path, mode); - if (NULL == my_info->fd) { - free(my_info); - return NULL; + struct FILE_INFO *stream; + size_t nnambuf; + + nnambuf = strlen(path); + stream = emalloc_zero(sizeof(*stream) + nnambuf); + stream->curpos.nline = 1; + stream->backch = EOF; + /* copy name with memcpy -- trailing NUL already there! */ + memcpy(stream->fname, path, nnambuf); + + if (NULL != mode) { + stream->fpi = fopen(path, mode); + if (NULL == stream->fpi) { + free(stream); + stream = NULL; + } } - return my_info; + return stream; } -int -FGETC( +/* get next character from buffer or file. This will return any putback + * character first; it will also make sure the last line is at least + * virtually terminated with a '\n'. + */ +static int +lex_getch( struct FILE_INFO *stream ) { int ch; - - do - ch = fgetc(stream->fd); - while (EOF != ch && (CHAR_MIN > ch || ch > CHAR_MAX)); - - if (EOF != ch) { - if (input_from_file) - conf_file_sum += (u_char)ch; - ++stream->col_no; - if (ch == '\n') { - stream->prev_line_col_no = stream->col_no; - ++stream->line_no; - stream->col_no = 1; + + if (NULL == stream || stream->force_eof) + return EOF; + + if (EOF != stream->backch) { + ch = stream->backch; + stream->backch = EOF; + if (stream->fpi) + conf_file_sum += ch; + } else if (stream->fpi) { + /* fetch next 7-bit ASCII char (or EOF) from file */ + while ((ch = fgetc(stream->fpi)) != EOF && ch > SCHAR_MAX) + stream->curpos.ncol++; + if (EOF != ch) { + conf_file_sum += ch; + stream->curpos.ncol++; } + } else { + /* fetch next 7-bit ASCII char from buffer */ + const char * scan; + scan = &remote_config.buffer[remote_config.pos]; + while ((ch = (u_char)*scan) > SCHAR_MAX) { + scan++; + stream->curpos.ncol++; + } + if ('\0' != ch) { + scan++; + stream->curpos.ncol++; + } else { + ch = EOF; + } + remote_config.pos = (int)(scan - remote_config.buffer); + } + + /* If the last line ends without '\n', generate one. This + * happens most likely on Windows, where editors often have a + * sloppy concept of a line. + */ + if (EOF == ch && stream->curpos.ncol != 0) + ch = '\n'; + + /* update scan position tallies */ + if (ch == '\n') { + stream->bakpos = stream->curpos; + stream->curpos.nline++; + stream->curpos.ncol = 0; } return ch; } -/* BUGS: 1. Function will fail on more than one line of pushback - * 2. No error checking is done to see if ungetc fails - * SK: I don't think its worth fixing these bugs for our purposes ;-) +/* Note: lex_ungetch will fail to track more than one line of push + * back. But since it guarantees only one char of back storage anyway, + * this should not be a problem. */ -int -UNGETC( +static int +lex_ungetch( int ch, struct FILE_INFO *stream ) { - if (input_from_file) - conf_file_sum -= (u_char)ch; - if (ch == '\n') { - stream->col_no = stream->prev_line_col_no; - stream->prev_line_col_no = -1; - --stream->line_no; + /* check preconditions */ + if (NULL == stream || stream->force_eof) + return EOF; + if (EOF != stream->backch || EOF == ch) + return EOF; + + /* keep for later reference and update checksum */ + stream->backch = (u_char)ch; + if (stream->fpi) + conf_file_sum -= stream->backch; + + /* update position */ + if (stream->backch == '\n') { + stream->curpos = stream->bakpos; + stream->bakpos.ncol = -1; } - --stream->col_no; - return ungetc(ch, stream->fd); + stream->curpos.ncol--; + return stream->backch; } -int -FCLOSE( +/* dispose of an input structure. If the file pointer is not NULL, close + * the file. This function does not check the result of 'fclose()'. + */ +static void +lex_close( struct FILE_INFO *stream ) { - int ret_val = fclose(stream->fd); - - if (!ret_val) + if (NULL != stream) { + if (NULL != stream->fpi) + fclose(stream->fpi); free(stream); - return ret_val; + } } -/* STREAM INTERFACE - * ---------------- - * Provide a wrapper for the stream functions so that the - * stream can either read from a file or from a character - * array. - * NOTE: This is not very efficient for reading from character - * arrays, but needed to allow remote configuration where the - * configuration command is provided through ntpq. - * - * The behavior of there two functions is determined by the - * input_from_file flag. +/* INPUT STACK + * ----------- + * + * Nested input sources are a bit tricky at first glance. We deal with + * this problem using a stack of input sources, that is, a forward + * linked list of FILE_INFO structs. + * + * This stack is never empty during parsing; while an encounter with EOF + * can and will remove nested input sources, removing the last element + * in the stack will not work during parsing, and the EOF condition of + * the outermost input file remains until the parser folds up. */ -static int -get_next_char( - struct FILE_INFO *ip_file +static struct FILE_INFO * +_drop_stack_do( + struct FILE_INFO * head ) { - char ch; - - if (input_from_file) - return FGETC(ip_file); - else { - if (remote_config.buffer[remote_config.pos] == '\0') - return EOF; - else { - ip_file->col_no++; - ch = remote_config.buffer[remote_config.pos++]; - if (ch == '\n') { - ip_file->prev_line_col_no = ip_file->col_no; - ++ip_file->line_no; - ip_file->col_no = 1; - } - return ch; - } + struct FILE_INFO * tail; + while (NULL != head) { + tail = head->st_next; + lex_close(head); + head = tail; } + return head; } -static void -push_back_char( - struct FILE_INFO *ip_file, - int ch + + +/* Create a singleton input source on an empty lexer stack. This will + * fail if there is already an input source, or if the underlying disk + * file cannot be opened. + * + * Returns TRUE if a new input object was successfully created. + */ +int/*BOOL*/ +lex_init_stack( + const char * path, + const char * mode + ) +{ + if (NULL != lex_stack || NULL == path) + return FALSE; + + lex_stack = lex_open(path, mode); + return (NULL != lex_stack); +} + +/* This removes *all* input sources from the stack, leaving the head + * pointer as NULL. Any attempt to parse in that state is likely to bomb + * with segmentation faults or the like. + * + * In other words: Use this to clean up after parsing, and do not parse + * anything until the next 'lex_init_stack()' succeeded. + */ +void +lex_drop_stack() +{ + lex_stack = _drop_stack_do(lex_stack); +} + +/* Flush the lexer input stack: This will nip all input objects on the + * stack (but keeps the current top-of-stack) and marks the top-of-stack + * as inactive. Any further calls to lex_getch yield only EOF, and it's + * no longer possible to push something back. + * + * Returns TRUE if there is a head element (top-of-stack) that was not + * in the force-eof mode before this call. + */ +int/*BOOL*/ +lex_flush_stack() +{ + int retv = FALSE; + + if (NULL != lex_stack) { + retv = !lex_stack->force_eof; + lex_stack->force_eof = TRUE; + lex_stack->st_next = _drop_stack_do( + lex_stack->st_next); + } + return retv; +} + +/* Push another file on the parsing stack. If the mode is NULL, create a + * FILE_INFO suitable for in-memory parsing; otherwise, create a + * FILE_INFO that is bound to a local/disc file. Note that 'path' must + * not be NULL, or the function will fail. + * + * Returns TRUE if a new info record was pushed onto the stack. + */ +int/*BOOL*/ lex_push_file( + const char * path, + const char * mode ) { - if (input_from_file) - UNGETC(ch, ip_file); - else { - if (ch == '\n') { - ip_file->col_no = ip_file->prev_line_col_no; - ip_file->prev_line_col_no = -1; - --ip_file->line_no; + struct FILE_INFO * next = NULL; + + if (NULL != path) { + next = lex_open(path, mode); + if (NULL != next) { + next->st_next = lex_stack; + lex_stack = next; } - --ip_file->col_no; + } + return (NULL != next); +} - remote_config.pos--; +/* Pop, close & free the top of the include stack, unless the stack + * contains only a singleton input object. In that case the function + * fails, because the parser does not expect the input stack to be + * empty. + * + * Returns TRUE if an object was successfuly popped from the stack. + */ +int/*BOOL*/ +lex_pop_file(void) +{ + struct FILE_INFO * head = lex_stack; + struct FILE_INFO * tail = NULL; + + if (NULL != head) { + tail = head->st_next; + if (NULL != tail) { + lex_stack = tail; + lex_close(head); + } } + return (NULL != tail); +} + +/* Get include nesting level. This currently loops over the stack and + * counts elements; but since this is of concern only with an include + * statement and the nesting depth has a small limit, there's no + * bottleneck expected here. + * + * Returns the nesting level of includes, that is, the current depth of + * the lexer input stack. + * + * Note: + */ +size_t +lex_level(void) +{ + size_t cnt = 0; + struct FILE_INFO *ipf = lex_stack; + + while (NULL != ipf) { + cnt++; + ipf = ipf->st_next; + } + return cnt; +} + +/* check if the current input is from a file */ +int/*BOOL*/ +lex_from_file(void) +{ + return (NULL != lex_stack) && (NULL != lex_stack->fpi); +} + +struct FILE_INFO * +lex_current() +{ + /* this became so simple, it could be a macro. But then, + * lex_stack needed to be global... + */ + return lex_stack; } - /* STATE MACHINES * -------------- @@ -297,7 +487,7 @@ is_integer( /* Check that all the remaining characters are digits */ for (; lexeme[i] != '\0'; i++) { - if (!isdigit((unsigned char)lexeme[i])) + if (!isdigit((u_char)lexeme[i])) return FALSE; } @@ -322,7 +512,7 @@ is_u_int( int is_hex; i = 0; - if ('0' == lexeme[i] && 'x' == tolower((unsigned char)lexeme[i + 1])) { + if ('0' == lexeme[i] && 'x' == tolower((u_char)lexeme[i + 1])) { i += 2; is_hex = TRUE; } else { @@ -331,9 +521,9 @@ is_u_int( /* Check that all the remaining characters are digits */ for (; lexeme[i] != '\0'; i++) { - if (is_hex && !isxdigit((unsigned char)lexeme[i])) + if (is_hex && !isxdigit((u_char)lexeme[i])) return FALSE; - if (!is_hex && !isdigit((unsigned char)lexeme[i])) + if (!is_hex && !isdigit((u_char)lexeme[i])) return FALSE; } @@ -357,14 +547,14 @@ is_double( i++; /* Read the integer part */ - for (; lexeme[i] && isdigit((unsigned char)lexeme[i]); i++) + for (; lexeme[i] && isdigit((u_char)lexeme[i]); i++) num_digits++; /* Check for the optional decimal point */ if ('.' == lexeme[i]) { i++; /* Check for any digits after the decimal point */ - for (; lexeme[i] && isdigit((unsigned char)lexeme[i]); i++) + for (; lexeme[i] && isdigit((u_char)lexeme[i]); i++) num_digits++; } @@ -380,7 +570,7 @@ is_double( return 1; /* There is still more input, read the exponent */ - if ('e' == tolower((unsigned char)lexeme[i])) + if ('e' == tolower((u_char)lexeme[i])) i++; else return 0; @@ -390,7 +580,7 @@ is_double( i++; /* Now read the exponent part */ - while (lexeme[i] && isdigit((unsigned char)lexeme[i])) + while (lexeme[i] && isdigit((u_char)lexeme[i])) i++; /* Check if we are done */ @@ -455,7 +645,7 @@ create_string_token( * ignore end of line whitespace */ pch = lexeme; - while (*pch && isspace((unsigned char)*pch)) + while (*pch && isspace((u_char)*pch)) pch++; if (!*pch) { @@ -476,37 +666,31 @@ create_string_token( * value representing the token or type. */ int -yylex( - struct FILE_INFO *ip_file - ) +yylex(void) { static follby followedby = FOLLBY_TOKEN; - size_t i; + int i; int instring; int yylval_was_set; int converted; int token; /* The return value */ int ch; - if (input_from_file) - ip_file = fp[curr_include_level]; instring = FALSE; yylval_was_set = FALSE; do { /* Ignore whitespace at the beginning */ - while (EOF != (ch = get_next_char(ip_file)) && + while (EOF != (ch = lex_getch(lex_stack)) && isspace(ch) && !is_EOC(ch)) + ; /* Null Statement */ if (EOF == ch) { - if (!input_from_file || curr_include_level <= 0) + if ( ! lex_pop_file()) return 0; - - FCLOSE(fp[curr_include_level]); - ip_file = fp[--curr_include_level]; token = T_EOC; goto normal_return; @@ -531,15 +715,14 @@ yylex( yytext[1] = '\0'; goto normal_return; } else - push_back_char(ip_file, ch); + lex_ungetch(ch, lex_stack); /* save the position of start of the token */ - ip_file->prev_token_line_no = ip_file->line_no; - ip_file->prev_token_col_no = ip_file->col_no; + lex_stack->tokpos = lex_stack->curpos; /* Read in the lexeme */ i = 0; - while (EOF != (ch = get_next_char(ip_file))) { + while (EOF != (ch = lex_getch(lex_stack))) { yytext[i] = (char)ch; @@ -553,7 +736,7 @@ yylex( /* Read the rest of the line on reading a start of comment character */ if ('#' == ch) { - while (EOF != (ch = get_next_char(ip_file)) + while (EOF != (ch = lex_getch(lex_stack)) && '\n' != ch) ; /* Null Statement */ break; @@ -571,7 +754,7 @@ yylex( */ if ('"' == ch) { instring = TRUE; - while (EOF != (ch = get_next_char(ip_file)) && + while (EOF != (ch = lex_getch(lex_stack)) && ch != '"' && ch != '\n') { yytext[i++] = (char)ch; if (i >= COUNTOF(yytext)) @@ -583,18 +766,15 @@ yylex( * not be pushed back, so we read another char. */ if ('"' == ch) - ch = get_next_char(ip_file); + ch = lex_getch(lex_stack); } /* Pushback the last character read that is not a part - * of this lexeme. - * If the last character read was an EOF, pushback a - * newline character. This is to prevent a parse error - * when there is no newline at the end of a file. + * of this lexeme. This fails silently if ch is EOF, + * but then the EOF condition persists and is handled on + * the next turn by the include stack mechanism. */ - if (EOF == ch) - push_back_char(ip_file, '\n'); - else - push_back_char(ip_file, ch); + lex_ungetch(ch, lex_stack); + yytext[i] = '\0'; } while (i == 0); @@ -627,7 +807,7 @@ yylex( msyslog(LOG_ERR, "Integer cannot be represented: %s", yytext); - if (input_from_file) { + if (lex_from_file()) { exit(1); } else { /* force end of parsing */ @@ -640,7 +820,7 @@ yylex( } else if (is_u_int(yytext)) { yylval_was_set = TRUE; if ('0' == yytext[0] && - 'x' == tolower((unsigned char)yytext[1])) + 'x' == tolower((unsigned long)yytext[1])) converted = sscanf(&yytext[2], "%x", &yylval.U_int); else @@ -650,7 +830,7 @@ yylex( msyslog(LOG_ERR, "U_int cannot be represented: %s", yytext); - if (input_from_file) { + if (lex_from_file()) { exit(1); } else { /* force end of parsing */ @@ -735,14 +915,14 @@ lex_too_long: yytext[min(sizeof(yytext) - 1, 50)] = 0; msyslog(LOG_ERR, "configuration item on line %d longer than limit of %lu, began with '%s'", - ip_file->line_no, (u_long)min(sizeof(yytext) - 1, 50), + lex_stack->curpos.nline, (u_long)min(sizeof(yytext) - 1, 50), yytext); /* * If we hit the length limit reading the startup configuration * file, abort. */ - if (input_from_file) + if (lex_from_file()) exit(sizeof(yytext) - 1); /* diff --git a/ntpd/ntp_scanner.h b/ntpd/ntp_scanner.h index 67976371d8ff0..11bbfe914be56 100644 --- a/ntpd/ntp_scanner.h +++ b/ntpd/ntp_scanner.h @@ -83,22 +83,28 @@ typedef enum { typedef u_int32 scan_state; +struct LCPOS { + int nline; + int ncol; +}; -/* Structure to hold a filename, file pointer and positional info */ +/* Structure to hold a filename, file pointer and positional info. + * Instances are dynamically allocated, and the file name is copied by + * value into a dynamic extension of the 'fname' array. (Which *must* be + * the last field for that reason!) + */ struct FILE_INFO { - const char * fname; /* Path to the file */ - FILE * fd; /* File Descriptor */ - int line_no; /* Line Number */ - int col_no; /* Column Number */ - int prev_line_col_no; /* Col No on the - previous line when a - '\n' was seen */ - int prev_token_line_no; /* Line at start of - token */ - int prev_token_col_no; /* Col No at start of - token */ - int err_line_no; - int err_col_no; + struct FILE_INFO * st_next; /* next on stack */ + FILE * fpi; /* File Descriptor */ + int force_eof; /* locked or not */ + int backch; /* ungetch buffer */ + + struct LCPOS curpos; /* current scan position */ + struct LCPOS bakpos; /* last line end for ungetc */ + struct LCPOS tokpos; /* current token position */ + struct LCPOS errpos; /* error position */ + + char fname[1]; /* (formal only) buffered name */ }; @@ -106,25 +112,31 @@ struct FILE_INFO { * ------------------------ */ extern config_tree cfgt; /* Parser output stored here */ -extern int curr_include_level; /* The current include level */ /* VARIOUS EXTERNAL DECLARATIONS * ----------------------------- */ extern int old_config_style; -extern int input_from_file; -extern struct FILE_INFO *fp[]; /* VARIOUS SUBROUTINE DECLARATIONS * ------------------------------- */ extern const char *keyword(int token); extern char *quote_if_needed(char *str); -int yylex(struct FILE_INFO *); +int yylex(void); + +/* managing the input source stack itself */ +extern int/*BOOL*/ lex_init_stack(const char * path, const char * mode); +extern void lex_drop_stack(void); +extern int/*BOOL*/ lex_flush_stack(void); + +/* add/remove a nested input source */ +extern int/*BOOL*/ lex_push_file(const char * path, const char * mode); +extern int/*BOOL*/ lex_pop_file(void); -struct FILE_INFO *F_OPEN(const char *path, const char *mode); -int FGETC(struct FILE_INFO *stream); -int UNGETC(int ch, struct FILE_INFO *stream); -int FCLOSE(struct FILE_INFO *stream); +/* input stack state query functions */ +extern size_t lex_level(void); +extern int/*BOOL*/ lex_from_file(void); +extern struct FILE_INFO * lex_current(void); #endif /* NTP_SCANNER_H */ diff --git a/ntpd/ntp_timer.c b/ntpd/ntp_timer.c index 958c8db394003..5cbb892e3ddd2 100644 --- a/ntpd/ntp_timer.c +++ b/ntpd/ntp_timer.c @@ -41,6 +41,7 @@ #define TC_ERR (-1) #endif + static void check_leapsec(u_int32, const time_t*, int/*BOOL*/); /* @@ -110,7 +111,7 @@ static RETSIGTYPE alarming (int); static timer_t timer_id; typedef struct itimerspec intervaltimer; # define itv_frac tv_nsec -# else +# else typedef struct itimerval intervaltimer; # define itv_frac tv_usec # endif @@ -151,7 +152,7 @@ set_timer_or_die( /* * reinit_timer - reinitialize interval timer after a clock step. */ -void +void reinit_timer(void) { #if !defined(SYS_WINNT) && !defined(VMS) @@ -211,7 +212,7 @@ init_timer(void) } # endif signal_no_reset(SIGALRM, alarming); - itimer.it_interval.tv_sec = + itimer.it_interval.tv_sec = itimer.it_value.tv_sec = (1 << EVENT_TIMEOUT); itimer.it_interval.itv_frac = itimer.it_value.itv_frac = 0; set_timer_or_die(&itimer); @@ -228,7 +229,7 @@ init_timer(void) #else /* SYS_WINNT follows */ /* * Set up timer interrupts for every 2**EVENT_TIMEOUT seconds - * Under Windows/NT, + * Under Windows/NT, */ WaitableTimerHandle = CreateWaitableTimer(NULL, FALSE, NULL); @@ -341,9 +342,9 @@ timer(void) if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL && current_time > orphwait) { if (sys_leap == LEAP_NOTINSYNC) { - sys_leap = LEAP_NOWARNING; + set_sys_leap(LEAP_NOWARNING); #ifdef AUTOKEY - if (crypto_flags) + if (crypto_flags) crypto_update(); #endif /* AUTOKEY */ } @@ -370,11 +371,11 @@ timer(void) if (sys_leap != LEAP_NOTINSYNC) { if (leapsec >= LSPROX_ANNOUNCE && leapdif) { if (leapdif > 0) - sys_leap = LEAP_ADDSECOND; + set_sys_leap(LEAP_ADDSECOND); else - sys_leap = LEAP_DELSECOND; + set_sys_leap(LEAP_DELSECOND); } else { - sys_leap = LEAP_NOWARNING; + set_sys_leap(LEAP_NOWARNING); } } @@ -472,7 +473,7 @@ alarming( # endif # ifdef DEBUG if (debug >= 4) - write(1, msg, strlen(msg)); + (void)(-1 == write(1, msg, strlen(msg))); # endif } #endif /* SYS_WINNT */ @@ -496,44 +497,162 @@ timer_clr_stats(void) timer_timereset = current_time; } + +static void +check_leap_sec_in_progress( const leap_result_t *lsdata ) { + int prv_leap_sec_in_progress = leap_sec_in_progress; + leap_sec_in_progress = lsdata->tai_diff && (lsdata->ddist < 3); + + /* if changed we may have to update the leap status sent to clients */ + if (leap_sec_in_progress != prv_leap_sec_in_progress) + set_sys_leap(sys_leap); +} + + static void check_leapsec( u_int32 now , const time_t * tpiv , int/*BOOL*/ reset) { + static const char leapmsg_p_step[] = + "Positive leap second, stepped backward."; + static const char leapmsg_p_slew[] = + "Positive leap second, no step correction. " + "System clock will be inaccurate for a long time."; + + static const char leapmsg_n_step[] = + "Negative leap second, stepped forward."; + static const char leapmsg_n_slew[] = + "Negative leap second, no step correction. " + "System clock will be inaccurate for a long time."; + leap_result_t lsdata; u_int32 lsprox; - +#ifdef AUTOKEY + int/*BOOL*/ update_autokey = FALSE; +#endif + #ifndef SYS_WINNT /* WinNT port has its own leap second handling */ # ifdef KERNEL_PLL leapsec_electric(pll_control && kern_enable); # else leapsec_electric(0); # endif -#endif +#endif +#ifdef LEAP_SMEAR + leap_smear.enabled = leap_smear_intv != 0; +#endif if (reset) { lsprox = LSPROX_NOWARN; leapsec_reset_frame(); memset(&lsdata, 0, sizeof(lsdata)); - } else if (leapsec_query(&lsdata, now, tpiv)) { + } else { + int fired = leapsec_query(&lsdata, now, tpiv); + + DPRINTF(1, ("*** leapsec_query: fired %i, now %u (0x%08X), tai_diff %i, ddist %u\n", + fired, now, now, lsdata.tai_diff, lsdata.ddist)); + +#ifdef LEAP_SMEAR + leap_smear.in_progress = 0; + leap_smear.doffset = 0.0; + + if (leap_smear.enabled) { + if (lsdata.tai_diff) { + if (leap_smear.interval == 0) { + leap_smear.interval = leap_smear_intv; + leap_smear.intv_end = lsdata.ttime.Q_s; + leap_smear.intv_start = leap_smear.intv_end - leap_smear.interval; + DPRINTF(1, ("*** leapsec_query: setting leap_smear interval %li, begin %.0f, end %.0f\n", + leap_smear.interval, leap_smear.intv_start, leap_smear.intv_end)); + } + } + else { + if (leap_smear.interval) + DPRINTF(1, ("*** leapsec_query: clearing leap_smear interval\n")); + leap_smear.interval = 0; + } + + if (leap_smear.interval) { + double dtemp = now; + if (dtemp >= leap_smear.intv_start && dtemp <= leap_smear.intv_end) { + double leap_smear_time = dtemp - leap_smear.intv_start; + /* + * For now we just do a linear interpolation over the smear interval + */ +#if 0 + // linear interpolation + leap_smear.doffset = -(leap_smear_time * lsdata.tai_diff / leap_smear.interval); +#else + // Google approach: lie(t) = (1.0 - cos(pi * t / w)) / 2.0 + leap_smear.doffset = -((double) lsdata.tai_diff - cos( M_PI * leap_smear_time / leap_smear.interval)) / 2.0; +#endif + /* + * TODO see if we're inside an inserted leap second, so we need to compute + * leap_smear.doffset = 1.0 - leap_smear.doffset + */ + leap_smear.in_progress = 1; +#if 0 && defined( DEBUG ) + msyslog(LOG_NOTICE, "*** leapsec_query: [%.0f:%.0f] (%li), now %u (%.0f), smear offset %.6f ms\n", + leap_smear.intv_start, leap_smear.intv_end, leap_smear.interval, + now, leap_smear_time, leap_smear.doffset); +#else + DPRINTF(1, ("*** leapsec_query: [%.0f:%.0f] (%li), now %u (%.0f), smear offset %.6f ms\n", + leap_smear.intv_start, leap_smear.intv_end, leap_smear.interval, + now, leap_smear_time, leap_smear.doffset)); +#endif + + } + } + } + else + leap_smear.interval = 0; + + /* + * Update the current leap smear offset, eventually 0.0 if outside smear interval. + */ + DTOLFP(leap_smear.doffset, &leap_smear.offset); + +#endif /* LEAP_SMEAR */ + + if (fired) { /* Full hit. Eventually step the clock, but always * announce the leap event has happened. */ + const char *leapmsg = NULL; if (lsdata.warped < 0) { - step_systime(lsdata.warped); - msyslog(LOG_NOTICE, "Inserting positive leap second."); + if (clock_max_back > 0.0 && + clock_max_back < fabs(lsdata.warped)) { + step_systime(lsdata.warped); + leapmsg = leapmsg_p_step; + } else { + leapmsg = leapmsg_p_slew; + } } else if (lsdata.warped > 0) { - step_systime(lsdata.warped); - msyslog(LOG_NOTICE, "Inserting negative leap second."); + if (clock_max_fwd > 0.0 && + clock_max_fwd < fabs(lsdata.warped)) { + step_systime(lsdata.warped); + leapmsg = leapmsg_n_step; + } else { + leapmsg = leapmsg_n_slew; + } } + if (leapmsg) + msyslog(LOG_NOTICE, "%s", leapmsg); report_event(EVNT_LEAP, NULL, NULL); +#ifdef AUTOKEY + update_autokey = TRUE; +#endif lsprox = LSPROX_NOWARN; leapsec = LSPROX_NOWARN; sys_tai = lsdata.tai_offs; - } else { + } else { +#ifdef AUTOKEY + update_autokey = (sys_tai != lsdata.tai_offs); +#endif lsprox = lsdata.proximity; sys_tai = lsdata.tai_offs; + } } /* We guard against panic alarming during the red alert phase. @@ -563,8 +682,15 @@ check_leapsec( leapsec = lsprox; } - if (leapsec >= LSPROX_SCHEDULE) - leapdif = lsdata.tai_diff; - else - leapdif = 0; + if (leapsec >= LSPROX_SCHEDULE) + leapdif = lsdata.tai_diff; + else + leapdif = 0; + + check_leap_sec_in_progress(&lsdata); + +#ifdef AUTOKEY + if (update_autokey) + crypto_update_taichange(); +#endif } diff --git a/ntpd/ntpd-opts.c b/ntpd/ntpd-opts.c index 910689d1ea973..2d547a18de799 100644 --- a/ntpd/ntpd-opts.c +++ b/ntpd/ntpd-opts.c @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpd-opts.c) * - * It has been AutoGen-ed April 7, 2015 at 04:23:14 AM by AutoGen 5.18.5pre4 + * It has been AutoGen-ed June 29, 2015 at 04:28:19 PM by AutoGen 5.18.5 * From the definitions ntpd-opts.def * and the template file options * @@ -75,7 +75,7 @@ extern FILE * option_usage_fp; * static const strings for ntpd options */ static char const ntpd_opt_strs[3129] = -/* 0 */ "ntpd 4.2.8p2\n" +/* 0 */ "ntpd 4.2.8p3\n" "Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n" "This is free software. It is licensed for use, modification and\n" "redistribution under the terms of the NTP License, copies of which\n" @@ -205,12 +205,12 @@ static char const ntpd_opt_strs[3129] = /* 2900 */ "output version information and exit\0" /* 2936 */ "version\0" /* 2944 */ "NTPD\0" -/* 2949 */ "ntpd - NTP daemon program - Ver. 4.2.8p2\n" +/* 2949 */ "ntpd - NTP daemon program - Ver. 4.2.8p3\n" "Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n" "\t\t[ <server1> ... <serverN> ]\n\0" /* 3080 */ "http://bugs.ntp.org, bugs@ntp.org\0" /* 3114 */ "\n\0" -/* 3116 */ "ntpd 4.2.8p2"; +/* 3116 */ "ntpd 4.2.8p3"; /** * ipv4 option description with @@ -1331,7 +1331,7 @@ OPT_VALUE_SET_DEBUG_LEVEL++; (void)pOptDesc; (void)pOptions; } -/* extracted from optmain.tlib near line 1245 */ +/* extracted from optmain.tlib near line 1250 */ /** * The directory containing the data associated with ntpd. @@ -1443,11 +1443,11 @@ AO_gettext(char const * pz) if (option_xlateable_txt.field_ct != 0) { res = dgettext("libopts", pz); if (res == pz) - res = (char *)(void *)_(pz); + res = (char *)VOIDP(_(pz)); } else - res = (char *)(void *)_(pz); + res = (char *)VOIDP(_(pz)); #else - res = (char *)(void *)_(pz); + res = (char *)VOIDP(_(pz)); #endif if (res == pz) return res; @@ -1484,7 +1484,7 @@ translate_option_strings(void) * Do the translations. The first pointer follows the field count * field. The field count field is the size of a pointer. */ - char ** ppz = (char**)(void*)&(option_xlateable_txt); + char ** ppz = (char**)VOIDP(&(option_xlateable_txt)); int ix = option_xlateable_txt.field_ct; do { @@ -1494,16 +1494,16 @@ translate_option_strings(void) /* prevent re-translation and disable "libopts" domain lookup */ option_xlateable_txt.field_ct = 0; - coerce_it((void*)&(opts->pzCopyright)); - coerce_it((void*)&(opts->pzCopyNotice)); - coerce_it((void*)&(opts->pzFullVersion)); - coerce_it((void*)&(opts->pzUsageTitle)); - coerce_it((void*)&(opts->pzExplain)); - coerce_it((void*)&(opts->pzDetail)); + coerce_it(VOIDP(&(opts->pzCopyright))); + coerce_it(VOIDP(&(opts->pzCopyNotice))); + coerce_it(VOIDP(&(opts->pzFullVersion))); + coerce_it(VOIDP(&(opts->pzUsageTitle))); + coerce_it(VOIDP(&(opts->pzExplain))); + coerce_it(VOIDP(&(opts->pzDetail))); { tOptDesc * od = opts->pOptDesc; for (ix = opts->optCt; ix > 0; ix--, od++) - coerce_it((void*)&(od->pzText)); + coerce_it(VOIDP(&(od->pzText))); } } } @@ -1529,7 +1529,7 @@ static void bogus_function(void) { translate option names. */ /* referenced via ntpdOptions.pzCopyright */ - puts(_("ntpd 4.2.8p2\n\ + puts(_("ntpd 4.2.8p3\n\ Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\ This is free software. It is licensed for use, modification and\n\ redistribution under the terms of the NTP License, copies of which\n\ @@ -1670,7 +1670,7 @@ implied warranty.\n")); puts(_("output version information and exit")); /* referenced via ntpdOptions.pzUsageTitle */ - puts(_("ntpd - NTP daemon program - Ver. 4.2.8p2\n\ + puts(_("ntpd - NTP daemon program - Ver. 4.2.8p3\n\ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\ \t\t[ <server1> ... <serverN> ]\n")); @@ -1678,7 +1678,7 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\ puts(_("\n")); /* referenced via ntpdOptions.pzFullVersion */ - puts(_("ntpd 4.2.8p2")); + puts(_("ntpd 4.2.8p3")); /* referenced via ntpdOptions.pzFullUsage */ puts(_("<<<NOT-FOUND>>>")); @@ -1704,7 +1704,7 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\ #line 121 "../version.c" puts(_("Automated Options version %s\n" "\tCopyright (C) 1999-2014 by Bruce Korb - all rights reserved\n")); -#line 82 "../makeshell.c" +#line 87 "../makeshell.c" puts(_("(AutoOpts bug): %s.\n")); #line 90 "../reset.c" puts(_("optionResetOpt() called, but reset-option not configured")); @@ -1728,9 +1728,9 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\ puts(_("%s: Command line arguments required\n")); #line 43 "../alias.c" puts(_("%d %s%s options allowed\n")); -#line 89 "../makeshell.c" +#line 94 "../makeshell.c" puts(_("%s error %d (%s) calling %s for '%s'\n")); -#line 301 "../makeshell.c" +#line 306 "../makeshell.c" puts(_("interprocess pipe")); #line 168 "../version.c" puts(_("error: version option argument '%c' invalid. Use:\n" @@ -1808,9 +1808,9 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\ puts(_("Try '%s %s' for more information.\n")); #line 45 "../alias.c" puts(_("one %s%s option allowed\n")); -#line 203 "../makeshell.c" +#line 208 "../makeshell.c" puts(_("standard output")); -#line 938 "../makeshell.c" +#line 943 "../makeshell.c" puts(_("standard output")); #line 274 "../usage.c" puts(_("standard output")); @@ -1828,9 +1828,9 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\ puts(_("standard error")); #line 175 "../version.c" puts(_("standard error")); -#line 203 "../makeshell.c" +#line 208 "../makeshell.c" puts(_("write")); -#line 938 "../makeshell.c" +#line 943 "../makeshell.c" puts(_("write")); #line 273 "../usage.c" puts(_("write")); @@ -1882,7 +1882,7 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\ #line 380 "../usage.c" puts(_("Options are specified by doubled hyphens and their name or by a single\n" "hyphen and the flag character.\n")); -#line 916 "../makeshell.c" +#line 921 "../makeshell.c" puts(_("\n" "= = = = = = = =\n\n" "This incarnation of genshell will produce\n" diff --git a/ntpd/ntpd-opts.h b/ntpd/ntpd-opts.h index 682aebda41aff..21142d8c4de28 100644 --- a/ntpd/ntpd-opts.h +++ b/ntpd/ntpd-opts.h @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpd-opts.h) * - * It has been AutoGen-ed April 7, 2015 at 04:23:13 AM by AutoGen 5.18.5pre4 + * It has been AutoGen-ed June 29, 2015 at 04:28:18 PM by AutoGen 5.18.5 * From the definitions ntpd-opts.def * and the template file options * @@ -106,9 +106,9 @@ typedef enum { /** count of all options for ntpd */ #define OPTION_CT 38 /** ntpd version */ -#define NTPD_VERSION "4.2.8p2" +#define NTPD_VERSION "4.2.8p3" /** Full ntpd version text */ -#define NTPD_FULL_VERSION "ntpd 4.2.8p2" +#define NTPD_FULL_VERSION "ntpd 4.2.8p3" /** * Interface defines for all options. Replace "n" with the UPPER_CASED diff --git a/ntpd/ntpd.1ntpdman b/ntpd/ntpd.1ntpdman index 5ded89b0cac00..c231b7fd84865 100644 --- a/ntpd/ntpd.1ntpdman +++ b/ntpd/ntpd.1ntpdman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpd 1ntpdman "07 Apr 2015" "4.2.8p2" "User Commands" +.TH ntpd 1ntpdman "29 Jun 2015" "4.2.8p3" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-TQays3/ag-5Qaqr3) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-LZaapD/ag-XZa4nD) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:25:45 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:24 PM by AutoGen 5.18.5 .\" From the definitions ntpd-opts.def .\" and the template file agman-cmd.tpl .SH NAME @@ -59,7 +59,7 @@ with future gigahertz CPU clocks and gigabit LANs. Ordinarily, \f\*[B-Font]ntpd\fP reads the -\fCntp.conf\fR(5)\f[] +\fCntp.conf\f[]\fR(5)\f[] configuration file at startup time in order to determine the synchronization sources and operating modes. It is also possible to @@ -78,7 +78,7 @@ then \f\*[B-Font]ntpd\fP will attempt to read its configuration from the NetInfo if the default -\fCntp.conf\fR(5)\f[] +\fCntp.conf\f[]\fR(5)\f[] file cannot be read and no file is specified by the \f\*[B-Font]\-c\f[] @@ -93,9 +93,9 @@ configuration options altered while the \f\*[B-Font]ntpd\fP is running using the -\fCntpq\fR(1ntpqmdoc)\f[] +\fCntpq\f[]\fR(1ntpqmdoc)\f[] and -\fCntpdc\fR(1ntpdcmdoc)\f[] +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[] utility programs. .sp \n(Ppu .ne 2 @@ -103,11 +103,11 @@ utility programs. When \f\*[B-Font]ntpd\fP starts it looks at the value of -\fCumask\fR(2)\f[], +\fCumask\f[]\fR(2)\f[], and if zero \f\*[B-Font]ntpd\fP will set the -\fCumask\fR(2)\f[] +\fCumask\f[]\fR(2)\f[] to 022. .SH "OPTIONS" .TP @@ -472,7 +472,7 @@ keyword with the \f\*[B-Font]server\f[] configuration command, as described in -\fCntp.conf\fR(5)\f[]. +\fCntp.conf\f[]\fR(5)\f[]. .sp \n(Ppu .ne 2 @@ -601,9 +601,9 @@ when you have permission to do so from the owner of the target host. Finally, in the past many startup scripts would run -\fCntpdate\fR(1ntpdatemdoc)\f[] +\fCntpdate\f[]\fR(1ntpdatemdoc)\f[] to get the system clock close to correct before starting -\fCntpd\fR(1ntpdmdoc)\f[], +\fCntpd\f[]\fR(1ntpdmdoc)\f[], but this was never more than a mediocre hack and is no longer needed. If you are following the instructions in \fIStarting NTP (Best Current Practice)\f[] @@ -611,12 +611,12 @@ and you still need to set the system time before starting \f\*[B-Font]ntpd\fP, please open a bug report and document what is going on, and then look at using -\fCsntp\fR(1sntpmdoc)\f[]. +\fCsntp\f[]\fR(1sntpmdoc)\f[]. .sp \n(Ppu .ne 2 There is a way to start -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] that often addresses all of the problems mentioned above. .SS "Starting NTP (Best Current Practice)" First, use the @@ -630,14 +630,14 @@ entries. If you can also keep a good \fIntp.drift\f[] file then -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] will effectively "warm-start" and your system's clock will be stable in under 11 seconds' time. .sp \n(Ppu .ne 2 As soon as possible in the startup sequence, start -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] with at least the \f\*[B-Font]\-g\f[] and perhaps the @@ -646,7 +646,7 @@ options. Then, start the rest of your "normal" processes. This will give -\fCntpd\fR(1ntpdmdoc)\f[] +\fCntpd\f[]\fR(1ntpdmdoc)\f[] as much time as possible to get the system's clock synchronized and stable. .sp \n(Ppu .ne 2 @@ -658,13 +658,13 @@ or database servers that require monotonically-increasing time, run -\fCntp-wait\fR(1ntp-waitmdoc)\f[] +\fCntp-wait\f[]\fR(1ntp-waitmdoc)\f[] as late as possible in the boot sequence (perhaps with the \f\*[B-Font]\-v\f[] flag) and after -\fCntp-wait\fR(1ntp-waitmdoc)\f[] +\fCntp-wait\f[]\fR(1ntp-waitmdoc)\f[] exits successfully it is as safe as it will ever be to start any process that require stable time. @@ -749,11 +749,11 @@ In some cases it may not be practical for \f\*[B-Font]ntpd\fP to run continuously. A common workaround has been to run the -\fCntpdate\fR(1ntpdatemdoc)\f[] +\fCntpdate\f[]\fR(1ntpdatemdoc)\f[] or -\fCsntp\fR(1sntpmdoc)\f[] +\fCsntp\f[]\fR(1sntpmdoc)\f[] programs from a -\fCcron\fR(8)\f[] +\fCcron\f[]\fR(8)\f[] job at designated times. However, these programs do not have the crafted signal @@ -780,7 +780,7 @@ If nothing is heard after a couple of minutes, the daemon times out and exits. After a suitable period of mourning, the -\fCntpdate\fR(1ntpdatemdoc)\f[] +\fCntpdate\f[]\fR(1ntpdatemdoc)\f[] program will be retired. .sp \n(Ppu @@ -891,7 +891,7 @@ The filter is activated by the command and \f\*[B-Font]huffpuff\f[] keyword, as described in -\fCntp.conf\fR(5)\f[]. +\fCntp.conf\f[]\fR(5)\f[]. .SH "ENVIRONMENT" See \fBOPTION PRESETS\fP for configuration environment variables. .SH FILES @@ -923,11 +923,11 @@ libopts had an internal operational error. Please report it to autogen-users@lists.sourceforge.net. Thank you. .PP .SH "SEE ALSO" -\fCntp.conf\fR(5)\f[], -\fCntpdate\fR(1ntpdatemdoc)\f[], -\fCntpdc\fR(1ntpdcmdoc)\f[], -\fCntpq\fR(1ntpqmdoc)\f[], -\fCsntp\fR(1sntpmdoc)\f[] +\fCntp.conf\f[]\fR(5)\f[], +\fCntpdate\f[]\fR(1ntpdatemdoc)\f[], +\fCntpdc\f[]\fR(1ntpdcmdoc)\f[], +\fCntpq\f[]\fR(1ntpqmdoc)\f[], +\fCsntp\f[]\fR(1sntpmdoc)\f[] .sp \n(Ppu .ne 2 diff --git a/ntpd/ntpd.1ntpdmdoc b/ntpd/ntpd.1ntpdmdoc index 14b38e40a8611..08d7655dff1fc 100644 --- a/ntpd/ntpd.1ntpdmdoc +++ b/ntpd/ntpd.1ntpdmdoc @@ -1,9 +1,9 @@ -.Dd April 7 2015 +.Dd June 29 2015 .Dt NTPD 1ntpdmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:26:02 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:41 PM by AutoGen 5.18.5 .\" From the definitions ntpd-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/ntpd/ntpd.html b/ntpd/ntpd.html index 8919ee90d241a..7af6d9859f95b 100644 --- a/ntpd/ntpd.html +++ b/ntpd/ntpd.html @@ -39,7 +39,7 @@ The program can operate in any of several modes, including client/server, symmetric and broadcast modes, and with both symmetric-key and public-key cryptography. - <p>This document applies to version 4.2.8p2 of <code>ntpd</code>. + <p>This document applies to version 4.2.8p3 of <code>ntpd</code>. <ul class="menu"> <li><a accesskey="1" href="#ntpd-Description">ntpd Description</a>: Description @@ -220,7 +220,7 @@ the usage text by passing it through a pager program. used to select the program, defaulting to <span class="file">more</span>. Both will exit with a status code of 0. -<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p2-RC3 +<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p3-RC3 Usage: ntpd [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \ [ <server1> ... <serverN> ] Flg Arg Option-Name Description diff --git a/ntpd/ntpd.man.in b/ntpd/ntpd.man.in index d9497a3ec46ce..c7c4eecd2edc5 100644 --- a/ntpd/ntpd.man.in +++ b/ntpd/ntpd.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpd @NTPD_MS@ "07 Apr 2015" "4.2.8p2" "User Commands" +.TH ntpd @NTPD_MS@ "29 Jun 2015" "4.2.8p3" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-TQays3/ag-5Qaqr3) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-LZaapD/ag-XZa4nD) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:25:45 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:24 PM by AutoGen 5.18.5 .\" From the definitions ntpd-opts.def .\" and the template file agman-cmd.tpl .SH NAME @@ -59,7 +59,7 @@ with future gigahertz CPU clocks and gigabit LANs. Ordinarily, \f\*[B-Font]ntpd\fP reads the -\fCntp.conf\fR(5)\f[] +\fCntp.conf\f[]\fR(5)\f[] configuration file at startup time in order to determine the synchronization sources and operating modes. It is also possible to @@ -78,7 +78,7 @@ then \f\*[B-Font]ntpd\fP will attempt to read its configuration from the NetInfo if the default -\fCntp.conf\fR(5)\f[] +\fCntp.conf\f[]\fR(5)\f[] file cannot be read and no file is specified by the \f\*[B-Font]\-c\f[] @@ -93,9 +93,9 @@ configuration options altered while the \f\*[B-Font]ntpd\fP is running using the -\fCntpq\fR(@NTPQ_MS@)\f[] +\fCntpq\f[]\fR(@NTPQ_MS@)\f[] and -\fCntpdc\fR(@NTPDC_MS@)\f[] +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[] utility programs. .sp \n(Ppu .ne 2 @@ -103,11 +103,11 @@ utility programs. When \f\*[B-Font]ntpd\fP starts it looks at the value of -\fCumask\fR(2)\f[], +\fCumask\f[]\fR(2)\f[], and if zero \f\*[B-Font]ntpd\fP will set the -\fCumask\fR(2)\f[] +\fCumask\f[]\fR(2)\f[] to 022. .SH "OPTIONS" .TP @@ -472,7 +472,7 @@ keyword with the \f\*[B-Font]server\f[] configuration command, as described in -\fCntp.conf\fR(5)\f[]. +\fCntp.conf\f[]\fR(5)\f[]. .sp \n(Ppu .ne 2 @@ -601,9 +601,9 @@ when you have permission to do so from the owner of the target host. Finally, in the past many startup scripts would run -\fCntpdate\fR(@NTPDATE_MS@)\f[] +\fCntpdate\f[]\fR(@NTPDATE_MS@)\f[] to get the system clock close to correct before starting -\fCntpd\fR(@NTPD_MS@)\f[], +\fCntpd\f[]\fR(@NTPD_MS@)\f[], but this was never more than a mediocre hack and is no longer needed. If you are following the instructions in \fIStarting NTP (Best Current Practice)\f[] @@ -611,12 +611,12 @@ and you still need to set the system time before starting \f\*[B-Font]ntpd\fP, please open a bug report and document what is going on, and then look at using -\fCsntp\fR(@SNTP_MS@)\f[]. +\fCsntp\f[]\fR(@SNTP_MS@)\f[]. .sp \n(Ppu .ne 2 There is a way to start -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] that often addresses all of the problems mentioned above. .SS "Starting NTP (Best Current Practice)" First, use the @@ -630,14 +630,14 @@ entries. If you can also keep a good \fIntp.drift\f[] file then -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] will effectively "warm-start" and your system's clock will be stable in under 11 seconds' time. .sp \n(Ppu .ne 2 As soon as possible in the startup sequence, start -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] with at least the \f\*[B-Font]\-g\f[] and perhaps the @@ -646,7 +646,7 @@ options. Then, start the rest of your "normal" processes. This will give -\fCntpd\fR(@NTPD_MS@)\f[] +\fCntpd\f[]\fR(@NTPD_MS@)\f[] as much time as possible to get the system's clock synchronized and stable. .sp \n(Ppu .ne 2 @@ -658,13 +658,13 @@ or database servers that require monotonically-increasing time, run -\fCntp-wait\fR(@NTP_WAIT_MS@)\f[] +\fCntp-wait\f[]\fR(@NTP_WAIT_MS@)\f[] as late as possible in the boot sequence (perhaps with the \f\*[B-Font]\-v\f[] flag) and after -\fCntp-wait\fR(@NTP_WAIT_MS@)\f[] +\fCntp-wait\f[]\fR(@NTP_WAIT_MS@)\f[] exits successfully it is as safe as it will ever be to start any process that require stable time. @@ -749,11 +749,11 @@ In some cases it may not be practical for \f\*[B-Font]ntpd\fP to run continuously. A common workaround has been to run the -\fCntpdate\fR(@NTPDATE_MS@)\f[] +\fCntpdate\f[]\fR(@NTPDATE_MS@)\f[] or -\fCsntp\fR(@SNTP_MS@)\f[] +\fCsntp\f[]\fR(@SNTP_MS@)\f[] programs from a -\fCcron\fR(8)\f[] +\fCcron\f[]\fR(8)\f[] job at designated times. However, these programs do not have the crafted signal @@ -780,7 +780,7 @@ If nothing is heard after a couple of minutes, the daemon times out and exits. After a suitable period of mourning, the -\fCntpdate\fR(@NTPDATE_MS@)\f[] +\fCntpdate\f[]\fR(@NTPDATE_MS@)\f[] program will be retired. .sp \n(Ppu @@ -891,7 +891,7 @@ The filter is activated by the command and \f\*[B-Font]huffpuff\f[] keyword, as described in -\fCntp.conf\fR(5)\f[]. +\fCntp.conf\f[]\fR(5)\f[]. .SH "ENVIRONMENT" See \fBOPTION PRESETS\fP for configuration environment variables. .SH FILES @@ -923,11 +923,11 @@ libopts had an internal operational error. Please report it to autogen-users@lists.sourceforge.net. Thank you. .PP .SH "SEE ALSO" -\fCntp.conf\fR(5)\f[], -\fCntpdate\fR(@NTPDATE_MS@)\f[], -\fCntpdc\fR(@NTPDC_MS@)\f[], -\fCntpq\fR(@NTPQ_MS@)\f[], -\fCsntp\fR(@SNTP_MS@)\f[] +\fCntp.conf\f[]\fR(5)\f[], +\fCntpdate\f[]\fR(@NTPDATE_MS@)\f[], +\fCntpdc\f[]\fR(@NTPDC_MS@)\f[], +\fCntpq\f[]\fR(@NTPQ_MS@)\f[], +\fCsntp\f[]\fR(@SNTP_MS@)\f[] .sp \n(Ppu .ne 2 diff --git a/ntpd/ntpd.mdoc.in b/ntpd/ntpd.mdoc.in index 4458532848871..7d87d85bbc272 100644 --- a/ntpd/ntpd.mdoc.in +++ b/ntpd/ntpd.mdoc.in @@ -1,9 +1,9 @@ -.Dd April 7 2015 +.Dd June 29 2015 .Dt NTPD @NTPD_MS@ User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc) .\" -.\" It has been AutoGen-ed April 7, 2015 at 04:26:02 AM by AutoGen 5.18.5pre4 +.\" It has been AutoGen-ed June 29, 2015 at 04:30:41 PM by AutoGen 5.18.5 .\" From the definitions ntpd-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME diff --git a/ntpd/rc_cmdlength.c b/ntpd/rc_cmdlength.c new file mode 100644 index 0000000000000..2807d2acd73e7 --- /dev/null +++ b/ntpd/rc_cmdlength.c @@ -0,0 +1,35 @@ +#include <config.h> + +#if HAVE_UNISTD_H +# include <unistd.h> +#endif + + +/* Bug 2853 */ +/* evaluate the length of the command sequence. This breaks at the first + * char that is not >= SPACE and <= 127 after trimming from the right. + */ +size_t +remoteconfig_cmdlength( + const char *src_buf, + const char *src_end + ) +{ + const char *scan; + unsigned char ch; + + /* trim whitespace & garbage from the right */ + while (src_end != src_buf) { + ch = src_end[-1]; + if (ch > ' ' && ch < 128) + break; + --src_end; + } + /* now do a forward scan */ + for (scan = src_buf; scan != src_end; ++scan) { + ch = scan[0]; + if ((ch < ' ' || ch >= 128) && ch != '\t') + break; + } + return (size_t)(scan - src_buf); +} diff --git a/ntpd/refclock_gpsdjson.c b/ntpd/refclock_gpsdjson.c index 2171a4fff7886..0a88cece4d24a 100644 --- a/ntpd/refclock_gpsdjson.c +++ b/ntpd/refclock_gpsdjson.c @@ -6,36 +6,121 @@ * * Heavily inspired by refclock_nmea.c * + * Special thanks to Gary Miller and Hal Murray for their comments and + * ideas. + * * Note: This will currently NOT work with Windows due to some * limitations: * * - There is no GPSD for Windows. (There is an unofficial port to * cygwin, but Windows is not officially supported.) * - * - To work properly, this driver needs PPS and TPV sentences from - * GPSD. I don't see how the cygwin port should deal with that. + * - To work properly, this driver needs PPS and TPV/TOFF sentences + * from GPSD. I don't see how the cygwin port should deal with the + * PPS signal. * * - The device name matching must be done in a different way for * Windows. (Can be done with COMxx matching, as done for NMEA.) * * Apart from those minor hickups, once GPSD has been fully ported to - * Windows, there's no reason why this should not work there ;-) + * Windows, there's no reason why this should not work there ;-) If this + * is ever to happen at all is a different question. + * + * --------------------------------------------------------------------- + * + * This driver works slightly different from most others, as the PPS + * information (if available) is also coming from GPSD via the data + * connection. This makes using both the PPS data and the serial data + * easier, but OTOH it's not possible to use the ATOM driver to feed a + * raw PPS stream to the core of NTPD. + * + * To go around this, the driver can use a secondary clock unit + * (units>=128) that operate in tandem with the primary clock unit + * (unit%128). The primary clock unit does all the IO stuff and data + * decoding; if a a secondary unit is attached to a primary unit, this + * secondary unit is feed with the PPS samples only and can act as a PPS + * source to the clock selection. + * + * The drawback is that the primary unit must be present for the + * secondary unit to work. + * + * This design is a compromise to reduce the IO load for both NTPD and + * GPSD; it also ensures that data is transmitted and evaluated only + * once on the side of NTPD. + * + * --------------------------------------------------------------------- + * + * trouble shooting hints: + * + * Enable and check the clock stats. Check if there are bad replies; + * there should be none. If there are actually bad replies, then the + * driver cannot parse all JSON records from GPSD, and some record + * types are vital for the operation of the driver. This indicates a + * problem on the protocol level. + * + * When started on the command line with a debug level >= 2, the + * driver dumps the raw received data and the parser input to + * stdout. Since the debug level is global, NTPD starts to create a + * *lot* of output. It makes sense to pipe it through '(f)grep + * GPSD_JSON' before writing the result to disk. + * + * A bit less intrusive is using netcat or telnet to connect to GPSD + * and snoop what NTPD would get. If you try this, you have to send a + * WATCH command to GPSD: + * + * ?WATCH={"device":"/dev/gps0","enable":true,"json":true,"pps":true};<CRLF> + * + * should show you what GPSD has to say to NTPD. Replace "/dev/gps0" + * with the device link used by GPSD, if necessary. */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif #include "ntp_types.h" -#if defined(REFCLOCK) && defined(CLOCK_GPSDJSON) && !defined(SYS_WINNT) +#if defined(REFCLOCK) && defined(CLOCK_GPSDJSON) && !defined(SYS_WINNT) /* ===================================================================== - * get the little JSMN library directly into our guts + * Get the little JSMN library directly into our guts. Use the 'parent + * link' feature for maximum speed. */ +#define JSMN_PARENT_LINKS #include "../libjsmn/jsmn.c" /* ===================================================================== + * JSON parsing stuff + */ + +#define JSMN_MAXTOK 350 +#define INVALID_TOKEN (-1) + +typedef struct json_ctx { + char * buf; + int ntok; + jsmntok_t tok[JSMN_MAXTOK]; +} json_ctx; + +typedef int tok_ref; + +/* Not all targets have 'long long', and not all of them have 'strtoll'. + * Sigh. We roll our own integer number parser. + */ +#ifdef HAVE_LONG_LONG +typedef signed long long int json_int; +typedef unsigned long long int json_uint; +#define JSON_INT_MAX LLONG_MAX +#define JSON_INT_MIN LLONG_MIN +#else +typedef signed long int json_int; +typedef unsigned long int json_uint; +#define JSON_INT_MAX LONG_MAX +#define JSON_INT_MIN LONG_MIN +#endif + +/* ===================================================================== * header stuff we need */ @@ -44,6 +129,7 @@ #include <fcntl.h> #include <string.h> #include <ctype.h> +#include <math.h> #include <sys/types.h> #include <sys/socket.h> @@ -66,6 +152,42 @@ #include "ntp_calendar.h" #include "timespecops.h" +/* get operation modes from mode word. + + * + SERIAL (default) evaluates only serial time information ('STI') as + * provided by TPV and TOFF records. TPV evaluation suffers from a + * bigger jitter than TOFF, sine it does not contain the receive time + * from GPSD and therefore the receive time of NTPD must be + * substituted for it. The network latency makes this a second rate + * guess. + * + * If TOFF records are detected in the data stream, the timing + * information is gleaned from this record -- it contains the local + * receive time stamp from GPSD and therefore eliminates the + * transmission latency between GPSD and NTPD. The timing information + * from TPV is ignored once a TOFF is detected or expected. + * + * TPV is still used to check the fix status, so the driver can stop + * feeding samples when GPSD says that the time information is + * effectively unreliable. + * + * + STRICT means only feed clock samples when a valid STI/PPS pair is + * available. Combines the reference time from STI with the pulse time + * from PPS. Masks the serial data jitter as long PPS is available, + * but can rapidly deteriorate once PPS drops out. + * + * + AUTO tries to use STI/PPS pairs if available for some time, and if + * this fails for too long switches back to STI only until the PPS + * signal becomes available again. See the HTML docs for this driver + * about the gotchas and why this is not the default. + */ +#define MODE_OP_MASK 0x03 +#define MODE_OP_STI 0 +#define MODE_OP_STRICT 1 +#define MODE_OP_AUTO 2 +#define MODE_OP_MAXVAL 2 +#define MODE_OP_MODE(x) ((x) & MODE_OP_MASK) + #define PRECISION (-9) /* precision assumed (about 2 ms) */ #define PPS_PRECISION (-20) /* precision assumed (about 1 us) */ #define REFID "GPSD" /* reference id */ @@ -76,9 +198,24 @@ #define TICKOVER_HIGH 120 #define LOGTHROTTLE 3600 -#define PPS_MAXCOUNT 30 -#define PPS_HIWAT 20 -#define PPS_LOWAT 10 +/* Primary channel PPS avilability dance: + * Every good PPS sample gets us a credit of PPS_INCCOUNT points, every + * bad/missing PPS sample costs us a debit of PPS_DECCOUNT points. When + * the account reaches the upper limit we change to a mode where only + * PPS-augmented samples are fed to the core; when the account drops to + * zero we switch to a mode where TPV-only timestamps are fed to the + * core. + * This reduces the chance of rapid alternation between raw and + * PPS-augmented time stamps. + */ +#define PPS_MAXCOUNT 60 /* upper limit of account */ +#define PPS_INCCOUNT 3 /* credit for good samples */ +#define PPS_DECCOUNT 1 /* debit for bad samples */ + +/* The secondary (PPS) channel uses a different strategy to avoid old + * PPS samples in the median filter. + */ +#define PPS2_MAXCOUNT 10 #ifndef BOOL # define BOOL int @@ -90,7 +227,11 @@ # define FALSE 0 #endif -/* some local typedefs : The NTPD formatting style cries for short type +#define PROTO_VERSION(hi,lo) \ + ((((uint32_t)(hi) << 16) & 0xFFFF0000u) | \ + ((uint32_t)(lo) & 0x0FFFFu)) + +/* some local typedefs: The NTPD formatting style cries for short type * names, and we provide them locally. Note:the suffix '_t' is reserved * for the standard; I use a capital T instead. */ @@ -116,9 +257,11 @@ static void gpsd_poll (int, peerT *); static void gpsd_control (int, const struct refclockstat *, struct refclockstat *, peerT *); static void gpsd_timer (int, peerT *); -static void gpsd_clockstats (int, peerT *); -static int myasprintf(char**, char const*, ...); +static int myasprintf(char**, char const*, ...) NTP_PRINTF(2, 3); + +static void enter_opmode(peerT *peer, int mode); +static void leave_opmode(peerT *peer, int mode); struct refclock refclock_gpsdjson = { gpsd_start, /* start up driver */ @@ -133,55 +276,86 @@ struct refclock refclock_gpsdjson = { /* ===================================================================== * our local clock unit and data */ -typedef struct gpsd_unit { - int unit; +struct gpsd_unit; +typedef struct gpsd_unit gpsd_unitT; + +struct gpsd_unit { + /* links for sharing between master/slave units */ + gpsd_unitT *next_unit; + size_t refcount; + + /* data for the secondary PPS channel */ + peerT *pps_peer; + + /* unit and operation modes */ + int unit; + int mode; + char *logname; /* cached name for log/print */ + char * device; /* device name of unit */ + /* current line protocol version */ - uint16_t proto_major; - uint16_t proto_minor; + uint32_t proto_version; - /* PPS time stamps */ + /* PPS time stamps primary + secondary channel */ l_fp pps_local; /* when we received the PPS message */ l_fp pps_stamp; /* related reference time */ l_fp pps_recvt; /* when GPSD detected the pulse */ + l_fp pps_stamp2;/* related reference time (secondary) */ + l_fp pps_recvt2;/* when GPSD detected the pulse (secondary)*/ + int ppscount; /* PPS counter (primary unit) */ + int ppscount2; /* PPS counter (secondary unit) */ - /* TPV (GPS data) time stamps */ - l_fp tpv_local; /* when we received the TPV message */ - l_fp tpv_stamp; /* effective GPS time stamp */ - l_fp tpv_recvt; /* when GPSD got the fix */ + /* TPV or TOFF serial time information */ + l_fp sti_local; /* when we received the TPV/TOFF message */ + l_fp sti_stamp; /* effective GPS time stamp */ + l_fp sti_recvt; /* when GPSD got the fix */ + + /* precision estimates */ + int16_t sti_prec; /* serial precision based on EPT */ + int16_t pps_prec; /* PPS precision from GPSD or above */ /* fudge values for correction, mirrored as 'l_fp' */ - l_fp pps_fudge; - l_fp tpv_fudge; + l_fp pps_fudge; /* PPS fudge primary channel */ + l_fp pps_fudge2; /* PPS fudge secondary channel */ + l_fp sti_fudge; /* TPV/TOFF serial data fudge */ /* Flags to indicate available data */ - int fl_tpv : 1; /* valid TPV seen (have time) */ + int fl_nosync: 1; /* GPSD signals bad quality */ + int fl_sti : 1; /* valid TPV/TOFF seen (have time) */ int fl_pps : 1; /* valid pulse seen */ + int fl_pps2 : 1; /* valid pulse seen for PPS channel */ + int fl_rawsti: 1; /* permit raw TPV/TOFF time stamps */ int fl_vers : 1; /* have protocol version */ int fl_watch : 1; /* watch reply seen */ - int fl_nsec : 1; /* have nanosec PPS info */ + /* protocol flags */ + int pf_nsec : 1; /* have nanosec PPS info */ + int pf_toff : 1; /* have TOFF record for timing */ /* admin stuff for sockets and device selection */ int fdt; /* current connecting socket */ addrinfoT * addr; /* next address to try */ u_int tickover; /* timeout countdown */ u_int tickpres; /* timeout preset */ - u_int ppscount; /* PPS mode up/down count */ - char * device; /* device name of unit */ /* tallies for the various events */ - u_int tc_good; /* good samples received */ - u_int tc_btime; /* bad time stamps */ - u_int tc_bdate; /* bad date strings */ - u_int tc_breply; /* bad replies */ u_int tc_recv; /* received known records */ + u_int tc_breply; /* bad replies / parsing errors */ + u_int tc_nosync; /* TPV / sample cycles w/o fix */ + u_int tc_sti_recv;/* received serial time info records */ + u_int tc_sti_used;/* used --^-- */ + u_int tc_pps_recv;/* received PPS timing info records */ + u_int tc_pps_used;/* used --^-- */ /* log bloat throttle */ u_int logthrottle;/* seconds to next log slot */ - /* record assemby buffer and saved length */ + /* The parse context for the current record */ + json_ctx json_parse; + + /* record assemby buffer and saved length */ int buflen; char buffer[MAX_PDU_LEN]; -} gpsd_unitT; +}; /* ===================================================================== * static local helpers forward decls @@ -195,6 +369,9 @@ static void gpsd_parse(peerT * const peer, static BOOL convert_ascii_time(l_fp * fp, const char * gps_time); static void save_ltc(clockprocT * const pp, const char * const tc); static int syslogok(clockprocT * const pp, gpsd_unitT * const up); +static void log_data(peerT *peer, const char *what, + const char *buf, size_t len); +static int16_t clamped_precision(int rawprec); /* ===================================================================== * local / static stuff @@ -202,15 +379,45 @@ static int syslogok(clockprocT * const pp, gpsd_unitT * const up); /* The logon string is actually the ?WATCH command of GPSD, using JSON * data and selecting the GPS device name we created from our unit - * number. [Note: This is a format string!] + * number. We have an old a newer version that request PPS (and TOFF) + * transmission. + * Note: These are actually format strings! */ -#define s_logon \ - "?WATCH={\"enable\":true,\"json\":true,\"device\":\"%s\"};\r\n" +static const char * const s_req_watch[2] = { + "?WATCH={\"device\":\"%s\",\"enable\":true,\"json\":true};\r\n", + "?WATCH={\"device\":\"%s\",\"enable\":true,\"json\":true,\"pps\":true};\r\n" +}; + +static const char * const s_req_version = + "?VERSION;\r\n"; -/* We keep a static list of network addresses for 'localhost:gpsd', and - * we try to connect to them in round-robin fashion. +/* We keep a static list of network addresses for 'localhost:gpsd' or a + * fallback alias of it, and we try to connect to them in round-robin + * fashion. The service lookup is done during the driver init + * function to minmise the impact of 'getaddrinfo()'. + * + * Alas, the init function is called even if there are no clocks + * configured for this driver. So it makes sense to defer the logging of + * any errors or other notifications until the first clock unit is + * started -- otherwise there might be syslog entries from a driver that + * is not used at all. */ -static addrinfoT * s_gpsd_addr; +static addrinfoT *s_gpsd_addr; +static gpsd_unitT *s_clock_units; + +/* list of service/socket names we want to resolve against */ +static const char * const s_svctab[][2] = { + { "localhost", "gpsd" }, + { "localhost", "2947" }, + { "127.0.0.1", "2947" }, + { NULL, NULL } +}; + +/* list of address resolution errors and index of service entry that + * finally worked. + */ +static int s_svcerr[sizeof(s_svctab)/sizeof(s_svctab[0])]; +static int s_svcidx; /* ===================================================================== * log throttling @@ -238,41 +445,122 @@ syslogok( static void gpsd_init(void) { - addrinfoT hints; - + addrinfoT hints; + int rc, idx; + + memset(s_svcerr, 0, sizeof(s_svcerr)); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_protocol = IPPROTO_TCP; hints.ai_socktype = SOCK_STREAM; - /* just take the first configured address of localhost... */ - if (getaddrinfo("localhost", "gpsd", &hints, &s_gpsd_addr)) + for (idx = 0; s_svctab[idx][0] && !s_gpsd_addr; idx++) { + rc = getaddrinfo(s_svctab[idx][0], s_svctab[idx][1], + &hints, &s_gpsd_addr); + s_svcerr[idx] = rc; + if (0 == rc) + break; s_gpsd_addr = NULL; + } + s_svcidx = idx; } /* --------------------------------------------------------------------- - * Start: allocate a unit pointer and set up the runtime data + * Init Check: flush pending log messages and check if we can proceed */ +static int/*BOOL*/ +gpsd_init_check(void) +{ + int idx; + + /* Check if there is something to log */ + if (s_svcidx == 0) + return (s_gpsd_addr != NULL); + + /* spool out the resolver errors */ + for (idx = 0; idx < s_svcidx; ++idx) { + msyslog(LOG_WARNING, + "GPSD_JSON: failed to resolve '%s:%s', rc=%d (%s)", + s_svctab[idx][0], s_svctab[idx][1], + s_svcerr[idx], gai_strerror(s_svcerr[idx])); + } + /* check if it was fatal, or if we can proceed */ + if (s_gpsd_addr == NULL) + msyslog(LOG_ERR, "%s", + "GPSD_JSON: failed to get socket address, giving up."); + else if (idx != 0) + msyslog(LOG_WARNING, + "GPSD_JSON: using '%s:%s' instead of '%s:%s'", + s_svctab[idx][0], s_svctab[idx][1], + s_svctab[0][0], s_svctab[0][1]); + + /* make sure this gets logged only once and tell if we can + * proceed or not + */ + s_svcidx = 0; + return (s_gpsd_addr != NULL); +} + +/* --------------------------------------------------------------------- + * Start: allocate a unit pointer and set up the runtime data + */ static int gpsd_start( int unit, peerT * peer) { - clockprocT * const pp = peer->procptr; - gpsd_unitT * const up = emalloc_zero(sizeof(*up)); + clockprocT * const pp = peer->procptr; + gpsd_unitT * up; + gpsd_unitT ** uscan = &s_clock_units; struct stat sb; - /* initialize the unit structure */ - up->fdt = -1; - up->addr = s_gpsd_addr; - up->tickpres = TICKOVER_LOW; + /* check if we can proceed at all or if init failed */ + if ( ! gpsd_init_check()) + return FALSE; + /* search for matching unit */ + while ((up = *uscan) != NULL && up->unit != (unit & 0x7F)) + uscan = &up->next_unit; + if (up == NULL) { + /* alloc unit, add to list and increment use count ASAP. */ + up = emalloc_zero(sizeof(*up)); + *uscan = up; + ++up->refcount; + + /* initialize the unit structure */ + up->logname = estrdup(refnumtoa(&peer->srcadr)); + up->unit = unit & 0x7F; + up->fdt = -1; + up->addr = s_gpsd_addr; + up->tickpres = TICKOVER_LOW; + + /* Create the device name and check for a Character + * Device. It's assumed that GPSD was started with the + * same link, so the names match. (If this is not + * practicable, we will have to read the symlink, if + * any, so we can get the true device file.) + */ + if (-1 == myasprintf(&up->device, "%s%u", + s_dev_stem, up->unit)) { + msyslog(LOG_ERR, "%s: clock device name too long", + up->logname); + goto dev_fail; + } + if (-1 == stat(up->device, &sb) || !S_ISCHR(sb.st_mode)) { + msyslog(LOG_ERR, "%s: '%s' is not a character device", + up->logname, up->device); + goto dev_fail; + } + } else { + /* All set up, just increment use count. */ + ++up->refcount; + } + /* setup refclock processing */ - up->unit = unit; pp->unitptr = (caddr_t)up; - pp->io.fd = -1; + pp->io.fd = -1; pp->io.clock_recv = gpsd_receive; pp->io.srcclock = peer; pp->io.datalen = 0; @@ -282,35 +570,39 @@ gpsd_start( memcpy(&pp->refid, REFID, 4); /* Initialize miscellaneous variables */ - peer->precision = PRECISION; + if (unit >= 128) + peer->precision = PPS_PRECISION; + else + peer->precision = PRECISION; - /* Create the device name and check for a Character Device. It's - * assumed that GPSD was started with the same link, so the - * names match. (If this is not practicable, we will have to - * read the symlink, if any, so we can get the true device - * file.) - */ - if (-1 == myasprintf(&up->device, "%s%u", s_dev_stem, unit)) { - msyslog(LOG_ERR, "%s clock device name too long", - refnumtoa(&peer->srcadr)); - goto dev_fail; - } - if (-1 == stat(up->device, &sb) || !S_ISCHR(sb.st_mode)) { - msyslog(LOG_ERR, "%s: '%s' is not a character device", - refnumtoa(&peer->srcadr), up->device); - goto dev_fail; + /* If the daemon name lookup failed, just give up now. */ + if (NULL == up->addr) { + msyslog(LOG_ERR, "%s: no GPSD socket address, giving up", + up->logname); + goto dev_fail; } + LOGIF(CLOCKINFO, (LOG_NOTICE, "%s: startup, device is '%s'", refnumtoa(&peer->srcadr), up->device)); + up->mode = MODE_OP_MODE(peer->ttl); + if (up->mode > MODE_OP_MAXVAL) + up->mode = 0; + if (unit >= 128) + up->pps_peer = peer; + else + enter_opmode(peer, up->mode); return TRUE; dev_fail: /* On failure, remove all UNIT ressources and declare defeat. */ INSIST (up); - free(up->device); - free(up); + if (!--up->refcount) { + *uscan = up->next_unit; + free(up->device); + free(up); + } pp->unitptr = (caddr_t)NULL; return FALSE; @@ -325,17 +617,38 @@ gpsd_shutdown( { clockprocT * const pp = peer->procptr; gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; + gpsd_unitT ** uscan = &s_clock_units; UNUSED_ARG(unit); - if (up) { - free(up->device); - free(up); + /* The unit pointer might have been removed already. */ + if (up == NULL) + return; + + /* now check if we must close IO resources */ + if (peer != up->pps_peer) { + if (-1 != pp->io.fd) { + DPRINTF(1, ("%s: closing clock, fd=%d\n", + up->logname, pp->io.fd)); + io_closeclock(&pp->io); + pp->io.fd = -1; + } + if (up->fdt != -1) + close(up->fdt); + } + /* decrement use count and eventually remove this unit. */ + if (!--up->refcount) { + /* unlink this unit */ + while (*uscan != NULL) + if (*uscan == up) + *uscan = up->next_unit; + else + uscan = &(*uscan)->next_unit; + free(up->logname); + free(up->device); + free(up); } pp->unitptr = (caddr_t)NULL; - if (-1 != pp->io.fd) - io_closeclock(&pp->io); - pp->io.fd = -1; LOGIF(CLOCKINFO, (LOG_NOTICE, "%s: shutdown", refnumtoa(&peer->srcadr))); } @@ -349,11 +662,16 @@ gpsd_receive( /* declare & init control structure ptrs */ peerT * const peer = rbufp->recv_peer; clockprocT * const pp = peer->procptr; - gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; + gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; const char *psrc, *esrc; char *pdst, *edst, ch; + /* log the data stream, if this is enabled */ + log_data(peer, "recv", (const char*)rbufp->recv_buffer, + (size_t)rbufp->recv_length); + + /* Since we're getting a raw stream data, we must assemble lines * in our receive buffer. We can't use neither 'refclock_gtraw' * not 'refclock_gtlin' here... We process chars until we reach @@ -375,6 +693,7 @@ gpsd_receive( --pdst; *pdst = '\0'; /* process data and reset buffer */ + up->buflen = pdst - up->buffer; gpsd_parse(peer, &rbufp->recv_time); pdst = up->buffer; } else if (pdst != edst) { @@ -390,49 +709,80 @@ gpsd_receive( /* ------------------------------------------------------------------ */ static void -gpsd_poll( - int unit, - peerT * peer) +poll_primary( + peerT * const peer , + clockprocT * const pp , + gpsd_unitT * const up ) { - clockprocT * const pp = peer->procptr; - gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; - u_int tc_max; - - ++pp->polls; - - /* find the dominant error */ - tc_max = max(up->tc_btime, up->tc_bdate); - tc_max = max(tc_max, up->tc_breply); - if (pp->coderecv != pp->codeproc) { /* all is well */ pp->lastref = pp->lastrec; + refclock_report(peer, CEVNT_NOMINAL); refclock_receive(peer); } else { - /* not working properly, admit to it */ - peer->flags &= ~FLAG_PPS; + /* Not working properly, admit to it. If we have no + * connection to GPSD, declare the clock as faulty. If + * there were bad replies, this is handled as the major + * cause, and everything else is just a timeout. + */ peer->precision = PRECISION; - - if (-1 == pp->io.fd) { - /* not connected to GPSD: clearly not working! */ + if (-1 == pp->io.fd) refclock_report(peer, CEVNT_FAULT); - } else if (tc_max == up->tc_breply) { + else if (0 != up->tc_breply) refclock_report(peer, CEVNT_BADREPLY); - } else if (tc_max == up->tc_btime) { - refclock_report(peer, CEVNT_BADTIME); - } else if (tc_max == up->tc_bdate) { - refclock_report(peer, CEVNT_BADDATE); - } else { + else refclock_report(peer, CEVNT_TIMEOUT); - } } if (pp->sloppyclockflag & CLK_FLAG4) - gpsd_clockstats(unit, peer); + mprintf_clock_stats( + &peer->srcadr,"%u %u %u %u %u %u %u", + up->tc_recv, + up->tc_breply, up->tc_nosync, + up->tc_sti_recv, up->tc_sti_used, + up->tc_pps_recv, up->tc_pps_used); /* clear tallies for next round */ - up->tc_good = up->tc_btime = up->tc_bdate = - up->tc_breply = up->tc_recv = 0; + up->tc_breply = 0; + up->tc_recv = 0; + up->tc_nosync = 0; + up->tc_sti_recv = 0; + up->tc_sti_used = 0; + up->tc_pps_recv = 0; + up->tc_pps_used = 0; +} + +static void +poll_secondary( + peerT * const peer , + clockprocT * const pp , + gpsd_unitT * const up ) +{ + if (pp->coderecv != pp->codeproc) { + /* all is well */ + pp->lastref = pp->lastrec; + refclock_report(peer, CEVNT_NOMINAL); + refclock_receive(peer); + } else { + peer->precision = PPS_PRECISION; + peer->flags &= ~FLAG_PPS; + refclock_report(peer, CEVNT_TIMEOUT); + } +} + +static void +gpsd_poll( + int unit, + peerT * peer) +{ + clockprocT * const pp = peer->procptr; + gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; + + ++pp->polls; + if (peer == up->pps_peer) + poll_secondary(peer, pp, up); + else + poll_primary(peer, pp, up); } /* ------------------------------------------------------------------ */ @@ -447,23 +797,32 @@ gpsd_control( clockprocT * const pp = peer->procptr; gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; - /* save preprocessed fudge times */ - DTOLFP(pp->fudgetime1, &up->pps_fudge); - DTOLFP(pp->fudgetime2, &up->tpv_fudge); -} + if (peer == up->pps_peer) { + DTOLFP(pp->fudgetime1, &up->pps_fudge2); + if ( ! (pp->sloppyclockflag & CLK_FLAG1)) + peer->flags &= ~FLAG_PPS; + } else { + /* save preprocessed fudge times */ + DTOLFP(pp->fudgetime1, &up->pps_fudge); + DTOLFP(pp->fudgetime2, &up->sti_fudge); + + if (MODE_OP_MODE(up->mode ^ peer->ttl)) { + leave_opmode(peer, up->mode); + up->mode = MODE_OP_MODE(peer->ttl); + enter_opmode(peer, up->mode); + } + } + } /* ------------------------------------------------------------------ */ static void -gpsd_timer( - int unit, - peerT * peer) +timer_primary( + peerT * const peer , + clockprocT * const pp , + gpsd_unitT * const up ) { - static const char query[] = "?VERSION;"; - - clockprocT * const pp = peer->procptr; - gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; - int rc; + int rc; /* This is used for timeout handling. Nothing that needs * sub-second precison happens here, so receive/connect/retry @@ -479,20 +838,17 @@ gpsd_timer( --up->tickover; switch (up->tickover) { case 4: - /* try to get a live signal - * If the device is not yet present, we will most likely - * get an error. We put out a new version request, - * because the reply will initiate a new watch request - * cycle. + /* If we are connected to GPSD, try to get a live signal + * by querying the version. Otherwise just check the + * socket to become ready. */ if (-1 != pp->io.fd) { - if ( ! up->fl_watch) { - DPRINTF(2, ("GPSD_JSON(%d): timer livecheck: '%s'\n", - up->unit, query)); - rc = write(pp->io.fd, - query, sizeof(query)); - (void)rc; - } + size_t rlen = strlen(s_req_version); + DPRINTF(2, ("%s: timer livecheck: '%s'\n", + up->logname, s_req_version)); + log_data(peer, "send", s_req_version, rlen); + rc = write(pp->io.fd, s_req_version, rlen); + (void)rc; } else if (-1 != up->fdt) { gpsd_test_socket(peer); } @@ -511,35 +867,278 @@ gpsd_timer( if (-1 == pp->io.fd && -1 != up->fdt) gpsd_test_socket(peer); } +} - if (up->ppscount > PPS_HIWAT && !(peer->flags & FLAG_PPS)) - peer->flags |= FLAG_PPS; - if (up->ppscount < PPS_LOWAT && (peer->flags & FLAG_PPS)) +static void +timer_secondary( + peerT * const peer , + clockprocT * const pp , + gpsd_unitT * const up ) +{ + /* Reduce the count by one. Flush sample buffer and clear PPS + * flag when this happens. + */ + up->ppscount2 = max(0, (up->ppscount2 - 1)); + if (0 == up->ppscount2) { + if (pp->coderecv != pp->codeproc) { + refclock_report(peer, CEVNT_TIMEOUT); + pp->coderecv = pp->codeproc; + } peer->flags &= ~FLAG_PPS; + } +} + +static void +gpsd_timer( + int unit, + peerT * peer) +{ + clockprocT * const pp = peer->procptr; + gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; + + if (peer == up->pps_peer) + timer_secondary(peer, pp, up); + else + timer_primary(peer, pp, up); +} + +/* ===================================================================== + * handle opmode switches + */ + +static void +enter_opmode( + peerT *peer, + int mode) +{ + clockprocT * const pp = peer->procptr; + gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; + + DPRINTF(1, ("%s: enter operation mode %d\n", + up->logname, MODE_OP_MODE(mode))); + + if (MODE_OP_MODE(mode) == MODE_OP_AUTO) { + up->fl_rawsti = 0; + up->ppscount = PPS_MAXCOUNT / 2; + } + up->fl_pps = 0; + up->fl_sti = 0; +} + +/* ------------------------------------------------------------------ */ + +static void +leave_opmode( + peerT *peer, + int mode) +{ + clockprocT * const pp = peer->procptr; + gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; + + DPRINTF(1, ("%s: leaving operation mode %d\n", + up->logname, MODE_OP_MODE(mode))); + + if (MODE_OP_MODE(mode) == MODE_OP_AUTO) { + up->fl_rawsti = 0; + up->ppscount = 0; + } + up->fl_pps = 0; + up->fl_sti = 0; +} + +/* ===================================================================== + * operation mode specific evaluation + */ + +static void +add_clock_sample( + peerT * const peer , + clockprocT * const pp , + l_fp stamp, + l_fp recvt) +{ + pp->lastref = stamp; + if (pp->coderecv == pp->codeproc) + refclock_report(peer, CEVNT_NOMINAL); + refclock_process_offset(pp, stamp, recvt, 0.0); +} + +/* ------------------------------------------------------------------ */ + +static void +eval_strict( + peerT * const peer , + clockprocT * const pp , + gpsd_unitT * const up ) +{ + if (up->fl_sti && up->fl_pps) { + /* use TPV reference time + PPS receive time */ + add_clock_sample(peer, pp, up->sti_stamp, up->pps_recvt); + peer->precision = up->pps_prec; + /* both packets consumed now... */ + up->fl_pps = 0; + up->fl_sti = 0; + ++up->tc_sti_used; + } +} + +/* ------------------------------------------------------------------ */ +/* PPS processing for the secondary channel. GPSD provides us with full + * timing information, so there's no danger of PLL-locking to the wrong + * second. The belts and suspenders needed for the raw ATOM clock are + * unnecessary here. + */ +static void +eval_pps_secondary( + peerT * const peer , + clockprocT * const pp , + gpsd_unitT * const up ) +{ + if (up->fl_pps2) { + /* feed data */ + add_clock_sample(peer, pp, up->pps_stamp2, up->pps_recvt2); + peer->precision = up->pps_prec; + /* PPS peer flag logic */ + up->ppscount2 = min(PPS2_MAXCOUNT, (up->ppscount2 + 2)); + if ((PPS2_MAXCOUNT == up->ppscount2) && + (pp->sloppyclockflag & CLK_FLAG1) ) + peer->flags |= FLAG_PPS; + /* mark time stamp as burned... */ + up->fl_pps2 = 0; + ++up->tc_pps_used; + } +} + +/* ------------------------------------------------------------------ */ + +static void +eval_serial( + peerT * const peer , + clockprocT * const pp , + gpsd_unitT * const up ) +{ + if (up->fl_sti) { + add_clock_sample(peer, pp, up->sti_stamp, up->sti_recvt); + peer->precision = up->sti_prec; + /* mark time stamp as burned... */ + up->fl_sti = 0; + ++up->tc_sti_used; + } +} + +/* ------------------------------------------------------------------ */ +static void +eval_auto( + peerT * const peer , + clockprocT * const pp , + gpsd_unitT * const up ) +{ + /* If there's no TPV available, stop working here... */ + if (!up->fl_sti) + return; + + /* check how to handle STI+PPS: Can PPS be used to augment STI + * (or vice versae), do we drop the sample because there is a + * temporary missing PPS signal, or do we feed on STI time + * stamps alone? + * + * Do a counter/threshold dance to decide how to proceed. + */ + if (up->fl_pps) { + up->ppscount = min(PPS_MAXCOUNT, + (up->ppscount + PPS_INCCOUNT)); + if ((PPS_MAXCOUNT == up->ppscount) && up->fl_rawsti) { + up->fl_rawsti = 0; + msyslog(LOG_INFO, + "%s: expect valid PPS from now", + up->logname); + } + } else { + up->ppscount = max(0, (up->ppscount - PPS_DECCOUNT)); + if ((0 == up->ppscount) && !up->fl_rawsti) { + up->fl_rawsti = -1; + msyslog(LOG_WARNING, + "%s: use TPV alone from now", + up->logname); + } + } + + /* now eventually feed the sample */ + if (up->fl_rawsti) + eval_serial(peer, pp, up); + else + eval_strict(peer, pp, up); } /* ===================================================================== * JSON parsing stuff */ -#define JSMN_MAXTOK 100 -#define INVALID_TOKEN (-1) +/* ------------------------------------------------------------------ */ +/* Parse a decimal integer with a possible sign. Works like 'strtoll()' + * or 'strtol()', but with a fixed base of 10 and without eating away + * leading whitespace. For the error codes, the handling of the end + * pointer and the return values see 'strtol()'. + */ +static json_int +strtojint( + const char *cp, char **ep) +{ + json_uint accu, limit_lo, limit_hi; + int flags; /* bit 0: overflow; bit 1: sign */ + const char * hold; -typedef struct json_ctx { - char * buf; - int ntok; - jsmntok_t tok[JSMN_MAXTOK]; -} json_ctx; + /* pointer union to circumvent a tricky/sticky const issue */ + union { const char * c; char * v; } vep; -typedef int tok_ref; + /* store initial value of 'cp' -- see 'strtol()' */ + vep.c = cp; -#ifdef HAVE_LONG_LONG -typedef long long json_int; - #define JSON_STRING_TO_INT strtoll -#else -typedef long json_int; - #define JSON_STRING_TO_INT strtol -#endif + /* Eat away an optional sign and set the limits accordingly: The + * high limit is the maximum absolute value that can be returned, + * and the low limit is the biggest value that does not cause an + * overflow when multiplied with 10. Avoid negation overflows. + */ + if (*cp == '-') { + cp += 1; + flags = 2; + limit_hi = (json_uint)-(JSON_INT_MIN + 1) + 1; + } else { + cp += (*cp == '+'); + flags = 0; + limit_hi = (json_uint)JSON_INT_MAX; + } + limit_lo = limit_hi / 10; + + /* Now try to convert a sequence of digits. */ + hold = cp; + accu = 0; + while (isdigit(*(const unsigned char*)cp)) { + flags |= (accu > limit_lo); + accu = accu * 10 + (*(const unsigned char*)cp++ - '0'); + flags |= (accu > limit_hi); + } + /* Check for empty conversion (no digits seen). */ + if (hold != cp) + vep.c = cp; + else + errno = EINVAL; /* accu is still zero */ + /* Check for range overflow */ + if (flags & 1) { + errno = ERANGE; + accu = limit_hi; + } + /* If possible, store back the end-of-conversion pointer */ + if (ep) + *ep = vep.v; + /* If negative, return the negated result if the accu is not + * zero. Avoid negation overflows. + */ + if ((flags & 2) && accu) + return -(json_int)(accu - 1) - 1; + else + return (json_int)accu; +} /* ------------------------------------------------------------------ */ @@ -548,64 +1147,117 @@ json_token_skip( const json_ctx * ctx, tok_ref tid) { - int len; - len = ctx->tok[tid].size; - for (++tid; len; --len) - if (tid < ctx->ntok) - tid = json_token_skip(ctx, tid); - else + if (tid >= 0 && tid < ctx->ntok) { + int len = ctx->tok[tid].size; + /* For arrays and objects, the size is the number of + * ITEMS in the compound. Thats the number of objects in + * the array, and the number of key/value pairs for + * objects. In theory, the key must be a string, and we + * could simply skip one token before skipping the + * value, which can be anything. We're a bit paranoid + * and lazy at the same time: We simply double the + * number of tokens to skip and fall through into the + * array processing when encountering an object. + */ + switch (ctx->tok[tid].type) { + case JSMN_OBJECT: + len *= 2; + /* FALLTHROUGH */ + case JSMN_ARRAY: + for (++tid; len; --len) + tid = json_token_skip(ctx, tid); break; - if (tid > ctx->ntok) - tid = ctx->ntok; + + default: + ++tid; + break; + } + if (tid > ctx->ntok) /* Impossible? Paranoia rulez. */ + tid = ctx->ntok; + } return tid; } - + /* ------------------------------------------------------------------ */ static int json_object_lookup( - const json_ctx * ctx, - tok_ref tid, - const char * key) + const json_ctx * ctx , + tok_ref tid , + const char * key , + int what) { int len; - if (tid >= ctx->ntok || ctx->tok[tid].type != JSMN_OBJECT) + if (tid < 0 || tid >= ctx->ntok || + ctx->tok[tid].type != JSMN_OBJECT) return INVALID_TOKEN; - len = ctx->ntok - tid - 1; - if (len > ctx->tok[tid].size) - len = ctx->tok[tid].size; - for (tid += 1; len > 1; len-=2) { - if (ctx->tok[tid].type != JSMN_STRING) - continue; /* hmmm... that's an error, strictly speaking */ - if (!strcmp(key, ctx->buf + ctx->tok[tid].start)) + + len = ctx->tok[tid].size; + for (++tid; len && tid+1 < ctx->ntok; --len) { + if (ctx->tok[tid].type != JSMN_STRING) { /* Blooper! */ + tid = json_token_skip(ctx, tid); /* skip key */ + tid = json_token_skip(ctx, tid); /* skip val */ + } else if (strcmp(key, ctx->buf + ctx->tok[tid].start)) { + tid = json_token_skip(ctx, tid+1); /* skip key+val */ + } else if (what < 0 || what == ctx->tok[tid+1].type) { return tid + 1; - tid = json_token_skip(ctx, tid + 1); + } else { + break; + } + /* if skipping ahead returned an error, bail out here. */ + if (tid < 0) + break; } return INVALID_TOKEN; } /* ------------------------------------------------------------------ */ -#if 0 /* currently unused */ +static const char* +json_object_lookup_primitive( + const json_ctx * ctx, + tok_ref tid, + const char * key) +{ + tid = json_object_lookup(ctx, tid, key, JSMN_PRIMITIVE); + if (INVALID_TOKEN != tid) + return ctx->buf + ctx->tok[tid].start; + else + return NULL; +} +/* ------------------------------------------------------------------ */ +/* look up a boolean value. This essentially returns a tribool: + * 0->false, 1->true, (-1)->error/undefined + */ +static int +json_object_lookup_bool( + const json_ctx * ctx, + tok_ref tid, + const char * key) +{ + const char *cp; + cp = json_object_lookup_primitive(ctx, tid, key); + switch ( cp ? *cp : '\0') { + case 't': return 1; + case 'f': return 0; + default : return -1; + } +} + +/* ------------------------------------------------------------------ */ + static const char* json_object_lookup_string( const json_ctx * ctx, tok_ref tid, const char * key) { - tok_ref val_ref; - val_ref = json_object_lookup(ctx, tid, key); - if (INVALID_TOKEN == val_ref || - JSMN_STRING != ctx->tok[val_ref].type ) - goto cvt_error; - return ctx->buf + ctx->tok[val_ref].start; - - cvt_error: - errno = EINVAL; + tid = json_object_lookup(ctx, tid, key, JSMN_STRING); + if (INVALID_TOKEN != tid) + return ctx->buf + ctx->tok[tid].start; return NULL; } -#endif static const char* json_object_lookup_string_default( @@ -614,12 +1266,10 @@ json_object_lookup_string_default( const char * key, const char * def) { - tok_ref val_ref; - val_ref = json_object_lookup(ctx, tid, key); - if (INVALID_TOKEN == val_ref || - JSMN_STRING != ctx->tok[val_ref].type ) - return def; - return ctx->buf + ctx->tok[val_ref].start; + tid = json_object_lookup(ctx, tid, key, JSMN_STRING); + if (INVALID_TOKEN != tid) + return ctx->buf + ctx->tok[tid].start; + return def; } /* ------------------------------------------------------------------ */ @@ -630,22 +1280,18 @@ json_object_lookup_int( tok_ref tid, const char * key) { - json_int ret; - tok_ref val_ref; - char * ep; - - val_ref = json_object_lookup(ctx, tid, key); - if (INVALID_TOKEN == val_ref || - JSMN_PRIMITIVE != ctx->tok[val_ref].type ) - goto cvt_error; - ret = JSON_STRING_TO_INT( - ctx->buf + ctx->tok[val_ref].start, &ep, 10); - if (*ep) - goto cvt_error; - return ret; - - cvt_error: - errno = EINVAL; + json_int ret; + const char * cp; + char * ep; + + cp = json_object_lookup_primitive(ctx, tid, key); + if (NULL != cp) { + ret = strtojint(cp, &ep); + if (cp != ep && '\0' == *ep) + return ret; + } else { + errno = EINVAL; + } return 0; } @@ -656,43 +1302,42 @@ json_object_lookup_int_default( const char * key, json_int def) { - json_int retv; - int esave; - - esave = errno; - errno = 0; - retv = json_object_lookup_int(ctx, tid, key); - if (0 != errno) - retv = def; - errno = esave; - return retv; + json_int ret; + const char * cp; + char * ep; + + cp = json_object_lookup_primitive(ctx, tid, key); + if (NULL != cp) { + ret = strtojint(cp, &ep); + if (cp != ep && '\0' == *ep) + return ret; + } + return def; } /* ------------------------------------------------------------------ */ - +#if 0 /* currently unused */ static double json_object_lookup_float( const json_ctx * ctx, tok_ref tid, const char * key) { - double ret; - tok_ref val_ref; - char * ep; - - val_ref = json_object_lookup(ctx, tid, key); - if (INVALID_TOKEN == val_ref || - JSMN_PRIMITIVE != ctx->tok[val_ref].type ) - goto cvt_error; - ret = strtod(ctx->buf + ctx->tok[val_ref].start, &ep); - if (*ep) - goto cvt_error; - return ret; - - cvt_error: - errno = EINVAL; + double ret; + const char * cp; + char * ep; + + cp = json_object_lookup_primitive(ctx, tid, key); + if (NULL != cp) { + ret = strtod(cp, &ep); + if (cp != ep && '\0' == *ep) + return ret; + } else { + errno = EINVAL; + } return 0.0; } +#endif static double json_object_lookup_float_default( @@ -701,16 +1346,17 @@ json_object_lookup_float_default( const char * key, double def) { - double retv; - int esave; - - esave = errno; - errno = 0; - retv = json_object_lookup_float(ctx, tid, key); - if (0 != errno) - retv = def; - errno = esave; - return retv; + double ret; + const char * cp; + char * ep; + + cp = json_object_lookup_primitive(ctx, tid, key); + if (NULL != cp) { + ret = strtod(cp, &ep); + if (cp != ep && '\0' == *ep) + return ret; + } + return def; } /* ------------------------------------------------------------------ */ @@ -718,31 +1364,29 @@ json_object_lookup_float_default( static BOOL json_parse_record( json_ctx * ctx, - char * buf) + char * buf, + size_t len) { jsmn_parser jsm; int idx, rc; jsmn_init(&jsm); - rc = jsmn_parse(&jsm, buf, ctx->tok, JSMN_MAXTOK); + rc = jsmn_parse(&jsm, buf, len, ctx->tok, JSMN_MAXTOK); + if (rc <= 0) + return FALSE; ctx->buf = buf; - ctx->ntok = jsm.toknext; + ctx->ntok = rc; + + if (JSMN_OBJECT != ctx->tok[0].type) + return FALSE; /* not object!?! */ /* Make all tokens NUL terminated by overwriting the - * terminator symbol + * terminator symbol. Makes string compares and number parsing a + * lot easier! */ - for (idx = 0; idx < jsm.toknext; ++idx) + for (idx = 0; idx < ctx->ntok; ++idx) if (ctx->tok[idx].end > ctx->tok[idx].start) ctx->buf[ctx->tok[idx].end] = '\0'; - - if (JSMN_ERROR_PART != rc && - JSMN_ERROR_NOMEM != rc && - JSMN_SUCCESS != rc ) - return FALSE; /* not parseable - bail out */ - - if (0 >= jsm.toknext || JSMN_OBJECT != ctx->tok[0].type) - return FALSE; /* not object or no data!?! */ - return TRUE; } @@ -750,6 +1394,27 @@ json_parse_record( /* ===================================================================== * static local helpers */ +static BOOL +get_binary_time( + l_fp * const dest , + json_ctx * const jctx , + const char * const time_name, + const char * const frac_name, + long fscale ) +{ + BOOL retv = FALSE; + struct timespec ts; + + errno = 0; + ts.tv_sec = (time_t)json_object_lookup_int(jctx, 0, time_name); + ts.tv_nsec = (long )json_object_lookup_int(jctx, 0, frac_name); + if (0 == errno) { + ts.tv_nsec *= fscale; + *dest = tspec_stamp_to_lfp(ts); + retv = TRUE; + } + return retv; +} /* ------------------------------------------------------------------ */ /* Process a WATCH record @@ -766,7 +1431,19 @@ process_watch( clockprocT * const pp = peer->procptr; gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; - up->fl_watch = -1; + const char * path; + + path = json_object_lookup_string(jctx, 0, "device"); + if (NULL == path || strcmp(path, up->device)) + return; + + if (json_object_lookup_bool(jctx, 0, "enable") > 0 && + json_object_lookup_bool(jctx, 0, "json" ) > 0 ) + up->fl_watch = -1; + else + up->fl_watch = 0; + DPRINTF(2, ("%s: process_watch, enabled=%d\n", + up->logname, (up->fl_watch & 1))); } /* ------------------------------------------------------------------ */ @@ -784,39 +1461,48 @@ process_version( char * buf; const char *revision; const char *release; + uint16_t pvhi, pvlo; /* get protocol version number */ revision = json_object_lookup_string_default( - jctx, 0, "rev", "(unknown)"); + jctx, 0, "rev", "(unknown)"); release = json_object_lookup_string_default( - jctx, 0, "release", "(unknown)"); + jctx, 0, "release", "(unknown)"); errno = 0; - up->proto_major = (uint16_t)json_object_lookup_int( - jctx, 0, "proto_major"); - up->proto_minor = (uint16_t)json_object_lookup_int( - jctx, 0, "proto_minor"); + pvhi = (uint16_t)json_object_lookup_int(jctx, 0, "proto_major"); + pvlo = (uint16_t)json_object_lookup_int(jctx, 0, "proto_minor"); + if (0 == errno) { + if ( ! up->fl_vers) + msyslog(LOG_INFO, + "%s: GPSD revision=%s release=%s protocol=%u.%u", + up->logname, revision, release, + pvhi, pvlo); + up->proto_version = PROTO_VERSION(pvhi, pvlo); up->fl_vers = -1; + } else { if (syslogok(pp, up)) msyslog(LOG_INFO, - "%s: GPSD revision=%s release=%s protocol=%u.%u", - refnumtoa(&peer->srcadr), - revision, release, - up->proto_major, up->proto_minor); + "%s: could not evaluate version data", + up->logname); + return; } + /* With the 3.9 GPSD protocol, '*_musec' vanished from the PPS + * record and was replace by '*_nsec'. + */ + up->pf_nsec = -(up->proto_version >= PROTO_VERSION(3,9)); - /* With the 3.9 GPSD protocol, '*_musec' vanished and was - * replace by '*_nsec'. Dispatch properly. + /* With the 3.10 protocol we can get TOFF records for better + * timing information. */ - if ( up->proto_major > 3 || - (up->proto_major == 3 && up->proto_minor >= 9)) - up->fl_nsec = -1; - else - up->fl_nsec = 0; + up->pf_toff = -(up->proto_version >= PROTO_VERSION(3,10)); - /*TODO: validate protocol version! */ - - /* request watch for our GPS device + /* request watch for our GPS device if not yet watched. + * + * The version string is also sent as a life signal, if we have + * seen useable data. So if we're already watching the device, + * skip the request. + * * Reuse the input buffer, which is no longer needed in the * current cycle. Also assume that we can write the watch * request in one sweep into the socket; since we do not do @@ -824,19 +1510,21 @@ process_version( * TCP/IP window size gets lower than the length of the * request. We handle that when it happens.) */ + if (up->fl_watch) + return; + snprintf(up->buffer, sizeof(up->buffer), - s_logon, up->device); + s_req_watch[up->pf_toff != 0], up->device); buf = up->buffer; len = strlen(buf); - if (len != write(pp->io.fd, buf, len)) { - /*Note: if the server fails to read our request, the + log_data(peer, "send", buf, len); + if (len != write(pp->io.fd, buf, len) && (syslogok(pp, up))) { + /* Note: if the server fails to read our request, the * resulting data timeout will take care of the * connection! */ - if (syslogok(pp, up)) - msyslog(LOG_ERR, - "%s: failed to write watch request (%m)", - refnumtoa(&peer->srcadr)); + msyslog(LOG_ERR, "%s: failed to write watch request (%m)", + up->logname); } } @@ -853,76 +1541,72 @@ process_tpv( const char * gps_time; int gps_mode; - double ept, epp, epx, epy, epv; + double ept; int xlog2; gps_mode = (int)json_object_lookup_int_default( jctx, 0, "mode", 0); - gps_time = json_object_lookup_string_default( - jctx, 0, "time", NULL); + gps_time = json_object_lookup_string( + jctx, 0, "time"); - if (gps_mode < 1 || NULL == gps_time) { + /* accept time stamps only in 2d or 3d fix */ + if (gps_mode < 2 || NULL == gps_time) { /* receiver has no fix; tell about and avoid stale data */ - up->tc_breply += 1; - up->fl_tpv = 0; - up->fl_pps = 0; + if ( ! up->pf_toff) + ++up->tc_sti_recv; + ++up->tc_nosync; + up->fl_sti = 0; + up->fl_pps = 0; + up->fl_nosync = -1; return; } + up->fl_nosync = 0; - /* save last time code to clock data */ - save_ltc(pp, gps_time); - - /* convert clock and set resulting ref time */ - if (convert_ascii_time(&up->tpv_stamp, gps_time)) { - DPRINTF(2, ("GPSD_JSON(%d): process_tpv, stamp='%s', recvt='%s' mode=%u\n", - up->unit, - gmprettydate(&up->tpv_stamp), - gmprettydate(&up->tpv_recvt), - gps_mode)); - - up->tpv_local = *rtime; - up->tpv_recvt = *rtime;/*TODO: hack until we get it remote from GPSD */ - L_SUB(&up->tpv_recvt, &up->tpv_fudge); - up->fl_tpv = -1; - } else { - up->tc_btime += 1; - up->fl_tpv = 0; - } - - /* Set the precision from the GPSD data - * - * Since EPT has some issues, we use EPT and a home-brewed error - * estimation base on a sphere derived from EPX/Y/V and the - * speed of light. Use the better one of those two. + /* convert clock and set resulting ref time, but only if the + * TOFF sentence is *not* available */ - ept = json_object_lookup_float_default(jctx, 0, "ept", 1.0); - epx = json_object_lookup_float_default(jctx, 0, "epx", 1000.0); - epy = json_object_lookup_float_default(jctx, 0, "epy", 1000.0); - if (1 == gps_mode) { - /* 2d-fix: extend bounding rectangle to cuboid */ - epv = max(epx, epy); - } else { - /* 3d-fix: get bounding cuboid */ - epv = json_object_lookup_float_default( - jctx, 0, "epv", 1000.0); + if ( ! up->pf_toff) { + ++up->tc_sti_recv; + /* save last time code to clock data */ + save_ltc(pp, gps_time); + /* now parse the time string */ + if (convert_ascii_time(&up->sti_stamp, gps_time)) { + DPRINTF(2, ("%s: process_tpv, stamp='%s'," + " recvt='%s' mode=%u\n", + up->logname, + gmprettydate(&up->sti_stamp), + gmprettydate(&up->sti_recvt), + gps_mode)); + + /* have to use local receive time as substitute + * for the real receive time: TPV does not tell + * us. + */ + up->sti_local = *rtime; + up->sti_recvt = *rtime; + L_SUB(&up->sti_recvt, &up->sti_fudge); + up->fl_sti = -1; + } else { + ++up->tc_breply; + up->fl_sti = 0; + } } - /* get diameter of enclosing sphere of bounding cuboid as spatial - * error, then divide spatial error by speed of light to get - * another time error estimate. Add extra 100 meters as - * optimistic lower bound. Then use the better one of the two - * estimations. + /* Set the precision from the GPSD data + * Use the ETP field for an estimation of the precision of the + * serial data. If ETP is not available, use the default serial + * data presion instead. (Note: The PPS branch has a different + * precision estimation, since it gets the proper value directly + * from GPSD!) */ - epp = 2.0 * sqrt(epx*epx + epy*epy + epv*epv); - epp = (epp + 100.0) / 299792458.0; - - ept = min(ept, epp ); - ept = min(ept, 0.5 ); - ept = max(ept, 1.0-9); - ept = frexp(ept, &xlog2); - - peer->precision = xlog2; + ept = json_object_lookup_float_default(jctx, 0, "ept", 2.0e-3); + ept = frexp(fabs(ept)*0.70710678, &xlog2); /* ~ sqrt(0.5) */ + if (ept < 0.25) + xlog2 = INT_MIN; + if (ept > 2.0) + xlog2 = INT_MAX; + up->sti_prec = clamped_precision(xlog2); } /* ------------------------------------------------------------------ */ @@ -936,51 +1620,118 @@ process_pps( clockprocT * const pp = peer->procptr; gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; - struct timespec ts; - - errno = 0; - ts.tv_sec = (time_t)json_object_lookup_int( - jctx, 0, "clock_sec"); - if (up->fl_nsec) - ts.tv_nsec = json_object_lookup_int( - jctx, 0, "clock_nsec"); - else - ts.tv_nsec = json_object_lookup_int( - jctx, 0, "clock_musec") * 1000; + int xlog2; - if (0 != errno) - goto fail; + ++up->tc_pps_recv; + + /* Bail out if there's indication that time sync is bad or + * if we're explicitely requested to ignore PPS data. + */ + if (up->fl_nosync) + return; up->pps_local = *rtime; - /* get fudged receive time */ - up->pps_recvt = tspec_stamp_to_lfp(ts); - L_SUB(&up->pps_recvt, &up->pps_fudge); + /* Now grab the time values. 'clock_*' is the event time of the + * pulse measured on the local system clock; 'real_*' is the GPS + * reference time GPSD associated with the pulse. + */ + if (up->pf_nsec) { + if ( ! get_binary_time(&up->pps_recvt2, jctx, + "clock_sec", "clock_nsec", 1)) + goto fail; + if ( ! get_binary_time(&up->pps_stamp2, jctx, + "real_sec", "real_nsec", 1)) + goto fail; + } else { + if ( ! get_binary_time(&up->pps_recvt2, jctx, + "clock_sec", "clock_musec", 1000)) + goto fail; + if ( ! get_binary_time(&up->pps_stamp2, jctx, + "real_sec", "real_musec", 1000)) + goto fail; + } - /* map to next full second as reference time stamp */ + /* Try to read the precision field from the PPS record. If it's + * not there, take the precision from the serial data. + */ + xlog2 = json_object_lookup_int_default( + jctx, 0, "precision", up->sti_prec); + up->pps_prec = clamped_precision(xlog2); + + /* Get fudged receive times for primary & secondary unit */ + up->pps_recvt = up->pps_recvt2; + L_SUB(&up->pps_recvt , &up->pps_fudge ); + L_SUB(&up->pps_recvt2, &up->pps_fudge2); + pp->lastrec = up->pps_recvt; + + /* Map to nearest full second as reference time stamp for the + * primary channel. Sanity checks are done in evaluation step. + */ up->pps_stamp = up->pps_recvt; L_ADDUF(&up->pps_stamp, 0x80000000u); up->pps_stamp.l_uf = 0; - - pp->lastrec = up->pps_stamp; - DPRINTF(2, ("GPSD_JSON(%d): process_pps, stamp='%s', recvt='%s'\n", - up->unit, - gmprettydate(&up->pps_stamp), - gmprettydate(&up->pps_recvt))); + if (NULL != up->pps_peer) + save_ltc(up->pps_peer->procptr, + gmprettydate(&up->pps_stamp2)); + DPRINTF(2, ("%s: PPS record processed," + " stamp='%s', recvt='%s'\n", + up->logname, + gmprettydate(&up->pps_stamp2), + gmprettydate(&up->pps_recvt2))); - /* When we have a time pulse, clear the TPV flag: the - * PPS is only valid for the >NEXT< TPV value! - */ - up->fl_pps = -1; - up->fl_tpv = 0; + up->fl_pps = (0 != (pp->sloppyclockflag & CLK_FLAG2)) - 1; + up->fl_pps2 = -1; return; fail: - DPRINTF(2, ("GPSD_JSON(%d): process_pps FAILED, nsec=%d stamp='%s', recvt='%s'\n", - up->unit, up->fl_nsec, - gmprettydate(&up->pps_stamp), - gmprettydate(&up->pps_recvt))); - up->tc_breply += 1; + DPRINTF(1, ("%s: PPS record processing FAILED\n", + up->logname)); + ++up->tc_breply; +} + +/* ------------------------------------------------------------------ */ + +static void +process_toff( + peerT * const peer , + json_ctx * const jctx , + const l_fp * const rtime) +{ + clockprocT * const pp = peer->procptr; + gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; + + ++up->tc_sti_recv; + + /* remember this! */ + up->pf_toff = -1; + + /* bail out if there's indication that time sync is bad */ + if (up->fl_nosync) + return; + + if ( ! get_binary_time(&up->sti_recvt, jctx, + "clock_sec", "clock_nsec", 1)) + goto fail; + if ( ! get_binary_time(&up->sti_stamp, jctx, + "real_sec", "real_nsec", 1)) + goto fail; + L_SUB(&up->sti_recvt, &up->sti_fudge); + up->sti_local = *rtime; + up->fl_sti = -1; + + save_ltc(pp, gmprettydate(&up->sti_stamp)); + DPRINTF(2, ("%s: TOFF record processed," + " stamp='%s', recvt='%s'\n", + up->logname, + gmprettydate(&up->sti_stamp), + gmprettydate(&up->sti_recvt))); + return; + + fail: + DPRINTF(1, ("%s: TOFF record processing FAILED\n", + up->logname)); + ++up->tc_breply; } /* ------------------------------------------------------------------ */ @@ -993,53 +1744,75 @@ gpsd_parse( clockprocT * const pp = peer->procptr; gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; - json_ctx jctx; const char * clsid; - l_fp tmpfp; - DPRINTF(2, ("GPSD_JSON(%d): gpsd_parse: time %s '%s'\n", - up->unit, ulfptoa(rtime, 6), up->buffer)); + DPRINTF(2, ("%s: gpsd_parse: time %s '%.*s'\n", + up->logname, ulfptoa(rtime, 6), + up->buflen, up->buffer)); - /* See if we can grab anything potentially useful */ - if (!json_parse_record(&jctx, up->buffer)) + /* See if we can grab anything potentially useful. JSMN does not + * need a trailing NUL, but it needs the number of bytes to + * process. */ + if (!json_parse_record(&up->json_parse, up->buffer, up->buflen)) { + ++up->tc_breply; return; - + } + /* Now dispatch over the objects we know */ - clsid = json_object_lookup_string_default( - &jctx, 0, "class", "-bad-repy-"); - - up->tc_recv += 1; - if (!strcmp("VERSION", clsid)) - process_version(peer, &jctx, rtime); - else if (!strcmp("TPV", clsid)) - process_tpv(peer, &jctx, rtime); + clsid = json_object_lookup_string(&up->json_parse, 0, "class"); + if (NULL == clsid) { + ++up->tc_breply; + return; + } + + if (!strcmp("TPV", clsid)) + process_tpv(peer, &up->json_parse, rtime); else if (!strcmp("PPS", clsid)) - process_pps(peer, &jctx, rtime); + process_pps(peer, &up->json_parse, rtime); + else if (!strcmp("TOFF", clsid)) + process_toff(peer, &up->json_parse, rtime); + else if (!strcmp("VERSION", clsid)) + process_version(peer, &up->json_parse, rtime); else if (!strcmp("WATCH", clsid)) - process_watch(peer, &jctx, rtime); + process_watch(peer, &up->json_parse, rtime); else return; /* nothing we know about... */ + ++up->tc_recv; - /* now aggregate TPV and PPS -- no PPS? just use TPV...*/ - if (up->fl_tpv) { - /* TODO: also check remote receive time stamps */ - tmpfp = up->tpv_local; - L_SUB(&tmpfp, &up->pps_local); - - if (up->fl_pps && 0 == tmpfp.l_ui) { - refclock_process_offset( - pp, up->tpv_stamp, up->pps_recvt, 0.0); - if (up->ppscount < PPS_MAXCOUNT) - up->ppscount += 1; - } else { - refclock_process_offset( - pp, up->tpv_stamp, up->tpv_recvt, 0.0); - if (up->ppscount > 0) - up->ppscount -= 1; - } - up->fl_pps = 0; - up->fl_tpv = 0; - up->tc_good += 1; + /* if possible, feed the PPS side channel */ + if (up->pps_peer) + eval_pps_secondary( + up->pps_peer, up->pps_peer->procptr, up); + + /* check PPS vs. STI receive times: + * If STI is before PPS, then clearly the STI is too old. If PPS + * is before STI by more than one second, then PPS is too old. + * Weed out stale time stamps & flags. + */ + if (up->fl_pps && up->fl_sti) { + l_fp diff; + diff = up->sti_local; + L_SUB(&diff, &up->pps_local); + if (diff.l_i > 0) + up->fl_pps = 0; /* pps too old */ + else if (diff.l_i < 0) + up->fl_sti = 0; /* serial data too old */ + } + + /* dispatch to the mode-dependent processing functions */ + switch (up->mode) { + default: + case MODE_OP_STI: + eval_serial(peer, pp, up); + break; + + case MODE_OP_STRICT: + eval_strict(peer, pp, up); + break; + + case MODE_OP_AUTO: + eval_auto(peer, pp, up); + break; } } @@ -1052,17 +1825,21 @@ gpsd_stop_socket( clockprocT * const pp = peer->procptr; gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; - if (-1 != pp->io.fd) + if (-1 != pp->io.fd) { + if (syslogok(pp, up)) + msyslog(LOG_INFO, + "%s: closing socket to GPSD, fd=%d", + up->logname, pp->io.fd); + else + DPRINTF(1, ("%s: closing socket to GPSD, fd=%d\n", + up->logname, pp->io.fd)); io_closeclock(&pp->io); - pp->io.fd = -1; - if (syslogok(pp, up)) - msyslog(LOG_INFO, - "%s: closing socket to GPSD", - refnumtoa(&peer->srcadr)); + pp->io.fd = -1; + } up->tickover = up->tickpres; up->tickpres = min(up->tickpres + 5, TICKOVER_HIGH); up->fl_vers = 0; - up->fl_tpv = 0; + up->fl_sti = 0; up->fl_pps = 0; up->fl_watch = 0; } @@ -1092,20 +1869,28 @@ gpsd_init_socket( if (syslogok(pp, up)) msyslog(LOG_ERR, "%s: cannot create GPSD socket: %m", - refnumtoa(&peer->srcadr)); + up->logname); goto no_socket; } - - /* make sure the socket is non-blocking */ + + /* Make sure the socket is non-blocking. Connect/reconnect and + * IO happen in an event-driven environment, and synchronous + * operations wreak havoc on that. + */ rc = fcntl(up->fdt, F_SETFL, O_NONBLOCK, 1); if (-1 == rc) { if (syslogok(pp, up)) msyslog(LOG_ERR, "%s: cannot set GPSD socket to non-blocking: %m", - refnumtoa(&peer->srcadr)); + up->logname); goto no_socket; } - /* disable nagling */ + /* Disable nagling. The way both GPSD and NTPD handle the + * protocol makes it record-oriented, and in most cases + * complete records (JSON serialised objects) will be sent in + * one sweep. Nagling gives not much advantage but adds another + * delay, which can worsen the situation for some packets. + */ ov = 1; rc = setsockopt(up->fdt, IPPROTO_TCP, TCP_NODELAY, (char*)&ov, sizeof(ov)); @@ -1113,24 +1898,53 @@ gpsd_init_socket( if (syslogok(pp, up)) msyslog(LOG_INFO, "%s: cannot disable TCP nagle: %m", - refnumtoa(&peer->srcadr)); + up->logname); } - /* start a non-blocking connect */ + /* Start a non-blocking connect. There might be a synchronous + * connection result we have to handle. + */ rc = connect(up->fdt, ai->ai_addr, ai->ai_addrlen); - if (-1 == rc && errno != EINPROGRESS) { + if (-1 == rc) { + if (errno == EINPROGRESS) { + DPRINTF(1, ("%s: async connect pending, fd=%d\n", + up->logname, up->fdt)); + return; + } + if (syslogok(pp, up)) msyslog(LOG_ERR, "%s: cannot connect GPSD socket: %m", - refnumtoa(&peer->srcadr)); + up->logname); + goto no_socket; + } + + /* We had a successful synchronous connect, so we add the + * refclock processing ASAP. We still have to wait for the + * version string and apply the watch command later on, but we + * might as well get the show on the road now. + */ + DPRINTF(1, ("%s: new socket connection, fd=%d\n", + up->logname, up->fdt)); + + pp->io.fd = up->fdt; + up->fdt = -1; + if (0 == io_addclock(&pp->io)) { + if (syslogok(pp, up)) + msyslog(LOG_ERR, + "%s: failed to register with I/O engine", + up->logname); goto no_socket; } return; - + no_socket: + if (-1 != pp->io.fd) + close(pp->io.fd); if (-1 != up->fdt) close(up->fdt); + pp->io.fd = -1; up->fdt = -1; up->tickover = up->tickpres; up->tickpres = min(up->tickpres + 5, TICKOVER_HIGH); @@ -1152,8 +1966,8 @@ gpsd_test_socket( * socket for writeability. Use the 'poll()' API if available * and 'select()' otherwise. */ - DPRINTF(2, ("GPSD_JSON(%d): check connect, fd=%d\n", - up->unit, up->fdt)); + DPRINTF(2, ("%s: check connect, fd=%d\n", + up->logname, up->fdt)); #if defined(HAVE_SYS_POLL_H) { @@ -1188,16 +2002,26 @@ gpsd_test_socket( ec = 0; lc = sizeof(ec); rc = getsockopt(up->fdt, SOL_SOCKET, SO_ERROR, &ec, &lc); - DPRINTF(1, ("GPSD_JSON(%d): connect finshed, fd=%d, ec=%d(%s)\n", - up->unit, up->fdt, ec, strerror(ec))); if (-1 == rc || 0 != ec) { - errno = ec; + const char *errtxt; + if (0 == ec) + ec = errno; + errtxt = strerror(ec); if (syslogok(pp, up)) msyslog(LOG_ERR, - "%s: (async)cannot connect GPSD socket: %m", - refnumtoa(&peer->srcadr)); + "%s: async connect to GPSD failed," + " fd=%d, ec=%d(%s)", + up->logname, up->fdt, ec, errtxt); + else + DPRINTF(1, ("%s: async connect to GPSD failed," + " fd=%d, ec=%d(%s)\n", + up->logname, up->fdt, ec, errtxt)); goto no_socket; - } + } else { + DPRINTF(1, ("%s: async connect to GPSD succeeded, fd=%d\n", + up->logname, up->fdt)); + } + /* swap socket FDs, and make sure the clock was added */ pp->io.fd = up->fdt; up->fdt = -1; @@ -1205,14 +2029,17 @@ gpsd_test_socket( if (syslogok(pp, up)) msyslog(LOG_ERR, "%s: failed to register with I/O engine", - refnumtoa(&peer->srcadr)); + up->logname); goto no_socket; } return; - + no_socket: - if (-1 != up->fdt) + if (-1 != up->fdt) { + DPRINTF(1, ("%s: closing socket, fd=%d\n", + up->logname, up->fdt)); close(up->fdt); + } up->fdt = -1; up->tickover = up->tickpres; up->tickpres = min(up->tickpres + 5, TICKOVER_HIGH); @@ -1222,35 +2049,22 @@ gpsd_test_socket( * helper stuff */ -/* - * shm_clockstats - dump and reset counters +/* ------------------------------------------------------------------- + * store a properly clamped precision value */ -static void -gpsd_clockstats( - int unit, - peerT * const peer - ) +static int16_t +clamped_precision( + int rawprec) { - clockprocT * const pp = peer->procptr; - gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; - - char logbuf[128]; - unsigned int llen; - - /* if snprintf() returns a negative values on errors (some older - * ones do) make sure we are NUL terminated. Using an unsigned - * result does the trick. - */ - llen = snprintf(logbuf, sizeof(logbuf), - "good=%-3u badtime=%-3u baddate=%-3u badreply=%-3u recv=%-3u", - up->tc_good, up->tc_btime, up->tc_bdate, - up->tc_breply, up->tc_recv); - logbuf[min(llen, sizeof(logbuf)-1)] = '\0'; - record_clock_stats(&peer->srcadr, logbuf); + if (rawprec > 0) + rawprec = 0; + if (rawprec < -32) + rawprec = -32; + return (int16_t)rawprec; } /* ------------------------------------------------------------------- - * Convert a GPSD timestam (ISO8601 Format) to an l_fp + * Convert a GPSD timestamp (ISO8601 Format) to an l_fp */ static BOOL convert_ascii_time( @@ -1260,7 +2074,7 @@ convert_ascii_time( char *ep; struct tm gd; struct timespec ts; - long dw; + uint32_t dw; /* Use 'strptime' to take the brunt of the work, then parse * the fractional part manually, starting with a digit weight of @@ -1268,17 +2082,22 @@ convert_ascii_time( */ ts.tv_nsec = 0; ep = strptime(gps_time, "%Y-%m-%dT%H:%M:%S", &gd); + if (NULL == ep) + return FALSE; /* could not parse the mandatory stuff! */ if (*ep == '.') { - dw = 100000000; - while (isdigit((unsigned char)*++ep)) { - ts.tv_nsec += (*ep - '0') * dw; - dw /= 10; + dw = 100000000u; + while (isdigit(*(unsigned char*)++ep)) { + ts.tv_nsec += (*(unsigned char*)ep - '0') * dw; + dw /= 10u; } } if (ep[0] != 'Z' || ep[1] != '\0') - return FALSE; + return FALSE; /* trailing garbage */ - /* now convert the whole thing into a 'l_fp' */ + /* Now convert the whole thing into a 'l_fp'. We do not use + * 'mkgmtime()' since its not standard and going through the + * calendar routines is not much effort, either. + */ ts.tv_sec = (ntpcal_tm_to_rd(&gd) - DAY_NTP_STARTS) * SECSPERDAY + ntpcal_tm_to_daysec(&gd); *fp = tspec_intv_to_lfp(ts); @@ -1305,8 +2124,7 @@ save_ltc( pp->a_lastcode[len] = '\0'; } -/* - * ------------------------------------------------------------------- +/* ------------------------------------------------------------------- * asprintf replacement... it's not available everywhere... */ static int @@ -1336,6 +2154,57 @@ myasprintf( return (int)plen; } +/* ------------------------------------------------------------------- + * dump a raw data buffer + */ + +static char * +add_string( + char *dp, + char *ep, + const char *sp) +{ + while (dp != ep && *sp) + *dp++ = *sp++; + return dp; +} + +static void +log_data( + peerT *peer, + const char *what, + const char *buf , + size_t len ) +{ + /* we're running single threaded with regards to the clocks. */ + static char s_lbuf[2048]; + + clockprocT * const pp = peer->procptr; + gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; + + if (debug > 1) { + const char *sptr = buf; + const char *stop = buf + len; + char *dptr = s_lbuf; + char *dtop = s_lbuf + sizeof(s_lbuf) - 1; /* for NUL */ + + while (sptr != stop && dptr != dtop) { + if (*sptr == '\\') { + dptr = add_string(dptr, dtop, "\\\\"); + } else if (isprint(*sptr)) { + *dptr++ = *sptr; + } else { + char fbuf[6]; + snprintf(fbuf, sizeof(fbuf), "\\%03o", *(const u_char*)sptr); + dptr = add_string(dptr, dtop, fbuf); + } + sptr++; + } + *dptr = '\0'; + mprintf("%s[%s]: '%s'\n", up->logname, what, s_lbuf); + } +} + #else NONEMPTY_TRANSLATION_UNIT #endif /* REFCLOCK && CLOCK_GPSDJSON */ diff --git a/ntpd/refclock_jjy.c b/ntpd/refclock_jjy.c index e279ee307d737..fef829ca071b2 100644 --- a/ntpd/refclock_jjy.c +++ b/ntpd/refclock_jjy.c @@ -4,7 +4,7 @@ /**********************************************************************/ /* */ -/* Copyright (C) 2001-2011, Takao Abe. All rights reserved. */ +/* Copyright (C) 2001-2015, Takao Abe. All rights reserved. */ /* */ /* Permission to use, copy, modify, and distribute this software */ /* and its documentation for any purpose is hereby granted */ @@ -95,6 +95,17 @@ /* 2011/04/30 */ /* [Add] Support the Tristate Ltd. TS-GPSclock-01 */ /* */ +/* 2015/03/29 */ +/* [Add] Support the Telephone JJY */ +/* [Change] Split the start up routine into each JJY receivers. */ +/* Change raw data internal bufferring process */ +/* Change over midnight handling of TS-JJY01 and TS-GPS01 */ +/* to put DATE command between before and after TIME's. */ +/* Unify the writing clockstats of all JJY receivers. */ +/* */ +/* 2015/05/15 */ +/* [Add] Support the SEIKO TIME SYSTEMS TDC-300 */ +/* */ /**********************************************************************/ #ifdef HAVE_CONFIG_H @@ -117,81 +128,18 @@ #include "ntp_stdlib.h" /**********************************************************************/ -/* */ -/* The Tristate Ltd. JJY receiver JJY01 */ -/* */ -/* Command Response Remarks */ -/* ------------ ---------------------- --------------------- */ -/* dcst<CR><LF> VALID|INVALID<CR><LF> */ -/* stus<CR><LF> ADJUSTED|UNADJUSTED<CR><LF> */ -/* date<CR><LF> YYYY/MM/DD XXX<CR><LF> */ -/* time<CR><LF> HH:MM:SS<CR><LF> Not used by this driver */ -/* stim<CR><LF> HH:MM:SS<CR><LF> Reply at just second */ -/* */ -/* During synchronization after a receiver is turned on, */ -/* It replies the past time from 2000/01/01 00:00:00. */ -/* The function "refclock_process" checks the time and tells */ -/* as an insanity time. */ -/* */ -/**********************************************************************/ -/* */ -/* The C-DEX Co. Ltd. JJY receiver JST2000 */ -/* */ -/* Command Response Remarks */ -/* ------------ ---------------------- --------------------- */ -/* <ENQ>1J<ETX> <STX>JYYMMDD HHMMSSS<ETX> */ -/* */ -/**********************************************************************/ -/* */ -/* The Echo Keisokuki Co. Ltd. JJY receiver LT2000 */ -/* */ -/* Command Response Remarks */ -/* ------------ ---------------------- --------------------- */ -/* # Mode 1 (Request&Send) */ -/* T YYMMDDWHHMMSS<BCC1><BCC2><CR> */ -/* C Mode 2 (Continuous) */ -/* YYMMDDWHHMMSS<ST1><ST2><ST3><ST4><CR> */ -/* <SUB> Second signal */ -/* */ -/**********************************************************************/ -/* */ -/* The CITIZEN T.I.C CO., LTD. JJY receiver JJY200 */ -/* */ -/* Command Response Remarks */ -/* ------------ ---------------------- --------------------- */ -/* 'XX YY/MM/DD W HH:MM:SS<CR> */ -/* XX: OK|NG|ER */ -/* W: 0(Monday)-6(Sunday) */ -/* */ -/**********************************************************************/ -/* */ -/* The Tristate Ltd. GPS clock TS-GPSCLOCK-01 */ -/* */ -/* This clock has NMEA mode and command/respose mode. */ -/* When this jjy driver are used, set to command/respose mode */ -/* of this clock by the onboard switch SW4, and make sure the */ -/* LED-Y is tured on. */ -/* Other than this JJY driver, the refclock driver type 20, */ -/* generic NMEA driver, works with the NMEA mode of this clock. */ -/* */ -/* Command Response Remarks */ -/* ------------ ---------------------- --------------------- */ -/* stus<CR><LF> *R|*G|*U|+U<CR><LF> */ -/* date<CR><LF> YY/MM/DD<CR><LF> */ -/* time<CR><LF> HH:MM:SS<CR><LF> */ -/* */ -/**********************************************************************/ /* * Interface definitions */ #define DEVICE "/dev/jjy%d" /* device name and unit */ -#define SPEED232 B9600 /* uart speed (9600 baud) */ #define SPEED232_TRISTATE_JJY01 B9600 /* UART speed (9600 baud) */ #define SPEED232_CDEX_JST2000 B9600 /* UART speed (9600 baud) */ #define SPEED232_ECHOKEISOKUKI_LT2000 B9600 /* UART speed (9600 baud) */ #define SPEED232_CITIZENTIC_JJY200 B4800 /* UART speed (4800 baud) */ #define SPEED232_TRISTATE_GPSCLOCK01 B38400 /* USB speed (38400 baud) */ +#define SPEED232_SEIKO_TIMESYS_TDC_300 B2400 /* UART speed (2400 baud) */ +#define SPEED232_TELEPHONE B2400 /* UART speed (4800 baud) */ #define REFID "JJY" /* reference ID */ #define DESCRIPTION "JJY Receiver" #define PRECISION (-3) /* precision assumed (about 100 ms) */ @@ -199,22 +147,65 @@ /* * JJY unit control structure */ + +struct jjyRawDataBreak { + char *pString ; + int iLength ; +} ; + +#define MAX_TIMESTAMP 6 +#define MAX_RAWBUF 100 +#define MAX_LOOPBACK 5 + struct jjyunit { +/* Set up by the function "jjy_start_xxxxxxxx" */ char unittype ; /* UNITTYPE_XXXXXXXXXX */ - short operationmode ; /* Echo Keisokuki LT-2000 : 1 or 2 */ - short version ; + short operationmode ; /* Echo Keisokuki LT-2000 */ + int linespeed ; /* SPEED232_XXXXXXXXXX */ short linediscipline ; /* LDISC_CLK or LDISC_RAW */ - char bPollFlag ; /* Set by jjy_pool and Reset by jjy_receive */ - int linecount ; - int lineerror ; +/* Receiving data */ + char bInitError ; /* Set by jjy_start if any error during initialization */ + short iProcessState ; /* JJY_PROCESS_STATE_XXXXXX */ + char bReceiveFlag ; /* Set and reset by jjy_receive */ + char bLineError ; /* Reset by jjy_poll / Set by jjy_receive_xxxxxxxx*/ + short iCommandSeq ; /* 0:Idle Non-Zero:Issued */ + short iReceiveSeq ; + int iLineCount ; int year, month, day, hour, minute, second, msecond ; + int leapsecond ; + int iTimestampCount ; /* TS-JJY01, TS-GPS01, Telephone-JJY */ + int iTimestamp [ MAX_TIMESTAMP ] ; /* Serial second ( 0 - 86399 ) */ /* LDISC_RAW only */ -#define MAX_LINECOUNT 8 -#define MAX_RAWBUF 64 - int lineexpect ; - int charexpect [ MAX_LINECOUNT ] ; - int charcount ; - char rawbuf [ MAX_RAWBUF ] ; + char sRawBuf [ MAX_RAWBUF ] ; + int iRawBufLen ; + struct jjyRawDataBreak *pRawBreak ; + char bWaitBreakString ; + char sLineBuf [ MAX_RAWBUF ] ; + int iLineBufLen ; + char sTextBuf [ MAX_RAWBUF ] ; + int iTextBufLen ; + char bSkipCntrlCharOnly ; +/* Telephone JJY auto measurement of the loopback delay */ + char bLoopbackMode ; + short iLoopbackCount ; + struct timeval sendTime[MAX_LOOPBACK], delayTime[MAX_LOOPBACK] ; + char bLoopbackTimeout[MAX_LOOPBACK] ; + short iLoopbackValidCount ; +/* Telephone JJY timer */ + short iTeljjySilentTimer ; + short iTeljjyStateTimer ; +/* Telephone JJY control finite state machine */ + short iClockState ; + short iClockEvent ; + short iClockCommandSeq ; +/* Modem timer */ + short iModemSilentCount ; + short iModemSilentTimer ; + short iModemStateTimer ; +/* Modem control finite state machine */ + short iModemState ; + short iModemEvent ; + short iModemCommandSeq ; }; #define UNITTYPE_TRISTATE_JJY01 1 @@ -222,12 +213,93 @@ struct jjyunit { #define UNITTYPE_ECHOKEISOKUKI_LT2000 3 #define UNITTYPE_CITIZENTIC_JJY200 4 #define UNITTYPE_TRISTATE_GPSCLOCK01 5 +#define UNITTYPE_SEIKO_TIMESYS_TDC_300 6 +#define UNITTYPE_TELEPHONE 100 + +#define JJY_PROCESS_STATE_IDLE 0 +#define JJY_PROCESS_STATE_POLL 1 +#define JJY_PROCESS_STATE_RECEIVE 2 +#define JJY_PROCESS_STATE_DONE 3 +#define JJY_PROCESS_STATE_ERROR 4 + +/**********************************************************************/ /* + * Function calling structure + * + * jjy_start + * |-- jjy_start_tristate_jjy01 + * |-- jjy_start_cdex_jst2000 + * |-- jjy_start_echokeisokuki_lt2000 + * |-- jjy_start_citizentic_jjy200 + * |-- jjy_start_tristate_gpsclock01 + * |-- jjy_start_seiko_tsys_tdc_300 + * |-- jjy_start_telephone + * + * jjy_shutdown + * + * jjy_poll + * |-- jjy_poll_tristate_jjy01 + * |-- jjy_poll_cdex_jst2000 + * |-- jjy_poll_echokeisokuki_lt2000 + * |-- jjy_poll_citizentic_jjy200 + * |-- jjy_poll_tristate_gpsclock01 + * |-- jjy_poll_seiko_tsys_tdc_300 + * |-- jjy_poll_telephone + * |-- teljjy_control + * |-- teljjy_XXXX_YYYY ( XXXX_YYYY is an event handler name. ) + * |-- modem_connect + * |-- modem_control + * |-- modem_XXXX_YYYY ( XXXX_YYYY is an event handler name. ) + * + * jjy_receive + * | + * |-- jjy_receive_tristate_jjy01 + * | |-- jjy_synctime + * |-- jjy_receive_cdex_jst2000 + * | |-- jjy_synctime + * |-- jjy_receive_echokeisokuki_lt2000 + * | |-- jjy_synctime + * |-- jjy_receive_citizentic_jjy200 + * | |-- jjy_synctime + * |-- jjy_receive_tristate_gpsclock01 + * | |-- jjy_synctime + * |-- jjy_receive_seiko_tsys_tdc_300 + * | |-- jjy_synctime + * |-- jjy_receive_telephone + * |-- modem_receive + * | |-- modem_control + * | |-- modem_XXXX_YYYY ( XXXX_YYYY is an event handler name. ) + * |-- teljjy_control + * |-- teljjy_XXXX_YYYY ( XXXX_YYYY is an event handler name. ) + * |-- jjy_synctime + * |-- modem_disconnect + * |-- modem_control + * |-- modem_XXXX_YYYY ( XXXX_YYYY is an event handler name. ) + * + * jjy_timer + * |-- jjy_timer_telephone + * |-- modem_timer + * | |-- modem_control + * | |-- modem_XXXX_YYYY ( XXXX_YYYY is an event handler name. ) + * |-- teljjy_control + * |-- teljjy_XXXX_YYYY ( XXXX_YYYY is an event handler name. ) + * |-- modem_disconnect + * |-- modem_control + * |-- modem_XXXX_YYYY ( XXXX_YYYY is an event handler name. ) + * * Function prototypes */ - + static int jjy_start (int, struct peer *); +static int jjy_start_tristate_jjy01 (int, struct peer *, struct jjyunit *); +static int jjy_start_cdex_jst2000 (int, struct peer *, struct jjyunit *); +static int jjy_start_echokeisokuki_lt2000 (int, struct peer *, struct jjyunit *); +static int jjy_start_citizentic_jjy200 (int, struct peer *, struct jjyunit *); +static int jjy_start_tristate_gpsclock01 (int, struct peer *, struct jjyunit *); +static int jjy_start_seiko_tsys_tdc_300 (int, struct peer *, struct jjyunit *); +static int jjy_start_telephone (int, struct peer *, struct jjyunit *); + static void jjy_shutdown (int, struct peer *); static void jjy_poll (int, struct peer *); @@ -236,15 +308,36 @@ static void jjy_poll_cdex_jst2000 (int, struct peer *); static void jjy_poll_echokeisokuki_lt2000 (int, struct peer *); static void jjy_poll_citizentic_jjy200 (int, struct peer *); static void jjy_poll_tristate_gpsclock01 (int, struct peer *); +static void jjy_poll_seiko_tsys_tdc_300 (int, struct peer *); +static void jjy_poll_telephone (int, struct peer *); static void jjy_receive (struct recvbuf *); -static int jjy_receive_tristate_jjy01 (struct recvbuf *); -static int jjy_receive_cdex_jst2000 (struct recvbuf *); -static int jjy_receive_echokeisokuki_lt2000 (struct recvbuf *); -static int jjy_receive_citizentic_jjy200 (struct recvbuf *); -static int jjy_receive_tristate_gpsclock01 (struct recvbuf *); +static int jjy_receive_tristate_jjy01 (struct recvbuf *); +static int jjy_receive_cdex_jst2000 (struct recvbuf *); +static int jjy_receive_echokeisokuki_lt2000 (struct recvbuf *); +static int jjy_receive_citizentic_jjy200 (struct recvbuf *); +static int jjy_receive_tristate_gpsclock01 (struct recvbuf *); +static int jjy_receive_seiko_tsys_tdc_300 (struct recvbuf *); +static int jjy_receive_telephone (struct recvbuf *); -static void printableString ( char*, int, char*, int ) ; +static void jjy_timer (int, struct peer *); +static void jjy_timer_telephone (int, struct peer *); + +static void jjy_synctime ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static void jjy_write_clockstats ( struct peer *, int, const char* ) ; + +static int getRawDataBreakPosition ( struct jjyunit *, int ) ; + +static short getModemState ( struct jjyunit * ) ; +static int isModemStateConnect ( short ) ; +static int isModemStateDisconnect ( short ) ; +static int isModemStateTimerOn ( struct jjyunit * ) ; +static void modem_connect ( int, struct peer * ) ; +static void modem_disconnect ( int, struct peer * ) ; +static int modem_receive ( struct recvbuf * ) ; +static void modem_timer ( int, struct peer * ); + +static void printableString ( char*, int, const char*, int ) ; /* * Transfer vector @@ -256,7 +349,7 @@ struct refclock refclock_jjy = { noentry, /* not used */ noentry, /* not used */ noentry, /* not used */ - NOFLAGS /* not used */ + jjy_timer /* 1 second interval timer */ }; /* @@ -269,88 +362,64 @@ struct refclock refclock_jjy = { * Local constants definition */ -#define MAX_LOGTEXT 64 - -/* - * Tristate JJY01/JJY02 constants definition - */ - -#define TS_JJY01_COMMAND_NUMBER_DATE 1 -#define TS_JJY01_COMMAND_NUMBER_TIME 2 -#define TS_JJY01_COMMAND_NUMBER_STIM 3 -#define TS_JJY01_COMMAND_NUMBER_STUS 4 -#define TS_JJY01_COMMAND_NUMBER_DCST 5 - -#define TS_JJY01_REPLY_DATE "yyyy/mm/dd www\r\n" -#define TS_JJY01_REPLY_STIM "hh:mm:ss\r\n" -#define TS_JJY01_REPLY_STUS_YES "adjusted\r\n" -#define TS_JJY01_REPLY_STUS_NO "unadjusted\r\n" -#define TS_JJY01_REPLY_DCST_VALID "valid\r\n" -#define TS_JJY01_REPLY_DCST_INVALID "invalid\r\n" - -#define TS_JJY01_REPLY_LENGTH_DATE 14 /* Length without <CR><LF> */ -#define TS_JJY01_REPLY_LENGTH_STIM 8 /* Length without <CR><LF> */ -#define TS_JJY01_REPLY_LENGTH_STUS_YES 8 /* Length without <CR><LF> */ -#define TS_JJY01_REPLY_LENGTH_STUS_NO 10 /* Length without <CR><LF> */ -#define TS_JJY01_REPLY_LENGTH_DCST_VALID 5 /* Length without <CR><LF> */ -#define TS_JJY01_REPLY_LENGTH_DCST_INVALID 7 /* Length without <CR><LF> */ - -static struct -{ - const char commandNumber ; - const char *commandLog ; - const char *command ; - int commandLength ; -} tristate_jjy01_command_sequence[] = -{ - /* dcst<CR><LF> -> VALID<CR><LF> or INVALID<CR><LF> */ - { TS_JJY01_COMMAND_NUMBER_DCST, "dcst", "dcst\r\n", 6 }, - /* stus<CR><LF> -> ADJUSTED<CR><LF> or UNADJUSTED<CR><LF> */ - { TS_JJY01_COMMAND_NUMBER_STUS, "stus", "stus\r\n", 6 }, - /* date<CR><LF> -> YYYY/MM/DD WWW<CR><LF> */ - { TS_JJY01_COMMAND_NUMBER_DATE, "date", "date\r\n", 6 }, - /* stim<CR><LF> -> HH:MM:SS<CR><LF> */ - { TS_JJY01_COMMAND_NUMBER_STIM, "stim", "stim\r\n", 6 }, - /* End of command */ - { 0, NULL, NULL, 0 } -} ; - -/* - * Tristate TS-GPSCLOCK01 constants definition - */ - -#define TS_GPSCLOCK01_COMMAND_NUMBER_DATE 1 -#define TS_GPSCLOCK01_COMMAND_NUMBER_TIME 2 -#define TS_GPSCLOCK01_COMMAND_NUMBER_STUS 4 +#define MAX_LOGTEXT 100 -#define TS_GPSCLOCK01_REPLY_DATE "yyyy/mm/dd\r\n" -#define TS_GPSCLOCK01_REPLY_TIME "hh:mm:ss\r\n" -#define TS_GPSCLOCK01_REPLY_STUS_RTC "*R\r\n" -#define TS_GPSCLOCK01_REPLY_STUS_GPS "*G\r\n" -#define TS_GPSCLOCK01_REPLY_STUS_UTC "*U\r\n" -#define TS_GPSCLOCK01_REPLY_STUS_PPS "+U\r\n" - -#define TS_GPSCLOCK01_REPLY_LENGTH_DATE 10 /* Length without <CR><LF> */ -#define TS_GPSCLOCK01_REPLY_LENGTH_TIME 8 /* Length without <CR><LF> */ -#define TS_GPSCLOCK01_REPLY_LENGTH_STUS 2 /* Length without <CR><LF> */ +#ifndef TRUE +#define TRUE (0==0) +#endif +#ifndef FALSE +#define FALSE (!TRUE) +#endif -static struct -{ - char commandNumber ; - const char *commandLog ; - const char *command ; - int commandLength ; -} tristate_gpsclock01_command_sequence[] = -{ - /* stus<CR><LF> -> *R<CR><LF> or *G<CR><LF> or *U<CR><LF> or +U<CR><LF> */ - { TS_GPSCLOCK01_COMMAND_NUMBER_STUS, "stus", "stus\r\n", 6 }, - /* date<CR><LF> -> YYYY/MM/DD WWW<CR><LF> */ - { TS_GPSCLOCK01_COMMAND_NUMBER_DATE, "date", "date\r\n", 6 }, - /* time<CR><LF> -> HH:MM:SS<CR><LF> */ - { TS_GPSCLOCK01_COMMAND_NUMBER_TIME, "time", "time\r\n", 6 }, - /* End of command */ - { 0, NULL, NULL, 0 } -} ; +/* Local constants definition for the return code of the jjy_receive_xxxxxxxx */ + +#define JJY_RECEIVE_DONE 0 +#define JJY_RECEIVE_SKIP 1 +#define JJY_RECEIVE_UNPROCESS 2 +#define JJY_RECEIVE_WAIT 3 +#define JJY_RECEIVE_ERROR 4 + +/* Local constants definition for the 2nd parameter of the jjy_write_clockstats */ + +#define JJY_CLOCKSTATS_MARK_NONE 0 +#define JJY_CLOCKSTATS_MARK_JJY 1 +#define JJY_CLOCKSTATS_MARK_SEND 2 +#define JJY_CLOCKSTATS_MARK_RECEIVE 3 +#define JJY_CLOCKSTATS_MARK_INFORMATION 4 +#define JJY_CLOCKSTATS_MARK_ATTENTION 5 +#define JJY_CLOCKSTATS_MARK_WARNING 6 +#define JJY_CLOCKSTATS_MARK_ERROR 7 + +/* Local constants definition for the clockstats messages */ + +#define JJY_CLOCKSTATS_MESSAGE_ECHOBACK "* Echoback" +#define JJY_CLOCKSTATS_MESSAGE_IGNORE_REPLY "* Ignore replay : [%s]" +#define JJY_CLOCKSTATS_MESSAGE_OVER_MIDNIGHT_2 "* Over midnight : timestamp=%d, %d" +#define JJY_CLOCKSTATS_MESSAGE_OVER_MIDNIGHT_3 "* Over midnight : timestamp=%d, %d, %d" +#define JJY_CLOCKSTATS_MESSAGE_TIMESTAMP_UNSURE "* Unsure timestamp : %s" +#define JJY_CLOCKSTATS_MESSAGE_LOOPBACK_DELAY "* Loopback delay : %d.%03d mSec." +#define JJY_CLOCKSTATS_MESSAGE_DELAY_ADJUST "* Delay adjustment : %d mSec. ( valid=%hd/%d )" +#define JJY_CLOCKSTATS_MESSAGE_DELAY_UNADJUST "* Delay adjustment : None ( valid=%hd/%d )" + +#define JJY_CLOCKSTATS_MESSAGE_UNEXPECTED_REPLY "# Unexpected reply : [%s]" +#define JJY_CLOCKSTATS_MESSAGE_INVALID_LENGTH "# Invalid length : length=%d" +#define JJY_CLOCKSTATS_MESSAGE_TOO_MANY_REPLY "# Too many reply : count=%d" +#define JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY "# Invalid reply : [%s]" +#define JJY_CLOCKSTATS_MESSAGE_SLOW_REPLY_2 "# Slow reply : timestamp=%d, %d" +#define JJY_CLOCKSTATS_MESSAGE_SLOW_REPLY_3 "# Slow reply : timestamp=%d, %d, %d" +#define JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATE "# Invalid date : rc=%d year=%d month=%d day=%d" +#define JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_TIME "# Invalid time : rc=%d hour=%d minute=%d second=%d" +#define JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATETIME "# Invalid time : rc=%d year=%d month=%d day=%d hour=%d minute=%d second=%d" +#define JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_LEAP "# Invalid leap : leapsecond=[%s]" +#define JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_STATUS "# Invalid status : status=[%s]" + +/* Debug print macro */ + +#ifdef DEBUG +#define DEBUG_PRINTF_JJY_RECEIVE(sFunc,iLen) { if ( debug ) { printf ( "refclock_jjy.c : %s : iProcessState=%d bLineError=%d iCommandSeq=%d iLineCount=%d iTimestampCount=%d iLen=%d\n", sFunc, up->iProcessState, up->bLineError, up->iCommandSeq, up->iLineCount, up->iTimestampCount, iLen ) ; } } +#else +#define DEBUG_PRINTF_JJY_RECEIVE(sFunc,iLen) +#endif /**************************************************************************************************/ /* jjy_start - open the devices and initialize data for processing */ @@ -359,31 +428,42 @@ static int jjy_start ( int unit, struct peer *peer ) { - struct jjyunit *up ; - struct refclockproc *pp ; + struct refclockproc *pp ; + struct jjyunit *up ; + int rc ; int fd ; - char *pDeviceName ; - short iDiscipline ; - int iSpeed232 ; - - char sLogText [ MAX_LOGTEXT ] , sDevText [ MAX_LOGTEXT ] ; + char sDeviceName [ sizeof(DEVICE) + 10 ], sLog [ 60 ] ; #ifdef DEBUG if ( debug ) { - printf ( "jjy_start (refclock_jjy.c) : %s mode=%d ", ntoa(&peer->srcadr), peer->ttl ) ; - printf ( DEVICE, unit ) ; - printf ( "\n" ) ; + printf( "refclock_jjy.c : jjy_start : %s mode=%d dev=%s unit=%d\n", + ntoa(&peer->srcadr), peer->ttl, DEVICE, unit ) ; } #endif - snprintf ( sDevText, sizeof(sDevText), DEVICE, unit ) ; - snprintf ( sLogText, sizeof(sLogText), "*Initialze* %s mode=%d", sDevText, peer->ttl ) ; - record_clock_stats ( &peer->srcadr, sLogText ) ; - /* - * Open serial port - */ - pDeviceName = emalloc ( strlen(DEVICE) + 10 ); - snprintf ( pDeviceName, strlen(DEVICE) + 10, DEVICE, unit ) ; + /* Allocate memory for the unit structure */ + up = emalloc( sizeof(*up) ) ; + if ( up == NULL ) { + msyslog ( LOG_ERR, "refclock_jjy.c : jjy_start : emalloc" ) ; + return RC_START_ERROR ; + } + memset ( up, 0, sizeof(*up) ) ; + + up->bInitError = FALSE ; + up->iProcessState = JJY_PROCESS_STATE_IDLE ; + up->bReceiveFlag = FALSE ; + up->iCommandSeq = 0 ; + up->iLineCount = 0 ; + up->iTimestampCount = 0 ; + up->bWaitBreakString = FALSE ; + up->iRawBufLen = up->iLineBufLen = up->iTextBufLen = 0 ; + up->bSkipCntrlCharOnly = TRUE ; + + /* Set up the device name */ + snprintf( sDeviceName, sizeof(sDeviceName), DEVICE, unit ) ; + + snprintf( sLog, sizeof(sLog), "mode=%d dev=%s", peer->ttl, sDeviceName ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, sLog ) ; /* * peer->ttl is a mode number specified by "127.127.40.X mode N" in the ntp.conf @@ -391,101 +471,57 @@ jjy_start ( int unit, struct peer *peer ) switch ( peer->ttl ) { case 0 : case 1 : - iDiscipline = LDISC_CLK ; - iSpeed232 = SPEED232_TRISTATE_JJY01 ; + rc = jjy_start_tristate_jjy01 ( unit, peer, up ) ; break ; case 2 : - iDiscipline = LDISC_RAW ; - iSpeed232 = SPEED232_CDEX_JST2000 ; + rc = jjy_start_cdex_jst2000 ( unit, peer, up ) ; break ; case 3 : - iDiscipline = LDISC_CLK ; - iSpeed232 = SPEED232_ECHOKEISOKUKI_LT2000 ; + rc = jjy_start_echokeisokuki_lt2000 ( unit, peer, up ) ; break ; case 4 : - iDiscipline = LDISC_CLK ; - iSpeed232 = SPEED232_CITIZENTIC_JJY200 ; + rc = jjy_start_citizentic_jjy200 ( unit, peer, up ) ; break ; case 5 : - iDiscipline = LDISC_CLK ; - iSpeed232 = SPEED232_TRISTATE_GPSCLOCK01 ; + rc = jjy_start_tristate_gpsclock01 ( unit, peer, up ) ; + break ; + case 6 : + rc = jjy_start_seiko_tsys_tdc_300 ( unit, peer, up ) ; + break ; + case 100 : + rc = jjy_start_telephone ( unit, peer, up ) ; break ; default : - msyslog ( LOG_ERR, "JJY receiver [ %s mode %d ] : Unsupported mode", + if ( 101 <= peer->ttl && peer->ttl <= 180 ) { + rc = jjy_start_telephone ( unit, peer, up ) ; + } else { + msyslog ( LOG_ERR, "JJY receiver [ %s mode %d ] : Unsupported mode", + ntoa(&peer->srcadr), peer->ttl ) ; + free ( (void*) up ) ; + return RC_START_ERROR ; + } + } + + if ( rc != 0 ) { + msyslog ( LOG_ERR, "JJY receiver [ %s mode %d ] : Initialize error", ntoa(&peer->srcadr), peer->ttl ) ; - free ( (void*) pDeviceName ) ; + free ( (void*) up ) ; return RC_START_ERROR ; } - fd = refclock_open ( pDeviceName, iSpeed232, iDiscipline ) ; + /* Open the device */ + fd = refclock_open ( sDeviceName, up->linespeed, up->linediscipline ) ; if ( fd <= 0 ) { - free ( (void*) pDeviceName ) ; + free ( (void*) up ) ; return RC_START_ERROR ; } - free ( (void*) pDeviceName ) ; /* - * Allocate and initialize unit structure - */ - up = emalloc (sizeof(*up)); - memset ( up, 0, sizeof(*up) ) ; - up->linediscipline = iDiscipline ; - - /* - * peer->ttl is a mode number specified by "127.127.40.X mode N" in the ntp.conf + * Initialize variables */ - switch ( peer->ttl ) { - case 0 : - /* - * The mode 0 is a default clock type at this time. - * But this will be change to auto-detect mode in the future. - */ - case 1 : - up->unittype = UNITTYPE_TRISTATE_JJY01 ; - up->version = 100 ; - /* 2010/11/20 */ - /* Command sequence is defined by the struct tristate_jjy01_command_sequence, */ - /* and the following 3 lines are not used in the mode LDISC_CLK. */ - /* up->lineexpect = 2 ; */ - /* up->charexpect[0] = 14 ; */ /* YYYY/MM/DD WWW<CR><LF> */ - /* up->charexpect[1] = 8 ; */ /* HH:MM:SS<CR><LF> */ - break ; - case 2 : - up->unittype = UNITTYPE_CDEX_JST2000 ; - up->lineexpect = 1 ; - up->charexpect[0] = 15 ; /* <STX>JYYMMDD HHMMSSS<ETX> */ - break ; - case 3 : - up->unittype = UNITTYPE_ECHOKEISOKUKI_LT2000 ; - up->operationmode = 2 ; /* Mode 2 : Continuous mode */ - up->lineexpect = 1 ; - switch ( up->operationmode ) { - case 1 : - up->charexpect[0] = 15 ; /* YYMMDDWHHMMSS<BCC1><BCC2><CR> */ - break ; - case 2 : - up->charexpect[0] = 17 ; /* YYMMDDWHHMMSS<ST1><ST2><ST3><ST4><CR> */ - break ; - } - break ; - case 4 : - up->unittype = UNITTYPE_CITIZENTIC_JJY200 ; - up->lineexpect = 1 ; - up->charexpect[0] = 23 ; /* 'XX YY/MM/DD W HH:MM:SS<CR> */ - break ; - case 5 : - up->unittype = UNITTYPE_TRISTATE_GPSCLOCK01 ; - break ; - - /* 2010/11/20 */ - /* The "default:" section of this switch block is never executed, */ - /* because the former switch block traps the same "default:" case. */ - /* This "default:" section codes are removed to avoid spending time */ - /* in the future looking, though the codes are functionally harmless. */ - - } - pp = peer->procptr ; + + pp->clockdesc = DESCRIPTION ; pp->unitptr = up ; pp->io.clock_recv = jjy_receive ; pp->io.srcclock = peer ; @@ -498,19 +534,17 @@ jjy_start ( int unit, struct peer *peer ) pp->unitptr = NULL ; return RC_START_ERROR ; } + memcpy( (char*)&pp->refid, REFID, strlen(REFID) ) ; - /* - * Initialize miscellaneous variables - */ peer->precision = PRECISION ; - pp->clockdesc = DESCRIPTION ; - memcpy ( (char*)&pp->refid, REFID, strlen(REFID) ) ; + + snprintf( sLog, sizeof(sLog), "minpoll=%d maxpoll=%d", peer->minpoll, peer->maxpoll ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, sLog ) ; return RC_START_SUCCESS ; } - /**************************************************************************************************/ /* jjy_shutdown - shutdown the clock */ /**************************************************************************************************/ @@ -521,15 +555,21 @@ jjy_shutdown ( int unit, struct peer *peer ) struct jjyunit *up; struct refclockproc *pp; + char sLog [ 60 ] ; + pp = peer->procptr ; up = pp->unitptr ; - if ( -1 != pp->io.fd ) + if ( -1 != pp->io.fd ) { io_closeclock ( &pp->io ) ; - if ( NULL != up ) + } + if ( NULL != up ) { free ( up ) ; + } -} + snprintf( sLog, sizeof(sLog), "JJY stopped. unit=%d mode=%d", unit, peer->ttl ) ; + record_clock_stats( &peer->srcadr, sLog ) ; +} /**************************************************************************************************/ /* jjy_receive - receive data from the serial interface */ @@ -537,6 +577,9 @@ jjy_shutdown ( int unit, struct peer *peer ) static void jjy_receive ( struct recvbuf *rbufp ) { +#ifdef DEBUG + static const char *sFunctionName = "jjy_receive" ; +#endif struct jjyunit *up ; struct refclockproc *pp ; @@ -544,8 +587,9 @@ jjy_receive ( struct recvbuf *rbufp ) l_fp tRecvTimestamp; /* arrival timestamp */ int rc ; - char sLogText [ MAX_LOGTEXT ] ; - int i, bCntrlChar ; + char *pBuf, sLogText [ MAX_LOGTEXT ] ; + int iLen, iCopyLen ; + int i, j, iReadRawBuf, iBreakPosition ; /* * Initialize pointers and read the timecode and timestamp @@ -557,139 +601,414 @@ jjy_receive ( struct recvbuf *rbufp ) /* * Get next input line */ - pp->lencode = refclock_gtlin ( rbufp, pp->a_lastcode, BMAX, &tRecvTimestamp ) ; - if ( up->linediscipline == LDISC_RAW ) { + + pp->lencode = refclock_gtraw ( rbufp, pp->a_lastcode, BMAX-1, &tRecvTimestamp ) ; + /* 3rd argument can be BMAX, but the coverity scan tool claim "Memory - corruptions (OVERRUN)" */ + /* "a_lastcode" is defined as "char a_lastcode[BMAX]" in the ntp_refclock.h */ + /* To avoid its claim, pass the value BMAX-1. */ + /* - * The reply with <STX> and <ETX> may give a blank line - */ - if ( pp->lencode == 0 && up->charcount == 0 ) return ; - /* - * Copy received charaters to temporary buffer + * Append received charaters to temporary buffer */ for ( i = 0 ; - i < pp->lencode && up->charcount < MAX_RAWBUF - 2 ; - i ++ , up->charcount ++ ) { - up->rawbuf[up->charcount] = pp->a_lastcode[i] ; - } - while ( up->charcount > 0 && up->rawbuf[0] < ' ' ) { - for ( i = 0 ; i < up->charcount - 1 ; i ++ ) - up->rawbuf[i] = up->rawbuf[i+1] ; - up->charcount -- ; - } - bCntrlChar = 0 ; - for ( i = 0 ; i < up->charcount ; i ++ ) { - if ( up->rawbuf[i] < ' ' ) { - bCntrlChar = 1 ; - break ; - } + i < pp->lencode && up->iRawBufLen < MAX_RAWBUF - 2 ; + i ++ , up->iRawBufLen ++ ) { + up->sRawBuf[up->iRawBufLen] = pp->a_lastcode[i] ; } - if ( pp->lencode > 0 && up->linecount < up->lineexpect ) { - if ( bCntrlChar == 0 && - up->charcount < up->charexpect[up->linecount] ) - return ; - } - up->rawbuf[up->charcount] = 0 ; + up->sRawBuf[up->iRawBufLen] = 0 ; + + } else { - /* - * The reply with <CR><LF> gives a blank line - */ - if ( pp->lencode == 0 ) return ; + + pp->lencode = refclock_gtlin ( rbufp, pp->a_lastcode, BMAX, &tRecvTimestamp ) ; + } +#ifdef DEBUG + printf( "\nrefclock_jjy.c : %s : Len=%d ", sFunctionName, pp->lencode ) ; + for ( i = 0 ; i < pp->lencode ; i ++ ) { + if ( iscntrl( pp->a_lastcode[i] & 0x7F ) ) { + printf( "<x%02X>", pp->a_lastcode[i] & 0xFF ) ; + } else { + printf( "%c", pp->a_lastcode[i] ) ; + } + } + printf( "\n" ) ; +#endif + + /* + * The reply with <CR><LF> gives a blank line + */ + + if ( pp->lencode == 0 ) return ; + + /* + * Receiving data is not expected + */ + + if ( up->iProcessState == JJY_PROCESS_STATE_IDLE + || up->iProcessState == JJY_PROCESS_STATE_DONE + || up->iProcessState == JJY_PROCESS_STATE_ERROR ) { + /* Discard received data */ + up->iRawBufLen = 0 ; +#ifdef DEBUG + if ( debug ) { + printf( "refclock_jjy.c : %s : Discard received data\n", sFunctionName ) ; + } +#endif + return ; + } + /* * We get down to business */ + pp->lastrec = tRecvTimestamp ; + + up->iLineCount ++ ; + + up->iProcessState = JJY_PROCESS_STATE_RECEIVE ; + up->bReceiveFlag = TRUE ; + + iReadRawBuf = 0 ; + iBreakPosition = up->iRawBufLen - 1 ; + for ( ; up->iProcessState == JJY_PROCESS_STATE_RECEIVE ; ) { + + if ( up->linediscipline == LDISC_RAW ) { + + if ( up->bWaitBreakString ) { + iBreakPosition = getRawDataBreakPosition( up, iReadRawBuf ) ; + if ( iBreakPosition == -1 ) { + /* Break string have not come yet */ + if ( up->iRawBufLen < MAX_RAWBUF - 2 + || iReadRawBuf > 0 ) { + /* Temporary buffer is not full */ + break ; + } else { + /* Temporary buffer is full */ + iBreakPosition = up->iRawBufLen - 1 ; + } + } + } else { + iBreakPosition = up->iRawBufLen - 1 ; + } + + /* Copy charaters from temporary buffer to process buffer */ + up->iLineBufLen = up->iTextBufLen = 0 ; + for ( i = iReadRawBuf ; i <= iBreakPosition ; i ++ ) { + + /* Copy all characters */ + up->sLineBuf[up->iLineBufLen] = up->sRawBuf[i] ; + up->iLineBufLen ++ ; + + /* Copy printable characters */ + if ( ! iscntrl( up->sRawBuf[i] ) ) { + up->sTextBuf[up->iTextBufLen] = up->sRawBuf[i] ; + up->iTextBufLen ++ ; + } + + } + up->sLineBuf[up->iLineBufLen] = 0 ; + up->sTextBuf[up->iTextBufLen] = 0 ; #ifdef DEBUG - if ( debug ) { + printf( "refclock_jjy.c : %s : up->iLineBufLen=%d up->iTextBufLen=%d\n", + sFunctionName, up->iLineBufLen, up->iTextBufLen ) ; +#endif + + if ( up->bSkipCntrlCharOnly && up->iTextBufLen == 0 ) { +#ifdef DEBUG + printf( "refclock_jjy.c : %s : Skip cntrl char only : up->iRawBufLen=%d iReadRawBuf=%d iBreakPosition=%d\n", + sFunctionName, up->iRawBufLen, iReadRawBuf, iBreakPosition ) ; +#endif + if ( iBreakPosition + 1 < up->iRawBufLen ) { + iReadRawBuf = iBreakPosition + 1 ; + continue ; + } else { + break ; + } + + } + + } + if ( up->linediscipline == LDISC_RAW ) { - printableString( sLogText, MAX_LOGTEXT, up->rawbuf, up->charcount ) ; + pBuf = up->sLineBuf ; + iLen = up->iLineBufLen ; } else { - printableString( sLogText, MAX_LOGTEXT, pp->a_lastcode, pp->lencode ) ; + pBuf = pp->a_lastcode ; + iLen = pp->lencode ; + } + + iCopyLen = ( iLen <= sizeof(sLogText)-1 ? iLen : sizeof(sLogText)-1 ) ; + strncpy( sLogText, pBuf, iCopyLen ) ; + sLogText[iCopyLen] = 0 ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_RECEIVE, sLogText ) ; + + switch ( up->unittype ) { + + case UNITTYPE_TRISTATE_JJY01 : + rc = jjy_receive_tristate_jjy01 ( rbufp ) ; + break ; + + case UNITTYPE_CDEX_JST2000 : + rc = jjy_receive_cdex_jst2000 ( rbufp ) ; + break ; + + case UNITTYPE_ECHOKEISOKUKI_LT2000 : + rc = jjy_receive_echokeisokuki_lt2000 ( rbufp ) ; + break ; + + case UNITTYPE_CITIZENTIC_JJY200 : + rc = jjy_receive_citizentic_jjy200 ( rbufp ) ; + break ; + + case UNITTYPE_TRISTATE_GPSCLOCK01 : + rc = jjy_receive_tristate_gpsclock01 ( rbufp ) ; + break ; + + case UNITTYPE_SEIKO_TIMESYS_TDC_300 : + rc = jjy_receive_seiko_tsys_tdc_300 ( rbufp ) ; + break ; + + case UNITTYPE_TELEPHONE : + rc = jjy_receive_telephone ( rbufp ) ; + break ; + + default : + rc = JJY_RECEIVE_ERROR ; + break ; + + } + + switch ( rc ) { + case JJY_RECEIVE_DONE : + case JJY_RECEIVE_SKIP : + up->iProcessState = JJY_PROCESS_STATE_DONE ; + break ; + case JJY_RECEIVE_ERROR : + up->iProcessState = JJY_PROCESS_STATE_ERROR ; + break ; + default : + break ; + } + + if ( up->linediscipline == LDISC_RAW ) { + if ( rc == JJY_RECEIVE_UNPROCESS ) { + break ; + } + iReadRawBuf = iBreakPosition + 1 ; + if ( iReadRawBuf >= up->iRawBufLen ) { + /* Processed all received data */ + break ; + } + } + + if ( up->linediscipline == LDISC_CLK ) { + break ; + } + + } + + if ( up->linediscipline == LDISC_RAW && iReadRawBuf > 0 ) { + for ( i = 0, j = iReadRawBuf ; j < up->iRawBufLen ; i ++, j++ ) { + up->sRawBuf[i] = up->sRawBuf[j] ; } - printf ( "jjy_receive (refclock_jjy.c) : [%s]\n", sLogText ) ; + up->iRawBufLen -= iReadRawBuf ; + if ( up->iRawBufLen < 0 ) { + up->iRawBufLen = 0 ; + } + } + + up->bReceiveFlag = FALSE ; + +} + +/**************************************************************************************************/ + +static int +getRawDataBreakPosition ( struct jjyunit *up, int iStart ) +{ + + int i, j ; + + if ( iStart >= up->iRawBufLen ) { +#ifdef DEBUG + printf( "refclock_jjy.c : getRawDataBreakPosition : iStart=%d return=-1\n", iStart ) ; +#endif + return -1 ; } + + for ( i = iStart ; i < up->iRawBufLen ; i ++ ) { + + for ( j = 0 ; up->pRawBreak[j].pString != NULL ; j ++ ) { + + if ( i + up->pRawBreak[j].iLength <= up->iRawBufLen ) { + + if ( strncmp( up->sRawBuf + i, + up->pRawBreak[j].pString, + up->pRawBreak[j].iLength ) == 0 ) { + +#ifdef DEBUG + printf( "refclock_jjy.c : getRawDataBreakPosition : iStart=%d return=%d\n", + iStart, i + up->pRawBreak[j].iLength - 1 ) ; #endif + return i + up->pRawBreak[j].iLength - 1 ; - pp->lastrec = tRecvTimestamp ; + } + } + } + } + +#ifdef DEBUG + printf( "refclock_jjy.c : getRawDataBreakPosition : iStart=%d return=-1\n", iStart ) ; +#endif + return -1 ; + +} + +/**************************************************************************************************/ +/* jjy_poll - called by the transmit procedure */ +/**************************************************************************************************/ +static void +jjy_poll ( int unit, struct peer *peer ) +{ + + char sLog [ 40 ], sReach [ 9 ] ; + + struct jjyunit *up; + struct refclockproc *pp; + + pp = peer->procptr; + up = pp->unitptr ; + + if ( up->bInitError ) { + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, "Ignore polling because of error during initializing" ) ; + return ; + } + + if ( pp->polls > 0 && up->iLineCount == 0 ) { + /* + * No reply for last command + */ + refclock_report ( peer, CEVNT_TIMEOUT ) ; + } - up->linecount ++ ; + pp->polls ++ ; - if ( up->lineerror != 0 ) return ; + sReach[0] = peer->reach & 0x80 ? '1' : '0' ; + sReach[1] = peer->reach & 0x40 ? '1' : '0' ; + sReach[2] = peer->reach & 0x20 ? '1' : '0' ; + sReach[3] = peer->reach & 0x10 ? '1' : '0' ; + sReach[4] = peer->reach & 0x08 ? '1' : '0' ; + sReach[5] = peer->reach & 0x04 ? '1' : '0' ; + sReach[6] = peer->reach & 0x02 ? '1' : '0' ; + sReach[7] = 0 ; /* This poll */ + sReach[8] = 0 ; + + snprintf( sLog, sizeof(sLog), "polls=%ld reach=%s", pp->polls, sReach ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ATTENTION, sLog ) ; + + up->iProcessState = JJY_PROCESS_STATE_POLL ; + up->iCommandSeq = 0 ; + up->iReceiveSeq = 0 ; + up->iLineCount = 0 ; + up->bLineError = FALSE ; + up->iRawBufLen = 0 ; switch ( up->unittype ) { case UNITTYPE_TRISTATE_JJY01 : - rc = jjy_receive_tristate_jjy01 ( rbufp ) ; + jjy_poll_tristate_jjy01 ( unit, peer ) ; break ; case UNITTYPE_CDEX_JST2000 : - rc = jjy_receive_cdex_jst2000 ( rbufp ) ; + jjy_poll_cdex_jst2000 ( unit, peer ) ; break ; case UNITTYPE_ECHOKEISOKUKI_LT2000 : - rc = jjy_receive_echokeisokuki_lt2000 ( rbufp ) ; + jjy_poll_echokeisokuki_lt2000 ( unit, peer ) ; break ; case UNITTYPE_CITIZENTIC_JJY200 : - rc = jjy_receive_citizentic_jjy200 ( rbufp ) ; + jjy_poll_citizentic_jjy200 ( unit, peer ) ; break ; case UNITTYPE_TRISTATE_GPSCLOCK01 : - rc = jjy_receive_tristate_gpsclock01 ( rbufp ) ; + jjy_poll_tristate_gpsclock01 ( unit, peer ) ; + break ; + + case UNITTYPE_SEIKO_TIMESYS_TDC_300 : + jjy_poll_seiko_tsys_tdc_300 ( unit, peer ) ; + break ; + + case UNITTYPE_TELEPHONE : + jjy_poll_telephone ( unit, peer ) ; break ; default : - rc = 0 ; break ; } - if ( up->linediscipline == LDISC_RAW ) { - if ( up->linecount <= up->lineexpect && - up->charcount > up->charexpect[up->linecount-1] ) { - for ( i = 0 ; - i < up->charcount - up->charexpect[up->linecount-1] ; - i ++ ) { - up->rawbuf[i] = up->rawbuf[i+up->charexpect[up->linecount-1]] ; - } - up->charcount -= up->charexpect[up->linecount-1] ; - } else { - up->charcount = 0 ; - } +} + +/**************************************************************************************************/ +/* jjy_timer - called at one-second intervals */ +/**************************************************************************************************/ +static void +jjy_timer ( int unit, struct peer *peer ) +{ + + struct refclockproc *pp ; + struct jjyunit *up ; + +#ifdef DEBUG + if ( debug ) { + printf ( "refclock_jjy.c : jjy_timer\n" ) ; } +#endif - if ( rc == 0 ) { + pp = peer->procptr ; + up = pp->unitptr ; + + if ( up->bReceiveFlag ) { +#ifdef DEBUG + if ( debug ) { + printf ( "refclock_jjy.c : jjy_timer : up->bReceiveFlag= TRUE : Timer skipped.\n" ) ; + } +#endif return ; } - up->bPollFlag = 0 ; + switch ( up->unittype ) { + + case UNITTYPE_TELEPHONE : + jjy_timer_telephone ( unit, peer ) ; + break ; + + default : + break ; - if ( up->lineerror != 0 ) { - refclock_report ( peer, CEVNT_BADREPLY ) ; - strlcpy ( sLogText, "BAD REPLY [", - sizeof( sLogText ) ) ; - if ( up->linediscipline == LDISC_RAW ) { - strlcat ( sLogText, up->rawbuf, - sizeof( sLogText ) ) ; - } else { - strlcat ( sLogText, pp->a_lastcode, - sizeof( sLogText ) ) ; - } - sLogText[MAX_LOGTEXT-1] = 0 ; - if ( strlen ( sLogText ) < MAX_LOGTEXT - 2 ) - strlcat ( sLogText, "]", - sizeof( sLogText ) ) ; - record_clock_stats ( &peer->srcadr, sLogText ) ; - return ; } +} + +/**************************************************************************************************/ +/* jjy_synctime */ +/**************************************************************************************************/ +static void +jjy_synctime ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + char sLog [ 80 ], cStatus ; + const char *pStatus ; + pp->year = up->year ; - pp->day = ymd2yd ( up->year, up->month, up->day ) ; + pp->day = ymd2yd( up->year, up->month, up->day ) ; pp->hour = up->hour ; pp->minute = up->minute ; pp->second = up->second ; - pp->nsec = up->msecond * 1000000; + pp->nsec = up->msecond * 1000000 ; /* * JST to UTC @@ -700,226 +1019,423 @@ jjy_receive ( struct recvbuf *rbufp ) pp->day -- ; if ( pp->day < 1 ) { pp->year -- ; - pp->day = ymd2yd ( pp->year, 12, 31 ) ; + pp->day = ymd2yd( pp->year, 12, 31 ) ; } } -#ifdef DEBUG - if ( debug ) { - printf ( "jjy_receive (refclock_jjy.c) : %04d/%02d/%02d %02d:%02d:%02d.%1d JST ", - up->year, up->month, up->day, up->hour, - up->minute, up->second, up->msecond/100 ) ; - printf ( "( %04d/%03d %02d:%02d:%02d.%1d UTC )\n", - pp->year, pp->day, pp->hour, pp->minute, - pp->second, (int)(pp->nsec/100000000) ) ; - } -#endif /* * Process the new sample in the median filter and determine the * timecode timestamp. */ - snprintf ( sLogText, sizeof(sLogText), - "%04d/%02d/%02d %02d:%02d:%02d.%1d JST", - up->year, up->month, up->day, - up->hour, up->minute, up->second, up->msecond/100 ) ; - record_clock_stats ( &peer->srcadr, sLogText ) ; - - if ( ! refclock_process ( pp ) ) { - refclock_report(peer, CEVNT_BADTIME); + if ( ! refclock_process( pp ) ) { + refclock_report( peer, CEVNT_BADTIME ) ; return ; } - pp->lastref = pp->lastrec; - refclock_receive(peer); + pp->lastref = pp->lastrec ; + + refclock_receive( peer ) ; + + /* + * Write into the clockstats file + */ + snprintf ( sLog, sizeof(sLog), + "%04d/%02d/%02d %02d:%02d:%02d.%03d JST ( %04d/%03d %02d:%02d:%02d.%03d UTC )", + up->year, up->month, up->day, + up->hour, up->minute, up->second, up->msecond, + pp->year, pp->day, pp->hour, pp->minute, pp->second, + (int)(pp->nsec/1000000) ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ATTENTION, sLog ) ; + + cStatus = ' ' ; + pStatus = "" ; + + switch ( peer->status ) { + case 0 : cStatus = ' ' ; pStatus = "Reject" ; break ; + case 1 : cStatus = 'x' ; pStatus = "FalseTick" ; break ; + case 2 : cStatus = '.' ; pStatus = "Excess" ; break ; + case 3 : cStatus = '-' ; pStatus = "Outlier" ; break ; + case 4 : cStatus = '+' ; pStatus = "Candidate" ; break ; + case 5 : cStatus = '#' ; pStatus = "Selected" ; break ; + case 6 : cStatus = '*' ; pStatus = "Sys.Peer" ; break ; + case 7 : cStatus = 'o' ; pStatus = "PPS.Peer" ; break ; + default : break ; + } + + snprintf ( sLog, sizeof(sLog), + "status %d [%c] %s : offset %3.3f mSec. : jitter %3.3f mSec.", + peer->status, cStatus, pStatus, peer->offset * 1000, peer->jitter * 1000 ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_INFORMATION, sLog ) ; } +/*################################################################################################*/ +/*################################################################################################*/ +/*## ##*/ +/*## The Tristate Ltd. JJY receiver TS-JJY01, TS-JJY02 ##*/ +/*## ##*/ +/*## server 127.127.40.X mode 1 ##*/ +/*## ##*/ +/*################################################################################################*/ +/*################################################################################################*/ +/* */ +/* Command Response Remarks */ +/* -------------------- ---------------------------------------- ---------------------------- */ +/* dcst<CR><LF> VALID<CR><LF> or INVALID<CR><LF> */ +/* stus<CR><LF> ADJUSTED<CR><LF> or UNADJUSTED<CR><LF> */ +/* date<CR><LF> YYYY/MM/DD XXX<CR><LF> XXX is the day of the week */ +/* time<CR><LF> HH:MM:SS<CR><LF> Not used by this driver */ +/* stim<CR><LF> HH:MM:SS<CR><LF> Reply at just second */ +/* */ +/*################################################################################################*/ + +#define TS_JJY01_COMMAND_NUMBER_DATE 1 +#define TS_JJY01_COMMAND_NUMBER_TIME 2 +#define TS_JJY01_COMMAND_NUMBER_STIM 3 +#define TS_JJY01_COMMAND_NUMBER_STUS 4 +#define TS_JJY01_COMMAND_NUMBER_DCST 5 + +#define TS_JJY01_REPLY_DATE "yyyy/mm/dd www" +#define TS_JJY01_REPLY_STIM "hh:mm:ss" +#define TS_JJY01_REPLY_STUS_ADJUSTED "adjusted" +#define TS_JJY01_REPLY_STUS_UNADJUSTED "unadjusted" +#define TS_JJY01_REPLY_DCST_VALID "valid" +#define TS_JJY01_REPLY_DCST_INVALID "invalid" + +#define TS_JJY01_REPLY_LENGTH_DATE 14 /* Length without <CR><LF> */ +#define TS_JJY01_REPLY_LENGTH_TIME 8 /* Length without <CR><LF> */ +#define TS_JJY01_REPLY_LENGTH_STIM 8 /* Length without <CR><LF> */ +#define TS_JJY01_REPLY_LENGTH_STUS_ADJUSTED 8 /* Length without <CR><LF> */ +#define TS_JJY01_REPLY_LENGTH_STUS_UNADJUSTED 10 /* Length without <CR><LF> */ +#define TS_JJY01_REPLY_LENGTH_DCST_VALID 5 /* Length without <CR><LF> */ +#define TS_JJY01_REPLY_LENGTH_DCST_INVALID 7 /* Length without <CR><LF> */ + +static struct +{ + const char commandNumber ; + const char *command ; + int commandLength ; + int iExpectedReplyLength [ 2 ] ; +} tristate_jjy01_command_sequence[] = +{ + { 0, NULL, 0, { 0, 0 } }, /* Idle */ + { TS_JJY01_COMMAND_NUMBER_DCST, "dcst\r\n", 6, { TS_JJY01_REPLY_LENGTH_DCST_VALID , TS_JJY01_REPLY_LENGTH_DCST_INVALID } }, + { TS_JJY01_COMMAND_NUMBER_STUS, "stus\r\n", 6, { TS_JJY01_REPLY_LENGTH_STUS_ADJUSTED, TS_JJY01_REPLY_LENGTH_STUS_UNADJUSTED } }, + { TS_JJY01_COMMAND_NUMBER_TIME, "time\r\n", 6, { TS_JJY01_REPLY_LENGTH_TIME , TS_JJY01_REPLY_LENGTH_TIME } }, + { TS_JJY01_COMMAND_NUMBER_DATE, "date\r\n", 6, { TS_JJY01_REPLY_LENGTH_DATE , TS_JJY01_REPLY_LENGTH_DATE } }, + { TS_JJY01_COMMAND_NUMBER_STIM, "stim\r\n", 6, { TS_JJY01_REPLY_LENGTH_STIM , TS_JJY01_REPLY_LENGTH_STIM } }, + /* End of command */ + { 0, NULL, 0, { 0, 0 } } +} ; + /**************************************************************************************************/ static int -jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp ) +jjy_start_tristate_jjy01 ( int unit, struct peer *peer, struct jjyunit *up ) { -#ifdef DEBUG - static const char *sFunctionName = "jjy_receive_tristate_jjy01" ; -#endif + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, "Refclock: Tristate Ltd. TS-JJY01, TS-JJY02" ) ; + + up->unittype = UNITTYPE_TRISTATE_JJY01 ; + up->linespeed = SPEED232_TRISTATE_JJY01 ; + up->linediscipline = LDISC_CLK ; + + return 0 ; + +} + +/**************************************************************************************************/ + +static int +jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp ) +{ struct jjyunit *up ; struct refclockproc *pp ; struct peer *peer; - char *pBuf ; + char *pBuf, sLog [ 100 ] ; int iLen ; int rc ; - int bOverMidnight = 0 ; - - char sLogText [ MAX_LOGTEXT ], sReplyText [ MAX_LOGTEXT ] ; - const char *pCmd ; int iCmdLen ; - /* - * Initialize pointers and read the timecode and timestamp - */ + /* Initialize pointers */ + peer = rbufp->recv_peer ; pp = peer->procptr ; up = pp->unitptr ; if ( up->linediscipline == LDISC_RAW ) { - pBuf = up->rawbuf ; - iLen = up->charcount ; + pBuf = up->sTextBuf ; + iLen = up->iTextBufLen ; } else { pBuf = pp->a_lastcode ; iLen = pp->lencode ; } - switch ( tristate_jjy01_command_sequence[up->linecount-1].commandNumber ) { + DEBUG_PRINTF_JJY_RECEIVE( "jjy_receive_tristate_jjy01", iLen ) ; - case TS_JJY01_COMMAND_NUMBER_DATE : /* YYYY/MM/DD WWW */ + /* Check expected reply */ - if ( iLen != TS_JJY01_REPLY_LENGTH_DATE ) { - up->lineerror = 1 ; - break ; - } + if ( tristate_jjy01_command_sequence[up->iCommandSeq].command == NULL ) { + /* Command sequence has not been started, or has been completed */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_UNEXPECTED_REPLY, + pBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } - rc = sscanf ( pBuf, "%4d/%2d/%2d", &up->year, - &up->month, &up->day ) ; - if ( rc != 3 || up->year < 2000 || up->month < 1 || - up->month > 12 || up->day < 1 || up->day > 31 ) { - up->lineerror = 1 ; - break ; - } + /* Check reply length */ - /*** Start of modification on 2004/10/31 ***/ - /* - * Following codes are moved from the function jjy_poll_tristate_jjy01 in this source. - * The Tristate JJY-01 ( Firmware version 1.01 ) accepts "time" and "stim" commands without any delay. - * But the JJY-01 ( Firmware version 2.01 ) does not accept these commands continuously, - * so this driver issues the second command "stim" after the reply of the first command "date". - */ + if ( iLen != tristate_jjy01_command_sequence[up->iCommandSeq].iExpectedReplyLength[0] + && iLen != tristate_jjy01_command_sequence[up->iCommandSeq].iExpectedReplyLength[1] ) { + /* Unexpected reply length */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_LENGTH, + iLen ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } - /*** 2010/11/20 ***/ - /* - * Codes of a next command issue are moved to the end of this function. - */ + /* Parse reply */ + + switch ( tristate_jjy01_command_sequence[up->iCommandSeq].commandNumber ) { + + case TS_JJY01_COMMAND_NUMBER_DATE : /* YYYY/MM/DD WWW */ - /*** End of modification ***/ + rc = sscanf ( pBuf, "%4d/%2d/%2d", + &up->year, &up->month, &up->day ) ; + + if ( rc != 3 || up->year < 2000 || 2099 <= up->year + || up->month < 1 || 12 < up->month + || up->day < 1 || 31 < up->day ) { + /* Invalid date */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATE, + rc, up->year, up->month, up->day ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } break ; case TS_JJY01_COMMAND_NUMBER_TIME : /* HH:MM:SS */ case TS_JJY01_COMMAND_NUMBER_STIM : /* HH:MM:SS */ - if ( iLen != TS_JJY01_REPLY_LENGTH_STIM ) { - up->lineerror = 1 ; - break ; + if ( up->iTimestampCount >= 2 ) { + /* Too many time reply */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_TOO_MANY_REPLY, + up->iTimestampCount ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } - rc = sscanf ( pBuf, "%2d:%2d:%2d", &up->hour, - &up->minute, &up->second ) ; + rc = sscanf ( pBuf, "%2d:%2d:%2d", + &up->hour, &up->minute, &up->second ) ; + if ( rc != 3 || up->hour > 23 || up->minute > 59 || up->second > 60 ) { - up->lineerror = 1 ; - break ; + /* Invalid time */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_TIME, + rc, up->hour, up->minute, up->second ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } + up->iTimestamp[up->iTimestampCount] = ( up->hour * 60 + up->minute ) * 60 + up->second ; + + up->iTimestampCount++ ; + up->msecond = 0 ; - if ( up->hour == 0 && up->minute == 0 && up->second <= 2 ) { - /* - * The command "date" and "time" ( or "stim" ) were sent to the JJY receiver separately, - * and the JJY receiver replies a date and time separately. - * Just after midnight transitions, we ignore this time. - */ - bOverMidnight = 1 ; - } + break ; case TS_JJY01_COMMAND_NUMBER_STUS : - if ( ( iLen == TS_JJY01_REPLY_LENGTH_STUS_YES - && strncmp( pBuf, TS_JJY01_REPLY_STUS_YES, - TS_JJY01_REPLY_LENGTH_STUS_YES ) == 0 ) - || ( iLen == TS_JJY01_REPLY_LENGTH_STUS_NO - && strncmp( pBuf, TS_JJY01_REPLY_STUS_NO, - TS_JJY01_REPLY_LENGTH_STUS_NO ) == 0 ) ) { + if ( strncmp( pBuf, TS_JJY01_REPLY_STUS_ADJUSTED, + TS_JJY01_REPLY_LENGTH_STUS_ADJUSTED ) == 0 + || strncmp( pBuf, TS_JJY01_REPLY_STUS_UNADJUSTED, + TS_JJY01_REPLY_LENGTH_STUS_UNADJUSTED ) == 0 ) { /* Good */ } else { - up->lineerror = 1 ; - break ; + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY, + pBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } break ; case TS_JJY01_COMMAND_NUMBER_DCST : - if ( ( iLen == TS_JJY01_REPLY_LENGTH_DCST_VALID - && strncmp( pBuf, TS_JJY01_REPLY_DCST_VALID, - TS_JJY01_REPLY_LENGTH_DCST_VALID ) == 0 ) - || ( iLen == TS_JJY01_REPLY_LENGTH_DCST_INVALID - && strncmp( pBuf, TS_JJY01_REPLY_DCST_INVALID, - TS_JJY01_REPLY_LENGTH_DCST_INVALID ) == 0 ) ) { + if ( strncmp( pBuf, TS_JJY01_REPLY_DCST_VALID, + TS_JJY01_REPLY_LENGTH_DCST_VALID ) == 0 + || strncmp( pBuf, TS_JJY01_REPLY_DCST_INVALID, + TS_JJY01_REPLY_LENGTH_DCST_INVALID ) == 0 ) { /* Good */ } else { - up->lineerror = 1 ; - break ; + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY, + pBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } break ; default : /* Unexpected reply */ - up->lineerror = 1 ; - break ; + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY, + pBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } - /* Clockstats Log */ + if ( up->iTimestampCount == 2 ) { + /* Process date and time */ + + if ( up->iTimestamp[1] - 2 <= up->iTimestamp[0] + && up->iTimestamp[0] <= up->iTimestamp[1] ) { + /* 3 commands (time,date,stim) was excuted in two seconds */ + jjy_synctime( peer, pp, up ) ; + return JJY_RECEIVE_DONE ; + } else if ( up->iTimestamp[0] > up->iTimestamp[1] ) { + /* Over midnight, and date is unsure */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_OVER_MIDNIGHT_2, + up->iTimestamp[0], up->iTimestamp[1] ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_INFORMATION, sLog ) ; + return JJY_RECEIVE_SKIP ; + } else { + /* Slow reply */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SLOW_REPLY_2, + up->iTimestamp[0], up->iTimestamp[1] ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } - printableString( sReplyText, sizeof(sReplyText), pBuf, iLen ) ; - snprintf ( sLogText, sizeof(sLogText), "%d: %s -> %c: %s", - up->linecount, - tristate_jjy01_command_sequence[up->linecount-1].commandLog, - ( up->lineerror == 0 ) - ? ( ( bOverMidnight == 0 ) - ? 'O' - : 'S' ) - : 'X', - sReplyText ) ; - record_clock_stats ( &peer->srcadr, sLogText ) ; + } - /* Check before issue next command */ + /* Issue next command */ - if ( up->lineerror != 0 ) { - /* Do not issue next command */ - return 0 ; + if ( tristate_jjy01_command_sequence[up->iCommandSeq].command != NULL ) { + up->iCommandSeq ++ ; } - if ( bOverMidnight != 0 ) { - /* Do not issue next command */ - return 0 ; + if ( tristate_jjy01_command_sequence[up->iCommandSeq].command == NULL ) { + /* Command sequence completed */ + return JJY_RECEIVE_DONE ; } - if ( tristate_jjy01_command_sequence[up->linecount].command == NULL ) { - /* Command sequence completed */ - return 1 ; + pCmd = tristate_jjy01_command_sequence[up->iCommandSeq].command ; + iCmdLen = tristate_jjy01_command_sequence[up->iCommandSeq].commandLength ; + if ( write ( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) { + refclock_report ( peer, CEVNT_FAULT ) ; } - /* Issue next command */ + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, pCmd ) ; + + return JJY_RECEIVE_WAIT ; + +} + +/**************************************************************************************************/ + +static void +jjy_poll_tristate_jjy01 ( int unit, struct peer *peer ) +{ +#ifdef DEBUG + static const char *sFunctionName = "jjy_poll_tristate_jjy01" ; +#endif + + struct refclockproc *pp ; + struct jjyunit *up ; + + const char *pCmd ; + int iCmdLen ; + + pp = peer->procptr; + up = pp->unitptr ; + + up->bLineError = FALSE ; + up->iTimestampCount = 0 ; + + if ( ( pp->sloppyclockflag & CLK_FLAG1 ) == 0 ) { + /* Skip "dcst" and "stus" commands */ + up->iCommandSeq = 2 ; + up->iLineCount = 2 ; + } #ifdef DEBUG if ( debug ) { - printf ( "%s (refclock_jjy.c) : send '%s'\n", - sFunctionName, tristate_jjy01_command_sequence[up->linecount].commandLog ) ; + printf ( "%s (refclock_jjy.c) : flag1=%X CLK_FLAG1=%X up->iLineCount=%d\n", + sFunctionName, pp->sloppyclockflag, CLK_FLAG1, + up->iLineCount ) ; } #endif - pCmd = tristate_jjy01_command_sequence[up->linecount].command ; - iCmdLen = tristate_jjy01_command_sequence[up->linecount].commandLength ; + /* + * Send a first command + */ + + up->iCommandSeq ++ ; + + pCmd = tristate_jjy01_command_sequence[up->iCommandSeq].command ; + iCmdLen = tristate_jjy01_command_sequence[up->iCommandSeq].commandLength ; if ( write ( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) { refclock_report ( peer, CEVNT_FAULT ) ; } + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, pCmd ) ; + +} + +/*################################################################################################*/ +/*################################################################################################*/ +/*## ##*/ +/*## The C-DEX Co. Ltd. JJY receiver JST2000 ##*/ +/*## ##*/ +/*## server 127.127.40.X mode 2 ##*/ +/*## ##*/ +/*################################################################################################*/ +/*################################################################################################*/ +/* */ +/* Command Response Remarks */ +/* -------------------- ---------------------------------------- ---------------------------- */ +/* <ENQ>1J<ETX> <STX>JYYMMDD HHMMSSS<ETX> J is a fixed character */ +/* */ +/*################################################################################################*/ + +static struct jjyRawDataBreak cdex_jst2000_raw_break [ ] = +{ + { "\x03", 1 }, { NULL, 0 } +} ; + +/**************************************************************************************************/ + +static int +jjy_start_cdex_jst2000 ( int unit, struct peer *peer, struct jjyunit *up ) +{ + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, "Refclock: C-DEX Co. Ltd. JST2000" ) ; + + up->unittype = UNITTYPE_CDEX_JST2000 ; + up->linespeed = SPEED232_CDEX_JST2000 ; + up->linediscipline = LDISC_RAW ; + + up->pRawBreak = cdex_jst2000_raw_break ; + up->bWaitBreakString = TRUE ; + + up->bSkipCntrlCharOnly = FALSE ; + return 0 ; } @@ -929,78 +1445,161 @@ jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp ) static int jjy_receive_cdex_jst2000 ( struct recvbuf *rbufp ) { -#ifdef DEBUG - static const char *sFunctionName = "jjy_receive_cdex_jst2000" ; -#endif struct jjyunit *up ; struct refclockproc *pp ; - struct peer *peer; + struct peer *peer ; - char *pBuf ; + char *pBuf, sLog [ 100 ] ; int iLen ; int rc ; - /* - * Initialize pointers and read the timecode and timestamp - */ + /* Initialize pointers */ + peer = rbufp->recv_peer ; pp = peer->procptr ; up = pp->unitptr ; if ( up->linediscipline == LDISC_RAW ) { - pBuf = up->rawbuf ; - iLen = up->charcount ; + pBuf = up->sTextBuf ; + iLen = up->iTextBufLen ; } else { pBuf = pp->a_lastcode ; iLen = pp->lencode ; } - switch ( up->linecount ) { + DEBUG_PRINTF_JJY_RECEIVE( "jjy_receive_cdex_jst2000", iLen ) ; - case 1 : /* JYYMMDD HHMMSSS */ + /* Check expected reply */ - if ( iLen != 15 ) { -#ifdef DEBUG - if ( debug >= 2 ) { - printf ( "%s (refclock_jjy.c) : Reply length error ( iLen=%d )\n", - sFunctionName, iLen ) ; - } -#endif - up->lineerror = 1 ; - break ; - } - rc = sscanf ( pBuf, "J%2d%2d%2d%*1d%2d%2d%2d%1d", - &up->year, &up->month, &up->day, - &up->hour, &up->minute, &up->second, - &up->msecond ) ; - if ( rc != 7 || up->month < 1 || up->month > 12 || - up->day < 1 || up->day > 31 || up->hour > 23 || - up->minute > 59 || up->second > 60 ) { -#ifdef DEBUG - if ( debug >= 2 ) { - printf ( "%s (refclock_jjy.c) : Time error (rc=%d) [ %02d %02d %02d * %02d %02d %02d.%1d ]\n", - sFunctionName, rc, up->year, - up->month, up->day, up->hour, - up->minute, up->second, - up->msecond ) ; - } -#endif - up->lineerror = 1 ; - break ; - } - up->year += 2000 ; - up->msecond *= 100 ; - break ; + if ( up->iCommandSeq != 1 ) { + /* Command sequence has not been started, or has been completed */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_UNEXPECTED_REPLY, + pBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } - default : /* Unexpected reply */ + /* Wait until ETX comes */ - up->lineerror = 1 ; - break ; + if ( up->iLineBufLen < 17 || up->sLineBuf[up->iLineBufLen-1] != 0x03 ) { + return JJY_RECEIVE_UNPROCESS ; + } + + /* Check reply length */ + if ( iLen != 15 ) { + /* Unexpected reply length */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_LENGTH, + iLen ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } - return 1 ; + /* JYYMMDD HHMMSSS */ + + rc = sscanf ( pBuf, "J%2d%2d%2d %2d%2d%2d%1d", + &up->year, &up->month, &up->day, + &up->hour, &up->minute, &up->second, + &up->msecond ) ; + + if ( rc != 7 || up->month < 1 || up->month > 12 || + up->day < 1 || up->day > 31 || up->hour > 23 || + up->minute > 59 || up->second > 60 ) { + /* Invalid date and time */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATETIME, + rc, up->year, up->month, up->day, + up->hour, up->minute, up->second ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } + + up->year += 2000 ; + up->msecond *= 100 ; + + jjy_synctime( peer, pp, up ) ; + + return JJY_RECEIVE_DONE ; + +} + +/**************************************************************************************************/ + +static void +jjy_poll_cdex_jst2000 ( int unit, struct peer *peer ) +{ + + struct refclockproc *pp ; + struct jjyunit *up ; + + pp = peer->procptr ; + up = pp->unitptr ; + + up->bLineError = FALSE ; + up->iRawBufLen = 0 ; + up->iLineBufLen = 0 ; + up->iTextBufLen = 0 ; + + /* + * Send "<ENQ>1J<ETX>" command + */ + + up->iCommandSeq ++ ; + + if ( write ( pp->io.fd, "\0051J\003", 4 ) != 4 ) { + refclock_report ( peer, CEVNT_FAULT ) ; + } + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, "\0051J\003" ) ; + +} + +/*################################################################################################*/ +/*################################################################################################*/ +/*## ##*/ +/*## The Echo Keisokuki Co. Ltd. JJY receiver LT2000 ##*/ +/*## ##*/ +/*## server 127.127.40.X mode 3 ##*/ +/*## ##*/ +/*################################################################################################*/ +/*################################################################################################*/ +/* */ +/* Command Response Remarks */ +/* -------------------- ---------------------------------------- ---------------------------- */ +/* # Mode 1 ( Request & Send ) */ +/* T YYMMDDWHHMMSS<BCC1><BCC2><CR> */ +/* C Mode 2 ( Continuous ) */ +/* YYMMDDWHHMMSS<ST1><ST2><ST3><ST4><CR> 0.5 sec before time stamp */ +/* <SUB> Second signal */ +/* */ +/*################################################################################################*/ + +#define ECHOKEISOKUKI_LT2000_MODE_REQUEST_SEND 1 +#define ECHOKEISOKUKI_LT2000_MODE_CONTINUOUS 2 +#define ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS 3 + +#define ECHOKEISOKUKI_LT2000_COMMAND_REQUEST_SEND "#" +#define ECHOKEISOKUKI_LT2000_COMMAND_REQUEST_TIME "T" +#define ECHOKEISOKUKI_LT2000_COMMAND_CONTINUOUS "C" + +/**************************************************************************************************/ + +static int +jjy_start_echokeisokuki_lt2000 ( int unit, struct peer *peer, struct jjyunit *up ) +{ + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, "Refclock: Echo Keisokuki Co. Ltd. LT2000" ) ; + + up->unittype = UNITTYPE_ECHOKEISOKUKI_LT2000 ; + up->linespeed = SPEED232_ECHOKEISOKUKI_LT2000 ; + up->linediscipline = LDISC_CLK ; + + up->operationmode = ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS ; + + return 0 ; } @@ -1009,157 +1608,211 @@ jjy_receive_cdex_jst2000 ( struct recvbuf *rbufp ) static int jjy_receive_echokeisokuki_lt2000 ( struct recvbuf *rbufp ) { -#ifdef DEBUG - static const char *sFunctionName = "jjy_receive_echokeisokuki_lt2000" ; -#endif struct jjyunit *up ; struct refclockproc *pp ; struct peer *peer; - char *pBuf ; + char *pBuf, sLog [ 100 ], sErr [ 60 ] ; int iLen ; int rc ; int i, ibcc, ibcc1, ibcc2 ; - /* - * Initialize pointers and read the timecode and timestamp - */ + /* Initialize pointers */ + peer = rbufp->recv_peer ; pp = peer->procptr ; up = pp->unitptr ; if ( up->linediscipline == LDISC_RAW ) { - pBuf = up->rawbuf ; - iLen = up->charcount ; + pBuf = up->sTextBuf ; + iLen = up->iTextBufLen ; } else { pBuf = pp->a_lastcode ; iLen = pp->lencode ; } - switch ( up->linecount ) { + DEBUG_PRINTF_JJY_RECEIVE( "jjy_receive_echokeisokuki_lt2000", iLen ) ; + + /* Check reply length */ + + if ( ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_REQUEST_SEND + && iLen != 15 ) + || ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_CONTINUOUS + && iLen != 17 ) + || ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS + && iLen != 17 ) ) { + /* Unexpected reply length */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_LENGTH, + iLen ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } - case 1 : /* YYMMDDWHHMMSS<BCC1><BCC2> or YYMMDDWHHMMSS<ST1><ST2><ST3><ST4> */ + if ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_REQUEST_SEND && iLen == 15 ) { + /* YYMMDDWHHMMSS<BCC1><BCC2> */ - if ( ( up->operationmode == 1 && iLen != 15 ) || - ( up->operationmode == 2 && iLen != 17 ) ) { -#ifdef DEBUG - if ( debug >= 2 ) { - printf ( "%s (refclock_jjy.c) : Reply length error ( iLen=%d )\n", - sFunctionName, iLen ) ; - } -#endif - if ( up->operationmode == 1 ) { -#ifdef DEBUG - if ( debug ) { - printf ( "%s (refclock_jjy.c) : send '#'\n", __func__ ) ; - } -#endif - if ( write ( pp->io.fd, "#",1 ) != 1 ) { - refclock_report ( peer, CEVNT_FAULT ) ; - } - } - up->lineerror = 1 ; - break ; + for ( i = ibcc = 0 ; i < 13 ; i ++ ) { + ibcc ^= pBuf[i] ; } - if ( up->operationmode == 1 ) { + ibcc1 = 0x30 | ( ( ibcc >> 4 ) & 0xF ) ; + ibcc2 = 0x30 | ( ( ibcc ) & 0xF ) ; + if ( pBuf[13] != ibcc1 || pBuf[14] != ibcc2 ) { + snprintf( sErr, sizeof(sErr)-1, " BCC error : Recv=%02X,%02X / Calc=%02X,%02X ", + pBuf[13] & 0xFF, pBuf[14] & 0xFF, + ibcc1, ibcc2 ) ; + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY, + sErr ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } - for ( i = ibcc = 0 ; i < 13 ; i ++ ) - ibcc ^= pBuf[i] ; - ibcc1 = 0x30 | ( ( ibcc >> 4 ) & 0xF ) ; - ibcc2 = 0x30 | ( ( ibcc ) & 0xF ) ; - if ( pBuf[13] != ibcc1 || pBuf[14] != ibcc2 ) { -#ifdef DEBUG - if ( debug >= 2 ) { - printf ( "%s (refclock_jjy.c) : BCC error ( Recv=%02X,%02X / Calc=%02X,%02X)\n", - sFunctionName, - pBuf[13] & 0xFF, - pBuf[14] & 0xFF, - ibcc1, ibcc2 ) ; - } -#endif - up->lineerror = 1 ; - break ; - } + } - } + if ( ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_REQUEST_SEND + && iLen == 15 ) + || ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_CONTINUOUS + && iLen == 17 ) + || ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS + && iLen == 17 ) ) { + /* YYMMDDWHHMMSS<BCC1><BCC2> or YYMMDDWHHMMSS<ST1><ST2><ST3><ST4> */ rc = sscanf ( pBuf, "%2d%2d%2d%*1d%2d%2d%2d", &up->year, &up->month, &up->day, &up->hour, &up->minute, &up->second ) ; - if ( rc != 6 || up->month < 1 || up->month > 12 || - up->day < 1 || up->day > 31 || up->hour > 23 || - up->minute > 59 || up->second > 60 ) { -#ifdef DEBUG - if ( debug >= 2 ) { - printf ( "%s (refclock_jjy.c) : Time error (rc=%d) [ %02d %02d %02d * %02d %02d %02d ]\n", - sFunctionName, rc, up->year, - up->month, up->day, up->hour, - up->minute, up->second ) ; - } -#endif - up->lineerror = 1 ; - break ; + + if ( rc != 6 || up->month < 1 || up->month > 12 + || up->day < 1 || up->day > 31 + || up->hour > 23 || up->minute > 59 || up->second > 60 ) { + /* Invalid date and time */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATETIME, + rc, up->year, up->month, up->day, + up->hour, up->minute, up->second ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } up->year += 2000 ; - if ( up->operationmode == 2 ) { + if ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_CONTINUOUS + || up->operationmode == ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS ) { + /* A time stamp comes on every 0.5 second in the mode 2 of the LT-2000. */ - /* A time stamp comes on every 0.5 seccond in the mode 2 of the LT-2000. */ up->msecond = 500 ; - pp->second -- ; - if ( pp->second < 0 ) { - pp->second = 59 ; - pp->minute -- ; - if ( pp->minute < 0 ) { - pp->minute = 59 ; - pp->hour -- ; - if ( pp->hour < 0 ) { - pp->hour = 23 ; - pp->day -- ; - if ( pp->day < 1 ) { - pp->year -- ; - pp->day = ymd2yd ( pp->year, 12, 31 ) ; + up->second -- ; + if ( up->second < 0 ) { + up->second = 59 ; + up->minute -- ; + if ( up->minute < 0 ) { + up->minute = 59 ; + up->hour -- ; + if ( up->hour < 0 ) { + up->hour = 23 ; + up->day -- ; + if ( up->day < 1 ) { + up->month -- ; + if ( up->month < 1 ) { + up->month = 12 ; + up->year -- ; + } } } } } - /* Switch from mode 2 to mode 1 in order to restraint of useless time stamp. */ -#ifdef DEBUG - if ( debug ) { - printf ( "%s (refclock_jjy.c) : send '#'\n", - sFunctionName ) ; - } -#endif - if ( write ( pp->io.fd, "#",1 ) != 1 ) { - refclock_report ( peer, CEVNT_FAULT ) ; - } - } - break ; + jjy_synctime( peer, pp, up ) ; - default : /* Unexpected reply */ -#ifdef DEBUG - if ( debug ) { - printf ( "%s (refclock_jjy.c) : send '#'\n", - sFunctionName ) ; - } -#endif - if ( write ( pp->io.fd, "#",1 ) != 1 ) { + } + + if (up->operationmode == ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS ) { + /* Switch from mode 2 to mode 1 in order to restraint of useless time stamp. */ + + iLen = strlen( ECHOKEISOKUKI_LT2000_COMMAND_REQUEST_SEND ) ; + if ( write ( pp->io.fd, ECHOKEISOKUKI_LT2000_COMMAND_REQUEST_SEND, iLen ) != iLen ) { refclock_report ( peer, CEVNT_FAULT ) ; } - up->lineerror = 1 ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, ECHOKEISOKUKI_LT2000_COMMAND_REQUEST_SEND ) ; + + } + + return JJY_RECEIVE_DONE ; + +} + +/**************************************************************************************************/ + +static void +jjy_poll_echokeisokuki_lt2000 ( int unit, struct peer *peer ) +{ + + struct refclockproc *pp ; + struct jjyunit *up ; + + char sCmd[2] ; + + pp = peer->procptr ; + up = pp->unitptr ; + + up->bLineError = FALSE ; + + /* + * Send "T" or "C" command + */ + + switch ( up->operationmode ) { + case ECHOKEISOKUKI_LT2000_MODE_REQUEST_SEND : + sCmd[0] = 'T' ; + break ; + case ECHOKEISOKUKI_LT2000_MODE_CONTINUOUS : + case ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS : + sCmd[0] = 'C' ; break ; + } + sCmd[1] = 0 ; + if ( write ( pp->io.fd, sCmd, 1 ) != 1 ) { + refclock_report ( peer, CEVNT_FAULT ) ; } - return 1 ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, sCmd ) ; + +} + +/*################################################################################################*/ +/*################################################################################################*/ +/*## ##*/ +/*## The CITIZEN T.I.C CO., LTD. JJY receiver JJY200 ##*/ +/*## ##*/ +/*## server 127.127.40.X mode 4 ##*/ +/*## ##*/ +/*################################################################################################*/ +/*################################################################################################*/ +/* */ +/* Command Response Remarks */ +/* -------------------- ---------------------------------------- ---------------------------- */ +/* 'XX YY/MM/DD W HH:MM:SS<CR> XX:OK|NG|ER W:0(Mon)-6(Sun) */ +/* */ +/*################################################################################################*/ + +static int +jjy_start_citizentic_jjy200 ( int unit, struct peer *peer, struct jjyunit *up ) +{ + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, "Refclock: CITIZEN T.I.C CO. LTD. JJY200" ) ; + + up->unittype = UNITTYPE_CITIZENTIC_JJY200 ; + up->linespeed = SPEED232_CITIZENTIC_JJY200 ; + up->linediscipline = LDISC_CLK ; + + return 0 ; } @@ -1168,93 +1821,179 @@ jjy_receive_echokeisokuki_lt2000 ( struct recvbuf *rbufp ) static int jjy_receive_citizentic_jjy200 ( struct recvbuf *rbufp ) { -#ifdef DEBUG - static const char *sFunctionName = "jjy_receive_citizentic_jjy200" ; -#endif struct jjyunit *up ; struct refclockproc *pp ; struct peer *peer; - char *pBuf ; + char *pBuf, sLog [ 100 ], sMsg [ 16 ] ; int iLen ; int rc ; char cApostrophe, sStatus[3] ; int iWeekday ; - /* - * Initialize pointers and read the timecode and timestamp - */ + /* Initialize pointers */ + peer = rbufp->recv_peer ; pp = peer->procptr ; up = pp->unitptr ; if ( up->linediscipline == LDISC_RAW ) { - pBuf = up->rawbuf ; - iLen = up->charcount ; + pBuf = up->sTextBuf ; + iLen = up->iTextBufLen ; } else { pBuf = pp->a_lastcode ; iLen = pp->lencode ; } + DEBUG_PRINTF_JJY_RECEIVE( "jjy_receive_citizentic_jjy200", iLen ) ; + /* - * JJY-200 sends a timestamp every second. - * So, a timestamp is ignored unless it is right after polled. - */ - if ( ! up->bPollFlag ) - return 0 ; + * JJY-200 sends a timestamp every second. + * So, a timestamp is ignored unless it is right after polled. + */ - switch ( up->linecount ) { + if ( up->iProcessState != JJY_PROCESS_STATE_RECEIVE ) { + return JJY_RECEIVE_SKIP ; + } - case 1 : /* 'XX YY/MM/DD W HH:MM:SS<CR> */ + /* Check reply length */ - if ( iLen != 23 ) { -#ifdef DEBUG - if ( debug >= 2 ) { - printf ( "%s (refclock_jjy.c) : Reply length error ( iLen=%d )\n", - sFunctionName, iLen ) ; - } -#endif - up->lineerror = 1 ; - break ; - } + if ( iLen != 23 ) { + /* Unexpected reply length */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_LENGTH, + iLen ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } - rc = sscanf ( pBuf, "%c%2s %2d/%2d/%2d %1d %2d:%2d:%2d", - &cApostrophe, sStatus, &up->year, - &up->month, &up->day, &iWeekday, - &up->hour, &up->minute, &up->second ) ; - sStatus[2] = 0 ; - if ( rc != 9 || cApostrophe != '\'' || - strcmp( sStatus, "OK" ) != 0 || up->month < 1 || - up->month > 12 || up->day < 1 || up->day > 31 || - iWeekday > 6 || up->hour > 23 || up->minute > 59 || - up->second > 60 ) { -#ifdef DEBUG - if ( debug >= 2 ) { - printf ( "%s (refclock_jjy.c) : Time error (rc=%d) [ %c %2s %02d %02d %02d %d %02d %02d %02d ]\n", - sFunctionName, rc, cApostrophe, - sStatus, up->year, up->month, - up->day, iWeekday, up->hour, - up->minute, up->second ) ; - } -#endif - up->lineerror = 1 ; - break ; - } + /* 'XX YY/MM/DD W HH:MM:SS<CR> */ + + rc = sscanf ( pBuf, "%c%2s %2d/%2d/%2d %1d %2d:%2d:%2d", + &cApostrophe, sStatus, + &up->year, &up->month, &up->day, &iWeekday, + &up->hour, &up->minute, &up->second ) ; + sStatus[2] = 0 ; + + if ( rc != 9 || cApostrophe != '\'' + || ( strcmp( sStatus, "OK" ) != 0 + && strcmp( sStatus, "NG" ) != 0 + && strcmp( sStatus, "ER" ) != 0 ) + || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31 + || iWeekday > 6 + || up->hour > 23 || up->minute > 59 || up->second > 60 ) { + /* Invalid date and time */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATETIME, + rc, up->year, up->month, up->day, + up->hour, up->minute, up->second ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } else if ( strcmp( sStatus, "NG" ) == 0 + || strcmp( sStatus, "ER" ) == 0 ) { + /* Timestamp is unsure */ + snprintf( sMsg, sizeof(sMsg)-1, "status=%s", sStatus ) ; + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_TIMESTAMP_UNSURE, + sMsg ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_WARNING, sLog ) ; + return JJY_RECEIVE_SKIP ; + } - up->year += 2000 ; - up->msecond = 0 ; + up->year += 2000 ; + up->msecond = 0 ; - break ; + jjy_synctime( peer, pp, up ) ; - default : /* Unexpected reply */ + return JJY_RECEIVE_DONE ; - up->lineerror = 1 ; - break ; +} - } +/**************************************************************************************************/ - return 1 ; +static void +jjy_poll_citizentic_jjy200 ( int unit, struct peer *peer ) +{ + + struct refclockproc *pp ; + struct jjyunit *up ; + + pp = peer->procptr ; + up = pp->unitptr ; + + up->bLineError = FALSE ; + +} + +/*################################################################################################*/ +/*################################################################################################*/ +/*## ##*/ +/*## The Tristate Ltd. GPS clock TS-GPS01 ##*/ +/*## ##*/ +/*## server 127.127.40.X mode 5 ##*/ +/*## ##*/ +/*################################################################################################*/ +/*################################################################################################*/ +/* */ +/* This clock has NMEA mode and command/respose mode. */ +/* When this jjy driver are used, set to command/respose mode of this clock */ +/* by the onboard switch SW4, and make sure the LED-Y is tured on. */ +/* Other than this JJY driver, the refclock driver type 20, generic NMEA driver, */ +/* works with the NMEA mode of this clock. */ +/* */ +/* Command Response Remarks */ +/* -------------------- ---------------------------------------- ---------------------------- */ +/* stus<CR><LF> *R|*G|*U|+U<CR><LF> */ +/* date<CR><LF> YY/MM/DD<CR><LF> */ +/* time<CR><LF> HH:MM:SS<CR><LF> */ +/* */ +/*################################################################################################*/ + +#define TS_GPS01_COMMAND_NUMBER_DATE 1 +#define TS_GPS01_COMMAND_NUMBER_TIME 2 +#define TS_GPS01_COMMAND_NUMBER_STUS 4 + +#define TS_GPS01_REPLY_DATE "yyyy/mm/dd" +#define TS_GPS01_REPLY_TIME "hh:mm:ss" +#define TS_GPS01_REPLY_STUS_RTC "*R" +#define TS_GPS01_REPLY_STUS_GPS "*G" +#define TS_GPS01_REPLY_STUS_UTC "*U" +#define TS_GPS01_REPLY_STUS_PPS "+U" + +#define TS_GPS01_REPLY_LENGTH_DATE 10 /* Length without <CR><LF> */ +#define TS_GPS01_REPLY_LENGTH_TIME 8 /* Length without <CR><LF> */ +#define TS_GPS01_REPLY_LENGTH_STUS 2 /* Length without <CR><LF> */ + +static struct +{ + char commandNumber ; + const char *command ; + int commandLength ; + int iExpectedReplyLength ; +} tristate_gps01_command_sequence[] = +{ + { 0, NULL, 0, 0 }, /* Idle */ + { TS_GPS01_COMMAND_NUMBER_STUS, "stus\r\n", 6, TS_GPS01_REPLY_LENGTH_STUS }, + { TS_GPS01_COMMAND_NUMBER_TIME, "time\r\n", 6, TS_GPS01_REPLY_LENGTH_TIME }, + { TS_GPS01_COMMAND_NUMBER_DATE, "date\r\n", 6, TS_GPS01_REPLY_LENGTH_DATE }, + { TS_GPS01_COMMAND_NUMBER_TIME, "time\r\n", 6, TS_GPS01_REPLY_LENGTH_TIME }, + /* End of command */ + { 0, NULL, 0, 0 } +} ; + +/**************************************************************************************************/ + +static int +jjy_start_tristate_gpsclock01 ( int unit, struct peer *peer, struct jjyunit *up ) +{ + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, "Refclock: Tristate Ltd. TS-GPS01" ) ; + + up->unittype = UNITTYPE_TRISTATE_GPSCLOCK01 ; + up->linespeed = SPEED232_TRISTATE_GPSCLOCK01 ; + up->linediscipline = LDISC_CLK ; + + return 0 ; } @@ -1271,35 +2010,31 @@ jjy_receive_tristate_gpsclock01 ( struct recvbuf *rbufp ) struct refclockproc *pp ; struct peer *peer; - char *pBuf ; + char *pBuf, sLog [ 100 ] ; int iLen ; int rc ; - int bOverMidnight = 0 ; - - char sLogText [ MAX_LOGTEXT ], sReplyText [ MAX_LOGTEXT ] ; - const char *pCmd ; int iCmdLen ; - /* - * Initialize pointers and read the timecode and timestamp - */ + /* Initialize pointers */ + peer = rbufp->recv_peer ; pp = peer->procptr ; up = pp->unitptr ; if ( up->linediscipline == LDISC_RAW ) { - pBuf = up->rawbuf ; - iLen = up->charcount ; + pBuf = up->sTextBuf ; + iLen = up->iTextBufLen ; } else { pBuf = pp->a_lastcode ; iLen = pp->lencode ; } - /* - * Ignore NMEA data stream - */ + DEBUG_PRINTF_JJY_RECEIVE( "jjy_receive_tristate_gpsclock01", iLen ) ; + + /* Ignore NMEA data stream */ + if ( iLen > 5 && ( strncmp( pBuf, "$GP", 3 ) == 0 || strncmp( pBuf, "$PFEC", 5 ) == 0 ) ) { #ifdef DEBUG @@ -1308,14 +2043,14 @@ jjy_receive_tristate_gpsclock01 ( struct recvbuf *rbufp ) sFunctionName, pBuf ) ; } #endif - return 0 ; + return JJY_RECEIVE_WAIT ; } /* * Skip command prompt '$Cmd>' from the TS-GPSclock-01 */ if ( iLen == 5 && strncmp( pBuf, "$Cmd>", 5 ) == 0 ) { - return 0 ; + return JJY_RECEIVE_WAIT ; } else if ( iLen > 5 && strncmp( pBuf, "$Cmd>", 5 ) == 0 ) { pBuf += 5 ; iLen -= 5 ; @@ -1332,363 +2067,2343 @@ jjy_receive_tristate_gpsclock01 ( struct recvbuf *rbufp ) sFunctionName, pBuf ) ; } #endif - return 0 ; + return JJY_RECEIVE_WAIT ; } - switch ( tristate_gpsclock01_command_sequence[up->linecount-1].commandNumber ) { + /* Check expected reply */ - case TS_GPSCLOCK01_COMMAND_NUMBER_DATE : /* YYYY/MM/DD */ + if ( tristate_gps01_command_sequence[up->iCommandSeq].command == NULL ) { + /* Command sequence has not been started, or has been completed */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_UNEXPECTED_REPLY, + pBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } - if ( iLen != TS_GPSCLOCK01_REPLY_LENGTH_DATE ) { - up->lineerror = 1 ; - break ; - } + /* Check reply length */ + + if ( iLen != tristate_gps01_command_sequence[up->iCommandSeq].iExpectedReplyLength ) { + /* Unexpected reply length */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_LENGTH, + iLen ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } + + /* Parse reply */ + + switch ( tristate_gps01_command_sequence[up->iCommandSeq].commandNumber ) { + + case TS_GPS01_COMMAND_NUMBER_DATE : /* YYYY/MM/DD */ rc = sscanf ( pBuf, "%4d/%2d/%2d", &up->year, &up->month, &up->day ) ; - if ( rc != 3 || up->year < 2000 || up->month < 1 || up->month > 12 || - up->day < 1 || up->day > 31 ) { - up->lineerror = 1 ; - break ; + + if ( rc != 3 || up->year < 2000 || 2099 <= up->year + || up->month < 1 || 12 < up->month + || up->day < 1 || 31 < up->day ) { + /* Invalid date */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATE, + rc, up->year, up->month, up->day ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } break ; - case TS_GPSCLOCK01_COMMAND_NUMBER_TIME : /* HH:MM:SS */ + case TS_GPS01_COMMAND_NUMBER_TIME : /* HH:MM:SS */ - if ( iLen != TS_GPSCLOCK01_REPLY_LENGTH_TIME ) { - up->lineerror = 1 ; - break ; + if ( up->iTimestampCount >= 2 ) { + /* Too many time reply */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_TOO_MANY_REPLY, + up->iTimestampCount ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } - rc = sscanf ( pBuf, "%2d:%2d:%2d", &up->hour, &up->minute, &up->second ) ; - if ( rc != 3 || up->hour > 23 || up->minute > 59 || up->second > 60 ) { - up->lineerror = 1 ; - break ; + rc = sscanf ( pBuf, "%2d:%2d:%2d", + &up->hour, &up->minute, &up->second ) ; + + if ( rc != 3 + || up->hour > 23 || up->minute > 59 || up->second > 60 ) { + /* Invalid time */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_TIME, + rc, up->hour, up->minute, up->second ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } - up->msecond = 0 ; + up->iTimestamp[up->iTimestampCount] = ( up->hour * 60 + up->minute ) * 60 + up->second ; - if ( up->hour == 0 && up->minute == 0 && up->second <= 2 ) { - /* - * The command "date" and "time" were sent to the JJY receiver separately, - * and the JJY receiver replies a date and time separately. - * Just after midnight transitions, we ignore this time. - */ - bOverMidnight = 1 ; - } + up->iTimestampCount++ ; + + up->msecond = 0 ; break ; - case TS_GPSCLOCK01_COMMAND_NUMBER_STUS : + case TS_GPS01_COMMAND_NUMBER_STUS : - if ( iLen == TS_GPSCLOCK01_REPLY_LENGTH_STUS - && ( strncmp( pBuf, TS_GPSCLOCK01_REPLY_STUS_RTC, TS_GPSCLOCK01_REPLY_LENGTH_STUS ) == 0 - || strncmp( pBuf, TS_GPSCLOCK01_REPLY_STUS_GPS, TS_GPSCLOCK01_REPLY_LENGTH_STUS ) == 0 - || strncmp( pBuf, TS_GPSCLOCK01_REPLY_STUS_UTC, TS_GPSCLOCK01_REPLY_LENGTH_STUS ) == 0 - || strncmp( pBuf, TS_GPSCLOCK01_REPLY_STUS_PPS, TS_GPSCLOCK01_REPLY_LENGTH_STUS ) == 0 ) ) { + if ( strncmp( pBuf, TS_GPS01_REPLY_STUS_RTC, TS_GPS01_REPLY_LENGTH_STUS ) == 0 + || strncmp( pBuf, TS_GPS01_REPLY_STUS_GPS, TS_GPS01_REPLY_LENGTH_STUS ) == 0 + || strncmp( pBuf, TS_GPS01_REPLY_STUS_UTC, TS_GPS01_REPLY_LENGTH_STUS ) == 0 + || strncmp( pBuf, TS_GPS01_REPLY_STUS_PPS, TS_GPS01_REPLY_LENGTH_STUS ) == 0 ) { /* Good */ } else { - up->lineerror = 1 ; - break ; + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY, + pBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } break ; default : /* Unexpected reply */ - up->lineerror = 1 ; - break ; + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY, + pBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; } - /* Clockstats Log */ - - printableString( sReplyText, sizeof(sReplyText), pBuf, iLen ) ; - snprintf ( sLogText, sizeof(sLogText), "%d: %s -> %c: %s", - up->linecount, - tristate_gpsclock01_command_sequence[up->linecount-1].commandLog, - ( up->lineerror == 0 ) - ? ( ( bOverMidnight == 0 ) - ? 'O' - : 'S' ) - : 'X', - sReplyText ) ; - record_clock_stats ( &peer->srcadr, sLogText ) ; + if ( up->iTimestampCount == 2 ) { + /* Process date and time */ + + if ( up->iTimestamp[1] - 2 <= up->iTimestamp[0] + && up->iTimestamp[0] <= up->iTimestamp[1] ) { + /* 3 commands (time,date,stim) was excuted in two seconds */ + jjy_synctime( peer, pp, up ) ; + return JJY_RECEIVE_DONE ; + } else if ( up->iTimestamp[0] > up->iTimestamp[1] ) { + /* Over midnight, and date is unsure */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_OVER_MIDNIGHT_2, + up->iTimestamp[0], up->iTimestamp[1] ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_INFORMATION, sLog ) ; + return JJY_RECEIVE_SKIP ; + } else { + /* Slow reply */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SLOW_REPLY_2, + up->iTimestamp[0], up->iTimestamp[1] ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } - /* Check before issue next command */ + } - if ( up->lineerror != 0 ) { - /* Do not issue next command */ - return 0 ; + if ( tristate_gps01_command_sequence[up->iCommandSeq].command == NULL ) { + /* Command sequence completed */ + jjy_synctime( peer, pp, up ) ; + return JJY_RECEIVE_DONE ; } - if ( bOverMidnight != 0 ) { - /* Do not issue next command */ - return 0 ; + /* Issue next command */ + + if ( tristate_gps01_command_sequence[up->iCommandSeq].command != NULL ) { + up->iCommandSeq ++ ; } - if ( tristate_gpsclock01_command_sequence[up->linecount].command == NULL ) { + if ( tristate_gps01_command_sequence[up->iCommandSeq].command == NULL ) { /* Command sequence completed */ - return 1 ; + up->iProcessState = JJY_PROCESS_STATE_DONE ; + return JJY_RECEIVE_DONE ; } - /* Issue next command */ + pCmd = tristate_gps01_command_sequence[up->iCommandSeq].command ; + iCmdLen = tristate_gps01_command_sequence[up->iCommandSeq].commandLength ; + if ( write ( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) { + refclock_report ( peer, CEVNT_FAULT ) ; + } + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, pCmd ) ; + + return JJY_RECEIVE_WAIT ; + +} + +/**************************************************************************************************/ + +static void +jjy_poll_tristate_gpsclock01 ( int unit, struct peer *peer ) +{ +#ifdef DEBUG + static const char *sFunctionName = "jjy_poll_tristate_gpsclock01" ; +#endif + + struct refclockproc *pp ; + struct jjyunit *up ; + + const char *pCmd ; + int iCmdLen ; + + pp = peer->procptr ; + up = pp->unitptr ; + + up->iTimestampCount = 0 ; + + if ( ( pp->sloppyclockflag & CLK_FLAG1 ) == 0 ) { + /* Skip "stus" command */ + up->iCommandSeq = 1 ; + up->iLineCount = 1 ; + } #ifdef DEBUG if ( debug ) { - printf ( "%s (refclock_jjy.c) : send '%s'\n", - sFunctionName, tristate_gpsclock01_command_sequence[up->linecount].commandLog ) ; + printf ( "%s (refclock_jjy.c) : flag1=%X CLK_FLAG1=%X up->iLineCount=%d\n", + sFunctionName, pp->sloppyclockflag, CLK_FLAG1, + up->iLineCount ) ; } #endif - pCmd = tristate_gpsclock01_command_sequence[up->linecount].command ; - iCmdLen = tristate_gpsclock01_command_sequence[up->linecount].commandLength ; + /* + * Send a first command + */ + + up->iCommandSeq ++ ; + + pCmd = tristate_gps01_command_sequence[up->iCommandSeq].command ; + iCmdLen = tristate_gps01_command_sequence[up->iCommandSeq].commandLength ; if ( write ( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) { refclock_report ( peer, CEVNT_FAULT ) ; } - return 0 ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, pCmd ) ; } +/*################################################################################################*/ +/*################################################################################################*/ +/*## ##*/ +/*## The SEIKO TIME SYSTEMS TDC-300 ##*/ +/*## ##*/ +/*## server 127.127.40.X mode 6 ##*/ +/*## ##*/ +/*################################################################################################*/ +/*################################################################################################*/ +/* */ +/* Type Response Remarks */ +/* -------------------- ---------------------------------------- ---------------------------- */ +/* Type 1 <STX>HH:MM:SS<ETX> */ +/* Type 2 <STX>YYMMDDHHMMSSWLSCU<ETX> W:0(Sun)-6(Sat) */ +/* Type 3 <STX>YYMMDDWHHMMSS<ETX> W:0(Sun)-6(Sat) */ +/* <STX><xE5><ETX> 5 to 10 mSec. before second */ +/* */ +/*################################################################################################*/ + +static struct jjyRawDataBreak seiko_tsys_tdc_300_raw_break [ ] = +{ + { "\x03", 1 }, { NULL, 0 } +} ; + /**************************************************************************************************/ -/* jjy_poll - called by the transmit procedure */ + +static int +jjy_start_seiko_tsys_tdc_300 ( int unit, struct peer *peer, struct jjyunit *up ) +{ + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, "Refclock: SEIKO TIME SYSTEMS TDC-300" ) ; + + up->unittype = UNITTYPE_SEIKO_TIMESYS_TDC_300 ; + up->linespeed = SPEED232_SEIKO_TIMESYS_TDC_300 ; + up->linediscipline = LDISC_RAW ; + + up->pRawBreak = seiko_tsys_tdc_300_raw_break ; + up->bWaitBreakString = TRUE ; + + up->bSkipCntrlCharOnly = FALSE ; + + return 0 ; + +} + /**************************************************************************************************/ -static void -jjy_poll ( int unit, struct peer *peer ) + +static int +jjy_receive_seiko_tsys_tdc_300 ( struct recvbuf *rbufp ) { - struct jjyunit *up; - struct refclockproc *pp; + struct peer *peer; + struct refclockproc *pp ; + struct jjyunit *up ; - pp = peer->procptr; + char *pBuf, sLog [ 100 ] ; + int iLen, i ; + int rc, iWeekday ; + time_t now ; + struct tm *pTime ; + + /* Initialize pointers */ + + peer = rbufp->recv_peer ; + pp = peer->procptr ; up = pp->unitptr ; - if ( pp->polls > 0 && up->linecount == 0 ) { - /* - * No reply for last command - */ - refclock_report ( peer, CEVNT_TIMEOUT ) ; + if ( up->linediscipline == LDISC_RAW ) { + pBuf = up->sTextBuf ; + iLen = up->iTextBufLen ; + } else { + pBuf = pp->a_lastcode ; + iLen = pp->lencode ; } -#ifdef DEBUG - if ( debug ) { - printf ( "jjy_poll (refclock_jjy.c) : %ld\n", pp->polls ) ; + DEBUG_PRINTF_JJY_RECEIVE( "jjy_receive_seiko_tsys_tdc_300", iLen ) ; + + /* + * TDC-300 sends a timestamp every second. + * So, a timestamp is ignored unless it is right after polled. + */ + + if ( up->iProcessState != JJY_PROCESS_STATE_RECEIVE ) { + return JJY_RECEIVE_SKIP ; } -#endif - pp->polls ++ ; + /* Process timestamp */ - up->bPollFlag = 1 ; - up->linecount = 0 ; - up->lineerror = 0 ; - up->charcount = 0 ; + up->iReceiveSeq ++ ; - switch ( up->unittype ) { - - case UNITTYPE_TRISTATE_JJY01 : - jjy_poll_tristate_jjy01 ( unit, peer ) ; - break ; + switch ( iLen ) { - case UNITTYPE_CDEX_JST2000 : - jjy_poll_cdex_jst2000 ( unit, peer ) ; - break ; + case 8 : /* Type 1 : <STX>HH:MM:SS<ETX> */ - case UNITTYPE_ECHOKEISOKUKI_LT2000 : - jjy_poll_echokeisokuki_lt2000 ( unit, peer ) ; - break ; + for ( i = 0 ; i < iLen ; i ++ ) { + pBuf[i] &= 0x7F ; + } + + rc = sscanf ( pBuf+1, "%2d:%2d:%2d", + &up->hour, &up->minute, &up->second ) ; + + if ( rc != 3 + || up->hour > 23 || up->minute > 59 || up->second > 60 ) { + /* Invalid time */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_TIME, + rc, up->hour, up->minute, up->second ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } else if ( up->hour == 23 && up->minute == 59 && up->second >= 55 ) { + /* Uncertainty date guard */ + return JJY_RECEIVE_WAIT ; + } + + time( &now ) ; + pTime = localtime( &now ) ; + up->year = pTime->tm_year ; + up->month = pTime->tm_mon + 1 ; + up->day = pTime->tm_mday ; - case UNITTYPE_CITIZENTIC_JJY200 : - jjy_poll_citizentic_jjy200 ( unit, peer ) ; break ; - case UNITTYPE_TRISTATE_GPSCLOCK01 : - jjy_poll_tristate_gpsclock01 ( unit, peer ) ; + case 17 : /* Type 2 : <STX>YYMMDDHHMMSSWLSCU<ETX> */ + + for ( i = 0 ; i < iLen ; i ++ ) { + pBuf[i] &= 0x7F ; + } + + rc = sscanf ( pBuf+1, "%2d%2d%2d%2d%2d%2d%1d", + &up->year, &up->month, &up->day, + &up->hour, &up->minute, &up->second, &iWeekday ) ; + + if ( rc != 7 + || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31 + || iWeekday > 6 + || up->hour > 23 || up->minute > 59 || up->second > 60 ) { + /* Invalid date and time */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATETIME, + rc, up->year, up->month, up->day, + up->hour, up->minute, up->second ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } + break ; - default : + case 13 : /* Type 3 : <STX>YYMMDDWHHMMSS<ETX> */ + + rc = sscanf ( pBuf, "%2d%2d%2d%1d%2d%2d%2d", + &up->year, &up->month, &up->day, &iWeekday, + &up->hour, &up->minute, &up->second ) ; + + if ( rc != 7 + || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31 + || iWeekday > 6 + || up->hour > 23 || up->minute > 59 || up->second > 60 ) { + /* Invalid date and time */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATETIME, + rc, up->year, up->month, up->day, + up->hour, up->minute, up->second ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } + + return JJY_RECEIVE_WAIT ; + + case 1 : /* Type 3 : <STX><xE5><ETX> */ + + if ( ( *pBuf & 0xFF ) != 0xE5 ) { + /* Invalid second signal */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY, + up->sLineBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } else if ( up->iReceiveSeq == 1 ) { + /* Wait for next timestamp */ + up->iReceiveSeq -- ; + return JJY_RECEIVE_WAIT ; + } else if ( up->iReceiveSeq >= 3 ) { + /* Unexpected second signal */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_UNEXPECTED_REPLY, + up->sLineBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } + break ; + default : /* Unexpected reply length */ + + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_LENGTH, + iLen ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + return JJY_RECEIVE_ERROR ; + } + up->year += 2000 ; + up->msecond = 0 ; + + jjy_synctime( peer, pp, up ) ; + + return JJY_RECEIVE_DONE ; + } /**************************************************************************************************/ static void -jjy_poll_tristate_jjy01 ( int unit, struct peer *peer ) +jjy_poll_seiko_tsys_tdc_300 ( int unit, struct peer *peer ) { -#ifdef DEBUG - static const char *sFunctionName = "jjy_poll_tristate_jjy01" ; + + struct refclockproc *pp ; + struct jjyunit *up ; + + pp = peer->procptr ; + up = pp->unitptr ; + + up->bLineError = FALSE ; + +} + +/*################################################################################################*/ +/*################################################################################################*/ +/*## ##*/ +/*## Telephone JJY ##*/ +/*## ##*/ +/*## server 127.127.40.X mode 100 to 180 ##*/ +/*## ##*/ +/*################################################################################################*/ +/*################################################################################################*/ +/* */ +/* Prompt Command Response Remarks */ +/* -------------------- -------------------- -------------------- -------------------------- */ +/* Name<SP>?<SP> TJJY<CR> Welcome messages TJJY is a guest user ID */ +/* > 4DATE<CR> YYYYMMDD<CR> */ +/* > LEAPSEC<CR> XX<CR> One of <SP>0, +1, -1 */ +/* > TIME<CR> HHMMSS<CR> 3 times on second */ +/* > BYE<CR> Sayounara messages */ +/* */ +/*################################################################################################*/ + +static struct jjyRawDataBreak teljjy_raw_break [ ] = +{ + { "\r\n", 2 }, + { "\r" , 1 }, + { "\n" , 1 }, + { "Name ? ", 7 }, + { ">" , 1 }, + { "+++" , 3 }, + { NULL , 0 } +} ; + +#define TELJJY_STATE_IDLE 0 +#define TELJJY_STATE_DAILOUT 1 +#define TELJJY_STATE_LOGIN 2 +#define TELJJY_STATE_CONNECT 3 +#define TELJJY_STATE_BYE 4 + +#define TELJJY_EVENT_NULL 0 +#define TELJJY_EVENT_START 1 +#define TELJJY_EVENT_CONNECT 2 +#define TELJJY_EVENT_DISCONNECT 3 +#define TELJJY_EVENT_COMMAND 4 +#define TELJJY_EVENT_LOGIN 5 /* Posted by the jjy_receive_telephone */ +#define TELJJY_EVENT_PROMPT 6 /* Posted by the jjy_receive_telephone */ +#define TELJJY_EVENT_DATA 7 /* Posted by the jjy_receive_telephone */ +#define TELJJY_EVENT_ERROR 8 /* Posted by the jjy_receive_telephone */ +#define TELJJY_EVENT_SILENT 9 /* Posted by the jjy_timer_telephone */ +#define TELJJY_EVENT_TIMEOUT 10 /* Posted by the jjy_timer_telephone */ + +static void teljjy_control ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; + +static int teljjy_idle_ignore ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_idle_dialout ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_dial_ignore ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_dial_login ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_dial_disc ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_login_ignore ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_login_disc ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_login_conn ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_login_login ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_login_silent ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_login_error ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_conn_ignore ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_conn_disc ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_conn_send ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_conn_data ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_conn_silent ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_conn_error ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_bye_ignore ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_bye_disc ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; +static int teljjy_bye_modem ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; + +static int ( *pTeljjyHandler [ ] [ 5 ] ) ( ) = +{ /*STATE_IDLE STATE_DAILOUT STATE_LOGIN STATE_CONNECT STATE_BYE */ +/* NULL */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_ignore }, +/* START */ { teljjy_idle_dialout, teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_ignore }, +/* CONNECT */ { teljjy_idle_ignore , teljjy_dial_login , teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_ignore }, +/* DISCONNECT */ { teljjy_idle_ignore , teljjy_dial_disc , teljjy_login_disc , teljjy_conn_disc , teljjy_bye_disc }, +/* COMMAND */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_modem }, +/* LOGIN */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_login , teljjy_conn_error , teljjy_bye_ignore }, +/* PROMPT */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_conn , teljjy_conn_send , teljjy_bye_ignore }, +/* DATA */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_data , teljjy_bye_ignore }, +/* ERROR */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_error , teljjy_conn_error , teljjy_bye_ignore }, +/* SILENT */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_silent, teljjy_conn_silent, teljjy_bye_ignore }, +/* TIMEOUT */ { teljjy_idle_ignore , teljjy_dial_disc , teljjy_login_error , teljjy_conn_error , teljjy_bye_modem } +} ; + +static short iTeljjyNextState [ ] [ 5 ] = +{ /*STATE_IDLE STATE_DAILOUT STATE_LOGIN STATE_CONNECT STATE_BYE */ +/* NULL */ { TELJJY_STATE_IDLE , TELJJY_STATE_DAILOUT, TELJJY_STATE_LOGIN , TELJJY_STATE_CONNECT, TELJJY_STATE_BYE }, +/* START */ { TELJJY_STATE_DAILOUT, TELJJY_STATE_DAILOUT, TELJJY_STATE_LOGIN , TELJJY_STATE_CONNECT, TELJJY_STATE_BYE }, +/* CONNECT */ { TELJJY_STATE_IDLE , TELJJY_STATE_LOGIN , TELJJY_STATE_LOGIN , TELJJY_STATE_CONNECT, TELJJY_STATE_BYE }, +/* DISCONNECT */ { TELJJY_STATE_IDLE , TELJJY_STATE_IDLE , TELJJY_STATE_IDLE , TELJJY_STATE_IDLE , TELJJY_STATE_IDLE }, +/* COMMAND */ { TELJJY_STATE_IDLE , TELJJY_STATE_DAILOUT, TELJJY_STATE_LOGIN , TELJJY_STATE_CONNECT, TELJJY_STATE_BYE }, +/* LOGIN */ { TELJJY_STATE_IDLE , TELJJY_STATE_DAILOUT, TELJJY_STATE_LOGIN , TELJJY_STATE_BYE , TELJJY_STATE_BYE }, +/* PROMPT */ { TELJJY_STATE_IDLE , TELJJY_STATE_DAILOUT, TELJJY_STATE_CONNECT, TELJJY_STATE_BYE , TELJJY_STATE_BYE }, +/* DATA */ { TELJJY_STATE_IDLE , TELJJY_STATE_DAILOUT, TELJJY_STATE_LOGIN , TELJJY_STATE_CONNECT, TELJJY_STATE_BYE }, +/* ERROR */ { TELJJY_STATE_IDLE , TELJJY_STATE_DAILOUT, TELJJY_STATE_BYE , TELJJY_STATE_BYE , TELJJY_STATE_BYE }, +/* SILENT */ { TELJJY_STATE_IDLE , TELJJY_STATE_DAILOUT, TELJJY_STATE_LOGIN , TELJJY_STATE_CONNECT, TELJJY_STATE_BYE }, +/* TIMEOUT */ { TELJJY_STATE_IDLE , TELJJY_STATE_IDLE , TELJJY_STATE_BYE , TELJJY_STATE_BYE , TELJJY_STATE_BYE } +} ; + +static short iTeljjyPostEvent [ ] [ 5 ] = +{ /*STATE_IDLE STATE_DAILOUT STATE_LOGIN STATE_CONNECT STATE_BYE */ +/* NULL */ { TELJJY_EVENT_NULL, TELJJY_EVENT_NULL, TELJJY_EVENT_NULL , TELJJY_EVENT_NULL , TELJJY_EVENT_NULL }, +/* START */ { TELJJY_EVENT_NULL, TELJJY_EVENT_NULL, TELJJY_EVENT_NULL , TELJJY_EVENT_NULL , TELJJY_EVENT_NULL }, +/* CONNECT */ { TELJJY_EVENT_NULL, TELJJY_EVENT_NULL, TELJJY_EVENT_NULL , TELJJY_EVENT_NULL , TELJJY_EVENT_NULL }, +/* DISCONNECT */ { TELJJY_EVENT_NULL, TELJJY_EVENT_NULL, TELJJY_EVENT_NULL , TELJJY_EVENT_NULL , TELJJY_EVENT_NULL }, +/* COMMAND */ { TELJJY_EVENT_NULL, TELJJY_EVENT_NULL, TELJJY_EVENT_NULL , TELJJY_EVENT_NULL , TELJJY_EVENT_NULL }, +/* LOGIN */ { TELJJY_EVENT_NULL, TELJJY_EVENT_NULL, TELJJY_EVENT_NULL , TELJJY_EVENT_COMMAND, TELJJY_EVENT_NULL }, +/* PROMPT */ { TELJJY_EVENT_NULL, TELJJY_EVENT_NULL, TELJJY_EVENT_PROMPT , TELJJY_EVENT_COMMAND, TELJJY_EVENT_NULL }, +/* DATA */ { TELJJY_EVENT_NULL, TELJJY_EVENT_NULL, TELJJY_EVENT_NULL , TELJJY_EVENT_NULL , TELJJY_EVENT_NULL }, +/* ERROR */ { TELJJY_EVENT_NULL, TELJJY_EVENT_NULL, TELJJY_EVENT_COMMAND, TELJJY_EVENT_COMMAND, TELJJY_EVENT_NULL }, +/* SILENT */ { TELJJY_EVENT_NULL, TELJJY_EVENT_NULL, TELJJY_EVENT_NULL , TELJJY_EVENT_NULL , TELJJY_EVENT_NULL }, +/* TIMEOUT */ { TELJJY_EVENT_NULL, TELJJY_EVENT_NULL, TELJJY_EVENT_COMMAND, TELJJY_EVENT_COMMAND, TELJJY_EVENT_NULL } +} ; + +static short iTeljjySilentTimeout [ 5 ] = { 0, 0, 10, 5, 0 } ; +static short iTeljjyStateTimeout [ 5 ] = { 0, 120, 60, 60, 40 } ; + +#define TELJJY_STAY_CLOCK_STATE 0 +#define TELJJY_CHANGE_CLOCK_STATE 1 + +/* Command and replay */ + +#define TELJJY_REPLY_NONE 0 +#define TELJJY_REPLY_4DATE 1 +#define TELJJY_REPLY_TIME 2 +#define TELJJY_REPLY_LEAPSEC 3 +#define TELJJY_REPLY_LOOP 4 +#define TELJJY_REPLY_PROMPT 5 +#define TELJJY_REPLY_LOOPBACK 6 +#define TELJJY_REPLY_COM 7 + +#define TELJJY_COMMAND_START_SKIP_LOOPBACK 7 + +static struct +{ + const char *command ; + int commandLength ; + int iEchobackReplyLength ; + int iExpectedReplyType ; + int iExpectedReplyLength ; +} teljjy_command_sequence[] = +{ + { NULL, 0, 0, 0, 0 }, /* Idle */ + { "LOOP\r" , 5, 4, TELJJY_REPLY_LOOP , 0 }, /* Getting into loopback mode */ + { ">" , 1, 1, TELJJY_REPLY_LOOPBACK, 0 }, /* Loopback measuring of delay time */ + { ">" , 1, 1, TELJJY_REPLY_LOOPBACK, 0 }, /* Loopback measuring of delay time */ + { ">" , 1, 1, TELJJY_REPLY_LOOPBACK, 0 }, /* Loopback measuring of delay time */ + { ">" , 1, 1, TELJJY_REPLY_LOOPBACK, 0 }, /* Loopback measuring of delay time */ + { ">" , 1, 1, TELJJY_REPLY_LOOPBACK, 0 }, /* Loopback measuring of delay time */ + { "COM\r" , 4, 3, TELJJY_REPLY_COM , 0 }, /* Exit from loopback mode */ + /* TELJJY_COMMAND_START_SKIP_LOOPBACK */ + { "TIME\r" , 5, 4, TELJJY_REPLY_TIME , 6 }, + { "4DATE\r" , 6, 5, TELJJY_REPLY_4DATE , 8 }, + { "LEAPSEC\r", 8, 7, TELJJY_REPLY_LEAPSEC , 2 }, + { "TIME\r" , 5, 4, TELJJY_REPLY_TIME , 6 }, + { "BYE\r" , 4, 3, TELJJY_REPLY_NONE , 0 }, + /* End of command */ + { NULL, 0, 0, 0, 0 } +} ; + +#define TELJJY_LOOPBACK_DELAY_THRESHOLD 700 /* Milli second */ + +#ifdef DEBUG +#define DEBUG_TELJJY_PRINTF(sFunc) { if ( debug ) { printf ( "refclock_jjy.c : %s : iClockState=%d iClockEvent=%d iTeljjySilentTimer=%d iTeljjyStateTimer=%d iClockCommandSeq=%d\n", sFunc, up->iClockState, up->iClockEvent, up->iTeljjySilentTimer, up->iTeljjyStateTimer, up->iClockCommandSeq ) ; } } +#else +#define DEBUG_TELJJY_PRINTF(sFunc) #endif - struct jjyunit *up; - struct refclockproc *pp; +/**************************************************************************************************/ - const char *pCmd ; - int iCmdLen ; +static int +jjy_start_telephone ( int unit, struct peer *peer, struct jjyunit *up ) +{ - pp = peer->procptr; - up = pp->unitptr ; + char sLog [ 80 ], sFirstThreeDigits [ 4 ] ; + int i, iNumberOfDigitsOfPhoneNumber, iCommaCount, iCommaPosition ; + int iFirstThreeDigitsCount ; - if ( ( pp->sloppyclockflag & CLK_FLAG1 ) == 0 ) { - up->linecount = 2 ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, "Refclock: Telephone JJY" ) ; + + up->unittype = UNITTYPE_TELEPHONE ; + up->linespeed = SPEED232_TELEPHONE ; + up->linediscipline = LDISC_RAW ; + + up->pRawBreak = teljjy_raw_break ; + up->bWaitBreakString = TRUE ; + + up->bSkipCntrlCharOnly = TRUE ; + + up->iClockState = TELJJY_STATE_IDLE ; + up->iClockEvent = TELJJY_EVENT_NULL ; + + /* Check the telephone number */ + + if ( sys_phone[0] == NULL ) { + msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone in the ntpd.conf must be specified." ) ; + up->bInitError = TRUE ; + return 1 ; + } + + if ( sys_phone[1] != NULL ) { + msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone in the ntpd.conf should be only one." ) ; + up->bInitError = TRUE ; + return 1 ; + } + + iNumberOfDigitsOfPhoneNumber = iCommaCount = iCommaPosition = iFirstThreeDigitsCount = 0 ; + for ( i = 0 ; i < strlen( sys_phone[0] ) ; i ++ ) { + if ( isdigit( *(sys_phone[0]+i) ) ) { + if ( iFirstThreeDigitsCount < sizeof(sFirstThreeDigits)-1 ) { + sFirstThreeDigits[iFirstThreeDigitsCount++] = *(sys_phone[0]+i) ; + } + iNumberOfDigitsOfPhoneNumber ++ ; + } else if ( *(sys_phone[0]+i) == ',' ) { + iCommaCount ++ ; + if ( iCommaCount > 1 ) { + msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone in the ntpd.conf should be zero or one comma." ) ; + up->bInitError = TRUE ; + return 1 ; + } + iFirstThreeDigitsCount = 0 ; + iCommaPosition = i ; + } else if ( *(sys_phone[0]+i) != '-' ) { + msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone in the ntpd.conf should be a number or a hyphen." ) ; + up->bInitError = TRUE ; + return 1 ; + } + } + sFirstThreeDigits[iFirstThreeDigitsCount] = 0 ; + + if ( iCommaCount == 1 ) { + if ( iCommaPosition != 1 || *sys_phone[0] != '0' ) { + msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : Getting an outside line should be '0,'." ) ; + up->bInitError = TRUE ; + return 1 ; + } + } + + if ( iNumberOfDigitsOfPhoneNumber - iCommaPosition < 6 || 10 < iNumberOfDigitsOfPhoneNumber - iCommaPosition ) { + /* Too short or too long */ + msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone=%s : Number of digits should be 6 to 10.", sys_phone[0] ) ; + up->bInitError = TRUE ; + return 1 ; + } + + if ( strncmp( sFirstThreeDigits + iCommaPosition, "00" , 2 ) == 0 + || strncmp( sFirstThreeDigits + iCommaPosition, "10" , 2 ) == 0 + || strncmp( sFirstThreeDigits + iCommaPosition, "11" , 2 ) == 0 + || strncmp( sFirstThreeDigits + iCommaPosition, "12" , 2 ) == 0 + || strncmp( sFirstThreeDigits + iCommaPosition, "171", 3 ) == 0 + || strncmp( sFirstThreeDigits + iCommaPosition, "177", 3 ) == 0 + || ( sFirstThreeDigits[0] == '0' && sFirstThreeDigits[2] == '0' ) ) { + /* Not allowed because of emergency numbers or special service numbers */ + msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone=%s : First 2 or 3 digits are not allowed.", sys_phone[0] ) ; + up->bInitError = TRUE ; + return 1 ; } + snprintf( sLog, sizeof(sLog), "phone=%s", sys_phone[0] ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, sLog ) ; + + if ( peer->minpoll < 8 ) { + /* minpoll must be greater or equal to 8 ( 256 seconds = about 4 minutes ) */ + int oldminpoll = peer->minpoll ; + peer->minpoll = 8 ; + if ( peer->ppoll < peer->minpoll ) { + peer->ppoll = peer->minpoll ; + } + if ( peer->maxpoll < peer->minpoll ) { + peer->maxpoll = peer->minpoll ; + } + snprintf( sLog, sizeof(sLog), "minpoll=%d -> %d", oldminpoll, peer->minpoll ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, sLog ) ; + } + + return 0 ; + +} + +/**************************************************************************************************/ + +static int +jjy_receive_telephone ( struct recvbuf *rbufp ) +{ #ifdef DEBUG - if ( debug ) { - printf ( "%s (refclock_jjy.c) : flag1=%X CLK_FLAG1=%X up->linecount=%d\n", - sFunctionName, pp->sloppyclockflag, CLK_FLAG1, - up->linecount ) ; + static const char *sFunctionName = "jjy_receive_telephone" ; +#endif + + struct peer *peer; + struct refclockproc *pp ; + struct jjyunit *up ; + char *pBuf ; + int iLen ; + short iPreviousModemState ; + + peer = rbufp->recv_peer ; + pp = peer->procptr ; + up = pp->unitptr ; + + DEBUG_TELJJY_PRINTF( sFunctionName ) ; + + if ( up->iClockState == TELJJY_STATE_IDLE + || up->iClockState == TELJJY_STATE_DAILOUT + || up->iClockState == TELJJY_STATE_BYE ) { + + iPreviousModemState = getModemState( up ) ; + + modem_receive ( rbufp ) ; + + if ( iPreviousModemState != up->iModemState ) { + /* Modem state is changed just now. */ + if ( isModemStateDisconnect( up->iModemState ) ) { + up->iClockEvent = TELJJY_EVENT_DISCONNECT ; + teljjy_control ( peer, pp, up ) ; + } else if ( isModemStateConnect( up->iModemState ) ) { + up->iClockEvent = TELJJY_EVENT_CONNECT ; + teljjy_control ( peer, pp, up ) ; + } + } + + return JJY_RECEIVE_WAIT ; + } + + if ( up->linediscipline == LDISC_RAW ) { + pBuf = up->sTextBuf ; + iLen = up->iTextBufLen ; + } else { + pBuf = pp->a_lastcode ; + iLen = pp->lencode ; + } + + up->iTeljjySilentTimer = 0 ; + if ( iLen == 7 && strncmp( pBuf, "Name ? ", 7 ) == 0 ) { up->iClockEvent = TELJJY_EVENT_LOGIN ; } + else if ( iLen == 1 && strncmp( pBuf, ">" , 1 ) == 0 ) { up->iClockEvent = TELJJY_EVENT_PROMPT ; } + else if ( iLen >= 1 && strncmp( pBuf, "?" , 1 ) == 0 ) { up->iClockEvent = TELJJY_EVENT_ERROR ; } + else { up->iClockEvent = TELJJY_EVENT_DATA ; } + + teljjy_control ( peer, pp, up ) ; + + return JJY_RECEIVE_WAIT ; + +} + +/**************************************************************************************************/ + +static void +jjy_poll_telephone ( int unit, struct peer *peer ) +{ +#ifdef DEBUG + static const char *sFunctionName = "jjy_poll_telephone" ; #endif - /* - * Send a first command - */ + struct refclockproc *pp ; + struct jjyunit *up ; + pp = peer->procptr ; + up = pp->unitptr ; + + DEBUG_TELJJY_PRINTF( sFunctionName ) ; + + if ( up->iClockState == TELJJY_STATE_IDLE ) { + up->iRawBufLen = 0 ; + up->iLineBufLen = 0 ; + up->iTextBufLen = 0 ; + } + + up->iClockEvent = TELJJY_EVENT_START ; + teljjy_control ( peer, pp, up ) ; + +} + +/**************************************************************************************************/ + +static void +jjy_timer_telephone ( int unit, struct peer *peer ) +{ #ifdef DEBUG - if ( debug ) { - printf ( "%s (refclock_jjy.c) : send '%s'\n", - sFunctionName, - tristate_jjy01_command_sequence[up->linecount].commandLog ) ; + static const char *sFunctionName = "jjy_timer_telephone" ; +#endif + + struct refclockproc *pp ; + struct jjyunit *up ; + short iPreviousModemState ; + + pp = peer->procptr ; + up = pp->unitptr ; + + DEBUG_TELJJY_PRINTF( sFunctionName ) ; + + if ( iTeljjySilentTimeout[up->iClockState] != 0 ) { + up->iTeljjySilentTimer++ ; + if ( iTeljjySilentTimeout[up->iClockState] <= up->iTeljjySilentTimer ) { + up->iClockEvent = TELJJY_EVENT_SILENT ; + teljjy_control ( peer, pp, up ) ; + } + } + + if ( iTeljjyStateTimeout[up->iClockState] != 0 ) { + up->iTeljjyStateTimer++ ; + if ( iTeljjyStateTimeout[up->iClockState] <= up->iTeljjyStateTimer ) { + up->iClockEvent = TELJJY_EVENT_TIMEOUT ; + teljjy_control ( peer, pp, up ) ; + } } + + if ( isModemStateTimerOn( up ) ) { + + iPreviousModemState = getModemState( up ) ; + + modem_timer ( unit, peer ) ; + + if ( iPreviousModemState != up->iModemState ) { + /* Modem state is changed just now. */ + if ( isModemStateDisconnect( up->iModemState ) ) { + up->iClockEvent = TELJJY_EVENT_DISCONNECT ; + teljjy_control ( peer, pp, up ) ; + } else if ( isModemStateConnect( up->iModemState ) ) { + up->iClockEvent = TELJJY_EVENT_CONNECT ; + teljjy_control ( peer, pp, up ) ; + } + } + + } + +} + +/**************************************************************************************************/ + +static void +teljjy_control ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + int i, rc ; + short iPostEvent = TELJJY_EVENT_NULL ; + + DEBUG_TELJJY_PRINTF( "teljjy_control" ) ; + + rc = (*pTeljjyHandler[up->iClockEvent][up->iClockState])( peer, pp, up ) ; + + if ( rc == TELJJY_CHANGE_CLOCK_STATE ) { + iPostEvent = iTeljjyPostEvent[up->iClockEvent][up->iClockState] ; +#ifdef DEBUG + if ( debug ) { + printf( "refclock_jjy.c : teljjy_control : iClockState=%hd -> %hd iPostEvent=%hd\n", + up->iClockState, iTeljjyNextState[up->iClockEvent][up->iClockState], iPostEvent ) ; + } #endif + up->iTeljjySilentTimer = 0 ; + if ( up->iClockState != iTeljjyNextState[up->iClockEvent][up->iClockState] ) { + /* Telephone JJY state is changing now */ + up->iTeljjyStateTimer = 0 ; + up->bLineError = FALSE ; + up->iClockCommandSeq = 0 ; + up->iTimestampCount = 0 ; + up->iLoopbackCount = 0 ; + for ( i = 0 ; i < MAX_LOOPBACK ; i ++ ) { + up->bLoopbackTimeout[i] = FALSE ; + } + if (iTeljjyNextState[up->iClockEvent][up->iClockState] == TELJJY_STATE_IDLE ) { + /* Telephone JJY state is changing to IDLE just now */ + up->iProcessState = JJY_PROCESS_STATE_DONE ; + } + } + up->iClockState = iTeljjyNextState[up->iClockEvent][up->iClockState] ; - pCmd = tristate_jjy01_command_sequence[up->linecount].command ; - iCmdLen = tristate_jjy01_command_sequence[up->linecount].commandLength ; - if ( write ( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) { - refclock_report ( peer, CEVNT_FAULT ) ; } + if ( iPostEvent != TELJJY_EVENT_NULL ) { + up->iClockEvent = iPostEvent ; + teljjy_control ( peer, pp, up ) ; + } + + up->iClockEvent = TELJJY_EVENT_NULL ; + } /**************************************************************************************************/ static void -jjy_poll_cdex_jst2000 ( int unit, struct peer *peer ) +teljjy_setDelay ( struct peer *peer, struct jjyunit *up ) { - struct refclockproc *pp; + char sLog [ 60 ] ; + int milliSecond, microSecond ; - pp = peer->procptr; + gettimeofday( &(up->delayTime[up->iLoopbackCount]), NULL ) ; - /* - * Send "<ENQ>1J<ETX>" command - */ + up->delayTime[up->iLoopbackCount].tv_sec -= up->sendTime[up->iLoopbackCount].tv_sec ; + up->delayTime[up->iLoopbackCount].tv_usec -= up->sendTime[up->iLoopbackCount].tv_usec ; + if ( up->delayTime[up->iLoopbackCount].tv_usec < 0 ) { + up->delayTime[up->iLoopbackCount].tv_sec -- ; + up->delayTime[up->iLoopbackCount].tv_usec += 1000000 ; + } + + milliSecond = up->delayTime[up->iLoopbackCount].tv_usec / 1000 ; + microSecond = up->delayTime[up->iLoopbackCount].tv_usec - milliSecond * 1000 ; + milliSecond += up->delayTime[up->iLoopbackCount].tv_sec * 1000 ; + + snprintf( sLog, sizeof(sLog), JJY_CLOCKSTATS_MESSAGE_LOOPBACK_DELAY, + milliSecond, microSecond ) ; + + if ( milliSecond > TELJJY_LOOPBACK_DELAY_THRESHOLD ) { + /* Delay > 700 mS */ + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_WARNING, sLog ) ; + } else { + /* Delay <= 700 mS */ + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_INFORMATION, sLog ) ; + } + +} + +/**************************************************************************************************/ + +static int +teljjy_getDelay ( struct peer *peer, struct jjyunit *up ) +{ + + struct timeval maxTime, minTime, averTime ; + int i ; + int minIndex = 0, maxIndex = 0, iAverCount = 0 ; + int iThresholdSecond, iThresholdMicroSecond ; + int iPercent ; + + minTime.tv_sec = minTime.tv_usec = 0 ; + maxTime.tv_sec = maxTime.tv_usec = 0 ; + + iThresholdSecond = TELJJY_LOOPBACK_DELAY_THRESHOLD / 1000 ; + iThresholdMicroSecond = ( TELJJY_LOOPBACK_DELAY_THRESHOLD - ( TELJJY_LOOPBACK_DELAY_THRESHOLD / 1000 ) * 1000 ) * 1000 ; + up->iLoopbackValidCount = 0 ; + + for ( i = 0 ; i < MAX_LOOPBACK && i < up->iLoopbackCount ; i ++ ) { + if ( up->bLoopbackTimeout[i] + || up->delayTime[i].tv_sec > iThresholdSecond + || ( up->delayTime[i].tv_sec == iThresholdSecond + && up->delayTime[i].tv_usec > iThresholdMicroSecond ) ) { + continue ; + } + if ( up->iLoopbackValidCount == 0 ) { + minTime.tv_sec = up->delayTime[i].tv_sec ; + minTime.tv_usec = up->delayTime[i].tv_usec ; + maxTime.tv_sec = up->delayTime[i].tv_sec ; + maxTime.tv_usec = up->delayTime[i].tv_usec ; + minIndex = maxIndex = i ; + } else if ( minTime.tv_sec > up->delayTime[i].tv_sec + || ( minTime.tv_sec == up->delayTime[i].tv_sec + && minTime.tv_usec > up->delayTime[i].tv_usec ) ) { + minTime.tv_sec = up->delayTime[i].tv_sec ; + minTime.tv_usec = up->delayTime[i].tv_usec ; + minIndex = i ; + } else if ( maxTime.tv_sec < up->delayTime[i].tv_sec + || ( maxTime.tv_sec == up->delayTime[i].tv_sec + && maxTime.tv_usec < up->delayTime[i].tv_usec ) ) { + maxTime.tv_sec = up->delayTime[i].tv_sec ; + maxTime.tv_usec = up->delayTime[i].tv_usec ; + maxIndex = i ; + } + up->iLoopbackValidCount ++ ; + } + + if ( up->iLoopbackValidCount < 2 ) { + return -1 ; + } + + averTime.tv_usec = 0; + + for ( i = 0 ; i < MAX_LOOPBACK && i < up->iLoopbackCount ; i ++ ) { + if ( up->bLoopbackTimeout[i] + || up->delayTime[i].tv_sec > iThresholdSecond + || ( up->delayTime[i].tv_sec == iThresholdSecond + && up->delayTime[i].tv_usec > iThresholdMicroSecond ) ) { + continue ; + } + if ( up->iLoopbackValidCount >= 3 && i == maxIndex ) { + continue ; + } + if ( up->iLoopbackValidCount >= 4 && i == minIndex ) { + continue ; + } + averTime.tv_usec += up->delayTime[i].tv_usec ; + iAverCount ++ ; + } + + if ( iAverCount == 0 ) { + /* This is never happened. */ + /* Previous for-if-for blocks assure iAverCount > 0. */ + /* This code avoids a claim by the coverity scan tool. */ + return -1 ; + } + + /* mode 101 = 1%, mode 150 = 50%, mode 180 = 80% */ + + iPercent = ( peer->ttl - 100 ) ; + + /* Average delay time in milli second */ + + return ( ( averTime.tv_usec / iAverCount ) * iPercent ) / 100000 ; + +} + +/******************************/ +static int +teljjy_idle_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_idle_ignore" ) ; + + return TELJJY_STAY_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_idle_dialout ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_idle_dialout" ) ; + + modem_connect ( peer->refclkunit, peer ) ; + + return TELJJY_CHANGE_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_dial_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_dial_ignore" ) ; + + return TELJJY_STAY_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_dial_login ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_dial_login" ) ; + + return TELJJY_CHANGE_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_dial_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_dial_disc" ) ; + + return TELJJY_CHANGE_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_login_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_login_ignore" ) ; + + return TELJJY_STAY_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_login_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_login_disc" ) ; + + return TELJJY_CHANGE_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_login_conn ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + int i ; + + DEBUG_TELJJY_PRINTF( "teljjy_login_conn" ) ; + + up->bLineError = FALSE ; + up->iClockCommandSeq = 0 ; + up->iTimestampCount = 0 ; + up->iLoopbackCount = 0 ; + for ( i = 0 ; i < MAX_LOOPBACK ; i ++ ) { + up->bLoopbackTimeout[i] = FALSE ; + } + + return TELJJY_CHANGE_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_login_login ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + char *pCmd ; + int iCmdLen ; + + DEBUG_TELJJY_PRINTF( "teljjy_login_login" ) ; + + /* Send a guest user ID */ + pCmd = "TJJY\r" ; + + /* Send login ID */ + iCmdLen = strlen( pCmd ) ; + if ( write( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) { + refclock_report( peer, CEVNT_FAULT ) ; + } + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, pCmd ) ; + + return TELJJY_STAY_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_login_silent ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_login_silent" ) ; + + if ( write( pp->io.fd, "\r", 1 ) != 1 ) { + refclock_report( peer, CEVNT_FAULT ) ; + } + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, "\r" ) ; + + up->iTeljjySilentTimer = 0 ; + + return TELJJY_CHANGE_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_login_error ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_login_error" ) ; + + return TELJJY_CHANGE_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_conn_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_conn_ignore" ) ; + + return TELJJY_STAY_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_conn_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_conn_disc" ) ; + + return TELJJY_CHANGE_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_conn_send ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + const char *pCmd ; + int i, iLen, iNextClockState ; + + DEBUG_TELJJY_PRINTF( "teljjy_conn_send" ) ; + + if ( up->iClockCommandSeq > 0 + && teljjy_command_sequence[up->iClockCommandSeq].command == NULL ) { + /* Command sequence has been completed */ + return TELJJY_CHANGE_CLOCK_STATE ; + } + + if ( up->iClockCommandSeq == 0 && peer->ttl == 100 ) { + /* Skip loopback */ + + up->iClockCommandSeq = TELJJY_COMMAND_START_SKIP_LOOPBACK ; + + } else if ( up->iClockCommandSeq == 0 && peer->ttl != 100 ) { + /* Loopback start */ + + up->iLoopbackCount = 0 ; + for ( i = 0 ; i < MAX_LOOPBACK ; i ++ ) { + up->bLoopbackTimeout[i] = FALSE ; + } + + } else if ( up->iClockCommandSeq > 0 && peer->ttl != 100 + && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK + && up->iLoopbackCount < MAX_LOOPBACK ) { + /* Loopback character comes */ #ifdef DEBUG - if ( debug ) { - printf ( "jjy_poll_cdex_jst2000 (refclock_jjy.c) : send '<ENQ>1J<ETX>'\n" ) ; + if ( debug ) { + printf( "refclock_jjy.c : teljjy_conn_send : iLoopbackCount=%d\n", + up->iLoopbackCount ) ; + } +#endif + + teljjy_setDelay( peer, up ) ; + + up->iLoopbackCount ++ ; + } + + up->iClockCommandSeq++ ; + + pCmd = teljjy_command_sequence[up->iClockCommandSeq].command ; + iLen = teljjy_command_sequence[up->iClockCommandSeq].commandLength ; + + if ( pCmd != NULL ) { + + if ( write( pp->io.fd, pCmd, iLen ) != iLen ) { + refclock_report( peer, CEVNT_FAULT ) ; + } + + if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK ) { + /* Loopback character and timestamp */ + gettimeofday( &(up->sendTime[up->iLoopbackCount]), NULL ) ; + up->bLoopbackMode = TRUE ; + } else { + /* Regular command */ + up->bLoopbackMode = FALSE ; + } + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, pCmd ) ; + + if ( teljjy_command_sequence[up->iClockCommandSeq+1].command == NULL ) { + /* Last command of the command sequence */ + iNextClockState = TELJJY_CHANGE_CLOCK_STATE ; + } else { + /* More commands to be issued */ + iNextClockState = TELJJY_STAY_CLOCK_STATE ; + } + + } else { + + iNextClockState = TELJJY_CHANGE_CLOCK_STATE ; + + } + + return iNextClockState ; + +} + +/******************************/ +static int +teljjy_conn_data ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + char *pBuf ; + int iLen, rc ; + char sLog [ 80 ] ; + char bAdjustment ; + + + DEBUG_TELJJY_PRINTF( "teljjy_conn_data" ) ; + + if ( up->linediscipline == LDISC_RAW ) { + pBuf = up->sTextBuf ; + iLen = up->iTextBufLen ; + } else { + pBuf = pp->a_lastcode ; + iLen = pp->lencode ; + } + + if ( teljjy_command_sequence[up->iClockCommandSeq].iEchobackReplyLength == iLen + && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK + && up->sTextBuf[0] == *(teljjy_command_sequence[up->iClockCommandSeq].command) + && up->iLoopbackCount < MAX_LOOPBACK ) { + /* Loopback */ + + teljjy_setDelay( peer, up ) ; + + up->iLoopbackCount ++ ; + + } else if ( teljjy_command_sequence[up->iClockCommandSeq].iEchobackReplyLength == iLen + && strncmp( pBuf, teljjy_command_sequence[up->iClockCommandSeq].command, iLen ) == 0 ) { + /* Maybe echoback */ + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_INFORMATION, JJY_CLOCKSTATS_MESSAGE_ECHOBACK ) ; + + } else if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyLength == iLen + && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_4DATE ) { + /* 4DATE<CR> -> YYYYMMDD<CR> */ + + rc = sscanf ( pBuf, "%4d%2d%2d", &up->year, &up->month, &up->day ) ; + + if ( rc != 3 || up->year < 2000 || 2099 <= up->year + || up->month < 1 || 12 < up->month || up->day < 1 || 31 < up->day ) { + /* Invalid date */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATE, + rc, up->year, up->month, up->day ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + } + + } else if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyLength == iLen + && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LEAPSEC + && ( strncmp( pBuf, " 0", 2 ) == 0 || strncmp( pBuf, "+1", 2 ) == 0 || strncmp( pBuf, "-1", 2 ) == 0 ) ) { + /* LEAPSEC<CR> -> XX<CR> ( One of <SP>0, +1, -1 ) */ + + rc = sscanf ( pBuf, "%2d", &up->leapsecond ) ; + + if ( rc != 1 || up->leapsecond < -1 || 1 < up->leapsecond ) { + /* Invalid leap second */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_LEAP, + pBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + } + + } else if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyLength == iLen + && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_TIME ) { + /* TIME<CR> -> HHMMSS<CR> ( 3 times on second ) */ + + rc = sscanf ( pBuf, "%2d%2d%2d", &up->hour, &up->minute, &up->second ) ; + + if ( rc != 3 || up->hour > 23 || up->minute > 59 || up->second > 60 ) { + /* Invalid time */ + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_TIME, + rc, up->hour, up->minute, up->second ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + up->bLineError = TRUE ; + } + up->iTimestamp[up->iTimestampCount] = ( up->hour * 60 + up->minute ) * 60 + up->second ; + + up->iTimestampCount++ ; + + if ( up->iTimestampCount == 6 && ! up->bLineError ) { +#if DEBUG + printf( "refclock_jjy.c : teljjy_conn_data : bLineError=%d iTimestamp=%d, %d, %d\n", + up->bLineError, + up->iTimestamp[3], up->iTimestamp[4], up->iTimestamp[5] ) ; #endif + bAdjustment = TRUE ; + + if ( peer->ttl == 100 ) { + /* mode=100 */ + up->msecond = 0 ; + } else { + /* mode=101 to 110 */ + up->msecond = teljjy_getDelay( peer, up ) ; + if (up->msecond < 0 ) { + up->msecond = 0 ; + bAdjustment = FALSE ; + } + } - if ( write ( pp->io.fd, "\0051J\003", 4 ) != 4 ) { - refclock_report ( peer, CEVNT_FAULT ) ; + if ( ( up->iTimestamp[3] - 15 ) <= up->iTimestamp[2] + && up->iTimestamp[2] <= up->iTimestamp[3] + && ( up->iTimestamp[3] + 1 ) == up->iTimestamp[4] + && ( up->iTimestamp[4] + 1 ) == up->iTimestamp[5] ) { + /* Non over midnight */ + + jjy_synctime( peer, pp, up ) ; + + if ( peer->ttl != 100 ) { + if ( bAdjustment ) { + snprintf( sLog, sizeof(sLog), + JJY_CLOCKSTATS_MESSAGE_DELAY_ADJUST, + up->msecond, up->iLoopbackValidCount, MAX_LOOPBACK ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_INFORMATION, sLog ) ; + } else { + snprintf( sLog, sizeof(sLog), + JJY_CLOCKSTATS_MESSAGE_DELAY_UNADJUST, + up->iLoopbackValidCount, MAX_LOOPBACK ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + } + } + + } + } + + } else if ( teljjy_command_sequence[up->iClockCommandSeq].iEchobackReplyLength != iLen + && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK ) { + /* Loopback noise ( Unexpected replay ) */ + + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_IGNORE_REPLY, + pBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_WARNING, sLog ) ; + + } else { + + up->bLineError = TRUE ; + + snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_UNEXPECTED_REPLY, + pBuf ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ; + + } + + return TELJJY_STAY_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_conn_silent ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + const char *pCmd ; + + DEBUG_TELJJY_PRINTF( "teljjy_conn_silent" ) ; + + if ( up->iClockCommandSeq >= 1 + && up->iClockCommandSeq < TELJJY_COMMAND_START_SKIP_LOOPBACK ) { + /* Loopback */ +#ifdef DEBUG + if ( debug ) { + printf( "refclock_jjy.c : teljjy_conn_silent : call teljjy_conn_send\n" ) ; + } +#endif + if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK ) { + up->bLoopbackTimeout[up->iLoopbackCount] = TRUE ; + } + up->iTeljjySilentTimer = 0 ; + return teljjy_conn_send( peer, pp, up ) ; + } else { + pCmd = "\r" ; + } + + if ( write( pp->io.fd, pCmd, 1 ) != 1 ) { + refclock_report( peer, CEVNT_FAULT ) ; } + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, pCmd ) ; + + up->iTeljjySilentTimer = 0 ; + + return TELJJY_STAY_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_conn_error ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_conn_error" ) ; + + return TELJJY_CHANGE_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_bye_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_bye_ignore" ) ; + + return TELJJY_STAY_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_bye_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_bye_disc" ) ; + + return TELJJY_CHANGE_CLOCK_STATE ; + +} + +/******************************/ +static int +teljjy_bye_modem ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_TELJJY_PRINTF( "teljjy_bye_modem" ) ; + + modem_disconnect ( peer->refclkunit, peer ) ; + + return TELJJY_STAY_CLOCK_STATE ; + +} + +/*################################################################################################*/ +/*################################################################################################*/ +/*## ##*/ +/*## Modem control finite state machine ##*/ +/*## ##*/ +/*################################################################################################*/ +/*################################################################################################*/ + +/* struct jjyunit.iModemState */ + +#define MODEM_STATE_DISCONNECT 0 +#define MODEM_STATE_INITIALIZE 1 +#define MODEM_STATE_DAILING 2 +#define MODEM_STATE_CONNECT 3 +#define MODEM_STATE_ESCAPE 4 + +/* struct jjyunit.iModemEvent */ + +#define MODEM_EVENT_NULL 0 +#define MODEM_EVENT_INITIALIZE 1 +#define MODEM_EVENT_DIALOUT 2 +#define MODEM_EVENT_DISCONNECT 3 +#define MODEM_EVENT_RESP_OK 4 +#define MODEM_EVENT_RESP_CONNECT 5 +#define MODEM_EVENT_RESP_RING 6 +#define MODEM_EVENT_RESP_NO_CARRIER 7 +#define MODEM_EVENT_RESP_ERROR 8 +#define MODEM_EVENT_RESP_CONNECT_X 9 +#define MODEM_EVENT_RESP_NO_DAILTONE 10 +#define MODEM_EVENT_RESP_BUSY 11 +#define MODEM_EVENT_RESP_NO_ANSWER 12 +#define MODEM_EVENT_RESP_UNKNOWN 13 +#define MODEM_EVENT_SILENT 14 +#define MODEM_EVENT_TIMEOUT 15 + +/* Function prototypes */ + +static void modem_control ( struct peer *, struct refclockproc *, struct jjyunit * ) ; + +static int modem_disc_ignore ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_disc_init ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_init_ignore ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_init_start ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_init_disc ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_init_resp00 ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_init_resp04 ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_dial_ignore ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_dial_dialout ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_dial_escape ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_dial_connect ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_dial_disc ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_conn_ignore ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_conn_escape ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_esc_ignore ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_esc_escape ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_esc_data ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_esc_silent ( struct peer *, struct refclockproc *, struct jjyunit * ) ; +static int modem_esc_disc ( struct peer *, struct refclockproc *, struct jjyunit * ) ; + +static int ( *pModemHandler [ ] [ 5 ] ) ( ) = +{ /*STATE_DISCONNECT STATE_INITIALIZE STATE_DAILING STATE_CONNECT STATE_ESCAPE */ +/* NULL */ { modem_disc_ignore, modem_init_ignore, modem_dial_ignore , modem_conn_ignore, modem_esc_ignore }, +/* INITIALIZE */ { modem_disc_init , modem_init_start , modem_dial_ignore , modem_conn_ignore, modem_esc_ignore }, +/* DIALOUT */ { modem_disc_ignore, modem_init_ignore, modem_dial_dialout, modem_conn_ignore, modem_esc_ignore }, +/* DISCONNECT */ { modem_disc_ignore, modem_init_disc , modem_dial_escape , modem_conn_escape, modem_esc_escape }, +/* RESP: 0: OK */ { modem_disc_ignore, modem_init_resp00, modem_dial_ignore , modem_conn_ignore, modem_esc_data }, +/* RESP: 1: CONNECT */ { modem_disc_ignore, modem_init_ignore, modem_dial_connect, modem_conn_ignore, modem_esc_data }, +/* RESP: 2: RING */ { modem_disc_ignore, modem_init_ignore, modem_dial_ignore , modem_conn_ignore, modem_esc_data }, +/* RESP: 3: NO CARRIER */ { modem_disc_ignore, modem_init_ignore, modem_dial_disc , modem_conn_ignore, modem_esc_data }, +/* RESP: 4: ERROR */ { modem_disc_ignore, modem_init_resp04, modem_dial_disc , modem_conn_ignore, modem_esc_data }, +/* RESP: 5: CONNECT */ { modem_disc_ignore, modem_init_ignore, modem_dial_connect, modem_conn_ignore, modem_esc_data }, +/* RESP: 6: NO DAILTONE */ { modem_disc_ignore, modem_init_ignore, modem_dial_disc , modem_conn_ignore, modem_esc_data }, +/* RESP: 7: BUSY */ { modem_disc_ignore, modem_init_ignore, modem_dial_disc , modem_conn_ignore, modem_esc_data }, +/* RESP: 8: NO ANSWER */ { modem_disc_ignore, modem_init_ignore, modem_dial_disc , modem_conn_ignore, modem_esc_data }, +/* RESP: 9: UNKNOWN */ { modem_disc_ignore, modem_init_ignore, modem_dial_ignore , modem_conn_ignore, modem_esc_data }, +/* SILENT */ { modem_disc_ignore, modem_init_ignore, modem_dial_ignore , modem_conn_ignore, modem_esc_silent }, +/* TIMEOUT */ { modem_disc_ignore, modem_init_disc , modem_dial_escape , modem_conn_escape, modem_esc_disc } +} ; + +static short iModemNextState [ ] [ 5 ] = +{ /*STATE_DISCONNECT STATE_INITIALIZE STATE_DAILING STATE_CONNECT STATE_ESCAPE */ +/* NULL */ { MODEM_STATE_DISCONNECT, MODEM_STATE_INITIALIZE, MODEM_STATE_DAILING , MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* INITIALIZE */ { MODEM_STATE_INITIALIZE, MODEM_STATE_INITIALIZE, MODEM_STATE_DAILING , MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* DIALOUT */ { MODEM_STATE_DISCONNECT, MODEM_STATE_INITIALIZE, MODEM_STATE_DAILING , MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* DISCONNECT */ { MODEM_STATE_DISCONNECT, MODEM_STATE_DISCONNECT, MODEM_STATE_ESCAPE , MODEM_STATE_ESCAPE , MODEM_STATE_ESCAPE }, +/* RESP: 0: OK */ { MODEM_STATE_DISCONNECT, MODEM_STATE_DAILING , MODEM_STATE_DAILING , MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* RESP: 1: CONNECT */ { MODEM_STATE_DISCONNECT, MODEM_STATE_INITIALIZE, MODEM_STATE_CONNECT , MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* RESP: 2: RING */ { MODEM_STATE_DISCONNECT, MODEM_STATE_INITIALIZE, MODEM_STATE_DAILING , MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* RESP: 3: NO CARRIER */ { MODEM_STATE_DISCONNECT, MODEM_STATE_INITIALIZE, MODEM_STATE_DISCONNECT, MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* RESP: 4: ERROR */ { MODEM_STATE_DISCONNECT, MODEM_STATE_DAILING , MODEM_STATE_DISCONNECT, MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* RESP: 5: CONNECT X */ { MODEM_STATE_DISCONNECT, MODEM_STATE_INITIALIZE, MODEM_STATE_CONNECT , MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* RESP: 6: NO DAILTONE */ { MODEM_STATE_DISCONNECT, MODEM_STATE_INITIALIZE, MODEM_STATE_DISCONNECT, MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* RESP: 7: BUSY */ { MODEM_STATE_DISCONNECT, MODEM_STATE_INITIALIZE, MODEM_STATE_DISCONNECT, MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* RESP: 8: NO ANSWER */ { MODEM_STATE_DISCONNECT, MODEM_STATE_INITIALIZE, MODEM_STATE_DISCONNECT, MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* RESP: 9: UNKNOWN */ { MODEM_STATE_DISCONNECT, MODEM_STATE_INITIALIZE, MODEM_STATE_DAILING , MODEM_STATE_CONNECT, MODEM_STATE_ESCAPE }, +/* SILENT */ { MODEM_STATE_DISCONNECT, MODEM_STATE_INITIALIZE, MODEM_STATE_DAILING , MODEM_STATE_CONNECT, MODEM_STATE_DISCONNECT }, +/* TIMEOUT */ { MODEM_STATE_DISCONNECT, MODEM_STATE_DISCONNECT, MODEM_STATE_ESCAPE , MODEM_STATE_ESCAPE , MODEM_STATE_DISCONNECT } +} ; + +static short iModemPostEvent [ ] [ 5 ] = +{ /*STATE_DISCONNECT STATE_INITIALIZE STATE_DAILING STATE_CONNECT STATE_ESCAPE */ +/* NULL */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* INITIALIZE */ { MODEM_EVENT_INITIALIZE, MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* DIALOUT */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* DISCONNECT */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_DISCONNECT, MODEM_EVENT_DISCONNECT, MODEM_EVENT_NULL }, +/* RESP: 0: OK */ { MODEM_EVENT_NULL , MODEM_EVENT_DIALOUT, MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* RESP: 1: CONNECT */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* RESP: 2: RING */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* RESP: 3: NO CARRIER */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* RESP: 4: ERROR */ { MODEM_EVENT_NULL , MODEM_EVENT_DIALOUT, MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* RESP: 5: CONNECT X */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* RESP: 6: NO DAILTONE */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* RESP: 7: BUSY */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* RESP: 8: NO ANSWER */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* RESP: 9: UNKNOWN */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* SILENT */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_NULL }, +/* TIMEOUT */ { MODEM_EVENT_NULL , MODEM_EVENT_NULL , MODEM_EVENT_DISCONNECT, MODEM_EVENT_DISCONNECT, MODEM_EVENT_NULL } +} ; + +static short iModemSilentTimeout [ 5 ] = { 0, 0, 0, 0, 5 } ; +static short iModemStateTimeout [ 5 ] = { 0, 20, 90, 0, 20 } ; + +#define STAY_MODEM_STATE 0 +#define CHANGE_MODEM_STATE 1 + +#ifdef DEBUG +#define DEBUG_MODEM_PRINTF(sFunc) { if ( debug ) { printf ( "refclock_jjy.c : %s : iModemState=%d iModemEvent=%d iModemSilentTimer=%d iModemStateTimer=%d\n", sFunc, up->iModemState, up->iModemEvent, up->iModemSilentTimer, up->iModemStateTimer ) ; } } +#else +#define DEBUG_MODEM_PRINTF(sFunc) +#endif + +/**************************************************************************************************/ + +static short +getModemState ( struct jjyunit *up ) +{ + return up->iModemState ; +} + +/**************************************************************************************************/ + +static int +isModemStateConnect ( short iCheckState ) +{ + return ( iCheckState == MODEM_STATE_CONNECT ) ; +} + +/**************************************************************************************************/ + +static int +isModemStateDisconnect ( short iCheckState ) +{ + return ( iCheckState == MODEM_STATE_DISCONNECT ) ; +} + +/**************************************************************************************************/ + +static int +isModemStateTimerOn ( struct jjyunit *up ) +{ + return ( iModemSilentTimeout[up->iModemState] != 0 || iModemStateTimeout[up->iModemState] != 0 ) ; } /**************************************************************************************************/ static void -jjy_poll_echokeisokuki_lt2000 ( int unit, struct peer *peer ) +modem_connect ( int unit, struct peer *peer ) { + struct refclockproc *pp; + struct jjyunit *up; - struct jjyunit *up; - struct refclockproc *pp; + pp = peer->procptr ; + up = pp->unitptr ; - char sCmd[2] ; + DEBUG_MODEM_PRINTF( "modem_connect" ) ; - pp = peer->procptr; + up->iModemEvent = MODEM_EVENT_INITIALIZE ; + + modem_control ( peer, pp, up ) ; + +} + +/**************************************************************************************************/ + +static void +modem_disconnect ( int unit, struct peer *peer ) +{ + struct refclockproc *pp; + struct jjyunit *up; + + pp = peer->procptr ; up = pp->unitptr ; - /* - * Send "T" or "C" command - */ + DEBUG_MODEM_PRINTF( "modem_disconnect" ) ; - switch ( up->operationmode ) { - case 1 : sCmd[0] = 'T' ; break ; - case 2 : sCmd[0] = 'C' ; break ; + up->iModemEvent = MODEM_EVENT_DISCONNECT ; + + modem_control ( peer, pp, up ) ; + +} + +/**************************************************************************************************/ + +static int +modem_receive ( struct recvbuf *rbufp ) +{ + + struct peer *peer; + struct jjyunit *up; + struct refclockproc *pp; + char *pBuf ; + int iLen ; + +#ifdef DEBUG + static const char *sFunctionName = "modem_receive" ; +#endif + + peer = rbufp->recv_peer ; + pp = peer->procptr ; + up = pp->unitptr ; + + DEBUG_MODEM_PRINTF( sFunctionName ) ; + + if ( up->linediscipline == LDISC_RAW ) { + pBuf = up->sTextBuf ; + iLen = up->iTextBufLen ; + } else { + pBuf = pp->a_lastcode ; + iLen = pp->lencode ; } - sCmd[1] = 0 ; + + if ( iLen == 2 && strncmp( pBuf, "OK" , 2 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_OK ; } + else if ( iLen == 7 && strncmp( pBuf, "CONNECT" , 7 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_CONNECT ; } + else if ( iLen == 4 && strncmp( pBuf, "RING" , 4 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_RING ; } + else if ( iLen == 10 && strncmp( pBuf, "NO CARRIER" , 10 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_NO_CARRIER ; } + else if ( iLen == 5 && strncmp( pBuf, "ERROR" , 5 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_ERROR ; } + else if ( iLen >= 8 && strncmp( pBuf, "CONNECT " , 8 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_CONNECT_X ; } + else if ( iLen == 11 && strncmp( pBuf, "NO DAILTONE", 11 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_NO_DAILTONE ; } + else if ( iLen == 4 && strncmp( pBuf, "BUSY" , 4 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_BUSY ; } + else if ( iLen == 9 && strncmp( pBuf, "NO ANSWER" , 9 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_NO_ANSWER ; } + else { up->iModemEvent = MODEM_EVENT_RESP_UNKNOWN ; } #ifdef DEBUG if ( debug ) { - printf ( "jjy_poll_echokeisokuki_lt2000 (refclock_jjy.c) : send '%s'\n", sCmd ) ; + char sResp [ 40 ] ; + int iCopyLen ; + iCopyLen = ( iLen <= sizeof(sResp)-1 ? iLen : sizeof(sResp)-1 ) ; + strncpy( sResp, pBuf, iLen <= sizeof(sResp)-1 ? iLen : sizeof(sResp)-1 ) ; + sResp[iCopyLen] = 0 ; + printf ( "refclock_jjy.c : modem_receive : iLen=%d pBuf=[%s] iModemEvent=%d\n", iCopyLen, sResp, up->iModemEvent ) ; } #endif + modem_control ( peer, pp, up ) ; - if ( write ( pp->io.fd, sCmd, 1 ) != 1 ) { - refclock_report ( peer, CEVNT_FAULT ) ; - } + return 0 ; } /**************************************************************************************************/ static void -jjy_poll_citizentic_jjy200 ( int unit, struct peer *peer ) +modem_timer ( int unit, struct peer *peer ) { - /* Do nothing ( up->bPollFlag is set by the jjy_poll ) */ + struct refclockproc *pp ; + struct jjyunit *up ; + + pp = peer->procptr ; + up = pp->unitptr ; + + DEBUG_MODEM_PRINTF( "modem_timer" ) ; + + if ( iModemSilentTimeout[up->iModemState] != 0 ) { + up->iModemSilentTimer++ ; + if ( iModemSilentTimeout[up->iModemState] <= up->iModemSilentTimer ) { + up->iModemEvent = MODEM_EVENT_SILENT ; + modem_control ( peer, pp, up ) ; + } + } + + if ( iModemStateTimeout[up->iModemState] != 0 ) { + up->iModemStateTimer++ ; + if ( iModemStateTimeout[up->iModemState] <= up->iModemStateTimer ) { + up->iModemEvent = MODEM_EVENT_TIMEOUT ; + modem_control ( peer, pp, up ) ; + } + } } /**************************************************************************************************/ static void -jjy_poll_tristate_gpsclock01 ( int unit, struct peer *peer ) +modem_control ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) { + + int rc ; + short iPostEvent = MODEM_EVENT_NULL ; + + DEBUG_MODEM_PRINTF( "modem_control" ) ; + + rc = (*pModemHandler[up->iModemEvent][up->iModemState])( peer, pp, up ) ; + + if ( rc == CHANGE_MODEM_STATE ) { + iPostEvent = iModemPostEvent[up->iModemEvent][up->iModemState] ; #ifdef DEBUG - static const char *sFunctionName = "jjy_poll_tristate_gpsclock01" ; + if ( debug ) { + printf( "refclock_jjy.c : modem_control : iModemState=%d -> %d iPostEvent=%d\n", + up->iModemState, iModemNextState[up->iModemEvent][up->iModemState], iPostEvent ) ; + } #endif - struct jjyunit *up; - struct refclockproc *pp; + if ( up->iModemState != iModemNextState[up->iModemEvent][up->iModemState] ) { + up->iModemSilentCount = 0 ; + up->iModemStateTimer = 0 ; + up->iModemCommandSeq = 0 ; + } - const char *pCmd ; - int iCmdLen ; + up->iModemState = iModemNextState[up->iModemEvent][up->iModemState] ; + } - pp = peer->procptr; - up = pp->unitptr ; + if ( iPostEvent != MODEM_EVENT_NULL ) { + up->iModemEvent = iPostEvent ; + modem_control ( peer, pp, up ) ; + } + up->iModemEvent = MODEM_EVENT_NULL ; + +} + +/******************************/ +static int +modem_disc_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_disc_ignore" ) ; + + return STAY_MODEM_STATE ; + +} + +/******************************/ +static int +modem_disc_init ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_disc_init" ) ; + + return CHANGE_MODEM_STATE ; + +} + +/******************************/ +static int +modem_init_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_init_ignore" ) ; + + return STAY_MODEM_STATE ; + +} + +/******************************/ +static int +modem_init_start ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_init_start" ) ; + + up->iModemCommandSeq = 0 ; + +#ifdef DEBUG + if ( debug ) { + printf( "refclock_jjy.c : modem_init_start : call modem_init_resp00\n" ) ; + } +#endif + + return modem_init_resp00( peer, pp, up ) ; + +} + +/******************************/ +static int +modem_init_resp00 ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + char *pCmd, cBuf [ 46 ] ; + int iCmdLen ; + int iErrorCorrection, iSpeakerSwitch, iSpeakerVolume ; + int iNextModemState = STAY_MODEM_STATE ; + + DEBUG_MODEM_PRINTF( "modem_init_resp00" ) ; + + up->iModemCommandSeq++ ; + + switch ( up->iModemCommandSeq ) { + + case 1 : + /* En = Echoback 0:Off 1:On */ + /* Qn = Result codes 0:On 1:Off */ + /* Vn = Result codes 0:Numeric 1:Text */ + pCmd = "ATE0Q0V1\r\n" ; + break ; + + case 2 : + /* Mn = Speaker switch 0:Off 1:On until remote carrier detected 2:On */ + if ( ( pp->sloppyclockflag & CLK_FLAG3 ) == 0 ) { + /* fudge 127.127.40.n flag3 0 */ + iSpeakerSwitch = 0 ; + } else { + /* fudge 127.127.40.n flag3 1 */ + iSpeakerSwitch = 2 ; + } + + /* Ln = Speaker volume 0:Very low 1:Low 2:Middle 3:High */ + if ( ( pp->sloppyclockflag & CLK_FLAG4 ) == 0 ) { + /* fudge 127.127.40.n flag4 0 */ + iSpeakerVolume = 1 ; + } else { + /* fudge 127.127.40.n flag4 1 */ + iSpeakerVolume = 2 ; + } + + pCmd = cBuf ; + snprintf( pCmd, sizeof(cBuf), "ATM%dL%d\r\n", iSpeakerSwitch, iSpeakerVolume ) ; + break ; + + case 3 : + /* &Kn = Flow control 4:XON/XOFF */ + pCmd = "AT&K4\r\n" ; + break ; + + case 4 : + /* +MS = Protocol V22B:1200,2400bpsiV.22bis) */ + pCmd = "AT+MS=V22B\r\n" ; + break ; + + case 5 : + /* %Cn = Data compression 0:No data compression */ + pCmd = "AT%C0\r\n" ; + break ; + + case 6 : + /* \Nn = Error correction 0:Normal mode 1:Direct mode 2:V42,MNP 3:V42,MNP,Normal */ + if ( ( pp->sloppyclockflag & CLK_FLAG2 ) == 0 ) { + /* fudge 127.127.40.n flag2 0 */ + iErrorCorrection = 0 ; + } else { + /* fudge 127.127.40.n flag2 1 */ + iErrorCorrection = 3 ; + } + + pCmd = cBuf ; + snprintf( pCmd, sizeof(cBuf), "AT\\N%d\r\n", iErrorCorrection ) ; + break ; + + case 7 : + /* Hn = Hook 0:Hook-On ( Disconnect ) 1:Hook-Off ( Connect ) */ + pCmd = "ATH1\r\n" ; + break ; + + case 8 : + /* Initialize completion */ + pCmd = NULL ; + iNextModemState = CHANGE_MODEM_STATE ; + break ; + + default : + pCmd = NULL ; + break ; + + } + + if ( pCmd != NULL ) { + + iCmdLen = strlen( pCmd ) ; + if ( write( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) { + refclock_report( peer, CEVNT_FAULT ) ; + } + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, pCmd ) ; + + } + + return iNextModemState ; + +} + +/******************************/ +static int +modem_init_resp04 ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_init_resp04" ) ; + + return modem_init_resp00( peer, pp, up ) ; + +} + +/******************************/ +static int +modem_init_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_init_disc" ) ; +#ifdef DEBUG + if ( debug ) { + printf( "refclock_jjy.c : modem_init_disc : call modem_esc_disc\n" ) ; + } +#endif + + return CHANGE_MODEM_STATE ; + +} + +/******************************/ +static int +modem_dial_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_dial_ignore" ) ; + + return STAY_MODEM_STATE ; + +} + +/******************************/ +static int +modem_dial_dialout ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + char sCmd [ 46 ] ; + int iCmdLen ; + char cToneOrPulse ; + + DEBUG_MODEM_PRINTF( "modem_dial_dialout" ) ; + + /* Tone or Pulse */ if ( ( pp->sloppyclockflag & CLK_FLAG1 ) == 0 ) { - up->linecount = 1 ; + /* fudge 127.127.40.n flag1 0 */ + cToneOrPulse = 'T' ; + } else { + /* fudge 127.127.40.n flag1 1 */ + cToneOrPulse = 'P' ; } + /* Connect ( Dial number ) */ + snprintf( sCmd, sizeof(sCmd), "ATDW%c%s\r\n", cToneOrPulse, *sys_phone ) ; + + /* Send command */ + iCmdLen = strlen( sCmd ) ; + if ( write( pp->io.fd, sCmd, iCmdLen ) != iCmdLen ) { + refclock_report( peer, CEVNT_FAULT ) ; + } + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, sCmd ) ; + + return STAY_MODEM_STATE ; + +} + +/******************************/ +static int +modem_dial_escape ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_dial_escape" ) ; #ifdef DEBUG if ( debug ) { - printf ( "%s (refclock_jjy.c) : flag1=%X CLK_FLAG1=%X up->linecount=%d\n", - sFunctionName, pp->sloppyclockflag, CLK_FLAG1, - up->linecount ) ; + printf( "refclock_jjy.c : modem_dial_escape : call modem_conn_escape\n" ) ; } #endif - /* - * Send a first command - */ + return modem_conn_escape( peer, pp, up ) ; + +} + +/******************************/ +static int +modem_dial_connect ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_dial_connect" ) ; + return CHANGE_MODEM_STATE ; + +} + +/******************************/ +static int +modem_dial_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_dial_disc" ) ; #ifdef DEBUG if ( debug ) { - printf ( "%s (refclock_jjy.c) : send '%s'\n", - sFunctionName, - tristate_gpsclock01_command_sequence[up->linecount].commandLog ) ; + printf( "refclock_jjy.c : modem_dial_disc : call modem_esc_disc\n" ) ; } #endif - pCmd = tristate_gpsclock01_command_sequence[up->linecount].command ; - iCmdLen = tristate_gpsclock01_command_sequence[up->linecount].commandLength ; - if ( write ( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) { - refclock_report ( peer, CEVNT_FAULT ) ; + modem_esc_disc( peer, pp, up ) ; + + return CHANGE_MODEM_STATE ; + +} + +/******************************/ +static int +modem_conn_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_conn_ignore" ) ; + + return STAY_MODEM_STATE ; + +} + +/******************************/ +static int +modem_conn_escape ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_conn_escape" ) ; + + return CHANGE_MODEM_STATE ; + +} + +/******************************/ +static int +modem_esc_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_esc_ignore" ) ; + + return STAY_MODEM_STATE ; + +} + +/******************************/ +static int +modem_esc_escape ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + char *pCmd ; + int iCmdLen ; + + DEBUG_MODEM_PRINTF( "modem_esc_escape" ) ; + + /* Escape command ( Go to command mode ) */ + pCmd = "+++" ; + + /* Send command */ + iCmdLen = strlen( pCmd ) ; + if ( write( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) { + refclock_report( peer, CEVNT_FAULT ) ; } + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, pCmd ) ; + + return STAY_MODEM_STATE ; + } -/**************************************************************************************************/ +/******************************/ +static int +modem_esc_data ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_esc_data" ) ; + + up->iModemSilentTimer = 0 ; + + return STAY_MODEM_STATE ; + +} + +/******************************/ +static int +modem_esc_silent ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + DEBUG_MODEM_PRINTF( "modem_esc_silent" ) ; + + up->iModemSilentCount ++ ; + + if ( up->iModemSilentCount < iModemStateTimeout[up->iModemState] / iModemSilentTimeout[up->iModemState] ) { +#ifdef DEBUG + if ( debug ) { + printf( "refclock_jjy.c : modem_esc_silent : call modem_esc_escape\n" ) ; + } +#endif + modem_esc_escape( peer, pp, up ) ; + up->iModemSilentTimer = 0 ; + return STAY_MODEM_STATE ; + } + +#ifdef DEBUG + if ( debug ) { + printf( "refclock_jjy.c : modem_esc_silent : call modem_esc_disc\n" ) ; + } +#endif + return modem_esc_disc( peer, pp, up ) ; + +} +/******************************/ +static int +modem_esc_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) +{ + + char *pCmd ; + int iCmdLen ; + + DEBUG_MODEM_PRINTF( "modem_esc_disc" ) ; + + /* Disconnect */ + pCmd = "ATH0\r\n" ; + + /* Send command */ + iCmdLen = strlen( pCmd ) ; + if ( write( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) { + refclock_report( peer, CEVNT_FAULT ) ; + } + + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, pCmd ) ; + + return CHANGE_MODEM_STATE ; + +} + +/*################################################################################################*/ +/*################################################################################################*/ +/*## ##*/ +/*## jjy_write_clockstats ##*/ +/*## ##*/ +/*################################################################################################*/ +/*################################################################################################*/ + +static void +jjy_write_clockstats ( struct peer *peer, int iMark, const char *pData ) +{ + + char sLog [ 100 ] ; + char *pMark ; + int iMarkLen, iDataLen ; + + switch ( iMark ) { + case JJY_CLOCKSTATS_MARK_JJY : + pMark = "JJY " ; + break ; + case JJY_CLOCKSTATS_MARK_SEND : + pMark = "--> " ; + break ; + case JJY_CLOCKSTATS_MARK_RECEIVE : + pMark = "<-- " ; + break ; + case JJY_CLOCKSTATS_MARK_INFORMATION : + pMark = "--- " ; + break ; + case JJY_CLOCKSTATS_MARK_ATTENTION : + pMark = "=== " ; + break ; + case JJY_CLOCKSTATS_MARK_WARNING : + pMark = "-W- " ; + break ; + case JJY_CLOCKSTATS_MARK_ERROR : + pMark = "-X- " ; + break ; + default : + pMark = "" ; + break ; + } + + iDataLen = strlen( pData ) ; + iMarkLen = strlen( pMark ) ; + strcpy( sLog, pMark ) ; /* Harmless because of enough length */ + printableString( sLog+iMarkLen, sizeof(sLog)-iMarkLen, pData, iDataLen ) ; + +#ifdef DEBUG + if ( debug ) { + printf( "refclock_jjy.c : clockstats : %s\n", sLog ) ; + } +#endif + record_clock_stats( &peer->srcadr, sLog ) ; + +} + +/*################################################################################################*/ +/*################################################################################################*/ +/*## ##*/ +/*## printableString ##*/ +/*## ##*/ +/*################################################################################################*/ +/*################################################################################################*/ static void -printableString ( char *sOutput, int iOutputLen, char *sInput, int iInputLen ) +printableString ( char *sOutput, int iOutputLen, const char *sInput, int iInputLen ) { const char *printableControlChar[] = { "<NUL>", "<SOH>", "<STX>", "<ETX>", diff --git a/ntpd/refclock_parse.c b/ntpd/refclock_parse.c index 195ec39cb4f05..147a462231dd8 100644 --- a/ntpd/refclock_parse.c +++ b/ntpd/refclock_parse.c @@ -15,7 +15,7 @@ * Currently the STREAMS module is only available for Suns running * SunOS 4.x and SunOS5.x. * - * Copyright (c) 1995-2009 by Frank Kardel <kardel <AT> ntp.org> + * Copyright (c) 1995-2015 by Frank Kardel <kardel <AT> ntp.org> * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany * * Redistribution and use in source and binary forms, with or without @@ -2540,7 +2540,7 @@ parsestate( { { PARSEB_S_LEAP, "LEAP INDICATION" }, { PARSEB_S_PPS, "PPS SIGNAL" }, - { PARSEB_S_ANTENNA, "ANTENNA" }, + { PARSEB_S_CALLBIT, "CALLBIT" }, { PARSEB_S_POSITION, "POSITION" }, { 0, NULL } }; @@ -2562,7 +2562,7 @@ parsestate( i++; } - if (lstate & (PARSEB_S_LEAP|PARSEB_S_ANTENNA|PARSEB_S_PPS|PARSEB_S_POSITION)) + if (lstate & (PARSEB_S_LEAP|PARSEB_S_CALLBIT|PARSEB_S_PPS|PARSEB_S_POSITION)) { if (s != t) t = ap(buffer, size, t, "; "); @@ -2998,7 +2998,7 @@ parse_start( if (!notice) { NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */ - msyslog(LOG_INFO, "NTP PARSE support: Copyright (c) 1989-2009, Frank Kardel"); + msyslog(LOG_INFO, "NTP PARSE support: Copyright (c) 1989-2015, Frank Kardel"); notice = 1; } @@ -3782,6 +3782,8 @@ parse_process( msyslog(LOG_WARNING, "PARSE receiver #%d: FAILED TIMECODE: \"%s\" (check receiver configuration / wiring)", CLK_UNIT(parse->peer), mkascii(buffer, sizeof buffer, tmpctl.parsegettc.parse_buffer, (unsigned)(tmpctl.parsegettc.parse_count - 1))); } + /* copy status to show only changes in case of failures */ + parse->timedata.parse_status = parsetime->parse_status; } } diff --git a/ntpd/refclock_shm.c b/ntpd/refclock_shm.c index 7174abdbf4cf3..6ab5d0267e9e4 100644 --- a/ntpd/refclock_shm.c +++ b/ntpd/refclock_shm.c @@ -24,6 +24,7 @@ #include "timespecops.h" #undef fileno #include "ntp_stdlib.h" +#include "ntp_assert.h" #undef fileno #include <ctype.h> @@ -37,6 +38,10 @@ # include <stdio.h> #endif +#ifdef HAVE_STDATOMIC_H +# include <stdatomic.h> +#endif /* HAVE_STDATOMIC_H */ + /* * This driver supports a reference clock attached thru shared memory */ @@ -117,6 +122,7 @@ struct shmunit { time_t max_delay; /* age/stale limit */ }; + static struct shmTime* getShmTime( int unit, @@ -144,8 +150,8 @@ getShmTime( msyslog(LOG_ERR, "SHM shmat (unit %d): %m", unit); return NULL; } - return p; + return p; #else static const char * nspref[2] = { "Local", "Global" }; @@ -195,10 +201,14 @@ getShmTime( return NULL; } + return p; #endif - return p; + /* NOTREACHED */ + ENSURE(!"getShmTime(): Not reached."); } + + /* * shm_start - attach to shared memory */ @@ -348,10 +358,158 @@ shm_poll( shm_clockstats(unit, peer); } + +enum segstat_t { + OK, NO_SEGMENT, NOT_READY, BAD_MODE, CLASH +}; + +struct shm_stat_t { + int status; + int mode; + struct timespec tvc, tvr, tvt; + int precision; + int leap; +}; + +static inline void memory_barrier(void) +{ +#ifdef HAVE_ATOMIC_THREAD_FENCE + atomic_thread_fence(memory_order_seq_cst); +#endif /* HAVE_ATOMIC_THREAD_FENCE */ +} + +static enum segstat_t shm_query(volatile struct shmTime *shm_in, struct shm_stat_t *shm_stat) +/* try to grab a sample from the specified SHM segment */ +{ + volatile struct shmTime shmcopy, *shm = shm_in; + volatile int cnt; + + unsigned int cns_new, rns_new; + + /* + * This is the main routine. It snatches the time from the shm + * board and tacks on a local timestamp. + */ + if (shm == NULL) { + shm_stat->status = NO_SEGMENT; + return NO_SEGMENT; + } + + /*@-type@*//* splint is confused about struct timespec */ + shm_stat->tvc.tv_sec = shm_stat->tvc.tv_nsec = 0; + { + time_t now; + + time(&now); + shm_stat->tvc.tv_sec = now; + } + + /* relying on word access to be atomic here */ + if (shm->valid == 0) { + shm_stat->status = NOT_READY; + return NOT_READY; + } + + cnt = shm->count; + + /* + * This is proof against concurrency issues if either + * (a) the memory_barrier() call works on this host, or + * (b) memset compiles to an uninterruptible single-instruction bitblt. + */ + memory_barrier(); + memcpy((void *)&shmcopy, (void *)shm, sizeof(struct shmTime)); + shm->valid = 0; + memory_barrier(); + + /* + * Clash detection in case neither (a) nor (b) was true. + * Not supported in mode 0, and word access to the count field + * must be atomic for this to work. + */ + if (shmcopy.mode > 0 && cnt != shm->count) { + shm_stat->status = CLASH; + return shm_stat->status; + } + + shm_stat->status = OK; + shm_stat->mode = shmcopy.mode; + + switch (shmcopy.mode) { + case 0: + shm_stat->tvr.tv_sec = shmcopy.receiveTimeStampSec; + shm_stat->tvr.tv_nsec = shmcopy.receiveTimeStampUSec * 1000; + rns_new = shmcopy.receiveTimeStampNSec; + shm_stat->tvt.tv_sec = shmcopy.clockTimeStampSec; + shm_stat->tvt.tv_nsec = shmcopy.clockTimeStampUSec * 1000; + cns_new = shmcopy.clockTimeStampNSec; + + /* Since the following comparisons are between unsigned + ** variables they are always well defined, and any + ** (signed) underflow will turn into very large unsigned + ** values, well above the 1000 cutoff. + ** + ** Note: The usecs *must* be a *truncated* + ** representation of the nsecs. This code will fail for + ** *rounded* usecs, and the logic to deal with + ** wrap-arounds in the presence of rounded values is + ** much more convoluted. + */ + if ( ((cns_new - (unsigned)shm_stat->tvt.tv_nsec) < 1000) + && ((rns_new - (unsigned)shm_stat->tvr.tv_nsec) < 1000)) { + shm_stat->tvt.tv_nsec = cns_new; + shm_stat->tvr.tv_nsec = rns_new; + } + /* At this point shm_stat->tvr and shm_stat->tvt contain valid ns-level + ** timestamps, possibly generated by extending the old + ** us-level timestamps + */ + break; + + case 1: + + shm_stat->tvr.tv_sec = shmcopy.receiveTimeStampSec; + shm_stat->tvr.tv_nsec = shmcopy.receiveTimeStampUSec * 1000; + rns_new = shmcopy.receiveTimeStampNSec; + shm_stat->tvt.tv_sec = shmcopy.clockTimeStampSec; + shm_stat->tvt.tv_nsec = shmcopy.clockTimeStampUSec * 1000; + cns_new = shmcopy.clockTimeStampNSec; + + /* See the case above for an explanation of the + ** following test. + */ + if ( ((cns_new - (unsigned)shm_stat->tvt.tv_nsec) < 1000) + && ((rns_new - (unsigned)shm_stat->tvr.tv_nsec) < 1000)) { + shm_stat->tvt.tv_nsec = cns_new; + shm_stat->tvr.tv_nsec = rns_new; + } + /* At this point shm_stat->tvr and shm_stat->tvt contains valid ns-level + ** timestamps, possibly generated by extending the old + ** us-level timestamps + */ + break; + + default: + shm_stat->status = BAD_MODE; + break; + } + /*@-type@*/ + + /* + * leap field is not a leap offset but a leap notification code. + * The values are magic numbers used by NTP and set by GPSD, if at all, in + * the subframe code. + */ + shm_stat->leap = shmcopy.leap; + shm_stat->precision = shmcopy.precision; + + return shm_stat->status; +} + /* - * shm_timer - called onece every second. + * shm_timer - called once every second. * - * This tries to grab a sample from the SHM segment + * This tries to grab a sample from the SHM segment, filtering bad ones */ static void shm_timer( @@ -362,33 +520,20 @@ shm_timer( struct refclockproc * const pp = peer->procptr; struct shmunit * const up = pp->unitptr; - /* access order is important for lock-free SHM access; we - ** enforce order by treating the whole structure volatile. - ** - ** IMPORTANT NOTE: This does not protect from reordering on CPU - ** level, and it does nothing for cache consistency and - ** visibility of changes by other cores. We need atomic and/or - ** fence instructions for that. - */ volatile struct shmTime *shm; - struct timespec tvr; - struct timespec tvt; l_fp tsrcv; l_fp tsref; - unsigned int c; - unsigned int cns_new, rns_new; - int cnt; + int c; /* for formatting 'a_lastcode': */ struct calendar cd; - time_t tt, now; + time_t tt; vint64 ts; - /* - * This is the main routine. It snatches the time from the shm - * board and tacks on a local timestamp. - */ + enum segstat_t status; + struct shm_stat_t shm_stat; + up->ticks++; if ((shm = up->shm) == NULL) { /* try to map again - this may succeed if meanwhile some- @@ -400,88 +545,43 @@ shm_timer( return; } } - if ( ! shm->valid) { - DPRINTF(1, ("%s: SHM not ready\n", - refnumtoa(&peer->srcadr))); - up->notready++; - return; - } - - switch (shm->mode) { - case 0: - tvr.tv_sec = shm->receiveTimeStampSec; - tvr.tv_nsec = shm->receiveTimeStampUSec * 1000; - rns_new = shm->receiveTimeStampNSec; - tvt.tv_sec = shm->clockTimeStampSec; - tvt.tv_nsec = shm->clockTimeStampUSec * 1000; - cns_new = shm->clockTimeStampNSec; - - /* Since the following comparisons are between unsigned - ** variables they are always well defined, and any - ** (signed) underflow will turn into very large unsigned - ** values, well above the 1000 cutoff. - ** - ** Note: The usecs *must* be a *truncated* - ** representation of the nsecs. This code will fail for - ** *rounded* usecs, and the logic to deal with - ** wrap-arounds in the presence of rounded values is - ** much more convoluted. - */ - if ( ((cns_new - (unsigned)tvt.tv_nsec) < 1000) - && ((rns_new - (unsigned)tvr.tv_nsec) < 1000)) { - tvt.tv_nsec = cns_new; - tvr.tv_nsec = rns_new; - } - /* At this point tvr and tvt contains valid ns-level - ** timestamps, possibly generated by extending the old - ** us-level timestamps - */ - DPRINTF(2, ("%s: SHM type 0 sample\n", - refnumtoa(&peer->srcadr))); - break; - - case 1: - cnt = shm->count; - - tvr.tv_sec = shm->receiveTimeStampSec; - tvr.tv_nsec = shm->receiveTimeStampUSec * 1000; - rns_new = shm->receiveTimeStampNSec; - tvt.tv_sec = shm->clockTimeStampSec; - tvt.tv_nsec = shm->clockTimeStampUSec * 1000; - cns_new = shm->clockTimeStampNSec; - if (cnt != shm->count) { - DPRINTF(1, ("%s: type 1 access clash\n", - refnumtoa(&peer->srcadr))); - msyslog (LOG_NOTICE, "SHM: access clash in shared memory"); - up->clash++; - return; - } - - /* See the case above for an explanation of the - ** following test. - */ - if ( ((cns_new - (unsigned)tvt.tv_nsec) < 1000) - && ((rns_new - (unsigned)tvr.tv_nsec) < 1000)) { - tvt.tv_nsec = cns_new; - tvr.tv_nsec = rns_new; - } - /* At this point tvr and tvt contains valid ns-level - ** timestamps, possibly generated by extending the old - ** us-level timestamps - */ - DPRINTF(2, ("%s: SHM type 1 sample\n", - refnumtoa(&peer->srcadr))); - break; + /* query the segment, atomically */ + status = shm_query(shm, &shm_stat); + + switch (status) { + case OK: + DPRINTF(2, ("%s: SHM type %d sample\n", + refnumtoa(&peer->srcadr), shm_stat.mode)); + break; + case NO_SEGMENT: + /* should never happen, but is harmless */ + return; + case NOT_READY: + DPRINTF(1, ("%s: SHM not ready\n",refnumtoa(&peer->srcadr))); + up->notready++; + return; + case BAD_MODE: + DPRINTF(1, ("%s: SHM type blooper, mode=%d\n", + refnumtoa(&peer->srcadr), shm->mode)); + up->bad++; + msyslog (LOG_ERR, "SHM: bad mode found in shared memory: %d", + shm->mode); + return; + case CLASH: + DPRINTF(1, ("%s: type 1 access clash\n", + refnumtoa(&peer->srcadr))); + msyslog (LOG_NOTICE, "SHM: access clash in shared memory"); + up->clash++; + return; default: - DPRINTF(1, ("%s: SHM type blooper, mode=%d\n", - refnumtoa(&peer->srcadr), shm->mode)); - up->bad++; - msyslog (LOG_ERR, "SHM: bad mode found in shared memory: %d", - shm->mode); - return; + DPRINTF(1, ("%s: internal error, unknown SHM fetch status\n", + refnumtoa(&peer->srcadr))); + msyslog (LOG_NOTICE, "internal error, unknown SHM fetch status"); + up->bad++; + return; } - shm->valid = 0; + /* format the last time code in human-readable form into * 'pp->a_lastcode'. Someone claimed: "NetBSD has incompatible @@ -489,7 +589,7 @@ shm_timer( * around that potential problem. BTW, simply casting a pointer * is a receipe for disaster on some architectures. */ - tt = (time_t)tvt.tv_sec; + tt = (time_t)shm_stat.tvt.tv_sec; ts = time_to_vint64(&tt); ntpcal_time_to_date(&cd, &ts); @@ -498,12 +598,11 @@ shm_timer( "%04u-%02u-%02uT%02u:%02u:%02u.%09ldZ", cd.year, cd.month, cd.monthday, cd.hour, cd.minute, cd.second, - (long)tvt.tv_nsec); + (long)shm_stat.tvt.tv_nsec); pp->lencode = (c < sizeof(pp->a_lastcode)) ? c : 0; /* check 1: age control of local time stamp */ - time(&now); - tt = now - tvr.tv_sec; + tt = shm_stat.tvc.tv_sec - shm_stat.tvr.tv_sec; if (tt < 0 || tt > up->max_delay) { DPRINTF(1, ("%s:SHM stale/bad receive time, delay=%llds\n", refnumtoa(&peer->srcadr), (long long)tt)); @@ -514,7 +613,7 @@ shm_timer( } /* check 2: delta check */ - tt = tvr.tv_sec - tvt.tv_sec - (tvr.tv_nsec < tvt.tv_nsec); + tt = shm_stat.tvr.tv_sec - shm_stat.tvt.tv_sec - (shm_stat.tvr.tv_nsec < shm_stat.tvt.tv_nsec); if (tt < 0) tt = -tt; if (up->max_delta > 0 && tt > up->max_delta) { @@ -529,10 +628,10 @@ shm_timer( /* if we really made it to this point... we're winners! */ DPRINTF(2, ("%s: SHM feeding data\n", refnumtoa(&peer->srcadr))); - tsrcv = tspec_stamp_to_lfp(tvr); - tsref = tspec_stamp_to_lfp(tvt); - pp->leap = shm->leap; - peer->precision = shm->precision; + tsrcv = tspec_stamp_to_lfp(shm_stat.tvr); + tsref = tspec_stamp_to_lfp(shm_stat.tvt); + pp->leap = shm_stat.leap; + peer->precision = shm_stat.precision; refclock_process_offset(pp, tsref, tsrcv, pp->fudgetime1); up->good++; } diff --git a/ntpd/refclock_true.c b/ntpd/refclock_true.c index 7a5c491bb5951..67ba6dfbeccee 100644 --- a/ntpd/refclock_true.c +++ b/ntpd/refclock_true.c @@ -240,7 +240,7 @@ true_debug(struct peer *peer, const char *fmt, ...) "/tmp/true%d.debug", up->unit); fd = open(filename, O_CREAT | O_WRONLY | O_EXCL, 0600); - if (fd >= 0 && (up->debug = fdopen(fd, "r+"))) { + if (fd >= 0 && (up->debug = fdopen(fd, "w"))) { #ifdef HAVE_SETVBUF static char buf[BUFSIZ]; |