[MPTCP] Add connection_mptcp_is_supported() 06/173506/3 accepted/tizen/unified/20180403.182502 submit/tizen/20180329.042536
authorchleun.moon <chleun.moon@samsung.com>
Thu, 22 Mar 2018 05:24:05 +0000 (14:24 +0900)
committerchleun.moon <chleun.moon@samsung.com>
Thu, 22 Mar 2018 07:52:49 +0000 (16:52 +0900)
Change-Id: Ife77a96b74db82f3f32f9a0487aa4c2a68b20b78
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
include/connection_extension.h
include/net_connection_private.h
src/connection.c
src/connection_mptcp.c
test/connection_test.c

index 9ad8ef6..3f0457f 100755 (executable)
@@ -97,32 +97,137 @@ int connection_create_cs(int tid, connection_h *connection);
 int connection_destroy_cs(int tid, connection_h connection);
 
 typedef enum {
-       CONNECTION_MPTCP_DISABLE = 0,
-       CONNECTION_MPTCP_ENABLE_ALL = 1,
-       CONNECTION_MPTCP_ENABLE_SOCKOPT = 2,
+       CONNECTION_MPTCP_DISABLE = 0,                   // disable
+       CONNECTION_MPTCP_ENABLE_ALL = 1,                // enable
+       CONNECTION_MPTCP_ENABLE_SOCKOPT = 2,    // enable if the MPTCP_ENABLED socket option is set
 } connection_mptcp_enable_e;
 
 typedef enum {
-       CONNECTION_MPTCP_PM_UNKNOWN,
-       CONNECTION_MPTCP_PM_DEFAULT,
-       CONNECTION_MPTCP_PM_FULLMESH,
+       CONNECTION_MPTCP_PM_UNKNOWN,                    // Unknown path manager
+       CONNECTION_MPTCP_PM_DEFAULT,                    // Default path manager - Do nothing
+       CONNECTION_MPTCP_PM_FULLMESH,                   // Full mesh of subflows
 } connection_mptcp_path_manager_e;
 
 typedef enum {
-       CONNECTION_MPTCP_SCHEDULER_UNKNOWN,
-       CONNECTION_MPTCP_SCHEDULER_DEFAULT,
-       CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN,
+       CONNECTION_MPTCP_SCHEDULER_UNKNOWN,             // Unknown scheduler
+       CONNECTION_MPTCP_SCHEDULER_DEFAULT,             // Default scheduler
+       CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN,  // Round robin scheduler
 } connection_mptcp_scheduler_e;
 
-int connection_mptcp_enable(connection_mptcp_enable_e enable);
-int connection_mptcp_disable(void);
-int connection_mptcp_get_enabled(connection_mptcp_enable_e* enable);
+/**
+ * @brief Check if Multipath TCP is supported
+ * @since_tizen 5.0
+ * @param[in] connection       The connection handle
+ * @param[out] supported       true if Multipath TCP is supported, false otherwise
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE                              Successful
+ */
+int connection_mptcp_is_supported(connection_h connection, bool* supported);
+
+/**
+ * @brief Enable Multipath TCP
+ * @since_tizen 5.0
+ * @param[in] connection       The connection handle
+ * @param[in] enable   The enabled value
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE                              Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED             Not supported
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission denied
+ */
+int connection_mptcp_enable(connection_h connection, connection_mptcp_enable_e enable);
+
+/**
+ * @brief Disable Multipath TCP
+ * @since_tizen 5.0
+ * @param[in] connection       The connection handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE                              Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED             Not supported
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission denied
+ */
+int connection_mptcp_disable(connection_h connection);
+
+/**
+ * @brief Get the enabled value for Multipath TCP
+ * @since_tizen 5.0
+ * @param[in] connection       The connection handle
+ * @param[out] enable  The enabled value
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE                              Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED             Not supported
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission denied
+ */
+int connection_mptcp_get_enabled(connection_h connection, connection_mptcp_enable_e* enable);
+
+/**
+ * @brief Set the path manager of Multipath TCP
+ * @since_tizen 5.0
+ * @param[in] connection       The connection handle
+ * @param[in] pm       The path manager of Multipath TCP
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE                              Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED             Not supported
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission denied
+ */
+int connection_mptcp_set_path_manager(connection_h connection, connection_mptcp_path_manager_e pm);
 
