e0bbf1337da8adeadbb0ac2814468a9b3b0a64a0
[openwrt/staging/hauke.git] / package / network / services / hostapd / patches / 601-ucode_support.patch
1 --- a/hostapd/Makefile
2 +++ b/hostapd/Makefile
3 @@ -168,9 +168,21 @@ OBJS += ../src/eapol_auth/eapol_auth_sm.
4
5 ifdef CONFIG_UBUS
6 CFLAGS += -DUBUS_SUPPORT
7 -OBJS += ../src/utils/uloop.o
8 OBJS += ../src/ap/ubus.o
9 -LIBS += -lubox -lubus
10 +LIBS += -lubus
11 +NEED_ULOOP:=y
12 +endif
13 +
14 +ifdef CONFIG_UCODE
15 +CFLAGS += -DUCODE_SUPPORT
16 +OBJS += ../src/utils/ucode.o
17 +OBJS += ../src/ap/ucode.o
18 +NEED_ULOOP:=y
19 +endif
20 +
21 +ifdef NEED_ULOOP
22 +OBJS += ../src/utils/uloop.o
23 +LIBS += -lubox
24 endif
25
26 ifdef CONFIG_CODE_COVERAGE
27 --- a/hostapd/main.c
28 +++ b/hostapd/main.c
29 @@ -994,6 +994,7 @@ int main(int argc, char *argv[])
30 }
31
32 hostapd_global_ctrl_iface_init(&interfaces);
33 + hostapd_ucode_init(&interfaces);
34
35 if (hostapd_global_run(&interfaces, daemonize, pid_file)) {
36 wpa_printf(MSG_ERROR, "Failed to start eloop");
37 @@ -1003,6 +1004,7 @@ int main(int argc, char *argv[])
38 ret = 0;
39
40 out:
41 + hostapd_ucode_free();
42 hostapd_global_ctrl_iface_deinit(&interfaces);
43 /* Deinitialize all interfaces */
44 for (i = 0; i < interfaces.count; i++) {
45 --- a/src/ap/hostapd.h
46 +++ b/src/ap/hostapd.h
47 @@ -19,6 +19,7 @@
48 #include "ap_config.h"
49 #include "drivers/driver.h"
50 #include "ubus.h"
51 +#include "ucode.h"
52
53 #define OCE_STA_CFON_ENABLED(hapd) \
54 ((hapd->conf->oce & OCE_STA_CFON) && \
55 @@ -51,6 +52,10 @@ struct hapd_interfaces {
56 struct hostapd_config * (*config_read_cb)(const char *config_fname);
57 int (*ctrl_iface_init)(struct hostapd_data *hapd);
58 void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
59 + int (*ctrl_iface_recv)(struct hostapd_data *hapd,
60 + char *buf, char *reply, int reply_size,
61 + struct sockaddr_storage *from,
62 + socklen_t fromlen);
63 int (*for_each_interface)(struct hapd_interfaces *interfaces,
64 int (*cb)(struct hostapd_iface *iface,
65 void *ctx), void *ctx);
66 @@ -186,6 +191,7 @@ struct hostapd_data {
67 struct hostapd_config *iconf;
68 struct hostapd_bss_config *conf;
69 struct hostapd_ubus_bss ubus;
70 + struct hostapd_ucode_bss ucode;
71 int interface_added; /* virtual interface added for this BSS */
72 unsigned int started:1;
73 unsigned int disabled:1;
74 @@ -506,6 +512,7 @@ struct hostapd_sta_info {
75 */
76 struct hostapd_iface {
77 struct hapd_interfaces *interfaces;
78 + struct hostapd_ucode_iface ucode;
79 void *owner;
80 char *config_fname;
81 struct hostapd_config *conf;
82 @@ -706,6 +713,8 @@ struct hostapd_iface * hostapd_init(stru
83 struct hostapd_iface *
84 hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
85 const char *config_fname, int debug);
86 +int hostapd_setup_bss(struct hostapd_data *hapd, int first, bool start_beacon);
87 +void hostapd_bss_deinit(struct hostapd_data *hapd);
88 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
89 int reassoc);
90 void hostapd_interface_deinit_free(struct hostapd_iface *iface);
91 --- a/src/ap/hostapd.c
92 +++ b/src/ap/hostapd.c
93 @@ -252,6 +252,8 @@ int hostapd_reload_config(struct hostapd
94 struct hostapd_config *newconf, *oldconf;
95 size_t j;
96
97 + hostapd_ucode_reload_bss(hapd);
98 +
99 if (iface->config_fname == NULL) {
100 /* Only in-memory config in use - assume it has been updated */
101 hostapd_clear_old(iface);
102 @@ -435,6 +437,7 @@ void hostapd_free_hapd_data(struct hosta
103 hapd->beacon_set_done = 0;
104
105 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
106 + hostapd_ucode_free_bss(hapd);
107 hostapd_ubus_free_bss(hapd);
108 accounting_deinit(hapd);
109 hostapd_deinit_wpa(hapd);
110 @@ -599,6 +602,7 @@ void hostapd_cleanup_iface_partial(struc
111 static void hostapd_cleanup_iface(struct hostapd_iface *iface)
112 {
113 wpa_printf(MSG_DEBUG, "%s(%p)", __func__, iface);
114 + hostapd_ucode_free_iface(iface);
115 eloop_cancel_timeout(channel_list_update_timeout, iface, NULL);
116 eloop_cancel_timeout(hostapd_interface_setup_failure_handler, iface,
117 NULL);
118 @@ -1189,6 +1193,7 @@ static int hostapd_start_beacon(struct h
119 hapd->driver->set_operstate(hapd->drv_priv, 1);
120
121 hostapd_ubus_add_bss(hapd);
122 + hostapd_ucode_add_bss(hapd);
123
124 return 0;
125 }
126 @@ -1211,8 +1216,7 @@ static int hostapd_start_beacon(struct h
127 * initialized. Most of the modules that are initialized here will be
128 * deinitialized in hostapd_cleanup().
129 */
130 -static int hostapd_setup_bss(struct hostapd_data *hapd, int first,
131 - bool start_beacon)
132 +int hostapd_setup_bss(struct hostapd_data *hapd, int first, bool start_beacon)
133 {
134 struct hostapd_bss_config *conf = hapd->conf;
135 u8 ssid[SSID_MAX_LEN + 1];
136 @@ -2698,7 +2702,7 @@ hostapd_alloc_bss_data(struct hostapd_if
137 }
138
139
140 -static void hostapd_bss_deinit(struct hostapd_data *hapd)
141 +void hostapd_bss_deinit(struct hostapd_data *hapd)
142 {
143 if (!hapd)
144 return;
145 --- a/wpa_supplicant/Makefile
146 +++ b/wpa_supplicant/Makefile
147 @@ -195,8 +195,20 @@ endif
148 ifdef CONFIG_UBUS
149 CFLAGS += -DUBUS_SUPPORT
150 OBJS += ubus.o
151 +LIBS += -lubus
152 +NEED_ULOOP:=y
153 +endif
154 +
155 +ifdef CONFIG_UCODE
156 +CFLAGS += -DUCODE_SUPPORT
157 +OBJS += ../src/utils/ucode.o
158 +OBJS += ucode.o
159 +NEED_ULOOP:=y
160 +endif
161 +
162 +ifdef NEED_ULOOP
163 OBJS += ../src/utils/uloop.o
164 -LIBS += -lubox -lubus
165 +LIBS += -lubox
166 endif
167
168 ifdef CONFIG_CODE_COVERAGE
169 @@ -997,6 +1009,9 @@ OBJS += ../src/ap/ctrl_iface_ap.o
170 ifdef CONFIG_UBUS
171 OBJS += ../src/ap/ubus.o
172 endif
173 +ifdef CONFIG_UCODE
174 +OBJS += ../src/ap/ucode.o
175 +endif
176 endif
177
178 CFLAGS += -DEAP_SERVER -DEAP_SERVER_IDENTITY
179 --- a/wpa_supplicant/wpa_supplicant.c
180 +++ b/wpa_supplicant/wpa_supplicant.c
181 @@ -1044,6 +1044,7 @@ void wpa_supplicant_set_state(struct wpa
182 sme_sched_obss_scan(wpa_s, 0);
183 }
184 wpa_s->wpa_state = state;
185 + wpas_ucode_update_state(wpa_s);
186
187 #ifdef CONFIG_BGSCAN
188 if (state == WPA_COMPLETED && wpa_s->current_ssid != wpa_s->bgscan_ssid)
189 @@ -7567,6 +7568,7 @@ struct wpa_supplicant * wpa_supplicant_a
190 #endif /* CONFIG_P2P */
191
192 wpas_ubus_add_bss(wpa_s);
193 + wpas_ucode_add_bss(wpa_s);
194
195 return wpa_s;
196 }
197 @@ -7594,6 +7596,7 @@ int wpa_supplicant_remove_iface(struct w
198 struct wpa_supplicant *parent = wpa_s->parent;
199 #endif /* CONFIG_MESH */
200
201 + wpas_ucode_free_bss(wpa_s);
202 wpas_ubus_free_bss(wpa_s);
203
204 /* Remove interface from the global list of interfaces */
205 @@ -7904,6 +7907,7 @@ struct wpa_global * wpa_supplicant_init(
206
207 eloop_register_timeout(WPA_SUPPLICANT_CLEANUP_INTERVAL, 0,
208 wpas_periodic, global, NULL);
209 + wpas_ucode_init(global);
210
211 return global;
212 }
213 @@ -7942,12 +7946,8 @@ int wpa_supplicant_run(struct wpa_global
214 eloop_register_signal_terminate(wpa_supplicant_terminate, global);
215 eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);
216
217 - wpas_ubus_add(global);
218 -
219 eloop_run();
220
221 - wpas_ubus_free(global);
222 -
223 return 0;
224 }
225
226 @@ -7980,6 +7980,8 @@ void wpa_supplicant_deinit(struct wpa_gl
227
228 wpas_notify_supplicant_deinitialized(global);
229
230 + wpas_ucode_free();
231 +
232 eap_peer_unregister_methods();
233 #ifdef CONFIG_AP
234 eap_server_unregister_methods();
235 --- a/wpa_supplicant/wpa_supplicant_i.h
236 +++ b/wpa_supplicant/wpa_supplicant_i.h
237 @@ -22,6 +22,7 @@
238 #include "wmm_ac.h"
239 #include "pasn/pasn_common.h"
240 #include "ubus.h"
241 +#include "ucode.h"
242
243 extern const char *const wpa_supplicant_version;
244 extern const char *const wpa_supplicant_license;
245 @@ -654,6 +655,7 @@ struct wpa_supplicant {
246 unsigned char perm_addr[ETH_ALEN];
247 char ifname[100];
248 struct wpas_ubus_bss ubus;
249 + struct wpas_ucode_bss ucode;
250 #ifdef CONFIG_MATCH_IFACE
251 int matched;
252 #endif /* CONFIG_MATCH_IFACE */
253 --- a/hostapd/ctrl_iface.c
254 +++ b/hostapd/ctrl_iface.c
255 @@ -4856,6 +4856,7 @@ try_again:
256 return -1;
257 }
258
259 + interface->ctrl_iface_recv = hostapd_ctrl_iface_receive_process;
260 wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb);
261
262 return 0;
263 @@ -4957,6 +4958,7 @@ fail:
264 os_free(fname);
265
266 interface->global_ctrl_sock = s;
267 + interface->ctrl_iface_recv = hostapd_ctrl_iface_receive_process;
268 eloop_register_read_sock(s, hostapd_global_ctrl_iface_receive,
269 interface, NULL);
270
271 --- a/src/drivers/driver.h
272 +++ b/src/drivers/driver.h
273 @@ -6426,6 +6426,7 @@ union wpa_event_data {
274
275 /**
276 * struct ch_switch
277 + * @count: Count until channel switch activates
278 * @freq: Frequency of new channel in MHz
279 * @ht_enabled: Whether this is an HT channel
280 * @ch_offset: Secondary channel offset
281 @@ -6436,6 +6437,7 @@ union wpa_event_data {
282 * @punct_bitmap: Puncturing bitmap
283 */
284 struct ch_switch {
285 + int count;
286 int freq;
287 int ht_enabled;
288 int ch_offset;
289 --- a/src/drivers/driver_nl80211_event.c
290 +++ b/src/drivers/driver_nl80211_event.c
291 @@ -1202,6 +1202,7 @@ static void mlme_event_ch_switch(struct
292 struct nlattr *bw, struct nlattr *cf1,
293 struct nlattr *cf2,
294 struct nlattr *punct_bitmap,
295 + struct nlattr *count,
296 int finished)
297 {
298 struct i802_bss *bss;
299 @@ -1265,6 +1266,8 @@ static void mlme_event_ch_switch(struct
300 data.ch_switch.cf1 = nla_get_u32(cf1);
301 if (cf2)
302 data.ch_switch.cf2 = nla_get_u32(cf2);
303 + if (count)
304 + data.ch_switch.count = nla_get_u32(count);
305
306 if (finished)
307 bss->flink->freq = data.ch_switch.freq;
308 @@ -3848,6 +3851,7 @@ static void do_process_drv_event(struct
309 tb[NL80211_ATTR_CENTER_FREQ1],
310 tb[NL80211_ATTR_CENTER_FREQ2],
311 tb[NL80211_ATTR_PUNCT_BITMAP],
312 + tb[NL80211_ATTR_CH_SWITCH_COUNT],
313 0);
314 break;
315 case NL80211_CMD_CH_SWITCH_NOTIFY:
316 @@ -3860,6 +3864,7 @@ static void do_process_drv_event(struct
317 tb[NL80211_ATTR_CENTER_FREQ1],
318 tb[NL80211_ATTR_CENTER_FREQ2],
319 tb[NL80211_ATTR_PUNCT_BITMAP],
320 + NULL,
321 1);
322 break;
323 case NL80211_CMD_DISCONNECT:
324 --- a/wpa_supplicant/events.c
325 +++ b/wpa_supplicant/events.c
326 @@ -5381,6 +5381,7 @@ void supplicant_event(void *ctx, enum wp
327 event_to_string(event), event);
328 #endif /* CONFIG_NO_STDOUT_DEBUG */
329
330 + wpas_ucode_event(wpa_s, event, data);
331 switch (event) {
332 case EVENT_AUTH:
333 #ifdef CONFIG_FST