hostapd: add ucode support, use ucode for the main ubus object
[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 @@ -991,6 +991,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 @@ -1000,6 +1001,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 --- a/src/ap/hostapd.c
83 +++ b/src/ap/hostapd.c
84 @@ -276,6 +276,8 @@ int hostapd_reload_config(struct hostapd
85 size_t j;
86 int i;
87
88 + hostapd_ucode_reload_bss(hapd, reconf);
89 +
90 if (iface->config_fname == NULL) {
91 /* Only in-memory config in use - assume it has been updated */
92 hostapd_clear_old(iface);
93 @@ -455,6 +457,7 @@ void hostapd_free_hapd_data(struct hosta
94 hapd->beacon_set_done = 0;
95
96 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
97 + hostapd_ucode_free_bss(hapd);
98 hostapd_ubus_free_bss(hapd);
99 accounting_deinit(hapd);
100 hostapd_deinit_wpa(hapd);
101 @@ -619,6 +622,7 @@ void hostapd_cleanup_iface_partial(struc
102 static void hostapd_cleanup_iface(struct hostapd_iface *iface)
103 {
104 wpa_printf(MSG_DEBUG, "%s(%p)", __func__, iface);
105 + hostapd_ucode_free_iface(iface);
106 eloop_cancel_timeout(channel_list_update_timeout, iface, NULL);
107 eloop_cancel_timeout(hostapd_interface_setup_failure_handler, iface,
108 NULL);
109 @@ -1209,6 +1213,7 @@ static int hostapd_start_beacon(struct h
110 hapd->driver->set_operstate(hapd->drv_priv, 1);
111
112 hostapd_ubus_add_bss(hapd);
113 + hostapd_ucode_add_bss(hapd);
114
115 return 0;
116 }
117 --- a/wpa_supplicant/Makefile
118 +++ b/wpa_supplicant/Makefile
119 @@ -197,8 +197,20 @@ endif
120 ifdef CONFIG_UBUS
121 CFLAGS += -DUBUS_SUPPORT
122 OBJS += ubus.o
123 +LIBS += -lubus
124 +NEED_ULOOP:=y
125 +endif
126 +
127 +ifdef CONFIG_UCODE
128 +CFLAGS += -DUCODE_SUPPORT
129 +OBJS += ../src/utils/ucode.o
130 +OBJS += ucode.o
131 +NEED_ULOOP:=y
132 +endif
133 +
134 +ifdef NEED_ULOOP
135 OBJS += ../src/utils/uloop.o
136 -LIBS += -lubox -lubus
137 +LIBS += -lubox
138 endif
139
140 ifdef CONFIG_CODE_COVERAGE
141 --- a/wpa_supplicant/wpa_supplicant.c
142 +++ b/wpa_supplicant/wpa_supplicant.c
143 @@ -7636,6 +7636,7 @@ struct wpa_supplicant * wpa_supplicant_a
144 #endif /* CONFIG_P2P */
145
146 wpas_ubus_add_bss(wpa_s);
147 + wpas_ucode_add_bss(wpa_s);
148
149 return wpa_s;
150 }
151 @@ -7663,6 +7664,7 @@ int wpa_supplicant_remove_iface(struct w
152 struct wpa_supplicant *parent = wpa_s->parent;
153 #endif /* CONFIG_MESH */
154
155 + wpas_ucode_free_bss(wpa_s);
156 wpas_ubus_free_bss(wpa_s);
157
158 /* Remove interface from the global list of interfaces */
159 @@ -7973,6 +7975,7 @@ struct wpa_global * wpa_supplicant_init(
160
161 eloop_register_timeout(WPA_SUPPLICANT_CLEANUP_INTERVAL, 0,
162 wpas_periodic, global, NULL);
163 + wpas_ucode_init(global);
164
165 return global;
166 }
167 @@ -8011,12 +8014,8 @@ int wpa_supplicant_run(struct wpa_global
168 eloop_register_signal_terminate(wpa_supplicant_terminate, global);
169 eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);
170
171 - wpas_ubus_add(global);
172 -
173 eloop_run();
174
175 - wpas_ubus_free(global);
176 -
177 return 0;
178 }
179
180 @@ -8049,6 +8048,8 @@ void wpa_supplicant_deinit(struct wpa_gl
181
182 wpas_notify_supplicant_deinitialized(global);
183
184 + wpas_ucode_free();
185 +
186 eap_peer_unregister_methods();
187 #ifdef CONFIG_AP
188 eap_server_unregister_methods();
189 --- a/wpa_supplicant/wpa_supplicant_i.h
190 +++ b/wpa_supplicant/wpa_supplicant_i.h
191 @@ -22,6 +22,7 @@
192 #include "wmm_ac.h"
193 #include "pasn/pasn_common.h"
194 #include "ubus.h"
195 +#include "ucode.h"
196
197 extern const char *const wpa_supplicant_version;
198 extern const char *const wpa_supplicant_license;
199 @@ -659,6 +660,7 @@ struct wpa_supplicant {
200 unsigned char perm_addr[ETH_ALEN];
201 char ifname[100];
202 struct wpas_ubus_bss ubus;
203 + struct wpas_ucode_bss ucode;
204 #ifdef CONFIG_MATCH_IFACE
205 int matched;
206 #endif /* CONFIG_MATCH_IFACE */
207 --- a/hostapd/ctrl_iface.c
208 +++ b/hostapd/ctrl_iface.c
209 @@ -4921,6 +4921,7 @@ try_again:
210 return -1;
211 }
212
213 + interface->ctrl_iface_recv = hostapd_ctrl_iface_receive_process;
214 wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb);
215
216 return 0;
217 @@ -5022,6 +5023,7 @@ fail:
218 os_free(fname);
219
220 interface->global_ctrl_sock = s;
221 + interface->ctrl_iface_recv = hostapd_ctrl_iface_receive_process;
222 eloop_register_read_sock(s, hostapd_global_ctrl_iface_receive,
223 interface, NULL);
224