-int connection_mptcp_set_path_manager(connection_mptcp_path_manager_e pm);
-int connection_mptcp_get_path_manager(connection_mptcp_path_manager_e* pm);
+/**
+ * @brief Get the path manager of Multipath TCP
+ * @since_tizen 5.0
+ * @param[in] connection       The connection handle
+ * @param[out] pm      The path manager of Multipath TCP
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE                              Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED             Not supported
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission denied
+ */
+int connection_mptcp_get_path_manager(connection_h connection, connection_mptcp_path_manager_e* pm);
 
-int connection_mptcp_set_scheduler(connection_mptcp_scheduler_e scheduler);
-int connection_mptcp_get_scheduler(connection_mptcp_scheduler_e* scheduler);
+/**
+ * @brief Set the path manager of Multipath TCP
+ * @since_tizen 5.0
+ * @param[in] connection       The connection handle
+ * @param[in] scheduler                The schedduler of Multipath TCP
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE                              Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED             Not supported
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission denied
+ */
+int connection_mptcp_set_scheduler(connection_h connection, connection_mptcp_scheduler_e scheduler);
+
+/**
+ * @brief Set the path manager of Multipath TCP
+ * @since_tizen 5.0
+ * @param[in] connection       The connection handle
+ * @param[out] scheduler               The schedduler of Multipath TCP
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE                              Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED             Not supported
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission denied
+ */
+int connection_mptcp_get_scheduler(connection_h connection, connection_mptcp_scheduler_e* scheduler);
 
 /**
 * @}
index d05f0ad..f38e454 100755 (executable)
@@ -192,6 +192,7 @@ void _connection_libnet_set_type_changed_cb(libnet_type_changed_cb callback) NO_
 void _connection_libnet_set_ip_changed_cb(libnet_ip_changed_cb callback);
 void _connection_libnet_set_proxy_changed_cb(libnet_proxy_changed_cb callback);
 
+bool _connection_check_handle_validity(connection_h connection);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 4ae5640..51261f8 100755 (executable)
@@ -74,6 +74,11 @@ static bool __connection_check_handle_validity(connection_h connection)
        return ret;
 }
 
+bool _connection_check_handle_validity(connection_h connection)
+{
+       return __connection_check_handle_validity(connection);
+}
+
 static connection_type_changed_cb
 __connection_get_type_changed_callback(connection_handle_s *local_handle)
 {
index c0cf639..88546b0 100644 (file)
 #include "net_connection_private.h"
 #include "net_connection_mptcp_private.h"
 
-EXPORT_API int connection_mptcp_enable(connection_mptcp_enable_e enable)
+EXPORT_API int connection_mptcp_is_supported(connection_h connection, bool* supported)
 {
+       if (!(_connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       *supported = _connection_libnet_mptcp_supported();
+       return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_mptcp_enable(connection_h connection, connection_mptcp_enable_e enable)
+{
+       if (!(_connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
        // check MPTCP support
        if (_connection_libnet_mptcp_supported() == FALSE) {
                CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
@@ -39,8 +55,13 @@ EXPORT_API int connection_mptcp_enable(connection_mptcp_enable_e enable)
        return _connection_libnet_mptcp_enable(enable);
 }
 
-EXPORT_API int connection_mptcp_disable(void)
+EXPORT_API int connection_mptcp_disable(connection_h connection)
 {
+       if (!(_connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
        // check MPTCP support
        if (_connection_libnet_mptcp_supported() == FALSE) {
                CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
@@ -50,8 +71,13 @@ EXPORT_API int connection_mptcp_disable(void)
        return _connection_libnet_mptcp_enable(CONNECTION_MPTCP_DISABLE);
 }
 
-EXPORT_API int connection_mptcp_get_enabled(connection_mptcp_enable_e* enable)
+EXPORT_API int connection_mptcp_get_enabled(connection_h connection, connection_mptcp_enable_e* enable)
 {
+       if (!(_connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
        // check MPTCP support
        if (_connection_libnet_mptcp_supported() == FALSE) {
                CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
@@ -67,8 +93,13 @@ EXPORT_API int connection_mptcp_get_enabled(connection_mptcp_enable_e* enable)
 }
 
 
-EXPORT_API int connection_mptcp_set_path_manager(connection_mptcp_path_manager_e pm)
+EXPORT_API int connection_mptcp_set_path_manager(connection_h connection, connection_mptcp_path_manager_e pm)
 {
+       if (!(_connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
        // check MPTCP support
        if (_connection_libnet_mptcp_supported() == FALSE) {
                CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
@@ -78,8 +109,13 @@ EXPORT_API int connection_mptcp_set_path_manager(connection_mptcp_path_manager_e
        return _connection_libnet_mptcp_set_path_manager(pm);
 }
 
-EXPORT_API int connection_mptcp_get_path_manager(connection_mptcp_path_manager_e* pm)
+EXPORT_API int connection_mptcp_get_path_manager(connection_h connection, connection_mptcp_path_manager_e* pm)
 {
+       if (!(_connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
        // check MPTCP support
        if (_connection_libnet_mptcp_supported() == FALSE) {
                CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
@@ -95,8 +131,13 @@ EXPORT_API int connection_mptcp_get_path_manager(connection_mptcp_path_manager_e
 }
 
 
-EXPORT_API int connection_mptcp_set_scheduler(connection_mptcp_scheduler_e scheduler)
+EXPORT_API int connection_mptcp_set_scheduler(connection_h connection, connection_mptcp_scheduler_e scheduler)
 {
+       if (!(_connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
        // check MPTCP support
        if (_connection_libnet_mptcp_supported() == FALSE) {
                CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
@@ -106,8 +147,13 @@ EXPORT_API int connection_mptcp_set_scheduler(connection_mptcp_scheduler_e sched
        return _connection_libnet_mptcp_set_scheduler(scheduler);
 }
 
-EXPORT_API int connection_mptcp_get_scheduler(connection_mptcp_scheduler_e* scheduler)
+EXPORT_API int connection_mptcp_get_scheduler(connection_h connection, connection_mptcp_scheduler_e* scheduler)
 {
+       if (!(_connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
        // check MPTCP support
        if (_connection_libnet_mptcp_supported() == FALSE) {
                CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
index 350bae9..4864e36 100755 (executable)
@@ -2245,8 +2245,15 @@ int test_get_tcpdump_state(void)
 int test_mptcp_enable(void)
 {
        int rv = 0;
-       rv = connection_mptcp_enable(CONNECTION_MPTCP_ENABLE_ALL);
+       bool supported = false;
+       rv = connection_mptcp_is_supported(connection, &supported);
+       if (rv != CONNECTION_ERROR_NONE) {
+               printf("Failure[%s]\n", test_print_error(rv));
+               return -1;
+       }
+       printf("MPTCP Support: %d\n", supported);
 
+       rv = connection_mptcp_enable(connection, CONNECTION_MPTCP_ENABLE_ALL);
        if (rv != CONNECTION_ERROR_NONE) {
                printf("Failure[%s]\n", test_print_error(rv));
                return -1;
@@ -2257,7 +2264,7 @@ int test_mptcp_enable(void)
 int test_mptcp_disable(void)
 {
        int rv = 0;
-       rv = connection_mptcp_disable();
+       rv = connection_mptcp_disable(connection);
 
        if (rv != CONNECTION_ERROR_NONE) {
                printf("Failure[%s]\n", test_print_error(rv));
@@ -2274,10 +2281,10 @@ int test_mptcp_set_path_manager(void)
 
        switch (input) {
        case 1:
-               rv = connection_mptcp_set_path_manager(CONNECTION_MPTCP_PM_DEFAULT);
+               rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_DEFAULT);
                break;
        case 2:
-               rv = connection_mptcp_set_path_manager(CONNECTION_MPTCP_PM_FULLMESH);
+               rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_FULLMESH);
                break;
        default:
                printf("Invalid input!!\n");
@@ -2297,7 +2304,7 @@ int test_mptcp_get_path_manager(void)
        int rv = 0;
        connection_mptcp_path_manager_e pm;
 
-       rv = connection_mptcp_get_path_manager(&pm);
+       rv = connection_mptcp_get_path_manager(connection, &pm);
        if (rv != CONNECTION_ERROR_NONE) {
                printf("Failure[%s]\n", test_print_error(rv));
                return -1;
@@ -2326,10 +2333,10 @@ int test_mptcp_set_scheduler(void)
 
        switch (input) {
        case 1:
-               rv = connection_mptcp_set_scheduler(CONNECTION_MPTCP_SCHEDULER_DEFAULT);
+               rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_DEFAULT);
                break;
        case 2:
-               rv = connection_mptcp_set_scheduler(CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN);
+               rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN);
                break;
        default:
                printf("Invalid input!!\n");
@@ -2349,7 +2356,7 @@ int test_mptcp_get_scheduler(void)
        int rv = 0;
        connection_mptcp_scheduler_e scheduler;
 
-       rv = connection_mptcp_get_scheduler(&scheduler);
+       rv = connection_mptcp_get_scheduler(connection, &scheduler);
        if (rv != CONNECTION_ERROR_NONE) {
                printf("Failure[%s]\n", test_print_error(rv));
                return -1;