1 --- a/wpa_supplicant/wpa_supplicant_i.h
2 +++ b/wpa_supplicant/wpa_supplicant_i.h
3 @@ -100,6 +100,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 @@ -484,6 +489,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 @@ -114,6 +118,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 @@ -112,6 +112,55 @@ const char *const wpa_supplicant_full_li
50 #endif /* CONFIG_NO_STDOUT_DEBUG */
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 @@ -812,8 +861,12 @@ void wpa_supplicant_set_state(struct wpa
105 wpas_p2p_completed(wpa_s);
107 sme_sched_obss_scan(wpa_s, 1);
108 + if (wpa_s->hostapd)
109 + hostapd_reload(wpa_s, wpa_s->current_bss);
110 } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
111 state == WPA_ASSOCIATED) {
112 + if (wpa_s->hostapd)
113 + hostapd_stop(wpa_s);
114 wpa_s->new_connection = 1;
115 wpa_drv_set_operstate(wpa_s, 0);
116 #ifndef IEEE8021X_EAPOL
117 @@ -4748,6 +4801,20 @@ static int wpa_supplicant_init_iface(str
118 sizeof(wpa_s->bridge_ifname));
121 + if (iface->hostapd_ctrl) {
122 + char *cmd = "STOP_AP";
124 + int len = sizeof(buf);
126 + wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl);
127 + if (!wpa_s->hostapd) {
128 + wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n");
131 + if (hostapd_stop(wpa_s) < 0)
135 /* RSNA Supplicant Key Management - INITIALIZE */
136 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
137 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
138 @@ -5041,6 +5108,11 @@ static void wpa_supplicant_deinit_iface(
140 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING);
142 + if (wpa_s->hostapd) {
143 + wpa_ctrl_close(wpa_s->hostapd);
144 + wpa_s->hostapd = NULL;
147 if (wpa_s->ctrl_iface) {
148 wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
149 wpa_s->ctrl_iface = NULL;
150 --- a/wpa_supplicant/bss.c
151 +++ b/wpa_supplicant/bss.c
153 #include "utils/common.h"
154 #include "utils/eloop.h"
155 #include "common/ieee802_11_defs.h"
156 +#include "common/ieee802_11_common.h"
157 #include "drivers/driver.h"
158 #include "eap_peer/eap.h"
159 #include "wpa_supplicant_i.h"
160 @@ -288,6 +289,10 @@ static void calculate_update_time(const
161 static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
162 struct os_reltime *fetch_time)
164 + struct ieee80211_ht_capabilities *capab;
165 + struct ieee80211_ht_operation *oper;
166 + struct ieee802_11_elems elems;
168 dst->flags = src->flags;
169 os_memcpy(dst->bssid, src->bssid, ETH_ALEN);
170 dst->freq = src->freq;
171 @@ -300,6 +305,15 @@ static void wpa_bss_copy_res(struct wpa_
172 dst->est_throughput = src->est_throughput;
175 + memset(&elems, 0, sizeof(elems));
176 + ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
177 + capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
178 + oper = (struct ieee80211_ht_operation *) elems.ht_operation;
180 + dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
182 + dst->ht_param = oper->ht_param;
184 calculate_update_time(fetch_time, src->age, &dst->last_update);
187 --- a/wpa_supplicant/main.c
188 +++ b/wpa_supplicant/main.c
189 @@ -34,7 +34,7 @@ static void usage(void)
190 "vW] [-P<pid file>] "
191 "[-g<global ctrl>] \\\n"
193 - " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
194 + " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>] "
195 "[-p<driver_param>] \\\n"
196 " [-b<br_ifname>] [-e<entropy file>]"
197 #ifdef CONFIG_DEBUG_FILE
198 @@ -74,6 +74,7 @@ static void usage(void)
199 " -g = global ctrl_interface\n"
200 " -G = global ctrl_interface group\n"
201 " -h = show this help text\n"
202 + " -H = connect to a hostapd instance to manage state changes\n"
203 " -i = interface name\n"
204 " -I = additional configuration file\n"
205 " -K = include keys (passwords, etc.) in debug output\n"
206 @@ -201,7 +202,7 @@ int main(int argc, char *argv[])
209 c = getopt(argc, argv,
210 - "b:Bc:C:D:de:f:g:G:hi:I:KLMm:No:O:p:P:qsTtuvW");
211 + "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:No:O:p:P:qsTtuvW");
215 @@ -248,6 +249,9 @@ int main(int argc, char *argv[])
220 + iface->hostapd_ctrl = optarg;
223 iface->ifname = optarg;
225 --- a/wpa_supplicant/bss.h
226 +++ b/wpa_supplicant/bss.h
227 @@ -79,6 +79,10 @@ struct wpa_bss {
228 u8 ssid[SSID_MAX_LEN];
229 /** Length of SSID */
231 + /** HT capabilities */
233 + /* Five octets of HT Operation Information */
235 /** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
237 /** Beacon interval in TUs (host byte order) */