if ((cur = tb[ROUTE_MTU]) != NULL)
route->mtu = blobmsg_get_u32(cur);
- vlist_add(&ip->route, &route->node);
+ vlist_add(&ip->route, &route->node, &route->mask);
return;
error:
ip->enabled = true;
vlist_simple_init(&ip->dns_search, struct dns_search_domain, node);
vlist_simple_init(&ip->dns_servers, struct dns_server, node);
- vlist_init(&ip->route, route_cmp, interface_update_proto_route,
- struct device_route, node, mask);
- vlist_init(&ip->addr, addr_cmp, interface_update_proto_addr,
- struct device_addr, node, mask);
+ vlist_init(&ip->route, route_cmp, interface_update_proto_route);
+ vlist_init(&ip->addr, addr_cmp, interface_update_proto_addr);
}
iface->ifname = blobmsg_data(cur);
iface->config = config;
- vlist_add(&interfaces, &iface->node);
+ vlist_add(&interfaces, &iface->node, iface->name);
}
int
static void __init
interface_init_list(void)
{
- vlist_init(&interfaces, avl_strcmp, interface_update,
- struct interface, node, name);
+ vlist_init(&interfaces, avl_strcmp, interface_update);
interfaces.keep_old = true;
interfaces.no_delete = true;
}
if (ext)
addr->flags |= DEVADDR_EXTERNAL;
- vlist_add(&iface->proto_ip.addr, &addr->node);
+ vlist_add(&iface->proto_ip.addr, &addr->node, &addr->mask);
return true;
}
route->mask = 0;
route->flags = DEVADDR_DEVICE | (v6 ? DEVADDR_INET6 : DEVADDR_INET4);
- vlist_add(&iface->proto_ip.route, &route->node);
+ vlist_add(&iface->proto_ip.route, &route->node, &route->mask);
return true;
}
}
void
-__vlist_init(struct vlist_tree *tree, avl_tree_comp cmp,
- vlist_update_cb update, int offset)
+vlist_init(struct vlist_tree *tree, avl_tree_comp cmp, vlist_update_cb update)
{
- tree->key_offset = offset;
tree->update = update;
tree->version = 1;
}
void
-vlist_add(struct vlist_tree *tree, struct vlist_node *node)
+vlist_add(struct vlist_tree *tree, struct vlist_node *node, void *key)
{
struct vlist_node *old_node = NULL;
struct avl_node *anode;
- void *key = (char *) node + tree->key_offset;
node->avl.key = key;
node->version = tree->version;
struct avl_tree avl;
vlist_update_cb update;
- int key_offset;
bool keep_old;
bool no_delete;
int version;
};
-void __vlist_init(struct vlist_tree *tree, avl_tree_comp cmp, vlist_update_cb update, int offset);
-
-#define vlist_init(tree, cmp, update, type, node, key) \
- __vlist_init(tree, cmp, update, offsetof(type, key) - offsetof(type, node))
+void vlist_init(struct vlist_tree *tree, avl_tree_comp cmp, vlist_update_cb update);
#define vlist_find(tree, name, element, node_member) \
avl_find_element(&(tree)->avl, name, element, node_member.avl)
tree->version++;
}
-void vlist_add(struct vlist_tree *tree, struct vlist_node *node);
+void vlist_add(struct vlist_tree *tree, struct vlist_node *node, void *key);
void vlist_delete(struct vlist_tree *tree, struct vlist_node *node);
void vlist_flush(struct vlist_tree *tree);
void vlist_flush_all(struct vlist_tree *tree);