OSDN Git Service

Initial wpa_supplicant 0.6.9 code
[android-x86/external-wpa_supplicant_6.git] / wpa_supplicant / wpa_supplicant_i.h
1 /*
2  * wpa_supplicant - Internal definitions
3  * Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
4  *
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.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #ifndef WPA_SUPPLICANT_I_H
16 #define WPA_SUPPLICANT_I_H
17
18 #include "drivers/driver.h"
19
20 extern const char *wpa_supplicant_version;
21 extern const char *wpa_supplicant_license;
22 #ifndef CONFIG_NO_STDOUT_DEBUG
23 extern const char *wpa_supplicant_full_license1;
24 extern const char *wpa_supplicant_full_license2;
25 extern const char *wpa_supplicant_full_license3;
26 extern const char *wpa_supplicant_full_license4;
27 extern const char *wpa_supplicant_full_license5;
28 #endif /* CONFIG_NO_STDOUT_DEBUG */
29
30 extern struct wpa_driver_ops *wpa_supplicant_drivers[];
31
32
33 struct wpa_scan_result;
34 struct wpa_sm;
35 struct wpa_supplicant;
36
37 /*
38  * Forward declarations of private structures used within the ctrl_iface
39  * backends. Other parts of wpa_supplicant do not have access to data stored in
40  * these structures.
41  */
42 struct ctrl_iface_priv;
43 struct ctrl_iface_global_priv;
44 struct ctrl_iface_dbus_priv;
45
46 /**
47  * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
48  */
49 struct wpa_interface {
50         /**
51          * confname - Configuration name (file or profile) name
52          *
53          * This can also be %NULL when a configuration file is not used. In
54          * that case, ctrl_interface must be set to allow the interface to be
55          * configured.
56          */
57         const char *confname;
58
59         /**
60          * ctrl_interface - Control interface parameter
61          *
62          * If a configuration file is not used, this variable can be used to
63          * set the ctrl_interface parameter that would have otherwise been read
64          * from the configuration file. If both confname and ctrl_interface are
65          * set, ctrl_interface is used to override the value from configuration
66          * file.
67          */
68         const char *ctrl_interface;
69
70         /**
71          * driver - Driver interface name, or %NULL to use the default driver
72          */
73         const char *driver;
74
75         /**
76          * driver_param - Driver interface parameters
77          *
78          * If a configuration file is not used, this variable can be used to
79          * set the driver_param parameters that would have otherwise been read
80          * from the configuration file. If both confname and driver_param are
81          * set, driver_param is used to override the value from configuration
82          * file.
83          */
84         const char *driver_param;
85
86         /**
87          * ifname - Interface name
88          */
89         const char *ifname;
90
91         /**
92          * bridge_ifname - Optional bridge interface name
93          *
94          * If the driver interface (ifname) is included in a Linux bridge
95          * device, the bridge interface may need to be used for receiving EAPOL
96          * frames. This can be enabled by setting this variable to enable
97          * receiving of EAPOL frames from an additional interface.
98          */
99         const char *bridge_ifname;
100 };
101
102 /**
103  * struct wpa_params - Parameters for wpa_supplicant_init()
104  */
105 struct wpa_params {
106         /**
107          * daemonize - Run %wpa_supplicant in the background
108          */
109         int daemonize;
110
111         /**
112          * wait_for_monitor - Wait for a monitor program before starting
113          */
114         int wait_for_monitor;
115
116         /**
117          * pid_file - Path to a PID (process ID) file
118          *
119          * If this and daemonize are set, process ID of the background process
120          * will be written to the specified file.
121          */
122         char *pid_file;
123
124         /**
125          * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
126          */
127         int wpa_debug_level;
128
129         /**
130          * wpa_debug_show_keys - Whether keying material is included in debug
131          *
132          * This parameter can be used to allow keying material to be included
133          * in debug messages. This is a security risk and this option should
134          * not be enabled in normal configuration. If needed during
135          * development or while troubleshooting, this option can provide more
136          * details for figuring out what is happening.
137          */
138         int wpa_debug_show_keys;
139
140         /**
141          * wpa_debug_timestamp - Whether to include timestamp in debug messages
142          */
143         int wpa_debug_timestamp;
144
145         /**
146          * ctrl_interface - Global ctrl_iface path/parameter
147          */
148         char *ctrl_interface;
149
150         /**
151          * dbus_ctrl_interface - Enable the DBus control interface
152          */
153         int dbus_ctrl_interface;
154
155         /**
156          * wpa_debug_file_path - Path of debug file or %NULL to use stdout
157          */
158         const char *wpa_debug_file_path;
159 };
160
161 /**
162  * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
163  *
164  * This structure is initialized by calling wpa_supplicant_init() when starting
165  * %wpa_supplicant.
166  */
167 struct wpa_global {
168         struct wpa_supplicant *ifaces;
169         struct wpa_params params;
170         struct ctrl_iface_global_priv *ctrl_iface;
171         struct ctrl_iface_dbus_priv *dbus_ctrl_iface;
172         void **drv_priv;
173         size_t drv_count;
174 };
175
176
177 struct wpa_client_mlme {
178 #ifdef CONFIG_CLIENT_MLME
179         enum {
180                 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
181                 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
182                 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
183         } state;
184         u8 prev_bssid[ETH_ALEN];
185         u8 ssid[32];
186         size_t ssid_len;
187         u16 aid;
188         u16 ap_capab, capab;
189         u8 *extra_ie; /* to be added to the end of AssocReq */
190         size_t extra_ie_len;
191         u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
192         size_t extra_probe_ie_len;
193         wpa_key_mgmt key_mgmt;
194
195         /* The last AssocReq/Resp IEs */
196         u8 *assocreq_ies, *assocresp_ies;
197         size_t assocreq_ies_len, assocresp_ies_len;
198
199         int auth_tries, assoc_tries;
200
201         unsigned int ssid_set:1;
202         unsigned int bssid_set:1;
203         unsigned int prev_bssid_set:1;
204         unsigned int authenticated:1;
205         unsigned int associated:1;
206         unsigned int probereq_poll:1;
207         unsigned int use_protection:1;
208         unsigned int create_ibss:1;
209         unsigned int mixed_cell:1;
210         unsigned int wmm_enabled:1;
211
212         struct os_time last_probe;
213
214 #define IEEE80211_AUTH_ALG_OPEN BIT(0)
215 #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
216 #define IEEE80211_AUTH_ALG_LEAP BIT(2)
217         unsigned int auth_algs; /* bitfield of allowed auth algs */
218         int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
219         int auth_transaction;
220
221         struct os_time ibss_join_req;
222         u8 *probe_resp; /* ProbeResp template for IBSS */
223         size_t probe_resp_len;
224         u32 supp_rates_bits;
225
226         int wmm_last_param_set;
227
228         int sta_scanning;
229         int scan_hw_mode_idx;
230         int scan_channel_idx;
231         enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
232         struct os_time last_scan_completed;
233         int scan_oper_channel;
234         int scan_oper_freq;
235         int scan_oper_phymode;
236         u8 scan_ssid[32];
237         size_t scan_ssid_len;
238         int scan_skip_11b;
239
240         struct ieee80211_sta_bss *sta_bss_list;
241 #define STA_HASH_SIZE 256
242 #define STA_HASH(sta) (sta[5])
243         struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
244
245         int cts_protect_erp_frames;
246
247         int phymode; /* current mode; WPA_MODE_IEEE80211A, .. */
248         struct wpa_hw_modes *modes;
249         size_t num_modes;
250         unsigned int hw_modes; /* bitfield of allowed hardware modes;
251                                 * (1 << MODE_*) */
252         int num_curr_rates;
253         struct wpa_rate_data *curr_rates;
254         int freq; /* The current frequency in MHz */
255         int channel; /* The current IEEE 802.11 channel number */
256
257 #ifdef CONFIG_IEEE80211R
258         u8 current_md[6];
259         u8 *ft_ies;
260         size_t ft_ies_len;
261 #endif /* CONFIG_IEEE80211R */
262
263 #else /* CONFIG_CLIENT_MLME */
264         int dummy; /* to keep MSVC happy */
265 #endif /* CONFIG_CLIENT_MLME */
266 };
267
268 /**
269  * struct wpa_supplicant - Internal data for wpa_supplicant interface
270  *
271  * This structure contains the internal data for core wpa_supplicant code. This
272  * should be only used directly from the core code. However, a pointer to this
273  * data is used from other files as an arbitrary context pointer in calls to
274  * core functions.
275  */
276 struct wpa_supplicant {
277         struct wpa_global *global;
278         struct wpa_supplicant *next;
279         struct l2_packet_data *l2;
280         struct l2_packet_data *l2_br;
281         unsigned char own_addr[ETH_ALEN];
282         char ifname[100];
283 #ifdef CONFIG_CTRL_IFACE_DBUS
284         char *dbus_path;
285 #endif /* CONFIG_CTRL_IFACE_DBUS */
286         char bridge_ifname[16];
287
288         char *confname;
289         struct wpa_config *conf;
290         int countermeasures;
291         os_time_t last_michael_mic_error;
292         u8 bssid[ETH_ALEN];
293         u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
294                                      * field contains the targer BSSID. */
295         int reassociate; /* reassociation requested */
296         int disconnected; /* all connections disabled; i.e., do no reassociate
297                            * before this has been cleared */
298         struct wpa_ssid *current_ssid;
299         int ap_ies_from_associnfo;
300
301         /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
302         int pairwise_cipher;
303         int group_cipher;
304         int key_mgmt;
305         int mgmt_group_cipher;
306
307         void *drv_priv; /* private data used by driver_ops */
308
309         struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
310                                           * NULL = not yet initialized (start
311                                           * with broadcast SSID)
312                                           * BROADCAST_SSID_SCAN = broadcast
313                                           * SSID was used in the previous scan
314                                           */
315 #define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1)
316
317         struct wpa_scan_results *scan_res;
318
319         struct wpa_driver_ops *driver;
320         int interface_removed; /* whether the network interface has been
321                                 * removed */
322         struct wpa_sm *wpa;
323         struct eapol_sm *eapol;
324
325         struct ctrl_iface_priv *ctrl_iface;
326
327         wpa_states wpa_state;
328         int new_connection;
329         int reassociated_connection;
330
331         int eapol_received; /* number of EAPOL packets received after the
332                              * previous association event */
333
334         struct scard_data *scard;
335
336         unsigned char last_eapol_src[ETH_ALEN];
337
338         int keys_cleared;
339
340         struct wpa_blacklist *blacklist;
341
342         int scan_req; /* manual scan request; this forces a scan even if there
343                        * are no enabled networks in the configuration */
344         int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan
345                              * results without a new scan request; this is used
346                              * to speed up the first association if the driver
347                              * has already available scan results. */
348         int scan_runs; /* number of scan runs since WPS was started */
349
350         struct wpa_client_mlme mlme;
351         int use_client_mlme;
352         int driver_4way_handshake;
353
354         int pending_mic_error_report;
355         int pending_mic_error_pairwise;
356         int mic_errors_seen; /* Michael MIC errors with the current PTK */
357
358         struct wps_context *wps;
359         int wps_success; /* WPS success event received */
360         int blacklist_cleared;
361 };
362
363
364 /* wpa_supplicant.c */
365 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
366
367 const char * wpa_supplicant_state_txt(int state);
368 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
369 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
370                               struct wpa_scan_res *bss,
371                               struct wpa_ssid *ssid,
372                               u8 *wpa_ie, size_t *wpa_ie_len);
373 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
374                               struct wpa_scan_res *bss,
375                               struct wpa_ssid *ssid);
376 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
377                                        struct wpa_ssid *ssid);
378 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
379 int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
380 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
381 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
382                                      int sec, int usec);
383 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
384 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
385 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
386 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
387                                    int reason_code);
388 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
389                                  int reason_code);
390
391 void wpa_show_license(void);
392
393 struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
394                                                  struct wpa_interface *iface);
395 int wpa_supplicant_remove_iface(struct wpa_global *global,
396                                 struct wpa_supplicant *wpa_s);
397 struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
398                                                  const char *ifname);
399 struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
400 int wpa_supplicant_run(struct wpa_global *global);
401 void wpa_supplicant_deinit(struct wpa_global *global);
402
403 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
404                               struct wpa_ssid *ssid);
405
406 /* scan.c */
407 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
408 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
409
410 /* events.c */
411 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
412
413 /* driver_ops */
414 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
415                                   const char *ifname)
416 {
417         if (wpa_s->driver->init2)
418                 return wpa_s->driver->init2(wpa_s, ifname, wpa_s->global);
419         if (wpa_s->driver->init) {
420                 return wpa_s->driver->init(wpa_s, ifname);
421         }
422         return NULL;
423 }
424
425 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
426 {
427         if (wpa_s->driver->deinit)
428                 wpa_s->driver->deinit(wpa_s->drv_priv);
429 }
430
431 static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
432                                     const char *param)
433 {
434         if (wpa_s->driver->set_param)
435                 return wpa_s->driver->set_param(wpa_s->drv_priv, param);
436         return 0;
437 }
438
439 static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
440                                                int enabled)
441 {
442         if (wpa_s->driver->set_drop_unencrypted) {
443                 return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
444                                                            enabled);
445         }
446         return -1;
447 }
448
449 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
450                                               int enabled)
451 {
452         if (wpa_s->driver->set_countermeasures) {
453                 return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
454                                                           enabled);
455         }
456         return -1;
457 }
458
459 static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
460                                        int auth_alg)
461 {
462         if (wpa_s->driver->set_auth_alg) {
463                 return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
464                                                    auth_alg);
465         }
466         return -1;
467 }
468
469 static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
470 {
471         if (wpa_s->driver->set_wpa) {
472                 return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
473         }
474         return 0;
475 }
476
477 static inline int wpa_drv_set_mode(struct wpa_supplicant *wpa_s, int mode)
478 {
479         if (wpa_s->driver->set_mode) {
480                 return wpa_s->driver->set_mode(wpa_s->drv_priv, mode);
481         }
482         return 0;
483 }
484
485 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
486                                     struct wpa_driver_associate_params *params)
487 {
488         if (wpa_s->driver->associate) {
489                 return wpa_s->driver->associate(wpa_s->drv_priv, params);
490         }
491         return -1;
492 }
493
494 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
495                                size_t ssid_len)
496 {
497         if (wpa_s->driver->scan) {
498                 return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
499         }
500         return -1;
501 }
502
503 static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
504                                            struct wpa_scan_result *results,
505                                            size_t max_size)
506 {
507         if (wpa_s->driver->get_scan_results) {
508                 return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
509                                                        results, max_size);
510         }
511         return -1;
512 }
513
514 static inline struct wpa_scan_results * wpa_drv_get_scan_results2(
515         struct wpa_supplicant *wpa_s)
516 {
517         if (wpa_s->driver->get_scan_results2)
518                 return wpa_s->driver->get_scan_results2(wpa_s->drv_priv);
519         return NULL;
520 }
521
522 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
523 {
524         if (wpa_s->driver->get_bssid) {
525                 return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
526         }
527         return -1;
528 }
529
530 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
531 {
532         if (wpa_s->driver->get_ssid) {
533                 return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
534         }
535         return -1;
536 }
537
538 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
539                                    const u8 *addr, int key_idx, int set_tx,
540                                    const u8 *seq, size_t seq_len,
541                                    const u8 *key, size_t key_len)
542 {
543         if (wpa_s->driver->set_key) {
544                 wpa_s->keys_cleared = 0;
545                 return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
546                                               key_idx, set_tx, seq, seq_len,
547                                               key, key_len);
548         }
549         return -1;
550 }
551
552 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
553                                          const u8 *addr, int reason_code)
554 {
555         if (wpa_s->driver->deauthenticate) {
556                 return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
557                                                      reason_code);
558         }
559         return -1;
560 }
561
562 static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
563                                        const u8 *addr, int reason_code)
564 {
565         if (wpa_s->driver->disassociate) {
566                 return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
567                                                    reason_code);
568         }
569         return -1;
570 }
571
572 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
573                                     const u8 *bssid, const u8 *pmkid)
574 {
575         if (wpa_s->driver->add_pmkid) {
576                 return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
577         }
578         return -1;
579 }
580
581 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
582                                        const u8 *bssid, const u8 *pmkid)
583 {
584         if (wpa_s->driver->remove_pmkid) {
585                 return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
586                                                    pmkid);
587         }
588         return -1;
589 }
590
591 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
592 {
593         if (wpa_s->driver->flush_pmkid) {
594                 return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
595         }
596         return -1;
597 }
598
599 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
600                                    struct wpa_driver_capa *capa)
601 {
602         if (wpa_s->driver->get_capa) {
603                 return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
604         }
605         return -1;
606 }
607
608 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
609 {
610         if (wpa_s->driver->poll) {
611                 wpa_s->driver->poll(wpa_s->drv_priv);
612         }
613 }
614
615 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
616 {
617         if (wpa_s->driver->get_ifname) {
618                 return wpa_s->driver->get_ifname(wpa_s->drv_priv);
619         }
620         return NULL;
621 }
622
623 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
624 {
625         if (wpa_s->driver->get_mac_addr) {
626                 return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
627         }
628         return NULL;
629 }
630
631 static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
632                                      const u8 *dst, u16 proto,
633                                      const u8 *data, size_t data_len)
634 {
635         if (wpa_s->driver->send_eapol)
636                 return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
637                                                  data, data_len);
638         return -1;
639 }
640
641 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
642                                         int state)
643 {
644         if (wpa_s->driver->set_operstate)
645                 return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
646         return 0;
647 }
648
649 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
650                                              const u8 *addr, int protect_type,
651                                              int key_type)
652 {
653         if (wpa_s->driver->mlme_setprotection)
654                 return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
655                                                          protect_type,
656                                                          key_type);
657         return 0;
658 }
659
660 static inline struct wpa_hw_modes *
661 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
662                             u16 *flags)
663 {
664         if (wpa_s->driver->get_hw_feature_data)
665                 return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
666                                                           num_modes, flags);
667         return NULL;
668 }
669
670 static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s,
671                                       wpa_hw_mode phymode, int chan,
672                                       int freq)
673 {
674         if (wpa_s->driver->set_channel)
675                 return wpa_s->driver->set_channel(wpa_s->drv_priv, phymode,
676                                                   chan, freq);
677         return -1;
678 }
679
680 static inline int wpa_drv_set_ssid(struct wpa_supplicant *wpa_s,
681                                    const u8 *ssid, size_t ssid_len)
682 {
683         if (wpa_s->driver->set_ssid) {
684                 return wpa_s->driver->set_ssid(wpa_s->drv_priv, ssid,
685                                                ssid_len);
686         }
687         return -1;
688 }
689
690 static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s,
691                                     const u8 *bssid)
692 {
693         if (wpa_s->driver->set_bssid) {
694                 return wpa_s->driver->set_bssid(wpa_s->drv_priv, bssid);
695         }
696         return -1;
697 }
698
699 static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
700                                       const char *alpha2)
701 {
702         if (wpa_s->driver->set_country)
703                 return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
704         return 0;
705 }
706
707 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
708                                     const u8 *data, size_t data_len)
709 {
710         if (wpa_s->driver->send_mlme)
711                 return wpa_s->driver->send_mlme(wpa_s->drv_priv,
712                                                 data, data_len);
713         return -1;
714 }
715
716 static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant *wpa_s,
717                                        const u8 *addr, const u8 *supp_rates,
718                                        size_t supp_rates_len)
719 {
720         if (wpa_s->driver->mlme_add_sta)
721                 return wpa_s->driver->mlme_add_sta(wpa_s->drv_priv, addr,
722                                                    supp_rates, supp_rates_len);
723         return -1;
724 }
725
726 static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant *wpa_s,
727                                           const u8 *addr)
728 {
729         if (wpa_s->driver->mlme_remove_sta)
730                 return wpa_s->driver->mlme_remove_sta(wpa_s->drv_priv, addr);
731         return -1;
732 }
733
734 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
735                                         const u8 *md,
736                                         const u8 *ies, size_t ies_len)
737 {
738         if (wpa_s->driver->update_ft_ies)
739                 return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
740                                                     ies, ies_len);
741         return -1;
742 }
743
744 static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s,
745                                          u8 action, const u8 *target_ap,
746                                          const u8 *ies, size_t ies_len)
747 {
748         if (wpa_s->driver->send_ft_action)
749                 return wpa_s->driver->send_ft_action(wpa_s->drv_priv, action,
750                                                      target_ap, ies, ies_len);
751         return -1;
752 }
753
754 static inline int wpa_drv_set_probe_req_ie(struct wpa_supplicant *wpa_s,
755                                            const u8 *ies, size_t ies_len)
756 {
757         if (wpa_s->driver->set_probe_req_ie)
758                 return wpa_s->driver->set_probe_req_ie(wpa_s->drv_priv, ies,
759                                                        ies_len);
760         return -1;
761 }
762
763 #endif /* WPA_SUPPLICANT_I_H */