/* lists type of subnet */
-splay_tree_t *subnet_tree;
+splay_tree_t subnet_tree = {
+ .compare = (splay_compare_t) subnet_compare,
+ .delete = (splay_action_t) free_subnet,
+};
/* Subnet lookup cache */
/* Initialising trees */
void init_subnets(void) {
- subnet_tree = splay_alloc_tree((splay_compare_t) subnet_compare, (splay_action_t) free_subnet);
-
ipv4_cache = hash_alloc(0x100, sizeof(ipv4_t));
ipv6_cache = hash_alloc(0x100, sizeof(ipv6_t));
mac_cache = hash_alloc(0x100, sizeof(mac_t));
}
void exit_subnets(void) {
- splay_delete_tree(subnet_tree);
+ splay_empty_tree(&subnet_tree);
hash_free(ipv4_cache);
hash_free(ipv6_cache);
void subnet_add(node_t *n, subnet_t *subnet) {
subnet->owner = n;
- splay_insert(subnet_tree, subnet);
+ splay_insert(&subnet_tree, subnet);
if(n) {
splay_insert(n->subnet_tree, subnet);
splay_delete(n->subnet_tree, subnet);
}
- splay_delete(subnet_tree, subnet);
+ splay_delete(&subnet_tree, subnet);
subnet_cache_flush();
}
// Search all subnets for a matching one
- for splay_each(subnet_t, p, owner ? owner->subnet_tree : subnet_tree) {
+ for splay_each(subnet_t, p, owner ? owner->subnet_tree : &subnet_tree) {
if(!p || p->type != SUBNET_MAC) {
continue;
}
// Search all subnets for a matching one
- for splay_each(subnet_t, p, subnet_tree) {
+ for splay_each(subnet_t, p, &subnet_tree) {
if(!p || p->type != SUBNET_IPV4) {
continue;
}
// Search all subnets for a matching one
- for splay_each(subnet_t, p, subnet_tree) {
+ for splay_each(subnet_t, p, &subnet_tree) {
if(!p || p->type != SUBNET_IPV6) {
continue;
}
}
bool dump_subnets(connection_t *c) {
- for splay_each(subnet_t, subnet, subnet_tree) {
+ for splay_each(subnet_t, subnet, &subnet_tree) {
char netstr[MAXNETSTR];
if(!net2str(netstr, sizeof(netstr), subnet)) {