Patchwork P2P: Inviting a p2p device from already running persistent p2p go

login
register
mail settings
Submitter Neeraj Garg
Date Feb. 6, 2012, 1:47 p.m.
Message ID <2C2F1EBA8050E74EA81502D5740B4BD6BBD9F5FA94@SJEXCHCCR02.corp.ad.broadcom.com>
Download mbox | patch
Permalink /patch/139736/
State Accepted
Commit c427ac9211745a80c33d098dc8adc26fb9acd52c
Headers show

Comments

Neeraj Garg - Feb. 6, 2012, 1:47 p.m.
Hello Jouni,
Thanks for the quick reply. Your patch really looks good and work well for my requirement. I fully agree, this is a better patch.
Please apply it.

Regards,
-Neeraj
Jouni Malinen - Feb. 6, 2012, 7:59 p.m.
On Mon, Feb 06, 2012 at 05:47:56AM -0800, Neeraj Kumar Garg wrote:
> Your patch really looks good and work well for my requirement. I fully agree, this is a better patch.
> Please apply it.

Thanks for confirming - this patch is now in hostap.git.

Patch

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 88981d4..6a3223e 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -3053,7 +3053,7 @@  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);
+       ssid = wpas_p2p_get_persistent(wpa_s, info->p2p_device_addr, NULL, 0);
        if (ssid) {
                res = os_snprintf(pos, end - pos, "persistent=%d\n", ssid->id);
                if (res < 0 || res >= end - pos)
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index a6298a7..1b66bdd 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -3707,6 +3707,7 @@  int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname,
        enum p2p_invite_role role;
        u8 *bssid = NULL;
        struct wpa_ssid *ssid;
+       int persistent;

        for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
                if (os_strcmp(wpa_s->ifname, ifname) == 0)
@@ -3724,6 +3725,10 @@  int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname,
                return -1;
        }

+       persistent = ssid->p2p_persistent_group &&
+               wpas_p2p_get_persistent(wpa_s->parent, peer_addr,
+                                       ssid->ssid, ssid->ssid_len);
+
        if (ssid->mode == WPAS_MODE_P2P_GO) {
                role = P2P_INVITE_ROLE_ACTIVE_GO;
                bssid = wpa_s->own_addr;
@@ -3746,14 +3751,14 @@  int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname,
        if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
                return wpa_drv_p2p_invite(wpa_s, peer_addr, role, bssid,
                                          ssid->ssid, ssid->ssid_len,
-                                         go_dev_addr, 0);
+                                         go_dev_addr, persistent);

        if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
                return -1;

        return p2p_invite(wpa_s->global->p2p, peer_addr, role, bssid,
                          ssid->ssid, ssid->ssid_len, wpa_s->assoc_freq,
-                         go_dev_addr, 0);
+                         go_dev_addr, persistent);
 }


@@ -4353,7 +4358,8 @@  void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s,


 struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
-                                         const u8 *addr)
+                                         const u8 *addr, const u8 *ssid,
+                                         size_t ssid_len)
 {
        struct wpa_ssid *s;
        size_t i;
@@ -4361,6 +4367,10 @@  struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
        for (s = wpa_s->conf->ssid; s; s = s->next) {
                if (s->disabled != 2)
                        continue;
+               if (ssid &&
+                   (ssid_len != s->ssid_len ||
+                    os_memcmp(ssid, s->ssid, ssid_len) != 0))
+                       continue;
                if (os_memcmp(s->bssid, addr, ETH_ALEN) == 0)
                        return s; /* peer is GO in the persistent group */
                if (s->mode != WPAS_MODE_P2P_GO || s->p2p_client_list == NULL)
diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h
index 605741d..599ff3f 100644
--- a/wpa_supplicant/p2p_supplicant.h
+++ b/wpa_supplicant/p2p_supplicant.h
@@ -133,7 +133,8 @@  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);
+                                         const u8 *addr, const u8 *ssid,
+                                         size_t ssid_len);
 void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
                                       const u8 *addr);