mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-02-12 08:41:51 +00:00
iwinfo: fix get_bandwidth_iwinfo
Bug that was preventing kicking working due to mishandling of bandwidth discovery. Fixed bug in use of get_bandwidth_iwinfo() in AP kicking. Fix rounding of transmission rate calculations in get_bandwidth_iwinfo(). Restructure of get_bandwidth...() while finding bug. Signed-off-by: Ian Clowes <clowes_ian@hotmail.com>
This commit is contained in:
parent
9ce01ecce5
commit
877e2dc22f
2 changed files with 26 additions and 29 deletions
|
@ -721,7 +721,7 @@ int kick_clients(ap* kicking_ap, uint32_t id) {
|
|||
dawnlog_debug("Check if client is active receiving!\n");
|
||||
|
||||
float rx_rate, tx_rate;
|
||||
bool have_bandwidth_iwinfo = !(get_bandwidth_iwinfo(j->client_addr, &rx_rate, &tx_rate));
|
||||
bool have_bandwidth_iwinfo = get_bandwidth_iwinfo(j->client_addr, &rx_rate, &tx_rate);
|
||||
if (!have_bandwidth_iwinfo && dawn_metric.bandwidth_threshold > 0) {
|
||||
dawnlog_debug("No active transmission data for client. Don't kick!\n");
|
||||
}
|
||||
|
|
|
@ -103,12 +103,10 @@ int get_bandwidth_iwinfo(struct dawn_mac client_addr, float *rx_rate, float *tx_
|
|||
|
||||
int sucess = 0;
|
||||
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
while (!sucess && ((entry = readdir(dirp)) != NULL)) {
|
||||
if (entry->d_type == DT_SOCK) {
|
||||
if (get_bandwidth(entry->d_name, client_addr, rx_rate, tx_rate)) {
|
||||
sucess = 1;
|
||||
break;
|
||||
}
|
||||
dawnlog_debug("[BANDWIDTH INFO] Trying %s\n", entry->d_name);
|
||||
sucess = get_bandwidth(entry->d_name, client_addr, rx_rate, tx_rate);
|
||||
}
|
||||
}
|
||||
closedir(dirp);
|
||||
|
@ -116,35 +114,34 @@ int get_bandwidth_iwinfo(struct dawn_mac client_addr, float *rx_rate, float *tx_
|
|||
}
|
||||
|
||||
int get_bandwidth(const char *ifname, struct dawn_mac client_addr, float *rx_rate, float *tx_rate) {
|
||||
int ret = 0;
|
||||
|
||||
int i, len;
|
||||
char buf[IWINFO_BUFSIZE];
|
||||
struct iwinfo_assoclist_entry *e;
|
||||
const struct iwinfo_ops *iw;
|
||||
if (strcmp(ifname, "global") == 0)
|
||||
return 0;
|
||||
iw = iwinfo_backend(ifname);
|
||||
if (strcmp(ifname, "global") != 0)
|
||||
{
|
||||
const struct iwinfo_ops* iw = iwinfo_backend(ifname);
|
||||
|
||||
if (iw->assoclist(ifname, buf, &len)) {
|
||||
iwinfo_finish();
|
||||
return 0;
|
||||
} else if (len <= 0) {
|
||||
iwinfo_finish();
|
||||
return 0;
|
||||
}
|
||||
char buf[IWINFO_BUFSIZE];
|
||||
int len;
|
||||
if (iw->assoclist(ifname, buf, &len) == 0 && len > 0)
|
||||
{
|
||||
struct iwinfo_assoclist_entry* e = (struct iwinfo_assoclist_entry*)buf;
|
||||
for (int i = 0; ret == 0 && i < len; i += sizeof(struct iwinfo_assoclist_entry)) {
|
||||
|
||||
for (i = 0; i < len; i += sizeof(struct iwinfo_assoclist_entry)) {
|
||||
e = (struct iwinfo_assoclist_entry *) &buf[i];
|
||||
if (mac_is_equal(client_addr.u8, e->mac)) {
|
||||
*rx_rate = e->rx_rate.rate / 1000.0;
|
||||
*tx_rate = e->tx_rate.rate / 1000.0;
|
||||
|
||||
if (mac_is_equal(client_addr.u8, e->mac)) {
|
||||
*rx_rate = e->rx_rate.rate / 1000;
|
||||
*tx_rate = e->tx_rate.rate / 1000;
|
||||
iwinfo_finish();
|
||||
return 1;
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
e++;
|
||||
}
|
||||
}
|
||||
|
||||
iwinfo_finish();
|
||||
}
|
||||
iwinfo_finish();
|
||||
return 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int get_rssi_iwinfo(struct dawn_mac client_addr) {
|
||||
|
|
Loading…
Reference in a new issue