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"
26 EXPORT_API int connection_mptcp_is_supported(connection_h connection, bool* supported)
28 if (!(_connection_check_handle_validity(connection))) {
29 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
30 return CONNECTION_ERROR_INVALID_PARAMETER;
33 *supported = _connection_libnet_mptcp_supported(connection);
34 return CONNECTION_ERROR_NONE;
37 EXPORT_API int connection_mptcp_enable(connection_h connection, connection_mptcp_enable_e enable)
39 // check MPTCP support
40 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
41 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
42 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
45 if (!(_connection_check_handle_validity(connection))) {
46 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
47 return CONNECTION_ERROR_INVALID_PARAMETER;
50 if (enable <= CONNECTION_MPTCP_DISABLE
51 || enable > CONNECTION_MPTCP_ENABLE_SOCKOPT) {
52 CONNECTION_LOG(CONNECTION_ERROR, "Use connection_mptcp_disable()"); //LCOV_EXCL_LINE
53 return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
56 return _connection_libnet_mptcp_enable(connection, enable);
59 EXPORT_API int connection_mptcp_disable(connection_h connection)
61 // check MPTCP support
62 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
63 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
64 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
67 if (!(_connection_check_handle_validity(connection))) {
68 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
69 return CONNECTION_ERROR_INVALID_PARAMETER;
72 return _connection_libnet_mptcp_enable(connection, CONNECTION_MPTCP_DISABLE);
75 EXPORT_API int connection_mptcp_get_enabled(connection_h connection, connection_mptcp_enable_e* enable)
77 // check MPTCP support
78 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
79 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
80 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
83 if (!(_connection_check_handle_validity(connection))) {
84 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
85 return CONNECTION_ERROR_INVALID_PARAMETER;
89 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
90 return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
93 return _connection_libnet_mptcp_get_enabled(connection, enable);
97 EXPORT_API int connection_mptcp_set_path_manager(connection_h connection, connection_mptcp_path_manager_e pm)
99 // check MPTCP support
100 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
101 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
102 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
105 if (!(_connection_check_handle_validity(connection))) {
106 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
107 return CONNECTION_ERROR_INVALID_PARAMETER;
110 return _connection_libnet_mptcp_set_path_manager(connection, pm);
113 EXPORT_API int connection_mptcp_get_path_manager(connection_h connection, connection_mptcp_path_manager_e* pm)
115 // check MPTCP support
116 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
117 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
118 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
121 if (!(_connection_check_handle_validity(connection))) {
122 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
123 return CONNECTION_ERROR_INVALID_PARAMETER;
127 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
128 return CONNECTION_ERROR_INVALID_PARAMETER;
131 return _connection_libnet_mptcp_get_path_manager(connection, pm);
135 EXPORT_API int connection_mptcp_set_scheduler(connection_h connection, connection_mptcp_scheduler_e scheduler)
137 // check MPTCP support
138 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
139 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
140 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
143 if (!(_connection_check_handle_validity(connection))) {
144 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
145 return CONNECTION_ERROR_INVALID_PARAMETER;
148 return _connection_libnet_mptcp_set_scheduler(connection, scheduler);
151 EXPORT_API int connection_mptcp_get_scheduler(connection_h connection, connection_mptcp_scheduler_e* scheduler)
153 // check MPTCP support
154 if (_connection_libnet_mptcp_supported(connection) == FALSE) {
155 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE
156 return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
159 if (!(_connection_check_handle_validity(connection))) {
160 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
161 return CONNECTION_ERROR_INVALID_PARAMETER;
164 if (scheduler == NULL) {
165 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
166 return CONNECTION_ERROR_INVALID_PARAMETER;
169 return _connection_libnet_mptcp_get_scheduler(connection, scheduler);