Browse Source

P2P: Preparations for adding P2P IE into Beacon/Probe Response frames

Jouni Malinen 14 years ago
parent
commit
c2af2afb3b
3 changed files with 52 additions and 0 deletions
  1. 40 0
      src/ap/ap_drv_ops.c
  2. 7 0
      src/ap/hostapd.c
  3. 5 0
      src/ap/hostapd.h

+ 40 - 0
src/ap/ap_drv_ops.c

@@ -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;
 }
 

+ 7 - 0
src/ap/hostapd.c

@@ -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 */
 }
 
 

+ 5 - 0
src/ap/hostapd.h

@@ -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 */
 };