1 --- a/wpa_supplicant/wpa_supplicant_i.h
2 +++ b/wpa_supplicant/wpa_supplicant_i.h
3 @@ -100,6 +100,8 @@ struct wpa_interface {
4 * receiving of EAPOL frames from an additional interface.
6 const char *bridge_ifname;
8 + const char *hostapd_ctrl;
12 @@ -260,6 +262,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 @@ -69,6 +73,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 @@ -125,6 +125,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, "RELOAD 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 @@ -632,8 +681,16 @@ void wpa_supplicant_set_state(struct wpa
105 wpas_p2p_completed(wpa_s);
106 #endif /* CONFIG_P2P */
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 @@ -2245,6 +2302,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 @@ -79,6 +80,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_
154 static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src)
156 + struct ieee80211_ht_capabilities *capab;
157 + struct ieee802_11_elems elems;
160 dst->flags = src->flags;
161 @@ -91,6 +94,12 @@ static void wpa_bss_copy_res(struct wpa_
162 dst->level = src->level;
165 + memset(&elems, 0, sizeof(elems));
166 + ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
167 + capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
169 + dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
171 os_get_time(&dst->last_update);
172 dst->last_update.sec -= src->age / 1000;
173 usec = (src->age % 1000) * 1000;
174 --- a/wpa_supplicant/bss.h
175 +++ b/wpa_supplicant/bss.h
176 @@ -57,6 +57,7 @@ struct wpa_bss {
184 --- a/wpa_supplicant/main.c
185 +++ b/wpa_supplicant/main.c
186 @@ -31,7 +31,7 @@ static void usage(void)
188 " wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
189 "[-g<global ctrl>] \\\n"
190 - " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
191 + " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>]"
192 "[-p<driver_param>] \\\n"
193 " [-b<br_ifname>] [-f<debug file>] [-e<entropy file>] "
195 @@ -69,6 +69,7 @@ static void usage(void)
196 #endif /* CONFIG_DEBUG_SYSLOG */
197 printf(" -t = include timestamp in debug messages\n"
198 " -h = show this help text\n"
199 + " -H = connect to a hostapd instance to manage state changes\n"
200 " -L = show license (GPL and BSD)\n"
201 " -o = override driver parameter for new interfaces\n"
202 " -O = override ctrl_interface parameter for new interfaces\n"
203 @@ -145,7 +146,7 @@ int main(int argc, char *argv[])
204 wpa_supplicant_fd_workaround();
207 - c = getopt(argc, argv, "b:Bc:C:D:de:f:g:hi:KLNo:O:p:P:qstuvW");
208 + c = getopt(argc, argv, "b:Bc:C:D:de:f:g:hH:i:KLNo:O:p:P:qstuvW");
212 @@ -189,6 +190,9 @@ int main(int argc, char *argv[])
217 + iface->hostapd_ctrl = optarg;
220 iface->ifname = optarg;