1 --- a/wpa_supplicant/wpa_supplicant_i.h
2 +++ b/wpa_supplicant/wpa_supplicant_i.h
3 @@ -96,6 +96,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 @@ -328,6 +333,8 @@ struct wpa_supplicant {
16 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
17 char bridge_ifname[16];
19 + struct wpa_ctrl *hostapd;
23 struct wpa_config *conf;
24 --- a/wpa_supplicant/Makefile
25 +++ b/wpa_supplicant/Makefile
26 @@ -13,6 +13,10 @@ PKG_CONFIG ?= pkg-config
28 CFLAGS += -I../src/utils
31 +CFLAGS += -DMULTICALL
35 -include $(if $(MULTICALL),../hostapd/.config)
37 @@ -76,6 +80,10 @@ OBJS_c = wpa_cli.o ../src/common/wpa_ctr
38 OBJS_c += ../src/utils/wpa_debug.o
39 OBJS_c += ../src/utils/common.o
42 +OBJS += ../src/common/wpa_ctrl.o
46 ifdef CONFIG_NATIVE_WINDOWS
48 --- a/wpa_supplicant/wpa_supplicant.c
49 +++ b/wpa_supplicant/wpa_supplicant.c
50 @@ -109,6 +109,55 @@ extern int wpa_debug_show_keys;
51 extern int wpa_debug_timestamp;
52 extern struct wpa_driver_ops *wpa_drivers[];
55 +static int hostapd_stop(struct wpa_supplicant *wpa_s)
57 + const char *cmd = "DOWN";
59 + int len = sizeof(buf);
61 + if (wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL) < 0) {
62 + wpa_printf(MSG_ERROR, "\nFailed to stop hostapd AP interfaces\n");
68 +static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
72 + int len = sizeof(buf);
73 + int channel, hw_mode;
79 + if (bss->freq < 4000) {
80 + hw_mode = HOSTAPD_MODE_IEEE80211G;
81 + channel = (bss->freq - 2407) / 5;
83 + hw_mode = HOSTAPD_MODE_IEEE80211A;
84 + channel = (bss->freq - 5000) / 5;
87 + if (asprintf(&cmd, "UPDATE channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
88 + channel, hw_mode, !!bss->ht_capab) < 0) {
92 + ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
96 + wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
103 /* Configure default/group WEP keys for static WEP */
104 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
106 @@ -675,8 +724,16 @@ void wpa_supplicant_set_state(struct wpa
107 #endif /* CONFIG_P2P */
109 sme_sched_obss_scan(wpa_s, 1);
111 + if (wpa_s->hostapd)
112 + hostapd_reload(wpa_s, wpa_s->current_bss);
114 } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
115 state == WPA_ASSOCIATED) {
117 + if (wpa_s->hostapd)
118 + hostapd_stop(wpa_s);
120 wpa_s->new_connection = 1;
121 wpa_drv_set_operstate(wpa_s, 0);
122 #ifndef IEEE8021X_EAPOL
123 @@ -2866,6 +2923,21 @@ static int wpa_supplicant_init_iface(str
124 os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
125 sizeof(wpa_s->bridge_ifname));
128 + if (iface->hostapd_ctrl) {
129 + char *cmd = "DOWN";
131 + int len = sizeof(buf);
133 + wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl);
134 + if (!wpa_s->hostapd) {
135 + wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n");
138 + if (hostapd_stop(wpa_s) < 0)
143 /* RSNA Supplicant Key Management - INITIALIZE */
144 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
145 --- a/wpa_supplicant/bss.c
146 +++ b/wpa_supplicant/bss.c
148 #include "utils/common.h"
149 #include "utils/eloop.h"
150 #include "common/ieee802_11_defs.h"
151 +#include "common/ieee802_11_common.h"
152 #include "drivers/driver.h"
153 #include "wpa_supplicant_i.h"
155 @@ -245,6 +246,9 @@ static void calculate_update_time(const
156 static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
157 struct os_time *fetch_time)
159 + struct ieee80211_ht_capabilities *capab;
160 + struct ieee802_11_elems elems;
162 dst->flags = src->flags;
163 os_memcpy(dst->bssid, src->bssid, ETH_ALEN);
164 dst->freq = src->freq;
165 @@ -255,6 +259,12 @@ static void wpa_bss_copy_res(struct wpa_
166 dst->level = src->level;
169 + memset(&elems, 0, sizeof(elems));
170 + ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
171 + capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
173 + dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
175 calculate_update_time(fetch_time, src->age, &dst->last_update);
178 --- a/wpa_supplicant/main.c
179 +++ b/wpa_supplicant/main.c
180 @@ -27,7 +27,7 @@ static void usage(void)
181 " wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
182 "[-g<global ctrl>] \\\n"
184 - " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
185 + " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>] "
186 "[-p<driver_param>] \\\n"
187 " [-b<br_ifname>] [-f<debug file>] [-e<entropy file>] "
189 @@ -72,6 +72,7 @@ static void usage(void)
190 #endif /* CONFIG_DEBUG_LINUX_TRACING */
191 printf(" -t = include timestamp in debug messages\n"
192 " -h = show this help text\n"
193 + " -H = connect to a hostapd instance to manage state changes\n"
194 " -L = show license (BSD)\n"
195 " -o = override driver parameter for new interfaces\n"
196 " -O = override ctrl_interface parameter for new interfaces\n"
197 @@ -160,7 +161,7 @@ int main(int argc, char *argv[])
200 c = getopt(argc, argv,
201 - "b:Bc:C:D:de:f:g:G:hi:I:KLNo:O:p:P:qsTtuvW");
202 + "b:Bc:C:D:de:f:g:G:hH:i:I:KLNo:O:p:P:qsTtuvW");
206 @@ -207,6 +208,9 @@ int main(int argc, char *argv[])
211 + iface->hostapd_ctrl = optarg;
214 iface->ifname = optarg;
216 --- a/wpa_supplicant/bss.h
217 +++ b/wpa_supplicant/bss.h
218 @@ -69,6 +69,8 @@ struct wpa_bss {
220 /** Length of SSID */
222 + /** HT caapbilities */
224 /** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
226 /** Beacon interval in TUs (host byte order) */