Change 'Feature List' link
[platform/core/api/connection.git] / src / libnetwork.c
index abe373e..9925292 100755 (executable)
@@ -476,18 +476,6 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
 }
 //LCOV_EXCL_STOP
 
-static int __libnet_check_address_type(int address_family, const char *address)
-{
-       struct in6_addr buf;
-       int err = 0;
-
-       err = inet_pton(address_family, address, &buf);
-       if (err > 0)
-               return 1;
-
-       return 0;
-}
-
 int __libnet_get_connected_count(struct _profile_list_s *profile_list)
 {
        int count = 0;
@@ -758,7 +746,7 @@ int _connection_libnet_get_bluetooth_state(connection_bt_state_e *state)
        }
        //LCOV_EXCL_STOP
 
-done :
+done:
        __libnet_clear_profile_list(&bluetooth_profiles);
 
        return CONNECTION_ERROR_NONE;
@@ -1113,7 +1101,7 @@ int _connection_libnet_get_cellular_service_profile(
        }
        //LCOV_EXCL_STOP
 
-done :
+done:
        __libnet_clear_profile_list(&cellular_profiles);
        prof_handle_list = g_slist_append(prof_handle_list, *profile);
 
@@ -1206,24 +1194,15 @@ int _connection_libnet_add_route(const char *interface_name, const char *host_ad
        char *endstr = NULL;
        int address_family = 0;
 
-       if (__libnet_check_address_type(AF_INET, host_address))
-               address_family = AF_INET;
-       else
-               return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       address_family = AF_INET;
 
-       switch (address_family) {
-       case AF_INET:
-               endstr = strrchr(host_address, '.');
-               if (endstr == NULL ||
-                               strcmp(endstr, ".0") == 0 ||
-                               strncmp(host_address, "0.", 2) == 0 ||
-                               strstr(host_address, "255") != NULL) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
-                       return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
-               }
-               break;
-       default:
-               return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       endstr = strrchr(host_address, '.');
+       if (endstr == NULL ||
+                       strcmp(endstr, ".0") == 0 ||
+                       strncmp(host_address, "0.", 2) == 0 ||
+                       strstr(host_address, "255") != NULL) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        rv = net_add_route(host_address, interface_name, address_family);
@@ -1242,24 +1221,15 @@ int _connection_libnet_remove_route(const char *interface_name, const char *host
        char *endstr = strrchr(host_address, '.');
        int address_family = 0;
 
-       if (__libnet_check_address_type(AF_INET, host_address))
-               address_family = AF_INET;
-       else
-               return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       address_family = AF_INET;
 
-       switch (address_family) {
-       case AF_INET:
-               endstr = strrchr(host_address, '.');
-               if (endstr == NULL ||
-                       strcmp(endstr, ".0") == 0 ||
-                       strncmp(host_address, "0.", 2) == 0 ||
-                       strstr(host_address, ".0.") != NULL || strstr(host_address, "255") != NULL) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed"); //LCOV_EXCL_LINE
-                       return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
-               }
-               break;
-       default:
-               return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       endstr = strrchr(host_address, '.');
+       if (endstr == NULL ||
+               strcmp(endstr, ".0") == 0 ||
+               strncmp(host_address, "0.", 2) == 0 ||
+               strstr(host_address, ".0.") != NULL || strstr(host_address, "255") != NULL) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed"); //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        rv = net_remove_route(host_address, interface_name, address_family);
@@ -1278,22 +1248,12 @@ int _connection_libnet_add_route_ipv6(const char *interface_name, const char *ho
        int address_family = 0;
 
        address_family = AF_INET6;
-/*     if(__libnet_check_address_type(AF_INET6, host_address))
-               address_family = AF_INET6;
-       else
-               return CONNECTION_ERROR_INVALID_PARAMETER;*/
-
-       switch (address_family) {
-       case AF_INET6:
-               if (strncmp(host_address, "fe80:", 5) == 0 ||
-                       strncmp(host_address, "ff00:", 5) == 0 ||
-                       strncmp(host_address, "::", 2) == 0) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
-                       return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
-               }
-               break;
-       default:
-               return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+       if (strncmp(host_address, "fe80:", 5) == 0 ||
+               strncmp(host_address, "ff00:", 5) == 0 ||
+               strncmp(host_address, "::", 2) == 0) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        rv = net_add_route_ipv6(host_address, interface_name, address_family, gateway);
@@ -1312,22 +1272,12 @@ int _connection_libnet_remove_route_ipv6(const char *interface_name, const char
        int address_family = 0;
 
        address_family = AF_INET6;
-/*     if (__libnet_check_address_type(AF_INET6, host_address))
-               address_family = AF_INET6;
-       else
-               return CONNECTION_ERROR_INVALID_PARAMETER;*/
-
-       switch (address_family) {
-       case AF_INET6:
-               if (strncmp(host_address, "fe80:", 5) == 0 ||
-                       strncmp(host_address, "ff00:", 5) == 0 ||
-                       strncmp(host_address, "::", 2) == 0) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
-                       return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
-               }
-               break;
-       default:
-               return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+       if (strncmp(host_address, "fe80:", 5) == 0 ||
+               strncmp(host_address, "ff00:", 5) == 0 ||
+               strncmp(host_address, "::", 2) == 0) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        rv = net_remove_route_ipv6(host_address, interface_name, address_family, gateway);