prefix->ref_count--;
if (prefix->ref_count <= 0) {
- freeprefix(prefix);
- return;
+ freeprefix(prefix);
+ return;
}
}
}
new_node = patricia_new_node(patricia, prefix->bitlen, patricia_ref_prefix (prefix));
-
if (node->bit == differ_bit) {
new_node->parent = node;
if (node->bit < patricia->maxbits &&
if (bitlen == differ_bit) {
if (bitlen < patricia->maxbits &&
- (is_bit_set(addr,bitlen))) {
+ (is_bit_set(test_addr,bitlen))) {
new_node->r = node;
}
else {
node->parent->l = new_node;
}
node->parent = new_node;
+ new_node->usercount = node->usercount;
}
else {
glue = patricia_new_node(patricia, differ_bit, NULL);
glue->parent = node->parent;
-
if (differ_bit < patricia->maxbits &&
(is_bit_set(addr, differ_bit))) {
glue->r = new_node;
node->parent->l = glue;
}
node->parent = glue;
+ glue->usercount = node->usercount;
}
+
return (new_node);
}
return new_node;
}
+void node_increment_usercount( patricia_node_t *node) {
+ while(node) {
+ node->usercount++;
+ node=node->parent;
+ }
+}
+
+void node_decrement_usercount( patricia_node_t *node) {
+ while(node) {
+ node->usercount--;
+ node=node->parent;
+ }
+}
+
+int is_normalized_ipmask( struct irc_in_addr *sin, unsigned char bitlen ) {
+ u_char *addr = (u_char *)sin;
+
+ while (bitlen < PATRICIA_MAXBITS) {
+ if (is_bit_set(addr,bitlen))
+ return 0;
+ bitlen++;
+ }
+ return 1;
+}