From 7bb7834e700c37faa3dae7331f25a9d9a2fe7bd2 Mon Sep 17 00:00:00 2001 From: Eneas U de Queiroz Date: Tue, 6 Jul 2021 18:09:19 -0300 Subject: [PATCH] ubus: filter neighbors by SSID when preparing nr Only add neighbors with the same SSID to an interface's neighbor report. While it is possible to offer roaming to a different SSID, it is often not desired, while at least Apple devices limit the number of entries they will use to 6. Signed-off-by: Eneas U de Queiroz --- src/include/ubus.h | 2 +- src/utils/ubus.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/include/ubus.h b/src/include/ubus.h index 95bbb4f..57578c5 100644 --- a/src/include/ubus.h +++ b/src/include/ubus.h @@ -78,7 +78,7 @@ int build_hearing_map_sort_client(struct blob_buf* b); int build_network_overview(struct blob_buf* b); -int ap_get_nr(struct blob_buf* b, struct dawn_mac own_bssid_addr); +int ap_get_nr(struct blob_buf* b, struct dawn_mac own_bssid_addr, const char *ssid); int parse_add_mac_to_file(struct blob_attr* msg); diff --git a/src/utils/ubus.c b/src/utils/ubus.c index 5a7eaa8..7d23449 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -867,7 +867,7 @@ void ubus_set_nr(){ if (sub->subscribed) { int timeout = 1; blob_buf_init(&b_nr, 0); - ap_get_nr(&b_nr, sub->bssid_addr); + ap_get_nr(&b_nr, sub->bssid_addr, sub->ssid); ubus_invoke(ctx, sub->id, "rrm_nr_set", b_nr.head, NULL, NULL, timeout * 1000); } } @@ -1563,7 +1563,7 @@ int build_network_overview(struct blob_buf *b) { // TODO: Does all APs constitute neighbor report? How about using list of AP connected // clients can also see (from probe_set) to give more (physically) local set? -int ap_get_nr(struct blob_buf *b_local, struct dawn_mac own_bssid_addr) { +int ap_get_nr(struct blob_buf *b_local, struct dawn_mac own_bssid_addr, const char *ssid) { pthread_mutex_lock(&ap_array_mutex); ap *i; @@ -1571,8 +1571,9 @@ int ap_get_nr(struct blob_buf *b_local, struct dawn_mac own_bssid_addr) { void* nbs = blobmsg_open_array(b_local, "list"); for (i = ap_set; i != NULL; i = i->next_ap) { - if (mac_is_equal_bb(own_bssid_addr, i->bssid_addr)) { - continue; //TODO: Skip own entry?! + if (mac_is_equal_bb(own_bssid_addr, i->bssid_addr) || + strncmp((char *)i->ssid, ssid, SSID_MAX_LEN)) { + continue; } void* nr_entry = blobmsg_open_array(b_local, NULL);