5 * Copyright (C) 2007-2013 Intel Corporation. All rights reserved.
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.
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.
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
22 #ifndef __CONNMAN_NETWORK_H
23 #define __CONNMAN_NETWORK_H
28 #include <dbus/dbus.h>
30 #include <connman/device.h>
31 #include <connman/ipconfig.h>
38 #define WIFI_ENCYPTION_MODE_LEN_MAX 6
39 #define WIFI_BSSID_LEN_MAX 6
40 #define MAC_ADDRESS_LENGTH 18
45 * @title: Network premitives
46 * @short_description: Functions for handling networks
49 enum connman_network_type {
50 CONNMAN_NETWORK_TYPE_UNKNOWN = 0,
51 CONNMAN_NETWORK_TYPE_ETHERNET = 1,
52 CONNMAN_NETWORK_TYPE_WIFI = 2,
53 CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN = 8,
54 CONNMAN_NETWORK_TYPE_BLUETOOTH_DUN = 9,
55 CONNMAN_NETWORK_TYPE_CELLULAR = 10,
56 CONNMAN_NETWORK_TYPE_GADGET = 11,
57 CONNMAN_NETWORK_TYPE_VENDOR = 10000,
60 enum connman_network_error {
61 CONNMAN_NETWORK_ERROR_UNKNOWN = 0,
62 CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL = 1,
63 CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL = 2,
64 CONNMAN_NETWORK_ERROR_INVALID_KEY = 3,
65 CONNMAN_NETWORK_ERROR_CONNECT_FAIL = 4,
67 CONNMAN_NETWORK_ERROR_DHCP_FAIL = 5,
68 CONNMAN_NETWORK_ERROR_BLOCKED = 6,
69 CONNMAN_NETWORK_ERROR_AUTHENTICATE_FAIL = 7,
71 CONNMAN_NETWORK_ERROR_BLOCKED = 5,
76 struct connman_bssids {
77 unsigned char bssid[WIFI_BSSID_LEN_MAX];
80 uint16_t assoc_reject_cnt;
81 bool is_last_connected;
82 #if defined TIZEN_EXT_INS
83 int score_last_connected_bssid;
84 int score_assoc_reject;
91 /* Backward compatible
92 * modes of available network */
103 /* connection mode of connected network
104 * based on current linkspeed */
106 CONNECTION_MODE_IEEE80211_UNKNOWN,
107 CONNECTION_MODE_IEEE80211B,
108 CONNECTION_MODE_IEEE80211G,
109 CONNECTION_MODE_IEEE80211N,
110 CONNECTION_MODE_IEEE80211A,
111 CONNECTION_MODE_IEEE80211AC,
115 #define CONNMAN_NETWORK_PRIORITY_LOW -100
116 #define CONNMAN_NETWORK_PRIORITY_DEFAULT 0
117 #define CONNMAN_NETWORK_PRIORITY_HIGH 100
119 struct connman_network;
121 struct connman_network *connman_network_create(const char *identifier,
122 enum connman_network_type type);
124 #define connman_network_ref(network) \
125 connman_network_ref_debug(network, __FILE__, __LINE__, __func__)
127 #define connman_network_unref(network) \
128 connman_network_unref_debug(network, __FILE__, __LINE__, __func__)
130 struct connman_network *
131 connman_network_ref_debug(struct connman_network *network,
132 const char *file, int line, const char *caller);
133 void connman_network_unref_debug(struct connman_network *network,
134 const char *file, int line, const char *caller);
136 enum connman_network_type connman_network_get_type(struct connman_network *network);
137 const char *connman_network_get_identifier(struct connman_network *network);
139 void connman_network_set_index(struct connman_network *network, int index);
140 int connman_network_get_index(struct connman_network *network);
142 void connman_network_set_group(struct connman_network *network,
144 const char *connman_network_get_group(struct connman_network *network);
146 bool connman_network_get_connecting(struct connman_network *network);
147 #if defined TIZEN_EXT
148 void connman_network_set_connecting(struct connman_network *network);
150 #if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET
151 bool connman_network_check_validity(struct connman_network *network);
152 #endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */
153 int connman_network_set_available(struct connman_network *network,
155 bool connman_network_get_available(struct connman_network *network);
156 int connman_network_set_associating(struct connman_network *network,
158 void connman_network_set_error(struct connman_network *network,
159 enum connman_network_error error);
160 int connman_network_set_connected(struct connman_network *network,
162 bool connman_network_get_connected(struct connman_network *network);
163 void connman_network_set_connected_dhcp_later(struct connman_network *network,
166 bool connman_network_get_associating(struct connman_network *network);
168 void connman_network_clear_hidden(void *user_data);
169 int connman_network_connect_hidden(struct connman_network *network,
170 char *identity, char* passphrase, void *user_data);
172 void connman_network_set_ipv4_method(struct connman_network *network,
173 enum connman_ipconfig_method method);
174 void connman_network_set_ipv6_method(struct connman_network *network,
175 enum connman_ipconfig_method method);
176 int connman_network_set_ipaddress(struct connman_network *network,
177 struct connman_ipaddress *ipaddress);
178 int connman_network_set_nameservers(struct connman_network *network,
179 const char *nameservers);
180 int connman_network_set_domain(struct connman_network *network,
182 #if defined TIZEN_EXT
184 * Description: Network client requires additional wifi specific info
186 int connman_network_set_bssid(struct connman_network *network,
187 const unsigned char *bssid);
188 unsigned char *connman_network_get_bssid(struct connman_network *network);
190 int connman_network_set_transition_mode_bssid(struct connman_network *network,
191 const unsigned char *transition_mode_bssid);
193 unsigned char *connman_network_get_transition_mode_bssid(struct connman_network *network);
195 bool connman_network_check_transition_mode(struct connman_network *network1, struct connman_network *network2);
197 int connman_network_set_maxrate(struct connman_network *network,
198 unsigned int maxrate);
200 int connman_network_set_maxspeed(struct connman_network *network,
203 unsigned int connman_network_get_maxrate(struct connman_network *network);
205 int connman_network_get_maxspeed(struct connman_network *network);
207 int connman_network_set_sec_list(struct connman_network *network,
209 void *connman_network_get_sec_list(struct connman_network *network);
211 int connman_network_set_enc_mode(struct connman_network *network,
212 const char *encryption_mode);
213 const char *connman_network_get_enc_mode(struct connman_network *network);
215 int connman_network_set_rsn_mode(struct connman_network *network,
218 int connman_network_set_proxy(struct connman_network *network,
219 const char *proxies);
221 void connman_network_clear_associating(struct connman_network *network);
223 int connman_network_set_keymgmt(struct connman_network *network,
224 unsigned int keymgmt);
225 unsigned int connman_network_get_keymgmt(struct connman_network *network);
226 int connman_network_set_disconnect_reason(struct connman_network *network,
228 int connman_network_get_disconnect_reason(struct connman_network *network);
229 int connman_network_get_assoc_status_code(struct connman_network *network);
230 int connman_network_set_assoc_status_code(struct connman_network *network,
231 int assoc_status_code);
232 int connman_network_set_countrycode(struct connman_network *network, const
233 unsigned char *country_code);
234 unsigned char *connman_network_get_countrycode(struct connman_network *network);
235 int connman_network_set_bssid_list(struct connman_network *network,
237 void *connman_network_get_bssid_list(struct connman_network *network);
238 unsigned int connman_network_get_max_bssid_count(struct connman_network *network);
239 int connman_network_set_last_connected_bssid(struct connman_network *network,
240 const unsigned char *bssid);
241 unsigned char *connman_network_get_last_connected_bssid(struct connman_network *network);
242 void connman_network_set_assoc_reject_table(struct connman_network *network,
243 GHashTable *assoc_reject_table);
244 GHashTable *connman_network_get_assoc_reject_table(struct connman_network *network);
245 __time_t connman_network_get_roam_scan_time(struct connman_network *network);
246 void connman_network_set_roam_scan_time(struct connman_network *network,
247 __time_t roam_scan_time);
248 int connman_network_get_snr(struct connman_network *network);
249 void connman_network_set_snr(struct connman_network *network, int snr);
250 int connman_network_set_phy_mode(struct connman_network *network,
251 ieee80211_modes_e mode);
252 ieee80211_modes_e connman_network_get_phy_mode(struct connman_network *network);
253 int connman_network_set_connection_mode(struct connman_network *network,
254 connection_mode_e mode);
255 connection_mode_e connman_network_get_connection_mode(struct connman_network *network);
256 int set_connected_dhcp(struct connman_network *network);
259 int connman_network_set_name(struct connman_network *network,
261 int connman_network_set_strength(struct connman_network *network,
263 uint8_t connman_network_get_strength(struct connman_network *network);
264 int connman_network_set_frequency(struct connman_network *network,
266 uint16_t connman_network_get_frequency(struct connman_network *network);
267 int connman_network_set_wifi_channel(struct connman_network *network,
269 uint16_t connman_network_get_wifi_channel(struct connman_network *network);
270 int connman_network_set_autoconnect(struct connman_network *network,
273 int connman_network_set_string(struct connman_network *network,
274 const char *key, const char *value);
275 const char *connman_network_get_string(struct connman_network *network,
277 int connman_network_set_bool(struct connman_network *network,
278 const char *key, bool value);
279 bool connman_network_get_bool(struct connman_network *network,
281 int connman_network_set_blob(struct connman_network *network,
282 const char *key, const void *data, unsigned int size);
283 const void *connman_network_get_blob(struct connman_network *network,
284 const char *key, unsigned int *size);
285 #if defined TIZEN_EXT
286 void connman_network_set_vsie_list(struct connman_network *network, GSList *vsie_list);
287 void *connman_network_get_vsie_list(struct connman_network *network);
290 struct connman_device *connman_network_get_device(struct connman_network *network);
292 void *connman_network_get_data(struct connman_network *network);
293 void connman_network_set_data(struct connman_network *network, void *data);
295 void connman_network_update(struct connman_network *network);
297 struct connman_network_driver {
299 enum connman_network_type type;
301 int (*probe) (struct connman_network *network);
302 void (*remove) (struct connman_network *network);
303 int (*connect) (struct connman_network *network);
304 int (*disconnect) (struct connman_network *network);
305 int (*set_autoconnect) (struct connman_network *network,
307 #if defined TIZEN_EXT
308 int (*merge) (struct connman_network *network);
312 int connman_network_driver_register(struct connman_network_driver *driver);
313 void connman_network_driver_unregister(struct connman_network_driver *driver);
315 void connman_network_append_acddbus(DBusMessageIter *dict,
316 struct connman_network *network);
322 #endif /* __CONNMAN_NETWORK_H */