Skip to content

Commit

Permalink
hostapd: provide BSS-transition-queries to ubus subscribers
Browse files Browse the repository at this point in the history
Provide incoming BSS transition queries to ubus subscribers.

This allows external steering daemons to provide clients with
an optimal list of transition candidates.

This commit has no functional state in case no ubus subscriber is
present or it does not handle this ubus message.

To prevent hostapd from sending out a generic response by itself, a
subscribing daemon has to return a non-zero response code to hostapd.

Signed-off-by: David Bauer <[email protected]>
  • Loading branch information
blocktrron committed Dec 19, 2021
1 parent dd39249 commit 6d1e380
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 10 deletions.
16 changes: 13 additions & 3 deletions package/network/services/hostapd/patches/600-ubus_support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,17 @@

--- a/src/ap/wnm_ap.c
+++ b/src/ap/wnm_ap.c
@@ -463,7 +463,7 @@ static void ieee802_11_rx_bss_trans_mgmt
@@ -441,7 +441,8 @@ static void ieee802_11_rx_bss_trans_mgmt
wpa_hexdump(MSG_DEBUG, "WNM: BSS Transition Candidate List Entries",
pos, end - pos);

- ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
+ if (!hostapd_ubus_notify_bss_transition_query(hapd, addr, dialog_token, reason, pos, end - pos))
+ ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
}


@@ -463,7 +464,7 @@ static void ieee802_11_rx_bss_trans_mgmt
size_t len)
{
u8 dialog_token, status_code, bss_termination_delay;
Expand All @@ -524,15 +534,15 @@
int enabled = hapd->conf->bss_transition;
struct sta_info *sta;

@@ -510,6 +510,7 @@ static void ieee802_11_rx_bss_trans_mgmt
@@ -510,6 +511,7 @@ static void ieee802_11_rx_bss_trans_mgmt
wpa_printf(MSG_DEBUG, "WNM: not enough room for Target BSSID field");
return;
}
+ target_bssid = pos;
sta->agreed_to_steer = 1;
eloop_cancel_timeout(ap_sta_reset_steer_flag_timer, hapd, sta);
eloop_register_timeout(2, 0, ap_sta_reset_steer_flag_timer,
@@ -529,6 +530,10 @@ static void ieee802_11_rx_bss_trans_mgmt
@@ -529,6 +531,10 @@ static void ieee802_11_rx_bss_trans_mgmt
MAC2STR(addr), status_code, bss_termination_delay);
}

Expand Down
63 changes: 56 additions & 7 deletions package/network/services/hostapd/src/src/ap/ubus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1850,13 +1850,30 @@ void hostapd_ubus_notify_radar_detected(struct hostapd_iface *iface, int frequen
}
}

#ifdef CONFIG_WNM_AP
static void hostapd_ubus_notify_bss_transition_add_candidate_list(
const u8 *candidate_list, u16 candidate_list_len)
{
char *cl_str;
int i;

if (candidate_list_len == 0)
return;

cl_str = blobmsg_alloc_string_buffer(&b, "candidate-list", candidate_list_len * 2 + 1);
for (i = 0; i < candidate_list_len; i++)
snprintf(&cl_str[i*2], 3, "%02X", candidate_list[i]);
blobmsg_add_string_buffer(&b);

}
#endif

void hostapd_ubus_notify_bss_transition_response(
struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 status_code,
u8 bss_termination_delay, const u8 *target_bssid,
const u8 *candidate_list, u16 candidate_list_len)
{
#ifdef CONFIG_WNM_AP
char *cl_str;
u16 i;

if (!hapd->ubus.obj.has_subscribers)
Expand All @@ -1872,13 +1889,45 @@ void hostapd_ubus_notify_bss_transition_response(
blobmsg_add_u8(&b, "bss-termination-delay", bss_termination_delay);
if (target_bssid)
blobmsg_add_macaddr(&b, "target-bssid", target_bssid);
if (candidate_list_len > 0) {
cl_str = blobmsg_alloc_string_buffer(&b, "candidate-list", candidate_list_len * 2 + 1);
for (i = 0; i < candidate_list_len; i++)
snprintf(&cl_str[i*2], 3, "%02X", candidate_list[i]);
blobmsg_add_string_buffer(&b);
}

hostapd_ubus_notify_bss_transition_add_candidate_list(candidate_list, candidate_list_len);

ubus_notify(ctx, &hapd->ubus.obj, "bss-transition-response", b.head, -1);
#endif
}

int hostapd_ubus_notify_bss_transition_query(
struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 reason,
const u8 *candidate_list, u16 candidate_list_len)
{
#ifdef CONFIG_WNM_AP
struct ubus_event_req ureq = {};
char *cl_str;
u16 i;

if (!hapd->ubus.obj.has_subscribers)
return 0;

if (!addr)
return 0;

blob_buf_init(&b, 0);
blobmsg_add_macaddr(&b, "address", addr);
blobmsg_add_u8(&b, "dialog-token", dialog_token);
blobmsg_add_u8(&b, "reason", reason);
hostapd_ubus_notify_bss_transition_add_candidate_list(candidate_list, candidate_list_len);

if (!hapd->ubus.notify_response) {
ubus_notify(ctx, &hapd->ubus.obj, "bss-transition-query", b.head, -1);
return 0;
}

if (ubus_notify_async(ctx, &hapd->ubus.obj, "bss-transition-query", b.head, &ureq.nreq))
return 0;

ureq.nreq.status_cb = ubus_event_cb;
ubus_complete_request(ctx, &ureq.nreq.req, 100);

return ureq.resp;
#endif
}

0 comments on commit 6d1e380

Please sign in to comment.