From: Dmitry Shmidt Date: Tue, 27 Sep 2011 19:29:26 +0000 (-0700) Subject: nl80211: Add set_noa, set_p2p_powersave, set_ap_wps_ie X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85368139dfd5b53793f618d957559905a16cd088;p=thirdparty%2Fhostap.git nl80211: Add set_noa, set_p2p_powersave, set_ap_wps_ie Fix WFD and WPS certification problem for GO (BRCM) Change-Id: I5bbac818aad7c0a14fddb3beb88a6a2d87c07ea0 Signed-off-by: Dmitry Shmidt --- diff --git a/src/drivers/android_drv.h b/src/drivers/android_drv.h index 5906527a0..2a3daec8c 100644 --- a/src/drivers/android_drv.h +++ b/src/drivers/android_drv.h @@ -19,6 +19,8 @@ #define MAX_DRV_CMD_SIZE 248 #define DRV_NUMBER_SEQUENTIAL_ERRORS 4 +#define MAX_WPSP2PIE_CMD_SIZE 384 + #define WEXT_PNOSETUP_HEADER "PNOSETUP " #define WEXT_PNOSETUP_HEADER_SIZE 9 #define WEXT_PNO_TLV_PREFIX 'S' diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index f8a661f19..c21444091 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -60,6 +60,8 @@ #ifdef ANDROID #include "android_drv.h" +static int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf, + size_t buf_len); #endif /* ANDROID */ #ifdef CONFIG_LIBNL20 /* libnl 2.0 compatibility code */ @@ -364,12 +366,8 @@ static int android_pno_start(struct i802_bss *bss, static int android_pno_stop(struct i802_bss *bss); #endif /* ANDROID */ #ifdef ANDROID_P2P -int wpa_driver_set_p2p_noa(void *priv, u8 count, int start, int duration); int wpa_driver_get_p2p_noa(void *priv, u8 *buf, size_t len); 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, - const struct wpabuf *proberesp, - const struct wpabuf *assocresp); #endif /* ANDROID_P2P */ static void add_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx); @@ -10637,6 +10635,15 @@ nla_put_failure: static int nl80211_set_p2p_powersave(void *priv, int legacy_ps, int opp_ps, int ctwindow) { +#ifdef ANDROID_P2P + char buf[MAX_DRV_CMD_SIZE]; + + memset(buf, 0, sizeof(buf)); + wpa_printf(MSG_DEBUG, "%s: Entry", __func__); + os_snprintf(buf, sizeof(buf), "P2P_SET_PS %d %d %d", legacy_ps, opp_ps, + ctwindow); + return wpa_driver_nl80211_driver_cmd(priv, buf, buf, strlen(buf) + 1); +#else /* ANDROID_P2P */ struct i802_bss *bss = priv; wpa_printf(MSG_DEBUG, "nl80211: set_p2p_powersave (legacy_ps=%d " @@ -10656,6 +10663,7 @@ static int nl80211_set_p2p_powersave(void *priv, int legacy_ps, int opp_ps, return -1; /* Not yet supported */ return nl80211_set_power_save(bss, legacy_ps); +#endif /* ANDROID_P2P */ } @@ -11089,6 +11097,68 @@ static int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf, return ret; } +#ifdef ANDROID_P2P + +static int wpa_driver_set_p2p_noa(void *priv, u8 count, int start, + int duration) +{ + char buf[MAX_DRV_CMD_SIZE]; + + memset(buf, 0, sizeof(buf)); + wpa_printf(MSG_DEBUG, "%s: Entry", __func__); + os_snprintf(buf, sizeof(buf), "P2P_SET_NOA %d %d %d", count, start, + duration); + return wpa_driver_nl80211_driver_cmd(priv, buf, buf, strlen(buf) + 1); +} + + +static int wpa_driver_set_ap_wps_p2p_ie(void *priv, + const struct wpabuf *beacon, + const struct wpabuf *proberesp, + const struct wpabuf *assocresp) +{ + char buf[MAX_WPSP2PIE_CMD_SIZE]; + struct wpabuf *ap_wps_p2p_ie = NULL; + char *_cmd = "SET_AP_WPS_P2P_IE"; + char *pbuf; + int ret = 0; + int i; + struct cmd_desc { + int cmd; + const struct wpabuf *src; + } cmd_arr[] = { + {0x1, beacon}, + {0x2, proberesp}, + {0x4, assocresp}, + {-1, NULL} + }; + + wpa_printf(MSG_DEBUG, "%s: Entry", __func__); + for (i = 0; cmd_arr[i].cmd != -1; i++) { + os_memset(buf, 0, sizeof(buf)); + pbuf = buf; + pbuf += sprintf(pbuf, "%s %d", _cmd, cmd_arr[i].cmd); + *pbuf++ = '\0'; + ap_wps_p2p_ie = cmd_arr[i].src ? + wpabuf_dup(cmd_arr[i].src) : NULL; + if (ap_wps_p2p_ie) { + os_memcpy(pbuf, wpabuf_head(ap_wps_p2p_ie), + wpabuf_len(ap_wps_p2p_ie)); + ret = wpa_driver_nl80211_driver_cmd( + priv, buf, buf, + os_strlen(_cmd) + 3 + + wpabuf_len(ap_wps_p2p_ie)); + wpabuf_free(ap_wps_p2p_ie); + if (ret < 0) + break; + } + } + + return ret; +} + +#endif /* ANDROID_P2P */ + #endif /* ANDROID */