📄 wt_mac.c
字号:
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 ); 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 for( i = 0; i < Adapter->Ndis80211Parameter.pWlanScanDb->NumberOfItems; i++ ) { if( WtWlan_is_mac_address_equal( hdr->a3.a3, Adapter->Ndis80211Parameter.pWlanScanDb->wlandesc[i].ndisbssidex.MacAddress)) break;//bssid ==扫描到的bssid } if ( i == Adapter->Ndis80211Parameter.pWlanScanDb->NumberOfItems ) { if( Adapter->Ndis80211Parameter.pWlanScanDb->NumberOfItems < Adapter->NdisScanDbNUM ) { Adapter->Ndis80211Parameter.pWlanScanDb->NumberOfItems++; memset( &Adapter->Ndis80211Parameter.pWlanScanDb->wlandesc[i], 0, sizeof( WTWLAN_BSSID_DESC ) ); } else { i--; } }// common update WtWlan_copy_mac_address( Adapter->Ndis80211Parameter.pWlanScanDb->wlandesc[i].ndisbssidex.MacAddress, hdr->a3.a3); Adapter->Ndis80211Parameter.pWlanScanDb->wlandesc[i].ndisbssidex.Rssi = WtWlanGetRSSIFromPower( pWlanRxBuf->RXHwBuf.pHwRxBuf->RxStatus.RecvPower ); Adapter->Ndis80211Parameter.pWlanScanDb->wlandesc[i].ndisbssidex.NetworkTypeInUse = Ndis802_11DS; Adapter->Ndis80211Parameter.pWlanScanDb->wlandesc[i].ndisbssidex.Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION); Adapter->Ndis80211Parameter.pWlanScanDb->wlandesc[i].ndisbssidex.Configuration.FHConfig.Length= sizeof(NDIS_802_11_CONFIGURATION_FH); if( type == WLAN_BEACON ) { frmbeacon = &pWlanRxBuf->ParseData.a.beacon; //fixed if( frmbeacon->ts ) { //NdisMoveMemory(&Adapter->Ndis80211Parameter.pWlanScanDb->wlandesc[i].ie_fixed.Timestamp, frmbeacon->ts, 8); memmove(&Adapter->Ndis80211Parameter.pWlanScanDb->wlandesc[i].ie_fixed.Timestamp, frmbeacon->ts, 8); } if( frmbeacon->bcn_int )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -