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

📄 sanity.c

📁 华硕无线网卡 167G linux 驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************  * RT2x00 SourceForge Project - http://rt2x00.sourceforge.net              *  *                                                                         *  *   This program is free software; you can redistribute it and/or modify  *  *   it under the terms of the GNU General Public License as published by  *  *   the Free Software Foundation; either version 2 of the License, or     *  *   (at your option) any later version.                                   *  *                                                                         *  *   This program is distributed in the hope that it will be useful,       *  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *  *   GNU General Public License for more details.                          *  *                                                                         *  *   You should have received a copy of the GNU General Public License     *  *   along with this program; if not, write to the                         *  *   Free Software Foundation, Inc.,                                       *  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *  *                                                                         *  *   Licensed under the GNU GPL                                            *  *   Original code supplied under license from RaLink Inc, 2004.           *  ***************************************************************************//***************************************************************************  *	Module Name:	sanityc * *	Abstract: * *	Revision History: *	Who		When		What *	--------	----------	------------------------------- *	Name		Date		Modification logs *	Jan Lee		2005-06-01	Release ***************************************************************************/#include "rt_config.h"UCHAR	WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01};UCHAR	RSN_OUI[] = {0x00, 0x0f, 0xac};extern 	UCHAR	BCAST[];/*     ==========================================================================    Description:        MLME message sanity check    Return:        TRUE if all parameters are OK, FALSE otherwise    ========================================================================== */BOOLEAN MlmeScanReqSanity(    IN PRT2570ADAPTER pAd,     IN VOID *Msg,     IN ULONG MsgLen,     OUT UCHAR *BssType,     OUT CHAR Ssid[],     OUT UCHAR *SsidLen,     OUT UCHAR *ScanType) {    MLME_SCAN_REQ_STRUCT *Info;        Info = (MLME_SCAN_REQ_STRUCT *)(Msg);    *BssType = Info->BssType;    *SsidLen = Info->SsidLen;    memcpy(Ssid, Info->Ssid, *SsidLen);    *ScanType = Info->ScanType;        if ((*BssType == BSS_INFRA || *BssType == BSS_INDEP || *BssType == BSS_ANY) &&       (*ScanType == SCAN_ACTIVE || *ScanType == SCAN_PASSIVE))         return TRUE;    else     {        DBGPRINT(RT_DEBUG_TRACE, "MlmeScanReqSanity fail - wrong BssType or ScanType\n");        return FALSE;    }}/*     ==========================================================================    Description:        MLME message sanity check    Return:        TRUE if all parameters are OK, FALSE otherwise    ========================================================================== */BOOLEAN MlmeStartReqSanity(    IN PRT2570ADAPTER pAd,     IN VOID *Msg,     IN ULONG MsgLen,     OUT CHAR Ssid[],     OUT UCHAR *SsidLen) {    MLME_START_REQ_STRUCT *Info;    Info = (MLME_START_REQ_STRUCT *)(Msg);        if (Info->SsidLen > MAX_LEN_OF_SSID)    {        DBGPRINT(RT_DEBUG_TRACE, "MlmeStartReqSanity fail - wrong SSID length\n");        return FALSE;    }    *SsidLen = Info->SsidLen;    memcpy(Ssid, Info->Ssid, *SsidLen);    return TRUE;}/*     ==========================================================================    Description:        MLME message sanity check    Return:        TRUE if all parameters are OK, FALSE otherwise        	IRQL = DISPATCH_LEVEL    ========================================================================== */BOOLEAN MlmeAssocReqSanity(    IN PRT2570ADAPTER pAd,     IN VOID *Msg,     IN ULONG MsgLen,     OUT MACADDR *ApAddr,     OUT USHORT *CapabilityInfo,     OUT ULONG *Timeout,     OUT USHORT *ListenIntv) {    MLME_ASSOC_REQ_STRUCT *Info;    Info = (MLME_ASSOC_REQ_STRUCT *)Msg;    *Timeout = Info->Timeout;                             // timeout    COPY_MAC_ADDR(ApAddr, &Info->Addr);                   // AP address    *CapabilityInfo = Info->CapabilityInfo;               // capability info    *ListenIntv = Info->ListenIntv;        return TRUE;}/*     ==========================================================================    Description:        MLME message sanity check    Return:        TRUE if all parameters are OK, FALSE otherwise    ========================================================================== */BOOLEAN MlmeAuthReqSanity(    IN PRT2570ADAPTER pAd,     IN VOID *Msg,     IN ULONG MsgLen,     OUT MACADDR *Addr,     OUT ULONG *Timeout,     OUT USHORT *Alg) {    MLME_AUTH_REQ_STRUCT *Info;    Info  = (MLME_AUTH_REQ_STRUCT *)Msg;    COPY_MAC_ADDR(Addr, &Info->Addr);    *Timeout = Info->Timeout;    *Alg = Info->Alg;        if ((*Alg == Ndis802_11AuthModeShared || *Alg == Ndis802_11AuthModeOpen) && !MAC_ADDR_IS_GROUP(*Addr))     {        return TRUE;    }     else     {        DBGPRINT(RT_DEBUG_TRACE, "MlmeAuthReqSanity fail - wrong algorithm\n");        return FALSE;    }}/*     ==========================================================================    Description:        MLME message sanity check    Return:        TRUE if all parameters are OK, FALSE otherwise        	IRQL = DISPATCH_LEVEL    ========================================================================== */BOOLEAN PeerAssocRspSanity(    IN PRT2570ADAPTER pAd,     IN VOID *Msg,     IN ULONG MsgLen,     OUT MACADDR *Addr2,     OUT USHORT *CapabilityInfo,     OUT USHORT *Status,     OUT USHORT *Aid,     OUT UCHAR Rates[],     OUT UCHAR *RatesLen,    OUT BOOLEAN *ExtendedRateIeExist) {    CHAR          IeType, *Ptr;    MACFRAME     *Fr = (MACFRAME *)Msg;    PBEACON_EID_STRUCT	eid_ptr;        COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);    Ptr = Fr->Octet;            memcpy(CapabilityInfo, &Fr->Octet[0], 2);    memcpy(Status,         &Fr->Octet[2], 2);	// Mask out unnecessary capability information	*CapabilityInfo &= SUPPORTED_CAPABILITY_INFO;        if (*Status == MLME_SUCCESS)     {        memcpy(Aid, &Fr->Octet[4], 2);        *Aid = (*Aid) & 0x3fff; // AID is low 14-bit                // -- get supported rates from payload and advance the pointer        IeType = Fr->Octet[6];        *RatesLen = Fr->Octet[7];        if ((IeType != IE_SUPP_RATES) || (*RatesLen > MAX_LEN_OF_SUPPORTED_RATES))        {            DBGPRINT(RT_DEBUG_TRACE, "PeerAssocRspSanity fail - wrong SupportedRates IE\n");            return FALSE;        }         else        		memcpy(Rates, &Fr->Octet[8], *RatesLen);        // many AP implement proprietary IEs in non-standard order, we'd better        // tolerate mis-ordered IEs to get best compatibility        *ExtendedRateIeExist = FALSE;        eid_ptr = (PBEACON_EID_STRUCT) &Fr->Octet[8 + (*RatesLen)];                    // get variable fields from payload and advance the pointer        while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))        {            switch (eid_ptr->Eid)            {                case IE_EXT_SUPP_RATES:                    *ExtendedRateIeExist = TRUE;                    if ((*RatesLen + eid_ptr->Len) <= MAX_LEN_OF_SUPPORTED_RATES)                    {                        memcpy(&Rates[*RatesLen], eid_ptr->Octet, eid_ptr->Len);                        *RatesLen = (*RatesLen) + eid_ptr->Len;                    }                    else                    {                        memcpy(&Rates[*RatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*RatesLen));                        *RatesLen = MAX_LEN_OF_SUPPORTED_RATES;                    }                    break;                default:                    DBGPRINT(RT_DEBUG_TRACE, "PeerAssocRspSanity - ignore unrecognized EID = %d\n", eid_ptr->Eid);                    break;            }                               eid_ptr = (PBEACON_EID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);                }    }        return TRUE;}/*     ==========================================================================    Description:        MLME message sanity check    Return:        TRUE if all parameters are OK, FALSE otherwise        	IRQL = DISPATCH_LEVEL    ========================================================================== */BOOLEAN PeerDisassocSanity(    IN PRT2570ADAPTER pAd,     IN VOID *Msg,     IN ULONG MsgLen,     OUT MACADDR *Addr2,     OUT USHORT *Reason) {    MACFRAME *Fr = (MACFRAME *)Msg;    COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);    memcpy(Reason, &Fr->Octet[0], 2);    return TRUE;}/*     ==========================================================================    Description:        MLME message sanity check    Return:        TRUE if all parameters are OK, FALSE otherwise        	IRQL = DISPATCH_LEVEL    ========================================================================== */BOOLEAN PeerDeauthSanity(    IN PRT2570ADAPTER pAd,     IN VOID *Msg,     IN ULONG MsgLen,     OUT MACADDR *Addr2,     OUT USHORT *Reason) {    MACFRAME *Fr = (MACFRAME *)Msg;    COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);    memcpy(Reason, &Fr->Octet[0], 2);    return TRUE;}/*     ==========================================================================    Description:        MLME message sanity check    Return:        TRUE if all parameters are OK, FALSE otherwise        	IRQL = DISPATCH_LEVEL    ========================================================================== */BOOLEAN PeerAuthSanity(    IN PRT2570ADAPTER pAd,     IN VOID *Msg,     IN ULONG MsgLen,     OUT MACADDR *Addr,     OUT USHORT *Alg,     OUT USHORT *Seq,     OUT USHORT *Status,     CHAR *ChlgText) {    MACFRAME     *Fr = (MACFRAME *)Msg;    COPY_MAC_ADDR(Addr,    &Fr->Hdr.Addr2);    memcpy(Alg,    &Fr->Octet[0], 2);    memcpy(Seq,    &Fr->Octet[2], 2);    memcpy(Status, &Fr->Octet[4], 2);    if (*Alg == Ndis802_11AuthModeOpen)     {        if (*Seq == 1 || *Seq == 2)         {            return TRUE;        }         else         {            DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong Seg#\n");            return FALSE;        }    }     else if (*Alg == Ndis802_11AuthModeShared)     {        if (*Seq == 1 || *Seq == 4)         {            return TRUE;        }         else if (*Seq == 2 || *Seq == 3)         {            memcpy(ChlgText, &Fr->Octet[8], CIPHER_TEXT_LEN);            return TRUE;        }         else         {            DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong Seg#\n");            return FALSE;        }    }     else     {        DBGPRINT(RT_DEBUG_TRACE, "PeerAuthSanity fail - wrong algorithm\n");        return FALSE;    }}/*     ==========================================================================    Description:        MLME message sanity check    Return:        TRUE if all parameters are OK, FALSE otherwise        	IRQL = DISPATCH_LEVEL    ========================================================================== */BOOLEAN PeerProbeReqSanity(    IN PRT2570ADAPTER pAd,     IN VOID *Msg,     IN ULONG MsgLen,     OUT MACADDR *Addr2,    OUT CHAR Ssid[],     OUT UCHAR *SsidLen) //    OUT UCHAR Rates[], //    OUT UCHAR *RatesLen) {    UCHAR Idx;	UCHAR	RateLen;	CHAR          IeType;    MACFRAME *Fr = (MACFRAME *)Msg;    COPY_MAC_ADDR(Addr2, &Fr->Hdr.Addr2);    if ((Fr->Octet[0] != IE_SSID) || (Fr->Octet[1] > MAX_LEN_OF_SSID))     {        DBGPRINT(RT_DEBUG_TRACE, "PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",Fr->Octet[0],Fr->Octet[1]);        return FALSE;    }         *SsidLen = Fr->Octet[1];    memcpy(Ssid, &Fr->Octet[2], *SsidLen);    Idx = *SsidLen + 2;	// -- get supported rates from payload and advance the pointer	IeType = Fr->Octet[Idx];	RateLen = Fr->Octet[Idx + 1];	if (IeType != IE_SUPP_RATES)     {        DBGPRINT(RT_DEBUG_TRACE, "PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",Fr->Octet[Idx],Fr->Octet[Idx+1]);        return FALSE;    }	else	{		if ((pAd->PortCfg.AdhocMode == 2) && (RateLen < 8))			return (FALSE);	}    return TRUE;}/*     ==========================================================================    Description:        MLME message sanity check    Return:        TRUE if all parameters are OK, FALSE otherwise        	IRQL = DISPATCH_LEVEL    ========================================================================== */BOOLEAN PeerBeaconAndProbeRspSanity(    IN PRT2570ADAPTER pAd,     IN VOID *Msg,     IN ULONG MsgLen,     OUT MACADDR *Addr2,     OUT MACADDR *Bssid,     OUT CHAR Ssid[],     OUT UCHAR *SsidLen,     OUT UCHAR *BssType,     OUT USHORT *BeaconPeriod,     OUT UCHAR *Channel,     OUT LARGE_INTEGER *Timestamp,     OUT BOOLEAN *CfExist,     OUT CF_PARM *CfParm,     OUT USHORT *AtimWin,     OUT USHORT *CapabilityInfo,     OUT UCHAR Rate[],     OUT UCHAR *RateLen,    OUT BOOLEAN *ExtendedRateIeExist,    OUT UCHAR *Erp,    OUT UCHAR *DtimCount,     OUT UCHAR *DtimPeriod,     OUT UCHAR *BcastFlag,     OUT UCHAR *MessageToMe,     OUT UCHAR *Legacy,    OUT UCHAR SupRate[],	OUT UCHAR *SupRateLen,	OUT UCHAR ExtRate[],	OUT UCHAR *ExtRateLen,    OUT UCHAR *LengthVIE,    OUT	PNDIS_802_11_VARIABLE_IEs pVIE) {    CHAR				*Ptr, TimLen;    MACFRAME			*Fr;    PBEACON_EID_STRUCT	eid_ptr;    UCHAR				SubType;	UCHAR				Sanity;

⌨️ 快捷键说明

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