mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
wpa_gui-qt4: Update BSS entries in Peers dialog dynamically
Use the new BSS added/removed events to add/remove BSS (AP) entries in the Peers dialog.
This commit is contained in:
parent
ba96adb65f
commit
1179cb834d
@ -30,7 +30,8 @@ enum {
|
||||
peer_role_pri_dev_type,
|
||||
peer_role_ssid,
|
||||
peer_role_config_methods,
|
||||
peer_role_dev_passwd_id
|
||||
peer_role_dev_passwd_id,
|
||||
peer_role_bss_id
|
||||
};
|
||||
|
||||
/*
|
||||
@ -320,29 +321,35 @@ void Peers::add_single_station(const char *addr)
|
||||
}
|
||||
|
||||
|
||||
void Peers::add_scan_results()
|
||||
void Peers::remove_bss(int id)
|
||||
{
|
||||
if (model.rowCount() == 0)
|
||||
return;
|
||||
|
||||
QModelIndexList lst = model.match(model.index(0, 0), peer_role_bss_id,
|
||||
id);
|
||||
if (lst.size() == 0)
|
||||
return;
|
||||
model.removeRow(lst[0].row());
|
||||
}
|
||||
|
||||
|
||||
void Peers::add_bss(const char *cmd)
|
||||
{
|
||||
char reply[2048];
|
||||
size_t reply_len;
|
||||
int index;
|
||||
char cmd[20];
|
||||
|
||||
index = 0;
|
||||
while (wpagui) {
|
||||
snprintf(cmd, sizeof(cmd), "BSS %d", index++);
|
||||
if (index > 1000)
|
||||
break;
|
||||
|
||||
reply_len = sizeof(reply) - 1;
|
||||
if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0)
|
||||
break;
|
||||
return;
|
||||
reply[reply_len] = '\0';
|
||||
|
||||
QString bss(reply);
|
||||
if (bss.isEmpty() || bss.startsWith("FAIL"))
|
||||
break;
|
||||
return;
|
||||
|
||||
QString ssid, bssid, flags, wps_name, pri_dev_type;
|
||||
int id = -1;
|
||||
|
||||
QStringList lines = bss.split(QRegExp("\\n"));
|
||||
for (QStringList::Iterator it = lines.begin();
|
||||
@ -353,6 +360,8 @@ void Peers::add_scan_results()
|
||||
|
||||
if ((*it).startsWith("bssid="))
|
||||
bssid = (*it).mid(pos);
|
||||
else if ((*it).startsWith("id="))
|
||||
id = (*it).mid(pos).toInt();
|
||||
else if ((*it).startsWith("flags="))
|
||||
flags = (*it).mid(pos);
|
||||
else if ((*it).startsWith("ssid="))
|
||||
@ -370,6 +379,8 @@ void Peers::add_scan_results()
|
||||
QStandardItem *item = new QStandardItem(*ap_icon, name);
|
||||
if (item) {
|
||||
item->setData(bssid, peer_role_address);
|
||||
if (id >= 0)
|
||||
item->setData(id, peer_role_bss_id);
|
||||
int type;
|
||||
if (flags.contains("[WPS"))
|
||||
type = PEER_TYPE_AP_WPS;
|
||||
@ -379,8 +390,7 @@ void Peers::add_scan_results()
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
if (lines[i].length() > 60) {
|
||||
lines[i].remove(
|
||||
60, lines[i].length());
|
||||
lines[i].remove(60, lines[i].length());
|
||||
lines[i] += "..";
|
||||
}
|
||||
}
|
||||
@ -394,6 +404,21 @@ void Peers::add_scan_results()
|
||||
model.appendRow(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Peers::add_scan_results()
|
||||
{
|
||||
int index;
|
||||
char cmd[20];
|
||||
|
||||
index = 0;
|
||||
while (wpagui) {
|
||||
snprintf(cmd, sizeof(cmd), "BSS %d", index++);
|
||||
if (index > 1000)
|
||||
break;
|
||||
|
||||
add_bss(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -715,6 +740,26 @@ void Peers::event_notify(WpaMsg msg)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (text.startsWith(WPA_EVENT_BSS_ADDED)) {
|
||||
/* CTRL-EVENT-BSS-ADDED 34 00:11:22:33:44:55 */
|
||||
QStringList items = text.split(' ');
|
||||
if (items.size() < 2)
|
||||
return;
|
||||
char cmd[20];
|
||||
snprintf(cmd, sizeof(cmd), "BSS ID-%d", items[1].toInt());
|
||||
add_bss(cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (text.startsWith(WPA_EVENT_BSS_REMOVED)) {
|
||||
/* CTRL-EVENT-BSS-REMOVED 34 00:11:22:33:44:55 */
|
||||
QStringList items = text.split(' ');
|
||||
if (items.size() < 2)
|
||||
return;
|
||||
remove_bss(items[1].toInt());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,6 +49,8 @@ private:
|
||||
void add_station(QString info);
|
||||
void add_stations();
|
||||
void add_single_station(const char *addr);
|
||||
void add_bss(const char *cmd);
|
||||
void remove_bss(int id);
|
||||
void add_scan_results();
|
||||
void update_peers();
|
||||
QStandardItem * find_addr(QString addr);
|
||||
|
Loading…
Reference in New Issue
Block a user