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

📄 rtmp_info.c

📁 Ralink RT61 SoftAP Driver source code. RT61:MiniPCI
💻 C
📖 第 1 页 / 共 5 页
字号:
#if WIRELESS_EXT >= 14
		case SIOCGIWSCAN:   //get scanning results
			RTMP_SIOCGIWSCAN(pAd,wrq);
			break;
		case SIOCSIWSCAN:   //trigger scanning (list cells)
			ApSiteSurvey(pAd);
			break;
#endif
		case SIOCGIWAPLIST: //client association list
			RTMP_SIOCGIWAPLIST(pAd,wrq);
			break;
		case RT_PRIV_IOCTL:
			subcmd = wrq->u.data.flags;
			if( subcmd & OID_GET_SET_TOGGLE)
				Status = RTMPSetInformation(pAd, rq, subcmd);
			else
				Status = RTMPQueryInformation(pAd, rq, subcmd);
			break;
		case SIOCGIWPRIV:
			if (wrq->u.data.pointer) {
				if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
					break;
				wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
				if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
					Status = -EFAULT;
			}
			break;
		case RTPRIV_IOCTL_SET:
			{				
				CHAR *this_char;
				CHAR *value;

				if( access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
					break;

				while ((this_char = strsep((char **)&wrq->u.data.pointer, ",")) != NULL) 
				{
					if (!*this_char)
						 continue;

					if ((value = strchr(this_char, '=')) != NULL)
						*value++ = 0;

					if (!value)
						continue;  							

					for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
					{
						if (!strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name)) 
						{						
							if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAd, value))
							{   //FALSE:Set private failed then return Invalid argument 								
								Status = -EINVAL;							
							}
							break;  //Exit for loop.
						}
					}

					if(PRTMP_PRIVATE_SET_PROC->name == NULL)
					{  //Not found argument
						Status = -EINVAL;
						DBGPRINT(RT_DEBUG_TRACE, "IOCTL::(iwpriv) Command not Support [%s=%s]\n", this_char, value);
						break;
					}	
				}
			}
			break;
		    
		case RTPRIV_IOCTL_GET_MAC_TABLE:
			RTMPIoctlGetMacTable(pAd,wrq);
		    break;
		    
		case RTPRIV_IOCTL_GSITESURVEY:
			RTMPIoctlGetSiteSurvey(pAd,wrq);
		    break;
		
		case RTPRIV_IOCTL_STATISTICS:
		    RTMPIoctlStatistics(pAd, wrq);
		    break;

		case RTPRIV_IOCTL_RADIUS_DATA:
		    RTMPIoctlRadiusData(pAd, wrq);
		    break;

		case RTPRIV_IOCTL_ADD_WPA_KEY:
		    RTMPIoctlAddWPAKey(pAd, wrq);
		    break;

		case RTPRIV_IOCTL_ADD_PMKID_CACHE:
		    RTMPIoctlAddPMKIDCache(pAd, wrq);
		    break;

		case RTPRIV_IOCTL_STATIC_WEP_COPY:
		    RTMPIoctlStaticWepCopy(pAd, wrq);
		    break;

#ifdef DBG
		case RTPRIV_IOCTL_BBP:
			RTMPIoctlBBP(pAd, wrq);
			break;
			
		case RTPRIV_IOCTL_MAC:
			RTMPIoctlMAC(pAd, wrq);
			break;

		case RTPRIV_IOCTL_E2P:
			RTMPIoctlE2PROM(pAd, wrq);
			break;
#endif

		default:
			DBGPRINT(RT_DEBUG_ERROR, "IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd);
			Status = -EOPNOTSUPP;
			break;
	}

	return Status;
}

