summaryrefslogtreecommitdiff
path: root/src/ipconfig.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-08-11 23:23:50 -0700
committerMarcel Holtmann <marcel@holtmann.org>2009-08-11 23:23:50 -0700
commit885ac067b4332bea808de50885d0ccd6386b8636 (patch)
tree8529a2b87f956d0562929aabddeaa6773026bfad /src/ipconfig.c
parent213dec4c14f6c15bf91273185dfbc802339edc33 (diff)
downloadconnman-885ac067b4332bea808de50885d0ccd6386b8636.tar.gz
connman-885ac067b4332bea808de50885d0ccd6386b8636.tar.bz2
connman-885ac067b4332bea808de50885d0ccd6386b8636.zip
Add callbacks for IP bound and release events
Diffstat (limited to 'src/ipconfig.c')
-rw-r--r--src/ipconfig.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/ipconfig.c b/src/ipconfig.c
index faed54d3..b02f20c0 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -256,6 +256,8 @@ static void __connman_ipconfig_lower_down(struct connman_ipdevice *ipdevice)
return;
ipdevice->driver->release(ipdevice->config);
+
+ connman_inet_clear_address(ipdevice->index);
}
void __connman_ipconfig_newlink(int index, unsigned short type,
@@ -317,6 +319,8 @@ update:
lower_down = TRUE;
}
+ connman_inet_clear_address(index);
+
ipdevice->flags = flags;
str = g_string_new(NULL);
@@ -401,6 +405,7 @@ void __connman_ipconfig_newaddr(int index, const char *label,
{
struct connman_ipdevice *ipdevice;
struct connman_ipaddress *ipaddress;
+ GList *list;
DBG("index %d", index);
@@ -420,6 +425,23 @@ void __connman_ipconfig_newaddr(int index, const char *label,
connman_info("%s {add} address %s/%u label %s", ipdevice->ifname,
address, prefixlen, label);
+
+ if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) != (IFF_RUNNING | IFF_LOWER_UP))
+ return;
+
+ if (g_slist_length(ipdevice->address_list) > 1)
+ return;
+
+ for (list = g_list_first(ipconfig_list); list;
+ list = g_list_next(list)) {
+ struct connman_ipconfig *ipconfig = list->data;
+
+ if (index != ipconfig->index)
+ continue;
+
+ if (ipconfig->ops && ipconfig->ops->ip_bound)
+ ipconfig->ops->ip_bound(ipconfig);
+ }
}
void __connman_ipconfig_deladdr(int index, const char *label,
@@ -427,6 +449,7 @@ void __connman_ipconfig_deladdr(int index, const char *label,
{
struct connman_ipdevice *ipdevice;
struct connman_ipaddress *ipaddress;
+ GList *list;
DBG("index %d", index);
@@ -445,6 +468,23 @@ void __connman_ipconfig_deladdr(int index, const char *label,
connman_info("%s {del} address %s/%u label %s", ipdevice->ifname,
address, prefixlen, label);
+
+ if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) != (IFF_RUNNING | IFF_LOWER_UP))
+ return;
+
+ if (g_slist_length(ipdevice->address_list) > 0)
+ return;
+
+ for (list = g_list_first(ipconfig_list); list;
+ list = g_list_next(list)) {
+ struct connman_ipconfig *ipconfig = list->data;
+
+ if (index != ipconfig->index)
+ continue;
+
+ if (ipconfig->ops && ipconfig->ops->ip_release)
+ ipconfig->ops->ip_release(ipconfig);
+ }
}
void __connman_ipconfig_newroute(int index, unsigned char scope,
@@ -697,6 +737,8 @@ void connman_ipconfig_bind(struct connman_ipconfig *ipconfig,
struct connman_ipaddress *ipaddress)
{
connman_ipaddress_copy(ipconfig->address, ipaddress);
+
+ connman_inet_set_address(ipconfig->index, ipconfig->address);
}
const char *__connman_ipconfig_method2string(enum connman_ipconfig_method method)