diff options
Diffstat (limited to 'include/isc')
| -rw-r--r-- | include/isc/Makefile.am | 3 | ||||
| -rw-r--r-- | include/isc/Makefile.in | 172 | ||||
| -rw-r--r-- | include/isc/buffer.h | 800 | ||||
| -rw-r--r-- | include/isc/interfaceiter.h | 2 | ||||
| -rw-r--r-- | include/isc/ipv6.h | 32 | ||||
| -rw-r--r-- | include/isc/msgs.h | 22 | ||||
| -rw-r--r-- | include/isc/net.h | 71 | ||||
| -rw-r--r-- | include/isc/netaddr.h | 34 | ||||
| -rw-r--r-- | include/isc/netscope.h | 40 | ||||
| -rw-r--r-- | include/isc/region.h | 95 | ||||
| -rw-r--r-- | include/isc/result.h | 25 | ||||
| -rw-r--r-- | include/isc/sockaddr.h | 6 |
12 files changed, 1183 insertions, 119 deletions
diff --git a/include/isc/Makefile.am b/include/isc/Makefile.am index a5b253c9ddc6f..3d8c2a47f90ec 100644 --- a/include/isc/Makefile.am +++ b/include/isc/Makefile.am @@ -7,6 +7,7 @@ noinst_HEADERS = \ app.h \ assertions.h \ boolean.h \ + buffer.h \ error.h \ formatcheck.h \ int.h \ @@ -22,11 +23,13 @@ noinst_HEADERS = \ 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 \ diff --git a/include/isc/Makefile.in b/include/isc/Makefile.in index 3270f4a9f726f..26ea36f2acff0 100644 --- a/include/isc/Makefile.in +++ b/include/isc/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.7.7 from Makefile.am. +# Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 -# Free Software Foundation, Inc. +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -21,7 +21,6 @@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../.. - am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 @@ -37,16 +36,37 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -target_triplet = @target@ +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 \ + $(top_srcdir)/m4/os_cflags.m4 $(top_srcdir)/version.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ +AR = @AR@ ARLIB_DIR = @ARLIB_DIR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BINSUBDIR = @BINSUBDIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -54,10 +74,15 @@ CHUTEST = @CHUTEST@ CLKTEST = @CLKTEST@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DCFD = @DCFD@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -65,30 +90,39 @@ EF_LIBS = @EF_LIBS@ EF_PROGS = @EF_PROGS@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ INSTALL_DATA = @INSTALL_DATA@ +INSTALL_LIBOPTS_FALSE = @INSTALL_LIBOPTS_FALSE@ +INSTALL_LIBOPTS_TRUE = @INSTALL_LIBOPTS_TRUE@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LCRYPTO = @LCRYPTO@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ LIBPARSE = @LIBPARSE@ LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ +MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@ MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@ MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@ MAKE_LIBPARSE = @MAKE_LIBPARSE@ MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@ MAKE_NTPDSIM = @MAKE_NTPDSIM@ MAKE_NTPTIME = @MAKE_NTPTIME@ -MAKE_NTP_KEYGEN = @MAKE_NTP_KEYGEN@ MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@ -MAKE_SNTP = @MAKE_SNTP@ MAKE_TICKADJ = @MAKE_TICKADJ@ MAKE_TIMETRIM = @MAKE_TIMETRIM@ +NEED_LIBOPTS_FALSE = @NEED_LIBOPTS_FALSE@ +NEED_LIBOPTS_TRUE = @NEED_LIBOPTS_TRUE@ OBJEXT = @OBJEXT@ OPENSSL = @OPENSSL@ OPENSSL_INC = @OPENSSL_INC@ @@ -111,14 +145,21 @@ STRIP = @STRIP@ TESTDCF = @TESTDCF@ U = @U@ VERSION = @VERSION@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -139,6 +180,7 @@ libdir = @libdir@ libexecdir = @libexecdir@ localstatedir = @localstatedir@ mandir = @mandir@ +mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ prefix = @prefix@ program_transform_name = @program_transform_name@ @@ -146,21 +188,17 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ subdirs = @subdirs@ sysconfdir = @sysconfdir@ -target = @target@ target_alias = @target_alias@ -target_cpu = @target_cpu@ -target_os = @target_os@ -target_vendor = @target_vendor@ #AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies AUTOMAKE_OPTIONS = ../util/ansi2knr ETAGS_ARGS = $(srcdir)/Makefile.am - #EXTRA_DIST = TAGS noinst_HEADERS = \ app.h \ assertions.h \ boolean.h \ + buffer.h \ error.h \ formatcheck.h \ int.h \ @@ -176,44 +214,62 @@ noinst_HEADERS = \ 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 -subdir = include/isc -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -DIST_SOURCES = -HEADERS = $(noinst_HEADERS) - -DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.in Makefile.am all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/isc/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu include/isc/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) + $(AUTOMAKE) --foreign include/isc/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool uninstall-info-am: -ETAGS = etags -ETAGSFLAGS = - -CTAGS = ctags -CTAGSFLAGS = - -tags: TAGS - ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -222,6 +278,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique +tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) @@ -233,10 +290,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$tags$$unique" \ - || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique - + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) @@ -259,10 +317,6 @@ GTAGS: distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) - -top_distdir = ../.. -distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ @@ -276,7 +330,7 @@ distdir: $(DISTFILES) dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ - $(mkinstalldirs) "$(distdir)$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ @@ -294,7 +348,6 @@ distdir: $(DISTFILES) check-am: all-am check: check-am all-am: Makefile $(HEADERS) - installdirs: install: install-am install-exec: install-exec-am @@ -307,7 +360,7 @@ install-am: all-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - INSTALL_STRIP_FLAG=-s \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: @@ -315,24 +368,26 @@ mostlyclean-generic: clean-generic: distclean-generic: - -rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-generic mostlyclean-am +clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile - -distclean-am: clean-am distclean-generic distclean-tags +distclean-am: clean-am distclean-generic distclean-libtool \ + distclean-tags dvi: dvi-am dvi-am: +html: html-am + info: info-am info-am: @@ -349,12 +404,11 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile - maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am -mostlyclean-am: mostlyclean-generic +mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am @@ -366,14 +420,16 @@ ps-am: uninstall-am: uninstall-info-am -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic ctags \ - distclean distclean-generic distclean-tags distdir dvi dvi-am \ - info info-am install install-am install-data install-data-am \ - install-exec install-exec-am install-info install-info-am \ - install-man install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ - uninstall uninstall-am uninstall-info-am +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool ctags distclean distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/include/isc/buffer.h b/include/isc/buffer.h new file mode 100644 index 0000000000000..47c8f0c95d418 --- /dev/null +++ b/include/isc/buffer.h @@ -0,0 +1,800 @@ +/* + * 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/interfaceiter.h b/include/isc/interfaceiter.h index fbd1b82246153..f2d11ba8a432c 100644 --- a/include/isc/interfaceiter.h +++ b/include/isc/interfaceiter.h @@ -59,6 +59,8 @@ struct isc_interface { 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. */ diff --git a/include/isc/ipv6.h b/include/isc/ipv6.h index 18893b7003ce3..007de7c0dd372 100644 --- a/include/isc/ipv6.h +++ b/include/isc/ipv6.h @@ -1,21 +1,21 @@ /* - * Copyright (C) 1999-2001 Internet Software Consortium. + * 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 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: ipv6.h,v 1.19 2002/04/03 06:38:33 marka Exp $ */ +/* $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 @@ -59,7 +59,7 @@ /* * We probably don't need this on NTP */ -#ifdef ISC_ONLY_IPV6 +#ifdef ISC_ONLY_IPV6 /*** *** Types. ***/ @@ -76,8 +76,8 @@ struct in6_addr { #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 }}} +#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; @@ -102,12 +102,13 @@ struct sockaddr_in6 { /* * 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 */ @@ -138,9 +139,10 @@ struct sockaddr_in6 { /* * Multicast */ +#ifndef IN6_IS_ADDR_MULTICAST #define IN6_IS_ADDR_MULTICAST(a) \ ((a)->s6_addr8[0] == 0xffU) - +#endif /* * Unicast link / site local. */ diff --git a/include/isc/msgs.h b/include/isc/msgs.h index b166199e8f0d9..967005bf35317 100644 --- a/include/isc/msgs.h +++ b/include/isc/msgs.h @@ -1,21 +1,21 @@ /* - * Copyright (C) 2000, 2001 Internet Software Consortium. + * 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 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: msgs.h,v 1.7 2002/05/27 00:40:18 marka Exp $ */ +/* $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 @@ -48,6 +48,7 @@ #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, @@ -176,6 +177,7 @@ #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/net.h b/include/isc/net.h index 25924febca389..dae59780b69b7 100644 --- a/include/isc/net.h +++ b/include/isc/net.h @@ -1,21 +1,21 @@ /* - * Copyright (C) 1999-2001 Internet Software Consortium. + * 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 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: net.h,v 1.34 2002/04/03 06:38:38 marka Exp $ */ +/* $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 @@ -75,6 +75,8 @@ #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 @@ -230,6 +232,10 @@ typedef isc_uint16_t in_port_t; (((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. ***/ @@ -245,6 +251,7 @@ isc_net_probeipv4(void); * * ISC_R_SUCCESS IPv4 is supported. * ISC_R_NOTFOUND IPv4 is not supported. + * ISC_R_DISABLED IPv4 is disabled. * ISC_R_UNEXPECTED */ @@ -257,25 +264,63 @@ isc_net_probeipv6(void); * * 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); -#ifdef ISC_PLATFORM_NEEDNTOP #define inet_ntop isc_net_ntop #endif +#ifdef ISC_PLATFORM_NEEDPTON int isc_net_pton(int af, const char *src, void *dst); -#ifdef ISC_PLATFORM_NEEDPTON #undef inet_pton #define inet_pton isc_net_pton #endif +#ifdef ISC_PLATFORM_NEEDATON int isc_net_aton(const char *cp, struct in_addr *addr); -#ifdef ISC_PLATFORM_NEEDATON #define inet_aton isc_net_aton #endif diff --git a/include/isc/netaddr.h b/include/isc/netaddr.h index 811e8dd48e0c8..e209a9fa77497 100644 --- a/include/isc/netaddr.h +++ b/include/isc/netaddr.h @@ -1,21 +1,21 @@ /* + * 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 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: netaddr.h,v 1.21 2002/04/03 06:38:35 marka Exp $ */ +/* $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 @@ -23,9 +23,6 @@ #include <isc/lang.h> #include <isc/net.h> #include <isc/types.h> -#include "ntp_rfc2553.h" - - ISC_LANG_BEGINDECLS @@ -35,6 +32,7 @@ struct isc_netaddr { struct in_addr in; struct in6_addr in6; } type; + isc_uint32_t zone; }; isc_boolean_t @@ -98,6 +96,12 @@ 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. @@ -116,6 +120,12 @@ isc_netaddr_ismulticast(isc_netaddr_t *na); */ 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. diff --git a/include/isc/netscope.h b/include/isc/netscope.h new file mode 100644 index 0000000000000..7cc0f182d7424 --- /dev/null +++ b/include/isc/netscope.h @@ -0,0 +1,40 @@ +/* + * 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/region.h b/include/isc/region.h new file mode 100644 index 0000000000000..5622394aaf437 --- /dev/null +++ b/include/isc/region.h @@ -0,0 +1,95 @@ +/* + * 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 index bf6b992587322..93f7cefbd658b 100644 --- a/include/isc/result.h +++ b/include/isc/result.h @@ -1,21 +1,21 @@ /* - * Copyright (C) 1998-2001 Internet Software Consortium. + * 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 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: result.h,v 1.59 2001/11/30 01:02:17 gson Exp $ */ +/* $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 @@ -80,11 +80,14 @@ #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 57 +#define ISC_R_NRESULTS 60 ISC_LANG_BEGINDECLS diff --git a/include/isc/sockaddr.h b/include/isc/sockaddr.h index 5257b059de01f..635af38117bf5 100644 --- a/include/isc/sockaddr.h +++ b/include/isc/sockaddr.h @@ -174,6 +174,12 @@ isc_sockaddr_ismulticast(isc_sockaddr_t *sa); */ 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. |
