Get the Gateway address 62/33062/1
authorChengyi Zhao <chengyi1.zhao@archermind.com>
Wed, 31 Dec 2014 02:40:25 +0000 (10:40 +0800)
committerChengyi Zhao <chengyi1.zhao@archermind.com>
Sun, 4 Jan 2015 01:47:56 +0000 (09:47 +0800)
Change-Id: I6ed17657638ed050a912290f701e497972daa27f
Signed-off-by: Chengyi Zhao <chengyi1.zhao@archermind.com>
src/connection_profile.c

index a729686f1371f6cbc1c9140a9b53bb1c112acb73..ee70ab0867d53aea2602315c371daa4ca17a6d02 100644 (file)
@@ -542,19 +542,22 @@ EXPORT_API int connection_profile_get_gateway_address(connection_profile_h profi
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       /*
-       net_profile_info_t *profile_info = profile;
-       net_dev_info_t *net_info = __profile_get_net_info(profile_info);
-       if (net_info == NULL)
-               return CONNECTION_ERROR_OPERATION_FAILED;
-
        if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
                return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
 
-       *gateway_address = __profile_convert_ip_to_string(&net_info->GatewayAddr);
+       const struct service_ipv4 *ipv4;
+       struct connman_service *service =
+                               _connection_libnet_get_service_h(profile);
+       if (service == NULL)
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+
+       ipv4 = connman_service_get_ipv4_info(service);
+       if (ipv4 == NULL || ipv4->gateway == NULL)
+               return CONNECTION_ERROR_OPERATION_FAILED;
+
+       *gateway_address = g_strdup(ipv4->gateway);
        if (*gateway_address == NULL)
                return CONNECTION_ERROR_OUT_OF_MEMORY;
-        */
 
        return CONNECTION_ERROR_NONE;
 }