More Broadcom 43xx PCI IDs.
[dragonfly/port-amd64.git] / contrib / wpa_supplicant-0.4.9 / wpa_supplicant_i.h
blob1c33aa419bc9b07df2b1945b6305735c2e257c1e
1 /*
2 * wpa_supplicant - Internal definitions
3 * Copyright (c) 2003-2006, Jouni Malinen <jkmaline@cc.hut.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #ifndef WPA_SUPPLICANT_I_H
16 #define WPA_SUPPLICANT_I_H
18 #include "driver.h"
20 struct wpa_blacklist {
21 struct wpa_blacklist *next;
22 u8 bssid[ETH_ALEN];
23 int count;
27 struct wpa_scan_result;
28 struct wpa_sm;
29 struct wpa_supplicant;
31 /**
32 * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
34 struct wpa_interface {
35 /**
36 * confname - Configuration name (file or profile) name
38 * This can also be %NULL when a configuration file is not used. In
39 * that case, ctrl_interface must be set to allow the interface to be
40 * configured.
42 const char *confname;
44 /**
45 * ctrl_interface - Control interface parameter
47 * If a configuration file is not used, this variable can be used to
48 * set the ctrl_interface parameter that would have otherwise been read
49 * from the configuration file. If both confname and ctrl_interface are
50 * set, ctrl_interface is used to override the value from configuration
51 * file.
53 const char *ctrl_interface;
55 /**
56 * driver - Driver interface name, or %NULL to use the default driver
58 const char *driver;
60 /**
61 * driver_param - Driver interface parameters
63 * If a configuration file is not used, this variable can be used to
64 * set the driver_param parameters that would have otherwise been read
65 * from the configuration file. If both confname and driver_param are
66 * set, driver_param is used to override the value from configuration
67 * file.
69 const char *driver_param;
71 /**
72 * ifname - Interface name
74 const char *ifname;
77 /**
78 * struct wpa_params - Parameters for wpa_supplicant_init()
80 struct wpa_params {
81 /**
82 * daemonize - Run %wpa_supplicant in the background
84 int daemonize;
86 /**
87 * wait_for_interface - Wait for the network interface to appear
89 * If set, %wpa_supplicant will wait until all the configured network
90 * interfaces are available before starting processing. Please note
91 * that in many cases, a better alternative would be to start
92 * %wpa_supplicant without network interfaces and add the interfaces
93 * dynamically whenever they become available.
95 int wait_for_interface;
97 /**
98 * wait_for_monitor - Wait for a monitor program before starting
100 int wait_for_monitor;
103 * pid_file - Path to a PID (process ID) file
105 * If this and daemonize are set, process ID of the background process
106 * will be written to the specified file.
108 char *pid_file;
111 * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
113 int wpa_debug_level;
116 * wpa_debug_show_keys - Whether keying material is included in debug
118 * This parameter can be used to allow keying material to be included
119 * in debug messages. This is a security risk and this option should
120 * not be enabled in normal configuration. If needed during
121 * development or while troubleshooting, this option can provide more
122 * details for figuring out what is happening.
124 int wpa_debug_show_keys;
127 * wpa_debug_timestamp - Whether to include timestamp in debug messages
129 int wpa_debug_timestamp;
132 * ctrl_interface - Global ctrl_iface path/parameter
134 char *ctrl_interface;
138 * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
140 * This structure is initialized by calling wpa_supplicant_init() when starting
141 * %wpa_supplicant.
143 struct wpa_global {
144 struct wpa_supplicant *ifaces;
145 struct wpa_params params;
146 int ctrl_sock;
150 * struct wpa_supplicant - Internal data for wpa_supplicant interface
152 * This structure contains the internal data for core wpa_supplicant code. This
153 * should be only used directly from the core code. However, a pointer to this
154 * data is used from other files as an arbitrary context pointer in calls to
155 * core functions.
157 struct wpa_supplicant {
158 struct wpa_global *global;
159 struct wpa_supplicant *next;
160 struct l2_packet_data *l2;
161 unsigned char own_addr[ETH_ALEN];
162 char ifname[100];
164 char *confname;
165 struct wpa_config *conf;
166 int countermeasures;
167 time_t last_michael_mic_error;
168 u8 bssid[ETH_ALEN];
169 int reassociate; /* reassociation requested */
170 int disconnected; /* all connections disabled; i.e., do no reassociate
171 * before this has been cleared */
172 struct wpa_ssid *current_ssid;
174 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
175 int pairwise_cipher;
176 int group_cipher;
177 int key_mgmt;
179 void *drv_priv; /* private data used by driver_ops */
181 struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
182 * NULL = not yet initialized (start
183 * with broadcast SSID)
184 * BROADCAST_SSID_SCAN = broadcast
185 * SSID was used in the previous scan
187 #define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1)
189 struct wpa_scan_result *scan_results;
190 int num_scan_results;
192 struct wpa_driver_ops *driver;
193 int interface_removed; /* whether the network interface has been
194 * removed */
195 struct wpa_sm *wpa;
196 struct eapol_sm *eapol;
198 int ctrl_sock; /* UNIX domain socket for control interface or -1 if
199 * not used */
200 struct wpa_ctrl_dst *ctrl_dst;
202 wpa_states wpa_state;
203 int new_connection;
204 int reassociated_connection;
206 int eapol_received; /* number of EAPOL packets received after the
207 * previous association event */
209 struct scard_data *scard;
211 unsigned char last_eapol_src[ETH_ALEN];
213 int keys_cleared;
215 struct wpa_blacklist *blacklist;
217 int scan_req; /* manual scan request; this forces a scan even if there
218 * are no enabled networks in the configuration */
222 /* wpa_supplicant.c */
223 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
225 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
227 const char * wpa_supplicant_state_txt(int state);
228 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s,
229 int wait_for_interface);
230 struct wpa_blacklist * wpa_blacklist_get(struct wpa_supplicant *wpa_s,
231 const u8 *bssid);
232 int wpa_blacklist_add(struct wpa_supplicant *wpa_s, const u8 *bssid);
233 void wpa_blacklist_clear(struct wpa_supplicant *wpa_s);
234 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
235 struct wpa_scan_result *bss,
236 struct wpa_ssid *ssid,
237 u8 *wpa_ie, size_t *wpa_ie_len);
238 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
239 struct wpa_scan_result *bss,
240 struct wpa_ssid *ssid);
241 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
242 struct wpa_ssid *ssid);
243 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
244 int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
245 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
246 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
247 int sec, int usec);
248 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
249 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
250 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
251 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
252 int reason_code);
253 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
254 int reason_code);
255 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
257 void wpa_show_license(void);
259 struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
260 struct wpa_interface *iface);
261 int wpa_supplicant_remove_iface(struct wpa_global *global,
262 struct wpa_supplicant *wpa_s);
263 struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
264 const char *ifname);
265 struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
266 int wpa_supplicant_run(struct wpa_global *global);
267 void wpa_supplicant_deinit(struct wpa_global *global);
269 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
270 struct wpa_ssid *ssid);
273 /* driver_ops */
274 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
275 const char *ifname)
277 if (wpa_s->driver->init) {
278 return wpa_s->driver->init(wpa_s, ifname);
280 return NULL;
283 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
285 if (wpa_s->driver->deinit)
286 wpa_s->driver->deinit(wpa_s->drv_priv);
289 static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
290 const char *param)
292 if (wpa_s->driver->set_param)
293 return wpa_s->driver->set_param(wpa_s->drv_priv, param);
294 return 0;
297 static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
298 int enabled)
300 if (wpa_s->driver->set_drop_unencrypted) {
301 return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
302 enabled);
304 return -1;
307 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
308 int enabled)
310 if (wpa_s->driver->set_countermeasures) {
311 return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
312 enabled);
314 return -1;
317 static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
318 int auth_alg)
320 if (wpa_s->driver->set_auth_alg) {
321 return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
322 auth_alg);
324 return -1;
327 static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
329 if (wpa_s->driver->set_wpa) {
330 return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
332 return 0;
335 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
336 struct wpa_driver_associate_params *params)
338 if (wpa_s->driver->associate) {
339 return wpa_s->driver->associate(wpa_s->drv_priv, params);
341 return -1;
344 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
345 size_t ssid_len)
347 if (wpa_s->driver->scan) {
348 return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
350 return -1;
353 static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
354 struct wpa_scan_result *results,
355 size_t max_size)
357 if (wpa_s->driver->get_scan_results) {
358 return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
359 results, max_size);
361 return -1;
364 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
366 if (wpa_s->driver->get_bssid) {
367 return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
369 return -1;
372 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
374 if (wpa_s->driver->get_ssid) {
375 return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
377 return -1;
380 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
381 const u8 *addr, int key_idx, int set_tx,
382 const u8 *seq, size_t seq_len,
383 const u8 *key, size_t key_len)
385 if (wpa_s->driver->set_key) {
386 wpa_s->keys_cleared = 0;
387 return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
388 key_idx, set_tx, seq, seq_len,
389 key, key_len);
391 return -1;
394 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
395 const u8 *addr, int reason_code)
397 if (wpa_s->driver->deauthenticate) {
398 return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
399 reason_code);
401 return -1;
404 static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
405 const u8 *addr, int reason_code)
407 if (wpa_s->driver->disassociate) {
408 return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
409 reason_code);
411 return -1;
414 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
415 const u8 *bssid, const u8 *pmkid)
417 if (wpa_s->driver->add_pmkid) {
418 return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
420 return -1;
423 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
424 const u8 *bssid, const u8 *pmkid)
426 if (wpa_s->driver->remove_pmkid) {
427 return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
428 pmkid);
430 return -1;
433 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
435 if (wpa_s->driver->flush_pmkid) {
436 return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
438 return -1;
441 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
442 struct wpa_driver_capa *capa)
444 if (wpa_s->driver->get_capa) {
445 return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
447 return -1;
450 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
452 if (wpa_s->driver->poll) {
453 wpa_s->driver->poll(wpa_s->drv_priv);
457 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
459 if (wpa_s->driver->get_ifname) {
460 return wpa_s->driver->get_ifname(wpa_s->drv_priv);
462 return NULL;
465 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
467 if (wpa_s->driver->get_mac_addr) {
468 return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
470 return NULL;
473 static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
474 const u8 *dst, u16 proto,
475 const u8 *data, size_t data_len)
477 if (wpa_s->driver->send_eapol)
478 return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
479 data, data_len);
480 return -1;
483 #endif /* WPA_SUPPLICANT_I_H */