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,48 @@ 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 + enum hostapd_hw_mode hw_mode;
80 + hw_mode = ieee80211_freq_to_chan(bss->freq, &channel);
81 + if (asprintf(&cmd, "UPDATE channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
82 + channel, hw_mode, !!bss->ht_capab) < 0)
85 + ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
89 + wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
96 /* Configure default/group WEP keys for static WEP */
97 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
99 @@ -675,8 +717,16 @@ void wpa_supplicant_set_state(struct wpa
100 #endif /* CONFIG_P2P */
102 sme_sched_obss_scan(wpa_s, 1);
104 + if (wpa_s->hostapd)
105 + hostapd_reload(wpa_s, wpa_s->current_bss);
107 } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
108 state == WPA_ASSOCIATED) {
110 + if (wpa_s->hostapd)
111 + hostapd_stop(wpa_s);
113 wpa_s->new_connection = 1;
114 wpa_drv_set_operstate(wpa_s, 0);
115 #ifndef IEEE8021X_EAPOL
116 @@ -2866,6 +2916,21 @@ static int wpa_supplicant_init_iface(str
117 os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
118 sizeof(wpa_s->bridge_ifname));
121 + if (iface->hostapd_ctrl) {
122 + char *cmd = "DOWN";
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)
136 /* RSNA Supplicant Key Management - INITIALIZE */
137 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
138 --- a/wpa_supplicant/bss.c
139 +++ b/wpa_supplicant/bss.c
141 #include "utils/common.h"
142 #include "utils/eloop.h"
143 #include "common/ieee802_11_defs.h"
144 +#include "common/ieee802_11_common.h"
145 #include "drivers/driver.h"
146 #include "wpa_supplicant_i.h"
148 @@ -245,6 +246,9 @@ static void calculate_update_time(const
149 static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
150 struct os_time *fetch_time)
152 + struct ieee80211_ht_capabilities *capab;
153 + struct ieee802_11_elems elems;
155 dst->flags = src->flags;
156 os_memcpy(dst->bssid, src->bssid, ETH_ALEN);
157 dst->freq = src->freq;
158 @@ -255,6 +259,12 @@ static void wpa_bss_copy_res(struct wpa_
159 dst->level = src->level;
162 + memset(&elems, 0, sizeof(elems));
163 + ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0);
164 + capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities;
166 + dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
168 calculate_update_time(fetch_time, src->age, &dst->last_update);
171 --- a/wpa_supplicant/main.c
172 +++ b/wpa_supplicant/main.c
173 @@ -27,7 +27,7 @@ static void usage(void)
174 " wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
175 "[-g<global ctrl>] \\\n"
177 - " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
178 + " -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-H<hostapd path>] "
179 "[-p<driver_param>] \\\n"
180 " [-b<br_ifname>] [-f<debug file>] [-e<entropy file>] "
182 @@ -72,6 +72,7 @@ static void usage(void)
183 #endif /* CONFIG_DEBUG_LINUX_TRACING */
184 printf(" -t = include timestamp in debug messages\n"
185 " -h = show this help text\n"
186 + " -H = connect to a hostapd instance to manage state changes\n"
187 " -L = show license (BSD)\n"
188 " -o = override driver parameter for new interfaces\n"
189 " -O = override ctrl_interface parameter for new interfaces\n"
190 @@ -160,7 +161,7 @@ int main(int argc, char *argv[])
193 c = getopt(argc, argv,
194 - "b:Bc:C:D:de:f:g:G:hi:I:KLNo:O:p:P:qsTtuvW");
195 + "b:Bc:C:D:de:f:g:G:hH:i:I:KLNo:O:p:P:qsTtuvW");
199 @@ -207,6 +208,9 @@ int main(int argc, char *argv[])
204 + iface->hostapd_ctrl = optarg;
207 iface->ifname = optarg;
209 --- a/wpa_supplicant/bss.h
210 +++ b/wpa_supplicant/bss.h
211 @@ -69,6 +69,8 @@ struct wpa_bss {
213 /** Length of SSID */
215 + /** HT caapbilities */
217 /** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
219 /** Beacon interval in TUs (host byte order) */