P2P: Store SSID of the group in p2p_group data
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 8 May 2012 14:33:14 +0000 (17:33 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 8 May 2012 14:38:57 +0000 (17:38 +0300)
This can be used with P2P management operations that need to verify
whether the local device is operating a specific group based on
P2P Group ID attribute from a peer.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/p2p/p2p.h
src/p2p/p2p_group.c
src/p2p/p2p_i.h
wpa_supplicant/ap.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/p2p_supplicant.h

index 44162f6..92e7048 100644 (file)
@@ -1262,6 +1262,16 @@ struct p2p_group_config {
        unsigned int max_clients;
 
        /**
+        * ssid - Group SSID
+        */
+       u8 ssid[32];
+
+       /**
+        * ssid_len - Length of SSID
+        */
+       size_t ssid_len;
+
+       /**
         * cb_ctx - Context to use with callback functions
         */
        void *cb_ctx;
index fafd135..44b387a 100644 (file)
@@ -731,3 +731,15 @@ int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr)
 
        return 0;
 }
+
+
+int p2p_group_is_group_id_match(struct p2p_group *group, const u8 *group_id,
+                               size_t group_id_len)
+{
+       if (group_id_len != ETH_ALEN + group->cfg->ssid_len)
+               return 0;
+       if (os_memcmp(group_id, group->p2p->cfg->dev_addr, ETH_ALEN) != 0)
+               return 0;
+       return os_memcmp(group_id + ETH_ALEN, group->cfg->ssid,
+                        group->cfg->ssid_len) == 0;
+}
index 3a764ca..279225c 100644 (file)
@@ -549,6 +549,8 @@ const u8 * p2p_group_get_interface_addr(struct p2p_group *group);
 u8 p2p_group_presence_req(struct p2p_group *group,
                          const u8 *client_interface_addr,
                          const u8 *noa, size_t noa_len);
+int p2p_group_is_group_id_match(struct p2p_group *group, const u8 *group_id,
+                               size_t group_id_len);
 
 
 void p2p_buf_add_action_hdr(struct wpabuf *buf, u8 subtype, u8 dialog_token);
index 21aa7f6..d531583 100644 (file)
@@ -540,9 +540,8 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
                hapd_iface->bss[i]->sta_authorized_cb_ctx = wpa_s;
 #ifdef CONFIG_P2P
                hapd_iface->bss[i]->p2p = wpa_s->global->p2p;
-               hapd_iface->bss[i]->p2p_group = wpas_p2p_group_init(
-                       wpa_s, ssid->p2p_persistent_group,
-                       ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION);
+               hapd_iface->bss[i]->p2p_group = wpas_p2p_group_init(wpa_s,
+                                                                   ssid);
 #endif /* CONFIG_P2P */
                hapd_iface->bss[i]->setup_complete_cb = wpas_ap_configured_cb;
                hapd_iface->bss[i]->setup_complete_cb_ctx = wpa_s;
index 79c7b65..c25c03e 100644 (file)
@@ -3665,8 +3665,7 @@ static void wpas_p2p_idle_update(void *ctx, int idle)
 
 
 struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s,
-                                      int persistent_group,
-                                      int group_formation)
+                                      struct wpa_ssid *ssid)
 {
        struct p2p_group *group;
        struct p2p_group_config *cfg;
@@ -3680,9 +3679,9 @@ struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s,
        if (cfg == NULL)
                return NULL;
 
-       if (persistent_group && wpa_s->conf->persistent_reconnect)
+       if (ssid->p2p_persistent_group && wpa_s->conf->persistent_reconnect)
                cfg->persistent_group = 2;
-       else if (persistent_group)
+       else if (ssid->p2p_persistent_group)
                cfg->persistent_group = 1;
        os_memcpy(cfg->interface_addr, wpa_s->own_addr, ETH_ALEN);
        if (wpa_s->max_stations &&
@@ -3690,6 +3689,8 @@ struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s,
                cfg->max_clients = wpa_s->max_stations;
        else
                cfg->max_clients = wpa_s->conf->max_num_sta;
+       os_memcpy(cfg->ssid, ssid->ssid, ssid->ssid_len);
+       cfg->ssid_len = ssid->ssid_len;
        cfg->cb_ctx = wpa_s;
        cfg->ie_update = wpas_p2p_ie_update;
        cfg->idle_update = wpas_p2p_idle_update;
@@ -3697,7 +3698,7 @@ struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s,
        group = p2p_group_init(wpa_s->global->p2p, cfg);
        if (group == NULL)
                os_free(cfg);
-       if (!group_formation)
+       if (ssid->mode != WPAS_MODE_P2P_GROUP_FORMATION)
                p2p_group_notif_formation_done(group);
        wpa_s->p2p_group = group;
        return group;
index a0d94b6..87fde00 100644 (file)
@@ -32,8 +32,7 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
                                  struct wpa_ssid *ssid, int addr_allocated,
                                  int freq);
 struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s,
-                                      int persistent_group,
-                                      int group_formation);
+                                      struct wpa_ssid *ssid);
 void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
                          int registrar);
 enum wpas_p2p_prov_disc_use {