mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-02-12 08:41:51 +00:00
treewide: RSSI / RCPI handling updates
Adjust how RSSI levels are shared and stored to help visibility of activity [cleanup commit message] Signed-off-by: Nick Hainke <vincent@systemli.org>
This commit is contained in:
parent
c54cd95abe
commit
d37a768766
5 changed files with 94 additions and 41 deletions
|
@ -81,7 +81,7 @@ int handle_auth_req(struct blob_attr* msg);
|
|||
* @param probe_entry
|
||||
* @return
|
||||
*/
|
||||
int ubus_send_probe_via_network(struct probe_entry_s *probe_entry);
|
||||
int ubus_send_probe_via_network(struct probe_entry_s *probe_entry, bool is_beacon);
|
||||
|
||||
/**
|
||||
* Add mac to a list that contains addresses of clients that can not be controlled.
|
||||
|
|
|
@ -794,16 +794,42 @@ probe_entry* probe_array_update_rssi(struct dawn_mac client_addr, struct dawn_ma
|
|||
dawnlog_debug_func("Entering...");
|
||||
|
||||
dawn_mutex_require(&probe_array_mutex);
|
||||
probe_entry* entry = probe_array_get_entry(client_addr, bssid_addr);
|
||||
probe_entry* probe_req_new = dawn_malloc(sizeof(probe_entry));
|
||||
|
||||
if (entry) {
|
||||
entry->signal = rssi;
|
||||
if (probe_req_new) {
|
||||
// Fields we will update
|
||||
probe_req_new->client_addr = client_addr;
|
||||
probe_req_new->bssid_addr = bssid_addr;
|
||||
probe_req_new->signal = rssi;
|
||||
|
||||
// Other fields in case entry is new
|
||||
probe_req_new->ht_capabilities = false;
|
||||
probe_req_new->vht_capabilities = false;
|
||||
probe_req_new->rcpi = -1;
|
||||
probe_req_new->rsni = -1;
|
||||
|
||||
//FIXME: Should we put the linked list defaults in the insert function?
|
||||
probe_req_new->next_probe = NULL;
|
||||
probe_req_new->next_probe_skip = NULL;
|
||||
|
||||
probe_entry* probe_req_updated = insert_to_probe_array(probe_req_new, false, false, false, time(0));
|
||||
if (probe_req_new != probe_req_updated)
|
||||
{
|
||||
dawnlog_info("RSSI PROBE used to update client / BSSID = " MACSTR " / " MACSTR " \n", MAC2STR(probe_req_updated->client_addr.u8), MAC2STR(probe_req_updated->bssid_addr.u8));
|
||||
|
||||
dawn_free(probe_req_new);
|
||||
probe_req_new = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
dawnlog_info("RSSI PROBE is new for client / BSSID = " MACSTR " / " MACSTR " \n", MAC2STR(probe_req_updated->client_addr.u8), MAC2STR(probe_req_updated->bssid_addr.u8));
|
||||
}
|
||||
|
||||
if (send_network)
|
||||
ubus_send_probe_via_network(entry);
|
||||
ubus_send_probe_via_network(probe_req_updated, false);
|
||||
}
|
||||
|
||||
return entry;
|
||||
return probe_req_new;
|
||||
}
|
||||
|
||||
probe_entry* probe_array_update_rcpi_rsni(struct dawn_mac client_addr, struct dawn_mac bssid_addr, uint32_t rcpi, uint32_t rsni, int send_network)
|
||||
|
@ -822,7 +848,7 @@ probe_entry* probe_array_update_rcpi_rsni(struct dawn_mac client_addr, struct da
|
|||
entry->rsni = rsni;
|
||||
|
||||
if (send_network)
|
||||
ubus_send_probe_via_network(entry);
|
||||
ubus_send_probe_via_network(entry, true);
|
||||
}
|
||||
|
||||
return entry;
|
||||
|
@ -897,8 +923,13 @@ probe_entry* insert_to_probe_array(probe_entry* entry, int is_local, int save_80
|
|||
|
||||
// Beacon reports don't have these fields, so only update them from probes
|
||||
(*node_ref)->signal = entry->signal;
|
||||
(*node_ref)->ht_capabilities = entry->ht_capabilities;
|
||||
(*node_ref)->vht_capabilities = entry->vht_capabilities;
|
||||
|
||||
// Some "synthetic" PROBE entries have FALSE for these which would overwrite genuine values
|
||||
if (entry->ht_capabilities)
|
||||
(*node_ref)->ht_capabilities = entry->ht_capabilities;
|
||||
|
||||
if (entry->vht_capabilities)
|
||||
(*node_ref)->vht_capabilities = entry->vht_capabilities;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -917,6 +948,7 @@ probe_entry* insert_to_probe_array(probe_entry* entry, int is_local, int save_80
|
|||
else
|
||||
{
|
||||
dawnlog_debug("Adding...\n");
|
||||
|
||||
if (is_local && !is_beacon)
|
||||
entry->counter = 1;
|
||||
else
|
||||
|
@ -938,10 +970,10 @@ probe_entry* insert_to_probe_array(probe_entry* entry, int is_local, int save_80
|
|||
{
|
||||
entry->next_probe_skip = NULL;
|
||||
}
|
||||
|
||||
entry->time = expiry;
|
||||
}
|
||||
|
||||
entry->time = expiry;
|
||||
|
||||
return entry; // return pointer to what we used, which may not be what was passed in
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ void del_client_interface(uint32_t id, const struct dawn_mac client_addr, uint32
|
|||
printf("del_client_interface() was called...\n");
|
||||
}
|
||||
|
||||
int ubus_send_probe_via_network(struct probe_entry_s *probe_entry)
|
||||
int ubus_send_probe_via_network(struct probe_entry_s *probe_entry, bool is_beacon)
|
||||
{
|
||||
printf("send_probe_via_network() was called...\n");
|
||||
return 0;
|
||||
|
|
|
@ -301,7 +301,7 @@ int handle_network_msg(char* msg) {
|
|||
dawn_mutex_lock(&probe_array_mutex);
|
||||
|
||||
dawn_mutex_require(&probe_array_mutex);
|
||||
if (entry != insert_to_probe_array(entry, false, true, false, time(0))) // use 802.11k values
|
||||
if (entry != insert_to_probe_array(entry, false, false, false, time(0))) // use 802.11k values
|
||||
{
|
||||
// insert found an existing entry, rather than linking in our new one
|
||||
dawnlog_info("Remote PROBE updated client / BSSID = " MACSTR " / " MACSTR " \n",
|
||||
|
@ -341,13 +341,28 @@ int handle_network_msg(char* msg) {
|
|||
handle_uci_config(data_buf.head);
|
||||
}
|
||||
else if (strncmp(method, "beacon-report", 12) == 0) {
|
||||
// TODO: Check beacon report stuff
|
||||
probe_entry* entry = parse_to_probe_req(data_buf.head);
|
||||
if (entry != NULL) {
|
||||
dawn_mutex_lock(&probe_array_mutex);
|
||||
|
||||
dawnlog_debug("HANDLING BEACON REPORT NETWORK!\n");
|
||||
dawnlog_debug("The Method for beacon-report is: %s\n", method);
|
||||
// ignore beacon reports send via network!, use probe functions for it
|
||||
//probe_entry entry; // for now just stay at probe entry stuff...
|
||||
//parse_to_beacon_rep(data_buf.head, &entry, true);
|
||||
dawn_mutex_require(&probe_array_mutex);
|
||||
if (entry != insert_to_probe_array(entry, false, true, true, time(0))) // use 802.11k values
|
||||
{
|
||||
// insert found an existing entry, rather than linking in our new one
|
||||
dawnlog_info("Remote BEACON updated client / BSSID = " MACSTR " / " MACSTR " \n",
|
||||
MAC2STR(entry->client_addr.u8), MAC2STR(entry->bssid_addr.u8));
|
||||
|
||||
dawn_free(entry);
|
||||
entry = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
dawnlog_info("Remote BEACON is for new client / BSSID = " MACSTR " / " MACSTR " \n",
|
||||
MAC2STR(entry->client_addr.u8), MAC2STR(entry->bssid_addr.u8));
|
||||
}
|
||||
|
||||
dawn_mutex_unlock(&probe_array_mutex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -504,7 +504,7 @@ static int handle_probe_req(struct blob_attr* msg) {
|
|||
dawn_mutex_lock(&probe_array_mutex);
|
||||
|
||||
dawn_mutex_require(&probe_array_mutex);
|
||||
probe_entry* probe_req_updated = insert_to_probe_array(probe_req_new, true, true, false, time(0));
|
||||
probe_entry* probe_req_updated = insert_to_probe_array(probe_req_new, true, false, false, time(0));
|
||||
// If insert finds an existing entry, rather than linking in our new one,
|
||||
// send new probe req because we want to stay synced.
|
||||
// If not, probe_req and probe_req_updated should be equivalent
|
||||
|
@ -520,7 +520,7 @@ static int handle_probe_req(struct blob_attr* msg) {
|
|||
dawnlog_info("Local PROBE is new for client / BSSID = " MACSTR " / " MACSTR " \n", MAC2STR(probe_req_updated->client_addr.u8), MAC2STR(probe_req_updated->bssid_addr.u8));
|
||||
}
|
||||
|
||||
ubus_send_probe_via_network(probe_req_updated);
|
||||
ubus_send_probe_via_network(probe_req_updated, false);
|
||||
|
||||
if (dawn_metric.eval_probe_req <= 0) {
|
||||
dawnlog_trace(MACSTR " Allow probe due to not evaluating requests", MAC2STR(probe_req_updated->client_addr.u8));
|
||||
|
@ -600,8 +600,8 @@ static int handle_beacon_rep(struct blob_attr *msg) {
|
|||
|
||||
// BEACON will never set RSSI, but may have RCPI and RSNI
|
||||
dawn_mutex_require(&probe_array_mutex);
|
||||
entry = insert_to_probe_array(entry, false, false, true, time(0));
|
||||
ubus_send_probe_via_network(entry);
|
||||
entry = insert_to_probe_array(entry, true, true, true, time(0));
|
||||
ubus_send_probe_via_network(entry, true);
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
|
@ -1249,7 +1249,7 @@ int ubus_call_umdns() {
|
|||
}
|
||||
|
||||
//TODO: ADD STUFF HERE!!!!
|
||||
int ubus_send_probe_via_network(struct probe_entry_s *probe_entry) { // TODO: probe_entry is also a typedef - fix?
|
||||
int ubus_send_probe_via_network(struct probe_entry_s *probe_entry, bool is_beacon) { // TODO: probe_entry is also a typedef - fix?
|
||||
struct blob_buf b = {0};
|
||||
|
||||
dawnlog_debug_func("Entering...");
|
||||
|
@ -1259,27 +1259,33 @@ int ubus_send_probe_via_network(struct probe_entry_s *probe_entry) { // TODO: p
|
|||
blobmsg_add_macaddr(&b, "bssid", probe_entry->bssid_addr);
|
||||
blobmsg_add_macaddr(&b, "address", probe_entry->client_addr);
|
||||
blobmsg_add_macaddr(&b, "target", probe_entry->target_addr);
|
||||
blobmsg_add_u32(&b, "signal", probe_entry->signal);
|
||||
blobmsg_add_u32(&b, "freq", probe_entry->freq);
|
||||
|
||||
blobmsg_add_u32(&b, "rcpi", probe_entry->rcpi);
|
||||
blobmsg_add_u32(&b, "rsni", probe_entry->rsni);
|
||||
|
||||
blobmsg_add_u32(&b, "ht_capabilities", probe_entry->ht_capabilities);
|
||||
blobmsg_add_u32(&b, "vht_capabilities", probe_entry->vht_capabilities);
|
||||
|
||||
/*if (probe_entry->ht_capabilities)
|
||||
if (!is_beacon)
|
||||
{
|
||||
void *ht_cap = blobmsg_open_table(&b, "ht_capabilities");
|
||||
blobmsg_close_table(&b, ht_cap);
|
||||
blobmsg_add_u32(&b, "signal", probe_entry->signal);
|
||||
blobmsg_add_u32(&b, "freq", probe_entry->freq);
|
||||
|
||||
blobmsg_add_u32(&b, "ht_capabilities", probe_entry->ht_capabilities);
|
||||
blobmsg_add_u32(&b, "vht_capabilities", probe_entry->vht_capabilities);
|
||||
|
||||
/*if (probe_entry->ht_capabilities)
|
||||
{
|
||||
void *ht_cap = blobmsg_open_table(&b, "ht_capabilities");
|
||||
blobmsg_close_table(&b, ht_cap);
|
||||
}
|
||||
|
||||
if (probe_entry->vht_capabilities) {
|
||||
void *vht_cap = blobmsg_open_table(&b, "vht_capabilities");
|
||||
blobmsg_close_table(&b, vht_cap);
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
blobmsg_add_u32(&b, "rcpi", probe_entry->rcpi);
|
||||
blobmsg_add_u32(&b, "rsni", probe_entry->rsni);
|
||||
}
|
||||
|
||||
if (probe_entry->vht_capabilities) {
|
||||
void *vht_cap = blobmsg_open_table(&b, "vht_capabilities");
|
||||
blobmsg_close_table(&b, vht_cap);
|
||||
}*/
|
||||
|
||||
send_blob_attr_via_network(b.head, "probe");
|
||||
send_blob_attr_via_network(b.head, is_beacon ? "beacon-report" : "probe");
|
||||
|
||||
blob_buf_free(&b);
|
||||
dawn_unregmem(&b);
|
||||
|
|
Loading…
Reference in a new issue