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 || enable > CONNECTION_MPTCP_ENABLE_SOCKOPT) {
52 CONNECTION_LOG(CONNECTION_ERROR, "Use connection_mptcp_disable()");
53 return CONNECTION_ERROR_INVALID_PARAMETER;
56 return _connection_libnet_mptcp_enable(enable);
59 EXPORT_API int connection_mptcp_disable(connection_h connection)
61 if (!(_connection_check_handle_validity(connection))) {
62 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
63 return CONNECTION_ERROR_INVALID_PARAMETER;
66 // check MPTCP support
67 if (_connection_libnet_mptcp_supported() == FALSE) {
68 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
69 return CONNECTION_ERROR_NOT_SUPPORTED;
72 return _connection_libnet_mptcp_enable(CONNECTION_MPTCP_DISABLE);
75 EXPORT_API int connection_mptcp_get_enabled(connection_h connection, connection_mptcp_enable_e* enable)
77 if (!(_connection_check_handle_validity(connection))) {
78 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
79 return CONNECTION_ERROR_INVALID_PARAMETER;
82 // check MPTCP support
83 if (_connection_libnet_mptcp_supported() == FALSE) {
84 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
85 return CONNECTION_ERROR_NOT_SUPPORTED;
89 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
90 return CONNECTION_ERROR_INVALID_PARAMETER;
93 return _connection_libnet_mptcp_get_enabled(enable);
97 EXPORT_API int connection_mptcp_set_path_manager(connection_h connection, connection_mptcp_path_manager_e pm)
99 if (!(_connection_check_handle_validity(connection))) {
100 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
101 return CONNECTION_ERROR_INVALID_PARAMETER;
104 // check MPTCP support
105 if (_connection_libnet_mptcp_supported() == FALSE) {
106 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
107 return CONNECTION_ERROR_NOT_SUPPORTED;
110 return _connection_libnet_mptcp_set_path_manager(pm);
113 EXPORT_API int connection_mptcp_get_path_manager(connection_h connection, connection_mptcp_path_manager_e* pm)
115 if (!(_connection_check_handle_validity(connection))) {
116 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
117 return CONNECTION_ERROR_INVALID_PARAMETER;
120 // check MPTCP support
121 if (_connection_libnet_mptcp_supported() == FALSE) {
122 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
123 return CONNECTION_ERROR_NOT_SUPPORTED;
127 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
128 return CONNECTION_ERROR_INVALID_PARAMETER;
131 return _connection_libnet_mptcp_get_path_manager(pm);
135 EXPORT_API int connection_mptcp_set_scheduler(connection_h connection, connection_mptcp_scheduler_e scheduler)
137 if (!(_connection_check_handle_validity(connection))) {
138 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
139 return CONNECTION_ERROR_INVALID_PARAMETER;
142 // check MPTCP support
143 if (_connection_libnet_mptcp_supported() == FALSE) {
144 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
145 return CONNECTION_ERROR_NOT_SUPPORTED;
148 return _connection_libnet_mptcp_set_scheduler(scheduler);
151 EXPORT_API int connection_mptcp_get_scheduler(connection_h connection, connection_mptcp_scheduler_e* scheduler)
153 if (!(_connection_check_handle_validity(connection))) {
154 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
155 return CONNECTION_ERROR_INVALID_PARAMETER;
158 // check MPTCP support
159 if (_connection_libnet_mptcp_supported() == FALSE) {
160 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
161 return CONNECTION_ERROR_NOT_SUPPORTED;
164 if (scheduler == NULL) {
165 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
166 return CONNECTION_ERROR_INVALID_PARAMETER;
169 return _connection_libnet_mptcp_get_scheduler(scheduler);