Browse Source

P2P: Add Device Name into WPS IE in Probe Request frames

Jouni Malinen 14 years ago
parent
commit
63675def6e
4 changed files with 18 additions and 0 deletions
  1. 5 0
      src/wps/wps.c
  2. 3 0
      src/wps/wps.h
  3. 1 0
      src/wps/wps_dev_attr.h
  4. 9 0
      src/wps/wps_registrar.c

+ 5 - 0
src/wps/wps.c

@@ -488,6 +488,11 @@ struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev,
 		return NULL;
 		return NULL;
 	}
 	}
 
 
+	if (dev->p2p && wps_build_dev_name(dev, ie)) {
+		wpabuf_free(ie);
+		return NULL;
+	}
+
 	return wps_ie_encapsulate(ie);
 	return wps_ie_encapsulate(ie);
 }
 }
 
 

+ 3 - 0
src/wps/wps.h

@@ -75,6 +75,7 @@ struct wps_credential {
  * @pri_dev_type: Primary Device Type
  * @pri_dev_type: Primary Device Type
  * @os_version: OS Version
  * @os_version: OS Version
  * @rf_bands: RF bands (WPS_RF_24GHZ, WPS_RF_50GHZ flags)
  * @rf_bands: RF bands (WPS_RF_24GHZ, WPS_RF_50GHZ flags)
+ * @p2p: Whether the device is a P2P device
  */
  */
 struct wps_device_data {
 struct wps_device_data {
 	u8 mac_addr[ETH_ALEN];
 	u8 mac_addr[ETH_ALEN];
@@ -86,6 +87,8 @@ struct wps_device_data {
 	u8 pri_dev_type[WPS_DEV_TYPE_LEN];
 	u8 pri_dev_type[WPS_DEV_TYPE_LEN];
 	u32 os_version;
 	u32 os_version;
 	u8 rf_bands;
 	u8 rf_bands;
+
+	int p2p;
 };
 };
 
 
 struct oob_conf_data {
 struct oob_conf_data {

+ 1 - 0
src/wps/wps_dev_attr.h

@@ -26,6 +26,7 @@ int wps_build_os_version(struct wps_device_data *dev, struct wpabuf *msg);
 int wps_build_rf_bands(struct wps_device_data *dev, struct wpabuf *msg);
 int wps_build_rf_bands(struct wps_device_data *dev, struct wpabuf *msg);
 int wps_build_primary_dev_type(struct wps_device_data *dev,
 int wps_build_primary_dev_type(struct wps_device_data *dev,
 			       struct wpabuf *msg);
 			       struct wpabuf *msg);
+int wps_build_dev_name(struct wps_device_data *dev, struct wpabuf *msg);
 int wps_process_device_attrs(struct wps_device_data *dev,
 int wps_process_device_attrs(struct wps_device_data *dev,
 			     struct wps_parse_attr *attr);
 			     struct wps_parse_attr *attr);
 int wps_process_os_version(struct wps_device_data *dev, const u8 *ver);
 int wps_process_os_version(struct wps_device_data *dev, const u8 *ver);

+ 9 - 0
src/wps/wps_registrar.c

@@ -1056,6 +1056,15 @@ static int wps_set_ie(struct wps_registrar *reg)
 		return -1;
 		return -1;
 	}
 	}
 
 
+#ifdef CONFIG_P2P
+	if (wps_build_dev_name(&reg->wps->dev, beacon) ||
+	    wps_build_primary_dev_type(&reg->wps->dev, beacon)) {
+		wpabuf_free(beacon);
+		wpabuf_free(probe);
+		return -1;
+	}
+#endif /* CONFIG_P2P */
+
 	beacon = wps_ie_encapsulate(beacon);
 	beacon = wps_ie_encapsulate(beacon);
 	probe = wps_ie_encapsulate(probe);
 	probe = wps_ie_encapsulate(probe);