1 --- a/wpa_supplicant/wpa_supplicant_i.h
2 +++ b/wpa_supplicant/wpa_supplicant_i.h
3 @@ -99,6 +99,8 @@ struct wpa_interface {
4 * receiving of EAPOL frames from an additional interface.
6 const char *bridge_ifname;
8 + const char *hostapd_ctrl;
12 @@ -337,6 +339,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 @@ -51,6 +51,11 @@ OBJS_p += ../src/utils/wpa_debug.o
24 OBJS_p += ../src/utils/wpabuf.o
25 OBJS_c = wpa_cli.o ../src/common/wpa_ctrl.o
28 +OBJS += ../src/common/wpa_ctrl.o
29 +CFLAGS += -DMULTICALL
33 -include $(if $(MULTICALL),../hostapd/.config)
35 --- a/wpa_supplicant/wpa_supplicant.c
36 +++ b/wpa_supplicant/wpa_supplicant.c
37 @@ -122,6 +122,55 @@ extern int wpa_debug_show_keys;
38 extern int wpa_debug_timestamp;
39 extern struct wpa_driver_ops *wpa_drivers[];
42 +static int hostapd_stop(struct wpa_supplicant *wpa_s)
44 + const char *cmd = "DOWN";
46 + int len = sizeof(buf);
48 + if (wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL) < 0) {
49 + wpa_printf(MSG_ERROR, "\nFailed to stop hostapd AP interfaces\n");
55 +static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
59 + int len = sizeof(buf);
60 + int channel, hw_mode;
66 + if (bss->freq < 4000) {
67 + hw_mode = HOSTAPD_MODE_IEEE80211G;
68 + channel = (bss->freq - 2407) / 5;
70 + hw_mode = HOSTAPD_MODE_IEEE80211A;
71 + channel = (bss->freq - 5000) / 5;
74 + if (asprintf(&cmd, "RELOAD channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
75 + channel, hw_mode, !!bss->ht_capab) < 0) {
79 + ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
83 + wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
90 /* Configure default/group WEP keys for static WEP */
91 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
93 @@ -557,8 +606,16 @@ void wpa_supplicant_set_state(struct wpa
95 wpas_p2p_completed(wpa_s);
96 #endif /* CONFIG_P2P */
99 + hostapd_reload(wpa_s, wpa_s->current_bss);
101 } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
102 state == WPA_ASSOCIATED) {
104 + if (wpa_s->hostapd)
105 + hostapd_stop(wpa_s);
107 wpa_s->new_connection = 1;
108 wpa_drv_set_operstate(wpa_s, 0);
109 #ifndef IEEE8021X_EAPOL
110 @@ -2033,6 +2090,21 @@ static int wpa_supplicant_init_iface(str
111 os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
112 sizeof(wpa_s->bridge_ifname));
115 + if (iface->hostapd_ctrl) {
116 + char *cmd = "DOWN";
118 + int len = sizeof(buf);
120 + wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl);
121 + if (!wpa_s->hostapd) {
122 + wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n");
125 + if (hostapd_stop(wpa_s) < 0)
130 /* RSNA Supplicant Key Management - INITIALIZE */
131 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
132 --- a/wpa_supplicant/bss.c
133 +++ b/wpa_supplicant/bss.c
135 #include "utils/common.h"
136 #include "utils/eloop.h"
137 #include "common/ieee802_11_defs.h"
138 +#include "common/ieee802_11_common.h"
139 #include "drivers/driver.h"
140 #include "wpa_supplicant_i.h"
142 @@ -89,6 +90,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_
144 static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src)
146 + struct ieee80211_ht_capabilities *capab;
147 + struct ieee802_11_elems elems;
150 dst->flags = src->flags;
151 @@ -101,6 +104,12 @@ static void wpa_bss_copy_res(struct wpa_
152 dst->level = src->level;
155 + memset(&elems, 0, sizeof(elems));
156 + ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
157 + capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
159 + dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
161 os_get_time(&dst->last_update);
162 dst->last_update.sec -= src->age / 1000;
163 usec = (src->age % 1000) * 1000;
164 --- a/wpa_supplicant/bss.h
165 +++ b/wpa_supplicant/bss.h
166 @@ -56,6 +56,7 @@ struct wpa_bss {
174 --- a/wpa_supplicant/main.c
175 +++ b/wpa_supplicant/main.c
176 @@ -31,7 +31,7 @@ static void usage(void)
178 " wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
179 "[-g<global ctrl>] \\\n"
180 - " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
181 + " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>]"
182 "[-p<driver_param>] \\\n"
183 " [-b<br_ifname>] [-f<debug file>] \\\n"
184 " [-o<override driver>] [-O<override ctrl>] \\\n"
185 @@ -67,6 +67,7 @@ static void usage(void)
186 #endif /* CONFIG_DEBUG_SYSLOG */
187 printf(" -t = include timestamp in debug messages\n"
188 " -h = show this help text\n"
189 + " -H = connect to a hostapd instance to manage state changes\n"
190 " -L = show license (GPL and BSD)\n"
191 " -o = override driver parameter for new interfaces\n"
192 " -O = override ctrl_interface parameter for new interfaces\n"
193 @@ -143,7 +144,7 @@ int main(int argc, char *argv[])
194 wpa_supplicant_fd_workaround();
197 - c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNo:O:p:P:qstuvW");
198 + c = getopt(argc, argv, "b:Bc:C:D:df:g:hH:i:KLNo:O:p:P:qstuvW");
202 @@ -184,6 +185,9 @@ int main(int argc, char *argv[])
207 + iface->hostapd_ctrl = optarg;
210 iface->ifname = optarg;