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();
34 return CONNECTION_ERROR_NONE;
37 EXPORT_API int connection_mptcp_enable(connection_h connection, connection_mptcp_enable_e enable)
39 if (!(_connection_check_handle_validity(connection))) {
40 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
41 return CONNECTION_ERROR_INVALID_PARAMETER;
44 // check MPTCP support
45 if (_connection_libnet_mptcp_supported() == FALSE) {
46 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
47 return CONNECTION_ERROR_NOT_SUPPORTED;
50 if (enable == CONNECTION_MPTCP_DISABLE) {
51 CONNECTION_LOG(CONNECTION_ERROR, "Use connection_mptcp_disable()");
52 return CONNECTION_ERROR_INVALID_PARAMETER;
55 return _connection_libnet_mptcp_enable(enable);
58 EXPORT_API int connection_mptcp_disable(connection_h connection)
60 if (!(_connection_check_handle_validity(connection))) {
61 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
62 return CONNECTION_ERROR_INVALID_PARAMETER;
65 // check MPTCP support
66 if (_connection_libnet_mptcp_supported() == FALSE) {
67 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
68 return CONNECTION_ERROR_NOT_SUPPORTED;
71 return _connection_libnet_mptcp_enable(CONNECTION_MPTCP_DISABLE);
74 EXPORT_API int connection_mptcp_get_enabled(connection_h connection, connection_mptcp_enable_e* enable)
76 if (!(_connection_check_handle_validity(connection))) {
77 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
78 return CONNECTION_ERROR_INVALID_PARAMETER;
81 // check MPTCP support
82 if (_connection_libnet_mptcp_supported() == FALSE) {
83 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
84 return CONNECTION_ERROR_NOT_SUPPORTED;
88 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
89 return CONNECTION_ERROR_INVALID_PARAMETER;
92 return _connection_libnet_mptcp_get_enabled(enable);
96 EXPORT_API int connection_mptcp_set_path_manager(connection_h connection, connection_mptcp_path_manager_e pm)
98 if (!(_connection_check_handle_validity(connection))) {
99 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
100 return CONNECTION_ERROR_INVALID_PARAMETER;
103 // check MPTCP support
104 if (_connection_libnet_mptcp_supported() == FALSE) {
105 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
106 return CONNECTION_ERROR_NOT_SUPPORTED;
109 return _connection_libnet_mptcp_set_path_manager(pm);
112 EXPORT_API int connection_mptcp_get_path_manager(connection_h connection, connection_mptcp_path_manager_e* pm)
114 if (!(_connection_check_handle_validity(connection))) {
115 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
116 return CONNECTION_ERROR_INVALID_PARAMETER;
119 // check MPTCP support
120 if (_connection_libnet_mptcp_supported() == FALSE) {
121 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
122 return CONNECTION_ERROR_NOT_SUPPORTED;
126 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
127 return CONNECTION_ERROR_INVALID_PARAMETER;
130 return _connection_libnet_mptcp_get_path_manager(pm);
134 EXPORT_API int connection_mptcp_set_scheduler(connection_h connection, connection_mptcp_scheduler_e scheduler)
136 if (!(_connection_check_handle_validity(connection))) {
137 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
138 return CONNECTION_ERROR_INVALID_PARAMETER;
141 // check MPTCP support
142 if (_connection_libnet_mptcp_supported() == FALSE) {
143 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
144 return CONNECTION_ERROR_NOT_SUPPORTED;
147 return _connection_libnet_mptcp_set_scheduler(scheduler);
150 EXPORT_API int connection_mptcp_get_scheduler(connection_h connection, connection_mptcp_scheduler_e* scheduler)
152 if (!(_connection_check_handle_validity(connection))) {
153 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
154 return CONNECTION_ERROR_INVALID_PARAMETER;
157 // check MPTCP support
158 if (_connection_libnet_mptcp_supported() == FALSE) {
159 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
160 return CONNECTION_ERROR_NOT_SUPPORTED;
163 if (scheduler == NULL) {
164 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
165 return CONNECTION_ERROR_INVALID_PARAMETER;
168 return _connection_libnet_mptcp_get_scheduler(scheduler);