WPS: Added [WPS], [WPS-PIN], [WPS-PBC] flags for scan results

This commit is contained in:
Jouni Malinen 2008-12-08 20:57:59 +02:00
parent 7e45830ab7
commit eef7d7a138
2 changed files with 43 additions and 0 deletions

View file

@ -136,3 +136,15 @@ wpa_cli:
wpa_cli wps_reg <AP BSSID> <AP PIN>
(example: wpa_cli wps_reg 02:34:56:78:9a:bc 12345670)
Scanning
--------
Scan results ('wpa_cli scan_results' or 'wpa_cli bss <idx>') include a
flags field that is used to indicate whether the BSS support WPS. If
the AP support WPS, but has not recently activated a Registrar, [WPS]
flag will be included. If PIN method has been recently selected,
[WPS-PIN] is shown instead. Similarly, [WPS-PBC] is shown if PBC mode
is in progress. GUI programs can use these as triggers for suggesting
a guided WPS configuration to the user.

View file

@ -28,6 +28,7 @@
#include "eap_peer/eap.h"
#include "ieee802_11_defs.h"
#include "wps_supplicant.h"
#include "wps/wps.h"
static int wpa_supplicant_global_iface_interfaces(struct wpa_global *global,
@ -614,6 +615,34 @@ static char * wpa_supplicant_ie_txt(char *pos, char *end, const char *proto,
return pos;
}
static char * wpa_supplicant_wps_ie_txt(char *pos, char *end,
const struct wpa_scan_res *res)
{
#ifdef CONFIG_WPS
struct wpabuf *wps_ie;
int ret;
const char *txt;
wps_ie = wpa_scan_get_vendor_ie_multi(res, WPS_IE_VENDOR_TYPE);
if (wps_ie == NULL)
return pos;
if (wps_is_selected_pbc_registrar(wps_ie))
txt = "[WPS-PBC]";
else if (wps_is_selected_pin_registrar(wps_ie))
txt = "[WPS-PIN]";
else
txt = "[WPS]";
ret = os_snprintf(pos, end - pos, "%s", txt);
if (ret >= 0 && ret < end - pos)
pos += ret;
wpabuf_free(wps_ie);
#endif /* CONFIG_WPS */
return pos;
}
/* Format one result on one text line into a buffer. */
static int wpa_supplicant_ctrl_iface_scan_result(
@ -637,6 +666,7 @@ static int wpa_supplicant_ctrl_iface_scan_result(
ie2 = wpa_scan_get_ie(res, WLAN_EID_RSN);
if (ie2)
pos = wpa_supplicant_ie_txt(pos, end, "WPA2", ie2, 2 + ie2[1]);
pos = wpa_supplicant_wps_ie_txt(pos, end, res);
if (!ie && !ie2 && res->caps & IEEE80211_CAP_PRIVACY) {
ret = os_snprintf(pos, end - pos, "[WEP]");
if (ret < 0 || ret >= end - pos)
@ -1400,6 +1430,7 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
ie2 = wpa_scan_get_ie(bss, WLAN_EID_RSN);
if (ie2)
pos = wpa_supplicant_ie_txt(pos, end, "WPA2", ie2, 2 + ie2[1]);
pos = wpa_supplicant_wps_ie_txt(pos, end, bss);
if (!ie && !ie2 && bss->caps & IEEE80211_CAP_PRIVACY) {
ret = os_snprintf(pos, end - pos, "[WEP]");
if (ret < 0 || ret >= end - pos)