--- a/hostapd/Makefile +++ b/hostapd/Makefile @@ -168,9 +168,21 @@ OBJS += ../src/eapol_auth/eapol_auth_sm. ifdef CONFIG_UBUS CFLAGS += -DUBUS_SUPPORT -OBJS += ../src/utils/uloop.o OBJS += ../src/ap/ubus.o -LIBS += -lubox -lubus +LIBS += -lubus +NEED_ULOOP:=y +endif + +ifdef CONFIG_UCODE +CFLAGS += -DUCODE_SUPPORT +OBJS += ../src/utils/ucode.o +OBJS += ../src/ap/ucode.o +NEED_ULOOP:=y +endif + +ifdef NEED_ULOOP +OBJS += ../src/utils/uloop.o +LIBS += -lubox endif ifdef CONFIG_CODE_COVERAGE --- a/hostapd/main.c +++ b/hostapd/main.c @@ -991,6 +991,7 @@ int main(int argc, char *argv[]) } hostapd_global_ctrl_iface_init(&interfaces); + hostapd_ucode_init(&interfaces); if (hostapd_global_run(&interfaces, daemonize, pid_file)) { wpa_printf(MSG_ERROR, "Failed to start eloop"); @@ -1000,6 +1001,7 @@ int main(int argc, char *argv[]) ret = 0; out: + hostapd_ucode_free(); hostapd_global_ctrl_iface_deinit(&interfaces); /* Deinitialize all interfaces */ for (i = 0; i < interfaces.count; i++) { --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -19,6 +19,7 @@ #include "ap_config.h" #include "drivers/driver.h" #include "ubus.h" +#include "ucode.h" #define OCE_STA_CFON_ENABLED(hapd) \ ((hapd->conf->oce & OCE_STA_CFON) && \ @@ -51,6 +52,10 @@ struct hapd_interfaces { struct hostapd_config * (*config_read_cb)(const char *config_fname); int (*ctrl_iface_init)(struct hostapd_data *hapd); void (*ctrl_iface_deinit)(struct hostapd_data *hapd); + int (*ctrl_iface_recv)(struct hostapd_data *hapd, + char *buf, char *reply, int reply_size, + struct sockaddr_storage *from, + socklen_t fromlen); int (*for_each_interface)(struct hapd_interfaces *interfaces, int (*cb)(struct hostapd_iface *iface, void *ctx), void *ctx); @@ -186,6 +191,7 @@ struct hostapd_data { struct hostapd_config *iconf; struct hostapd_bss_config *conf; struct hostapd_ubus_bss ubus; + struct hostapd_ucode_bss ucode; int interface_added; /* virtual interface added for this BSS */ unsigned int started:1; unsigned int disabled:1; @@ -506,6 +512,7 @@ struct hostapd_sta_info { */ struct hostapd_iface { struct hapd_interfaces *interfaces; + struct hostapd_ucode_iface ucode; void *owner; char *config_fname; struct hostapd_config *conf; --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -276,6 +276,8 @@ int hostapd_reload_config(struct hostapd size_t j; int i; + hostapd_ucode_reload_bss(hapd, reconf); + if (iface->config_fname == NULL) { /* Only in-memory config in use - assume it has been updated */ hostapd_clear_old(iface); @@ -455,6 +457,7 @@ void hostapd_free_hapd_data(struct hosta hapd->beacon_set_done = 0; wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface); + hostapd_ucode_free_bss(hapd); hostapd_ubus_free_bss(hapd); accounting_deinit(hapd); hostapd_deinit_wpa(hapd); @@ -619,6 +622,7 @@ void hostapd_cleanup_iface_partial(struc static void hostapd_cleanup_iface(struct hostapd_iface *iface) { wpa_printf(MSG_DEBUG, "%s(%p)", __func__, iface); + hostapd_ucode_free_iface(iface); eloop_cancel_timeout(channel_list_update_timeout, iface, NULL); eloop_cancel_timeout(hostapd_interface_setup_failure_handler, iface, NULL); @@ -1209,6 +1213,7 @@ static int hostapd_start_beacon(struct h hapd->driver->set_operstate(hapd->drv_priv, 1); hostapd_ubus_add_bss(hapd); + hostapd_ucode_add_bss(hapd); return 0; } --- a/wpa_supplicant/Makefile +++ b/wpa_supplicant/Makefile @@ -197,8 +197,20 @@ endif ifdef CONFIG_UBUS CFLAGS += -DUBUS_SUPPORT OBJS += ubus.o +LIBS += -lubus +NEED_ULOOP:=y +endif + +ifdef CONFIG_UCODE +CFLAGS += -DUCODE_SUPPORT +OBJS += ../src/utils/ucode.o +OBJS += ucode.o +NEED_ULOOP:=y +endif + +ifdef NEED_ULOOP OBJS += ../src/utils/uloop.o -LIBS += -lubox -lubus +LIBS += -lubox endif ifdef CONFIG_CODE_COVERAGE @@ -999,6 +1011,9 @@ OBJS += ../src/ap/ctrl_iface_ap.o ifdef CONFIG_UBUS OBJS += ../src/ap/ubus.o endif +ifdef CONFIG_UCODE +OBJS += ../src/ap/ucode.o +endif endif CFLAGS += -DEAP_SERVER -DEAP_SERVER_IDENTITY --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -7636,6 +7636,7 @@ struct wpa_supplicant * wpa_supplicant_a #endif /* CONFIG_P2P */ wpas_ubus_add_bss(wpa_s); + wpas_ucode_add_bss(wpa_s); return wpa_s; } @@ -7663,6 +7664,7 @@ int wpa_supplicant_remove_iface(struct w struct wpa_supplicant *parent = wpa_s->parent; #endif /* CONFIG_MESH */ + wpas_ucode_free_bss(wpa_s); wpas_ubus_free_bss(wpa_s); /* Remove interface from the global list of interfaces */ @@ -7973,6 +7975,7 @@ struct wpa_global * wpa_supplicant_init( eloop_register_timeout(WPA_SUPPLICANT_CLEANUP_INTERVAL, 0, wpas_periodic, global, NULL); + wpas_ucode_init(global); return global; } @@ -8011,12 +8014,8 @@ int wpa_supplicant_run(struct wpa_global eloop_register_signal_terminate(wpa_supplicant_terminate, global); eloop_register_signal_reconfig(wpa_supplicant_reconfig, global); - wpas_ubus_add(global); - eloop_run(); - wpas_ubus_free(global); - return 0; } @@ -8049,6 +8048,8 @@ void wpa_supplicant_deinit(struct wpa_gl wpas_notify_supplicant_deinitialized(global); + wpas_ucode_free(); + eap_peer_unregister_methods(); #ifdef CONFIG_AP eap_server_unregister_methods(); --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -22,6 +22,7 @@ #include "wmm_ac.h" #include "pasn/pasn_common.h" #include "ubus.h" +#include "ucode.h" extern const char *const wpa_supplicant_version; extern const char *const wpa_supplicant_license; @@ -659,6 +660,7 @@ struct wpa_supplicant { unsigned char perm_addr[ETH_ALEN]; char ifname[100]; struct wpas_ubus_bss ubus; + struct wpas_ucode_bss ucode; #ifdef CONFIG_MATCH_IFACE int matched; #endif /* CONFIG_MATCH_IFACE */ --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -4921,6 +4921,7 @@ try_again: return -1; } + interface->ctrl_iface_recv = hostapd_ctrl_iface_receive_process; wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb); return 0; @@ -5022,6 +5023,7 @@ fail: os_free(fname); interface->global_ctrl_sock = s; + interface->ctrl_iface_recv = hostapd_ctrl_iface_receive_process; eloop_register_read_sock(s, hostapd_global_ctrl_iface_receive, interface, NULL);