P2P: Show persistent group info on P2P_PEER data
authorJouni Malinen <j@w1.fi>
Thu, 22 Dec 2011 19:45:20 +0000 (21:45 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 22 Dec 2011 19:45:20 +0000 (21:45 +0200)
Add "persistent=<network id>" 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 <j@w1.fi>

wpa_supplicant/ctrl_iface.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/p2p_supplicant.h

index 09739ee..fcb4fa4 100644 (file)
@@ -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;
index a606b9d..367fce1 100644 (file)
@@ -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;
+}
index 9a0af1f..0a450b6 100644 (file)
@@ -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 */