/*----------------------------------------------------------------------------*/
BOOLEAN kalP2PCmpBlackList(IN P_GLUE_INFO_T prGlueInfo, IN PARAM_MAC_ADDRESS rbssid)
{
	UINT_8 aucNullAddr[] = NULL_MAC_ADDR;
	BOOLEAN fgIsExsit = FALSE;
	UINT_32 i;

	ASSERT(prGlueInfo);
	ASSERT(prGlueInfo->prP2PInfo);

	for (i = 0; i < 8; i++) {
		if (UNEQUAL_MAC_ADDR(rbssid, aucNullAddr)) {
			if (EQUAL_MAC_ADDR(&(prGlueInfo->prP2PInfo->aucblackMACList[i]), rbssid)) {
				fgIsExsit = TRUE;
				return fgIsExsit;
			}
		}
	}

	return fgIsExsit;

}
Esempio n. 2
0
int
mtk_cfg80211_get_station (
    struct wiphy *wiphy,
    struct net_device *ndev,
    u8 *mac,
    struct station_info *sinfo
)
{
    P_GLUE_INFO_T prGlueInfo = NULL;
    WLAN_STATUS rStatus;
    PARAM_MAC_ADDRESS arBssid;
    UINT_32 u4BufLen, u4Rate;
    INT_32 i4Rssi;

    prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy);
    ASSERT(prGlueInfo);

    kalMemZero(arBssid, MAC_ADDR_LEN);
    wlanQueryInformation(prGlueInfo->prAdapter,
                         wlanoidQueryBssid,
                         &arBssid[0],
                         sizeof(arBssid),
                         &u4BufLen);

    /* 1. check BSSID */
    if(UNEQUAL_MAC_ADDR(arBssid, mac)) {
        /* wrong MAC address */
        DBGLOG(REQ, WARN, ("incorrect BSSID: ["MACSTR"] currently connected BSSID["MACSTR"]\n",
                           MAC2STR(mac), MAC2STR(arBssid)));
        return -ENOENT;
    }

    /* 2. fill TX rate */
    rStatus = kalIoctl(prGlueInfo,
                       wlanoidQueryLinkSpeed,
                       &u4Rate,
                       sizeof(u4Rate),
                       TRUE,
                       FALSE,
                       FALSE,
                       FALSE,
                       &u4BufLen);

    if (rStatus != WLAN_STATUS_SUCCESS) {
        DBGLOG(REQ, WARN, ("unable to retrieve link speed\n"));
    }
    else {
        sinfo->filled |= STATION_INFO_TX_BITRATE;
        sinfo->txrate.legacy = u4Rate / 1000; /* convert from 100bps to 100kbps */
    }

    if(prGlueInfo->eParamMediaStateIndicated != PARAM_MEDIA_STATE_CONNECTED) {
        /* not connected */
        DBGLOG(REQ, WARN, ("not yet connected\n"));
    }
    else {
        /* 3. fill RSSI */
        rStatus = kalIoctl(prGlueInfo,
                           wlanoidQueryRssi,
                           &i4Rssi,
                           sizeof(i4Rssi),
                           TRUE,
                           FALSE,
                           FALSE,
                           FALSE,
                           &u4BufLen);

        if (rStatus != WLAN_STATUS_SUCCESS) {
            DBGLOG(REQ, WARN, ("unable to retrieve link speed\n"));
        }
        else {
            sinfo->filled |= STATION_INFO_SIGNAL;
            //in the cfg80211 layer, the signal is a signed char variable.
            if(i4Rssi < -128)
                sinfo->signal = -128;
            else
                sinfo->signal = i4Rssi; /* dBm */
        }
    }

    /* scott.chiang@20130405, refer to 6628's gl_cfg80211.c - made by Zhang.Luo */

    sinfo->rx_packets = prGlueInfo->rNetDevStats.rx_packets;
    sinfo->filled |= STATION_INFO_TX_PACKETS;
    sinfo->tx_packets = prGlueInfo->rNetDevStats.tx_packets;
    sinfo->filled |= STATION_INFO_TX_FAILED;

