From 80de85a6242c7b2957401dbf75520862798b8d16 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Wed, 22 Jun 2011 13:37:46 +0300 Subject: ipconfig: Add function to remove address from interface. The new function removes the address from interface but does not touch internal data structures. --- src/connman.h | 1 + src/ipconfig.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src') 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 @@ -1393,6 +1393,34 @@ int __connman_ipconfig_address_remove(struct connman_ipconfig *ipconfig) 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: + 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: @@ -1412,8 +1440,6 @@ int __connman_ipconfig_address_remove(struct connman_ipconfig *ipconfig) else err = -EINVAL; - connman_ipaddress_clear(ipconfig->address); - return err; } -- cgit v1.2.3