2 * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License")
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include "connection_extension.h"
23 #include "net_connection_private.h"
24 #include "net_connection_mptcp_private.h"
27 EXPORT_API int connection_mptcp_is_supported(connection_h connection, bool* supported)
29 if (!(_connection_check_handle_validity(connection))) {
30 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
31 return CONNECTION_ERROR_INVALID_PARAMETER;
34 *supported = _connection_libnet_mptcp_supported(connection);
35 return CONNECTION_ERROR_NONE;
38 EXPORT_API int connection_mptcp_enable(connection_h connection, connection_mptcp_enable_e enable)
40 // check MPTCP support
41 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
42 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
43 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
46 if (!(_connection_check_handle_validity(connection))) {
47 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
48 return CONNECTION_ERROR_INVALID_PARAMETER;
51 if (enable <= CONNECTION_MPTCP_DISABLE
52 || enable > CONNECTION_MPTCP_ENABLE_SOCKOPT) {
53 CONNECTION_LOG(CONNECTION_ERROR, "Use connection_mptcp_disable()"); //LCOV_EXCL_LINE
54 return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
57 return _connection_libnet_mptcp_enable(connection, enable);
60 EXPORT_API int connection_mptcp_disable(connection_h connection)
62 // check MPTCP support
63 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
64 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
65 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
68 if (!(_connection_check_handle_validity(connection))) {
69 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
70 return CONNECTION_ERROR_INVALID_PARAMETER;
73 return _connection_libnet_mptcp_enable(connection, CONNECTION_MPTCP_DISABLE);
76 EXPORT_API int connection_mptcp_get_enabled(connection_h connection, connection_mptcp_enable_e* enable)
78 // check MPTCP support
79 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
80 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
81 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
84 if (!(_connection_check_handle_validity(connection))) {
85 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
86 return CONNECTION_ERROR_INVALID_PARAMETER;
90 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
91 return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
94 return _connection_libnet_mptcp_get_enabled(connection, enable);
98 EXPORT_API int connection_mptcp_set_path_manager(connection_h connection, connection_mptcp_path_manager_e pm)
100 // check MPTCP support
101 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
102 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
103 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
106 if (!(_connection_check_handle_validity(connection))) {
107 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
108 return CONNECTION_ERROR_INVALID_PARAMETER;
111 return _connection_libnet_mptcp_set_path_manager(connection, pm);
114 EXPORT_API int connection_mptcp_get_path_manager(connection_h connection, connection_mptcp_path_manager_e* pm)
116 // check MPTCP support
117 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
118 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
119 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
122 if (!(_connection_check_handle_validity(connection))) {
123 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
124 return CONNECTION_ERROR_INVALID_PARAMETER;
128 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
129 return CONNECTION_ERROR_INVALID_PARAMETER;
132 return _connection_libnet_mptcp_get_path_manager(connection, pm);
136 EXPORT_API int connection_mptcp_set_scheduler(connection_h connection, connection_mptcp_scheduler_e scheduler)
138 // check MPTCP support
139 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
140 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
141 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
144 if (!(_connection_check_handle_validity(connection))) {
145 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
146 return CONNECTION_ERROR_INVALID_PARAMETER;
149 return _connection_libnet_mptcp_set_scheduler(connection, scheduler);
152 EXPORT_API int connection_mptcp_get_scheduler(connection_h connection, connection_mptcp_scheduler_e* scheduler)
154 // check MPTCP support
155 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
156 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
157 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
160 if (!(_connection_check_handle_validity(connection))) {
161 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
162 return CONNECTION_ERROR_INVALID_PARAMETER;
165 if (scheduler == NULL) {
166 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
167 return CONNECTION_ERROR_INVALID_PARAMETER;
170 return _connection_libnet_mptcp_get_scheduler(connection, scheduler);