⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wlan_ccx.c

📁 此压缩包为杰得开发得z228的BSP的源代码,可以实现很多功能,尤其是视频解码有很好的效果.
💻 C
📖 第 1 页 / 共 4 页
字号:
	NdisMoveMemory(pBufVM, pktbuf, pktlen);//	pCCXMsg = (PCCX_MSG_T)pBufVM;//	NdisMoveMemory(pCCXMsg->dstAddr, ccxCurBSSID, sizeof(pCCXMsg->dstAddr));	 //	NdisMoveMemory(pCCXMsg->srcAddr, ccxStaMac, sizeof(pCCXMsg->srcAddr));//	pCCXMsg->protocolLen[0] = 0;//	pCCXMsg->protocolLen[1] = 0;//	NdisMoveMemory(pCCXMsg->snapHdr, ccxSnapHdr, sizeof(pCCXMsg->snapHdr));//	pCCXMsg->length[0] = 0;//	pCCXMsg->length[1] = 40;//	pCCXMsg->msgType = 0x40;//	pCCXMsg->function = 0x8e;//	NdisMoveMemory(pCCXMsg->apAddr, ccxCurBSSID, sizeof(pCCXMsg->apAddr));	 //	NdisMoveMemory(pCCXMsg->staAddr, ccxStaMac, sizeof(pCCXMsg->staAddr));	////	pCCXMsg->failcode[0] = (UCHAR)(pRougeAPMsg->FailureReason >> 8);//	pCCXMsg->failcode[1] = (UCHAR)(pRougeAPMsg->FailureReason & 0xFF);//	NdisMoveMemory(pCCXMsg->rogueAddr, pRougeAPMsg->RogueAPMacAddress, sizeof(pCCXMsg->rogueAddr));	 //	NdisMoveMemory(pCCXMsg->rogueName, pRougeAPMsg->RogueAPName, sizeof(pCCXMsg->rogueName));//	pCCXCurPacket = pPacket;//	DBGPRINT(DBG_CCX, ("[ccx_send_packet] cur packet=%x\n", pCCXCurPacket));	///return SendSinglePacket(Adapter, pPacket);
	EnterCriticalSection(&Adapter->TxCriticalSection);	status = CCX_SendSinglePacket(Adapter, pPacket);
	LeaveCriticalSection(&Adapter->TxCriticalSection);
	return status;}void wlan_ccx_send_ddp(IN PMRVDRV_ADAPTER Adapter){	UCHAR		iapp[256];	UCHAR		*bufpt = iapp;	///Fill the "header" of the packet we need to generate	wlan_ccx_fillFrameHeader(Adapter, bufpt);	bufpt += sizeof(MRVPKTDESC);	///Fill the "SNAP" header	NdisMoveMemory(bufpt, ccxSnapHdr, sizeof(ccxSnapHdr));	bufpt += sizeof(ccxSnapHdr);	///Generate the iapp frame	wlan_ccx_fillDDPINFOPkt(Adapter, bufpt);	///Send the iapp frame	{		int		i, j, k;		UCHAR	*datpt=iapp;		int		pktlen = sizeof(MRVPKTDESC)+sizeof(ccxSnapHdr)+sizeof(CCX_DDPINFO);		RETAILMSG(1,(TEXT("PktLen(%d): "), pktlen));		for (i=0; i<pktlen/16 ; i++) {			k = i*16;			RETAILMSG(1,(TEXT("%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n"),				datpt[k+0], datpt[k+1], datpt[k+2], datpt[k+3], datpt[k+4], datpt[k+5], datpt[k+6], datpt[k+7],				datpt[k+8], datpt[k+9], datpt[k+10], datpt[k+11], datpt[k+12], datpt[k+13], datpt[k+14], datpt[k+15]));		}		if ((pktlen%16) != 0) {			UCHAR	tmpbuf[16];			for (j=0 ; j<(pktlen%16) ; j++) {				tmpbuf[j] = iapp[i*16+j];			}			for (;j<16 ; j++) {				tmpbuf[j] = 0xff;			}			RETAILMSG(1,(TEXT("%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n"),				tmpbuf[0], tmpbuf[1], tmpbuf[2], tmpbuf[3], tmpbuf[4], tmpbuf[5], tmpbuf[6], tmpbuf[7],				tmpbuf[8], tmpbuf[9], tmpbuf[10], tmpbuf[11], tmpbuf[12], tmpbuf[13], tmpbuf[14], tmpbuf[15]));		}	}	ccx_send(Adapter, pCCXPacket[0], iapp, sizeof(MRVPKTDESC)+sizeof(ccxSnapHdr)+sizeof(CCX_DDPINFO));	return;}///crlo:fastroam --#ifdef CCX_TPCvoid wlan_ccx_recTxPower(int userPower){	ccxTPCUserPower = userPower;	DBGPRINT(DBG_CCX,  ("[wlan_ccx_recTxPower] userPower=%x\n", userPower));}void wlan_ccx_setTxPower(void){    if (ifNeedTPC) {	ccx_set_txpower(ccxTPCMinPower, ccxTPCMaxPower);    }}#endifvoid wlan_ccx_assocSuccess(void){#ifdef CCX_TPC	wlan_ccx_setTxPower();#endif}void wlan_ccx_authSuccess(void){#ifdef CCX_CCKM	ccxCCKMState = CCX_CCKM_START;#endif}///crlo:RadioMeasure ++int wlan_ccx_fillBeaconTable(IN PMRVDRV_ADAPTER pAdapter, u8* pktBufPt){	PCCX_MEASURE_REPORT_MSG	pMeasureRep = (PCCX_MEASURE_REPORT_MSG)pktBufPt;	PCCX_IAPP_HEADER		pIAPPFrameHdr = &pMeasureRep->iappHdr;	///PCCX_MEASURE_REPORT_ELEMENT	pMRElem = pMeasureRep->repElement;	PCCX_MEASURE_REPORT_ELEMENT	pMRElem;	PCCX_BEACON_MEASURE_REPORT	pBeaconReport;	OS_UINT16	pktlen;	UCHAR		*repBufPt;	OS_UINT16	i;	///	///Fill the IAPP header	///	///tmp = (WORD)sizeof(CCX_DDPINFO);	///pIAPPFrameHdr->Length = GetBigEndian((OS_UINT8 *) &tmp);	pIAPPFrameHdr->Type = CCX_IAPP_TYPE_RADIO_MEASURE;	pIAPPFrameHdr->Func_SubType = CCX_IAPP_SUBTYPE_REPORT;	///Destination MAC (All 0s, ref S36.5 of CCX specification v2.8	///NdisMoveMemory((PVOID)pIAPPFrameHdr->imDest, pAdapter->ccxCurrentAP.alMACAddr, MRVDRV_ETH_ADDR_LEN);	NdisZeroMemory((PVOID)pIAPPFrameHdr->imDest, MRVDRV_ETH_ADDR_LEN);	///Source MAC	NdisMoveMemory((PVOID)pIAPPFrameHdr->imSrc, pAdapter->PermanentAddr, MRVDRV_ETH_ADDR_LEN);	pktlen = sizeof(CCX_MEASURE_REPORT_MSG);RETAILMSG(1,(TEXT("CCX_MEASURE_REPORT_MSG len: %d\n"), sizeof(CCX_MEASURE_REPORT_MSG)));PrintMacro("CCX_MEASURE_REPORT_MSG len: %d\n", sizeof(CCX_MEASURE_REPORT_MSG));	///Fill the Dialog-token	pMeasureRep->dialogToken = pAdapter->dialogToken;///	pktlen += sizeof(pMeasureRep->dialogToken);RETAILMSG(1,(TEXT("dialogToken len: %d\n"), sizeof(pMeasureRep->dialogToken)));PrintMacro("dialogToken len: %d\n", sizeof(pMeasureRep->dialogToken));	///	///Fill in the Measurment Report Element	///RETAILMSG(1,(TEXT("NumOfBSSIDs: %d\n"), pAdapter->ulPSNumOfBSSIDs));PrintMacro("NumOfBSSIDs: %d\n", pAdapter->ulPSNumOfBSSIDs);	pMRElem = (PCCX_MEASURE_REPORT_ELEMENT)(pMeasureRep+1);	for (i=0 ; i< pAdapter->ulPSNumOfBSSIDs; i++) {		NDIS_WLAN_BSSID_EX*	pBSSIDList = &pAdapter->PSBSSIDList[i];		BSS_DESCRIPTION_SET_ALL_FIELDS*	pBssDescList = &pAdapter->PSBssDescList[i];		PMRV_BSSID_IE_LIST  pBSSIDIEListSrc = &pAdapter->PSIEBuffer[i];		UCHAR       *pCurPtr;        UCHAR       ElemID, IELen;		OS_UINT16	MRELength;		///PUCHAR		pIEBuf = pBSSIDIEListSrc->VariableIE;		ULONG		ulCurOffset = 0;		pMRElem->ElementID = ELEM_MEASUR_REPORT;		pMRElem->MeasureToken = pAdapter->MeasureToken;		pMRElem->MeasureMode = pAdapter->MeasureMode;		pMRElem->MeasureType = MEASURE_REP_BEACON;///		pktlen += sizeof(CCX_MEASURE_REPORT_ELEMENT);		MRELength = sizeof(CCX_MEASURE_REPORT_ELEMENT);		///Fill in the Measure Report (Beacon Report)		///repBufPt is one byte ahead of pBeaconReport		///repBufPt = ((UCHAR*)pMRElem)+sizeof(CCX_MEASURE_REPORT_MSG);		pBeaconReport = (PCCX_BEACON_MEASURE_REPORT)(pMRElem+1);		///Channel Number		pBeaconReport->ChannelNumber = (OS_UINT8)((pBSSIDList->Configuration.DSConfig - 2407) / 5);		RETAILMSG(1,(TEXT("CCX=>(%d) Channel: %xh\n"), i, pBeaconReport->ChannelNumber));		///Spare		pBeaconReport->Spare = 0;		///MeasureDuration		pBeaconReport->MeasureDuration = pAdapter->MeasureDuration;		///PHY Type		///PrintMacro("PhyType: %d\n", pBSSIDList->NetworkTypeInUse);		pBeaconReport->PhyType = pBSSIDList->NetworkTypeInUse;		switch (pBSSIDList->NetworkTypeInUse) 		{		case Ndis802_11DS:			pBeaconReport->PhyType = PHY_TYPE_DSS;			///RETAILMSG(1,(TEXT("PhyType: PHY_TYPE_DSS\n")));			break;		case Ndis802_11OFDM24:			pBeaconReport->PhyType = PHY_TYPE_OFDM;			///RETAILMSG(1,(TEXT("PhyType: PHY_TYPE_OFDM\n")));			break;		case Ndis802_11OFDM5:			pBeaconReport->PhyType = PHY_TYPE_ERP;			///RETAILMSG(1,(TEXT("PhyType: PHY_TYPE_ERP\n")));			break;		}				///Received Signal Power		pBeaconReport->RcvSignalPower = (OS_UINT8)pBSSIDList->Rssi;		///BSSID		///NdisMoveMemory((PVOID)pBeaconReport->BSSID, pAdapter->PermanentAddr, MRVDRV_ETH_ADDR_LEN);		NdisMoveMemory((PVOID)pBeaconReport->BSSID, pBSSIDList->MacAddress, MRVDRV_ETH_ADDR_LEN);		///Parent TSF		pBeaconReport->ParentTSF = pAdapter->parentTSF;		///Target TSF		NdisMoveMemory((PVOID)pBeaconReport->TargetTSF, pBssDescList->TimeStamp, 8);		///Beacon Interval		pBeaconReport->BeaconInterval = (OS_UINT16)(pBSSIDList->Configuration.BeaconPeriod);		///Capability Information		NdisMoveMemory((PVOID)&pBeaconReport->CapabilityInfo, (PVOID)&pBssDescList->Cap, sizeof(pBeaconReport->CapabilityInfo));		///RETAILMSG(1,(TEXT("CapabilityInfo: %xh\n"), pBeaconReport->CapabilityInfo));		MRELength += sizeof(CCX_BEACON_MEASURE_REPORT);		repBufPt = ((UCHAR*)pBeaconReport) + sizeof(CCX_BEACON_MEASURE_REPORT);		///Received-Element		pCurPtr = pBSSIDIEListSrc->VariableIE;///PrintMacro("VariableIE_Len: %d\n", (pBSSIDList->IELength - MRVL_FIXED_IE_SIZE));///RETAILMSG(1,(TEXT("VariableIE_Len: %d\n"), (pBSSIDList->IELength - MRVL_FIXED_IE_SIZE)));		while ( ulCurOffset <                    (pBSSIDList->IELength - MRVL_FIXED_IE_SIZE) )		{			ElemID = *pCurPtr;            IELen = *(pCurPtr+1);			if (IELen == 0) {				PrintMacro("Abnormal: IELen is 0\n");				RETAILMSG(1,(TEXT("Abnormal: IELen is 0\n")));				break;			}			if ((ElemID != SSID) &&				(ElemID != SUPPORTED_RATES) && 				(ElemID != FH_PARAM_SET) && 				(ElemID != DS_PARAM_SET) && 				(ElemID != CF_PARAM_SET) && 				(ElemID != IBSS_PARAM_SET) && 				(ElemID != TIM)  				///(ElemID != RM_CAPABILITY)				) {				///RETAILMSG(1,(TEXT("Unknown IE(%d): %xh\n"), IELen, ElemID));				pCurPtr = pCurPtr + 2 + IELen;				continue;			}			///crlo:test ++			/*if (ElemID == TIM) {				RETAILMSG(1,(TEXT("TIM(%d)\n"), IELen));			}			if (ElemID == CF_PARAM_SET) {				RETAILMSG(1,(TEXT("CF_PARAM_SET(%d)\n"), IELen));			}*/			///crlo:test --			NdisMoveMemory((PVOID)repBufPt, (PVOID)pCurPtr, (IELen+2));			repBufPt = repBufPt + 2 + IELen;			pCurPtr = pCurPtr + 2 + IELen;			MRELength += (2 + IELen);			ulCurOffset = ulCurOffset + 2 + IELen;		}		///Record the length of the Measure_Report_Element (= total_length - [ElementID] - [Length])		pMRElem->Length = MRELength - 4;		///RETAILMSG(1,(TEXT("CCX_MEASURE_REPORT_ELEMENT len: %d\n"), pMRElem->Length));		pktlen += MRELength;		///Moving the pointer for the next Measure_Report_Element		pMRElem = (PCCX_MEASURE_REPORT_ELEMENT)repBufPt;	}	pIAPPFrameHdr->Length = GetBigEndian((OS_UINT8 *)&pktlen);	return pktlen;}void wlan_ccx_send_BeaconTable(IN PMRVDRV_ADAPTER Adapter){	UCHAR		iapp[SDIO_MAX_PKT_LEN];	UCHAR		*bufpt = iapp;	int			pktlen;	///Fill the "header" of the packet we need to generate	wlan_ccx_fillFrameHeader(Adapter, bufpt);	bufpt += sizeof(MRVPKTDESC);	///Fill the "SNAP" header	NdisMoveMemory(bufpt, ccxSnapHdr, sizeof(ccxSnapHdr));	bufpt += sizeof(ccxSnapHdr);	///Generate the iapp frame	pktlen = wlan_ccx_fillBeaconTable(Adapter, bufpt);	///PrintMacro("Iapp(%d) \n", pktlen);
	RETAILMSG(1,(TEXT("Iapp(%d) \n"), pktlen));	///Send the iapp frame	ccx_send(Adapter, pCCXPacket[0], iapp, sizeof(MRVPKTDESC)+sizeof(ccxSnapHdr)+pktlen);	RETAILMSG(1,(TEXT("End of wlan_ccx_send_BeaconTable \n")));	return;}void wlan_ccx_parse_iapp(IN PMRVDRV_ADAPTER Adapter, u8* pktBufPt, PPKTPARAM pPktParam){	PCCX_MEASURE_REQ_MSG	pPktMsg;	NdisZeroMemory(pPktParam, sizeof(PKTPARAM));	pPktParam->pkttype = CCXPKT_INVALID;	if (!NdisEqualMemory(pktBufPt, ccxSnapHdr, sizeof(ccxSnapHdr))) {		///RETAILMSG(1,(TEXT("ccxSnapHdr(%d)\n"), sizeof(ccxSnapHdr)));		///RETAILMSG(1,(TEXT("pktBufPt(%02xh, %02xh, %02xh, %02xh, %02xh, %02xh, %02xh, %02xh)\n"), 		///	pktBufPt[0], pktBufPt[1], pktBufPt[2], pktBufPt[3],		///	pktBufPt[4], pktBufPt[5], pktBufPt[6], pktBufPt[7]));		///RETAILMSG(1,(TEXT("ccxSnapHdr(%02xh, %02xh, %02xh, %02xh, %02xh, %02xh, %02xh, %02xh)\n"), 		///	ccxSnapHdr[0], ccxSnapHdr[1], ccxSnapHdr[2], ccxSnapHdr[3],		///	ccxSnapHdr[4], ccxSnapHdr[5], ccxSnapHdr[6], ccxSnapHdr[7]));		goto funcFinal;	}	pPktMsg = (PCCX_MEASURE_REQ_MSG)(&pktBufPt[sizeof(ccxSnapHdr)]);	if ((pPktMsg->iappHdr.Type == CCX_IAPP_TYPE_RADIO_MEASURE) &&		(pPktMsg->iappHdr.Func_SubType == CCX_IAPP_SUBTYPE_REQUEST) &&		(pPktMsg->reqElement[0].ElementID == ELEM_MEASURE_REQUEST)) {		///This is Radio Measurement, request Pkt		PCCX_MEASURE_REQ_ELEMENT	pMRmsg = &pPktMsg->reqElement[0];		Adapter->dialogToken = pPktMsg->dialogToken;		Adapter->MeasureToken = pMRmsg->MeasureToken;		RETAILMSG(1,(TEXT("MeasureToken: %xh\n"), Adapter->MeasureToken));		switch (pMRmsg->MeasureType) {		case MEASURE_REP_BEACON: {		///ASD Only supports Beacon_Request						PCCX_MEASURE_REQUEST	pParam = &pPktParam->beaconReq;			pPktParam->pkttype = CCXPKT_BEACON_REQUEST;			NdisMoveMemory(&pPktParam->beaconReq, pMRmsg->MeasureReq, sizeof(pMRmsg->MeasureReq[0]));			if (pPktParam->beaconReq.MeasureDuration > 200) {				RETAILMSG(1,(TEXT("MeasureDuration: %d is too big, Igonore this request\n"), pPktParam->beaconReq.MeasureDuration));				pPktParam->pkttype = CCXPKT_INVALID;				break;			}			}			break;		default:			break;;		}		RETAILMSG(1,(TEXT("pMRmsg->MeasureType: %xh\n"), pMRmsg->MeasureType));	}funcFinal:	return ;}///crlo:RadioMeasure --#ifdef CCX_CCKM// CCKM implementationint wlan_ccx_cckmStart(PUCHAR pTimestamp){	static FSW_CCX_CCKM_START cckmStart;	DBGPRINT(DBG_CCX,  ("[wlan_ccx_cckmStart] start"));	NdisMoveMemory(cckmStart.BSSID, ccxCurBSSID, sizeof(cckmStart.BSSID));	 	NdisMoveMemory(cckmStart.Timestamp, pTimestamp, sizeof(cckmStart.Timestamp));	        NdisMIndicateStatus(                              pCcxAdapter->MrvDrvAdapterHdl,                              OID_FSW_CCX_CCKM_START,                              (PVOID)&cckmStart,                              sizeof(cckmStart));       NdisMIndicateStatusComplete(pCcxAdapter->MrvDrvAdapterHdl);//	Our UI doesn't support CCKM yet//    MrvlNotifyApplication(COMMAND_EVENT_CCX_CCKM_START, (PUCHAR)&CckmStart,  sizeof(CckmStart));	// Start Timer	ccxCCKMState = CCX_CCKM_REQUEST;	return 0;}void	wlan_ccx_CCKMRequest(PFSW_CCX_CCKM_REQUEST pRequest){    	DBGPRINT(DBG_CCX,  ("[wlan_ccx_CCKMRequest] start"));	// Timer Handler	if ( ccxCCKMState == CCX_CCKM_REQUEST ) {	    	DBGPRINT(DBG_CCX,  ("[wlan_ccx_CCKMRequest] RequestCode=%d\n", pRequest->RequestCode));	        /* if this is a good hand-off, save parameters */	        if ( pRequest->RequestCode == FswCcx_CckmFastHandoff )	        {	            /* make sure IE length will fit our buffer */	            if ( pRequest->AssociationRequestIELength > 128 )	            {	                DBGPRINT(DBG_CCX, ("ccxCCKMReqeust: IE too long\n"));	                return;	            }		     ccxAssociationRequestIELength = pRequest->AssociationRequestIELength;		     NdisMoveMemory(ccxAssociationRequestIE, pRequest->AssociationRequestIE, ccxAssociationRequestIELength);		      ccxCCKMState = CCX_CCKM_RESULT;  // do re-association and wait result			  DBGPRINT(DBG_CCX, ("FswCcx_CckmFastHandoff --StaReAssociateRequest\n"));			//StaReAssociateRequest(p802_11,&p802_11->ccxTargetBSSID);					        } else	        {   /* otherwise, make sure that we don't send out CCKM IE */			ccxAssociationRequestIELength = 0;				DBGPRINT(DBG_CCX, ("FswCcx_CckmFastFirstTime-StaAssociateRequest \n"));		      //StaAssociateRequest(p802_11,&p802_11->ccxTargetBSSID);	        }		ccx_associate();	}}#endif#endif ///CCX

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -