8 #include "interface-ip.h"
14 addr_cmp(const void *k1, const void *k2, void *ptr)
16 const struct device_addr *a1 = k1, *a2 = k2;
18 return memcmp(&a1->mask, &a2->mask,
19 sizeof(*a1) - offsetof(struct device_addr, mask));
23 route_cmp(const void *k1, const void *k2, void *ptr)
25 const struct device_route *r1 = k1, *r2 = k2;
27 return memcmp(&r1->mask, &r2->mask,
28 sizeof(*r1) - offsetof(struct device_route, mask));
32 interface_update_proto_addr(struct vlist_tree *tree,
33 struct vlist_node *node_new,
34 struct vlist_node *node_old)
36 struct interface *iface;
38 struct device_addr *addr;
40 iface = container_of(tree, struct interface, proto_addr);
41 dev = iface->l3_dev->dev;
44 addr = container_of(node_old, struct device_addr, node);
45 if (!(addr->flags & DEVADDR_EXTERNAL))
46 system_del_address(dev, addr);
51 addr = container_of(node_new, struct device_addr, node);
52 if (!(addr->flags & DEVADDR_EXTERNAL))
53 system_add_address(dev, addr);
58 interface_update_proto_route(struct vlist_tree *tree,
59 struct vlist_node *node_new,
60 struct vlist_node *node_old)
62 struct interface *iface;
64 struct device_route *route;
66 iface = container_of(tree, struct interface, proto_route);
67 dev = iface->l3_dev->dev;
70 route = container_of(node_old, struct device_route, node);
71 if (!(route->flags & DEVADDR_EXTERNAL))
72 system_del_route(dev, route);
77 route = container_of(node_new, struct device_route, node);
78 if (!(route->flags & DEVADDR_EXTERNAL))
79 system_add_route(dev, route);
84 interface_ip_init(struct interface *iface)
86 vlist_init(&iface->proto_route, route_cmp, interface_update_proto_route,
87 struct device_route, node);
88 vlist_init(&iface->proto_addr, addr_cmp, interface_update_proto_addr,
89 struct device_addr, node);