8 #include "interface-ip.h"
14 addr_cmp(const void *k1
, const void *k2
, void *ptr
)
16 return memcmp(k1
, k2
, sizeof(struct device_addr
) -
17 offsetof(struct device_addr
, mask
));
21 route_cmp(const void *k1
, const void *k2
, void *ptr
)
23 return memcmp(k1
, k2
, sizeof(struct device_route
) -
24 offsetof(struct device_route
, mask
));
28 interface_update_proto_addr(struct vlist_tree
*tree
,
29 struct vlist_node
*node_new
,
30 struct vlist_node
*node_old
)
32 struct interface
*iface
;
34 struct device_addr
*addr
;
36 iface
= container_of(tree
, struct interface
, proto_addr
);
37 dev
= iface
->l3_dev
->dev
;
40 addr
= container_of(node_old
, struct device_addr
, node
);
41 if (!(addr
->flags
& DEVADDR_EXTERNAL
))
42 system_del_address(dev
, addr
);
47 addr
= container_of(node_new
, struct device_addr
, node
);
48 if (!(addr
->flags
& DEVADDR_EXTERNAL
))
49 system_add_address(dev
, addr
);
54 interface_update_proto_route(struct vlist_tree
*tree
,
55 struct vlist_node
*node_new
,
56 struct vlist_node
*node_old
)
58 struct interface
*iface
;
60 struct device_route
*route
;
62 iface
= container_of(tree
, struct interface
, proto_route
);
63 dev
= iface
->l3_dev
->dev
;
66 route
= container_of(node_old
, struct device_route
, node
);
67 if (!(route
->flags
& DEVADDR_EXTERNAL
))
68 system_del_route(dev
, route
);
73 route
= container_of(node_new
, struct device_route
, node
);
74 if (!(route
->flags
& DEVADDR_EXTERNAL
))
75 system_add_route(dev
, route
);
80 interface_ip_init(struct interface
*iface
)
82 vlist_init(&iface
->proto_route
, route_cmp
, interface_update_proto_route
,
83 struct device_route
, node
, mask
);
84 vlist_init(&iface
->proto_addr
, addr_cmp
, interface_update_proto_addr
,
85 struct device_addr
, node
, mask
);