diff options
-rw-r--r-- | src/connman.h | 2 | ||||
-rw-r--r-- | src/ipconfig.c | 4 | ||||
-rw-r--r-- | src/network.c | 6 | ||||
-rw-r--r-- | src/provider.c | 10 | ||||
-rw-r--r-- | src/service.c | 12 |
5 files changed, 19 insertions, 15 deletions
diff --git a/src/connman.h b/src/connman.h index a390516f..437eaed7 100644 --- a/src/connman.h +++ b/src/connman.h @@ -481,6 +481,8 @@ struct connman_ipconfig *__connman_service_get_ip4config( struct connman_service *service); struct connman_ipconfig *__connman_service_get_ip6config( struct connman_service *service); +struct connman_ipconfig *__connman_service_get_ipconfig( + struct connman_service *service, int family); const char *__connman_service_get_ident(struct connman_service *service); const char *__connman_service_get_path(struct connman_service *service); unsigned int __connman_service_get_order(struct connman_service *service); diff --git a/src/ipconfig.c b/src/ipconfig.c index d620383a..7eea909f 100644 --- a/src/ipconfig.c +++ b/src/ipconfig.c @@ -168,7 +168,7 @@ int connman_ipaddress_set_ipv6(struct connman_ipaddress *ipaddress, DBG("prefix_len %d address %s gateway %s", prefix_length, address, gateway); - ipaddress->family = CONNMAN_IPCONFIG_TYPE_IPV6; + ipaddress->family = AF_INET6; ipaddress->prefixlen = prefix_length; @@ -187,7 +187,7 @@ int connman_ipaddress_set_ipv4(struct connman_ipaddress *ipaddress, if (ipaddress == NULL) return -EINVAL; - ipaddress->family = CONNMAN_IPCONFIG_TYPE_IPV4; + ipaddress->family = AF_INET; ipaddress->prefixlen = __connman_ipconfig_netmask_prefix_len(netmask); diff --git a/src/network.c b/src/network.c index 2ad073b8..babb28ba 100644 --- a/src/network.c +++ b/src/network.c @@ -1207,11 +1207,7 @@ int connman_network_set_ipaddress(struct connman_network *network, if (service == NULL) return -EINVAL; - if (ipaddress->family == CONNMAN_IPCONFIG_TYPE_IPV4) - ipconfig = __connman_service_get_ip4config(service); - else if (ipaddress->family == CONNMAN_IPCONFIG_TYPE_IPV6) - ipconfig = __connman_service_get_ip6config(service); - + ipconfig = __connman_service_get_ipconfig(service, ipaddress->family); if (ipconfig == NULL) return -EINVAL; diff --git a/src/provider.c b/src/provider.c index 816ad3d6..c930d373 100644 --- a/src/provider.c +++ b/src/provider.c @@ -683,14 +683,8 @@ int connman_provider_set_ipaddress(struct connman_provider *provider, { struct connman_ipconfig *ipconfig = NULL; - if (ipaddress->family == CONNMAN_IPCONFIG_TYPE_IPV4) { - ipconfig = __connman_service_get_ip4config( - provider->vpn_service); - } else if (ipaddress->family == CONNMAN_IPCONFIG_TYPE_IPV6) { - ipconfig = __connman_service_get_ip6config( - provider->vpn_service); - } - + ipconfig = __connman_service_get_ipconfig(provider->vpn_service, + ipaddress->family); if (ipconfig == NULL) return -EINVAL; diff --git a/src/service.c b/src/service.c index a103549f..c95c96b3 100644 --- a/src/service.c +++ b/src/service.c @@ -3247,6 +3247,18 @@ __connman_service_get_ip6config(struct connman_service *service) return service->ipconfig_ipv6; } +struct connman_ipconfig * +__connman_service_get_ipconfig(struct connman_service *service, int family) +{ + if (family == AF_INET) + return __connman_service_get_ip4config(service); + else if (family == AF_INET6) + return __connman_service_get_ip6config(service); + else + return NULL; + +} + enum connman_service_security __connman_service_get_security(struct connman_service *service) { if (service == NULL) |