diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2011-06-22 13:37:46 +0300 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-06-27 16:15:09 +0200 |
commit | 80de85a6242c7b2957401dbf75520862798b8d16 (patch) | |
tree | 2c1b56b8720865bc8d6c876b1171293d7b0caf0e /src | |
parent | 3d761a0d18626e1ac8610a73d1cccf74af8988b2 (diff) | |
download | connman-80de85a6242c7b2957401dbf75520862798b8d16.tar.gz connman-80de85a6242c7b2957401dbf75520862798b8d16.tar.bz2 connman-80de85a6242c7b2957401dbf75520862798b8d16.zip |
ipconfig: Add function to remove address from interface.
The new function removes the address from interface but does not
touch internal data structures.
Diffstat (limited to 'src')
-rw-r--r-- | src/connman.h | 1 | ||||
-rw-r--r-- | src/ipconfig.c | 30 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/connman.h b/src/connman.h index 0d6ca8b2..0c6d6b1c 100644 --- a/src/connman.h +++ b/src/connman.h @@ -249,6 +249,7 @@ enum connman_ipconfig_method __connman_ipconfig_get_method( int __connman_ipconfig_address_add(struct connman_ipconfig *ipconfig); int __connman_ipconfig_address_remove(struct connman_ipconfig *ipconfig); +int __connman_ipconfig_address_unset(struct connman_ipconfig *ipconfig); int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig); void __connman_ipconfig_gateway_remove(struct connman_ipconfig *ipconfig); unsigned char __connman_ipconfig_netmask_prefix_len(const char *netmask); diff --git a/src/ipconfig.c b/src/ipconfig.c index c8466d98..4d74ca82 100644 --- a/src/ipconfig.c +++ b/src/ipconfig.c @@ -1401,6 +1401,34 @@ int __connman_ipconfig_address_remove(struct connman_ipconfig *ipconfig) case CONNMAN_IPCONFIG_METHOD_FIXED: case CONNMAN_IPCONFIG_METHOD_DHCP: case CONNMAN_IPCONFIG_METHOD_MANUAL: + err = __connman_ipconfig_address_unset(ipconfig); + connman_ipaddress_clear(ipconfig->address); + + return err; + } + + return 0; +} + +int __connman_ipconfig_address_unset(struct connman_ipconfig *ipconfig) +{ + int err; + + DBG(""); + + if (ipconfig == NULL) + return 0; + + DBG("method %d", ipconfig->method); + + switch (ipconfig->method) { + case CONNMAN_IPCONFIG_METHOD_UNKNOWN: + case CONNMAN_IPCONFIG_METHOD_OFF: + case CONNMAN_IPCONFIG_METHOD_AUTO: + break; + case CONNMAN_IPCONFIG_METHOD_FIXED: + case CONNMAN_IPCONFIG_METHOD_DHCP: + case CONNMAN_IPCONFIG_METHOD_MANUAL: if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4) err = connman_inet_clear_address(ipconfig->index, ipconfig->address); @@ -1412,8 +1440,6 @@ int __connman_ipconfig_address_remove(struct connman_ipconfig *ipconfig) else err = -EINVAL; - connman_ipaddress_clear(ipconfig->address); - return err; } |