/*
	========================================================================
	
	Routine Description:
		Change NIC PHY mode. Re-association may be necessary.

	Arguments:
		pAdapter						Pointer to our adapter
        phmode
		
	========================================================================
*/
VOID	RTMPSetPhyMode(
	IN	PRTMP_ADAPTER	pAd,
	IN  ULONG phymode,
	IN  UCHAR apidx)
{
	DBGPRINT(RT_DEBUG_TRACE,"IF(ra%d) RTMPSetPhyMode(=%d)\n", apidx, phymode);
    
	NdisZeroMemory(pAd->PortCfg.SupportedRates, MAX_LEN_OF_SUPPORTED_RATES);
	NdisZeroMemory(pAd->PortCfg.MBSSID[apidx].DesiredRates, MAX_LEN_OF_SUPPORTED_RATES);
	
    switch (phymode) {
    	case PHY_11A:
            pAd->PortCfg.SupportedRates[0]  = 0x8C;    // 6 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[1]  = 0x12;    // 9 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[2]  = 0x98;    // 12 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[3]  = 0x24;    // 18 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[4]  = 0xb0;    // 24 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[5]  = 0x48;    // 36 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[6]  = 0x60;    // 48 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[7]  = 0x6c;    // 54 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRatesLen  = 8;
            pAd->PortCfg.MBSSID[apidx].DesiredRates[0]  = 12;    // 6 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[1]  = 18;    // 9 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[2]  = 24;    // 12 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[3]  = 36;    // 18 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[4]  = 48;    // 24 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[5]  = 72;    // 36 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[6]  = 96;    // 48 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[7]  = 108;   // 54 mbps, in units of 0.5 Mbps
            break;
        case PHY_11B:
            pAd->PortCfg.SupportedRates[0]  = 0x82;    // 1 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[1]  = 0x84;    // 2 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[2]  = 0x0B;    // 5.5 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[3]  = 0x16;    // 11 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRatesLen  = 4;
            pAd->PortCfg.MBSSID[apidx].DesiredRates[0]  = 2;     // 1 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[1]  = 4;     // 2 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[2]  = 11;    // 5.5 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[3]  = 22;    // 11 mbps, in units of 0.5 Mbps
            break;
        case PHY_11BG_MIXED:
            // 2004-1-12 to keep maximum compatibility with 802.11b-only clients, we should not turn on
            // BASIC RATE bit of any OFDM rates in outgoing BEACON and ProbrResponse frames
            pAd->PortCfg.SupportedRates[0]  = 0x82;    // 1 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[1]  = 0x84;    // 2 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[2]  = 0x8B;    // 5.5 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[3]  = 0x96;    // 11 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[4]  = 0x0C;    // 6 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[5]  = 0x12;    // 9 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[6]  = 0x18;    // 12 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[7]  = 0x24;    // 18 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[8]  = 0x30;    // 24 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[9]  = 0x48;    // 36 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[10] = 0x60;    // 48 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[11] = 0x6C;    // 54 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRatesLen  = 12;
            pAd->PortCfg.MBSSID[apidx].DesiredRates[0]  = 2;     // 1 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[1]  = 4;     // 2 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[2]  = 11;    // 5.5 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[3]  = 22;    // 11 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[4]  = 12;    // 6 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[5]  = 18;    // 9 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[6]  = 24;    // 12 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[7]  = 36;    // 18 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[8]  = 48;    // 24 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[9]  = 72;    // 36 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[10] = 96;    // 48 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[11] = 108;   // 54 mbps, in units of 0.5 Mbps
            break;
        case PHY_11G:
            // 2004-1-12 to keep maximum compatibility with 802.11b-only clients, we should not turn on
            // BASIC RATE bit of any OFDM rates in outgoing BEACON and ProbrResponse frames
            pAd->PortCfg.SupportedRates[0]  = 0x82;    // 1 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[1]  = 0x84;    // 2 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[2]  = 0x8B;    // 5.5 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[3]  = 0x96;    // 11 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[4]  = 0x8C;    // 6 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[5]  = 0x12;    // 9 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[6]  = 0x98;    // 12 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[7]  = 0x24;    // 18 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[8]  = 0xB0;    // 24 mbps, in units of 0.5 Mbps, basic rate
            pAd->PortCfg.SupportedRates[9]  = 0x48;    // 36 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[10] = 0x60;    // 48 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRates[11] = 0x6C;    // 54 mbps, in units of 0.5 Mbps
            pAd->PortCfg.SupportedRatesLen  = 12;
            pAd->PortCfg.MBSSID[apidx].DesiredRates[0]  = 2;     // 1 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[1]  = 4;     // 2 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[2]  = 11;    // 5.5 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[3]  = 22;    // 11 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[4]  = 12;    // 6 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[5]  = 18;    // 9 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[6]  = 24;    // 12 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[7]  = 36;    // 18 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[8]  = 48;    // 24 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[9]  = 72;    // 36 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[10] = 96;    // 48 mbps, in units of 0.5 Mbps
            pAd->PortCfg.MBSSID[apidx].DesiredRates[11] = 108;   // 54 mbps, in units of 0.5 Mbps
            break;
        default:
            break;
    }
}

INT Set_DriverVersion_Proc(
	IN	PRTMP_ADAPTER	pAd, 
	IN	PUCHAR			arg)
{
    DBGPRINT(RT_DEBUG_TRACE, "Driver version-%s\n", DRIVER_VERSION);
    
    return TRUE;
}

