From: Martin Xu Date: Tue, 9 Feb 2010 09:29:49 +0000 (+0100) Subject: Add some ipconfig helpers X-Git-Tag: accepted/2.0alpha-wayland/20121110.002834~2847 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e61f21a9e72cf4100c7ecbd80d2a25c84a63b33a;p=profile%2Fivi%2Fconnman.git Add some ipconfig helpers __connman_ipconfig_get_method(): Returns the selected ipconfig method. __connman_ipconfig_set_address(): Sets the device's IP address according to the selected method. Only the manual method is supported. __connman_ipconfig_clear_address(): Clears the device's IP address. Again, only the manual method is supported for now. --- diff --git a/src/connman.h b/src/connman.h index 593a517..ff38ad5 100644 --- a/src/connman.h +++ b/src/connman.h @@ -151,6 +151,10 @@ void __connman_ipconfig_append_proxy(struct connman_ipconfig *ipconfig, DBusMessageIter *iter); void __connman_ipconfig_append_ethernet(struct connman_ipconfig *ipconfig, DBusMessageIter *iter); +enum connman_ipconfig_method __connman_ipconfig_get_method( + struct connman_ipconfig *ipconfig); +int __connman_ipconfig_set_address(struct connman_ipconfig *ipconfig); +int __connman_ipconfig_clear_address(struct connman_ipconfig *ipconfig); int __connman_ipconfig_load(struct connman_ipconfig *ipconfig, GKeyFile *keyfile, const char *identifier, const char *prefix); diff --git a/src/ipconfig.c b/src/ipconfig.c index 38c317b..5d626e2 100644 --- a/src/ipconfig.c +++ b/src/ipconfig.c @@ -888,6 +888,15 @@ int connman_ipconfig_set_method(struct connman_ipconfig *ipconfig, return 0; } +enum connman_ipconfig_method __connman_ipconfig_get_method( + struct connman_ipconfig *ipconfig) +{ + if (ipconfig == NULL) + return CONNMAN_IPCONFIG_METHOD_UNKNOWN; + + return ipconfig->method; +} + /** * connman_ipconfig_bind: * @ipconfig: ipconfig structure @@ -907,6 +916,42 @@ void connman_ipconfig_bind(struct connman_ipconfig *ipconfig, connman_inet_set_address(origin->index, origin->address); } +int __connman_ipconfig_set_address(struct connman_ipconfig *ipconfig) +{ + DBG(""); + + switch (ipconfig->method) { + case CONNMAN_IPCONFIG_METHOD_UNKNOWN: + case CONNMAN_IPCONFIG_METHOD_OFF: + case CONNMAN_IPCONFIG_METHOD_FIXED: + case CONNMAN_IPCONFIG_METHOD_DHCP: + break; + case CONNMAN_IPCONFIG_METHOD_MANUAL: + return connman_inet_set_address(ipconfig->index, + ipconfig->address); + } + + return 0; +} + +int __connman_ipconfig_clear_address(struct connman_ipconfig *ipconfig) +{ + DBG(""); + + switch (ipconfig->method) { + case CONNMAN_IPCONFIG_METHOD_UNKNOWN: + case CONNMAN_IPCONFIG_METHOD_OFF: + case CONNMAN_IPCONFIG_METHOD_FIXED: + case CONNMAN_IPCONFIG_METHOD_DHCP: + break; + case CONNMAN_IPCONFIG_METHOD_MANUAL: + return connman_inet_clear_address(ipconfig->index); + } + + return 0; + +} + int __connman_ipconfig_enable(struct connman_ipconfig *ipconfig) { struct connman_ipdevice *ipdevice;