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

📄 wlan_11d.c

📁 此压缩包为杰得开发得z228的BSP的源代码,可以实现很多功能,尤其是视频解码有很好的效果.
💻 C
📖 第 1 页 / 共 2 页
字号:

#include "precomp.h"

// Convert Region string to code integer
UCHAR region_2_code(CHAR *region)
{
	int i, size;
	CHAR country1[COUNTRY_CODE_LEN + 1];
	//CHAR country2[COUNTRY_CODE_LEN + 1];

	DBGPRINT(DBG_ALLEN, ("region_2_code() \n"));

    NdisMoveMemory (country1, region, COUNTRY_CODE_LEN);
	country1[COUNTRY_CODE_LEN]='\0';
	
	size = sizeof(region_code_mapping)/sizeof(region_code_mapping_t);  

	for (i=0; i<size; i++)
	{  
        if( !(strncmp(region_code_mapping[i].region,country1,COUNTRY_CODE_LEN-1) ) )  
              break;

        #if 0 //dralee_20060613
		NdisMoveMemory (country2, region_code_mapping[i].region, COUNTRY_CODE_LEN);	
		country2[COUNTRY_CODE_LEN]='\0';	
		if ((country1[0]==country2[0] || country1[0]+0x20==country2[0] || country1[0]==country2[0]+0x20) &&
			(country1[1]==country2[1] || country1[1]+0x20==country2[1] || country1[1]==country2[1]+0x20) &&
			(country1[2]==country2[2] || country1[2]+0x20==country2[2] || country1[2]==country2[2]+0x20)) 
        #endif 
         
        return (region_code_mapping[i].code);
	}
	                                          
    RETAILMSG(1,(L"Use default:US region code:%x",region_code_mapping[0].code));
	//return 0; dralee_20060613 use US default
    return region_code_mapping[0].code;
}


// Convert interger code to region string
CHAR *code_2_region( UCHAR code )
{
	int i;
	int size = sizeof(region_code_mapping)/ sizeof(region_code_mapping_t); 
	for ( i=0; i< size; i++ ) 
	{
		if ( region_code_mapping[i].code == code )
			return (region_code_mapping[i].region);
	}
	return NULL;
}

/*
// Convert chan to frequency
ULONG chan_2_freq ( USHORT chan, UCHAR band)
{
	CHANNEL_FREQ_POWER 	*cf;
	UCHAR			    cnt;
	int 			    i;

	if ( band == MRVDRV_802_11_BAND_A ) 
	{
		cf =channel_freq_power_UN_AJ; 
		cnt = sizeof(channel_freq_power_UN_AJ)/sizeof(CHANNEL_FREQ_POWER);
	}
	else
	{
		cf = channel_freq_power_UN_BG;
		cnt = sizeof(channel_freq_power_UN_BG)/sizeof(CHANNEL_FREQ_POWER);
	}

	for ( i=0; i< cnt; i++ ) 
	{
		if ( chan == cf[i].Channel ) 
			return cf[i].Freq;
	}
	return 0;
}
*/

VOID
ResetAllScanTypeAndPower(
		PMRVDRV_ADAPTER Adapter
)
{
    UCHAR mode;

	DBGPRINT(DBG_ALLEN, ("ResetAllScanTypeAndPower() \n"));
                                                       
    //++dralee_20060427
	//RETAILMSG(1, (L"0ResetAllScanTypeAndPower() \n")); 
    if( Adapter->Enable80211D )  
        mode = HostCmd_SCAN_TYPE_PASSIVE;
    else
        mode = HostCmd_SCAN_TYPE_ACTIVE; 

	if (Adapter->region_channel[0].Valid)
	{
		Adapter->region_channel[0].Region = 0;
		NdisFillMemory(Adapter->region_channel[0].ScanType, MAX_PSCAN_CH_NUM, mode);
		NdisFillMemory(Adapter->region_channel[0].TxPower, MAX_PSCAN_CH_NUM, TX_PWR_DEFAULT);
	}
	if (Adapter->region_channel[1].Valid)
	{
		Adapter->region_channel[1].Region = 0;
		NdisFillMemory(Adapter->region_channel[1].ScanType, MAX_PSCAN_CH_NUM, mode);
		NdisFillMemory(Adapter->region_channel[1].TxPower, MAX_PSCAN_CH_NUM, TX_PWR_DEFAULT);
	}
}

