#ifndef __TIZEN_NETWORK_CONNECTION_EXTENSION_H__
#define __TIZEN_NETWORK_CONNECTION_EXTENSION_H__
+#include "net_connection.h"
+#include "network-mptcp-intf.h"
+
#ifdef __cplusplus
extern "C" {
#endif
*/
int connection_profile_get_tcpdump_state(connection_h connection, gboolean *tcpdump_state);
+
+typedef enum {
+ CONNECTION_MPTCP_DISABLE = 0,
+ CONNECTION_MPTCP_ENABLE_ALL = 1,
+ CONNECTION_MPTCP_ENABLE_SOCKOPT = 2,
+} connection_mptcp_enable_e;
+
+typedef enum {
+ CONNECTION_MPTCP_PM_UNKNOWN,
+ CONNECTION_MPTCP_PM_DEFAULT,
+ CONNECTION_MPTCP_PM_FULLMESH,
+} connection_mptcp_path_manager_e;
+
+typedef enum {
+ CONNECTION_MPTCP_SCHEDULER_UNKNOWN,
+ CONNECTION_MPTCP_SCHEDULER_DEFAULT,
+ CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN,
+} 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);
+
+int connection_mptcp_set_path_manager(connection_mptcp_path_manager_e pm);
+int connection_mptcp_get_path_manager(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);
+
/**
* @}
*/
--- /dev/null
+#ifndef __CONNECTION_MPTCP_H__
+#define __CONNECTION_MPTCP_H__
+
+#include "connection_extension.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+gboolean _connection_libnet_mptcp_supported();
+int _connection_libnet_mptcp_enable(connection_mptcp_enable_e enable);
+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_get_path_manager(connection_mptcp_path_manager_e* pm);
+int _connection_libnet_mptcp_set_scheduler(connection_mptcp_scheduler_e scheduler);
+int _connection_libnet_mptcp_get_scheduler(connection_mptcp_scheduler_e* scheduler);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Name: capi-network-connection
Summary: Network Connection library in TIZEN C API
-Version: 1.0.108
+Version: 1.0.109
Release: 1
Group: System/Network
License: Apache-2.0
--- /dev/null
+/*
+ * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+{
+}
+
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+
+#include "connection_extension.h"
+#include "net_connection_private.h"
+#include "net_connection_mptcp_private.h"
+
+EXPORT_API int connection_mptcp_enable(connection_mptcp_enable_e enable)
+{
+ // check MPTCP support
+ if (_connection_libnet_mptcp_supported() == FALSE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
+ return CONNECTION_ERROR_NOT_SUPPORTED;
+ }
+
+ if (enable == CONNECTION_MPTCP_DISABLE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Use connection_mptcp_disable()");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_mptcp_enable(enable);
+}
+
+EXPORT_API int connection_mptcp_disable(void)
+{
+ // check MPTCP support
+ if (_connection_libnet_mptcp_supported() == FALSE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
+ return CONNECTION_ERROR_NOT_SUPPORTED;
+ }
+
+ return _connection_libnet_mptcp_enable(CONNECTION_MPTCP_DISABLE);
+}
+
+EXPORT_API int connection_mptcp_get_enabled(connection_mptcp_enable_e* enable)
+{
+ // check MPTCP support
+ if (_connection_libnet_mptcp_supported() == FALSE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
+ return CONNECTION_ERROR_NOT_SUPPORTED;
+ }
+
+ if (enable == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_mptcp_get_enabled(enable);
+}
+
+
+EXPORT_API int connection_mptcp_set_path_manager(connection_mptcp_path_manager_e pm)
+{
+ // check MPTCP support
+ if (_connection_libnet_mptcp_supported() == FALSE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
+ return CONNECTION_ERROR_NOT_SUPPORTED;
+ }
+
+ return _connection_libnet_mptcp_set_path_manager(pm);
+}
+
+EXPORT_API int connection_mptcp_get_path_manager(connection_mptcp_path_manager_e* pm)
+{
+ // check MPTCP support
+ if (_connection_libnet_mptcp_supported() == FALSE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
+ return CONNECTION_ERROR_NOT_SUPPORTED;
+ }
+
+ if (pm == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_mptcp_get_path_manager(pm);
+}
+
+
+EXPORT_API int connection_mptcp_set_scheduler(connection_mptcp_scheduler_e scheduler)
+{
+ // check MPTCP support
+ if (_connection_libnet_mptcp_supported() == FALSE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
+ return CONNECTION_ERROR_NOT_SUPPORTED;
+ }
+
+ return _connection_libnet_mptcp_set_scheduler(scheduler);
+}
+
+EXPORT_API int connection_mptcp_get_scheduler(connection_mptcp_scheduler_e* scheduler)
+{
+ // check MPTCP support
+ if (_connection_libnet_mptcp_supported() == FALSE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
+ return CONNECTION_ERROR_NOT_SUPPORTED;
+ }
+
+ if (scheduler == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_mptcp_get_scheduler(scheduler);
+}
+
+
--- /dev/null
+/*
+ * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+
+#include "net_connection_private.h"
+#include "connection_extension.h"
+#include "net_connection_mptcp_private.h"
+
+static const char* __convert_mptcp_path_manager_enum_to_str(connection_mptcp_path_manager_e pm)
+{
+ switch (pm) {
+ case CONNECTION_MPTCP_PM_UNKNOWN:
+ return NULL;
+ case CONNECTION_MPTCP_PM_DEFAULT:
+ return "default";
+ case CONNECTION_MPTCP_PM_FULLMESH:
+ return "fullmesh";
+ }
+ return NULL;
+}
+
+static connection_mptcp_path_manager_e __convert_mptcp_path_manager_str_to_enum(char* pm)
+{
+ if (g_strcmp0(pm, "default") == 0)
+ return CONNECTION_MPTCP_PM_DEFAULT;
+ if (g_strcmp0(pm, "fullmesh") == 0)
+ return CONNECTION_MPTCP_PM_FULLMESH;
+ return CONNECTION_MPTCP_PM_UNKNOWN;
+}
+
+static const char* __convert_mptcp_scheduler_enum_to_str(connection_mptcp_scheduler_e scheduler)
+{
+ switch (scheduler) {
+ case CONNECTION_MPTCP_SCHEDULER_UNKNOWN:
+ return NULL;
+ case CONNECTION_MPTCP_SCHEDULER_DEFAULT:
+ return "default";
+ case CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN:
+ return "roundrobin";
+ }
+ return NULL;
+}
+
+static connection_mptcp_scheduler_e __convert_mptcp_scheduler_str_to_enum(char *scheduler)
+{
+ if (g_strcmp0(scheduler, "default") == 0)
+ return CONNECTION_MPTCP_SCHEDULER_DEFAULT;
+ if (g_strcmp0(scheduler, "roundrobin") == 0)
+ return CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN;
+ return CONNECTION_MPTCP_SCHEDULER_UNKNOWN;
+}
+
+gboolean _connection_libnet_mptcp_supported()
+{
+ int rv = 0;
+ gboolean support = false;
+
+ rv = net_mptcp_supported(&support);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return false;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable MPTCP [%d]", rv);
+ return false;
+ }
+
+ return support;
+}
+
+int _connection_libnet_mptcp_enable(connection_mptcp_enable_e enable)
+{
+ int rv = 0;
+
+ rv = net_mptcp_set_enable((int)enable);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable MPTCP [%d]", rv);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_mptcp_get_enabled(connection_mptcp_enable_e* enable)
+{
+ int rv = 0;
+ int result = 0;
+
+ rv = net_mptcp_get_enabled(&result);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MPTCP enabled state [%d]", rv);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ *enable = (connection_mptcp_enable_e)result;
+ return CONNECTION_ERROR_NONE;
+}
+
+
+int _connection_libnet_mptcp_set_path_manager(connection_mptcp_path_manager_e pm)
+{
+ int rv = 0;
+ const char* str = __convert_mptcp_path_manager_enum_to_str(pm);
+ CONNECTION_LOG(CONNECTION_ERROR, "set path manager %s", str);
+
+ if (str == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid Parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ rv = net_mptcp_set_path_manager(str);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to set MPTCP path manager [%d]", rv);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_mptcp_get_path_manager(connection_mptcp_path_manager_e* pm)
+{
+ int rv = 0;
+ char* result = NULL;
+
+ rv = net_mptcp_get_path_manager(&result);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } 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, "get path manager %s", result);
+ *pm = __convert_mptcp_path_manager_str_to_enum(result);
+ g_free(result);
+ return CONNECTION_ERROR_NONE;
+}
+
+
+int _connection_libnet_mptcp_set_scheduler(connection_mptcp_scheduler_e scheduler)
+{
+ int rv = 0;
+ const char *str = __convert_mptcp_scheduler_enum_to_str(scheduler);
+ CONNECTION_LOG(CONNECTION_ERROR, "set scheduler %s", str);
+
+ if (str == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid Parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ rv = net_mptcp_set_scheduler(str);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to set MPTCP scheduler [%d]", rv);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_mptcp_get_scheduler(connection_mptcp_scheduler_e* scheduler)
+{
+ int rv = 0;
+ char* result = NULL;
+
+ rv = net_mptcp_get_scheduler(&result);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } 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, "get scheduler %s", result);
+ *scheduler = __convert_mptcp_scheduler_str_to_enum(result);
+ g_free(result);
+ return CONNECTION_ERROR_NONE;
+}
return 1;
}
+int test_mptcp_enable(void)
+{
+ int rv = 0;
+ rv = connection_mptcp_enable(CONNECTION_MPTCP_ENABLE_ALL);
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+ return 1;
+}
+
+int test_mptcp_disable(void)
+{
+ int rv = 0;
+ rv = connection_mptcp_disable();
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+ return 1;
+}
+
+int test_mptcp_set_path_manager(void)
+{
+ int rv = 0;
+ int input = 0;
+ rv = test_get_user_int("Input Path Manager (1: default, 2: fullmesh)", &input);
+
+ switch (input) {
+ case 1:
+ rv = connection_mptcp_set_path_manager(CONNECTION_MPTCP_PM_DEFAULT);
+ break;
+ case 2:
+ rv = connection_mptcp_set_path_manager(CONNECTION_MPTCP_PM_FULLMESH);
+ break;
+ default:
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_mptcp_get_path_manager(void)
+{
+ int rv = 0;
+ connection_mptcp_path_manager_e pm;
+
+ rv = connection_mptcp_get_path_manager(&pm);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ switch (pm) {
+ case CONNECTION_MPTCP_PM_DEFAULT:
+ printf("Path Manager: Default\n");
+ break;
+ case CONNECTION_MPTCP_PM_FULLMESH:
+ printf("Path Manager: FullMesh\n");
+ break;
+ default:
+ printf("Error: Invalid Path Manager\n");
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_mptcp_set_scheduler(void)
+{
+ int rv = 0;
+ int input = 0;
+ rv = test_get_user_int("Input Scheduler (1: default, 2: roundrobin)", &input);
+
+ switch (input) {
+ case 1:
+ rv = connection_mptcp_set_scheduler(CONNECTION_MPTCP_SCHEDULER_DEFAULT);
+ break;
+ case 2:
+ rv = connection_mptcp_set_scheduler(CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN);
+ break;
+ default:
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_mptcp_get_scheduler(void)
+{
+ int rv = 0;
+ connection_mptcp_scheduler_e scheduler;
+
+ rv = connection_mptcp_get_scheduler(&scheduler);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ switch (scheduler) {
+ case CONNECTION_MPTCP_SCHEDULER_DEFAULT:
+ printf("Scheduler: Default\n");
+ break;
+ case CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN:
+ printf("Scheduler: RountRobin\n");
+ break;
+ default:
+ printf("Error: Invalid Scheduler\n");
+ return -1;
+ }
+
+ return 1;
+}
+
int main(int argc, char **argv)
{
GMainLoop *mainloop;
printf("H - Start TCP Dump\n");
printf("I - Stop TCP Dump\n");
printf("J - Get TCP Dump State\n");
+ printf("K - Enable MPTCP (internal)\n");
+ printf("L - Disable MPTCP (internal)\n");
+ printf("M - Set MPTCP Path Manager (internal)\n");
+ printf("N - Get MPTCP Path Manager (internal)\n");
+ printf("O - Set MPTCP Scheduler (internal)\n");
+ printf("P - Get MPTCP Scheduler (internal)\n");
printf(LOG_RED "0 - Exit \n" LOG_END);
printf("ENTER - Show options menu.......\n");
}
case 'J':
rv = test_get_tcpdump_state();
break;
+ case 'K':
+ rv = test_mptcp_enable();
+ break;
+ case 'L':
+ rv = test_mptcp_disable();
+ break;
+ case 'M':
+ rv = test_mptcp_set_path_manager();
+ break;
+ case 'N':
+ rv = test_mptcp_get_path_manager();
+ break;
+ case 'O':
+ rv = test_mptcp_set_scheduler();
+ break;
+ case 'P':
+ rv = test_mptcp_get_scheduler();
+ break;
}