Add new error (ACR-1257)
[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                 CONNECTION_LOG(CONNECTION_ERROR, "Use connection_mptcp_disable()");
52                 return CONNECTION_ERROR_INVALID_PARAMETER;
53         }
54
55         return _connection_libnet_mptcp_enable(enable);
56 }
57
58 EXPORT_API int connection_mptcp_disable(connection_h connection)
59 {
60         if (!(_connection_check_handle_validity(connection))) {
61                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
62                 return CONNECTION_ERROR_INVALID_PARAMETER;
63         }
64
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;
69         }
70
71         return _connection_libnet_mptcp_enable(CONNECTION_MPTCP_DISABLE);
72 }
73
74 EXPORT_API int connection_mptcp_get_enabled(connection_h connection, connection_mptcp_enable_e* enable)
75 {
76         if (!(_connection_check_handle_validity(connection))) {
77                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
78                 return CONNECTION_ERROR_INVALID_PARAMETER;
79         }
80
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;
85         }
86
87         if (enable == NULL) {
88                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
89                 return CONNECTION_ERROR_INVALID_PARAMETER;
90         }
91
92         return _connection_libnet_mptcp_get_enabled(enable);
93 }
94
95
96 EXPORT_API int connection_mptcp_set_path_manager(connection_h connection, connection_mptcp_path_manager_e pm)
97 {
98         if (!(_connection_check_handle_validity(connection))) {
99                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
100                 return CONNECTION_ERROR_INVALID_PARAMETER;
101         }
102
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;
107         }
108
109         return _connection_libnet_mptcp_set_path_manager(pm);
110 }
111
112 EXPORT_API int connection_mptcp_get_path_manager(connection_h connection, connection_mptcp_path_manager_e* pm)
113 {
114         if (!(_connection_check_handle_validity(connection))) {
115                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
116                 return CONNECTION_ERROR_INVALID_PARAMETER;
117         }
118
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;
123         }
124
125         if (pm == NULL) {
126                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
127                 return CONNECTION_ERROR_INVALID_PARAMETER;
128         }
129
130         return _connection_libnet_mptcp_get_path_manager(pm);
131 }
132
133
134 EXPORT_API int connection_mptcp_set_scheduler(connection_h connection, connection_mptcp_scheduler_e scheduler)
135 {
136         if (!(_connection_check_handle_validity(connection))) {
137                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
138                 return CONNECTION_ERROR_INVALID_PARAMETER;
139         }
140
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;
145         }
146
147         return _connection_libnet_mptcp_set_scheduler(scheduler);
148 }
149
150 EXPORT_API int connection_mptcp_get_scheduler(connection_h connection, connection_mptcp_scheduler_e* scheduler)
151 {
152         if (!(_connection_check_handle_validity(connection))) {
153                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
154                 return CONNECTION_ERROR_INVALID_PARAMETER;
155         }
156
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;
161         }
162
163         if (scheduler == NULL) {
164                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
165                 return CONNECTION_ERROR_INVALID_PARAMETER;
166         }
167
168         return _connection_libnet_mptcp_get_scheduler(scheduler);
169 }
170
171