nl80211: Add get_noa() support for WFD certification (BRCM)
BUG: b/5367351
Change-Id: I14ed79e10ade205c5dd4cdc0d2e888ed1279d1bb
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index dfca9ef..9dc2494 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -209,6 +209,7 @@
static void mlme_event_deauth_disassoc(struct wpa_driver_nl80211_data *drv,
enum wpa_event_type type,
const u8 *frame, size_t len);
+int wpa_driver_get_p2p_noa(void *priv, u8 *buf, size_t len);
int wpa_driver_set_p2p_noa(void *priv, u8 count, int start, int duration);
int wpa_driver_set_p2p_ps(void *priv, int legacy_ps, int opp_ps, int ctwindow);
int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon,
@@ -6837,6 +6838,7 @@
.remove_pmkid = nl80211_remove_pmkid,
.flush_pmkid = nl80211_flush_pmkid,
#ifdef ANDROID_BRCM_P2P_PATCH
+ .get_noa = wpa_driver_get_p2p_noa,
.set_noa = wpa_driver_set_p2p_noa,
.set_p2p_powersave = wpa_driver_set_p2p_ps,
.set_ap_wps_ie = wpa_driver_set_ap_wps_p2p_ie,
diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c
index 9fb9f00..0d05319 100644
--- a/src/p2p/p2p_group.c
+++ b/src/p2p/p2p_group.c
@@ -499,7 +499,11 @@
} else {
if (group->noa) {
if (wpabuf_size(group->noa) >= noa_len) {
+ #ifdef ANDROID_BRCM_P2P_PATCH
+ group->noa->used = 0;
+ #else
group->noa->size = 0;
+ #endif
wpabuf_put_data(group->noa, noa, noa_len);
} else {
wpabuf_free(group->noa);
@@ -658,11 +662,11 @@
else
wpa_hexdump(MSG_DEBUG, "P2P: Current NoA", curr_noa,
curr_noa_len);
-
+#ifndef ANDROID_BRCM_P2P_PATCH
/* TODO: properly process request and store copy */
if (curr_noa_len > 0)
return P2P_SC_FAIL_UNABLE_TO_ACCOMMODATE;
-
+#endif
return P2P_SC_SUCCESS;
}
diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h
index 52d9311..afb891e 100644
--- a/src/p2p/p2p_i.h
+++ b/src/p2p/p2p_i.h
@@ -532,6 +532,11 @@
/* p2p_group.c */
const u8 * p2p_group_get_interface_addr(struct p2p_group *group);
+
+#ifdef ANDROID_BRCM_P2P_PATCH
+void p2p_get_group_noa(struct p2p_group *group, u8 *noa, size_t* noa_len);
+#endif
+
u8 p2p_group_presence_req(struct p2p_group *group,
const u8 *client_interface_addr,
const u8 *noa, size_t noa_len);
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 1ee2d15..a163c28 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -327,12 +327,12 @@
#if defined(ANDROID_BRCM_P2P_PATCH) && defined(CONFIG_AP)
for (iface = wpa_s->global->ifaces; iface; iface = iface->next) {
if (iface->ap_iface){
- wpa_printf(MSG_DEBUG, "CTRL_IFACE WPS_PBC: iface 0x%08x wpa_s->ap_iface %p", iface, iface->ap_iface);
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE WPS_PBC: iface 0x%08x wpa_s->ap_iface %p", (u32)iface, iface->ap_iface);
wpa_supplicant_ap_wps_pbc(iface, _bssid, _p2p_dev_addr);
return 0;
}
else
- wpa_printf(MSG_DEBUG, "CTRL_IFACE WPS_PBC: ap_iface is not set iface 0x%08x", iface);
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE WPS_PBC: ap_iface is not set iface 0x%08x", (u32)iface);
}
#elif defined CONFIG_AP
if (wpa_s->ap_iface)
@@ -370,14 +370,14 @@
#if defined(ANDROID_BRCM_P2P_PATCH) && defined(CONFIG_AP)
for (iface = wpa_s->global->ifaces; iface; iface = iface->next) {
if (iface->ap_iface){
- wpa_printf(MSG_DEBUG, "CTRL_IFACE WPS_PIN: iface 0x%08x wpa_s->ap_iface %p", iface, iface->ap_iface);
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE WPS_PIN: iface 0x%08x wpa_s->ap_iface %p", (u32)iface, iface->ap_iface);
/* Call the wps registrar for the main interface */
wpa_supplicant_ap_wps_pin(iface, _bssid, pin,
buf, buflen);
return 0;
}
else
- wpa_printf(MSG_DEBUG, "CTRL_IFACE WPS_PIN: ap_iface is not set iface 0x%08x", iface);
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE WPS_PIN: ap_iface is not set iface 0x%08x", (u32)iface);
}
#elif defined CONFIG_AP
if (wpa_s->ap_iface)
@@ -2814,6 +2814,24 @@
buf, buflen);
}
+#ifdef ANDROID_BRCM_P2P_PATCH
+struct wpa_supplicant* p2p_get_apif(struct wpa_supplicant* wpa_s)
+{
+ struct wpa_supplicant* iface;
+ for (iface = wpa_s->global->ifaces; iface; iface = iface->next)
+ if (iface->ap_iface)
+ return iface;
+ return wpa_s;
+}
+struct wpa_supplicant* p2p_get_clientif(struct wpa_supplicant* wpa_s)
+{
+ struct wpa_supplicant* iface;
+ for (iface = wpa_s->global->ifaces; iface; iface = iface->next)
+ if (iface->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT)
+ return iface;
+ return wpa_s;
+}
+#endif
static int p2p_ctrl_set(struct wpa_supplicant *wpa_s, char *cmd)
{
@@ -2869,17 +2887,46 @@
return -1;
wpa_printf(MSG_DEBUG, "CTRL_IFACE: P2P_SET GO NoA: count=%d "
"start=%d duration=%d", count, start, duration);
+#ifdef ANDROID_BRCM_P2P_PATCH
+ return wpas_p2p_set_noa(p2p_get_apif(wpa_s), count, start, duration);
+#else
return wpas_p2p_set_noa(wpa_s, count, start, duration);
+#endif
}
if (os_strcmp(cmd, "ps") == 0)
+#ifdef ANDROID_BRCM_P2P_PATCH
+ return wpas_drv_set_p2p_powersave(p2p_get_clientif(wpa_s), atoi(param), -1, -1);
+#else
return wpa_drv_set_p2p_powersave(wpa_s, atoi(param), -1, -1);
+#endif
if (os_strcmp(cmd, "oppps") == 0)
+#ifdef ANDROID_BRCM_P2P_PATCH
+ return wpas_drv_set_p2p_powersave(p2p_get_apif(wpa_s), -1, atoi(param), -1);
+#else
return wpa_drv_set_p2p_powersave(wpa_s, -1, atoi(param), -1);
+#endif
if (os_strcmp(cmd, "ctwindow") == 0)
+#ifdef ANDROID_BRCM_P2P_PATCH
+ return wpa_drv_set_p2p_powersave(p2p_get_apif(wpa_s), -1, -1, atoi(param));
+#else
return wpa_drv_set_p2p_powersave(wpa_s, -1, -1, atoi(param));
+#endif
+
+ if (os_strcmp(cmd, "disabled") == 0) {
+ wpa_s->global->p2p_disabled = atoi(param);
+ wpa_printf(MSG_DEBUG, "P2P functionality %s",
+ wpa_s->global->p2p_disabled ?
+ "disabled" : "enabled");
+ if (wpa_s->global->p2p_disabled) {
+ wpas_p2p_stop_find(wpa_s);
+ os_memset(wpa_s->p2p_auth_invite, 0, ETH_ALEN);
+ p2p_flush(wpa_s->global->p2p);
+ }
+ return 0;
+ }
if (os_strcmp(cmd, "disabled") == 0) {
wpa_s->global->p2p_disabled = atoi(param);
@@ -3312,6 +3359,18 @@
if (wpas_p2p_cancel(wpa_s))
reply_len = -1;
} else if (os_strncmp(buf, "P2P_PRESENCE_REQ ", 17) == 0) {
+ #if defined(ANDROID_BRCM_P2P_PATCH) && defined(CONFIG_P2P)
+ /* We have to send presence command to p2p interface if p2p_interface is started
+ * otherwise we can send it to primary interface
+ */
+ struct wpa_supplicant* ifs;
+ for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
+ if ( (ifs->p2p_group_interface == P2P_GROUP_INTERFACE_GO ) ||(ifs->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT )) {
+ wpa_s = ifs;
+ break;
+ }
+ }
+ #endif /* defined ANDROID_BRCM_P2P_PATCH && defined CONFIG_P2P */
if (p2p_ctrl_presence_req(wpa_s, buf + 17) < 0)
reply_len = -1;
} else if (os_strcmp(buf, "P2P_PRESENCE_REQ") == 0) {
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 12dae34..f4c5a53 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -4168,10 +4168,49 @@
{
if (!wpa_s->ap_iface)
return -1;
+
+#ifdef ANDROID_BRCM_P2P_PATCH
+#define NOA_BUF_LEN 50
+ /* Now get the NOA descriptor from the driver */
+ hostapd_p2p_set_noa(wpa_s->ap_iface->bss[0], count, start,
+ duration);
+ if(count > 0) {
+ u8 noa[NOA_BUF_LEN];
+ int noa_len = 0;
+ wpa_printf(MSG_DEBUG, "P2P: Get NOA attribute from driver");
+ noa_len = wpa_drv_get_noa(wpa_s, noa, NOA_BUF_LEN);
+ if (noa_len) {
+ wpa_printf(MSG_DEBUG, "P2P: Now Update NOA attributes in Beacons/ProbeRsps noa_len %d", noa_len);
+ return p2p_group_notif_noa(wpa_s->p2p_group, noa, noa_len);
+ }
+ else
+ return 0;
+ }
+ else
+ return 0;
+#else
return hostapd_p2p_set_noa(wpa_s->ap_iface->bss[0], count, start,
duration);
+#endif
}
+#ifdef ANDROID_BRCM_P2P_PATCH
+int wpas_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s, int legacy_ps, int opp_ps, int ctwindow)
+{
+#define NOA_BUF_LEN 50
+ u8 noa[NOA_BUF_LEN];
+ int noa_len = 0;
+ wpa_drv_set_p2p_powersave(wpa_s, legacy_ps, opp_ps, ctwindow);
+ wpa_printf(MSG_DEBUG, "P2P: Get NOA attribute from driver");
+ noa_len = wpa_drv_get_noa(wpa_s, noa, NOA_BUF_LEN);
+ if (noa_len) {
+ wpa_printf(MSG_DEBUG, "P2P: Now Update NOA attributes in Beacons/ProbeRsps noa_len %d", noa_len);
+ return p2p_group_notif_noa(wpa_s->p2p_group, noa, noa_len);
+ }
+ else
+ return 0;
+}
+#endif
int wpas_p2p_set_cross_connect(struct wpa_supplicant *wpa_s, int enabled)
{
diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h
index 93a5afd..5be9ba2 100644
--- a/wpa_supplicant/p2p_supplicant.h
+++ b/wpa_supplicant/p2p_supplicant.h
@@ -111,6 +111,8 @@
#ifdef ANDROID_BRCM_P2P_PATCH
void wpas_p2p_group_remove_notif(struct wpa_supplicant *wpa_s,
u16 reason_code);
+int wpas_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s, int legacy_ps,
+ int opp_ps, int ctwindow);
#endif /* ANDROID_BRCM_P2P_PATCH */
void wpas_p2p_disassoc_notif(struct wpa_supplicant *wpa_s, const u8 *bssid,
u16 reason_code, const u8 *ie, size_t ie_len);