version 1.2, 2011/06/07 11:49:39
|
version 1.5, 2012/07/03 08:51:05
|
Line 12 terms:
|
Line 12 terms:
|
All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 | Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
Line 151 static char *prefix_toa2x(prefix_t *prefix, char *buff
|
Line 151 static char *prefix_toa2x(prefix_t *prefix, char *buff
|
assert (prefix->bitlen <= 32); |
assert (prefix->bitlen <= 32); |
a = prefix_touchar(prefix); |
a = prefix_touchar(prefix); |
if (with_len) |
if (with_len) |
sprintf(buff, "%d.%d.%d.%d/%d", a[0], a[1], a[2], a[3], prefix->bitlen); | snprintf(buff, with_len, "%d.%d.%d.%d/%d", a[0], a[1], a[2], |
| a[3], prefix->bitlen); |
else |
else |
sprintf(buff, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]); | snprintf(buff, 16, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]); |
return buff; |
return buff; |
} |
} |
#ifdef HAVE_IPV6 |
#ifdef HAVE_IPV6 |
Line 162 static char *prefix_toa2x(prefix_t *prefix, char *buff
|
Line 163 static char *prefix_toa2x(prefix_t *prefix, char *buff
|
a = (char*) inet_ntop(AF_INET6, &prefix->add.sin6, buff, 48 /* a guess value */); |
a = (char*) inet_ntop(AF_INET6, &prefix->add.sin6, buff, 48 /* a guess value */); |
if (a && with_len) { |
if (a && with_len) { |
assert(prefix->bitlen <= 128); |
assert(prefix->bitlen <= 128); |
sprintf(buff + strlen(buff), "/%d", prefix->bitlen); | snprintf(buff + strlen(buff), with_len - strlen(buff), |
| "/%d", prefix->bitlen); |
} |
} |
return buff; |
return buff; |
} |
} |
Line 180 static prefix_t *New_Prefix2(int family, void *dest, i
|
Line 182 static prefix_t *New_Prefix2(int family, void *dest, i
|
if (family == AF_INET6) { |
if (family == AF_INET6) { |
default_bitlen = 128; |
default_bitlen = 128; |
if (!prefix) { |
if (!prefix) { |
prefix = calloc(1, sizeof(prefix6_t)); | prefix = io_calloc(1, sizeof(prefix6_t)); |
dynamic_allocated++; |
dynamic_allocated++; |
} |
} |
memcpy(&prefix->add.sin6, dest, 16); |
memcpy(&prefix->add.sin6, dest, 16); |
Line 188 static prefix_t *New_Prefix2(int family, void *dest, i
|
Line 190 static prefix_t *New_Prefix2(int family, void *dest, i
|
#endif /* HAVE_IPV6 */ |
#endif /* HAVE_IPV6 */ |
if (family == AF_INET) { |
if (family == AF_INET) { |
if (!prefix) { |
if (!prefix) { |
prefix = calloc(1, sizeof(prefix4_t)); | prefix = io_calloc(1, sizeof(prefix4_t)); |
dynamic_allocated++; |
dynamic_allocated++; |
} |
} |
memcpy(&prefix->add.sin, dest, 4); |
memcpy(&prefix->add.sin, dest, 4); |
Line 311 inline patricia_tree_t *New_Patricia(int maxbits)
|
Line 313 inline patricia_tree_t *New_Patricia(int maxbits)
|
{ |
{ |
patricia_tree_t *patricia; |
patricia_tree_t *patricia; |
|
|
patricia = calloc(1, sizeof *patricia); | patricia = io_calloc(1, sizeof *patricia); |
|
|
patricia->maxbits = maxbits; |
patricia->maxbits = maxbits; |
patricia->head = NULL; |
patricia->head = NULL; |
Line 565 inline patricia_node_t *patricia_lookup(patricia_tree_
|
Line 567 inline patricia_node_t *patricia_lookup(patricia_tree_
|
assert(prefix->bitlen <= patricia->maxbits); |
assert(prefix->bitlen <= patricia->maxbits); |
|
|
if (!patricia->head) { |
if (!patricia->head) { |
node = calloc(1, sizeof *node); | node = io_calloc(1, sizeof *node); |
node->bit = prefix->bitlen; |
node->bit = prefix->bitlen; |
node->prefix = Ref_Prefix(prefix); |
node->prefix = Ref_Prefix(prefix); |
node->parent = NULL; |
node->parent = NULL; |
Line 675 inline patricia_node_t *patricia_lookup(patricia_tree_
|
Line 677 inline patricia_node_t *patricia_lookup(patricia_tree_
|
return node; |
return node; |
} |
} |
|
|
new_node = calloc(1, sizeof *new_node); | new_node = io_calloc(1, sizeof *new_node); |
new_node->bit = prefix->bitlen; |
new_node->bit = prefix->bitlen; |
new_node->prefix = Ref_Prefix (prefix); |
new_node->prefix = Ref_Prefix (prefix); |
new_node->parent = NULL; |
new_node->parent = NULL; |
Line 721 inline patricia_node_t *patricia_lookup(patricia_tree_
|
Line 723 inline patricia_node_t *patricia_lookup(patricia_tree_
|
prefix_toa(prefix), prefix->bitlen); |
prefix_toa(prefix), prefix->bitlen); |
#endif /* PATRICIA_DEBUG */ |
#endif /* PATRICIA_DEBUG */ |
} else { |
} else { |
glue = calloc(1, sizeof *glue); | glue = io_calloc(1, sizeof *glue); |
glue->bit = differ_bit; |
glue->bit = differ_bit; |
glue->prefix = NULL; |
glue->prefix = NULL; |
glue->parent = node->parent; |
glue->parent = node->parent; |