Make local handle for event loop
[platform/core/api/connection.git] / src / libnetwork_mptcp.c
index 3b53185..ebbff07 100755 (executable)
@@ -19,6 +19,7 @@
 #include "net_connection_private.h"
 #include "connection_extension.h"
 #include "net_connection_mptcp_private.h"
+#include "network-mptcp-intf.h"
 
 static const char* __convert_mptcp_path_manager_enum_to_str(connection_mptcp_path_manager_e pm)
 {
@@ -39,7 +40,7 @@ static connection_mptcp_path_manager_e __convert_mptcp_path_manager_str_to_enum(
                return CONNECTION_MPTCP_PM_DEFAULT;
        if (g_strcmp0(pm, "fullmesh") == 0)
                return CONNECTION_MPTCP_PM_FULLMESH;
-       return CONNECTION_MPTCP_PM_UNKNOWN;
+       return CONNECTION_MPTCP_PM_UNKNOWN;     //LCOV_EXCL_LINE
 }
 
 static const char* __convert_mptcp_scheduler_enum_to_str(connection_mptcp_scheduler_e scheduler)
@@ -61,54 +62,54 @@ static connection_mptcp_scheduler_e __convert_mptcp_scheduler_str_to_enum(char *
                return CONNECTION_MPTCP_SCHEDULER_DEFAULT;
        if (g_strcmp0(scheduler, "roundrobin") == 0)
                return CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN;
-       return CONNECTION_MPTCP_SCHEDULER_UNKNOWN;
+       return CONNECTION_MPTCP_SCHEDULER_UNKNOWN;      //LCOV_EXCL_LINE
 }
 
-gboolean _connection_libnet_mptcp_supported()
+gboolean _connection_libnet_mptcp_supported(connection_handle_s *conn_handle)
 {
        int rv = 0;
        gboolean support = false;
 
-       rv = net_mptcp_supported(&support);
+       rv = net_mptcp_supported(conn_handle->network_info_handle, &support);
        if (rv == NET_ERR_ACCESS_DENIED) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");      //LCOV_EXCL_LINE
                return false;
        } else if (rv != NET_ERR_NONE) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable MPTCP [%d]", rv);
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable MPTCP [%d]", rv);    //LCOV_EXCL_LINE
                return false;
        }
 
        return support;
 }
 
-int _connection_libnet_mptcp_enable(connection_mptcp_enable_e enable)
+int _connection_libnet_mptcp_enable(connection_handle_s *conn_handle, connection_mptcp_enable_e enable)
 {
        int rv = 0;
 
-       rv = net_mptcp_set_enable((int)enable);
+       rv = net_mptcp_set_enabled(conn_handle->network_info_handle, (int)enable);
        if (rv == NET_ERR_ACCESS_DENIED) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
-               return CONNECTION_ERROR_PERMISSION_DENIED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");      //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_PERMISSION_DENIED;      //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable MPTCP [%d]", rv);
-               return CONNECTION_ERROR_OPERATION_FAILED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable MPTCP [%d]", rv);    //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_OPERATION_FAILED;       //LCOV_EXCL_LINE
        }
 
        return CONNECTION_ERROR_NONE;
 }
 
-int _connection_libnet_mptcp_get_enabled(connection_mptcp_enable_e* enable)
+int _connection_libnet_mptcp_get_enabled(connection_handle_s *conn_handle, connection_mptcp_enable_e* enable)
 {
        int rv = 0;
        int result = 0;
 
-       rv = net_mptcp_get_enabled(&result);
+       rv = net_mptcp_get_enabled(conn_handle->network_info_handle, &result);
        if (rv == NET_ERR_ACCESS_DENIED) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
-               return CONNECTION_ERROR_PERMISSION_DENIED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");      //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_PERMISSION_DENIED;      //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MPTCP enabled state [%d]", rv);
-               return CONNECTION_ERROR_OPERATION_FAILED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MPTCP enabled state [%d]", rv); //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_OPERATION_FAILED;       //LCOV_EXCL_LINE
        }
 
        *enable = (connection_mptcp_enable_e)result;
@@ -116,7 +117,7 @@ int _connection_libnet_mptcp_get_enabled(connection_mptcp_enable_e* enable)
 }
 
 
