mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-02-14 17:51:51 +00:00
dawn_iwinfo: fix bug in use of get_bandwidth_iwinfo
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
This commit is contained in:
parent
94b2bc42a1
commit
b0aa1c0d15
1 changed files with 29 additions and 31 deletions
|
@ -89,54 +89,52 @@ int get_bandwidth_iwinfo(struct dawn_mac client_addr, float *rx_rate, float *tx_
|
|||
struct dirent *entry;
|
||||
dirp = opendir(hostapd_dir_glob); // error handling?
|
||||
if (!dirp) {
|
||||
fprintf(stderr, "[BANDWIDTH INFO] Failed to open %s\n", hostapd_dir_glob);
|
||||
fprintf(stderr,"[BANDWIDTH INFO] Failed to open %s\n", hostapd_dir_glob);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"[BANDWIDTH INFO] Opened %s\n", hostapd_dir_glob);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
fprintf(stdout,"[BANDWIDTH INFO] Trying %s\n", entry->d_name);
|
||||
sucess = get_bandwidth(entry->d_name, client_addr, rx_rate, tx_rate);
|
||||
}
|
||||
}
|
||||
closedir(dirp);
|
||||
return sucess;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
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)) {
|
||||
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 (iw->assoclist(ifname, buf, &len)) {
|
||||
iwinfo_finish();
|
||||
return 0;
|
||||
} else if (len <= 0) {
|
||||
iwinfo_finish();
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
*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