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