P2P: Add group notifications
authorJouni Malinen <jouni.malinen@atheros.com>
Sun, 18 Jul 2010 21:30:25 +0000 (14:30 -0700)
committerJouni Malinen <j@w1.fi>
Thu, 9 Sep 2010 14:17:17 +0000 (07:17 -0700)
src/ap/ieee802_11.c
src/ap/sta_info.c

index c1f33f2..4cf6229 100644 (file)
@@ -779,6 +779,10 @@ static u16 check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta,
                wpabuf_free(sta->p2p_ie);
                sta->p2p_ie = ieee802_11_vendor_ie_concat(ies, ies_len,
                                                          P2P_IE_VENDOR_TYPE);
+
+               if (p2p_group_notif_assoc(hapd->p2p_group, sta->addr,
+                                         ies, ies_len) < 0)
+                       return WLAN_STATUS_UNSPECIFIED_FAILURE;
        } else {
                wpabuf_free(sta->p2p_ie);
                sta->p2p_ie = NULL;
@@ -876,6 +880,31 @@ static void send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta,
        }
 #endif /* CONFIG_WPS */
 
+#ifdef CONFIG_P2P
+       if (sta->p2p_ie) {
+               struct wpabuf *p2p_resp_ie;
+               enum p2p_status_code status;
+               switch (status_code) {
+               case WLAN_STATUS_SUCCESS:
+                       status = P2P_SC_SUCCESS;
+                       break;
+               case WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA:
+                       status = P2P_SC_FAIL_LIMIT_REACHED;
+                       break;
+               default:
+                       status = P2P_SC_FAIL_INVALID_PARAMS;
+                       break;
+               }
+               p2p_resp_ie = p2p_group_assoc_resp_ie(hapd->p2p_group, status);
+               if (p2p_resp_ie) {
+                       os_memcpy(p, wpabuf_head(p2p_resp_ie),
+                                 wpabuf_len(p2p_resp_ie));
+                       p += wpabuf_len(p2p_resp_ie);
+                       wpabuf_free(p2p_resp_ie);
+               }
+       }
+#endif /* CONFIG_P2P */
+
        send_len += p - reply->u.assoc_resp.variable;
 
        if (hapd->drv.send_mgmt_frame(hapd, reply, send_len) < 0)
index b0c80f5..8cd6c3f 100644 (file)
@@ -20,6 +20,7 @@
 #include "radius/radius.h"
 #include "radius/radius_client.h"
 #include "drivers/driver.h"
+#include "p2p/p2p.h"
 #include "hostapd.h"
 #include "accounting.h"
 #include "ieee802_1x.h"
@@ -199,6 +200,10 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
        eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
 #endif /* CONFIG_IEEE80211W */
 
+#ifdef CONFIG_P2P
+       p2p_group_notif_disassoc(hapd->p2p_group, sta->addr);
+#endif /* CONFIG_P2P */
+
        wpabuf_free(sta->wps_ie);
        wpabuf_free(sta->p2p_ie);