hostapd: update to version 2014-04-04
[openwrt/staging/dedeckeh.git] / package / network / services / hostapd / patches / 370-ap_sta_support.patch
1 --- a/wpa_supplicant/wpa_supplicant_i.h
2 +++ b/wpa_supplicant/wpa_supplicant_i.h
3 @@ -108,6 +108,11 @@ struct wpa_interface {
4 const char *ifname;
5
6 /**
7 + * hostapd_ctrl - path to hostapd control socket for notification
8 + */
9 + const char *hostapd_ctrl;
10 +
11 + /**
12 * bridge_ifname - Optional bridge interface name
13 *
14 * If the driver interface (ifname) is included in a Linux bridge
15 @@ -395,6 +400,8 @@ struct wpa_supplicant {
16 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
17 char bridge_ifname[16];
18
19 + struct wpa_ctrl *hostapd;
20 +
21 char *confname;
22 char *confanother;
23
24 --- a/wpa_supplicant/Makefile
25 +++ b/wpa_supplicant/Makefile
26 @@ -13,6 +13,10 @@ PKG_CONFIG ?= pkg-config
27 CFLAGS += -I$(abspath ../src)
28 CFLAGS += -I$(abspath ../src/utils)
29
30 +ifdef MULTICALL
31 +CFLAGS += -DMULTICALL
32 +endif
33 +
34 -include .config
35 -include $(if $(MULTICALL),../hostapd/.config)
36
37 @@ -82,6 +86,8 @@ OBJS_c = wpa_cli.o ../src/common/wpa_ctr
38 OBJS_c += ../src/utils/wpa_debug.o
39 OBJS_c += ../src/utils/common.o
40
41 +OBJS += ../src/common/wpa_ctrl.o
42 +
43 ifndef CONFIG_OS
44 ifdef CONFIG_NATIVE_WINDOWS
45 CONFIG_OS=win32
46 --- a/wpa_supplicant/wpa_supplicant.c
47 +++ b/wpa_supplicant/wpa_supplicant.c
48 @@ -104,6 +104,46 @@ const char *wpa_supplicant_full_license5
49 "\n";
50 #endif /* CONFIG_NO_STDOUT_DEBUG */
51
52 +static int hostapd_stop(struct wpa_supplicant *wpa_s)
53 +{
54 + const char *cmd = "DOWN";
55 + char buf[256];
56 + int len = sizeof(buf);
57 +
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");
60 + return -1;
61 + }
62 + return 0;
63 +}
64 +
65 +static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
66 +{
67 + char *cmd = NULL;
68 + char buf[256];
69 + int len = sizeof(buf);
70 + enum hostapd_hw_mode hw_mode;
71 + u8 channel;
72 + int ret;
73 +
74 + if (!bss)
75 + return;
76 +
77 + hw_mode = ieee80211_freq_to_chan(bss->freq, &channel);
78 + if (asprintf(&cmd, "UPDATE channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
79 + channel, hw_mode, !!bss->ht_capab) < 0)
80 + return -1;
81 +
82 + ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
83 + free(cmd);
84 +
85 + if (ret < 0) {
86 + wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
87 + return -1;
88 + }
89 + return 0;
90 +}
91 +
92 /* Configure default/group WEP keys for static WEP */
93 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
94 {
95 @@ -702,8 +742,12 @@ void wpa_supplicant_set_state(struct wpa
96 #endif /* CONFIG_P2P */
97
98 sme_sched_obss_scan(wpa_s, 1);
99 + if (wpa_s->hostapd)
100 + hostapd_reload(wpa_s, wpa_s->current_bss);
101 } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
102 state == WPA_ASSOCIATED) {
103 + if (wpa_s->hostapd)
104 + hostapd_stop(wpa_s);
105 wpa_s->new_connection = 1;
106 wpa_drv_set_operstate(wpa_s, 0);
107 #ifndef IEEE8021X_EAPOL
108 @@ -3505,6 +3549,20 @@ static int wpa_supplicant_init_iface(str
109 sizeof(wpa_s->bridge_ifname));
110 }
111
112 + if (iface->hostapd_ctrl) {
113 + char *cmd = "DOWN";
114 + char buf[256];
115 + int len = sizeof(buf);
116 +
117 + wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl);
118 + if (!wpa_s->hostapd) {
119 + wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n");
120 + return -1;
121 + }
122 + if (hostapd_stop(wpa_s) < 0)
123 + return -1;
124 + }
125 +
126 /* RSNA Supplicant Key Management - INITIALIZE */
127 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
128 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
129 @@ -3698,6 +3756,11 @@ static void wpa_supplicant_deinit_iface(
130 if (terminate)
131 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING);
132
133 + if (wpa_s->hostapd) {
134 + wpa_ctrl_close(wpa_s->hostapd);
135 + wpa_s->hostapd = NULL;
136 + }
137 +
138 if (wpa_s->ctrl_iface) {
139 wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
140 wpa_s->ctrl_iface = NULL;
141 --- a/wpa_supplicant/bss.c
142 +++ b/wpa_supplicant/bss.c
143 @@ -11,6 +11,7 @@
144 #include "utils/common.h"
145 #include "utils/eloop.h"
146 #include "common/ieee802_11_defs.h"
147 +#include "common/ieee802_11_common.h"
148 #include "drivers/driver.h"
149 #include "wpa_supplicant_i.h"
150 #include "config.h"
151 @@ -247,6 +248,9 @@ static void calculate_update_time(const
152 static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
153 struct os_reltime *fetch_time)
154 {
155 + struct ieee80211_ht_capabilities *capab;
156 + struct ieee802_11_elems elems;
157 +
158 dst->flags = src->flags;
159 os_memcpy(dst->bssid, src->bssid, ETH_ALEN);
160 dst->freq = src->freq;
161 @@ -257,6 +261,12 @@ static void wpa_bss_copy_res(struct wpa_
162 dst->level = src->level;
163 dst->tsf = src->tsf;
164
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;
168 + if (capab)
169 + dst->ht_capab = le_to_host16(capab->ht_capabilities_info);
170 +
171 calculate_update_time(fetch_time, src->age, &dst->last_update);
172 }
173
174 --- a/wpa_supplicant/main.c
175 +++ b/wpa_supplicant/main.c
176 @@ -33,7 +33,7 @@ static void usage(void)
177 "vW] [-P<pid file>] "
178 "[-g<global ctrl>] \\\n"
179 " [-G<group>] \\\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>] [-e<entropy file>]"
184 #ifdef CONFIG_DEBUG_FILE
185 @@ -84,6 +84,7 @@ static void usage(void)
186 #endif /* CONFIG_DEBUG_LINUX_TRACING */
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 (BSD)\n"
191 " -o = override driver parameter for new interfaces\n"
192 " -O = override ctrl_interface parameter for new interfaces\n"
193 @@ -175,7 +176,7 @@ int main(int argc, char *argv[])
194
195 for (;;) {
196 c = getopt(argc, argv,
197 - "b:Bc:C:D:de:f:g:G:hi:I:KLm:No:O:p:P:qsTtuvW");
198 + "b:Bc:C:D:de:f:g:G:hH:i:I:KLm:No:O:p:P:qsTtuvW");
199 if (c < 0)
200 break;
201 switch (c) {
202 @@ -222,6 +223,9 @@ int main(int argc, char *argv[])
203 usage();
204 exitcode = 0;
205 goto out;
206 + case 'H':
207 + iface->hostapd_ctrl = optarg;
208 + break;
209 case 'i':
210 iface->ifname = optarg;
211 break;
212 --- a/wpa_supplicant/bss.h
213 +++ b/wpa_supplicant/bss.h
214 @@ -70,6 +70,8 @@ struct wpa_bss {
215 u8 ssid[32];
216 /** Length of SSID */
217 size_t ssid_len;
218 + /** HT caapbilities */
219 + u16 ht_capab;
220 /** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
221 int freq;
222 /** Beacon interval in TUs (host byte order) */