Add initial support for scanning in supplicant test program
[platform/upstream/connman.git] / tools / supplicant.h
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2009  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 #define SUPPLICANT_EAP_METHOD_MD5       (1 << 0)
23 #define SUPPLICANT_EAP_METHOD_TLS       (1 << 1)
24 #define SUPPLICANT_EAP_METHOD_MSCHAPV2  (1 << 2)
25 #define SUPPLICANT_EAP_METHOD_PEAP      (1 << 3)
26 #define SUPPLICANT_EAP_METHOD_TTLS      (1 << 4)
27 #define SUPPLICANT_EAP_METHOD_GTC       (1 << 5)
28 #define SUPPLICANT_EAP_METHOD_OTP       (1 << 6)
29 #define SUPPLICANT_EAP_METHOD_LEAP      (1 << 7)
30 #define SUPPLICANT_EAP_METHOD_WSC       (1 << 8)
31
32 #define SUPPLICANT_CAPABILITY_KEYMGMT_NONE      (1 << 0)
33 #define SUPPLICANT_CAPABILITY_KEYMGMT_IEEE8021X (1 << 1)
34 #define SUPPLICANT_CAPABILITY_KEYMGMT_WPA_NONE  (1 << 2)
35 #define SUPPLICANT_CAPABILITY_KEYMGMT_WPA_PSK   (1 << 3)
36 #define SUPPLICANT_CAPABILITY_KEYMGMT_WPA_EAP   (1 << 4)
37 #define SUPPLICANT_CAPABILITY_KEYMGMT_WPS       (1 << 5)
38
39 #define SUPPLICANT_CAPABILITY_AUTHALG_OPEN      (1 << 0)
40 #define SUPPLICANT_CAPABILITY_AUTHALG_SHARED    (1 << 1)
41 #define SUPPLICANT_CAPABILITY_AUTHALG_LEAP      (1 << 2)
42
43 #define SUPPLICANT_CAPABILITY_PROTO_WPA         (1 << 0)
44 #define SUPPLICANT_CAPABILITY_PROTO_RSN         (1 << 1)
45
46 #define SUPPLICANT_CAPABILITY_GROUP_WEP40       (1 << 0)
47 #define SUPPLICANT_CAPABILITY_GROUP_WEP104      (1 << 1)
48 #define SUPPLICANT_CAPABILITY_GROUP_TKIP        (1 << 2)
49 #define SUPPLICANT_CAPABILITY_GROUP_CCMP        (1 << 3)
50
51 #define SUPPLICANT_CAPABILITY_PAIRWISE_NONE     (1 << 0)
52 #define SUPPLICANT_CAPABILITY_PAIRWISE_TKIP     (1 << 1)
53 #define SUPPLICANT_CAPABILITY_PAIRWISE_CCMP     (1 << 2)
54
55 #define SUPPLICANT_CAPABILITY_SCAN_ACTIVE       (1 << 0)
56 #define SUPPLICANT_CAPABILITY_SCAN_PASSIVE      (1 << 1)
57 #define SUPPLICANT_CAPABILITY_SCAN_SSID         (1 << 2)
58
59 #define SUPPLICANT_CAPABILITY_MODE_INFRA        (1 << 0)
60 #define SUPPLICANT_CAPABILITY_MODE_IBSS         (1 << 1)
61 #define SUPPLICANT_CAPABILITY_MODE_AP           (1 << 2)
62
63 enum supplicant_mode {
64         SUPPLICANT_MODE_UNKNOWN,
65         SUPPLICANT_MODE_INFRA,
66         SUPPLICANT_MODE_IBSS,
67 };
68
69 enum supplicant_security {
70         SUPPLICANT_SECURITY_UNKNOWN,
71         SUPPLICANT_SECURITY_NONE,
72         SUPPLICANT_SECURITY_WEP,
73         SUPPLICANT_SECURITY_PSK,
74         SUPPLICANT_SECURITY_IEEE8021X,
75 };
76
77 enum supplicant_state {
78         SUPPLICANT_STATE_UNKNOWN,
79         SUPPLICANT_STATE_DISCONNECTED,
80         SUPPLICANT_STATE_INACTIVE,
81         SUPPLICANT_STATE_SCANNING,
82         SUPPLICANT_STATE_AUTHENTICATING,
83         SUPPLICANT_STATE_ASSOCIATING,
84         SUPPLICANT_STATE_ASSOCIATED,
85         SUPPLICANT_STATE_4WAY_HANDSHAKE,
86         SUPPLICANT_STATE_GROUP_HANDSHAKE,
87         SUPPLICANT_STATE_COMPLETED,
88 };
89
90 struct supplicant_interface;
91
92 typedef void (* supplicant_interface_create_callback) (int result,
93                                 struct supplicant_interface *interface,
94                                                         void *user_data);
95 typedef void (* supplicant_interface_remove_callback) (int result,
96                                                         void *user_data);
97
98 int supplicant_interface_create(const char *ifname, const char *driver,
99                         supplicant_interface_create_callback callback,
100                                                         void *user_data);
101 int supplicant_interface_remove(struct supplicant_interface *interface,
102                         supplicant_interface_remove_callback callback,
103                                                         void *user_data);
104 int supplicant_interface_scan(struct supplicant_interface *interface);
105 int supplicant_interface_disconnect(struct supplicant_interface *interface);
106
107 const char *supplicant_interface_get_ifname(struct supplicant_interface *interface);
108 const char *supplicant_interface_get_driver(struct supplicant_interface *interface);
109
110 struct supplicant_network;
111
112 struct supplicant_interface *supplicant_network_get_interface(struct supplicant_network *network);
113 const char *supplicant_network_get_name(struct supplicant_network *network);
114 const char *supplicant_network_get_identifier(struct supplicant_network *network);
115 enum supplicant_mode supplicant_network_get_mode(struct supplicant_network *network);
116
117 struct supplicant_callbacks {
118         void (*system_ready) (void);
119         void (*system_killed) (void);
120         void (*interface_added) (struct supplicant_interface *interface);
121         void (*interface_removed) (struct supplicant_interface *interface);
122         void (*scan_started) (struct supplicant_interface *interface);
123         void (*scan_finished) (struct supplicant_interface *interface);
124         void (*network_added) (struct supplicant_network *network);
125         void (*network_removed) (struct supplicant_network *network);
126 };
127
128 int supplicant_register(const struct supplicant_callbacks *callbacks);
129 void supplicant_unregister(const struct supplicant_callbacks *callbacks);
130
131 void supplicant_set_debug_level(unsigned int level);