P2P: Preparations for adding P2P IE into Beacon/Probe Response frames
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/ap_drv_ops.c
src/ap/hostapd.c
src/ap/hostapd.h

index f264a3e..2f6932b 100644 (file)
@@ -50,8 +50,48 @@ static int hostapd_set_ap_wps_ie(struct hostapd_data *hapd)
        beacon = hapd->wps_beacon_ie;
        proberesp = hapd->wps_probe_resp_ie;
 
+#ifdef CONFIG_P2P
+       if (hapd->wps_beacon_ie == NULL && hapd->p2p_beacon_ie == NULL)
+               beacon = NULL;
+       else {
+               beacon = wpabuf_alloc((hapd->wps_beacon_ie ?
+                                      wpabuf_len(hapd->wps_beacon_ie) : 0) +
+                                     (hapd->p2p_beacon_ie ?
+                                      wpabuf_len(hapd->p2p_beacon_ie) : 0));
+               if (beacon == NULL)
+                       return -1;
+               if (hapd->wps_beacon_ie)
+                       wpabuf_put_buf(beacon, hapd->wps_beacon_ie);
+               if (hapd->p2p_beacon_ie)
+                       wpabuf_put_buf(beacon, hapd->p2p_beacon_ie);
+       }
+
+       if (hapd->wps_probe_resp_ie == NULL && hapd->p2p_probe_resp_ie == NULL)
+               proberesp = NULL;
+       else {
+               proberesp = wpabuf_alloc(
+                       (hapd->wps_probe_resp_ie ?
+                        wpabuf_len(hapd->wps_probe_resp_ie) : 0) +
+                       (hapd->p2p_probe_resp_ie ?
+                        wpabuf_len(hapd->p2p_probe_resp_ie) : 0));
+               if (proberesp == NULL) {
+                       wpabuf_free(beacon);
+                       return -1;
+               }
+               if (hapd->wps_probe_resp_ie)
+                       wpabuf_put_buf(proberesp, hapd->wps_probe_resp_ie);
+               if (hapd->p2p_probe_resp_ie)
+                       wpabuf_put_buf(proberesp, hapd->p2p_probe_resp_ie);
+       }
+#endif /* CONFIG_P2P */
+
        ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp);
 
+#ifdef CONFIG_P2P
+       wpabuf_free(beacon);
+       wpabuf_free(proberesp);
+#endif /* CONFIG_P2P */
+
        return ret;
 }
 
index 841f9c5..2d50a51 100644 (file)
@@ -235,6 +235,13 @@ static void hostapd_cleanup(struct hostapd_data *hapd)
 
        os_free(hapd->probereq_cb);
        hapd->probereq_cb = NULL;
+
+#ifdef CONFIG_P2P
+       wpabuf_free(hapd->p2p_beacon_ie);
+       hapd->p2p_beacon_ie = NULL;
+       wpabuf_free(hapd->p2p_probe_resp_ie);
+       hapd->p2p_probe_resp_ie = NULL;
+#endif /* CONFIG_P2P */
 }
 
 
index d0d67c8..1eacb8d 100644 (file)
@@ -180,6 +180,11 @@ struct hostapd_data {
        void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
                                   const u8 *uuid_e);
        void *wps_reg_success_cb_ctx;
+
+#ifdef CONFIG_P2P
+       struct wpabuf *p2p_beacon_ie;
+       struct wpabuf *p2p_probe_resp_ie;
+#endif /* CONFIG_P2P */
 };