static void
interface_event(struct interface *iface, enum interface_event ev)
{
+ struct interface_user *dep, *tmp;
+
+ list_for_each_entry_safe(dep, tmp, &iface->users, list)
+ dep->cb(dep, IFEV_UP);
+
interface_queue_event(iface, ev);
}
__interface_set_down(iface, true);
}
+void
+interface_add_user(struct interface_user *dep, struct interface *iface)
+{
+ dep->iface = iface;
+ list_add(&dep->list, &iface->users);
+ if (iface->state == IFS_UP)
+ dep->cb(dep, IFEV_UP);
+}
+
+void
+interface_remove_user(struct interface_user *dep)
+{
+ list_del_init(&dep->list);
+ dep->iface = NULL;
+}
+
static void
interface_claim_device(struct interface *iface)
{
static void
interface_cleanup(struct interface *iface)
{
+ struct interface_user *dep, *tmp;
+
+ list_for_each_entry_safe(dep, tmp, &iface->users, list)
+ interface_remove_user(dep);
+
interface_clear_dns(iface);
interface_clear_errors(iface);
if (iface->main_dev.dev)
strncpy(iface->name, name, sizeof(iface->name) - 1);
INIT_LIST_HEAD(&iface->errors);
+ INIT_LIST_HEAD(&iface->users);
INIT_LIST_HEAD(&iface->hotplug_list);
INIT_LIST_HEAD(&iface->proto_dns_search);
INIT_LIST_HEAD(&iface->proto_dns_servers);
const char *data[];
};
+struct interface_user {
+ struct list_head list;
+ struct interface *iface;
+ void (*cb)(struct interface_user *dep, enum interface_event ev);
+};
+
/*
* interface configuration
*/
enum interface_state state;
enum interface_config_state config_state;
+ struct list_head users;
+
/* main interface that the interface is bound to */
struct device_user main_dev;
int interface_set_up(struct interface *iface);
int interface_set_down(struct interface *iface);
+void interface_add_user(struct interface_user *dep, struct interface *iface);
+void interface_remove_user(struct interface_user *dep);
+
int interface_add_link(struct interface *iface, struct device *llif);
void interface_remove_link(struct interface *iface, struct device *llif);