Fix wrong function name
[platform/core/api/connection.git] / src / connection_mptcp.c
1 /*
2  * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License")
5 {
6 }
7
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
20 #include <glib.h>
21
22 #include "connection_extension.h"
23 #include "net_connection_private.h"
24 #include "net_connection_mptcp_private.h"
25
26 EXPORT_API int connection_mptcp_is_supported(connection_h connection, bool* supported)
27 {
28         if (!(_connection_check_handle_validity(connection))) {
29                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
30                 return CONNECTION_ERROR_INVALID_PARAMETER;
31         }
32
33         *supported = _connection_libnet_mptcp_supported();
34         return CONNECTION_ERROR_NONE;
35 }
36
37 EXPORT_API int connection_mptcp_enable(connection_h connection, connection_mptcp_enable_e enable)
38 {
39         if (!(_connection_check_handle_validity(connection))) {
40                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
41                 return CONNECTION_ERROR_INVALID_PARAMETER;
42         }
43
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;
48         }
49
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;
54         }
55
56         return _connection_libnet_mptcp_enable(enable);
57 }
58
59 EXPORT_API int connection_mptcp_disable(connection_h connection)
60 {
61         if (!(_connection_check_handle_validity(connection))) {
62                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
63                 return CONNECTION_ERROR_INVALID_PARAMETER;
64         }
65
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;
70         }
71
72         return _connection_libnet_mptcp_enable(CONNECTION_MPTCP_DISABLE);
73 }
74
75 EXPORT_API int connection_mptcp_get_enabled(connection_h connection, connection_mptcp_enable_e* enable)
76 {
77         if (!(_connection_check_handle_validity(connection))) {
78                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
79                 return CONNECTION_ERROR_INVALID_PARAMETER;
80         }
81
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;
86         }
87
88         if (enable == NULL) {
89                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
90                 return CONNECTION_ERROR_INVALID_PARAMETER;
91         }
92
93         return _connection_libnet_mptcp_get_enabled(enable);
94 }
95
96
97 EXPORT_API int connection_mptcp_set_path_manager(connection_h connection, connection_mptcp_path_manager_e pm)
98 {
99         if (!(_connection_check_handle_validity(connection))) {
100                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
101                 return CONNECTION_ERROR_INVALID_PARAMETER;
102         }
103
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;
108         }
109
110         return _connection_libnet_mptcp_set_path_manager(pm);
111 }
112
113 EXPORT_API int connection_mptcp_get_path_manager(connection_h connection, connection_mptcp_path_manager_e* pm)
114 {
115         if (!(_connection_check_handle_validity(connection))) {
116                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
117                 return CONNECTION_ERROR_INVALID_PARAMETER;
118         }
119
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;
124         }
125
126         if (pm == NULL) {
127                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
128                 return CONNECTION_ERROR_INVALID_PARAMETER;
129         }
130
131         return _connection_libnet_mptcp_get_path_manager(pm);
132 }
133
134
135 EXPORT_API int connection_mptcp_set_scheduler(connection_h connection, connection_mptcp_scheduler_e scheduler)
136 {
137         if (!(_connection_check_handle_validity(connection))) {
138                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
139                 return CONNECTION_ERROR_INVALID_PARAMETER;
140         }
141
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;
146         }
147
148         return _connection_libnet_mptcp_set_scheduler(scheduler);
149 }
150
151 EXPORT_API int connection_mptcp_get_scheduler(connection_h connection, connection_mptcp_scheduler_e* scheduler)
152 {
153         if (!(_connection_check_handle_validity(connection))) {
154                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
155                 return CONNECTION_ERROR_INVALID_PARAMETER;
156         }
157
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;
162         }
163
164         if (scheduler == NULL) {
165                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
166                 return CONNECTION_ERROR_INVALID_PARAMETER;
167         }
168
169         return _connection_libnet_mptcp_get_scheduler(scheduler);
170 }
171
172