VOID
UpdateScanTypeFromCountryIE(
		PMRVDRV_ADAPTER Adapter, 
	    UCHAR           BssidListIndex   // 0xff for all list entry	
)
{
    PBSS_DESCRIPTION_SET_ALL_FIELDS pBissidListDesc;
	IEEEtypes_CountryInfoFullSet_t  *pCountryIE;
	CHANNEL_FREQ_POWER              *pNewCFP_BG;
    CHANNEL_FREQ_POWER              *pNewCFP_A;

	IEEEtypes_SubbandSet_t          *pSubband;
	int                             RemainLen;
	int 							i, j, k, k1;
    UCHAR 							CountryNum;

	//RETAILMSG(1, (L"UpdateScanTypeFromCountryIE() \n"));	
	
	pBissidListDesc = Adapter->PSBssDescList;
	
	if (BssidListIndex == 0xff)
	{
    	for (i=0; Adapter->ulPSNumOfBSSIDs ; i++)
    	{
            pCountryIE = &(pBissidListDesc[i].CountryInfo);	
			CountryNum = region_2_code( pCountryIE->CountryCode);
			if (CountryNum != 0)  // first conntry info 
				break;			
    	}
	}
	else
	{
	    pCountryIE = &(pBissidListDesc[BssidListIndex].CountryInfo);
        CountryNum = region_2_code( pCountryIE->CountryCode);
	}
    
#if 0  //dralee-20060613
	if ((CountryNum != 0) && 
	    ((CountryNum == 0x10) || (CountryNum == 0x30) || (CountryNum == 0x31) ||
	     (CountryNum == 0x32) || (CountryNum == 0x40)))
    {
#endif
    RETAILMSG(1,(L"REGION CODE INDEX:%x\n\r",CountryNum)); 


	switch (CountryNum)
	{
    	case 0x10:    // "US ", "CA "
        	pNewCFP_BG = channel_freq_power_US_BG;
			pNewCFP_A  = channel_freq_power_A;

			k = sizeof(channel_freq_power_US_BG)/sizeof(CHANNEL_FREQ_POWER); 
	        k1 = sizeof(channel_freq_power_A)/sizeof(CHANNEL_FREQ_POWER);
        	break;
			
		case 0x30:    // "EU "
			pNewCFP_BG = channel_freq_power_EU_BG;
			pNewCFP_A  = channel_freq_power_EU_A;

			k = sizeof(channel_freq_power_EU_BG)/sizeof(CHANNEL_FREQ_POWER); 
	        k1 = sizeof(channel_freq_power_EU_A)/sizeof(CHANNEL_FREQ_POWER);
			break;

		case 0x31:    // "ES "	
			pNewCFP_BG = channel_freq_power_SPN_BG;
			pNewCFP_A  = channel_freq_power_A;

			k = sizeof(channel_freq_power_SPN_BG)/sizeof(CHANNEL_FREQ_POWER); 
	        k1 = sizeof(channel_freq_power_A)/sizeof(CHANNEL_FREQ_POWER);
			break;

		case 0x32:    // "FR "
			pNewCFP_BG = channel_freq_power_FR_BG;
			pNewCFP_A  = channel_freq_power_A;

			k = sizeof(channel_freq_power_FR_BG)/sizeof(CHANNEL_FREQ_POWER); 
	        k1 = sizeof(channel_freq_power_A)/sizeof(CHANNEL_FREQ_POWER);
			break;	

		case 0x40:    // "JP "
			pNewCFP_BG = channel_freq_power_JPN_BG;
			pNewCFP_A  = channel_freq_power_JPN_A;

			k = sizeof(channel_freq_power_JPN_BG)/sizeof(CHANNEL_FREQ_POWER); 
	        k1 = sizeof(channel_freq_power_JPN_A)/sizeof(CHANNEL_FREQ_POWER);
			break;	
    }

	DBGPRINT(DBG_ALLEN, ("CountryNum = %d, k = %d, k1 = %d \n", CountryNum, k, k1));
		
    if (Adapter->region_channel[0].Valid)
	{   
        //RETAILMSG(1,(L"region channel 0 valid\n\r"));

		Adapter->region_channel[0].Region  = CountryNum;
		// set passive scan type to all channel 
		NdisFillMemory(Adapter->region_channel[0].ScanType, MAX_PSCAN_CH_NUM, 0x01);

		for (i=0; i< Adapter->region_channel[0].NrCFP; i++)
		{
			for (j=0; j< k; j++)
			{
				if (Adapter->region_channel[0].CFP[i].Channel == pNewCFP_BG[j].Channel)
				{
					Adapter->region_channel[0].ScanType[i] = 0;	
				    break;
				}	
			}
        }

        RemainLen = pCountryIE->Len - COUNTRY_CODE_LEN;
		pSubband = pCountryIE->Subband;
		while (RemainLen)
		{
			for(j=0; j<pSubband->NoOfChan; j++)
			{
				for (i=0; i< Adapter->region_channel[0].NrCFP; i++)
				{
					if (Adapter->region_channel[0].CFP[i].Channel == pSubband->FirstChan + j)
					{
						Adapter->region_channel[0].TxPower[i] = pSubband->MaxTxPwr;
						break;
					
					}
				}	
			}
			RemainLen -= sizeof(IEEEtypes_SubbandSet_t);
			if (RemainLen < sizeof(IEEEtypes_SubbandSet_t))
				break;
			pSubband += 1;
		}

        HexDump(DBG_ALLEN, "region_channel[0]", (UCHAR *)&(Adapter->region_channel[0]), 
			               sizeof(REGION_CHANNEL));
		HexDump(DBG_ALLEN, "Adapter->region_channel.CFP", (UCHAR *)(Adapter->region_channel[0].CFP), 
			               sizeof(CHANNEL_FREQ_POWER)*k);
	}
	if (Adapter->region_channel[1].Valid)
	{                  
        //RETAILMSG(1,(L"region channel 1 valid\n\r"));

		Adapter->region_channel[1].Region  = CountryNum;
		// set passive scan type to all channel 
        NdisFillMemory(Adapter->region_channel[1].ScanType, MAX_PSCAN_CH_NUM, 0x01);

		
		for (i=0; i< Adapter->region_channel[1].NrCFP; i++)
		{
			for (j=0; j< k1; j++)
			{
				if (Adapter->region_channel[1].CFP[i].Channel == pNewCFP_BG[j].Channel)
				{   // set active sacn type to the channel  
					Adapter->region_channel[1].ScanType[i] = 0;	
				    break;
				}	
			}
        }

		RemainLen = pCountryIE->Len - COUNTRY_CODE_LEN;
		pSubband = pCountryIE->Subband;
		while (RemainLen)
		{
			for(j=0; j<pSubband->NoOfChan; j++)
			{
				for (i=0; i< Adapter->region_channel[1].NrCFP; i++)
				{
					if (Adapter->region_channel[1].CFP[i].Channel == pSubband->FirstChan + j)
					{
						Adapter->region_channel[1].TxPower[i] = pSubband->MaxTxPwr;
						break;
					
					}
				}	
			}
			RemainLen -= sizeof(IEEEtypes_SubbandSet_t);
			if (RemainLen < sizeof(IEEEtypes_SubbandSet_t))
				break;
			pSubband += 1;
		}
		HexDump(DBG_ALLEN, "region_channel[1]", (UCHAR *)&(Adapter->region_channel[1]), 
			               sizeof(REGION_CHANNEL));
		HexDump(DBG_ALLEN, "Adapter->region_channel.CFP", (UCHAR *)(Adapter->region_channel[1].CFP), 
			               sizeof(CHANNEL_FREQ_POWER)*k1);
	} 
    return;
}  
                                                     
//dralee_20060613
VOID UpdateScanTypeByCountryCode( PMRVDRV_ADAPTER Adapter, UCHAR CountryNum ) 

⌨️ 快捷键说明

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