Fix debug and scanning handling of supplicant test program
[framework/connectivity/connman.git] / tools / supplicant.h
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-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
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 typedef void (* supplicant_interface_scan_callback) (int result,
98                                                         void *user_data);
99 typedef void (* supplicant_interface_disconnect_callback) (int result,
100                                                         void *user_data);
101
102 int supplicant_interface_create(const char *ifname, const char *driver,
103                         supplicant_interface_create_callback callback,
104                                                         void *user_data);
105 int supplicant_interface_remove(struct supplicant_interface *interface,
106                         supplicant_interface_remove_callback callback,
107                                                         void *user_data);
108 int supplicant_interface_scan(struct supplicant_interface *interface,
109                         supplicant_interface_scan_callback callback,
110                                                         void *user_data);
111 int supplicant_interface_disconnect(struct supplicant_interface *interface,
112                         supplicant_interface_disconnect_callback callback,
113                                                         void *user_data);
114
115 const char *supplicant_interface_get_ifname(struct supplicant_interface *interface);
116 const char *supplicant_interface_get_driver(struct supplicant_interface *interface);
117
118 struct supplicant_network;
119
120 struct supplicant_interface *supplicant_network_get_interface(struct supplicant_network *network);
121 const char *supplicant_network_get_name(struct supplicant_network *network);
122 const char *supplicant_network_get_identifier(struct supplicant_network *network);
123 enum supplicant_mode supplicant_network_get_mode(struct supplicant_network *network);
124
125 struct supplicant_callbacks {
126         void (*system_ready) (void);
127         void (*system_killed) (void);
128         void (*interface_added) (struct supplicant_interface *interface);
129         void (*interface_removed) (struct supplicant_interface *interface);
130         void (*scan_started) (struct supplicant_interface *interface);
131         void (*scan_finished) (struct supplicant_interface *interface);
132         void (*network_added) (struct supplicant_network *network);
133         void (*network_removed) (struct supplicant_network *network);
134 };
135
136 int supplicant_register(const struct supplicant_callbacks *callbacks);
137 void supplicant_unregister(const struct supplicant_callbacks *callbacks);
138
139 void supplicant_set_debug_level(unsigned int level);