1 --- a/wpa_supplicant/wpa_supplicant_i.h
2 +++ b/wpa_supplicant/wpa_supplicant_i.h
3 @@ -96,6 +96,8 @@ struct wpa_interface {
4 * receiving of EAPOL frames from an additional interface.
6 const char *bridge_ifname;
8 + const char *hostapd_ctrl;
12 @@ -306,6 +308,8 @@ struct wpa_supplicant {
13 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
14 char bridge_ifname[16];
16 + struct wpa_ctrl *hostapd;
19 struct wpa_config *conf;
21 --- a/wpa_supplicant/Makefile
22 +++ b/wpa_supplicant/Makefile
23 @@ -13,6 +13,10 @@ PKG_CONFIG ?= pkg-config
25 CFLAGS += -I../src/utils
28 +CFLAGS += -DMULTICALL
32 -include $(if $(MULTICALL),../hostapd/.config)
34 @@ -76,6 +80,10 @@ OBJS_c = wpa_cli.o ../src/common/wpa_ctr
35 OBJS_c += ../src/utils/wpa_debug.o
36 OBJS_c += ../src/utils/common.o
39 +OBJS += ../src/common/wpa_ctrl.o
43 ifdef CONFIG_NATIVE_WINDOWS
45 --- a/wpa_supplicant/wpa_supplicant.c
46 +++ b/wpa_supplicant/wpa_supplicant.c
47 @@ -107,6 +107,55 @@ extern int wpa_debug_show_keys;
48 extern int wpa_debug_timestamp;
49 extern struct wpa_driver_ops *wpa_drivers[];
52 +static int hostapd_stop(struct wpa_supplicant *wpa_s)
54 + const char *cmd = "DOWN";
56 + int 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 + int len = sizeof(buf);
70 + int channel, hw_mode;
76 + if (bss->freq < 4000) {
77 + hw_mode = HOSTAPD_MODE_IEEE80211G;
78 + channel = (bss->freq - 2407) / 5;
80 + hw_mode = HOSTAPD_MODE_IEEE80211A;
81 + channel = (bss->freq - 5000) / 5;
84 + if (asprintf(&cmd, "UPDATE channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
85 + channel, hw_mode, !!bss->ht_capab) < 0) {
89 + ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
93 + wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
100 /* Configure default/group WEP keys for static WEP */
101 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
103 @@ -667,8 +716,16 @@ void wpa_supplicant_set_state(struct wpa
104 #endif /* CONFIG_P2P */
106 sme_sched_obss_scan(wpa_s, 1);
108 + if (wpa_s->hostapd)
109 + hostapd_reload(wpa_s, wpa_s->current_bss);
111 } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
112 state == WPA_ASSOCIATED) {
114 + if (wpa_s->hostapd)
115 + hostapd_stop(wpa_s);
117 wpa_s->new_connection = 1;
118 wpa_drv_set_operstate(wpa_s, 0);
119 #ifndef IEEE8021X_EAPOL
120 @@ -2853,6 +2910,21 @@ static int wpa_supplicant_init_iface(str
121 os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
122 sizeof(wpa_s->bridge_ifname));
125 + if (iface->hostapd_ctrl) {
126 + char *cmd = "DOWN";
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)
140 /* RSNA Supplicant Key Management - INITIALIZE */
141 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
142 --- a/wpa_supplicant/bss.c
143 +++ b/wpa_supplicant/bss.c
145 #include "utils/common.h"
146 #include "utils/eloop.h"
147 #include "common/ieee802_11_defs.h"
148 +#include "common/ieee802_11_common.h"
149 #include "drivers/driver.h"
150 #include "wpa_supplicant_i.h"
152 @@ -245,6 +246,9 @@ static void calculate_update_time(const
153 static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
154 struct os_time *fetch_time)
156 + struct ieee80211_ht_capabilities *capab;
157 + struct ieee802_11_elems elems;
159 dst->flags = src->flags;
160 os_memcpy(dst->bssid, src->bssid, ETH_ALEN);
161 dst->freq = src->freq;
162 @@ -255,6 +259,12 @@ static void wpa_bss_copy_res(struct wpa_
163 dst->level = src->level;
166 + memset(&elems, 0, sizeof(elems));
167 + ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
168 + capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
170 + dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
172 calculate_update_time(fetch_time, src->age, &dst->last_update);
175 --- a/wpa_supplicant/main.c
176 +++ b/wpa_supplicant/main.c
177 @@ -25,7 +25,7 @@ static void usage(void)
179 " wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
180 "[-g<global ctrl>] \\\n"
181 - " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
182 + " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>]"
183 "[-p<driver_param>] \\\n"
184 " [-b<br_ifname>] [-f<debug file>] [-e<entropy file>] "
186 @@ -67,6 +67,7 @@ static void usage(void)
187 #endif /* CONFIG_DEBUG_LINUX_TRACING */
188 printf(" -t = include timestamp in debug messages\n"
189 " -h = show this help text\n"
190 + " -H = connect to a hostapd instance to manage state changes\n"
191 " -L = show license (BSD)\n"
192 " -o = override driver parameter for new interfaces\n"
193 " -O = override ctrl_interface parameter for new interfaces\n"
194 @@ -155,7 +156,7 @@ int main(int argc, char *argv[])
197 c = getopt(argc, argv,
198 - "b:Bc:C:D:de:f:g:hi:KLNo:O:p:P:qsTtuvW");
199 + "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qsTtuvW");
203 @@ -199,6 +200,9 @@ int main(int argc, char *argv[])
208 + iface->hostapd_ctrl = optarg;
211 iface->ifname = optarg;
213 --- a/wpa_supplicant/bss.h
214 +++ b/wpa_supplicant/bss.h
215 @@ -69,6 +69,8 @@ struct wpa_bss {
217 /** Length of SSID */
219 + /** HT caapbilities */
221 /** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
223 /** Beacon interval in TUs (host byte order) */