Added function to get address from connection CAPI 93/132493/3
authorAbhishek Sansanwal <abhishek.s94@samsung.com>
Tue, 6 Jun 2017 07:01:42 +0000 (12:31 +0530)
committerAbhishek Sansanwal <abhishek.s94@samsung.com>
Thu, 8 Jun 2017 03:52:22 +0000 (09:22 +0530)
Description: Added function to get ip, dns, gateway and
subnet mask from connection CAPI.

Signed-off-by: Abhishek Sansanwal <abhishek.s94@samsung.com>
Change-Id: I36777a9ad27328a1bdcb1c9ca82b20ae84f9d502

include/data/system/data_wired.h
src/data/system/data_wired.c

index 8fa8acf..e2b9f68 100644 (file)
@@ -28,6 +28,13 @@ enum wired_status_type {
        WIRED_STATUS_COMPLETE,
 };
 
+enum address_type {
+       IP_ADDRESS = 0,
+       DNS_ADDRESS,
+       SUBNET_MASK,
+       GATEWAY_ADDRESS,
+};
+
 enum wired_network_type {
        WIRED_TYPE_DEFAULT = 0,
        WIRED_TYPE_MANUAL,
@@ -63,6 +70,17 @@ int get_wired_network_status(struct _connection_data *data);
 * @brief
 *
 * @param data
+* @param type
+* @param address
+*
+* @return
+*/
+bool get_address(struct _connection_data *data, int type, char **address);
+
+/**
+* @brief
+*
+* @param data
 *
 * @return
 */
index bab2903..b436ddb 100755 (executable)
@@ -51,6 +51,46 @@ int get_wired_network_status(struct _connection_data *data)
        return result;
 }
 
+bool get_address(struct _connection_data *data, int type, char **address)
+{
+       int rv = 0;
+       connection_profile_h profile;
+
+       if (!data || !data->profile)
+               return false;
+
+       profile = data->profile;
+       switch (type) {
+       case IP_ADDRESS:
+               rv = connection_profile_get_ip_address(profile,
+                               CONNECTION_ADDRESS_FAMILY_IPV4, address);
+               break;
+       case DNS_ADDRESS:
+               rv = connection_profile_get_dns_address(profile, 1,
+                               CONNECTION_ADDRESS_FAMILY_IPV4, address);
+               break;
+       case SUBNET_MASK:
+               rv = connection_profile_get_subnet_mask(profile,
+                               CONNECTION_ADDRESS_FAMILY_IPV4, address);
+               break;
+       case GATEWAY_ADDRESS:
+               rv = connection_profile_get_gateway_address(profile,
+                               CONNECTION_ADDRESS_FAMILY_IPV4, address);
+               break;
+       default:
+               _ERR("Unknown address type");
+               return false;
+       }
+
+       if (rv != CONNECTION_ERROR_NONE) {
+               _ERR("Failed to get address [%d]", rv);
+               return false;
+       }
+
+       return true;
+
+}
+
 bool get_ethernet_profile(struct _connection_data *data)
 {
        int rv = 0;