radix.c revision df925e6c66d45d960fbac0383169763967d2111c
/*
* Copyright (C) 2007-2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
*
* 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$ */
/*
* This source was adapted from MRT's RCS Ids:
* Id: radix.c,v 1.10.2.1 1999/11/29 05:16:24 masaki Exp
* Id: prefix.c,v 1.37.2.9 2000/03/10 02:53:19 labovit Exp
*/
#include <config.h>
static isc_result_t
static void
static isc_result_t
static int
static void
static isc_result_t
int bitlen)
{
return (ISC_R_NOTIMPLEMENTED);
return (ISC_R_NOMEMORY);
} else {
/* AF_UNSPEC is "any" or "none"--treat it as AF_INET */
}
return (ISC_R_SUCCESS);
}
static void
int refs;
return;
if (refs <= 0) {
sizeof(isc_prefix_t));
}
}
static isc_result_t
/*
* If this prefix is a static allocation, copy it into new memory.
* (Note, the refcount still has to be destroyed by the calling
* routine.)
*/
return (ret);
}
return (ISC_R_SUCCESS);
}
static int
/* Mask length of zero matches everything */
if (mask == 0)
return (1);
int n = mask / 8;
if ((mask % 8) == 0 ||
return (1);
}
return (0);
}
return (ISC_R_NOMEMORY);
radix->num_active_node = 0;
radix->num_added_node = 0;
return (ISC_R_SUCCESS);
}
/*
* if func is supplied, it will be called as func(node->data)
* before deleting the node
*/
static void
isc_radix_node_t *l = Xrn->l;
isc_radix_node_t *r = Xrn->r;
} else {
}
radix->num_active_node--;
if (l != NULL) {
if (r != NULL) {
*Xsp++ = r;
}
Xrn = l;
} else if (r != NULL) {
Xrn = r;
} else {
}
}
}
}
void
}
/*
* func will be called as func(node->prefix, node->data)
*/
void
}
{
int tfamily = -1;
int cnt = 0;
return (ISC_R_NOTFOUND);
}
else
break;
}
while (cnt-- > 0) {
}
}
}
return (ISC_R_NOTFOUND);
} else {
return (ISC_R_SUCCESS);
}
}
{
isc_uint32_t i, j, r;
return (ISC_R_NOMEMORY);
if (result != ISC_R_SUCCESS) {
sizeof(isc_radix_node_t));
return (result);
}
/*
* If source is non-NULL, then we're merging in a
* node from an existing radix tree. To keep
* the node_num values consistent, the calling
* function will add the total number of nodes
* added to num_added_node at the end of
* the merge operation--we don't do it here.
*/
} else {
/* "any" or "none" */
++radix->num_added_node;
} else {
++radix->num_added_node;
}
}
radix->num_active_node++;
return (ISC_R_SUCCESS);
}
{
break;
} else {
break;
}
}
/* Find the first bit different. */
differ_bit = 0;
for (i = 0; i*8 < check_bit; i++) {
continue;
}
/* I know the better way, but for now. */
for (j = 0; j < 8; j++) {
if (BIT_TEST (r, (0x80 >> j)))
break;
}
/* Must be found. */
INSIST(j < 8);
differ_bit = i * 8 + j;
break;
}
if (differ_bit > check_bit)
}
/* Set node_num only if it hasn't been set before */
/* Merging node */
}
}
} else {
/* "any" or "none" */
}
}
} else {
= ++radix->num_added_node;
}
}
return (ISC_R_SUCCESS);
} else {
if (result != ISC_R_SUCCESS)
return (result);
}
/* Merging node */
}
}
} else {
/* "any" or "none" */
++radix->num_added_node;
} else {
++radix->num_added_node;
}
}
return (ISC_R_SUCCESS);
}
return (ISC_R_NOMEMORY);
sizeof(isc_radix_node_t));
return (ISC_R_NOMEMORY);
}
}
if (result != ISC_R_SUCCESS) {
sizeof(isc_radix_node_t));
return (result);
}
radix->num_active_node++;
/* Merging node */
} else {
/* "any" or "none" */
++radix->num_added_node;
} else {
++radix->num_added_node;
}
}
{
} else {
}
return (ISC_R_SUCCESS);
}
if (bitlen == differ_bit) {
} else {
}
} else {
}
} else {
radix->num_active_node++;
} else {
}
} else {
}
}
return (ISC_R_SUCCESS);
}
void
/*
* This might be a placeholder node -- have to check and
* make sure there is a prefix associated with it!
*/
return;
}
radix->num_active_node--;
return;
}
} else {
}
return;
/* We need to remove parent too. */
} else {
}
radix->num_active_node--;
return;
}
if (node->r) {
} else {
}
radix->num_active_node--;
return;
}
} else {
}
}
/*
Local Variables:
c-basic-offset: 4
indent-tabs-mode: t
End:
*/