gsupplicant: Get the number of scan ssids from supplicant
[platform/upstream/connman.git] / gsupplicant / gsupplicant.h
1 /*
2  *
3  *  WPA supplicant library with GLib integration
4  *
5  *  Copyright (C) 2010  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 #ifndef __G_SUPPLICANT_H
22 #define __G_SUPPLICANT_H
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 #define G_SUPPLICANT_EAP_METHOD_MD5     (1 << 0)
29 #define G_SUPPLICANT_EAP_METHOD_TLS     (1 << 1)
30 #define G_SUPPLICANT_EAP_METHOD_MSCHAPV2        (1 << 2)
31 #define G_SUPPLICANT_EAP_METHOD_PEAP    (1 << 3)
32 #define G_SUPPLICANT_EAP_METHOD_TTLS    (1 << 4)
33 #define G_SUPPLICANT_EAP_METHOD_GTC     (1 << 5)
34 #define G_SUPPLICANT_EAP_METHOD_OTP     (1 << 6)
35 #define G_SUPPLICANT_EAP_METHOD_LEAP    (1 << 7)
36 #define G_SUPPLICANT_EAP_METHOD_WSC     (1 << 8)
37
38 #define G_SUPPLICANT_CAPABILITY_AUTHALG_OPEN    (1 << 0)
39 #define G_SUPPLICANT_CAPABILITY_AUTHALG_SHARED  (1 << 1)
40 #define G_SUPPLICANT_CAPABILITY_AUTHALG_LEAP    (1 << 2)
41
42 #define G_SUPPLICANT_CAPABILITY_PROTO_WPA               (1 << 0)
43 #define G_SUPPLICANT_CAPABILITY_PROTO_RSN               (1 << 1)
44
45 #define G_SUPPLICANT_CAPABILITY_SCAN_ACTIVE     (1 << 0)
46 #define G_SUPPLICANT_CAPABILITY_SCAN_PASSIVE    (1 << 1)
47 #define G_SUPPLICANT_CAPABILITY_SCAN_SSID               (1 << 2)
48
49 #define G_SUPPLICANT_CAPABILITY_MODE_INFRA      (1 << 0)
50 #define G_SUPPLICANT_CAPABILITY_MODE_IBSS               (1 << 1)
51 #define G_SUPPLICANT_CAPABILITY_MODE_AP         (1 << 2)
52
53 #define G_SUPPLICANT_KEYMGMT_NONE               (1 << 0)
54 #define G_SUPPLICANT_KEYMGMT_IEEE8021X  (1 << 1)
55 #define G_SUPPLICANT_KEYMGMT_WPA_NONE   (1 << 2)
56 #define G_SUPPLICANT_KEYMGMT_WPA_PSK    (1 << 3)
57 #define G_SUPPLICANT_KEYMGMT_WPA_PSK_256        (1 << 4)
58 #define G_SUPPLICANT_KEYMGMT_WPA_FT_PSK (1 << 5)
59 #define G_SUPPLICANT_KEYMGMT_WPA_FT_EAP (1 << 6)
60 #define G_SUPPLICANT_KEYMGMT_WPA_EAP    (1 << 7)
61 #define G_SUPPLICANT_KEYMGMT_WPA_EAP_256        (1 << 8)
62 #define G_SUPPLICANT_KEYMGMT_WPS                (1 << 9)
63
64 #define G_SUPPLICANT_PROTO_WPA          (1 << 0)
65 #define G_SUPPLICANT_PROTO_RSN          (1 << 1)
66
67 #define G_SUPPLICANT_GROUP_WEP40                (1 << 0)
68 #define G_SUPPLICANT_GROUP_WEP104               (1 << 1)
69 #define G_SUPPLICANT_GROUP_TKIP         (1 << 2)
70 #define G_SUPPLICANT_GROUP_CCMP         (1 << 3)
71
72 #define G_SUPPLICANT_PAIRWISE_NONE      (1 << 0)
73 #define G_SUPPLICANT_PAIRWISE_TKIP      (1 << 1)
74 #define G_SUPPLICANT_PAIRWISE_CCMP      (1 << 2)
75
76 typedef enum {
77         G_SUPPLICANT_MODE_UNKNOWN,
78         G_SUPPLICANT_MODE_INFRA,
79         G_SUPPLICANT_MODE_IBSS,
80         G_SUPPLICANT_MODE_MASTER,
81 } GSupplicantMode;
82
83 typedef enum {
84         G_SUPPLICANT_SECURITY_UNKNOWN,
85         G_SUPPLICANT_SECURITY_NONE,
86         G_SUPPLICANT_SECURITY_WEP,
87         G_SUPPLICANT_SECURITY_PSK,
88         G_SUPPLICANT_SECURITY_IEEE8021X,
89 } GSupplicantSecurity;
90
91 typedef enum {
92         G_SUPPLICANT_STATE_UNKNOWN,
93         G_SUPPLICANT_STATE_DISCONNECTED,
94         G_SUPPLICANT_STATE_INACTIVE,
95         G_SUPPLICANT_STATE_SCANNING,
96         G_SUPPLICANT_STATE_AUTHENTICATING,
97         G_SUPPLICANT_STATE_ASSOCIATING,
98         G_SUPPLICANT_STATE_ASSOCIATED,
99         G_SUPPLICANT_STATE_4WAY_HANDSHAKE,
100         G_SUPPLICANT_STATE_GROUP_HANDSHAKE,
101         G_SUPPLICANT_STATE_COMPLETED,
102 } GSupplicantState;
103
104 typedef enum {
105         G_SUPPLICANT_WPS_STATE_UNKNOWN,
106         G_SUPPLICANT_WPS_STATE_SUCCESS,
107         G_SUPPLICANT_WPS_STATE_FAIL,
108 } GSupplicantWpsState;
109
110 struct _GSupplicantSSID {
111         const void *ssid;
112         unsigned int ssid_len;
113         unsigned int scan_ssid;
114         GSupplicantMode mode;
115         GSupplicantSecurity security;
116         unsigned int protocol;
117         unsigned int pairwise_cipher;
118         unsigned int group_cipher;
119         unsigned int freq;
120         const char *eap;
121         const char *passphrase;
122         const char *identity;
123         const char *ca_cert_path;
124         const char *client_cert_path;
125         const char *private_key_path;
126         const char *private_key_passphrase;
127         const char *phase2_auth;
128         dbus_bool_t use_wps;
129         const char *pin_wps;
130 };
131
132 typedef struct _GSupplicantSSID GSupplicantSSID;
133
134 /* global API */
135 typedef void (*GSupplicantCountryCallback) (void *user_data);
136
137 int g_supplicant_set_country(const char *alpha2,
138                                 GSupplicantCountryCallback callback,
139                                                 const void *user_data);
140
141 /* Interface API */
142 struct _GSupplicantInterface;
143
144 typedef struct _GSupplicantInterface GSupplicantInterface;
145
146 typedef void (*GSupplicantInterfaceCallback) (int result,
147                                         GSupplicantInterface *interface,
148                                                         void *user_data);
149
150 int g_supplicant_interface_create(const char *ifname, const char *driver,
151                                         const char *bridge,
152                                         GSupplicantInterfaceCallback callback,
153                                                         void *user_data);
154 int g_supplicant_interface_remove(GSupplicantInterface *interface,
155                                         GSupplicantInterfaceCallback callback,
156                                                         void *user_data);
157 int g_supplicant_interface_scan(GSupplicantInterface *interface,
158                                         GSupplicantInterfaceCallback callback,
159                                                         void *user_data);
160
161 int g_supplicant_interface_connect(GSupplicantInterface *interface,
162                                         GSupplicantSSID *ssid,
163                                         GSupplicantInterfaceCallback callback,
164                                                         void *user_data);
165
166 int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
167                                         GSupplicantInterfaceCallback callback,
168                                                         void *user_data);
169
170 int g_supplicant_interface_set_apscan(GSupplicantInterface *interface,
171                                                         unsigned int ap_scan);
172
173 void g_supplicant_interface_set_data(GSupplicantInterface *interface,
174                                                                 void *data);
175 void *g_supplicant_interface_get_data(GSupplicantInterface *interface);
176 const char *g_supplicant_interface_get_ifname(GSupplicantInterface *interface);
177 const char *g_supplicant_interface_get_driver(GSupplicantInterface *interface);
178 GSupplicantState g_supplicant_interface_get_state(GSupplicantInterface *interface);
179 const char *g_supplicant_interface_get_wps_key(GSupplicantInterface *interface);
180 const void *g_supplicant_interface_get_wps_ssid(GSupplicantInterface *interface,
181                                                         unsigned int *ssid_len);
182 GSupplicantWpsState g_supplicant_interface_get_wps_state(GSupplicantInterface *interface);
183 unsigned int g_supplicant_interface_get_mode(GSupplicantInterface *interface);
184 unsigned int g_supplicant_interface_get_max_scan_ssids(
185                                         GSupplicantInterface *interface);
186
187 /* Network API */
188 struct _GSupplicantNetwork;
189
190 typedef struct _GSupplicantNetwork GSupplicantNetwork;
191
192 GSupplicantInterface *g_supplicant_network_get_interface(GSupplicantNetwork *network);
193 const char *g_supplicant_network_get_name(GSupplicantNetwork *network);
194 const char *g_supplicant_network_get_identifier(GSupplicantNetwork *network);
195 const char *g_supplicant_network_get_path(GSupplicantNetwork *network);
196 const void *g_supplicant_network_get_ssid(GSupplicantNetwork *network,
197                                                         unsigned int *ssid_len);
198 const char *g_supplicant_network_get_mode(GSupplicantNetwork *network);
199 const char *g_supplicant_network_get_security(GSupplicantNetwork *network);
200 dbus_int16_t g_supplicant_network_get_signal(GSupplicantNetwork *network);
201 dbus_uint16_t g_supplicant_network_get_frequency(GSupplicantNetwork *network);
202 dbus_bool_t g_supplicant_network_get_wps(GSupplicantNetwork *network);
203
204 struct _GSupplicantCallbacks {
205         void (*system_ready) (void);
206         void (*system_killed) (void);
207         void (*interface_added) (GSupplicantInterface *interface);
208         void (*interface_state) (GSupplicantInterface *interface);
209         void (*interface_removed) (GSupplicantInterface *interface);
210         void (*scan_started) (GSupplicantInterface *interface);
211         void (*scan_finished) (GSupplicantInterface *interface);
212         void (*network_added) (GSupplicantNetwork *network);
213         void (*network_removed) (GSupplicantNetwork *network);
214         void (*network_changed) (GSupplicantNetwork *network,
215                                         const char *property);
216         void (*debug) (const char *str);
217 };
218
219 typedef struct _GSupplicantCallbacks GSupplicantCallbacks;
220
221 int g_supplicant_register(const GSupplicantCallbacks *callbacks);
222 void g_supplicant_unregister(const GSupplicantCallbacks *callbacks);
223
224 #ifdef __cplusplus
225 }
226 #endif
227
228 #endif /* __G_SUPPLICANT_H */