3 @@ -168,9 +168,21 @@ OBJS += ../src/eapol_auth/eapol_auth_sm.
6 CFLAGS += -DUBUS_SUPPORT
7 -OBJS += ../src/utils/uloop.o
8 OBJS += ../src/ap/ubus.o
15 +CFLAGS += -DUCODE_SUPPORT
16 +OBJS += ../src/utils/ucode.o
17 +OBJS += ../src/ap/ucode.o
22 +OBJS += ../src/utils/uloop.o
26 ifdef CONFIG_CODE_COVERAGE
29 @@ -1007,6 +1007,7 @@ int main(int argc, char *argv[])
32 hostapd_global_ctrl_iface_init(&interfaces);
33 + hostapd_ucode_init(&interfaces);
35 if (hostapd_global_run(&interfaces, daemonize, pid_file)) {
36 wpa_printf(MSG_ERROR, "Failed to start eloop");
37 @@ -1016,6 +1017,7 @@ int main(int argc, char *argv[])
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
48 #include "ap_config.h"
49 #include "drivers/driver.h"
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,
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 {
76 struct hostapd_iface {
77 struct hapd_interfaces *interfaces;
78 + struct hostapd_ucode_iface ucode;
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,
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;
97 + hostapd_ucode_reload_bss(hapd);
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;
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)
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,
118 @@ -1189,6 +1193,7 @@ static int hostapd_start_beacon(struct h
119 hapd->driver->set_operstate(hapd->drv_priv, 1);
121 hostapd_ubus_add_bss(hapd);
122 + hostapd_ucode_add_bss(hapd);
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().
130 -static int hostapd_setup_bss(struct hostapd_data *hapd, int first,
132 +int hostapd_setup_bss(struct hostapd_data *hapd, int first, bool start_beacon)
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
140 -static void hostapd_bss_deinit(struct hostapd_data *hapd)
141 +void hostapd_bss_deinit(struct hostapd_data *hapd)
145 --- a/wpa_supplicant/Makefile
146 +++ b/wpa_supplicant/Makefile
147 @@ -195,8 +195,20 @@ endif
149 CFLAGS += -DUBUS_SUPPORT
156 +CFLAGS += -DUCODE_SUPPORT
157 +OBJS += ../src/utils/ucode.o
163 OBJS += ../src/utils/uloop.o
164 -LIBS += -lubox -lubus
168 ifdef CONFIG_CODE_COVERAGE
169 @@ -997,6 +1009,9 @@ OBJS += ../src/ap/ctrl_iface_ap.o
171 OBJS += ../src/ap/ubus.o
174 +OBJS += ../src/ap/ucode.o
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);
184 wpa_s->wpa_state = state;
185 + wpas_ucode_update_state(wpa_s);
188 if (state == WPA_COMPLETED && wpa_s->current_ssid != wpa_s->bgscan_ssid)
189 @@ -7594,6 +7595,7 @@ struct wpa_supplicant * wpa_supplicant_a
190 #endif /* CONFIG_P2P */
192 wpas_ubus_add_bss(wpa_s);
193 + wpas_ucode_add_bss(wpa_s);
197 @@ -7621,6 +7623,7 @@ int wpa_supplicant_remove_iface(struct w
198 struct wpa_supplicant *parent = wpa_s->parent;
199 #endif /* CONFIG_MESH */
201 + wpas_ucode_free_bss(wpa_s);
202 wpas_ubus_free_bss(wpa_s);
204 /* Remove interface from the global list of interfaces */
205 @@ -7931,6 +7934,7 @@ struct wpa_global * wpa_supplicant_init(
207 eloop_register_timeout(WPA_SUPPLICANT_CLEANUP_INTERVAL, 0,
208 wpas_periodic, global, NULL);
209 + wpas_ucode_init(global);
213 @@ -7969,12 +7973,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);
217 - wpas_ubus_add(global);
221 - wpas_ubus_free(global);
226 @@ -8007,6 +8007,8 @@ void wpa_supplicant_deinit(struct wpa_gl
228 wpas_notify_supplicant_deinitialized(global);
232 eap_peer_unregister_methods();
234 eap_server_unregister_methods();
235 --- a/wpa_supplicant/wpa_supplicant_i.h
236 +++ b/wpa_supplicant/wpa_supplicant_i.h
239 #include "pasn/pasn_common.h"
243 extern const char *const wpa_supplicant_version;
244 extern const char *const wpa_supplicant_license;
245 @@ -689,6 +690,7 @@ struct wpa_supplicant {
246 unsigned char perm_addr[ETH_ALEN];
248 struct wpas_ubus_bss ubus;
249 + struct wpas_ucode_bss ucode;
250 #ifdef CONFIG_MATCH_IFACE
252 #endif /* CONFIG_MATCH_IFACE */
253 --- a/hostapd/ctrl_iface.c
254 +++ b/hostapd/ctrl_iface.c
255 @@ -4856,6 +4856,7 @@ try_again:
259 + interface->ctrl_iface_recv = hostapd_ctrl_iface_receive_process;
260 wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb);
263 @@ -4957,6 +4958,7 @@ fail:
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,
271 --- a/src/drivers/driver.h
272 +++ b/src/drivers/driver.h
273 @@ -3787,6 +3787,25 @@ struct wpa_driver_ops {
277 + * if_rename - Rename a virtual interface
278 + * @priv: Private driver interface data
279 + * @type: Interface type
280 + * @ifname: Interface name of the virtual interface to be renamed
281 + * (NULL when renaming the AP BSS interface)
282 + * @new_name: New interface name of the virtual interface
283 + * Returns: 0 on success, -1 on failure
285 + int (*if_rename)(void *priv, enum wpa_driver_if_type type,
286 + const char *ifname, const char *new_name);
289 + * set_first_bss - Make a virtual interface the first (primary) bss
290 + * @priv: Private driver interface data
291 + * Returns: 0 on success, -1 on failure
293 + int (*set_first_bss)(void *priv);
296 * set_sta_vlan - Bind a station into a specific interface (AP only)
297 * @priv: Private driver interface data
298 * @ifname: Interface (main or virtual BSS or VLAN)
299 @@ -6440,6 +6459,7 @@ union wpa_event_data {
303 + * @count: Count until channel switch activates
304 * @freq: Frequency of new channel in MHz
305 * @ht_enabled: Whether this is an HT channel
306 * @ch_offset: Secondary channel offset
307 @@ -6450,6 +6470,7 @@ union wpa_event_data {
308 * @punct_bitmap: Puncturing bitmap
315 --- a/src/drivers/driver_nl80211_event.c
316 +++ b/src/drivers/driver_nl80211_event.c
317 @@ -1202,6 +1202,7 @@ static void mlme_event_ch_switch(struct
318 struct nlattr *bw, struct nlattr *cf1,
320 struct nlattr *punct_bitmap,
321 + struct nlattr *count,
324 struct i802_bss *bss;
325 @@ -1265,6 +1266,8 @@ static void mlme_event_ch_switch(struct
326 data.ch_switch.cf1 = nla_get_u32(cf1);
328 data.ch_switch.cf2 = nla_get_u32(cf2);
330 + data.ch_switch.count = nla_get_u32(count);
333 bss->flink->freq = data.ch_switch.freq;
334 @@ -3912,6 +3915,7 @@ static void do_process_drv_event(struct
335 tb[NL80211_ATTR_CENTER_FREQ1],
336 tb[NL80211_ATTR_CENTER_FREQ2],
337 tb[NL80211_ATTR_PUNCT_BITMAP],
338 + tb[NL80211_ATTR_CH_SWITCH_COUNT],
341 case NL80211_CMD_CH_SWITCH_NOTIFY:
342 @@ -3924,6 +3928,7 @@ static void do_process_drv_event(struct
343 tb[NL80211_ATTR_CENTER_FREQ1],
344 tb[NL80211_ATTR_CENTER_FREQ2],
345 tb[NL80211_ATTR_PUNCT_BITMAP],
349 case NL80211_CMD_DISCONNECT:
350 --- a/wpa_supplicant/events.c
351 +++ b/wpa_supplicant/events.c
352 @@ -5389,6 +5389,7 @@ void supplicant_event(void *ctx, enum wp
353 event_to_string(event), event);
354 #endif /* CONFIG_NO_STDOUT_DEBUG */
356 + wpas_ucode_event(wpa_s, event, data);
360 --- a/src/ap/ap_drv_ops.h
361 +++ b/src/ap/ap_drv_ops.h
362 @@ -393,6 +393,23 @@ static inline int hostapd_drv_stop_ap(st
363 return hapd->driver->stop_ap(hapd->drv_priv);
366 +static inline int hostapd_drv_if_rename(struct hostapd_data *hapd,
367 + enum wpa_driver_if_type type,
368 + const char *ifname,
369 + const char *new_name)
371 + if (!hapd->driver || !hapd->driver->if_rename || !hapd->drv_priv)
373 + return hapd->driver->if_rename(hapd->drv_priv, type, ifname, new_name);
376 +static inline int hostapd_drv_set_first_bss(struct hostapd_data *hapd)
378 + if (!hapd->driver || !hapd->driver->set_first_bss || !hapd->drv_priv)
380 + return hapd->driver->set_first_bss(hapd->drv_priv);
383 static inline int hostapd_drv_channel_info(struct hostapd_data *hapd,
384 struct wpa_channel_info *ci)
386 --- a/src/drivers/driver_nl80211.c
387 +++ b/src/drivers/driver_nl80211.c
388 @@ -1333,7 +1333,7 @@ static void wpa_driver_nl80211_event_rtm
390 wpa_printf(MSG_DEBUG, "nl80211: Interface down (%s/%s)",
392 - if (os_strcmp(drv->first_bss->ifname, ifname) != 0) {
393 + if (drv->first_bss->ifindex != ifi->ifi_index) {
394 wpa_printf(MSG_DEBUG,
395 "nl80211: Not the main interface (%s) - do not indicate interface down",
396 drv->first_bss->ifname);
397 @@ -1369,7 +1369,7 @@ static void wpa_driver_nl80211_event_rtm
399 wpa_printf(MSG_DEBUG, "nl80211: Interface up (%s/%s)",
401 - if (os_strcmp(drv->first_bss->ifname, ifname) != 0) {
402 + if (drv->first_bss->ifindex != ifi->ifi_index) {
403 wpa_printf(MSG_DEBUG,
404 "nl80211: Not the main interface (%s) - do not indicate interface up",
405 drv->first_bss->ifname);
406 @@ -8432,6 +8432,7 @@ static void *i802_init(struct hostapd_da
407 char master_ifname[IFNAMSIZ];
408 int ifindex, br_ifindex = 0;
412 bss = wpa_driver_nl80211_drv_init(hapd, params->ifname,
413 params->global_priv, 1,
414 @@ -8491,21 +8492,17 @@ static void *i802_init(struct hostapd_da
415 (params->num_bridge == 0 || !params->bridge[0]))
416 add_ifidx(drv, br_ifindex, drv->ifindex);
418 - if (bss->added_if_into_bridge || bss->already_in_bridge) {
421 - drv->rtnl_sk = nl_socket_alloc();
422 - if (drv->rtnl_sk == NULL) {
423 - wpa_printf(MSG_ERROR, "nl80211: Failed to allocate nl_sock");
426 + drv->rtnl_sk = nl_socket_alloc();
427 + if (drv->rtnl_sk == NULL) {
428 + wpa_printf(MSG_ERROR, "nl80211: Failed to allocate nl_sock");
432 - err = nl_connect(drv->rtnl_sk, NETLINK_ROUTE);
434 - wpa_printf(MSG_ERROR, "nl80211: Failed to connect nl_sock to NETLINK_ROUTE: %s",
438 + err = nl_connect(drv->rtnl_sk, NETLINK_ROUTE);
440 + wpa_printf(MSG_ERROR, "nl80211: Failed to connect nl_sock to NETLINK_ROUTE: %s",
445 if (drv->capa.flags2 & WPA_DRIVER_FLAGS2_CONTROL_PORT_RX) {
446 @@ -8874,6 +8871,50 @@ static int wpa_driver_nl80211_if_remove(
450 +static int wpa_driver_nl80211_if_rename(struct i802_bss *bss,
451 + enum wpa_driver_if_type type,
452 + const char *ifname, const char *new_name)
454 + struct wpa_driver_nl80211_data *drv = bss->drv;
455 + struct ifinfomsg ifi = {
456 + .ifi_family = AF_UNSPEC,
457 + .ifi_index = bss->ifindex,
459 + struct nl_msg *msg;
463 + ifi.ifi_index = if_nametoindex(ifname);
465 + msg = nlmsg_alloc_simple(RTM_SETLINK, 0);
469 + if (nlmsg_append(msg, &ifi, sizeof(ifi), NLMSG_ALIGNTO) < 0)
472 + if (nla_put_string(msg, IFLA_IFNAME, new_name))
475 + res = nl_send_auto_complete(drv->rtnl_sk, msg);
479 + res = nl_wait_for_ack(drv->rtnl_sk);
481 + wpa_printf(MSG_INFO,
482 + "nl80211: Renaming device %s to %s failed: %s",
483 + ifname ? ifname : bss->ifname, new_name, nl_geterror(res));
487 + if (type == WPA_IF_AP_BSS && !ifname)
488 + os_strlcpy(bss->ifname, new_name, sizeof(bss->ifname));
495 static int cookie_handler(struct nl_msg *msg, void *arg)
497 @@ -10512,6 +10553,37 @@ static int driver_nl80211_if_remove(void
501 +static int driver_nl80211_if_rename(void *priv, enum wpa_driver_if_type type,
502 + const char *ifname, const char *new_name)
504 + struct i802_bss *bss = priv;
505 + return wpa_driver_nl80211_if_rename(bss, type, ifname, new_name);
509 +static int driver_nl80211_set_first_bss(void *priv)
511 + struct i802_bss *bss = priv, *tbss;
512 + struct wpa_driver_nl80211_data *drv = bss->drv;
514 + if (drv->first_bss == bss)
517 + for (tbss = drv->first_bss; tbss; tbss = tbss->next) {
518 + if (tbss->next != bss)
521 + tbss->next = bss->next;
522 + bss->next = drv->first_bss;
523 + drv->first_bss = bss;
524 + drv->ctx = bss->ctx;
532 static int driver_nl80211_send_mlme(void *priv, const u8 *data,
533 size_t data_len, int noack,
535 @@ -13696,6 +13768,8 @@ const struct wpa_driver_ops wpa_driver_n
536 .set_acl = wpa_driver_nl80211_set_acl,
537 .if_add = wpa_driver_nl80211_if_add,
538 .if_remove = driver_nl80211_if_remove,
539 + .if_rename = driver_nl80211_if_rename,
540 + .set_first_bss = driver_nl80211_set_first_bss,
541 .send_mlme = driver_nl80211_send_mlme,
542 .get_hw_feature_data = nl80211_get_hw_feature_data,
543 .sta_add = wpa_driver_nl80211_sta_add,