diff options
Diffstat (limited to 'contrib/ntp/include')
54 files changed, 4623 insertions, 505 deletions
diff --git a/contrib/ntp/include/Makefile.am b/contrib/ntp/include/Makefile.am index 44301eefe60b..8f8b934afeb4 100644 --- a/contrib/ntp/include/Makefile.am +++ b/contrib/ntp/include/Makefile.am @@ -3,6 +3,8 @@ AUTOMAKE_OPTIONS = ../util/ansi2knr ETAGS_ARGS = $(srcdir)/Makefile.am #EXTRA_DIST = TAGS +SUBDIRS = isc + noinst_HEADERS = \ adjtime.h \ audio.h \ @@ -17,7 +19,6 @@ noinst_HEADERS = \ iosignal.h \ l_stdlib.h \ mbg_gps166.h \ - md5.h \ mx4200.h \ ntif.h \ ntp.h \ @@ -33,10 +34,13 @@ noinst_HEADERS = \ ntp_io.h \ ntp_machine.h \ ntp_malloc.h \ + ntp_md5.h \ ntp_proto.h \ ntp_refclock.h \ ntp_request.h \ + ntp_rfc2553.h \ ntp_select.h \ + ntp_sprintf.h \ ntp_stdlib.h \ ntp_string.h \ ntp_syscall.h \ @@ -45,9 +49,10 @@ noinst_HEADERS = \ ntp_types.h \ ntp_unixtime.h \ ntpd.h \ + ntpsim.h \ parse.h \ parse_conf.h \ recvbuff.h \ + rsa_md5.h \ trimble.h - diff --git a/contrib/ntp/include/Makefile.in b/contrib/ntp/include/Makefile.in index 136e6dd91373..d0a688243ec3 100644 --- a/contrib/ntp/include/Makefile.in +++ b/contrib/ntp/include/Makefile.in @@ -1,6 +1,7 @@ -# Makefile.in generated automatically by automake 1.5 from Makefile.am. +# Makefile.in generated by automake 1.7.7 from Makefile.am. +# @configure_input@ -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 # Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -13,82 +14,79 @@ @SET_MAKE@ -#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies - -SHELL = @SHELL@ - srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) -transform = @program_transform_name@ +transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : -build_alias = @build_alias@ build_triplet = @build@ -host_alias = @host_alias@ host_triplet = @host@ -target_alias = @target_alias@ target_triplet = @target@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ -AUTOKEY = @AUTOKEY@ +ARLIB_DIR = @ARLIB_DIR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ +CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CHUTEST = @CHUTEST@ CLKTEST = @CLKTEST@ CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ DCFD = @DCFD@ +DEFS = @DEFS@ DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ EF_LIBS = @EF_LIBS@ EF_PROGS = @EF_PROGS@ +EGREP = @EGREP@ EXEEXT = @EXEEXT@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LCRYPTO = @LCRYPTO@ LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ LIBPARSE = @LIBPARSE@ -LIBRSAREF = @LIBRSAREF@ +LIBS = @LIBS@ LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@ +MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@ MAKE_LIBPARSE = @MAKE_LIBPARSE@ MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@ -MAKE_LIBRSAREF = @MAKE_LIBRSAREF@ +MAKE_NTPDSIM = @MAKE_NTPDSIM@ MAKE_NTPTIME = @MAKE_NTPTIME@ -MAKE_NTP_GENKEYS = @MAKE_NTP_GENKEYS@ +MAKE_NTP_KEYGEN = @MAKE_NTP_KEYGEN@ MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@ +MAKE_SNTP = @MAKE_SNTP@ MAKE_TICKADJ = @MAKE_TICKADJ@ MAKE_TIMETRIM = @MAKE_TIMETRIM@ OBJEXT = @OBJEXT@ @@ -96,25 +94,71 @@ OPENSSL = @OPENSSL@ OPENSSL_INC = @OPENSSL_INC@ OPENSSL_LIB = @OPENSSL_LIB@ PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_PERL = @PATH_PERL@ +PATH_SEPARATOR = @PATH_SEPARATOR@ PATH_SH = @PATH_SH@ PROPDELAY = @PROPDELAY@ RANLIB = @RANLIB@ -RSADIR = @RSADIR@ -RSAOBJS = @RSAOBJS@ -RSAREF = @RSAREF@ -RSASRCS = @RSASRCS@ +READLINE_LIBS = @READLINE_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ TESTDCF = @TESTDCF@ U = @U@ VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__include = @am__include@ +am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +subdirs = @subdirs@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies AUTOMAKE_OPTIONS = ../util/ansi2knr ETAGS_ARGS = $(srcdir)/Makefile.am #EXTRA_DIST = TAGS +SUBDIRS = isc + noinst_HEADERS = \ adjtime.h \ audio.h \ @@ -129,7 +173,6 @@ noinst_HEADERS = \ iosignal.h \ l_stdlib.h \ mbg_gps166.h \ - md5.h \ mx4200.h \ ntif.h \ ntp.h \ @@ -145,10 +188,13 @@ noinst_HEADERS = \ ntp_io.h \ ntp_machine.h \ ntp_malloc.h \ + ntp_md5.h \ ntp_proto.h \ ntp_refclock.h \ ntp_request.h \ + ntp_rfc2553.h \ ntp_select.h \ + ntp_sprintf.h \ ntp_stdlib.h \ ntp_string.h \ ntp_syscall.h \ @@ -157,101 +203,226 @@ noinst_HEADERS = \ ntp_types.h \ ntp_unixtime.h \ ntpd.h \ + ntpsim.h \ parse.h \ parse_conf.h \ recvbuff.h \ + rsa_md5.h \ trimble.h subdir = include +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = DIST_SOURCES = HEADERS = $(noinst_HEADERS) -DIST_COMMON = README $(noinst_HEADERS) Makefile.am Makefile.in -all: all-am + +RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \ + ps-recursive install-info-recursive uninstall-info-recursive \ + all-recursive install-data-recursive install-exec-recursive \ + installdirs-recursive install-recursive uninstall-recursive \ + check-recursive installcheck-recursive +DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.in \ + Makefile.am +DIST_SUBDIRS = $(SUBDIRS) +all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu include/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) && \ - CONFIG_HEADERS= CONFIG_LINKS= \ - CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) uninstall-info-am: +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ETAGS = etags +ETAGSFLAGS = + +CTAGS = ctags +CTAGSFLAGS = + tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if (etags --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + else \ + include_option=--include; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ - mkid -fID $$unique $(LISP) + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique GTAGS: - here=`CDPATH=: && cd $(top_builddir) && pwd` \ + here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH - + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = .. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) - @for file in $(DISTFILES); do \ - if test -f $$file; then d=.; else d=$(srcdir); fi; \ + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - $(mkinstalldirs) "$(distdir)/$$dir"; \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ fi; \ if test -d $$d/$$file; then \ - cp -pR $$d/$$file $(distdir) \ - || exit 1; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done check-am: all-am -check: check-am +check: check-recursive all-am: Makefile $(HEADERS) +installdirs: installdirs-recursive +installdirs-am: -installdirs: - -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -installcheck: installcheck-am +installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: @@ -259,24 +430,24 @@ mostlyclean-generic: clean-generic: distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + -rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -clean: clean-am +clean: clean-recursive clean-am: clean-generic mostlyclean-am -distclean: distclean-am - +distclean: distclean-recursive + -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags -dvi: dvi-am +dvi: dvi-recursive dvi-am: -info: info-am +info: info-recursive info-am: @@ -284,30 +455,46 @@ install-data-am: install-exec-am: -install-info: install-info-am +install-info: install-info-recursive install-man: installcheck-am: -maintainer-clean: maintainer-clean-am - +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic -mostlyclean: mostlyclean-am +mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + uninstall-am: uninstall-info-am -.PHONY: GTAGS all all-am check check-am clean clean-generic distclean \ - distclean-generic distclean-tags distdir dvi dvi-am info \ - info-am install install-am install-data install-data-am \ - install-exec install-exec-am install-info install-info-am \ - install-man install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic tags uninstall uninstall-am \ - uninstall-info-am +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \ + clean-generic clean-recursive ctags ctags-recursive distclean \ + distclean-generic distclean-recursive distclean-tags distdir \ + dvi dvi-am dvi-recursive info info-am info-recursive install \ + install-am install-data install-data-am install-data-recursive \ + install-exec install-exec-am install-exec-recursive \ + install-info install-info-am install-info-recursive install-man \ + install-recursive install-strip installcheck installcheck-am \ + installdirs installdirs-am installdirs-recursive \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-generic \ + mostlyclean-recursive pdf pdf-am pdf-recursive ps ps-am \ + ps-recursive tags tags-recursive uninstall uninstall-am \ + uninstall-info-am uninstall-info-recursive uninstall-recursive # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/contrib/ntp/include/adjtime.h b/contrib/ntp/include/adjtime.h index 74d91eb2719d..b6e2a3e99541 100644 --- a/contrib/ntp/include/adjtime.h +++ b/contrib/ntp/include/adjtime.h @@ -39,6 +39,10 @@ #include "ntp_types.h" +#ifdef __QNXNTO__ +int adjtime( const struct timeval * oldtime, struct timeval * newtime ); +#else /* not __QNXNTO__ */ + #define KEY 659847L typedef union { @@ -61,3 +65,5 @@ typedef union { */ #define DELTA1 0 #define DELTA2 1 + +#endif /* not __QNXNTO__ */ diff --git a/contrib/ntp/include/audio.h b/contrib/ntp/include/audio.h index 9f728ddbba6e..6d16347ec80d 100644 --- a/contrib/ntp/include/audio.h +++ b/contrib/ntp/include/audio.h @@ -3,11 +3,12 @@ */ #include "ntp_types.h" -#define AUDIO_BUFSIZ 160 /* codec buffer size (Solaris only) */ +#define MAXGAIN 255 /* max codec gain */ +#define MONGAIN 127 /* codec monitor gain */ /* * Function prototypes */ -int audio_init P((char *)); -int audio_gain P((int, int)); +int audio_init P((char *, int, int)); +int audio_gain P((int, int, int)); void audio_show P((void)); diff --git a/contrib/ntp/include/isc/Makefile.am b/contrib/ntp/include/isc/Makefile.am new file mode 100644 index 000000000000..a5b253c9ddc6 --- /dev/null +++ b/contrib/ntp/include/isc/Makefile.am @@ -0,0 +1,34 @@ +#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies +AUTOMAKE_OPTIONS = ../util/ansi2knr +ETAGS_ARGS = $(srcdir)/Makefile.am +#EXTRA_DIST = TAGS + +noinst_HEADERS = \ + app.h \ + assertions.h \ + boolean.h \ + error.h \ + formatcheck.h \ + int.h \ + interfaceiter.h \ + ipv6.h \ + lang.h \ + lib.h \ + list.h \ + magic.h \ + mem.h \ + msgcat.h \ + msgs.h \ + mutex.h \ + net.h \ + netaddr.h \ + offset.h \ + once.h \ + platform.h \ + print.h \ + result.h \ + sockaddr.h \ + strerror.h \ + string.h \ + types.h \ + util.h diff --git a/contrib/ntp/include/isc/Makefile.in b/contrib/ntp/include/isc/Makefile.in new file mode 100644 index 000000000000..3270f4a9f726 --- /dev/null +++ b/contrib/ntp/include/isc/Makefile.in @@ -0,0 +1,380 @@ +# Makefile.in generated by automake 1.7.7 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +ARLIB_DIR = @ARLIB_DIR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHUTEST = @CHUTEST@ +CLKTEST = @CLKTEST@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DCFD = @DCFD@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EF_LIBS = @EF_LIBS@ +EF_PROGS = @EF_PROGS@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LCRYPTO = @LCRYPTO@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBPARSE = @LIBPARSE@ +LIBS = @LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MAKE_ADJTIMED = @MAKE_ADJTIMED@ +MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@ +MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@ +MAKE_LIBPARSE = @MAKE_LIBPARSE@ +MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@ +MAKE_NTPDSIM = @MAKE_NTPDSIM@ +MAKE_NTPTIME = @MAKE_NTPTIME@ +MAKE_NTP_KEYGEN = @MAKE_NTP_KEYGEN@ +MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@ +MAKE_SNTP = @MAKE_SNTP@ +MAKE_TICKADJ = @MAKE_TICKADJ@ +MAKE_TIMETRIM = @MAKE_TIMETRIM@ +OBJEXT = @OBJEXT@ +OPENSSL = @OPENSSL@ +OPENSSL_INC = @OPENSSL_INC@ +OPENSSL_LIB = @OPENSSL_LIB@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_PERL = @PATH_PERL@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PATH_SH = @PATH_SH@ +PROPDELAY = @PROPDELAY@ +RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TESTDCF = @TESTDCF@ +U = @U@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +subdirs = @subdirs@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ + +#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies +AUTOMAKE_OPTIONS = ../util/ansi2knr +ETAGS_ARGS = $(srcdir)/Makefile.am + +#EXTRA_DIST = TAGS +noinst_HEADERS = \ + app.h \ + assertions.h \ + boolean.h \ + error.h \ + formatcheck.h \ + int.h \ + interfaceiter.h \ + ipv6.h \ + lang.h \ + lib.h \ + list.h \ + magic.h \ + mem.h \ + msgcat.h \ + msgs.h \ + mutex.h \ + net.h \ + netaddr.h \ + offset.h \ + once.h \ + platform.h \ + print.h \ + result.h \ + sockaddr.h \ + strerror.h \ + string.h \ + types.h \ + util.h + +subdir = include/isc +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = +HEADERS = $(noinst_HEADERS) + +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.in Makefile.am +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu include/isc/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) +uninstall-info-am: + +ETAGS = etags +ETAGSFLAGS = + +CTAGS = ctags +CTAGSFLAGS = + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(HEADERS) + +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile + +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic ctags \ + distclean distclean-generic distclean-tags distdir dvi dvi-am \ + info info-am install install-am install-data install-data-am \ + install-exec install-exec-am install-info install-info-am \ + install-man install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ + uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/contrib/ntp/include/isc/app.h b/contrib/ntp/include/isc/app.h new file mode 100644 index 000000000000..5aa3d23acaca --- /dev/null +++ b/contrib/ntp/include/isc/app.h @@ -0,0 +1,212 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: app.h,v 1.1 2001/07/06 19:50:03 gson Exp $ */ + +#ifndef ISC_APP_H +#define ISC_APP_H 1 + +/***** + ***** Module Info + *****/ + +/* + * ISC Application Support + * + * Dealing with program termination can be difficult, especially in a + * multithreaded program. The routines in this module help coordinate + * the shutdown process. They are used as follows by the initial (main) + * thread of the application: + * + * isc_app_start(); Call very early in main(), before + * any other threads have been created. + * + * isc_app_run(); This will post any on-run events, + * and then block until application + * shutdown is requested. A shutdown + * request is made by calling + * isc_app_shutdown(), or by sending + * SIGINT or SIGTERM to the process. + * After isc_app_run() returns, the + * application should shutdown itself. + * + * isc_app_finish(); Call very late in main(). + * + * Applications that want to use SIGHUP/isc_app_reload() to trigger reloading + * should check the result of isc_app_run() and call the reload routine if + * the result is ISC_R_RELOAD. They should then call isc_app_run() again + * to resume waiting for reload or termination. + * + * Use of this module is not required. In particular, isc_app_start() is + * NOT an ISC library initialization routine. + * + * MP: + * Clients must ensure that isc_app_start(), isc_app_run(), and + * isc_app_finish() are called at most once. isc_app_shutdown() + * is safe to use by any thread (provided isc_app_start() has been + * called previously). + * + * Reliability: + * No anticipated impact. + * + * Resources: + * None. + * + * Security: + * No anticipated impact. + * + * Standards: + * None. + */ + +#include <isc/eventclass.h> +#include <isc/lang.h> +#include <isc/result.h> + +typedef isc_event_t isc_appevent_t; + +#define ISC_APPEVENT_FIRSTEVENT (ISC_EVENTCLASS_APP + 0) +#define ISC_APPEVENT_SHUTDOWN (ISC_EVENTCLASS_APP + 1) +#define ISC_APPEVENT_LASTEVENT (ISC_EVENTCLASS_APP + 65535) + +ISC_LANG_BEGINDECLS + +isc_result_t +isc_app_start(void); +/* + * Start an ISC library application. + * + * Notes: + * This call should be made before any other ISC library call, and as + * close to the beginning of the application as possible. + */ + +isc_result_t +isc_app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action, + void *arg); +/* + * Request delivery of an event when the application is run. + * + * Requires: + * isc_app_start() has been called. + * + * Returns: + * ISC_R_SUCCESS + * ISC_R_NOMEMORY + */ + +isc_result_t +isc_app_run(void); +/* + * Run an ISC library application. + * + * Notes: + * The caller (typically the initial thread of an application) will + * block until shutdown is requested. When the call returns, the + * caller should start shutting down the application. + * + * Requires: + * isc_app_start() has been called. + * + * Ensures: + * Any events requested via isc_app_onrun() will have been posted (in + * FIFO order) before isc_app_run() blocks. + * + * Returns: + * ISC_R_SUCCESS Shutdown has been requested. + * ISC_R_RELOAD Reload has been requested. + */ + +isc_result_t +isc_app_shutdown(void); +/* + * Request application shutdown. + * + * Notes: + * It is safe to call isc_app_shutdown() multiple times. Shutdown will + * only be triggered once. + * + * Requires: + * isc_app_run() has been called. + * + * Returns: + * ISC_R_SUCCESS + * ISC_R_UNEXPECTED + */ + +isc_result_t +isc_app_reload(void); +/* + * Request application reload. + * + * Requires: + * isc_app_run() has been called. + * + * Returns: + * ISC_R_SUCCESS + * ISC_R_UNEXPECTED + */ + +void +isc_app_finish(void); +/* + * Finish an ISC library application. + * + * Notes: + * This call should be made at or near the end of main(). + * + * Requires: + * isc_app_start() has been called. + * + * Ensures: + * Any resources allocated by isc_app_start() have been released. + */ + +void +isc_app_block(void); +/* + * Indicate that a blocking operation will be performed. + * + * Notes: + * If a blocking operation is in process, a call to isc_app_shutdown() + * or an external signal will abort the program, rather than allowing + * clean shutdown. This is primarily useful for reading user input. + * + * Requires: + * isc_app_start() has been called. + * No other blocking operations are in progress. + */ + +void +isc_app_unblock(void); +/* + * Indicate that a blocking operation is complete. + * + * Notes: + * When a blocking operation has completed, return the program to a + * state where a call to isc_app_shutdown() or an external signal will + * shutdown normally. + * + * Requires: + * isc_app_start() has been called. + * isc_app_block() has been called by the same thread. + */ + + +ISC_LANG_ENDDECLS + +#endif /* ISC_APP_H */ diff --git a/contrib/ntp/include/isc/assertions.h b/contrib/ntp/include/isc/assertions.h new file mode 100644 index 000000000000..45855c663180 --- /dev/null +++ b/contrib/ntp/include/isc/assertions.h @@ -0,0 +1,120 @@ +/* + * Copyright (C) 1997-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * $Id: assertions.h,v 1.17 2001/07/12 05:58:21 mayer Exp $ + */ + +#ifndef ISC_ASSERTIONS_H +#define ISC_ASSERTIONS_H 1 + +#include <isc/lang.h> +#include <isc/platform.h> + +ISC_LANG_BEGINDECLS + +typedef enum { + isc_assertiontype_require, + isc_assertiontype_ensure, + isc_assertiontype_insist, + isc_assertiontype_invariant +} isc_assertiontype_t; + +typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t, + const char *); + +LIBISC_EXTERNAL_DATA extern isc_assertioncallback_t isc_assertion_failed; + +void +isc_assertion_setcallback(isc_assertioncallback_t); + +const char * +isc_assertion_typetotext(isc_assertiontype_t type); + +#ifdef ISC_CHECK_ALL +#define ISC_CHECK_REQUIRE 1 +#define ISC_CHECK_ENSURE 1 +#define ISC_CHECK_INSIST 1 +#define ISC_CHECK_INVARIANT 1 +#endif + +#ifdef ISC_CHECK_NONE +#define ISC_CHECK_REQUIRE 0 +#define ISC_CHECK_ENSURE 0 +#define ISC_CHECK_INSIST 0 +#define ISC_CHECK_INVARIANT 0 +#endif + +#ifndef ISC_CHECK_REQUIRE +#define ISC_CHECK_REQUIRE 1 +#endif + +#ifndef ISC_CHECK_ENSURE +#define ISC_CHECK_ENSURE 1 +#endif + +#ifndef ISC_CHECK_INSIST +#define ISC_CHECK_INSIST 1 +#endif + +#ifndef ISC_CHECK_INVARIANT +#define ISC_CHECK_INVARIANT 1 +#endif + +#if ISC_CHECK_REQUIRE != 0 +#define ISC_REQUIRE(cond) \ + ((void) ((cond) || \ + ((isc_assertion_failed)(__FILE__, __LINE__, \ + isc_assertiontype_require, \ + #cond), 0))) +#else +#define ISC_REQUIRE(cond) ((void) 0) +#endif /* ISC_CHECK_REQUIRE */ + +#if ISC_CHECK_ENSURE != 0 +#define ISC_ENSURE(cond) \ + ((void) ((cond) || \ + ((isc_assertion_failed)(__FILE__, __LINE__, \ + isc_assertiontype_ensure, \ + #cond), 0))) +#else +#define ISC_ENSURE(cond) ((void) 0) +#endif /* ISC_CHECK_ENSURE */ + +#if ISC_CHECK_INSIST != 0 +#define ISC_INSIST(cond) \ + ((void) ((cond) || \ + ((isc_assertion_failed)(__FILE__, __LINE__, \ + isc_assertiontype_insist, \ + #cond), 0))) +#else +#define ISC_INSIST(cond) ((void) 0) +#endif /* ISC_CHECK_INSIST */ + +#if ISC_CHECK_INVARIANT != 0 +#define ISC_INVARIANT(cond) \ + ((void) ((cond) || \ + ((isc_assertion_failed)(__FILE__, __LINE__, \ + isc_assertiontype_invariant, \ + #cond), 0))) +#else +#define ISC_INVARIANT(cond) ((void) 0) +#endif /* ISC_CHECK_INVARIANT */ + +ISC_LANG_ENDDECLS + +#endif /* ISC_ASSERTIONS_H */ diff --git a/contrib/ntp/include/isc/boolean.h b/contrib/ntp/include/isc/boolean.h new file mode 100644 index 000000000000..d10007b5802a --- /dev/null +++ b/contrib/ntp/include/isc/boolean.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 1998-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: boolean.h,v 1.12 2001/01/09 21:56:45 bwelling Exp $ */ + +#ifndef ISC_BOOLEAN_H +#define ISC_BOOLEAN_H 1 + +typedef enum { isc_boolean_false = 0, isc_boolean_true = 1 } isc_boolean_t; + +#define ISC_FALSE isc_boolean_false +#define ISC_TRUE isc_boolean_true +#define ISC_TF(x) ((x) ? ISC_TRUE : ISC_FALSE) + +#endif /* ISC_BOOLEAN_H */ diff --git a/contrib/ntp/include/isc/error.h b/contrib/ntp/include/isc/error.h new file mode 100644 index 000000000000..1dc07748c21d --- /dev/null +++ b/contrib/ntp/include/isc/error.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 1998-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: error.h,v 1.13 2001/01/09 21:56:51 bwelling Exp $ */ + +#ifndef ISC_ERROR_H +#define ISC_ERROR_H 1 + +#include <stdarg.h> + +#include <isc/formatcheck.h> +#include <isc/lang.h> + +ISC_LANG_BEGINDECLS + +typedef void (*isc_errorcallback_t)(const char *, int, const char *, va_list); + +void +isc_error_setunexpected(isc_errorcallback_t); + +void +isc_error_setfatal(isc_errorcallback_t); + +void +isc_error_unexpected(const char *, int, const char *, ...) + ISC_FORMAT_PRINTF(3, 4); + +void +isc_error_fatal(const char *, int, const char *, ...) + ISC_FORMAT_PRINTF(3, 4); + +void +isc_error_runtimecheck(const char *, int, const char *); + +#define ISC_ERROR_RUNTIMECHECK(cond) \ + ((void) ((cond) || \ + ((isc_error_runtimecheck)(__FILE__, __LINE__, #cond), 0))) + +ISC_LANG_ENDDECLS + +#endif /* ISC_ERROR_H */ diff --git a/contrib/ntp/include/isc/formatcheck.h b/contrib/ntp/include/isc/formatcheck.h new file mode 100644 index 000000000000..e9b91698e979 --- /dev/null +++ b/contrib/ntp/include/isc/formatcheck.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2000, 2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: formatcheck.h,v 1.6 2001/01/09 21:56:55 bwelling Exp $ */ + +#ifndef ISC_FORMATCHECK_H +#define ISC_FORMATCHECK_H 1 + +/* + * fmt is the location of the format string parameter. + * args is the location of the first argument (or 0 for no argument checking). + * Note: the first parameter is 1, not 0. + */ +#ifdef __GNUC__ +#define ISC_FORMAT_PRINTF(fmt, args) __attribute__((__format__(__printf__, fmt, args))) +#else +#define ISC_FORMAT_PRINTF(fmt, args) +#endif + +#endif /* ISC_FORMATCHECK_H */ diff --git a/contrib/ntp/include/isc/int.h b/contrib/ntp/include/isc/int.h new file mode 100644 index 000000000000..d30e6dcc6290 --- /dev/null +++ b/contrib/ntp/include/isc/int.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: int.h,v 1.11 2001/01/09 21:58:39 bwelling Exp $ */ + +#ifndef ISC_INT_H +#define ISC_INT_H 1 + +typedef char isc_int8_t; +typedef unsigned char isc_uint8_t; +typedef short isc_int16_t; +typedef unsigned short isc_uint16_t; +typedef int isc_int32_t; +typedef unsigned int isc_uint32_t; +typedef long long isc_int64_t; +typedef unsigned long long isc_uint64_t; + +#define ISC_INT8_MIN -128 +#define ISC_INT8_MAX 127 +#define ISC_UINT8_MAX 255 + +#define ISC_INT16_MIN -32768 +#define ISC_INT16_MAX 32767 +#define ISC_UINT16_MAX 65535 + +/* + * Note that "int" is 32 bits on all currently supported Unix-like operating + * systems, but "long" can be either 32 bits or 64 bits, thus the 32 bit + * constants are not qualified with "L". + */ +#define ISC_INT32_MIN -2147483648 +#define ISC_INT32_MAX 2147483647 +#define ISC_UINT32_MAX 4294967295U + +#define ISC_INT64_MIN -9223372036854775808LL +#define ISC_INT64_MAX 9223372036854775807LL +#define ISC_UINT64_MAX 18446744073709551615ULL + +#endif /* ISC_INT_H */ diff --git a/contrib/ntp/include/isc/interfaceiter.h b/contrib/ntp/include/isc/interfaceiter.h new file mode 100644 index 000000000000..fbd1b8224615 --- /dev/null +++ b/contrib/ntp/include/isc/interfaceiter.h @@ -0,0 +1,137 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: interfaceiter.h,v 1.10 2001/01/09 21:57:01 bwelling Exp $ */ + +#ifndef ISC_INTERFACEITER_H +#define ISC_INTERFACEITER_H 1 + +/***** + ***** Module Info + *****/ + +/* + * Interface iterator + * + * Iterate over the list of network interfaces. + * + * Interfaces whose address family is not supported are ignored and never + * returned by the iterator. Interfaces whose netmask, interface flags, + * or similar cannot be obtained are also ignored, and the failure is logged. + * + * Standards: + * The API for scanning varies greatly among operating systems. + * This module attempts to hide the differences. + */ + +/*** + *** Imports + ***/ + +#include <isc/lang.h> +#include <isc/netaddr.h> +#include <isc/types.h> + +/* + * Public structure describing a network interface. + */ + +struct isc_interface { + char name[32]; /* Interface name, null-terminated. */ + unsigned int af; /* Address family. */ + isc_netaddr_t address; /* Local address. */ + isc_netaddr_t netmask; /* Network mask. */ + isc_netaddr_t broadcast; /* Broadcast address. */ + isc_netaddr_t dstaddress; /* Destination address + (point-to-point only). */ + isc_uint32_t flags; /* Flags; see below. */ +}; + +/* Interface flags. */ + +#define INTERFACE_F_UP 0x00000001U /* Interface is up */ +#define INTERFACE_F_POINTTOPOINT 0x00000002U /*this is point-to-point interface*/ +#define INTERFACE_F_LOOPBACK 0x00000004U /* this is loopback interface */ +#define INTERFACE_F_BROADCAST 0x00000008U /* Broadcast is supported */ +#define INTERFACE_F_MULTICAST 0x00000010U /* multicast is supported */ + +/*** + *** Functions + ***/ + +ISC_LANG_BEGINDECLS + +isc_result_t +isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp); +/* + * Create an iterator for traversing the operating system's list + * of network interfaces. + * + * Returns: + * ISC_R_SUCCESS + * ISC_R_NOMEMORY + * Various network-related errors + */ + +isc_result_t +isc_interfaceiter_first(isc_interfaceiter_t *iter); +/* + * Position the iterator on the first interface. + * + * Returns: + * ISC_R_SUCCESS Success. + * ISC_R_NOMORE There are no interfaces. + */ + +isc_result_t +isc_interfaceiter_current(isc_interfaceiter_t *iter, + isc_interface_t *ifdata); +/* + * Get information about the interface the iterator is currently + * positioned at and store it at *ifdata. + * + * Requires: + * The iterator has been successfully positioned using + * isc_interface_iter_first() / isc_interface_iter_next(). + * + * Returns: + * ISC_R_SUCCESS Success. + */ + +isc_result_t +isc_interfaceiter_next(isc_interfaceiter_t *iter); +/* + * Position the iterator on the next interface. + * + * Requires: + * The iterator has been successfully positioned using + * isc_interface_iter_first() / isc_interface_iter_next(). + * + * Returns: + * ISC_R_SUCCESS Success. + * ISC_R_NOMORE There are no more interfaces. + */ + +void +isc_interfaceiter_destroy(isc_interfaceiter_t **iterp); +/* + * Destroy the iterator. + */ + +ISC_LANG_ENDDECLS + +#endif /* ISC_INTERFACEITER_H */ diff --git a/contrib/ntp/include/isc/ipv6.h b/contrib/ntp/include/isc/ipv6.h new file mode 100644 index 000000000000..18893b7003ce --- /dev/null +++ b/contrib/ntp/include/isc/ipv6.h @@ -0,0 +1,153 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: ipv6.h,v 1.19 2002/04/03 06:38:33 marka Exp $ */ + +#ifndef ISC_IPV6_H +#define ISC_IPV6_H 1 + +/* + * Also define LWRES_IPV6_H to keep it from being included if liblwres is + * being used, or redefinition errors will occur. + */ +#define LWRES_IPV6_H 1 + +/***** + ***** Module Info + *****/ + +/* + * IPv6 definitions for systems which do not support IPv6. + * + * MP: + * No impact. + * + * Reliability: + * No anticipated impact. + * + * Resources: + * N/A. + * + * Security: + * No anticipated impact. + * + * Standards: + * RFC 2553. + */ + +/*** + *** Imports. + ***/ + +#include <isc/int.h> +#include <isc/platform.h> + +/* + * We probably don't need this on NTP + */ +#ifdef ISC_ONLY_IPV6 +/*** + *** Types. + ***/ + +struct in6_addr { + union { + isc_uint8_t _S6_u8[16]; + isc_uint16_t _S6_u16[8]; + isc_uint32_t _S6_u32[4]; + } _S6_un; +}; +#define s6_addr _S6_un._S6_u8 +#define s6_addr8 _S6_un._S6_u8 +#define s6_addr16 _S6_un._S6_u16 +#define s6_addr32 _S6_un._S6_u32 + +#define IN6ADDR_ANY_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}} +#define IN6ADDR_LOOPBACK_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}} + +LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_any; +LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_loopback; + +struct sockaddr_in6 { +#ifdef ISC_PLATFORM_HAVESALEN + isc_uint8_t sin6_len; + isc_uint8_t sin6_family; +#else + isc_uint16_t sin6_family; +#endif + isc_uint16_t sin6_port; + isc_uint32_t sin6_flowinfo; + struct in6_addr sin6_addr; + isc_uint32_t sin6_scope_id; +}; + +#ifdef ISC_PLATFORM_HAVESALEN +#define SIN6_LEN 1 +#endif + +/* + * Unspecified + */ +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + (((a)->s6_addr32[0] == 0) && \ + ((a)->s6_addr32[1] == 0) && \ + ((a)->s6_addr32[2] == 0) && \ + ((a)->s6_addr32[3] == 0)) + +/* + * Loopback + */ +#define IN6_IS_ADDR_LOOPBACK(a) \ + (((a)->s6_addr32[0] == 0) && \ + ((a)->s6_addr32[1] == 0) && \ + ((a)->s6_addr32[2] == 0) && \ + ((a)->s6_addr32[3] == htonl(1))) + +/* + * IPv4 compatible + */ +#define IN6_IS_ADDR_V4COMPAT(a) \ + (((a)->s6_addr32[0] == 0) && \ + ((a)->s6_addr32[1] == 0) && \ + ((a)->s6_addr32[2] == 0) && \ + ((a)->s6_addr32[3] != 0) && \ + ((a)->s6_addr32[3] != htonl(1))) + +/* + * Mapped + */ +#define IN6_IS_ADDR_V4MAPPED(a) \ + (((a)->s6_addr32[0] == 0) && \ + ((a)->s6_addr32[1] == 0) && \ + ((a)->s6_addr32[2] == htonl(0x0000ffff))) + +/* + * Multicast + */ +#define IN6_IS_ADDR_MULTICAST(a) \ + ((a)->s6_addr8[0] == 0xffU) + +/* + * Unicast link / site local. + */ +#define IN6_IS_ADDR_LINKLOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) +#define IN6_IS_ADDR_SITELOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) + +#endif /* ISC_ONLY_IPV6 */ +#endif /* ISC_IPV6_H */ diff --git a/contrib/ntp/include/isc/lang.h b/contrib/ntp/include/isc/lang.h new file mode 100644 index 000000000000..b3ba5908fe14 --- /dev/null +++ b/contrib/ntp/include/isc/lang.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: lang.h,v 1.6 2001/01/09 21:57:03 bwelling Exp $ */ + +#ifndef ISC_LANG_H +#define ISC_LANG_H 1 + +#ifdef __cplusplus +#define ISC_LANG_BEGINDECLS extern "C" { +#define ISC_LANG_ENDDECLS } +#else +#define ISC_LANG_BEGINDECLS +#define ISC_LANG_ENDDECLS +#endif + +#endif /* ISC_LANG_H */ diff --git a/contrib/ntp/include/isc/lib.h b/contrib/ntp/include/isc/lib.h new file mode 100644 index 000000000000..7feef43c5ebe --- /dev/null +++ b/contrib/ntp/include/isc/lib.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: lib.h,v 1.7 2001/11/19 03:08:25 mayer Exp $ */ + +#ifndef ISC_LIB_H +#define ISC_LIB_H 1 + +#include <isc/types.h> +#include <isc/lang.h> + +ISC_LANG_BEGINDECLS + +LIBISC_EXTERNAL_DATA extern isc_msgcat_t *isc_msgcat; + +void +isc_lib_initmsgcat(void); +/* + * Initialize the ISC library's message catalog, isc_msgcat, if it + * has not already been initialized. + */ + +ISC_LANG_ENDDECLS + +#endif /* ISC_LIB_H */ diff --git a/contrib/ntp/include/isc/list.h b/contrib/ntp/include/isc/list.h new file mode 100644 index 000000000000..d0ae7a91a6f3 --- /dev/null +++ b/contrib/ntp/include/isc/list.h @@ -0,0 +1,180 @@ +/* + * Copyright (C) 1997-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: list.h,v 1.19 2002/05/09 07:09:30 marka Exp $ */ + +#ifndef ISC_LIST_H +#define ISC_LIST_H 1 +#include <isc/boolean.h> +#include <isc/assertions.h> + +#ifdef ISC_LIST_CHECKINIT +#define ISC_LINK_INSIST(x) ISC_INSIST(x) +#else +#define ISC_LINK_INSIST(x) +#endif + +#define ISC_LIST(type) struct { type *head, *tail; } +#define ISC_LIST_INIT(list) \ + do { (list).head = NULL; (list).tail = NULL; } while (0) + +#define ISC_LINK(type) struct { type *prev, *next; } +#define ISC_LINK_INIT_TYPE(elt, link, type) \ + do { \ + (elt)->link.prev = (type *)(-1); \ + (elt)->link.next = (type *)(-1); \ + } while (0) +#define ISC_LINK_INIT(elt, link) \ + ISC_LINK_INIT_TYPE(elt, link, void) +#define ISC_LINK_LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1)) + +#define ISC_LIST_HEAD(list) ((list).head) +#define ISC_LIST_TAIL(list) ((list).tail) +#define ISC_LIST_EMPTY(list) ISC_TF((list).head == NULL) + +#define __ISC_LIST_PREPENDUNSAFE(list, elt, link) \ + do { \ + if ((list).head != NULL) \ + (list).head->link.prev = (elt); \ + else \ + (list).tail = (elt); \ + (elt)->link.prev = NULL; \ + (elt)->link.next = (list).head; \ + (list).head = (elt); \ + } while (0) + +#define ISC_LIST_PREPEND(list, elt, link) \ + do { \ + ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \ + __ISC_LIST_PREPENDUNSAFE(list, elt, link); \ + } while (0) + +#define ISC_LIST_INITANDPREPEND(list, elt, link) \ + __ISC_LIST_PREPENDUNSAFE(list, elt, link) + +#define __ISC_LIST_APPENDUNSAFE(list, elt, link) \ + do { \ + if ((list).tail != NULL) \ + (list).tail->link.next = (elt); \ + else \ + (list).head = (elt); \ + (elt)->link.prev = (list).tail; \ + (elt)->link.next = NULL; \ + (list).tail = (elt); \ + } while (0) + +#define ISC_LIST_APPEND(list, elt, link) \ + do { \ + ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \ + __ISC_LIST_APPENDUNSAFE(list, elt, link); \ + } while (0) + +#define ISC_LIST_INITANDAPPEND(list, elt, link) \ + __ISC_LIST_APPENDUNSAFE(list, elt, link) + +#define __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, type) \ + do { \ + if ((elt)->link.next != NULL) \ + (elt)->link.next->link.prev = (elt)->link.prev; \ + else \ + (list).tail = (elt)->link.prev; \ + if ((elt)->link.prev != NULL) \ + (elt)->link.prev->link.next = (elt)->link.next; \ + else \ + (list).head = (elt)->link.next; \ + (elt)->link.prev = (type *)(-1); \ + (elt)->link.next = (type *)(-1); \ + } while (0) + +#define __ISC_LIST_UNLINKUNSAFE(list, elt, link) \ + __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, void) + +#define ISC_LIST_UNLINK_TYPE(list, elt, link, type) \ + do { \ + ISC_LINK_INSIST(ISC_LINK_LINKED(elt, link)); \ + __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, type); \ + } while (0) +#define ISC_LIST_UNLINK(list, elt, link) \ + ISC_LIST_UNLINK_TYPE(list, elt, link, void) + +#define ISC_LIST_PREV(elt, link) ((elt)->link.prev) +#define ISC_LIST_NEXT(elt, link) ((elt)->link.next) + +#define __ISC_LIST_INSERTBEFOREUNSAFE(list, before, elt, link) \ + do { \ + if ((before)->link.prev == NULL) \ + ISC_LIST_PREPEND(list, elt, link); \ + else { \ + (elt)->link.prev = (before)->link.prev; \ + (before)->link.prev = (elt); \ + (elt)->link.prev->link.next = (elt); \ + (elt)->link.next = (before); \ + } \ + } while (0) + +#define ISC_LIST_INSERTBEFORE(list, before, elt, link) \ + do { \ + ISC_LINK_INSIST(ISC_LINK_LINKED(before, link)); \ + ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \ + __ISC_LIST_INSERTBEFOREUNSAFE(list, before, elt, link); \ + } while (0) + +#define __ISC_LIST_INSERTAFTERUNSAFE(list, after, elt, link) \ + do { \ + if ((after)->link.next == NULL) \ + ISC_LIST_APPEND(list, elt, link); \ + else { \ + (elt)->link.next = (after)->link.next; \ + (after)->link.next = (elt); \ + (elt)->link.next->link.prev = (elt); \ + (elt)->link.prev = (after); \ + } \ + } while (0) + +#define ISC_LIST_INSERTAFTER(list, after, elt, link) \ + do { \ + ISC_LINK_INSIST(ISC_LINK_LINKED(after, link)); \ + ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \ + __ISC_LIST_INSERTAFTERUNSAFE(list, after, elt, link); \ + } while (0) + +#define ISC_LIST_APPENDLIST(list1, list2, link) \ + do { \ + if (ISC_LIST_EMPTY(list1)) \ + (list1) = (list2); \ + else if (!ISC_LIST_EMPTY(list2)) { \ + (list1).tail->link.next = (list2).head; \ + (list2).head->link.prev = (list1).tail; \ + (list1).tail = (list2).tail; \ + } \ + (list2).head = NULL; \ + (list2).tail = NULL; \ + } while (0) + +#define ISC_LIST_ENQUEUE(list, elt, link) ISC_LIST_APPEND(list, elt, link) +#define __ISC_LIST_ENQUEUEUNSAFE(list, elt, link) \ + __ISC_LIST_APPENDUNSAFE(list, elt, link) +#define ISC_LIST_DEQUEUE(list, elt, link) \ + ISC_LIST_UNLINK_TYPE(list, elt, link, void) +#define ISC_LIST_DEQUEUE_TYPE(list, elt, link, type) \ + ISC_LIST_UNLINK_TYPE(list, elt, link, type) +#define __ISC_LIST_DEQUEUEUNSAFE(list, elt, link) \ + __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, void) +#define __ISC_LIST_DEQUEUEUNSAFE_TYPE(list, elt, link, type) \ + __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, type) + +#endif /* ISC_LIST_H */ diff --git a/contrib/ntp/include/isc/magic.h b/contrib/ntp/include/isc/magic.h new file mode 100644 index 000000000000..ff3df24bdfc8 --- /dev/null +++ b/contrib/ntp/include/isc/magic.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: magic.h,v 1.11 2001/01/09 21:57:10 bwelling Exp $ */ + +#ifndef ISC_MAGIC_H +#define ISC_MAGIC_H 1 + +typedef struct { + unsigned int magic; +} isc__magic_t; + + +/* + * To use this macro the magic number MUST be the first thing in the + * structure, and MUST be of type "unsigned int". + * + * The intent of this is to allow magic numbers to be checked even though + * the object is otherwise opaque. + */ +#define ISC_MAGIC_VALID(a,b) (((a) != NULL) && \ + (((const isc__magic_t *)(a))->magic == (b))) + +#define ISC_MAGIC(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d)) + +#endif /* ISC_MAGIC_H */ diff --git a/contrib/ntp/include/isc/mem.h b/contrib/ntp/include/isc/mem.h new file mode 100644 index 000000000000..f8e73d0e73d8 --- /dev/null +++ b/contrib/ntp/include/isc/mem.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 1997-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: mem.h,v 1.58 2001/09/07 00:51:51 marka Exp $ */ + +#ifndef ISC_MEM_H +#define ISC_MEM_H 1 + +#include <stdio.h> +#include <isc/types.h> + +void * +isc_mem_get(isc_mem_t *, size_t); +void +isc_mem_put(isc_mem_t *, void *, size_t); + +#endif /* ISC_MEM_H */ diff --git a/contrib/ntp/include/isc/msgcat.h b/contrib/ntp/include/isc/msgcat.h new file mode 100644 index 000000000000..d2bf1e1622d9 --- /dev/null +++ b/contrib/ntp/include/isc/msgcat.h @@ -0,0 +1,132 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: msgcat.h,v 1.8 2001/01/09 21:57:13 bwelling Exp $ */ + +#ifndef ISC_MSGCAT_H +#define ISC_MSGCAT_H 1 + +/***** + ***** Module Info + *****/ + +/* + * ISC Message Catalog + * + * Message catalogs aid internationalization of applications by allowing + * messages to be retrieved from locale-specific files instead of + * hardwiring them into the application. This allows translations of + * messages appropriate to the locale to be supplied without recompiling + * the application. + * + * Notes: + * It's very important that message catalogs work, even if only the + * default_text can be used. + * + * MP: + * The caller must ensure appropriate synchronization of + * isc_msgcat_open() and isc_msgcat_close(). isc_msgcat_get() + * ensures appropriate synchronization. + * + * Reliability: + * No anticipated impact. + * + * Resources: + * <TBS> + * + * Security: + * No anticipated impact. + * + * Standards: + * None. + */ + +/***** + ***** Imports + *****/ + +#include <isc/lang.h> +#include <isc/types.h> + +ISC_LANG_BEGINDECLS + +/***** + ***** Methods + *****/ + +void +isc_msgcat_open(const char *name, isc_msgcat_t **msgcatp); +/* + * Open a message catalog. + * + * Notes: + * + * If memory cannot be allocated or other failures occur, *msgcatp + * will be set to NULL. If a NULL msgcat is given to isc_msgcat_get(), + * the default_text will be returned, ensuring that some message text + * will be available, no matter what's going wrong. + * + * Requires: + * + * 'name' is a valid string. + * + * msgcatp != NULL && *msgcatp == NULL + */ + +void +isc_msgcat_close(isc_msgcat_t **msgcatp); +/* + * Close a message catalog. + * + * Notes: + * + * Any string pointers returned by prior calls to isc_msgcat_get() are + * invalid after isc_msgcat_close() has been called and must not be + * used. + * + * Requires: + * + * *msgcatp is a valid message catalog or is NULL. + * + * Ensures: + * + * All resources associated with the message catalog are released. + * + * *msgcatp == NULL + */ + +const char * +isc_msgcat_get(isc_msgcat_t *msgcat, int set, int message, + const char *default_text); +/* + * Get message 'message' from message set 'set' in 'msgcat'. If it + * is not available, use 'default_text'. + * + * Requires: + * + * 'msgcat' is a valid message catalog or is NULL. + * + * set > 0 + * + * message > 0 + * + * 'default_text' is a valid string. + */ + +ISC_LANG_ENDDECLS + +#endif /* ISC_MSGCAT_H */ diff --git a/contrib/ntp/include/isc/msgs.h b/contrib/ntp/include/isc/msgs.h new file mode 100644 index 000000000000..b166199e8f0d --- /dev/null +++ b/contrib/ntp/include/isc/msgs.h @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2000, 2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: msgs.h,v 1.7 2002/05/27 00:40:18 marka Exp $ */ + +#ifndef ISC_MSGS_H +#define ISC_MSGS_H 1 + +#include <isc/lib.h> /* Provide isc_msgcat global variable. */ +#include <isc/msgcat.h> /* Provide isc_msgcat_*() functions. */ + +/* + * Message sets, named per source file, excepting "GENERAL". + * IMPORTANT: The original list is alphabetical, but any new sets must + * be added to the end. + */ +#define ISC_MSGSET_GENERAL 1 +/* ISC_RESULT_RESULTSET 2 */ /* XXX */ +/* ISC_RESULT_UNAVAILABLESET 3 */ /* XXX */ +#define ISC_MSGSET_APP 4 +#define ISC_MSGSET_COMMANDLINE 5 +#define ISC_MSGSET_ENTROPY 6 +#define ISC_MSGSET_IFITERIOCTL 7 +#define ISC_MSGSET_IFITERSYSCTL 8 +#define ISC_MSGSET_LEX 9 +#define ISC_MSGSET_LOG 10 +#define ISC_MSGSET_MEM 11 +#define ISC_MSGSET_NETADDR 12 +#define ISC_MSGSET_PRINT 13 +#define ISC_MSGSET_RESULT 14 +#define ISC_MSGSET_RWLOCK 15 +#define ISC_MSGSET_SOCKADDR 16 +#define ISC_MSGSET_SOCKET 17 +#define ISC_MSGSET_TASK 18 +#define ISC_MSGSET_TIMER 19 +#define ISC_MSGSET_UTIL 20 + +/* + * Message numbers. They are only required to be unique per message set, + * but are unique throughout the entire catalog to not be as confusing when + * debugging. + * + * The initial numbering was done by multiply by 100 the set number the + * message appears in then adding the incremental message number. + */ +#define ISC_MSG_FAILED 101 /* "failed" */ +#define ISC_MSG_SUCCEEDED 102 /* Compatible with "failed" */ +#define ISC_MSG_SUCCESS 103 /* More usual way to say "success" */ +#define ISC_MSG_STARTING 104 /* As in "daemon: starting" */ +#define ISC_MSG_STOPING 105 /* As in "daemon: stopping" */ +#define ISC_MSG_ENTERING 106 /* As in "some_subr: entering" */ +#define ISC_MSG_EXITING 107 /* As in "some_subr: exiting" */ +#define ISC_MSG_CALLING 108 /* As in "calling some_subr()" */ +#define ISC_MSG_RETURNED 109 /* As in "some_subr: returned <foo>" */ +#define ISC_MSG_FATALERROR 110 /* "fatal error" */ +#define ISC_MSG_SHUTTINGDOWN 111 /* "shutting down" */ +#define ISC_MSG_RUNNING 112 /* "running" */ +#define ISC_MSG_WAIT 113 /* "wait" */ +#define ISC_MSG_WAITUNTIL 114 /* "waituntil" */ + +#define ISC_MSG_SIGNALSETUP 201 /* "handle_signal() %d setup: %s" */ + +#define ISC_MSG_ILLEGALOPT 301 /* "illegal option" */ +#define ISC_MSG_OPTNEEDARG 302 /* "option requires an argument" */ + +#define ISC_MSG_ENTROPYSTATS 401 /* "Entropy pool %p: refcnt %u ..." */ + +#define ISC_MSG_MAKESCANSOCKET 501 /* "making interface scan socket: %s" */ +#define ISC_MSG_GETIFCONFIG 502 /* "get interface configuration: %s" */ +#define ISC_MSG_BUFFERMAX 503 /* "... maximum buffer size exceeded" */ +#define ISC_MSG_GETDESTADDR 504 /* "%s: getting destination address: %s" */ +#define ISC_MSG_GETNETMASK 505 /* "%s: getting netmask: %s" */ + +#define ISC_MSG_GETIFLISTSIZE 601 /* "getting interface list size: ..." */ +#define ISC_MSG_GETIFLIST 602 /* "getting interface list: ..." */ +#define ISC_MSG_UNEXPECTEDTYPE 603 /* "... unexpected ... message type" */ + +#define ISC_MSG_UNEXPECTEDSTATE 701 /* "Unexpected state %d" */ + +#define ISC_MSG_BADTIME 801 /* "Bad 00 99:99:99.999 " */ +#define ISC_MSG_LEVEL 802 /* "level %d: " */ + +#define ISC_MSG_ADDTRACE 901 /* "add %p size %u " */ +#define ISC_MSG_DELTRACE 902 /* "del %p size %u " */ +#define ISC_MSG_POOLSTATS 903 /* "[Pool statistics]\n" */ +#define ISC_MSG_POOLNAME 904 /* "name" */ +#define ISC_MSG_POOLSIZE 905 /* "size" */ +#define ISC_MSG_POOLMAXALLOC 906 /* "maxalloc" */ +#define ISC_MSG_POOLALLOCATED 907 /* "allocated" */ +#define ISC_MSG_POOLFREECOUNT 908 /* "freecount" */ +#define ISC_MSG_POOLFREEMAX 909 /* "freemax" */ +#define ISC_MSG_POOLFILLCOUNT 910 /* "fillcount" */ +#define ISC_MSG_POOLGETS 911 /* "gets" */ +#define ISC_MSG_DUMPALLOC 912 /* "DUMP OF ALL OUTSTANDING MEMORY ..." */ +#define ISC_MSG_NONE 913 /* "\tNone.\n" */ +#define ISC_MSG_PTRFILELINE 914 /* "\tptr %p file %s line %u\n" */ + +#define ISC_MSG_UNKNOWNADDR 1001 /* "<unknown address, family %u>" */ + +#define ISC_MSG_NOLONGDBL 1104 /* "long doubles are not supported" */ + +#define ISC_MSG_PRINTLOCK 1201 /* "rwlock %p thread %lu ..." */ +#define ISC_MSG_READ 1202 /* "read" */ +#define ISC_MSG_WRITE 1203 /* "write" */ +#define ISC_MSG_READING 1204 /* "reading" */ +#define ISC_MSG_WRITING 1205 /* "writing" */ +#define ISC_MSG_PRELOCK 1206 /* "prelock" */ +#define ISC_MSG_POSTLOCK 1207 /* "postlock" */ +#define ISC_MSG_PREUNLOCK 1208 /* "preunlock" */ +#define ISC_MSG_POSTUNLOCK 1209 /* "postunlock" */ + +#define ISC_MSG_UNKNOWNFAMILY 1301 /* "unknown address family: %d" */ + +#define ISC_MSG_WRITEFAILED 1401 /* "write() failed during watcher ..." */ +#define ISC_MSG_READFAILED 1402 /* "read() failed during watcher ... " */ +#define ISC_MSG_PROCESSCMSG 1403 /* "processing cmsg %p" */ +#define ISC_MSG_IFRECEIVED 1404 /* "interface received on ifindex %u" */ +#define ISC_MSG_SENDTODATA 1405 /* "sendto pktinfo data, ifindex %u" */ +#define ISC_MSG_DOIORECV 1406 /* "doio_recv: recvmsg(%d) %d bytes ..." */ +#define ISC_MSG_PKTRECV 1407 /* "packet received correctly" */ +#define ISC_MSG_DESTROYING 1408 /* "destroying" */ +#define ISC_MSG_CREATED 1409 /* "created" */ +#define ISC_MSG_ACCEPTLOCK 1410 /* "internal_accept called, locked ..." */ +#define ISC_MSG_ACCEPTEDCXN 1411 /* "accepted connection, new socket %p" */ +#define ISC_MSG_INTERNALRECV 1412 /* "internal_recv: task %p got event %p" */ +#define ISC_MSG_INTERNALSEND 1413 /* "internal_send: task %p got event %p" */ +#define ISC_MSG_WATCHERMSG 1414 /* "watcher got message %d" */ +#define ISC_MSG_SOCKETSREMAIN 1415 /* "sockets exist" */ +#define ISC_MSG_PKTINFOPROVIDED 1416 /* "pktinfo structure provided, ..." */ +#define ISC_MSG_BOUND 1417 /* "bound" */ +#define ISC_MSG_ACCEPTRETURNED 1418 /* accept() returned %d/%s */ +#define ISC_MSG_TOOMANYFDS 1419 /* %s: too many open file descriptors */ +#define ISC_MSG_ZEROPORT 1420 /* dropping source port zero packet */ +#define ISC_MSG_FILTER 1420 /* setsockopt(SO_ACCEPTFILTER): %s */ + +#define ISC_MSG_AWAKE 1502 /* "awake" */ +#define ISC_MSG_WORKING 1503 /* "working" */ +#define ISC_MSG_EXECUTE 1504 /* "execute action" */ +#define ISC_MSG_EMPTY 1505 /* "empty" */ +#define ISC_MSG_DONE 1506 /* "done" */ +#define ISC_MSG_QUANTUM 1507 /* "quantum" */ + +#define ISC_MSG_SCHEDULE 1601 /* "schedule" */ +#define ISC_MSG_SIGNALSCHED 1602 /* "signal (schedule)" */ +#define ISC_MSG_SIGNALDESCHED 1603 /* "signal (deschedule)" */ +#define ISC_MSG_SIGNALDESTROY 1604 /* "signal (destroy)" */ +#define ISC_MSG_IDLERESCHED 1605 /* "idle reschedule" */ +#define ISC_MSG_EVENTNOTALLOC 1606 /* "couldn't allocate event" */ +#define ISC_MSG_SCHEDFAIL 1607 /* "couldn't schedule timer: %u" */ +#define ISC_MSG_POSTING 1608 /* "posting" */ +#define ISC_MSG_WAKEUP 1609 /* "wakeup" */ + +#define ISC_MSG_LOCK 1701 /* "LOCK" */ +#define ISC_MSG_LOCKING 1702 /* "LOCKING" */ +#define ISC_MSG_LOCKED 1703 /* "LOCKED" */ +#define ISC_MSG_UNLOCKED 1704 /* "UNLOCKED" */ +#define ISC_MSG_RWLOCK 1705 /* "RWLOCK" */ +#define ISC_MSG_RWLOCKED 1706 /* "RWLOCKED" */ +#define ISC_MSG_RWUNLOCK 1707 /* "RWUNLOCK" */ +#define ISC_MSG_BROADCAST 1708 /* "BROADCAST" */ +#define ISC_MSG_SIGNAL 1709 /* "SIGNAL" */ +#define ISC_MSG_UTILWAIT 1710 /* "WAIT" */ +#define ISC_MSG_WAITED 1711 /* "WAITED" */ + + + +#endif /* ISC_MSGS_H */ diff --git a/contrib/ntp/include/isc/mutex.h b/contrib/ntp/include/isc/mutex.h new file mode 100644 index 000000000000..fd6f3ec5ea1a --- /dev/null +++ b/contrib/ntp/include/isc/mutex.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2000, 2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: mutex.h,v 1.3 2001/01/09 21:57:55 bwelling Exp $ */ + +#ifndef ISC_MUTEX_H +#define ISC_MUTEX_H 1 + +#include <isc/result.h> /* for ISC_R_ codes */ + +typedef int isc_mutex_t; + +#define isc_mutex_init(mp) \ + (*(mp) = 0, ISC_R_SUCCESS) +#define isc_mutex_lock(mp) \ + ((*(mp))++ == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED) +#define isc_mutex_unlock(mp) \ + (--(*(mp)) == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED) +#define isc_mutex_trylock(mp) \ + (*(mp) == 0 ? ((*(mp))++, ISC_R_SUCCESS) : ISC_R_LOCKBUSY) +#define isc_mutex_destroy(mp) \ + (*(mp) == 0 ? (*(mp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED) +#define isc_mutex_stats(fp) + +#endif /* ISC_MUTEX_H */ diff --git a/contrib/ntp/include/isc/net.h b/contrib/ntp/include/isc/net.h new file mode 100644 index 000000000000..25924febca38 --- /dev/null +++ b/contrib/ntp/include/isc/net.h @@ -0,0 +1,284 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: net.h,v 1.34 2002/04/03 06:38:38 marka Exp $ */ + +#ifndef ISC_NET_H +#define ISC_NET_H 1 + +/***** + ***** Module Info + *****/ + +/* + * Basic Networking Types + * + * This module is responsible for defining the following basic networking + * types: + * + * struct in_addr + * struct in6_addr + * struct in6_pktinfo + * struct sockaddr + * struct sockaddr_in + * struct sockaddr_in6 + * in_port_t + * + * It ensures that the AF_ and PF_ macros are defined. + * + * It declares ntoh[sl]() and hton[sl](). + * + * It declares inet_aton(), inet_ntop(), and inet_pton(). + * + * It ensures that INADDR_LOOPBACK, INADDR_ANY, IN6ADDR_ANY_INIT, + * in6addr_any, and in6addr_loopback are available. + * + * It ensures that IN_MULTICAST() is available to check for multicast + * addresses. + * + * MP: + * No impact. + * + * Reliability: + * No anticipated impact. + * + * Resources: + * N/A. + * + * Security: + * No anticipated impact. + * + * Standards: + * BSD Socket API + * RFC 2553 + */ + +/*** + *** Imports. + ***/ +#include <isc/platform.h> + +#include <sys/types.h> +#include <sys/socket.h> /* Contractual promise. */ + +#include <netinet/in.h> /* Contractual promise. */ +#include <arpa/inet.h> /* Contractual promise. */ +#ifdef ISC_PLATFORM_NEEDNETINETIN6H +#include <netinet/in6.h> /* Required on UnixWare. */ +#endif +#ifdef ISC_PLATFORM_NEEDNETINET6IN6H +#include <netinet6/in6.h> /* Required on BSD/OS for in6_pktinfo. */ +#endif + +#ifndef ISC_PLATFORM_HAVEIPV6 +#include <isc/ipv6.h> /* Contractual promise. */ +#endif + +#include <isc/lang.h> +#include <isc/types.h> + +#ifdef ISC_PLATFORM_HAVEINADDR6 +#define in6_addr in_addr6 /* Required for pre RFC2133 implementations. */ +#endif + +#ifdef ISC_PLATFORM_HAVEIPV6 +/* + * Required for some pre RFC2133 implementations. + * IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT were added in + * draft-ietf-ipngwg-bsd-api-04.txt or draft-ietf-ipngwg-bsd-api-05.txt. + * If 's6_addr' is defined then assume that there is a union and three + * levels otherwise assume two levels required. + */ +#ifndef IN6ADDR_ANY_INIT +#ifdef s6_addr +#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } } +#else +#define IN6ADDR_ANY_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } +#endif +#endif + +#ifndef IN6ADDR_LOOPBACK_INIT +#ifdef s6_addr +#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } } +#else +#define IN6ADDR_LOOPBACK_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } +#endif +#endif + +#ifndef IN6_IS_ADDR_V4MAPPED +#define IN6_IS_ADDR_V4MAPPED(x) \ + (memcmp((x)->s6_addr, in6addr_any.s6_addr, 10) == 0 && \ + (x)->s6_addr[10] == 0xff && (x)->s6_addr[11] == 0xff) +#endif + +#ifndef IN6_IS_ADDR_V4COMPAT +#define IN6_IS_ADDR_V4COMPAT(x) \ + (memcmp((x)->s6_addr, in6addr_any.s6_addr, 12) == 0 && \ + ((x)->s6_addr[12] != 0 || (x)->s6_addr[13] != 0 || \ + (x)->s6_addr[14] != 0 || \ + ((x)->s6_addr[15] != 0 && (x)->s6_addr[15] != 1))) +#endif + +#ifndef IN6_IS_ADDR_MULTICAST +#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) +#endif + +#ifndef IN6_IS_ADDR_LINKLOCAL +#define IN6_IS_ADDR_LINKLOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) +#endif + +#ifndef IN6_IS_ADDR_SITELOCAL +#define IN6_IS_ADDR_SITELOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) +#endif + + +#ifndef IN6_IS_ADDR_LOOPBACK +#define IN6_IS_ADDR_LOOPBACK(x) \ + (memcmp((x)->s6_addr, in6addr_loopback.s6_addr, 16) == 0) +#endif +#endif + +#ifndef AF_INET6 +#define AF_INET6 99 +#endif + +#ifndef PF_INET6 +#define PF_INET6 AF_INET6 +#endif + +#ifndef INADDR_LOOPBACK +#define INADDR_LOOPBACK 0x7f000001UL +#endif + +#if 0 +#ifndef ISC_PLATFORM_HAVEIN6PKTINFO +struct in6_pktinfo { + struct in6_addr ipi6_addr; /* src/dst IPv6 address */ + unsigned int ipi6_ifindex; /* send/recv interface index */ +}; +#endif +#endif + +/* + * Cope with a missing in6addr_any and in6addr_loopback. + */ +#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY) +extern const struct in6_addr isc_net_in6addrany; +#define in6addr_any isc_net_in6addrany +#endif + +#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK) +extern const struct in6_addr isc_net_in6addrloop; +#define in6addr_loopback isc_net_in6addrloop +#endif + +/* + * Fix UnixWare 7.1.1's broken IN6_IS_ADDR_* definitions. + */ +#ifdef ISC_PLATFORM_FIXIN6ISADDR +#undef IN6_IS_ADDR_GEOGRAPHIC +#define IN6_IS_ADDR_GEOGRAPHIC(a) (((a)->S6_un.S6_l[0] & 0xE0) == 0x80) +#undef IN6_IS_ADDR_IPX +#define IN6_IS_ADDR_IPX(a) (((a)->S6_un.S6_l[0] & 0xFE) == 0x04) +#undef IN6_IS_ADDR_LINKLOCAL +#define IN6_IS_ADDR_LINKLOCAL(a) (((a)->S6_un.S6_l[0] & 0xC0FF) == 0x80FE) +#undef IN6_IS_ADDR_MULTICAST +#define IN6_IS_ADDR_MULTICAST(a) (((a)->S6_un.S6_l[0] & 0xFF) == 0xFF) +#undef IN6_IS_ADDR_NSAP +#define IN6_IS_ADDR_NSAP(a) (((a)->S6_un.S6_l[0] & 0xFE) == 0x02) +#undef IN6_IS_ADDR_PROVIDER +#define IN6_IS_ADDR_PROVIDER(a) (((a)->S6_un.S6_l[0] & 0xE0) == 0x40) +#undef IN6_IS_ADDR_SITELOCAL +#define IN6_IS_ADDR_SITELOCAL(a) (((a)->S6_un.S6_l[0] & 0xC0FF) == 0xC0FE) +#endif /* ISC_PLATFORM_FIXIN6ISADDR */ + +/* + * Ensure type in_port_t is defined. + */ +#ifdef ISC_PLATFORM_NEEDPORTT +typedef isc_uint16_t in_port_t; +#endif + +/* + * If this system does not have MSG_TRUNC (as returned from recvmsg()) + * ISC_PLATFORM_RECVOVERFLOW will be defined. This will enable the MSG_TRUNC + * faking code in socket.c. + */ +#ifndef MSG_TRUNC +#define ISC_PLATFORM_RECVOVERFLOW +#endif + +#define ISC__IPADDR(x) ((isc_uint32_t)htonl((isc_uint32_t)(x))) + +#define ISC_IPADDR_ISMULTICAST(i) \ + (((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \ + == ISC__IPADDR(0xe0000000)) + +/*** + *** Functions. + ***/ + +ISC_LANG_BEGINDECLS + +isc_result_t +isc_net_probeipv4(void); +/* + * Check if the system's kernel supports IPv4. + * + * Returns: + * + * ISC_R_SUCCESS IPv4 is supported. + * ISC_R_NOTFOUND IPv4 is not supported. + * ISC_R_UNEXPECTED + */ + +isc_result_t +isc_net_probeipv6(void); +/* + * Check if the system's kernel supports IPv6. + * + * Returns: + * + * ISC_R_SUCCESS IPv6 is supported. + * ISC_R_NOTFOUND IPv6 is not supported. + * ISC_R_UNEXPECTED + */ + +const char * +isc_net_ntop(int af, const void *src, char *dst, size_t size); +#ifdef ISC_PLATFORM_NEEDNTOP +#define inet_ntop isc_net_ntop +#endif + +int +isc_net_pton(int af, const char *src, void *dst); +#ifdef ISC_PLATFORM_NEEDPTON +#undef inet_pton +#define inet_pton isc_net_pton +#endif + +int +isc_net_aton(const char *cp, struct in_addr *addr); +#ifdef ISC_PLATFORM_NEEDATON +#define inet_aton isc_net_aton +#endif + +ISC_LANG_ENDDECLS + +#endif /* ISC_NET_H */ diff --git a/contrib/ntp/include/isc/netaddr.h b/contrib/ntp/include/isc/netaddr.h new file mode 100644 index 000000000000..811e8dd48e0c --- /dev/null +++ b/contrib/ntp/include/isc/netaddr.h @@ -0,0 +1,139 @@ +/* + * Copyright (C) 1998-2002 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: netaddr.h,v 1.21 2002/04/03 06:38:35 marka Exp $ */ + +#ifndef ISC_NETADDR_H +#define ISC_NETADDR_H 1 + +#include <isc/lang.h> +#include <isc/net.h> +#include <isc/types.h> +#include "ntp_rfc2553.h" + + + +ISC_LANG_BEGINDECLS + +struct isc_netaddr { + unsigned int family; + union { + struct in_addr in; + struct in6_addr in6; + } type; +}; + +isc_boolean_t +isc_netaddr_equal(const isc_netaddr_t *a, const isc_netaddr_t *b); + +isc_boolean_t +isc_netaddr_eqprefix(const isc_netaddr_t *a, const isc_netaddr_t *b, + unsigned int prefixlen); +/* + * Compare the 'prefixlen' most significant bits of the network + * addresses 'a' and 'b'. Return ISC_TRUE if they are equal, + * ISC_FALSE if not. + */ + +isc_result_t +isc_netaddr_masktoprefixlen(const isc_netaddr_t *s, unsigned int *lenp); +/* + * Convert a netmask in 's' into a prefix length in '*lenp'. + * The mask should consist of zero or more '1' bits in the most + * most significant part of the address, followed by '0' bits. + * If this is not the case, ISC_R_MASKNONCONTIG is returned. + * + * Returns: + * ISC_R_SUCCESS + * ISC_R_MASKNONCONTIG + */ + +isc_result_t +isc_netaddr_totext(const isc_netaddr_t *netaddr, isc_buffer_t *target); +/* + * Append a text representation of 'sockaddr' to the buffer 'target'. + * The text is NOT null terminated. Handles IPv4 and IPv6 addresses. + * + * Returns: + * ISC_R_SUCCESS + * ISC_R_NOSPACE The text or the null termination did not fit. + * ISC_R_FAILURE Unspecified failure + */ + +void +isc_netaddr_format(const isc_netaddr_t *na, char *array, unsigned int size); +/* + * Format a human-readable representation of the network address '*na' + * into the character array 'array', which is of size 'size'. + * The resulting string is guaranteed to be null-terminated. + */ + +#define ISC_NETADDR_FORMATSIZE \ + sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX") +/* + * Minimum size of array to pass to isc_netaddr_format(). + */ + +void +isc_netaddr_fromsockaddr(isc_netaddr_t *netaddr, const isc_sockaddr_t *source); + +void +isc_netaddr_fromin(isc_netaddr_t *netaddr, const struct in_addr *ina); + +void +isc_netaddr_fromin6(isc_netaddr_t *netaddr, const struct in6_addr *ina6); + +void +isc_netaddr_any(isc_netaddr_t *netaddr); +/* + * Return the IPv4 wildcard address. + */ + +void +isc_netaddr_any6(isc_netaddr_t *netaddr); +/* + * Return the IPv6 wildcard address. + */ + +isc_boolean_t +isc_netaddr_ismulticast(isc_netaddr_t *na); +/* + * Returns ISC_TRUE if the address is a multicast address. + */ + +isc_boolean_t +isc_netaddr_islinklocal(isc_netaddr_t *na); +/* + * Returns ISC_TRUE if the address is a link local address. + */ + +isc_boolean_t +isc_netaddr_issitelocal(isc_netaddr_t *na); +/* + * Returns ISC_TRUE if the address is a site local address. + */ + +void +isc_netaddr_fromv4mapped(isc_netaddr_t *t, const isc_netaddr_t *s); +/* + * Convert an IPv6 v4mapped address into an IPv4 address. + */ + + +ISC_LANG_ENDDECLS + +#endif /* ISC_NETADDR_H */ diff --git a/contrib/ntp/include/isc/offset.h b/contrib/ntp/include/isc/offset.h new file mode 100644 index 000000000000..709bde4e07be --- /dev/null +++ b/contrib/ntp/include/isc/offset.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2000, 2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: offset.h,v 1.10 2001/01/09 21:58:43 bwelling Exp $ */ + +#ifndef ISC_OFFSET_H +#define ISC_OFFSET_H 1 + +/* + * File offsets are operating-system dependent. + */ +#include <limits.h> /* Required for CHAR_BIT. */ +#include <sys/types.h> + +typedef off_t isc_offset_t; + +/* + * POSIX says "Additionally, blkcnt_t and off_t are extended signed integral + * types", so the maximum value is all 1s except for the high bit. + * This definition is more complex than it really needs to be because it was + * crafted to keep both the SunOS 5.6 and the HP/UX 11 compilers quiet about + * integer overflow. For example, though this is equivalent to just left + * shifting 1 to the high bit and then inverting the bits, the SunOS compiler + * is unhappy about shifting a positive "1" to negative in a signed integer. + */ +#define ISC_OFFSET_MAXIMUM \ + (~(((off_t)-1 >> (sizeof(off_t) * CHAR_BIT - 1)) \ + << (sizeof(off_t) * CHAR_BIT - 1))) + +#endif /* ISC_OFFSET_H */ diff --git a/contrib/ntp/include/isc/once.h b/contrib/ntp/include/isc/once.h new file mode 100644 index 000000000000..f57d6215fe3e --- /dev/null +++ b/contrib/ntp/include/isc/once.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2000, 2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: once.h,v 1.3 2001/01/09 21:57:56 bwelling Exp $ */ + +#ifndef ISC_ONCE_H +#define ISC_ONCE_H 1 + +#include <isc/result.h> + +typedef isc_boolean_t isc_once_t; + +#define ISC_ONCE_INIT ISC_FALSE + +#define isc_once_do(op, f) \ + (!*(op) ? (f(), *(op) = ISC_TRUE, ISC_R_SUCCESS) : ISC_R_SUCCESS) + +#endif /* ISC_ONCE_H */ diff --git a/contrib/ntp/include/isc/platform.h b/contrib/ntp/include/isc/platform.h new file mode 100644 index 000000000000..bd11a25503a5 --- /dev/null +++ b/contrib/ntp/include/isc/platform.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: platform.h.in,v 1.28 2001/11/19 03:08:26 mayer Exp $ */ + +#ifndef ISC_PLATFORM_H +#define ISC_PLATFORM_H 1 + + +#ifndef ISC_PLATFORM_USEDECLSPEC +#define LIBISC_EXTERNAL_DATA +#define LIBDNS_EXTERNAL_DATA +#define LIBISCCC_EXTERNAL_DATA +#define LIBISCCFG_EXTERNAL_DATA +#define LIBBIND9_EXTERNAL_DATA +#endif /* ISC_PLATFORM_USEDECLSPEC */ + +/* + * Tell emacs to use C mode for this file. + * + * Local Variables: + * mode: c + * End: + */ + +#endif /* ISC_PLATFORM_H */ diff --git a/contrib/ntp/include/isc/print.h b/contrib/ntp/include/isc/print.h new file mode 100644 index 000000000000..7a1bc83b6741 --- /dev/null +++ b/contrib/ntp/include/isc/print.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: print.h,v 1.17 2001/02/27 02:19:33 gson Exp $ */ + +#ifndef ISC_PRINT_H +#define ISC_PRINT_H 1 + +/*** + *** Imports + ***/ + +#include <isc/formatcheck.h> /* Required for ISC_FORMAT_PRINTF() macro. */ +#include <isc/lang.h> +#include <isc/platform.h> + +/* + * This block allows lib/isc/print.c to be cleanly compiled even if + * the platform does not need it. The standard Makefile will still + * not compile print.c or archive print.o, so this is just to make test + * compilation ("make print.o") easier. + */ +#if !defined(ISC_PLATFORM_NEEDVSNPRINTF) && defined(ISC__PRINT_SOURCE) +#define ISC_PLATFORM_NEEDVSNPRINTF +#endif + +/*** + *** Macros + ***/ +#define ISC_PRINT_QUADFORMAT ISC_PLATFORM_QUADFORMAT + +/*** + *** Functions + ***/ + +#ifdef ISC_PLATFORM_NEEDVSNPRINTF +#include <stdarg.h> +#include <stddef.h> + +ISC_LANG_BEGINDECLS + +int +isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) + ISC_FORMAT_PRINTF(3, 0); +#define vsnprintf isc_print_vsnprintf + +int +isc_print_snprintf(char *str, size_t size, const char *format, ...) + ISC_FORMAT_PRINTF(3, 4); +#define snprintf isc_print_snprintf + +ISC_LANG_ENDDECLS +#endif /* ISC_PLATFORM_NEEDVSNPRINTF */ + +#endif /* ISC_PRINT_H */ diff --git a/contrib/ntp/include/isc/result.h b/contrib/ntp/include/isc/result.h new file mode 100644 index 000000000000..bf6b99258732 --- /dev/null +++ b/contrib/ntp/include/isc/result.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 1998-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: result.h,v 1.59 2001/11/30 01:02:17 gson Exp $ */ + +#ifndef ISC_RESULT_H +#define ISC_RESULT_H 1 + +#include <isc/lang.h> +#include <isc/types.h> + +#define ISC_R_SUCCESS 0 /* success */ +#define ISC_R_NOMEMORY 1 /* out of memory */ +#define ISC_R_TIMEDOUT 2 /* timed out */ +#define ISC_R_NOTHREADS 3 /* no available threads */ +#define ISC_R_ADDRNOTAVAIL 4 /* address not available */ +#define ISC_R_ADDRINUSE 5 /* address in use */ +#define ISC_R_NOPERM 6 /* permission denied */ +#define ISC_R_NOCONN 7 /* no pending connections */ +#define ISC_R_NETUNREACH 8 /* network unreachable */ +#define ISC_R_HOSTUNREACH 9 /* host unreachable */ +#define ISC_R_NETDOWN 10 /* network down */ +#define ISC_R_HOSTDOWN 11 /* host down */ +#define ISC_R_CONNREFUSED 12 /* connection refused */ +#define ISC_R_NORESOURCES 13 /* not enough free resources */ +#define ISC_R_EOF 14 /* end of file */ +#define ISC_R_BOUND 15 /* socket already bound */ +#define ISC_R_RELOAD 16 /* reload */ +#define ISC_R_LOCKBUSY 17 /* lock busy */ +#define ISC_R_EXISTS 18 /* already exists */ +#define ISC_R_NOSPACE 19 /* ran out of space */ +#define ISC_R_CANCELED 20 /* operation canceled */ +#define ISC_R_NOTBOUND 21 /* socket is not bound */ +#define ISC_R_SHUTTINGDOWN 22 /* shutting down */ +#define ISC_R_NOTFOUND 23 /* not found */ +#define ISC_R_UNEXPECTEDEND 24 /* unexpected end of input */ +#define ISC_R_FAILURE 25 /* generic failure */ +#define ISC_R_IOERROR 26 /* I/O error */ +#define ISC_R_NOTIMPLEMENTED 27 /* not implemented */ +#define ISC_R_UNBALANCED 28 /* unbalanced parentheses */ +#define ISC_R_NOMORE 29 /* no more */ +#define ISC_R_INVALIDFILE 30 /* invalid file */ +#define ISC_R_BADBASE64 31 /* bad base64 encoding */ +#define ISC_R_UNEXPECTEDTOKEN 32 /* unexpected token */ +#define ISC_R_QUOTA 33 /* quota reached */ +#define ISC_R_UNEXPECTED 34 /* unexpected error */ +#define ISC_R_ALREADYRUNNING 35 /* already running */ +#define ISC_R_IGNORE 36 /* ignore */ +#define ISC_R_MASKNONCONTIG 37 /* addr mask not contiguous */ +#define ISC_R_FILENOTFOUND 38 /* file not found */ +#define ISC_R_FILEEXISTS 39 /* file already exists */ +#define ISC_R_NOTCONNECTED 40 /* socket is not connected */ +#define ISC_R_RANGE 41 /* out of range */ +#define ISC_R_NOENTROPY 42 /* out of entropy */ +#define ISC_R_MULTICAST 43 /* invalid use of multicast */ +#define ISC_R_NOTFILE 44 /* not a file */ +#define ISC_R_NOTDIRECTORY 45 /* not a directory */ +#define ISC_R_QUEUEFULL 46 /* queue is full */ +#define ISC_R_FAMILYMISMATCH 47 /* address family mismatch */ +#define ISC_R_FAMILYNOSUPPORT 48 /* AF not supported */ +#define ISC_R_BADHEX 49 /* bad hex encoding */ +#define ISC_R_TOOMANYOPENFILES 50 /* too many open files */ +#define ISC_R_NOTBLOCKING 51 /* not blocking */ +#define ISC_R_UNBALANCEDQUOTES 52 /* unbalanced quotes */ +#define ISC_R_INPROGRESS 53 /* operation in progress */ +#define ISC_R_CONNECTIONRESET 54 /* connection reset */ +#define ISC_R_SOFTQUOTA 55 /* soft quota reached */ +#define ISC_R_BADNUMBER 56 /* not a valid number */ + +/* + * Not a result code: the number of results. + */ +#define ISC_R_NRESULTS 57 + +ISC_LANG_BEGINDECLS + +const char * +isc_result_totext(isc_result_t); +/* + * Convert an isc_result_t into a string message describing the result. + */ + +isc_result_t +isc_result_register(unsigned int base, unsigned int nresults, + const char **text, isc_msgcat_t *msgcat, int set); + +ISC_LANG_ENDDECLS + +#endif /* ISC_RESULT_H */ diff --git a/contrib/ntp/include/isc/sockaddr.h b/contrib/ntp/include/isc/sockaddr.h new file mode 100644 index 000000000000..5257b059de01 --- /dev/null +++ b/contrib/ntp/include/isc/sockaddr.h @@ -0,0 +1,196 @@ +/* + * Copyright (C) 1998-2002 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: sockaddr.h,v 1.39 2002/04/03 06:38:36 marka Exp $ */ + +#ifndef ISC_SOCKADDR_H +#define ISC_SOCKADDR_H 1 + +#include <isc/lang.h> +#include <isc/net.h> +#include <isc/types.h> + +struct isc_sockaddr { + union { + struct sockaddr sa; + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + } type; + unsigned int length; /* XXXRTH beginning? */ + ISC_LINK(struct isc_sockaddr) link; +}; + +typedef ISC_LIST(struct isc_sockaddr) isc_sockaddrlist_t; + +ISC_LANG_BEGINDECLS + +isc_boolean_t +isc_sockaddr_equal(const isc_sockaddr_t *a, const isc_sockaddr_t *b); +/* + * Return ISC_TRUE iff the socket addresses 'a' and 'b' are equal. + */ + +isc_boolean_t +isc_sockaddr_eqaddr(const isc_sockaddr_t *a, const isc_sockaddr_t *b); +/* + * Return ISC_TRUE iff the address parts of the socket addresses + * 'a' and 'b' are equal, ignoring the ports. + */ + +isc_boolean_t +isc_sockaddr_eqaddrprefix(const isc_sockaddr_t *a, const isc_sockaddr_t *b, + unsigned int prefixlen); +/* + * Return ISC_TRUE iff the most significant 'prefixlen' bits of the + * socket addresses 'a' and 'b' are equal, ignoring the ports. + */ + +unsigned int +isc_sockaddr_hash(const isc_sockaddr_t *sockaddr, isc_boolean_t address_only); +/* + * Return a hash value for the socket address 'sockaddr'. If 'address_only' + * is ISC_TRUE, the hash value will not depend on the port. + * + * IPv6 addresses containing mapped IPv4 addresses generate the same hash + * value as the equivalent IPv4 address. + */ + +void +isc_sockaddr_any(isc_sockaddr_t *sockaddr); +/* + * Return the IPv4 wildcard address. + */ + +void +isc_sockaddr_any6(isc_sockaddr_t *sockaddr); +/* + * Return the IPv6 wildcard address. + */ + +void +isc_sockaddr_anyofpf(isc_sockaddr_t *sockaddr, int family); +/* + * Set '*sockaddr' to the wildcard address of protocol family + * 'family'. + * + * Requires: + * 'family' is AF_INET or AF_INET6. + */ + +void +isc_sockaddr_fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina, + in_port_t port); +/* + * Construct an isc_sockaddr_t from an IPv4 address and port. + */ + +void +isc_sockaddr_fromin6(isc_sockaddr_t *sockaddr, const struct in6_addr *ina6, + in_port_t port); +/* + * Construct an isc_sockaddr_t from an IPv6 address and port. + */ + +void +isc_sockaddr_v6fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina, + in_port_t port); +/* + * Construct an IPv6 isc_sockaddr_t representing a mapped IPv4 address. + */ + +void +isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na, + in_port_t port); +/* + * Construct an isc_sockaddr_t from an isc_netaddr_t and port. + */ + +int +isc_sockaddr_pf(const isc_sockaddr_t *sockaddr); +/* + * Get the protocol family of 'sockaddr'. + * + * Requires: + * + * 'sockaddr' is a valid sockaddr with an address family of AF_INET + * or AF_INET6. + * + * Returns: + * + * The protocol family of 'sockaddr', e.g. PF_INET or PF_INET6. + */ + +void +isc_sockaddr_setport(isc_sockaddr_t *sockaddr, in_port_t port); +/* + * Set the port of 'sockaddr' to 'port'. + */ + +in_port_t +isc_sockaddr_getport(isc_sockaddr_t *sockaddr); +/* + * Get the port stored in 'sockaddr'. + */ + +isc_result_t +isc_sockaddr_totext(const isc_sockaddr_t *sockaddr, isc_buffer_t *target); +/* + * Append a text representation of 'sockaddr' to the buffer 'target'. + * The text will include both the IP address (v4 or v6) and the port. + * The text is null terminated, but the terminating null is not + * part of the buffer's used region. + * + * Returns: + * ISC_R_SUCCESS + * ISC_R_NOSPACE The text or the null termination did not fit. + */ + +void +isc_sockaddr_format(const isc_sockaddr_t *sa, char *array, unsigned int size); +/* + * Format a human-readable representation of the socket address '*sa' + * into the character array 'array', which is of size 'size'. + * The resulting string is guaranteed to be null-terminated. + */ + +isc_boolean_t +isc_sockaddr_ismulticast(isc_sockaddr_t *sa); +/* + * Returns ISC_TRUE if the address is a multicast address. + */ + +isc_boolean_t +isc_sockaddr_islinklocal(isc_sockaddr_t *sa); +/* + * Returns ISC_TRUE if the address is a link local addresss. + */ + +isc_boolean_t +isc_sockaddr_issitelocal(isc_sockaddr_t *sa); +/* + * Returns ISC_TRUE if the address is a sitelocal address. + */ + +#define ISC_SOCKADDR_FORMATSIZE \ + sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX#YYYYY") +/* + * Minimum size of array to pass to isc_sockaddr_format(). + */ + +ISC_LANG_ENDDECLS + +#endif /* ISC_SOCKADDR_H */ diff --git a/contrib/ntp/include/isc/strerror.h b/contrib/ntp/include/isc/strerror.h new file mode 100644 index 000000000000..ca428af9553f --- /dev/null +++ b/contrib/ntp/include/isc/strerror.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: strerror.h,v 1.3 2001/11/20 01:45:47 gson Exp $ */ + +#ifndef ISC_STRERROR_H +#define ISC_STRERROR_H + +#include <sys/types.h> + +#include <isc/lang.h> + +ISC_LANG_BEGINDECLS + +#define ISC_STRERRORSIZE 128 + +/* + * Provide a thread safe wrapper to strerrror(). + * + * Requires: + * 'buf' to be non NULL. + */ +void +isc__strerror(int num, char *buf, size_t bufsize); + +ISC_LANG_ENDDECLS + +#endif /* ISC_STRERROR_H */ diff --git a/contrib/ntp/include/isc/string.h b/contrib/ntp/include/isc/string.h new file mode 100644 index 000000000000..e16219fdaad0 --- /dev/null +++ b/contrib/ntp/include/isc/string.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2000, 2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: string.h,v 1.9 2001/01/09 21:57:37 bwelling Exp $ */ + +#ifndef ISC_STRING_H +#define ISC_STRING_H 1 + +#include <string.h> + +#include <isc/int.h> +#include <isc/lang.h> +#include <isc/platform.h> + +ISC_LANG_BEGINDECLS + +isc_uint64_t +isc_string_touint64(char *source, char **endp, int base); +/* + * Convert the string pointed to by 'source' to isc_uint64_t. + * + * On successful conversion 'endp' points to the first character + * after conversion is complete. + * + * 'base': 0 or 2..36 + * + * If base is 0 the base is computed from the string type. + * + * On error 'endp' points to 'source'. + */ + + +char * +isc_string_separate(char **stringp, const char *delim); + +#ifdef ISC_PLATFORM_NEEDSTRSEP +#define strsep isc_string_separate +#endif + +ISC_LANG_ENDDECLS + +#endif /* ISC_STRING_H */ diff --git a/contrib/ntp/include/isc/types.h b/contrib/ntp/include/isc/types.h new file mode 100644 index 000000000000..b30f55ee7fe9 --- /dev/null +++ b/contrib/ntp/include/isc/types.h @@ -0,0 +1,102 @@ +/* + * Copyright (C) 1999-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: types.h,v 1.33 2002/07/19 03:39:44 marka Exp $ */ + +#ifndef ISC_TYPES_H +#define ISC_TYPES_H 1 + +/* + * OS-specific types, from the OS-specific include directories. + */ +#include <isc/int.h> +#include <isc/offset.h> + +/* + * XXXDCL should isc_boolean_t be moved here, requiring an explicit include + * of <isc/boolean.h> when ISC_TRUE/ISC_FALSE/ISC_TF() are desired? + */ +#include <isc/boolean.h> +/* + * XXXDCL This is just for ISC_LIST and ISC_LINK, but gets all of the other + * list macros too. + */ +#include <isc/list.h> + +/*** + *** Core Types. Alphabetized by defined type. + ***/ + +typedef struct isc_bitstring isc_bitstring_t; +typedef struct isc_buffer isc_buffer_t; +typedef ISC_LIST(isc_buffer_t) isc_bufferlist_t; +typedef struct isc_constregion isc_constregion_t; +typedef struct isc_consttextregion isc_consttextregion_t; +typedef struct isc_entropy isc_entropy_t; +typedef struct isc_entropysource isc_entropysource_t; +typedef struct isc_event isc_event_t; +typedef ISC_LIST(isc_event_t) isc_eventlist_t; +typedef unsigned int isc_eventtype_t; +typedef isc_uint32_t isc_fsaccess_t; +typedef struct isc_interface isc_interface_t; +typedef struct isc_interfaceiter isc_interfaceiter_t; +typedef struct isc_interval isc_interval_t; +typedef struct isc_lex isc_lex_t; +typedef struct isc_log isc_log_t; +typedef struct isc_logcategory isc_logcategory_t; +typedef struct isc_logconfig isc_logconfig_t; +typedef struct isc_logmodule isc_logmodule_t; +typedef struct isc_mem isc_mem_t; +typedef struct isc_mempool isc_mempool_t; +typedef struct isc_msgcat isc_msgcat_t; +typedef struct isc_ondestroy isc_ondestroy_t; +typedef struct isc_netaddr isc_netaddr_t; +typedef struct isc_quota isc_quota_t; +typedef struct isc_random isc_random_t; +typedef struct isc_ratelimiter isc_ratelimiter_t; +typedef struct isc_region isc_region_t; +typedef isc_uint64_t isc_resourcevalue_t; +typedef unsigned int isc_result_t; +typedef struct isc_rwlock isc_rwlock_t; +typedef struct isc_sockaddr isc_sockaddr_t; +typedef struct isc_socket isc_socket_t; +typedef struct isc_socketevent isc_socketevent_t; +typedef struct isc_socketmgr isc_socketmgr_t; +typedef struct isc_symtab isc_symtab_t; +typedef struct isc_task isc_task_t; +typedef ISC_LIST(isc_task_t) isc_tasklist_t; +typedef struct isc_taskmgr isc_taskmgr_t; +typedef struct isc_textregion isc_textregion_t; +typedef struct isc_time isc_time_t; +typedef struct isc_timer isc_timer_t; +typedef struct isc_timermgr isc_timermgr_t; + +typedef void (*isc_taskaction_t)(isc_task_t *, isc_event_t *); + +typedef enum { + isc_resource_coresize = 1, + isc_resource_cputime, + isc_resource_datasize, + isc_resource_filesize, + isc_resource_lockedmemory, + isc_resource_openfiles, + isc_resource_processes, + isc_resource_residentsize, + isc_resource_stacksize +} isc_resource_t; + +#endif /* ISC_TYPES_H */ diff --git a/contrib/ntp/include/isc/util.h b/contrib/ntp/include/isc/util.h new file mode 100644 index 000000000000..6144e11ba863 --- /dev/null +++ b/contrib/ntp/include/isc/util.h @@ -0,0 +1,225 @@ +/* + * Copyright (C) 1998-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: util.h,v 1.23 2001/11/30 01:59:38 gson Exp $ */ + +#ifndef ISC_UTIL_H +#define ISC_UTIL_H 1 + +/* + * NOTE: + * + * This file is not to be included from any <isc/???.h> (or other) library + * files. + * + * Including this file puts several macros in your name space that are + * not protected (as all the other ISC functions/macros do) by prepending + * ISC_ or isc_ to the name. + */ + +/*** + *** General Macros. + ***/ + +/* + * Use this to hide unused function arguments. + * + * int + * foo(char *bar) + * { + * UNUSED(bar); + * } + */ +#define UNUSED(x) (void)(x) + +#define ISC_MAX(a, b) ((a) > (b) ? (a) : (b)) +#define ISC_MIN(a, b) ((a) < (b) ? (a) : (b)) + +/* + * Use this to remove the const qualifier of a variable to assign it to + * a non-const variable or pass it as a non-const function argument ... + * but only when you are sure it won't then be changed! + * This is necessary to sometimes shut up some compilers + * (as with gcc -Wcast-qual) when there is just no other good way to avoid the + * situation. + */ +#define DE_CONST(konst, var) \ + do { \ + union { const void *k; void *v; } _u; \ + _u.k = konst; \ + var = _u.v; \ + } while (0) + +/* + * Use this in translation units that would otherwise be empty, to + * suppress compiler warnings. + */ +#define EMPTY_TRANSLATION_UNIT static void isc__empty(void) { isc__empty(); } + +/* + * We use macros instead of calling the routines directly because + * the capital letters make the locking stand out. + * + * We RUNTIME_CHECK for success since in general there's no way + * for us to continue if they fail. + */ + +#ifdef ISC_UTIL_TRACEON +#define ISC_UTIL_TRACE(a) a +#include <stdio.h> /* Required for fprintf/stderr when tracing. */ +#include <isc/msgs.h> /* Required for isc_msgcat when tracing. */ +#else +#define ISC_UTIL_TRACE(a) +#endif + +#include <isc/result.h> /* Contractual promise. */ + +#define LOCK(lp) do { \ + ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_LOCKING, "LOCKING"), \ + (lp), __FILE__, __LINE__)); \ + RUNTIME_CHECK(isc_mutex_lock((lp)) == ISC_R_SUCCESS); \ + ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_LOCKED, "LOCKED"), \ + (lp), __FILE__, __LINE__)); \ + } while (0) +#define UNLOCK(lp) do { \ + RUNTIME_CHECK(isc_mutex_unlock((lp)) == ISC_R_SUCCESS); \ + ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_UNLOCKED, "UNLOCKED"), \ + (lp), __FILE__, __LINE__)); \ + } while (0) +#define ISLOCKED(lp) (1) +#define DESTROYLOCK(lp) \ + RUNTIME_CHECK(isc_mutex_destroy((lp)) == ISC_R_SUCCESS) + + +#define BROADCAST(cvp) do { \ + ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_BROADCAST, "BROADCAST"),\ + (cvp), __FILE__, __LINE__)); \ + RUNTIME_CHECK(isc_condition_broadcast((cvp)) == ISC_R_SUCCESS); \ + } while (0) +#define SIGNAL(cvp) do { \ + ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_SIGNAL, "SIGNAL"), \ + (cvp), __FILE__, __LINE__)); \ + RUNTIME_CHECK(isc_condition_signal((cvp)) == ISC_R_SUCCESS); \ + } while (0) +#define WAIT(cvp, lp) do { \ + ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %p %s %d\n", \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_UTILWAIT, "WAIT"), \ + (cvp), \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_LOCK, "LOCK"), \ + (lp), __FILE__, __LINE__)); \ + RUNTIME_CHECK(isc_condition_wait((cvp), (lp)) == ISC_R_SUCCESS); \ + ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %p %s %d\n", \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_WAITED, "WAITED"), \ + (cvp), \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_LOCKED, "LOCKED"), \ + (lp), __FILE__, __LINE__)); \ + } while (0) + +/* + * isc_condition_waituntil can return ISC_R_TIMEDOUT, so we + * don't RUNTIME_CHECK the result. + * + * XXX Also, can't really debug this then... + */ + +#define WAITUNTIL(cvp, lp, tp) \ + isc_condition_waituntil((cvp), (lp), (tp)) + +#define RWLOCK(lp, t) do { \ + ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_RWLOCK, "RWLOCK"), \ + (lp), (t), __FILE__, __LINE__)); \ + RUNTIME_CHECK(isc_rwlock_lock((lp), (t)) == ISC_R_SUCCESS); \ + ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_RWLOCKED, "RWLOCKED"), \ + (lp), (t), __FILE__, __LINE__)); \ + } while (0) +#define RWUNLOCK(lp, t) do { \ + ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \ + isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ + ISC_MSG_RWUNLOCK, "RWUNLOCK"), \ + (lp), (t), __FILE__, __LINE__)); \ + RUNTIME_CHECK(isc_rwlock_unlock((lp), (t)) == ISC_R_SUCCESS); \ + } while (0) + +#define DESTROYMUTEXBLOCK(bp, n) \ + RUNTIME_CHECK(isc_mutexblock_destroy((bp), (n)) == ISC_R_SUCCESS) + +/* + * List Macros. + */ +#include <isc/list.h> /* Contractual promise. */ + +#define LIST(type) ISC_LIST(type) +#define INIT_LIST(type) ISC_LIST_INIT(type) +#define LINK(type) ISC_LINK(type) +#define INIT_LINK(elt, link) ISC_LINK_INIT(elt, link) +#define HEAD(list) ISC_LIST_HEAD(list) +#define TAIL(list) ISC_LIST_TAIL(list) +#define EMPTY(list) ISC_LIST_EMPTY(list) +#define PREV(elt, link) ISC_LIST_PREV(elt, link) +#define NEXT(elt, link) ISC_LIST_NEXT(elt, link) +#define APPEND(list, elt, link) ISC_LIST_APPEND(list, elt, link) +#define PREPEND(list, elt, link) ISC_LIST_PREPEND(list, elt, link) +#define UNLINK(list, elt, link) ISC_LIST_UNLINK(list, elt, link) +#define ENQUEUE(list, elt, link) ISC_LIST_APPEND(list, elt, link) +#define DEQUEUE(list, elt, link) ISC_LIST_UNLINK(list, elt, link) +#define INSERTBEFORE(li, b, e, ln) ISC_LIST_INSERTBEFORE(li, b, e, ln) +#define INSERTAFTER(li, a, e, ln) ISC_LIST_INSERTAFTER(li, a, e, ln) +#define APPENDLIST(list1, list2, link) ISC_LIST_APPENDLIST(list1, list2, link) + +/* + * Assertions + */ +#include <isc/assertions.h> /* Contractual promise. */ + +#define REQUIRE(e) ISC_REQUIRE(e) +#define ENSURE(e) ISC_ENSURE(e) +#define INSIST(e) ISC_INSIST(e) +#define INVARIANT(e) ISC_INVARIANT(e) + +/* + * Errors + */ +#include <isc/error.h> /* Contractual promise. */ + +#define UNEXPECTED_ERROR isc_error_unexpected +#define FATAL_ERROR isc_error_fatal +#define RUNTIME_CHECK(cond) ISC_ERROR_RUNTIMECHECK(cond) + +/* + * Time + */ +#define TIME_NOW(tp) RUNTIME_CHECK(isc_time_now((tp)) == ISC_R_SUCCESS) + +#endif /* ISC_UTIL_H */ diff --git a/contrib/ntp/include/l_stdlib.h b/contrib/ntp/include/l_stdlib.h index 89eb54535e3a..3f242b7994a0 100644 --- a/contrib/ntp/include/l_stdlib.h +++ b/contrib/ntp/include/l_stdlib.h @@ -14,6 +14,12 @@ # include <stdlib.h> #endif +#if defined(__STDC__) || defined(HAVE_STDARG_H) +# include <stdarg.h> +#else +# include <varargs.h> +#endif + #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif @@ -145,6 +151,11 @@ extern int sigvec P((int, struct sigvec *, struct sigvec *)); extern int snprintf P((char *, size_t, const char *, ...)); #endif +/* HMS: does this need further protection? */ +#ifndef HAVE_VSNPRINTF +extern int vsnprintf P((char *, size_t, const char *, va_list)); +#endif + #ifdef DECL_SRAND48_0 extern void srand48 P((long)); #endif diff --git a/contrib/ntp/include/ntp.h b/contrib/ntp/include/ntp.h index 5708b7c315a4..1ce302b7be98 100644 --- a/contrib/ntp/include/ntp.h +++ b/contrib/ntp/include/ntp.h @@ -1,12 +1,14 @@ /* * ntp.h - NTP definitions for the masses */ - #ifndef NTP_H #define NTP_H #include "ntp_types.h" #include <math.h> +#ifdef OPENSSL +#include "ntp_crypto.h" +#endif /* OPENSSL */ /* * Calendar arithmetic - contributed by G. Healton @@ -92,24 +94,53 @@ typedef char s_char; */ #define NTP_VERSION ((u_char)4) /* current version number */ #define NTP_OLDVERSION ((u_char)1) /* oldest credible version */ -#define NTP_PORT 123 /* included for sake of non-unix machines */ +#define NTP_PORT 123 /* included for non-unix machines */ + +/* + * Poll interval parameters + */ #define NTP_UNREACH 16 /* poll interval backoff count */ -#define NTP_MINDPOLL 6 /* log2 default min poll interval (64 s) */ -#define NTP_MAXDPOLL 10 /* log2 default max poll interval (~17 m) */ #define NTP_MINPOLL 4 /* log2 min poll interval (16 s) */ -#define NTP_MAXPOLL 17 /* log2 max poll interval (~4.5 h) */ -#define NTP_MINCLOCK 3 /* minimum survivors */ -#define NTP_MAXCLOCK 10 /* maximum candidates */ -#define NTP_SHIFT 8 /* 8 suitable for crystal time base */ -#define NTP_MAXKEY 65535 /* maximum authentication key number */ -#define NTP_MAXSESSION 100 /* maximum session key list entries */ -#define NTP_AUTOMAX 13 /* log2 default max session key lifetime */ -#define KEY_REVOKE 16 /* log2 default key revoke timeout */ +#define NTP_MINDPOLL 6 /* log2 default min poll (64 s) */ +#define NTP_MAXDPOLL 10 /* log2 default max poll (~17 m) */ +#define NTP_MAXPOLL 17 /* log2 max poll interval (~36 h) */ +#define NTP_BURST 8 /* packets in burst */ +#define BURST_DELAY 2 /* interburst delay (s) */ +#define RESP_DELAY 1 /* crypto response delay (s) */ + +/* + * Clock filter algorithm tuning parameters + */ +#define MINDISPERSE .01 /* min dispersion */ +#define MAXDISPERSE 16. /* max dispersion */ +#define NTP_SHIFT 8 /* clock filter stages */ #define NTP_FWEIGHT .5 /* clock filter weight */ -#define CLOCK_SGATE 4. /* popcorn spike gate */ -#define BURST_INTERVAL1 4 /* first interburst interval (log2) */ -#define BURST_INTERVAL2 1 /* succeeding interburst intervals (log2) */ + +/* + * Selection algorithm tuning parameters + */ +#define NTP_MINCLOCK 4 /* minimum survivors */ +#define NTP_MAXCLOCK 50 /* maximum candidates */ +#define MAXDISTANCE 1. /* max root distance */ +#define CLOCK_SGATE 3. /* popcorn spike gate */ #define HUFFPUFF 900 /* huff-n'-puff sample interval (s) */ +#define HYST .5 /* anti-clockhop hysteresis */ +#define HYST_TC .875 /* anti-clockhop hysteresis decay */ +#define MAX_TTL 8 /* max ttl mapping vector size */ +#define NTP_MAXEXTEN 1024 /* maximum extension field size */ + +/* + * Miscellaneous stuff + */ +#define NTP_MAXKEY 65535 /* maximum authentication key number */ + +/* + * Limits of things + */ +#define MAXFILENAME 128 /* max length of file name */ +#define MAXHOSTNAME 512 /* max length of host/node name */ +#define NTP_MAXSTRLEN 256 /* maximum string length */ +#define MAXINTERFACES 512 /* max number of interfaces */ /* * Operations for jitter calculations (these use doubles). @@ -129,67 +160,24 @@ typedef char s_char; 1L << (int)(a)) /* log2 to double */ #define UNIVAR(x) (SQUARE(.28867513 * LOGTOD(x))) /* std uniform distr */ #define ULOGTOD(a) (1L << (int)(a)) /* ulog2 to double */ -#define MAXDISPERSE 16. /* max dispersion (square) */ -#define MINDISPERSE .01 /* min dispersion */ -#define MAXDISTANCE 1. /* max root distance */ #define EVENT_TIMEOUT 0 /* one second, that is */ -#ifdef AUTOKEY -/* - * The following structures are used in the autokey protocol. - * - * The autokey structure holds the values used to authenticate key IDs. - */ -struct autokey { /* network byte order */ - tstamp_t tstamp; /* timestamp */ - keyid_t key; /* key ID */ - int32 seq; /* key number */ - u_int32 siglen; /* signature length */ - u_int32 pkt[1]; /* start of signature field */ - u_char *sig; /* signature */ -}; - -/* - * The cookie structure holds the current private value used to - * construct session keys. - */ -struct cookie { /* network byte order */ - tstamp_t tstamp; /* timestamp */ - keyid_t key; /* key ID */ - u_int32 siglen; /* signature length */ - u_int32 pkt[1]; /* start of signature field */ - u_char *sig; /* signature */ -}; - -/* - * The value structure holds variable length data such as public - * key, agreement parameters, public valule and leapsecond table. - */ -struct value { /* network byte order */ - tstamp_t tstamp; /* timestamp */ - tstamp_t fstamp; /* filestamp */ - u_int32 vallen; /* value length */ - u_int32 pkt[1]; /* start of value field */ - u_char *ptr; /* data pointer */ - u_int32 siglen; /* signature length */ - u_char *sig; /* signature */ -}; -#endif /* AUTOKEY */ - /* * The interface structure is used to hold the addresses and socket * numbers of each of the interfaces we are using. */ struct interface { - int fd; /* socket this is opened on */ - int bfd; /* socket for receiving broadcasts */ - struct sockaddr_in sin; /* interface address */ - struct sockaddr_in bcast; /* broadcast address */ - struct sockaddr_in mask; /* interface mask */ - char name[8]; /* name of interface */ + SOCKET fd; /* socket this is opened on */ + SOCKET bfd; /* socket for receiving broadcasts */ + struct sockaddr_storage sin; /* interface address */ + struct sockaddr_storage bcast; /* broadcast address */ + struct sockaddr_storage mask; /* interface mask */ + char name[32]; /* name of interface */ int flags; /* interface flags */ int last_ttl; /* last TTL specified */ + u_int addr_refid; /* IPv4 addr or IPv6 hash */ + int num_mcast; /* No. of IP addresses in multicast socket */ volatile long received; /* number of incoming packets */ long sent; /* number of outgoing packets */ long notsent; /* number of send failures */ @@ -198,10 +186,12 @@ struct interface { /* * Flags for interfaces */ -#define INT_BROADCAST 1 /* can broadcast out this interface */ -#define INT_BCASTOPEN 2 /* broadcast socket is open */ -#define INT_LOOPBACK 4 /* the loopback interface */ -#define INT_MULTICAST 8 /* multicasting enabled */ +#define INT_UP 1 /* Interface is up */ +#define INT_PPP 2 /* Point-to-point interface */ +#define INT_LOOPBACK 4 /* the loopback interface */ +#define INT_BROADCAST 8 /* can broadcast out this interface */ +#define INT_MULTICAST 16 /* multicasting enabled */ +#define INT_BCASTOPEN 32 /* broadcast socket is open */ /* * Define flasher bits (tests 1 through 11 in packet procedure) @@ -229,7 +219,7 @@ struct interface { struct peer { struct peer *next; /* pointer to next association */ struct peer *ass_next; /* link pointer in associd hash */ - struct sockaddr_in srcadr; /* address of remote host */ + struct sockaddr_storage srcadr; /* address of remote host */ struct interface *dstadr; /* pointer to address on local host */ associd_t associd; /* association ID */ u_char version; /* version number */ @@ -244,7 +234,7 @@ struct peer { u_int flash; /* protocol error test tally bits */ u_char last_event; /* last peer error code */ u_char num_events; /* number of error events */ - u_char ttlmax; /* max ttl/refclock mode */ + u_char ttl; /* ttl/refclock mode */ /* * Variables used by reference clock support @@ -269,38 +259,41 @@ struct peer { * Variables used by authenticated client */ keyid_t keyid; /* current key ID */ -#ifdef AUTOKEY +#ifdef OPENSSL #define clear_to_zero assoc associd_t assoc; /* peer association ID */ u_int32 crypto; /* peer status word */ -#ifdef PUBKEY - struct value pubkey; /* public key */ - struct value certif; /* certificate */ - u_char *keystr; /* host name */ -#endif /* PUBKEY */ + EVP_PKEY *pkey; /* public key */ + const EVP_MD *digest; /* message digest algorithm */ + char *subject; /* certificate subject name */ + char *issuer; /* certificate issuer name */ keyid_t pkeyid; /* previous key ID */ - keyid_t hcookie; /* host cookie */ - struct cookie pcookie; /* peer cookie */ - struct autokey recauto; /* autokey */ - u_int32 cmmd; /* peer command */ + keyid_t pcookie; /* peer cookie */ + EVP_PKEY *ident_pkey; /* identity key */ + tstamp_t fstamp; /* identity filestamp */ + BIGNUM *iffval; /* IFF/GQ challenge */ + BIGNUM *grpkey; /* GQ group key */ + struct value cookval; /* cookie values */ + struct value recval; /* receive autokey values */ + struct value tai_leap; /* leapseconds values */ + struct exten *cmmd; /* extension pointer */ + /* * Variables used by authenticated server */ keyid_t *keylist; /* session key ID list */ int keynumber; /* current key number */ - struct autokey sndauto; /* autokey */ -#else /* AUTOKEY */ + struct value encrypt; /* send encrypt values */ + struct value sndval; /* send autokey values */ +#else /* OPENSSL */ #define clear_to_zero status -#endif /* AUTOKEY */ +#endif /* OPENSSL */ /* * Ephemeral state variables */ u_char status; /* peer status */ - u_char pollsw; /* what it says */ - u_char ttl; /* ttl for manycast mode */ u_char reach; /* reachability register */ - u_char unreach; /* unreachable count */ u_long epoch; /* reference epoch */ u_short filter_nextpt; /* index into filter shift register */ double filter_delay[NTP_SHIFT]; /* delay shift register */ @@ -316,6 +309,7 @@ struct peer { double jitter; /* peer jitter (squares) */ double disp; /* peer dispersion */ double estbdelay; /* clock offset to broadcast server */ + double hyst; /* anti-clockhop hysteresis */ /* * Variables set by received packet @@ -328,10 +322,11 @@ struct peer { */ u_long update; /* receive epoch */ #define end_clear_to_zero update + u_int unreach; /* unreachable count */ u_long outdate; /* send time last packet */ u_long nextdate; /* send time next packet */ - u_long nextaction; /* peer local activity timeout (refclocks mainly) */ - void (*action) P((struct peer *)); /* action timeout function */ + u_long nextaction; /* peer local activity timeout (refclocks mainly) */ + void (*action) P((struct peer *)); /* action timeout function */ /* * Statistic counters */ @@ -347,6 +342,7 @@ struct peer { u_long oldpkt; /* packets duplicate packet */ u_long seldisptoolarge; /* packets dispersion to large*/ u_long selbroken; /* not used */ + u_long rank; /* number of times selected or in cluster */ }; /* @@ -360,7 +356,7 @@ struct peer { /* * Values for peer.mode */ -#define MODE_UNSPEC 0 /* unspecified (probably old NTP version) */ +#define MODE_UNSPEC 0 /* unspecified (old version) */ #define MODE_ACTIVE 1 /* symmetric active */ #define MODE_PASSIVE 2 /* symmetric passive */ #define MODE_CLIENT 3 /* client mode */ @@ -373,7 +369,7 @@ struct peer { /* * Values for peer.stratum, sys_stratum */ -#define STRATUM_REFCLOCK ((u_char)0) /* stratum claimed by primary clock */ +#define STRATUM_REFCLOCK ((u_char)0) /* default stratum */ /* A stratum of 0 in the packet is mapped to 16 internally */ #define STRATUM_PKT_UNSPEC ((u_char)0) /* unspecified in packet */ #define STRATUM_UNSPEC ((u_char)16) /* unspecified */ @@ -392,9 +388,7 @@ struct peer { #define FLAG_BURST 0x0100 /* burst mode */ #define FLAG_IBURST 0x0200 /* initial burst mode */ #define FLAG_NOSELECT 0x0400 /* this is a "noselect" peer */ -#define FLAG_AUTOKEY 0x0800 /* autokey confirmed */ -#define FLAG_ASSOC 0x1000 /* autokey reqeust */ -#define FLAG_PROVEN 0x2000 /* proventic confirmed */ +#define FLAG_ASSOC 0x0800 /* autokey request */ /* * Definitions for the clear() routine. We use memset() to clear @@ -405,9 +399,9 @@ struct peer { #define END_CLEAR_TO_ZERO(p) ((char *)&((p)->end_clear_to_zero)) #define LEN_CLEAR_TO_ZERO (END_CLEAR_TO_ZERO((struct peer *)0) \ - CLEAR_TO_ZERO((struct peer *)0)) -#define CRYPTO_TO_ZERO(p) ((char *)&((p)->clear_to_zero)) -#define END_CRYPTO_TO_ZERO(p) ((char *)&((p)->end_clear_to_zero)) -#define LEN_CRYPTO_TO_ZERO (END_CRYPTO_TO_ZERO((struct peer *)0) \ +#define CRYPTO_TO_ZERO(p) ((char *)&((p)->clear_to_zero)) +#define END_CRYPTO_TO_ZERO(p) ((char *)&((p)->end_clear_to_zero)) +#define LEN_CRYPTO_TO_ZERO (END_CRYPTO_TO_ZERO((struct peer *)0) \ - CRYPTO_TO_ZERO((struct peer *)0)) /* @@ -424,7 +418,7 @@ struct peer { #define REFCLK_WWV_PST 3 /* PST/Traconex 1020 WWV/H */ #define REFCLK_SPECTRACOM 4 /* Spectracom (generic) Receivers */ #define REFCLK_TRUETIME 5 /* TrueTime (generic) Receivers */ -#define REFCLK_IRIG_AUDIO 6 /* IRIG-B/W audio decoder */ +#define REFCLK_IRIG_AUDIO 6 /* IRIG-B/W audio decoder */ #define REFCLK_CHU_AUDIO 7 /* CHU audio demodulator/decoder */ #define REFCLK_PARSE 8 /* generic driver (usually DCF77,GPS,MSF) */ #define REFCLK_GPS_MX4200 9 /* Magnavox MX4200 GPS */ @@ -444,25 +438,57 @@ struct peer { #define REFCLK_PTB_ACTS 23 /* PTB Auto Computer Time Service */ #define REFCLK_USNO 24 /* Naval Observatory dialup */ #define REFCLK_GPS_HP 26 /* HP 58503A Time/Frequency Receiver */ -#define REFCLK_ARCRON_MSF 27 /* ARCRON MSF radio clock. */ +#define REFCLK_ARCRON_MSF 27 /* ARCRON MSF radio clock. */ #define REFCLK_SHM 28 /* clock attached thru shared memory */ #define REFCLK_PALISADE 29 /* Trimble Navigation Palisade GPS */ #define REFCLK_ONCORE 30 /* Motorola UT Oncore GPS */ #define REFCLK_GPS_JUPITER 31 /* Rockwell Jupiter GPS receiver */ -#define REFCLK_CHRONOLOG 32 /* Chrono-log K WWVB receiver */ -#define REFCLK_DUMBCLOCK 33 /* Dumb localtime clock */ -#define REFCLK_ULINK 34 /* Ultralink M320 WWVB receiver */ +#define REFCLK_CHRONOLOG 32 /* Chrono-log K WWVB receiver */ +#define REFCLK_DUMBCLOCK 33 /* Dumb localtime clock */ +#define REFCLK_ULINK 34 /* Ultralink M320 WWVB receiver */ #define REFCLK_PCF 35 /* Conrad parallel port radio clock */ #define REFCLK_WWV_AUDIO 36 /* WWV/H audio demodulator/decoder */ #define REFCLK_FG 37 /* Forum Graphic GPS */ -#define REFCLK_HOPF_SERIAL 38 /* hopf DCF77/GPS serial line receiver */ +#define REFCLK_HOPF_SERIAL 38 /* hopf DCF77/GPS serial receiver */ #define REFCLK_HOPF_PCI 39 /* hopf DCF77/GPS PCI receiver */ #define REFCLK_JJY 40 /* JJY receiver */ #define REFCLK_TT560 41 /* TrueTime 560 IRIG-B decoder */ #define REFCLK_ZYFER 42 /* Zyfer GPStarplus receiver */ #define REFCLK_RIPENCC 43 /* RIPE NCC Trimble driver */ -#define REFCLK_NEOCLOCK4X 44 /* NeoClock4X DCF77 or TDF receiver */ -#define REFCLK_MAX 44 /* Grow as needed... */ +#define REFCLK_NEOCLOCK4X 44 /* NeoClock4X DCF77 or TDF receiver */ +#define REFCLK_MAX 44 /* NeoClock4X DCF77 or TDF receiver */ + + /* + * Macro for sockaddr_storage structures operations + */ +#define SOCKCMP(sock1, sock2) \ + (((struct sockaddr_storage *)sock1)->ss_family \ + == ((struct sockaddr_storage *)sock2)->ss_family ? \ + ((struct sockaddr_storage *)sock1)->ss_family == AF_INET ? \ + memcmp(&((struct sockaddr_in *)sock1)->sin_addr, \ + &((struct sockaddr_in *)sock2)->sin_addr, \ + sizeof(struct in_addr)) == 0 : \ + memcmp(&((struct sockaddr_in6 *)sock1)->sin6_addr, \ + &((struct sockaddr_in6 *)sock2)->sin6_addr, \ + sizeof(struct in6_addr)) == 0 : \ + 0) + +#define SOCKNUL(sock1) \ + (((struct sockaddr_storage *)sock1)->ss_family == AF_INET ? \ + (((struct sockaddr_in *)sock1)->sin_addr.s_addr == 0) : \ + (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)sock1)->sin6_addr))) + +#define SOCKLEN(sock) \ + (((struct sockaddr_storage *)sock)->ss_family == AF_INET ? \ + (sizeof(struct sockaddr_in)) : (sizeof(struct sockaddr_in6))) + +#define ANYSOCK(sock) \ + memset(((struct sockaddr_in *)sock), 0, \ + sizeof(struct sockaddr_storage)) + +#define ANY_INTERFACE_CHOOSE(sock) \ + (((struct sockaddr_storage *)sock)->ss_family == AF_INET ? \ + any_interface : any6_interface) /* * We tell reference clocks from real peers by giving the reference @@ -492,11 +518,27 @@ struct peer { /* * Utilities for manipulating addresses and port numbers */ -#define NSRCADR(src) ((src)->sin_addr.s_addr) /* address in net byte order */ -#define NSRCPORT(src) ((src)->sin_port) /* port in net byte order */ +#define NSRCADR(src) (((struct sockaddr_in *)src)->sin_addr.s_addr) /* address in net byte order */ +#define NSRCPORT(src) (((struct sockaddr_in *)src)->sin_port) /* port in net byte order */ #define SRCADR(src) (ntohl(NSRCADR((src)))) /* address in host byte order */ #define SRCPORT(src) (ntohs(NSRCPORT((src)))) /* host port */ +#define CAST_V4(src) ((struct sockaddr_in *)&(src)) +#define CAST_V6(src) ((struct sockaddr_in6 *)&(src)) +#define GET_INADDR(src) (CAST_V4(src)->sin_addr.s_addr) +#define GET_INADDR6(src) (CAST_V6(src)->sin6_addr) + +#define SET_HOSTMASK(addr, family) \ + do { \ + memset((char *)(addr), 0, sizeof(struct sockaddr_storage)); \ + (addr)->ss_family = (family); \ + if ((family) == AF_INET) \ + GET_INADDR(*(addr)) = 0xffffffff; \ + else \ + memset(&GET_INADDR6(*(addr)), 0xff, \ + sizeof(struct in6_addr)); \ + } while(0) + /* * NTP packet format. The mac field is optional. It isn't really * an l_fp either, but for now declaring it that way is convenient. @@ -533,15 +575,11 @@ struct pkt { * octets. But, to handle humungus certificates, the bank must * be broke. */ -#ifdef AUTOKEY -#ifdef PUBKEY - u_int32 exten[5000 / 4]; /* max extension field */ -#else - u_int32 exten[672 / 4]; /* max extension field */ -#endif /* PUBKEY */ -#else /* AUTOKEY */ +#ifdef OPENSSL + u_int32 exten[NTP_MAXEXTEN / 4]; /* max extension field */ +#else /* OPENSSL */ u_int32 exten[1]; /* misused */ -#endif /* AUTOKEY */ +#endif /* OPENSSL */ u_char mac[MAX_MAC_LEN]; /* mac */ }; @@ -572,7 +610,8 @@ struct pkt { /* * Event codes. Used for reporting errors/events to the control module */ -#define PEER_EVENT 0x80 /* this is a peer event */ +#define PEER_EVENT 0x080 /* this is a peer event */ +#define CRPT_EVENT 0x100 /* this is a crypto event */ /* * System event codes @@ -617,9 +656,9 @@ struct pkt { * To speed lookups, peers are hashed by the low order bits of the * remote IP address. These definitions relate to that. */ -#define HASH_SIZE 32 +#define HASH_SIZE 128 #define HASH_MASK (HASH_SIZE-1) -#define HASH_ADDR(src) ((SRCADR((src))^(SRCADR((src))>>8)) & HASH_MASK) +#define HASH_ADDR(src) sock_hash(src) /* * How we randomize polls. The poll interval is a power of two. @@ -666,6 +705,13 @@ struct pkt { #define PROTO_FILEGEN 11 #define PROTO_PPS 12 #define PROTO_CAL 13 +#define PROTO_MINCLOCK 14 +#define PROTO_MINSANE 15 +#define PROTO_FLOOR 16 +#define PROTO_CEILING 17 +#define PROTO_COHORT 18 +#define PROTO_CALLDELAY 19 +#define PROTO_ADJ 20 /* * Configuration items for the loop filter @@ -679,6 +725,7 @@ struct pkt { #define LOOP_MINPOLL 7 /* set min poll interval (log2 s) */ #define LOOP_ALLAN 8 /* set minimum Allan intercept */ #define LOOP_HUFFPUFF 9 /* set huff-n'-puff filter length */ +#define LOOP_FREQ 10 /* set initial frequency */ /* * Configuration items for the stats printer @@ -687,7 +734,7 @@ struct pkt { #define STATS_STATSDIR 2 /* directory prefix for stats files */ #define STATS_PID_FILE 3 /* configure ntpd PID file */ -#define MJD_1970 40587 /* MJD for 1 Jan 1970 */ +#define MJD_1900 15020 /* MJD for 1 Jan 1900 */ /* * Default parameters. We use these in the absence of something better. @@ -702,13 +749,11 @@ struct mon_data { struct mon_data *hash_next; /* next structure in hash list */ struct mon_data *mru_next; /* next structure in MRU list */ struct mon_data *mru_prev; /* previous structure in MRU list */ - struct mon_data *fifo_next; /* next structure in FIFO list */ - struct mon_data *fifo_prev; /* previous structure in FIFO list */ - u_long lastdrop; /* last time dropped due to RES_LIMIT*/ - u_long lasttime; /* last time data updated */ - u_long firsttime; /* time structure initialized */ - u_long count; /* count we have seen */ - u_int32 rmtadr; /* address of remote host */ + u_long drop_count; /* dropped due RESLIMIT*/ + double avg_interval; /* average interpacket interval */ + u_long lasttime; /* interval since last packet */ + u_long count; /* total packet count */ + struct sockaddr_storage rmtadr; /* address of remote host */ struct interface *interface; /* interface on which this arrived */ u_short rmtport; /* remote port last came from */ u_char mode; /* mode of incoming packet */ @@ -725,6 +770,7 @@ struct mon_data { #define MDF_LCAST 0x08 /* localcast */ #define MDF_ACAST 0x10 /* manycast */ #define MDF_BCLNT 0x20 /* broadcast client */ +#define MDF_ACLNT 0x40 /* manycast client */ /* * Values used with mon_enabled to indicate reason for enabling monitoring @@ -737,32 +783,49 @@ struct mon_data { */ struct restrictlist { struct restrictlist *next; /* link to next entry */ - u_int32 addr; /* host address (host byte order) */ - u_int32 mask; /* mask for address (host byte order) */ + u_int32 addr; /* Ipv4 host address (host byte order) */ + u_int32 mask; /* Ipv4 mask for address (host byte order) */ + u_long count; /* number of packets matched */ + u_short flags; /* accesslist flags */ + u_short mflags; /* match flags */ +}; + +struct restrictlist6 { + struct restrictlist6 *next; /* link to next entry */ + struct in6_addr addr6; /* Ipv6 host address */ + struct in6_addr mask6; /* Ipv6 mask address */ u_long count; /* number of packets matched */ u_short flags; /* accesslist flags */ u_short mflags; /* match flags */ }; + /* * Access flags */ -#define RES_IGNORE 0x001 /* ignore if matched */ -#define RES_DONTSERVE 0x002 /* don't give him any time */ -#define RES_DONTTRUST 0x004 /* don't trust if matched */ -#define RES_NOQUERY 0x008 /* don't allow queries if matched */ -#define RES_NOMODIFY 0x010 /* don't allow him to modify server */ -#define RES_NOPEER 0x020 /* don't allocate memory resources */ -#define RES_NOTRAP 0x040 /* don't allow him to set traps */ -#define RES_LPTRAP 0x080 /* traps set by him are low priority */ -#define RES_LIMITED 0x100 /* limit per net number of clients */ -#define RES_VERSION 0x200 /* serve only current version */ -#define RES_DEMOBILIZE 0x400 /* demobilize association */ +#define RES_IGNORE 0x001 /* ignore packet */ +#define RES_DONTSERVE 0x002 /* access denied */ +#define RES_DONTTRUST 0x004 /* authentication required */ +#define RES_VERSION 0x008 /* version mismatch */ +#define RES_NOPEER 0x010 /* new association denied */ +#define RES_LIMITED 0x020 /* packet rate exceeded */ + +#define RES_FLAGS (RES_IGNORE | RES_DONTSERVE |\ + RES_DONTTRUST | RES_VERSION |\ + RES_NOPEER | RES_LIMITED) -#define RES_ALLFLAGS \ - (RES_IGNORE | RES_DONTSERVE | RES_DONTTRUST | RES_NOQUERY | \ - RES_NOMODIFY | RES_NOPEER | RES_NOTRAP | RES_LPTRAP | \ - RES_LIMITED | RES_VERSION | RES_DEMOBILIZE) +#define RES_NOQUERY 0x040 /* mode 6/7 packet denied */ +#define RES_NOMODIFY 0x080 /* mode 6/7 modify denied */ +#define RES_NOTRAP 0x100 /* mode 6/7 set trap denied */ +#define RES_LPTRAP 0x200 /* mode 6/7 low priority trap */ + +#define RES_DEMOBILIZE 0x400 /* send kiss of death packet */ +#define RES_TIMEOUT 0x800 /* timeout this entry */ + +#define RES_ALLFLAGS (RES_FLAGS | RES_NOQUERY |\ + RES_NOMODIFY | RES_NOTRAP |\ + RES_LPTRAP | RES_DEMOBILIZE |\ + RES_TIMEOUT) /* * Match flags @@ -777,16 +840,6 @@ struct restrictlist { #define RESTRICT_UNFLAG 2 /* remove flags from restrict entry */ #define RESTRICT_REMOVE 3 /* remove a restrict entry */ - -/* - * Experimental alternate selection algorithm identifiers - */ -#define SELECT_1 1 -#define SELECT_2 2 -#define SELECT_3 3 -#define SELECT_4 4 -#define SELECT_5 5 - /* * Endpoint structure for the select algorithm */ diff --git a/contrib/ntp/include/ntp_config.h b/contrib/ntp/include/ntp_config.h index 92f5cd116c1d..01478d2b6b07 100644 --- a/contrib/ntp/include/ntp_config.h +++ b/contrib/ntp/include/ntp_config.h @@ -7,6 +7,7 @@ # else /* SYS_WINNT */ # define CONFIG_FILE "%windir%\\system32\\drivers\\etc\\ntp.conf" # define ALT_CONFIG_FILE "%windir%\\ntp.conf" +# define NTP_KEYSDIR "%windir%\\system32\\drivers\\etc" # endif /* SYS_WINNT */ #endif /* not CONFIG_FILE */ @@ -41,8 +42,8 @@ #define CONFIG_STATISTICS 21 #define CONFIG_PIDFILE 22 #define CONFIG_SETVAR 23 -#define CONFIG_CLIENTLIMIT 24 -#define CONFIG_CLIENTPERIOD 25 +#define CONFIG_DISCARD 24 +#define CONFIG_ADJ 25 #define CONFIG_MULTICASTCLIENT 26 #define CONFIG_ENABLE 27 #define CONFIG_DISABLE 28 @@ -51,11 +52,14 @@ #define CONFIG_LOGCONFIG 31 #define CONFIG_MANYCASTCLIENT 32 #define CONFIG_MANYCASTSERVER 33 -#ifdef PUBKEY -#define CONFIG_CRYPTO 34 -#define CONFIG_KEYSDIR 35 -#endif /* PUBKEY */ -#define CONFIG_INCLUDEFILE 36 +#define CONFIG_TOS 34 +#define CONFIG_TTL 35 +#define CONFIG_INCLUDEFILE 36 +#define CONFIG_KEYSDIR 37 +#define CONFIG_CDELAY 38 +#ifdef OPENSSL +#define CONFIG_CRYPTO 39 +#endif /* OPENSSL */ /* * "peer", "server", "broadcast" modifier keywords @@ -71,9 +75,6 @@ #define CONF_MOD_TTL 9 #define CONF_MOD_MODE 10 #define CONF_MOD_NOSELECT 11 -#ifdef PUBKEY -#define CONF_MOD_PUBLICKEY 12 -#endif /* PUBKEY */ /* * "restrict" modifier keywords @@ -128,24 +129,50 @@ #define CONF_PPS_HARDPPS 3 /* + * "discard" modifier keywords + */ +#define CONF_DISCARD_AVERAGE 1 +#define CONF_DISCARD_MINIMUM 2 +#define CONF_DISCARD_MONITOR 3 + +/* * "tinker" modifier keywords */ #define CONF_CLOCK_MAX 1 #define CONF_CLOCK_PANIC 2 #define CONF_CLOCK_PHI 3 #define CONF_CLOCK_MINSTEP 4 -#define CONF_CLOCK_MINPOLL 5 -#define CONF_CLOCK_ALLAN 6 -#define CONF_CLOCK_HUFFPUFF 7 +#define CONF_CLOCK_ALLAN 5 +#define CONF_CLOCK_HUFFPUFF 6 +#define CONF_CLOCK_FREQ 7 -#ifdef PUBKEY +/* + * "tos" modifier keywords + */ +#define CONF_TOS_MINCLOCK 1 +#define CONF_TOS_MINSANE 2 +#define CONF_TOS_FLOOR 3 +#define CONF_TOS_CEILING 4 +#define CONF_TOS_COHORT 5 + +#ifdef OPENSSL /* * "crypto" modifier keywords */ -#define CONF_CRYPTO_DH 1 -#define CONF_CRYPTO_PRIVATEKEY 2 -#define CONF_CRYPTO_PUBLICKEY 3 -#define CONF_CRYPTO_LEAP 4 -#define CONF_CRYPTO_FLAGS 5 -#define CONF_CRYPTO_CERT 6 -#endif /* PUBKEY */ +#define CONF_CRYPTO_RSA 1 +#define CONF_CRYPTO_SIGN 2 +#define CONF_CRYPTO_LEAP 3 +#define CONF_CRYPTO_CERT 4 +#define CONF_CRYPTO_RAND 5 +#define CONF_CRYPTO_KEYS 6 +#define CONF_CRYPTO_IFFPAR 7 +#define CONF_CRYPTO_GQPAR 8 +#define CONF_CRYPTO_MVPAR 9 +#define CONF_CRYPTO_PW 10 +#endif /* OPENSSL */ + +/* + * Address selection, IPv4 or IPv6 + */ +#define CONF_ADDR_IPV4 1 +#define CONF_ADDR_IPV6 2 diff --git a/contrib/ntp/include/ntp_control.h b/contrib/ntp/include/ntp_control.h index e31a2fdde236..c75d38b31ad6 100644 --- a/contrib/ntp/include/ntp_control.h +++ b/contrib/ntp/include/ntp_control.h @@ -164,19 +164,19 @@ struct ntp_control { #define CS_VERSION 17 #define CS_STABIL 18 #define CS_VARLIST 19 -#ifdef PUBKEY +#ifdef OPENSSL #define CS_FLAGS 20 #define CS_HOST 21 #define CS_PUBLIC 22 #define CS_CERTIF 23 -#define CS_DHPARAMS 24 -#define CS_REVTIME 25 -#define CS_LEAPTAB 26 -#define CS_TAI 27 -#define CS_MAXCODE CS_TAI +#define CS_REVTIME 24 +#define CS_LEAPTAB 25 +#define CS_TAI 26 +#define CS_DIGEST 27 +#define CS_MAXCODE CS_DIGEST #else #define CS_MAXCODE CS_VARLIST -#endif /* PUBKEY */ +#endif /* OPENSSL */ /* * Peer variables we understand @@ -217,22 +217,20 @@ struct ntp_control { #define CP_FILTERROR 34 #define CP_FLASH 35 #define CP_TTL 36 -#define CP_TTLMAX 37 +#define CP_RANK 37 #define CP_VARLIST 38 -#ifdef PUBKEY +#ifdef OPENSSL #define CP_FLAGS 39 #define CP_HOST 40 -#define CP_PUBLIC 41 -#define CP_CERTIF 42 -#define CP_SESKEY 43 -#define CP_SASKEY 44 -#define CP_INITSEQ 45 -#define CP_INITKEY 46 -#define CP_INITTSP 47 -#define CP_MAXCODE CP_INITTSP +#define CP_INITSEQ 41 +#define CP_INITKEY 42 +#define CP_INITTSP 43 +#define CP_DIGEST 44 +#define CP_IDENT 45 +#define CP_MAXCODE CP_IDENT #else #define CP_MAXCODE CP_VARLIST -#endif /* PUBKEY */ +#endif /* OPENSSL */ /* * Clock variables we understand @@ -258,7 +256,7 @@ struct ntp_control { * ntp_request.c wants to see this. */ struct ctl_trap { - struct sockaddr_in tr_addr; /* address of trap recipient */ + struct sockaddr_storage tr_addr;/* address of trap recipient */ struct interface *tr_localaddr; /* interface to send this through */ u_long tr_settime; /* time trap was set */ u_long tr_count; /* async messages sent to this guy */ diff --git a/contrib/ntp/include/ntp_crypto.h b/contrib/ntp/include/ntp_crypto.h index a4e6d70d6577..fb1955ce4064 100644 --- a/contrib/ntp/include/ntp_crypto.h +++ b/contrib/ntp/include/ntp_crypto.h @@ -1,93 +1,166 @@ /* * ntp_crypto.h - definitions for cryptographic operations */ -#ifdef AUTOKEY -#include "global.h" -#include "md5.h" -#ifdef RSAREF -#include "rsaref.h" -#include "rsa.h" - -#define EVP_SignInit(a, b) R_SignInit(a, b) -#define EVP_SignUpdate(a, b, c) R_SignUpdate(a, b, c); -#define EVP_SignFinal(a, b, c, d) R_SignFinal(a, b, c, d); -#define EVP_VerifyInit(a, b) R_VerifyInit(a, b) -#define EVP_VerifyUpdate(a, b, c) R_VerifyUpdate(a, b, c); -#define EVP_VerifyFinal(a, b, c, d) R_VerifyFinal(a, b, c, d); +#ifdef OPENSSL +#include "openssl/evp.h" +/* + * The following bits are set by the CRYPTO_ASSOC message from + * the server and are not modified by the client. + */ +#define CRYPTO_FLAG_ENAB 0x0001 /* crypto enable */ +#define CRYPTO_FLAG_TAI 0x0002 /* leapseconds table */ -#endif /* RSAREF */ +#define CRYPTO_FLAG_PRIV 0x0010 /* PC identity scheme */ +#define CRYPTO_FLAG_IFF 0x0020 /* IFF identity scheme */ +#define CRYPTO_FLAG_GQ 0x0040 /* GQ identity scheme */ +#define CRYPTO_FLAG_MV 0x0080 /* MV identity scheme */ +#define CRYPTO_FLAG_MASK 0x00f0 /* identity scheme mask */ + +/* + * The following bits are used by the client during the protocol + * exchange. + */ +#define CRYPTO_FLAG_VALID 0x0100 /* public key verified */ +#define CRYPTO_FLAG_VRFY 0x0200 /* identity verified */ +#define CRYPTO_FLAG_PROV 0x0400 /* signature verified */ +#define CRYPTO_FLAG_AGREE 0x0800 /* cookie verifed */ +#define CRYPTO_FLAG_AUTO 0x1000 /* autokey verified */ +#define CRYPTO_FLAG_SIGN 0x2000 /* certificate signed */ +#define CRYPTO_FLAG_LEAP 0x4000 /* leapseconds table verified */ /* - * Cryptostatus word + * Flags used for certificate management */ -#define CRYPTO_FLAG_ENAB 0x01 /* crypto enable */ -#define CRYPTO_FLAG_RSA 0x02 /* public/private keys */ -#define CRYPTO_FLAG_CERT 0x04 /* certificate */ -#define CRYPTO_FLAG_DH 0x08 /* agreement parameters */ -#define CRYPTO_FLAG_TAI 0x10 /* leapseconds table */ +#define CERT_SIGN 0x01 /* certificate is signed */ +#define CERT_TRUST 0x02 /* certificate is trusted */ +#define CERT_PRIV 0x04 /* certificate is private */ +#define CERT_ERROR 0x80 /* certificate has errors */ /* * Extension field definitions */ -#define CRYPTO_VN 1 /* current protocol version number */ +#define CRYPTO_MAXLEN 1024 /* max extension field length */ +#define CRYPTO_VN 2 /* current protocol version number */ +#define CRYPTO_CMD(x) (((CRYPTO_VN << 8) | (x)) << 16) +#define CRYPTO_NULL CRYPTO_CMD(0) /* no operation */ +#define CRYPTO_ASSOC CRYPTO_CMD(1) /* association */ +#define CRYPTO_CERT CRYPTO_CMD(2) /* certificate */ +#define CRYPTO_COOK CRYPTO_CMD(3) /* cookie value */ +#define CRYPTO_AUTO CRYPTO_CMD(4) /* autokey values */ +#define CRYPTO_TAI CRYPTO_CMD(5) /* leapseconds table */ +#define CRYPTO_SIGN CRYPTO_CMD(6) /* certificate sign */ +#define CRYPTO_IFF CRYPTO_CMD(7) /* IFF identity scheme */ +#define CRYPTO_GQ CRYPTO_CMD(8) /* GQ identity scheme */ +#define CRYPTO_MV CRYPTO_CMD(9) /* MV identity scheme */ +#define CRYPTO_RESP 0x80000000 /* response */ +#define CRYPTO_ERROR 0x40000000 /* error */ -#define CRYPTO_NULL ((CRYPTO_VN << 8) | 0) /* no operation */ -#define CRYPTO_STAT ((CRYPTO_VN << 8) | 1) /* status */ -#define CRYPTO_ASSOC ((CRYPTO_VN << 8) | 2) /* association ID */ -#define CRYPTO_AUTO ((CRYPTO_VN << 8) | 3) /* autokey values */ -#define CRYPTO_PRIV ((CRYPTO_VN << 8) | 4) /* cookie value */ -#define CRYPTO_DHPAR ((CRYPTO_VN << 8) | 5) /* agreement params */ -#define CRYPTO_DH ((CRYPTO_VN << 8) | 6) /* public value */ -#define CRYPTO_NAME ((CRYPTO_VN << 8) | 7) /* host name/pub key */ -#define CRYPTO_CERT ((CRYPTO_VN << 8) | 8) /* PKI certificate */ -#define CRYPTO_TAI ((CRYPTO_VN << 8) | 9) /* leapseconds table */ -#define CRYPTO_RESP 0x8000 /* response */ -#define CRYPTO_ERROR 0x4000 /* error */ +/* + * Autokey event codes + */ +#define XEVNT_CMD(x) (CRPT_EVENT | (x)) +#define XEVNT_OK XEVNT_CMD(0) /* success */ +#define XEVNT_LEN XEVNT_CMD(1) /* bad field format or length */ +#define XEVNT_TSP XEVNT_CMD(2) /* bad timestamp */ +#define XEVNT_FSP XEVNT_CMD(3) /* bad filestamp */ +#define XEVNT_PUB XEVNT_CMD(4) /* bad procedure or data */ +#define XEVNT_MD XEVNT_CMD(5) /* unsupported digest type */ +#define XEVNT_KEY XEVNT_CMD(6) /* unsupported identity type */ +#define XEVNT_SGL XEVNT_CMD(7) /* bad signature length */ +#define XEVNT_SIG XEVNT_CMD(8) /* signature not verified */ +#define XEVNT_VFY XEVNT_CMD(9) /* certificate not verified */ +#define XEVNT_PER XEVNT_CMD(10) /* certificate expired */ +#define XEVNT_CKY XEVNT_CMD(11) /* bad or missing cookie */ +#define XEVNT_DAT XEVNT_CMD(12) /* bad or missing leapseconds table */ +#define XEVNT_CRT XEVNT_CMD(13) /* bad or missing certificate */ +#define XEVNT_ID XEVNT_CMD(14) /* bad or missing identification */ -#ifdef PUBKEY /* * Configuration codes */ #define CRYPTO_CONF_NONE 0 /* nothing doing */ -#define CRYPTO_CONF_FLAGS 1 /* initialize flags */ -#define CRYPTO_CONF_PRIV 2 /* load private key from file */ -#define CRYPTO_CONF_PUBL 3 /* load public key from file */ -#define CRYPTO_CONF_DH 4 /* load Diffie_Hellman pars from file */ -#define CRYPTO_CONF_LEAP 5 /* load leapsecond table */ -#define CRYPTO_CONF_KEYS 6 /* set keys directory path */ -#define CRYPTO_CONF_CERT 7 /* load PKI certificate from file */ -#endif /* PUBKEY */ +#define CRYPTO_CONF_PRIV 1 /* host keys file name */ +#define CRYPTO_CONF_SIGN 2 /* signature keys file name */ +#define CRYPTO_CONF_LEAP 3 /* leapseconds table file name */ +#define CRYPTO_CONF_KEYS 4 /* keys directory path */ +#define CRYPTO_CONF_CERT 5 /* certificate file name */ +#define CRYPTO_CONF_RAND 6 /* random seed file name */ +#define CRYPTO_CONF_TRST 7 /* specify trust */ +#define CRYPTO_CONF_IFFPAR 8 /* IFF parameters file name */ +#define CRYPTO_CONF_GQPAR 9 /* GQ parameters file name */ +#define CRYPTO_CONF_MVPAR 10 /* GQ parameters file name */ +#define CRYPTO_CONF_PW 11 /* private key password */ + +/* + * Miscellaneous crypto stuff + */ +#define NTP_MAXSESSION 100 /* maximum session key list entries */ +#define NTP_AUTOMAX 13 /* log2 default max session key life */ +#define KEY_REVOKE 16 /* log2 default key revoke timeout */ +#define NTP_MAXEXTEN 1024 /* maximum extension field size */ + +/* + * The autokey structure holds the values used to authenticate key IDs. + */ +struct autokey { /* network byte order */ + keyid_t key; /* key ID */ + int32 seq; /* key number */ +}; + +/* + * The value structure holds variable length data such as public + * key, agreement parameters, public valule and leapsecond table. + * They are in network byte order. + */ +struct value { /* network byte order */ + tstamp_t tstamp; /* timestamp */ + tstamp_t fstamp; /* filestamp */ + u_int32 vallen; /* value length */ + u_char *ptr; /* data pointer (various) */ + u_int32 siglen; /* signature length */ + u_char *sig; /* signature */ +}; + +/* + * The packet extension field structures are used to hold values + * and signatures in network byte order. + */ +struct exten { + u_int32 opcode; /* opcode */ + u_int32 associd; /* association ID */ + u_int32 tstamp; /* timestamp */ + u_int32 fstamp; /* filestamp */ + u_int32 vallen; /* value length */ + u_int32 pkt[1]; /* start of value field */ +}; /* - * Function prototypes + * The certificate info/value structure */ -extern void crypto_recv P((struct peer *, struct recvbuf *)); -extern int crypto_xmit P((u_int32 *, int, u_int, keyid_t, - u_int)); -extern keyid_t session_key P((struct sockaddr_in *, struct - sockaddr_in *, keyid_t, keyid_t, - u_long)); -extern void make_keylist P((struct peer *, struct interface *)); -extern void key_expire P((struct peer *)); -extern void crypto_agree P((void)); -#ifdef PUBKEY -extern void crypto_config P((int, char *)); -extern void crypto_setup P((void)); -extern int crypto_public P((struct peer *, u_char *, u_int)); -#endif /* PUBKEY */ +struct cert_info { + struct cert_info *link; /* forward link */ + u_int flags; /* flags that wave */ + EVP_PKEY *pkey; /* generic key */ + long version; /* X509 version */ + int nid; /* signature/digest ID */ + const EVP_MD *digest; /* message digest algorithm */ + u_long serial; /* serial number */ + tstamp_t first; /* valid not before */ + tstamp_t last; /* valid not after */ + char *subject; /* subject common name */ + char *issuer; /* issuer common name */ + u_char *grpkey; /* GQ group key */ + u_int grplen; /* GQ group key length */ + struct value cert; /* certificate/value */ +}; /* * Cryptographic values */ +extern char *keysdir; /* crypto keys directory */ extern u_int crypto_flags; /* status word */ -#ifdef PUBKEY -extern R_DH_PARAMS dh_params; -extern struct value host; /* host name/public key */ -extern struct value certif; /* certificate */ -extern struct value dhparam; /* agreement parameters */ -extern struct value dhpub; /* public value */ +extern struct value hostval; /* host name/value */ +extern struct cert_info *cinfo; /* host certificate information */ extern struct value tai_leap; /* leapseconds table */ -extern u_int crypto_flags; /* status word */ extern u_int sys_tai; /* current UTC offset from TAI */ -#endif /* PUBKEY */ -#endif /* AUTOKEY */ +#endif /* OPENSSL */ diff --git a/contrib/ntp/include/ntp_fp.h b/contrib/ntp/include/ntp_fp.h index 027add32d9ba..256bab830a04 100644 --- a/contrib/ntp/include/ntp_fp.h +++ b/contrib/ntp/include/ntp_fp.h @@ -7,6 +7,7 @@ #include <sys/types.h> #include <sys/socket.h> +#include "ntp_rfc2553.h" #include <netinet/in.h> #include "ntp_types.h" @@ -338,14 +339,13 @@ typedef u_int32 u_fp; /* * Prototypes */ -extern char * dofptoa P((u_fp, int, int, int)); -extern char * dolfptoa P((u_long, u_long, int, int, int)); +extern char * dofptoa P((u_fp, int, short, int)); +extern char * dolfptoa P((u_long, u_long, int, short, int)); extern int atolfp P((const char *, l_fp *)); extern int buftvtots P((const char *, l_fp *)); -extern char * fptoa P((s_fp, int)); -extern char * fptoms P((s_fp, int)); -extern char * fptoms P((s_fp, int)); +extern char * fptoa P((s_fp, short)); +extern char * fptoms P((s_fp, short)); extern int hextolfp P((const char *, l_fp *)); extern void gpstolfp P((int, int, unsigned long, l_fp *)); extern int mstolfp P((const char *, l_fp *)); @@ -361,8 +361,11 @@ extern int adj_systime P((double)); #define lfptoa(_fpv, _ndec) mfptoa((_fpv)->l_ui, (_fpv)->l_uf, (_ndec)) #define lfptoms(_fpv, _ndec) mfptoms((_fpv)->l_ui, (_fpv)->l_uf, (_ndec)) -#define ntoa(_sin) numtoa((_sin)->sin_addr.s_addr) -#define ntohost(_sin) numtohost((_sin)->sin_addr.s_addr) +#define stoa(_sin) socktoa((_sin)) +#define stohost(_sin) socktohost((_sin)) + +#define ntoa(_sin) stoa(_sin) +#define ntohost(_sin) stohost(_sin) #define ufptoa(_fpv, _ndec) dofptoa((_fpv), 0, (_ndec), 0) #define ufptoms(_fpv, _ndec) dofptoa((_fpv), 0, (_ndec), 1) diff --git a/contrib/ntp/include/ntp_if.h b/contrib/ntp/include/ntp_if.h index 91362d83106a..3af5865ffae2 100644 --- a/contrib/ntp/include/ntp_if.h +++ b/contrib/ntp/include/ntp_if.h @@ -22,27 +22,6 @@ # include <sys/stropts.h> #endif -/* Was: #if defined(SYS_SVR4) */ -#if defined(USE_STREAMS_DEVICE_FOR_IF_CONFIG) -# include <netinet/ip.h> -# undef SIOCGIFCONF -# undef SIOCGIFFLAGS -# undef SIOCGIFADDR -# undef SIOCGIFBRDADDR -# undef SIOCGIFNETMASK -# define SIOCGIFCONF IPIOC_GETIFCONF -# define SIOCGIFFLAGS IPIOC_GETIFFLAGS -# define SIOCGIFADDR IPIOC_GETIFADDR -# define SIOCGIFBRDADDR IPIOC_GETIFBRDADDR -# define SIOCGIFNETMASK IPIOC_GETIFNETMASK -#if 0 /* We don't need this now that sys/sockio.h is handled above */ -# else /* USE_STREAMS_DEVICE_FOR_IF_CONFIG */ -# include <sys/sockio.h> -#endif -# endif /* USE_STREAMS_DEVICE_FOR_IF_CONFIG */ -/* was #endif SYS_SVR4 */ - - #ifdef HAVE_NET_IF_H # include <net/if.h> #endif /* HAVE_NET_IF_H */ diff --git a/contrib/ntp/include/ntp_io.h b/contrib/ntp/include/ntp_io.h index 0ef4fa65386f..983c6c7dce85 100644 --- a/contrib/ntp/include/ntp_io.h +++ b/contrib/ntp/include/ntp_io.h @@ -30,4 +30,21 @@ # include "win32_io.h" #endif +/* + * Define FNDELAY and FASYNC using O_NONBLOCK and O_ASYNC if we need + * to (and can). This is here initially for QNX, but may help for + * others as well... + */ +#ifndef FNDELAY +# ifdef O_NONBLOCK +# define FNDELAY O_NONBLOCK +# endif +#endif + +#ifndef FASYNC +# ifdef O_ASYNC +# define FASYNC O_ASYNC +# endif +#endif + #endif diff --git a/contrib/ntp/include/ntp_machine.h b/contrib/ntp/include/ntp_machine.h index 17026a776e6c..65ef5be88e3d 100644 --- a/contrib/ntp/include/ntp_machine.h +++ b/contrib/ntp/include/ntp_machine.h @@ -235,29 +235,60 @@ typedef unsigned long u_long; #endif /* 0 */ /* + * Define these here for non-Windows NT systems + * SOCKET and INVALID_SOCKET are native macros + * on Windows NT and since they have different + * requirements we use them in the code and + * make them macros for everyone else + */ +#ifndef SYS_WINNT +# define SOCKET int +# define INVALID_SOCKET -1 +# define closesocket close +#endif +/* * Windows NT */ #if defined(SYS_WINNT) # if !defined(HAVE_CONFIG_H) || !defined(__config) - error "NT requires config.h to be included" +# include <config.h> # endif /* HAVE_CONFIG_H) */ +# include <windows.h> +# include <ws2tcpip.h> +# include <winsock2.h> # define ifreq _INTERFACE_INFO # define ifr_flags iiFlags # define ifr_addr iiAddress.AddressIn # define ifr_broadaddr iiBroadcastAddress.AddressIn # define ifr_mask iiNetmask.AddressIn +# define zz_family sin_family +# define S_IFREG _S_IFREG +# define stat _stat # define isascii __isascii # define isatty _isatty # define mktemp _mktemp -# if 0 -# define getpid GetCurrentProcessId -# endif -# include <windows.h> -# include <ws2tcpip.h> +# define unlink _unlink +# define fileno _fileno +# define write _write +# define vsnprintf _vsnprintf +# define snprintf _snprintf +#ifndef close +# define close _close +#endif # undef interface +# include <process.h> +#define getpid _getpid +/* + * Defining registers are not a good idea on Windows + * This gets rid of the usage + */ +#ifndef register +# define register +#endif typedef char *caddr_t; +# define vsnprintf _vsnprintf #endif /* SYS_WINNT */ int ntp_set_tod P((struct timeval *tvp, void *tzp)); @@ -518,6 +549,10 @@ extern char *strdup(const char *); # undef HAVE_SYSV_TTYS #endif +#ifndef HAVE_TIMEGM +extern time_t timegm P((struct tm *)); +#endif + #ifdef HAVE_SYSV_TTYS # undef HAVE_BSD_TTYS #endif @@ -537,8 +572,8 @@ extern char *strdup(const char *); #endif /* - * Byte order woes. The DES code is sensitive to byte order. This - * used to be resolved by calling ntohl() and htonl() to swap things + * Byte order woes. + * This used to be resolved by calling ntohl() and htonl() to swap things * around, but this turned out to be quite costly on Vaxes where those * things are actual functions. The code now straightens out byte * order troubles on its own, with no performance penalty for little diff --git a/contrib/ntp/include/ntp_md5.h b/contrib/ntp/include/ntp_md5.h new file mode 100644 index 000000000000..bb6985a2f367 --- /dev/null +++ b/contrib/ntp/include/ntp_md5.h @@ -0,0 +1,9 @@ +/* + * ntp_md5.h: deal with md5.h headers + */ + +#ifdef HAVE_MD5_H +# include <md5.h> +#else +# include "rsa_md5.h" +#endif diff --git a/contrib/ntp/include/ntp_refclock.h b/contrib/ntp/include/ntp_refclock.h index 3995e9a1af7d..5e33a8ce25a1 100644 --- a/contrib/ntp/include/ntp_refclock.h +++ b/contrib/ntp/include/ntp_refclock.h @@ -44,9 +44,10 @@ #define BSD_TTYS #endif /* SYSV_TTYS STREAM BSD_TTYS */ -#define SAMPLE(x) pp->filter[pp->coderecv++ % MAXSTAGE] = (x); \ - if (pp->coderecv % MAXSTAGE == pp->codeproc % MAXSTAGE) \ - pp->codeproc++; +#define SAMPLE(x) pp->coderecv = (pp->coderecv + 1) % MAXSTAGE; \ + pp->filter[pp->coderecv] = (x); \ + if (pp->coderecv == pp->codeproc) \ + pp->codeproc = (pp->codeproc + 1) % MAXSTAGE; /* * Macros to determine the clock type and unit numbers from a @@ -128,7 +129,7 @@ struct refclockio { of refclock input data */ caddr_t srcclock; /* pointer to clock structure */ int datalen; /* lenth of data */ - int fd; /* file descriptor */ + SOCKET fd; /* file descriptor */ u_long recvcount; /* count of receive completions */ }; @@ -187,13 +188,12 @@ struct refclockproc { int hour; /* hour of day */ int minute; /* minute of hour */ int second; /* second of minute */ - int msec; /* millisecond of second */ - long usec; /* microsecond of second (alt) */ + long nsec; /* nanosecond of second */ u_long yearstart; /* beginning of year */ int coderecv; /* put pointer */ int codeproc; /* get pointer */ - l_fp lastref; /* timecode timestamp */ - l_fp lastrec; /* local timestamp */ + l_fp lastref; /* reference timestamp */ + l_fp lastrec; /* receive timestamp */ double offset; /* mean offset */ double disp; /* sample dispersion */ double jitter; /* jitter (mean squares) */ @@ -204,6 +204,7 @@ struct refclockproc { */ double fudgetime1; /* fudge time1 */ double fudgetime2; /* fudge time2 */ + u_char stratum; /* server stratum */ u_int32 refid; /* reference identifier */ u_char sloppyclockflag; /* fudge flags */ @@ -248,9 +249,9 @@ extern int io_addclock P((struct refclockio *)); extern void io_closeclock P((struct refclockio *)); #ifdef REFCLOCK -extern void refclock_buginfo P((struct sockaddr_in *, +extern void refclock_buginfo P((struct sockaddr_storage *, struct refclockbug *)); -extern void refclock_control P((struct sockaddr_in *, +extern void refclock_control P((struct sockaddr_storage *, struct refclockstat *, struct refclockstat *)); extern int refclock_open P((char *, int, int)); diff --git a/contrib/ntp/include/ntp_request.h b/contrib/ntp/include/ntp_request.h index 9e76df58e64d..8166a4df2c5f 100644 --- a/contrib/ntp/include/ntp_request.h +++ b/contrib/ntp/include/ntp_request.h @@ -2,6 +2,9 @@ * ntp_request.h - definitions for the ntpd remote query facility */ +#ifndef _NTP_REQUEST_H +#define _NTP_REQUEST_H + #include "ntp_types.h" /* @@ -111,10 +114,6 @@ /* * A request packet. These are almost a fixed length. */ - -#define MAXFILENAME 128 /* max key file name length */ - /* NOTE: also in ntp.h */ - struct req_pkt { u_char rm_vn_mode; /* response, more, version, mode */ u_char auth_seq; /* key, sequence number */ @@ -122,7 +121,8 @@ struct req_pkt { u_char request; /* request number */ u_short err_nitems; /* error code/number of data items */ u_short mbz_itemsize; /* item size */ - char data[MAXFILENAME + 16]; /* data area [32 prev](144 byte max) */ + char data[MAXFILENAME + 48]; /* data area [32 prev](176 byte max) */ + /* struct conf_peer must fit */ l_fp tstamp; /* time stamp, for authentication */ keyid_t keyid; /* encryption key */ char mac[MAX_MAC_LEN-sizeof(u_int32)]; /* (optional) 8 byte auth code */ @@ -207,7 +207,7 @@ struct resp_pkt { |((u_short)(nitems)&0xfff)))) #define INFO_MBZ(mbz_itemsize) ((ntohs(mbz_itemsize)>>12)&0xf) -#define INFO_ITEMSIZE(mbz_itemsize) (ntohs(mbz_itemsize)&0xfff) +#define INFO_ITEMSIZE(mbz_itemsize) ((u_short)(ntohs(mbz_itemsize)&0xfff)) #define MBZ_ITEMSIZE(itemsize) (htons((u_short)(itemsize))) @@ -215,7 +215,8 @@ struct resp_pkt { * Implementation numbers. One for universal use and one for ntpd. */ #define IMPL_UNIV 0 -#define IMPL_XNTPD 2 +#define IMPL_XNTPD_OLD 2 /* Used by pre ipv6 ntpdc */ +#define IMPL_XNTPD 3 /* Used by post ipv6 ntpdc */ /* * Some limits related to authentication. Frames which are @@ -275,6 +276,9 @@ struct resp_pkt { #define REQ_MON_GETLIST_1 42 /* return collected v1 monitor data */ #define REQ_HOSTNAME_ASSOCID 43 /* Here is a hostname + assoc_id */ +/* Determine size of pre-v6 version of structures */ +#define v4sizeof(type) offsetof(type, v6_flag) + /* * Flags in the peer information returns */ @@ -305,10 +309,13 @@ struct resp_pkt { * Well, it *would* have gone without saying, but somebody said it. */ struct info_peer_list { - u_int32 address; /* address of peer */ + u_int32 addr; /* address of peer */ u_short port; /* port number of peer */ u_char hmode; /* mode for this peer */ u_char flags; /* flags (from above) */ + u_int v6_flag; /* is this v6 or not */ + u_int unused1; /* (unused) padding for addr6 */ + struct in6_addr addr6; /* v6 address of peer */ }; @@ -328,6 +335,10 @@ struct info_peer_summary { s_fp delay; /* peer.estdelay */ l_fp offset; /* peer.estoffset */ u_fp dispersion; /* peer.estdisp */ + u_int v6_flag; /* is this v6 or not */ + u_int unused1; /* (unused) padding for dstadr6 */ + struct in6_addr dstadr6; /* local address (v6) */ + struct in6_addr srcadr6; /* source address (v6) */ }; @@ -336,7 +347,7 @@ struct info_peer_summary { */ struct info_peer { u_int32 dstadr; /* local address */ - u_int32 srcadr; /* remote address */ + u_int32 srcadr; /* source address */ u_short srcport; /* remote port */ u_char flags; /* peer flags */ u_char leap; /* peer.leap */ @@ -379,6 +390,10 @@ struct info_peer { int32 unused6; int32 unused7; s_fp estbdelay; /* broadcast offset */ + u_int v6_flag; /* is this v6 or not */ + u_int unused9; /* (unused) padding for dstadr6 */ + struct in6_addr dstadr6; /* local address (v6-like) */ + struct in6_addr srcadr6; /* sources address (v6-like) */ }; @@ -410,6 +425,10 @@ struct info_peer_stats { u_char unused6; /* (unused) */ u_char unused7; /* (unused) */ u_char unused8; /* (unused) */ + u_int v6_flag; /* is this v6 or not */ + u_int unused9; /* (unused) padding for dstadr6 */ + struct in6_addr dstadr6; /* local address */ + struct in6_addr srcadr6; /* remote address */ }; @@ -429,7 +448,7 @@ struct info_loop { * the implementation. */ struct info_sys { - u_int32 peer; /* system peer address */ + u_int32 peer; /* system peer address (v4) */ u_char peer_mode; /* mode we are syncing to peer in */ u_char leap; /* system leap bits */ u_char stratum; /* our stratum */ @@ -447,6 +466,9 @@ struct info_sys { s_fp frequency; /* frequency residual (scaled ppm) */ l_fp authdelay; /* default authentication delay */ u_fp stability; /* clock stability (scaled ppm) */ + u_int v6_flag; /* is this v6 or not */ + u_int unused4; /* unused, padding for peer6 */ + struct in6_addr peer6; /* system peer address (v6) */ }; @@ -454,17 +476,17 @@ struct info_sys { * System stats. These are collected in the protocol module */ struct info_sys_stats { - u_int32 timeup; /* time we have been up and running */ - u_int32 timereset; /* time since these were last cleared */ - u_int32 badstratum; /* packets claiming an invalid stratum */ - u_int32 oldversionpkt; /* old version packets received */ - u_int32 newversionpkt; /* new version packets received */ - u_int32 unknownversion; /* don't know version packets */ - u_int32 badlength; /* packets with bad length */ + u_int32 timeup; /* time since restart */ + u_int32 timereset; /* time since reset */ + u_int32 denied; /* access denied */ + u_int32 oldversionpkt; /* recent version */ + u_int32 newversionpkt; /* current version */ + u_int32 unknownversion; /* bad version */ + u_int32 badlength; /* bad length or format */ u_int32 processed; /* packets processed */ - u_int32 badauth; /* packets dropped because of authorization */ - u_int32 wanderhold; /* (obsolete) */ - u_int32 limitrejected; /* rejected because of client limitation */ + u_int32 badauth; /* bad authentication */ + u_int32 received; /* packets received */ + u_int32 limitrejected; /* rate exceeded */ }; @@ -472,16 +494,16 @@ struct info_sys_stats { * System stats - old version */ struct old_info_sys_stats { - u_int32 timeup; /* time we have been up and running */ - u_int32 timereset; /* time since these were last cleared */ - u_int32 badstratum; /* packets claiming an invalid stratum */ - u_int32 oldversionpkt; /* old version packets received */ - u_int32 newversionpkt; /* new version packets received */ - u_int32 unknownversion; /* don't know version packets */ - u_int32 badlength; /* packets with bad length */ + u_int32 timeup; /* time since restart */ + u_int32 timereset; /* time since reset */ + u_int32 denied; /* access denied */ + u_int32 oldversionpkt; /* recent version */ + u_int32 newversionpkt; /* current version */ + u_int32 unknownversion; /* bad version */ + u_int32 badlength; /* bad length or format */ u_int32 processed; /* packets processed */ - u_int32 badauth; /* packets dropped because of authorization */ - u_int32 wanderhold; + u_int32 badauth; /* bad authentication */ + u_int32 wanderhold; /* (not used) */ }; @@ -552,9 +574,12 @@ struct conf_peer { u_char maxpoll; /* max host poll interval */ u_char flags; /* flags for this request */ u_char ttl; /* time to live (multicast) or refclock mode */ - u_short unused; /* unused */ + u_short unused1; /* unused */ keyid_t keyid; /* key to use for this association */ char keystr[MAXFILENAME]; /* public key file name*/ + u_int v6_flag; /* is this v6 or not */ + u_int unused2; /* unused, padding for peeraddr6 */ + struct in6_addr peeraddr6; /* ipv6 address to poll */ }; #define CONF_FLAG_AUTHENABLE 0x01 @@ -570,7 +595,9 @@ struct conf_peer { * this addess. */ struct conf_unpeer { - u_int32 peeraddr; /* address of peer */ + u_int32 peeraddr; /* address of peer */ + u_int v6_flag; /* is this v6 or not */ + struct in6_addr peeraddr6; /* address of peer (v6) */ }; /* @@ -601,6 +628,10 @@ struct info_restrict { u_int32 count; /* number of packets matched */ u_short flags; /* restrict flags */ u_short mflags; /* match flags */ + u_int v6_flag; /* is this v6 or not */ + u_int unused1; /* unused, padding for addr6 */ + struct in6_addr addr6; /* match address (v6) */ + struct in6_addr mask6; /* match mask (v6) */ }; @@ -608,10 +639,13 @@ struct info_restrict { * Structure used for specifying restrict entries */ struct conf_restrict { - u_int32 addr; /* match address */ + u_int32 addr; /* match address */ u_int32 mask; /* match mask */ u_short flags; /* restrict flags */ u_short mflags; /* match flags */ + u_int v6_flag; /* is this v6 or not */ + struct in6_addr addr6; /* match address (v6) */ + struct in6_addr mask6; /* match mask (v6) */ }; @@ -623,12 +657,16 @@ struct info_monitor_1 { u_int32 firsttime; /* first time we received a packet */ u_int32 lastdrop; /* last time we rejected a packet due to client limitation policy */ u_int32 count; /* count of packets received */ - u_int32 addr; /* host address */ + u_int32 addr; /* host address V4 style */ u_int32 daddr; /* destination host address */ u_int32 flags; /* flags about destination */ u_short port; /* port number of last reception */ u_char mode; /* mode of last packet */ u_char version; /* version number of last packet */ + u_int v6_flag; /* is this v6 or not */ + u_int unused1; /* unused, padding for addr6 */ + struct in6_addr addr6; /* host address V6 style */ + struct in6_addr daddr6; /* host address V6 style */ }; @@ -644,6 +682,9 @@ struct info_monitor { u_short port; /* port number of last reception */ u_char mode; /* mode of last packet */ u_char version; /* version number of last packet */ + u_int v6_flag; /* is this v6 or not */ + u_int unused1; /* unused, padding for addr6 */ + struct in6_addr addr6; /* host v6 address */ }; /* @@ -657,6 +698,8 @@ struct old_info_monitor { u_short port; /* port number of last reception */ u_char mode; /* mode of last packet */ u_char version; /* version number of last packet */ + u_int v6_flag; /* is this v6 or not */ + struct in6_addr addr6; /* host address (v6)*/ }; /* @@ -699,24 +742,30 @@ struct info_auth { * Structure used to pass trap information to the client */ struct info_trap { - u_int32 local_address; /* local interface address */ - u_int32 trap_address; /* remote client's address */ + u_int32 local_address; /* local interface addres (v4) */ + u_int32 trap_address; /* remote client's addres (v4) */ u_short trap_port; /* remote port number */ u_short sequence; /* sequence number */ u_int32 settime; /* time trap last set */ u_int32 origtime; /* time trap originally set */ u_int32 resets; /* number of resets on this trap */ u_int32 flags; /* trap flags, as defined in ntp_control.h */ + u_int v6_flag; /* is this v6 or not */ + struct in6_addr local_address6; /* local interface address (v6) */ + struct in6_addr trap_address6; /* remote client's address (v6) */ }; /* * Structure used to pass add/clear trap information to the client */ struct conf_trap { - u_int32 local_address; /* local interface address */ - u_int32 trap_address; /* remote client's address */ + u_int32 local_address; /* remote client's address */ + u_int32 trap_address; /* local interface address */ u_short trap_port; /* remote client's port */ u_short unused; /* (unused) */ + u_int v6_flag; /* is this v6 or not */ + struct in6_addr local_address6; /* local interface address (v6) */ + struct in6_addr trap_address6; /* remote client's address (v6) */ }; @@ -832,3 +881,4 @@ struct info_dns_assoc { associd_t associd; /* association ID */ char hostname[NTP_MAXHOSTNAME]; /* hostname */ }; +#endif /* NTP_REQUEST_H */ diff --git a/contrib/ntp/include/ntp_rfc2553.h b/contrib/ntp/include/ntp_rfc2553.h new file mode 100644 index 000000000000..28ff004b8808 --- /dev/null +++ b/contrib/ntp/include/ntp_rfc2553.h @@ -0,0 +1,254 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)in.h 8.3 (Berkeley) 1/3/94 + */ + +/* + * Compatability shims with the rfc2553 API to simplify ntp. + */ +#ifndef _NTP_RFC2553_H_ +#define _NTP_RFC2553_H_ + +#if defined(_SS_MAXSIZE) || defined(_SS_SIZE) +#define HAVE_IPV6 +#else + +#include <sys/types.h> +#include "ntp_types.h" + +#ifndef AF_INET6 +#define AF_INET6 AF_MAX +#define PF_INET6 AF_INET6 +#endif + +#ifndef HAVE_TYPE_U_INT8_T +typedef u_char u_int8_t; +typedef u_short u_int16_t; +typedef u_int32 u_int32_t; +#endif /* HAVE_TYPE_U_INT8_T */ + +#ifndef HAVE_TYPE_U_INT64_T +typedef struct u_int64_t { u_int32 val[2]; } u_int64_t; +#endif /* HAVE_TYPE_U_INT64_T */ + +/* + * IPv6 address + */ +#ifdef SYS_WINNT +#define in6_addr in_addr6 +#else +/* + * Don't include any additional IPv6 definitions + * We are defining our own here. + */ +#define ISC_IPV6_H 1 + +struct in6_addr { + union { + u_int8_t __u6_addr8[16]; + u_int16_t __u6_addr16[8]; + u_int32_t __u6_addr32[4]; + } __u6_addr; /* 128-bit IP6 address */ +}; + +#define s6_addr __u6_addr.__u6_addr8 +#endif + +/* + * Definition of some useful macros to handle IP6 addresses + */ +#ifdef SYS_WINNT +#define IN6ADDR_ANY_INIT {{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }} +#else +#define IN6ADDR_ANY_INIT \ + {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} +#endif + +extern const struct in6_addr in6addr_any; + +#define SIN6_LEN +#ifndef HAVE_SOCKADDR_IN6 +struct sockaddr_in6 { +#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR + u_int8_t sin6_len; /* length of this struct(sa_family_t)*/ + u_int8_t sin6_family; /* AF_INET6 (sa_family_t) */ +#else + short sin6_family; /* AF_INET6 (sa_family_t) */ +#endif + u_int16_t sin6_port; /* Transport layer port # (in_port_t)*/ + u_int32_t sin6_flowinfo; /* IP6 flow information */ + struct in6_addr sin6_addr; /* IP6 address */ + u_int32_t sin6_scope_id; /* scope zone index */ +}; +#endif + +/* + * Unspecified + */ +#ifndef IN6_IS_ADDR_UNSPECIFIED +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ + (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ + (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ + (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == 0)) +#endif +/* + * Multicast + */ +#ifndef IN6_IS_ADDR_MULTICAST +#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) +#endif + +/* + * RFC 2553: protocol-independent placeholder for socket addresses + */ +#define _SS_MAXSIZE 128 +#define _SS_ALIGNSIZE (sizeof(u_int64_t)) +#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) - sizeof(u_int8_t)) +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) - sizeof(u_int8_t) - \ + _SS_PAD1SIZE - _SS_ALIGNSIZE) +#else +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(short)) +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(short) - \ + _SS_PAD1SIZE - _SS_ALIGNSIZE) +#endif /* HAVE_SA_LEN_IN_STRUCT_SOCKADDR */ + +struct sockaddr_storage { +#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR + u_int8_t ss_len; /* address length */ + u_int8_t ss_family; /* address family */ +#else + short ss_family; /* address family */ +#endif + char __ss_pad1[_SS_PAD1SIZE]; + u_int64_t __ss_align; /* force desired structure storage alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; + +struct addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for hostname */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ +}; + +/* + * Error return codes from getaddrinfo() + */ +#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ +#define EAI_AGAIN 2 /* temporary failure in name resolution */ +#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ +#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ +#define EAI_FAMILY 5 /* ai_family not supported */ +#define EAI_MEMORY 6 /* memory allocation failure */ +#define EAI_NODATA 7 /* no address associated with hostname */ +#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ +#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ +#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ +#define EAI_SYSTEM 11 /* system error returned in errno */ +#define EAI_BADHINTS 12 +#define EAI_PROTOCOL 13 +#define EAI_MAX 14 + +/* + * Flag values for getaddrinfo() + */ +#define AI_PASSIVE 0x00000001 /* get address to use bind() */ +#define AI_CANONNAME 0x00000002 /* fill ai_canonname */ +#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ +/* valid flags for addrinfo */ +#define AI_MASK \ + (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_ADDRCONFIG) + +#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ + +/* + * Constants for getnameinfo() + */ +#define NI_MAXHOST 1025 +#define NI_MAXSERV 32 + +/* + * Flag values for getnameinfo() + */ +#define NI_NOFQDN 0x00000001 +#define NI_NUMERICHOST 0x00000002 +#define NI_NAMEREQD 0x00000004 +#define NI_NUMERICSERV 0x00000008 +#define NI_DGRAM 0x00000010 +#define NI_WITHSCOPEID 0x00000020 + +int getaddrinfo P((const char *, const char *, + const struct addrinfo *, struct addrinfo **)); +int getnameinfo P((const struct sockaddr *, u_int, char *, + size_t, char *, size_t, int)); +void freeaddrinfo P((struct addrinfo *)); +char *gai_strerror P((int)); + +#endif /* _SS_MAXSIZE */ +#endif /* !_NTP_RFC2553_H_ */ diff --git a/contrib/ntp/include/ntp_sprintf.h b/contrib/ntp/include/ntp_sprintf.h new file mode 100644 index 000000000000..a456a8925949 --- /dev/null +++ b/contrib/ntp/include/ntp_sprintf.h @@ -0,0 +1,13 @@ +/* + * Handle ancient char* *s*printf*() systems + */ + +#ifdef SPRINTF_CHAR +# define SPRINTF(x) strlen(sprintf/**/x) +# define SNPRINTF(x) strlen(snprintf/**/x) +# define VSNPRINTF(x) strlen(vsnprintf/**/x) +#else +# define SPRINTF(x) ((size_t)sprintf x) +# define SNPRINTF(x) ((size_t)snprintf x) +# define VSNPRINTF(x) ((size_t)vsnprintf x) +#endif diff --git a/contrib/ntp/include/ntp_stdlib.h b/contrib/ntp/include/ntp_stdlib.h index d10f67946dd8..9d1d4c9bdcc0 100644 --- a/contrib/ntp/include/ntp_stdlib.h +++ b/contrib/ntp/include/ntp_stdlib.h @@ -2,6 +2,8 @@ * ntp_stdlib.h - Prototypes for NTP lib. */ #include <sys/types.h> +#include <sys/socket.h> +#include "ntp_rfc2553.h" #include "ntp_types.h" #include "ntp_string.h" @@ -27,9 +29,12 @@ # include <stdarg.h> extern void msyslog P((int, const char *, ...)) __attribute__((__format__(__printf__, 2, 3))); +extern void netsyslog P((int, const char *, ...)) + __attribute__((__format__(__printf__, 2, 3))); #else # include <varargs.h> extern void msyslog P(()); +extern void netsyslog P(()); #endif extern void auth_delkeys P((void)); @@ -60,18 +65,10 @@ extern struct savekey *auth_findkey P((keyid_t)); extern int auth_moremem P((void)); extern int ymd2yd P((int, int, int)); -#ifdef DES -extern int DESauthdecrypt P((u_char *, u_int32 *, int, int)); -extern int DESauthencrypt P((u_char *, u_int32 *, int)); -extern void DESauth_setkey P((keyid_t, const u_int32 *)); -extern void DESauth_subkeys P((const u_int32 *, u_char *, u_char *)); -extern void DESauth_des P((u_int32 *, u_char *)); -extern int DESauth_parity P((u_int32 *)); -#endif /* DES */ - extern int MD5authdecrypt P((u_char *, u_int32 *, int, int)); extern int MD5authencrypt P((u_char *, u_int32 *, int)); extern void MD5auth_setkey P((keyid_t, const u_char *, const int)); +extern u_int32 addr2refid P((struct sockaddr_storage *)); extern int atoint P((const char *, long *)); extern int atouint P((const char *, u_long *)); @@ -79,8 +76,8 @@ extern int hextoint P((const char *, u_long *)); extern char * humandate P((u_long)); extern char * humanlogtime P((void)); extern char * inttoa P((long)); -extern char * mfptoa P((u_long, u_long, int)); -extern char * mfptoms P((u_long, u_long, int)); +extern char * mfptoa P((u_long, u_long, short)); +extern char * mfptoms P((u_long, u_long, short)); extern const char * modetoa P((int)); extern const char * eventstr P((int)); extern const char * ceventstr P((int)); @@ -88,16 +85,18 @@ extern char * statustoa P((int, int)); extern const char * sysstatstr P((int)); extern const char * peerstatstr P((int)); extern const char * clockstatstr P((int)); -extern u_int32 netof P((u_int32)); +extern struct sockaddr_storage* netof P((struct sockaddr_storage*)); extern char * numtoa P((u_int32)); extern char * numtohost P((u_int32)); +extern char * socktoa P((struct sockaddr_storage *)); +extern char * socktohost P((struct sockaddr_storage *)); extern int octtoint P((const char *, u_long *)); extern u_long ranp2 P((int)); -extern char * refnumtoa P((u_int32)); +extern char * refnumtoa P((struct sockaddr_storage *)); extern int tsftomsu P((u_long, int)); extern char * uinttoa P((u_long)); -extern int decodenetnum P((const char *, u_int32 *)); +extern int decodenetnum P((const char *, struct sockaddr_storage *)); extern const char * FindConfig P((const char *)); @@ -151,7 +150,7 @@ extern HANDLE hServDoneEvent; #endif /* systime.c */ -extern int systime_10ms_ticks; /* adj sysclock in 10ms increments */ +extern double sys_tick; /* adjtime() resolution */ /* version.c */ extern const char *Version; /* version declaration */ diff --git a/contrib/ntp/include/ntp_unixtime.h b/contrib/ntp/include/ntp_unixtime.h index bdc080e6edd2..ce96980209e9 100644 --- a/contrib/ntp/include/ntp_unixtime.h +++ b/contrib/ntp/include/ntp_unixtime.h @@ -5,6 +5,16 @@ #include "ntp_types.h" +#ifdef SIM +#include "ntpsim.h" +#endif + +#ifdef SIM +# define GETTIMEOFDAY(a, b) (node_gettime(&ntp_node, a)) +# define SETTIMEOFDAY(a, b) (node_settime(&ntp_node, a)) +# define ADJTIMEOFDAY(a, b) (node_adjtime(&ntp_node, a, b)) +#else +# define ADJTIMEOFDAY(a, b) (adjtime(a, b)) /* gettimeofday() takes two args in BSD and only one in SYSV */ # if defined(HAVE_SYS_TIMERS_H) && defined(HAVE_GETCLOCK) # include <sys/timers.h> @@ -25,6 +35,7 @@ int getclock (int clock_type, struct timespec *tp); #endif # endif /* SYSV_TIMEOFDAY */ # endif /* not (HAVE_SYS_TIMERS_H && HAVE_GETCLOCK) */ +#endif /* SIM */ /* * Time of day conversion constant. Ntp's time scale starts in 1900, diff --git a/contrib/ntp/include/ntpd.h b/contrib/ntp/include/ntpd.h index 2e030e68a1a6..cd3aad2d464d 100644 --- a/contrib/ntp/include/ntpd.h +++ b/contrib/ntp/include/ntpd.h @@ -10,9 +10,6 @@ #include "ntp_refclock.h" #include "recvbuff.h" -#define MAXINTERFACES 512 -#define MAXFILENAME 128 /* maximum length of a file name */ - #ifdef SYS_WINNT #define exit service_exit extern void service_exit (int); @@ -21,8 +18,6 @@ void service_main (DWORD, LPTSTR *); void service_ctrl (DWORD); void worker_thread (void *); #define sleep(x) Sleep((DWORD) x * 1000 /* milliseconds */ ); -#else -#define closesocket close #endif /* SYS_WINNT */ /* ntp_config.c */ @@ -30,9 +25,9 @@ extern void getconfig P((int, char **)); /* ntp_config.c */ extern void ctl_clr_stats P((void)); -extern int ctlclrtrap P((struct sockaddr_in *, struct interface *, int)); +extern int ctlclrtrap P((struct sockaddr_storage *, struct interface *, int)); extern u_short ctlpeerstatus P((struct peer *)); -extern int ctlsettrap P((struct sockaddr_in *, struct interface *, int, int)); +extern int ctlsettrap P((struct sockaddr_storage *, struct interface *, int, int)); extern u_short ctlsysstatus P((void)); extern void init_control P((void)); extern void process_control P((struct recvbuf *, int)); @@ -65,30 +60,30 @@ struct ctl_var { #define WO (CAN_WRITE) #define RW (CAN_READ|CAN_WRITE) -extern char * add_var P((struct ctl_var **, unsigned long, int)); +extern char * add_var P((struct ctl_var **, u_long, u_short)); extern void free_varlist P((struct ctl_var *)); -extern void set_var P((struct ctl_var **, const char *, unsigned long, int)); -extern void set_sys_var P((char *, unsigned long, int)); +extern void set_var P((struct ctl_var **, const char *, u_long, u_short)); +extern void set_sys_var P((char *, u_long, u_short)); /* ntp_intres.c */ -extern void ntp_res_name P((u_int32, u_short)); +extern void ntp_res_name P((struct sockaddr_storage, u_short)); extern void ntp_res_recv P((void)); extern void ntp_intres P((void)); /* ntp_io.c */ -extern struct interface *findinterface P((struct sockaddr_in *)); -extern struct interface *findbcastinter P((struct sockaddr_in *)); +extern struct interface *findinterface P((struct sockaddr_storage *)); +extern struct interface *findbcastinter P((struct sockaddr_storage *)); extern void init_io P((void)); extern void input_handler P((l_fp *)); extern void io_clr_stats P((void)); extern void io_setbclient P((void)); extern void io_unsetbclient P((void)); -extern void io_multicast_add P((u_int32)); -extern void io_multicast_del P((u_int32)); -extern void kill_asyncio P((void)); +extern void io_multicast_add P((struct sockaddr_storage)); +extern void io_multicast_del P((struct sockaddr_storage)); +extern void kill_asyncio P((int)); -extern void sendpkt P((struct sockaddr_in *, struct interface *, int, struct pkt *, int)); +extern void sendpkt P((struct sockaddr_storage *, struct interface *, int, struct pkt *, int)); #ifdef HAVE_SIGNALED_IO extern void wait_for_signal P((void)); extern void unblock_io_and_alarm P((void)); @@ -122,29 +117,46 @@ extern void ntp_monitor P((struct recvbuf *)); /* ntp_peer.c */ extern void init_peer P((void)); -extern struct peer *findexistingpeer P((struct sockaddr_in *, struct peer *, int)); -extern struct peer *findpeer P((struct sockaddr_in *, struct interface *, int, int, int *)); +extern struct peer *findexistingpeer P((struct sockaddr_storage *, struct peer *, int)); +extern struct peer *findpeer P((struct sockaddr_storage *, struct interface *, int, int, int *)); extern struct peer *findpeerbyassoc P((u_int)); -extern struct peer *newpeer P((struct sockaddr_in *, struct interface *, int, int, int, int, u_int, u_int, int, keyid_t)); +extern struct peer *newpeer P((struct sockaddr_storage *, struct interface *, int, int, int, int, u_int, u_char, int, keyid_t)); extern void peer_all_reset P((void)); extern void peer_clr_stats P((void)); -extern struct peer *peer_config P((struct sockaddr_in *, struct interface *, int, int, int, int, u_int, int, keyid_t, u_char *)); +extern struct peer *peer_config P((struct sockaddr_storage *, struct interface *, int, int, int, int, u_int, int, keyid_t, u_char *)); extern void peer_reset P((struct peer *)); -extern int peer_unconfig P((struct sockaddr_in *, struct interface *, int)); +extern int peer_unconfig P((struct sockaddr_storage *, struct interface *, int)); extern void unpeer P((struct peer *)); extern void clear_all P((void)); -#ifdef AUTOKEY +#ifdef OPENSSL extern void expire_all P((void)); -#endif /* AUTOKEY */ +#endif /* OPENSSL */ extern struct peer *findmanycastpeer P((struct recvbuf *)); extern void resetmanycast P((void)); +/* ntp_crypto.c */ +#ifdef OPENSSL +extern int crypto_recv P((struct peer *, struct recvbuf *)); +extern int crypto_xmit P((struct pkt *, struct sockaddr_storage *, int, struct exten *, keyid_t)); +extern keyid_t session_key P((struct sockaddr_storage *, struct sockaddr_storage *, keyid_t, keyid_t, u_long)); +extern void make_keylist P((struct peer *, struct interface *)); +extern void key_expire P((struct peer *)); +extern void crypto_update P((void)); +extern void crypto_config P((int, char *)); +extern void crypto_setup P((void)); +extern u_int crypto_ident P((struct peer *)); +extern struct exten *crypto_args P((struct peer *, u_int, char *)); +extern int crypto_public P((struct peer *, u_char *, u_int)); +extern void value_free P((struct value *)); +#endif /* OPENSSL */ + /* ntp_proto.c */ extern void transmit P((struct peer *)); extern void receive P((struct recvbuf *)); -extern void peer_clear P((struct peer *)); +extern void peer_clear P((struct peer *, char *)); extern void process_packet P((struct peer *, struct pkt *, l_fp *)); extern void clock_select P((void)); +extern void kod_proto P((void)); /* * there seems to be a bug in the IRIX 4 compiler which prevents @@ -157,7 +169,7 @@ extern void poll_update P((struct peer *, int)); extern void clear P((struct peer *)); extern void clock_filter P((struct peer *, double, double, double)); extern void init_proto P((void)); -extern void proto_config P((int, u_long, double)); +extern void proto_config P((int, u_long, double, struct sockaddr_storage*)); extern void proto_clr_stats P((void)); #ifdef REFCLOCK @@ -175,26 +187,30 @@ extern void process_private P((struct recvbuf *, int)); /* ntp_restrict.c */ extern void init_restrict P((void)); -extern int restrictions P((struct sockaddr_in *)); -extern void hack_restrict P((int, struct sockaddr_in *, struct sockaddr_in *, int, int)); +extern int restrictions P((struct sockaddr_storage *)); +extern void hack_restrict P((int, struct sockaddr_storage *, struct sockaddr_storage *, int, int)); /* ntp_timer.c */ extern void init_timer P((void)); +extern void reinit_timer P((void)); extern void timer P((void)); extern void timer_clr_stats P((void)); -#ifdef AUTOKEY +#ifdef OPENSSL extern char *sys_hostname; extern l_fp sys_revoketime; -#endif /* AUTOKEY */ +#endif /* OPENSSL */ /* ntp_util.c */ extern void init_util P((void)); extern void hourly_stats P((void)); extern void stats_config P((int, char *)); -extern void record_peer_stats P((struct sockaddr_in *, int, double, double, double, double)); +extern void record_peer_stats P((struct sockaddr_storage *, int, double, double, double, double)); extern void record_loop_stats P((double, double, double, double, int)); -extern void record_clock_stats P((struct sockaddr_in *, const char *)); -extern void record_raw_stats P((struct sockaddr_in *, struct sockaddr_in *, l_fp *, l_fp *, l_fp *, l_fp *)); +extern void record_clock_stats P((struct sockaddr_storage *, const char *)); +extern void record_raw_stats P((struct sockaddr_storage *, struct sockaddr_storage *, l_fp *, l_fp *, l_fp *, l_fp *)); +extern void record_sys_stats P((void)); +extern void record_crypto_stats P((struct sockaddr_storage *, const char *)); +extern int sock_hash P((struct sockaddr_storage *)); /* * Variable declarations for ntpd. @@ -254,7 +270,8 @@ extern u_long io_timereset; /* time counters were reset */ /* * Interface stuff */ -extern struct interface *any_interface; /* default interface */ +extern struct interface *any_interface; /* default ipv4 interface */ +extern struct interface *any6_interface;/* default ipv6 interface */ extern struct interface *loopback_interface; /* loopback interface */ /* @@ -284,21 +301,20 @@ extern int kern_enable; /* kernel support enabled */ extern int pps_enable; /* kernel PPS discipline enabled */ extern int ext_enable; /* external clock enabled */ extern int cal_enable; /* refclock calibrate enable */ -extern int allow_step; /* allow step correction */ extern int allow_panic; /* allow panic correction */ extern int mode_ntpdate; /* exit on first clock set */ extern int peer_ntpdate; /* count of ntpdate peers */ +extern int forground_process; /* run the process in the forground */ /* * Clock state machine variables */ extern u_char sys_poll; /* system poll interval (log2 s) */ -extern u_char sys_minpoll; /* min system poll interval (log2 s) */ extern int state; /* clock discipline state */ extern int tc_counter; /* poll-adjust counter */ extern u_long last_time; /* time of last clock update (s) */ extern double last_offset; /* last clock offset (s) */ -extern u_char allan_xpt; /* Allan intercept (s) */ +extern double allan_xpt; /* Allan intercept (s) */ extern double sys_error; /* system RMS error (s) */ extern double sys_jitter; /* system RMS jitter (s) */ @@ -349,20 +365,27 @@ extern double sys_bdelay; /* broadcast client default delay */ extern int sys_authenticate; /* requre authentication for config */ extern l_fp sys_authdelay; /* authentication delay */ extern keyid_t sys_private; /* private value for session seed */ -extern int sys_manycastserver; /* 1 => respond to manycast client pkts */ +extern int sys_manycastserver; /* respond to manycast client pkts */ +extern int sys_minclock; /* minimum survivors */ +extern int sys_minsane; /* minimum candidates */ +extern int sys_floor; /* cluster stratum floor */ +extern int sys_ceiling; /* cluster stratum ceiling */ +extern u_char sys_ttl[]; /* ttl mapping vector */ +extern int sys_ttlmax; /* max ttl mapping vector index */ /* * Statistics counters */ extern u_long sys_stattime; /* time when we started recording */ -extern u_long sys_badstratum; /* packets with invalid stratum */ -extern u_long sys_oldversionpkt; /* old version packets received */ -extern u_long sys_newversionpkt; /* new version packets received */ +extern u_long sys_restricted; /* restricted packets */ +extern u_long sys_oldversionpkt; /* old version packets */ +extern u_long sys_newversionpkt; /* new version packets */ extern u_long sys_unknownversion; /* don't know version packets */ -extern u_long sys_badlength; /* packets with bad length */ +extern u_long sys_badlength; /* bad length or format */ extern u_long sys_processed; /* packets processed */ -extern u_long sys_badauth; /* packets dropped because of auth */ -extern u_long sys_limitrejected; /* pkts rejected due to client count per net */ +extern u_long sys_badauth; /* bad authentication */ +extern u_long sys_limitrejected; /* rate limit exceeded */ +extern u_long sys_received; /* packets received */ /* ntp_refclock.c */ #ifdef REFCLOCK @@ -375,13 +398,15 @@ extern int fdpps; /* pps file descriptor */ extern keyid_t info_auth_keyid; /* keyid used to authenticate requests */ /* ntp_restrict.c */ -extern struct restrictlist *restrictlist; /* the restriction list */ -extern u_long client_limit; -extern u_long client_limit_period; +extern struct restrictlist *restrictlist; /* the ipv4 restriction list */ +extern struct restrictlist6 *restrictlist6; /* the ipv6 restriction list */ +extern u_long res_min_interval; +extern u_long res_avg_interval; +extern u_long mon_age; /* monitor preempt age */ /* ntp_timer.c */ extern volatile int alarm_flag; /* alarm flag */ -extern u_long sys_revoke; /* keys revoke timeout */ +extern u_char sys_revoke; /* keys revoke timeout (log2 s) */ extern volatile u_long alarm_overflow; extern u_long current_time; /* current time (s) */ extern u_long timer_timereset; @@ -395,6 +420,11 @@ extern int stats_control; /* write stats to fileset? */ extern volatile int debug; /* debugging flag */ extern int nofork; /* no-fork flag */ extern int initializing; /* initializing flag */ +#ifdef HAVE_CLOCKCTL +extern char *user; /* user to switch to */ +extern char *group; /* group to switch to */ +extern char *chrootdir; /* directory to chroot to */ +#endif /* refclock_conf.c */ #ifdef REFCLOCK diff --git a/contrib/ntp/include/ntpsim.h b/contrib/ntp/include/ntpsim.h new file mode 100644 index 000000000000..c48dc59542be --- /dev/null +++ b/contrib/ntp/include/ntpsim.h @@ -0,0 +1,93 @@ +/* + * ntpsim.h - Prototypes for ntpsim + */ + +#ifndef __ntpsim_h +#define __ntpsim_h + +#include <stdio.h> +#include <math.h> +#include <sys/socket.h> +#include <arpa/inet.h> +#include "ntp_syslog.h" +#include "ntp_fp.h" +#include "ntp.h" +#include "ntp_select.h" +#include "ntp_malloc.h" +#include "ntp_refclock.h" +#include "recvbuff.h" +#include "ntp_io.h" +#include "ntp_stdlib.h" + +#define PI 3.1415926535 + +/* + * ntpsim declarations + */ +typedef enum { + BEEP, CLOCK, TIMER, PACKET +} funcTkn; + +typedef struct { + double time; + union { + struct pkt evnt_pkt; + struct recvbuf evnt_buf; + } buffer; +#define ntp_pkt buffer.evnt_pkt +#define rcv_buf buffer.evnt_buf + funcTkn function; +} Event; + +typedef struct List { + Event event; + struct List *next; +} *Queue; + +typedef struct nde { + double time; /* simulation time */ + double sim_time; /* end simulation time */ + double ntp_time; /* client disciplined time */ + double adj; /* remaining time correction */ + double slew; /* correction slew rate */ + + double clk_time; /* server time */ + double ferr; /* frequency errort */ + double fnse; /* random walk noise */ + double ndly; /* network delay */ + double snse; /* phase noise */ + double pdly; /* processing delay */ + double bdly; /* beep interval */ + + double last_time; /* last clock read time */ + Queue events; /* Node Event Queue */ + struct recvbuf *rbuflist; /* Node Receive Buffer */ +} Node; + +/* + * Function prototypes + */ +int ntpsim P((int argc, char *argv[])); +Event event P((double, funcTkn)); +Queue queue P((Event, Queue )); +Node node P((void)); +void push P((Event, Queue *)); +Event pop P((Queue *)); +void ndbeep P((Node *, Event)); +void ndeclk P((Node *, Event)); +void ntptmr P((Node *, Event)); +void netpkt P((Node *, Event)); +int srvr_rply P((Node *, struct sockaddr_storage *, + struct interface *, struct pkt *)); +double gauss P((double, double)); +double poisson P((double, double)); +int node_clock P((Node *, double)); +void abortsim P((char *)); + +/* + * The global Node + */ +Node ntp_node; + +#endif + diff --git a/contrib/ntp/include/recvbuff.h b/contrib/ntp/include/recvbuff.h index 687bc9659a6d..4fde7f19250a 100644 --- a/contrib/ntp/include/recvbuff.h +++ b/contrib/ntp/include/recvbuff.h @@ -39,16 +39,16 @@ extern HANDLE get_recv_buff_event P((void)); */ /* - * the maximum length NTP packet is a full length NTP control message with - * the maximum length message authenticator. I hate to hard-code 468 and 12, - * but only a few modules include ntp_control.h... + * the maximum length NTP packet contains the NTP header, one Autokey + * request, one Autokey response and the MAC. Assuming certificates don't + * get too big, the maximum packet length is set arbitrarily at 1000. */ -#define RX_BUFF_SIZE (468+12+MAX_MAC_LEN) +#define RX_BUFF_SIZE 1000 /* hail Mary */ struct recvbuf { struct recvbuf *next; /* next buffer in chain */ union { - struct sockaddr_in X_recv_srcadr; + struct sockaddr_storage X_recv_srcadr; caddr_t X_recv_srcclock; struct peer *X_recv_peer; } X_from_where; @@ -60,10 +60,10 @@ struct recvbuf { WSABUF wsabuff; DWORD AddressLength; #else - struct sockaddr_in srcadr; /* where packet came from */ + struct sockaddr_storage srcadr; /* where packet came from */ #endif struct interface *dstadr; /* interface datagram arrived thru */ - int fd; /* fd on which it was received */ + SOCKET fd; /* fd on which it was received */ l_fp recv_time; /* time of arrival */ void (*receiver) P((struct recvbuf *)); /* routine to receive buffer */ int recv_length; /* number of octets received */ diff --git a/contrib/ntp/include/rsa_md5.h b/contrib/ntp/include/rsa_md5.h new file mode 100644 index 000000000000..8241647601b3 --- /dev/null +++ b/contrib/ntp/include/rsa_md5.h @@ -0,0 +1,51 @@ +/* MD5.H - header file for MD5C.C + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +#ifndef _MD5_H_ +#define _MD5_H_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/*#include "global.h" */ + +/* MD5 context. */ +typedef struct { + UINT4 state[4]; /* state (ABCD) */ + UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} MD5_CTX; + +void MD5Init PROTO_LIST ((MD5_CTX *)); +void MD5Update PROTO_LIST + ((MD5_CTX *, unsigned char *, unsigned int)); +void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *)); + +#ifdef __cplusplus +} +#endif + +#endif |