?? wt_mac.c
字號:
}/*void FrmBeaconProc( IN PWT_ADAPTER Adapter, PWTWLAN_RXBUF pWtRxBuf){ BOOLEAN TimerCanceled; wlan_fr_beacon_t *frm; p80211_hdr_t * hdr; frm = &pWtRxBuf->ParseData.a.beacon; NdisZeroMemory( frm, sizeof(wlan_fr_beacon_t)); frm->buf = (UINT8 *)pWtRxBuf; //解析beacon幀 if( FALSE == wt_mgmt_decode_beacon(frm) ) { return; } hdr = (p80211_hdr_t *)(&pWtRxBuf->RXHwBuf.pHwRxBuf->dot11Head);//added by hk 2005.6.28 if ((Adapter->MacParameter.CurrentState == NO_BSS)&&(Adapter->MacParameter.mSsId.SsidLength>0)) { JoinAct(Adapter, pWtRxBuf, 0, 0); } if(NdisEqualMemory (hdr->a3.a3, Adapter->MacParameter.mBssid, WLAN_ETHADDR_LEN)) { DBGPRINT(WT_TRACE, ("receive beacon \n")); Adapter->BeaconReceiveWatchDog = 0; } if( Adapter->MlmeParameter.bScanOngoing ) { ScanListen( Adapter,pWtRxBuf ); }}*///IBSS錕斤拷錕斤拷錕?void FrmIBSSBeacon( IN PWT_ADAPTER Adapter, PWTWLAN_RXBUF PDU,Time REnd,Time tstr){ FrameElement Ele; INT64 TStamp,TStampTmp; FN_ENTER; memset(&Ele, 0, sizeof(Ele)); if (Adapter->MacParameter.mProcState != Ibss_Active && Adapter->MacParameter.mProcState != Ibss_Idle) { if (capA(PDU->RXHwBuf.pHwRxBuf->Buffer, cIbss) && memcmp(Adapter->MacParameter.mSsId.Ssid, PDU->ParseData.a.beacon.ssid->ssid, Adapter->MacParameter.mSsId.SsidLength) == 0) { memcpy(&TStampTmp, PDU->RXHwBuf.pHwRxBuf + 30, 8 ); TStamp = ieee2host64(TStampTmp); if (TStamp > TSF(Adapter, 0, FALSE)); { TSF(Adapter,TStamp + (now() - tstr), TRUE); Adapter->MacParameter.mProcState = Ibss_Idle; Cancel(); } } } FN_EXIT(0,0); }/***********************************************//***********************************************/void FrmBssBeacon( IN PWT_ADAPTER Adapter, WTWLAN_RXBUF *PRxBuffer){ int i; MacAddr tmp_addr2; NDIS_802_11_SSID tmp_essid; int16 tmp_data; UCHAR tmpelement[256]; INT64 Timestamp,CurTime,tmp_int64; static INT64 ytemp; //???? change later //int8 tmp_int8data; FN_ENTER; for (i=0; i<256; i++) tmpelement[i] = 0; if (Adapter->MacParameter.CurrentState==BSS) { addr2(PRxBuffer->RXHwBuf.pHwRxBuf->dot11Head, tmp_addr2); //GetElemToBuff( tmp_frame_p , eSupRates, &tmpmsdu,(unsigned char *)dot11OperationalRateSet); memset( &tmp_essid , 0 , sizeof(NDIS_802_11_SSID)); //tmp_essid.ssidLng = tmp_msdu.MsduLng; //memcpy( tmp_essid.ssid , tmpelement , tmp_msdu.MsduLng ); if((memcmp(Adapter->MacParameter.mBssid, tmp_addr2, 6)==0) && (memcmp(&Adapter->MacParameter.mSsId, &tmp_essid, Adapter->MacParameter.mSsId.SsidLength)==0)) { /*adopt values from beacon*/ memcpy(&tmp_data, &(PRxBuffer->RXHwBuf.pHwRxBuf->Buffer[8]), 2); Adapter->dot11Mib.dot11BeaconPeriod = tmp_data ; Adapter->MacParameter.yBcn = tmp_data ; //GetElemToBuff(cur_frame_p, eCfParms, &tmp_msdu, tmpelement); memcpy(&(Adapter->MacParameter.ycfpm.Count), tmpelement, 1); memcpy(&(Adapter->MacParameter.ycfpm.Period), &(tmpelement[1]), 1); memcpy(&(Adapter->MacParameter.ycfpm.MaxDur), &(tmpelement[2]), 2); memcpy(&(Adapter->MacParameter.ycfpm.DurRem), &(tmpelement[4]), 2); //memcpy(&tmp_int64, &(PRxBuffer->RXHwBuf.pHwRxBuf->Buffer[0]), 8); //ytemp = TSF( Adapter, tmp_int64 + now() - ieee2host64( PRxBuffer->RXHwBuf.pHwRxBuf->RxStatus.RecvStartTime ), TRUE); memcpy(&tmp_int64, &(PRxBuffer->RXHwBuf.pHwRxBuf->Buffer[0]), 8); Timestamp = ieee2host64(tmp_int64); CurTime = TSF( Adapter, 0ull, FALSE ); tmp_int64 = ieee2host64( PRxBuffer->RXHwBuf.pHwRxBuf->RxStatus.RecvStartTime ); ytemp = TSF( Adapter, Timestamp + CurTime - ieee2host64( PRxBuffer->RXHwBuf.pHwRxBuf->RxStatus.RecvStartTime ), TRUE); if(Adapter->MacParameter.ycfpm.DurRem>0) Adapter->MacParameter.mCfp = TRUE; else Adapter->MacParameter.mCfp = FALSE; if(Adapter->dot11Mib.dot11PowerMangementMode == power_save) { //GetElemToBuff( cur_frame_p , eTim , &tmp_msdu, tmpelement );#if 0 if(tmp_msdu.MsduLng != 0) //??? { yTim.Length = tmp_msdu.MsduLng; tmp_int8data = 0; memcpy(&tmp_int8data, tmpelement, 1); yTim.Count = tmp_int8data; tmp_int8data = 0; memcpy(&tmp_int8data, &(tmpelement[1]), 1); yTim.Period = tmp_int8data; tmp_int8data = 0; memcpy(&tmp_int8data, &(tmpelement[2]), 1); yTim.mapControl = tmp_int8data; memset(yTim.pvMap , 0 , 251); memcpy(yTim.pvMap , &(tmpelement[3]) , tmp_msdu.MsduLng-3); if(bufFrame(&yTim, mAId) || (bufBcst(&yTim)&&(dtCount(&yTim)==0))) { mPss = awake ; /*??????????????? //Not pollabel and in CFP if(( mCfp == FALSE )&&((staCap & 0XC) == 0)) { memcpy(tmpelement,&mAId,2); new_frame_id = AllocFrameID(); new_frame_p = GetFramePoint( new_frame_id ); mkCtl(new_frame_p, ps_poll, tmpelement, mBssid, dot11MacAddress); new_msg_id = AllocMessageID(); new_msg = GetMessagePoint(new_msg_id ); if(!new_msg) return; new_msg->Pid_Src = Synchronization_sta_ID; new_msg->Pid_Des = Distribute_Mmpdus_ID; new_msg->Msgtype = Send; new_msg->Message_Body.Send_Var = new_frame_id; MsgQlast(Queue_Current, new_msg_id); } */ } else { // Doze /* new_msg_id = AllocMessageID(); new_msg = GetMessagePoint(new_msg_id ); if(!new_msg) return; new_msg->Pid_Src = Synchronization_sta_ID; new_msg->Pid_Des = Tx_Coordination_sta_ID; new_msg->Msgtype = Doze; MsgQlast(Queue_Current, new_msg_id); */ }#endif //if 0 } } } FN_EXIT(0,0); } //錕紸TIM幀時拇錕斤拷void FrmATIMProc( IN PWT_ADAPTER Adapter ){ FN_ENTER; if ((Adapter->MacParameter.CurrentState == IBSS_IDLE) || (Adapter->MacParameter.CurrentState == IBSS_ACTIVE) ) Adapter->MacParameter.mAtimRx = TRUE; FN_EXIT(0,0);} void TATIMProc(IN PWT_ADAPTER Adapter){ //PWT_ADAPTER Adapter = (PWT_ADAPTER)FunctionContext; FN_ENTER; if ((Adapter->MacParameter.CurrentState == IBSS_IDLE) || (Adapter->MacParameter.CurrentState == IBSS_ACTIVE) ) { Adapter->MacParameter.mAtimW = FALSE; if (Adapter->dot11Mib.dot11PowerMangementMode && (~Adapter->MacParameter.mAtimRx) && Adapter->MacParameter.mTrsl == FALSE) { Adapter->MacParameter.mPss = doze; Doze(); } } FN_EXIT(0,0);}int MlmeScan( IN PWT_ADAPTER Adapter, MlmeScanRequest *PMlmeScanRequest) //int MlmeScan(BssType BssType,MacAddr BSSID,Essid SSID, ScanType ScanType,int ProbeDelay,Intstring ChannelList,int MinChannelTime,int MaxChannelTime){ char Str[34]; char FrameBody[100]; PWTWLAN_TXBUF PTxBuffer; FN_ENTER; PTxBuffer = (PWTWLAN_TXBUF)Adapter->MlmeParameter.PTxScanFrame; memset( PTxBuffer->TXHwBuf.pHwTxBuf, 0, (sizeof(WTWLAN_HWTXBUF))); if (PMlmeScanRequest->BssType > 3 || PMlmeScanRequest->BssType <0) return -1;//MlmeScan.confirm(empty,invalid) if (PMlmeScanRequest->ScanType != ACTIVE_SCAN && PMlmeScanRequest->ScanType != PASSIVE_SCAN) return -1; MacAddrCpy( Adapter->dot11Mib.dot11DesiredSSID, PMlmeScanRequest->BSSID ); printk("~~~~~~~~~=%d%d\n",PMlmeScanRequest->BSSID[0],PMlmeScanRequest->BSSID[1]); Adapter->dot11Mib.dot11DesiredBssType = PMlmeScanRequest->BssType; //SSID //? memcpy(FrameBody, mkElem(eSsId, Str, PMlmeScanRequest->SSID.ssid, PMlmeScanRequest->SSID.ssidLng), PMlmeScanRequest->SSID.ssidLng + 2); //Supported rates memcpy(FrameBody + PMlmeScanRequest->SSID.ssidLng + 2, mkElem(eSupRates, Str, Adapter->dot11Mib.dot11OperationalRateSet, 8), 10); //NxChnlParms值錕斤拷錕絊canProc錕斤拷錕? ////Adapter->MacParameter.mMlmeScanRequest.BssType = PMlmeScanRequest->BssType; ////Adapter->MacParameter.mMlmeScanRequest.ScanType = PMlmeScanRequest->ScanType; ////Adapter->MacParameter.mMlmeScanRequest.ProbeDelay = PMlmeScanRequest->ProbeDelay; ////Adapter->MacParameter.mMlmeScanRequest.ChannelList.cnLng= PMlmeScanRequest->ChannelList.cnLng; ////memcpy(Adapter->MacParameter.mMlmeScanRequest.ChannelList.cn, PMlmeScanRequest->ChannelList.cn, PMlmeScanRequest->ChannelList.cnLng); ////Adapter->MacParameter.mMlmeScanRequest.MaxChannelTime =(int)PMlmeScanRequest->MaxChannelTime; ////Adapter->MacParameter.mMlmeScanRequest.MinChannelTime = (int)PMlmeScanRequest->MinChannelTime; ////Adapter->MacParameter.mMlmeScanRequest.PTxScanFrame = PTxBuffer; if (PMlmeScanRequest->ScanType == ACTIVE_SCAN) mkFrame(PTxBuffer, WLAN_FSTYPE_PROBEREQ,Adapter->MacParameter.BcstAddr, Adapter->MacParameter.dot11MacAddress, PMlmeScanRequest->BSSID, FrameBody, 10 + PMlmeScanRequest->SSID.ssidLng);//12 + SSID.ssidLng?????????? // mkFrame(PTxBuffer, probe_req,Adapter->MacParameter.BcstAddr, Adapter->MacParameter.dot11MacAddress, PMlmeScanRequest->BSSID, FrameBody, 12 + PMlmeScanRequest->SSID.ssidLng);//12 + SSID.ssidLng?????????? //printk(LEVEL" Now we entered function %s and prepare to dump %08x !!!\n", __FUNCTION__, PTxBuffer); //Dump( (char *)PTxBuffer->TXHwBuf.pBuffer,300, TRUE, 1 ); NxChnl( Adapter, &Adapter->MlmeParameter.mScanReq); memset(&Adapter->Ap_conceal_ssid,0,sizeof(NDIS_802_11_SSID)); FN_EXIT(0,0); return 1;}//void TScanProc(IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)void TScanProc(IN PWT_ADAPTER Adapter){ FN_ENTER; //printk("<0>******In Function %s******\r\n",__FUNCTION__); if( Adapter->MlmeParameter.bScanOngoing ) NxChnl( Adapter, &Adapter->MlmeParameter.mScanReq) ; FN_EXIT(0,0); } //Scan錕斤拷錕揭伙拷錕?int NxChnl( IN PWT_ADAPTER Adapter, MlmeScanRequest *PMlmeScanRequest) //int NxChnl(BssType BssType, ScanType ScanType, int ProbeDelay,Intstring ChannelList, int64 MinChannelTime, int64 MaxChannelTime){ ULONG Timeout; // printk("<0>******In Function %s******\r\n",__FUNCTION__); FN_ENTER; Adapter->MlmeParameter.mScanChnlIndex++; if (Adapter->MlmeParameter.mScanChnlIndex > PMlmeScanRequest->ChannelList.cnLng) { #ifdef WIN_PLATFORM NdisCancelTimer(&Adapter->MacParameter.MacTimer.TScan, &TimerCanceled); #else del_timer(&(Adapter->MacParameter.MacTimer.ScanProcTimer)); #endif SwChnl( Adapter, Adapter->Ndis80211Parameter.CONFIGURATION.DSConfig); Adapter->MlmeParameter.bScanOngoing = FALSE; return 1; //MlmeScan.confirm(mbdset,success) } SwChnl( Adapter, PMlmeScanRequest->ChannelList.cn[Adapter->MlmeParameter.mScanChnlIndex - 1] ); if (PMlmeScanRequest->ScanType == PASSIVE_SCAN) { // printk("<0> now we are in step1 PASSIVE_SCAN\n"); #ifdef WIN_PLATFORM NdisSetTimer(&Adapter->MacParameter.MacTimer.TScan, (unsigned int)kUsec(now() + PMlmeScanRequest->MaxChannelTime)); #else //mod_timer(&(Adapter->MacParameter.MacTimer.ScanProcTimer), jiffies+(PMlmeScanRequest->MaxChannelTime/10000)*(HZ/100) ); Timeout = ((PMlmeScanRequest->MaxChannelTime/1000)*HZ)/1000; //mod_timer(&(Adapter->MacParameter.MacTimer.ScanProcTimer), jiffies+(PMlmeScanRequest->MaxChannelTime/10000)*(HZ/100) ); mod_timer(&(Adapter->MacParameter.MacTimer.ScanProcTimer), jiffies+Timeout ); #endif //Adapter->MacParameter.mProcState = PasListen; } else//ACTIVE_SCAN { // printk("<0>now we are in step2 PACTIVE_SCAN\n"); #ifdef WIN_PLATFORM NdisStallExecution(PMlmeScanRequest->ProbeDelay); NdisSetTimer(&Adapter->MacParameter.MacTimer.TScan, (unsigned int)(now() + PMlmeScanRequest->MinChannelTime)); #else udelay(PMlmeScanRequest->ProbeDelay); //mod_timer(&(Adapter->MacParameter.MacTimer.ScanProcTimer), jiffies+(PMlmeScanRequest->MinChannelTime/10000)*(HZ/100) ); Timeout = ((PMlmeScanRequest->MinChannelTime/1000)*HZ)/1000; //mod_timer(&(Adapter->MacParameter.MacTimer.ScanProcTimer), jiffies+(PMlmeScanRequest->MinChannelTime/10000)*(HZ/100) ); mod_timer(&(Adapter->MacParameter.MacTimer.ScanProcTimer), jiffies + Timeout ); #endif //printk("<0> scan delay = %d : %d\r\n",(PMlmeScanRequest->MinChannelTime/10000)*(HZ/100) ,(PMlmeScanRequest->MinChannelTime/1000000)*(HZ) ); //Adapter->MacParameter.mProcState = ActListen; MmRequest( Adapter, Adapter->MlmeParameter.PTxScanFrame); } FN_EXIT(0,0); return 1;} void ScanListen( IN PWT_ADAPTER Adapter, PWTWLAN_RXBUF pWlanRxBuf){ //FrameElement Ele; //int8 tmp_int8data; //int16 Sign, tmp_beaconinterval; UINT16 type; //UINT16 len; //UINT8 *buf; p80211_hdr_t *hdr; wlan_fr_proberesp_t *frmprobresp; wlan_fr_beacon_t *frmbeacon; ULONG i; int j = 0; FN_ENTER;//assump beacon type = pWlanRxBuf->ParseData.a.beacon.type; hdr = pWlanRxBuf->ParseData.a.beacon.hdr;// check newer or update
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -