hostapd: improve ucode bss notifications

Reduce code duplication, add extra callback for bss create

Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau 2024-07-17 18:33:43 +02:00
parent 3727731e6a
commit 127078567b
7 changed files with 41 additions and 34 deletions

View File

@ -889,13 +889,13 @@ return {
hostapd.udebug_set(null); hostapd.udebug_set(null);
hostapd.ubus.disconnect(); hostapd.ubus.disconnect();
}, },
bss_add: function(name, obj) { bss_add: function(phy, name, obj) {
bss_event("add", name); bss_event("add", name);
}, },
bss_reload: function(name, obj, reconf) { bss_reload: function(phy, name, obj, reconf) {
bss_event("reload", name, { reconf: reconf != 0 }); bss_event("reload", name, { reconf: reconf != 0 });
}, },
bss_remove: function(name, obj) { bss_remove: function(phy, name, obj) {
bss_event("remove", name); bss_event("remove", name);
} }
}; };

View File

@ -139,7 +139,16 @@ as adding/removing interfaces.
{ {
struct hostapd_bss_config *conf = hapd->conf; struct hostapd_bss_config *conf = hapd->conf;
u8 ssid[SSID_MAX_LEN + 1]; u8 ssid[SSID_MAX_LEN + 1];
@@ -2954,7 +2958,7 @@ hostapd_alloc_bss_data(struct hostapd_if @@ -1510,6 +1514,8 @@ setup_mld:
}
#endif /* CONFIG_IEEE80211BE */
+ hostapd_ucode_create_bss(hapd);
+
if (conf->wmm_enabled < 0)
conf->wmm_enabled = hapd->iconf->ieee80211n |
hapd->iconf->ieee80211ax;
@@ -2954,7 +2960,7 @@ hostapd_alloc_bss_data(struct hostapd_if
} }
@ -148,7 +157,7 @@ as adding/removing interfaces.
{ {
if (!hapd) if (!hapd)
return; return;
@@ -4015,7 +4019,8 @@ int hostapd_remove_iface(struct hapd_int @@ -4015,7 +4021,8 @@ int hostapd_remove_iface(struct hapd_int
hapd_iface = interfaces->iface[i]; hapd_iface = interfaces->iface[i];
if (hapd_iface == NULL) if (hapd_iface == NULL)
return -1; return -1;

View File

@ -53,7 +53,7 @@ Hotfix-by: Sebastian Gottschall https://github.com/mirror/dd-wrt/commit/0c3001a6
--- a/hostapd/config_file.c --- a/hostapd/config_file.c
+++ b/hostapd/config_file.c +++ b/hostapd/config_file.c
@@ -5200,6 +5200,15 @@ static int hostapd_config_fill(struct ho @@ -5202,6 +5202,15 @@ static int hostapd_config_fill(struct ho
bss->mld_indicate_disabled = atoi(pos); bss->mld_indicate_disabled = atoi(pos);
#endif /* CONFIG_TESTING_OPTIONS */ #endif /* CONFIG_TESTING_OPTIONS */
#endif /* CONFIG_IEEE80211BE */ #endif /* CONFIG_IEEE80211BE */
@ -71,7 +71,7 @@ Hotfix-by: Sebastian Gottschall https://github.com/mirror/dd-wrt/commit/0c3001a6
"Line %d: unknown configuration item '%s'", "Line %d: unknown configuration item '%s'",
--- a/src/ap/ap_config.h --- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h +++ b/src/ap/ap_config.h
@@ -999,6 +999,35 @@ struct hostapd_bss_config { @@ -1000,6 +1000,35 @@ struct hostapd_bss_config {
bool mld_indicate_disabled; bool mld_indicate_disabled;
#endif /* CONFIG_TESTING_OPTIONS */ #endif /* CONFIG_TESTING_OPTIONS */
#endif /* CONFIG_IEEE80211BE */ #endif /* CONFIG_IEEE80211BE */

View File

@ -58,7 +58,7 @@ Signed-off-by: Gioacchino Mazzurco <gio@polymathes.cc>
+#endif // def CONFIG_APUP +#endif // def CONFIG_APUP
--- a/src/ap/ubus.h --- a/src/ap/ubus.h
+++ b/src/ap/ubus.h +++ b/src/ap/ubus.h
@@ -71,6 +71,11 @@ int hostapd_ubus_notify_bss_transition_q @@ -69,6 +69,11 @@ int hostapd_ubus_notify_bss_transition_q
void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta, void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta,
const char *auth_alg); const char *auth_alg);

View File

@ -34,7 +34,7 @@ Signed-off-by: Gioacchino Mazzurco <gio@polymathes.cc>
} }
--- a/src/ap/ucode.c --- a/src/ap/ucode.c
+++ b/src/ap/ucode.c +++ b/src/ap/ucode.c
@@ -815,3 +815,20 @@ void hostapd_ucode_free_bss(struct hosta @@ -802,3 +802,20 @@ void hostapd_ucode_free_bss(struct hosta
ucv_put(wpa_ucode_call(2)); ucv_put(wpa_ucode_call(2));
ucv_gc(vm); ucv_gc(vm);
} }
@ -57,9 +57,9 @@ Signed-off-by: Gioacchino Mazzurco <gio@polymathes.cc>
+#endif // def CONFIG_APUP +#endif // def CONFIG_APUP
--- a/src/ap/ucode.h --- a/src/ap/ucode.h
+++ b/src/ap/ucode.h +++ b/src/ap/ucode.h
@@ -27,6 +27,10 @@ void hostapd_ucode_add_bss(struct hostap @@ -26,6 +26,10 @@ void hostapd_ucode_free_iface(struct hos
void hostapd_ucode_free_bss(struct hostapd_data *hapd); void hostapd_ucode_free_bss(struct hostapd_data *hapd);
void hostapd_ucode_reload_bss(struct hostapd_data *hapd); void hostapd_ucode_bss_cb(struct hostapd_data *hapd, const char *type);
+#ifdef CONFIG_APUP +#ifdef CONFIG_APUP
+void hostapd_ucode_apup_newpeer(struct hostapd_data *hapd, const char *ifname); +void hostapd_ucode_apup_newpeer(struct hostapd_data *hapd, const char *ifname);

View File

@ -770,31 +770,18 @@ void hostapd_ucode_free_iface(struct hostapd_iface *iface)
wpa_ucode_registry_remove(iface_registry, iface->ucode.idx); wpa_ucode_registry_remove(iface_registry, iface->ucode.idx);
} }
void hostapd_ucode_add_bss(struct hostapd_data *hapd) void hostapd_ucode_bss_cb(struct hostapd_data *hapd, const char *type)
{ {
uc_value_t *val; uc_value_t *val;
if (wpa_ucode_call_prepare("bss_add")) if (wpa_ucode_call_prepare(type))
return; return;
val = hostapd_ucode_bss_get_uval(hapd); val = hostapd_ucode_bss_get_uval(hapd);
uc_value_push(ucv_get(ucv_string_new(hapd->iface->phy)));
uc_value_push(ucv_get(ucv_string_new(hapd->conf->iface))); uc_value_push(ucv_get(ucv_string_new(hapd->conf->iface)));
uc_value_push(ucv_get(val)); uc_value_push(ucv_get(val));
ucv_put(wpa_ucode_call(2)); ucv_put(wpa_ucode_call(3));
ucv_gc(vm);
}
void hostapd_ucode_reload_bss(struct hostapd_data *hapd)
{
uc_value_t *val;
if (wpa_ucode_call_prepare("bss_reload"))
return;
val = hostapd_ucode_bss_get_uval(hapd);
uc_value_push(ucv_get(ucv_string_new(hapd->conf->iface)));
uc_value_push(ucv_get(val));
ucv_put(wpa_ucode_call(2));
ucv_gc(vm); ucv_gc(vm);
} }

View File

@ -23,9 +23,8 @@ int hostapd_ucode_init(struct hapd_interfaces *ifaces);
void hostapd_ucode_free(void); void hostapd_ucode_free(void);
void hostapd_ucode_free_iface(struct hostapd_iface *iface); void hostapd_ucode_free_iface(struct hostapd_iface *iface);
void hostapd_ucode_add_bss(struct hostapd_data *hapd);
void hostapd_ucode_free_bss(struct hostapd_data *hapd); void hostapd_ucode_free_bss(struct hostapd_data *hapd);
void hostapd_ucode_reload_bss(struct hostapd_data *hapd); void hostapd_ucode_bss_cb(struct hostapd_data *hapd, const char *type);
#else #else
@ -39,10 +38,7 @@ static inline void hostapd_ucode_free(void)
static inline void hostapd_ucode_free_iface(struct hostapd_iface *iface) static inline void hostapd_ucode_free_iface(struct hostapd_iface *iface)
{ {
} }
static inline void hostapd_ucode_reload_bss(struct hostapd_data *hapd) static inline void hostapd_ucode_bss_cb(struct hostapd_data *hapd, const char *type)
{
}
static inline void hostapd_ucode_add_bss(struct hostapd_data *hapd)
{ {
} }
static inline void hostapd_ucode_free_bss(struct hostapd_data *hapd) static inline void hostapd_ucode_free_bss(struct hostapd_data *hapd)
@ -51,4 +47,19 @@ static inline void hostapd_ucode_free_bss(struct hostapd_data *hapd)
#endif #endif
static inline void hostapd_ucode_create_bss(struct hostapd_data *hapd)
{
hostapd_ucode_bss_cb(hapd, "bss_create");
}
static inline void hostapd_ucode_add_bss(struct hostapd_data *hapd)
{
hostapd_ucode_bss_cb(hapd, "bss_add");
}
static inline void hostapd_ucode_reload_bss(struct hostapd_data *hapd)
{
hostapd_ucode_bss_cb(hapd, "bss_reload");
}
#endif #endif