[NBS] Adding and removing routes with new native methods. 13/190813/8
authorArkadiusz Pietraszek <a.pietraszek@partner.samsung.com>
Fri, 5 Oct 2018 10:52:18 +0000 (12:52 +0200)
committerArkadiusz Pietraszek <a.pietraszek@partner.samsung.com>
Mon, 15 Oct 2018 13:54:02 +0000 (15:54 +0200)
Old implementation used deprecated native methods - changed
to replacement methods.

[Verification] TCT pass rate: 100%

Change-Id: I62f264b547666bc807e8451aec1d216264726750

src/networkbearerselection/networkbearerselection_manager.cc

index b6206f468d62fc0b36e14db292aa1143864fbd8c..b9372d1ce965a57aeeaaa40f40c07c624674747b 100644 (file)
@@ -278,25 +278,26 @@ bool NetworkBearerSelectionManager::removeDomainRoute(
   }
 
   int ai_family = iter->second;
+  connection_address_family_e address_family = CONNECTION_ADDRESS_FAMILY_IPV4;
+
   if (AF_INET == ai_family) {
     LoggerD("IPv4 address");
-    ret = connection_remove_route(m_connection_handle_, interface_name, domain_name);
   } else if (AF_INET6 == ai_family) {
     LoggerD("IPv6 address");
-    ret = connection_profile_get_gateway_address(m_profile_handle_, CONNECTION_ADDRESS_FAMILY_IPV6,
-                                                 &gateway);
-
-    if (CONNECTION_ERROR_NONE != ret) {
-      LoggerE("Failed to get gateway");
-      return false;
-    }
-
-    ret = connection_remove_route_ipv6(m_connection_handle_, interface_name, domain_name, gateway);
+    address_family = CONNECTION_ADDRESS_FAMILY_IPV6;
   } else {
     LoggerE("Incorrect family address");
     return false;
   }
 
+  ret = connection_profile_get_gateway_address(m_profile_handle_, address_family, &gateway);
+  if (CONNECTION_ERROR_NONE != ret) {
+    LoggerE("Failed to get gateway");
+    return false;
+  }
+  ret = connection_remove_route_entry(m_connection_handle_, address_family, interface_name,
+                                      domain_name, gateway);
+
   if (CONNECTION_ERROR_NONE != ret) {
     LoggerE("Failed to remove route");
     return false;
@@ -407,23 +408,27 @@ bool NetworkBearerSelectionManager::registerStateChangeListener(const std::strin
     return false;
   }
 
+  connection_address_family_e address_family = CONNECTION_ADDRESS_FAMILY_IPV4;
+
   if (AF_INET == serv_info->ai_family) {
-    LoggerD("IPv4 add route");
-    ret = connection_add_route(m_connection_handle_, interface_name, host_addr_ptr.get());
+    LoggerD("IPv4 address");
+  } else if (AF_INET6 == serv_info->ai_family) {
+    LoggerD("IPv6 address");
+    address_family = CONNECTION_ADDRESS_FAMILY_IPV6;
   } else {
-    LoggerD("IPv6 add route");
-    ret = connection_profile_get_gateway_address(m_profile_handle_, CONNECTION_ADDRESS_FAMILY_IPV6,
-                                                 &gateway);
-
-    if (CONNECTION_ERROR_NONE != ret) {
-      LoggerE("Error while getting gateway address %d", ret);
-      return false;
-    }
+    LoggerE("Incorrect family address");
+    return false;
+  }
 
-    ret = connection_add_route_ipv6(m_connection_handle_, interface_name, host_addr_ptr.get(),
-                                    gateway);
+  ret = connection_profile_get_gateway_address(m_profile_handle_, address_family, &gateway);
+  if (CONNECTION_ERROR_NONE != ret) {
+    LoggerE("Failed to get gateway");
+    return false;
   }
 
+  ret = connection_add_route_entry(m_connection_handle_, address_family, interface_name,
+                                   host_addr_ptr.get(), gateway);
+
   if (CONNECTION_ERROR_NONE != ret) {
     LoggerE("Adding route failed");
     return false;