/* 
    ==========================================================================
    Description:
        Set Country Region.
        This command will not work, if the field of CountryRegion in eeprom is programmed.
    Return:
        TRUE if all parameters are OK, FALSE otherwise
    ==========================================================================
*/
INT Set_CountryRegion_Proc(
	IN	PRTMP_ADAPTER	pAd, 
	IN	PUCHAR			arg)
{
	ULONG region;
		
	region = simple_strtol(arg, 0, 10);

	// Country can be set only when EEPROM not programmed
	if (pAd->PortCfg.CountryRegion & 0x80)
	{
		DBGPRINT(RT_DEBUG_ERROR, "Set_CountryRegion_Proc::parameter of CountryRegion in eeprom is programmed \n");
		return FALSE;
	}
	
	if(region >= 0)
	{
		pAd->PortCfg.CountryRegion = (UCHAR) region;
	}
	else
	{
		DBGPRINT(RT_DEBUG_ERROR, "Set_CountryRegion_Proc::parameters out of range\n");
		return FALSE;
	}

	// if set country region, driver needs to be reset
	BuildChannelList(pAd);

	DBGPRINT(RT_DEBUG_TRACE, "Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAd->PortCfg.CountryRegion);

	return TRUE;
}

/* 
    ==========================================================================
    Description:
        Set Country Region for A band.
        This command will not work, if the field of CountryRegion in eeprom is programmed.
    Return:
        TRUE if all parameters are OK, FALSE otherwise
    ==========================================================================
*/
INT Set_CountryRegionABand_Proc(
	IN	PRTMP_ADAPTER	pAd, 
	IN	PUCHAR			arg)
{
	ULONG region;
		
	region = simple_strtol(arg, 0, 10);

	// Country can be set only when EEPROM not programmed
	if (pAd->PortCfg.CountryRegionForABand & 0x80)
	{
		DBGPRINT(RT_DEBUG_ERROR, "Set_CountryRegionABand_Proc::parameter of CountryRegion in eeprom is programmed \n");
		return FALSE;
	}
	
	if((region >= 0) && (region != 9)) //region 9 already not support old band
	{
		pAd->PortCfg.CountryRegionForABand = (UCHAR) region;
	}
	else
	{
		DBGPRINT(RT_DEBUG_ERROR, "Set_CountryRegionABand_Proc::parameters out of range\n");
		return FALSE;
	}

	// if set country region, driver needs to be reset
	BuildChannelList(pAd);

	DBGPRINT(RT_DEBUG_TRACE, "Set_CountryRegionABand_Proc::(CountryRegion=%d)\n", pAd->PortCfg.CountryRegionForABand);

	return TRUE;
}

/* 
    ==========================================================================
    Description:
        Set Country Code.
    Return:
        TRUE if all parameters are OK, FALSE otherwise
    ==========================================================================
*/
INT Set_CountryCode_Proc(
	IN	PRTMP_ADAPTER	pAd, 
	IN	PUCHAR			arg)
{

	if(strlen(arg) == 2)
	{
		NdisMoveMemory(pAd->PortCfg.CountryCode, arg, 2);
		pAd->PortCfg.CountryCode[2] = ' ';
		pAd->PortCfg.bCountryFlag = TRUE;
	}
	else
	{
		NdisZeroMemory(pAd->PortCfg.CountryCode, 3);
		pAd->PortCfg.bCountryFlag = FALSE;
	}	
		
	DBGPRINT(RT_DEBUG_TRACE, "Set_CountryCode_Proc::(bCountryFlag=%d, CountryCode=%s)\n", pAd->PortCfg.bCountryFlag, pAd->PortCfg.CountryCode);

	return TRUE;
}

/* 
    ==========================================================================
    Description:
        Set SSID
    Return:
        TRUE if all parameters are OK, FALSE otherwise
    ==========================================================================
*/
INT	Set_SSID_Proc(
	IN	PRTMP_ADAPTER	pAdapter, 
	IN	PUCHAR			arg)
{
	INT   success = FALSE;

	if(strlen(arg) <= MAX_LEN_OF_SSID)
	{
		NdisZeroMemory(pAdapter->PortCfg.MBSSID[pAdapter->IoctlIF].Ssid, MAX_LEN_OF_SSID);
		NdisMoveMemory(pAdapter->PortCfg.MBSSID[pAdapter->IoctlIF].Ssid, arg, strlen(arg));
		pAdapter->PortCfg.MBSSID[pAdapter->IoctlIF].SsidLen = (UCHAR)strlen(arg);
		success = TRUE;

		// If in detection mode, need to stop detect first.
		if (pAdapter->PortCfg.RadarDetect.IEEE80211H == FALSE)
		{
			ApStop(pAdapter, TRUE);
			ApStartUp(pAdapter, TRUE);
		}

⌨️ 快捷键说明

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