#if 1
    {
        WLAN_STATUS rStatus;
        UINT_32 u4XmitError = 0;
//           UINT_32 u4XmitOk = 0;
//          UINT_32 u4RecvError = 0;
//           UINT_32 u4RecvOk = 0;
//           UINT_32 u4BufLen;

        /* @FIX ME: need a more clear way to do this */


        rStatus = kalIoctl(prGlueInfo,
                           wlanoidQueryXmitError,
                           &u4XmitError,
                           sizeof(UINT_32),
                           TRUE,
                           TRUE,
                           TRUE,
                           FALSE,
                           &u4BufLen);

        prGlueInfo->rNetDevStats.tx_errors = u4XmitError;

    }
#else
    prGlueInfo->rNetDevStats.tx_errors = 0;
#endif

    sinfo->tx_failed = prGlueInfo->rNetDevStats.tx_errors;

    return 0;
}
VOID
scanP2pProcessBeaconAndProbeResp(IN P_ADAPTER_T prAdapter,
				 IN P_SW_RFB_T prSwRfb,
				 IN P_WLAN_STATUS prStatus,
				 IN P_BSS_DESC_T prBssDesc,
				 IN P_WLAN_BEACON_FRAME_T prWlanBeaconFrame)
{
	if (prBssDesc->fgIsP2PPresent) {
		if ((prBssDesc->fgIsConnected) &&	/* P2P GC connected. */
		    ((prWlanBeaconFrame->u2FrameCtrl & MASK_FRAME_TYPE) == MAC_FRAME_BEACON)	/* TX Beacon */
		    ) {
			UINT_32 u4Idx = 0;
			P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;

			for (u4Idx = 0; u4Idx < BSS_INFO_NUM; u4Idx++) {
				/* Check BSS for P2P. */
				/* Check BSSID. */
				prP2pBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, (UINT_8) u4Idx);

				if (!IS_BSS_ACTIVE(prP2pBssInfo)) {
					continue;
				}

				if ((prP2pBssInfo->eNetworkType != NETWORK_TYPE_P2P) ||
				    (UNEQUAL_MAC_ADDR(prP2pBssInfo->aucBSSID, prBssDesc->aucBSSID)
				     ||
				     (!EQUAL_SSID
				      (prP2pBssInfo->aucSSID, prP2pBssInfo->ucSSIDLen,
				       prBssDesc->aucSSID, prBssDesc->ucSSIDLen)))) {
					continue;
				}

				if ((prP2pBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) &&	/* P2P GC */
				    (prP2pBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) &&	/* Connected */
				    (!prP2pBssInfo->ucDTIMPeriod)) {	/* First Time. */
					prP2pBssInfo->ucDTIMPeriod = prBssDesc->ucDTIMPeriod;
					nicPmIndicateBssConnected(prAdapter,
								  prP2pBssInfo->ucBssIndex);
				}

			}

		}

		do {
			RF_CHANNEL_INFO_T rChannelInfo;

			ASSERT_BREAK((prSwRfb != NULL) && (prBssDesc != NULL));

			if (((prWlanBeaconFrame->u2FrameCtrl & MASK_FRAME_TYPE) !=
			     MAC_FRAME_PROBE_RSP)) {
				/* Only report Probe Response frame to supplicant. */
				/* Probe response collect much more information. */
				break;
			}

			rChannelInfo.ucChannelNum = prBssDesc->ucChannelNum;
			rChannelInfo.eBand = prBssDesc->eBand;
			prBssDesc->fgIsP2PReport = TRUE;

			DBGLOG(P2P, INFO,
			       ("indicate %s [%d]\n", prBssDesc->aucSSID, prBssDesc->ucChannelNum));

			kalP2PIndicateBssInfo(prAdapter->prGlueInfo,
					      (PUINT_8) prSwRfb->pvHeader,
					      (UINT_32) prSwRfb->u2PacketLen,
					      &rChannelInfo, RCPI_TO_dBm(prBssDesc->ucRCPI));


		} while (FALSE);
	}
}
Esempio n. 4
0
/*----------------------------------------------------------------------------*/
VOID
nicRxAddP2pDevice (
    IN P_ADAPTER_T  prAdapter,
    IN P_EVENT_P2P_DEV_DISCOVER_RESULT_T prP2pResult,
    IN PUINT_8 pucRxIEBuf,
    IN UINT_16 u2RxIELength
    )
{
    P_P2P_INFO_T prP2pInfo = (P_P2P_INFO_T)NULL;
    P_EVENT_P2P_DEV_DISCOVER_RESULT_T prTargetResult = (P_EVENT_P2P_DEV_DISCOVER_RESULT_T)NULL;
    UINT_32 u4Idx = 0;
    BOOLEAN bUpdate = FALSE;

    PUINT_8 pucIeBuf = (PUINT_8)NULL;
    UINT_16 u2IELength = 0;
    UINT_8  zeroMac[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};

    ASSERT(prAdapter);

    prP2pInfo = prAdapter->prP2pInfo;

    for (u4Idx = 0; u4Idx < prP2pInfo->u4DeviceNum; u4Idx++) {
        prTargetResult = &prP2pInfo->arP2pDiscoverResult[u4Idx];

        if (EQUAL_MAC_ADDR(prTargetResult->aucDeviceAddr, prP2pResult->aucDeviceAddr)) {
            bUpdate = TRUE;

            /* Backup OLD buffer result. */
            pucIeBuf = prTargetResult->pucIeBuf;
            u2IELength = prTargetResult->u2IELength;

            /* Update Device Info. */
            // zero
            kalMemZero(prTargetResult, sizeof(EVENT_P2P_DEV_DISCOVER_RESULT_T));

            // then buffer
            kalMemCopy(prTargetResult,
                (PVOID)prP2pResult,
                sizeof(EVENT_P2P_DEV_DISCOVER_RESULT_T));

            /* See if new IE length is longer or not. */
            if ((u2RxIELength > u2IELength) && (u2IELength != 0)) {
                /* Buffer is not enough. */
                u2RxIELength = u2IELength;
            }
            else if ((u2IELength == 0) && (u2RxIELength != 0)) {
                /* RX new IE buf. */
                ASSERT(pucIeBuf == NULL);
                pucIeBuf = prP2pInfo->pucCurrIePtr;

                if (((UINT_32)prP2pInfo->pucCurrIePtr + (UINT_32)u2RxIELength) >
                        (UINT_32)&prP2pInfo->aucCommIePool[CFG_MAX_COMMON_IE_BUF_LEN]) {
                    /* Common Buffer is no enough. */
                    u2RxIELength = (UINT_16)((UINT_32)&prP2pInfo->aucCommIePool[CFG_MAX_COMMON_IE_BUF_LEN] - (UINT_32)prP2pInfo->pucCurrIePtr);
                }

                /* Step to next buffer address. */
                prP2pInfo->pucCurrIePtr = (PUINT_8)((UINT_32)prP2pInfo->pucCurrIePtr + (UINT_32)u2RxIELength);
            }

            /* Restore buffer pointer. */
            prTargetResult->pucIeBuf = pucIeBuf;

            if (pucRxIEBuf) {
                /* If new received IE is availabe.
                  * Replace the old one & update new IE length.
                  */
                kalMemCopy(pucIeBuf, pucRxIEBuf, u2RxIELength);
                prTargetResult->u2IELength = u2RxIELength;
            }
            else {
                /* There is no new IE information, keep the old one. */
                prTargetResult->u2IELength = u2IELength;
            }
        }
    }

    if (!bUpdate) {
        /* We would flush the whole scan result after each scan request is issued.
          * If P2P device is too many, it may over the scan list.
          */
        if ((u4Idx < CFG_MAX_NUM_BSS_LIST) && (UNEQUAL_MAC_ADDR(zeroMac, prP2pResult->aucDeviceAddr))) { /* whsu:XXX */
            prTargetResult = &prP2pInfo->arP2pDiscoverResult[u4Idx];

            // zero
            kalMemZero(prTargetResult, sizeof(EVENT_P2P_DEV_DISCOVER_RESULT_T));

            // then buffer
            kalMemCopy(prTargetResult,
                (PVOID)prP2pResult,
                sizeof(EVENT_P2P_DEV_DISCOVER_RESULT_T));

            //printk("DVC FND %d " MACSTR", " MACSTR "\n", prP2pInfo->u4DeviceNum, MAC2STR(prP2pResult->aucDeviceAddr), MAC2STR(prTargetResult->aucDeviceAddr));

            if (u2RxIELength) {
                prTargetResult->pucIeBuf = prP2pInfo->pucCurrIePtr;

                if (((UINT_32)prP2pInfo->pucCurrIePtr + (UINT_32)u2RxIELength) >
                        (UINT_32)&prP2pInfo->aucCommIePool[CFG_MAX_COMMON_IE_BUF_LEN]) {
                    /* Common Buffer is no enough. */
                    u2IELength = (UINT_16)((UINT_32)&prP2pInfo->aucCommIePool[CFG_MAX_COMMON_IE_BUF_LEN] - (UINT_32)prP2pInfo->pucCurrIePtr);
                }
                else {
                    u2IELength = u2RxIELength;
                }

                prP2pInfo->pucCurrIePtr = (PUINT_8)((UINT_32)prP2pInfo->pucCurrIePtr + (UINT_32)u2IELength);

                kalMemCopy((PVOID)prTargetResult->pucIeBuf, (PVOID)pucRxIEBuf, (UINT_32)u2IELength);
                prTargetResult->u2IELength = u2IELength;
            }
            else {
                prTargetResult->pucIeBuf = NULL;
                prTargetResult->u2IELength = 0;
            }

            prP2pInfo->u4DeviceNum++;

        }
        else {
            // TODO: Fixme to replace an old one. (?)
            ASSERT(FALSE);
        }
    }
} /* nicRxAddP2pDevice */
int
mtk_cfg80211_get_station (
    struct wiphy *wiphy,
    struct net_device *ndev,
    u8 *mac,
    struct station_info *sinfo
    )
{
    P_GLUE_INFO_T prGlueInfo = NULL;
    WLAN_STATUS rStatus;
    PARAM_MAC_ADDRESS arBssid;
    UINT_32 u4BufLen, u4Rate;
    INT_32 i4Rssi;

    prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy);
    ASSERT(prGlueInfo);

    kalMemZero(arBssid, MAC_ADDR_LEN);
    wlanQueryInformation(prGlueInfo->prAdapter,
            wlanoidQueryBssid,
            &arBssid[0],
            sizeof(arBssid),
            &u4BufLen);

    /* 1. check BSSID */
    if(UNEQUAL_MAC_ADDR(arBssid, mac)) {
        /* wrong MAC address */
        DBGLOG(REQ, WARN, ("incorrect BSSID: ["MACSTR"] currently connected BSSID["MACSTR"]\n", 
                    MAC2STR(mac), MAC2STR(arBssid)));
        return -ENOENT;
    }

    /* 2. fill TX rate */
    rStatus = kalIoctl(prGlueInfo,
        wlanoidQueryLinkSpeed,
        &u4Rate,
        sizeof(u4Rate),
        TRUE,
        FALSE,
        FALSE,
        FALSE,
        &u4BufLen);

    if (rStatus != WLAN_STATUS_SUCCESS) {
        DBGLOG(REQ, WARN, ("unable to retrieve link speed\n"));
    }
    else {
        sinfo->filled |= STATION_INFO_TX_BITRATE;
        sinfo->txrate.legacy = u4Rate / 1000; /* convert from 100bps to 100kbps */
    }

    if(prGlueInfo->eParamMediaStateIndicated != PARAM_MEDIA_STATE_CONNECTED) {
        /* not connected */
        DBGLOG(REQ, WARN, ("not yet connected\n"));
    }
    else {
        /* 3. fill RSSI */
        rStatus = kalIoctl(prGlueInfo,
                wlanoidQueryRssi,
                &i4Rssi,
                sizeof(i4Rssi),
                TRUE,
                FALSE,
                FALSE,
                FALSE,
                &u4BufLen);
        
        if (rStatus != WLAN_STATUS_SUCCESS) {
            DBGLOG(REQ, WARN, ("unable to retrieve link speed\n"));
        }
        else {
            sinfo->filled |= STATION_INFO_SIGNAL;
            sinfo->signal = i4Rssi; /* dBm */
        }
    }

    return 0;
}