Merge lp:~vicamo/ubuntu/vivid/wpa/add-wowlan-support into lp:ubuntu/vivid/wpa

Proposed by You-Sheng Yang
Status: Needs review
Proposed branch: lp:~vicamo/ubuntu/vivid/wpa/add-wowlan-support
Merge into: lp:ubuntu/vivid/wpa
Diff against target: 39148 lines (+38938/-0)
19 files modified
.pc/add-wowlan-configuration-support.patch/src/drivers/driver.h (+3847/-0)
.pc/add-wowlan-configuration-support.patch/src/drivers/driver_nl80211.c (+11773/-0)
.pc/add-wowlan-configuration-support.patch/wpa_supplicant/config.c (+3468/-0)
.pc/add-wowlan-configuration-support.patch/wpa_supplicant/config.h (+1042/-0)
.pc/add-wowlan-configuration-support.patch/wpa_supplicant/config_file.c (+1147/-0)
.pc/add-wowlan-configuration-support.patch/wpa_supplicant/driver_i.h (+607/-0)
.pc/add-wowlan-configuration-support.patch/wpa_supplicant/wpa_supplicant.c (+4451/-0)
.pc/applied-patches (+2/-0)
.pc/install-nl80211-disconnect-wowlan-trigger-at-startup.patch/src/drivers/driver_nl80211.c (+11857/-0)
debian/patches/add-wowlan-configuration-support.patch (+474/-0)
debian/patches/install-nl80211-disconnect-wowlan-trigger-at-startup.patch (+55/-0)
debian/patches/series (+2/-0)
src/drivers/driver.h (+19/-0)
src/drivers/driver_nl80211.c (+92/-0)
wpa_supplicant/config.c (+2/-0)
wpa_supplicant/config.h (+7/-0)
wpa_supplicant/config_file.c (+4/-0)
wpa_supplicant/driver_i.h (+8/-0)
wpa_supplicant/wpa_supplicant.c (+81/-0)
To merge this branch: bzr merge lp:~vicamo/ubuntu/vivid/wpa/add-wowlan-support
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Needs Fixing
Review via email: mp+264157@code.launchpad.net

Description of the change

This change back ports WoWLAN configuration support from upstream commit http://w1.fi/cgit/hostap/commit/src/drivers?id=e4fa8b120bf0014bc7f6f79f8d85923215833c9f , which is only available in v2.2 or newer, and installs a "disconnect" trigger automatically when changing interface mode.

This is for https://bugs.launchpad.net/tangxi/+bug/1465520 , Arale WiFi suspend power consumption improvements. For kernel v3.10(?) or newer, wlan devices with no wowlan trigger installed will be deactivated in function `wiphy_suspend` by calling function `cfg80211_leave_all` and results a DISCONNECT event dispatched to NetworkManager. NetworkManager on Arale does not aware that system is going to suspend, so it asks wpasupplicant to reconnect the device upon such DISCONNECT event received. Then it becomes a endless loop between kernel, wpasupplicant and NetworkManager, and the system is busy all the time, kills the battery in a few hours. With at least one trigger installed, such loop is prevented.

There is no WoWLAN configuration support in v2.1, so there shouldn't affect current system in installed wowlan triggers.

To post a comment you must log in.
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Have all the patches been sent upstream for review? It would be nice to have a trace of this on the relevant patches (ie. links to mailing list posts maybe?)

To go along with this, so we can provide this fix as a Stable Release update, please open a *public* bug that has all the information, against wpa, so that we can track the whole SRU process.

review: Needs Fixing

Unmerged revisions

20. By You-Sheng Yang

nl80211: install disconnect trigger at startup

This installs WoWLAN dissconnect trigger if supported. For WoWLAN
supported devices with kernel version 3.10 or newer, this keeps the
device from being disconnected before going to suspend, so that
NetworkManager won't be busy reconnecting the device during the
suspend-resume process.

19. By You-Sheng Yang

wpa_supplicant: Add Wake-on-WLAN configuration support

Add a new wowlan_triggers option to wpa_supplicant.conf. The triggers in
this key will be used to configure the kernel wowlan configuration.

For now, support only simple flags. More complex triggers can be added
later on.

