1 --- a/wpa_supplicant/wpa_supplicant_i.h
2 +++ b/wpa_supplicant/wpa_supplicant_i.h
3 @@ -101,6 +101,11 @@ struct wpa_interface {
7 + * hostapd_ctrl - path to hostapd control socket for notification
9 + const char *hostapd_ctrl;
12 * bridge_ifname - Optional bridge interface name
14 * If the driver interface (ifname) is included in a Linux bridge
15 @@ -513,6 +518,8 @@ struct wpa_supplicant {
16 #endif /* CONFIG_CTRL_IFACE_BINDER */
17 char bridge_ifname[16];
19 + struct wpa_ctrl *hostapd;
24 --- a/wpa_supplicant/Makefile
25 +++ b/wpa_supplicant/Makefile
26 @@ -26,6 +26,10 @@ CFLAGS += $(EXTRA_CFLAGS)
27 CFLAGS += -I$(abspath ../src)
28 CFLAGS += -I$(abspath ../src/utils)
31 +CFLAGS += -DMULTICALL
35 -include $(if $(MULTICALL),../hostapd/.config)
37 @@ -117,6 +121,8 @@ OBJS_c += ../src/utils/common.o
38 OBJS_c += ../src/common/cli.o
41 +OBJS += ../src/common/wpa_ctrl.o
44 ifdef CONFIG_NATIVE_WINDOWS
46 --- a/wpa_supplicant/wpa_supplicant.c
47 +++ b/wpa_supplicant/wpa_supplicant.c
48 @@ -125,6 +125,55 @@ static void wpas_update_fils_connect_par
49 #endif /* CONFIG_FILS && IEEE8021X_EAPOL */
52 +static int hostapd_stop(struct wpa_supplicant *wpa_s)
54 + const char *cmd = "STOP_AP";
56 + size_t len = sizeof(buf);
58 + if (wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL) < 0) {
59 + wpa_printf(MSG_ERROR, "\nFailed to stop hostapd AP interfaces\n");
65 +static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
69 + size_t len = sizeof(buf);
70 + enum hostapd_hw_mode hw_mode;
78 + if (bss->ht_param & HT_INFO_HT_PARAM_STA_CHNL_WIDTH) {
79 + int sec = bss->ht_param & HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK;
80 + if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE)
82 + else if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW)
86 + hw_mode = ieee80211_freq_to_chan(bss->freq, &channel);
87 + if (asprintf(&cmd, "UPDATE channel=%d sec_chan=%d hw_mode=%d",
88 + channel, sec_chan, hw_mode) < 0)
91 + ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
95 + wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
101 /* Configure default/group WEP keys for static WEP */
102 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
104 @@ -893,12 +942,16 @@ void wpa_supplicant_set_state(struct wpa
106 sme_sched_obss_scan(wpa_s, 1);
108 + if (wpa_s->hostapd)
109 + hostapd_reload(wpa_s, wpa_s->current_bss);
110 #if defined(CONFIG_FILS) && defined(IEEE8021X_EAPOL)
111 if (!fils_hlp_sent && ssid && ssid->eap.erp)
112 wpas_update_fils_connect_params(wpa_s);
113 #endif /* CONFIG_FILS && IEEE8021X_EAPOL */
114 } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
115 state == WPA_ASSOCIATED) {
116 + if (wpa_s->hostapd)
117 + hostapd_stop(wpa_s);
118 wpa_s->new_connection = 1;
119 wpa_drv_set_operstate(wpa_s, 0);
120 #ifndef IEEE8021X_EAPOL
121 @@ -5301,6 +5354,20 @@ static int wpa_supplicant_init_iface(str
122 sizeof(wpa_s->bridge_ifname));
125 + if (iface->hostapd_ctrl) {
126 + char *cmd = "STOP_AP";
128 + int len = sizeof(buf);
130 + wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl);
131 + if (!wpa_s->hostapd) {
132 + wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n");
135 + if (hostapd_stop(wpa_s) < 0)
139 /* RSNA Supplicant Key Management - INITIALIZE */
140 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
141 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
142 @@ -5625,6 +5692,11 @@ static void wpa_supplicant_deinit_iface(
144 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING);
146 + if (wpa_s->hostapd) {
147 + wpa_ctrl_close(wpa_s->hostapd);
148 + wpa_s->hostapd = NULL;
151 if (wpa_s->ctrl_iface) {
152 wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
153 wpa_s->ctrl_iface = NULL;
154 --- a/wpa_supplicant/bss.c
155 +++ b/wpa_supplicant/bss.c
157 #include "utils/common.h"
158 #include "utils/eloop.h"
159 #include "common/ieee802_11_defs.h"
160 +#include "common/ieee802_11_common.h"
161 #include "drivers/driver.h"
162 #include "eap_peer/eap.h"
163 #include "wpa_supplicant_i.h"
164 @@ -290,6 +291,10 @@ void calculate_update_time(const struct
165 static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
166 struct os_reltime *fetch_time)
168 + struct ieee80211_ht_capabilities *capab;
169 + struct ieee80211_ht_operation *oper;
170 + struct ieee802_11_elems elems;
172 dst->flags = src->flags;
173 os_memcpy(dst->bssid, src->bssid, ETH_ALEN);
174 dst->freq = src->freq;
175 @@ -302,6 +307,15 @@ static void wpa_bss_copy_res(struct wpa_
176 dst->est_throughput = src->est_throughput;
179 + memset(&elems, 0, sizeof(elems));
180 + ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
181 + capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
182 + oper = (struct ieee80211_ht_operation *) elems.ht_operation;
184 + dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
186 + dst->ht_param = oper->ht_param;
188 calculate_update_time(fetch_time, src->age, &dst->last_update);
191 --- a/wpa_supplicant/main.c
192 +++ b/wpa_supplicant/main.c
193 @@ -34,7 +34,7 @@ static void usage(void)
194 "vW] [-P<pid file>] "
195 "[-g<global ctrl>] \\\n"
197 - " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
198 + " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>] "
199 "[-p<driver_param>] \\\n"
200 " [-b<br_ifname>] [-e<entropy file>]"
201 #ifdef CONFIG_DEBUG_FILE
202 @@ -74,6 +74,7 @@ static void usage(void)
203 " -g = global ctrl_interface\n"
204 " -G = global ctrl_interface group\n"
205 " -h = show this help text\n"
206 + " -H = connect to a hostapd instance to manage state changes\n"
207 " -i = interface name\n"
208 " -I = additional configuration file\n"
209 " -K = include keys (passwords, etc.) in debug output\n"
210 @@ -201,7 +202,7 @@ int main(int argc, char *argv[])
213 c = getopt(argc, argv,
214 - "b:Bc:C:D:de:f:g:G:hi:I:KLMm:No:O:p:P:qsTtuvW");
215 + "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:No:O:p:P:qsTtuvW");
219 @@ -248,6 +249,9 @@ int main(int argc, char *argv[])
224 + iface->hostapd_ctrl = optarg;
227 iface->ifname = optarg;
229 --- a/wpa_supplicant/bss.h
230 +++ b/wpa_supplicant/bss.h
231 @@ -80,6 +80,10 @@ struct wpa_bss {
232 u8 ssid[SSID_MAX_LEN];
233 /** Length of SSID */
235 + /** HT capabilities */
237 + /* Five octets of HT Operation Information */
239 /** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
241 /** Beacon interval in TUs (host byte order) */