diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2011-02-23 21:05:39 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-02-23 21:05:39 +0100 |
commit | e4932cc390e77c7af2f7085e1caedad44b3420f2 (patch) | |
tree | af138cfd08d6723a7150f327009316b29374c9d3 /src/ipconfig.c | |
parent | 878520659c5cdb35b94e99f84dbf366281ac868b (diff) | |
download | connman-e4932cc390e77c7af2f7085e1caedad44b3420f2.tar.gz connman-e4932cc390e77c7af2f7085e1caedad44b3420f2.tar.bz2 connman-e4932cc390e77c7af2f7085e1caedad44b3420f2.zip |
ipconfig: Split ipconfig_set_gateway()
ipconfig_set_gateway() sets the gateway pointer while gateway_add() sets
the route.
Diffstat (limited to 'src/ipconfig.c')
-rw-r--r-- | src/ipconfig.c | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/src/ipconfig.c b/src/ipconfig.c index 0ca44b83..ca983b41 100644 --- a/src/ipconfig.c +++ b/src/ipconfig.c @@ -1054,31 +1054,51 @@ const char *__connman_ipconfig_get_gateway(struct connman_ipconfig *ipconfig) void __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig, const char *gateway) { - struct connman_service *service; + DBG(""); if (ipconfig->address == NULL) return; + g_free(ipconfig->address->gateway); + ipconfig->address->gateway = g_strdup(gateway); +} + +int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig) +{ + struct connman_service *service; + + DBG(""); + + if (ipconfig->address == NULL || ipconfig->address->gateway == NULL) + return -EINVAL; service = __connman_service_lookup_from_index(ipconfig->index); - if (service != NULL) - __connman_connection_gateway_remove(service); + if (service == NULL) + return -EINVAL; - g_free(ipconfig->address->gateway); - ipconfig->address->gateway = g_strdup(gateway); + __connman_connection_gateway_remove(service); - if (service != NULL && ipconfig->address->gateway != NULL) { - if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6) { - __connman_connection_gateway_add(service, - NULL, + if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6) { + return __connman_connection_gateway_add(service, NULL, ipconfig->address->gateway, - ipconfig->address->peer); - } else if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4) { - __connman_connection_gateway_add(service, + ipconfig->address->peer); + } else if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4) { + return __connman_connection_gateway_add(service, ipconfig->address->gateway, - NULL, - ipconfig->address->peer); - } + NULL, ipconfig->address->peer); } + + return 0; +} + +void __connman_ipconfig_gateway_remove(struct connman_ipconfig *ipconfig) +{ + struct connman_service *service; + + DBG(""); + + service = __connman_service_lookup_from_index(ipconfig->index); + if (service != NULL) + __connman_connection_gateway_remove(service); } unsigned char __connman_ipconfig_get_prefixlen(struct connman_ipconfig *ipconfig) |