cherry-picked from commit e4fa8b120

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '.pc/add-wowlan-configuration-support.patch'
2=== added file '.pc/add-wowlan-configuration-support.patch/.timestamp'
3=== added directory '.pc/add-wowlan-configuration-support.patch/src'
4=== added directory '.pc/add-wowlan-configuration-support.patch/src/drivers'
5=== added file '.pc/add-wowlan-configuration-support.patch/src/drivers/driver.h'
6--- .pc/add-wowlan-configuration-support.patch/src/drivers/driver.h 1970-01-01 00:00:00 +0000
7+++ .pc/add-wowlan-configuration-support.patch/src/drivers/driver.h 2015-07-08 14:42:11 +0000
8@@ -0,0 +1,3847 @@
9+/*
10+ * Driver interface definition
11+ * Copyright (c) 2003-2014, Jouni Malinen <j@w1.fi>
12+ *
13+ * This software may be distributed under the terms of the BSD license.
14+ * See README for more details.
15+ *
16+ * This file defines a driver interface used by both %wpa_supplicant and
17+ * hostapd. The first part of the file defines data structures used in various
18+ * driver operations. This is followed by the struct wpa_driver_ops that each
19+ * driver wrapper will beed to define with callback functions for requesting
20+ * driver operations. After this, there are definitions for driver event
21+ * reporting with wpa_supplicant_event() and some convenience helper functions
22+ * that can be used to report events.
23+ */
24+
25+#ifndef DRIVER_H
26+#define DRIVER_H
27+
28+#define WPA_SUPPLICANT_DRIVER_VERSION 4
29+
30+#include "common/defs.h"
31+#include "utils/list.h"
32+
33+#define HOSTAPD_CHAN_DISABLED 0x00000001
34+#define HOSTAPD_CHAN_PASSIVE_SCAN 0x00000002
35+#define HOSTAPD_CHAN_NO_IBSS 0x00000004
36+#define HOSTAPD_CHAN_RADAR 0x00000008
37+#define HOSTAPD_CHAN_HT40PLUS 0x00000010
38+#define HOSTAPD_CHAN_HT40MINUS 0x00000020
39+#define HOSTAPD_CHAN_HT40 0x00000040
40+#define HOSTAPD_CHAN_SURVEY_LIST_INITIALIZED 0x00000080
41+
42+#define HOSTAPD_CHAN_DFS_UNKNOWN 0x00000000
43+#define HOSTAPD_CHAN_DFS_USABLE 0x00000100
44+#define HOSTAPD_CHAN_DFS_UNAVAILABLE 0x00000200
45+#define HOSTAPD_CHAN_DFS_AVAILABLE 0x00000300
46+#define HOSTAPD_CHAN_DFS_MASK 0x00000300
47+
48+#define HOSTAPD_CHAN_VHT_10_70 0x00000800
49+#define HOSTAPD_CHAN_VHT_30_50 0x00001000
50+#define HOSTAPD_CHAN_VHT_50_30 0x00002000
51+#define HOSTAPD_CHAN_VHT_70_10 0x00004000
52+
53+enum reg_change_initiator {
54+ REGDOM_SET_BY_CORE,
55+ REGDOM_SET_BY_USER,
56+ REGDOM_SET_BY_DRIVER,
57+ REGDOM_SET_BY_COUNTRY_IE,
58+ REGDOM_BEACON_HINT,
59+};
60+
61+/**
62+ * struct hostapd_channel_data - Channel information
63+ */
64+struct hostapd_channel_data {
65+ /**
66+ * chan - Channel number (IEEE 802.11)
67+ */
68+ short chan;
69+
70+ /**
71+ * freq - Frequency in MHz
72+ */
73+ int freq;
74+
75+ /**
76+ * flag - Channel flags (HOSTAPD_CHAN_*)
77+ */
78+ int flag;
79+
80+ /**
81+ * max_tx_power - Regulatory transmit power limit in dBm
82+ */
83+ u8 max_tx_power;
84+
85+ /*
86+ * survey_list - Linked list of surveys
87+ */
88+ struct dl_list survey_list;
89+
90+ /**
91+ * min_nf - Minimum observed noise floor, in dBm, based on all
92+ * surveyed channel data
93+ */
94+ s8 min_nf;
95+
96+#ifdef CONFIG_ACS
97+ /**
98+ * interference_factor - Computed interference factor on this
99+ * channel (used internally in src/ap/acs.c; driver wrappers do not
100+ * need to set this)
101+ */
102+ long double interference_factor;
103+#endif /* CONFIG_ACS */
104+};
105+
106+#define HOSTAPD_MODE_FLAG_HT_INFO_KNOWN BIT(0)
107+#define HOSTAPD_MODE_FLAG_VHT_INFO_KNOWN BIT(1)
108+
109+/**
110+ * struct hostapd_hw_modes - Supported hardware mode information
111+ */
112+struct hostapd_hw_modes {
113+ /**
114+ * mode - Hardware mode
115+ */
116+ enum hostapd_hw_mode mode;
117+
118+ /**
119+ * num_channels - Number of entries in the channels array
120+ */
121+ int num_channels;
122+
123+ /**
124+ * channels - Array of supported channels
125+ */
126+ struct hostapd_channel_data *channels;
127+
128+ /**
129+ * num_rates - Number of entries in the rates array
130+ */
131+ int num_rates;
132+
133+ /**
134+ * rates - Array of supported rates in 100 kbps units
135+ */
136+ int *rates;
137+
138+ /**
139+ * ht_capab - HT (IEEE 802.11n) capabilities
140+ */
141+ u16 ht_capab;
142+
143+ /**
144+ * mcs_set - MCS (IEEE 802.11n) rate parameters
145+ */
146+ u8 mcs_set[16];
147+
148+ /**
149+ * a_mpdu_params - A-MPDU (IEEE 802.11n) parameters
150+ */
151+ u8 a_mpdu_params;
152+
153+ /**
154+ * vht_capab - VHT (IEEE 802.11ac) capabilities
155+ */
156+ u32 vht_capab;
157+
158+ /**
159+ * vht_mcs_set - VHT MCS (IEEE 802.11ac) rate parameters
160+ */
161+ u8 vht_mcs_set[8];
162+
163+ unsigned int flags; /* HOSTAPD_MODE_FLAG_* */
164+};
165+
166+
167+#define IEEE80211_MODE_INFRA 0
168+#define IEEE80211_MODE_IBSS 1
169+#define IEEE80211_MODE_AP 2
170+
171+#define IEEE80211_CAP_ESS 0x0001
172+#define IEEE80211_CAP_IBSS 0x0002
173+#define IEEE80211_CAP_PRIVACY 0x0010
174+
175+/* DMG (60 GHz) IEEE 802.11ad */
176+/* type - bits 0..1 */
177+#define IEEE80211_CAP_DMG_MASK 0x0003
178+#define IEEE80211_CAP_DMG_IBSS 0x0001 /* Tx by: STA */
179+#define IEEE80211_CAP_DMG_PBSS 0x0002 /* Tx by: PCP */
180+#define IEEE80211_CAP_DMG_AP 0x0003 /* Tx by: AP */
181+
182+#define WPA_SCAN_QUAL_INVALID BIT(0)
183+#define WPA_SCAN_NOISE_INVALID BIT(1)
184+#define WPA_SCAN_LEVEL_INVALID BIT(2)
185+#define WPA_SCAN_LEVEL_DBM BIT(3)
186+#define WPA_SCAN_AUTHENTICATED BIT(4)
187+#define WPA_SCAN_ASSOCIATED BIT(5)
188+
189+/**
190+ * struct wpa_scan_res - Scan result for an BSS/IBSS
191+ * @flags: information flags about the BSS/IBSS (WPA_SCAN_*)
192+ * @bssid: BSSID
193+ * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
194+ * @beacon_int: beacon interval in TUs (host byte order)
195+ * @caps: capability information field in host byte order
196+ * @qual: signal quality
197+ * @noise: noise level
198+ * @level: signal level
199+ * @tsf: Timestamp
200+ * @age: Age of the information in milliseconds (i.e., how many milliseconds
201+ * ago the last Beacon or Probe Response frame was received)
202+ * @ie_len: length of the following IE field in octets
203+ * @beacon_ie_len: length of the following Beacon IE field in octets
204+ *
205+ * This structure is used as a generic format for scan results from the
206+ * driver. Each driver interface implementation is responsible for converting
207+ * the driver or OS specific scan results into this format.
208+ *
209+ * If the driver does not support reporting all IEs, the IE data structure is
210+ * constructed of the IEs that are available. This field will also need to
211+ * include SSID in IE format. All drivers are encouraged to be extended to
212+ * report all IEs to make it easier to support future additions.
213+ */
214+struct wpa_scan_res {
215+ unsigned int flags;
216+ u8 bssid[ETH_ALEN];
217+ int freq;
218+ u16 beacon_int;
219+ u16 caps;
220+ int qual;
221+ int noise;
222+ int level;
223+ u64 tsf;
224+ unsigned int age;
225+ size_t ie_len;
226+ size_t beacon_ie_len;
227+ /*
228+ * Followed by ie_len octets of IEs from Probe Response frame (or if
229+ * the driver does not indicate source of IEs, these may also be from
230+ * Beacon frame). After the first set of IEs, another set of IEs may
231+ * follow (with beacon_ie_len octets of data) if the driver provides
232+ * both IE sets.
233+ */
234+};
235+
236+/**
237+ * struct wpa_scan_results - Scan results
238+ * @res: Array of pointers to allocated variable length scan result entries
239+ * @num: Number of entries in the scan result array
240+ * @fetch_time: Time when the results were fetched from the driver
241+ */
242+struct wpa_scan_results {
243+ struct wpa_scan_res **res;
244+ size_t num;
245+ struct os_reltime fetch_time;
246+};
247+
248+/**
249+ * struct wpa_interface_info - Network interface information
250+ * @next: Pointer to the next interface or NULL if this is the last one
251+ * @ifname: Interface name that can be used with init() or init2()
252+ * @desc: Human readable adapter description (e.g., vendor/model) or NULL if
253+ * not available
254+ * @drv_name: struct wpa_driver_ops::name (note: unlike other strings, this one
255+ * is not an allocated copy, i.e., get_interfaces() caller will not free
256+ * this)
257+ */
258+struct wpa_interface_info {
259+ struct wpa_interface_info *next;
260+ char *ifname;
261+ char *desc;
262+ const char *drv_name;
263+};
264+
265+#define WPAS_MAX_SCAN_SSIDS 16
266+
267+/**
268+ * struct wpa_driver_scan_params - Scan parameters
269+ * Data for struct wpa_driver_ops::scan2().
270+ */
271+struct wpa_driver_scan_params {
272+ /**
273+ * ssids - SSIDs to scan for
274+ */
275+ struct wpa_driver_scan_ssid {
276+ /**
277+ * ssid - specific SSID to scan for (ProbeReq)
278+ * %NULL or zero-length SSID is used to indicate active scan
279+ * with wildcard SSID.
280+ */
281+ const u8 *ssid;
282+ /**
283+ * ssid_len: Length of the SSID in octets
284+ */
285+ size_t ssid_len;
286+ } ssids[WPAS_MAX_SCAN_SSIDS];
287+
288+ /**
289+ * num_ssids - Number of entries in ssids array
290+ * Zero indicates a request for a passive scan.
291+ */
292+ size_t num_ssids;
293+
294+ /**
295+ * extra_ies - Extra IE(s) to add into Probe Request or %NULL
296+ */
297+ const u8 *extra_ies;
298+
299+ /**
300+ * extra_ies_len - Length of extra_ies in octets
301+ */
302+ size_t extra_ies_len;
303+
304+ /**
305+ * freqs - Array of frequencies to scan or %NULL for all frequencies
306+ *
307+ * The frequency is set in MHz. The array is zero-terminated.
308+ */
309+ int *freqs;
310+
311+ /**
312+ * filter_ssids - Filter for reporting SSIDs
313+ *
314+ * This optional parameter can be used to request the driver wrapper to
315+ * filter scan results to include only the specified SSIDs. %NULL
316+ * indicates that no filtering is to be done. This can be used to
317+ * reduce memory needs for scan results in environments that have large
318+ * number of APs with different SSIDs.
319+ *
320+ * The driver wrapper is allowed to take this allocated buffer into its
321+ * own use by setting the pointer to %NULL. In that case, the driver
322+ * wrapper is responsible for freeing the buffer with os_free() once it
323+ * is not needed anymore.
324+ */
325+ struct wpa_driver_scan_filter {
326+ u8 ssid[32];
327+ size_t ssid_len;
328+ } *filter_ssids;
329+
330+ /**
331+ * num_filter_ssids - Number of entries in filter_ssids array
332+ */
333+ size_t num_filter_ssids;
334+
335+ /**
336+ * filter_rssi - Filter by RSSI
337+ *
338+ * The driver may filter scan results in firmware to reduce host
339+ * wakeups and thereby save power. Specify the RSSI threshold in s32
340+ * dBm.
341+ */
342+ s32 filter_rssi;
343+
344+ /**
345+ * p2p_probe - Used to disable CCK (802.11b) rates for P2P probes
346+ *
347+ * When set, the driver is expected to remove rates 1, 2, 5.5, and 11
348+ * Mbps from the support rates element(s) in the Probe Request frames
349+ * and not to transmit the frames at any of those rates.
350+ */
351+ u8 p2p_probe;
352+
353+ /**
354+ * only_new_results - Request driver to report only new results
355+ *
356+ * This is used to request the driver to report only BSSes that have
357+ * been detected after this scan request has been started, i.e., to
358+ * flush old cached BSS entries.
359+ */
360+ int only_new_results;
361+
362+ /*
363+ * NOTE: Whenever adding new parameters here, please make sure
364+ * wpa_scan_clone_params() and wpa_scan_free_params() get updated with
365+ * matching changes.
366+ */
367+};
368+
369+/**
370+ * struct wpa_driver_auth_params - Authentication parameters
371+ * Data for struct wpa_driver_ops::authenticate().
372+ */
373+struct wpa_driver_auth_params {
374+ int freq;
375+ const u8 *bssid;
376+ const u8 *ssid;
377+ size_t ssid_len;
378+ int auth_alg;
379+ const u8 *ie;
380+ size_t ie_len;
381+ const u8 *wep_key[4];
382+ size_t wep_key_len[4];
383+ int wep_tx_keyidx;
384+ int local_state_change;
385+
386+ /**
387+ * p2p - Whether this connection is a P2P group
388+ */
389+ int p2p;
390+
391+ const u8 *sae_data;
392+ size_t sae_data_len;
393+
394+};
395+
396+enum wps_mode {
397+ WPS_MODE_NONE /* no WPS provisioning being used */,
398+ WPS_MODE_OPEN /* WPS provisioning with AP that is in open mode */,
399+ WPS_MODE_PRIVACY /* WPS provisioning with AP that is using protection
400+ */
401+};
402+
403+/**
404+ * struct wpa_driver_associate_params - Association parameters
405+ * Data for struct wpa_driver_ops::associate().
406+ */
407+struct wpa_driver_associate_params {
408+ /**
409+ * bssid - BSSID of the selected AP
410+ * This can be %NULL, if ap_scan=2 mode is used and the driver is
411+ * responsible for selecting with which BSS to associate. */
412+ const u8 *bssid;
413+
414+ /**
415+ * ssid - The selected SSID
416+ */
417+ const u8 *ssid;
418+
419+ /**
420+ * ssid_len - Length of the SSID (1..32)
421+ */
422+ size_t ssid_len;
423+
424+ /**
425+ * freq - Frequency of the channel the selected AP is using
426+ * Frequency that the selected AP is using (in MHz as
427+ * reported in the scan results)
428+ */
429+ int freq;
430+
431+ /**
432+ * bg_scan_period - Background scan period in seconds, 0 to disable
433+ * background scan, or -1 to indicate no change to default driver
434+ * configuration
435+ */
436+ int bg_scan_period;
437+
438+ /**
439+ * wpa_ie - WPA information element for (Re)Association Request
440+ * WPA information element to be included in (Re)Association
441+ * Request (including information element id and length). Use
442+ * of this WPA IE is optional. If the driver generates the WPA
443+ * IE, it can use pairwise_suite, group_suite, and
444+ * key_mgmt_suite to select proper algorithms. In this case,
445+ * the driver has to notify wpa_supplicant about the used WPA
446+ * IE by generating an event that the interface code will
447+ * convert into EVENT_ASSOCINFO data (see below).
448+ *
449+ * When using WPA2/IEEE 802.11i, wpa_ie is used for RSN IE
450+ * instead. The driver can determine which version is used by
451+ * looking at the first byte of the IE (0xdd for WPA, 0x30 for
452+ * WPA2/RSN).
453+ *
454+ * When using WPS, wpa_ie is used for WPS IE instead of WPA/RSN IE.
455+ */
456+ const u8 *wpa_ie;
457+
458+ /**
459+ * wpa_ie_len - length of the wpa_ie
460+ */
461+ size_t wpa_ie_len;
462+
463+ /**
464+ * wpa_proto - Bitfield of WPA_PROTO_* values to indicate WPA/WPA2
465+ */
466+ unsigned int wpa_proto;
467+
468+ /**
469+ * pairwise_suite - Selected pairwise cipher suite (WPA_CIPHER_*)
470+ *
471+ * This is usually ignored if @wpa_ie is used.
472+ */
473+ unsigned int pairwise_suite;
474+
475+ /**
476+ * group_suite - Selected group cipher suite (WPA_CIPHER_*)
477+ *
478+ * This is usually ignored if @wpa_ie is used.
479+ */
480+ unsigned int group_suite;
481+
482+ /**
483+ * key_mgmt_suite - Selected key management suite (WPA_KEY_MGMT_*)
484+ *
485+ * This is usually ignored if @wpa_ie is used.
486+ */
487+ unsigned int key_mgmt_suite;
488+
489+ /**
490+ * auth_alg - Allowed authentication algorithms
491+ * Bit field of WPA_AUTH_ALG_*
492+ */
493+ int auth_alg;
494+
495+ /**
496+ * mode - Operation mode (infra/ibss) IEEE80211_MODE_*
497+ */
498+ int mode;
499+
500+ /**
501+ * wep_key - WEP keys for static WEP configuration
502+ */
503+ const u8 *wep_key[4];
504+
505+ /**
506+ * wep_key_len - WEP key length for static WEP configuration
507+ */
508+ size_t wep_key_len[4];
509+
510+ /**
511+ * wep_tx_keyidx - WEP TX key index for static WEP configuration
512+ */
513+ int wep_tx_keyidx;
514+
515+ /**
516+ * mgmt_frame_protection - IEEE 802.11w management frame protection
517+ */
518+ enum mfp_options mgmt_frame_protection;
519+
520+ /**
521+ * ft_ies - IEEE 802.11r / FT information elements
522+ * If the supplicant is using IEEE 802.11r (FT) and has the needed keys
523+ * for fast transition, this parameter is set to include the IEs that
524+ * are to be sent in the next FT Authentication Request message.
525+ * update_ft_ies() handler is called to update the IEs for further
526+ * FT messages in the sequence.
527+ *
528+ * The driver should use these IEs only if the target AP is advertising
529+ * the same mobility domain as the one included in the MDIE here.
530+ *
531+ * In ap_scan=2 mode, the driver can use these IEs when moving to a new
532+ * AP after the initial association. These IEs can only be used if the
533+ * target AP is advertising support for FT and is using the same MDIE
534+ * and SSID as the current AP.
535+ *
536+ * The driver is responsible for reporting the FT IEs received from the
537+ * AP's response using wpa_supplicant_event() with EVENT_FT_RESPONSE
538+ * type. update_ft_ies() handler will then be called with the FT IEs to
539+ * include in the next frame in the authentication sequence.
540+ */
541+ const u8 *ft_ies;
542+
543+ /**
544+ * ft_ies_len - Length of ft_ies in bytes
545+ */
546+ size_t ft_ies_len;
547+
548+ /**
549+ * ft_md - FT Mobility domain (6 octets) (also included inside ft_ies)
550+ *
551+ * This value is provided to allow the driver interface easier access
552+ * to the current mobility domain. This value is set to %NULL if no
553+ * mobility domain is currently active.
554+ */
555+ const u8 *ft_md;
556+
557+ /**
558+ * passphrase - RSN passphrase for PSK
559+ *
560+ * This value is made available only for WPA/WPA2-Personal (PSK) and
561+ * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
562+ * the 8..63 character ASCII passphrase, if available. Please note that
563+ * this can be %NULL if passphrase was not used to generate the PSK. In
564+ * that case, the psk field must be used to fetch the PSK.
565+ */
566+ const char *passphrase;
567+
568+ /**
569+ * psk - RSN PSK (alternative for passphrase for PSK)
570+ *
571+ * This value is made available only for WPA/WPA2-Personal (PSK) and
572+ * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
573+ * the 32-octet (256-bit) PSK, if available. The driver wrapper should
574+ * be prepared to handle %NULL value as an error.
575+ */
576+ const u8 *psk;
577+
578+ /**
579+ * drop_unencrypted - Enable/disable unencrypted frame filtering
580+ *
581+ * Configure the driver to drop all non-EAPOL frames (both receive and
582+ * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
583+ * still be allowed for key negotiation.
584+ */
585+ int drop_unencrypted;
586+
587+ /**
588+ * prev_bssid - Previously used BSSID in this ESS
589+ *
590+ * When not %NULL, this is a request to use reassociation instead of
591+ * association.
592+ */
593+ const u8 *prev_bssid;
594+
595+ /**
596+ * wps - WPS mode
597+ *
598+ * If the driver needs to do special configuration for WPS association,
599+ * this variable provides more information on what type of association
600+ * is being requested. Most drivers should not need ot use this.
601+ */
602+ enum wps_mode wps;
603+
604+ /**
605+ * p2p - Whether this connection is a P2P group
606+ */
607+ int p2p;
608+
609+ /**
610+ * uapsd - UAPSD parameters for the network
611+ * -1 = do not change defaults
612+ * AP mode: 1 = enabled, 0 = disabled
613+ * STA mode: bits 0..3 UAPSD enabled for VO,VI,BK,BE
614+ */
615+ int uapsd;
616+
617+ /**
618+ * fixed_bssid - Whether to force this BSSID in IBSS mode
619+ * 1 = Fix this BSSID and prevent merges.
620+ * 0 = Do not fix BSSID.
621+ */
622+ int fixed_bssid;
623+
624+ /**
625+ * disable_ht - Disable HT (IEEE 802.11n) for this connection
626+ */
627+ int disable_ht;
628+
629+ /**
630+ * HT Capabilities over-rides. Only bits set in the mask will be used,
631+ * and not all values are used by the kernel anyway. Currently, MCS,
632+ * MPDU and MSDU fields are used.
633+ */
634+ const u8 *htcaps; /* struct ieee80211_ht_capabilities * */
635+ const u8 *htcaps_mask; /* struct ieee80211_ht_capabilities * */
636+
637+#ifdef CONFIG_VHT_OVERRIDES
638+ /**
639+ * disable_vht - Disable VHT for this connection
640+ */
641+ int disable_vht;
642+
643+ /**
644+ * VHT capability overrides.
645+ */
646+ const struct ieee80211_vht_capabilities *vhtcaps;
647+ const struct ieee80211_vht_capabilities *vhtcaps_mask;
648+#endif /* CONFIG_VHT_OVERRIDES */
649+};
650+
651+enum hide_ssid {
652+ NO_SSID_HIDING,
653+ HIDDEN_SSID_ZERO_LEN,
654+ HIDDEN_SSID_ZERO_CONTENTS
655+};
656+
657+struct wpa_driver_ap_params {
658+ /**
659+ * head - Beacon head from IEEE 802.11 header to IEs before TIM IE
660+ */
661+ u8 *head;
662+
663+ /**
664+ * head_len - Length of the head buffer in octets
665+ */
666+ size_t head_len;
667+
668+ /**
669+ * tail - Beacon tail following TIM IE
670+ */
671+ u8 *tail;
672+
673+ /**
674+ * tail_len - Length of the tail buffer in octets
675+ */
676+ size_t tail_len;
677+
678+ /**
679+ * dtim_period - DTIM period
680+ */
681+ int dtim_period;
682+
683+ /**
684+ * beacon_int - Beacon interval
685+ */
686+ int beacon_int;
687+
688+ /**
689+ * basic_rates: -1 terminated array of basic rates in 100 kbps
690+ *
691+ * This parameter can be used to set a specific basic rate set for the
692+ * BSS. If %NULL, default basic rate set is used.
693+ */
694+ int *basic_rates;
695+
696+ /**
697+ * proberesp - Probe Response template
698+ *
699+ * This is used by drivers that reply to Probe Requests internally in
700+ * AP mode and require the full Probe Response template.
701+ */
702+ u8 *proberesp;
703+
704+ /**
705+ * proberesp_len - Length of the proberesp buffer in octets
706+ */
707+ size_t proberesp_len;
708+
709+ /**
710+ * ssid - The SSID to use in Beacon/Probe Response frames
711+ */
712+ const u8 *ssid;
713+
714+ /**
715+ * ssid_len - Length of the SSID (1..32)
716+ */
717+ size_t ssid_len;
718+
719+ /**
720+ * hide_ssid - Whether to hide the SSID
721+ */
722+ enum hide_ssid hide_ssid;
723+
724+ /**
725+ * pairwise_ciphers - WPA_CIPHER_* bitfield
726+ */
727+ unsigned int pairwise_ciphers;
728+
729+ /**
730+ * group_cipher - WPA_CIPHER_*
731+ */
732+ unsigned int group_cipher;
733+
734+ /**
735+ * key_mgmt_suites - WPA_KEY_MGMT_* bitfield
736+ */
737+ unsigned int key_mgmt_suites;
738+
739+ /**
740+ * auth_algs - WPA_AUTH_ALG_* bitfield
741+ */
742+ unsigned int auth_algs;
743+
744+ /**
745+ * wpa_version - WPA_PROTO_* bitfield
746+ */
747+ unsigned int wpa_version;
748+
749+ /**
750+ * privacy - Whether privacy is used in the BSS
751+ */
752+ int privacy;
753+
754+ /**
755+ * beacon_ies - WPS/P2P IE(s) for Beacon frames
756+ *
757+ * This is used to add IEs like WPS IE and P2P IE by drivers that do
758+ * not use the full Beacon template.
759+ */
760+ const struct wpabuf *beacon_ies;
761+
762+ /**
763+ * proberesp_ies - P2P/WPS IE(s) for Probe Response frames
764+ *
765+ * This is used to add IEs like WPS IE and P2P IE by drivers that
766+ * reply to Probe Request frames internally.
767+ */
768+ const struct wpabuf *proberesp_ies;
769+
770+ /**
771+ * assocresp_ies - WPS IE(s) for (Re)Association Response frames
772+ *
773+ * This is used to add IEs like WPS IE by drivers that reply to
774+ * (Re)Association Request frames internally.
775+ */
776+ const struct wpabuf *assocresp_ies;
777+
778+ /**
779+ * isolate - Whether to isolate frames between associated stations
780+ *
781+ * If this is non-zero, the AP is requested to disable forwarding of
782+ * frames between associated stations.
783+ */
784+ int isolate;
785+
786+ /**
787+ * cts_protect - Whether CTS protection is enabled
788+ */
789+ int cts_protect;
790+
791+ /**
792+ * preamble - Whether short preamble is enabled
793+ */
794+ int preamble;
795+
796+ /**
797+ * short_slot_time - Whether short slot time is enabled
798+ *
799+ * 0 = short slot time disable, 1 = short slot time enabled, -1 = do
800+ * not set (e.g., when 802.11g mode is not in use)
801+ */
802+ int short_slot_time;
803+
804+ /**
805+ * ht_opmode - HT operation mode or -1 if HT not in use
806+ */
807+ int ht_opmode;
808+
809+ /**
810+ * interworking - Whether Interworking is enabled
811+ */
812+ int interworking;
813+
814+ /**
815+ * hessid - Homogeneous ESS identifier or %NULL if not set
816+ */
817+ const u8 *hessid;
818+
819+ /**
820+ * access_network_type - Access Network Type (0..15)
821+ *
822+ * This is used for filtering Probe Request frames when Interworking is
823+ * enabled.
824+ */
825+ u8 access_network_type;
826+
827+ /**
828+ * ap_max_inactivity - Timeout in seconds to detect STA's inactivity
829+ *
830+ * This is used by driver which advertises this capability.
831+ */
832+ int ap_max_inactivity;
833+
834+ /**
835+ * disable_dgaf - Whether group-addressed frames are disabled
836+ */
837+ int disable_dgaf;
838+};
839+
840+/**
841+ * struct wpa_driver_capa - Driver capability information
842+ */
843+struct wpa_driver_capa {
844+#define WPA_DRIVER_CAPA_KEY_MGMT_WPA 0x00000001
845+#define WPA_DRIVER_CAPA_KEY_MGMT_WPA2 0x00000002
846+#define WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK 0x00000004
847+#define WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK 0x00000008
848+#define WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE 0x00000010
849+#define WPA_DRIVER_CAPA_KEY_MGMT_FT 0x00000020
850+#define WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK 0x00000040
851+#define WPA_DRIVER_CAPA_KEY_MGMT_WAPI_PSK 0x00000080
852+ unsigned int key_mgmt;
853+
854+#define WPA_DRIVER_CAPA_ENC_WEP40 0x00000001
855+#define WPA_DRIVER_CAPA_ENC_WEP104 0x00000002
856+#define WPA_DRIVER_CAPA_ENC_TKIP 0x00000004
857+#define WPA_DRIVER_CAPA_ENC_CCMP 0x00000008
858+#define WPA_DRIVER_CAPA_ENC_WEP128 0x00000010
859+#define WPA_DRIVER_CAPA_ENC_GCMP 0x00000020
860+#define WPA_DRIVER_CAPA_ENC_GCMP_256 0x00000040
861+#define WPA_DRIVER_CAPA_ENC_CCMP_256 0x00000080
862+#define WPA_DRIVER_CAPA_ENC_BIP 0x00000100
863+#define WPA_DRIVER_CAPA_ENC_BIP_GMAC_128 0x00000200
864+#define WPA_DRIVER_CAPA_ENC_BIP_GMAC_256 0x00000400
865+#define WPA_DRIVER_CAPA_ENC_BIP_CMAC_256 0x00000800
866+ unsigned int enc;
867+
868+#define WPA_DRIVER_AUTH_OPEN 0x00000001
869+#define WPA_DRIVER_AUTH_SHARED 0x00000002
870+#define WPA_DRIVER_AUTH_LEAP 0x00000004
871+ unsigned int auth;
872+
873+/* Driver generated WPA/RSN IE */
874+#define WPA_DRIVER_FLAGS_DRIVER_IE 0x00000001
875+/* Driver needs static WEP key setup after association command */
876+#define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC 0x00000002
877+/* unused: 0x00000004 */
878+/* Driver takes care of RSN 4-way handshake internally; PMK is configured with
879+ * struct wpa_driver_ops::set_key using alg = WPA_ALG_PMK */
880+#define WPA_DRIVER_FLAGS_4WAY_HANDSHAKE 0x00000008
881+#define WPA_DRIVER_FLAGS_WIRED 0x00000010
882+/* Driver provides separate commands for authentication and association (SME in
883+ * wpa_supplicant). */
884+#define WPA_DRIVER_FLAGS_SME 0x00000020
885+/* Driver supports AP mode */
886+#define WPA_DRIVER_FLAGS_AP 0x00000040
887+/* Driver needs static WEP key setup after association has been completed */
888+#define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE 0x00000080
889+/* unused: 0x00000100 */
890+/* Driver supports concurrent P2P operations */
891+#define WPA_DRIVER_FLAGS_P2P_CONCURRENT 0x00000200
892+/*
893+ * Driver uses the initial interface as a dedicated management interface, i.e.,
894+ * it cannot be used for P2P group operations or non-P2P purposes.
895+ */
896+#define WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE 0x00000400
897+/* This interface is P2P capable (P2P GO or P2P Client) */
898+#define WPA_DRIVER_FLAGS_P2P_CAPABLE 0x00000800
899+/* unused: 0x00001000 */
900+/*
901+ * Driver uses the initial interface for P2P management interface and non-P2P
902+ * purposes (e.g., connect to infra AP), but this interface cannot be used for
903+ * P2P group operations.
904+ */
905+#define WPA_DRIVER_FLAGS_P2P_MGMT_AND_NON_P2P 0x00002000
906+/*
907+ * Driver is known to use sane error codes, i.e., when it indicates that
908+ * something (e.g., association) fails, there was indeed a failure and the
909+ * operation does not end up getting completed successfully later.
910+ */
911+#define WPA_DRIVER_FLAGS_SANE_ERROR_CODES 0x00004000
912+/* Driver supports off-channel TX */
913+#define WPA_DRIVER_FLAGS_OFFCHANNEL_TX 0x00008000
914+/* Driver indicates TX status events for EAPOL Data frames */
915+#define WPA_DRIVER_FLAGS_EAPOL_TX_STATUS 0x00010000
916+/* Driver indicates TX status events for Deauth/Disassoc frames */
917+#define WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS 0x00020000
918+/* Driver supports roaming (BSS selection) in firmware */
919+#define WPA_DRIVER_FLAGS_BSS_SELECTION 0x00040000
920+/* Driver supports operating as a TDLS peer */
921+#define WPA_DRIVER_FLAGS_TDLS_SUPPORT 0x00080000
922+/* Driver requires external TDLS setup/teardown/discovery */
923+#define WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP 0x00100000
924+/* Driver indicates support for Probe Response offloading in AP mode */
925+#define WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD 0x00200000
926+/* Driver supports U-APSD in AP mode */
927+#define WPA_DRIVER_FLAGS_AP_UAPSD 0x00400000
928+/* Driver supports inactivity timer in AP mode */
929+#define WPA_DRIVER_FLAGS_INACTIVITY_TIMER 0x00800000
930+/* Driver expects user space implementation of MLME in AP mode */
931+#define WPA_DRIVER_FLAGS_AP_MLME 0x01000000
932+/* Driver supports SAE with user space SME */
933+#define WPA_DRIVER_FLAGS_SAE 0x02000000
934+/* Driver makes use of OBSS scan mechanism in wpa_supplicant */
935+#define WPA_DRIVER_FLAGS_OBSS_SCAN 0x04000000
936+/* Driver supports IBSS (Ad-hoc) mode */
937+#define WPA_DRIVER_FLAGS_IBSS 0x08000000
938+/* Driver supports radar detection */
939+#define WPA_DRIVER_FLAGS_RADAR 0x10000000
940+/* Driver supports a dedicated interface for P2P Device */
941+#define WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE 0x20000000
942+/* Driver supports QoS Mapping */
943+#define WPA_DRIVER_FLAGS_QOS_MAPPING 0x40000000
944+/* Driver supports CSA in AP mode */
945+#define WPA_DRIVER_FLAGS_AP_CSA 0x80000000
946+ unsigned int flags;
947+
948+ int max_scan_ssids;
949+ int max_sched_scan_ssids;
950+ int sched_scan_supported;
951+ int max_match_sets;
952+
953+ /**
954+ * max_remain_on_chan - Maximum remain-on-channel duration in msec
955+ */
956+ unsigned int max_remain_on_chan;
957+
958+ /**
959+ * max_stations - Maximum number of associated stations the driver
960+ * supports in AP mode
961+ */
962+ unsigned int max_stations;
963+
964+ /**
965+ * probe_resp_offloads - Bitmap of supported protocols by the driver
966+ * for Probe Response offloading.
967+ */
968+/* Driver Probe Response offloading support for WPS ver. 1 */
969+#define WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS 0x00000001
970+/* Driver Probe Response offloading support for WPS ver. 2 */
971+#define WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2 0x00000002
972+/* Driver Probe Response offloading support for P2P */
973+#define WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P 0x00000004
974+/* Driver Probe Response offloading support for IEEE 802.11u (Interworking) */
975+#define WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING 0x00000008
976+ unsigned int probe_resp_offloads;
977+
978+ unsigned int max_acl_mac_addrs;
979+
980+ /**
981+ * Number of supported concurrent channels
982+ */
983+ unsigned int num_multichan_concurrent;
984+
985+ /**
986+ * extended_capa - extended capabilities in driver/device
987+ *
988+ * Must be allocated and freed by driver and the pointers must be
989+ * valid for the lifetime of the driver, i.e., freed in deinit()
990+ */
991+ const u8 *extended_capa, *extended_capa_mask;
992+ unsigned int extended_capa_len;
993+};
994+
995+
996+struct hostapd_data;
997+
998+struct hostap_sta_driver_data {
999+ unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
1000+ unsigned long current_tx_rate;
1001+ unsigned long inactive_msec;
1002+ unsigned long flags;
1003+ unsigned long num_ps_buf_frames;
1004+ unsigned long tx_retry_failed;
1005+ unsigned long tx_retry_count;
1006+ int last_rssi;
1007+ int last_ack_rssi;
1008+};
1009+
1010+struct hostapd_sta_add_params {
1011+ const u8 *addr;
1012+ u16 aid;
1013+ u16 capability;
1014+ const u8 *supp_rates;
1015+ size_t supp_rates_len;
1016+ u16 listen_interval;
1017+ const struct ieee80211_ht_capabilities *ht_capabilities;
1018+ const struct ieee80211_vht_capabilities *vht_capabilities;
1019+ u32 flags; /* bitmask of WPA_STA_* flags */
1020+ int set; /* Set STA parameters instead of add */
1021+ u8 qosinfo;
1022+ const u8 *ext_capab;
1023+ size_t ext_capab_len;
1024+ const u8 *supp_channels;
1025+ size_t supp_channels_len;
1026+ const u8 *supp_oper_classes;
1027+ size_t supp_oper_classes_len;
1028+};
1029+
1030+struct hostapd_freq_params {
1031+ int mode;
1032+ int freq;
1033+ int channel;
1034+ /* for HT */
1035+ int ht_enabled;
1036+ int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
1037+ * secondary channel below primary, 1 = HT40
1038+ * enabled, secondary channel above primary */
1039+
1040+ /* for VHT */
1041+ int vht_enabled;
1042+
1043+ /* valid for both HT and VHT, center_freq2 is non-zero
1044+ * only for bandwidth 80 and an 80+80 channel */
1045+ int center_freq1, center_freq2;
1046+ int bandwidth;
1047+};
1048+
1049+struct mac_address {
1050+ u8 addr[ETH_ALEN];
1051+};
1052+
1053+struct hostapd_acl_params {
1054+ u8 acl_policy;
1055+ unsigned int num_mac_acl;
1056+ struct mac_address mac_acl[0];
1057+};
1058+
1059+enum wpa_driver_if_type {
1060+ /**
1061+ * WPA_IF_STATION - Station mode interface
1062+ */
1063+ WPA_IF_STATION,
1064+
1065+ /**
1066+ * WPA_IF_AP_VLAN - AP mode VLAN interface
1067+ *
1068+ * This interface shares its address and Beacon frame with the main
1069+ * BSS.
1070+ */
1071+ WPA_IF_AP_VLAN,
1072+
1073+ /**
1074+ * WPA_IF_AP_BSS - AP mode BSS interface
1075+ *
1076+ * This interface has its own address and Beacon frame.
1077+ */
1078+ WPA_IF_AP_BSS,
1079+
1080+ /**
1081+ * WPA_IF_P2P_GO - P2P Group Owner
1082+ */
1083+ WPA_IF_P2P_GO,
1084+
1085+ /**
1086+ * WPA_IF_P2P_CLIENT - P2P Client
1087+ */
1088+ WPA_IF_P2P_CLIENT,
1089+
1090+ /**
1091+ * WPA_IF_P2P_GROUP - P2P Group interface (will become either
1092+ * WPA_IF_P2P_GO or WPA_IF_P2P_CLIENT, but the role is not yet known)
1093+ */
1094+ WPA_IF_P2P_GROUP,
1095+
1096+ /**
1097+ * WPA_IF_P2P_DEVICE - P2P Device interface is used to indentify the
1098+ * abstracted P2P Device function in the driver
1099+ */
1100+ WPA_IF_P2P_DEVICE
1101+};
1102+
1103+struct wpa_init_params {
1104+ void *global_priv;
1105+ const u8 *bssid;
1106+ const char *ifname;
1107+ const u8 *ssid;
1108+ size_t ssid_len;
1109+ const char *test_socket;
1110+ int use_pae_group_addr;
1111+ char **bridge;
1112+ size_t num_bridge;
1113+
1114+ u8 *own_addr; /* buffer for writing own MAC address */
1115+};
1116+
1117+
1118+struct wpa_bss_params {
1119+ /** Interface name (for multi-SSID/VLAN support) */
1120+ const char *ifname;
1121+ /** Whether IEEE 802.1X or WPA/WPA2 is enabled */
1122+ int enabled;
1123+
1124+ int wpa;
1125+ int ieee802_1x;
1126+ int wpa_group;
1127+ int wpa_pairwise;
1128+ int wpa_key_mgmt;
1129+ int rsn_preauth;
1130+ enum mfp_options ieee80211w;
1131+};
1132+
1133+#define WPA_STA_AUTHORIZED BIT(0)
1134+#define WPA_STA_WMM BIT(1)
1135+#define WPA_STA_SHORT_PREAMBLE BIT(2)
1136+#define WPA_STA_MFP BIT(3)
1137+#define WPA_STA_TDLS_PEER BIT(4)
1138+
1139+enum tdls_oper {
1140+ TDLS_DISCOVERY_REQ,
1141+ TDLS_SETUP,
1142+ TDLS_TEARDOWN,
1143+ TDLS_ENABLE_LINK,
1144+ TDLS_DISABLE_LINK,
1145+ TDLS_ENABLE,
1146+ TDLS_DISABLE
1147+};
1148+
1149+enum wnm_oper {
1150+ WNM_SLEEP_ENTER_CONFIRM,
1151+ WNM_SLEEP_ENTER_FAIL,
1152+ WNM_SLEEP_EXIT_CONFIRM,
1153+ WNM_SLEEP_EXIT_FAIL,
1154+ WNM_SLEEP_TFS_REQ_IE_ADD, /* STA requests driver to add TFS req IE */
1155+ WNM_SLEEP_TFS_REQ_IE_NONE, /* STA requests empty TFS req IE */
1156+ WNM_SLEEP_TFS_REQ_IE_SET, /* AP requests driver to set TFS req IE for
1157+ * a STA */
1158+ WNM_SLEEP_TFS_RESP_IE_ADD, /* AP requests driver to add TFS resp IE
1159+ * for a STA */
1160+ WNM_SLEEP_TFS_RESP_IE_NONE, /* AP requests empty TFS resp IE */
1161+ WNM_SLEEP_TFS_RESP_IE_SET, /* AP requests driver to set TFS resp IE
1162+ * for a STA */
1163+ WNM_SLEEP_TFS_IE_DEL /* AP delete the TFS IE */
1164+};
1165+
1166+/* enum chan_width - Channel width definitions */
1167+enum chan_width {
1168+ CHAN_WIDTH_20_NOHT,
1169+ CHAN_WIDTH_20,
1170+ CHAN_WIDTH_40,
1171+ CHAN_WIDTH_80,
1172+ CHAN_WIDTH_80P80,
1173+ CHAN_WIDTH_160,
1174+ CHAN_WIDTH_UNKNOWN
1175+};
1176+
1177+/**
1178+ * struct wpa_signal_info - Information about channel signal quality
1179+ */
1180+struct wpa_signal_info {
1181+ u32 frequency;
1182+ int above_threshold;
1183+ int current_signal;
1184+ int avg_signal;
1185+ int current_noise;
1186+ int current_txrate;
1187+ enum chan_width chanwidth;
1188+ int center_frq1;
1189+ int center_frq2;
1190+};
1191+
1192+/**
1193+ * struct beacon_data - Beacon data
1194+ * @head: Head portion of Beacon frame (before TIM IE)
1195+ * @tail: Tail portion of Beacon frame (after TIM IE)
1196+ * @beacon_ies: Extra information element(s) to add into Beacon frames or %NULL
1197+ * @proberesp_ies: Extra information element(s) to add into Probe Response
1198+ * frames or %NULL
1199+ * @assocresp_ies: Extra information element(s) to add into (Re)Association
1200+ * Response frames or %NULL
1201+ * @probe_resp: Probe Response frame template
1202+ * @head_len: Length of @head
1203+ * @tail_len: Length of @tail
1204+ * @beacon_ies_len: Length of beacon_ies in octets
1205+ * @proberesp_ies_len: Length of proberesp_ies in octets
1206+ * @proberesp_ies_len: Length of proberesp_ies in octets
1207+ * @probe_resp_len: Length of probe response template (@probe_resp)
1208+ */
1209+struct beacon_data {
1210+ u8 *head, *tail;
1211+ u8 *beacon_ies;
1212+ u8 *proberesp_ies;
1213+ u8 *assocresp_ies;
1214+ u8 *probe_resp;
1215+
1216+ size_t head_len, tail_len;
1217+ size_t beacon_ies_len;
1218+ size_t proberesp_ies_len;
1219+ size_t assocresp_ies_len;
1220+ size_t probe_resp_len;
1221+};
1222+
1223+/**
1224+ * struct csa_settings - Settings for channel switch command
1225+ * @cs_count: Count in Beacon frames (TBTT) to perform the switch
1226+ * @block_tx: 1 - block transmission for CSA period
1227+ * @freq_params: Next channel frequency parameter
1228+ * @beacon_csa: Beacon/probe resp/asooc resp info for CSA period
1229+ * @beacon_after: Next beacon/probe resp/asooc resp info
1230+ * @counter_offset_beacon: Offset to the count field in beacon's tail
1231+ * @counter_offset_presp: Offset to the count field in probe resp.
1232+ */
1233+struct csa_settings {
1234+ u8 cs_count;
1235+ u8 block_tx;
1236+
1237+ struct hostapd_freq_params freq_params;
1238+ struct beacon_data beacon_csa;
1239+ struct beacon_data beacon_after;
1240+
1241+ u16 counter_offset_beacon;
1242+ u16 counter_offset_presp;
1243+};
1244+
1245+/**
1246+ * struct wpa_driver_ops - Driver interface API definition
1247+ *
1248+ * This structure defines the API that each driver interface needs to implement
1249+ * for core wpa_supplicant code. All driver specific functionality is captured
1250+ * in this wrapper.
1251+ */
1252+struct wpa_driver_ops {
1253+ /** Name of the driver interface */
1254+ const char *name;
1255+ /** One line description of the driver interface */
1256+ const char *desc;
1257+
1258+ /**
1259+ * get_bssid - Get the current BSSID
1260+ * @priv: private driver interface data
1261+ * @bssid: buffer for BSSID (ETH_ALEN = 6 bytes)
1262+ *
1263+ * Returns: 0 on success, -1 on failure
1264+ *
1265+ * Query kernel driver for the current BSSID and copy it to bssid.
1266+ * Setting bssid to 00:00:00:00:00:00 is recommended if the STA is not
1267+ * associated.
1268+ */
1269+ int (*get_bssid)(void *priv, u8 *bssid);
1270+
1271+ /**
1272+ * get_ssid - Get the current SSID
1273+ * @priv: private driver interface data
1274+ * @ssid: buffer for SSID (at least 32 bytes)
1275+ *
1276+ * Returns: Length of the SSID on success, -1 on failure
1277+ *
1278+ * Query kernel driver for the current SSID and copy it to ssid.
1279+ * Returning zero is recommended if the STA is not associated.
1280+ *
1281+ * Note: SSID is an array of octets, i.e., it is not nul terminated and
1282+ * can, at least in theory, contain control characters (including nul)
1283+ * and as such, should be processed as binary data, not a printable
1284+ * string.
1285+ */
1286+ int (*get_ssid)(void *priv, u8 *ssid);
1287+
1288+ /**
1289+ * set_key - Configure encryption key
1290+ * @ifname: Interface name (for multi-SSID/VLAN support)
1291+ * @priv: private driver interface data
1292+ * @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
1293+ * %WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK,
1294+ * %WPA_ALG_GCMP, %WPA_ALG_GCMP_256, %WPA_ALG_CCMP_256,
1295+ * %WPA_ALG_BIP_GMAC_128, %WPA_ALG_BIP_GMAC_256,
1296+ * %WPA_ALG_BIP_CMAC_256);
1297+ * %WPA_ALG_NONE clears the key.
1298+ * @addr: Address of the peer STA (BSSID of the current AP when setting
1299+ * pairwise key in station mode), ff:ff:ff:ff:ff:ff for
1300+ * broadcast keys, %NULL for default keys that are used both for
1301+ * broadcast and unicast; when clearing keys, %NULL is used to
1302+ * indicate that both the broadcast-only and default key of the
1303+ * specified key index is to be cleared
1304+ * @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
1305+ * IGTK
1306+ * @set_tx: configure this key as the default Tx key (only used when
1307+ * driver does not support separate unicast/individual key
1308+ * @seq: sequence number/packet number, seq_len octets, the next
1309+ * packet number to be used for in replay protection; configured
1310+ * for Rx keys (in most cases, this is only used with broadcast
1311+ * keys and set to zero for unicast keys); %NULL if not set
1312+ * @seq_len: length of the seq, depends on the algorithm:
1313+ * TKIP: 6 octets, CCMP/GCMP: 6 octets, IGTK: 6 octets
1314+ * @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
1315+ * 8-byte Rx Mic Key
1316+ * @key_len: length of the key buffer in octets (WEP: 5 or 13,
1317+ * TKIP: 32, CCMP/GCMP: 16, IGTK: 16)
1318+ *
1319+ * Returns: 0 on success, -1 on failure
1320+ *
1321+ * Configure the given key for the kernel driver. If the driver
1322+ * supports separate individual keys (4 default keys + 1 individual),
1323+ * addr can be used to determine whether the key is default or
1324+ * individual. If only 4 keys are supported, the default key with key
1325+ * index 0 is used as the individual key. STA must be configured to use
1326+ * it as the default Tx key (set_tx is set) and accept Rx for all the
1327+ * key indexes. In most cases, WPA uses only key indexes 1 and 2 for
1328+ * broadcast keys, so key index 0 is available for this kind of
1329+ * configuration.
1330+ *
1331+ * Please note that TKIP keys include separate TX and RX MIC keys and
1332+ * some drivers may expect them in different order than wpa_supplicant
1333+ * is using. If the TX/RX keys are swapped, all TKIP encrypted packets
1334+ * will trigger Michael MIC errors. This can be fixed by changing the
1335+ * order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
1336+ * in driver_*.c set_key() implementation, see driver_ndis.c for an
1337+ * example on how this can be done.
1338+ */
1339+ int (*set_key)(const char *ifname, void *priv, enum wpa_alg alg,
1340+ const u8 *addr, int key_idx, int set_tx,
1341+ const u8 *seq, size_t seq_len,
1342+ const u8 *key, size_t key_len);
1343+
1344+ /**
1345+ * init - Initialize driver interface
1346+ * @ctx: context to be used when calling wpa_supplicant functions,
1347+ * e.g., wpa_supplicant_event()
1348+ * @ifname: interface name, e.g., wlan0
1349+ *
1350+ * Returns: Pointer to private data, %NULL on failure
1351+ *
1352+ * Initialize driver interface, including event processing for kernel
1353+ * driver events (e.g., associated, scan results, Michael MIC failure).
1354+ * This function can allocate a private configuration data area for
1355+ * @ctx, file descriptor, interface name, etc. information that may be
1356+ * needed in future driver operations. If this is not used, non-NULL
1357+ * value will need to be returned because %NULL is used to indicate
1358+ * failure. The returned value will be used as 'void *priv' data for
1359+ * all other driver_ops functions.
1360+ *
1361+ * The main event loop (eloop.c) of wpa_supplicant can be used to
1362+ * register callback for read sockets (eloop_register_read_sock()).
1363+ *
1364+ * See below for more information about events and
1365+ * wpa_supplicant_event() function.
1366+ */
1367+ void * (*init)(void *ctx, const char *ifname);
1368+
1369+ /**
1370+ * deinit - Deinitialize driver interface
1371+ * @priv: private driver interface data from init()
1372+ *
1373+ * Shut down driver interface and processing of driver events. Free
1374+ * private data buffer if one was allocated in init() handler.
1375+ */
1376+ void (*deinit)(void *priv);
1377+
1378+ /**
1379+ * set_param - Set driver configuration parameters
1380+ * @priv: private driver interface data from init()
1381+ * @param: driver specific configuration parameters
1382+ *
1383+ * Returns: 0 on success, -1 on failure
1384+ *
1385+ * Optional handler for notifying driver interface about configuration
1386+ * parameters (driver_param).
1387+ */
1388+ int (*set_param)(void *priv, const char *param);
1389+
1390+ /**
1391+ * set_countermeasures - Enable/disable TKIP countermeasures
1392+ * @priv: private driver interface data
1393+ * @enabled: 1 = countermeasures enabled, 0 = disabled
1394+ *
1395+ * Returns: 0 on success, -1 on failure
1396+ *
1397+ * Configure TKIP countermeasures. When these are enabled, the driver
1398+ * should drop all received and queued frames that are using TKIP.
1399+ */
1400+ int (*set_countermeasures)(void *priv, int enabled);
1401+
1402+ /**
1403+ * deauthenticate - Request driver to deauthenticate
1404+ * @priv: private driver interface data
1405+ * @addr: peer address (BSSID of the AP)
1406+ * @reason_code: 16-bit reason code to be sent in the deauthentication
1407+ * frame
1408+ *
1409+ * Returns: 0 on success, -1 on failure
1410+ */
1411+ int (*deauthenticate)(void *priv, const u8 *addr, int reason_code);
1412+
1413+ /**
1414+ * associate - Request driver to associate
1415+ * @priv: private driver interface data
1416+ * @params: association parameters
1417+ *
1418+ * Returns: 0 on success, -1 on failure
1419+ */
1420+ int (*associate)(void *priv,
1421+ struct wpa_driver_associate_params *params);
1422+
1423+ /**
1424+ * add_pmkid - Add PMKSA cache entry to the driver
1425+ * @priv: private driver interface data
1426+ * @bssid: BSSID for the PMKSA cache entry
1427+ * @pmkid: PMKID for the PMKSA cache entry
1428+ *
1429+ * Returns: 0 on success, -1 on failure
1430+ *
1431+ * This function is called when a new PMK is received, as a result of
1432+ * either normal authentication or RSN pre-authentication.
1433+ *
1434+ * If the driver generates RSN IE, i.e., it does not use wpa_ie in
1435+ * associate(), add_pmkid() can be used to add new PMKSA cache entries
1436+ * in the driver. If the driver uses wpa_ie from wpa_supplicant, this
1437+ * driver_ops function does not need to be implemented. Likewise, if
1438+ * the driver does not support WPA, this function is not needed.
1439+ */
1440+ int (*add_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
1441+
1442+ /**
1443+ * remove_pmkid - Remove PMKSA cache entry to the driver
1444+ * @priv: private driver interface data
1445+ * @bssid: BSSID for the PMKSA cache entry
1446+ * @pmkid: PMKID for the PMKSA cache entry
1447+ *
1448+ * Returns: 0 on success, -1 on failure
1449+ *
1450+ * This function is called when the supplicant drops a PMKSA cache
1451+ * entry for any reason.
1452+ *
1453+ * If the driver generates RSN IE, i.e., it does not use wpa_ie in
1454+ * associate(), remove_pmkid() can be used to synchronize PMKSA caches
1455+ * between the driver and wpa_supplicant. If the driver uses wpa_ie
1456+ * from wpa_supplicant, this driver_ops function does not need to be
1457+ * implemented. Likewise, if the driver does not support WPA, this
1458+ * function is not needed.
1459+ */
1460+ int (*remove_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
1461+
1462+ /**
1463+ * flush_pmkid - Flush PMKSA cache
1464+ * @priv: private driver interface data
1465+ *
1466+ * Returns: 0 on success, -1 on failure
1467+ *
1468+ * This function is called when the supplicant drops all PMKSA cache
1469+ * entries for any reason.
1470+ *
1471+ * If the driver generates RSN IE, i.e., it does not use wpa_ie in
1472+ * associate(), remove_pmkid() can be used to synchronize PMKSA caches
1473+ * between the driver and wpa_supplicant. If the driver uses wpa_ie
1474+ * from wpa_supplicant, this driver_ops function does not need to be
1475+ * implemented. Likewise, if the driver does not support WPA, this
1476+ * function is not needed.
1477+ */
1478+ int (*flush_pmkid)(void *priv);
1479+
1480+ /**
1481+ * get_capa - Get driver capabilities
1482+ * @priv: private driver interface data
1483+ *
1484+ * Returns: 0 on success, -1 on failure
1485+ *
1486+ * Get driver/firmware/hardware capabilities.
1487+ */
1488+ int (*get_capa)(void *priv, struct wpa_driver_capa *capa);
1489+
1490+ /**
1491+ * poll - Poll driver for association information
1492+ * @priv: private driver interface data
1493+ *
1494+ * This is an option callback that can be used when the driver does not
1495+ * provide event mechanism for association events. This is called when
1496+ * receiving WPA EAPOL-Key messages that require association
1497+ * information. The driver interface is supposed to generate associnfo
1498+ * event before returning from this callback function. In addition, the
1499+ * driver interface should generate an association event after having
1500+ * sent out associnfo.
1501+ */
1502+ void (*poll)(void *priv);
1503+
1504+ /**
1505+ * get_ifname - Get interface name
1506+ * @priv: private driver interface data
1507+ *
1508+ * Returns: Pointer to the interface name. This can differ from the
1509+ * interface name used in init() call. Init() is called first.
1510+ *
1511+ * This optional function can be used to allow the driver interface to
1512+ * replace the interface name with something else, e.g., based on an
1513+ * interface mapping from a more descriptive name.
1514+ */
1515+ const char * (*get_ifname)(void *priv);
1516+
1517+ /**
1518+ * get_mac_addr - Get own MAC address
1519+ * @priv: private driver interface data
1520+ *
1521+ * Returns: Pointer to own MAC address or %NULL on failure
1522+ *
1523+ * This optional function can be used to get the own MAC address of the
1524+ * device from the driver interface code. This is only needed if the
1525+ * l2_packet implementation for the OS does not provide easy access to
1526+ * a MAC address. */
1527+ const u8 * (*get_mac_addr)(void *priv);
1528+
1529+ /**
1530+ * send_eapol - Optional function for sending EAPOL packets
1531+ * @priv: private driver interface data
1532+ * @dest: Destination MAC address
1533+ * @proto: Ethertype
1534+ * @data: EAPOL packet starting with IEEE 802.1X header
1535+ * @data_len: Size of the EAPOL packet
1536+ *
1537+ * Returns: 0 on success, -1 on failure
1538+ *
1539+ * This optional function can be used to override l2_packet operations
1540+ * with driver specific functionality. If this function pointer is set,
1541+ * l2_packet module is not used at all and the driver interface code is
1542+ * responsible for receiving and sending all EAPOL packets. The
1543+ * received EAPOL packets are sent to core code with EVENT_EAPOL_RX
1544+ * event. The driver interface is required to implement get_mac_addr()
1545+ * handler if send_eapol() is used.
1546+ */
1547+ int (*send_eapol)(void *priv, const u8 *dest, u16 proto,
1548+ const u8 *data, size_t data_len);
1549+
1550+ /**
1551+ * set_operstate - Sets device operating state to DORMANT or UP
1552+ * @priv: private driver interface data
1553+ * @state: 0 = dormant, 1 = up
1554+ * Returns: 0 on success, -1 on failure
1555+ *
1556+ * This is an optional function that can be used on operating systems
1557+ * that support a concept of controlling network device state from user
1558+ * space applications. This function, if set, gets called with
1559+ * state = 1 when authentication has been completed and with state = 0
1560+ * when connection is lost.
1561+ */
1562+ int (*set_operstate)(void *priv, int state);
1563+
1564+ /**
1565+ * mlme_setprotection - MLME-SETPROTECTION.request primitive
1566+ * @priv: Private driver interface data
1567+ * @addr: Address of the station for which to set protection (may be
1568+ * %NULL for group keys)
1569+ * @protect_type: MLME_SETPROTECTION_PROTECT_TYPE_*
1570+ * @key_type: MLME_SETPROTECTION_KEY_TYPE_*
1571+ * Returns: 0 on success, -1 on failure
1572+ *
1573+ * This is an optional function that can be used to set the driver to
1574+ * require protection for Tx and/or Rx frames. This uses the layer
1575+ * interface defined in IEEE 802.11i-2004 clause 10.3.22.1
1576+ * (MLME-SETPROTECTION.request). Many drivers do not use explicit
1577+ * set protection operation; instead, they set protection implicitly
1578+ * based on configured keys.
1579+ */
1580+ int (*mlme_setprotection)(void *priv, const u8 *addr, int protect_type,
1581+ int key_type);
1582+
1583+ /**
1584+ * get_hw_feature_data - Get hardware support data (channels and rates)
1585+ * @priv: Private driver interface data
1586+ * @num_modes: Variable for returning the number of returned modes
1587+ * flags: Variable for returning hardware feature flags
1588+ * Returns: Pointer to allocated hardware data on success or %NULL on
1589+ * failure. Caller is responsible for freeing this.
1590+ */
1591+ struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
1592+ u16 *num_modes,
1593+ u16 *flags);
1594+
1595+ /**
1596+ * send_mlme - Send management frame from MLME
1597+ * @priv: Private driver interface data
1598+ * @data: IEEE 802.11 management frame with IEEE 802.11 header
1599+ * @data_len: Size of the management frame
1600+ * @noack: Do not wait for this frame to be acked (disable retries)
1601+ * Returns: 0 on success, -1 on failure
1602+ */
1603+ int (*send_mlme)(void *priv, const u8 *data, size_t data_len,
1604+ int noack);
1605+
1606+ /**
1607+ * update_ft_ies - Update FT (IEEE 802.11r) IEs
1608+ * @priv: Private driver interface data
1609+ * @md: Mobility domain (2 octets) (also included inside ies)
1610+ * @ies: FT IEs (MDIE, FTIE, ...) or %NULL to remove IEs
1611+ * @ies_len: Length of FT IEs in bytes
1612+ * Returns: 0 on success, -1 on failure
1613+ *
1614+ * The supplicant uses this callback to let the driver know that keying
1615+ * material for FT is available and that the driver can use the
1616+ * provided IEs in the next message in FT authentication sequence.
1617+ *
1618+ * This function is only needed for driver that support IEEE 802.11r
1619+ * (Fast BSS Transition).
1620+ */
1621+ int (*update_ft_ies)(void *priv, const u8 *md, const u8 *ies,
1622+ size_t ies_len);
1623+
1624+ /**
1625+ * send_ft_action - Send FT Action frame (IEEE 802.11r)
1626+ * @priv: Private driver interface data
1627+ * @action: Action field value
1628+ * @target_ap: Target AP address
1629+ * @ies: FT IEs (MDIE, FTIE, ...) (FT Request action frame body)
1630+ * @ies_len: Length of FT IEs in bytes
1631+ * Returns: 0 on success, -1 on failure
1632+ *
1633+ * The supplicant uses this callback to request the driver to transmit
1634+ * an FT Action frame (action category 6) for over-the-DS fast BSS
1635+ * transition.
1636+ */
1637+ int (*send_ft_action)(void *priv, u8 action, const u8 *target_ap,
1638+ const u8 *ies, size_t ies_len);
1639+
1640+ /**
1641+ * get_scan_results2 - Fetch the latest scan results
1642+ * @priv: private driver interface data
1643+ *
1644+ * Returns: Allocated buffer of scan results (caller is responsible for
1645+ * freeing the data structure) on success, NULL on failure
1646+ */
1647+ struct wpa_scan_results * (*get_scan_results2)(void *priv);
1648+
1649+ /**
1650+ * set_country - Set country
1651+ * @priv: Private driver interface data
1652+ * @alpha2: country to which to switch to
1653+ * Returns: 0 on success, -1 on failure
1654+ *
1655+ * This function is for drivers which support some form
1656+ * of setting a regulatory domain.
1657+ */
1658+ int (*set_country)(void *priv, const char *alpha2);
1659+
1660+ /**
1661+ * get_country - Get country
1662+ * @priv: Private driver interface data
1663+ * @alpha2: Buffer for returning country code (at least 3 octets)
1664+ * Returns: 0 on success, -1 on failure
1665+ */
1666+ int (*get_country)(void *priv, char *alpha2);
1667+
1668+ /**
1669+ * global_init - Global driver initialization
1670+ * Returns: Pointer to private data (global), %NULL on failure
1671+ *
1672+ * This optional function is called to initialize the driver wrapper
1673+ * for global data, i.e., data that applies to all interfaces. If this
1674+ * function is implemented, global_deinit() will also need to be
1675+ * implemented to free the private data. The driver will also likely
1676+ * use init2() function instead of init() to get the pointer to global
1677+ * data available to per-interface initializer.
1678+ */
1679+ void * (*global_init)(void);
1680+
1681+ /**
1682+ * global_deinit - Global driver deinitialization
1683+ * @priv: private driver global data from global_init()
1684+ *
1685+ * Terminate any global driver related functionality and free the
1686+ * global data structure.
1687+ */
1688+ void (*global_deinit)(void *priv);
1689+
1690+ /**
1691+ * init2 - Initialize driver interface (with global data)
1692+ * @ctx: context to be used when calling wpa_supplicant functions,
1693+ * e.g., wpa_supplicant_event()
1694+ * @ifname: interface name, e.g., wlan0
1695+ * @global_priv: private driver global data from global_init()
1696+ * Returns: Pointer to private data, %NULL on failure
1697+ *
1698+ * This function can be used instead of init() if the driver wrapper
1699+ * uses global data.
1700+ */
1701+ void * (*init2)(void *ctx, const char *ifname, void *global_priv);
1702+
1703+ /**
1704+ * get_interfaces - Get information about available interfaces
1705+ * @global_priv: private driver global data from global_init()
1706+ * Returns: Allocated buffer of interface information (caller is
1707+ * responsible for freeing the data structure) on success, NULL on
1708+ * failure
1709+ */
1710+ struct wpa_interface_info * (*get_interfaces)(void *global_priv);
1711+
1712+ /**
1713+ * scan2 - Request the driver to initiate scan
1714+ * @priv: private driver interface data
1715+ * @params: Scan parameters
1716+ *
1717+ * Returns: 0 on success, -1 on failure
1718+ *
1719+ * Once the scan results are ready, the driver should report scan
1720+ * results event for wpa_supplicant which will eventually request the
1721+ * results with wpa_driver_get_scan_results2().
1722+ */
1723+ int (*scan2)(void *priv, struct wpa_driver_scan_params *params);
1724+
1725+ /**
1726+ * authenticate - Request driver to authenticate
1727+ * @priv: private driver interface data
1728+ * @params: authentication parameters
1729+ * Returns: 0 on success, -1 on failure
1730+ *
1731+ * This is an optional function that can be used with drivers that
1732+ * support separate authentication and association steps, i.e., when
1733+ * wpa_supplicant can act as the SME. If not implemented, associate()
1734+ * function is expected to take care of IEEE 802.11 authentication,
1735+ * too.
1736+ */
1737+ int (*authenticate)(void *priv,
1738+ struct wpa_driver_auth_params *params);
1739+
1740+ /**
1741+ * set_ap - Set Beacon and Probe Response information for AP mode
1742+ * @priv: Private driver interface data
1743+ * @params: Parameters to use in AP mode
1744+ *
1745+ * This function is used to configure Beacon template and/or extra IEs
1746+ * to add for Beacon and Probe Response frames for the driver in
1747+ * AP mode. The driver is responsible for building the full Beacon
1748+ * frame by concatenating the head part with TIM IE generated by the
1749+ * driver/firmware and finishing with the tail part. Depending on the
1750+ * driver architectue, this can be done either by using the full
1751+ * template or the set of additional IEs (e.g., WPS and P2P IE).
1752+ * Similarly, Probe Response processing depends on the driver design.
1753+ * If the driver (or firmware) takes care of replying to Probe Request
1754+ * frames, the extra IEs provided here needs to be added to the Probe
1755+ * Response frames.
1756+ *
1757+ * Returns: 0 on success, -1 on failure
1758+ */
1759+ int (*set_ap)(void *priv, struct wpa_driver_ap_params *params);
1760+
1761+ /**
1762+ * set_acl - Set ACL in AP mode
1763+ * @priv: Private driver interface data
1764+ * @params: Parameters to configure ACL
1765+ * Returns: 0 on success, -1 on failure
1766+ *
1767+ * This is used only for the drivers which support MAC address ACL.
1768+ */
1769+ int (*set_acl)(void *priv, struct hostapd_acl_params *params);
1770+
1771+ /**
1772+ * hapd_init - Initialize driver interface (hostapd only)
1773+ * @hapd: Pointer to hostapd context
1774+ * @params: Configuration for the driver wrapper
1775+ * Returns: Pointer to private data, %NULL on failure
1776+ *
1777+ * This function is used instead of init() or init2() when the driver
1778+ * wrapper is used with hostapd.
1779+ */
1780+ void * (*hapd_init)(struct hostapd_data *hapd,
1781+ struct wpa_init_params *params);
1782+
1783+ /**
1784+ * hapd_deinit - Deinitialize driver interface (hostapd only)
1785+ * @priv: Private driver interface data from hapd_init()
1786+ */
1787+ void (*hapd_deinit)(void *priv);
1788+
1789+ /**
1790+ * set_ieee8021x - Enable/disable IEEE 802.1X support (AP only)
1791+ * @priv: Private driver interface data
1792+ * @params: BSS parameters
1793+ * Returns: 0 on success, -1 on failure
1794+ *
1795+ * This is an optional function to configure the kernel driver to
1796+ * enable/disable IEEE 802.1X support and set WPA/WPA2 parameters. This
1797+ * can be left undefined (set to %NULL) if IEEE 802.1X support is
1798+ * always enabled and the driver uses set_ap() to set WPA/RSN IE
1799+ * for Beacon frames.
1800+ *
1801+ * DEPRECATED - use set_ap() instead
1802+ */
1803+ int (*set_ieee8021x)(void *priv, struct wpa_bss_params *params);
1804+
1805+ /**
1806+ * set_privacy - Enable/disable privacy (AP only)
1807+ * @priv: Private driver interface data
1808+ * @enabled: 1 = privacy enabled, 0 = disabled
1809+ * Returns: 0 on success, -1 on failure
1810+ *
1811+ * This is an optional function to configure privacy field in the
1812+ * kernel driver for Beacon frames. This can be left undefined (set to
1813+ * %NULL) if the driver uses the Beacon template from set_ap().
1814+ *
1815+ * DEPRECATED - use set_ap() instead
1816+ */
1817+ int (*set_privacy)(void *priv, int enabled);
1818+
1819+ /**
1820+ * get_seqnum - Fetch the current TSC/packet number (AP only)
1821+ * @ifname: The interface name (main or virtual)
1822+ * @priv: Private driver interface data
1823+ * @addr: MAC address of the station or %NULL for group keys
1824+ * @idx: Key index
1825+ * @seq: Buffer for returning the latest used TSC/packet number
1826+ * Returns: 0 on success, -1 on failure
1827+ *
1828+ * This function is used to fetch the last used TSC/packet number for
1829+ * a TKIP, CCMP, GCMP, or BIP/IGTK key. It is mainly used with group
1830+ * keys, so there is no strict requirement on implementing support for
1831+ * unicast keys (i.e., addr != %NULL).
1832+ */
1833+ int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
1834+ int idx, u8 *seq);
1835+
1836+ /**
1837+ * flush - Flush all association stations (AP only)
1838+ * @priv: Private driver interface data
1839+ * Returns: 0 on success, -1 on failure
1840+ *
1841+ * This function requests the driver to disassociate all associated
1842+ * stations. This function does not need to be implemented if the
1843+ * driver does not process association frames internally.
1844+ */
1845+ int (*flush)(void *priv);
1846+
1847+ /**
1848+ * set_generic_elem - Add IEs into Beacon/Probe Response frames (AP)
1849+ * @priv: Private driver interface data
1850+ * @elem: Information elements
1851+ * @elem_len: Length of the elem buffer in octets
1852+ * Returns: 0 on success, -1 on failure
1853+ *
1854+ * This is an optional function to add information elements in the
1855+ * kernel driver for Beacon and Probe Response frames. This can be left
1856+ * undefined (set to %NULL) if the driver uses the Beacon template from
1857+ * set_ap().
1858+ *
1859+ * DEPRECATED - use set_ap() instead
1860+ */
1861+ int (*set_generic_elem)(void *priv, const u8 *elem, size_t elem_len);
1862+
1863+ /**
1864+ * read_sta_data - Fetch station data
1865+ * @priv: Private driver interface data
1866+ * @data: Buffer for returning station information
1867+ * @addr: MAC address of the station
1868+ * Returns: 0 on success, -1 on failure
1869+ */
1870+ int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
1871+ const u8 *addr);
1872+
1873+ /**
1874+ * hapd_send_eapol - Send an EAPOL packet (AP only)
1875+ * @priv: private driver interface data
1876+ * @addr: Destination MAC address
1877+ * @data: EAPOL packet starting with IEEE 802.1X header
1878+ * @data_len: Length of the EAPOL packet in octets
1879+ * @encrypt: Whether the frame should be encrypted
1880+ * @own_addr: Source MAC address
1881+ * @flags: WPA_STA_* flags for the destination station
1882+ *
1883+ * Returns: 0 on success, -1 on failure
1884+ */
1885+ int (*hapd_send_eapol)(void *priv, const u8 *addr, const u8 *data,
1886+ size_t data_len, int encrypt,
1887+ const u8 *own_addr, u32 flags);
1888+
1889+ /**
1890+ * sta_deauth - Deauthenticate a station (AP only)
1891+ * @priv: Private driver interface data
1892+ * @own_addr: Source address and BSSID for the Deauthentication frame
1893+ * @addr: MAC address of the station to deauthenticate
1894+ * @reason: Reason code for the Deauthentiation frame
1895+ * Returns: 0 on success, -1 on failure
1896+ *
1897+ * This function requests a specific station to be deauthenticated and
1898+ * a Deauthentication frame to be sent to it.
1899+ */
1900+ int (*sta_deauth)(void *priv, const u8 *own_addr, const u8 *addr,
1901+ int reason);
1902+
1903+ /**
1904+ * sta_disassoc - Disassociate a station (AP only)
1905+ * @priv: Private driver interface data
1906+ * @own_addr: Source address and BSSID for the Disassociation frame
1907+ * @addr: MAC address of the station to disassociate
1908+ * @reason: Reason code for the Disassociation frame
1909+ * Returns: 0 on success, -1 on failure
1910+ *
1911+ * This function requests a specific station to be disassociated and
1912+ * a Disassociation frame to be sent to it.
1913+ */
1914+ int (*sta_disassoc)(void *priv, const u8 *own_addr, const u8 *addr,
1915+ int reason);
1916+
1917+ /**
1918+ * sta_remove - Remove a station entry (AP only)
1919+ * @priv: Private driver interface data
1920+ * @addr: MAC address of the station to be removed
1921+ * Returns: 0 on success, -1 on failure
1922+ */
1923+ int (*sta_remove)(void *priv, const u8 *addr);
1924+
1925+ /**
1926+ * hapd_get_ssid - Get the current SSID (AP only)
1927+ * @priv: Private driver interface data
1928+ * @buf: Buffer for returning the SSID
1929+ * @len: Maximum length of the buffer
1930+ * Returns: Length of the SSID on success, -1 on failure
1931+ *
1932+ * This function need not be implemented if the driver uses Beacon
1933+ * template from set_ap() and does not reply to Probe Request frames.
1934+ */
1935+ int (*hapd_get_ssid)(void *priv, u8 *buf, int len);
1936+
1937+ /**
1938+ * hapd_set_ssid - Set SSID (AP only)
1939+ * @priv: Private driver interface data
1940+ * @buf: SSID
1941+ * @len: Length of the SSID in octets
1942+ * Returns: 0 on success, -1 on failure
1943+ *
1944+ * DEPRECATED - use set_ap() instead
1945+ */
1946+ int (*hapd_set_ssid)(void *priv, const u8 *buf, int len);
1947+
1948+ /**
1949+ * hapd_set_countermeasures - Enable/disable TKIP countermeasures (AP)
1950+ * @priv: Private driver interface data
1951+ * @enabled: 1 = countermeasures enabled, 0 = disabled
1952+ * Returns: 0 on success, -1 on failure
1953+ *
1954+ * This need not be implemented if the driver does not take care of
1955+ * association processing.
1956+ */
1957+ int (*hapd_set_countermeasures)(void *priv, int enabled);
1958+
1959+ /**
1960+ * sta_add - Add a station entry
1961+ * @priv: Private driver interface data
1962+ * @params: Station parameters
1963+ * Returns: 0 on success, -1 on failure
1964+ *
1965+ * This function is used to add a station entry to the driver once the
1966+ * station has completed association. This is only used if the driver
1967+ * does not take care of association processing.
1968+ *
1969+ * With TDLS, this function is also used to add or set (params->set 1)
1970+ * TDLS peer entries.
1971+ */
1972+ int (*sta_add)(void *priv, struct hostapd_sta_add_params *params);
1973+
1974+ /**
1975+ * get_inact_sec - Get station inactivity duration (AP only)
1976+ * @priv: Private driver interface data
1977+ * @addr: Station address
1978+ * Returns: Number of seconds station has been inactive, -1 on failure
1979+ */
1980+ int (*get_inact_sec)(void *priv, const u8 *addr);
1981+
1982+ /**
1983+ * sta_clear_stats - Clear station statistics (AP only)
1984+ * @priv: Private driver interface data
1985+ * @addr: Station address
1986+ * Returns: 0 on success, -1 on failure
1987+ */
1988+ int (*sta_clear_stats)(void *priv, const u8 *addr);
1989+
1990+ /**
1991+ * set_freq - Set channel/frequency (AP only)
1992+ * @priv: Private driver interface data
1993+ * @freq: Channel parameters
1994+ * Returns: 0 on success, -1 on failure
1995+ */
1996+ int (*set_freq)(void *priv, struct hostapd_freq_params *freq);
1997+
1998+ /**
1999+ * set_rts - Set RTS threshold
2000+ * @priv: Private driver interface data
2001+ * @rts: RTS threshold in octets
2002+ * Returns: 0 on success, -1 on failure
2003+ */
2004+ int (*set_rts)(void *priv, int rts);
2005+
2006+ /**
2007+ * set_frag - Set fragmentation threshold
2008+ * @priv: Private driver interface data
2009+ * @frag: Fragmentation threshold in octets
2010+ * Returns: 0 on success, -1 on failure
2011+ */
2012+ int (*set_frag)(void *priv, int frag);
2013+
2014+ /**
2015+ * sta_set_flags - Set station flags (AP only)
2016+ * @priv: Private driver interface data
2017+ * @addr: Station address
2018+ * @total_flags: Bitmap of all WPA_STA_* flags currently set
2019+ * @flags_or: Bitmap of WPA_STA_* flags to add
2020+ * @flags_and: Bitmap of WPA_STA_* flags to us as a mask
2021+ * Returns: 0 on success, -1 on failure
2022+ */
2023+ int (*sta_set_flags)(void *priv, const u8 *addr,
2024+ int total_flags, int flags_or, int flags_and);
2025+
2026+ /**
2027+ * set_tx_queue_params - Set TX queue parameters
2028+ * @priv: Private driver interface data
2029+ * @queue: Queue number (0 = VO, 1 = VI, 2 = BE, 3 = BK)
2030+ * @aifs: AIFS
2031+ * @cw_min: cwMin
2032+ * @cw_max: cwMax
2033+ * @burst_time: Maximum length for bursting in 0.1 msec units
2034+ */
2035+ int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
2036+ int cw_max, int burst_time);
2037+
2038+ /**
2039+ * if_add - Add a virtual interface
2040+ * @priv: Private driver interface data
2041+ * @type: Interface type
2042+ * @ifname: Interface name for the new virtual interface
2043+ * @addr: Local address to use for the interface or %NULL to use the
2044+ * parent interface address
2045+ * @bss_ctx: BSS context for %WPA_IF_AP_BSS interfaces
2046+ * @drv_priv: Pointer for overwriting the driver context or %NULL if
2047+ * not allowed (applies only to %WPA_IF_AP_BSS type)
2048+ * @force_ifname: Buffer for returning an interface name that the
2049+ * driver ended up using if it differs from the requested ifname
2050+ * @if_addr: Buffer for returning the allocated interface address
2051+ * (this may differ from the requested addr if the driver cannot
2052+ * change interface address)
2053+ * @bridge: Bridge interface to use or %NULL if no bridge configured
2054+ * @use_existing: Whether to allow existing interface to be used
2055+ * Returns: 0 on success, -1 on failure
2056+ */
2057+ int (*if_add)(void *priv, enum wpa_driver_if_type type,
2058+ const char *ifname, const u8 *addr, void *bss_ctx,
2059+ void **drv_priv, char *force_ifname, u8 *if_addr,
2060+ const char *bridge, int use_existing);
2061+
2062+ /**
2063+ * if_remove - Remove a virtual interface
2064+ * @priv: Private driver interface data
2065+ * @type: Interface type
2066+ * @ifname: Interface name of the virtual interface to be removed
2067+ * Returns: 0 on success, -1 on failure
2068+ */
2069+ int (*if_remove)(void *priv, enum wpa_driver_if_type type,
2070+ const char *ifname);
2071+
2072+ /**
2073+ * set_sta_vlan - Bind a station into a specific interface (AP only)
2074+ * @priv: Private driver interface data
2075+ * @ifname: Interface (main or virtual BSS or VLAN)
2076+ * @addr: MAC address of the associated station
2077+ * @vlan_id: VLAN ID
2078+ * Returns: 0 on success, -1 on failure
2079+ *
2080+ * This function is used to bind a station to a specific virtual
2081+ * interface. It is only used if when virtual interfaces are supported,
2082+ * e.g., to assign stations to different VLAN interfaces based on
2083+ * information from a RADIUS server. This allows separate broadcast
2084+ * domains to be used with a single BSS.
2085+ */
2086+ int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
2087+ int vlan_id);
2088+
2089+ /**
2090+ * commit - Optional commit changes handler (AP only)
2091+ * @priv: driver private data
2092+ * Returns: 0 on success, -1 on failure
2093+ *
2094+ * This optional handler function can be registered if the driver
2095+ * interface implementation needs to commit changes (e.g., by setting
2096+ * network interface up) at the end of initial configuration. If set,
2097+ * this handler will be called after initial setup has been completed.
2098+ */
2099+ int (*commit)(void *priv);
2100+
2101+ /**
2102+ * send_ether - Send an ethernet packet (AP only)
2103+ * @priv: private driver interface data
2104+ * @dst: Destination MAC address
2105+ * @src: Source MAC address
2106+ * @proto: Ethertype
2107+ * @data: EAPOL packet starting with IEEE 802.1X header
2108+ * @data_len: Length of the EAPOL packet in octets
2109+ * Returns: 0 on success, -1 on failure
2110+ */
2111+ int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
2112+ const u8 *data, size_t data_len);
2113+
2114+ /**
2115+ * set_radius_acl_auth - Notification of RADIUS ACL change
2116+ * @priv: Private driver interface data
2117+ * @mac: MAC address of the station
2118+ * @accepted: Whether the station was accepted
2119+ * @session_timeout: Session timeout for the station
2120+ * Returns: 0 on success, -1 on failure
2121+ */
2122+ int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted,
2123+ u32 session_timeout);
2124+
2125+ /**
2126+ * set_radius_acl_expire - Notification of RADIUS ACL expiration
2127+ * @priv: Private driver interface data
2128+ * @mac: MAC address of the station
2129+ * Returns: 0 on success, -1 on failure
2130+ */
2131+ int (*set_radius_acl_expire)(void *priv, const u8 *mac);
2132+
2133+ /**
2134+ * set_ap_wps_ie - Add WPS IE(s) into Beacon/Probe Response frames (AP)
2135+ * @priv: Private driver interface data
2136+ * @beacon: WPS IE(s) for Beacon frames or %NULL to remove extra IE(s)
2137+ * @proberesp: WPS IE(s) for Probe Response frames or %NULL to remove
2138+ * extra IE(s)
2139+ * @assocresp: WPS IE(s) for (Re)Association Response frames or %NULL
2140+ * to remove extra IE(s)
2141+ * Returns: 0 on success, -1 on failure
2142+ *
2143+ * This is an optional function to add WPS IE in the kernel driver for
2144+ * Beacon and Probe Response frames. This can be left undefined (set
2145+ * to %NULL) if the driver uses the Beacon template from set_ap()
2146+ * and does not process Probe Request frames. If the driver takes care
2147+ * of (Re)Association frame processing, the assocresp buffer includes
2148+ * WPS IE(s) that need to be added to (Re)Association Response frames
2149+ * whenever a (Re)Association Request frame indicated use of WPS.
2150+ *
2151+ * This will also be used to add P2P IE(s) into Beacon/Probe Response
2152+ * frames when operating as a GO. The driver is responsible for adding
2153+ * timing related attributes (e.g., NoA) in addition to the IEs
2154+ * included here by appending them after these buffers. This call is
2155+ * also used to provide Probe Response IEs for P2P Listen state
2156+ * operations for drivers that generate the Probe Response frames
2157+ * internally.
2158+ *
2159+ * DEPRECATED - use set_ap() instead
2160+ */
2161+ int (*set_ap_wps_ie)(void *priv, const struct wpabuf *beacon,
2162+ const struct wpabuf *proberesp,
2163+ const struct wpabuf *assocresp);
2164+
2165+ /**
2166+ * set_supp_port - Set IEEE 802.1X Supplicant Port status
2167+ * @priv: Private driver interface data
2168+ * @authorized: Whether the port is authorized
2169+ * Returns: 0 on success, -1 on failure
2170+ */
2171+ int (*set_supp_port)(void *priv, int authorized);
2172+
2173+ /**
2174+ * set_wds_sta - Bind a station into a 4-address WDS (AP only)
2175+ * @priv: Private driver interface data
2176+ * @addr: MAC address of the associated station
2177+ * @aid: Association ID
2178+ * @val: 1 = bind to 4-address WDS; 0 = unbind
2179+ * @bridge_ifname: Bridge interface to use for the WDS station or %NULL
2180+ * to indicate that bridge is not to be used
2181+ * @ifname_wds: Buffer to return the interface name for the new WDS
2182+ * station or %NULL to indicate name is not returned.
2183+ * Returns: 0 on success, -1 on failure
2184+ */
2185+ int (*set_wds_sta)(void *priv, const u8 *addr, int aid, int val,
2186+ const char *bridge_ifname, char *ifname_wds);
2187+
2188+ /**
2189+ * send_action - Transmit an Action frame
2190+ * @priv: Private driver interface data
2191+ * @freq: Frequency (in MHz) of the channel
2192+ * @wait: Time to wait off-channel for a response (in ms), or zero
2193+ * @dst: Destination MAC address (Address 1)
2194+ * @src: Source MAC address (Address 2)
2195+ * @bssid: BSSID (Address 3)
2196+ * @data: Frame body
2197+ * @data_len: data length in octets
2198+ @ @no_cck: Whether CCK rates must not be used to transmit this frame
2199+ * Returns: 0 on success, -1 on failure
2200+ *
2201+ * This command can be used to request the driver to transmit an action
2202+ * frame to the specified destination.
2203+ *
2204+ * If the %WPA_DRIVER_FLAGS_OFFCHANNEL_TX flag is set, the frame will
2205+ * be transmitted on the given channel and the device will wait for a
2206+ * response on that channel for the given wait time.
2207+ *
2208+ * If the flag is not set, the wait time will be ignored. In this case,
2209+ * if a remain-on-channel duration is in progress, the frame must be
2210+ * transmitted on that channel; alternatively the frame may be sent on
2211+ * the current operational channel (if in associated state in station
2212+ * mode or while operating as an AP.)
2213+ */
2214+ int (*send_action)(void *priv, unsigned int freq, unsigned int wait,
2215+ const u8 *dst, const u8 *src, const u8 *bssid,
2216+ const u8 *data, size_t data_len, int no_cck);
2217+
2218+ /**
2219+ * send_action_cancel_wait - Cancel action frame TX wait
2220+ * @priv: Private driver interface data
2221+ *
2222+ * This command cancels the wait time associated with sending an action
2223+ * frame. It is only available when %WPA_DRIVER_FLAGS_OFFCHANNEL_TX is
2224+ * set in the driver flags.
2225+ */
2226+ void (*send_action_cancel_wait)(void *priv);
2227+
2228+ /**
2229+ * remain_on_channel - Remain awake on a channel
2230+ * @priv: Private driver interface data
2231+ * @freq: Frequency (in MHz) of the channel
2232+ * @duration: Duration in milliseconds
2233+ * Returns: 0 on success, -1 on failure
2234+ *
2235+ * This command is used to request the driver to remain awake on the
2236+ * specified channel for the specified duration and report received
2237+ * Action frames with EVENT_RX_MGMT events. Optionally, received
2238+ * Probe Request frames may also be requested to be reported by calling
2239+ * probe_req_report(). These will be reported with EVENT_RX_PROBE_REQ.
2240+ *
2241+ * The driver may not be at the requested channel when this function
2242+ * returns, i.e., the return code is only indicating whether the
2243+ * request was accepted. The caller will need to wait until the
2244+ * EVENT_REMAIN_ON_CHANNEL event indicates that the driver has
2245+ * completed the channel change. This may take some time due to other
2246+ * need for the radio and the caller should be prepared to timing out
2247+ * its wait since there are no guarantees on when this request can be
2248+ * executed.
2249+ */
2250+ int (*remain_on_channel)(void *priv, unsigned int freq,
2251+ unsigned int duration);
2252+
2253+ /**
2254+ * cancel_remain_on_channel - Cancel remain-on-channel operation
2255+ * @priv: Private driver interface data
2256+ *
2257+ * This command can be used to cancel a remain-on-channel operation
2258+ * before its originally requested duration has passed. This could be
2259+ * used, e.g., when remain_on_channel() is used to request extra time
2260+ * to receive a response to an Action frame and the response is
2261+ * received when there is still unneeded time remaining on the
2262+ * remain-on-channel operation.
2263+ */
2264+ int (*cancel_remain_on_channel)(void *priv);
2265+
2266+ /**
2267+ * probe_req_report - Request Probe Request frames to be indicated
2268+ * @priv: Private driver interface data
2269+ * @report: Whether to report received Probe Request frames
2270+ * Returns: 0 on success, -1 on failure (or if not supported)
2271+ *
2272+ * This command can be used to request the driver to indicate when
2273+ * Probe Request frames are received with EVENT_RX_PROBE_REQ events.
2274+ * Since this operation may require extra resources, e.g., due to less
2275+ * optimal hardware/firmware RX filtering, many drivers may disable
2276+ * Probe Request reporting at least in station mode. This command is
2277+ * used to notify the driver when the Probe Request frames need to be
2278+ * reported, e.g., during remain-on-channel operations.
2279+ */
2280+ int (*probe_req_report)(void *priv, int report);
2281+
2282+ /**
2283+ * deinit_ap - Deinitialize AP mode
2284+ * @priv: Private driver interface data
2285+ * Returns: 0 on success, -1 on failure (or if not supported)
2286+ *
2287+ * This optional function can be used to disable AP mode related
2288+ * configuration. If the interface was not dynamically added,
2289+ * change the driver mode to station mode to allow normal station
2290+ * operations like scanning to be completed.
2291+ */
2292+ int (*deinit_ap)(void *priv);
2293+
2294+ /**
2295+ * deinit_p2p_cli - Deinitialize P2P client mode
2296+ * @priv: Private driver interface data
2297+ * Returns: 0 on success, -1 on failure (or if not supported)
2298+ *
2299+ * This optional function can be used to disable P2P client mode. If the
2300+ * interface was not dynamically added, change the interface type back
2301+ * to station mode.
2302+ */
2303+ int (*deinit_p2p_cli)(void *priv);
2304+
2305+ /**
2306+ * suspend - Notification on system suspend/hibernate event
2307+ * @priv: Private driver interface data
2308+ */
2309+ void (*suspend)(void *priv);
2310+
2311+ /**
2312+ * resume - Notification on system resume/thaw event
2313+ * @priv: Private driver interface data
2314+ */
2315+ void (*resume)(void *priv);
2316+
2317+ /**
2318+ * signal_monitor - Set signal monitoring parameters
2319+ * @priv: Private driver interface data
2320+ * @threshold: Threshold value for signal change events; 0 = disabled
2321+ * @hysteresis: Minimum change in signal strength before indicating a
2322+ * new event
2323+ * Returns: 0 on success, -1 on failure (or if not supported)
2324+ *
2325+ * This function can be used to configure monitoring of signal strength
2326+ * with the current AP. Whenever signal strength drops below the
2327+ * %threshold value or increases above it, EVENT_SIGNAL_CHANGE event
2328+ * should be generated assuming the signal strength has changed at
2329+ * least %hysteresis from the previously indicated signal change event.
2330+ */
2331+ int (*signal_monitor)(void *priv, int threshold, int hysteresis);
2332+
2333+ /**
2334+ * send_frame - Send IEEE 802.11 frame (testing use only)
2335+ * @priv: Private driver interface data
2336+ * @data: IEEE 802.11 frame with IEEE 802.11 header
2337+ * @data_len: Size of the frame
2338+ * @encrypt: Whether to encrypt the frame (if keys are set)
2339+ * Returns: 0 on success, -1 on failure
2340+ *
2341+ * This function is only used for debugging purposes and is not
2342+ * required to be implemented for normal operations.
2343+ */
2344+ int (*send_frame)(void *priv, const u8 *data, size_t data_len,
2345+ int encrypt);
2346+
2347+ /**
2348+ * shared_freq - Get operating frequency of shared interface(s)
2349+ * @priv: Private driver interface data
2350+ * Returns: Operating frequency in MHz, 0 if no shared operation in
2351+ * use, or -1 on failure
2352+ *
2353+ * This command can be used to request the current operating frequency
2354+ * of any virtual interface that shares the same radio to provide
2355+ * information for channel selection for other virtual interfaces.
2356+ */
2357+ int (*shared_freq)(void *priv);
2358+
2359+ /**
2360+ * get_noa - Get current Notice of Absence attribute payload
2361+ * @priv: Private driver interface data
2362+ * @buf: Buffer for returning NoA
2363+ * @buf_len: Buffer length in octets
2364+ * Returns: Number of octets used in buf, 0 to indicate no NoA is being
2365+ * advertized, or -1 on failure
2366+ *
2367+ * This function is used to fetch the current Notice of Absence
2368+ * attribute value from GO.
2369+ */
2370+ int (*get_noa)(void *priv, u8 *buf, size_t buf_len);
2371+
2372+ /**
2373+ * set_noa - Set Notice of Absence parameters for GO (testing)
2374+ * @priv: Private driver interface data
2375+ * @count: Count
2376+ * @start: Start time in ms from next TBTT
2377+ * @duration: Duration in ms
2378+ * Returns: 0 on success or -1 on failure
2379+ *
2380+ * This function is used to set Notice of Absence parameters for GO. It
2381+ * is used only for testing. To disable NoA, all parameters are set to
2382+ * 0.
2383+ */
2384+ int (*set_noa)(void *priv, u8 count, int start, int duration);
2385+
2386+ /**
2387+ * set_p2p_powersave - Set P2P power save options
2388+ * @priv: Private driver interface data
2389+ * @legacy_ps: 0 = disable, 1 = enable, 2 = maximum PS, -1 = no change
2390+ * @opp_ps: 0 = disable, 1 = enable, -1 = no change
2391+ * @ctwindow: 0.. = change (msec), -1 = no change
2392+ * Returns: 0 on success or -1 on failure
2393+ */
2394+ int (*set_p2p_powersave)(void *priv, int legacy_ps, int opp_ps,
2395+ int ctwindow);
2396+
2397+ /**
2398+ * ampdu - Enable/disable aggregation
2399+ * @priv: Private driver interface data
2400+ * @ampdu: 1/0 = enable/disable A-MPDU aggregation
2401+ * Returns: 0 on success or -1 on failure
2402+ */
2403+ int (*ampdu)(void *priv, int ampdu);
2404+
2405+ /**
2406+ * get_radio_name - Get physical radio name for the device
2407+ * @priv: Private driver interface data
2408+ * Returns: Radio name or %NULL if not known
2409+ *
2410+ * The returned data must not be modified by the caller. It is assumed
2411+ * that any interface that has the same radio name as another is
2412+ * sharing the same physical radio. This information can be used to
2413+ * share scan results etc. information between the virtual interfaces
2414+ * to speed up various operations.
2415+ */
2416+ const char * (*get_radio_name)(void *priv);
2417+
2418+ /**
2419+ * send_tdls_mgmt - for sending TDLS management packets
2420+ * @priv: private driver interface data
2421+ * @dst: Destination (peer) MAC address
2422+ * @action_code: TDLS action code for the mssage
2423+ * @dialog_token: Dialog Token to use in the message (if needed)
2424+ * @status_code: Status Code or Reason Code to use (if needed)
2425+ * @buf: TDLS IEs to add to the message
2426+ * @len: Length of buf in octets
2427+ * Returns: 0 on success, negative (<0) on failure
2428+ *
2429+ * This optional function can be used to send packet to driver which is
2430+ * responsible for receiving and sending all TDLS packets.
2431+ */
2432+ int (*send_tdls_mgmt)(void *priv, const u8 *dst, u8 action_code,
2433+ u8 dialog_token, u16 status_code,
2434+ const u8 *buf, size_t len);
2435+
2436+ /**
2437+ * tdls_oper - Ask the driver to perform high-level TDLS operations
2438+ * @priv: Private driver interface data
2439+ * @oper: TDLS high-level operation. See %enum tdls_oper
2440+ * @peer: Destination (peer) MAC address
2441+ * Returns: 0 on success, negative (<0) on failure
2442+ *
2443+ * This optional function can be used to send high-level TDLS commands
2444+ * to the driver.
2445+ */
2446+ int (*tdls_oper)(void *priv, enum tdls_oper oper, const u8 *peer);
2447+
2448+ /**
2449+ * wnm_oper - Notify driver of the WNM frame reception
2450+ * @priv: Private driver interface data
2451+ * @oper: WNM operation. See %enum wnm_oper
2452+ * @peer: Destination (peer) MAC address
2453+ * @buf: Buffer for the driver to fill in (for getting IE)
2454+ * @buf_len: Return the len of buf
2455+ * Returns: 0 on success, negative (<0) on failure
2456+ */
2457+ int (*wnm_oper)(void *priv, enum wnm_oper oper, const u8 *peer,
2458+ u8 *buf, u16 *buf_len);
2459+
2460+ /**
2461+ * set_qos_map - Set QoS Map
2462+ * @priv: Private driver interface data
2463+ * @qos_map_set: QoS Map
2464+ * @qos_map_set_len: Length of QoS Map
2465+ */
2466+ int (*set_qos_map)(void *priv, const u8 *qos_map_set,
2467+ u8 qos_map_set_len);
2468+
2469+ /**
2470+ * signal_poll - Get current connection information
2471+ * @priv: Private driver interface data
2472+ * @signal_info: Connection info structure
2473+ */
2474+ int (*signal_poll)(void *priv, struct wpa_signal_info *signal_info);
2475+
2476+ /**
2477+ * set_authmode - Set authentication algorithm(s) for static WEP
2478+ * @priv: Private driver interface data
2479+ * @authmode: 1=Open System, 2=Shared Key, 3=both
2480+ * Returns: 0 on success, -1 on failure
2481+ *
2482+ * This function can be used to set authentication algorithms for AP
2483+ * mode when static WEP is used. If the driver uses user space MLME/SME
2484+ * implementation, there is no need to implement this function.
2485+ *
2486+ * DEPRECATED - use set_ap() instead
2487+ */
2488+ int (*set_authmode)(void *priv, int authmode);
2489+
2490+#ifdef ANDROID
2491+ /**
2492+ * driver_cmd - Execute driver-specific command
2493+ * @priv: Private driver interface data
2494+ * @cmd: Command to execute
2495+ * @buf: Return buffer
2496+ * @buf_len: Buffer length
2497+ * Returns: 0 on success, -1 on failure
2498+ */
2499+ int (*driver_cmd)(void *priv, char *cmd, char *buf, size_t buf_len);
2500+#endif /* ANDROID */
2501+
2502+ /**
2503+ * set_rekey_info - Set rekey information
2504+ * @priv: Private driver interface data
2505+ * @kek: Current KEK
2506+ * @kck: Current KCK
2507+ * @replay_ctr: Current EAPOL-Key Replay Counter
2508+ *
2509+ * This optional function can be used to provide information for the
2510+ * driver/firmware to process EAPOL-Key frames in Group Key Handshake
2511+ * while the host (including wpa_supplicant) is sleeping.
2512+ */
2513+ void (*set_rekey_info)(void *priv, const u8 *kek, const u8 *kck,
2514+ const u8 *replay_ctr);
2515+
2516+ /**
2517+ * sta_assoc - Station association indication
2518+ * @priv: Private driver interface data
2519+ * @own_addr: Source address and BSSID for association frame
2520+ * @addr: MAC address of the station to associate
2521+ * @reassoc: flag to indicate re-association
2522+ * @status: association response status code
2523+ * @ie: assoc response ie buffer
2524+ * @len: ie buffer length
2525+ * Returns: 0 on success, -1 on failure
2526+ *
2527+ * This function indicates the driver to send (Re)Association
2528+ * Response frame to the station.
2529+ */
2530+ int (*sta_assoc)(void *priv, const u8 *own_addr, const u8 *addr,
2531+ int reassoc, u16 status, const u8 *ie, size_t len);
2532+
2533+ /**
2534+ * sta_auth - Station authentication indication
2535+ * @priv: Private driver interface data
2536+ * @own_addr: Source address and BSSID for authentication frame
2537+ * @addr: MAC address of the station to associate
2538+ * @seq: authentication sequence number
2539+ * @status: authentication response status code
2540+ * @ie: authentication frame ie buffer
2541+ * @len: ie buffer length
2542+ *
2543+ * This function indicates the driver to send Authentication frame
2544+ * to the station.
2545+ */
2546+ int (*sta_auth)(void *priv, const u8 *own_addr, const u8 *addr,
2547+ u16 seq, u16 status, const u8 *ie, size_t len);
2548+
2549+ /**
2550+ * add_tspec - Add traffic stream
2551+ * @priv: Private driver interface data
2552+ * @addr: MAC address of the station to associate
2553+ * @tspec_ie: tspec ie buffer
2554+ * @tspec_ielen: tspec ie length
2555+ * Returns: 0 on success, -1 on failure
2556+ *
2557+ * This function adds the traffic steam for the station
2558+ * and fills the medium_time in tspec_ie.
2559+ */
2560+ int (*add_tspec)(void *priv, const u8 *addr, u8 *tspec_ie,
2561+ size_t tspec_ielen);
2562+
2563+ /**
2564+ * add_sta_node - Add a station node in the driver
2565+ * @priv: Private driver interface data
2566+ * @addr: MAC address of the station to add
2567+ * @auth_alg: authentication algorithm used by the station
2568+ * Returns: 0 on success, -1 on failure
2569+ *
2570+ * This function adds the station node in the driver, when
2571+ * the station gets added by FT-over-DS.
2572+ */
2573+ int (*add_sta_node)(void *priv, const u8 *addr, u16 auth_alg);
2574+
2575+ /**
2576+ * sched_scan - Request the driver to initiate scheduled scan
2577+ * @priv: Private driver interface data
2578+ * @params: Scan parameters
2579+ * @interval: Interval between scan cycles in milliseconds
2580+ * Returns: 0 on success, -1 on failure
2581+ *
2582+ * This operation should be used for scheduled scan offload to
2583+ * the hardware. Every time scan results are available, the
2584+ * driver should report scan results event for wpa_supplicant
2585+ * which will eventually request the results with
2586+ * wpa_driver_get_scan_results2(). This operation is optional
2587+ * and if not provided or if it returns -1, we fall back to
2588+ * normal host-scheduled scans.
2589+ */
2590+ int (*sched_scan)(void *priv, struct wpa_driver_scan_params *params,
2591+ u32 interval);
2592+
2593+ /**
2594+ * stop_sched_scan - Request the driver to stop a scheduled scan
2595+ * @priv: Private driver interface data
2596+ * Returns: 0 on success, -1 on failure
2597+ *
2598+ * This should cause the scheduled scan to be stopped and
2599+ * results should stop being sent. Must be supported if
2600+ * sched_scan is supported.
2601+ */
2602+ int (*stop_sched_scan)(void *priv);
2603+
2604+ /**
2605+ * poll_client - Probe (null data or such) the given station
2606+ * @priv: Private driver interface data
2607+ * @own_addr: MAC address of sending interface
2608+ * @addr: MAC address of the station to probe
2609+ * @qos: Indicates whether station is QoS station
2610+ *
2611+ * This function is used to verify whether an associated station is
2612+ * still present. This function does not need to be implemented if the
2613+ * driver provides such inactivity polling mechanism.
2614+ */
2615+ void (*poll_client)(void *priv, const u8 *own_addr,
2616+ const u8 *addr, int qos);
2617+
2618+ /**
2619+ * radio_disable - Disable/enable radio
2620+ * @priv: Private driver interface data
2621+ * @disabled: 1=disable 0=enable radio
2622+ * Returns: 0 on success, -1 on failure
2623+ *
2624+ * This optional command is for testing purposes. It can be used to
2625+ * disable the radio on a testbed device to simulate out-of-radio-range
2626+ * conditions.
2627+ */
2628+ int (*radio_disable)(void *priv, int disabled);
2629+
2630+ /**
2631+ * switch_channel - Announce channel switch and migrate the GO to the
2632+ * given frequency
2633+ * @priv: Private driver interface data
2634+ * @settings: Settings for CSA period and new channel
2635+ * Returns: 0 on success, -1 on failure
2636+ *
2637+ * This function is used to move the GO to the legacy STA channel to
2638+ * avoid frequency conflict in single channel concurrency.
2639+ */
2640+ int (*switch_channel)(void *priv, struct csa_settings *settings);
2641+
2642+ /**
2643+ * start_dfs_cac - Listen for radar interference on the channel
2644+ * @priv: Private driver interface data
2645+ * @freq: Channel parameters
2646+ * Returns: 0 on success, -1 on failure
2647+ */
2648+ int (*start_dfs_cac)(void *priv, struct hostapd_freq_params *freq);
2649+
2650+ /**
2651+ * stop_ap - Removes beacon from AP
2652+ * @priv: Private driver interface data
2653+ * Returns: 0 on success, -1 on failure (or if not supported)
2654+ *
2655+ * This optional function can be used to disable AP mode related
2656+ * configuration. Unlike deinit_ap, it does not change to station
2657+ * mode.
2658+ */
2659+ int (*stop_ap)(void *priv);
2660+
2661+ /**
2662+ * get_survey - Retrieve survey data
2663+ * @priv: Private driver interface data
2664+ * @freq: If set, survey data for the specified frequency is only
2665+ * being requested. If not set, all survey data is requested.
2666+ * Returns: 0 on success, -1 on failure
2667+ *
2668+ * Use this to retrieve:
2669+ *
2670+ * - the observed channel noise floor
2671+ * - the amount of time we have spent on the channel
2672+ * - the amount of time during which we have spent on the channel that
2673+ * the radio has determined the medium is busy and we cannot
2674+ * transmit
2675+ * - the amount of time we have spent receiving data
2676+ * - the amount of time we have spent transmitting data
2677+ *
2678+ * This data can be used for spectrum heuristics. One example is
2679+ * Automatic Channel Selection (ACS). The channel survey data is
2680+ * kept on a linked list on the channel data, one entry is added
2681+ * for each survey. The min_nf of the channel is updated for each
2682+ * survey.
2683+ */
2684+ int (*get_survey)(void *priv, unsigned int freq);
2685+
2686+ /**
2687+ * status - Get driver interface status information
2688+ * @priv: Private driver interface data
2689+ * @buf: Buffer for printing tou the status information
2690+ * @buflen: Maximum length of the buffer
2691+ * Returns: Length of written status information or -1 on failure
2692+ */
2693+ int (*status)(void *priv, char *buf, size_t buflen);
2694+};
2695+
2696+
2697+/**
2698+ * enum wpa_event_type - Event type for wpa_supplicant_event() calls
2699+ */
2700+enum wpa_event_type {
2701+ /**
2702+ * EVENT_ASSOC - Association completed
2703+ *
2704+ * This event needs to be delivered when the driver completes IEEE
2705+ * 802.11 association or reassociation successfully.
2706+ * wpa_driver_ops::get_bssid() is expected to provide the current BSSID
2707+ * after this event has been generated. In addition, optional
2708+ * EVENT_ASSOCINFO may be generated just before EVENT_ASSOC to provide
2709+ * more information about the association. If the driver interface gets
2710+ * both of these events at the same time, it can also include the
2711+ * assoc_info data in EVENT_ASSOC call.
2712+ */
2713+ EVENT_ASSOC,
2714+
2715+ /**
2716+ * EVENT_DISASSOC - Association lost
2717+ *
2718+ * This event should be called when association is lost either due to
2719+ * receiving deauthenticate or disassociate frame from the AP or when
2720+ * sending either of these frames to the current AP. If the driver
2721+ * supports separate deauthentication event, EVENT_DISASSOC should only
2722+ * be used for disassociation and EVENT_DEAUTH for deauthentication.
2723+ * In AP mode, union wpa_event_data::disassoc_info is required.
2724+ */
2725+ EVENT_DISASSOC,
2726+
2727+ /**
2728+ * EVENT_MICHAEL_MIC_FAILURE - Michael MIC (TKIP) detected
2729+ *
2730+ * This event must be delivered when a Michael MIC error is detected by
2731+ * the local driver. Additional data for event processing is
2732+ * provided with union wpa_event_data::michael_mic_failure. This
2733+ * information is used to request new encyption key and to initiate
2734+ * TKIP countermeasures if needed.
2735+ */
2736+ EVENT_MICHAEL_MIC_FAILURE,
2737+
2738+ /**
2739+ * EVENT_SCAN_RESULTS - Scan results available
2740+ *
2741+ * This event must be called whenever scan results are available to be
2742+ * fetched with struct wpa_driver_ops::get_scan_results(). This event
2743+ * is expected to be used some time after struct wpa_driver_ops::scan()
2744+ * is called. If the driver provides an unsolicited event when the scan
2745+ * has been completed, this event can be used to trigger
2746+ * EVENT_SCAN_RESULTS call. If such event is not available from the
2747+ * driver, the driver wrapper code is expected to use a registered
2748+ * timeout to generate EVENT_SCAN_RESULTS call after the time that the
2749+ * scan is expected to be completed. Optional information about
2750+ * completed scan can be provided with union wpa_event_data::scan_info.
2751+ */
2752+ EVENT_SCAN_RESULTS,
2753+
2754+ /**
2755+ * EVENT_ASSOCINFO - Report optional extra information for association
2756+ *
2757+ * This event can be used to report extra association information for
2758+ * EVENT_ASSOC processing. This extra information includes IEs from
2759+ * association frames and Beacon/Probe Response frames in union
2760+ * wpa_event_data::assoc_info. EVENT_ASSOCINFO must be send just before
2761+ * EVENT_ASSOC. Alternatively, the driver interface can include
2762+ * assoc_info data in the EVENT_ASSOC call if it has all the
2763+ * information available at the same point.
2764+ */
2765+ EVENT_ASSOCINFO,
2766+
2767+ /**
2768+ * EVENT_INTERFACE_STATUS - Report interface status changes
2769+ *
2770+ * This optional event can be used to report changes in interface
2771+ * status (interface added/removed) using union
2772+ * wpa_event_data::interface_status. This can be used to trigger
2773+ * wpa_supplicant to stop and re-start processing for the interface,
2774+ * e.g., when a cardbus card is ejected/inserted.
2775+ */
2776+ EVENT_INTERFACE_STATUS,
2777+
2778+ /**
2779+ * EVENT_PMKID_CANDIDATE - Report a candidate AP for pre-authentication
2780+ *
2781+ * This event can be used to inform wpa_supplicant about candidates for
2782+ * RSN (WPA2) pre-authentication. If wpa_supplicant is not responsible
2783+ * for scan request (ap_scan=2 mode), this event is required for
2784+ * pre-authentication. If wpa_supplicant is performing scan request
2785+ * (ap_scan=1), this event is optional since scan results can be used
2786+ * to add pre-authentication candidates. union
2787+ * wpa_event_data::pmkid_candidate is used to report the BSSID of the
2788+ * candidate and priority of the candidate, e.g., based on the signal
2789+ * strength, in order to try to pre-authenticate first with candidates
2790+ * that are most likely targets for re-association.
2791+ *
2792+ * EVENT_PMKID_CANDIDATE can be called whenever the driver has updates
2793+ * on the candidate list. In addition, it can be called for the current
2794+ * AP and APs that have existing PMKSA cache entries. wpa_supplicant
2795+ * will automatically skip pre-authentication in cases where a valid
2796+ * PMKSA exists. When more than one candidate exists, this event should
2797+ * be generated once for each candidate.
2798+ *
2799+ * Driver will be notified about successful pre-authentication with
2800+ * struct wpa_driver_ops::add_pmkid() calls.
2801+ */
2802+ EVENT_PMKID_CANDIDATE,
2803+
2804+ /**
2805+ * EVENT_STKSTART - Request STK handshake (MLME-STKSTART.request)
2806+ *
2807+ * This event can be used to inform wpa_supplicant about desire to set
2808+ * up secure direct link connection between two stations as defined in
2809+ * IEEE 802.11e with a new PeerKey mechanism that replaced the original
2810+ * STAKey negotiation. The caller will need to set peer address for the
2811+ * event.
2812+ */
2813+ EVENT_STKSTART,
2814+
2815+ /**
2816+ * EVENT_TDLS - Request TDLS operation
2817+ *
2818+ * This event can be used to request a TDLS operation to be performed.
2819+ */
2820+ EVENT_TDLS,
2821+
2822+ /**
2823+ * EVENT_FT_RESPONSE - Report FT (IEEE 802.11r) response IEs
2824+ *
2825+ * The driver is expected to report the received FT IEs from
2826+ * FT authentication sequence from the AP. The FT IEs are included in
2827+ * the extra information in union wpa_event_data::ft_ies.
2828+ */
2829+ EVENT_FT_RESPONSE,
2830+
2831+ /**
2832+ * EVENT_IBSS_RSN_START - Request RSN authentication in IBSS
2833+ *
2834+ * The driver can use this event to inform wpa_supplicant about a STA
2835+ * in an IBSS with which protected frames could be exchanged. This
2836+ * event starts RSN authentication with the other STA to authenticate
2837+ * the STA and set up encryption keys with it.
2838+ */
2839+ EVENT_IBSS_RSN_START,
2840+
2841+ /**
2842+ * EVENT_AUTH - Authentication result
2843+ *
2844+ * This event should be called when authentication attempt has been
2845+ * completed. This is only used if the driver supports separate
2846+ * authentication step (struct wpa_driver_ops::authenticate).
2847+ * Information about authentication result is included in
2848+ * union wpa_event_data::auth.
2849+ */
2850+ EVENT_AUTH,
2851+
2852+ /**
2853+ * EVENT_DEAUTH - Authentication lost
2854+ *
2855+ * This event should be called when authentication is lost either due
2856+ * to receiving deauthenticate frame from the AP or when sending that
2857+ * frame to the current AP.
2858+ * In AP mode, union wpa_event_data::deauth_info is required.
2859+ */
2860+ EVENT_DEAUTH,
2861+
2862+ /**
2863+ * EVENT_ASSOC_REJECT - Association rejected
2864+ *
2865+ * This event should be called when (re)association attempt has been
2866+ * rejected by the AP. Information about the association response is
2867+ * included in union wpa_event_data::assoc_reject.
2868+ */
2869+ EVENT_ASSOC_REJECT,
2870+
2871+ /**
2872+ * EVENT_AUTH_TIMED_OUT - Authentication timed out
2873+ */
2874+ EVENT_AUTH_TIMED_OUT,
2875+
2876+ /**
2877+ * EVENT_ASSOC_TIMED_OUT - Association timed out
2878+ */
2879+ EVENT_ASSOC_TIMED_OUT,
2880+
2881+ /**
2882+ * EVENT_FT_RRB_RX - FT (IEEE 802.11r) RRB frame received
2883+ */
2884+ EVENT_FT_RRB_RX,
2885+
2886+ /**
2887+ * EVENT_WPS_BUTTON_PUSHED - Report hardware push button press for WPS
2888+ */
2889+ EVENT_WPS_BUTTON_PUSHED,
2890+
2891+ /**
2892+ * EVENT_TX_STATUS - Report TX status
2893+ */
2894+ EVENT_TX_STATUS,
2895+
2896+ /**
2897+ * EVENT_RX_FROM_UNKNOWN - Report RX from unknown STA
2898+ */
2899+ EVENT_RX_FROM_UNKNOWN,
2900+
2901+ /**
2902+ * EVENT_RX_MGMT - Report RX of a management frame
2903+ */
2904+ EVENT_RX_MGMT,
2905+
2906+ /**
2907+ * EVENT_REMAIN_ON_CHANNEL - Remain-on-channel duration started
2908+ *
2909+ * This event is used to indicate when the driver has started the
2910+ * requested remain-on-channel duration. Information about the
2911+ * operation is included in union wpa_event_data::remain_on_channel.
2912+ */
2913+ EVENT_REMAIN_ON_CHANNEL,
2914+
2915+ /**
2916+ * EVENT_CANCEL_REMAIN_ON_CHANNEL - Remain-on-channel timed out
2917+ *
2918+ * This event is used to indicate when the driver has completed
2919+ * remain-on-channel duration, i.e., may noot be available on the
2920+ * requested channel anymore. Information about the
2921+ * operation is included in union wpa_event_data::remain_on_channel.
2922+ */
2923+ EVENT_CANCEL_REMAIN_ON_CHANNEL,
2924+
2925+ /**
2926+ * EVENT_MLME_RX - Report reception of frame for MLME (test use only)
2927+ *
2928+ * This event is used only by driver_test.c and userspace MLME.
2929+ */
2930+ EVENT_MLME_RX,
2931+
2932+ /**
2933+ * EVENT_RX_PROBE_REQ - Indicate received Probe Request frame
2934+ *
2935+ * This event is used to indicate when a Probe Request frame has been
2936+ * received. Information about the received frame is included in
2937+ * union wpa_event_data::rx_probe_req. The driver is required to report
2938+ * these events only after successfully completed probe_req_report()
2939+ * commands to request the events (i.e., report parameter is non-zero)
2940+ * in station mode. In AP mode, Probe Request frames should always be
2941+ * reported.
2942+ */
2943+ EVENT_RX_PROBE_REQ,
2944+
2945+ /**
2946+ * EVENT_NEW_STA - New wired device noticed
2947+ *
2948+ * This event is used to indicate that a new device has been detected
2949+ * in a network that does not use association-like functionality (i.e.,
2950+ * mainly wired Ethernet). This can be used to start EAPOL
2951+ * authenticator when receiving a frame from a device. The address of
2952+ * the device is included in union wpa_event_data::new_sta.
2953+ */
2954+ EVENT_NEW_STA,
2955+
2956+ /**
2957+ * EVENT_EAPOL_RX - Report received EAPOL frame
2958+ *
2959+ * When in AP mode with hostapd, this event is required to be used to
2960+ * deliver the receive EAPOL frames from the driver. With
2961+ * %wpa_supplicant, this event is used only if the send_eapol() handler
2962+ * is used to override the use of l2_packet for EAPOL frame TX.
2963+ */
2964+ EVENT_EAPOL_RX,
2965+
2966+ /**
2967+ * EVENT_SIGNAL_CHANGE - Indicate change in signal strength
2968+ *
2969+ * This event is used to indicate changes in the signal strength
2970+ * observed in frames received from the current AP if signal strength
2971+ * monitoring has been enabled with signal_monitor().
2972+ */
2973+ EVENT_SIGNAL_CHANGE,
2974+
2975+ /**
2976+ * EVENT_INTERFACE_ENABLED - Notify that interface was enabled
2977+ *
2978+ * This event is used to indicate that the interface was enabled after
2979+ * having been previously disabled, e.g., due to rfkill.
2980+ */
2981+ EVENT_INTERFACE_ENABLED,
2982+
2983+ /**
2984+ * EVENT_INTERFACE_DISABLED - Notify that interface was disabled
2985+ *
2986+ * This event is used to indicate that the interface was disabled,
2987+ * e.g., due to rfkill.
2988+ */
2989+ EVENT_INTERFACE_DISABLED,
2990+
2991+ /**
2992+ * EVENT_CHANNEL_LIST_CHANGED - Channel list changed
2993+ *
2994+ * This event is used to indicate that the channel list has changed,
2995+ * e.g., because of a regulatory domain change triggered by scan
2996+ * results including an AP advertising a country code.
2997+ */
2998+ EVENT_CHANNEL_LIST_CHANGED,
2999+
3000+ /**
3001+ * EVENT_INTERFACE_UNAVAILABLE - Notify that interface is unavailable
3002+ *
3003+ * This event is used to indicate that the driver cannot maintain this
3004+ * interface in its operation mode anymore. The most likely use for
3005+ * this is to indicate that AP mode operation is not available due to
3006+ * operating channel would need to be changed to a DFS channel when
3007+ * the driver does not support radar detection and another virtual
3008+ * interfaces caused the operating channel to change. Other similar
3009+ * resource conflicts could also trigger this for station mode
3010+ * interfaces.
3011+ */
3012+ EVENT_INTERFACE_UNAVAILABLE,
3013+
3014+ /**
3015+ * EVENT_BEST_CHANNEL
3016+ *
3017+ * Driver generates this event whenever it detects a better channel
3018+ * (e.g., based on RSSI or channel use). This information can be used
3019+ * to improve channel selection for a new AP/P2P group.
3020+ */
3021+ EVENT_BEST_CHANNEL,
3022+
3023+ /**
3024+ * EVENT_UNPROT_DEAUTH - Unprotected Deauthentication frame received
3025+ *
3026+ * This event should be called when a Deauthentication frame is dropped
3027+ * due to it not being protected (MFP/IEEE 802.11w).
3028+ * union wpa_event_data::unprot_deauth is required to provide more
3029+ * details of the frame.
3030+ */
3031+ EVENT_UNPROT_DEAUTH,
3032+
3033+ /**
3034+ * EVENT_UNPROT_DISASSOC - Unprotected Disassociation frame received
3035+ *
3036+ * This event should be called when a Disassociation frame is dropped
3037+ * due to it not being protected (MFP/IEEE 802.11w).
3038+ * union wpa_event_data::unprot_disassoc is required to provide more
3039+ * details of the frame.
3040+ */
3041+ EVENT_UNPROT_DISASSOC,
3042+
3043+ /**
3044+ * EVENT_STATION_LOW_ACK
3045+ *
3046+ * Driver generates this event whenever it detected that a particular
3047+ * station was lost. Detection can be through massive transmission
3048+ * failures for example.
3049+ */
3050+ EVENT_STATION_LOW_ACK,
3051+
3052+ /**
3053+ * EVENT_IBSS_PEER_LOST - IBSS peer not reachable anymore
3054+ */
3055+ EVENT_IBSS_PEER_LOST,
3056+
3057+ /**
3058+ * EVENT_DRIVER_GTK_REKEY - Device/driver did GTK rekey
3059+ *
3060+ * This event carries the new replay counter to notify wpa_supplicant
3061+ * of the current EAPOL-Key Replay Counter in case the driver/firmware
3062+ * completed Group Key Handshake while the host (including
3063+ * wpa_supplicant was sleeping).
3064+ */
3065+ EVENT_DRIVER_GTK_REKEY,
3066+
3067+ /**
3068+ * EVENT_SCHED_SCAN_STOPPED - Scheduled scan was stopped
3069+ */
3070+ EVENT_SCHED_SCAN_STOPPED,
3071+
3072+ /**
3073+ * EVENT_DRIVER_CLIENT_POLL_OK - Station responded to poll
3074+ *
3075+ * This event indicates that the station responded to the poll
3076+ * initiated with @poll_client.
3077+ */
3078+ EVENT_DRIVER_CLIENT_POLL_OK,
3079+
3080+ /**
3081+ * EVENT_EAPOL_TX_STATUS - notify of EAPOL TX status
3082+ */
3083+ EVENT_EAPOL_TX_STATUS,
3084+
3085+ /**
3086+ * EVENT_CH_SWITCH - AP or GO decided to switch channels
3087+ *
3088+ * Described in wpa_event_data.ch_switch
3089+ * */
3090+ EVENT_CH_SWITCH,
3091+
3092+ /**
3093+ * EVENT_WNM - Request WNM operation
3094+ *
3095+ * This event can be used to request a WNM operation to be performed.
3096+ */
3097+ EVENT_WNM,
3098+
3099+ /**
3100+ * EVENT_CONNECT_FAILED_REASON - Connection failure reason in AP mode
3101+ *
3102+ * This event indicates that the driver reported a connection failure
3103+ * with the specified client (for example, max client reached, etc.) in
3104+ * AP mode.
3105+ */
3106+ EVENT_CONNECT_FAILED_REASON,
3107+
3108+ /**
3109+ * EVENT_RADAR_DETECTED - Notify of radar detection
3110+ *
3111+ * A radar has been detected on the supplied frequency, hostapd should
3112+ * react accordingly (e.g., change channel).
3113+ */
3114+ EVENT_DFS_RADAR_DETECTED,
3115+
3116+ /**
3117+ * EVENT_CAC_FINISHED - Notify that channel availability check has been completed
3118+ *
3119+ * After a successful CAC, the channel can be marked clear and used.
3120+ */
3121+ EVENT_DFS_CAC_FINISHED,
3122+
3123+ /**
3124+ * EVENT_CAC_ABORTED - Notify that channel availability check has been aborted
3125+ *
3126+ * The CAC was not successful, and the channel remains in the previous
3127+ * state. This may happen due to a radar beeing detected or other
3128+ * external influences.
3129+ */
3130+ EVENT_DFS_CAC_ABORTED,
3131+
3132+ /**
3133+ * EVENT_DFS_CAC_NOP_FINISHED - Notify that non-occupancy period is over
3134+ *
3135+ * The channel which was previously unavailable is now available again.
3136+ */
3137+ EVENT_DFS_NOP_FINISHED,
3138+
3139+ /**
3140+ * EVENT_SURVEY - Received survey data
3141+ *
3142+ * This event gets triggered when a driver query is issued for survey
3143+ * data and the requested data becomes available. The returned data is
3144+ * stored in struct survey_results. The results provide at most one
3145+ * survey entry for each frequency and at minimum will provide one
3146+ * survey entry for one frequency. The survey data can be os_malloc()'d
3147+ * and then os_free()'d, so the event callback must only copy data.
3148+ */
3149+ EVENT_SURVEY,
3150+
3151+ /**
3152+ * EVENT_SCAN_STARTED - Scan started
3153+ *
3154+ * This indicates that driver has started a scan operation either based
3155+ * on a request from wpa_supplicant/hostapd or from another application.
3156+ * EVENT_SCAN_RESULTS is used to indicate when the scan has been
3157+ * completed (either successfully or by getting cancelled).
3158+ */
3159+ EVENT_SCAN_STARTED,
3160+
3161+ /**
3162+ * EVENT_AVOID_FREQUENCIES - Received avoid frequency range
3163+ *
3164+ * This event indicates a set of frequency ranges that should be avoided
3165+ * to reduce issues due to interference or internal co-existence
3166+ * information in the driver.
3167+ */
3168+ EVENT_AVOID_FREQUENCIES
3169+};
3170+
3171+
3172+/**
3173+ * struct freq_survey - Channel survey info
3174+ *
3175+ * @ifidx: Interface index in which this survey was observed
3176+ * @freq: Center of frequency of the surveyed channel
3177+ * @nf: Channel noise floor in dBm
3178+ * @channel_time: Amount of time in ms the radio spent on the channel
3179+ * @channel_time_busy: Amount of time in ms the radio detected some signal
3180+ * that indicated to the radio the channel was not clear
3181+ * @channel_time_rx: Amount of time the radio spent receiving data
3182+ * @channel_time_tx: Amount of time the radio spent transmitting data
3183+ * @filled: bitmask indicating which fields have been reported, see
3184+ * SURVEY_HAS_* defines.
3185+ * @list: Internal list pointers
3186+ */
3187+struct freq_survey {
3188+ u32 ifidx;
3189+ unsigned int freq;
3190+ s8 nf;
3191+ u64 channel_time;
3192+ u64 channel_time_busy;
3193+ u64 channel_time_rx;
3194+ u64 channel_time_tx;
3195+ unsigned int filled;
3196+ struct dl_list list;
3197+};
3198+
3199+#define SURVEY_HAS_NF BIT(0)
3200+#define SURVEY_HAS_CHAN_TIME BIT(1)
3201+#define SURVEY_HAS_CHAN_TIME_BUSY BIT(2)
3202+#define SURVEY_HAS_CHAN_TIME_RX BIT(3)
3203+#define SURVEY_HAS_CHAN_TIME_TX BIT(4)
3204+
3205+
3206+/**
3207+ * union wpa_event_data - Additional data for wpa_supplicant_event() calls
3208+ */
3209+union wpa_event_data {
3210+ /**
3211+ * struct assoc_info - Data for EVENT_ASSOC and EVENT_ASSOCINFO events
3212+ *
3213+ * This structure is optional for EVENT_ASSOC calls and required for
3214+ * EVENT_ASSOCINFO calls. By using EVENT_ASSOC with this data, the
3215+ * driver interface does not need to generate separate EVENT_ASSOCINFO
3216+ * calls.
3217+ */
3218+ struct assoc_info {
3219+ /**
3220+ * reassoc - Flag to indicate association or reassociation
3221+ */
3222+ int reassoc;
3223+
3224+ /**
3225+ * req_ies - (Re)Association Request IEs
3226+ *
3227+ * If the driver generates WPA/RSN IE, this event data must be
3228+ * returned for WPA handshake to have needed information. If
3229+ * wpa_supplicant-generated WPA/RSN IE is used, this
3230+ * information event is optional.
3231+ *
3232+ * This should start with the first IE (fixed fields before IEs
3233+ * are not included).
3234+ */
3235+ const u8 *req_ies;
3236+
3237+ /**
3238+ * req_ies_len - Length of req_ies in bytes
3239+ */
3240+ size_t req_ies_len;
3241+
3242+ /**
3243+ * resp_ies - (Re)Association Response IEs
3244+ *
3245+ * Optional association data from the driver. This data is not
3246+ * required WPA, but may be useful for some protocols and as
3247+ * such, should be reported if this is available to the driver
3248+ * interface.
3249+ *
3250+ * This should start with the first IE (fixed fields before IEs
3251+ * are not included).
3252+ */
3253+ const u8 *resp_ies;
3254+
3255+ /**
3256+ * resp_ies_len - Length of resp_ies in bytes
3257+ */
3258+ size_t resp_ies_len;
3259+
3260+ /**
3261+ * beacon_ies - Beacon or Probe Response IEs
3262+ *
3263+ * Optional Beacon/ProbeResp data: IEs included in Beacon or
3264+ * Probe Response frames from the current AP (i.e., the one
3265+ * that the client just associated with). This information is
3266+ * used to update WPA/RSN IE for the AP. If this field is not
3267+ * set, the results from previous scan will be used. If no
3268+ * data for the new AP is found, scan results will be requested
3269+ * again (without scan request). At this point, the driver is
3270+ * expected to provide WPA/RSN IE for the AP (if WPA/WPA2 is
3271+ * used).
3272+ *
3273+ * This should start with the first IE (fixed fields before IEs
3274+ * are not included).
3275+ */
3276+ const u8 *beacon_ies;
3277+
3278+ /**
3279+ * beacon_ies_len - Length of beacon_ies */
3280+ size_t beacon_ies_len;
3281+
3282+ /**
3283+ * freq - Frequency of the operational channel in MHz
3284+ */
3285+ unsigned int freq;
3286+
3287+ /**
3288+ * addr - Station address (for AP mode)
3289+ */
3290+ const u8 *addr;
3291+ } assoc_info;
3292+
3293+ /**
3294+ * struct disassoc_info - Data for EVENT_DISASSOC events
3295+ */
3296+ struct disassoc_info {
3297+ /**
3298+ * addr - Station address (for AP mode)
3299+ */
3300+ const u8 *addr;
3301+
3302+ /**
3303+ * reason_code - Reason Code (host byte order) used in
3304+ * Deauthentication frame
3305+ */
3306+ u16 reason_code;
3307+
3308+ /**
3309+ * ie - Optional IE(s) in Disassociation frame
3310+ */
3311+ const u8 *ie;
3312+
3313+ /**
3314+ * ie_len - Length of ie buffer in octets
3315+ */
3316+ size_t ie_len;
3317+
3318+ /**
3319+ * locally_generated - Whether the frame was locally generated
3320+ */
3321+ int locally_generated;
3322+ } disassoc_info;
3323+
3324+ /**
3325+ * struct deauth_info - Data for EVENT_DEAUTH events
3326+ */
3327+ struct deauth_info {
3328+ /**
3329+ * addr - Station address (for AP mode)
3330+ */
3331+ const u8 *addr;
3332+
3333+ /**
3334+ * reason_code - Reason Code (host byte order) used in
3335+ * Deauthentication frame
3336+ */
3337+ u16 reason_code;
3338+
3339+ /**
3340+ * ie - Optional IE(s) in Deauthentication frame
3341+ */
3342+ const u8 *ie;
3343+
3344+ /**
3345+ * ie_len - Length of ie buffer in octets
3346+ */
3347+ size_t ie_len;
3348+
3349+ /**
3350+ * locally_generated - Whether the frame was locally generated
3351+ */
3352+ int locally_generated;
3353+ } deauth_info;
3354+
3355+ /**
3356+ * struct michael_mic_failure - Data for EVENT_MICHAEL_MIC_FAILURE
3357+ */
3358+ struct michael_mic_failure {
3359+ int unicast;
3360+ const u8 *src;
3361+ } michael_mic_failure;
3362+
3363+ /**
3364+ * struct interface_status - Data for EVENT_INTERFACE_STATUS
3365+ */
3366+ struct interface_status {
3367+ char ifname[100];
3368+ enum {
3369+ EVENT_INTERFACE_ADDED, EVENT_INTERFACE_REMOVED
3370+ } ievent;
3371+ } interface_status;
3372+
3373+ /**
3374+ * struct pmkid_candidate - Data for EVENT_PMKID_CANDIDATE
3375+ */
3376+ struct pmkid_candidate {
3377+ /** BSSID of the PMKID candidate */
3378+ u8 bssid[ETH_ALEN];
3379+ /** Smaller the index, higher the priority */
3380+ int index;
3381+ /** Whether RSN IE includes pre-authenticate flag */
3382+ int preauth;
3383+ } pmkid_candidate;
3384+
3385+ /**
3386+ * struct stkstart - Data for EVENT_STKSTART
3387+ */
3388+ struct stkstart {
3389+ u8 peer[ETH_ALEN];
3390+ } stkstart;
3391+
3392+ /**
3393+ * struct tdls - Data for EVENT_TDLS
3394+ */
3395+ struct tdls {
3396+ u8 peer[ETH_ALEN];
3397+ enum {
3398+ TDLS_REQUEST_SETUP,
3399+ TDLS_REQUEST_TEARDOWN
3400+ } oper;
3401+ u16 reason_code; /* for teardown */
3402+ } tdls;
3403+
3404+ /**
3405+ * struct wnm - Data for EVENT_WNM
3406+ */
3407+ struct wnm {
3408+ u8 addr[ETH_ALEN];
3409+ enum {
3410+ WNM_OPER_SLEEP,
3411+ } oper;
3412+ enum {
3413+ WNM_SLEEP_ENTER,
3414+ WNM_SLEEP_EXIT
3415+ } sleep_action;
3416+ int sleep_intval;
3417+ u16 reason_code;
3418+ u8 *buf;
3419+ u16 buf_len;
3420+ } wnm;
3421+
3422+ /**
3423+ * struct ft_ies - FT information elements (EVENT_FT_RESPONSE)
3424+ *
3425+ * During FT (IEEE 802.11r) authentication sequence, the driver is
3426+ * expected to use this event to report received FT IEs (MDIE, FTIE,
3427+ * RSN IE, TIE, possible resource request) to the supplicant. The FT
3428+ * IEs for the next message will be delivered through the
3429+ * struct wpa_driver_ops::update_ft_ies() callback.
3430+ */
3431+ struct ft_ies {
3432+ const u8 *ies;
3433+ size_t ies_len;
3434+ int ft_action;
3435+ u8 target_ap[ETH_ALEN];
3436+ /** Optional IE(s), e.g., WMM TSPEC(s), for RIC-Request */
3437+ const u8 *ric_ies;
3438+ /** Length of ric_ies buffer in octets */
3439+ size_t ric_ies_len;
3440+ } ft_ies;
3441+
3442+ /**
3443+ * struct ibss_rsn_start - Data for EVENT_IBSS_RSN_START
3444+ */
3445+ struct ibss_rsn_start {
3446+ u8 peer[ETH_ALEN];
3447+ } ibss_rsn_start;
3448+
3449+ /**
3450+ * struct auth_info - Data for EVENT_AUTH events
3451+ */
3452+ struct auth_info {
3453+ u8 peer[ETH_ALEN];
3454+ u8 bssid[ETH_ALEN];
3455+ u16 auth_type;
3456+ u16 auth_transaction;
3457+ u16 status_code;
3458+ const u8 *ies;
3459+ size_t ies_len;
3460+ } auth;
3461+
3462+ /**
3463+ * struct assoc_reject - Data for EVENT_ASSOC_REJECT events
3464+ */
3465+ struct assoc_reject {
3466+ /**
3467+ * bssid - BSSID of the AP that rejected association
3468+ */
3469+ const u8 *bssid;
3470+
3471+ /**
3472+ * resp_ies - (Re)Association Response IEs
3473+ *
3474+ * Optional association data from the driver. This data is not
3475+ * required WPA, but may be useful for some protocols and as
3476+ * such, should be reported if this is available to the driver
3477+ * interface.
3478+ *
3479+ * This should start with the first IE (fixed fields before IEs
3480+ * are not included).
3481+ */
3482+ const u8 *resp_ies;
3483+
3484+ /**
3485+ * resp_ies_len - Length of resp_ies in bytes
3486+ */
3487+ size_t resp_ies_len;
3488+
3489+ /**
3490+ * status_code - Status Code from (Re)association Response
3491+ */
3492+ u16 status_code;
3493+ } assoc_reject;
3494+
3495+ struct timeout_event {
3496+ u8 addr[ETH_ALEN];
3497+ } timeout_event;
3498+
3499+ /**
3500+ * struct ft_rrb_rx - Data for EVENT_FT_RRB_RX events
3501+ */
3502+ struct ft_rrb_rx {
3503+ const u8 *src;
3504+ const u8 *data;
3505+ size_t data_len;
3506+ } ft_rrb_rx;
3507+
3508+ /**
3509+ * struct tx_status - Data for EVENT_TX_STATUS events
3510+ */
3511+ struct tx_status {
3512+ u16 type;
3513+ u16 stype;
3514+ const u8 *dst;
3515+ const u8 *data;
3516+ size_t data_len;
3517+ int ack;
3518+ } tx_status;
3519+
3520+ /**
3521+ * struct rx_from_unknown - Data for EVENT_RX_FROM_UNKNOWN events
3522+ */
3523+ struct rx_from_unknown {
3524+ const u8 *bssid;
3525+ const u8 *addr;
3526+ int wds;
3527+ } rx_from_unknown;
3528+
3529+ /**
3530+ * struct rx_mgmt - Data for EVENT_RX_MGMT events
3531+ */
3532+ struct rx_mgmt {
3533+ const u8 *frame;
3534+ size_t frame_len;
3535+ u32 datarate;
3536+
3537+ /**
3538+ * freq - Frequency (in MHz) on which the frame was received
3539+ */
3540+ int freq;
3541+
3542+ /**
3543+ * ssi_signal - Signal strength in dBm (or 0 if not available)
3544+ */
3545+ int ssi_signal;
3546+ } rx_mgmt;
3547+
3548+ /**
3549+ * struct remain_on_channel - Data for EVENT_REMAIN_ON_CHANNEL events
3550+ *
3551+ * This is also used with EVENT_CANCEL_REMAIN_ON_CHANNEL events.
3552+ */
3553+ struct remain_on_channel {
3554+ /**
3555+ * freq - Channel frequency in MHz
3556+ */
3557+ unsigned int freq;
3558+
3559+ /**
3560+ * duration - Duration to remain on the channel in milliseconds
3561+ */
3562+ unsigned int duration;
3563+ } remain_on_channel;
3564+
3565+ /**
3566+ * struct scan_info - Optional data for EVENT_SCAN_RESULTS events
3567+ * @aborted: Whether the scan was aborted
3568+ * @freqs: Scanned frequencies in MHz (%NULL = all channels scanned)
3569+ * @num_freqs: Number of entries in freqs array
3570+ * @ssids: Scanned SSIDs (%NULL or zero-length SSID indicates wildcard
3571+ * SSID)
3572+ * @num_ssids: Number of entries in ssids array
3573+ */
3574+ struct scan_info {
3575+ int aborted;
3576+ const int *freqs;
3577+ size_t num_freqs;
3578+ struct wpa_driver_scan_ssid ssids[WPAS_MAX_SCAN_SSIDS];
3579+ size_t num_ssids;
3580+ } scan_info;
3581+
3582+ /**
3583+ * struct mlme_rx - Data for EVENT_MLME_RX events
3584+ */
3585+ struct mlme_rx {
3586+ const u8 *buf;
3587+ size_t len;
3588+ int freq;
3589+ int channel;
3590+ int ssi;
3591+ } mlme_rx;
3592+
3593+ /**
3594+ * struct rx_probe_req - Data for EVENT_RX_PROBE_REQ events
3595+ */
3596+ struct rx_probe_req {
3597+ /**
3598+ * sa - Source address of the received Probe Request frame
3599+ */
3600+ const u8 *sa;
3601+
3602+ /**
3603+ * da - Destination address of the received Probe Request frame
3604+ * or %NULL if not available
3605+ */
3606+ const u8 *da;
3607+
3608+ /**
3609+ * bssid - BSSID of the received Probe Request frame or %NULL
3610+ * if not available
3611+ */
3612+ const u8 *bssid;
3613+
3614+ /**
3615+ * ie - IEs from the Probe Request body
3616+ */
3617+ const u8 *ie;
3618+
3619+ /**
3620+ * ie_len - Length of ie buffer in octets
3621+ */
3622+ size_t ie_len;
3623+
3624+ /**
3625+ * signal - signal strength in dBm (or 0 if not available)
3626+ */
3627+ int ssi_signal;
3628+ } rx_probe_req;
3629+
3630+ /**
3631+ * struct new_sta - Data for EVENT_NEW_STA events
3632+ */
3633+ struct new_sta {
3634+ const u8 *addr;
3635+ } new_sta;
3636+
3637+ /**
3638+ * struct eapol_rx - Data for EVENT_EAPOL_RX events
3639+ */
3640+ struct eapol_rx {
3641+ const u8 *src;
3642+ const u8 *data;
3643+ size_t data_len;
3644+ } eapol_rx;
3645+
3646+ /**
3647+ * signal_change - Data for EVENT_SIGNAL_CHANGE events
3648+ */
3649+ struct wpa_signal_info signal_change;
3650+
3651+ /**
3652+ * struct best_channel - Data for EVENT_BEST_CHANNEL events
3653+ * @freq_24: Best 2.4 GHz band channel frequency in MHz
3654+ * @freq_5: Best 5 GHz band channel frequency in MHz
3655+ * @freq_overall: Best channel frequency in MHz
3656+ *
3657+ * 0 can be used to indicate no preference in either band.
3658+ */
3659+ struct best_channel {
3660+ int freq_24;
3661+ int freq_5;
3662+ int freq_overall;
3663+ } best_chan;
3664+
3665+ struct unprot_deauth {
3666+ const u8 *sa;
3667+ const u8 *da;
3668+ u16 reason_code;
3669+ } unprot_deauth;
3670+
3671+ struct unprot_disassoc {
3672+ const u8 *sa;
3673+ const u8 *da;
3674+ u16 reason_code;
3675+ } unprot_disassoc;
3676+
3677+ /**
3678+ * struct low_ack - Data for EVENT_STATION_LOW_ACK events
3679+ * @addr: station address
3680+ */
3681+ struct low_ack {
3682+ u8 addr[ETH_ALEN];
3683+ } low_ack;
3684+
3685+ /**
3686+ * struct ibss_peer_lost - Data for EVENT_IBSS_PEER_LOST
3687+ */
3688+ struct ibss_peer_lost {
3689+ u8 peer[ETH_ALEN];
3690+ } ibss_peer_lost;
3691+
3692+ /**
3693+ * struct driver_gtk_rekey - Data for EVENT_DRIVER_GTK_REKEY
3694+ */
3695+ struct driver_gtk_rekey {
3696+ const u8 *bssid;
3697+ const u8 *replay_ctr;
3698+ } driver_gtk_rekey;
3699+
3700+ /**
3701+ * struct client_poll - Data for EVENT_DRIVER_CLIENT_POLL_OK events
3702+ * @addr: station address
3703+ */
3704+ struct client_poll {
3705+ u8 addr[ETH_ALEN];
3706+ } client_poll;
3707+
3708+ /**
3709+ * struct eapol_tx_status
3710+ * @dst: Original destination
3711+ * @data: Data starting with IEEE 802.1X header (!)
3712+ * @data_len: Length of data
3713+ * @ack: Indicates ack or lost frame
3714+ *
3715+ * This corresponds to hapd_send_eapol if the frame sent
3716+ * there isn't just reported as EVENT_TX_STATUS.
3717+ */
3718+ struct eapol_tx_status {
3719+ const u8 *dst;
3720+ const u8 *data;
3721+ int data_len;
3722+ int ack;
3723+ } eapol_tx_status;
3724+
3725+ /**
3726+ * struct ch_switch
3727+ * @freq: Frequency of new channel in MHz
3728+ * @ht_enabled: Whether this is an HT channel
3729+ * @ch_offset: Secondary channel offset
3730+ * @ch_width: Channel width
3731+ * @cf1: Center frequency 1
3732+ * @cf2: Center frequency 2
3733+ */
3734+ struct ch_switch {
3735+ int freq;
3736+ int ht_enabled;
3737+ int ch_offset;
3738+ enum chan_width ch_width;
3739+ int cf1;
3740+ int cf2;
3741+ } ch_switch;
3742+
3743+ /**
3744+ * struct connect_failed - Data for EVENT_CONNECT_FAILED_REASON
3745+ * @addr: Remote client address
3746+ * @code: Reason code for connection failure
3747+ */
3748+ struct connect_failed_reason {
3749+ u8 addr[ETH_ALEN];
3750+ enum {
3751+ MAX_CLIENT_REACHED,
3752+ BLOCKED_CLIENT
3753+ } code;
3754+ } connect_failed_reason;
3755+
3756+ /**
3757+ * struct dfs_event - Data for radar detected events
3758+ * @freq: Frequency of the channel in MHz
3759+ */
3760+ struct dfs_event {
3761+ int freq;
3762+ int ht_enabled;
3763+ int chan_offset;
3764+ enum chan_width chan_width;
3765+ int cf1;
3766+ int cf2;
3767+ } dfs_event;
3768+
3769+ /**
3770+ * survey_results - Survey result data for EVENT_SURVEY
3771+ * @freq_filter: Requested frequency survey filter, 0 if request
3772+ * was for all survey data
3773+ * @survey_list: Linked list of survey data
3774+ */
3775+ struct survey_results {
3776+ unsigned int freq_filter;
3777+ struct dl_list survey_list; /* struct freq_survey */
3778+ } survey_results;
3779+
3780+ /**
3781+ * channel_list_changed - Data for EVENT_CHANNEL_LIST_CHANGED
3782+ * @initiator: Initiator of the regulatory change
3783+ */
3784+ struct channel_list_changed {
3785+ enum reg_change_initiator initiator;
3786+ } channel_list_changed;
3787+
3788+ /**
3789+ * freq_range - List of frequency ranges
3790+ *
3791+ * This is used as the data with EVENT_AVOID_FREQUENCIES.
3792+ */
3793+ struct wpa_freq_range_list freq_range;
3794+};
3795+
3796+/**
3797+ * wpa_supplicant_event - Report a driver event for wpa_supplicant
3798+ * @ctx: Context pointer (wpa_s); this is the ctx variable registered
3799+ * with struct wpa_driver_ops::init()
3800+ * @event: event type (defined above)
3801+ * @data: possible extra data for the event
3802+ *
3803+ * Driver wrapper code should call this function whenever an event is received
3804+ * from the driver.
3805+ */
3806+void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
3807+ union wpa_event_data *data);
3808+
3809+
3810+/*
3811+ * The following inline functions are provided for convenience to simplify
3812+ * event indication for some of the common events.
3813+ */
3814+
3815+static inline void drv_event_assoc(void *ctx, const u8 *addr, const u8 *ie,
3816+ size_t ielen, int reassoc)
3817+{
3818+ union wpa_event_data event;
3819+ os_memset(&event, 0, sizeof(event));
3820+ event.assoc_info.reassoc = reassoc;
3821+ event.assoc_info.req_ies = ie;
3822+ event.assoc_info.req_ies_len = ielen;
3823+ event.assoc_info.addr = addr;
3824+ wpa_supplicant_event(ctx, EVENT_ASSOC, &event);
3825+}
3826+
3827+static inline void drv_event_disassoc(void *ctx, const u8 *addr)
3828+{
3829+ union wpa_event_data event;
3830+ os_memset(&event, 0, sizeof(event));
3831+ event.disassoc_info.addr = addr;
3832+ wpa_supplicant_event(ctx, EVENT_DISASSOC, &event);
3833+}
3834+
3835+static inline void drv_event_eapol_rx(void *ctx, const u8 *src, const u8 *data,
3836+ size_t data_len)
3837+{
3838+ union wpa_event_data event;
3839+ os_memset(&event, 0, sizeof(event));
3840+ event.eapol_rx.src = src;
3841+ event.eapol_rx.data = data;
3842+ event.eapol_rx.data_len = data_len;
3843+ wpa_supplicant_event(ctx, EVENT_EAPOL_RX, &event);
3844+}
3845+
3846+/* driver_common.c */
3847+void wpa_scan_results_free(struct wpa_scan_results *res);
3848+
3849+/* Convert wpa_event_type to a string for logging */
3850+const char * event_to_string(enum wpa_event_type event);
3851+
3852+/* NULL terminated array of linked in driver wrappers */
3853+extern struct wpa_driver_ops *wpa_drivers[];
3854+
3855+#endif /* DRIVER_H */
3856
3857=== added file '.pc/add-wowlan-configuration-support.patch/src/drivers/driver_nl80211.c'
3858--- .pc/add-wowlan-configuration-support.patch/src/drivers/driver_nl80211.c 1970-01-01 00:00:00 +0000
3859+++ .pc/add-wowlan-configuration-support.patch/src/drivers/driver_nl80211.c 2015-07-08 14:42:11 +0000
3860@@ -0,0 +1,11773 @@
3861+/*
3862+ * Driver interaction with Linux nl80211/cfg80211
3863+ * Copyright (c) 2002-2014, Jouni Malinen <j@w1.fi>
3864+ * Copyright (c) 2003-2004, Instant802 Networks, Inc.
3865+ * Copyright (c) 2005-2006, Devicescape Software, Inc.
3866+ * Copyright (c) 2007, Johannes Berg <johannes@sipsolutions.net>
3867+ * Copyright (c) 2009-2010, Atheros Communications
3868+ *
3869+ * This software may be distributed under the terms of the BSD license.
3870+ * See README for more details.
3871+ */
3872+
3873+#include "includes.h"
3874+#include <sys/ioctl.h>
3875+#include <sys/types.h>
3876+#include <sys/stat.h>
3877+#include <fcntl.h>
3878+#include <net/if.h>
3879+#include <netlink/genl/genl.h>
3880+#include <netlink/genl/family.h>
3881+#include <netlink/genl/ctrl.h>
3882+#include <linux/rtnetlink.h>
3883+#include <netpacket/packet.h>
3884+#include <linux/filter.h>
3885+#include <linux/errqueue.h>
3886+#include "nl80211_copy.h"
3887+
3888+#include "common.h"
3889+#include "eloop.h"
3890+#include "utils/list.h"
3891+#include "common/qca-vendor.h"
3892+#include "common/ieee802_11_defs.h"
3893+#include "common/ieee802_11_common.h"
3894+#include "l2_packet/l2_packet.h"
3895+#include "netlink.h"
3896+#include "linux_ioctl.h"
3897+#include "radiotap.h"
3898+#include "radiotap_iter.h"
3899+#include "rfkill.h"
3900+#include "driver.h"
3901+
3902+#ifndef SO_WIFI_STATUS
3903+# if defined(__sparc__)
3904+# define SO_WIFI_STATUS 0x0025
3905+# elif defined(__parisc__)
3906+# define SO_WIFI_STATUS 0x4022
3907+# else
3908+# define SO_WIFI_STATUS 41
3909+# endif
3910+
3911+# define SCM_WIFI_STATUS SO_WIFI_STATUS
3912+#endif
3913+
3914+#ifndef SO_EE_ORIGIN_TXSTATUS
3915+#define SO_EE_ORIGIN_TXSTATUS 4
3916+#endif
3917+
3918+#ifndef PACKET_TX_TIMESTAMP
3919+#define PACKET_TX_TIMESTAMP 16
3920+#endif
3921+
3922+#ifdef ANDROID
3923+#include "android_drv.h"
3924+#endif /* ANDROID */
3925+#ifdef CONFIG_LIBNL20
3926+/* libnl 2.0 compatibility code */
3927+#define nl_handle nl_sock
3928+#define nl80211_handle_alloc nl_socket_alloc_cb
3929+#define nl80211_handle_destroy nl_socket_free
3930+#else
3931+/*
3932+ * libnl 1.1 has a bug, it tries to allocate socket numbers densely
3933+ * but when you free a socket again it will mess up its bitmap and
3934+ * and use the wrong number the next time it needs a socket ID.
3935+ * Therefore, we wrap the handle alloc/destroy and add our own pid
3936+ * accounting.
3937+ */
3938+static uint32_t port_bitmap[32] = { 0 };
3939+
3940+static struct nl_handle *nl80211_handle_alloc(void *cb)
3941+{
3942+ struct nl_handle *handle;
3943+ uint32_t pid = getpid() & 0x3FFFFF;
3944+ int i;
3945+
3946+ handle = nl_handle_alloc_cb(cb);
3947+
3948+ for (i = 0; i < 1024; i++) {
3949+ if (port_bitmap[i / 32] & (1 << (i % 32)))
3950+ continue;
3951+ port_bitmap[i / 32] |= 1 << (i % 32);
3952+ pid += i << 22;
3953+ break;
3954+ }
3955+
3956+ nl_socket_set_local_port(handle, pid);
3957+
3958+ return handle;
3959+}
3960+
3961+static void nl80211_handle_destroy(struct nl_handle *handle)
3962+{
3963+ uint32_t port = nl_socket_get_local_port(handle);
3964+
3965+ port >>= 22;
3966+ port_bitmap[port / 32] &= ~(1 << (port % 32));
3967+
3968+ nl_handle_destroy(handle);
3969+}
3970+#endif /* CONFIG_LIBNL20 */
3971+
3972+
3973+#ifdef ANDROID
3974+/* system/core/libnl_2 does not include nl_socket_set_nonblocking() */
3975+static int android_nl_socket_set_nonblocking(struct nl_handle *handle)
3976+{
3977+ return fcntl(nl_socket_get_fd(handle), F_SETFL, O_NONBLOCK);
3978+}
3979+#undef nl_socket_set_nonblocking
3980+#define nl_socket_set_nonblocking(h) android_nl_socket_set_nonblocking(h)
3981+#endif /* ANDROID */
3982+
3983+
3984+static struct nl_handle * nl_create_handle(struct nl_cb *cb, const char *dbg)
3985+{
3986+ struct nl_handle *handle;
3987+
3988+ handle = nl80211_handle_alloc(cb);
3989+ if (handle == NULL) {
3990+ wpa_printf(MSG_ERROR, "nl80211: Failed to allocate netlink "
3991+ "callbacks (%s)", dbg);
3992+ return NULL;
3993+ }
3994+
3995+ if (genl_connect(handle)) {
3996+ wpa_printf(MSG_ERROR, "nl80211: Failed to connect to generic "
3997+ "netlink (%s)", dbg);
3998+ nl80211_handle_destroy(handle);
3999+ return NULL;
4000+ }
4001+
4002+ return handle;
4003+}
4004+
4005+
4006+static void nl_destroy_handles(struct nl_handle **handle)
4007+{
4008+ if (*handle == NULL)
4009+ return;
4010+ nl80211_handle_destroy(*handle);
4011+ *handle = NULL;
4012+}
4013+
4014+
4015+#if __WORDSIZE == 64
4016+#define ELOOP_SOCKET_INVALID (intptr_t) 0x8888888888888889ULL
4017+#else
4018+#define ELOOP_SOCKET_INVALID (intptr_t) 0x88888889ULL
4019+#endif
4020+
4021+static void nl80211_register_eloop_read(struct nl_handle **handle,
4022+ eloop_sock_handler handler,
4023+ void *eloop_data)
4024+{
4025+ nl_socket_set_nonblocking(*handle);
4026+ eloop_register_read_sock(nl_socket_get_fd(*handle), handler,
4027+ eloop_data, *handle);
4028+ *handle = (void *) (((intptr_t) *handle) ^ ELOOP_SOCKET_INVALID);
4029+}
4030+
4031+
4032+static void nl80211_destroy_eloop_handle(struct nl_handle **handle)
4033+{
4034+ *handle = (void *) (((intptr_t) *handle) ^ ELOOP_SOCKET_INVALID);
4035+ eloop_unregister_read_sock(nl_socket_get_fd(*handle));
4036+ nl_destroy_handles(handle);
4037+}
4038+
4039+
4040+#ifndef IFF_LOWER_UP
4041+#define IFF_LOWER_UP 0x10000 /* driver signals L1 up */
4042+#endif
4043+#ifndef IFF_DORMANT
4044+#define IFF_DORMANT 0x20000 /* driver signals dormant */
4045+#endif
4046+
4047+#ifndef IF_OPER_DORMANT
4048+#define IF_OPER_DORMANT 5
4049+#endif
4050+#ifndef IF_OPER_UP
4051+#define IF_OPER_UP 6
4052+#endif
4053+
4054+struct nl80211_global {
4055+ struct dl_list interfaces;
4056+ int if_add_ifindex;
4057+ u64 if_add_wdevid;
4058+ int if_add_wdevid_set;
4059+ struct netlink_data *netlink;
4060+ struct nl_cb *nl_cb;
4061+ struct nl_handle *nl;
4062+ int nl80211_id;
4063+ int ioctl_sock; /* socket for ioctl() use */
4064+
4065+ struct nl_handle *nl_event;
4066+};
4067+
4068+struct nl80211_wiphy_data {
4069+ struct dl_list list;
4070+ struct dl_list bsss;
4071+ struct dl_list drvs;
4072+
4073+ struct nl_handle *nl_beacons;
4074+ struct nl_cb *nl_cb;
4075+
4076+ int wiphy_idx;
4077+};
4078+
4079+static void nl80211_global_deinit(void *priv);
4080+
4081+struct i802_bss {
4082+ struct wpa_driver_nl80211_data *drv;
4083+ struct i802_bss *next;
4084+ int ifindex;
4085+ u64 wdev_id;
4086+ char ifname[IFNAMSIZ + 1];
4087+ char brname[IFNAMSIZ];
4088+ unsigned int beacon_set:1;
4089+ unsigned int added_if_into_bridge:1;
4090+ unsigned int added_bridge:1;
4091+ unsigned int in_deinit:1;
4092+ unsigned int wdev_id_set:1;
4093+ unsigned int added_if:1;
4094+
4095+ u8 addr[ETH_ALEN];
4096+
4097+ int freq;
4098+ int if_dynamic;
4099+
4100+ void *ctx;
4101+ struct nl_handle *nl_preq, *nl_mgmt;
4102+ struct nl_cb *nl_cb;
4103+
4104+ struct nl80211_wiphy_data *wiphy_data;
4105+ struct dl_list wiphy_list;
4106+};
4107+
4108+struct wpa_driver_nl80211_data {
4109+ struct nl80211_global *global;
4110+ struct dl_list list;
4111+ struct dl_list wiphy_list;
4112+ char phyname[32];
4113+ void *ctx;
4114+ int ifindex;
4115+ int if_removed;
4116+ int if_disabled;
4117+ int ignore_if_down_event;
4118+ struct rfkill_data *rfkill;
4119+ struct wpa_driver_capa capa;
4120+ u8 *extended_capa, *extended_capa_mask;
4121+ unsigned int extended_capa_len;
4122+ int has_capability;
4123+
4124+ int operstate;
4125+
4126+ int scan_complete_events;
4127+ enum scan_states {
4128+ NO_SCAN, SCAN_REQUESTED, SCAN_STARTED, SCAN_COMPLETED,
4129+ SCAN_ABORTED, SCHED_SCAN_STARTED, SCHED_SCAN_STOPPED,
4130+ SCHED_SCAN_RESULTS
4131+ } scan_state;
4132+
4133+ struct nl_cb *nl_cb;
4134+
4135+ u8 auth_bssid[ETH_ALEN];
4136+ u8 auth_attempt_bssid[ETH_ALEN];
4137+ u8 bssid[ETH_ALEN];
4138+ u8 prev_bssid[ETH_ALEN];
4139+ int associated;
4140+ u8 ssid[32];
4141+ size_t ssid_len;
4142+ enum nl80211_iftype nlmode;
4143+ enum nl80211_iftype ap_scan_as_station;
4144+ unsigned int assoc_freq;
4145+
4146+ int monitor_sock;
4147+ int monitor_ifidx;
4148+ int monitor_refcount;
4149+
4150+ unsigned int disabled_11b_rates:1;
4151+ unsigned int pending_remain_on_chan:1;
4152+ unsigned int in_interface_list:1;
4153+ unsigned int device_ap_sme:1;
4154+ unsigned int poll_command_supported:1;
4155+ unsigned int data_tx_status:1;
4156+ unsigned int scan_for_auth:1;
4157+ unsigned int retry_auth:1;
4158+ unsigned int use_monitor:1;
4159+ unsigned int ignore_next_local_disconnect:1;
4160+ unsigned int allow_p2p_device:1;
4161+ unsigned int hostapd:1;
4162+ unsigned int start_mode_ap:1;
4163+ unsigned int start_iface_up:1;
4164+
4165+ u64 remain_on_chan_cookie;
4166+ u64 send_action_cookie;
4167+
4168+ unsigned int last_mgmt_freq;
4169+
4170+ struct wpa_driver_scan_filter *filter_ssids;
4171+ size_t num_filter_ssids;
4172+
4173+ struct i802_bss *first_bss;
4174+
4175+ int eapol_tx_sock;
4176+
4177+ int eapol_sock; /* socket for EAPOL frames */
4178+
4179+ int default_if_indices[16];
4180+ int *if_indices;
4181+ int num_if_indices;
4182+
4183+ /* From failed authentication command */
4184+ int auth_freq;
4185+ u8 auth_bssid_[ETH_ALEN];
4186+ u8 auth_ssid[32];
4187+ size_t auth_ssid_len;
4188+ int auth_alg;
4189+ u8 *auth_ie;
4190+ size_t auth_ie_len;
4191+ u8 auth_wep_key[4][16];
4192+ size_t auth_wep_key_len[4];
4193+ int auth_wep_tx_keyidx;
4194+ int auth_local_state_change;
4195+ int auth_p2p;
4196+};
4197+
4198+
4199+static void wpa_driver_nl80211_deinit(struct i802_bss *bss);
4200+static void wpa_driver_nl80211_scan_timeout(void *eloop_ctx,
4201+ void *timeout_ctx);
4202+static int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
4203+ enum nl80211_iftype nlmode);
4204+static int
4205+wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv,
4206+ const u8 *set_addr, int first);
4207+static int wpa_driver_nl80211_mlme(struct wpa_driver_nl80211_data *drv,
4208+ const u8 *addr, int cmd, u16 reason_code,
4209+ int local_state_change);
4210+static void nl80211_remove_monitor_interface(
4211+ struct wpa_driver_nl80211_data *drv);
4212+static int nl80211_send_frame_cmd(struct i802_bss *bss,
4213+ unsigned int freq, unsigned int wait,
4214+ const u8 *buf, size_t buf_len, u64 *cookie,
4215+ int no_cck, int no_ack, int offchanok);
4216+static int nl80211_register_frame(struct i802_bss *bss,
4217+ struct nl_handle *hl_handle,
4218+ u16 type, const u8 *match, size_t match_len);
4219+static int wpa_driver_nl80211_probe_req_report(struct i802_bss *bss,
4220+ int report);
4221+#ifdef ANDROID
4222+static int android_pno_start(struct i802_bss *bss,
4223+ struct wpa_driver_scan_params *params);
4224+static int android_pno_stop(struct i802_bss *bss);
4225+extern int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf,
4226+ size_t buf_len);
4227+#endif /* ANDROID */
4228+#ifdef ANDROID_P2P
4229+int wpa_driver_set_p2p_noa(void *priv, u8 count, int start, int duration);
4230+int wpa_driver_get_p2p_noa(void *priv, u8 *buf, size_t len);
4231+int wpa_driver_set_p2p_ps(void *priv, int legacy_ps, int opp_ps, int ctwindow);
4232+int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon,
4233+ const struct wpabuf *proberesp,
4234+ const struct wpabuf *assocresp);
4235+#endif /* ANDROID_P2P */
4236+
4237+static void add_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx);
4238+static void del_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx);
4239+static int have_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx);
4240+static int wpa_driver_nl80211_if_remove(struct i802_bss *bss,
4241+ enum wpa_driver_if_type type,
4242+ const char *ifname);
4243+
4244+static int wpa_driver_nl80211_set_freq(struct i802_bss *bss,
4245+ struct hostapd_freq_params *freq);
4246+static int nl80211_disable_11b_rates(struct wpa_driver_nl80211_data *drv,
4247+ int ifindex, int disabled);
4248+
4249+static int nl80211_leave_ibss(struct wpa_driver_nl80211_data *drv);
4250+static int wpa_driver_nl80211_authenticate_retry(
4251+ struct wpa_driver_nl80211_data *drv);
4252+
4253+static int i802_set_iface_flags(struct i802_bss *bss, int up);
4254+
4255+
4256+static const char * nl80211_command_to_string(enum nl80211_commands cmd)
4257+{
4258+#define C2S(x) case x: return #x;
4259+ switch (cmd) {
4260+ C2S(NL80211_CMD_UNSPEC)
4261+ C2S(NL80211_CMD_GET_WIPHY)
4262+ C2S(NL80211_CMD_SET_WIPHY)
4263+ C2S(NL80211_CMD_NEW_WIPHY)
4264+ C2S(NL80211_CMD_DEL_WIPHY)
4265+ C2S(NL80211_CMD_GET_INTERFACE)
4266+ C2S(NL80211_CMD_SET_INTERFACE)
4267+ C2S(NL80211_CMD_NEW_INTERFACE)
4268+ C2S(NL80211_CMD_DEL_INTERFACE)
4269+ C2S(NL80211_CMD_GET_KEY)
4270+ C2S(NL80211_CMD_SET_KEY)
4271+ C2S(NL80211_CMD_NEW_KEY)
4272+ C2S(NL80211_CMD_DEL_KEY)
4273+ C2S(NL80211_CMD_GET_BEACON)
4274+ C2S(NL80211_CMD_SET_BEACON)
4275+ C2S(NL80211_CMD_START_AP)
4276+ C2S(NL80211_CMD_STOP_AP)
4277+ C2S(NL80211_CMD_GET_STATION)
4278+ C2S(NL80211_CMD_SET_STATION)
4279+ C2S(NL80211_CMD_NEW_STATION)
4280+ C2S(NL80211_CMD_DEL_STATION)
4281+ C2S(NL80211_CMD_GET_MPATH)
4282+ C2S(NL80211_CMD_SET_MPATH)
4283+ C2S(NL80211_CMD_NEW_MPATH)
4284+ C2S(NL80211_CMD_DEL_MPATH)
4285+ C2S(NL80211_CMD_SET_BSS)
4286+ C2S(NL80211_CMD_SET_REG)
4287+ C2S(NL80211_CMD_REQ_SET_REG)
4288+ C2S(NL80211_CMD_GET_MESH_CONFIG)
4289+ C2S(NL80211_CMD_SET_MESH_CONFIG)
4290+ C2S(NL80211_CMD_SET_MGMT_EXTRA_IE)
4291+ C2S(NL80211_CMD_GET_REG)
4292+ C2S(NL80211_CMD_GET_SCAN)
4293+ C2S(NL80211_CMD_TRIGGER_SCAN)
4294+ C2S(NL80211_CMD_NEW_SCAN_RESULTS)
4295+ C2S(NL80211_CMD_SCAN_ABORTED)
4296+ C2S(NL80211_CMD_REG_CHANGE)
4297+ C2S(NL80211_CMD_AUTHENTICATE)
4298+ C2S(NL80211_CMD_ASSOCIATE)
4299+ C2S(NL80211_CMD_DEAUTHENTICATE)
4300+ C2S(NL80211_CMD_DISASSOCIATE)
4301+ C2S(NL80211_CMD_MICHAEL_MIC_FAILURE)
4302+ C2S(NL80211_CMD_REG_BEACON_HINT)
4303+ C2S(NL80211_CMD_JOIN_IBSS)
4304+ C2S(NL80211_CMD_LEAVE_IBSS)
4305+ C2S(NL80211_CMD_TESTMODE)
4306+ C2S(NL80211_CMD_CONNECT)
4307+ C2S(NL80211_CMD_ROAM)
4308+ C2S(NL80211_CMD_DISCONNECT)
4309+ C2S(NL80211_CMD_SET_WIPHY_NETNS)
4310+ C2S(NL80211_CMD_GET_SURVEY)
4311+ C2S(NL80211_CMD_NEW_SURVEY_RESULTS)
4312+ C2S(NL80211_CMD_SET_PMKSA)
4313+ C2S(NL80211_CMD_DEL_PMKSA)
4314+ C2S(NL80211_CMD_FLUSH_PMKSA)
4315+ C2S(NL80211_CMD_REMAIN_ON_CHANNEL)
4316+ C2S(NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL)
4317+ C2S(NL80211_CMD_SET_TX_BITRATE_MASK)
4318+ C2S(NL80211_CMD_REGISTER_FRAME)
4319+ C2S(NL80211_CMD_FRAME)
4320+ C2S(NL80211_CMD_FRAME_TX_STATUS)
4321+ C2S(NL80211_CMD_SET_POWER_SAVE)
4322+ C2S(NL80211_CMD_GET_POWER_SAVE)
4323+ C2S(NL80211_CMD_SET_CQM)
4324+ C2S(NL80211_CMD_NOTIFY_CQM)
4325+ C2S(NL80211_CMD_SET_CHANNEL)
4326+ C2S(NL80211_CMD_SET_WDS_PEER)
4327+ C2S(NL80211_CMD_FRAME_WAIT_CANCEL)
4328+ C2S(NL80211_CMD_JOIN_MESH)
4329+ C2S(NL80211_CMD_LEAVE_MESH)
4330+ C2S(NL80211_CMD_UNPROT_DEAUTHENTICATE)
4331+ C2S(NL80211_CMD_UNPROT_DISASSOCIATE)
4332+ C2S(NL80211_CMD_NEW_PEER_CANDIDATE)
4333+ C2S(NL80211_CMD_GET_WOWLAN)
4334+ C2S(NL80211_CMD_SET_WOWLAN)
4335+ C2S(NL80211_CMD_START_SCHED_SCAN)
4336+ C2S(NL80211_CMD_STOP_SCHED_SCAN)
4337+ C2S(NL80211_CMD_SCHED_SCAN_RESULTS)
4338+ C2S(NL80211_CMD_SCHED_SCAN_STOPPED)
4339+ C2S(NL80211_CMD_SET_REKEY_OFFLOAD)
4340+ C2S(NL80211_CMD_PMKSA_CANDIDATE)
4341+ C2S(NL80211_CMD_TDLS_OPER)
4342+ C2S(NL80211_CMD_TDLS_MGMT)
4343+ C2S(NL80211_CMD_UNEXPECTED_FRAME)
4344+ C2S(NL80211_CMD_PROBE_CLIENT)
4345+ C2S(NL80211_CMD_REGISTER_BEACONS)
4346+ C2S(NL80211_CMD_UNEXPECTED_4ADDR_FRAME)
4347+ C2S(NL80211_CMD_SET_NOACK_MAP)
4348+ C2S(NL80211_CMD_CH_SWITCH_NOTIFY)
4349+ C2S(NL80211_CMD_START_P2P_DEVICE)
4350+ C2S(NL80211_CMD_STOP_P2P_DEVICE)
4351+ C2S(NL80211_CMD_CONN_FAILED)
4352+ C2S(NL80211_CMD_SET_MCAST_RATE)
4353+ C2S(NL80211_CMD_SET_MAC_ACL)
4354+ C2S(NL80211_CMD_RADAR_DETECT)
4355+ C2S(NL80211_CMD_GET_PROTOCOL_FEATURES)
4356+ C2S(NL80211_CMD_UPDATE_FT_IES)
4357+ C2S(NL80211_CMD_FT_EVENT)
4358+ C2S(NL80211_CMD_CRIT_PROTOCOL_START)
4359+ C2S(NL80211_CMD_CRIT_PROTOCOL_STOP)
4360+ C2S(NL80211_CMD_GET_COALESCE)
4361+ C2S(NL80211_CMD_SET_COALESCE)
4362+ C2S(NL80211_CMD_CHANNEL_SWITCH)
4363+ C2S(NL80211_CMD_VENDOR)
4364+ C2S(NL80211_CMD_SET_QOS_MAP)
4365+ default:
4366+ return "NL80211_CMD_UNKNOWN";
4367+ }
4368+#undef C2S
4369+}
4370+
4371+
4372+/* Converts nl80211_chan_width to a common format */
4373+static enum chan_width convert2width(int width)
4374+{
4375+ switch (width) {
4376+ case NL80211_CHAN_WIDTH_20_NOHT:
4377+ return CHAN_WIDTH_20_NOHT;
4378+ case NL80211_CHAN_WIDTH_20:
4379+ return CHAN_WIDTH_20;
4380+ case NL80211_CHAN_WIDTH_40:
4381+ return CHAN_WIDTH_40;
4382+ case NL80211_CHAN_WIDTH_80:
4383+ return CHAN_WIDTH_80;
4384+ case NL80211_CHAN_WIDTH_80P80:
4385+ return CHAN_WIDTH_80P80;
4386+ case NL80211_CHAN_WIDTH_160:
4387+ return CHAN_WIDTH_160;
4388+ }
4389+ return CHAN_WIDTH_UNKNOWN;
4390+}
4391+
4392+
4393+static int is_ap_interface(enum nl80211_iftype nlmode)
4394+{
4395+ return (nlmode == NL80211_IFTYPE_AP ||
4396+ nlmode == NL80211_IFTYPE_P2P_GO);
4397+}
4398+
4399+
4400+static int is_sta_interface(enum nl80211_iftype nlmode)
4401+{
4402+ return (nlmode == NL80211_IFTYPE_STATION ||
4403+ nlmode == NL80211_IFTYPE_P2P_CLIENT);
4404+}
4405+
4406+
4407+static int is_p2p_net_interface(enum nl80211_iftype nlmode)
4408+{
4409+ return (nlmode == NL80211_IFTYPE_P2P_CLIENT ||
4410+ nlmode == NL80211_IFTYPE_P2P_GO);
4411+}
4412+
4413+
4414+static void nl80211_mark_disconnected(struct wpa_driver_nl80211_data *drv)
4415+{
4416+ if (drv->associated)
4417+ os_memcpy(drv->prev_bssid, drv->bssid, ETH_ALEN);
4418+ drv->associated = 0;
4419+ os_memset(drv->bssid, 0, ETH_ALEN);
4420+}
4421+
4422+
4423+struct nl80211_bss_info_arg {
4424+ struct wpa_driver_nl80211_data *drv;
4425+ struct wpa_scan_results *res;
4426+ unsigned int assoc_freq;
4427+ u8 assoc_bssid[ETH_ALEN];
4428+};
4429+
4430+static int bss_info_handler(struct nl_msg *msg, void *arg);
4431+
4432+
4433+/* nl80211 code */
4434+static int ack_handler(struct nl_msg *msg, void *arg)
4435+{
4436+ int *err = arg;
4437+ *err = 0;
4438+ return NL_STOP;
4439+}
4440+
4441+static int finish_handler(struct nl_msg *msg, void *arg)
4442+{
4443+ int *ret = arg;
4444+ *ret = 0;
4445+ return NL_SKIP;
4446+}
4447+
4448+static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
4449+ void *arg)
4450+{
4451+ int *ret = arg;
4452+ *ret = err->error;
4453+ return NL_SKIP;
4454+}
4455+
4456+
4457+static int no_seq_check(struct nl_msg *msg, void *arg)
4458+{
4459+ return NL_OK;
4460+}
4461+
4462+
4463+static int send_and_recv(struct nl80211_global *global,
4464+ struct nl_handle *nl_handle, struct nl_msg *msg,
4465+ int (*valid_handler)(struct nl_msg *, void *),
4466+ void *valid_data)
4467+{
4468+ struct nl_cb *cb;
4469+ int err = -ENOMEM;
4470+
4471+ cb = nl_cb_clone(global->nl_cb);
4472+ if (!cb)
4473+ goto out;
4474+
4475+ err = nl_send_auto_complete(nl_handle, msg);
4476+ if (err < 0)
4477+ goto out;
4478+
4479+ err = 1;
4480+
4481+ nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
4482+ nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
4483+ nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
4484+
4485+ if (valid_handler)
4486+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
4487+ valid_handler, valid_data);
4488+
4489+ while (err > 0) {
4490+ int res = nl_recvmsgs(nl_handle, cb);
4491+ if (res) {
4492+ wpa_printf(MSG_INFO,
4493+ "nl80211: %s->nl_recvmsgs failed: %d",
4494+ __func__, res);
4495+ }
4496+ }
4497+ out:
4498+ nl_cb_put(cb);
4499+ nlmsg_free(msg);
4500+ return err;
4501+}
4502+
4503+
4504+static int send_and_recv_msgs_global(struct nl80211_global *global,
4505+ struct nl_msg *msg,
4506+ int (*valid_handler)(struct nl_msg *, void *),
4507+ void *valid_data)
4508+{
4509+ return send_and_recv(global, global->nl, msg, valid_handler,
4510+ valid_data);
4511+}
4512+
4513+
4514+static int send_and_recv_msgs(struct wpa_driver_nl80211_data *drv,
4515+ struct nl_msg *msg,
4516+ int (*valid_handler)(struct nl_msg *, void *),
4517+ void *valid_data)
4518+{
4519+ return send_and_recv(drv->global, drv->global->nl, msg,
4520+ valid_handler, valid_data);
4521+}
4522+
4523+
4524+struct family_data {
4525+ const char *group;
4526+ int id;
4527+};
4528+
4529+
4530+static int nl80211_set_iface_id(struct nl_msg *msg, struct i802_bss *bss)
4531+{
4532+ if (bss->wdev_id_set)
4533+ NLA_PUT_U64(msg, NL80211_ATTR_WDEV, bss->wdev_id);
4534+ else
4535+ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex);
4536+ return 0;
4537+
4538+nla_put_failure:
4539+ return -1;
4540+}
4541+
4542+
4543+static int family_handler(struct nl_msg *msg, void *arg)
4544+{
4545+ struct family_data *res = arg;
4546+ struct nlattr *tb[CTRL_ATTR_MAX + 1];
4547+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
4548+ struct nlattr *mcgrp;
4549+ int i;
4550+
4551+ nla_parse(tb, CTRL_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
4552+ genlmsg_attrlen(gnlh, 0), NULL);
4553+ if (!tb[CTRL_ATTR_MCAST_GROUPS])
4554+ return NL_SKIP;
4555+
4556+ nla_for_each_nested(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], i) {
4557+ struct nlattr *tb2[CTRL_ATTR_MCAST_GRP_MAX + 1];
4558+ nla_parse(tb2, CTRL_ATTR_MCAST_GRP_MAX, nla_data(mcgrp),
4559+ nla_len(mcgrp), NULL);
4560+ if (!tb2[CTRL_ATTR_MCAST_GRP_NAME] ||
4561+ !tb2[CTRL_ATTR_MCAST_GRP_ID] ||
4562+ os_strncmp(nla_data(tb2[CTRL_ATTR_MCAST_GRP_NAME]),
4563+ res->group,
4564+ nla_len(tb2[CTRL_ATTR_MCAST_GRP_NAME])) != 0)
4565+ continue;
4566+ res->id = nla_get_u32(tb2[CTRL_ATTR_MCAST_GRP_ID]);
4567+ break;
4568+ };
4569+
4570+ return NL_SKIP;
4571+}
4572+
4573+
4574+static int nl_get_multicast_id(struct nl80211_global *global,
4575+ const char *family, const char *group)
4576+{
4577+ struct nl_msg *msg;
4578+ int ret = -1;
4579+ struct family_data res = { group, -ENOENT };
4580+
4581+ msg = nlmsg_alloc();
4582+ if (!msg)
4583+ return -ENOMEM;
4584+ genlmsg_put(msg, 0, 0, genl_ctrl_resolve(global->nl, "nlctrl"),
4585+ 0, 0, CTRL_CMD_GETFAMILY, 0);
4586+ NLA_PUT_STRING(msg, CTRL_ATTR_FAMILY_NAME, family);
4587+
4588+ ret = send_and_recv_msgs_global(global, msg, family_handler, &res);
4589+ msg = NULL;
4590+ if (ret == 0)
4591+ ret = res.id;
4592+
4593+nla_put_failure:
4594+ nlmsg_free(msg);
4595+ return ret;
4596+}
4597+
4598+
4599+static void * nl80211_cmd(struct wpa_driver_nl80211_data *drv,
4600+ struct nl_msg *msg, int flags, uint8_t cmd)
4601+{
4602+ return genlmsg_put(msg, 0, 0, drv->global->nl80211_id,
4603+ 0, flags, cmd, 0);
4604+}
4605+
4606+
4607+struct wiphy_idx_data {
4608+ int wiphy_idx;
4609+ enum nl80211_iftype nlmode;
4610+ u8 *macaddr;
4611+};
4612+
4613+
4614+static int netdev_info_handler(struct nl_msg *msg, void *arg)
4615+{
4616+ struct nlattr *tb[NL80211_ATTR_MAX + 1];
4617+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
4618+ struct wiphy_idx_data *info = arg;
4619+
4620+ nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
4621+ genlmsg_attrlen(gnlh, 0), NULL);
4622+
4623+ if (tb[NL80211_ATTR_WIPHY])
4624+ info->wiphy_idx = nla_get_u32(tb[NL80211_ATTR_WIPHY]);
4625+
4626+ if (tb[NL80211_ATTR_IFTYPE])
4627+ info->nlmode = nla_get_u32(tb[NL80211_ATTR_IFTYPE]);
4628+
4629+ if (tb[NL80211_ATTR_MAC] && info->macaddr)
4630+ os_memcpy(info->macaddr, nla_data(tb[NL80211_ATTR_MAC]),
4631+ ETH_ALEN);
4632+
4633+ return NL_SKIP;
4634+}
4635+
4636+
4637+static int nl80211_get_wiphy_index(struct i802_bss *bss)
4638+{
4639+ struct nl_msg *msg;
4640+ struct wiphy_idx_data data = {
4641+ .wiphy_idx = -1,
4642+ .macaddr = NULL,
4643+ };
4644+
4645+ msg = nlmsg_alloc();
4646+ if (!msg)
4647+ return NL80211_IFTYPE_UNSPECIFIED;
4648+
4649+ nl80211_cmd(bss->drv, msg, 0, NL80211_CMD_GET_INTERFACE);
4650+
4651+ if (nl80211_set_iface_id(msg, bss) < 0)
4652+ goto nla_put_failure;
4653+
4654+ if (send_and_recv_msgs(bss->drv, msg, netdev_info_handler, &data) == 0)
4655+ return data.wiphy_idx;
4656+ msg = NULL;
4657+nla_put_failure:
4658+ nlmsg_free(msg);
4659+ return -1;
4660+}
4661+
4662+
4663+static enum nl80211_iftype nl80211_get_ifmode(struct i802_bss *bss)
4664+{
4665+ struct nl_msg *msg;
4666+ struct wiphy_idx_data data = {
4667+ .nlmode = NL80211_IFTYPE_UNSPECIFIED,
4668+ .macaddr = NULL,
4669+ };
4670+
4671+ msg = nlmsg_alloc();
4672+ if (!msg)
4673+ return -1;
4674+
4675+ nl80211_cmd(bss->drv, msg, 0, NL80211_CMD_GET_INTERFACE);
4676+
4677+ if (nl80211_set_iface_id(msg, bss) < 0)
4678+ goto nla_put_failure;
4679+
4680+ if (send_and_recv_msgs(bss->drv, msg, netdev_info_handler, &data) == 0)
4681+ return data.nlmode;
4682+ msg = NULL;
4683+nla_put_failure:
4684+ nlmsg_free(msg);
4685+ return NL80211_IFTYPE_UNSPECIFIED;
4686+}
4687+
4688+
4689+static int nl80211_get_macaddr(struct i802_bss *bss)
4690+{
4691+ struct nl_msg *msg;
4692+ struct wiphy_idx_data data = {
4693+ .macaddr = bss->addr,
4694+ };
4695+
4696+ msg = nlmsg_alloc();
4697+ if (!msg)
4698+ return NL80211_IFTYPE_UNSPECIFIED;
4699+
4700+ nl80211_cmd(bss->drv, msg, 0, NL80211_CMD_GET_INTERFACE);
4701+ if (nl80211_set_iface_id(msg, bss) < 0)
4702+ goto nla_put_failure;
4703+
4704+ return send_and_recv_msgs(bss->drv, msg, netdev_info_handler, &data);
4705+
4706+nla_put_failure:
4707+ nlmsg_free(msg);
4708+ return NL80211_IFTYPE_UNSPECIFIED;
4709+}
4710+
4711+
4712+static int nl80211_register_beacons(struct wpa_driver_nl80211_data *drv,
4713+ struct nl80211_wiphy_data *w)
4714+{
4715+ struct nl_msg *msg;
4716+ int ret = -1;
4717+
4718+ msg = nlmsg_alloc();
4719+ if (!msg)
4720+ return -1;
4721+
4722+ nl80211_cmd(drv, msg, 0, NL80211_CMD_REGISTER_BEACONS);
4723+
4724+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, w->wiphy_idx);
4725+
4726+ ret = send_and_recv(drv->global, w->nl_beacons, msg, NULL, NULL);
4727+ msg = NULL;
4728+ if (ret) {
4729+ wpa_printf(MSG_DEBUG, "nl80211: Register beacons command "
4730+ "failed: ret=%d (%s)",
4731+ ret, strerror(-ret));
4732+ goto nla_put_failure;
4733+ }
4734+ ret = 0;
4735+nla_put_failure:
4736+ nlmsg_free(msg);
4737+ return ret;
4738+}
4739+
4740+
4741+static void nl80211_recv_beacons(int sock, void *eloop_ctx, void *handle)
4742+{
4743+ struct nl80211_wiphy_data *w = eloop_ctx;
4744+ int res;
4745+
4746+ wpa_printf(MSG_EXCESSIVE, "nl80211: Beacon event message available");
4747+
4748+ res = nl_recvmsgs(handle, w->nl_cb);
4749+ if (res) {
4750+ wpa_printf(MSG_INFO, "nl80211: %s->nl_recvmsgs failed: %d",
4751+ __func__, res);
4752+ }
4753+}
4754+
4755+
4756+static int process_beacon_event(struct nl_msg *msg, void *arg)
4757+{
4758+ struct nl80211_wiphy_data *w = arg;
4759+ struct wpa_driver_nl80211_data *drv;
4760+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
4761+ struct nlattr *tb[NL80211_ATTR_MAX + 1];
4762+ union wpa_event_data event;
4763+
4764+ nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
4765+ genlmsg_attrlen(gnlh, 0), NULL);
4766+
4767+ if (gnlh->cmd != NL80211_CMD_FRAME) {
4768+ wpa_printf(MSG_DEBUG, "nl80211: Unexpected beacon event? (%d)",
4769+ gnlh->cmd);
4770+ return NL_SKIP;
4771+ }
4772+
4773+ if (!tb[NL80211_ATTR_FRAME])
4774+ return NL_SKIP;
4775+
4776+ dl_list_for_each(drv, &w->drvs, struct wpa_driver_nl80211_data,
4777+ wiphy_list) {
4778+ os_memset(&event, 0, sizeof(event));
4779+ event.rx_mgmt.frame = nla_data(tb[NL80211_ATTR_FRAME]);
4780+ event.rx_mgmt.frame_len = nla_len(tb[NL80211_ATTR_FRAME]);
4781+ wpa_supplicant_event(drv->ctx, EVENT_RX_MGMT, &event);
4782+ }
4783+
4784+ return NL_SKIP;
4785+}
4786+
4787+
4788+static struct nl80211_wiphy_data *
4789+nl80211_get_wiphy_data_ap(struct i802_bss *bss)
4790+{
4791+ static DEFINE_DL_LIST(nl80211_wiphys);
4792+ struct nl80211_wiphy_data *w;
4793+ int wiphy_idx, found = 0;
4794+ struct i802_bss *tmp_bss;
4795+
4796+ if (bss->wiphy_data != NULL)
4797+ return bss->wiphy_data;
4798+
4799+ wiphy_idx = nl80211_get_wiphy_index(bss);
4800+
4801+ dl_list_for_each(w, &nl80211_wiphys, struct nl80211_wiphy_data, list) {
4802+ if (w->wiphy_idx == wiphy_idx)
4803+ goto add;
4804+ }
4805+
4806+ /* alloc new one */
4807+ w = os_zalloc(sizeof(*w));
4808+ if (w == NULL)
4809+ return NULL;
4810+ w->wiphy_idx = wiphy_idx;
4811+ dl_list_init(&w->bsss);
4812+ dl_list_init(&w->drvs);
4813+
4814+ w->nl_cb = nl_cb_alloc(NL_CB_DEFAULT);
4815+ if (!w->nl_cb) {
4816+ os_free(w);
4817+ return NULL;
4818+ }
4819+ nl_cb_set(w->nl_cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
4820+ nl_cb_set(w->nl_cb, NL_CB_VALID, NL_CB_CUSTOM, process_beacon_event,
4821+ w);
4822+
4823+ w->nl_beacons = nl_create_handle(bss->drv->global->nl_cb,
4824+ "wiphy beacons");
4825+ if (w->nl_beacons == NULL) {
4826+ os_free(w);
4827+ return NULL;
4828+ }
4829+
4830+ if (nl80211_register_beacons(bss->drv, w)) {
4831+ nl_destroy_handles(&w->nl_beacons);
4832+ os_free(w);
4833+ return NULL;
4834+ }
4835+
4836+ nl80211_register_eloop_read(&w->nl_beacons, nl80211_recv_beacons, w);
4837+
4838+ dl_list_add(&nl80211_wiphys, &w->list);
4839+
4840+add:
4841+ /* drv entry for this bss already there? */
4842+ dl_list_for_each(tmp_bss, &w->bsss, struct i802_bss, wiphy_list) {
4843+ if (tmp_bss->drv == bss->drv) {
4844+ found = 1;
4845+ break;
4846+ }
4847+ }
4848+ /* if not add it */
4849+ if (!found)
4850+ dl_list_add(&w->drvs, &bss->drv->wiphy_list);
4851+
4852+ dl_list_add(&w->bsss, &bss->wiphy_list);
4853+ bss->wiphy_data = w;
4854+ return w;
4855+}
4856+
4857+
4858+static void nl80211_put_wiphy_data_ap(struct i802_bss *bss)
4859+{
4860+ struct nl80211_wiphy_data *w = bss->wiphy_data;
4861+ struct i802_bss *tmp_bss;
4862+ int found = 0;
4863+
4864+ if (w == NULL)
4865+ return;
4866+ bss->wiphy_data = NULL;
4867+ dl_list_del(&bss->wiphy_list);
4868+
4869+ /* still any for this drv present? */
4870+ dl_list_for_each(tmp_bss, &w->bsss, struct i802_bss, wiphy_list) {
4871+ if (tmp_bss->drv == bss->drv) {
4872+ found = 1;
4873+ break;
4874+ }
4875+ }
4876+ /* if not remove it */
4877+ if (!found)
4878+ dl_list_del(&bss->drv->wiphy_list);
4879+
4880+ if (!dl_list_empty(&w->bsss))
4881+ return;
4882+
4883+ nl80211_destroy_eloop_handle(&w->nl_beacons);
4884+
4885+ nl_cb_put(w->nl_cb);
4886+ dl_list_del(&w->list);
4887+ os_free(w);
4888+}
4889+
4890+
4891+static int wpa_driver_nl80211_get_bssid(void *priv, u8 *bssid)
4892+{
4893+ struct i802_bss *bss = priv;
4894+ struct wpa_driver_nl80211_data *drv = bss->drv;
4895+ if (!drv->associated)
4896+ return -1;
4897+ os_memcpy(bssid, drv->bssid, ETH_ALEN);
4898+ return 0;
4899+}
4900+
4901+
4902+static int wpa_driver_nl80211_get_ssid(void *priv, u8 *ssid)
4903+{
4904+ struct i802_bss *bss = priv;
4905+ struct wpa_driver_nl80211_data *drv = bss->drv;
4906+ if (!drv->associated)
4907+ return -1;
4908+ os_memcpy(ssid, drv->ssid, drv->ssid_len);
4909+ return drv->ssid_len;
4910+}
4911+
4912+
4913+static void wpa_driver_nl80211_event_newlink(
4914+ struct wpa_driver_nl80211_data *drv, char *ifname)
4915+{
4916+ union wpa_event_data event;
4917+
4918+ if (os_strcmp(drv->first_bss->ifname, ifname) == 0) {
4919+ if (if_nametoindex(drv->first_bss->ifname) == 0) {
4920+ wpa_printf(MSG_DEBUG, "nl80211: Interface %s does not exist - ignore RTM_NEWLINK",
4921+ drv->first_bss->ifname);
4922+ return;
4923+ }
4924+ if (!drv->if_removed)
4925+ return;
4926+ wpa_printf(MSG_DEBUG, "nl80211: Mark if_removed=0 for %s based on RTM_NEWLINK event",
4927+ drv->first_bss->ifname);
4928+ drv->if_removed = 0;
4929+ }
4930+
4931+ os_memset(&event, 0, sizeof(event));
4932+ os_strlcpy(event.interface_status.ifname, ifname,
4933+ sizeof(event.interface_status.ifname));
4934+ event.interface_status.ievent = EVENT_INTERFACE_ADDED;
4935+ wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS, &event);
4936+}
4937+
4938+
4939+static void wpa_driver_nl80211_event_dellink(
4940+ struct wpa_driver_nl80211_data *drv, char *ifname)
4941+{
4942+ union wpa_event_data event;
4943+
4944+ if (os_strcmp(drv->first_bss->ifname, ifname) == 0) {
4945+ if (drv->if_removed) {
4946+ wpa_printf(MSG_DEBUG, "nl80211: if_removed already set - ignore RTM_DELLINK event for %s",
4947+ ifname);
4948+ return;
4949+ }
4950+ wpa_printf(MSG_DEBUG, "RTM_DELLINK: Interface '%s' removed - mark if_removed=1",
4951+ ifname);
4952+ drv->if_removed = 1;
4953+ } else {
4954+ wpa_printf(MSG_DEBUG, "RTM_DELLINK: Interface '%s' removed",
4955+ ifname);
4956+ }
4957+
4958+ os_memset(&event, 0, sizeof(event));
4959+ os_strlcpy(event.interface_status.ifname, ifname,
4960+ sizeof(event.interface_status.ifname));
4961+ event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
4962+ wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS, &event);
4963+}
4964+
4965+
4966+static int wpa_driver_nl80211_own_ifname(struct wpa_driver_nl80211_data *drv,
4967+ u8 *buf, size_t len)
4968+{
4969+ int attrlen, rta_len;
4970+ struct rtattr *attr;
4971+
4972+ attrlen = len;
4973+ attr = (struct rtattr *) buf;
4974+
4975+ rta_len = RTA_ALIGN(sizeof(struct rtattr));
4976+ while (RTA_OK(attr, attrlen)) {
4977+ if (attr->rta_type == IFLA_IFNAME) {
4978+ if (os_strcmp(((char *) attr) + rta_len,
4979+ drv->first_bss->ifname) == 0)
4980+ return 1;
4981+ else
4982+ break;
4983+ }
4984+ attr = RTA_NEXT(attr, attrlen);
4985+ }
4986+
4987+ return 0;
4988+}
4989+
4990+
4991+static int wpa_driver_nl80211_own_ifindex(struct wpa_driver_nl80211_data *drv,
4992+ int ifindex, u8 *buf, size_t len)
4993+{
4994+ if (drv->ifindex == ifindex)
4995+ return 1;
4996+
4997+ if (drv->if_removed && wpa_driver_nl80211_own_ifname(drv, buf, len)) {
4998+ wpa_printf(MSG_DEBUG, "nl80211: Update ifindex for a removed "
4999+ "interface");
5000+ wpa_driver_nl80211_finish_drv_init(drv, NULL, 0);
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches