diff options
Diffstat (limited to 'include')
88 files changed, 3025 insertions, 5777 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 1fbe6fcfe35f..88727ddaf4e5 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,63 +1,72 @@ -#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies -AUTOMAKE_OPTIONS = ../util/ansi2knr +NULL = +AUTOMAKE_OPTIONS = ETAGS_ARGS = $(srcdir)/Makefile.am -EXTRA_DIST = autogen-version.def copyright.def debug-opt.def homerc.def version.def +EXTRA_DIST = autogen-version.def copyright.def debug-opt.def homerc.def version.def version.texi SUBDIRS = isc -noinst_HEADERS = \ - adjtime.h \ - audio.h \ - ascii.h \ - audio.h \ - binio.h \ - global.h \ - gps.h \ - hopf6039.h \ - icom.h \ - ieee754io.h \ - iosignal.h \ - l_stdlib.h \ - mbg_gps166.h \ - mx4200.h \ - ntif.h \ - ntp.h \ - ntp_calendar.h \ - ntp_cmdargs.h \ - ntp_config.h \ - ntp_control.h \ - ntp_crypto.h \ - ntp_datum.h \ - ntp_debug.h \ - ntp_filegen.h \ - ntp_fp.h \ - ntp_if.h \ - ntp_io.h \ - ntp_machine.h \ - ntp_malloc.h \ - ntp_md5.h \ - ntp_proto.h \ - ntp_random.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 \ - ntp_syslog.h \ - ntp_tty.h \ - ntp_types.h \ - ntp_unixtime.h \ - ntpd.h \ - ntpsim.h \ - parse.h \ - parse_conf.h \ - recvbuff.h \ - rsa_md5.h \ +noinst_HEADERS = \ + adjtime.h \ + audio.h \ + ascii.h \ + audio.h \ + binio.h \ + gps.h \ + hopf6039.h \ + icom.h \ + ieee754io.h \ + iosignal.h \ + l_stdlib.h \ + lib_strbuf.h \ + mbg_gps166.h \ + mx4200.h \ + ntif.h \ + ntp.h \ + ntp_assert.h \ + ntp_calendar.h \ + ntp_cmdargs.h \ + ntp_config.h \ + ntp_control.h \ + ntp_crypto.h \ + ntp_data_structures.h \ + ntp_datum.h \ + ntp_debug.h \ + ntp_filegen.h \ + ntp_fp.h \ + ntp_if.h \ + ntp_intres.h \ + ntp_io.h \ + ntp_libopts.h \ + ntp_lineedit.h \ + ntp_lists.h \ + ntp_machine.h \ + ntp_malloc.h \ + ntp_md5.h \ + ntp_net.h \ + ntp_proto.h \ + ntp_random.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 \ + ntp_syslog.h \ + ntp_tty.h \ + ntp_types.h \ + ntp_unixtime.h \ + ntpd.h \ + ntpsim.h \ + parse.h \ + parse_conf.h \ + recvbuff.h \ + refclock_atom.h \ + ssl_applink.c \ timepps-SCO.h \ timepps-Solaris.h \ timepps-SunOS.h \ - trimble.h + trimble.h \ + $(NULL) diff --git a/include/Makefile.in b/include/Makefile.in index 70b0330d7681..2f285def317b 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -38,9 +38,15 @@ subdir = include DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ - $(top_srcdir)/m4/define_dir.m4 \ - $(top_srcdir)/m4/hs_ulong_const.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ + $(top_srcdir)/m4/define_dir.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/ntp_cacheversion.m4 \ + $(top_srcdir)/m4/ntp_dir_sep.m4 \ + $(top_srcdir)/m4/ntp_lineeditlibs.m4 \ + $(top_srcdir)/m4/ntp_openssl.m4 \ + $(top_srcdir)/m4/ntp_vpathhack.m4 \ $(top_srcdir)/m4/os_cflags.m4 $(top_srcdir)/version.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -96,7 +102,6 @@ am__relativize = \ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ -ARLIB_DIR = @ARLIB_DIR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -113,14 +118,18 @@ CYGPATH_W = @CYGPATH_W@ DCFD = @DCFD@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -ECHO = @ECHO@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ +EDITLINE_LIBS = @EDITLINE_LIBS@ EF_LIBS = @EF_LIBS@ EF_PROGS = @EF_PROGS@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +FGREP = @FGREP@ GREP = @GREP@ HAVE_INLINE = @HAVE_INLINE@ INSTALL = @INSTALL@ @@ -129,6 +138,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LCRYPTO = @LCRYPTO@ +LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ @@ -137,6 +147,7 @@ LIBOPTS_LDADD = @LIBOPTS_LDADD@ LIBPARSE = @LIBPARSE@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ LTLIBOBJS = @LTLIBOBJS@ @@ -148,15 +159,22 @@ MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@ MAKE_LIBPARSE = @MAKE_LIBPARSE@ MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@ MAKE_NTPDSIM = @MAKE_NTPDSIM@ +MAKE_NTPSNMPD = @MAKE_NTPSNMPD@ MAKE_NTPTIME = @MAKE_NTPTIME@ MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@ MAKE_TICKADJ = @MAKE_TICKADJ@ MAKE_TIMETRIM = @MAKE_TIMETRIM@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL = @OPENSSL@ OPENSSL_INC = @OPENSSL_INC@ OPENSSL_LIB = @OPENSSL_LIB@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -164,23 +182,32 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@ PATH_PERL = @PATH_PERL@ PATH_SEPARATOR = @PATH_SEPARATOR@ PATH_SH = @PATH_SH@ +PATH_TEST = @PATH_TEST@ +POSIX_SHELL = @POSIX_SHELL@ PROPDELAY = @PROPDELAY@ RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ +SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ +SNMP_CFLAGS = @SNMP_CFLAGS@ +SNMP_CPPFLAGS = @SNMP_CPPFLAGS@ +SNMP_LIBS = @SNMP_LIBS@ STRIP = @STRIP@ TESTDCF = @TESTDCF@ -U = @U@ VERSION = @VERSION@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -227,67 +254,75 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ - -#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies -AUTOMAKE_OPTIONS = ../util/ansi2knr +NULL = +AUTOMAKE_OPTIONS = ETAGS_ARGS = $(srcdir)/Makefile.am -EXTRA_DIST = autogen-version.def copyright.def debug-opt.def homerc.def version.def +EXTRA_DIST = autogen-version.def copyright.def debug-opt.def homerc.def version.def version.texi SUBDIRS = isc noinst_HEADERS = \ - adjtime.h \ - audio.h \ - ascii.h \ - audio.h \ - binio.h \ - global.h \ - gps.h \ - hopf6039.h \ - icom.h \ - ieee754io.h \ - iosignal.h \ - l_stdlib.h \ - mbg_gps166.h \ - mx4200.h \ - ntif.h \ - ntp.h \ - ntp_calendar.h \ - ntp_cmdargs.h \ - ntp_config.h \ - ntp_control.h \ - ntp_crypto.h \ - ntp_datum.h \ - ntp_debug.h \ - ntp_filegen.h \ - ntp_fp.h \ - ntp_if.h \ - ntp_io.h \ - ntp_machine.h \ - ntp_malloc.h \ - ntp_md5.h \ - ntp_proto.h \ - ntp_random.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 \ - ntp_syslog.h \ - ntp_tty.h \ - ntp_types.h \ - ntp_unixtime.h \ - ntpd.h \ - ntpsim.h \ - parse.h \ - parse_conf.h \ - recvbuff.h \ - rsa_md5.h \ + adjtime.h \ + audio.h \ + ascii.h \ + audio.h \ + binio.h \ + gps.h \ + hopf6039.h \ + icom.h \ + ieee754io.h \ + iosignal.h \ + l_stdlib.h \ + lib_strbuf.h \ + mbg_gps166.h \ + mx4200.h \ + ntif.h \ + ntp.h \ + ntp_assert.h \ + ntp_calendar.h \ + ntp_cmdargs.h \ + ntp_config.h \ + ntp_control.h \ + ntp_crypto.h \ + ntp_data_structures.h \ + ntp_datum.h \ + ntp_debug.h \ + ntp_filegen.h \ + ntp_fp.h \ + ntp_if.h \ + ntp_intres.h \ + ntp_io.h \ + ntp_libopts.h \ + ntp_lineedit.h \ + ntp_lists.h \ + ntp_machine.h \ + ntp_malloc.h \ + ntp_md5.h \ + ntp_net.h \ + ntp_proto.h \ + ntp_random.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 \ + ntp_syslog.h \ + ntp_tty.h \ + ntp_types.h \ + ntp_unixtime.h \ + ntpd.h \ + ntpsim.h \ + parse.h \ + parse_conf.h \ + recvbuff.h \ + refclock_atom.h \ + ssl_applink.c \ timepps-SCO.h \ timepps-Solaris.h \ timepps-SunOS.h \ - trimble.h + trimble.h \ + $(NULL) all: all-recursive @@ -336,7 +371,7 @@ clean-libtool: # (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): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -361,7 +396,7 @@ $(RECURSIVE_TARGETS): fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ diff --git a/include/audio.h b/include/audio.h index 6d16347ec80d..1b969bd49ebd 100644 --- a/include/audio.h +++ b/include/audio.h @@ -9,6 +9,6 @@ /* * Function prototypes */ -int audio_init P((char *, int, int)); -int audio_gain P((int, int, int)); -void audio_show P((void)); +int audio_init (char *, int, int); +int audio_gain (int, int, int); +void audio_show (void); diff --git a/include/autogen-version.def b/include/autogen-version.def index 89439830eb87..d69457ccf1e0 100644 --- a/include/autogen-version.def +++ b/include/autogen-version.def @@ -1,2 +1,2 @@ -#assert (version-compare >= autogen-version "5.9.1") +#assert (version-compare >= autogen-version "5.11.9") guard-option-names; diff --git a/include/binio.h b/include/binio.h index 56e671fdb2fe..d1ee94429144 100644 --- a/include/binio.h +++ b/include/binio.h @@ -37,15 +37,15 @@ #include "ntp_stdlib.h" -long get_lsb_short P((unsigned char **)); -void put_lsb_short P((unsigned char **, long)); -long get_lsb_long P((unsigned char **)); -void put_lsb_long P((unsigned char **, long)); +long get_lsb_short (unsigned char **); +void put_lsb_short (unsigned char **, long); +long get_lsb_long (unsigned char **); +void put_lsb_long (unsigned char **, long); -long get_msb_short P((unsigned char **)); -void put_msb_short P((unsigned char **, long)); -long get_msb_long P((unsigned char **)); -void put_msb_long P((unsigned char **, long)); +long get_msb_short (unsigned char **); +void put_msb_short (unsigned char **, long); +long get_msb_long (unsigned char **); +void put_msb_long (unsigned char **, long); #endif /* diff --git a/include/copyright.def b/include/copyright.def index ccc3e91cf215..0f1708c5d7c5 100644 --- a/include/copyright.def +++ b/include/copyright.def @@ -1,18 +1,24 @@ /* -*- Mode: Text -*- */ copyright = { - date = "1970-2009"; + date = "1970-2011"; owner = "David L. Mills and/or others"; eaddr = "http://bugs.ntp.org, bugs@ntp.org"; type = note; - text = "see html/copyright.html"; + text = <<- _EndOfDoc_ + see html/copyright.html + + _EndOfDoc_; }; long-opts; config-header = config.h; environrc; +no-misuse-usage; version = ` eval VERSION=\`sed -e 's/.*,\\[//' -e 's/\\].*//' < ../version.m4\` [ -z "${VERSION}" ] && echo "Cannot determine VERSION" && kill -TERM $AG_pid echo $VERSION`; + +version-value = ''; /* Don't use -v as a shortcut for --version */ diff --git a/include/debug-opt.def b/include/debug-opt.def index 2c3da2a635bd..783e5b0b1ff0 100644 --- a/include/debug-opt.def +++ b/include/debug-opt.def @@ -11,7 +11,6 @@ flag = { name = debug-level; value = d; max = NOLIMIT; - ifdef = DEBUG; nopreset; descrip = "Increase output debug message level"; doc = <<- _EndOfDoc_ @@ -23,7 +22,6 @@ flag = { name = set-debug-level; value = D; max = NOLIMIT; - ifdef = DEBUG; descrip = "Set the output debug message level"; arg-type = string; flag-code = 'DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );'; diff --git a/include/global.h b/include/global.h deleted file mode 100644 index 742f84cd9433..000000000000 --- a/include/global.h +++ /dev/null @@ -1,54 +0,0 @@ -/* GLOBAL.H - RSAREF types and constants */ - -/* Copyright (C) RSA Laboratories, a division of RSA Data Security, - Inc., created 1991. All rights reserved. - */ - -/* - * Note: the modifications are necessary for little-endian machines - */ -#include "ntp_types.h" /* local modification */ - -#ifndef _GLOBAL_H_ -#define _GLOBAL_H_ 1 - -/* PROTOTYPES should be set to one if and only if the compiler supports - function argument prototyping. - The following makes PROTOTYPES default to 1 if it has not already been - defined as 0 with C compiler flags. - */ -#ifdef HAVE_PROTOTYPES -#define PROTOTYPES 1 -#endif - -/* POINTER defines a generic pointer type */ -typedef unsigned char *POINTER; - -/* UINT2 defines a two byte word */ -typedef unsigned short int UINT2; - -/* UINT4 defines a four byte word */ -typedef u_int32 UINT4; /* local modification */ - -/* BYTE defines a unsigned character */ -typedef unsigned char BYTE; /* local modification for RSAEuro */ - -#ifndef NULL_PTR -#define NULL_PTR ((POINTER)0) -#endif - -#ifndef UNUSED_ARG -#define UNUSED_ARG(x) x = *(&x); -#endif - -/* PROTO_LIST is defined depending on how PROTOTYPES is defined above. - If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it - returns an empty list. - */ -#if PROTOTYPES -#define PROTO_LIST(list) list -#else -#define PROTO_LIST(list) () -#endif - -#endif /* end _GLOBAL_H_ */ diff --git a/include/icom.h b/include/icom.h index aac62c8d3de4..66d12e51f1cc 100755 --- a/include/icom.h +++ b/include/icom.h @@ -83,5 +83,5 @@ /* * Function prototypes */ -int icom_init P((char *, int, int)); -int icom_freq P((int, int, double)); +int icom_init (char *, int, int); +int icom_freq (int, int, double); diff --git a/include/ieee754io.h b/include/ieee754io.h index 6906731cbfb4..73e7f798308a 100644 --- a/include/ieee754io.h +++ b/include/ieee754io.h @@ -52,8 +52,8 @@ #define IEEE_OFFSETS 8 /* number of byte positions */ typedef unsigned char offsets_t[IEEE_OFFSETS]; -int fetch_ieee754 P((unsigned char **bufp, int size, l_fp *lfpp, offsets_t offsets)); -int put_ieee754 P((unsigned char **bufpp, int size, l_fp *lfpp, offsets_t offsets)); +int fetch_ieee754 (unsigned char **bufp, int size, l_fp *lfpp, offsets_t offsets); +int put_ieee754 (unsigned char **bufpp, int size, l_fp *lfpp, offsets_t offsets); #endif /* diff --git a/include/iosignal.h b/include/iosignal.h index bd74e096d00b..6c4052b7f049 100644 --- a/include/iosignal.h +++ b/include/iosignal.h @@ -4,15 +4,15 @@ #include "ntp_refclock.h" #if defined(HAVE_SIGNALED_IO) -extern void block_sigio P((void)); -extern void unblock_sigio P((void)); -extern int init_clock_sig P((struct refclockio *)); -extern void init_socket_sig P((int)); -extern void set_signal P((void)); -RETSIGTYPE sigio_handler P((int)); +extern void block_sigio (void); +extern void unblock_sigio (void); +extern int init_clock_sig (struct refclockio *); +extern void init_socket_sig (int); +extern void set_signal (void); +RETSIGTYPE sigio_handler (int); -# define BLOCKIO() ((void) block_sigio()) -# define UNBLOCKIO() ((void) unblock_sigio()) +# define BLOCKIO() block_sigio() +# define UNBLOCKIO() unblock_sigio() #else diff --git a/include/isc/Makefile.am b/include/isc/Makefile.am index 3d8c2a47f90e..14aa70813e16 100644 --- a/include/isc/Makefile.am +++ b/include/isc/Makefile.am @@ -1,37 +1,7 @@ -#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies -AUTOMAKE_OPTIONS = ../util/ansi2knr +NULL = +AUTOMAKE_OPTIONS = ETAGS_ARGS = $(srcdir)/Makefile.am -#EXTRA_DIST = TAGS -noinst_HEADERS = \ - app.h \ - assertions.h \ - boolean.h \ - buffer.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 \ - netscope.h \ - offset.h \ - once.h \ - platform.h \ - print.h \ - result.h \ - region.h \ - sockaddr.h \ - strerror.h \ - string.h \ - types.h \ - util.h +noinst_HEADERS = \ + mem.h \ + $(NULL) diff --git a/include/isc/Makefile.in b/include/isc/Makefile.in index 531da09b454c..b792b24eb823 100644 --- a/include/isc/Makefile.in +++ b/include/isc/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -38,9 +38,15 @@ subdir = include/isc DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ - $(top_srcdir)/m4/define_dir.m4 \ - $(top_srcdir)/m4/hs_ulong_const.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ + $(top_srcdir)/m4/define_dir.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/ntp_cacheversion.m4 \ + $(top_srcdir)/m4/ntp_dir_sep.m4 \ + $(top_srcdir)/m4/ntp_lineeditlibs.m4 \ + $(top_srcdir)/m4/ntp_openssl.m4 \ + $(top_srcdir)/m4/ntp_vpathhack.m4 \ $(top_srcdir)/m4/os_cflags.m4 $(top_srcdir)/version.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -58,7 +64,6 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ -ARLIB_DIR = @ARLIB_DIR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -75,14 +80,18 @@ CYGPATH_W = @CYGPATH_W@ DCFD = @DCFD@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -ECHO = @ECHO@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ +EDITLINE_LIBS = @EDITLINE_LIBS@ EF_LIBS = @EF_LIBS@ EF_PROGS = @EF_PROGS@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +FGREP = @FGREP@ GREP = @GREP@ HAVE_INLINE = @HAVE_INLINE@ INSTALL = @INSTALL@ @@ -91,6 +100,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LCRYPTO = @LCRYPTO@ +LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ @@ -99,6 +109,7 @@ LIBOPTS_LDADD = @LIBOPTS_LDADD@ LIBPARSE = @LIBPARSE@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ LTLIBOBJS = @LTLIBOBJS@ @@ -110,15 +121,22 @@ MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@ MAKE_LIBPARSE = @MAKE_LIBPARSE@ MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@ MAKE_NTPDSIM = @MAKE_NTPDSIM@ +MAKE_NTPSNMPD = @MAKE_NTPSNMPD@ MAKE_NTPTIME = @MAKE_NTPTIME@ MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@ MAKE_TICKADJ = @MAKE_TICKADJ@ MAKE_TIMETRIM = @MAKE_TIMETRIM@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL = @OPENSSL@ OPENSSL_INC = @OPENSSL_INC@ OPENSSL_LIB = @OPENSSL_LIB@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -126,23 +144,32 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@ PATH_PERL = @PATH_PERL@ PATH_SEPARATOR = @PATH_SEPARATOR@ PATH_SH = @PATH_SH@ +PATH_TEST = @PATH_TEST@ +POSIX_SHELL = @POSIX_SHELL@ PROPDELAY = @PROPDELAY@ RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ +SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ +SNMP_CFLAGS = @SNMP_CFLAGS@ +SNMP_CPPFLAGS = @SNMP_CPPFLAGS@ +SNMP_LIBS = @SNMP_LIBS@ STRIP = @STRIP@ TESTDCF = @TESTDCF@ -U = @U@ VERSION = @VERSION@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -189,43 +216,12 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ - -#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies -AUTOMAKE_OPTIONS = ../util/ansi2knr +NULL = +AUTOMAKE_OPTIONS = ETAGS_ARGS = $(srcdir)/Makefile.am -#EXTRA_DIST = TAGS noinst_HEADERS = \ - app.h \ - assertions.h \ - boolean.h \ - buffer.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 \ - netscope.h \ - offset.h \ - once.h \ - platform.h \ - print.h \ - result.h \ - region.h \ - sockaddr.h \ - strerror.h \ - string.h \ - types.h \ - util.h + mem.h \ + $(NULL) all: all-am diff --git a/include/isc/app.h b/include/isc/app.h deleted file mode 100644 index 5aa3d23acaca..000000000000 --- a/include/isc/app.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - * 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/include/isc/assertions.h b/include/isc/assertions.h deleted file mode 100644 index 45855c663180..000000000000 --- a/include/isc/assertions.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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/include/isc/boolean.h b/include/isc/boolean.h deleted file mode 100644 index d10007b5802a..000000000000 --- a/include/isc/boolean.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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/include/isc/buffer.h b/include/isc/buffer.h deleted file mode 100644 index 47c8f0c95d41..000000000000 --- a/include/isc/buffer.h +++ /dev/null @@ -1,800 +0,0 @@ -/* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") - * 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 ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC 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: buffer.h,v 1.39.12.2 2004/03/08 09:04:51 marka Exp $ */ - -#ifndef ISC_BUFFER_H -#define ISC_BUFFER_H 1 - -/***** - ***** Module Info - *****/ - -/* - * Buffers - * - * A buffer is a region of memory, together with a set of related subregions. - * Buffers are used for parsing and I/O operations. - * - * The 'used region' and the 'available' region are disjoint, and their - * union is the buffer's region. The used region extends from the beginning - * of the buffer region to the last used byte. The available region - * extends from one byte greater than the last used byte to the end of the - * buffer's region. The size of the used region can be changed using various - * buffer commands. Initially, the used region is empty. - * - * The used region is further subdivided into two disjoint regions: the - * 'consumed region' and the 'remaining region'. The union of these two - * regions is the used region. The consumed region extends from the beginning - * of the used region to the byte before the 'current' offset (if any). The - * 'remaining' region the current pointer to the end of the used - * region. The size of the consumed region can be changed using various - * buffer commands. Initially, the consumed region is empty. - * - * The 'active region' is an (optional) subregion of the remaining region. - * It extends from the current offset to an offset in the remaining region - * that is selected with isc_buffer_setactive(). Initially, the active region - * is empty. If the current offset advances beyond the chosen offset, the - * active region will also be empty. - * - * /------------entire length---------------\ - * /----- used region -----\/-- available --\ - * +----------------------------------------+ - * | consumed | remaining | | - * +----------------------------------------+ - * a b c d e - * - * a == base of buffer. - * b == current pointer. Can be anywhere between a and d. - * c == active pointer. Meaningful between b and d. - * d == used pointer. - * e == length of buffer. - * - * a-e == entire length of buffer. - * a-d == used region. - * a-b == consumed region. - * b-d == remaining region. - * b-c == optional active region. - * - * The following invariants are maintained by all routines: - * - * length > 0 - * - * base is a valid pointer to length bytes of memory - * - * 0 <= used <= length - * - * 0 <= current <= used - * - * 0 <= active <= used - * (although active < current implies empty active region) - * - * MP: - * Buffers have no synchronization. Clients must ensure exclusive - * access. - * - * Reliability: - * No anticipated impact. - * - * Resources: - * Memory: 1 pointer + 6 unsigned integers per buffer. - * - * Security: - * No anticipated impact. - * - * Standards: - * None. - */ - -/*** - *** Imports - ***/ - -#include <isc/lang.h> -#include <isc/magic.h> -#include <isc/types.h> - -/* - * To make many functions be inline macros (via #define) define this. - * If it is undefined, a function will be used. - */ -#define ISC_BUFFER_USEINLINE - -ISC_LANG_BEGINDECLS - -/*** - *** Magic numbers - ***/ -#define ISC_BUFFER_MAGIC 0x42756621U /* Buf!. */ -#define ISC_BUFFER_VALID(b) ISC_MAGIC_VALID(b, ISC_BUFFER_MAGIC) - -/* - * The following macros MUST be used only on valid buffers. It is the - * caller's responsibility to ensure this by using the ISC_BUFFER_VALID - * check above, or by calling another isc_buffer_*() function (rather than - * another macro.) - */ - -/* - * Fundamental buffer elements. (A through E in the introductory comment.) - */ -#define isc_buffer_base(b) ((void *)(b)->base) /*a*/ -#define isc_buffer_current(b) \ - ((void *)((unsigned char *)(b)->base + (b)->current)) /*b*/ -#define isc_buffer_active(b) \ - ((void *)((unsigned char *)(b)->base + (b)->active)) /*c*/ -#define isc_buffer_used(b) \ - ((void *)((unsigned char *)(b)->base + (b)->used)) /*d*/ -#define isc_buffer_length(b) ((b)->length) /*e*/ - -/* - * Derived lengths. (Described in the introductory comment.) - */ -#define isc_buffer_usedlength(b) ((b)->used) /* d-a */ -#define isc_buffer_consumedlength(b) ((b)->current) /* b-a */ -#define isc_buffer_remaininglength(b) ((b)->used - (b)->current) /* d-b */ -#define isc_buffer_activelength(b) ((b)->active - (b)->current) /* c-b */ -#define isc_buffer_availablelength(b) ((b)->length - (b)->used) /* e-d */ - -/* - * Note that the buffer structure is public. This is principally so buffer - * operations can be implemented using macros. Applications are strongly - * discouraged from directly manipulating the structure. - */ - -struct isc_buffer { - unsigned int magic; - void *base; - /* The following integers are byte offsets from 'base'. */ - unsigned int length; - unsigned int used; - unsigned int current; - unsigned int active; - /* linkable */ - ISC_LINK(isc_buffer_t) link; - /* private internal elements */ - isc_mem_t *mctx; -}; - -/*** - *** Functions - ***/ - -isc_result_t -isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer, - unsigned int length); -/* - * Allocate a dynamic linkable buffer which has "length" bytes in the - * data region. - * - * Requires: - * "mctx" is valid. - * - * "dynbuffer" is non-NULL, and "*dynbuffer" is NULL. - * - * Returns: - * ISC_R_SUCCESS - success - * ISC_R_NOMEMORY - no memory available - * - * Note: - * Changing the buffer's length field is not permitted. - */ - -void -isc_buffer_free(isc_buffer_t **dynbuffer); -/* - * Release resources allocated for a dynamic buffer. - * - * Requires: - * "dynbuffer" is not NULL. - * - * "*dynbuffer" is a valid dynamic buffer. - * - * Ensures: - * "*dynbuffer" will be NULL on return, and all memory associated with - * the dynamic buffer is returned to the memory context used in - * isc_buffer_allocate(). - */ - -void -isc__buffer_init(isc_buffer_t *b, const void *base, unsigned int length); -/* - * Make 'b' refer to the 'length'-byte region starting at base. - * - * Requires: - * - * 'length' > 0 - * - * 'base' is a pointer to a sequence of 'length' bytes. - * - */ - -void -isc__buffer_invalidate(isc_buffer_t *b); -/* - * Make 'b' an invalid buffer. - * - * Requires: - * 'b' is a valid buffer. - * - * Ensures: - * If assertion checking is enabled, future attempts to use 'b' without - * calling isc_buffer_init() on it will cause an assertion failure. - */ - -void -isc__buffer_region(isc_buffer_t *b, isc_region_t *r); -/* - * Make 'r' refer to the region of 'b'. - * - * Requires: - * - * 'b' is a valid buffer. - * - * 'r' points to a region structure. - */ - -void -isc__buffer_usedregion(isc_buffer_t *b, isc_region_t *r); -/* - * Make 'r' refer to the used region of 'b'. - * - * Requires: - * - * 'b' is a valid buffer. - * - * 'r' points to a region structure. - */ - -void -isc__buffer_availableregion(isc_buffer_t *b, isc_region_t *r); -/* - * Make 'r' refer to the available region of 'b'. - * - * Requires: - * - * 'b' is a valid buffer. - * - * 'r' points to a region structure. - */ - -void -isc__buffer_add(isc_buffer_t *b, unsigned int n); -/* - * Increase the 'used' region of 'b' by 'n' bytes. - * - * Requires: - * - * 'b' is a valid buffer - * - * used + n <= length - * - */ - -void -isc__buffer_subtract(isc_buffer_t *b, unsigned int n); -/* - * Decrease the 'used' region of 'b' by 'n' bytes. - * - * Requires: - * - * 'b' is a valid buffer - * - * used >= n - * - */ - -void -isc__buffer_clear(isc_buffer_t *b); -/* - * Make the used region empty. - * - * Requires: - * - * 'b' is a valid buffer - * - * Ensures: - * - * used = 0 - * - */ - -void -isc__buffer_consumedregion(isc_buffer_t *b, isc_region_t *r); -/* - * Make 'r' refer to the consumed region of 'b'. - * - * Requires: - * - * 'b' is a valid buffer. - * - * 'r' points to a region structure. - */ - -void -isc__buffer_remainingregion(isc_buffer_t *b, isc_region_t *r); -/* - * Make 'r' refer to the remaining region of 'b'. - * - * Requires: - * - * 'b' is a valid buffer. - * - * 'r' points to a region structure. - */ - -void -isc__buffer_activeregion(isc_buffer_t *b, isc_region_t *r); -/* - * Make 'r' refer to the active region of 'b'. - * - * Requires: - * - * 'b' is a valid buffer. - * - * 'r' points to a region structure. - */ - -void -isc__buffer_setactive(isc_buffer_t *b, unsigned int n); -/* - * Sets the end of the active region 'n' bytes after current. - * - * Requires: - * - * 'b' is a valid buffer. - * - * current + n <= used - */ - -void -isc__buffer_first(isc_buffer_t *b); -/* - * Make the consumed region empty. - * - * Requires: - * - * 'b' is a valid buffer - * - * Ensures: - * - * current == 0 - * - */ - -void -isc__buffer_forward(isc_buffer_t *b, unsigned int n); -/* - * Increase the 'consumed' region of 'b' by 'n' bytes. - * - * Requires: - * - * 'b' is a valid buffer - * - * current + n <= used - * - */ - -void -isc__buffer_back(isc_buffer_t *b, unsigned int n); -/* - * Decrease the 'consumed' region of 'b' by 'n' bytes. - * - * Requires: - * - * 'b' is a valid buffer - * - * n <= current - * - */ - -void -isc_buffer_compact(isc_buffer_t *b); -/* - * Compact the used region by moving the remaining region so it occurs - * at the start of the buffer. The used region is shrunk by the size of - * the consumed region, and the consumed region is then made empty. - * - * Requires: - * - * 'b' is a valid buffer - * - * Ensures: - * - * current == 0 - * - * The size of the used region is now equal to the size of the remaining - * region (as it was before the call). The contents of the used region - * are those of the remaining region (as it was before the call). - */ - -isc_uint8_t -isc_buffer_getuint8(isc_buffer_t *b); -/* - * Read an unsigned 8-bit integer from 'b' and return it. - * - * Requires: - * - * 'b' is a valid buffer. - * - * The length of the available region of 'b' is at least 1. - * - * Ensures: - * - * The current pointer in 'b' is advanced by 1. - * - * Returns: - * - * A 8-bit unsigned integer. - */ - -void -isc__buffer_putuint8(isc_buffer_t *b, isc_uint8_t val); -/* - * Store an unsigned 8-bit integer from 'val' into 'b'. - * - * Requires: - * 'b' is a valid buffer. - * - * The length of the unused region of 'b' is at least 1. - * - * Ensures: - * The used pointer in 'b' is advanced by 1. - */ - -isc_uint16_t -isc_buffer_getuint16(isc_buffer_t *b); -/* - * Read an unsigned 16-bit integer in network byte order from 'b', convert - * it to host byte order, and return it. - * - * Requires: - * - * 'b' is a valid buffer. - * - * The length of the available region of 'b' is at least 2. - * - * Ensures: - * - * The current pointer in 'b' is advanced by 2. - * - * Returns: - * - * A 16-bit unsigned integer. - */ - -void -isc__buffer_putuint16(isc_buffer_t *b, isc_uint16_t val); -/* - * Store an unsigned 16-bit integer in host byte order from 'val' - * into 'b' in network byte order. - * - * Requires: - * 'b' is a valid buffer. - * - * The length of the unused region of 'b' is at least 2. - * - * Ensures: - * The used pointer in 'b' is advanced by 2. - */ - -isc_uint32_t -isc_buffer_getuint32(isc_buffer_t *b); -/* - * Read an unsigned 32-bit integer in network byte order from 'b', convert - * it to host byte order, and return it. - * - * Requires: - * - * 'b' is a valid buffer. - * - * The length of the available region of 'b' is at least 4. - * - * Ensures: - * - * The current pointer in 'b' is advanced by 4. - * - * Returns: - * - * A 32-bit unsigned integer. - */ - -void -isc__buffer_putuint32(isc_buffer_t *b, isc_uint32_t val); -/* - * Store an unsigned 32-bit integer in host byte order from 'val' - * into 'b' in network byte order. - * - * Requires: - * 'b' is a valid buffer. - * - * The length of the unused region of 'b' is at least 4. - * - * Ensures: - * The used pointer in 'b' is advanced by 4. - */ - -void -isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base, - unsigned int length); -/* - * Copy 'length' bytes of memory at 'base' into 'b'. - * - * Requires: - * 'b' is a valid buffer. - * - * 'base' points to 'length' bytes of valid memory. - * - */ - -void -isc__buffer_putstr(isc_buffer_t *b, const char *source); -/* - * Copy 'source' into 'b', not including terminating NUL. - * - * Requires: - * 'b' is a valid buffer. - * - * 'source' to be a valid NULL terminated string. - * - * strlen(source) <= isc_buffer_available(b) - */ - -isc_result_t -isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r); -/* - * Copy the contents of 'r' into 'b'. - * - * Requires: - * 'b' is a valid buffer. - * - * 'r' is a valid region. - * - * Returns: - * - * ISC_R_SUCCESS - * ISC_R_NOSPACE The available region of 'b' is not - * big enough. - */ - -ISC_LANG_ENDDECLS - -/* - * Inline macro versions of the functions. These should never be called - * directly by an application, but will be used by the functions within - * buffer.c. The callers should always use "isc_buffer_*()" names, never - * ones beginning with "isc__" - */ - -/* - * XXXDCL Something more could be done with initializing buffers that - * point to const data. For example, a new function, isc_buffer_initconst, - * could be used, and a new boolean flag in the buffer structure could - * indicate whether the buffer was initialized with that function. - * (isc_bufer_init itself would be reprototyped to *not* have its "base" - * parameter be const.) Then if the boolean were true, the isc_buffer_put* - * functions could assert a contractual requirement for a non-const buffer. - * One drawback is that the isc_buffer_* functions (macros) that return - * pointers would still need to return non-const pointers to avoid compiler - * warnings, so it would be up to code that uses them to have to deal - * with the possibility that the buffer was initialized as const -- - * a problem that they *already* have to deal with but have absolutely - * no ability to. With a new isc_buffer_isconst() function returning - * true/false, they could at least assert a contractual requirement for - * non-const buffers when needed. - */ -#define ISC__BUFFER_INIT(_b, _base, _length) \ - do { \ - union { \ - const void * konst; \ - void * var; \ - } _u; \ - _u.konst = (_base); \ - (_b)->base = _u.var; \ - (_b)->length = (_length); \ - (_b)->used = 0; \ - (_b)->current = 0; \ - (_b)->active = 0; \ - (_b)->mctx = NULL; \ - ISC_LINK_INIT(_b, link); \ - (_b)->magic = ISC_BUFFER_MAGIC; \ - } while (0) - -#define ISC__BUFFER_INVALIDATE(_b) \ - do { \ - (_b)->magic = 0; \ - (_b)->base = NULL; \ - (_b)->length = 0; \ - (_b)->used = 0; \ - (_b)->current = 0; \ - (_b)->active = 0; \ - } while (0) - -#define ISC__BUFFER_REGION(_b, _r) \ - do { \ - (_r)->base = (_b)->base; \ - (_r)->length = (_b)->length; \ - } while (0) - -#define ISC__BUFFER_USEDREGION(_b, _r) \ - do { \ - (_r)->base = (_b)->base; \ - (_r)->length = (_b)->used; \ - } while (0) - -#define ISC__BUFFER_AVAILABLEREGION(_b, _r) \ - do { \ - (_r)->base = isc_buffer_used(_b); \ - (_r)->length = isc_buffer_availablelength(_b); \ - } while (0) - -#define ISC__BUFFER_ADD(_b, _n) \ - do { \ - (_b)->used += (_n); \ - } while (0) - -#define ISC__BUFFER_SUBTRACT(_b, _n) \ - do { \ - (_b)->used -= (_n); \ - if ((_b)->current > (_b)->used) \ - (_b)->current = (_b)->used; \ - if ((_b)->active > (_b)->used) \ - (_b)->active = (_b)->used; \ - } while (0) - -#define ISC__BUFFER_CLEAR(_b) \ - do { \ - (_b)->used = 0; \ - (_b)->current = 0; \ - (_b)->active = 0; \ - } while (0) - -#define ISC__BUFFER_CONSUMEDREGION(_b, _r) \ - do { \ - (_r)->base = (_b)->base; \ - (_r)->length = (_b)->current; \ - } while (0) - -#define ISC__BUFFER_REMAININGREGION(_b, _r) \ - do { \ - (_r)->base = isc_buffer_current(_b); \ - (_r)->length = isc_buffer_remaininglength(_b); \ - } while (0) - -#define ISC__BUFFER_ACTIVEREGION(_b, _r) \ - do { \ - if ((_b)->current < (_b)->active) { \ - (_r)->base = isc_buffer_current(_b); \ - (_r)->length = isc_buffer_activelength(_b); \ - } else { \ - (_r)->base = NULL; \ - (_r)->length = 0; \ - } \ - } while (0) - -#define ISC__BUFFER_SETACTIVE(_b, _n) \ - do { \ - (_b)->active = (_b)->current + (_n); \ - } while (0) - -#define ISC__BUFFER_FIRST(_b) \ - do { \ - (_b)->current = 0; \ - } while (0) - -#define ISC__BUFFER_FORWARD(_b, _n) \ - do { \ - (_b)->current += (_n); \ - } while (0) - -#define ISC__BUFFER_BACK(_b, _n) \ - do { \ - (_b)->current -= (_n); \ - } while (0) - -#define ISC__BUFFER_PUTMEM(_b, _base, _length) \ - do { \ - memcpy(isc_buffer_used(_b), (_base), (_length)); \ - (_b)->used += (_length); \ - } while (0) - -#define ISC__BUFFER_PUTSTR(_b, _source) \ - do { \ - unsigned int _length; \ - unsigned char *_cp; \ - _length = strlen(_source); \ - _cp = isc_buffer_used(_b); \ - memcpy(_cp, (_source), _length); \ - (_b)->used += (_length); \ - } while (0) - -#define ISC__BUFFER_PUTUINT8(_b, _val) \ - do { \ - unsigned char *_cp; \ - isc_uint8_t _val2 = (_val); \ - _cp = isc_buffer_used(_b); \ - (_b)->used++; \ - _cp[0] = _val2 & 0x00ff; \ - } while (0) - -#define ISC__BUFFER_PUTUINT16(_b, _val) \ - do { \ - unsigned char *_cp; \ - isc_uint16_t _val2 = (_val); \ - _cp = isc_buffer_used(_b); \ - (_b)->used += 2; \ - _cp[0] = (unsigned char)((_val2 & 0xff00U) >> 8); \ - _cp[1] = (unsigned char)(_val2 & 0x00ffU); \ - } while (0) - -#define ISC__BUFFER_PUTUINT32(_b, _val) \ - do { \ - unsigned char *_cp; \ - isc_uint32_t _val2 = (_val); \ - _cp = isc_buffer_used(_b); \ - (_b)->used += 4; \ - _cp[0] = (unsigned char)((_val2 & 0xff000000) >> 24); \ - _cp[1] = (unsigned char)((_val2 & 0x00ff0000) >> 16); \ - _cp[2] = (unsigned char)((_val2 & 0x0000ff00) >> 8); \ - _cp[3] = (unsigned char)((_val2 & 0x000000ff)); \ - } while (0) - -#if defined(ISC_BUFFER_USEINLINE) -#define isc_buffer_init ISC__BUFFER_INIT -#define isc_buffer_invalidate ISC__BUFFER_INVALIDATE -#define isc_buffer_region ISC__BUFFER_REGION -#define isc_buffer_usedregion ISC__BUFFER_USEDREGION -#define isc_buffer_availableregion ISC__BUFFER_AVAILABLEREGION -#define isc_buffer_add ISC__BUFFER_ADD -#define isc_buffer_subtract ISC__BUFFER_SUBTRACT -#define isc_buffer_clear ISC__BUFFER_CLEAR -#define isc_buffer_consumedregion ISC__BUFFER_CONSUMEDREGION -#define isc_buffer_remainingregion ISC__BUFFER_REMAININGREGION -#define isc_buffer_activeregion ISC__BUFFER_ACTIVEREGION -#define isc_buffer_setactive ISC__BUFFER_SETACTIVE -#define isc_buffer_first ISC__BUFFER_FIRST -#define isc_buffer_forward ISC__BUFFER_FORWARD -#define isc_buffer_back ISC__BUFFER_BACK -#define isc_buffer_putmem ISC__BUFFER_PUTMEM -#define isc_buffer_putstr ISC__BUFFER_PUTSTR -#define isc_buffer_putuint8 ISC__BUFFER_PUTUINT8 -#define isc_buffer_putuint16 ISC__BUFFER_PUTUINT16 -#define isc_buffer_putuint32 ISC__BUFFER_PUTUINT32 -#else -#define isc_buffer_init isc__buffer_init -#define isc_buffer_invalidate isc__buffer_invalidate -#define isc_buffer_region isc__buffer_region -#define isc_buffer_usedregion isc__buffer_usedregion -#define isc_buffer_availableregion isc__buffer_availableregion -#define isc_buffer_add isc__buffer_add -#define isc_buffer_subtract isc__buffer_subtract -#define isc_buffer_clear isc__buffer_clear -#define isc_buffer_consumedregion isc__buffer_consumedregion -#define isc_buffer_remainingregion isc__buffer_remainingregion -#define isc_buffer_activeregion isc__buffer_activeregion -#define isc_buffer_setactive isc__buffer_setactive -#define isc_buffer_first isc__buffer_first -#define isc_buffer_forward isc__buffer_forward -#define isc_buffer_back isc__buffer_back -#define isc_buffer_putmem isc__buffer_putmem -#define isc_buffer_putstr isc__buffer_putstr -#define isc_buffer_putuint8 isc__buffer_putuint8 -#define isc_buffer_putuint16 isc__buffer_putuint16 -#define isc_buffer_putuint32 isc__buffer_putuint32 -#endif - -#endif /* ISC_BUFFER_H */ diff --git a/include/isc/error.h b/include/isc/error.h deleted file mode 100644 index 1dc07748c21d..000000000000 --- a/include/isc/error.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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/include/isc/formatcheck.h b/include/isc/formatcheck.h deleted file mode 100644 index e9b91698e979..000000000000 --- a/include/isc/formatcheck.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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/include/isc/int.h b/include/isc/int.h deleted file mode 100644 index d30e6dcc6290..000000000000 --- a/include/isc/int.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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/include/isc/interfaceiter.h b/include/isc/interfaceiter.h deleted file mode 100644 index f2d11ba8a432..000000000000 --- a/include/isc/interfaceiter.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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. */ - unsigned int ifindex; /* Interface Index */ - unsigned int scopeid; /* Scope id for Multicasting */ -}; - -/* 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/include/isc/ipv6.h b/include/isc/ipv6.h deleted file mode 100644 index 007de7c0dd37..000000000000 --- a/include/isc/ipv6.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") - * Copyright (C) 1999-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 ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC 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.17.12.4 2004/03/09 05:21:09 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 - */ -#ifndef IN6_IS_ADDR_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)) -#endif -/* - * 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 - */ -#ifndef IN6_IS_ADDR_MULTICAST -#define IN6_IS_ADDR_MULTICAST(a) \ - ((a)->s6_addr8[0] == 0xffU) -#endif -/* - * 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/include/isc/lang.h b/include/isc/lang.h deleted file mode 100644 index b3ba5908fe14..000000000000 --- a/include/isc/lang.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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/include/isc/lib.h b/include/isc/lib.h deleted file mode 100644 index 7feef43c5ebe..000000000000 --- a/include/isc/lib.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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/include/isc/list.h b/include/isc/list.h deleted file mode 100644 index d0ae7a91a6f3..000000000000 --- a/include/isc/list.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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/include/isc/magic.h b/include/isc/magic.h deleted file mode 100644 index ff3df24bdfc8..000000000000 --- a/include/isc/magic.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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/include/isc/mem.h b/include/isc/mem.h index f8e73d0e73d8..f5cf9ec57fff 100644 --- a/include/isc/mem.h +++ b/include/isc/mem.h @@ -1,31 +1,68 @@ /* + * libntp local override of isc/mem.h to stub it out. + * + * include/isc is searched before any of the lib/isc include + * directories and should be used only for replacement NTP headers + * overriding headers of the same name under lib/isc. + * + * NOTE: this assumes the system malloc is thread-safe and does + * not use any normal lib/isc locking. + */ + +/* + * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1997-2001 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC 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 $ */ +/* $Id: mem.h,v 1.78.120.3 2009/02/11 03:07:01 jinmei Exp $ */ #ifndef ISC_MEM_H #define ISC_MEM_H 1 #include <stdio.h> + +#include <isc/lang.h> +#include <isc/mutex.h> +#include <isc/platform.h> #include <isc/types.h> +#include <isc/xml.h> + +#include <ntp_stdlib.h> + + +#define ISC_MEM_UNUSED_ARG(a) ((void)(a)) + +#define isc_mem_allocate(c, cnt) isc_mem_get(c, cnt) +#define isc_mem_get(c, cnt) \ + ( ISC_MEM_UNUSED_ARG(c), emalloc(cnt) ) + +#define isc_mem_reallocate(c, mem, cnt) \ + ( ISC_MEM_UNUSED_ARG(c), erealloc((mem), cnt) ) + +#define isc_mem_put(c, mem, cnt) \ + ( ISC_MEM_UNUSED_ARG(cnt), isc_mem_free(c, (mem)) ) + +#define isc_mem_free(c, mem) \ + ( ISC_MEM_UNUSED_ARG(c), free(mem) ) + +#define isc_mem_strdup(c, str) \ + ( ISC_MEM_UNUSED_ARG(c), estrdup(str) ) -void * -isc_mem_get(isc_mem_t *, size_t); -void -isc_mem_put(isc_mem_t *, void *, size_t); +#define isc_mem_attach(src, ptgt) do { *(ptgt) = (src); } while (0) +#define isc_mem_detach(c) ISC_MEM_UNUSED_ARG(c) +#define isc_mem_printallactive(s) fprintf((s), \ + "isc_mem_printallactive() stubbed.\n") #endif /* ISC_MEM_H */ diff --git a/include/isc/msgcat.h b/include/isc/msgcat.h deleted file mode 100644 index d2bf1e1622d9..000000000000 --- a/include/isc/msgcat.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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/include/isc/msgs.h b/include/isc/msgs.h deleted file mode 100644 index 967005bf3531..000000000000 --- a/include/isc/msgs.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") - * Copyright (C) 2000-2003 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 ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC 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.5.2.2.8.3 2004/03/06 08:14:44 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 -#define ISC_MSGSET_IFITERGETIFADDRS 21 - -/* - * 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" */ - -#define ISC_MSG_GETIFADDRS 1801 /* "getting interface addresses: ..." */ - - -#endif /* ISC_MSGS_H */ diff --git a/include/isc/mutex.h b/include/isc/mutex.h deleted file mode 100644 index fd6f3ec5ea1a..000000000000 --- a/include/isc/mutex.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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/include/isc/net.h b/include/isc/net.h deleted file mode 100644 index dae59780b69b..000000000000 --- a/include/isc/net.h +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") - * Copyright (C) 1999-2003 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 ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC 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.31.2.2.10.8 2004/04/29 01:31:23 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 <net/if.h> - -#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)) - -#define ISC_IPADDR_ISEXPERIMENTAL(i) \ - (((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \ - == ISC__IPADDR(0xf0000000)) - -/*** - *** 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_DISABLED IPv4 is disabled. - * 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_DISABLED IPv6 is disabled. - * ISC_R_UNEXPECTED - */ - -isc_result_t -isc_net_probe_ipv6only(void); -/* - * Check if the system's kernel supports the IPV6_V6ONLY socket option. - * - * Returns: - * - * ISC_R_SUCCESS the option is supported for both TCP and UDP. - * ISC_R_NOTFOUND IPv6 itself or the option is not supported. - * ISC_R_UNEXPECTED - */ - -isc_result_t -isc_net_probe_ipv6pktinfo(void); -/* - * Check if the system's kernel supports the IPV6_(RECV)PKTINFO socket option - * for UDP sockets. - * - * Returns: - * - * ISC_R_SUCCESS the option is supported. - * ISC_R_NOTFOUND IPv6 itself or the option is not supported. - * ISC_R_UNEXPECTED - */ - -void -isc_net_disableipv4(void); - -void -isc_net_disableipv6(void); - -void -isc_net_enableipv4(void); - -void -isc_net_enableipv6(void); - -#ifdef ISC_PLATFORM_NEEDNTOP -const char * -isc_net_ntop(int af, const void *src, char *dst, size_t size); -#define inet_ntop isc_net_ntop -#endif - -#ifdef ISC_PLATFORM_NEEDPTON -int -isc_net_pton(int af, const char *src, void *dst); -#undef inet_pton -#define inet_pton isc_net_pton -#endif - -#ifdef ISC_PLATFORM_NEEDATON -int -isc_net_aton(const char *cp, struct in_addr *addr); -#define inet_aton isc_net_aton -#endif - -ISC_LANG_ENDDECLS - -#endif /* ISC_NET_H */ diff --git a/include/isc/netaddr.h b/include/isc/netaddr.h deleted file mode 100644 index e209a9fa7749..000000000000 --- a/include/isc/netaddr.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") - * 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 ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC 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.18.12.7 2004/03/08 09:04:52 marka Exp $ */ - -#ifndef ISC_NETADDR_H -#define ISC_NETADDR_H 1 - -#include <isc/lang.h> -#include <isc/net.h> -#include <isc/types.h> - -ISC_LANG_BEGINDECLS - -struct isc_netaddr { - unsigned int family; - union { - struct in_addr in; - struct in6_addr in6; - } type; - isc_uint32_t zone; -}; - -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_setzone(isc_netaddr_t *netaddr, isc_uint32_t zone); - -isc_uint32_t -isc_netaddr_getzone(const isc_netaddr_t *netaddr); - -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_isexperimental(isc_netaddr_t *na); -/* - * Returns ISC_TRUE if the address is a experimental (CLASS E) 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/include/isc/netscope.h b/include/isc/netscope.h deleted file mode 100644 index 7cc0f182d742..000000000000 --- a/include/isc/netscope.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") - * Copyright (C) 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 ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC 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: netscope.h,v 1.4.142.5 2004/03/08 09:04:52 marka Exp $ */ - -#ifndef ISC_NETSCOPE_H -#define ISC_NETSCOPE_H 1 - -ISC_LANG_BEGINDECLS - -/* - * Convert a string of an IPv6 scope zone to zone index. If the conversion - * succeeds, 'zoneid' will store the index value. - * XXXJT: when a standard interface for this purpose is defined, - * we should use it. - * - * Returns: - * ISC_R_SUCCESS: conversion succeeds - * ISC_R_FAILURE: conversion fails - */ -isc_result_t -isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid); - -ISC_LANG_ENDDECLS - -#endif /* ISC_NETADDR_H */ diff --git a/include/isc/offset.h b/include/isc/offset.h deleted file mode 100644 index 709bde4e07be..000000000000 --- a/include/isc/offset.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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/include/isc/once.h b/include/isc/once.h deleted file mode 100644 index f57d6215fe3e..000000000000 --- a/include/isc/once.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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/include/isc/platform.h b/include/isc/platform.h deleted file mode 100644 index bd11a25503a5..000000000000 --- a/include/isc/platform.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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/include/isc/print.h b/include/isc/print.h deleted file mode 100644 index 7a1bc83b6741..000000000000 --- a/include/isc/print.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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/include/isc/region.h b/include/isc/region.h deleted file mode 100644 index 5622394aaf43..000000000000 --- a/include/isc/region.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") - * 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 ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC 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: region.h,v 1.16.12.3 2004/03/08 09:04:53 marka Exp $ */ - -#ifndef ISC_REGION_H -#define ISC_REGION_H 1 - -#include <isc/types.h> - -struct isc_region { - unsigned char * base; - unsigned int length; -}; - -struct isc_textregion { - char * base; - unsigned int length; -}; - -/* XXXDCL questionable ... bears discussion. we have been putting off - * discussing the region api. - */ -struct isc_constregion { - const void * base; - unsigned int length; -}; - -struct isc_consttextregion { - const char * base; - unsigned int length; -}; - -/* - * The region structure is not opaque, and is usually directly manipulated. - * Some macros are defined below for convenience. - */ - -#define isc_region_consume(r,l) \ - do { \ - isc_region_t *_r = (r); \ - unsigned int _l = (l); \ - INSIST(_r->length >= _l); \ - _r->base += _l; \ - _r->length -= _l; \ - } while (0) - -#define isc_textregion_consume(r,l) \ - do { \ - isc_textregion_t *_r = (r); \ - unsigned int _l = (l); \ - INSIST(_r->length >= _l); \ - _r->base += _l; \ - _r->length -= _l; \ - } while (0) - -#define isc_constregion_consume(r,l) \ - do { \ - isc_constregion_t *_r = (r); \ - unsigned int _l = (l); \ - INSIST(_r->length >= _l); \ - _r->base += _l; \ - _r->length -= _l; \ - } while (0) - -int -isc_region_compare(isc_region_t *r1, isc_region_t *r2); -/* - * Compares the contents of two regions - * - * Requires: - * 'r1' is a valid region - * 'r2' is a valid region - * - * Returns: - * < 0 if r1 is lexicographically less than r2 - * = 0 if r1 is lexicographically identical to r2 - * > 0 if r1 is lexicographically greater than r2 - */ - -#endif /* ISC_REGION_H */ diff --git a/include/isc/result.h b/include/isc/result.h deleted file mode 100644 index 93f7cefbd658..000000000000 --- a/include/isc/result.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") - * Copyright (C) 1998-2001, 2003 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 ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC 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.57.2.2.8.5 2004/05/15 03:46:13 jinmei 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 */ -#define ISC_R_DISABLED 57 /* disabled */ -#define ISC_R_MAXSIZE 58 /* max size */ -#define ISC_R_BADADDRESSFORM 59 /* invalid address format */ - -/* - * Not a result code: the number of results. - */ -#define ISC_R_NRESULTS 60 - -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/include/isc/sockaddr.h b/include/isc/sockaddr.h deleted file mode 100644 index 635af38117bf..000000000000 --- a/include/isc/sockaddr.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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_isexperimental(isc_sockaddr_t *sa); -/* - * Returns ISC_TRUE if the address is a experimental (CLASS E) 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/include/isc/strerror.h b/include/isc/strerror.h deleted file mode 100644 index ca428af9553f..000000000000 --- a/include/isc/strerror.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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/include/isc/string.h b/include/isc/string.h deleted file mode 100644 index e16219fdaad0..000000000000 --- a/include/isc/string.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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/include/isc/types.h b/include/isc/types.h deleted file mode 100644 index b30f55ee7fe9..000000000000 --- a/include/isc/types.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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/include/isc/util.h b/include/isc/util.h deleted file mode 100644 index 6144e11ba863..000000000000 --- a/include/isc/util.h +++ /dev/null @@ -1,225 +0,0 @@ -/* - * 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/include/l_stdlib.h b/include/l_stdlib.h index 58bbeedc2123..0213d23c1c4f 100644 --- a/include/l_stdlib.h +++ b/include/l_stdlib.h @@ -14,15 +14,8 @@ # 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 +#include <stdarg.h> +#include <sys/types.h> /* Needed for speed_t. */ #ifdef HAVE_TERMIOS_H @@ -40,195 +33,195 @@ #ifdef DECL_ADJTIME_0 struct timeval; -extern int adjtime P((struct timeval *, struct timeval *)); +extern int adjtime (struct timeval *, struct timeval *); #endif #ifdef DECL_BCOPY_0 #ifndef bcopy -extern void bcopy P((const char *, char *, int)); +extern void bcopy (const char *, char *, int); #endif #endif #ifdef DECL_BZERO_0 #ifndef bzero -extern void bzero P((char *, int)); +extern void bzero (char *, int); #endif #endif #ifdef DECL_CFSETISPEED_0 struct termios; -extern int cfsetispeed P((struct termios *, speed_t)); -extern int cfsetospeed P((struct termios *, speed_t)); +extern int cfsetispeed (struct termios *, speed_t); +extern int cfsetospeed (struct termios *, speed_t); #endif -extern char * getpass P((const char *)); +extern char * getpass (const char *); #ifdef DECL_HSTRERROR_0 -extern const char * hstrerror P((int)); +extern const char * hstrerror (int); #endif #ifdef DECL_INET_NTOA_0 struct in_addr; -extern char * inet_ntoa P((struct in_addr)); +extern char * inet_ntoa (struct in_addr); #endif #ifdef DECL_IOCTL_0 -extern int ioctl P((int, u_long, char *)); +extern int ioctl (int, u_long, char *); #endif #ifdef DECL_IPC_0 struct sockaddr; -extern int bind P((int, struct sockaddr *, int)); -extern int connect P((int, struct sockaddr *, int)); -extern int recv P((int, char *, int, int)); -extern int recvfrom P((int, char *, int, int, struct sockaddr *, int *)); -extern int send P((int, char *, int, int)); -extern int sendto P((int, char *, int, int, struct sockaddr *, int)); -extern int setsockopt P((int, int, int, char *, int)); -extern int socket P((int, int, int)); +extern int bind (int, struct sockaddr *, int); +extern int connect (int, struct sockaddr *, int); +extern int recv (int, char *, int, int); +extern int recvfrom (int, char *, int, int, struct sockaddr *, int *); +extern int send (int, char *, int, int); +extern int sendto (int, char *, int, int, struct sockaddr *, int); +extern int setsockopt (int, int, int, char *, int); +extern int socket (int, int, int); #endif #ifdef DECL_MEMMOVE_0 -extern void * memmove P((void *, const void *, size_t)); +extern void * memmove (void *, const void *, size_t); #endif #ifdef DECL_MEMSET_0 -extern char * memset P((char *, int, int)); +extern char * memset (char *, int, int); #endif #ifdef DECL_MKSTEMP_0 -extern int mkstemp P((char *)); +extern int mkstemp (char *); #endif #ifdef DECL_MKTEMP_0 -extern char *mktemp P((char *)); +extern char *mktemp (char *); #endif #ifdef DECL_NLIST_0 struct nlist; -extern int nlist P((const char *, struct nlist *)); +extern int nlist (const char *, struct nlist *); #endif #ifdef DECL_PLOCK_0 -extern int plock P((int)); +extern int plock (int); #endif #ifdef DECL_RENAME_0 -extern int rename P((const char *, const char *)); +extern int rename (const char *, const char *); #endif #ifdef DECL_SELECT_0 #ifdef _ntp_select_h -extern int select P((int, fd_set *, fd_set *, fd_set *, struct timeval *)); +extern int select (int, fd_set *, fd_set *, fd_set *, struct timeval *); #endif #endif #ifdef DECL_SETITIMER_0 struct itimerval; -extern int setitimer P((int , struct itimerval *, struct itimerval *)); +extern int setitimer (int , struct itimerval *, struct itimerval *); #endif #ifdef PRIO_PROCESS #ifdef DECL_SETPRIORITY_0 -extern int setpriority P((int, int, int)); +extern int setpriority (int, int, int); #endif #ifdef DECL_SETPRIORITY_1 -extern int setpriority P((int, id_t, int)); +extern int setpriority (int, id_t, int); #endif #endif #ifdef DECL_SIGVEC_0 struct sigvec; -extern int sigvec P((int, struct sigvec *, struct sigvec *)); +extern int sigvec (int, struct sigvec *, struct sigvec *); #endif #ifndef HAVE_SNPRINTF /* PRINTFLIKE3 */ -extern int snprintf P((char *, size_t, const char *, ...)); +extern int snprintf (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)); +extern int vsnprintf (char *, size_t, const char *, va_list); #endif #ifdef DECL_STDIO_0 #if defined(FILE) || defined(BUFSIZ) -extern int _flsbuf P((int, FILE *)); -extern int _filbuf P((FILE *)); -extern int fclose P((FILE *)); -extern int fflush P((FILE *)); -extern int fprintf P((FILE *, const char *, ...)); -extern int fscanf P((FILE *, const char *, ...)); -extern int fputs P((const char *, FILE *)); -extern int fputc P((int, FILE *)); -extern int fread P((char *, int, int, FILE *)); -extern void perror P((const char *)); -extern int printf P((const char *, ...)); -extern int setbuf P((FILE *, char *)); +extern int _flsbuf (int, FILE *); +extern int _filbuf (FILE *); +extern int fclose (FILE *); +extern int fflush (FILE *); +extern int fprintf (FILE *, const char *, ...); +extern int fscanf (FILE *, const char *, ...); +extern int fputs (const char *, FILE *); +extern int fputc (int, FILE *); +extern int fread (char *, int, int, FILE *); +extern void perror (const char *); +extern int printf (const char *, ...); +extern int setbuf (FILE *, char *); # ifdef HAVE_SETLINEBUF -extern int setlinebuf P((FILE *)); +extern int setlinebuf (FILE *); # endif -extern int setvbuf P((FILE *, char *, int, int)); -extern int scanf P((const char *, ...)); -extern int sscanf P((const char *, const char *, ...)); -extern int vfprintf P((FILE *, const char *, ...)); -extern int vsprintf P((char *, const char *, ...)); +extern int setvbuf (FILE *, char *, int, int); +extern int scanf (const char *, ...); +extern int sscanf (const char *, const char *, ...); +extern int vfprintf (FILE *, const char *, ...); +extern int vsprintf (char *, const char *, ...); #endif #endif #ifdef DECL_STIME_0 -extern int stime P((const time_t *)); +extern int stime (const time_t *); #endif #ifdef DECL_STIME_1 -extern int stime P((long *)); +extern int stime (long *); #endif #ifdef DECL_STRERROR_0 -extern char * strerror P((int errnum)); +extern char * strerror (int errnum); #endif #ifdef DECL_STRTOL_0 -extern long strtol P((const char *, char **, int)); +extern long strtol (const char *, char **, int); #endif #ifdef DECL_SYSCALL -extern int syscall P((int, ...)); +extern int syscall (int, ...); #endif #ifdef DECL_SYSLOG_0 -extern void closelog P((void)); +extern void closelog (void); #ifndef LOG_DAEMON -extern void openlog P((const char *, int)); +extern void openlog (const char *, int); #else -extern void openlog P((const char *, int, int)); +extern void openlog (const char *, int, int); #endif -extern int setlogmask P((int)); -extern void syslog P((int, const char *, ...)); +extern int setlogmask (int); +extern void syslog (int, const char *, ...); #endif #ifdef DECL_TIME_0 -extern time_t time P((time_t *)); +extern time_t time (time_t *); #endif #ifdef DECL_TIMEOFDAY_0 #ifdef SYSV_TIMEOFDAY -extern int gettimeofday P((struct timeval *)); -extern int settimeofday P((struct timeval *)); +extern int gettimeofday (struct timeval *); +extern int settimeofday (struct timeval *); #else /* not SYSV_TIMEOFDAY */ struct timezone; -extern int gettimeofday P((struct timeval *, struct timezone *)); -extern int settimeofday P((struct timeval *, void *)); +extern int gettimeofday (struct timeval *, struct timezone *); +extern int settimeofday (struct timeval *, void *); #endif /* not SYSV_TIMEOFDAY */ #endif #ifdef DECL_TOLOWER_0 -extern int tolower P((int)); +extern int tolower (int); #endif #ifdef DECL_TOUPPER_0 -extern int toupper P((int)); +extern int toupper (int); #endif /* @@ -242,265 +235,4 @@ extern int errno; extern int h_errno; #endif -/*******************************************************/ - -#if 0 -/* - * Unprotoyped library functions for SunOS 4.x.x - */ -#ifdef SYS_SUNOS4 -extern void closelog P((void)); -extern void openlog P((char *, int, int)); -extern void syslog P((int, char *, ...)); -extern int setlogmask P((int)); - -extern char * getpass P((char *)); - -extern int setpriority P((int ,int ,int)); - -extern long strtol P((char *, char **, int)); - -#if !defined(NTP_POSIX_SOURCE) -extern int atoi P((char *)); -extern int dup2 P((int, int)); -extern int execve P((char *, char **,char **)); -extern int fork P((void)); -extern int getdtablesize P((void)); -extern int qsort (void *, int , int, - int P((*compar)(void *, void *))); -extern int setpgrp P((int, int)); -extern void bcopy P((const char *, char *, int)); -#endif - -#ifndef bzero /* XXX macro prototyping clash */ -extern void bzero P((char *, int)); -extern int bcmp P((char *, char *, int)); -extern void bcopy P((const char *, char *, int)); -#endif -extern char *mktemp P((char *)); - -extern int tolower P((int)); - -extern int isatty P((int)); - -extern unsigned sleep P((unsigned )); -extern unsigned int alarm P((unsigned int)); -extern int pause P((void)); - -extern int getpid P((void)); -extern int getppid P((void)); - -extern int close P((int)); -extern int ioctl P((int, int, char *)); -extern int rename P((char *, char *)); -#if 0 -extern int read P((int, void *, size_t)); -extern int write P((int, const void *, size_t)); -#endif -extern int unlink P((const char *)); -extern int link P((const char *, const char *)); - -#ifdef FILE -extern int fclose P((FILE *)); -extern int fflush P((FILE *)); -extern int fprintf P((FILE *, char *, ...)); -extern int fscanf P((FILE *, char *, ...)); -extern int fputs P((char *, FILE *)); -extern int fputc P((char, FILE *)); -extern int fread P((char *, int, int, FILE *)); -extern int printf P((char *, ...)); -extern int setbuf P((FILE *, char *)); -extern int setvbuf P((FILE *, char *, int, int)); -extern int scanf P((char *, ...)); -extern int sscanf P((char *, char *, ...)); -extern int vsprintf P((char *, char *, ...)); -extern int _flsbuf P((int, FILE *)); -extern int _filbuf P((FILE *)); -extern void perror P((char *)); -#ifdef HAVE_SETLINEBUF -extern int setlinebuf P((FILE *)); -#endif -#endif - -#ifdef _ntp_string_h -#ifdef NTP_POSIX_SOURCE /* these are builtins */ -#ifndef NTP_NEED_BOPS /* but may be emulated by bops */ -extern char *memcpy P(()); -extern char *memset P(()); -extern int memcmp P(()); -#endif -#endif -#endif - -#ifdef _sys_socket_h -extern int bind P((int, struct sockaddr *, int)); -extern int connect P((int, struct sockaddr *, int)); -extern int sendto P((int, char *, int, int, struct sockaddr *, int)); -extern int setsockopt P((int, int, int, char *, int)); -extern int socket P((int, int, int)); -extern int recvfrom P((int, char *, int, int, struct sockaddr *, int *)); -#endif /* _sys_socket_h */ - -#ifdef _ntp_select_h -extern int select P((int, fd_set *, fd_set *, fd_set *, struct timeval *)); -#endif - -#ifdef _sys_time_h -extern int adjtime P((struct timeval *, struct timeval *)); -extern int setitimer P((int , struct itimerval *, struct itimerval *)); -#ifdef SYSV_TIMEOFDAY -extern int gettimeofday P((struct timeval *)); -extern int settimeofday P((struct timeval *)); -#else /* ! SYSV_TIMEOFDAY */ -extern int gettimeofday P((struct timeval *, struct timezone *)); -extern int settimeofday P((struct timeval *, struct timezone *)); -#endif /* SYSV_TIMEOFDAY */ -#endif /* _sys_time_h */ - -#ifdef __time_h -extern time_t time P((time_t *)); -#endif - -#ifdef __setjmp_h -extern int setjmp P((jmp_buf)); -extern void longjmp P((jmp_buf, int)); -#endif - -#ifdef _sys_resource_h -extern int getrusage P((int, struct rusage *)); -#endif - -#ifdef _nlist_h -extern int nlist P((char *, struct nlist *)); -#endif - -#endif /* SYS_SUNOS4 */ - -/* - * Unprototyped library functions for DEC OSF/1 - */ -#ifdef SYS_DECOSF1 -#ifndef _MACHINE_ENDIAN_H_ -#define _MACHINE_ENDIAN_H_ -extern u_short htons P((u_short)); -extern u_short ntohs P((u_short)); -extern u_int32 htonl P((u_int32)); -extern u_int32 ntohl P((u_int32)); -#endif /* _MACHINE_ENDIAN_H_ */ - -/* -extern char * getpass P((char *)); -*/ -extern char * mktemp P((char *)); -#ifndef SYS_IX86OSF1 -extern int ioctl P((int, u_long, char *)); -extern void bzero P((char *, int)); -#endif - -#ifdef SOCK_DGRAM -extern int bind P((int, const struct sockaddr *, int)); -extern int connect P((int, const struct sockaddr *, int)); -extern int socket P((int, int, int)); -extern int sendto P((int, const void *, int, int, const struct sockaddr *, int)); -extern int setsockopt P((int, int, int, const void *, int)); -extern int recvfrom P((int, void *, int, int, struct sockaddr *, int *)); -#endif /* SOCK_STREAM */ - -#ifdef _ntp_select_h -extern int select P((int, fd_set *, fd_set *, fd_set *, struct timeval *)); -#endif - -#endif /* DECOSF1 */ - -/* - * Unprototyped library functions for Ultrix - */ -#ifdef SYS_ULTRIX -extern int close P((int)); -extern char * getpass P((char *)); -extern int getpid P((void)); -extern int ioctl P((int, int, char *)); -extern char *mktemp P((char *)); -extern int unlink P((const char *)); -extern int link P((const char *, const char *)); - -extern void closelog P((void)); -extern void syslog P((int, char *, ...)); -#ifndef LOG_DAEMON -extern void openlog P((char *, int)); -#else -extern void openlog P((char *, int, int)); -#endif - -extern int setpriority P((int ,int ,int )); - -#ifdef SOCK_DGRAM -extern int bind P((int, struct sockaddr *, int)); -extern int connect P((int, struct sockaddr *, int)); -extern int socket P((int, int, int)); -extern int sendto P((int, char *, int, int, struct sockaddr *, int)); -extern int setsockopt P((int, int, int, char *, int)); -extern int recvfrom P((int, char *, int, int, struct sockaddr *, int *)); -#endif /* SOCK_STREAM */ - -#ifdef _TIME_H_ -extern int gettimeofday P((struct timeval *, struct timezone *)); -extern int settimeofday P((struct timeval *, struct timezone *)); -extern int adjtime P((struct timeval *, struct timeval *)); -extern int select P((int, fd_set *, fd_set *, fd_set *, struct timeval *)); -extern int setitimer P((int , struct itimerval *, struct itimerval *)); -#endif /* _TIME_H_ */ - -#ifdef N_UNDF -extern int nlist P((char *, struct nlist *)); -#endif - -#ifndef bzero /* XXX macro prototyping clash */ -extern void bzero P((char *, int)); -extern int bcmp P((char *, char *, int)); -extern void bcopy P((const char *, char *, int)); -#endif - -#ifndef NTP_POSIX_SOURCE -extern int atoi P((char *)); -extern void bzero P((char *, int)); -extern int bcmp P((char *, char *, int)); -extern void bcopy P((const char *, char *, int)); -extern int execve P((char *, char **,char **)); -extern int fork P((void)); -extern int getdtablesize P((void)); -extern int ran P((void)); -#ifdef _TIME_H_ -extern int gettimeofday P((struct timeval *, struct timezone *)); -extern int settimeofday P((struct timeval *, struct timezone *)); -#endif -#endif - -#ifdef _RESOURCE_H_ -extern int getrusage P((int, struct rusage *)); -#endif - -#endif /* SYS_ULTRIX */ - -#if defined(__convex__) -extern char * getpass P((char *)); -#endif - -#ifdef SYS_IRIX4 -extern char * getpass P((char *)); -#endif /* IRIX4 */ - -#ifdef SYS_VAX -extern char * getpass P((char *)); -#endif /* VAX */ - -#ifdef SYS_DOMAINOS -extern char * getpass P((char *)); -#endif /* SYS_DOMAINOS */ - -#ifdef SYS_BSD -#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) -#endif - -#endif /* 0 */ #endif /* l_stdlib_h */ diff --git a/include/lib_strbuf.h b/include/lib_strbuf.h new file mode 100644 index 000000000000..5aa0eb0a6d72 --- /dev/null +++ b/include/lib_strbuf.h @@ -0,0 +1,28 @@ +/* + * lib_strbuf.h - definitions for routines which use the common string buffers + */ + +#include <ntp_types.h> + +/* + * Sizes of things + */ +#define LIB_NUMBUFS 200 +#define LIB_BUFLENGTH 80 + +/* + * Macro to get a pointer to the next buffer + */ +#define LIB_GETBUF(buf) \ + do { \ + if (!lib_inited) \ + init_lib(); \ + buf = &lib_stringbuf[lib_nextbuf][0]; \ + if (++lib_nextbuf >= LIB_NUMBUFS) \ + lib_nextbuf = 0; \ + memset(buf, 0, LIB_BUFLENGTH); \ + } while (0) + +extern char lib_stringbuf[LIB_NUMBUFS][LIB_BUFLENGTH]; +extern int lib_nextbuf; +extern int lib_inited; diff --git a/include/mbg_gps166.h b/include/mbg_gps166.h index edaae9df20d1..f4b82381087e 100644 --- a/include/mbg_gps166.h +++ b/include/mbg_gps166.h @@ -391,7 +391,7 @@ typedef struct { l_fp A0; /* ± Clock Correction Coefficient 0 [sec] */ l_fp A1; /* ± Clock Correction Coefficient 1 [sec/sec] */ - ushort WNlsf; /* week number of nearest leap second */ + u_short WNlsf; /* week number of nearest leap second */ short DNt; /* the day number at the end of which LS is inserted */ char delta_tls; /* */ char delta_tlsf; /* */ @@ -524,31 +524,31 @@ typedef struct { } IONO; -void mbg_tm_str P((char **, TM *, int)); -void mbg_tgps_str P((char **, T_GPS *, int)); -void get_mbg_header P((unsigned char **, GPS_MSG_HDR *)); -void put_mbg_header P((unsigned char **, GPS_MSG_HDR *)); -void get_mbg_sw_rev P((unsigned char **, SW_REV *)); -void get_mbg_ascii_msg P((unsigned char **, ASCII_MSG *)); -void get_mbg_svno P((unsigned char **, SVNO *)); -void get_mbg_health P((unsigned char **, HEALTH *)); -void get_mbg_cfg P((unsigned char **, CFG *)); -void get_mbg_tgps P((unsigned char **, T_GPS *)); -void get_mbg_tm P((unsigned char **, TM *)); -void get_mbg_ttm P((unsigned char **, TTM *)); -void get_mbg_synth P((unsigned char **, SYNTH *)); -void get_mbg_tzdl P((unsigned char **, TZDL *)); -void get_mbg_antinfo P((unsigned char **, ANT_INFO *)); -void get_mbg_cfgh P((unsigned char **, CFGH *)); -void get_mbg_utc P((unsigned char **, UTC *)); -void get_mbg_lla P((unsigned char **, LLA)); -void get_mbg_xyz P((unsigned char **, XYZ)); -void get_mbg_portparam P((unsigned char **, PORT_PARM *)); -void get_mbg_eph P((unsigned char **, EPH *)); -void get_mbg_alm P((unsigned char **, ALM *)); -void get_mbg_iono P((unsigned char **, IONO *)); - -unsigned long mbg_csum P((unsigned char *, unsigned int)); +void mbg_tm_str (char **, TM *, int); +void mbg_tgps_str (char **, T_GPS *, int); +void get_mbg_header (unsigned char **, GPS_MSG_HDR *); +void put_mbg_header (unsigned char **, GPS_MSG_HDR *); +void get_mbg_sw_rev (unsigned char **, SW_REV *); +void get_mbg_ascii_msg (unsigned char **, ASCII_MSG *); +void get_mbg_svno (unsigned char **, SVNO *); +void get_mbg_health (unsigned char **, HEALTH *); +void get_mbg_cfg (unsigned char **, CFG *); +void get_mbg_tgps (unsigned char **, T_GPS *); +void get_mbg_tm (unsigned char **, TM *); +void get_mbg_ttm (unsigned char **, TTM *); +void get_mbg_synth (unsigned char **, SYNTH *); +void get_mbg_tzdl (unsigned char **, TZDL *); +void get_mbg_antinfo (unsigned char **, ANT_INFO *); +void get_mbg_cfgh (unsigned char **, CFGH *); +void get_mbg_utc (unsigned char **, UTC *); +void get_mbg_lla (unsigned char **, LLA); +void get_mbg_xyz (unsigned char **, XYZ); +void get_mbg_portparam (unsigned char **, PORT_PARM *); +void get_mbg_eph (unsigned char **, EPH *); +void get_mbg_alm (unsigned char **, ALM *); +void get_mbg_iono (unsigned char **, IONO *); + +unsigned long mbg_csum (unsigned char *, unsigned int); #endif /* diff --git a/include/ntp.h b/include/ntp.h index dad9de136701..d7e87582d708 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -4,15 +4,19 @@ #ifndef NTP_H #define NTP_H -#include "ntp_types.h" +#include <stddef.h> #include <math.h> + +#include <ntp_fp.h> +#include <ntp_types.h> +#include <ntp_stdlib.h> #ifdef OPENSSL -#include "ntp_crypto.h" +#include <ntp_crypto.h> #endif /* OPENSSL */ #include <ntp_random.h> +#include <ntp_net.h> #include <isc/boolean.h> -#include <isc/list.h> /* * Calendar arithmetic - contributed by G. Healton @@ -103,14 +107,13 @@ typedef char s_char; /* * Poll interval parameters */ -#define NTP_UNREACH 24 /* poll unreach threshold */ -#define NTP_MINPOLL 4 /* log2 min poll interval (16 s) */ +#define NTP_UNREACH 10 /* poll unreach threshold */ +#define NTP_MINPOLL 3 /* log2 min poll interval (8 s) */ #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) */ +#define NTP_RETRY 3 /* max packet retries */ +#define NTP_MINPKT 1 /* log2 min interburst interval (2 s) */ /* * Clock filter algorithm tuning parameters @@ -125,20 +128,20 @@ typedef char s_char; #define NTP_MINCLOCK 3 /* min survivors */ #define NTP_MAXCLOCK 10 /* max candidates */ #define NTP_MAXASSOC 50 /* max associations */ -#define MINDISPERSE .005 /* min dispersion increment */ -#define MAXDISTANCE 1. /* max root distance (select threshold) */ +#define MINDISPERSE .001 /* min distance */ +#define MAXDISTANCE 1.5 /* max root distance (select threshold) */ #define CLOCK_SGATE 3. /* popcorn spike gate */ #define HUFFPUFF 900 /* huff-n'-puff sample interval (s) */ #define MAXHOP 2 /* anti-clockhop threshold */ #define MAX_TTL 8 /* max ttl mapping vector size */ #define BEACON 7200 /* manycast beacon interval */ -#define NTP_MAXEXTEN 1024 /* max extension field size */ +#define NTP_MAXEXTEN 2048 /* max extension field size */ /* * Miscellaneous stuff */ #define NTP_MAXKEY 65535 /* max authentication key number */ - +#define KEY_TYPE_MD5 NID_md5 /* MD5 digest NID */ /* * Limits of things */ @@ -153,7 +156,7 @@ typedef char s_char; * dispersion component (frequency error plus precision). The frequency * error component is computed as CLOCK_PHI times the difference between * the epoch of the time measurement and the reference time. The - * precision componen is computed as the square root of the mean of the + * precision component is computed as the square root of the mean of the * squares of a zero-mean, uniform distribution of unit maximum * amplitude. Whether this makes statistical sense may be arguable. */ @@ -167,34 +170,40 @@ typedef char s_char; #define EVENT_TIMEOUT 0 /* one second, that is */ + /* * The interface structure is used to hold the addresses and socket - * numbers of each of the interfaces we are using. + * numbers of each of the local network addresses we are using. + * Because "interface" is a reserved word in C++ and has so many + * varied meanings, a change to "endpt" (via typedef) is under way. + * Eventually the struct tag will change from interface to endpt_tag. + * endpt is unrelated to the select algorithm's struct endpoint. */ +typedef struct interface endpt; struct 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 */ - short family; /* Address family */ - int flags; /* interface flags */ - int last_ttl; /* last TTL specified */ - u_int32 addr_refid; /* IPv4 addr or IPv6 hash */ - int num_mcast; /* No. of IP addresses in multicast socket */ - u_long starttime; /* current_time as of creation of interface structure */ - volatile long received; /* number of incoming packets */ - long sent; /* number of outgoing packets */ - long notsent; /* number of send failures */ - u_int scopeid; /* Scope used for Multicasting */ - u_int ifindex; /* interface index */ - u_int ifnum; /* sequential interface instance count */ - u_char phase; /* phase in update cycle */ - isc_boolean_t ignore_packets; /* Specify whether the packet should be ignored */ - ISC_LIST(struct peer) peers; /* list of peers for the interface */ - u_int peercnt; /* number of peers referencinf this interface - informational only */ - ISC_LINK(struct interface) link; /* interface list */ + endpt * elink; /* endpt list link */ + endpt * mclink; /* per-AF_* multicast list */ + SOCKET fd; /* socket descriptor */ + SOCKET bfd; /* for receiving broadcasts */ + u_int32 ifnum; /* endpt instance count */ + sockaddr_u sin; /* unicast address */ + sockaddr_u mask; /* subnet mask */ + sockaddr_u bcast; /* broadcast address */ + char name[32]; /* name of interface */ + u_short family; /* AF_INET/AF_INET6 */ + u_short phase; /* phase in update cycle */ + u_int32 flags; /* interface flags */ + int last_ttl; /* last TTL specified */ + u_int32 addr_refid; /* IPv4 addr or IPv6 hash */ + int num_mcast; /* mcast addrs enabled */ + u_long starttime; /* current_time at creation */ + volatile long received; /* number of incoming packets */ + long sent; /* number of outgoing packets */ + long notsent; /* number of send failures */ + u_int ifindex; /* for IPV6_MULTICAST_IF */ + isc_boolean_t ignore_packets; /* listen-read-drop this? */ + struct peer * peers; /* list of peers using endpt */ + u_int peercnt; /* count of same */ }; /* @@ -207,8 +216,10 @@ struct interface { #define INT_MULTICAST 0x010 /* can multicast out this interface */ #define INT_BCASTOPEN 0x020 /* broadcast socket is open */ #define INT_MCASTOPEN 0x040 /* multicasting enabled */ -#define INT_WILDCARD 0x080 /* wildcard interface - usually skipped */ -#define INT_MCASTIF 0x100 /* bound directly to MCAST address */ +#define INT_WILDCARD 0x080 /* wildcard interface - usually skipped */ +#define INT_MCASTIF 0x100 /* bound directly to MCAST address */ +#define INT_PRIVACY 0x200 /* RFC 4941 IPv6 privacy address */ + /* * Define flasher bits (tests 1 through 11 in packet procedure) * These reveal the state at the last grumble from the peer and are @@ -221,11 +232,11 @@ struct interface { #define TEST2 0x0002 /* bogus packet */ #define TEST3 0x0004 /* protocol unsynchronized */ #define TEST4 0x0008 /* access denied */ -#define TEST5 0x0010 /* authentication error */ +#define TEST5 0x0010 /* bad authentication */ #define TEST6 0x0020 /* bad synch or stratum */ -#define TEST7 0x0040 /* bad header data */ -#define TEST8 0x0080 /* autokey error */ -#define TEST9 0x0100 /* crypto error */ +#define TEST7 0x0040 /* bad header */ +#define TEST8 0x0080 /* bad autokey */ +#define TEST9 0x0100 /* bad crypto */ #define PKT_TEST_MASK (TEST1 | TEST2 | TEST3 | TEST4 | TEST5 |\ TEST6 | TEST7 | TEST8 | TEST9) /* @@ -238,24 +249,16 @@ struct interface { #define PEER_TEST_MASK (TEST10 | TEST11 | TEST12 | TEST13) /* - * Authentication codes - */ -#define AUTH_NONE 0 /* no authentication */ -#define AUTH_OK 1 /* authentication OK */ -#define AUTH_ERROR 2 /* authentication error */ -#define AUTH_CRYPTO 3 /* crypto-NAK */ - -/* * The peer structure. Holds state information relating to the guys * we are peering with. Most of this stuff is from section 3.2 of the * spec. */ struct peer { - struct peer *next; /* pointer to next association */ + struct peer *next; /* link pointer in peer hash */ struct peer *ass_next; /* link pointer in associd hash */ - struct sockaddr_storage srcadr; /* address of remote host */ - struct interface *dstadr; /* pointer to address on local host */ - ISC_LINK(struct peer) ilink; /* interface link list */ + struct peer *ilink; /* list of peers for interface */ + sockaddr_u srcadr; /* address of remote host */ + endpt * dstadr; /* local address */ associd_t associd; /* association ID */ u_char version; /* version number */ u_char hmode; /* local association mode */ @@ -264,7 +267,6 @@ struct peer { u_char maxpoll; /* max poll interval */ u_int flags; /* association flags */ u_char cast_flags; /* additional flags */ - 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 ttl; /* ttl/refclock mode */ @@ -287,8 +289,8 @@ struct peer { u_char stratum; /* remote stratum */ u_char ppoll; /* remote poll interval */ s_char precision; /* remote clock precision */ - double rootdelay; /* roundtrip delay to primary clock */ - double rootdispersion; /* dispersion to primary clock */ + double rootdelay; /* roundtrip delay to primary source */ + double rootdisp; /* dispersion to primary source */ u_int32 refid; /* remote reference ID */ l_fp reftime; /* update epoch */ @@ -297,22 +299,25 @@ struct peer { */ keyid_t keyid; /* current key ID */ #ifdef OPENSSL -#define clear_to_zero assoc +#define clear_to_zero opcode + u_int32 opcode; /* last request opcode */ associd_t assoc; /* peer association ID */ u_int32 crypto; /* peer status word */ EVP_PKEY *pkey; /* public key */ const EVP_MD *digest; /* message digest algorithm */ char *subject; /* certificate subject name */ char *issuer; /* certificate issuer name */ + struct cert_info *xinfo; /* issuer certificate */ keyid_t pkeyid; /* previous key ID */ + keyid_t hcookie; /* host cookie */ 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 */ + const struct pkey_info *ident_pkey; /* identity key */ + BIGNUM *iffval; /* identity challenge (IFF, GQ, MV) */ + const BIGNUM *grpkey; /* identity challenge key (GQ) */ + struct value cookval; /* receive cookie values */ struct value recval; /* receive autokey values */ struct exten *cmmd; /* extension pointer */ + u_long refresh; /* next refresh epoch */ /* * Variables used by authenticated server @@ -321,7 +326,6 @@ struct peer { int keynumber; /* current key number */ struct value encrypt; /* send encrypt values */ struct value sndval; /* send autokey values */ - struct value tai_leap; /* send leapsecond table */ #else /* OPENSSL */ #define clear_to_zero status #endif /* OPENSSL */ @@ -330,34 +334,53 @@ struct peer { * Ephemeral state variables */ u_char status; /* peer status */ + u_char new_status; /* under-construction status */ u_char reach; /* reachability register */ + int flash; /* protocol error test tally bits */ u_long epoch; /* reference epoch */ - u_int burst; /* packets remaining in burst */ - u_int filter_nextpt; /* index into filter shift register */ + int burst; /* packets remaining in burst */ + int retry; /* retry counter */ + int flip; /* interleave mode control */ + int filter_nextpt; /* index into filter shift register */ double filter_delay[NTP_SHIFT]; /* delay shift register */ double filter_offset[NTP_SHIFT]; /* offset shift register */ double filter_disp[NTP_SHIFT]; /* dispersion shift register */ u_long filter_epoch[NTP_SHIFT]; /* epoch shift register */ u_char filter_order[NTP_SHIFT]; /* filter sort index */ - l_fp org; /* originate time stamp */ l_fp rec; /* receive time stamp */ l_fp xmt; /* transmit time stamp */ + l_fp dst; /* destination timestamp */ + l_fp aorg; /* origin timestamp */ + l_fp borg; /* alternate origin timestamp */ double offset; /* peer clock offset */ double delay; /* peer roundtrip delay */ double jitter; /* peer jitter (squares) */ double disp; /* peer dispersion */ - double estbdelay; /* clock offset to broadcast server */ + double xleave; /* interleave delay */ + double bias; /* bias for NIC asymmetry */ + + /* + * Variables used to correct for packet length and asymmetry. + */ + double t21; /* outbound packet delay */ + int t21_bytes; /* outbound packet length */ + int t21_last; /* last outbound packet length */ + double r21; /* outbound data rate */ + double t34; /* inbound packet delay */ + int t34_bytes; /* inbound packet length */ + double r34; /* inbound data rate */ /* * End of clear-to-zero area */ u_long update; /* receive epoch */ - u_int unreach; /* unreachable count */ -#define end_clear_to_zero unreach +#define end_clear_to_zero update + int unreach; /* watchdog counter */ + int throttle; /* rate control */ u_long outdate; /* send time last packet */ u_long nextdate; /* send time next packet */ u_long nextaction; /* peer local activity timeout (refclocks) */ - void (*action) P((struct peer *)); /* action timeout function */ + void (*action) (struct peer *); /* action timeout function */ /* * Statistic counters @@ -368,12 +391,12 @@ struct peer { u_long sent; /* packets sent */ u_long received; /* packets received */ - u_long processed; /* packets processed by the protocol */ - u_long badauth; /* packets cryptosum failed */ - u_long bogusorg; /* packets bogus origin */ - u_long oldpkt; /* packets duplicate packet */ - u_long seldisptoolarge; /* packets dispersion too large */ - u_long selbroken; /* not used */ + u_long processed; /* packets processed */ + u_long badauth; /* bad authentication (TEST5) */ + u_long bogusorg; /* bogus origin (TEST2, TEST3) */ + u_long oldpkt; /* old duplicate (TEST1) */ + u_long seldisptoolarge; /* bad header (TEST6, TEST7) */ + u_long selbroken; /* KoD received */ }; /* @@ -419,20 +442,23 @@ struct peer { * Values for peer.flags */ #define FLAG_CONFIG 0x0001 /* association was configured */ -#define FLAG_AUTHENABLE 0x0002 /* authentication required */ +#define FLAG_PREEMPT 0x0002 /* preemptable association */ #define FLAG_AUTHENTIC 0x0004 /* last message was authentic */ -#define FLAG_SKEY 0x0008 /* autokey authentication */ -#define FLAG_MCAST 0x0010 /* multicast client mode */ -#define FLAG_REFCLOCK 0x0020 /* this is actually a reference clock */ -#define FLAG_SYSPEER 0x0040 /* this is one of the selected peers */ -#define FLAG_PREFER 0x0080 /* this is the preferred peer */ -#define FLAG_BURST 0x0100 /* burst mode */ -#define FLAG_IBURST 0x0200 /* initial burst mode */ -#define FLAG_NOSELECT 0x0400 /* never select */ -#define FLAG_ASSOC 0x0800 /* autokey request */ -#define FLAG_FIXPOLL 0x1000 /* stick at minpoll */ -#define FLAG_TRUE 0x2000 /* select truechimer */ -#define FLAG_PREEMPT 0x4000 /* preemptable association */ +#define FLAG_REFCLOCK 0x0008 /* this is actually a reference clock */ +#define FLAG_BC_VOL 0x0010 /* broadcast client volleying */ +#define FLAG_PREFER 0x0020 /* prefer peer */ +#define FLAG_BURST 0x0040 /* burst mode */ +#define FLAG_PPS 0x0080 /* steered by PPS */ +#define FLAG_IBURST 0x0100 /* initial burst mode */ +#define FLAG_NOSELECT 0x0200 /* never select */ +#define FLAG_TRUE 0x0400 /* force truechimer */ +#define FLAG_SKEY 0x0800 /* autokey authentication */ +#define FLAG_XLEAVE 0x1000 /* interleaved protocol */ +#define FLAG_XB 0x2000 /* interleaved broadcast */ +#define FLAG_XBOGUS 0x4000 /* interleaved bogus packet */ +#ifdef OPENSSL +#define FLAG_ASSOC 0x8000 /* autokey request */ +#endif /* OPENSSL */ /* * Definitions for the clear() routine. We use memset() to clear @@ -502,86 +528,6 @@ struct peer { #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_storage *)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 - * clocks an address of the form 127.127.t.u, where t is the type and - * u is the unit number. We define some of this here since we will need - * some sanity checks to make sure this address isn't interpretted as - * that of a normal peer. - */ -#define REFCLOCK_ADDR 0x7f7f0000 /* 127.127.0.0 */ -#define REFCLOCK_MASK 0xffff0000 /* 255.255.0.0 */ - -#define ISREFCLOCKADR(srcadr) ((SRCADR(srcadr) & REFCLOCK_MASK) \ - == REFCLOCK_ADDR) - -/* - * Macro for checking for invalid addresses. This is really, really - * gross, but is needed so no one configures a host on net 127 now that - * we're encouraging it the the configuration file. - */ -#define LOOPBACKADR 0x7f000001 -#define LOOPNETMASK 0xff000000 - -#define ISBADADR(srcadr) (((SRCADR(srcadr) & LOOPNETMASK) \ - == (LOOPBACKADR & LOOPNETMASK)) \ - && (SRCADR(srcadr) != LOOPBACKADR)) - -/* - * Utilities for manipulating addresses and port numbers - */ -#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 @@ -592,30 +538,30 @@ struct peer { * and must be converted (except the mac, which isn't, really). */ struct pkt { - u_char li_vn_mode; /* leap indicator, version and mode */ + u_char li_vn_mode; /* peer leap indicator */ u_char stratum; /* peer stratum */ u_char ppoll; /* peer poll interval */ s_char precision; /* peer clock precision */ - u_fp rootdelay; /* distance to primary clock */ - u_fp rootdispersion; /* clock dispersion */ - u_int32 refid; /* reference clock ID */ - l_fp reftime; /* time peer clock was last updated */ + u_fp rootdelay; /* roundtrip delay to primary source */ + u_fp rootdisp; /* dispersion to primary source*/ + u_int32 refid; /* reference id */ + l_fp reftime; /* last update time */ l_fp org; /* originate time stamp */ l_fp rec; /* receive time stamp */ l_fp xmt; /* transmit time stamp */ -#define LEN_PKT_NOMAC 12 * sizeof(u_int32) /* min header length */ -#define LEN_PKT_MAC LEN_PKT_NOMAC + sizeof(u_int32) -#define MIN_MAC_LEN 3 * sizeof(u_int32) /* DES */ -#define MAX_MAC_LEN 5 * sizeof(u_int32) /* MD5 */ +#define LEN_PKT_NOMAC (12 * sizeof(u_int32)) /* min header length */ +#define MIN_MAC_LEN (1 * sizeof(u_int32)) /* crypto_NAK */ +#define MAX_MD5_LEN (5 * sizeof(u_int32)) /* MD5 */ +#define MAX_MAC_LEN (6 * sizeof(u_int32)) /* SHA */ /* * The length of the packet less MAC must be a multiple of 64 - * with an RSA modulus and Diffie-Hellman prime of 64 octets + * with an RSA modulus and Diffie-Hellman prime of 256 octets * and maximum host name of 128 octets, the maximum autokey * command is 152 octets and maximum autokey response is 460 * octets. A packet can contain no more than one command and one - * response, so the maximum total extension field length is 672 + * response, so the maximum total extension field length is 864 * octets. But, to handle humungus certificates, the bank must * be broke. */ @@ -661,33 +607,53 @@ struct pkt { * System event codes */ #define EVNT_UNSPEC 0 /* unspecified */ -#define EVNT_SYSRESTART 1 /* system restart */ -#define EVNT_SYSFAULT 2 /* wsystem or hardware fault */ -#define EVNT_SYNCCHG 3 /* new leap or synch change */ -#define EVNT_PEERSTCHG 4 /* new source or stratum */ -#define EVNT_CLOCKRESET 5 /* clock reset */ -#define EVNT_BADDATETIM 6 /* invalid time or date */ -#define EVNT_CLOCKEXCPT 7 /* reference clock exception */ +#define EVNT_NSET 1 /* freq not set */ +#define EVNT_FSET 2 /* freq set */ +#define EVNT_SPIK 3 /* spike detect */ +#define EVNT_FREQ 4 /* freq mode */ +#define EVNT_SYNC 5 /* clock sync */ +#define EVNT_SYSRESTART 6 /* restart */ +#define EVNT_SYSFAULT 7 /* panic stop */ +#define EVNT_NOPEER 8 /* no sys peer */ +#define EVNT_ARMED 9 /* leap armed */ +#define EVNT_DISARMED 10 /* leap disarmed */ +#define EVNT_LEAP 11 /* leap event */ +#define EVNT_CLOCKRESET 12 /* clock step */ +#define EVNT_KERN 13 /* kernel event */ +#define EVNT_TAI 14 /* TAI */ +#define EVNT_LEAPVAL 15 /* stale leapsecond values */ +#define EVNT_CLKHOP 16 /* clockhop */ /* * Peer event codes */ -#define EVNT_PEERIPERR (1 | PEER_EVENT) /* IP error */ -#define EVNT_PEERAUTH (2 | PEER_EVENT) /* authentication failure */ -#define EVNT_UNREACH (3 | PEER_EVENT) /* change to unreachable */ -#define EVNT_REACH (4 | PEER_EVENT) /* change to reachable */ -#define EVNT_PEERCLOCK (5 | PEER_EVENT) /* clock exception */ +#define PEVNT_MOBIL (1 | PEER_EVENT) /* mobilize */ +#define PEVNT_DEMOBIL (2 | PEER_EVENT) /* demobilize */ +#define PEVNT_UNREACH (3 | PEER_EVENT) /* unreachable */ +#define PEVNT_REACH (4 | PEER_EVENT) /* reachable */ +#define PEVNT_RESTART (5 | PEER_EVENT) /* restart */ +#define PEVNT_REPLY (6 | PEER_EVENT) /* no reply */ +#define PEVNT_RATE (7 | PEER_EVENT) /* rate exceeded */ +#define PEVNT_DENY (8 | PEER_EVENT) /* access denied */ +#define PEVNT_ARMED (9 | PEER_EVENT) /* leap armed */ +#define PEVNT_NEWPEER (10 | PEER_EVENT) /* sys peer */ +#define PEVNT_CLOCK (11 | PEER_EVENT) /* clock event */ +#define PEVNT_AUTH (12 | PEER_EVENT) /* bad auth */ +#define PEVNT_POPCORN (13 | PEER_EVENT) /* popcorn */ +#define PEVNT_XLEAVE (14 | PEER_EVENT) /* interleave mode */ +#define PEVNT_XERR (15 | PEER_EVENT) /* interleave error */ +#define PEVNT_TAI (16 | PEER_EVENT) /* TAI */ /* * Clock event codes */ #define CEVNT_NOMINAL 0 /* unspecified */ -#define CEVNT_TIMEOUT 1 /* poll timeout */ -#define CEVNT_BADREPLY 2 /* bad reply format */ -#define CEVNT_FAULT 3 /* hardware or software fault */ -#define CEVNT_PROP 4 /* propagation failure */ -#define CEVNT_BADDATE 5 /* bad date format or value */ -#define CEVNT_BADTIME 6 /* bad time format or value */ +#define CEVNT_TIMEOUT 1 /* no reply */ +#define CEVNT_BADREPLY 2 /* bad format */ +#define CEVNT_FAULT 3 /* fault */ +#define CEVNT_PROP 4 /* bad signal */ +#define CEVNT_BADDATE 5 /* bad date */ +#define CEVNT_BADTIME 6 /* bad time */ #define CEVNT_MAX CEVNT_BADTIME /* @@ -705,12 +671,6 @@ struct pkt { #define NTP_HASH_ADDR(src) sock_hash(src) /* - * How we randomize polls. The poll interval is a power of two. We chose - * a random interval which is this value plus-minus one second. - */ -#define RANDPOLL(x) ((1 << (x)) - 1 + (ntp_random() & 0x3)) - -/* * min, min3 and max. Makes it easier to transliterate the spec without * thinking about it. */ @@ -763,6 +723,8 @@ struct pkt { #define LOOP_HUFFPUFF 9 /* set huff-n'-puff filter length */ #define LOOP_FREQ 10 /* set initial frequency */ #define LOOP_KERN_CLEAR 11 /* reset kernel pll parameters */ +#define LOOP_CODEC 12 /* set audio codec frequency */ +#define LOOP_LEAP 13 /* insert leap after second 23:59 */ /* * Configuration items for the stats printer @@ -770,13 +732,13 @@ struct pkt { #define STATS_FREQ_FILE 1 /* configure drift file */ #define STATS_STATSDIR 2 /* directory prefix for stats files */ #define STATS_PID_FILE 3 /* configure ntpd PID file */ +#define STATS_LEAP_FILE 4 /* configure ntpd leapseconds file */ #define MJD_1900 15020 /* MJD for 1 Jan 1900 */ /* * Default parameters. We use these in the absence of something better. */ -#define DEFBROADDELAY 4e-3 /* default broadcast offset */ #define INADDR_NTP 0xe0000101 /* NTP multicast address 224.0.1.1 */ /* @@ -786,16 +748,17 @@ 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 */ - 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 */ + int flags; /* restrict flags */ + int leak; /* leaky bucket accumulator */ + int count; /* total packet count */ + u_long firsttime; /* first time found */ + u_long lasttime; /* last time found */ + sockaddr_u 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 */ - u_char version; /* version of incoming packet */ - u_char cast_flags; /* flags MDF_?CAST */ + u_short rmtport; /* remote port last came from */ + u_char mode; /* packet mode */ + u_char version; /* packet version */ + u_char cast_flags; /* flags MDF_?CAST */ }; /* @@ -818,57 +781,65 @@ struct mon_data { /* * Structure used for restrictlist entries */ -struct restrictlist { - struct restrictlist *next; /* link to next entry */ - 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 */ +typedef struct res_addr4_tag { + u_int32 addr; /* IPv4 addr (host order) */ + u_int32 mask; /* IPv4 mask (host order) */ +} res_addr4; + +typedef struct res_addr6_tag { + struct in6_addr addr; /* IPv6 addr (net order) */ + struct in6_addr mask; /* IPv6 mask (net order) */ +} res_addr6; + +typedef struct restrict_u_tag restrict_u; +struct restrict_u_tag { + restrict_u * link; /* link to next entry */ + u_int32 count; /* number of packets matched */ + u_short flags; /* accesslist flags */ + u_short mflags; /* match flags */ + union { /* variant starting here */ + res_addr4 v4; + res_addr6 v6; + } u; }; +#define V4_SIZEOF_RESTRICT_U (offsetof(restrict_u, u) \ + + sizeof(res_addr4)) +#define V6_SIZEOF_RESTRICT_U (offsetof(restrict_u, u) \ + + sizeof(res_addr6)) /* * Access flags */ -#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_IGNORE 0x0001 /* ignore packet */ +#define RES_DONTSERVE 0x0002 /* access denied */ +#define RES_DONTTRUST 0x0004 /* authentication required */ +#define RES_VERSION 0x0008 /* version mismatch */ +#define RES_NOPEER 0x0010 /* new association denied */ +#define RES_LIMITED 0x0020 /* packet rate exceeded */ #define RES_FLAGS (RES_IGNORE | RES_DONTSERVE |\ RES_DONTTRUST | RES_VERSION |\ RES_NOPEER | RES_LIMITED) -#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_NOQUERY 0x0040 /* mode 6/7 packet denied */ +#define RES_NOMODIFY 0x0080 /* mode 6/7 modify denied */ +#define RES_NOTRAP 0x0100 /* mode 6/7 set trap denied */ +#define RES_LPTRAP 0x0200 /* mode 6/7 low priority trap */ -#define RES_DEMOBILIZE 0x400 /* send kiss of death packet */ -#define RES_TIMEOUT 0x800 /* timeout this entry */ +#define RES_KOD 0x0400 /* send kiss of death packet */ +#define RES_MSSNTP 0x0800 /* enable MS-SNTP authentication */ +#define RES_TIMEOUT 0x1000 /* timeout this entry */ #define RES_ALLFLAGS (RES_FLAGS | RES_NOQUERY |\ RES_NOMODIFY | RES_NOTRAP |\ - RES_LPTRAP | RES_DEMOBILIZE |\ - RES_TIMEOUT) + RES_LPTRAP | RES_KOD |\ + RES_MSSNTP | RES_TIMEOUT) /* * Match flags */ -#define RESM_INTERFACE 0x1 /* this is an interface */ -#define RESM_NTPONLY 0x2 /* match ntp port only */ +#define RESM_INTERFACE 0x1000 /* this is an interface */ +#define RESM_NTPONLY 0x2000 /* match ntp port only */ /* * Restriction configuration ops diff --git a/include/ntp_assert.h b/include/ntp_assert.h new file mode 100644 index 000000000000..ab9b41981be6 --- /dev/null +++ b/include/ntp_assert.h @@ -0,0 +1,97 @@ +/* + * ntp_assert.h - design by contract stuff + * + * example: + * + * int foo(char *a) { + * int result; + * int value; + * + * REQUIRE(a != NULL); + * ... + * bar(&value); + * INSIST(value > 2); + * ... + * + * ENSURE(result != 12); + * return result; + * } + * + * open question: when would we use INVARIANT()? + * + * For cases where the overhead for non-debug builds is deemed too high, + * use DEBUG_REQUIRE(), DEBUG_INSIST(), DEBUG_ENSURE(), and/or + * DEBUG_INVARIANT(). + */ + +#ifndef NTP_ASSERT_H +#define NTP_ASSERT_H + +# ifdef CALYSTO + +extern void calysto_assume(unsigned char cnd); /* assume this always holds */ +extern void calysto_assert(unsigned char cnd); /* check whether this holds */ +#define ALWAYS_REQUIRE(x) calysto_assert(x) +#define ALWAYS_INSIST(x) calysto_assume(x) /* DLH calysto_assert()? */ +#define ALWAYS_INVARIANT(x) calysto_assume(x) +#define ALWAYS_ENSURE(x) calysto_assert(x) + +/* # elif defined(__COVERITY__) */ +/* + * DH: try letting coverity scan our actual assertion macros, now that + * isc_assertioncallback_t is marked __attribute__ __noreturn__. + */ + +/* + * Coverity has special knowledge that assert(x) terminates the process + * if x is not true. Rather than teach it about our assertion macros, + * just use the one it knows about for Coverity Prevent scans. This + * means our assertion code (and ISC's) escapes Coverity analysis, but + * that seems to be a reasonable trade-off. + */ + +/* +#define ALWAYS_REQUIRE(x) assert(x) +#define ALWAYS_INSIST(x) assert(x) +#define ALWAYS_INVARIANT(x) assert(x) +#define ALWAYS_ENSURE(x) assert(x) +*/ + +# else /* neither Coverity nor Calysto */ + +#include "isc/assertions.h" + +#define ALWAYS_REQUIRE(x) ISC_REQUIRE(x) +#define ALWAYS_INSIST(x) ISC_INSIST(x) +#define ALWAYS_INVARIANT(x) ISC_INVARIANT(x) +#define ALWAYS_ENSURE(x) ISC_ENSURE(x) + +# endif /* neither Coverity nor Calysto */ + +#define REQUIRE(x) ALWAYS_REQUIRE(x) +#define INSIST(x) ALWAYS_INSIST(x) +#define INVARIANT(x) ALWAYS_INVARIANT(x) +#define ENSURE(x) ALWAYS_ENSURE(x) + +/* + * We initially used NTP_REQUIRE() instead of REQUIRE() etc, but that + * is unneccesarily verbose, as libisc use of REQUIRE() etc shows. + */ +#define NTP_REQUIRE(x) REQUIRE(x) +#define NTP_INSIST(x) INSIST(x) +#define NTP_INVARIANT(x) INVARIANT(x) +#define NTP_ENSURE(x) ENSURE(x) + +# ifdef DEBUG +#define DEBUG_REQUIRE(x) REQUIRE(x) +#define DEBUG_INSIST(x) INSIST(x) +#define DEBUG_INVARIANT(x) INVARIANT(x) +#define DEBUG_ENSURE(x) ENSURE(x) +# else +#define DEBUG_REQUIRE(x) (void)(x) +#define DEBUG_INSIST(x) (void)(x) +#define DEBUG_INVARIANT(x) (void)(x) +#define DEBUG_ENSURE(x) (void)(x) +# endif + +#endif /* NTP_ASSERT_H */ diff --git a/include/ntp_calendar.h b/include/ntp_calendar.h index 95e2c12974ba..fbdb27c7ab4f 100644 --- a/include/ntp_calendar.h +++ b/include/ntp_calendar.h @@ -7,13 +7,13 @@ #include "ntp_types.h" struct calendar { - u_short year; /* year (A.D.) */ + u_short year; /* year (A.D.) */ u_short yearday; /* day of year, 1 = January 1 */ - u_char month; /* month, 1 = January */ + u_char month; /* month, 1 = January */ u_char monthday; /* day of month */ - u_char hour; /* hour of day, midnight = 0 */ - u_char minute; /* minute of hour */ - u_char second; /* second of minute */ + u_char hour; /* hour of day, midnight = 0 */ + u_char minute; /* minute of hour */ + u_char second; /* second of minute */ }; /* @@ -44,7 +44,7 @@ struct calendar { #define DAYSPERYEAR (365) /* days per year */ #define SECSPERDAY (SECSPERMIN*MINSPERHR*HRSPERDAY) -#define SECSPERYEAR (365 * SECSPERDAY) /* regular year */ +#define SECSPERYEAR (365 * SECSPERDAY) /* regular year */ #define SECSPERLEAPYEAR (366 * SECSPERDAY) /* leap year */ #define MAR1900 ((JAN+FEB) * SECSPERDAY) /* no leap year in 1900 */ @@ -56,9 +56,9 @@ struct calendar { * Gross hacks. I have illicit knowlege that there won't be overflows * here, the compiler often can't tell this. */ -#define TIMES60(val) ((((val)<<4) - (val))<<2) /* *(16 - 1) * 4 */ +#define TIMES60(val) ((((val)<<4) - (val))<<2) /* *(16 - 1) * 4 */ #define TIMES24(val) (((val)<<4) + ((val)<<3)) /* *16 + *8 */ -#define TIMES7(val) (((val)<<3) - (val)) /* *8 - *1 */ +#define TIMES7(val) (((val)<<3) - (val)) /* *8 - *1 */ #define TIMESDPERC(val) (((val)<<10) + ((val)<<8) \ + ((val)<<7) + ((val)<<5) \ + ((val)<<4) + ((val)<<2) + (val)) /* *big* hack */ @@ -78,8 +78,8 @@ struct calendar { #define JANFEBLEAP ((JAN+FEBLEAP) * SECSPERDAY) -extern void caljulian P((u_long, struct calendar *)); -extern u_long caltontp P((const struct calendar *)); +extern void caljulian (u_long, struct calendar *); +extern u_long caltontp (const struct calendar *); /* * Additional support stuff for Ed Rheingold's calendrical calculations @@ -87,26 +87,26 @@ extern u_long caltontp P((const struct calendar *)); /* * Start day of NTP time as days past the imaginary date 12/1/1 BC. - * P((This is the beginning of the Christian Era, or BCE.)) + * (This is the beginning of the Christian Era, or BCE.) */ -#define DAY_NTP_STARTS 693596 +#define DAY_NTP_STARTS 693596 /* * The Gregorian calendar is based on a 400 year cycle. This is the number * of days in each cycle. */ -#define GREGORIAN_CYCLE_DAYS 146097 +#define GREGORIAN_CYCLE_DAYS 146097 /* * Days in a normal 100 year leap year calendar. We lose a leap year day * in years evenly divisible by 100 but not by 400. */ -#define GREGORIAN_NORMAL_CENTURY_DAYS 36524 +#define GREGORIAN_NORMAL_CENTURY_DAYS 36524 /* * Days in a normal 4 year leap year calendar cycle. */ -#define GREGORIAN_NORMAL_LEAP_CYCLE_DAYS 1461 +#define GREGORIAN_NORMAL_LEAP_CYCLE_DAYS 1461 -#define is_leapyear(y) (y%4 == 0 && !(y%100 == 0 && !(y%400 == 0))) +#define is_leapyear(y) (!((y) % 4) && !(!((y) % 100) && (y) % 400)) #endif diff --git a/include/ntp_cmdargs.h b/include/ntp_cmdargs.h index e9ab9b1c29cc..ee41b4a56c33 100644 --- a/include/ntp_cmdargs.h +++ b/include/ntp_cmdargs.h @@ -1,4 +1,4 @@ #include "ntp_types.h" -extern void getstartup P((int, char **)); -extern void getCmdOpts P((int, char **)); +extern void getstartup (int, char **); +extern void getCmdOpts (int, char **); diff --git a/include/ntp_config.h b/include/ntp_config.h index 66d4f9f9027c..037ed0733c3e 100644 --- a/include/ntp_config.h +++ b/include/ntp_config.h @@ -1,3 +1,11 @@ +#ifndef NTP_CONFIG_H +#define NTP_CONFIG_H + +#include "ntp_machine.h" +#include "ntp_data_structures.h" +#include "ntpsim.h" + + /* * Configuration file name */ @@ -11,171 +19,227 @@ # endif /* SYS_WINNT */ #endif /* not CONFIG_FILE */ -/* - * Types of entries we understand. +#ifdef HAVE_IPTOS_SUPPORT +/* + * "qos" modified keywords */ -#define CONFIG_UNKNOWN 0 +#define CONF_QOS_LOWDELAY 1 +#define CONF_QOS_THROUGHPUT 2 +#define CONF_QOS_RELIABILITY 3 +#define CONF_QOS_MINCOST 4 -/* - * Command keywords - */ -#define CONFIG_PEER 1 -#define CONFIG_SERVER 2 -#define CONFIG_AUTOMAX 3 -#define CONFIG_DRIFTFILE 4 -#define CONFIG_BROADCAST 5 -#define CONFIG_BROADCASTCLIENT 6 -#define CONFIG_AUTHENTICATE 7 -#define CONFIG_KEYS 8 -#define CONFIG_REVOKE 9 -#define CONFIG_CDELAY 10 -#define CONFIG_RESTRICT 11 -#define CONFIG_BDELAY 12 -#define CONFIG_TRUSTEDKEY 13 -#define CONFIG_REQUESTKEY 14 -#define CONFIG_CONTROLKEY 15 -#define CONFIG_TRAP 16 -#define CONFIG_FUDGE 17 -#define CONFIG_TINKER 18 -#define CONFIG_STATSDIR 19 -#define CONFIG_FILEGEN 20 -#define CONFIG_STATISTICS 21 -#define CONFIG_PIDFILE 22 -#define CONFIG_SETVAR 23 -#define CONFIG_DISCARD 24 -#define CONFIG_ADJ 25 -#define CONFIG_MULTICASTCLIENT 26 -#define CONFIG_ENABLE 27 -#define CONFIG_DISABLE 28 -#define CONFIG_PHONE 29 -#define CONFIG_LOGFILE 30 -#define CONFIG_LOGCONFIG 31 -#define CONFIG_MANYCASTCLIENT 32 -#define CONFIG_MANYCASTSERVER 33 -#define CONFIG_TOS 34 -#define CONFIG_TTL 35 -#define CONFIG_INCLUDEFILE 36 -#define CONFIG_KEYSDIR 37 -#define CONFIG_END 38 -#ifdef OPENSSL -#define CONFIG_CRYPTO 39 -#endif /* OPENSSL */ +#ifdef IPTOS_PREC_INTERNETCONTROL +#define CONF_QOS_CS0 5 +#define CONF_QOS_CS1 6 +#define CONF_QOS_CS2 7 +#define CONF_QOS_CS3 8 +#define CONF_QOS_CS4 9 +#define CONF_QOS_CS5 10 +#define CONF_QOS_CS6 11 +#define CONF_QOS_CS7 12 +#endif /* IPTOS_PREC_INTERNETCONTROL */ -/* - * "peer", "server", "broadcast" modifier keywords - */ -#define CONF_MOD_VERSION 1 -#define CONF_MOD_KEY 2 -#define CONF_MOD_MINPOLL 3 -#define CONF_MOD_MAXPOLL 4 -#define CONF_MOD_PREFER 5 -#define CONF_MOD_BURST 6 -#define CONF_MOD_IBURST 7 -#define CONF_MOD_SKEY 8 -#define CONF_MOD_TTL 9 -#define CONF_MOD_MODE 10 -#define CONF_MOD_NOSELECT 11 -#define CONF_MOD_TRUE 12 -#define CONF_MOD_PREEMPT 13 -#define CONF_MOD_DYNAMIC 14 +#endif /* HAVE_IPTOS_SUPPORT */ -/* - * "restrict" modifier keywords - */ -#define CONF_RES_MASK 1 -#define CONF_RES_IGNORE 2 -#define CONF_RES_NOSERVE 3 -#define CONF_RES_NOTRUST 4 -#define CONF_RES_NOQUERY 5 -#define CONF_RES_NOMODIFY 6 -#define CONF_RES_NOPEER 7 -#define CONF_RES_NOTRAP 8 -#define CONF_RES_LPTRAP 9 -#define CONF_RES_NTPPORT 10 -#define CONF_RES_LIMITED 11 -#define CONF_RES_VERSION 12 -#define CONF_RES_DEMOBILIZE 13 /* - * "trap" modifier keywords + * We keep config trees around for possible saveconfig use. When + * built with configure --disable-saveconfig, and when built with + * debugging enabled, include the free_config_*() routines. In the + * DEBUG case, they are used in an atexit() cleanup routine to make + * postmortem leak check reports more interesting. */ -#define CONF_TRAP_PORT 1 -#define CONF_TRAP_INTERFACE 2 +#if !defined(FREE_CFG_T) && (!defined(SAVECONFIG) || defined(DEBUG)) +#define FREE_CFG_T +#endif -/* - * "fudge" modifier keywords - */ -#define CONF_FDG_TIME1 1 -#define CONF_FDG_TIME2 2 -#define CONF_FDG_STRATUM 3 -#define CONF_FDG_REFID 4 -#define CONF_FDG_FLAG1 5 -#define CONF_FDG_FLAG2 6 -#define CONF_FDG_FLAG3 7 -#define CONF_FDG_FLAG4 8 +/* Limits */ +#define MAXLINE 1024 -/* - * "filegen" modifier keywords - */ -#define CONF_FGEN_FILE 1 -#define CONF_FGEN_TYPE 2 -#define CONF_FGEN_FLAG_LINK 3 -#define CONF_FGEN_FLAG_NOLINK 4 -#define CONF_FGEN_FLAG_ENABLE 5 -#define CONF_FGEN_FLAG_DISABLE 6 +/* Configuration sources */ -/* - * "discard" modifier keywords - */ -#define CONF_DISCARD_AVERAGE 1 -#define CONF_DISCARD_MINIMUM 2 -#define CONF_DISCARD_MONITOR 3 +#define CONF_SOURCE_FILE 0 +#define CONF_SOURCE_NTPQ 1 -/* - * "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_ALLAN 5 -#define CONF_CLOCK_HUFFPUFF 6 -#define CONF_CLOCK_FREQ 7 -/* - * "tos" modifier keywords - */ -#define CONF_TOS_MINCLOCK 1 -#define CONF_TOS_MAXCLOCK 2 -#define CONF_TOS_MINSANE 3 -#define CONF_TOS_FLOOR 4 -#define CONF_TOS_CEILING 5 -#define CONF_TOS_COHORT 6 -#define CONF_TOS_MINDISP 7 -#define CONF_TOS_MAXDIST 8 -#define CONF_TOS_MAXHOP 9 -#define CONF_TOS_BEACON 10 -#define CONF_TOS_ORPHAN 11 - -#ifdef OPENSSL -/* - * "crypto" modifier keywords - */ -#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_IDENT 7 -#define CONF_CRYPTO_IFFPAR 8 -#define CONF_CRYPTO_GQPAR 9 -#define CONF_CRYPTO_MVPAR 10 -#define CONF_CRYPTO_PW 11 -#endif /* OPENSSL */ +/* Structure for storing an attribute-value pair */ +struct attr_val { + int attr; + union val { + double d; + int i; + u_int u; + char * s; + void * p; + } value; + int type; +}; -/* - * Address selection, IPv4 or IPv6 - */ -#define CONF_ADDR_IPV4 1 -#define CONF_ADDR_IPV6 2 +/* Structure for nodes on the syntax tree */ +struct address_node { + char *address; + int type; +}; + +struct restrict_node { + struct address_node *addr; + struct address_node *mask; + queue *flags; + int line_no; +}; + +struct peer_node { + int host_mode; + struct address_node *addr; + queue *peerflags; + int minpoll; + int maxpoll; + int ttl; + int peerversion; + int peerkey; + double bias; +}; + +struct unpeer_node { + u_int assocID; + struct address_node * addr; +}; + +struct auth_node { + int control_key; + int cryptosw; + queue *crypto_cmd_list; + char *keys; + char *keysdir; + int request_key; + int revoke; + queue *trusted_key_list; + char *ntp_signd_socket; +}; + +struct filegen_node { + int filegen_token; + queue * options; +}; + +struct setvar_node { + char * var; + char * val; + int isdefault; +}; + +typedef struct nic_rule_node_tag { + int match_class; + char *if_name; /* interface name or numeric address */ + int action; +} nic_rule_node; + +struct addr_opts_node { + struct address_node *addr; + queue *options; +}; + +struct sim_node { + queue *init_opts; + queue *servers; +}; + + +/* The syntax tree */ +struct config_tree { + struct config_tree *link; + + struct attr_val source; + time_t timestamp; + + queue *peers; + queue *unpeers; + + /* Other Modes */ + int broadcastclient; + queue *manycastserver; + queue *multicastclient; + + queue *orphan_cmds; + + /* Monitoring Configuration */ + queue *stats_list; + char *stats_dir; + queue *filegen_opts; + + /* Access Control Configuration */ + queue *discard_opts; + queue *restrict_opts; + + queue *fudge; + queue *tinker; + queue *enable_opts; + queue *disable_opts; + struct auth_node auth; + + queue *logconfig; + queue *qos; + queue *phone; + queue *setvar; + queue *ttl; + queue *trap; + queue *vars; + queue *nic_rules; + + struct sim_node *sim_details; +}; + + +/* Structure for holding a remote configuration command */ +struct REMOTE_CONFIG_INFO { + char buffer[MAXLINE]; + char err_msg[MAXLINE]; + int pos; + int err_pos; + int no_errors; +}; + +/* get text from T_ tokens */ +const char * token_name(int token); + +struct peer_node *create_peer_node(int hmode, + struct address_node *addr, + queue *options); +struct unpeer_node *create_unpeer_node(struct address_node *addr); +struct address_node *create_address_node(char *addr, int type); +void destroy_address_node(struct address_node *my_node); +queue *enqueue_in_new_queue(void *my_node); +struct attr_val *create_attr_dval(int attr, double value); +struct attr_val *create_attr_ival(int attr, int value); +struct attr_val *create_attr_shorts(int, ntp_u_int16_t, ntp_u_int16_t); +struct attr_val *create_attr_sval(int attr, char *s); +struct attr_val *create_attr_pval(int attr, void *s); +struct filegen_node *create_filegen_node(int filegen_token, queue *options); +void **create_pval(void *val); +struct restrict_node *create_restrict_node(struct address_node *addr, + struct address_node *mask, + queue *flags, int line_no); +int *create_ival(int val); +struct addr_opts_node *create_addr_opts_node(struct address_node *addr, + queue *options); +struct sim_node *create_sim_node(queue *init_opts, queue *servers); +struct setvar_node *create_setvar_node(char *var, char *val, + int isdefault); +nic_rule_node *create_nic_rule_node(int match_class, char *if_name, + int action); + +script_info *create_sim_script_info(double duration, + queue *script_queue); +server_info *create_sim_server(struct address_node *addr, + double server_offset, queue *script); + +extern struct REMOTE_CONFIG_INFO remote_config; +void config_remotely(sockaddr_u *); + +#ifdef SAVECONFIG +int dump_config_tree(struct config_tree *ptree, FILE *df, int comment); +int dump_all_config_trees(FILE *df, int comment); +#endif + + +#endif /* !defined(NTP_CONFIG_H) */ diff --git a/include/ntp_control.h b/include/ntp_control.h index c299794534b3..3bca32b6e5b1 100644 --- a/include/ntp_control.h +++ b/include/ntp_control.h @@ -18,7 +18,7 @@ struct ntp_control { /* * Length of the control header, in octets */ -#define CTL_HEADER_LEN 12 +#define CTL_HEADER_LEN (offsetof(struct ntp_control, data)) #define CTL_MAX_DATA_LEN 468 @@ -45,30 +45,31 @@ struct ntp_control { /* * Opcodes */ -#define CTL_OP_UNSPEC 0 -#define CTL_OP_READSTAT 1 -#define CTL_OP_READVAR 2 -#define CTL_OP_WRITEVAR 3 -#define CTL_OP_READCLOCK 4 -#define CTL_OP_WRITECLOCK 5 -#define CTL_OP_SETTRAP 6 -#define CTL_OP_ASYNCMSG 7 -#define CTL_OP_UNSETTRAP 31 +#define CTL_OP_UNSPEC 0 /* unspeciffied */ +#define CTL_OP_READSTAT 1 /* read status */ +#define CTL_OP_READVAR 2 /* read variables */ +#define CTL_OP_WRITEVAR 3 /* write variables */ +#define CTL_OP_READCLOCK 4 /* read clock variables */ +#define CTL_OP_WRITECLOCK 5 /* write clock variables */ +#define CTL_OP_SETTRAP 6 /* set trap address */ +#define CTL_OP_ASYNCMSG 7 /* asynchronous message */ +#define CTL_OP_CONFIGURE 8 /* runtime configuration */ +#define CTL_OP_SAVECONFIG 9 /* save config to file */ +#define CTL_OP_UNSETTRAP 31 /* unset trap */ /* * {En,De}coding of the system status word */ -#define CTL_SST_TS_UNSPEC 0 /* time source unspecified */ -#define CTL_SST_TS_ATOM 1 /* time source calibrated atomic */ -#define CTL_SST_TS_LF 2 /* time source VLF or LF radio */ -#define CTL_SST_TS_HF 3 /* time source HF radio */ -#define CTL_SST_TS_UHF 4 /* time source UHF radio */ -#define CTL_SST_TS_LOCAL 5 /* time source LOCAL */ -#define CTL_SST_TS_NTP 6 /* time source NTP */ -#define CTL_SST_TS_UDPTIME 7 /* time source UDP/TIME */ -#define CTL_SST_TS_WRSTWTCH 8 /* time source is wristwatch */ -#define CTL_SST_TS_TELEPHONE 9 /* time source is telephone modem */ -#define CTL_SST_TS_PPS 0x20 /* time source is PPS signal */ +#define CTL_SST_TS_UNSPEC 0 /* unspec */ +#define CTL_SST_TS_ATOM 1 /* pps */ +#define CTL_SST_TS_LF 2 /* lf radio */ +#define CTL_SST_TS_HF 3 /* hf radio */ +#define CTL_SST_TS_UHF 4 /* uhf radio */ +#define CTL_SST_TS_LOCAL 5 /* local */ +#define CTL_SST_TS_NTP 6 /* ntp */ +#define CTL_SST_TS_UDPTIME 7 /* other */ +#define CTL_SST_TS_WRSTWTCH 8 /* wristwatch */ +#define CTL_SST_TS_TELEPHONE 9 /* telephone */ #define CTL_SYS_MAXEVENTS 15 @@ -90,14 +91,14 @@ struct ntp_control { #define CTL_PST_AUTHENABLE 0x40 #define CTL_PST_AUTHENTIC 0x20 #define CTL_PST_REACH 0x10 -#define CTL_PST_UNSPEC 0x08 +#define CTL_PST_BCAST 0x08 #define CTL_PST_SEL_REJECT 0 /* reject */ #define CTL_PST_SEL_SANE 1 /* x falsetick */ #define CTL_PST_SEL_CORRECT 2 /* . excess */ #define CTL_PST_SEL_SELCAND 3 /* - outlyer */ -#define CTL_PST_SEL_SYNCCAND 4 /* + candidat */ -#define CTL_PST_SEL_DISTSYSPEER 5 /* # selected */ +#define CTL_PST_SEL_SYNCCAND 4 /* + candidate */ +#define CTL_PST_SEL_EXCESS 5 /* # backup */ #define CTL_PST_SEL_SYSPEER 6 /* * sys.peer */ #define CTL_PST_SEL_PPS 7 /* o pps.peer */ @@ -154,31 +155,32 @@ struct ntp_control { #define CS_REFTIME 7 #define CS_POLL 8 #define CS_PEERID 9 -#define CS_STATE 10 -#define CS_OFFSET 11 -#define CS_DRIFT 12 -#define CS_JITTER 13 -#define CS_ERROR 14 -#define CS_CLOCK 15 -#define CS_PROCESSOR 16 -#define CS_SYSTEM 17 -#define CS_VERSION 18 -#define CS_STABIL 19 -#define CS_VARLIST 20 +#define CS_OFFSET 10 +#define CS_DRIFT 11 +#define CS_JITTER 12 +#define CS_ERROR 13 +#define CS_CLOCK 14 +#define CS_PROCESSOR 15 +#define CS_SYSTEM 16 +#define CS_VERSION 17 +#define CS_STABIL 18 +#define CS_VARLIST 19 +#define CS_TAI 20 +#define CS_LEAPTAB 21 +#define CS_LEAPEND 22 +#define CS_RATE 23 #ifdef OPENSSL -#define CS_FLAGS 21 -#define CS_HOST 22 -#define CS_PUBLIC 23 -#define CS_CERTIF 24 -#define CS_REVTIME 25 -#define CS_LEAPTAB 26 -#define CS_TAI 27 -#define CS_DIGEST 28 -#define CS_IDENT 29 -#define CS_REVOKE 30 -#define CS_MAXCODE CS_REVOKE +#define CS_FLAGS 24 +#define CS_HOST 25 +#define CS_PUBLIC 26 +#define CS_CERTIF 27 +#define CS_SIGNATURE 28 +#define CS_REVTIME 29 +#define CS_GROUP 30 +#define CS_DIGEST 31 +#define CS_MAXCODE CS_DIGEST #else -#define CS_MAXCODE CS_VARLIST +#define CS_MAXCODE CS_RATE #endif /* OPENSSL */ /* @@ -221,18 +223,21 @@ struct ntp_control { #define CP_FLASH 35 #define CP_TTL 36 #define CP_VARLIST 37 +#define CP_IN 38 +#define CP_OUT 39 +#define CP_RATE 40 +#define CP_BIAS 41 #ifdef OPENSSL -#define CP_FLAGS 38 -#define CP_HOST 39 -#define CP_VALID 40 -#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 +#define CP_FLAGS 42 +#define CP_HOST 43 +#define CP_VALID 44 +#define CP_INITSEQ 45 +#define CP_INITKEY 46 +#define CP_INITTSP 47 +#define CP_SIGNATURE 48 +#define CP_MAXCODE CP_SIGNATURE #else -#define CP_MAXCODE CP_VARLIST +#define CP_MAXCODE CP_BIAS #endif /* OPENSSL */ /* @@ -251,7 +256,6 @@ struct ntp_control { #define CC_FLAGS 11 #define CC_DEVICE 12 #define CC_VARLIST 13 - #define CC_MAXCODE CC_VARLIST /* @@ -259,7 +263,7 @@ struct ntp_control { * ntp_request.c wants to see this. */ struct ctl_trap { - struct sockaddr_storage tr_addr;/* address of trap recipient */ + sockaddr_u 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/include/ntp_crypto.h b/include/ntp_crypto.h index 14795e72dfbf..80e3fb11a8f1 100644 --- a/include/ntp_crypto.h +++ b/include/ntp_crypto.h @@ -1,8 +1,27 @@ /* * ntp_crypto.h - definitions for cryptographic operations */ +#ifndef NTP_CRYPTO_H +#define NTP_CRYPTO_H + +/* + * Configuration codes (also needed for parser without OPENSSL) + */ +#define CRYPTO_CONF_NONE 0 /* nothing doing */ +#define CRYPTO_CONF_PRIV 1 /* host keys file name */ +#define CRYPTO_CONF_SIGN 2 /* signature keys file name */ +#define CRYPTO_CONF_CERT 3 /* certificate file name */ +#define CRYPTO_CONF_RAND 4 /* random seed file name */ +#define CRYPTO_CONF_IFFPAR 5 /* IFF parameters file name */ +#define CRYPTO_CONF_GQPAR 6 /* GQ parameters file name */ +#define CRYPTO_CONF_MVPAR 7 /* MV parameters file name */ +#define CRYPTO_CONF_PW 8 /* private key password */ +#define CRYPTO_CONF_IDENT 9 /* specify identity scheme */ +#define CRYPTO_CONF_NID 10 /* specify digest name */ + #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. @@ -20,13 +39,14 @@ * The following bits are used by the client during the protocol * exchange. */ -#define CRYPTO_FLAG_VALID 0x0100 /* public key verified */ +#define CRYPTO_FLAG_CERT 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_COOK 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 */ +#define CRYPTO_FLAG_LEAP 0x4000 /* leapsecond values verified */ +#define CRYPTO_FLAG_ALL 0x7f00 /* all mask */ /* * Flags used for certificate management @@ -48,7 +68,7 @@ #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_LEAP CRYPTO_CMD(5) /* leapsecond values */ #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 */ @@ -72,37 +92,20 @@ #define XEVNT_VFY XEVNT_CMD(9) /* certificate not verified */ #define XEVNT_PER XEVNT_CMD(10) /* host 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_DAT XEVNT_CMD(12) /* bad or missing leapseconds */ #define XEVNT_CRT XEVNT_CMD(13) /* bad or missing certificate */ #define XEVNT_ID XEVNT_CMD(14) /* bad or missing group key */ #define XEVNT_ERR XEVNT_CMD(15) /* protocol error */ -#define XEVNT_SRV XEVNT_CMD(16) /* server certificate expired */ - -/* - * Configuration codes - */ -#define CRYPTO_CONF_NONE 0 /* nothing doing */ -#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 */ -#define CRYPTO_CONF_IDENT 12 /* specify identity scheme */ /* * 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 */ -#define TAI_1972 10 /* initial TAI offset (s) */ +#define NTP_MAXEXTEN 2048 /* maximum extension field size */ +#define NTP_AUTOMAX 12 /* default key list timeout (log2 s) */ +#define KEY_REVOKE 17 /* default key revoke timeout (log2 s) */ +#define NTP_REFRESH 19 /* default restart timeout (log2 s) */ +#define NTP_MAXKEY 65535 /* maximum symmetric key ID */ /* * The autokey structure holds the values used to authenticate key IDs. @@ -154,17 +157,27 @@ struct cert_info { tstamp_t last; /* not valid after */ char *subject; /* subject common name */ char *issuer; /* issuer common name */ - u_char *grpkey; /* GQ group key */ - u_int grplen; /* GQ group key length */ + BIGNUM *grpkey; /* GQ group key */ struct value cert; /* certificate/value */ }; /* + * The keys info/value structure + */ +struct pkey_info { + struct pkey_info *link; /* forward link */ + EVP_PKEY *pkey; /* generic key */ + char *name; /* file name */ + tstamp_t fstamp; /* filestamp */ +}; + +/* * Cryptographic values */ -extern char *keysdir; /* crypto keys directory */ extern u_int crypto_flags; /* status word */ +extern int crypto_nid; /* digest nid */ extern struct value hostval; /* host name/value */ extern struct cert_info *cinfo; /* host certificate information */ extern struct value tai_leap; /* leapseconds table */ #endif /* OPENSSL */ +#endif /* NTP_CRYPTO_H */ diff --git a/include/ntp_data_structures.h b/include/ntp_data_structures.h new file mode 100644 index 000000000000..363e0b47a4e9 --- /dev/null +++ b/include/ntp_data_structures.h @@ -0,0 +1,53 @@ +/* ntp_data_structures.h + * + * This file contains the structures and function prototypes for the data + * structures used by the ntp configuration code and the discrete event + * simulator. + * + * Written By: Sachin Kamboj + * University of Delaware + * Newark, DE 19711 + * Copyright (c) 2006 + */ + +#ifndef __NTP_DATA_STRUCTURES_H__ +#define __NTP_DATA_STRUCTURES_H__ + + +/* Structures for storing a priority queue + * --------------------------------------- + */ + +typedef struct node { + union { + struct node *next; + double d; + } nodeu; +} node; +#define node_next nodeu.next + +typedef struct Queue { + int (*get_order)(void *, void *); + node *front; + int no_of_elements; +} queue; + + +/* FUNCTION PROTOTYPES + * ------------------- + */ +queue *create_priority_queue(int (*get_order)(void *, void *)); +void destroy_queue(queue *my_queue); +void *get_node(size_t size); +void free_node(void *my_node); +void *next_node(void *my_node); +int empty(queue *my_queue); +void *queue_head(queue *my_queue); +queue *enqueue(queue *my_queue, void *my_node); +void *dequeue(queue *my_queue); +int get_no_of_elements(queue *my_queue); +void append_queue(queue *q1, queue *q2); +int get_fifo_order(void *el1, void *el2); +queue *create_queue(void); + +#endif diff --git a/include/ntp_filegen.h b/include/ntp_filegen.h index 836ec04ec0f9..2b90db29dde3 100644 --- a/include/ntp_filegen.h +++ b/include/ntp_filegen.h @@ -35,17 +35,20 @@ /* without this, open is suppressed */ typedef struct FILEGEN - { - FILE *fp; /* file referring to current generation */ - char *prefix; /* filename prefix and basename to be used*/ - char *basename; /* for constructing filename of generation file */ +{ + FILE * fp; /* file referring to current generation */ + const char * prefix; /* filename prefix and basename to be used*/ + char * basename; /* for constructing filename of generation file */ /* WARNING: must be malloced !!! will be fed to free()*/ - u_long id; /* id of current generation */ - u_char type; /* type of file generation */ - u_char flag; /* flags modifying processing of file generation */ - } FILEGEN; - -extern void filegen_setup P((FILEGEN *, u_long)); -extern void filegen_config P((FILEGEN *, char *, u_int, u_int)); -extern FILEGEN *filegen_get P((char *)); -extern void filegen_register P((char *, const char *, FILEGEN *)); + u_long id; /* id of current generation */ + u_char type; /* type of file generation */ + u_char flag; /* flags modifying processing of file generation */ +} FILEGEN; + +extern void filegen_setup (FILEGEN *, u_long); +extern void filegen_config (FILEGEN *, const char *, u_int, u_int); +extern FILEGEN *filegen_get (const char *); +extern void filegen_register (const char *, const char *, FILEGEN *); +#ifdef DEBUG +extern void filegen_unregister(char *); +#endif diff --git a/include/ntp_fp.h b/include/ntp_fp.h index 307ab102dd4b..99d4df37025f 100644 --- a/include/ntp_fp.h +++ b/include/ntp_fp.h @@ -5,12 +5,6 @@ #ifndef NTP_FP_H #define NTP_FP_H -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> - -#include "ntp_rfc2553.h" - #include "ntp_types.h" /* @@ -76,7 +70,7 @@ typedef int32 s_fp; typedef u_int32 u_fp; /* - * A unit second in fp format. Actually 2**(half_the_bits_in_a_long) + * A unit second in fp format. Actually 2**(half_the_bits_in_a_long) */ #define FP_SECOND (0x10000) @@ -92,9 +86,9 @@ typedef u_int32 u_fp; #define NTOHL_MFP(ni, nf, hi, hf) \ do { (hi) = ntohl(ni); (hf) = ntohl(nf); } while (0) #define HTONL_MFP(hi, hf, ni, nf) \ - do { (ni) = ntohl(hi); (nf) = ntohl(hf); } while (0) + do { (ni) = htonl(hi); (nf) = htonl(hf); } while (0) -/* funny ones. Converts ts fractions to net order ts */ +/* funny ones. Converts ts fractions to net order ts */ #define HTONL_UF(uf, nts) \ do { (nts)->l_ui = 0; (nts)->l_uf = htonl(uf); } while (0) #define HTONL_F(f, nts) do { (nts)->l_uf = htonl(f); \ @@ -124,7 +118,7 @@ typedef u_int32 u_fp; * be replaced by inline assembler for particular machines someday. * These are the (kind of inefficient) run-anywhere versions. */ -#define M_NEG(v_i, v_f) /* v = -v */ \ +#define M_NEG(v_i, v_f) /* v = -v */ \ do { \ if ((v_f) == 0) \ (v_i) = -((s_fp)(v_i)); \ @@ -134,7 +128,7 @@ typedef u_int32 u_fp; } \ } while(0) -#define M_NEGM(r_i, r_f, a_i, a_f) /* r = -a */ \ +#define M_NEGM(r_i, r_f, a_i, a_f) /* r = -a */ \ do { \ if ((a_f) == 0) { \ (r_f) = 0; \ @@ -145,7 +139,7 @@ typedef u_int32 u_fp; } \ } while(0) -#define M_ADD(r_i, r_f, a_i, a_f) /* r += a */ \ +#define M_ADD(r_i, r_f, a_i, a_f) /* r += a */ \ do { \ register u_int32 lo_tmp; \ register u_int32 hi_tmp; \ @@ -244,7 +238,7 @@ typedef u_int32 u_fp; (v_f) <<= 1; \ } while (0) -#define M_ADDUF(r_i, r_f, uf) /* r += uf, uf is u_int32 fraction */ \ +#define M_ADDUF(r_i, r_f, uf) /* r += uf, uf is u_int32 fraction */ \ M_ADD((r_i), (r_f), 0, (uf)) /* let optimizer worry about it */ #define M_SUBUF(r_i, r_f, uf) /* r -= uf, uf is u_int32 fraction */ \ @@ -258,7 +252,7 @@ typedef u_int32 u_fp; M_ADD((r_i), (r_f), (-1), (f));\ } while(0) -#define M_ISNEG(v_i, v_f) /* v < 0 */ \ +#define M_ISNEG(v_i, v_f) /* v < 0 */ \ (((v_i) & 0x80000000) != 0) #define M_ISHIS(a_i, a_f, b_i, b_f) /* a >= b unsigned */ \ @@ -297,7 +291,7 @@ typedef u_int32 u_fp; /* * s_fp/double and u_fp/double conversions */ -#define FRIC 65536. /* 2^16 as a double */ +#define FRIC 65536. /* 2^16 as a double */ #define DTOFP(r) ((s_fp)((r) * FRIC)) #define DTOUFP(r) ((u_fp)((r) * FRIC)) #define FPTOD(r) ((double)(r) / FRIC) @@ -305,8 +299,8 @@ typedef u_int32 u_fp; /* * l_fp/double conversions */ -#define FRAC 4294967296. /* 2^32 as a double */ -#define M_DTOLFP(d, r_i, r_uf) /* double to l_fp */ \ +#define FRAC 4294967296. /* 2^32 as a double */ +#define M_DTOLFP(d, r_i, r_uf) /* double to l_fp */ \ do { \ register double d_tmp; \ \ @@ -321,7 +315,7 @@ typedef u_int32 u_fp; (r_uf) = (u_int32)(((d_tmp) - (double)(r_i)) * FRAC); \ } \ } while (0) -#define M_LFPTOD(r_i, r_uf, d) /* l_fp to double */ \ +#define M_LFPTOD(r_i, r_uf, d) /* l_fp to double */ \ do { \ register l_fp l_tmp; \ \ @@ -334,46 +328,44 @@ typedef u_int32 u_fp; (d) = (double)l_tmp.l_i + ((double)l_tmp.l_uf) / FRAC; \ } \ } while (0) -#define DTOLFP(d, v) M_DTOLFP((d), (v)->l_ui, (v)->l_uf) -#define LFPTOD(v, d) M_LFPTOD((v)->l_ui, (v)->l_uf, (d)) +#define DTOLFP(d, v) M_DTOLFP((d), (v)->l_ui, (v)->l_uf) +#define LFPTOD(v, d) M_LFPTOD((v)->l_ui, (v)->l_uf, (d)) /* * Prototypes */ -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, short)); -extern char * fptoms P((s_fp, short)); -extern int hextolfp P((const char *, l_fp *)); -extern void gpstolfp P((int, int, unsigned long, l_fp *)); -extern int mstolfp P((const char *, l_fp *)); -extern char * prettydate P((l_fp *)); -extern char * gmprettydate P((l_fp *)); -extern char * uglydate P((l_fp *)); -extern void mfp_mul P((int32 *, u_int32 *, int32, u_int32, int32, u_int32)); - -extern void get_systime P((l_fp *)); -extern int step_systime P((double)); -extern int adj_systime P((double)); - -extern struct tm * ntp2unix_tm P((u_long ntp, int local)); - -#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 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) -#define ulfptoa(_fpv, _ndec) dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 0) -#define ulfptoms(_fpv, _ndec) dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 1) -#define umfptoa(_fpi, _fpf, _ndec) dolfptoa((_fpi), (_fpf), 0, (_ndec), 0) +extern char * dofptoa (u_fp, int, short, int); +extern char * dolfptoa (u_long, u_long, int, short, int); + +extern int atolfp (const char *, l_fp *); +extern int buftvtots (const char *, l_fp *); +extern char * fptoa (s_fp, short); +extern char * fptoms (s_fp, short); +extern int hextolfp (const char *, l_fp *); +extern void gpstolfp (int, int, unsigned long, l_fp *); +extern int mstolfp (const char *, l_fp *); +extern char * prettydate (l_fp *); +extern char * gmprettydate (l_fp *); +extern char * uglydate (l_fp *); +extern void mfp_mul (int32 *, u_int32 *, int32, u_int32, int32, u_int32); + +extern void get_systime (l_fp *); +extern int step_systime (double); +extern int adj_systime (double); + +extern struct tm * ntp2unix_tm (u_long ntp, int local); + +#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 stoa(addr) socktoa(addr) +#define ntoa(addr) stoa(addr) +#define stohost(addr) socktohost(addr) + +#define ufptoa(fpv, ndec) dofptoa((fpv), 0, (ndec), 0) +#define ufptoms(fpv, ndec) dofptoa((fpv), 0, (ndec), 1) +#define ulfptoa(fpv, ndec) dolfptoa((fpv)->l_ui, (fpv)->l_uf, 0, (ndec), 0) +#define ulfptoms(fpv, ndec) dolfptoa((fpv)->l_ui, (fpv)->l_uf, 0, (ndec), 1) +#define umfptoa(fpi, fpf, ndec) dolfptoa((fpi), (fpf), 0, (ndec), 0) #endif /* NTP_FP_H */ diff --git a/include/ntp_intres.h b/include/ntp_intres.h new file mode 100644 index 000000000000..53c8a63a4076 --- /dev/null +++ b/include/ntp_intres.h @@ -0,0 +1,14 @@ +#ifndef NTP_INTRES_H +#define NTP_INTRES_H + +/* + * Some systems do not support fork() and don't have an alternate + * threads implementation of ntp_intres. Such systems are limited + * to using numeric IP addresses. + */ +#if defined(VMS) || defined (SYS_VXWORKS) || \ + (!defined(HAVE_WORKING_FORK) && !defined(SYS_WINNT)) +#define NO_INTRES +#endif + +#endif /* !defined(NTP_INTRES_H) */ diff --git a/include/ntp_io.h b/include/ntp_io.h index 983c6c7dce85..920fd0d36f70 100644 --- a/include/ntp_io.h +++ b/include/ntp_io.h @@ -1,5 +1,5 @@ -#if !defined _NTP_IO_H -#define _NTP_IO_H +#ifndef NTP_IO_H +#define NTP_IO_H /* * POSIX says use <fnct.h> to get O_* symbols and * SEEK_SET symbol form <unistd.h>. @@ -8,9 +8,7 @@ # include <config.h> #endif -#ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif +#include <sys/types.h> #ifdef HAVE_UNISTD_H # include <unistd.h> #endif @@ -30,6 +28,17 @@ # include "win32_io.h" #endif +#include <isc/boolean.h> +#include <isc/netaddr.h> + +#if defined(HAVE_NETINET_IN_H) && defined(HAVE_NETINET_IP_H) +# include <netinet/in.h> +# ifdef HAVE_NETINET_IN_SYSTM_H +# include <netinet/in_systm.h> +# endif +# include <netinet/ip.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 @@ -47,4 +56,34 @@ # endif #endif -#endif + +/* + * NIC rule match types + */ +typedef enum { + MATCH_ALL, + MATCH_IPV4, + MATCH_IPV6, + MATCH_WILDCARD, + MATCH_IFNAME, + MATCH_IFADDR +} nic_rule_match; + + +/* + * NIC rule actions + */ +typedef enum { + ACTION_LISTEN, + ACTION_IGNORE, + ACTION_DROP +} nic_rule_action; + + +isc_boolean_t get_broadcastclient_flag(void); +extern int is_ip_address(const char *, sockaddr_u *); +extern void sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *); +extern void add_nic_rule(nic_rule_match match_type, const char *if_name, + int prefixlen, nic_rule_action action); + +#endif /* NTP_IO_H */ diff --git a/include/ntp_libopts.h b/include/ntp_libopts.h new file mode 100644 index 000000000000..c4d6e165f149 --- /dev/null +++ b/include/ntp_libopts.h @@ -0,0 +1,13 @@ +/* + * ntp_libopts.h + * + * Common code interfacing with Autogen's libopts command-line option + * processing. + */ +#ifndef NTP_LIBOPTS_H +# define NTP_LIBOPTS_H +# include "autoopts/options.h" + +extern int ntpOptionProcess(tOptions *pOpts, int argc, + char ** argv); +#endif diff --git a/include/ntp_lineedit.h b/include/ntp_lineedit.h new file mode 100644 index 000000000000..623c6f402530 --- /dev/null +++ b/include/ntp_lineedit.h @@ -0,0 +1,13 @@ + +/* + * ntp_lineedit.h - generic interface to various line editing libs + */ + +int ntp_readline_init(const char *prompt); +void ntp_readline_uninit(void); + +/* + * strings returned by ntp_readline go home to free() + */ +char * ntp_readline(int *pcount); + diff --git a/include/ntp_lists.h b/include/ntp_lists.h new file mode 100644 index 000000000000..2b6e616965a7 --- /dev/null +++ b/include/ntp_lists.h @@ -0,0 +1,443 @@ +/* + * ntp_lists.h - linked lists common code + * + * SLIST: singly-linked lists + * ========================== + * + * These macros implement a simple singly-linked list template. Both + * the listhead and per-entry next fields are declared as pointers to + * the list entry struct type. Initialization to NULL is typically + * implicit (for globals and statics) or handled by zeroing of the + * containing structure. + * + * The name of the next link field is passed as an argument to allow + * membership in several lists at once using multiple next link fields. + * + * When possible, placing the link field first in the entry structure + * allows slightly smaller code to be generated on some platforms. + * + * LINK_SLIST(listhead, pentry, nextlink) + * add entry at head + * + * LINK_TAIL_SLIST(listhead, pentry, nextlink, entrytype) + * add entry at tail. This is O(n), if this is a common + * operation the FIFO template may be more appropriate. + * + * LINK_SORT_SLIST(listhead, pentry, beforecur, nextlink, entrytype) + * add entry in sorted order. beforecur is an expression comparing + * pentry with the current list entry. The current entry can be + * referenced within beforecur as L_S_S_CUR(), which is short for + * LINK_SORT_SLIST_CUR(). beforecur is nonzero if pentry sorts + * before L_S_S_CUR(). + * + * UNLINK_HEAD_SLIST(punlinked, listhead, nextlink) + * unlink first entry and point punlinked to it, or set punlinked + * to NULL if the list is empty. + * + * UNLINK_SLIST(punlinked, listhead, ptounlink, nextlink, entrytype) + * unlink entry pointed to by ptounlink. punlinked is set to NULL + * if the entry is not found on the list, otherwise it is set to + * ptounlink. + * + * UNLINK_EXPR_SLIST(punlinked, listhead, expr, nextlink, entrytype) + * unlink entry where expression expr is nonzero. expr can refer + * to the entry being tested using UNLINK_EXPR_SLIST_CURRENT(), + * alias U_E_S_CUR(). See the implementation of UNLINK_SLIST() + * below for an example. U_E_S_CUR() is NULL iff the list is empty. + * punlinked is pointed to the removed entry or NULL if none + * satisfy expr. + * + * FIFO: singly-linked lists plus tail pointer + * =========================================== + * + * This is the same as FreeBSD's sys/queue.h STAILQ -- a singly-linked + * list implementation with tail-pointer maintenance, so that adding + * at the tail for first-in, first-out access is O(1). + * + * DECL_FIFO_ANCHOR(entrytype) + * provides the type specification portion of the declaration for + * a variable to refer to a FIFO queue (similar to listhead). The + * anchor contains the head and indirect tail pointers. Example: + * + * #include "ntp_lists.h" + * + * typedef struct myentry_tag myentry; + * struct myentry_tag { + * myentry *next_link; + * ... + * }; + * + * DECL_FIFO_ANCHOR(myentry) my_fifo; + * + * void somefunc(myentry *pentry) + * { + * LINK_FIFO(my_fifo, pentry, next_link); + * } + * + * If DECL_FIFO_ANCHOR is used with stack or heap storage, it + * should be initialized to NULL pointers using a = { NULL }; + * initializer or memset. + * + * HEAD_FIFO(anchor) + * TAIL_FIFO(anchor) + * Pointer to first/last entry, NULL if FIFO is empty. + * + * LINK_FIFO(anchor, pentry, nextlink) + * add entry at tail. + * + * UNLINK_FIFO(punlinked, anchor, nextlink) + * unlink head entry and point punlinked to it, or set punlinked + * to NULL if the list is empty. + * + * CONCAT_FIFO(q1, q2, nextlink) + * empty fifoq q2 moving its nodes to q1 following q1's existing + * nodes. + * + * DLIST: doubly-linked lists + * ========================== + * + * Elements on DLISTs always have non-NULL forward and back links, + * because both link chains are circular. The beginning/end is marked + * by the listhead, which is the same type as elements for simplicity. + * An empty list's listhead has both links set to its own address. + * + * + */ +#ifndef NTP_LISTS_H +#define NTP_LISTS_H + +#include "ntp_types.h" /* TRUE and FALSE */ +#include "ntp_assert.h" + +#ifdef DEBUG +# define NTP_DEBUG_LISTS_H +#endif + +/* + * If list debugging is not enabled, save a little time by not clearing + * an entry's link pointer when it is unlinked, as the stale pointer + * is harmless as long as it is ignored when the entry is not in a + * list. + */ +#ifndef NTP_DEBUG_LISTS_H +#define MAYBE_Z_LISTS(p) do { } while (FALSE) +#else +#define MAYBE_Z_LISTS(p) (p) = NULL +#endif + +#define LINK_SLIST(listhead, pentry, nextlink) \ +do { \ + (pentry)->nextlink = (listhead); \ + (listhead) = (pentry); \ +} while (FALSE) + +#define LINK_TAIL_SLIST(listhead, pentry, nextlink, entrytype) \ +do { \ + entrytype **pptail; \ + \ + pptail = &(listhead); \ + while (*pptail != NULL) \ + pptail = &((*pptail)->nextlink); \ + \ + (pentry)->nextlink = NULL; \ + *pptail = (pentry); \ +} while (FALSE) + +#define LINK_SORT_SLIST_CURRENT() (*ppentry) +#define L_S_S_CUR() LINK_SORT_SLIST_CURRENT() + +#define LINK_SORT_SLIST(listhead, pentry, beforecur, nextlink, \ + entrytype) \ +do { \ + entrytype **ppentry; \ + \ + ppentry = &(listhead); \ + while (TRUE) { \ + if (NULL == *ppentry || (beforecur)) { \ + (pentry)->nextlink = *ppentry; \ + *ppentry = (pentry); \ + break; \ + } \ + ppentry = &((*ppentry)->nextlink); \ + if (NULL == *ppentry) { \ + (pentry)->nextlink = NULL; \ + *ppentry = (pentry); \ + break; \ + } \ + } \ +} while (FALSE) + +#define UNLINK_HEAD_SLIST(punlinked, listhead, nextlink) \ +do { \ + (punlinked) = (listhead); \ + if (NULL != (punlinked)) { \ + (listhead) = (punlinked)->nextlink; \ + MAYBE_Z_LISTS((punlinked)->nextlink); \ + } \ +} while (FALSE) + +#define UNLINK_EXPR_SLIST_CURRENT() (*ppentry) +#define U_E_S_CUR() UNLINK_EXPR_SLIST_CURRENT() + +#define UNLINK_EXPR_SLIST(punlinked, listhead, expr, nextlink, \ + entrytype) \ +do { \ + entrytype **ppentry; \ + \ + ppentry = &(listhead); \ + \ + while (!(expr)) \ + if (*ppentry != NULL && \ + (*ppentry)->nextlink != NULL) { \ + ppentry = &((*ppentry)->nextlink); \ + } else { \ + ppentry = NULL; \ + break; \ + } \ + \ + if (ppentry != NULL) { \ + (punlinked) = *ppentry; \ + *ppentry = (punlinked)->nextlink; \ + MAYBE_Z_LISTS((punlinked)->nextlink); \ + } else { \ + (punlinked) = NULL; \ + } \ +} while (FALSE) + +#define UNLINK_SLIST(punlinked, listhead, ptounlink, nextlink, \ + entrytype) \ + UNLINK_EXPR_SLIST(punlinked, listhead, (ptounlink) == \ + U_E_S_CUR(), nextlink, entrytype) + +#define CHECK_SLIST(listhead, nextlink, entrytype) \ +do { \ + entrytype *pentry; \ + \ + for (pentry = (listhead); \ + pentry != NULL; \ + pentry = pentry->nextlink){ \ + NTP_INSIST(pentry != pentry->nextlink); \ + NTP_INSIST((listhead) != pentry->nextlink); \ + } \ +} while (FALSE) + +/* + * FIFO + */ + +#define DECL_FIFO_ANCHOR(entrytype) \ +struct { \ + entrytype * phead; /* NULL if list empty */ \ + entrytype ** pptail; /* NULL if list empty */ \ +} + +#define HEAD_FIFO(anchor) ((anchor).phead) +#define TAIL_FIFO(anchor) ((NULL == (anchor).pptail) \ + ? NULL \ + : *((anchor).pptail)) + +/* + * For DEBUG builds only, verify both or neither of the anchor pointers + * are NULL with each operation. + */ +#if !defined(NTP_DEBUG_LISTS_H) +#define CHECK_FIFO_CONSISTENCY(anchor) do { } while (FALSE) +#else +#define CHECK_FIFO_CONSISTENCY(anchor) \ + check_gen_fifo_consistency(&(anchor)) +void check_gen_fifo_consistency(void *fifo); +#endif + +/* + * generic FIFO element used to access any FIFO where each element + * begins with the link pointer + */ +typedef struct gen_node_tag gen_node; +struct gen_node_tag { + gen_node * link; +}; + +/* generic FIFO */ +typedef DECL_FIFO_ANCHOR(gen_node) gen_fifo; + + +#define LINK_FIFO(anchor, pentry, nextlink) \ +do { \ + CHECK_FIFO_CONSISTENCY(anchor); \ + \ + (pentry)->nextlink = NULL; \ + if (NULL != (anchor).pptail) { \ + (*((anchor).pptail))->nextlink = (pentry); \ + (anchor).pptail = \ + &(*((anchor).pptail))->nextlink; \ + } else { \ + (anchor).phead = (pentry); \ + (anchor).pptail = &(anchor).phead; \ + } \ + \ + CHECK_FIFO_CONSISTENCY(anchor); \ +} while (FALSE) + +#define UNLINK_FIFO(punlinked, anchor, nextlink) \ +do { \ + CHECK_FIFO_CONSISTENCY(anchor); \ + \ + (punlinked) = (anchor).phead; \ + if (NULL != (punlinked)) { \ + (anchor).phead = (punlinked)->nextlink; \ + if (NULL == (anchor).phead) \ + (anchor).pptail = NULL; \ + else if ((anchor).pptail == \ + &(punlinked)->nextlink) \ + (anchor).pptail = &(anchor).phead; \ + MAYBE_Z_LISTS((punlinked)->nextlink); \ + CHECK_FIFO_CONSISTENCY(anchor); \ + } \ +} while (FALSE) + +#define UNLINK_MID_FIFO(punlinked, anchor, tounlink, nextlink, \ + entrytype) \ +do { \ + entrytype **ppentry; \ + \ + CHECK_FIFO_CONSISTENCY(anchor); \ + \ + ppentry = &(anchor).phead; \ + \ + while ((tounlink) != *ppentry) \ + if ((*ppentry)->nextlink != NULL) { \ + ppentry = &((*ppentry)->nextlink); \ + } else { \ + ppentry = NULL; \ + break; \ + } \ + \ + if (ppentry != NULL) { \ + (punlinked) = *ppentry; \ + *ppentry = (punlinked)->nextlink; \ + if (NULL == *ppentry) \ + (anchor).pptail = NULL; \ + else if ((anchor).pptail == \ + &(punlinked)->nextlink) \ + (anchor).pptail = &(anchor).phead; \ + MAYBE_Z_LISTS((punlinked)->nextlink); \ + CHECK_FIFO_CONSISTENCY(anchor); \ + } else { \ + (punlinked) = NULL; \ + } \ +} while (FALSE) + +#define CONCAT_FIFO(f1, f2, nextlink) \ +do { \ + CHECK_FIFO_CONSISTENCY(f1); \ + CHECK_FIFO_CONSISTENCY(f2); \ + \ + if ((f2).pptail != NULL) { \ + if ((f1).pptail != NULL) { \ + (*(f1).pptail)->nextlink = (f2).phead; \ + if ((f2).pptail == &(f2).phead) \ + (f1).pptail = \ + &(*(f1).pptail)->nextlink; \ + else \ + (f1).pptail = (f2).pptail; \ + CHECK_FIFO_CONSISTENCY(f1); \ + } else { \ + (f1) = (f2); \ + } \ + MAYBE_Z_LISTS((f2).phead); \ + MAYBE_Z_LISTS((f2).pptail); \ + } \ +} while (FALSE) + +/* + * DLIST + */ +#define DECL_DLIST_LINK(entrytype, link) \ +struct { \ + entrytype * b; \ + entrytype * f; \ +} link + +#define INIT_DLIST(listhead, link) \ +do { \ + (listhead).link.f = &(listhead); \ + (listhead).link.b = &(listhead); \ +} while (FALSE) + +#define HEAD_DLIST(listhead, link) \ + ( \ + (&(listhead) != (listhead).link.f) \ + ? (listhead).link.f \ + : NULL \ + ) + +#define TAIL_DLIST(listhead, link) \ + ( \ + (&(listhead) != (listhead).link.b) \ + ? (listhead).link.b \ + : NULL \ + ) + +#define NEXT_DLIST(listhead, entry, link) \ + ( \ + (&(listhead) != (entry)->link.f) \ + ? (entry)->link.f \ + : NULL \ + ) + +#define PREV_DLIST(listhead, entry, link) \ + ( \ + (&(listhead) != (entry)->link.b) \ + ? (entry)->link.b \ + : NULL \ + ) + +#define LINK_DLIST(listhead, pentry, link) \ +do { \ + (pentry)->link.f = (listhead).link.f; \ + (pentry)->link.b = &(listhead); \ + (listhead).link.f->link.b = (pentry); \ + (listhead).link.f = (pentry); \ +} while (FALSE) + +#define LINK_TAIL_DLIST(listhead, pentry, link) \ +do { \ + (pentry)->link.b = (listhead).link.b; \ + (pentry)->link.f = &(listhead); \ + (listhead).link.b->link.f = (pentry); \ + (listhead).link.b = (pentry); \ +} while (FALSE) + +#define UNLINK_DLIST(ptounlink, link) \ +do { \ + (ptounlink)->link.b->link.f = (ptounlink)->link.f; \ + (ptounlink)->link.f->link.b = (ptounlink)->link.b; \ + MAYBE_Z_LISTS((ptounlink)->link.b); \ + MAYBE_Z_LISTS((ptounlink)->link.f); \ +} while (FALSE) + +#define ITER_DLIST_BEGIN(listhead, iter, link, entrytype) \ +{ \ + entrytype *i_dl_nextiter; \ + \ + for ((iter) = (listhead).link.f; \ + (iter) != &(listhead) \ + && ((i_dl_nextiter = (iter)->link.f), TRUE); \ + (iter) = i_dl_nextiter) { +#define ITER_DLIST_END() \ + } \ +} + +#define REV_ITER_DLIST_BEGIN(listhead, iter, link, entrytype) \ +{ \ + entrytype *i_dl_nextiter; \ + \ + for ((iter) = (listhead).link.b; \ + (iter) != &(listhead) \ + && ((i_dl_nextiter = (iter)->link.b), TRUE); \ + (iter) = i_dl_nextiter) { +#define REV_ITER_DLIST_END() \ + } \ +} + +#endif /* NTP_LISTS_H */ diff --git a/include/ntp_machine.h b/include/ntp_machine.h index 2a3b6e6a6c67..69dca68170f2 100644 --- a/include/ntp_machine.h +++ b/include/ntp_machine.h @@ -2,8 +2,8 @@ * Collect all machine dependent idiosyncrasies in one place. */ -#ifndef __ntp_machine -#define __ntp_machine +#ifndef NTP_MACHINE_H +#define NTP_MACHINE_H #ifdef HAVE_CONFIG_H # include <config.h> @@ -74,24 +74,12 @@ WILL IOCTL(SIOCGIFCONF) WORK ON A SOCKET MISC - HAVE_PROTOTYPES - Prototype functions DOSYNCTODR - Resync TODR clock every hour. RETSIGTYPE - Define signal function type. NO_SIGNED_CHAR_DECL - No "signed char" see include/ntp.h LOCK_PROCESS - Have plock. */ -/* - * Set up for prototyping (duplicated from ntp_types.h) - */ -#ifndef P -#if defined(__STDC__) || defined(HAVE_PROTOTYPES) -#define P(x) x -#else /* not __STDC__ and not HAVE_PROTOTYPES */ -#define P(x) () -#endif /* not __STDC__ and not HAVE_PROTOTYPES */ -#endif /* P */ - #if !defined(HAVE_NTP_ADJTIME) && defined(HAVE___ADJTIMEX) # define ntp_adjtime __adjtimex #endif @@ -239,55 +227,16 @@ typedef unsigned long u_long; * make them macros for everyone else */ #ifndef SYS_WINNT -# define SOCKET int +typedef int SOCKET; # define INVALID_SOCKET -1 # define SOCKET_ERROR -1 -# define closesocket close -#endif -/* - * Windows NT - */ -#if defined(SYS_WINNT) -# if !defined(HAVE_CONFIG_H) || !defined(__config) -# 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 -# define unlink _unlink -# define fileno _fileno -# define write _write -#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 +# define socket_errno() (errno) +# define closesocket(fd) close(fd) +#else /* SYS_WINNT follows */ +# define socket_errno() (errno = WSAGetLastError()) #endif - typedef char *caddr_t; -# define vsnprintf _vsnprintf -#endif /* SYS_WINNT */ -int ntp_set_tod P((struct timeval *tvp, void *tzp)); +int ntp_set_tod (struct timeval *tvp, void *tzp); #if defined (SYS_CYGWIN32) #include <windows.h> @@ -326,7 +275,7 @@ int ntp_set_tod P((struct timeval *tvp, void *tzp)); #include "taskLib.h" #include "time.h" -extern int sysClkRateGet P(()); +extern int sysClkRateGet (); /* usrtime.h * Bob Herlien's excellent time code find it at: @@ -335,14 +284,14 @@ extern int sysClkRateGet P(()); * adjtime() too ... casey */ /* -extern int gettimeofday P(( struct timeval *tp, struct timezone *tzp )); -extern int settimeofday P((struct timeval *, struct timezone *)); -extern int adjtime P(( struct timeval *delta, struct timeval *olddelta )); +extern int gettimeofday ( struct timeval *tp, struct timezone *tzp ); +extern int settimeofday (struct timeval *, struct timezone *); +extern int adjtime ( struct timeval *delta, struct timeval *olddelta ); */ /* in machines.c */ -extern void sleep P((int seconds)); -extern void alarm P((int seconds)); +extern void sleep (int seconds); +extern void alarm (int seconds); /* machines.c */ @@ -382,10 +331,10 @@ extern int h_errno; #define TRY_AGAIN 2 -struct hostent *gethostbyname P((char * netnum)); -struct hostent *gethostbyaddr P((char * netnum, int size, int addr_type)); +struct hostent *gethostbyname (char * netnum); +struct hostent *gethostbyaddr (char * netnum, int size, int addr_type); /* type is the protocol */ -struct servent *getservbyname P((char *name, char *type)); +struct servent *getservbyname (char *name, char *type); #endif /* NO_NETDB */ #ifdef NO_MAIN_ALLOWED @@ -515,8 +464,7 @@ extern char *strdup(const char *); #if !defined(HAVE_ATT_NICE) \ && !defined(HAVE_BSD_NICE) \ - && !defined(HAVE_NO_NICE) \ - && !defined(SYS_WINNT) + && !defined(HAVE_NO_NICE) #include "ERROR: You must define one of the HAVE_xx_NICE defines!" #endif @@ -544,7 +492,7 @@ extern char *strdup(const char *); #endif #ifndef HAVE_TIMEGM -extern time_t timegm P((struct tm *)); +extern time_t timegm (struct tm *); #endif #ifdef HAVE_SYSV_TTYS @@ -587,4 +535,4 @@ extern time_t timegm P((struct tm *)); BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION #endif -#endif /* __ntp_machine */ +#endif /* NTP_MACHINE_H */ diff --git a/include/ntp_malloc.h b/include/ntp_malloc.h index 099c83effe90..4cde62e1a7a5 100644 --- a/include/ntp_malloc.h +++ b/include/ntp_malloc.h @@ -1,19 +1,61 @@ /* * Define malloc and friends. */ -#ifndef _ntp_malloc_h -#define _ntp_malloc_h - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif +#ifndef NTP_MALLOC_H +#define NTP_MALLOC_H #ifdef HAVE_STDLIB_H # include <stdlib.h> -#else /* HAVE_STDLIB_H */ +#else # ifdef HAVE_MALLOC_H # include <malloc.h> # endif -#endif /* HAVE_STDLIB_H */ +#endif + +/* + * Deal with platform differences declaring alloca() + * This comes nearly verbatim from: + * + * http://www.gnu.org/software/autoconf/manual/autoconf.html#Particular-Functions + * + * The only modifications were to remove C++ support and guard against + * redefining alloca. + */ +#ifdef HAVE_ALLOCA_H +# include <alloca.h> +#elif defined __GNUC__ +# ifndef alloca +# define alloca __builtin_alloca +# endif +#elif defined _AIX +# ifndef alloca +# define alloca __alloca +# endif +#elif defined _MSC_VER +# include <malloc.h> +# ifndef alloca +# define alloca _alloca +# endif +#else +# include <stddef.h> +void * alloca(size_t); +#endif + +#ifdef EREALLOC_IMPL +# define EREALLOC_CALLSITE /* preserve __FILE__ and __LINE__ */ +#else +# define EREALLOC_IMPL(ptr, newsz, filenm, loc) \ + realloc(ptr, (newsz)) +#endif + +#ifdef HAVE_STRINGS_H +# include <strings.h> +# define zero_mem(p, s) bzero(p, s) +#endif + +#ifndef zero_mem +# define zero_mem(p, s) memset(p, 0, s) +#endif +#define ZERO(var) zero_mem(&(var), sizeof(var)) -#endif /* _ntp_malloc_h */ +#endif /* NTP_MALLOC_H */ diff --git a/include/ntp_md5.h b/include/ntp_md5.h index bb6985a2f367..458962fdab6f 100644 --- a/include/ntp_md5.h +++ b/include/ntp_md5.h @@ -1,9 +1,29 @@ /* * ntp_md5.h: deal with md5.h headers + * + * Use the system MD5 if available, otherwise libisc's. */ - -#ifdef HAVE_MD5_H +#if defined HAVE_MD5_H && defined HAVE_MD5INIT # include <md5.h> #else -# include "rsa_md5.h" +# include "isc/md5.h" + typedef isc_md5_t MD5_CTX; +# define MD5Init(c) isc_md5_init(c) +# define MD5Update(c, p, s) isc_md5_update(c, p, s) +# define MD5Final(d, c) isc_md5_final((c), (d)) /* swapped */ +#endif + +/* + * Provide OpenSSL-alike MD5 API if we're not using OpenSSL + */ +#ifndef OPENSSL + typedef MD5_CTX EVP_MD_CTX; +# define EVP_get_digestbynid(t) NULL +# define EVP_DigestInit(c, dt) MD5Init(c) +# define EVP_DigestUpdate(c, p, s) MD5Update(c, p, s) +# define EVP_DigestFinal(c, d, pdl) \ + do { \ + MD5Final((d), (c)); \ + *(pdl) = 16; \ + } while (0) #endif diff --git a/include/ntp_net.h b/include/ntp_net.h new file mode 100644 index 000000000000..d417cea4d3d7 --- /dev/null +++ b/include/ntp_net.h @@ -0,0 +1,241 @@ +/* + * ntp_net.h - definitions for NTP network stuff + */ + +#ifndef NTP_NET_H +#define NTP_NET_H + +#include <sys/types.h> +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif +#ifdef HAVE_NET_IF_H +#include <net/if.h> +#endif +#ifdef HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif +#ifdef HAVE_NET_IF_VAR_H +#include <net/if_var.h> +#endif +#ifdef HAVE_NETINET_IN_VAR_H +#include <netinet/in_var.h> +#endif + +#include "ntp_rfc2553.h" + +typedef union { + struct sockaddr sa; + struct sockaddr_in sa4; + struct sockaddr_in6 sa6; +} sockaddr_u; + +/* + * Utilities for manipulating sockaddr_u v4/v6 unions + */ +#define SOCK_ADDR4(psau) ((psau)->sa4.sin_addr) +#define SOCK_ADDR6(psau) ((psau)->sa6.sin6_addr) + +#define PSOCK_ADDR4(psau) (&SOCK_ADDR4(psau)) +#define PSOCK_ADDR6(psau) (&SOCK_ADDR6(psau)) + +#define AF(psau) ((psau)->sa.sa_family) + +#define IS_IPV4(psau) (AF_INET == AF(psau)) +#define IS_IPV6(psau) (AF_INET6 == AF(psau)) + +/* sockaddr_u v4 address in network byte order */ +#define NSRCADR(psau) (SOCK_ADDR4(psau).s_addr) + +/* sockaddr_u v4 address in host byte order */ +#define SRCADR(psau) (ntohl(NSRCADR(psau))) + +/* sockaddr_u v6 address in network byte order */ +#define NSRCADR6(psau) (SOCK_ADDR6(psau).s6_addr) + +/* assign sockaddr_u v4 address from host byte order */ +#define SET_ADDR4(psau, addr4) (NSRCADR(psau) = htonl(addr4)) + +/* assign sockaddr_u v4 address from network byte order */ +#define SET_ADDR4N(psau, addr4n) (NSRCADR(psau) = (addr4n)); + +/* assign sockaddr_u v6 address from network byte order */ +#define SET_ADDR6N(psau, s6_addr) \ + (SOCK_ADDR6(psau) = (s6_addr)) + +/* sockaddr_u v4/v6 port in network byte order */ +#define NSRCPORT(psau) ((psau)->sa4.sin_port) + +/* sockaddr_u v4/v6 port in host byte order */ +#define SRCPORT(psau) (ntohs(NSRCPORT(psau))) + +/* assign sockaddr_u v4/v6 port from host byte order */ +#define SET_PORT(psau, port) (NSRCPORT(psau) = htons(port)) + +/* sockaddr_u v6 scope */ +#define SCOPE_VAR(psau) ((psau)->sa6.sin6_scope_id) + +#ifdef ISC_PLATFORM_HAVESCOPEID +/* v4/v6 scope (always zero for v4) */ +# define SCOPE(psau) (IS_IPV4(psau) \ + ? 0 \ + : SCOPE_VAR(psau)) + +/* are two v6 sockaddr_u scopes equal? */ +# define SCOPE_EQ(psau1, psau2) \ + (SCOPE_VAR(psau1) == SCOPE_VAR(psau2)) + +/* assign scope if supported */ +# define SET_SCOPE(psau, s) \ + do \ + if (IS_IPV6(psau)) \ + SCOPE_VAR(psau) = (s); \ + while (0) +#else /* ISC_PLATFORM_HAVESCOPEID not defined */ +# define SCOPE(psau) (0) +# define SCOPE_EQ(psau1, psau2) (1) +# define SET_SCOPE(psau, s) do { } while (0) +#endif /* ISC_PLATFORM_HAVESCOPEID */ + +/* v4/v6 is multicast address */ +#define IS_MCAST(psau) \ + (IS_IPV4(psau) \ + ? IN_CLASSD(SRCADR(psau)) \ + : IN6_IS_ADDR_MULTICAST(PSOCK_ADDR6(psau))) + +/* v6 is interface ID scope universal, as with MAC-derived addresses */ +#define IS_IID_UNIV(psau) \ + (!!(0x02 & NSRCADR6(psau)[8])) + +#define SIZEOF_INADDR(fam) \ + ((AF_INET == (fam)) \ + ? sizeof(struct in_addr) \ + : sizeof(struct in6_addr)) + +#define SIZEOF_SOCKADDR(fam) \ + ((AF_INET == (fam)) \ + ? sizeof(struct sockaddr_in) \ + : sizeof(struct sockaddr_in6)) + +#define SOCKLEN(psau) \ + (IS_IPV4(psau) \ + ? sizeof((psau)->sa4) \ + : sizeof((psau)->sa6)) + +#define ZERO_SOCK(psau) \ + memset((psau), 0, sizeof(*(psau))) + +/* blast a byte value across sockaddr_u v6 address */ +#define MEMSET_ADDR6(psau, v) \ + memset((psau)->sa6.sin6_addr.s6_addr, (v), \ + sizeof((psau)->sa6.sin6_addr.s6_addr)) + +#define SET_ONESMASK(psau) \ + do { \ + if (IS_IPV6(psau)) \ + MEMSET_ADDR6((psau), 0xff); \ + else \ + NSRCADR(psau) = 0xffffffff; \ + } while(0) + +/* zero sockaddr_u, fill in family and all-ones (host) mask */ +#define SET_HOSTMASK(psau, family) \ + do { \ + ZERO_SOCK(psau); \ + AF(psau) = (family); \ + SET_ONESMASK(psau); \ + } while (0) + +/* + * compare two in6_addr returning negative, 0, or positive. + * ADDR6_CMP is negative if *pin6A is lower than *pin6B, zero if they + * are equal, positive if *pin6A is higher than *pin6B. IN6ADDR_ANY + * is the lowest address (128 zero bits). + */ +#define ADDR6_CMP(pin6A, pin6B) \ + memcmp((pin6A)->s6_addr, (pin6B)->s6_addr, \ + sizeof(pin6A)->s6_addr) + +/* compare two in6_addr for equality only */ +#if !defined(SYS_WINNT) || !defined(in_addr6) +#define ADDR6_EQ(pin6A, pin6B) \ + (!ADDR6_CMP(pin6A, pin6B)) +#else +#define ADDR6_EQ(pin6A, pin6B) \ + IN6_ADDR_EQUAL(pin6A, pin6B) +#endif + +/* compare a in6_addr with socket address */ +#define S_ADDR6_EQ(psau, pin6) \ + ADDR6_EQ(&(psau)->sa6.sin6_addr, pin6) + +/* are two sockaddr_u's addresses equal? (port excluded) */ +#define SOCK_EQ(psau1, psau2) \ + ((AF(psau1) != AF(psau2)) \ + ? 0 \ + : IS_IPV4(psau1) \ + ? (NSRCADR(psau1) == NSRCADR(psau2)) \ + : (S_ADDR6_EQ((psau1), PSOCK_ADDR6(psau2)) \ + && SCOPE_EQ((psau1), (psau2)))) + +/* are two sockaddr_u's addresses and ports equal? */ +#define ADDR_PORT_EQ(psau1, psau2) \ + ((NSRCPORT(psau1) != NSRCPORT(psau2) \ + ? 0 \ + : SOCK_EQ((psau1), (psau2)))) + +/* is sockaddr_u address unspecified? */ +#define SOCK_UNSPEC(psau) \ + (IS_IPV4(psau) \ + ? !NSRCADR(psau) \ + : IN6_IS_ADDR_UNSPECIFIED(PSOCK_ADDR6(psau))) + +/* just how unspecified do you mean? (scope 0/unspec too) */ +#define SOCK_UNSPEC_S(psau) \ + (SOCK_UNSPEC(psau) && !SCOPE(psau)) + +/* choose a default net interface (struct interface) for v4 or v6 */ +#define ANY_INTERFACE_BYFAM(family) \ + ((AF_INET == family) \ + ? any_interface \ + : any6_interface) + +/* choose a default interface for addresses' protocol (addr family) */ +#define ANY_INTERFACE_CHOOSE(psau) \ + ANY_INTERFACE_BYFAM(AF(psau)) + + +/* + * We tell reference clocks from real peers by giving the reference + * clocks an address of the form 127.127.t.u, where t is the type and + * u is the unit number. We define some of this here since we will need + * some sanity checks to make sure this address isn't interpretted as + * that of a normal peer. + */ +#define REFCLOCK_ADDR 0x7f7f0000 /* 127.127.0.0 */ +#define REFCLOCK_MASK 0xffff0000 /* 255.255.0.0 */ + +#ifdef REFCLOCK +#define ISREFCLOCKADR(srcadr) \ + (IS_IPV4(srcadr) && \ + (SRCADR(srcadr) & REFCLOCK_MASK) == REFCLOCK_ADDR) +#else +#define ISREFCLOCKADR(srcadr) (0) +#endif + +/* + * Macro for checking for invalid addresses. This is really, really + * gross, but is needed so no one configures a host on net 127 now that + * we're encouraging it the the configuration file. + */ +#define LOOPBACKADR 0x7f000001 +#define LOOPNETMASK 0xff000000 + +#define ISBADADR(srcadr) \ + (IS_IPV4(srcadr) \ + && ((SRCADR(srcadr) & LOOPNETMASK) \ + == (LOOPBACKADR & LOOPNETMASK)) \ + && SRCADR(srcadr) != LOOPBACKADR) + + +#endif /* NTP_NET_H */ diff --git a/include/ntp_random.h b/include/ntp_random.h index 766dcc376096..3f898312d77e 100644 --- a/include/ntp_random.h +++ b/include/ntp_random.h @@ -1,14 +1,14 @@ #include <ntp_types.h> -long ntp_random P((void)); -void ntp_srandom P((unsigned long)); -void ntp_srandomdev P((void)); -char * ntp_initstate P((unsigned long, /* seed for R.N.G. */ +long ntp_random (void); +void ntp_srandom (unsigned long); +void ntp_srandomdev (void); +char * ntp_initstate (unsigned long, /* seed for R.N.G. */ char *, /* pointer to state array */ long /* # bytes of state info */ - )); -char * ntp_setstate P((char *)); /* pointer to state array */ + ); +char * ntp_setstate (char *); /* pointer to state array */ diff --git a/include/ntp_refclock.h b/include/ntp_refclock.h index d63f3af38ead..9d803e4cc4d5 100644 --- a/include/ntp_refclock.h +++ b/include/ntp_refclock.h @@ -110,7 +110,7 @@ struct refclockstat { double fudgetime1; /* configure fudge time1 */ double fudgetime2; /* configure fudge time2 */ int32 fudgeval1; /* configure fudge value1 */ - int32 fudgeval2; /* configure fudge value2 */ + u_int32 fudgeval2; /* configure fudge value2 */ u_char currentstatus; /* clock status */ u_char lastevent; /* last exception event */ u_char leap; /* leap bits */ @@ -123,14 +123,14 @@ struct refclockstat { */ struct refclockio { struct refclockio *next; /* link to next structure */ - void (*clock_recv) P((struct recvbuf *)); /* completion routine */ - int (*io_input) P((struct recvbuf *)); /* input routine - + void (*clock_recv) (struct recvbuf *); /* completion routine */ + int (*io_input) (struct recvbuf *); /* input routine - to avoid excessive buffer use due to small bursts of refclock input data */ caddr_t srcclock; /* pointer to clock structure */ int datalen; /* lenth of data */ - SOCKET fd; /* file descriptor */ + int fd; /* file descriptor */ u_long recvcount; /* count of receive completions */ }; @@ -177,7 +177,7 @@ struct refclockbug { struct refclockproc { struct refclockio io; /* I/O handler structure */ - caddr_t unitptr; /* pointer to unit structure */ + void * unitptr; /* pointer to unit structure */ u_char leap; /* leap/synchronization code */ u_char currentstatus; /* clock status */ u_char lastevent; /* last exception event */ @@ -185,7 +185,7 @@ struct refclockproc { const char *clockdesc; /* clock description */ char a_lastcode[BMAX]; /* last timecode received */ - u_short lencode; /* length of last timecode */ + int lencode; /* length of last timecode */ int year; /* year of eternity */ int day; /* day of year */ @@ -231,14 +231,14 @@ struct refclockproc { #define NOFLAGS 0 /* flag for null flags */ struct refclock { - int (*clock_start) P((int, struct peer *)); - void (*clock_shutdown) P((int, struct peer *)); - void (*clock_poll) P((int, struct peer *)); - void (*clock_control) P((int, struct refclockstat *, - struct refclockstat *, struct peer *)); - void (*clock_init) P((void)); - void (*clock_buginfo) P((int, struct refclockbug *, struct peer *)); - void (*clock_timer) P((int, struct peer *)); + int (*clock_start) (int, struct peer *); + void (*clock_shutdown) (int, struct peer *); + void (*clock_poll) (int, struct peer *); + void (*clock_control) (int, struct refclockstat *, + struct refclockstat *, struct peer *); + void (*clock_init) (void); + void (*clock_buginfo) (int, struct refclockbug *, struct peer *); + void (*clock_timer) (int, struct peer *); }; /* @@ -247,27 +247,28 @@ struct refclock { /* * auxiliary PPS interface (implemented by refclock_atom()) */ -extern int pps_sample P((l_fp *)); -extern int io_addclock_simple P((struct refclockio *)); -extern int io_addclock P((struct refclockio *)); -extern void io_closeclock P((struct refclockio *)); +extern int pps_sample (l_fp *); +extern int io_addclock_simple (struct refclockio *); +extern int io_addclock (struct refclockio *); +extern void io_closeclock (struct refclockio *); #ifdef REFCLOCK -extern void refclock_buginfo P((struct sockaddr_storage *, - struct refclockbug *)); -extern void refclock_control P((struct sockaddr_storage *, +extern void refclock_buginfo (sockaddr_u *, + struct refclockbug *); +extern void refclock_control (sockaddr_u *, struct refclockstat *, - struct refclockstat *)); -extern int refclock_open P((char *, u_int, u_int)); -extern int refclock_setup P((int, u_int, u_int)); -extern void refclock_timer P((struct peer *)); -extern void refclock_transmit P((struct peer *)); -extern int refclock_ioctl P((int, u_int)); -extern int refclock_process P((struct refclockproc *)); -extern void refclock_process_offset P((struct refclockproc *, l_fp, l_fp, double)); -extern void refclock_report P((struct peer *, int)); -extern int refclock_gtlin P((struct recvbuf *, char *, int, l_fp *)); -extern int refclock_gtraw P((struct recvbuf *, char *, int, l_fp *)); + struct refclockstat *); +extern int refclock_open (char *, u_int, u_int); +extern int refclock_setup (int, u_int, u_int); +extern void refclock_timer (struct peer *); +extern void refclock_transmit (struct peer *); +extern int refclock_ioctl (int, u_int); +extern int refclock_process (struct refclockproc *); +extern int refclock_process_f (struct refclockproc *, double); +extern void refclock_process_offset (struct refclockproc *, l_fp, l_fp, double); +extern void refclock_report (struct peer *, int); +extern int refclock_gtlin (struct recvbuf *, char *, int, l_fp *); +extern int refclock_gtraw (struct recvbuf *, char *, int, l_fp *); #endif /* REFCLOCK */ #endif /* NTP_REFCLOCK_H */ diff --git a/include/ntp_request.h b/include/ntp_request.h index eb13fadb8fec..7f68894479dd 100644 --- a/include/ntp_request.h +++ b/include/ntp_request.h @@ -2,10 +2,12 @@ * ntp_request.h - definitions for the ntpd remote query facility */ -#ifndef _NTP_REQUEST_H -#define _NTP_REQUEST_H +#ifndef NTP_REQUEST_H +#define NTP_REQUEST_H +#include "stddef.h" #include "ntp_types.h" +#include "recvbuff.h" /* * A mode 7 packet is used exchanging data between an NTP server @@ -133,8 +135,8 @@ struct req_pkt { 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 */ + keyid_t keyid; /* (optional) encryption key */ + char mac[MAX_MAC_LEN-sizeof(keyid_t)]; /* (optional) auth code */ }; /* @@ -143,23 +145,24 @@ struct req_pkt { */ struct req_pkt_tail { 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 */ + keyid_t keyid; /* (optional) encryption key */ + char mac[MAX_MAC_LEN-sizeof(keyid_t)]; /* (optional) auth code */ }; -/* - * Input packet lengths. One with the mac, one without. - */ -#define REQ_LEN_HDR 8 /* 4 * u_char + 2 * u_short */ -#define REQ_LEN_MAC (sizeof(struct req_pkt)) -#define REQ_LEN_NOMAC (sizeof(struct req_pkt) - MAX_MAC_LEN) +/* MODE_PRIVATE request packet header length before optional items. */ +#define REQ_LEN_HDR (offsetof(struct req_pkt, data)) +/* MODE_PRIVATE request packet fixed length without MAC. */ +#define REQ_LEN_NOMAC (offsetof(struct req_pkt, keyid)) +/* MODE_PRIVATE req_pkt_tail minimum size (16 octet digest) */ +#define REQ_TAIL_MIN \ + (sizeof(struct req_pkt_tail) - (MAX_MAC_LEN - MAX_MD5_LEN)) /* - * A response packet. The length here is variable, this is a - * maximally sized one. Note that this implementation doesn't + * A MODE_PRIVATE response packet. The length here is variable, this + * is a maximally sized one. Note that this implementation doesn't * authenticate responses. */ -#define RESP_HEADER_SIZE (8) +#define RESP_HEADER_SIZE (offsetof(struct resp_pkt, data)) #define RESP_DATA_SIZE (500) struct resp_pkt { @@ -381,7 +384,7 @@ struct info_peer { u_int32 pkeyid; /* unused */ u_int32 refid; /* peer.refid */ u_int32 timer; /* peer.timer */ - s_fp rootdelay; /* peer.distance */ + s_fp rootdelay; /* peer.delay */ u_fp rootdispersion; /* peer.dispersion */ l_fp reftime; /* peer.reftime */ l_fp org; /* peer.org */ @@ -465,7 +468,7 @@ struct info_sys { u_char leap; /* system leap bits */ u_char stratum; /* our stratum */ s_char precision; /* local clock precision */ - s_fp rootdelay; /* distance from sync source */ + s_fp rootdelay; /* delay from sync source */ u_fp rootdispersion; /* dispersion from sync source */ u_int32 refid; /* reference ID of sync source */ l_fp reftime; /* system reference time */ @@ -667,7 +670,7 @@ struct conf_restrict { struct info_monitor_1 { u_int32 lasttime; /* last packet from this host */ 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 restr; /* restrict bits (was named lastdrop) */ u_int32 count; /* count of packets received */ u_int32 addr; /* host address V4 style */ u_int32 daddr; /* destination host address */ @@ -688,7 +691,7 @@ struct info_monitor_1 { struct info_monitor { u_int32 lasttime; /* last packet from this host */ 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 restr; /* restrict bits (was named lastdrop) */ u_int32 count; /* count of packets received */ u_int32 addr; /* host address */ u_short port; /* port number of last reception */ @@ -700,7 +703,7 @@ struct info_monitor { }; /* - * Structure used for returning monitor data (old format + * Structure used for returning monitor data (old format) */ struct old_info_monitor { u_int32 lasttime; /* last packet from this host */ @@ -820,7 +823,7 @@ struct info_clock { l_fp fudgetime1; l_fp fudgetime2; int32 fudgeval1; - int32 fudgeval2; + u_int32 fudgeval2; }; @@ -831,7 +834,7 @@ struct conf_fudge { u_int32 clockadr; u_int32 which; l_fp fudgetime; - int32 fudgeval_flags; + u_int32 fudgeval_flags; }; #define FUDGE_TIME1 1 @@ -923,4 +926,10 @@ struct info_dns_assoc { associd_t associd; /* association ID */ char hostname[NTP_MAXHOSTNAME]; /* hostname */ }; + +/* + * function declarations + */ +int get_packet_mode(struct recvbuf *rbufp); /* Return packet mode */ + #endif /* NTP_REQUEST_H */ diff --git a/include/ntp_rfc2553.h b/include/ntp_rfc2553.h index 662b118942f6..8e824f4a240b 100644 --- a/include/ntp_rfc2553.h +++ b/include/ntp_rfc2553.h @@ -65,47 +65,46 @@ /* * Compatability shims with the rfc2553 API to simplify ntp. */ -#ifndef _NTP_RFC2553_H_ -#define _NTP_RFC2553_H_ +#ifndef NTP_RFC2553_H +#define NTP_RFC2553_H /* * Ensure that we include the configuration file before we check * for IPV6 */ #include <config.h> - #include <netdb.h> +#include <isc/net.h> #include "ntp_types.h" -/* - * Don't include any additional IPv6 definitions - * We are defining our own here. - */ -#define ISC_IPV6_H 1 - /* +/* * If various macros are not defined we need to define them */ #ifndef AF_INET6 -#define AF_INET6 AF_MAX -#define PF_INET6 AF_INET6 +# define AF_INET6 AF_MAX +# define PF_INET6 AF_INET6 #endif #if !defined(_SS_MAXSIZE) && !defined(_SS_ALIGNSIZE) -#define _SS_MAXSIZE 128 -#define _SS_ALIGNSIZE (sizeof(ntp_uint64_t)) -#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR -#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) - sizeof(ntp_u_int8_t)) -#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) - sizeof(ntp_u_int8_t) - \ +# define _SS_MAXSIZE 128 +# define _SS_ALIGNSIZE (sizeof(ntp_uint64_t)) +# ifdef ISC_PLATFORM_HAVESALEN +# define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) - sizeof(ntp_u_int8_t)) +# define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) - sizeof(ntp_u_int8_t) - \ _SS_PAD1SIZE - _SS_ALIGNSIZE) -#else -#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(short)) -#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(short) - \ +# 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 */ +# endif /* ISC_PLATFORM_HAVESALEN */ +#endif + +#ifndef INET6_ADDRSTRLEN +# define INET6_ADDRSTRLEN 46 /* max len of IPv6 addr in ascii */ #endif /* @@ -115,7 +114,7 @@ #ifndef HAVE_STRUCT_SOCKADDR_STORAGE struct sockaddr_storage { -#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR +#ifdef ISC_PLATFORM_HAVESALEN ntp_u_int8_t ss_len; /* address length */ ntp_u_int8_t ss_family; /* address family */ #else @@ -135,7 +134,7 @@ struct sockaddr_storage { /* * Flag values for getaddrinfo() */ -#ifndef AI_NUMERICHOST +#ifndef AI_PASSIVE #define AI_PASSIVE 0x00000001 /* get address to use bind() */ #define AI_CANONNAME 0x00000002 /* fill ai_canonname */ #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ @@ -144,90 +143,24 @@ struct sockaddr_storage { (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_ADDRCONFIG) #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ -#endif +#endif /* !AI_PASSIVE */ -#ifndef ISC_PLATFORM_HAVEIPV6 -/* - * Definition of some useful macros to handle IP6 addresses - */ -#ifdef ISC_PLATFORM_NEEDIN6ADDRANY -#ifdef SYS_WINNT -#define IN6ADDR_ANY_INIT {{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }} +#ifndef AI_NUMERICHOST /* such as AIX 4.3 */ +# define Z_AI_NUMERICHOST 0 #else -#define IN6ADDR_ANY_INIT \ - {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} -#endif +# define Z_AI_NUMERICHOST AI_NUMERICHOST #endif - -/* - * IPv6 address - */ -#ifdef SYS_WINNT -#define in6_addr in_addr6 +#ifndef AI_NUMERICSERV /* not in RFC 2553 */ +# define Z_AI_NUMERICSERV 0 #else - -struct in6_addr { - union { - ntp_u_int8_t __u6_addr8[16]; - ntp_u_int16_t __u6_addr16[8]; - ntp_u_int32_t __u6_addr32[4]; - } __u6_addr; /* 128-bit IP6 address */ -}; - -#define s6_addr __u6_addr.__u6_addr8 +# define Z_AI_NUMERICSERV AI_NUMERICSERV #endif -#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY) -extern const struct in6_addr in6addr_any; -#endif - -#define SIN6_LEN -#ifndef HAVE_SOCKADDR_IN6 -struct sockaddr_in6 { -#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR - ntp_u_int8_t sin6_len; /* length of this struct(sa_family_t)*/ - ntp_u_int8_t sin6_family; /* AF_INET6 (sa_family_t) */ -#else - short sin6_family; /* AF_INET6 (sa_family_t) */ -#endif - ntp_u_int16_t sin6_port; /* Transport layer port # (in_port_t)*/ - ntp_u_int32_t sin6_flowinfo; /* IP6 flow information */ - struct in6_addr sin6_addr; /* IP6 address */ - ntp_u_int32_t sin6_scope_id; /* scope zone index */ -}; -#endif - -/* - * Unspecified - */ -#ifndef IN6_IS_ADDR_UNSPECIFIED -#define IN6_IS_ADDR_UNSPECIFIED(a) \ - ((*(const ntp_u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ - (*(const ntp_u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ - (*(const ntp_u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ - (*(const ntp_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 -/* - * Unicast link / site local. - */ -#ifndef IN6_IS_ADDR_LINKLOCAL -#define IN6_IS_ADDR_LINKLOCAL(a) (\ -(*((u_long *)((a)->s6_addr) ) == 0xfe) && \ -((*((u_long *)((a)->s6_addr) + 1) & 0xc0) == 0x80)) -#endif +#ifndef ISC_PLATFORM_HAVEIPV6 -#ifndef IN6_IS_ADDR_SITELOCAL -#define IN6_IS_ADDR_SITELOCAL(a) (\ -(*((u_long *)((a)->s6_addr) ) == 0xfe) && \ -((*((u_long *)((a)->s6_addr) + 1) & 0xc0) == 0xc0)) +#ifdef SYS_WINNT +# define in6_addr in_addr6 #endif struct addrinfo { @@ -260,12 +193,12 @@ struct addrinfo { #define EAI_MAX 14 -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)); +int getaddrinfo (const char *, const char *, + const struct addrinfo *, struct addrinfo **); +int getnameinfo (const struct sockaddr *, u_int, char *, + size_t, char *, size_t, int); +void freeaddrinfo (struct addrinfo *); +char *gai_strerror (int); /* * Constants for getnameinfo() @@ -287,6 +220,17 @@ char *gai_strerror P((int)); #define NI_WITHSCOPEID 0x00000020 #endif -#endif /* ISC_PLATFORM_HAVEIPV6 */ +#endif /* !ISC_PLATFORM_HAVEIPV6 */ + +/* + * Set up some macros to look for IPv6 and IPv6 multicast + */ + +#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6) +# define INCLUDE_IPV6_SUPPORT +# if defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP) +# define INCLUDE_IPV6_MULTICAST_SUPPORT +# endif /* IPV6 Multicast Support */ +#endif /* IPv6 Support */ -#endif /* !_NTP_RFC2553_H_ */ +#endif /* !NTP_RFC2553_H */ diff --git a/include/ntp_select.h b/include/ntp_select.h index 79c0fc0a56bf..dc60f70b3ae0 100644 --- a/include/ntp_select.h +++ b/include/ntp_select.h @@ -1,8 +1,8 @@ /* * Not all machines define FD_SET in sys/types.h */ -#ifndef _ntp_select_h -#define _ntp_select_h +#ifndef NTP_SELECT_H +#define NTP_SELECT_H /* Was: (defined(RS6000)||defined(SYS_PTX))&&!defined(_BSD) */ /* Could say: !defined(FD_SET) && defined(HAVE_SYS_SELECT_H) */ @@ -11,13 +11,13 @@ #include <sys/select.h> #else #include <sockLib.h> -extern int select P((int width, fd_set *pReadFds, fd_set *pWriteFds, - fd_set *pExceptFds, struct timeval *pTimeOut)); +extern int select (int width, fd_set *pReadFds, fd_set *pWriteFds, + fd_set *pExceptFds, struct timeval *pTimeOut); #endif #endif -#if !defined(FD_SET) && !defined(SYS_WINNT) +#if !defined(FD_SET) #define NFDBITS 32 #define FD_SETSIZE 32 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) @@ -32,4 +32,9 @@ typedef struct { } fd_set; #endif -#endif /* _ntp_select_h */ +#ifdef SYS_WINNT +/* ports/winnt/libntp/setpriority.c */ +extern void InitSockets(void); +#endif + +#endif /* NTP_SELECT_H */ diff --git a/include/ntp_stdlib.h b/include/ntp_stdlib.h index c389d1ecc98b..8fc237ae0351 100644 --- a/include/ntp_stdlib.h +++ b/include/ntp_stdlib.h @@ -1,13 +1,22 @@ /* * ntp_stdlib.h - Prototypes for NTP lib. */ +#ifndef NTP_STDLIB_H +#define NTP_STDLIB_H + #include <sys/types.h> +#ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> -#include "ntp_rfc2553.h" +#endif +#include "l_stdlib.h" +#include "ntp_rfc2553.h" #include "ntp_types.h" +#include "ntp_malloc.h" #include "ntp_string.h" -#include "l_stdlib.h" +#include "ntp_net.h" +#include "ntp_syslog.h" + /* * Handle gcc __attribute__ if available. @@ -25,84 +34,117 @@ # endif #endif -#if defined(__STDC__) || defined(HAVE_STDARG_H) -# include <stdarg.h> -extern void msyslog P((int, const char *, ...)) - __attribute__((__format__(__printf__, 2, 3))); -extern void netsyslog P((int, const char *, ...)) +extern int mprintf(const char *, ...) + __attribute__((__format__(__printf__, 1, 2))); +extern int mfprintf(FILE *, const char *, ...) + __attribute__((__format__(__printf__, 2, 3))); +extern int mvfprintf(FILE *, const char *, va_list) + __attribute__((__format__(__printf__, 2, 0))); +extern int mvsnprintf(char *, size_t, const char *, va_list) + __attribute__((__format__(__printf__, 3, 0))); +extern int msnprintf(char *, size_t, const char *, ...) + __attribute__((__format__(__printf__, 3, 4))); +extern void msyslog(int, const char *, ...) __attribute__((__format__(__printf__, 2, 3))); -#else -# include <varargs.h> -extern void msyslog P(()); -extern void netsyslog P(()); + +/* + * When building without OpenSSL, use a few macros of theirs to + * minimize source differences in NTP. + */ +#ifndef OPENSSL +#define NID_md5 4 /* from openssl/objects.h */ +/* from openssl/evp.h */ +#define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */ #endif -extern void auth_delkeys P((void)); -extern int auth_havekey P((keyid_t)); -extern int authdecrypt P((keyid_t, u_int32 *, int, int)); -extern int authencrypt P((keyid_t, u_int32 *, int)); -extern int authhavekey P((keyid_t)); -extern int authistrusted P((keyid_t)); -extern int authreadkeys P((const char *)); -extern void authtrust P((keyid_t, u_long)); -extern int authusekey P((keyid_t, int, const u_char *)); - -extern u_long calyearstart P((u_long)); -extern const char *clockname P((int)); -extern int clocktime P((int, int, int, int, int, u_long, u_long *, u_int32 *)); -#if defined SYS_WINNT && defined DEBUG -# define emalloc(_c) debug_emalloc(_c, __FILE__, __LINE__) -extern void * debug_emalloc P((u_int, char *, int)); +/* authkeys.c */ +extern void auth_delkeys (void); +extern int auth_havekey (keyid_t); +extern int authdecrypt (keyid_t, u_int32 *, int, int); +extern int authencrypt (keyid_t, u_int32 *, int); +extern int authhavekey (keyid_t); +extern int authistrusted (keyid_t); +extern int authreadkeys (const char *); +extern void authtrust (keyid_t, u_long); +extern int authusekey (keyid_t, int, const u_char *); + +extern u_long calyearstart (u_long); +extern const char *clockname (int); +extern int clocktime (int, int, int, int, int, u_long, u_long *, u_int32 *); +extern int ntp_getopt (int, char **, const char *); +extern void init_auth (void); +extern void init_lib (void); +extern struct savekey *auth_findkey (keyid_t); +extern int auth_moremem (void); +extern int ymd2yd (int, int, int); + +/* a_md5encrypt.c */ +extern int MD5authdecrypt (int, u_char *, u_int32 *, int, int); +extern int MD5authencrypt (int, u_char *, u_int32 *, int); +extern void MD5auth_setkey (keyid_t, int, const u_char *, const int); +extern u_int32 addr2refid (sockaddr_u *); + +/* emalloc.c */ +#ifndef EREALLOC_CALLSITE /* ntp_malloc.h defines */ +extern void * ereallocz (void *, size_t, size_t, int); +#define erealloczsite(p, n, o, z, f, l) ereallocz(p, n, o, (z)) +extern void * emalloc (size_t); +#define emalloc_zero(c) ereallocz(NULL, (c), 0, TRUE) +#define erealloc(p, c) ereallocz(p, (c), 0, FALSE) +#define erealloc_zero(p, n, o) ereallocz(p, n, (o), TRUE) +extern char * estrdup_impl (const char *); +#define estrdup(s) estrdup_impl(s) #else -extern void * emalloc P((u_int)); +extern void * ereallocz (void *, size_t, size_t, int, + const char *, int); +#define erealloczsite ereallocz +#define emalloc(c) ereallocz(NULL, (c), 0, FALSE, \ + __FILE__, __LINE__) +#define emalloc_zero(c) ereallocz(NULL, (c), 0, TRUE, \ + __FILE__, __LINE__) +#define erealloc(p, c) ereallocz(p, (c), 0, FALSE, \ + __FILE__, __LINE__) +#define erealloc_zero(p, n, o) ereallocz(p, n, (o), TRUE, \ + __FILE__, __LINE__) +extern char * estrdup_impl (const char *, const char *, int); +#define estrdup(s) estrdup_impl((s), __FILE__, __LINE__) #endif -extern int ntp_getopt P((int, char **, const char *)); -extern void init_auth P((void)); -extern void init_lib P((void)); -extern struct savekey *auth_findkey P((keyid_t)); -extern int auth_moremem P((void)); -extern int ymd2yd P((int, int, int)); - -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 *)); -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, 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)); -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 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((struct sockaddr_storage *)); -extern int tsftomsu P((u_long, int)); -extern char * uinttoa P((u_long)); - -extern int decodenetnum P((const char *, struct sockaddr_storage *)); - -extern const char * FindConfig P((const char *)); - -extern void signal_no_reset P((int, RETSIGTYPE (*func)(int))); - -extern void getauthkeys P((const char *)); -extern void auth_agekeys P((void)); -extern void rereadkeys P((void)); + + +extern int atoint (const char *, long *); +extern int atouint (const char *, u_long *); +extern int hextoint (const char *, u_long *); +extern char * humanlogtime (void); +extern char * inttoa (long); +extern char * mfptoa (u_long, u_long, short); +extern char * mfptoms (u_long, u_long, short); +extern const char * modetoa (int); +extern const char * eventstr (int); +extern const char * ceventstr (int); +extern char * statustoa (int, int); +extern const char * sysstatstr (int); +extern const char * peerstatstr (int); +extern const char * clockstatstr (int); +extern sockaddr_u * netof (sockaddr_u *); +extern char * numtoa (u_int32); +extern char * numtohost (u_int32); +extern char * socktoa (const sockaddr_u *); +extern char * socktohost (const sockaddr_u *); +extern int octtoint (const char *, u_long *); +extern u_long ranp2 (int); +extern char * refnumtoa (sockaddr_u *); +extern int tsftomsu (u_long, int); +extern char * uinttoa (u_long); + +extern int decodenetnum (const char *, sockaddr_u *); + +extern const char * FindConfig (const char *); + +extern void signal_no_reset (int, RETSIGTYPE (*func)(int)); + +extern void getauthkeys (const char *); +extern void auth_agekeys (void); +extern void rereadkeys (void); /* * Variable declarations for libntp. @@ -129,18 +171,51 @@ extern int authnumfreekeys; */ extern keyid_t cache_keyid; /* key identifier */ extern u_char * cache_key; /* key pointer */ +extern int cache_type; /* key type */ extern u_int cache_keylen; /* key length */ /* getopt.c */ extern char * ntp_optarg; /* global argument pointer */ extern int ntp_optind; /* global argv index */ -/* machines.c */ -extern const char *set_tod_using; +/* lib_strbuf.c */ +extern int ipv4_works; +extern int ipv6_works; -/* mexit.c */ -#if defined SYS_WINNT || defined SYS_CYGWIN32 -extern HANDLE hServDoneEvent; +/* machines.c */ +typedef void (*pset_tod_using)(const char *); +extern pset_tod_using set_tod_using; + +/* ssl_init.c */ +#ifdef OPENSSL +extern void ssl_init (void); +extern void ssl_check_version (void); +extern int ssl_init_done; +#define INIT_SSL() \ + do { \ + if (!ssl_init_done) \ + ssl_init(); \ + } while (0) +#else /* !OPENSSL follows */ +#define INIT_SSL() do {} while (0) +#endif +extern int keytype_from_text (const char *, size_t *); +extern const char *keytype_name (int); +extern char * getpass_keytype (int); + + +/* lib/isc/win32/strerror.c + * + * To minimize Windows-specific changes to the rest of the NTP code, + * particularly reference clocks, we hijack calls to strerror() to deal + * with our mixture of error codes from the C runtime (open, write) + * and Windows (sockets, serial ports). This is an ugly hack because + * both use the lowest values differently, but particularly for ntpd, + * it's not a problem. + */ +#ifdef NTP_REDEFINE_STRERROR +#define strerror(e) ntp_strerror(e) +extern char * ntp_strerror (int e); #endif /* systime.c */ @@ -148,3 +223,5 @@ extern double sys_tick; /* adjtime() resolution */ /* version.c */ extern const char *Version; /* version declaration */ + +#endif /* NTP_STDLIB_H */ diff --git a/include/ntp_string.h b/include/ntp_string.h index f7f0092ae493..aab7084b0536 100644 --- a/include/ntp_string.h +++ b/include/ntp_string.h @@ -36,13 +36,20 @@ char *strchr(), *strrchr(); #endif /* STDC_HEADERS */ #ifdef NTP_NEED_BOPS -# define memcmp(a,b,c) bcmp(a,b,(int)c) -# define memmove(t,f,c) bcopy(f,t,(int)c) -# define memcpy(t,f,c) bcopy(f,t,(int)c) -# define memset(a,x,c) if (x == 0x00) bzero(a,(int)c); else ntp_memset((char*)a,x,c) -void ntp_memset P((char *, int, int)); +#ifdef HAVE_STRINGS_H +# include <strings.h> /* bcmp, bcopy, bzero */ +#endif + +void ntp_memset (char *, int, int); +#define memcmp(a, b, c) bcmp(a, b, (int)(c)) +#define memmove(t, f, c) bcopy(f, t, (int)(c)) +#define memcpy(t, f, c) bcopy(f, t, (int)(c)) +#define memset(a, x, c) if (0 == (x)) \ + bzero(a, (int)(c)); \ + else \ + ntp_memset((char *)(a), x, c) #endif /* NTP_NEED_BOPS */ #endif /* _ntp_string_h */ diff --git a/include/ntp_syscall.h b/include/ntp_syscall.h index 521e753f6791..c255cee46b5f 100644 --- a/include/ntp_syscall.h +++ b/include/ntp_syscall.h @@ -20,10 +20,19 @@ # define ntp_gettime(t) syscall(SYS_ntp_gettime, (t)) #else /* !NTP_SYSCALLS_STD */ # ifdef HAVE___ADJTIMEX -extern int __adjtimex P((struct timex *)); +extern int __adjtimex (struct timex *); # define ntp_adjtime(t) __adjtimex((t)) +#ifndef HAVE_STRUCT_NTPTIMEVAL +struct ntptimeval +{ + struct timeval time; /* current time (ro) */ + long int maxerror; /* maximum error (us) (ro) */ + long int esterror; /* estimated error (us) (ro) */ +}; +#endif + static inline int ntp_gettime( struct ntptimeval *ntv diff --git a/include/ntp_syslog.h b/include/ntp_syslog.h index 38021e251682..12f78292b1ea 100644 --- a/include/ntp_syslog.h +++ b/include/ntp_syslog.h @@ -5,6 +5,8 @@ #ifndef NTP_SYSLOG_H #define NTP_SYSLOG_H +#include <ntp_types.h> /* u_int32 type */ + # ifdef VMS extern void msyslog(); # else @@ -15,7 +17,9 @@ extern void msyslog(); # include <stdio.h> extern int syslogit; -extern FILE *syslog_file; +extern int msyslog_term; /* duplicate to stdout/err */ +extern FILE *syslog_file; /* if syslogit is FALSE, log to + this file and not syslog */ #if defined(VMS) || defined (SYS_VXWORKS) #define LOG_EMERG 0 /* system is unusable */ @@ -37,34 +41,34 @@ extern FILE *syslog_file; #define NLOG_STATIST 0x00000008 #define NLOG_OSYS 0 /* offset for system flags */ -#define NLOG_SYSMASK 0x0000000F /* system log events */ +#define NLOG_SYSMASK 0x0000000F /* system log events */ #define NLOG_SYSINFO 0x00000001 /* system info log events */ #define NLOG_SYSEVENT 0x00000002 /* system events */ #define NLOG_SYSSTATUS 0x00000004 /* system status (sync/unsync) */ #define NLOG_SYSSTATIST 0x00000008 /* system statistics output */ #define NLOG_OPEER 4 /* offset for peer flags */ -#define NLOG_PEERMASK 0x000000F0 /* peer log events */ +#define NLOG_PEERMASK 0x000000F0 /* peer log events */ #define NLOG_PEERINFO 0x00000010 /* peer info log events */ #define NLOG_PEEREVENT 0x00000020 /* peer events */ #define NLOG_PEERSTATUS 0x00000040 /* peer status (sync/unsync) */ #define NLOG_PEERSTATIST 0x00000080 /* peer statistics output */ #define NLOG_OCLOCK 8 /* offset for clock flags */ -#define NLOG_CLOCKMASK 0x00000F00 /* clock log events */ +#define NLOG_CLOCKMASK 0x00000F00 /* clock log events */ #define NLOG_CLOCKINFO 0x00000100 /* clock info log events */ #define NLOG_CLOCKEVENT 0x00000200 /* clock events */ #define NLOG_CLOCKSTATUS 0x00000400 /* clock status (sync/unsync) */ #define NLOG_CLOCKSTATIST 0x00000800 /* clock statistics output */ #define NLOG_OSYNC 12 /* offset for sync flags */ -#define NLOG_SYNCMASK 0x0000F000 /* sync log events */ +#define NLOG_SYNCMASK 0x0000F000 /* sync log events */ #define NLOG_SYNCINFO 0x00001000 /* sync info log events */ #define NLOG_SYNCEVENT 0x00002000 /* sync events */ #define NLOG_SYNCSTATUS 0x00004000 /* sync status (sync/unsync) */ #define NLOG_SYNCSTATIST 0x00008000 /* sync statistics output */ -extern unsigned long ntp_syslogmask; +extern u_int32 ntp_syslogmask; #define NLOG(_X_) if (ntp_syslogmask & (_X_)) #endif /* NTP_SYSLOG_H */ diff --git a/include/ntp_types.h b/include/ntp_types.h index 0b575c8c6ae3..c975a08163cc 100644 --- a/include/ntp_types.h +++ b/include/ntp_types.h @@ -4,11 +4,18 @@ * as int and u_int. * For 32 bit systems, define them as long and u_long */ +#ifndef NTP_TYPES_H +#define NTP_TYPES_H + #include <sys/types.h> #include "ntp_machine.h" -#ifndef _NTP_TYPES_ -#define _NTP_TYPES_ +#ifndef TRUE +# define TRUE 1 +#endif +#ifndef FALSE +# define FALSE 0 +#endif /* * This is another naming conflict. @@ -23,15 +30,16 @@ #endif /* - * Set up for prototyping + * used to quiet compiler warnings + */ +#ifndef UNUSED_ARG +#define UNUSED_ARG(arg) ((void)(arg)) +#endif + +/* + * COUNTOF(array) - size of array in elements */ -#ifndef P -#if defined(__STDC__) || defined(HAVE_PROTOTYPES) -#define P(x) x -#else /* not __STDC__ and not HAVE_PROTOTYPES */ -#define P(x) () -#endif /* not __STDC__ and HAVE_PROTOTYPES */ -#endif /* P */ +#define COUNTOF(arr) (sizeof(arr) / sizeof((arr)[0])) /* * VMS DECC (v4.1), {u_char,u_short,u_long} are only in SOCKET.H, @@ -49,21 +57,39 @@ typedef unsigned int u_int; #if (SIZEOF_INT == 4) # ifndef int32 # define int32 int +# ifndef INT32_MIN +# define INT32_MIN INT_MIN +# endif +# ifndef INT32_MAX +# define INT32_MAX INT_MAX +# endif # endif # ifndef u_int32 # define u_int32 unsigned int +# ifndef U_INT32_MAX +# define U_INT32_MAX UINT_MAX +# endif # endif #else /* not sizeof(int) == 4 */ # if (SIZEOF_LONG == 4) -# else /* not sizeof(long) == 4 */ # ifndef int32 # define int32 long +# ifndef INT32_MIN +# define INT32_MIN LONG_MIN +# endif +# ifndef INT32_MAX +# define INT32_MAX LONG_MAX +# endif # endif # ifndef u_int32 # define u_int32 unsigned long +# ifndef U_INT32_MAX +# define U_INT32_MAX ULONG_MAX +# endif # endif +# else /* not sizeof(long) == 4 */ +# include "Bletch: what's 32 bits on this machine?" # endif /* not sizeof(long) == 4 */ -# include "Bletch: what's 32 bits on this machine?" #endif /* not sizeof(int) == 4 */ typedef u_char ntp_u_int8_t; @@ -76,5 +102,29 @@ typedef unsigned short associd_t; /* association ID */ typedef u_int32 keyid_t; /* cryptographic key ID */ typedef u_int32 tstamp_t; /* NTP seconds timestamp */ -#endif /* _NTP_TYPES_ */ +/* + * On Unix struct sock_timeval is equivalent to struct timeval. + * On Windows built with 64-bit time_t, sock_timeval.tv_sec is a long + * as required by Windows' socket() interface timeout argument, while + * timeval.tv_sec is time_t for the more common use as a UTC time + * within NTP. + */ +#ifndef SYS_WINNT +#define sock_timeval timeval +#endif + +/* + * On Unix open() works for tty (serial) devices just fine, while on + * Windows refclock serial devices are opened using CreateFile, a lower + * level than the CRT-provided descriptors, because the C runtime lacks + * tty APIs. For refclocks which wish to use open() as well as or + * instead of refclock_open(), tty_open() is equivalent to open() on + * Unix and implemented in the Windows port similarly to + * refclock_open(). + */ +#ifndef SYS_WINNT +#define tty_open(f, a, m) open(f, a, m) +#endif + +#endif /* NTP_TYPES_H */ diff --git a/include/ntp_unixtime.h b/include/ntp_unixtime.h index ce96980209e9..8c43f1cea037 100644 --- a/include/ntp_unixtime.h +++ b/include/ntp_unixtime.h @@ -136,6 +136,3 @@ extern u_long msutotsfhi[]; #define MSUTOTSF(msu, tsf) \ (tsf) = msutotsfhi[((msu) >> 5) & 0x1f] + msutotsflo[(msu) & 0x1f] - -extern char * tvtoa P((const struct timeval *)); -extern char * utvtoa P((const struct timeval *)); diff --git a/include/ntpd.h b/include/ntpd.h index d0957191becb..75e87de97a41 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -2,31 +2,31 @@ * ntpd.h - Prototypes for ntpd. */ -#include "ntp_syslog.h" -#include "ntp_fp.h" #include "ntp.h" #include "ntp_debug.h" +#include "ntp_syslog.h" #include "ntp_select.h" #include "ntp_malloc.h" #include "ntp_refclock.h" #include "recvbuff.h" - /* ntp_config.c */ -extern void getconfig P((int, char **)); -/* ntp_config.c */ -extern void ctl_clr_stats P((void)); -extern int ctlclrtrap P((struct sockaddr_storage *, struct interface *, int)); -extern u_short ctlpeerstatus P((struct peer *)); -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)); -extern void report_event P((int, struct peer *)); - -extern double fabs P((double)); -extern double sqrt P((double)); +#define TAI_1972 10 /* initial TAI offset (s) */ +extern char *keysdir; /* crypto keys and leaptable directory */ +extern char * saveconfigdir; /* ntpq saveconfig output directory */ + +extern void getconfig (int, char **); +extern void ctl_clr_stats (void); +extern int ctlclrtrap (sockaddr_u *, struct interface *, int); +extern u_short ctlpeerstatus (struct peer *); +extern int ctlsettrap (sockaddr_u *, struct interface *, int, int); +extern u_short ctlsysstatus (void); +extern void init_control (void); +extern void init_logging (char const *, int); +extern void setup_logfile (void); +extern void process_control (struct recvbuf *, int); +extern void report_event (int, struct peer *, const char *); /* ntp_control.c */ /* @@ -52,120 +52,114 @@ struct ctl_var { #define WO (CAN_WRITE) #define RW (CAN_READ|CAN_WRITE) -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 *, u_long, u_short)); -extern void set_sys_var P((const char *, u_long, u_short)); +extern char * add_var (struct ctl_var **, u_long, u_short); +extern void free_varlist (struct ctl_var *); +extern void set_var (struct ctl_var **, const char *, u_long, u_short); +extern void set_sys_var (const char *, u_long, u_short); /* ntp_intres.c */ -extern void ntp_res_name P((struct sockaddr_storage, u_short)); -extern void ntp_res_recv P((void)); -extern void ntp_intres P((void)); +extern void ntp_res_name (sockaddr_u, u_short); +extern void ntp_res_recv (void); +extern void ntp_intres (void); +#ifdef SYS_WINNT +extern unsigned WINAPI ntp_intres_thread (void *); +#endif /* ntp_io.c */ typedef struct interface_info { - struct interface *interface; - u_char action; + endpt * ep; + u_char action; } interface_info_t; -typedef void (*interface_receiver_t)(void *, interface_info_t *); - -extern volatile int disable_dynamic_updates; - -extern void interface_enumerate P((interface_receiver_t, void *)); -extern struct interface *findinterface P((struct sockaddr_storage *)); -extern struct interface *findbcastinter P((struct sockaddr_storage *)); -extern void enable_broadcast P((struct interface *, struct sockaddr_storage *)); -extern void enable_multicast_if P((struct interface *, struct sockaddr_storage *)); -extern void interface_dump P((struct interface *)); - -extern void interface_update P((interface_receiver_t, void *)); -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((struct sockaddr_storage)); -extern void io_multicast_del P((struct sockaddr_storage)); -extern void kill_asyncio P((int)); -extern void sendpkt P((struct sockaddr_storage *, struct interface *, int, struct pkt *, int)); +typedef void (*interface_receiver_t) (void *, interface_info_t *); + +extern int disable_dynamic_updates; + +extern void interface_enumerate (interface_receiver_t, void *); +extern endpt * findinterface (sockaddr_u *); +extern endpt * findbcastinter (sockaddr_u *); +extern void enable_broadcast (endpt *, sockaddr_u *); +extern void enable_multicast_if (endpt *, sockaddr_u *); +extern void interface_update (interface_receiver_t, void *); + +extern void init_io (void); +extern void io_open_sockets (void); +extern void input_handler (l_fp *); +extern void io_clr_stats (void); +extern void io_setbclient (void); +extern void io_unsetbclient (void); +extern void io_multicast_add(sockaddr_u *); +extern void io_multicast_del(sockaddr_u *); +extern void sendpkt (sockaddr_u *, struct interface *, int, struct pkt *, int); +#ifndef SYS_WINNT +extern void kill_asyncio (int); +#endif #ifdef DEBUG -extern void collect_timing P((struct recvbuf *, const char *, int, l_fp *)); +extern void collect_timing (struct recvbuf *, const char *, int, l_fp *); #endif #ifdef HAVE_SIGNALED_IO -extern void wait_for_signal P((void)); -extern void unblock_io_and_alarm P((void)); -extern void block_io_and_alarm P((void)); -#define UNBLOCK_IO_AND_ALARM() unblock_io_and_alarm() -#define BLOCK_IO_AND_ALARM() block_io_and_alarm() +extern void wait_for_signal (void); +extern void unblock_io_and_alarm (void); +extern void block_io_and_alarm (void); +#define UNBLOCK_IO_AND_ALARM() unblock_io_and_alarm() +#define BLOCK_IO_AND_ALARM() block_io_and_alarm() #else #define UNBLOCK_IO_AND_ALARM() #define BLOCK_IO_AND_ALARM() #endif - -/* ntp_leap.c */ -extern void init_leap P((void)); -extern void leap_process P((void)); -extern int leap_setleap P((int, int)); -/* - * there seems to be a bug in the IRIX 4 compiler which prevents - * u_char from beeing used in prototyped functions. - * This is also true AIX compiler. - * So give up and define it to be int. WLJ - */ -extern int leap_actual P((int)); +#define latoa(pif) localaddrtoa(pif) +extern const char * localaddrtoa(endpt *); /* ntp_loopfilter.c */ -extern void init_loopfilter P((void)); -extern int local_clock P((struct peer *, double)); -extern void adj_host_clock P((void)); -extern void loop_config P((int, double)); -extern void huffpuff P((void)); +extern void init_loopfilter(void); +extern int local_clock(struct peer *, double); +extern void adj_host_clock(void); +extern void loop_config(int, double); +extern void huffpuff(void); extern u_long sys_clocktime; -extern u_long sys_tai; +extern u_int sys_tai; /* ntp_monitor.c */ -extern void init_mon P((void)); -extern void mon_start P((int)); -extern void mon_stop P((int)); -extern int ntp_monitor P((struct recvbuf *)); -extern void ntp_monclearinterface P((struct interface *interface)); +extern void init_mon (void); +extern void mon_start (int); +extern void mon_stop (int); +extern int ntp_monitor (struct recvbuf *, int); +extern void ntp_monclearinterface (struct interface *interface); /* ntp_peer.c */ -extern void init_peer P((void)); -extern struct peer *findexistingpeer P((struct sockaddr_storage *, struct peer *, int)); -extern struct peer *findpeer P((struct sockaddr_storage *, struct interface *, int, int *)); -extern struct peer *findpeerbyassoc P((u_int)); -extern void set_peerdstadr P((struct peer *peer, struct interface *interface)); -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_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_storage *, struct interface *, int)); -extern void refresh_all_peerinterfaces P((void)); -extern void unpeer P((struct peer *)); -extern void clear_all P((void)); - -#ifdef OPENSSL -extern void expire_all P((void)); -#endif /* OPENSSL */ -extern struct peer *findmanycastpeer P((struct recvbuf *)); +extern void init_peer (void); +extern struct peer *findexistingpeer (sockaddr_u *, struct peer *, int, u_char); +extern struct peer *findpeer (struct recvbuf *, int, int *); +extern struct peer *findpeerbyassoc (u_int); +extern void set_peerdstadr (struct peer *peer, struct interface *interface); +extern struct peer *newpeer (sockaddr_u *, struct interface *, int, int, int, int, u_int, u_char, int, keyid_t); +extern void peer_all_reset (void); +extern void peer_clr_stats (void); +extern struct peer *peer_config (sockaddr_u *, struct interface *, int, int, int, int, u_int, int, keyid_t, u_char *); +extern void peer_reset (struct peer *); +extern void refresh_all_peerinterfaces (void); +extern void unpeer (struct peer *); +extern void clear_all (void); +extern int score_all (struct peer *); +extern struct peer *findmanycastpeer (struct recvbuf *); /* 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 int 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 *)); +extern int crypto_recv (struct peer *, struct recvbuf *); +extern int crypto_xmit (struct peer *, struct pkt *, + struct recvbuf *, int, + struct exten *, keyid_t); +extern keyid_t session_key (sockaddr_u *, sockaddr_u *, keyid_t, + keyid_t, u_long); +extern int make_keylist (struct peer *, struct interface *); +extern void key_expire (struct peer *); +extern void crypto_update (void); +extern void crypto_config (int, char *); +extern void crypto_setup (void); +extern u_int crypto_ident (struct peer *); +extern struct exten *crypto_args (struct peer *, u_int, associd_t, char *); +extern int crypto_public (struct peer *, u_char *, u_int); +extern void value_free (struct value *); extern char *iffpar_file; extern EVP_PKEY *iffpar_pkey; extern char *gqpar_file; @@ -176,13 +170,20 @@ extern struct value tai_leap; #endif /* OPENSSL */ /* ntp_proto.c */ -extern void transmit P((struct peer *)); -extern void receive P((struct recvbuf *)); -extern void peer_crypto_clear P((struct peer *peer)); -extern void peer_clear P((struct peer *, char *)); -extern void process_packet P((struct peer *, struct pkt *)); -extern void clock_select P((void)); -extern void kod_proto P((void)); +extern void transmit (struct peer *); +extern void receive (struct recvbuf *); +extern void peer_clear (struct peer *, char *); +extern void process_packet (struct peer *, struct pkt *, u_int); +extern void clock_select (void); + +extern int leap_tai; /* TAI at next leap */ +extern u_long leap_sec; /* next scheduled leap from file */ +extern u_long leap_peers; /* next scheduled leap from peers */ +extern u_long leapsec; /* seconds to next leap */ +extern u_long leap_expire; /* leap information expiration */ +extern int sys_orphan; +extern double sys_mindisp; +extern double sys_maxdist; /* * there seems to be a bug in the IRIX 4 compiler which prevents @@ -190,65 +191,71 @@ extern void kod_proto P((void)); * This is also true AIX compiler. * So give up and define it to be int. WLJ */ -extern void poll_update P((struct peer *, int)); +extern void poll_update (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, struct sockaddr_storage*)); -extern void proto_clr_stats P((void)); +extern void clear (struct peer *); +extern void clock_filter (struct peer *, double, double, double); +extern void init_proto (void); +extern void proto_config (int, u_long, double, sockaddr_u *); +extern void proto_clr_stats (void); #ifdef REFCLOCK /* ntp_refclock.c */ -extern int refclock_newpeer P((struct peer *)); -extern void refclock_unpeer P((struct peer *)); -extern void refclock_receive P((struct peer *)); -extern void refclock_transmit P((struct peer *)); -extern void init_refclock P((void)); +extern int refclock_newpeer (struct peer *); +extern void refclock_unpeer (struct peer *); +extern void refclock_receive (struct peer *); +extern void refclock_transmit (struct peer *); +extern void init_refclock (void); #endif /* REFCLOCK */ /* ntp_request.c */ -extern void init_request P((void)); -extern void process_private P((struct recvbuf *, int)); +extern void init_request (void); +extern void process_private (struct recvbuf *, int); /* ntp_restrict.c */ -extern void init_restrict P((void)); -extern int restrictions P((struct sockaddr_storage *, int)); -extern void hack_restrict P((int, struct sockaddr_storage *, struct sockaddr_storage *, int, int)); +extern void init_restrict (void); +extern u_short restrictions (sockaddr_u *); +extern void hack_restrict (int, sockaddr_u *, sockaddr_u *, u_short, u_short); /* 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)); -extern void timer_interfacetimeout P((u_long)); +extern void init_timer (void); +extern void reinit_timer (void); +extern void timer (void); +extern void timer_clr_stats (void); +extern void timer_interfacetimeout (u_long); extern volatile int interface_interval; - #ifdef OPENSSL -extern char *sys_hostname; -extern l_fp sys_revoketime; +extern char *sys_hostname; /* host name */ +extern char *sys_groupname; /* group name */ +extern char *group_name; /* group name */ +extern u_long sys_revoke; /* keys revoke timeout */ +extern u_long sys_automax; /* session key timeout */ #endif /* OPENSSL */ /* ntp_util.c */ -extern void init_util P((void)); -extern void write_stats P((void)); -extern void stats_config P((int, const char *)); -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_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 void init_util (void); +extern void write_stats (void); +extern void stats_config (int, const char *); +extern void record_peer_stats (sockaddr_u *, int, double, double, double, double); +extern void record_proto_stats (char *); +extern void record_loop_stats (double, double, double, double, int); +extern void record_clock_stats (sockaddr_u *, const char *); +extern void record_raw_stats (sockaddr_u *, sockaddr_u *, l_fp *, l_fp *, l_fp *, l_fp *); +extern u_long leap_month(u_long); +extern void record_crypto_stats (sockaddr_u *, const char *); #ifdef DEBUG -extern void record_timing_stats P((const char *)); +extern void record_timing_stats (const char *); #endif -extern int sock_hash P((struct sockaddr_storage *)); +extern u_short sock_hash (sockaddr_u *); +extern char * fstostr(time_t); /* NTP timescale seconds */ extern double old_drift; +extern int drift_file_sw; +extern double wander_threshold; +extern double wander_resid; /* * Variable declarations for ntpd. */ - /* ntp_config.c */ extern char const * progname; extern char *sys_phone[]; /* ACTS phone numbers */ @@ -256,6 +263,20 @@ extern char *sys_phone[]; /* ACTS phone numbers */ extern int config_priority_override; extern int config_priority; #endif +extern char *ntp_signd_socket; +extern struct config_tree *cfg_tree_history; + +#ifdef BC_LIST_FRAMEWORK_NOT_YET_USED +/* + * backwards compatibility flags + */ +typedef struct bc_entry_tag { + int token; + int enabled; +} bc_entry; + +extern bc_entry bc_list[]; +#endif /* ntp_control.c */ extern int num_ctl_traps; @@ -282,6 +303,8 @@ extern u_long numasyncmsgs; /* number of async messages we've sent */ /* ntp_intres.c */ extern keyid_t req_keyid; /* request keyid */ +extern int req_keytype; /* OpenSSL NID such as NID_md5 */ +extern size_t req_hashlen; /* digest size for req_keytype */ extern char * req_file; /* name of the file with configuration info */ #ifdef SYS_WINNT extern HANDLE ResolverEventHandle; @@ -305,9 +328,9 @@ extern u_long io_timereset; /* time counters were reset */ /* * Interface stuff */ -extern struct interface *any_interface; /* default ipv4 interface */ -extern struct interface *any6_interface;/* default ipv6 interface */ -extern struct interface *loopback_interface; /* loopback interface */ +extern endpt * any_interface; /* IPv4 wildcard */ +extern endpt * any6_interface; /* IPv6 wildcard */ +extern endpt * loopback_interface; /* IPv4 loopback for refclocks */ /* * File descriptor masks etc. for call to select @@ -322,7 +345,7 @@ extern double clock_max; /* max offset before step (s) */ extern double clock_panic; /* max offset before panic (s) */ extern double clock_phi; /* dispersion rate (s/s) */ extern double clock_minstep; /* step timeout (s) */ -extern u_long pps_control; /* last pps sample time */ +extern double clock_codec; /* codec frequency */ #ifdef KERNEL_PLL extern int pll_status; /* status bits for kernel pll */ #endif /* KERNEL_PLL */ @@ -348,8 +371,9 @@ 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 double allan_xpt; /* Allan intercept (s) */ +extern u_char allan_xpt; /* Allan intercept (log2 s) */ extern double clock_jitter; /* clock jitter (s) */ +extern double sys_offset; /* system offset (s) */ extern double sys_jitter; /* system jitter (s) */ /* ntp_monitor.c */ @@ -381,16 +405,13 @@ extern int peer_preempt; /* preemptable associations */ * specification. */ extern u_char sys_leap; /* system leap indicator */ -extern u_char sys_stratum; /* stratum of system */ +extern u_char sys_stratum; /* system stratum */ extern s_char sys_precision; /* local clock precision */ -extern double sys_rootdelay; /* distance to current sync source */ -extern double sys_rootdispersion; /* dispersion of system clock */ -extern u_int32 sys_refid; /* reference source for local clock */ -extern l_fp sys_reftime; /* time we were last updated */ -extern struct peer *sys_peer; /* our current peer */ -extern struct peer *sys_pps; /* our current PPS peer */ -extern struct peer *sys_prefer; /* our cherished peer */ -extern u_long sys_automax; /* maximum session key lifetime */ +extern double sys_rootdelay; /* roundtrip delay to primary source */ +extern double sys_rootdisp; /* dispersion to primary source */ +extern u_int32 sys_refid; /* reference id */ +extern l_fp sys_reftime; /* last update time */ +extern struct peer *sys_peer; /* current peer */ /* * Nonspecified system state variables. @@ -405,23 +426,24 @@ 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 u_char sys_ttl[MAX_TTL]; /* ttl mapping vector */ extern int sys_ttlmax; /* max ttl mapping vector index */ -extern int leap_next; /* leap consensus */ /* * Statistics counters */ -extern u_long sys_stattime; /* time when we started recording */ +extern u_long sys_stattime; /* time since reset */ +extern u_long sys_received; /* packets received */ +extern u_long sys_processed; /* packets for this host */ 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_newversion; /* current version */ +extern u_long sys_oldversion; /* old version */ +extern u_long sys_restricted; /* access denied */ extern u_long sys_badlength; /* bad length or format */ -extern u_long sys_processed; /* packets processed */ extern u_long sys_badauth; /* bad authentication */ -extern u_long sys_limitrejected; /* rate limit exceeded */ -extern u_long sys_received; /* packets received */ +extern u_long sys_declined; /* declined */ +extern u_long sys_limitrejected; /* rate exceeded */ +extern u_long sys_kodsent; /* KoD sent */ /* ntp_refclock.c */ #ifdef REFCLOCK @@ -434,15 +456,14 @@ 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 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 */ +extern restrict_u * restrictlist4; /* IPv4 restriction list */ +extern restrict_u * restrictlist6; /* IPv6 restriction list */ +extern int ntp_minpkt; +extern int ntp_minpoll; +extern int mon_age; /* monitor preempt age */ /* ntp_timer.c */ extern volatile int alarm_flag; /* alarm flag */ -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; @@ -462,11 +483,24 @@ extern int initializing; /* initializing flag */ extern int droproot; /* flag: try to drop root privileges after startup */ extern char *user; /* user to switch to */ extern char *group; /* group to switch to */ -extern char *chrootdir; /* directory to chroot to */ +extern const char *chrootdir; /* directory to chroot to */ #endif /* refclock_conf.c */ #ifdef REFCLOCK -extern struct refclock *refclock_conf[]; /* refclock configuration table */ +/* refclock configuration table */ +extern struct refclock * const refclock_conf[]; extern u_char num_refclock_conf; #endif + +/* ntp_signd.c */ +#ifdef HAVE_NTP_SIGND +extern void +send_via_ntp_signd( + struct recvbuf *rbufp, /* receive packet pointer */ + int xmode, + keyid_t xkeyid, + int flags, + struct pkt *xpkt + ); +#endif diff --git a/include/ntpsim.h b/include/ntpsim.h index c48dc59542be..971c7f16340c 100644 --- a/include/ntpsim.h +++ b/include/ntpsim.h @@ -1,13 +1,21 @@ -/* - * ntpsim.h - Prototypes for ntpsim +/* ntpsim.h + * + * The header file for the ntp discrete event simulator. + * + * Written By: Sachin Kamboj + * University of Delaware + * Newark, DE 19711 + * Copyright (c) 2006 */ -#ifndef __ntpsim_h -#define __ntpsim_h +#ifndef NTPSIM_H +#define NTPSIM_H #include <stdio.h> #include <math.h> +#ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> +#endif #include <arpa/inet.h> #include "ntp_syslog.h" #include "ntp_fp.h" @@ -19,75 +27,117 @@ #include "ntp_io.h" #include "ntp_stdlib.h" -#define PI 3.1415926535 +#include "ntp_data_structures.h" + +/* CONSTANTS */ + +#ifdef PI +# undef PI +#endif +#define PI 3.1415926535 /* The world's most famous constant */ +#define SIM_TIME 86400 /* end simulation time */ +#define NET_DLY .001 /* network delay */ +#define PROC_DLY .001 /* processing delay */ +#define BEEP_DLY 3600 /* beep interval (s) */ -/* - * ntpsim declarations + +/* Discrete Event Queue + * -------------------- + * The NTP simulator is a discrete event simulator. + * + * Central to this simulator is an event queue which is a priority queue + * in which the "priority" is given by the time of arrival of the event. + * + * A discrete set of events can happen and are stored in the queue to arrive + * at a particular time. */ + +/* Possible Discrete Events */ + typedef enum { - BEEP, CLOCK, TIMER, PACKET + BEEP, /* Event to record simulator stats */ + CLOCK, /* Event to advance the clock to the specified time */ + TIMER, /* Event that designates a timer interrupt. */ + PACKET /* Event that designates arrival of a packet */ } funcTkn; + +/* Event information */ + typedef struct { - double time; - union { - struct pkt evnt_pkt; - struct recvbuf evnt_buf; - } buffer; + double time; /* Time at which event occurred */ + funcTkn function; /* Type of event that occured */ + union { + struct pkt evnt_pkt; + struct recvbuf evnt_buf; + } buffer; /* Other data associated with the event */ #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 +/* Server Script Information */ + +typedef struct { + double duration; + double freq_offset; + double wander; + double jitter; + double prop_delay; + double proc_delay; +} script_info; + + + +/* Server Structures */ + +typedef struct { + double server_time; /* Server time */ + sockaddr_u *addr; /* Server Address */ + queue *script; /* Server Script */ + script_info *curr_script; /* Current Script */ +} server_info; + + +/* Simulation control information */ + +typedef struct Sim_Info { + double sim_time; /* Time in the simulation */ + double end_time; /* Time at which simulation needs to be ended */ + double beep_delay; /* Delay between simulation "beeps" at which + simulation stats are recorded. */ + int num_of_servers; /* Number of servers in the simulation */ + server_info *servers; /* Pointer to array of servers */ +} sim_info; + + +/* Local Clock (Client) Variables */ + +typedef struct Local_Clock_Info { + double local_time; /* Client disciplined time */ + double adj; /* Remaining time correction */ + double slew; /* Correction Slew Rate */ + double last_read_time; /* Last time the clock was read */ +} local_clock_info; + +extern local_clock_info simclock; /* Local Clock Variables */ +extern sim_info simulation; /* Simulation Control Variables */ + +/* Function Prototypes */ + +int ntpsim (int argc, char *argv[]); +Event *event (double t, funcTkn f); +void sim_event_timer (Event *e); +int simulate_server (sockaddr_u *serv_addr, + struct interface *inter, + struct pkt *rpkt); +void sim_update_clocks (Event *e); +void sim_event_recv_packet (Event *e); +void sim_event_beep (Event *e); +void abortsim (char *errmsg); +double gauss (double, double); +double poisson (double, double); +int yyparse (void); +void create_server_associations (void); +#endif /* NTPSIM_H */ diff --git a/include/parse.h b/include/parse.h index 8b4edcf8e625..3a98408f07de 100644 --- a/include/parse.h +++ b/include/parse.h @@ -58,11 +58,11 @@ #endif #ifdef PARSEKERNEL #ifndef _KERNEL -extern caddr_t kmem_alloc P((unsigned int)); -extern caddr_t kmem_free P((caddr_t, unsigned int)); -extern unsigned int splx P((unsigned int)); -extern unsigned int splhigh P((void)); -extern unsigned int splclock P((void)); +extern caddr_t kmem_alloc (unsigned int); +extern caddr_t kmem_free (caddr_t, unsigned int); +extern unsigned int splx (unsigned int); +extern unsigned int splhigh (void); +extern unsigned int splclock (void); #define MALLOC(_X_) (char *)kmem_alloc(_X_) #define FREE(_X_, _Y_) kmem_free((caddr_t)_X_, _Y_) #else @@ -340,12 +340,12 @@ typedef struct clocktime clocktime_t; struct clockformat { /* special input protocol - implies fixed format */ - u_long (*input) P((parse_t *, unsigned int, timestamp_t *)); + u_long (*input) (parse_t *, unsigned int, timestamp_t *); /* conversion routine */ - u_long (*convert) P((unsigned char *, int, struct format *, clocktime_t *, void *)); + u_long (*convert) (unsigned char *, int, struct format *, clocktime_t *, void *); /* routine for handling RS232 sync events (time stamps) */ /* PPS input routine */ - u_long (*syncpps) P((parse_t *, int, timestamp_t *)); + u_long (*syncpps) (parse_t *, int, timestamp_t *); /* time code synthesizer */ void *data; /* local parameters */ @@ -359,30 +359,30 @@ typedef struct clockformat clockformat_t; /* * parse interface */ -extern int parse_ioinit P((parse_t *)); -extern void parse_ioend P((parse_t *)); -extern int parse_ioread P((parse_t *, unsigned int, timestamp_t *)); -extern int parse_iopps P((parse_t *, int, timestamp_t *)); -extern void parse_iodone P((parse_t *)); -extern int parse_timecode P((parsectl_t *, parse_t *)); -extern int parse_getfmt P((parsectl_t *, parse_t *)); -extern int parse_setfmt P((parsectl_t *, parse_t *)); -extern int parse_setcs P((parsectl_t *, parse_t *)); - -extern unsigned int parse_restart P((parse_t *, unsigned int)); -extern unsigned int parse_addchar P((parse_t *, unsigned int)); -extern unsigned int parse_end P((parse_t *)); - -extern int Strok P((const unsigned char *, const unsigned char *)); -extern int Stoi P((const unsigned char *, long *, int)); - -extern time_t parse_to_unixtime P((clocktime_t *, u_long *)); -extern u_long updatetimeinfo P((parse_t *, u_long)); -extern void syn_simple P((parse_t *, timestamp_t *, struct format *, u_long)); -extern u_long pps_simple P((parse_t *, int, timestamp_t *)); -extern u_long pps_one P((parse_t *, int, timestamp_t *)); -extern u_long pps_zero P((parse_t *, int, timestamp_t *)); -extern int parse_timedout P((parse_t *, timestamp_t *, struct timeval *)); +extern int parse_ioinit (parse_t *); +extern void parse_ioend (parse_t *); +extern int parse_ioread (parse_t *, unsigned int, timestamp_t *); +extern int parse_iopps (parse_t *, int, timestamp_t *); +extern void parse_iodone (parse_t *); +extern int parse_timecode (parsectl_t *, parse_t *); +extern int parse_getfmt (parsectl_t *, parse_t *); +extern int parse_setfmt (parsectl_t *, parse_t *); +extern int parse_setcs (parsectl_t *, parse_t *); + +extern unsigned int parse_restart (parse_t *, unsigned int); +extern unsigned int parse_addchar (parse_t *, unsigned int); +extern unsigned int parse_end (parse_t *); + +extern int Strok (const unsigned char *, const unsigned char *); +extern int Stoi (const unsigned char *, long *, int); + +extern time_t parse_to_unixtime (clocktime_t *, u_long *); +extern u_long updatetimeinfo (parse_t *, u_long); +extern void syn_simple (parse_t *, timestamp_t *, struct format *, u_long); +extern u_long pps_simple (parse_t *, int, timestamp_t *); +extern u_long pps_one (parse_t *, int, timestamp_t *); +extern u_long pps_zero (parse_t *, int, timestamp_t *); +extern int parse_timedout (parse_t *, timestamp_t *, struct timeval *); #endif diff --git a/include/recvbuff.h b/include/recvbuff.h index 771b90b94a88..3b205452e206 100644 --- a/include/recvbuff.h +++ b/include/recvbuff.h @@ -1,5 +1,5 @@ -#if !defined __recvbuff_h -#define __recvbuff_h +#ifndef RECVBUFF_H +#define RECVBUFF_H #ifdef HAVE_CONFIG_H # include <config.h> @@ -7,9 +7,8 @@ #include "ntp.h" #include "ntp_fp.h" -#include "ntp_types.h" +#include "ntp_lists.h" -#include <isc/list.h> #include <isc/result.h> /* @@ -29,7 +28,7 @@ /* Return the event which is set when items are added to the full list */ -extern HANDLE get_recv_buff_event P((void)); +extern HANDLE get_recv_buff_event (void); #else # define RECV_BLOCK_IO() # define RECV_UNBLOCK_IO() @@ -52,41 +51,40 @@ extern HANDLE get_recv_buff_event P((void)); typedef struct recvbuf recvbuf_t; struct recvbuf { - ISC_LINK(recvbuf_t) link; + ISC_LINK(recvbuf_t) link; /* next in list */ union { - struct sockaddr_storage X_recv_srcadr; + sockaddr_u X_recv_srcadr; caddr_t X_recv_srcclock; struct peer *X_recv_peer; } X_from_where; #define recv_srcadr X_from_where.X_recv_srcadr #define recv_srcclock X_from_where.X_recv_srcclock #define recv_peer X_from_where.X_recv_peer -#if defined HAVE_IO_COMPLETION_PORT - WSABUF wsabuff; +#ifndef HAVE_IO_COMPLETION_PORT + sockaddr_u srcadr; /* where packet came from */ #else - struct sockaddr_storage srcadr; /* where packet came from */ + int recv_srcadr_len; /* filled in on completion */ #endif - int src_addr_len; /* source address length */ - struct interface *dstadr; /* interface datagram arrived thru */ + endpt * dstadr; /* address pkt arrived on */ SOCKET fd; /* fd on which it was received */ int msg_flags; /* Flags received about the packet */ l_fp recv_time; /* time of arrival */ - void (*receiver) P((struct recvbuf *)); /* routine to receive buffer */ + void (*receiver) (struct recvbuf *); /* routine to receive buffer */ int recv_length; /* number of octets received */ union { struct pkt X_recv_pkt; u_char X_recv_buffer[RX_BUFF_SIZE]; } recv_space; - int used; #define recv_pkt recv_space.X_recv_pkt #define recv_buffer recv_space.X_recv_buffer + int used; /* reference count */ }; -extern void init_recvbuff P((int)); +extern void init_recvbuff (int); /* freerecvbuf - make a single recvbuf available for reuse */ -extern void freerecvbuf P((struct recvbuf *)); +extern void freerecvbuf (struct recvbuf *); /* Get a free buffer (typically used so an async * read can directly place data into the buffer @@ -94,30 +92,29 @@ extern void freerecvbuf P((struct recvbuf *)); * The buffer is removed from the free list. Make sure * you put it back with freerecvbuf() or */ -extern struct recvbuf *get_free_recv_buffer P((void)); /* signal safe - no malloc */ -extern struct recvbuf *get_free_recv_buffer_alloc P((void)); /* signal unsafe - may malloc */ +extern struct recvbuf *get_free_recv_buffer (void); /* signal safe - no malloc */ +extern struct recvbuf *get_free_recv_buffer_alloc (void); /* signal unsafe - may malloc */ /* Add a buffer to the full list */ -extern void add_full_recv_buffer P((struct recvbuf *)); +extern void add_full_recv_buffer (struct recvbuf *); -/*extern void process_recv_buffers P((void)); */ +/*extern void process_recv_buffers (void); */ /* number of recvbufs on freelist */ -extern u_long free_recvbuffs P((void)); -extern u_long full_recvbuffs P((void)); -extern u_long total_recvbuffs P((void)); -extern u_long lowater_additions P((void)); +extern u_long free_recvbuffs (void); +extern u_long full_recvbuffs (void); +extern u_long total_recvbuffs (void); +extern u_long lowater_additions (void); /* Returns the next buffer in the full list. * */ -extern struct recvbuf *get_full_recv_buffer P((void)); +extern struct recvbuf *get_full_recv_buffer (void); /* * Checks to see if there are buffers to process */ -extern isc_boolean_t has_full_recv_buffer P((void)); - -#endif /* defined __recvbuff_h */ +extern isc_boolean_t has_full_recv_buffer (void); +#endif /* RECVBUFF_H */ diff --git a/include/refclock_atom.h b/include/refclock_atom.h new file mode 100644 index 000000000000..9afce0207ff8 --- /dev/null +++ b/include/refclock_atom.h @@ -0,0 +1,15 @@ +/* + * Definitions for the atom driver and its friends + */ +#define NANOSECOND 1000000000 /* one second (ns) */ +#define RANGEGATE 500000 /* range gate (ns) */ + +struct refclock_atom { + pps_handle_t handle; + pps_params_t pps_params; + struct timespec ts; +}; + +extern int refclock_ppsapi(int, struct refclock_atom *); +extern int refclock_params(int, struct refclock_atom *); +extern int refclock_pps(struct peer *, struct refclock_atom *, int); diff --git a/include/rsa_md5.h b/include/rsa_md5.h deleted file mode 100644 index 8241647601b3..000000000000 --- a/include/rsa_md5.h +++ /dev/null @@ -1,51 +0,0 @@ -/* 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 diff --git a/include/ssl_applink.c b/include/ssl_applink.c new file mode 100644 index 000000000000..ba1f4a8fe916 --- /dev/null +++ b/include/ssl_applink.c @@ -0,0 +1,74 @@ +/* + * include/ssl_applink.c -- common NTP code for openssl/applink.c + * + * Each program which uses OpenSSL should include this file in _one_ + * of its source files and call ssl_applink() before any OpenSSL + * functions. + */ + +#if defined(OPENSSL) && defined(SYS_WINNT) +# ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4152) +# endif +# include <openssl/applink.c> +# ifdef _MSC_VER +# pragma warning(pop) +# endif +#endif + +#if defined(OPENSSL) && defined(_MSC_VER) && defined(_DEBUG) +#define WRAP_DBG_MALLOC +#endif + +#ifdef WRAP_DBG_MALLOC +void *wrap_dbg_malloc(size_t s, const char *f, int l); +void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l); +void wrap_dbg_free(void *p); +#endif + + +#if defined(OPENSSL) && defined(SYS_WINNT) +void ssl_applink(void); + +void +ssl_applink(void) +{ +#ifdef WRAP_DBG_MALLOC + CRYPTO_set_mem_ex_functions(wrap_dbg_malloc, wrap_dbg_realloc, wrap_dbg_free); +#else + CRYPTO_malloc_init(); +#endif +} +#else /* !OPENSSL || !SYS_WINNT */ +#define ssl_applink() do {} while (0) +#endif + + +#ifdef WRAP_DBG_MALLOC +/* + * OpenSSL malloc overriding uses different parameters + * for DEBUG malloc/realloc/free (lacking block type). + * Simple wrappers convert. + */ +void *wrap_dbg_malloc(size_t s, const char *f, int l) +{ + void *ret; + + ret = _malloc_dbg(s, _NORMAL_BLOCK, f, l); + return ret; +} + +void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l) +{ + void *ret; + + ret = _realloc_dbg(p, s, _NORMAL_BLOCK, f, l); + return ret; +} + +void wrap_dbg_free(void *p) +{ + _free_dbg(p, _NORMAL_BLOCK); +} +#endif /* WRAP_DBG_MALLOC */ diff --git a/include/timepps-Solaris.h b/include/timepps-Solaris.h index da8fd9403c71..73faa5e08745 100644 --- a/include/timepps-Solaris.h +++ b/include/timepps-Solaris.h @@ -1,6 +1,6 @@ /*********************************************************************** * * - * Copyright (c) David L. Mills 1999-2000 * + * Copyright (c) David L. Mills 1999-2009 * * * * Permission to use, copy, modify, and distribute this software and * * its documentation for any purpose and without fee is hereby * @@ -178,20 +178,39 @@ typedef struct pps_params { #define assert_offset_ntpfp assert_off_tu.ntpfp #define clear_offset_ntpfp clear_off_tu.ntpfp +/* addition of NTP fixed-point format */ + +#define NTPFP_M_ADD(r_i, r_f, a_i, a_f) /* r += a */ \ + do { \ + register u_int32 lo_tmp; \ + register u_int32 hi_tmp; \ + \ + lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \ + hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \ + if (lo_tmp & 0x10000) \ + hi_tmp++; \ + (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \ + \ + (r_i) += (a_i); \ + if (hi_tmp & 0x10000) \ + (r_i)++; \ + } while (0) + +#define NTPFP_L_ADDS(r, a) NTPFP_M_ADD((r)->integral, (r)->fractional, \ + (int)(a)->integral, (a)->fractional) + /* * The following definitions are architecture-dependent */ #define PPS_CAP (PPS_CAPTUREASSERT | PPS_OFFSETASSERT | PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP) -#define PPS_RO (PPS_CANWAIT | PPS_CANPOLL | PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP) +#define PPS_RO (PPS_CANWAIT | PPS_CANPOLL) typedef struct { int filedes; /* file descriptor */ pps_params_t params; /* PPS parameters set by user */ } pps_unit_t; -typedef pps_unit_t* pps_handle_t; /* pps handlebars */ - /* *------ Here begins the implementation-specific part! ------ */ @@ -199,6 +218,13 @@ typedef pps_unit_t* pps_handle_t; /* pps handlebars */ #include <errno.h> /* + * pps handlebars, which are required to be an opaque scalar. This + * implementation uses the handle as a pointer so it must be large + * enough. uintptr_t is as large as a pointer. + */ +typedef uintptr_t pps_handle_t; + +/* * create PPS handle from file descriptor */ @@ -208,6 +234,7 @@ time_pps_create( pps_handle_t *handle /* returned handle */ ) { + pps_unit_t *punit; int one = 1; /* @@ -228,16 +255,18 @@ time_pps_create( * Allocate and initialize default unit structure. */ - *handle = malloc(sizeof(pps_unit_t)); - if (!(*handle)) { - errno = EBADF; + punit = malloc(sizeof(*punit)); + if (NULL == punit) { + errno = ENOMEM; return (-1); /* what, no memory? */ } - memset(*handle, 0, sizeof(pps_unit_t)); - (*handle)->filedes = filedes; - (*handle)->params.api_version = PPS_API_VERS_1; - (*handle)->params.mode = PPS_CAPTUREASSERT | PPS_TSFMT_TSPEC; + memset(punit, 0, sizeof(*punit)); + punit->filedes = filedes; + punit->params.api_version = PPS_API_VERS_1; + punit->params.mode = PPS_CAPTUREASSERT | PPS_TSFMT_TSPEC; + + *handle = (pps_handle_t)punit; return (0); } @@ -250,6 +279,8 @@ time_pps_destroy( pps_handle_t handle ) { + pps_unit_t *punit; + /* * Check for valid arguments and detach PPS signal. */ @@ -258,7 +289,8 @@ time_pps_destroy( errno = EBADF; return (-1); /* bad handle */ } - free(handle); + punit = (pps_unit_t *)handle; + free(punit); return (0); } @@ -272,7 +304,8 @@ time_pps_setparams( const pps_params_t *params ) { - int mode, mode_in; + pps_unit_t * punit; + int mode, mode_in; /* * Check for valid arguments and set parameters. */ @@ -302,14 +335,42 @@ time_pps_setparams( */ mode_in = params->mode; + punit = (pps_unit_t *)handle; + + /* + * Only one of the time formats may be selected + * if a nonzero assert offset is supplied. + */ + if ((mode_in & (PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)) == + (PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)) { + + if (punit->params.assert_offset.tv_sec || + punit->params.assert_offset.tv_nsec) { + + errno = EINVAL; + return(-1); + } + + /* + * If no offset was specified but both time + * format flags are used consider it harmless + * but turn off PPS_TSFMT_NTPFP so getparams + * will not show both formats lit. + */ + mode_in &= ~PPS_TSFMT_NTPFP; + } /* turn off read-only bits */ mode_in &= ~PPS_RO; - /* test remaining bits, should only have captureassert and/or offsetassert */ + /* + * test remaining bits, should only have captureassert, + * offsetassert, and/or timestamp format bits. + */ - if (mode_in & ~(PPS_CAPTUREASSERT | PPS_OFFSETASSERT)) { + if (mode_in & ~(PPS_CAPTUREASSERT | PPS_OFFSETASSERT | + PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)) { errno = EOPNOTSUPP; return(-1); } @@ -318,10 +379,10 @@ time_pps_setparams( * ok, ready to go. */ - mode = handle->params.mode; - memcpy(&handle->params, params, sizeof(pps_params_t)); - handle->params.api_version = PPS_API_VERS_1; - handle->params.mode = mode | mode_in; + mode = punit->params.mode; + memcpy(&punit->params, params, sizeof(punit->params)); + punit->params.api_version = PPS_API_VERS_1; + punit->params.mode = mode | mode_in; return (0); } @@ -335,6 +396,8 @@ time_pps_getparams( pps_params_t *params ) { + pps_unit_t * punit; + /* * Check for valid arguments and get parameters. */ @@ -349,11 +412,12 @@ time_pps_getparams( return (-1); /* bad argument */ } - memcpy(params, &handle->params, sizeof(pps_params_t)); + punit = (pps_unit_t *)handle; + memcpy(params, &punit->params, sizeof(params)); return (0); } -/* ( +/* * get capabilities for handle */ @@ -397,7 +461,8 @@ time_pps_fetch( u_int serial; } ev; - pps_info_t infobuf; + pps_info_t infobuf; + pps_unit_t * punit; /* * Check for valid arguments and fetch timestamps @@ -419,56 +484,58 @@ time_pps_fetch( */ memset(&infobuf, 0, sizeof(infobuf)); + punit = (pps_unit_t *)handle; /* * if not captureassert, nothing to return. */ - if (!handle->params.mode & PPS_CAPTUREASSERT) { - memcpy(ppsinfo, &infobuf, sizeof(pps_info_t)); + if (!punit->params.mode & PPS_CAPTUREASSERT) { + memcpy(ppsinfo, &infobuf, sizeof(*ppsinfo)); return (0); } - if (ioctl(handle->filedes, TIOCGPPSEV, (caddr_t) &ev) < 0) { + if (ioctl(punit->filedes, TIOCGPPSEV, (caddr_t) &ev) < 0) { perror("time_pps_fetch:"); errno = EOPNOTSUPP; return(-1); } - /* - * Apply offsets as specified. Note that only assert timestamps - * are captured by this interface. - */ - infobuf.assert_sequence = ev.serial; infobuf.assert_timestamp.tv_sec = ev.tv.tv_sec; infobuf.assert_timestamp.tv_nsec = ev.tv.tv_usec * 1000; - if (handle->params.mode & PPS_OFFSETASSERT) { - infobuf.assert_timestamp.tv_sec += handle->params.assert_offset.tv_sec; - infobuf.assert_timestamp.tv_nsec += handle->params.assert_offset.tv_nsec; - PPS_NORMALIZE(infobuf.assert_timestamp); - } - /* - * Translate to specified format + * Translate to specified format then apply offset */ switch (tsformat) { case PPS_TSFMT_TSPEC: - break; /* timespec format requires no translation */ + /* timespec format requires no conversion */ + if (punit->params.mode & PPS_OFFSETASSERT) { + infobuf.assert_timestamp.tv_sec += + punit->params.assert_offset.tv_sec; + infobuf.assert_timestamp.tv_nsec += + punit->params.assert_offset.tv_nsec; + PPS_NORMALIZE(infobuf.assert_timestamp); + } + break; - case PPS_TSFMT_NTPFP: /* NTP format requires conversion to fraction form */ + case PPS_TSFMT_NTPFP: + /* NTP format requires conversion to fraction form */ PPS_TSPECTONTP(infobuf.assert_timestamp_ntpfp); - break; + if (punit->params.mode & PPS_OFFSETASSERT) + NTPFP_L_ADDS(&infobuf.assert_timestamp_ntpfp, + &punit->params.assert_offset_ntpfp); + break; default: errno = EINVAL; return (-1); } - infobuf.current_mode = handle->params.mode; - memcpy(ppsinfo, &infobuf, sizeof(pps_info_t)); + infobuf.current_mode = punit->params.mode; + memcpy(ppsinfo, &infobuf, sizeof(*ppsinfo)); return (0); } @@ -480,7 +547,8 @@ static inline int time_pps_kcbind( pps_handle_t handle, const int kernel_consumer, - const int edge, const int tsformat + const int edge, + const int tsformat ) { /* diff --git a/include/trimble.h b/include/trimble.h index 0387639612c8..aaa5baa78f9a 100644 --- a/include/trimble.h +++ b/include/trimble.h @@ -132,7 +132,7 @@ typedef struct cmd_info extern cmd_info_t trimble_rcmds[]; extern cmd_info_t trimble_scmds[]; -extern cmd_info_t *trimble_convert P((unsigned int cmd, cmd_info_t *tbl)); +extern cmd_info_t *trimble_convert (unsigned int cmd, cmd_info_t *tbl); #endif /* diff --git a/include/version.def b/include/version.def index f0dc444146e4..706bf967cac2 100644 --- a/include/version.def +++ b/include/version.def @@ -1 +1 @@ -version = '4.2.4p8'; +version = '4.2.6p5'; diff --git a/include/version.texi b/include/version.texi new file mode 100644 index 000000000000..1d549577f406 --- /dev/null +++ b/include/version.texi @@ -0,0 +1,3 @@ +@set UPDATED 24 December 2011 +@set EDITION 4.2.6p5 +@set VERSION 4.2.6p5 |