-int _connection_libnet_mptcp_set_path_manager(connection_mptcp_path_manager_e pm)
+int _connection_libnet_mptcp_set_path_manager(connection_handle_s *conn_handle, connection_mptcp_path_manager_e pm)
 {
        int rv = 0;
        const char* str = __convert_mptcp_path_manager_enum_to_str(pm);
@@ -127,30 +128,30 @@ int _connection_libnet_mptcp_set_path_manager(connection_mptcp_path_manager_e pm
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       rv = net_mptcp_set_path_manager(str);
+       rv = net_mptcp_set_path_manager(conn_handle->network_info_handle, str);
        if (rv == NET_ERR_ACCESS_DENIED) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
-               return CONNECTION_ERROR_PERMISSION_DENIED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");      //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_PERMISSION_DENIED;      //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Failed to set MPTCP path manager [%d]", rv);
-               return CONNECTION_ERROR_OPERATION_FAILED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to set MPTCP path manager [%d]", rv);  //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_OPERATION_FAILED;       //LCOV_EXCL_LINE
        }
 
        return CONNECTION_ERROR_NONE;
 }
 
-int _connection_libnet_mptcp_get_path_manager(connection_mptcp_path_manager_e* pm)
+int _connection_libnet_mptcp_get_path_manager(connection_handle_s *conn_handle, connection_mptcp_path_manager_e* pm)
 {
        int rv = 0;
        char* result = NULL;
 
-       rv = net_mptcp_get_path_manager(&result);
+       rv = net_mptcp_get_path_manager(conn_handle->network_info_handle, &result);
        if (rv == NET_ERR_ACCESS_DENIED) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
-               return CONNECTION_ERROR_PERMISSION_DENIED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");      //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_PERMISSION_DENIED;      //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MPTCP path manager [%d]", rv);
-               return CONNECTION_ERROR_OPERATION_FAILED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MPTCP path manager [%d]", rv);  //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_OPERATION_FAILED;       //LCOV_EXCL_LINE
        }
 
        CONNECTION_LOG(CONNECTION_ERROR, "get path manager %s", result);
@@ -160,7 +161,7 @@ int _connection_libnet_mptcp_get_path_manager(connection_mptcp_path_manager_e* p
 }
 
 
-int _connection_libnet_mptcp_set_scheduler(connection_mptcp_scheduler_e scheduler)
+int _connection_libnet_mptcp_set_scheduler(connection_handle_s *conn_handle, connection_mptcp_scheduler_e scheduler)
 {
        int rv = 0;
        const char *str = __convert_mptcp_scheduler_enum_to_str(scheduler);
@@ -171,30 +172,30 @@ int _connection_libnet_mptcp_set_scheduler(connection_mptcp_scheduler_e schedule
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       rv = net_mptcp_set_scheduler(str);
+       rv = net_mptcp_set_scheduler(conn_handle->network_info_handle, str);
        if (rv == NET_ERR_ACCESS_DENIED) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
-               return CONNECTION_ERROR_PERMISSION_DENIED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");      //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_PERMISSION_DENIED;      //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Failed to set MPTCP scheduler [%d]", rv);
-               return CONNECTION_ERROR_OPERATION_FAILED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to set MPTCP scheduler [%d]", rv);     //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_OPERATION_FAILED;       //LCOV_EXCL_LINE
        }
 
        return CONNECTION_ERROR_NONE;
 }
 
-int _connection_libnet_mptcp_get_scheduler(connection_mptcp_scheduler_e* scheduler)
+int _connection_libnet_mptcp_get_scheduler(connection_handle_s *conn_handle, connection_mptcp_scheduler_e* scheduler)
 {
        int rv = 0;
        char* result = NULL;
 
-       rv = net_mptcp_get_scheduler(&result);
+       rv = net_mptcp_get_scheduler(conn_handle->network_info_handle, &result);
        if (rv == NET_ERR_ACCESS_DENIED) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
-               return CONNECTION_ERROR_PERMISSION_DENIED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");      //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_PERMISSION_DENIED;      //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
-               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MPTCP scheduler [%d]", rv);
-               return CONNECTION_ERROR_OPERATION_FAILED;
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MPTCP scheduler [%d]", rv);     //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_OPERATION_FAILED;       //LCOV_EXCL_LINE
        }
 
        CONNECTION_LOG(CONNECTION_ERROR, "get scheduler %s", result);