Base Code merged to SPIN 2.4
[platform/upstream/connman.git] / include / service.h
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2014  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifndef __CONNMAN_SERVICE_H
23 #define __CONNMAN_SERVICE_H
24
25 #include <stdbool.h>
26
27 #if defined TIZEN_EXT
28 #include <glib.h>
29 #endif
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36  * SECTION:service
37  * @title: Service premitives
38  * @short_description: Functions for handling services
39  */
40
41 enum connman_service_type {
42         CONNMAN_SERVICE_TYPE_UNKNOWN   = 0,
43         CONNMAN_SERVICE_TYPE_SYSTEM    = 1,
44         CONNMAN_SERVICE_TYPE_ETHERNET  = 2,
45         CONNMAN_SERVICE_TYPE_WIFI      = 3,
46         CONNMAN_SERVICE_TYPE_BLUETOOTH = 4,
47         CONNMAN_SERVICE_TYPE_CELLULAR  = 5,
48         CONNMAN_SERVICE_TYPE_GPS       = 6,
49         CONNMAN_SERVICE_TYPE_VPN       = 7,
50         CONNMAN_SERVICE_TYPE_GADGET    = 8,
51         CONNMAN_SERVICE_TYPE_P2P       = 9,
52 };
53 #define MAX_CONNMAN_SERVICE_TYPES        10
54
55
56 enum connman_service_security {
57         CONNMAN_SERVICE_SECURITY_UNKNOWN = 0,
58         CONNMAN_SERVICE_SECURITY_NONE    = 1,
59         CONNMAN_SERVICE_SECURITY_WEP     = 2,
60         CONNMAN_SERVICE_SECURITY_PSK     = 3,
61         CONNMAN_SERVICE_SECURITY_8021X   = 4,
62         CONNMAN_SERVICE_SECURITY_WPA     = 8,
63         CONNMAN_SERVICE_SECURITY_RSN     = 9,
64 };
65
66 enum connman_service_state {
67         CONNMAN_SERVICE_STATE_UNKNOWN       = 0,
68         CONNMAN_SERVICE_STATE_IDLE          = 1,
69         CONNMAN_SERVICE_STATE_ASSOCIATION   = 2,
70         CONNMAN_SERVICE_STATE_CONFIGURATION = 3,
71         CONNMAN_SERVICE_STATE_READY         = 4,
72         CONNMAN_SERVICE_STATE_ONLINE        = 5,
73         CONNMAN_SERVICE_STATE_DISCONNECT    = 6,
74         CONNMAN_SERVICE_STATE_FAILURE       = 7,
75 };
76
77 enum connman_service_error {
78         CONNMAN_SERVICE_ERROR_UNKNOWN        = 0,
79         CONNMAN_SERVICE_ERROR_OUT_OF_RANGE   = 1,
80         CONNMAN_SERVICE_ERROR_PIN_MISSING    = 2,
81         CONNMAN_SERVICE_ERROR_DHCP_FAILED    = 3,
82         CONNMAN_SERVICE_ERROR_CONNECT_FAILED = 4,
83         CONNMAN_SERVICE_ERROR_LOGIN_FAILED  = 5,
84         CONNMAN_SERVICE_ERROR_AUTH_FAILED    = 6,
85         CONNMAN_SERVICE_ERROR_INVALID_KEY    = 7,
86 };
87
88 enum connman_service_proxy_method {
89         CONNMAN_SERVICE_PROXY_METHOD_UNKNOWN     = 0,
90         CONNMAN_SERVICE_PROXY_METHOD_DIRECT      = 1,
91         CONNMAN_SERVICE_PROXY_METHOD_MANUAL      = 2,
92         CONNMAN_SERVICE_PROXY_METHOD_AUTO        = 3,
93 };
94
95 enum connman_service_connect_reason {
96         CONNMAN_SERVICE_CONNECT_REASON_NONE     = 0,
97         CONNMAN_SERVICE_CONNECT_REASON_AUTO     = 1,
98         CONNMAN_SERVICE_CONNECT_REASON_USER     = 2,
99         CONNMAN_SERVICE_CONNECT_REASON_SESSION  = 3,
100 };
101
102 struct connman_service;
103 struct connman_network;
104
105 struct connman_service *connman_service_create(void);
106
107 #define connman_service_ref(service) \
108         connman_service_ref_debug(service, __FILE__, __LINE__, __func__)
109
110 #define connman_service_unref(service) \
111         connman_service_unref_debug(service, __FILE__, __LINE__, __func__)
112
113 struct connman_service *
114 connman_service_ref_debug(struct connman_service *service,
115                         const char *file, int line, const char *caller);
116 void connman_service_unref_debug(struct connman_service *service,
117                         const char *file, int line, const char *caller);
118
119 enum connman_service_type connman_service_get_type(struct connman_service *service);
120 char *connman_service_get_interface(struct connman_service *service);
121
122 const char *connman_service_get_domainname(struct connman_service *service);
123 char **connman_service_get_nameservers(struct connman_service *service);
124 char **connman_service_get_timeservers_config(struct connman_service *service);
125 char **connman_service_get_timeservers(struct connman_service *service);
126 void connman_service_set_proxy_method(struct connman_service *service, enum connman_service_proxy_method method);
127 enum connman_service_proxy_method connman_service_get_proxy_method(struct connman_service *service);
128 char **connman_service_get_proxy_servers(struct connman_service *service);
129 char **connman_service_get_proxy_excludes(struct connman_service *service);
130 const char *connman_service_get_proxy_url(struct connman_service *service);
131 const char *connman_service_get_proxy_autoconfig(struct connman_service *service);
132 bool connman_service_get_favorite(struct connman_service *service);
133 bool connman_service_get_autoconnect(struct connman_service *service);
134
135 struct connman_service *connman_service_lookup_from_network(struct connman_network *network);
136
137 void connman_service_create_ip4config(struct connman_service *service,
138                                                                 int index);
139 void connman_service_create_ip6config(struct connman_service *service,
140                                                                 int index);
141
142 #if defined TIZEN_EXT
143 /*
144  * Description: TIZEN implements system global connection management.
145  *              It's only for PDP (cellular) bearer. Wi-Fi is managed by ConnMan automatically.
146  *              Reference count can help to manage open/close connection requests by each application.
147  */
148
149 /*
150  * Increase reference count of user-initiated packet data network connection
151  */
152 void connman_service_user_pdn_connection_ref(struct connman_service *service);
153
154 /*
155  * Decrease reference count of user initiated packet data network connection
156  * and return TRUE if counter is zero.
157  */
158 gboolean connman_service_user_pdn_connection_unref_and_test(
159                                         struct connman_service *service);
160
161 /*
162  * Test reference count of user initiated packet data network connection
163  * and return TRUE if counter is zero. No impact to reference count
164  */
165 gboolean connman_service_is_no_ref_user_pdn_connection(
166                                         struct connman_service *service);
167 #endif
168
169 #if defined TIZEN_EXT
170 struct connman_service *connman_service_get_default_connection(void);
171
172 /*
173  * Description: telephony plug-in requires manual PROXY setting
174  */
175 int connman_service_set_proxy(struct connman_service *service,
176                                         const char *proxy, gboolean active);
177 #endif
178
179 #ifdef __cplusplus
180 }
181 #endif
182
183 #endif /* __CONNMAN_SERVICE_H */