#endif
+/*
+ * returns = TRUE if associated, FALSE if not associated
+ */
+bool is_associated(dhd_pub_t *dhd, void *bss_buf)
+{
+ char bssid[ETHER_ADDR_LEN], zbuf[ETHER_ADDR_LEN];
+ int ret = -1;
+
+ bzero(bssid, ETHER_ADDR_LEN);
+ bzero(zbuf, ETHER_ADDR_LEN);
+
+ ret = dhdcdc_set_ioctl(dhd, 0, WLC_GET_BSSID, (char *)bssid, ETHER_ADDR_LEN);
+ DHD_TRACE((" %s WLC_GET_BSSID ioctl res = %d\n", __FUNCTION__, ret));
+
+ if (ret == BCME_NOTASSOCIATED) {
+ DHD_TRACE(("%s: not associated! res:%d\n", __FUNCTION__, ret));
+ }
+
+ if (ret < 0)
+ return FALSE;
+
+ if ((memcmp(bssid, zbuf, ETHER_ADDR_LEN) != 0)) {
+ /* STA is assocoated BSSID is non zero */
+
+ if (bss_buf) {
+ /* return bss if caller provided buf */
+ memcpy(bss_buf, bssid, ETHER_ADDR_LEN);
+ }
+ return TRUE;
+ } else {
+ DHD_TRACE(("%s: WLC_GET_BSSID ioctl returned zero bssid\n", __FUNCTION__));
+ return FALSE;
+ }
+}
+
/* Function to estimate possible DTIM_SKIP value */
int dhd_get_dtim_skip(dhd_pub_t *dhd)
{
int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled)
{
char iovbuf[128];
- uint8 bssid[6];
int ret = -1;
if ((!dhd) && ((pfn_enabled != 0) || (pfn_enabled != 1))) {
memset(iovbuf, 0, sizeof(iovbuf));
/* Check if disassoc to enable pno */
- if ((pfn_enabled) && \
- ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_GET_BSSID, \
- (char *)&bssid, ETHER_ADDR_LEN)) == BCME_NOTASSOCIATED)) {
- DHD_TRACE(("%s pno enable called in disassoc mode\n", __FUNCTION__));
- }
- else if (pfn_enabled) {
+ if (pfn_enabled && (is_associated(dhd, NULL) == TRUE)) {
DHD_ERROR(("%s pno enable called in assoc mode ret=%d\n", \
__FUNCTION__, ret));
return ret;