From 0c6b310e833738693062411b1d25d4d7a22ec0e7 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 18 Jul 2010 14:30:25 -0700 Subject: [PATCH] P2P: Show P2P info in ctrl_iface scan results --- wpa_supplicant/bss.c | 7 ++++++- wpa_supplicant/ctrl_iface.c | 28 +++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index e2ac23072..dc978afae 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -325,7 +325,7 @@ void wpa_bss_update_start(struct wpa_supplicant *wpa_s) void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s, struct wpa_scan_res *res) { - const u8 *ssid; + const u8 *ssid, *p2p; struct wpa_bss *bss; ssid = wpa_scan_get_ie(res, WLAN_EID_SSID); @@ -340,6 +340,11 @@ void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s, return; } + p2p = wpa_scan_get_vendor_ie(res, P2P_IE_VENDOR_TYPE); + if (p2p && ssid[1] == P2P_WILDCARD_SSID_LEN && + os_memcmp(ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN) == 0) + return; /* Skip P2P listen discovery results here */ + /* TODO: add option for ignoring BSSes we are not interested in * (to save memory) */ bss = wpa_bss_get(wpa_s, res->bssid, ssid + 2, ssid[1]); diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 3b72121eb..74daf9606 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -904,7 +904,13 @@ static int wpa_supplicant_ctrl_iface_scan_result( { char *pos, *end; int ret; - const u8 *ie, *ie2; + const u8 *ie, *ie2, *p2p; + + p2p = wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE); + if (p2p && bss->ssid_len == P2P_WILDCARD_SSID_LEN && + os_memcmp(bss->ssid, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN) == + 0) + return 0; /* Do not show P2P listen discovery results here */ pos = buf; end = buf + buflen; @@ -939,6 +945,12 @@ static int wpa_supplicant_ctrl_iface_scan_result( return pos - buf; pos += ret; } + if (p2p) { + ret = os_snprintf(pos, end - pos, "[P2P]"); + if (ret < 0 || ret >= end - pos) + return pos - buf; + pos += ret; + } ret = os_snprintf(pos, end - pos, "\t%s", wpa_ssid_txt(bss->ssid, bss->ssid_len)); @@ -1658,6 +1670,12 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s, return pos - buf; pos += ret; } + if (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE)) { + ret = os_snprintf(pos, end - pos, "[P2P]"); + if (ret < 0 || ret >= end - pos) + return pos - buf; + pos += ret; + } ret = os_snprintf(pos, end - pos, "\n"); if (ret < 0 || ret >= end - pos) @@ -1714,6 +1732,14 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s, pos += ret; #endif /* CONFIG_WPS */ +#ifdef CONFIG_P2P + ie = (const u8 *) (bss + 1); + ret = wpas_p2p_scan_result_text(ie, bss->ie_len, pos, end); + if (ret < 0 || ret >= end - pos) + return pos - buf; + pos += ret; +#endif /* CONFIG_P2P */ + return pos - buf; }