From 63675def6e4b2b97c0bc36288d4c205007f24ef0 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 18 Jul 2010 14:30:24 -0700 Subject: [PATCH] P2P: Add Device Name into WPS IE in Probe Request frames --- src/wps/wps.c | 5 +++++ src/wps/wps.h | 3 +++ src/wps/wps_dev_attr.h | 1 + src/wps/wps_registrar.c | 9 +++++++++ 4 files changed, 18 insertions(+) diff --git a/src/wps/wps.c b/src/wps/wps.c index 4436e83e9..3b6bf193e 100644 --- a/src/wps/wps.c +++ b/src/wps/wps.c @@ -488,6 +488,11 @@ struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev, return NULL; } + if (dev->p2p && wps_build_dev_name(dev, ie)) { + wpabuf_free(ie); + return NULL; + } + return wps_ie_encapsulate(ie); } diff --git a/src/wps/wps.h b/src/wps/wps.h index b8fb4e9a6..432dcc5f0 100644 --- a/src/wps/wps.h +++ b/src/wps/wps.h @@ -75,6 +75,7 @@ struct wps_credential { * @pri_dev_type: Primary Device Type * @os_version: OS Version * @rf_bands: RF bands (WPS_RF_24GHZ, WPS_RF_50GHZ flags) + * @p2p: Whether the device is a P2P device */ struct wps_device_data { u8 mac_addr[ETH_ALEN]; @@ -86,6 +87,8 @@ struct wps_device_data { u8 pri_dev_type[WPS_DEV_TYPE_LEN]; u32 os_version; u8 rf_bands; + + int p2p; }; struct oob_conf_data { diff --git a/src/wps/wps_dev_attr.h b/src/wps/wps_dev_attr.h index 1c80df1b6..e3cdf0db2 100644 --- a/src/wps/wps_dev_attr.h +++ b/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_primary_dev_type(struct wps_device_data *dev, 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, struct wps_parse_attr *attr); int wps_process_os_version(struct wps_device_data *dev, const u8 *ver); diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c index 7f26306c5..03023b007 100644 --- a/src/wps/wps_registrar.c +++ b/src/wps/wps_registrar.c @@ -1056,6 +1056,15 @@ static int wps_set_ie(struct wps_registrar *reg) return -1; } +#ifdef CONFIG_P2P + if (wps_build_dev_name(®->wps->dev, beacon) || + wps_build_primary_dev_type(®->wps->dev, beacon)) { + wpabuf_free(beacon); + wpabuf_free(probe); + return -1; + } +#endif /* CONFIG_P2P */ + beacon = wps_ie_encapsulate(beacon); probe = wps_ie_encapsulate(probe);