?? wt_mac.c
字號:
#include "wtprecomp.h"#if DBG#define _FILENUMBER 'CAMS'#endifvoid setWepBit( PWTWLAN_TXBUF PTxBuffer,char wb); //Have modified/***********************************************//* *//* *//* *//* *//***********************************************/void WtInitializeTimer(struct timer_list* timer, void* timer_function, IN PWT_ADAPTER Adapter){ init_timer(timer); (*timer).function = timer_function; (*timer).data = (unsigned long)(Adapter); add_timer(timer);}void WtCancelTimer(struct timer_list* timer){ del_timer_sync(timer);}void TimerInitialize(IN PWT_ADAPTER Adapter){ FN_ENTER; #ifdef WIN_PLATFORM NdisInitializeTimer(&Adapter->MacParameter.MacTimer.MacTimer.TBeacon), TBeaconProc, Adapter);//錕? NdisInitializeTimer(&Adapter->MacParameter.MacTimer.TATIM, TATIMProc, Adapter);//錕絋ATIM NdisInitializeTimer(&Adapter->MacParameter.MacTimer.TScan, TScanProc, Adapter);//錕絋Scan NdisInitializeTimer(&Adapter->MacParameter.MacTimer.TAuth, TAuthProc, Adapter); NdisInitializeTimer(&Adapter->MacParameter.MacTimer.TAsoc, TAsocProc, Adapter); NdisInitializeTimer(&Adapter->MacParameter.MacTimer.TReasoc, TReAsocProc, Adapter); NdisInitializeTimer(&Adapter->MacParameter.MacTimer.TJoin, TJoinProc, Adapter);//錕絋Join#else WtInitializeTimer(&(Adapter->MacParameter.MacTimer.BeaconProcTimer), &TBeaconProc, Adapter); WtInitializeTimer(&(Adapter->MacParameter.MacTimer.ATIMProcTimer), &TATIMProc, Adapter); WtInitializeTimer(&(Adapter->MacParameter.MacTimer.ScanProcTimer), &TScanProc, Adapter); WtInitializeTimer(&(Adapter->MacParameter.MacTimer.AuthProcTimer), &TAuthProc, Adapter); WtInitializeTimer(&(Adapter->MacParameter.MacTimer.AsocProcTimer), &TAsocProc, Adapter); WtInitializeTimer(&(Adapter->MacParameter.MacTimer.ReasocProcTimer), &TReAsocProc, Adapter); WtInitializeTimer(&(Adapter->MacParameter.MacTimer.JoinProcTimer), &TJoinProc, Adapter); WtInitializeTimer(&(Adapter->MacParameter.MacTimer.WatchDogTimer), &TWatchDogProc, Adapter);#endif FN_EXIT(0,0);}void TimerCancel(IN PWT_ADAPTER Adapter){ FN_ENTER; //deactivate timer del_timer_sync(&(Adapter->MacParameter.MacTimer.BeaconProcTimer)); del_timer_sync(&(Adapter->MacParameter.MacTimer.ATIMProcTimer)); del_timer_sync(&(Adapter->MacParameter.MacTimer.ScanProcTimer)); del_timer_sync(&(Adapter->MacParameter.MacTimer.AuthProcTimer)); del_timer_sync(&(Adapter->MacParameter.MacTimer.AsocProcTimer)); del_timer_sync(&(Adapter->MacParameter.MacTimer.ReasocProcTimer)); del_timer_sync(&(Adapter->MacParameter.MacTimer.JoinProcTimer)); del_timer_sync(&(Adapter->MacParameter.MacTimer.WatchDogTimer)); FN_EXIT(0,0);}void TBeaconProc(IN PWT_ADAPTER Adapter){ FN_ENTER; //printk("<0>current stat = %d\r\n",Adapter->MacParameter.CurrentState); if(Adapter->MacParameter.CurrentState == IBSS_IDLE || Adapter->MacParameter.CurrentState == IBSS_ACTIVE) TBeacnIBSS(Adapter); else if(Adapter->MacParameter.CurrentState == ASOC_PASS) TBeacnBSS(Adapter); FN_EXIT(0,0); return; }//錕絀BSSvoid TBeacnIBSS(IN PWT_ADAPTER Adapter){ char Str[11]/*[10]*/, FrameBody[256]; USHORT BodyLen = 0; ULONG Timeout; PWTWLAN_TXBUF PTxBuffer; FN_ENTER; //printk("In TBeacn IBSS\n"); if((Adapter->MacParameter.CurrentState == IBSS_IDLE) || (Adapter->MacParameter.CurrentState == IBSS_ACTIVE) ) { //mod_timer(&(Adapter->MacParameter.MacTimer.BeaconProcTimer), jiffies+(100/1000000)*HZ); Timeout = (100*HZ)/1000; mod_timer(&(Adapter->MacParameter.MacTimer.BeaconProcTimer), jiffies+Timeout); //printk("<0>In Function %s before AllocTxMgmt\n\r",__FUNCTION__); AllocTxMgmt( Adapter, &PTxBuffer); //printk("<0>In Function %s after AllocTxMgmt\n\r",__FUNCTION__); if( PTxBuffer == NULL ) return; memset(&(PTxBuffer->TXHwBuf.pHwTxBuf->TxAUXBuf), 0, (sizeof(WTWLAN_TAUXB))); memset(&(PTxBuffer->TXHwBuf.pHwTxBuf->dot11Head), 0, (Adapter->MacHwCfg.HeadLen)); //TimeStamp memset(FrameBody, 0, 8); BodyLen +=8; //beacon interval memcpy(FrameBody + BodyLen, int16ToS((int16)(Adapter->MacParameter.mBcnInterval & 0xFFFF), Str), 2); BodyLen +=2; //cap Adapter->MacParameter.mCap = 2 ;//edited by hk 2004.11.12 if(Adapter->MacParameter.mEncryptMode) { Adapter->MacParameter.mCap |= 0x10; } memcpy(FrameBody + BodyLen, int16ToS(Adapter->MacParameter.mCap, Str), 2); BodyLen +=2; //SSID FrameBody[BodyLen] = eSsId;BodyLen+=1; FrameBody[BodyLen] = (UCHAR)Adapter->MacParameter.mSsId.SsidLength;BodyLen+=1; memcpy(FrameBody + BodyLen, Adapter->MacParameter.mSsId.Ssid, Adapter->MacParameter.mSsId.SsidLength); BodyLen += (USHORT)(Adapter->MacParameter.mSsId.SsidLength ); //edited by hk 2005.6.13 //Supported rates //memcpy(FrameBody + BodyLen, mkElem(eSupRates, Str, Adapter->dot11Mib.dot11OperationalRateSet,8), 10); //BodyLen += 10; switch ( Adapter->Ndis80211Parameter.ABGMode) { case IEEE80211A_ONLY: { //eSupRate Str[0] = eSupRates ; Str[1] = 8 ; //just for test Str[2] = 0x0c; Str[3] = 0x12; Str[4] = 0x18; Str[5] = 0x24; Str[6] = 0x30; Str[7] = 0x48; Str[8] = 0x60; Str[9] = 0x6c; memcpy( FrameBody + BodyLen, Str, 10); BodyLen += 10; } break; case IEEE80211B_AND_G: { Str[0] = eSupRates ; Str[1] = 8; //just for test Str[2] = dot11rate1M; Str[3] = dot11rate2M; Str[4] = dot11rate5_5M; Str[5] = dot11rate11M; Str[6] = dot11rate6M; Str[7] = dot11rate12M; Str[8] = dot11rate24M; Str[9] = dot11rate36M; memcpy( FrameBody + BodyLen, Str, 10); BodyLen += 10; } break; case IEEE80211B_ONLY: { //eSupRate Str[0] = eSupRates ; Str[1] = 4 ; /*memcpy( tmpelement+2, Adapter->MacParameter.mBrates, 8);*/ //just for test Str[2] = 0x82; Str[3] = 0x84; Str[4] = 0x8b; Str[5] = 0x96; memcpy( FrameBody + BodyLen, Str, 6); BodyLen += 6; } break; case IEEE80211G_ONLY: { Str[0] = eSupRates ; Str[1] = 8; //just for test Str[2] = 0x82; Str[3] = 0x84; Str[4] = 0x8b; Str[5] = 0x96; Str[6] = 0x8c; Str[7] = 0x98; Str[8] = 0xb0; Str[9] = 0x48; memcpy( FrameBody + BodyLen, Str, 10); BodyLen += 10; } break; default: //DBGPRINT_RAW(WT_ERROR, (" -- failed\n")); //ASSERT(FALSE); ; } //DS Parameter Set memcpy(FrameBody + BodyLen, mkElem(eDsParms, Str, &Adapter->MacParameter.mPhPm,1), 3);//channel BodyLen += 3; //IBSS Parameter Set Adapter->MacParameter.mIBPm = 0x0; memcpy(FrameBody + BodyLen, mkElem(eIbParms, Str, int16ToS(Adapter->MacParameter.mIBPm, Str), 2), 4); BodyLen += 4; //added by hk 2006.12.13 //extended supported rates switch ( Adapter->Ndis80211Parameter.ABGMode) { case IEEE80211A_ONLY://?????????? break; case IEEE80211B_AND_G: Str[0] = 0x2a; Str[1] = 1; Str[2] = 7; memcpy( FrameBody + BodyLen, Str, 3); BodyLen += 3; Str[0] = eXSupRates ;//信息元素 Str[1] = 4; Str[2] = dot11rate9M; Str[3] = dot11rate18M; Str[4] = dot11rate48M; Str[5] = dot11rate54M; memcpy( FrameBody + BodyLen, Str, 6); BodyLen += 6; break; case IEEE80211B_ONLY: break; case IEEE80211G_ONLY: break; default: //DBGPRINT_RAW(WT_ERROR, (" -- failed\n")); //ASSERT(FALSE); ; } //Generate beacon frame mkFrame(PTxBuffer, WLAN_FSTYPE_BEACON, Adapter->MacParameter.BcstAddr, Adapter->MacParameter.dot11MacAddress, Adapter->MacParameter.mBssid, FrameBody, BodyLen); Adapter->MacParameter.mAtimW = TRUE; Adapter->MacParameter.mAtimRx = FALSE; Adapter->MacParameter.mPss = awake; Timeout = (ULONG)(div64(Adapter->MacParameter.mIBPm,1000)*HZ); Timeout = Timeout/1000; //mod_timer(&(Adapter->MacParameter.MacTimer.ATIMProcTimer), (jiffies+div64(Adapter->MacParameter.mIBPm,1000)*HZ)); mod_timer(&(Adapter->MacParameter.MacTimer.ATIMProcTimer), (jiffies+Timeout)); Adapter->MacParameter.mProcState = Ibss_Active; Wake(); TBTT(); MmRequest(Adapter,PTxBuffer); } FN_EXIT(0,0); }#ifdef WIN_PLATFORMvoid TBeacnBSS(IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)#elsevoid TBeacnBSS(IN PWT_ADAPTER Adapter)#endif{ ULONG Timeout; FN_EXIT(0,0); // Timeout = (ULONG)(div64(Adapter->MacParameter.mBcnPeriod,1000)*HZ); Timeout = (Adapter->MacParameter.mBcnInterval*HZ)/1000; // mod_timer(&(Adapter->MacParameter.MacTimer.BeaconProcTimer), (jiffies+div64(Adapter->MacParameter.mBcnPeriod,1000)*HZ)); mod_timer(&(Adapter->MacParameter.MacTimer.BeaconProcTimer), (jiffies+Timeout)); if (Adapter->MacParameter.mDtimCount == 0) Adapter->MacParameter.mDtimCount = Adapter->dot11Mib.dot11DtimPeriod - 1; else Adapter->MacParameter.mDtimCount = Adapter->MacParameter.mDtimCount-1; if (Adapter->MacParameter.mDtimCount == 0) { if (CfpCount(Adapter->MacParameter.mCfPm) == 0) Adapter->MacParameter.mCfPm = SetCfpCount(Adapter->MacParameter.mCfPm, (char)(CfpPeriod(Adapter->MacParameter.mCfPm) - 1)); else Adapter->MacParameter.mCfPm = SetCfpCount(Adapter->MacParameter.mCfPm, (char)(CfpCount(Adapter->MacParameter.mCfPm) - 1)); if (CfpCount(Adapter->MacParameter.mCfPm) == 0) { ; //ChangeNav((Duration)CfpMaxDur(mCfPm), cfpBss);//錕斤拷錕斤拷始 } if (Adapter->MacParameter.mLiCnt == 0) Adapter->MacParameter.mLiCnt = Adapter->MacParameter.mListenInt -1; else Adapter->MacParameter.mLiCnt = Adapter->MacParameter.mLiCnt -1; if(Adapter->dot11Mib.dot11PowerMangementMode == power_save && Adapter->MacParameter.mLiCnt == 0 && Adapter->MacParameter.mReceiveDtims) { Adapter->MacParameter.mPss = awake; Wake(); } } FN_EXIT(0,0); }void FrmBeaconProc( IN PWT_ADAPTER Adapter, PWTWLAN_RXBUF pWtRxBuf){ wlan_fr_beacon_t *frm; FN_ENTER; p80211_hdr_t * hdr; frm = &pWtRxBuf->ParseData.a.beacon; memset( frm, 0, sizeof(wlan_fr_beacon_t)); frm->buf = (UINT8 *)pWtRxBuf; //printk("~~~enter function FrmBeaconProc"); if( FALSE == wt_mgmt_decode_beacon(frm) ) { printk("~~~~~~~~~~~~~~~~wt_mgmt_decode_beacon error\n"); goto out; } //printk("~~~enter function FrmBeaconProc ===%d\n",Adapter->MacParameter.CurrentState); if (Adapter->MacParameter.CurrentState == NO_BSS) { // printk("<0>In Function %s mxx~~~~~~~~~just before JoinAct\n\r",__FUNCTION__); JoinAct(Adapter, pWtRxBuf, 0, 0); //Adapter->BeaconReceiveWatchDog = 0; } //Adapter->BeaconReceiveWatchDog = 0; hdr = (p80211_hdr_t *)(&pWtRxBuf->RXHwBuf.pHwRxBuf->dot11Head);//added by hk 2005.6.28 if(0==memcmp (hdr->a3.a3, Adapter->MacParameter.mBssid, WLAN_ETHADDR_LEN)) { // printk("~~~enter function FrmBeaconProc adsfasdf \n"); Adapter->BeaconReceiveWatchDog = 0; }// printk("~~~~~Adapter->MlmeParameter.bScanOngoing==%d\n",Adapter->MlmeParameter.bScanOngoing); if( Adapter->MlmeParameter.bScanOngoing ) { ScanListen( Adapter,pWtRxBuf ); }out: FN_EXIT(0,0); return;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -