diff options
author | Doug Barton <dougb@FreeBSD.org> | 2006-12-10 07:09:56 +0000 |
---|---|---|
committer | Doug Barton <dougb@FreeBSD.org> | 2006-12-10 07:09:56 +0000 |
commit | e99fbbb680307fe016c8db7d6611f1a3249761fb (patch) | |
tree | d7fa0e61cadfdb3b3752a55401049f2294a7cfaf /contrib/bind9/lib/isc | |
parent | a02f92e875d0d48c46103eef0fbea835048a278b (diff) | |
download | src-e99fbbb680307fe016c8db7d6611f1a3249761fb.tar.gz src-e99fbbb680307fe016c8db7d6611f1a3249761fb.zip |
Vendor import of BIND 9.3.3
Notes
Notes:
svn path=/vendor/bind9/dist/; revision=165071
Diffstat (limited to 'contrib/bind9/lib/isc')
22 files changed, 296 insertions, 119 deletions
diff --git a/contrib/bind9/lib/isc/api b/contrib/bind9/lib/isc/api index ddeff334f036..b4d017358ad1 100644 --- a/contrib/bind9/lib/isc/api +++ b/contrib/bind9/lib/isc/api @@ -1,3 +1,3 @@ -LIBINTERFACE = 11 +LIBINTERFACE = 12 LIBREVISION = 1 -LIBAGE = 0 +LIBAGE = 1 diff --git a/contrib/bind9/lib/isc/hash.c b/contrib/bind9/lib/isc/hash.c index 22f370064af4..10942066633f 100644 --- a/contrib/bind9/lib/isc/hash.c +++ b/contrib/bind9/lib/isc/hash.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: hash.c,v 1.2.2.4.2.1 2004/03/06 08:14:29 marka Exp $ */ +/* $Id: hash.c,v 1.2.2.4.2.3 2006/01/04 00:37:22 marka Exp $ */ /* * Some portion of this code was derived from universal hash function @@ -68,7 +68,6 @@ if advised of the possibility of such damage. #include <isc/once.h> #include <isc/random.h> #include <isc/refcount.h> -#include <isc/rwlock.h> #include <isc/string.h> #include <isc/util.h> @@ -99,7 +98,7 @@ struct isc_hash { hash_random_t *rndvector; /* random vector for universal hashing */ }; -static isc_rwlock_t createlock; +static isc_mutex_t createlock; static isc_once_t once = ISC_ONCE_INIT; static isc_hash_t *hash = NULL; @@ -209,7 +208,7 @@ isc_hash_ctxcreate(isc_mem_t *mctx, isc_entropy_t *entropy, static void initialize_lock(void) { - RUNTIME_CHECK(isc_rwlock_init(&createlock, 0, 0) == ISC_R_SUCCESS); + RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS); } isc_result_t @@ -221,12 +220,12 @@ isc_hash_create(isc_mem_t *mctx, isc_entropy_t *entropy, size_t limit) { RUNTIME_CHECK(isc_once_do(&once, initialize_lock) == ISC_R_SUCCESS); - RWLOCK(&createlock, isc_rwlocktype_write); + LOCK(&createlock); if (hash == NULL) result = isc_hash_ctxcreate(mctx, entropy, limit, &hash); - RWUNLOCK(&createlock, isc_rwlocktype_write); + UNLOCK(&createlock); return (result); } diff --git a/contrib/bind9/lib/isc/heap.c b/contrib/bind9/lib/isc/heap.c index 78b192548a9c..fd67d7bd7897 100644 --- a/contrib/bind9/lib/isc/heap.c +++ b/contrib/bind9/lib/isc/heap.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1997-2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,15 +15,15 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: heap.c,v 1.28.12.3 2004/03/08 09:04:48 marka Exp $ */ +/* $Id: heap.c,v 1.28.12.4 2006/04/17 18:27:20 explorer Exp $ */ -/* +/*! \file * Heap implementation of priority queues adapted from the following: * - * _Introduction to Algorithms_, Cormen, Leiserson, and Rivest, + * \li "Introduction to Algorithms," Cormen, Leiserson, and Rivest, * MIT Press / McGraw Hill, 1990, ISBN 0-262-03141-8, chapter 7. * - * _Algorithms_, Second Edition, Sedgewick, Addison-Wesley, 1988, + * \li "Algorithms," Second Edition, Sedgewick, Addison-Wesley, 1988, * ISBN 0-201-06673-4, chapter 11. */ @@ -35,20 +35,23 @@ #include <isc/string.h> /* Required for memcpy. */ #include <isc/util.h> -/* +/*@{*/ +/*% * Note: to make heap_parent and heap_left easy to compute, the first * element of the heap array is not used; i.e. heap subscripts are 1-based, - * not 0-based. + * not 0-based. The parent is index/2, and the left-child is index*2. + * The right child is index*2+1. */ #define heap_parent(i) ((i) >> 1) #define heap_left(i) ((i) << 1) +/*@}*/ #define SIZE_INCREMENT 1024 #define HEAP_MAGIC ISC_MAGIC('H', 'E', 'A', 'P') #define VALID_HEAP(h) ISC_MAGIC_VALID(h, HEAP_MAGIC) -/* +/*% * When the heap is in a consistent state, the following invariant * holds true: for every element i > 1, heap_parent(i) has a priority * higher than or equal to that of i. @@ -57,6 +60,7 @@ ! heap->compare(heap->array[(i)], \ heap->array[heap_parent(i)])) +/*% ISC heap structure. */ struct isc_heap { unsigned int magic; isc_mem_t * mctx; @@ -141,8 +145,8 @@ static void float_up(isc_heap_t *heap, unsigned int i, void *elt) { unsigned int p; - for (p = heap_parent(i); - i > 1 && heap->compare(elt, heap->array[p]); + for (p = heap_parent(i) ; + i > 1 && heap->compare(elt, heap->array[p]) ; i = p, p = heap_parent(i)) { heap->array[i] = heap->array[p]; if (heap->index != NULL) @@ -196,48 +200,48 @@ isc_heap_insert(isc_heap_t *heap, void *elt) { } void -isc_heap_delete(isc_heap_t *heap, unsigned int i) { +isc_heap_delete(isc_heap_t *heap, unsigned int index) { void *elt; isc_boolean_t less; REQUIRE(VALID_HEAP(heap)); - REQUIRE(i >= 1 && i <= heap->last); + REQUIRE(index >= 1 && index <= heap->last); - if (i == heap->last) { + if (index == heap->last) { heap->last--; } else { elt = heap->array[heap->last--]; - less = heap->compare(elt, heap->array[i]); - heap->array[i] = elt; + less = heap->compare(elt, heap->array[index]); + heap->array[index] = elt; if (less) - float_up(heap, i, heap->array[i]); + float_up(heap, index, heap->array[index]); else - sink_down(heap, i, heap->array[i]); + sink_down(heap, index, heap->array[index]); } } void -isc_heap_increased(isc_heap_t *heap, unsigned int i) { +isc_heap_increased(isc_heap_t *heap, unsigned int index) { REQUIRE(VALID_HEAP(heap)); - REQUIRE(i >= 1 && i <= heap->last); + REQUIRE(index >= 1 && index <= heap->last); - float_up(heap, i, heap->array[i]); + float_up(heap, index, heap->array[index]); } void -isc_heap_decreased(isc_heap_t *heap, unsigned int i) { +isc_heap_decreased(isc_heap_t *heap, unsigned int index) { REQUIRE(VALID_HEAP(heap)); - REQUIRE(i >= 1 && i <= heap->last); + REQUIRE(index >= 1 && index <= heap->last); - sink_down(heap, i, heap->array[i]); + sink_down(heap, index, heap->array[index]); } void * -isc_heap_element(isc_heap_t *heap, unsigned int i) { +isc_heap_element(isc_heap_t *heap, unsigned int index) { REQUIRE(VALID_HEAP(heap)); - REQUIRE(i >= 1 && i <= heap->last); + REQUIRE(index >= 1 && index <= heap->last); - return (heap->array[i]); + return (heap->array[index]); } void @@ -247,6 +251,6 @@ isc_heap_foreach(isc_heap_t *heap, isc_heapaction_t action, void *uap) { REQUIRE(VALID_HEAP(heap)); REQUIRE(action != NULL); - for (i = 1; i <= heap->last; i++) + for (i = 1 ; i <= heap->last ; i++) (action)(heap->array[i], uap); } diff --git a/contrib/bind9/lib/isc/hmacmd5.c b/contrib/bind9/lib/isc/hmacmd5.c index 04dc8c5e0576..5166a98cf6ee 100644 --- a/contrib/bind9/lib/isc/hmacmd5.c +++ b/contrib/bind9/lib/isc/hmacmd5.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: hmacmd5.c,v 1.5.12.3 2004/03/08 09:04:48 marka Exp $ */ +/* $Id: hmacmd5.c,v 1.5.12.5 2006/02/26 23:49:48 marka Exp $ */ /* * This code implements the HMAC-MD5 keyed hash algorithm @@ -65,7 +65,6 @@ void isc_hmacmd5_invalidate(isc_hmacmd5_t *ctx) { isc_md5_invalidate(&ctx->md5ctx); memset(ctx->key, 0, sizeof(ctx->key)); - memset(ctx, 0, sizeof(ctx)); } /* diff --git a/contrib/bind9/lib/isc/include/isc/heap.h b/contrib/bind9/lib/isc/include/isc/heap.h index 5ebf40471e22..7c7f3c2916a6 100644 --- a/contrib/bind9/lib/isc/include/isc/heap.h +++ b/contrib/bind9/lib/isc/include/isc/heap.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1997-2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,36 +15,155 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: heap.h,v 1.16.206.1 2004/03/06 08:14:41 marka Exp $ */ +/* $Id: heap.h,v 1.16.206.2 2006/04/17 18:27:20 explorer Exp $ */ #ifndef ISC_HEAP_H #define ISC_HEAP_H 1 +/*! \file */ + #include <isc/lang.h> #include <isc/types.h> ISC_LANG_BEGINDECLS -/* +/*% * The comparision function returns ISC_TRUE if the first argument has * higher priority than the second argument, and ISC_FALSE otherwise. */ typedef isc_boolean_t (*isc_heapcompare_t)(void *, void *); +/*% + * The index function allows the client of the heap to receive a callback + * when an item's index number changes. This allows it to maintain + * sync with its external state, but still delete itself, since deletions + * from the heap require the index be provided. + */ typedef void (*isc_heapindex_t)(void *, unsigned int); + +/*% + * The heapaction function is used when iterating over the heap. + * + * NOTE: The heap structure CANNOT BE MODIFIED during the call to + * isc_heap_foreach(). + */ typedef void (*isc_heapaction_t)(void *, void *); typedef struct isc_heap isc_heap_t; -isc_result_t isc_heap_create(isc_mem_t *, isc_heapcompare_t, - isc_heapindex_t, unsigned int, isc_heap_t **); -void isc_heap_destroy(isc_heap_t **); -isc_result_t isc_heap_insert(isc_heap_t *, void *); -void isc_heap_delete(isc_heap_t *, unsigned int); -void isc_heap_increased(isc_heap_t *, unsigned int); -void isc_heap_decreased(isc_heap_t *, unsigned int); -void * isc_heap_element(isc_heap_t *, unsigned int); -void isc_heap_foreach(isc_heap_t *, isc_heapaction_t, void *); +isc_result_t +isc_heap_create(isc_mem_t *mctx, isc_heapcompare_t compare, + isc_heapindex_t index, unsigned int size_increment, + isc_heap_t **heapp); +/*!< + * \brief Create a new heap. The heap is implemented using a space-efficient + * storage method. When the heap elements are deleted space is not freed + * but will be reused when new elements are inserted. + * + * Requires: + *\li "mctx" is valid. + *\li "compare" is a function which takes two void * arguments and + * returns ISC_TRUE if the first argument has a higher priority than + * the second, and ISC_FALSE otherwise. + *\li "index" is a function which takes a void *, and an unsigned int + * argument. This function will be called whenever an element's + * index value changes, so it may continue to delete itself from the + * heap. This option may be NULL if this functionality is unneeded. + *\li "size_increment" is a hint about how large the heap should grow + * when resizing is needed. If this is 0, a default size will be + * used, which is currently 1024, allowing space for an additional 1024 + * heap elements to be inserted before adding more space. + *\li "heapp" is not NULL, and "*heap" is NULL. + * + * Returns: + *\li ISC_R_SUCCESS - success + *\li ISC_R_NOMEMORY - insufficient memory + */ + +void +isc_heap_destroy(isc_heap_t **heapp); +/*!< + * \brief Destroys a heap. + * + * Requires: + *\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t. + */ + +isc_result_t +isc_heap_insert(isc_heap_t *heap, void *elt); +/*!< + * \brief Inserts a new element into a heap. + * + * Requires: + *\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t. + */ + +void +isc_heap_delete(isc_heap_t *heap, unsigned int index); +/*!< + * \brief Deletes an element from a heap, by element index. + * + * Requires: + *\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t. + *\li "index" is a valid element index, as provided by the "index" callback + * provided during heap creation. + */ + +void +isc_heap_increased(isc_heap_t *heap, unsigned int index); +/*!< + * \brief Indicates to the heap that an element's priority has increased. + * This function MUST be called whenever an element has increased in priority. + * + * Requires: + *\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t. + *\li "index" is a valid element index, as provided by the "index" callback + * provided during heap creation. + */ + +void +isc_heap_decreased(isc_heap_t *heap, unsigned int index); +/*!< + * \brief Indicates to the heap that an element's priority has decreased. + * This function MUST be called whenever an element has decreased in priority. + * + * Requires: + *\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t. + *\li "index" is a valid element index, as provided by the "index" callback + * provided during heap creation. + */ + +void * +isc_heap_element(isc_heap_t *heap, unsigned int index); +/*!< + * \brief Returns the element for a specific element index. + * + * Requires: + *\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t. + *\li "index" is a valid element index, as provided by the "index" callback + * provided during heap creation. + * + * Returns: + *\li A pointer to the element for the element index. + */ + +void +isc_heap_foreach(isc_heap_t *heap, isc_heapaction_t action, void *uap); +/*!< + * \brief Iterate over the heap, calling an action for each element. The + * order of iteration is not sorted. + * + * Requires: + *\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t. + *\li "action" is not NULL, and is a function which takes two arguments. + * The first is a void *, representing the element, and the second is + * "uap" as provided to isc_heap_foreach. + *\li "uap" is a caller-provided argument, and may be NULL. + * + * Note: + *\li The heap structure CANNOT be modified during this iteration. The only + * safe function to call while iterating the heap is isc_heap_element(). + */ ISC_LANG_ENDDECLS diff --git a/contrib/bind9/lib/isc/include/isc/list.h b/contrib/bind9/lib/isc/include/isc/list.h index 962336ada8a0..5fe82e3fe51d 100644 --- a/contrib/bind9/lib/isc/include/isc/list.h +++ b/contrib/bind9/lib/isc/include/isc/list.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1997-2002 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: list.h,v 1.18.2.2.8.1 2004/03/06 08:14:43 marka Exp $ */ +/* $Id: list.h,v 1.18.2.2.8.3 2006/06/06 00:11:40 marka Exp $ */ #ifndef ISC_LIST_H #define ISC_LIST_H 1 @@ -90,12 +90,16 @@ do { \ if ((elt)->link.next != NULL) \ (elt)->link.next->link.prev = (elt)->link.prev; \ - else \ + else { \ + ISC_INSIST((list).tail == (elt)); \ (list).tail = (elt)->link.prev; \ + } \ if ((elt)->link.prev != NULL) \ (elt)->link.prev->link.next = (elt)->link.next; \ - else \ + else { \ + ISC_INSIST((list).head == (elt)); \ (list).head = (elt)->link.next; \ + } \ (elt)->link.prev = (type *)(-1); \ (elt)->link.next = (type *)(-1); \ } while (0) diff --git a/contrib/bind9/lib/isc/include/isc/sockaddr.h b/contrib/bind9/lib/isc/include/isc/sockaddr.h index 1ffbca640fc1..88e45940ca0e 100644 --- a/contrib/bind9/lib/isc/include/isc/sockaddr.h +++ b/contrib/bind9/lib/isc/include/isc/sockaddr.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sockaddr.h,v 1.35.12.8 2005/07/29 00:13:10 marka Exp $ */ +/* $Id: sockaddr.h,v 1.35.12.10 2006/03/02 00:37:20 marka Exp $ */ #ifndef ISC_SOCKADDR_H #define ISC_SOCKADDR_H 1 @@ -141,7 +141,7 @@ isc_sockaddr_setport(isc_sockaddr_t *sockaddr, in_port_t port); */ in_port_t -isc_sockaddr_getport(isc_sockaddr_t *sockaddr); +isc_sockaddr_getport(const isc_sockaddr_t *sockaddr); /* * Get the port stored in 'sockaddr'. */ @@ -168,25 +168,25 @@ isc_sockaddr_format(const isc_sockaddr_t *sa, char *array, unsigned int size); */ isc_boolean_t -isc_sockaddr_ismulticast(isc_sockaddr_t *sa); +isc_sockaddr_ismulticast(const isc_sockaddr_t *sa); /* * Returns ISC_TRUE if the address is a multicast address. */ isc_boolean_t -isc_sockaddr_isexperimental(isc_sockaddr_t *sa); +isc_sockaddr_isexperimental(const 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); +isc_sockaddr_islinklocal(const 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); +isc_sockaddr_issitelocal(const isc_sockaddr_t *sa); /* * Returns ISC_TRUE if the address is a sitelocal address. */ diff --git a/contrib/bind9/lib/isc/include/isc/symtab.h b/contrib/bind9/lib/isc/include/isc/symtab.h index d8dbd2107ec5..b22fe8159663 100644 --- a/contrib/bind9/lib/isc/include/isc/symtab.h +++ b/contrib/bind9/lib/isc/include/isc/symtab.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1996-2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: symtab.h,v 1.16.206.1 2004/03/06 08:14:49 marka Exp $ */ +/* $Id: symtab.h,v 1.16.206.3 2006/03/02 00:37:20 marka Exp $ */ #ifndef ISC_SYMTAB_H #define ISC_SYMTAB_H 1 @@ -88,6 +88,7 @@ typedef union isc_symvalue { void * as_pointer; + const void * as_cpointer; int as_integer; unsigned int as_uinteger; } isc_symvalue_t; diff --git a/contrib/bind9/lib/isc/lex.c b/contrib/bind9/lib/isc/lex.c index bb832dd0b41c..3511d6bd0e70 100644 --- a/contrib/bind9/lib/isc/lex.c +++ b/contrib/bind9/lib/isc/lex.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: lex.c,v 1.66.2.6.2.8 2004/08/28 06:25:21 marka Exp $ */ +/* $Id: lex.c,v 1.66.2.6.2.10 2006/01/04 23:50:21 marka Exp $ */ #include <config.h> @@ -372,9 +372,6 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { source = HEAD(lex->sources); REQUIRE(tokenp != NULL); - lex->saved_paren_count = lex->paren_count; - source->saved_line = source->line; - if (source == NULL) { if ((options & ISC_LEXOPT_NOMORE) != 0) { tokenp->type = isc_tokentype_nomore; @@ -386,6 +383,9 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { if (source->result != ISC_R_SUCCESS) return (source->result); + lex->saved_paren_count = lex->paren_count; + source->saved_line = source->line; + if (isc_buffer_remaininglength(source->pushback) == 0 && source->at_eof) { @@ -633,9 +633,13 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { remaining--; break; case lexstate_string: - if ((!escaped && - (c == ' ' || c == '\t' || lex->specials[c])) || - c == '\r' || c == '\n' || c == EOF) { + /* + * EOF needs to be checked before lex->specials[c] + * as lex->specials[EOF] is not a good idea. + */ + if (c == '\r' || c == '\n' || c == EOF || + (!escaped && + (c == ' ' || c == '\t' || lex->specials[c]))) { pushback(source, c); if (source->result != ISC_R_SUCCESS) { result = source->result; diff --git a/contrib/bind9/lib/isc/log.c b/contrib/bind9/lib/isc/log.c index 247b25339d26..511573bcc30b 100644 --- a/contrib/bind9/lib/isc/log.c +++ b/contrib/bind9/lib/isc/log.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: log.c,v 1.70.2.8.2.12 2004/06/11 00:35:38 marka Exp $ */ +/* $Id: log.c,v 1.70.2.8.2.14 2006/03/02 00:37:20 marka Exp $ */ /* Principal Authors: DCL */ @@ -1728,8 +1728,9 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, syslog_level = syslog_map[-level]; (void)syslog(FACILITY(channel) | syslog_level, - "%s%s%s%s%s%s%s%s%s", + "%s%s%s%s%s%s%s%s%s%s", printtime ? time_string : "", + printtime ? " " : "", printtag ? lcfg->tag : "", printtag ? ": " : "", printcategory ? category->name : "", diff --git a/contrib/bind9/lib/isc/netscope.c b/contrib/bind9/lib/isc/netscope.c index 843c46df9e2b..8df448399c5d 100644 --- a/contrib/bind9/lib/isc/netscope.c +++ b/contrib/bind9/lib/isc/netscope.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2002 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -17,9 +17,11 @@ #if defined(LIBC_SCCS) && !defined(lint) static char rcsid[] = - "$Id: netscope.c,v 1.5.142.7 2004/03/12 10:31:26 marka Exp $"; + "$Id: netscope.c,v 1.5.142.9 2006/08/25 05:25:50 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <config.h> + #include <isc/string.h> #include <isc/net.h> #include <isc/netscope.h> diff --git a/contrib/bind9/lib/isc/nothreads/condition.c b/contrib/bind9/lib/isc/nothreads/condition.c index 0bc6196a1a73..395d52f7d307 100644 --- a/contrib/bind9/lib/isc/nothreads/condition.c +++ b/contrib/bind9/lib/isc/nothreads/condition.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: condition.c,v 1.4.12.3 2004/03/08 09:04:54 marka Exp $ */ +/* $Id: condition.c,v 1.4.12.5 2006/08/25 05:25:50 marka Exp $ */ + +#include <config.h> #include <isc/util.h> diff --git a/contrib/bind9/lib/isc/nothreads/mutex.c b/contrib/bind9/lib/isc/nothreads/mutex.c index cc7572a69738..a707947fe9b7 100644 --- a/contrib/bind9/lib/isc/nothreads/mutex.c +++ b/contrib/bind9/lib/isc/nothreads/mutex.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mutex.c,v 1.4.12.3 2004/03/08 09:04:54 marka Exp $ */ +/* $Id: mutex.c,v 1.4.12.5 2006/08/25 05:25:50 marka Exp $ */ + +#include <config.h> #include <isc/util.h> diff --git a/contrib/bind9/lib/isc/print.c b/contrib/bind9/lib/isc/print.c index 6542fe4f1909..ee50b29e5d6d 100644 --- a/contrib/bind9/lib/isc/print.c +++ b/contrib/bind9/lib/isc/print.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,12 +15,15 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: print.c,v 1.22.2.3.2.3 2004/03/06 08:14:33 marka Exp $ */ +/* $Id: print.c,v 1.22.2.3.2.4 2006/04/17 18:27:20 explorer Exp $ */ + +/*! \file */ #include <config.h> #include <ctype.h> -#include <stdio.h> /* for sprintf */ +#include <stdio.h> /* for sprintf() */ +#include <string.h> /* for strlen() */ #define ISC__PRINT_SOURCE /* Used to get the isc_print_* prototypes. */ @@ -41,7 +44,7 @@ isc_print_sprintf(char *str, const char *format, ...) { return (strlen(str)); } -/* +/*! * Return length of string that would have been written if not truncated. */ @@ -57,7 +60,7 @@ isc_print_snprintf(char *str, size_t size, const char *format, ...) { } -/* +/*! * Return length of string that would have been written if not truncated. */ diff --git a/contrib/bind9/lib/isc/sockaddr.c b/contrib/bind9/lib/isc/sockaddr.c index 4c47e4e06bce..a40f0c9ccf99 100644 --- a/contrib/bind9/lib/isc/sockaddr.c +++ b/contrib/bind9/lib/isc/sockaddr.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sockaddr.c,v 1.48.2.1.2.10 2004/05/15 03:46:12 jinmei Exp $ */ +/* $Id: sockaddr.c,v 1.48.2.1.2.12 2006/03/02 00:37:20 marka Exp $ */ #include <config.h> @@ -400,7 +400,7 @@ isc_sockaddr_setport(isc_sockaddr_t *sockaddr, in_port_t port) { } in_port_t -isc_sockaddr_getport(isc_sockaddr_t *sockaddr) { +isc_sockaddr_getport(const isc_sockaddr_t *sockaddr) { in_port_t port = 0; switch (sockaddr->type.sa.sa_family) { @@ -422,7 +422,7 @@ isc_sockaddr_getport(isc_sockaddr_t *sockaddr) { } isc_boolean_t -isc_sockaddr_ismulticast(isc_sockaddr_t *sockaddr) { +isc_sockaddr_ismulticast(const isc_sockaddr_t *sockaddr) { isc_netaddr_t netaddr; isc_netaddr_fromsockaddr(&netaddr, sockaddr); @@ -430,7 +430,7 @@ isc_sockaddr_ismulticast(isc_sockaddr_t *sockaddr) { } isc_boolean_t -isc_sockaddr_isexperimental(isc_sockaddr_t *sockaddr) { +isc_sockaddr_isexperimental(const isc_sockaddr_t *sockaddr) { isc_netaddr_t netaddr; if (sockaddr->type.sa.sa_family == AF_INET) { @@ -441,7 +441,7 @@ isc_sockaddr_isexperimental(isc_sockaddr_t *sockaddr) { } isc_boolean_t -isc_sockaddr_issitelocal(isc_sockaddr_t *sockaddr) { +isc_sockaddr_issitelocal(const isc_sockaddr_t *sockaddr) { isc_netaddr_t netaddr; if (sockaddr->type.sa.sa_family == AF_INET6) { @@ -452,7 +452,7 @@ isc_sockaddr_issitelocal(isc_sockaddr_t *sockaddr) { } isc_boolean_t -isc_sockaddr_islinklocal(isc_sockaddr_t *sockaddr) { +isc_sockaddr_islinklocal(const isc_sockaddr_t *sockaddr) { isc_netaddr_t netaddr; if (sockaddr->type.sa.sa_family == AF_INET6) { diff --git a/contrib/bind9/lib/isc/taskpool.c b/contrib/bind9/lib/isc/taskpool.c index 0b400bf722f6..a3931a9fb90c 100644 --- a/contrib/bind9/lib/isc/taskpool.c +++ b/contrib/bind9/lib/isc/taskpool.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: taskpool.c,v 1.10.12.3 2004/03/08 09:04:50 marka Exp $ */ +/* $Id: taskpool.c,v 1.10.12.5 2006/01/04 23:50:21 marka Exp $ */ #include <config.h> @@ -52,6 +52,10 @@ isc_taskpool_create(isc_taskmgr_t *tmgr, isc_mem_t *mctx, pool->mctx = mctx; pool->ntasks = ntasks; pool->tasks = isc_mem_get(mctx, ntasks * sizeof(isc_task_t *)); + if (pool->tasks == NULL) { + isc_mem_put(mctx, pool, sizeof(*pool)); + return (ISC_R_NOMEMORY); + } for (i = 0; i < ntasks; i++) pool->tasks[i] = NULL; for (i = 0; i < ntasks; i++) { diff --git a/contrib/bind9/lib/isc/timer.c b/contrib/bind9/lib/isc/timer.c index 5426079397e0..6a6acf6bb081 100644 --- a/contrib/bind9/lib/isc/timer.c +++ b/contrib/bind9/lib/isc/timer.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: timer.c,v 1.64.12.11 2005/10/27 00:27:29 marka Exp $ */ +/* $Id: timer.c,v 1.64.12.13 2006/01/04 23:50:21 marka Exp $ */ #include <config.h> @@ -212,9 +212,10 @@ schedule(isc_timer_t *timer, isc_time_t *now, isc_boolean_t signal_ok) { isc_time_t then; isc_interval_set(&fifteen, 15, 0); - isc_time_add(&manager->due, &fifteen, &then); + result = isc_time_add(&manager->due, &fifteen, &then); - if (isc_time_compare(&then, now) < 0) { + if (result == ISC_R_SUCCESS && + isc_time_compare(&then, now) < 0) { SIGNAL(&manager->wakeup); signal_ok = ISC_FALSE; isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, @@ -347,8 +348,10 @@ isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type, if (type == isc_timertype_once && !isc_interval_iszero(interval)) { result = isc_time_add(&now, interval, &timer->idle); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { + isc_mem_put(manager->mctx, timer, sizeof(*timer)); return (result); + } } else isc_time_settoepoch(&timer->idle); diff --git a/contrib/bind9/lib/isc/unix/entropy.c b/contrib/bind9/lib/isc/unix/entropy.c index 50506634e4cd..d52849aa35b8 100644 --- a/contrib/bind9/lib/isc/unix/entropy.c +++ b/contrib/bind9/lib/isc/unix/entropy.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: entropy.c,v 1.60.2.3.8.11 2005/07/12 05:47:43 marka Exp $ */ +/* $Id: entropy.c,v 1.60.2.3.8.14 2006/03/02 23:29:17 marka Exp $ */ /* * This is the system depenedent part of the ISC entropy API. @@ -127,7 +127,7 @@ get_from_usocketsource(isc_entropysource_t *source, isc_uint32_t desired) { switch ( source->sources.usocket.status ) { case isc_usocketsource_ndesired: buf[0] = ndesired; - if ((n = send(fd, buf, 1, 0)) < 0) { + if ((n = sendto(fd, buf, 1, 0, NULL, 0)) < 0) { if (errno == EWOULDBLOCK || errno == EINTR || errno == ECONNRESET) goto out; @@ -142,7 +142,7 @@ get_from_usocketsource(isc_entropysource_t *source, isc_uint32_t desired) { case isc_usocketsource_connected: buf[0] = 1; buf[1] = ndesired; - if ((n = send(fd, buf, 2, 0)) < 0) { + if ((n = sendto(fd, buf, 2, 0, NULL, 0)) < 0) { if (errno == EWOULDBLOCK || errno == EINTR || errno == ECONNRESET) goto out; @@ -159,12 +159,12 @@ get_from_usocketsource(isc_entropysource_t *source, isc_uint32_t desired) { /*FALLTHROUGH*/ case isc_usocketsource_wrote: - if (recv(fd, buf, 1, 0) != 1) { + if (recvfrom(fd, buf, 1, 0, NULL, NULL) != 1) { if (errno == EAGAIN) { /* * The problem of EAGAIN (try again * later) is a major issue on HP-UX. - * Solaris actually tries the recv + * Solaris actually tries the recvfrom * call again, while HP-UX just dies. * This code is an attempt to let the * entropy pool fill back up (at least @@ -503,7 +503,7 @@ isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname) { if (S_ISSOCK(_stat.st_mode)) is_usocket = ISC_TRUE; #endif -#if defined(S_ISFIFO) +#if defined(S_ISFIFO) && defined(sun) if (S_ISFIFO(_stat.st_mode)) is_usocket = ISC_TRUE; #endif diff --git a/contrib/bind9/lib/isc/unix/fsaccess.c b/contrib/bind9/lib/isc/unix/fsaccess.c index 5fa4fb47495a..3745ca227f25 100644 --- a/contrib/bind9/lib/isc/unix/fsaccess.c +++ b/contrib/bind9/lib/isc/unix/fsaccess.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: fsaccess.c,v 1.6.206.1 2004/03/06 08:14:59 marka Exp $ */ +/* $Id: fsaccess.c,v 1.6.206.3 2006/08/25 05:25:50 marka Exp $ */ + +#include <config.h> #include <sys/types.h> #include <sys/stat.h> diff --git a/contrib/bind9/lib/isc/unix/ifiter_ioctl.c b/contrib/bind9/lib/isc/unix/ifiter_ioctl.c index 0b01b96f942c..68a13651bc86 100644 --- a/contrib/bind9/lib/isc/unix/ifiter_ioctl.c +++ b/contrib/bind9/lib/isc/unix/ifiter_ioctl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ifiter_ioctl.c,v 1.19.2.5.2.17 2005/10/14 02:13:07 marka Exp $ */ +/* $Id: ifiter_ioctl.c,v 1.19.2.5.2.19 2006/02/03 23:51:37 marka Exp $ */ /* * Obtain the list of network interfaces using the SIOCGLIFCONF ioctl. @@ -529,7 +529,8 @@ internal_current4(isc_interfaceiter_t *iter) { #endif REQUIRE(VALID_IFITER(iter)); - REQUIRE (iter->pos < (unsigned int) iter->ifc.ifc_len); + REQUIRE(iter->ifc.ifc_len == 0 || + iter->pos < (unsigned int) iter->ifc.ifc_len); #ifdef __linux result = linux_if_inet6_current(iter); @@ -538,6 +539,9 @@ internal_current4(isc_interfaceiter_t *iter) { iter->first = ISC_TRUE; #endif + if (iter->ifc.ifc_len == 0) + return (ISC_R_NOMORE); + ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos); memset(&ifreq, 0, sizeof(ifreq)); diff --git a/contrib/bind9/lib/isc/unix/ipv6.c b/contrib/bind9/lib/isc/unix/ipv6.c index 25e0c57b09fc..f11262f59927 100644 --- a/contrib/bind9/lib/isc/unix/ipv6.c +++ b/contrib/bind9/lib/isc/unix/ipv6.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ipv6.c,v 1.7.206.1 2004/03/06 08:15:00 marka Exp $ */ +/* $Id: ipv6.c,v 1.7.206.3 2006/08/25 05:25:50 marka Exp $ */ + +#include <config.h> #include <isc/ipv6.h> diff --git a/contrib/bind9/lib/isc/unix/socket.c b/contrib/bind9/lib/isc/unix/socket.c index 595990f995c5..f95e3c8f75d4 100644 --- a/contrib/bind9/lib/isc/unix/socket.c +++ b/contrib/bind9/lib/isc/unix/socket.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.207.2.19.2.22 2005/11/03 23:08:42 marka Exp $ */ +/* $Id: socket.c,v 1.207.2.19.2.26 2006/05/19 02:53:36 marka Exp $ */ #include <config.h> @@ -109,7 +109,7 @@ typedef isc_event_t intev_t; * to collect the destination address and interface so the client can * set them on outgoing packets. */ -#ifdef ISC_PLATFORM_HAVEIPV6 +#ifdef ISC_PLATFORM_HAVEIN6PKTINFO #ifndef USE_CMSG #define USE_CMSG 1 #endif @@ -747,8 +747,26 @@ build_msghdr_recv(isc_socket_t *sock, isc_socketevent_t *dev, if (sock->type == isc_sockettype_udp) { memset(&dev->address, 0, sizeof(dev->address)); +#ifdef BROKEN_RECVMSG + if (sock->pf == AF_INET) { + msg->msg_name = (void *)&dev->address.type.sin; + msg->msg_namelen = sizeof(dev->address.type.sin6); + } else if (sock->pf == AF_INET6) { + msg->msg_name = (void *)&dev->address.type.sin6; + msg->msg_namelen = sizeof(dev->address.type.sin6); +#ifdef ISC_PLATFORM_HAVESYSUNH + } else if (sock->pf == AF_UNIX) { + msg->msg_name = (void *)&dev->address.type.sunix; + msg->msg_namelen = sizeof(dev->address.type.sunix); +#endif + } else { + msg->msg_name = (void *)&dev->address.type.sa; + msg->msg_namelen = sizeof(dev->address.type); + } +#else msg->msg_name = (void *)&dev->address.type.sa; msg->msg_namelen = sizeof(dev->address.type); +#endif #ifdef ISC_NET_RECVOVERFLOW /* If needed, steal one iovec for overflow detection. */ maxiov--; @@ -921,6 +939,10 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) { cc = recvmsg(sock->fd, &msghdr, 0); recv_errno = errno; +#if defined(ISC_SOCKET_DEBUG) + dump_msg(&msghdr); +#endif + if (cc < 0) { if (SOFT_ERROR(recv_errno)) return (DOIO_SOFT); @@ -2681,8 +2703,8 @@ socket_send(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, dev->attributes |= ISC_SOCKEVENTATTR_PKTINFO; dev->pktinfo = *pktinfo; - if (!isc_sockaddr_issitelocal(address) && - !isc_sockaddr_islinklocal(address)) { + if (!isc_sockaddr_issitelocal(&dev->address) && + !isc_sockaddr_islinklocal(&dev->address)) { socket_log(sock, NULL, TRACE, isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_PKTINFOPROVIDED, "pktinfo structure provided, ifindex %u " |