c0cf63950aa24d0d43f5400dec2fe3c9853e2b7f
[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_enable(connection_mptcp_enable_e enable)
27 {
28         // check MPTCP support
29         if (_connection_libnet_mptcp_supported() == FALSE) {
30                 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
31                 return CONNECTION_ERROR_NOT_SUPPORTED;
32         }
33
34         if (enable == CONNECTION_MPTCP_DISABLE) {
35                 CONNECTION_LOG(CONNECTION_ERROR, "Use connection_mptcp_disable()");
36                 return CONNECTION_ERROR_INVALID_PARAMETER;
37         }
38
39         return _connection_libnet_mptcp_enable(enable);
40 }
41
42 EXPORT_API int connection_mptcp_disable(void)
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         return _connection_libnet_mptcp_enable(CONNECTION_MPTCP_DISABLE);
51 }
52
53 EXPORT_API int connection_mptcp_get_enabled(connection_mptcp_enable_e* enable)
54 {
55         // check MPTCP support
56         if (_connection_libnet_mptcp_supported() == FALSE) {
57                 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
58                 return CONNECTION_ERROR_NOT_SUPPORTED;
59         }
60
61         if (enable == NULL) {
62                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
63                 return CONNECTION_ERROR_INVALID_PARAMETER;
64         }
65
66         return _connection_libnet_mptcp_get_enabled(enable);
67 }
68
69
70 EXPORT_API int connection_mptcp_set_path_manager(connection_mptcp_path_manager_e pm)
71 {
72         // check MPTCP support
73         if (_connection_libnet_mptcp_supported() == FALSE) {
74                 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
75                 return CONNECTION_ERROR_NOT_SUPPORTED;
76         }
77
78         return _connection_libnet_mptcp_set_path_manager(pm);
79 }
80
81 EXPORT_API int connection_mptcp_get_path_manager(connection_mptcp_path_manager_e* pm)
82 {
83         // check MPTCP support
84         if (_connection_libnet_mptcp_supported() == FALSE) {
85                 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
86                 return CONNECTION_ERROR_NOT_SUPPORTED;
87         }
88
89         if (pm == NULL) {
90                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
91                 return CONNECTION_ERROR_INVALID_PARAMETER;
92         }
93
94         return _connection_libnet_mptcp_get_path_manager(pm);
95 }
96
97
98 EXPORT_API int connection_mptcp_set_scheduler(connection_mptcp_scheduler_e scheduler)
99 {
100         // check MPTCP support
101         if (_connection_libnet_mptcp_supported() == FALSE) {
102                 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
103                 return CONNECTION_ERROR_NOT_SUPPORTED;
104         }
105
106         return _connection_libnet_mptcp_set_scheduler(scheduler);
107 }
108
109 EXPORT_API int connection_mptcp_get_scheduler(connection_mptcp_scheduler_e* scheduler)
110 {
111         // check MPTCP support
112         if (_connection_libnet_mptcp_supported() == FALSE) {
113                 CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported");
114                 return CONNECTION_ERROR_NOT_SUPPORTED;
115         }
116
117         if (scheduler == NULL) {
118                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
119                 return CONNECTION_ERROR_INVALID_PARAMETER;
120         }
121
122         return _connection_libnet_mptcp_get_scheduler(scheduler);
123 }
124
125