WPS ER: Add more AP information into the ctrl_interface message
This allow wpa_gui to show AP BSSID, WPS State (configured/unconfigured), and primary device type.
This commit is contained in:
parent
c3016248f4
commit
e694b34474
4 changed files with 55 additions and 14 deletions
|
@ -413,6 +413,7 @@ union wps_event_data {
|
|||
|
||||
struct wps_event_er_ap {
|
||||
const u8 *uuid;
|
||||
const u8 *mac_addr;
|
||||
const char *friendly_name;
|
||||
const char *manufacturer;
|
||||
const char *manufacturer_url;
|
||||
|
@ -422,6 +423,8 @@ union wps_event_data {
|
|||
const char *model_url;
|
||||
const char *serial_number;
|
||||
const char *upc;
|
||||
const u8 *pri_dev_type;
|
||||
u8 wps_state;
|
||||
} ap;
|
||||
|
||||
struct wps_event_er_enrollee {
|
||||
|
|
|
@ -68,6 +68,7 @@ struct wps_er_ap {
|
|||
u8 uuid[WPS_UUID_LEN];
|
||||
u8 pri_dev_type[8];
|
||||
u8 wps_state;
|
||||
u8 mac_addr[ETH_ALEN];
|
||||
char *friendly_name;
|
||||
char *manufacturer;
|
||||
char *manufacturer_url;
|
||||
|
@ -246,6 +247,9 @@ static void wps_er_ap_event(struct wps_context *wps, struct wps_er_ap *ap,
|
|||
evap->model_url = ap->model_url;
|
||||
evap->serial_number = ap->serial_number;
|
||||
evap->upc = ap->upc;
|
||||
evap->pri_dev_type = ap->pri_dev_type;
|
||||
evap->wps_state = ap->wps_state;
|
||||
evap->mac_addr = ap->mac_addr;
|
||||
wps->event_cb(wps->cb_ctx, event, &data);
|
||||
}
|
||||
|
||||
|
@ -396,6 +400,8 @@ static void wps_er_ap_get_m1(struct wps_er_ap *ap, struct wpabuf *m1)
|
|||
os_memcpy(ap->pri_dev_type, attr.primary_dev_type, 8);
|
||||
if (attr.wps_state)
|
||||
ap->wps_state = *attr.wps_state;
|
||||
if (attr.mac_addr)
|
||||
os_memcpy(ap->mac_addr, attr.mac_addr, ETH_ALEN);
|
||||
|
||||
wps_er_subscribe(ap);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ enum peer_type {
|
|||
PEER_TYPE_AP_WPS,
|
||||
PEER_TYPE_WPS_PIN_NEEDED,
|
||||
PEER_TYPE_WPS_ER_AP,
|
||||
PEER_TYPE_WPS_ER_AP_UNCONFIGURED,
|
||||
PEER_TYPE_WPS_ER_ENROLLEE
|
||||
};
|
||||
|
||||
|
@ -117,6 +118,9 @@ void Peers::context_menu(const QPoint &pos)
|
|||
case PEER_TYPE_WPS_ER_AP:
|
||||
title = tr("ER: WPS AP");
|
||||
break;
|
||||
case PEER_TYPE_WPS_ER_AP_UNCONFIGURED:
|
||||
title = tr("ER: WPS AP (Unconfigured)");
|
||||
break;
|
||||
case PEER_TYPE_WPS_ER_ENROLLEE:
|
||||
title = tr("ER: WPS Enrollee");
|
||||
break;
|
||||
|
@ -456,26 +460,40 @@ void Peers::event_notify(WpaMsg msg)
|
|||
|
||||
if (text.startsWith(WPS_EVENT_ER_AP_ADD)) {
|
||||
/*
|
||||
* WPS-ER-AP-ADD 87654321-9abc-def0-1234-56789abc0002|
|
||||
* Very friendly name|Company|Long description of the model|
|
||||
* WPS-ER-AP-ADD 87654321-9abc-def0-1234-56789abc0002
|
||||
* 02:11:22:33:44:55 pri_dev_type=6-0050F204-1 wps_state=1
|
||||
* |Very friendly name|Company|Long description of the model|
|
||||
* WAP|http://w1.fi/|http://w1.fi/hostapd/
|
||||
*/
|
||||
int pos = text.indexOf(' ');
|
||||
QStringList items = text.split(' ');
|
||||
if (items.size() < 5)
|
||||
return;
|
||||
QString uuid = items[1];
|
||||
QString addr = items[2];
|
||||
QString pri_dev_type = items[3];
|
||||
int wps_state = items[4].mid(10).toInt();
|
||||
|
||||
int pos = text.indexOf('|');
|
||||
if (pos < 0)
|
||||
return;
|
||||
QStringList items = text.mid(pos + 1).split('|');
|
||||
if (items.size() < 2)
|
||||
items = text.mid(pos + 1).split('|');
|
||||
if (items.size() < 1)
|
||||
return;
|
||||
|
||||
QStandardItem *item = find_uuid(items[0]);
|
||||
QStandardItem *item = find_uuid(uuid);
|
||||
if (item)
|
||||
return;
|
||||
|
||||
item = new QStandardItem(*ap_icon, items[1]);
|
||||
item = new QStandardItem(*ap_icon, items[0]);
|
||||
if (item) {
|
||||
item->setData(items[0], peer_role_uuid);
|
||||
item->setData(PEER_TYPE_WPS_ER_AP, peer_role_type);
|
||||
item->setToolTip(items.join(QString("\n")));
|
||||
item->setData(uuid, peer_role_uuid);
|
||||
item->setData(addr, peer_role_address);
|
||||
item->setData(wps_state == 2 ? PEER_TYPE_WPS_ER_AP:
|
||||
PEER_TYPE_WPS_ER_AP_UNCONFIGURED,
|
||||
peer_role_type);
|
||||
item->setToolTip(addr + QString("\n") +
|
||||
pri_dev_type + QString("\n") +
|
||||
items.join(QString("\n")));
|
||||
model.appendRow(item);
|
||||
}
|
||||
|
||||
|
@ -494,8 +512,11 @@ void Peers::event_notify(WpaMsg msg)
|
|||
peer_role_uuid, items[1]);
|
||||
for (int i = 0; i < lst.size(); i++) {
|
||||
QStandardItem *item = model.itemFromIndex(lst[i]);
|
||||
if (item && item->data(peer_role_type).toInt() ==
|
||||
PEER_TYPE_WPS_ER_AP)
|
||||
if (item &&
|
||||
(item->data(peer_role_type).toInt() ==
|
||||
PEER_TYPE_WPS_ER_AP ||
|
||||
item->data(peer_role_type).toInt() ==
|
||||
PEER_TYPE_WPS_ER_AP_UNCONFIGURED))
|
||||
model.removeRow(lst[i].row());
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -414,9 +414,20 @@ static void wpa_supplicant_wps_event_er_ap_add(struct wpa_supplicant *wpa_s,
|
|||
struct wps_event_er_ap *ap)
|
||||
{
|
||||
char uuid_str[100];
|
||||
char dev_type[20];
|
||||
|
||||
uuid_bin2str(ap->uuid, uuid_str, sizeof(uuid_str));
|
||||
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_ER_AP_ADD "%s|%s|%s|%s|%s|%s|%s",
|
||||
uuid_str,
|
||||
if (ap->pri_dev_type)
|
||||
os_snprintf(dev_type, sizeof(dev_type), "%u-%08X-%u",
|
||||
WPA_GET_BE16(ap->pri_dev_type),
|
||||
WPA_GET_BE32(ap->pri_dev_type + 2),
|
||||
WPA_GET_BE16(ap->pri_dev_type + 6));
|
||||
else
|
||||
dev_type[0] = '\0';
|
||||
|
||||
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_ER_AP_ADD "%s " MACSTR
|
||||
" pri_dev_type=%s wps_state=%d |%s|%s|%s|%s|%s|%s|",
|
||||
uuid_str, MAC2STR(ap->mac_addr), dev_type, ap->wps_state,
|
||||
ap->friendly_name ? ap->friendly_name : "",
|
||||
ap->manufacturer ? ap->manufacturer : "",
|
||||
ap->model_description ? ap->model_description : "",
|
||||
|
|
Loading…
Reference in a new issue