uci: update to latest version, fixes return code of the cli on various failures
[openwrt.git] / package / hostapd / patches / 453-ap_sta_support.patch
1 --- a/wpa_supplicant/wpa_supplicant_i.h
2 +++ b/wpa_supplicant/wpa_supplicant_i.h
3 @@ -95,6 +95,8 @@ struct wpa_interface {
4 * receiving of EAPOL frames from an additional interface.
5 */
6 const char *bridge_ifname;
7 +
8 + const char *hostapd_ctrl;
9 };
10
11 /**
12 @@ -263,6 +265,8 @@ struct wpa_supplicant {
13 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
14 char bridge_ifname[16];
15
16 + struct wpa_ctrl *hostapd;
17 +
18 char *confname;
19 struct wpa_config *conf;
20 int countermeasures;
21 --- a/wpa_supplicant/Makefile
22 +++ b/wpa_supplicant/Makefile
23 @@ -13,6 +13,10 @@ PKG_CONFIG ?= pkg-config
24 CFLAGS += -I../src
25 CFLAGS += -I../src/utils
26
27 +ifdef MULTICALL
28 +CFLAGS += -DMULTICALL
29 +endif
30 +
31 -include .config
32 -include $(if $(MULTICALL),../hostapd/.config)
33
34 @@ -71,6 +75,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
37
38 +ifdef MULTICALL
39 +OBJS += ../src/common/wpa_ctrl.o
40 +endif
41 +
42 ifndef CONFIG_OS
43 ifdef CONFIG_NATIVE_WINDOWS
44 CONFIG_OS=win32
45 --- a/wpa_supplicant/wpa_supplicant.c
46 +++ b/wpa_supplicant/wpa_supplicant.c
47 @@ -103,6 +103,55 @@ extern int wpa_debug_show_keys;
48 extern int wpa_debug_timestamp;
49 extern struct wpa_driver_ops *wpa_drivers[];
50
51 +#ifdef MULTICALL
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 + int channel, hw_mode;
71 + int ret;
72 +
73 + if (!bss)
74 + return;
75 +
76 + if (bss->freq < 4000) {
77 + hw_mode = HOSTAPD_MODE_IEEE80211G;
78 + channel = (bss->freq - 2407) / 5;
79 + } else {
80 + hw_mode = HOSTAPD_MODE_IEEE80211A;
81 + channel = (bss->freq - 5000) / 5;
82 + }
83 +
84 + if (asprintf(&cmd, "RELOAD channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
85 + channel, hw_mode, !!bss->ht_capab) < 0) {
86 + return -1;
87 + }
88 +
89 + ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
90 + free(cmd);
91 +
92 + if (ret < 0) {
93 + wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n");
94 + return -1;
95 + }
96 + return 0;
97 +}
98 +#endif
99 +
100 /* Configure default/group WEP keys for static WEP */
101 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
102 {
103 @@ -607,8 +656,16 @@ void wpa_supplicant_set_state(struct wpa
104 #ifdef CONFIG_P2P
105 wpas_p2p_completed(wpa_s);
106 #endif /* CONFIG_P2P */
107 +#ifdef MULTICALL
108 + if (wpa_s->hostapd)
109 + hostapd_reload(wpa_s, wpa_s->current_bss);
110 +#endif
111 } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING ||
112 state == WPA_ASSOCIATED) {
113 +#ifdef MULTICALL
114 + if (wpa_s->hostapd)
115 + hostapd_stop(wpa_s);
116 +#endif
117 wpa_s->new_connection = 1;
118 wpa_drv_set_operstate(wpa_s, 0);
119 #ifndef IEEE8021X_EAPOL
120 @@ -2498,6 +2555,21 @@ static int wpa_supplicant_init_iface(str
121 os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
122 sizeof(wpa_s->bridge_ifname));
123 }
124 +#ifdef MULTICALL
125 + if (iface->hostapd_ctrl) {
126 + char *cmd = "DOWN";
127 + char buf[256];
128 + int len = sizeof(buf);
129 +
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");
133 + return -1;
134 + }
135 + if (hostapd_stop(wpa_s) < 0)
136 + return -1;
137 + }
138 +#endif
139
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
144 @@ -11,6 +11,7 @@
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"
151 #include "config.h"
152 @@ -75,6 +76,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_
153
154 static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src)
155 {
156 + struct ieee80211_ht_capabilities *capab;
157 + struct ieee802_11_elems elems;
158 os_time_t usec;
159
160 dst->flags = src->flags;
161 @@ -87,6 +90,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 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 @@ -51,6 +51,7 @@ struct wpa_bss {
177 unsigned int flags;
178 u8 bssid[ETH_ALEN];
179 u8 ssid[32];
180 + u16 ht_capab;
181 size_t ssid_len;
182 int freq;
183 u16 beacon_int;
184 --- a/wpa_supplicant/main.c
185 +++ b/wpa_supplicant/main.c
186 @@ -25,7 +25,7 @@ static void usage(void)
187 "usage:\n"
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>] "
194 "\\\n"
195 @@ -63,6 +63,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 (BSD)\n"
201 " -o = override driver parameter for new interfaces\n"
202 " -O = override ctrl_interface parameter for new interfaces\n"
203 @@ -139,7 +140,7 @@ int main(int argc, char *argv[])
204 wpa_supplicant_fd_workaround();
205
206 for (;;) {
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");
209 if (c < 0)
210 break;
211 switch (c) {
212 @@ -183,6 +184,9 @@ int main(int argc, char *argv[])
213 usage();
214 exitcode = 0;
215 goto out;
216 + case 'H':
217 + iface->hostapd_ctrl = optarg;
218 + break;
219 case 'i':
220 iface->ifname = optarg;
221 break;
This page took 0.052491 seconds and 5 git commands to generate.