projects
/
project
/
netifd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0ee5204
)
add interface users (similar to device users)
author
Felix Fietkau
<nbd@openwrt.org>
Tue, 18 Oct 2011 15:06:17 +0000
(17:06 +0200)
committer
Felix Fietkau
<nbd@openwrt.org>
Tue, 18 Oct 2011 16:17:54 +0000
(18:17 +0200)
interface.c
patch
|
blob
|
history
interface.h
patch
|
blob
|
history
diff --git
a/interface.c
b/interface.c
index
9d6a7c1
..
0a2afd0
100644
(file)
--- a/
interface.c
+++ b/
interface.c
@@
-79,6
+79,11
@@
void interface_add_error(struct interface *iface, const char *subsystem,
static void
interface_event(struct interface *iface, enum interface_event ev)
{
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_queue_event(iface, ev);
}
@@
-168,6
+173,22
@@
interface_set_available(struct interface *iface, bool new_state)
__interface_set_down(iface, true);
}
__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_claim_device(struct interface *iface)
{
@@
-185,6
+206,11
@@
interface_claim_device(struct interface *iface)
static void
interface_cleanup(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)
interface_clear_dns(iface);
interface_clear_errors(iface);
if (iface->main_dev.dev)
@@
-290,6
+316,7
@@
interface_init(struct interface *iface, const char *name,
strncpy(iface->name, name, sizeof(iface->name) - 1);
INIT_LIST_HEAD(&iface->errors);
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);
INIT_LIST_HEAD(&iface->hotplug_list);
INIT_LIST_HEAD(&iface->proto_dns_search);
INIT_LIST_HEAD(&iface->proto_dns_servers);
diff --git
a/interface.h
b/interface.h
index
6620796
..
7f84060
100644
(file)
--- a/
interface.h
+++ b/
interface.h
@@
-33,6
+33,12
@@
struct interface_error {
const char *data[];
};
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
*/
/*
* interface configuration
*/
@@
-52,6
+58,8
@@
struct interface {
enum interface_state state;
enum interface_config_state config_state;
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;
/* main interface that the interface is bound to */
struct device_user main_dev;
@@
-91,6
+99,9
@@
void interface_set_available(struct interface *iface, bool new_state);
int interface_set_up(struct interface *iface);
int interface_set_down(struct interface *iface);
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);
int interface_add_link(struct interface *iface, struct device *llif);
void interface_remove_link(struct interface *iface, struct device *llif);