From 87f841a1407dc8f988d6c43a9c4307e34e86986f Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 22 Dec 2011 21:45:20 +0200 Subject: [PATCH] P2P: Show persistent group info on P2P_PEER data Add "persistent=" line to P2P_PEER ctrl_iface data if a persistent group credentials are available for this peer. This makes it easier for external programs to figure out when a persistent group could be re-invoked with this peer. For now, this information is only available on the P2P client, but similar information can be added for GO once a list of P2P clients is maintained with the persistent group data. Signed-hostap: Jouni Malinen --- wpa_supplicant/ctrl_iface.c | 11 ++++++++++- wpa_supplicant/p2p_supplicant.c | 15 +++++++++++++++ wpa_supplicant/p2p_supplicant.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 09739eea4..fcb4fa48d 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2989,6 +2989,7 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd, const struct p2p_peer_info *info; char *pos, *end; char devtype[WPS_DEV_TYPE_BUFSIZE]; + struct wpa_ssid *ssid; if (!wpa_s->global->p2p) return -1; @@ -3042,9 +3043,17 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd, return pos - buf; pos += res; + ssid = wpas_p2p_get_persistent(wpa_s, info->p2p_device_addr); + if (ssid) { + res = os_snprintf(pos, end - pos, "persistent=%d\n", ssid->id); + if (res < 0 || res >= end - pos) + return pos - buf; + pos += res; + } + res = p2p_get_peer_info_txt(info, pos, end - pos); if (res < 0) - return -1; + return pos - buf; pos += res; return pos - buf; diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index a606b9d07..367fce144 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -4260,3 +4260,18 @@ void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s, wpas_p2p_group_formation_timeout(wpa_s->parent, NULL); } } + + +struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s, + const u8 *addr) +{ + struct wpa_ssid *s; + + for (s = wpa_s->conf->ssid; s; s = s->next) { + if (s->disabled == 2 && + os_memcmp(s->bssid, addr, ETH_ALEN) == 0) + return s; + } + + return NULL; +} diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h index 9a0af1fa5..0a450b6c7 100644 --- a/wpa_supplicant/p2p_supplicant.h +++ b/wpa_supplicant/p2p_supplicant.h @@ -131,5 +131,7 @@ void wpas_p2p_wps_failed(struct wpa_supplicant *wpa_s, int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s); void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); +struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s, + const u8 *addr); #endif /* P2P_SUPPLICANT_H */