8 extern const U16 dot11A_Channel
[];
9 extern u8 LastSetChannel
;
11 void zd_makeRateInfoMAP(U8
*pRates
, U16
*basicRateMap
, U16
*supRateMap
)
15 U8 eleLen
= *(pRates
+1);
17 for (j
=0; j
<eleLen
; j
++){
23 *basicRateMap
|= BIT_0
;
29 *basicRateMap
|= BIT_1
;
35 *basicRateMap
|= BIT_2
;
41 *basicRateMap
|= BIT_3
;
47 *basicRateMap
|= BIT_4
;
53 *basicRateMap
|= BIT_5
;
59 *basicRateMap
|= BIT_6
;
65 *basicRateMap
|= BIT_7
;
71 *basicRateMap
|= BIT_8
;
77 *basicRateMap
|= BIT_9
;
81 *supRateMap
|= BIT_10
;
83 *basicRateMap
|= BIT_10
;
87 *supRateMap
|= BIT_11
;
89 *basicRateMap
|= BIT_11
;
94 *supRateMap
|= BIT_12
;
96 *basicRateMap
|= BIT_12
;
100 *supRateMap
|= BIT_13
;
102 *basicRateMap
|= BIT_13
;
112 BOOLEAN
Probe(Signal_t
*signal
)
118 Element
*pWPA
= NULL
;
120 Element
*pExtRate
= NULL
;
125 pfrmDesc
= signal
->frmInfo
.frmDesc
;
126 rdu
= pfrmDesc
->mpdu
;
128 if (mBssType
== INFRASTRUCTURE_BSS
){
132 if (!getElem(rdu
, EID_SSID
, &rSsid
,1))
135 if (mHiddenSSID
){ //discard broadcast ssid
136 if (eLen(&rSsid
) == 0){
141 memcpy((U8
*)&sta
, (U8
*)addr2(rdu
), 6);
142 pExtRate
= &mExtRates
;
146 if (eLen(&rSsid
) == 0){
148 if (mDynKeyMode
== DYN_KEY_TKIP
|| mDynKeyMode
==DYN_KEY_AES
)
152 mkProbeRspFrm(pfrmDesc
, &sta
, mBeaconPeriod
, mCap
, &dot11DesiredSsid
, &mBrates
, &mPhpm
, pExtRate
, (Element
*)pWPA
, vapId
);
153 return sendMgtFrame(signal
, pfrmDesc
);
156 if (memcmp(&rSsid
, &dot11DesiredSsid
, eLen(&dot11DesiredSsid
)+2) == 0){
158 if ((mDynKeyMode
== DYN_KEY_TKIP
) || (mDynKeyMode
== DYN_KEY_AES
))
161 mkProbeRspFrm(pfrmDesc
, &sta
, mBeaconPeriod
, mCap
, &dot11DesiredSsid
, &mBrates
, &mPhpm
, pExtRate
, (Element
*)pWPA
, vapId
);
162 return sendMgtFrame(signal
, pfrmDesc
);
167 ZDEBUG("goto release");
172 BOOLEAN
ProbeReq(Signal_t
*signal
)
177 Element
*pSsid
= NULL
;
178 Element
*pExtRate
= NULL
;
181 //FPRINT("ProbeReq");
183 pfrmDesc
= allocFdesc();
185 sigEnque(pMgtQ
, (signal
));
189 BCSsid
.buf
[0] = EID_SSID
;
195 pSsid
= &dot11DesiredSsid
;
200 pExtRate
= &mExtRates
;
202 mkProbeReqFrm(pfrmDesc
, &dot11BCAddress
, pSsid
, &mBrates
, pExtRate
, NULL
, vapId
);
203 if (signal
->vapId
== 0)
204 pdot11Obj
->StartTimer(SCAN_TIMEOUT
, DO_SCAN
);
205 //mProbeWithSsid = FALSE;
206 return sendMgtFrame(signal
, pfrmDesc
);
209 BOOLEAN
ProbeRsp_Beacon(Signal_t
*signal
)
213 MacAddr_t
*pBssid
= NULL
;
214 //Element *pWPA = NULL;
219 BOOLEAN bUpdateInfo
= FALSE
;
222 #if ZDCONF_LP_SUPPORT == 1
225 #if ZDCONF_SES_SUPPORT == 1
226 U8 SES_OUI
[] = { 0x00, 0x90, 0x4C };
228 u8 WPA_OUI
[4]={0x00, 0x50, 0xF2, 0x01};
234 BssInfo_t
*pCurrBssInfo
;
236 ZDEBUG("ProbeRsp_Beacon");
237 pfrmDesc
= signal
->frmInfo
.frmDesc
;
238 rdu
= pfrmDesc
->mpdu
;
240 FrmType
= frmType(rdu
);
242 if (pdot11Obj
->ConfigFlag
& ACTIVE_CHANNEL_SCAN_SET
){
244 //FPRINT_V("Cap", Cap);
245 BcnInterval
= beaconInt(rdu
);
247 pAddr2ForIBSS
= (u8
*) addr2(rdu
);
255 //The following if-statements is used to filter existing AP Info.
257 //1. The bssid is seen before.
258 //2. The old Info.apMode equals to LastMacMode
259 //The meaning is if the incoming ap's bssid == old's bssid and
260 // ap's apMode(judged by LastMacMode) == old's apMode then Drop It.
261 for (i
=0; i
<mBssNum
; i
++){
262 if ((memcmp((U8
*)&mBssInfo
[i
].bssid
, (U8
*)pBssid
, 6) == 0) &&
263 ((PURE_A_AP
==mBssInfo
[i
].apMode
&& PURE_A_MODE
==LastMacMode
) ||
264 (PURE_A_AP
!=mBssInfo
[i
].apMode
&& PURE_A_MODE
!=LastMacMode
)
267 if (FrmType
== ST_BEACON
) {
277 pCurrBssInfo
= &mBssInfo
[index
];
278 pCurrBssInfo
->basicRateMap
= 0;
279 pCurrBssInfo
->supRateMap
= 0;
281 /* Reset supRates, extRates */
282 memset(&pCurrBssInfo
->supRates
, 0, NUM_SUPPORTED_RATE
);
283 memset(&pCurrBssInfo
->extRates
, 0, NUM_SUPPORTED_RATE
);
284 #if ZDCONF_LP_SUPPORT == 1
285 memset(&pCurrBssInfo
->zdIE_BURST
,0, sizeof(Element
));
286 memset(&pCurrBssInfo
->zdIE_AMSDU
,0, sizeof(Element
));
287 memset(&tmpElement
,0, sizeof(Element
));
289 #if ZDCONF_SES_SUPPORT == 1
290 memset(&pCurrBssInfo
->SES_Element
,0, sizeof(Element
));
291 pCurrBssInfo
->SES_Element_Valid
= FALSE
;
295 memcpy((U8
*)&pCurrBssInfo
->bssid
, (U8
*)pBssid
, 6);
297 //get beacon interval
298 pCurrBssInfo
->bcnInterval
= BcnInterval
;
301 pCurrBssInfo
->cap
= Cap
;
303 if (!getElem(rdu
, EID_SSID
, &pCurrBssInfo
->ssid
,1)){
307 if (!getElem(rdu
, EID_SUPRATES
, &pCurrBssInfo
->supRates
,1)){
311 if (!getElem(rdu
, EID_DSPARMS
, &pCurrBssInfo
->Phpm
,1)){
312 pCurrBssInfo
->Phpm
.buf
[0]=0x3;// DS Parameter Set
313 pCurrBssInfo
->Phpm
.buf
[1]=1;
314 if (!(Cap
& CAP_IBSS
)) // In IBSS use the ch carried in Beacon/Rsp
315 pCurrBssInfo
->Phpm
.buf
[2]=LastSetChannel
;
318 #if ZDCONF_LP_SUPPORT == 1
320 while(getElem(rdu
, EID_ZYDAS
, &tmpElement
,elemIdx
))
322 //If elemIdx++ doesn't execute, there would be endless loop.
323 if(loopCheck
++ > 100)
325 printk("infinite loop occurs in %s\n", __FUNCTION__
);
331 if(tmpElement
.buf
[2] == (U8
)ZDOUI_AMSDU
&&
332 tmpElement
.buf
[3] == (U8
)(ZDOUI_AMSDU
>> 8) &&
333 tmpElement
.buf
[4] == (U8
)(ZDOUI_AMSDU
>> 16) )
335 memcpy(&pCurrBssInfo
->zdIE_AMSDU
, &tmpElement
, sizeof(Element
));
337 else if(tmpElement
.buf
[2] == (U8
)ZDOUI_BURST
&&
338 tmpElement
.buf
[3] == (U8
)(ZDOUI_BURST
>> 8) &&
339 tmpElement
.buf
[4] == (U8
)(ZDOUI_BURST
>> 16) )
341 memcpy(&pCurrBssInfo
->zdIE_BURST
, &tmpElement
, sizeof(Element
));
345 #if ZDCONF_SES_SUPPORT
347 while(getElem(rdu
, EID_WPA
, &(pCurrBssInfo
->SES_Element
), elemIdx
))
349 //if elemIdx++ doesn't execute, endless loop occur
350 if(loopCheck
++ > 100)
352 printk("infinite loop occurs in %s\n", __FUNCTION__
);
357 if(pCurrBssInfo
->SES_Element
.buf
[1] >= 3)
359 if(memcmp(pCurrBssInfo
->SES_Element
.buf
+2, SES_OUI
, sizeof(SES_OUI
)) == 0)
361 pCurrBssInfo
->SES_Element_Valid
= TRUE
;
369 //This is used to filter non-allowed channel beacons
370 if (!((1 << (pCurrBssInfo
->Phpm
.buf
[2]-1)) & pdot11Obj
->AllowedChannel
)){
371 if(PURE_A_MODE
!= mMacMode
)
376 if (!getElem(rdu
, EID_IBPARMS
, &pCurrBssInfo
->IbssParms
,1)){
381 if (getElem(rdu
, EID_EXT_RATES
, &pCurrBssInfo
->extRates
,1)){
382 //zd1205_dump_data("Ext Rates", &pCurrBssInfo->extRates.buf[2], pCurrBssInfo->extRates.buf[1]);
385 if (getElem(rdu
, EID_ERP
, &pCurrBssInfo
->erp
,1)){
386 //zd1205_dump_data("ERP Info", &pCurrBssInfo->erp.buf[2], pCurrBssInfo->erp.buf[1]);
388 getElem(rdu
, EID_COUNTRY
, &pCurrBssInfo
->country
,1);
390 zd_makeRateInfoMAP((U8
*)&pCurrBssInfo
->supRates
, &pCurrBssInfo
->basicRateMap
, &pCurrBssInfo
->supRateMap
);
391 zd_makeRateInfoMAP((U8
*)&pCurrBssInfo
->extRates
, &pCurrBssInfo
->basicRateMap
, &pCurrBssInfo
->supRateMap
);
392 //FPRINT_V("basicRateMap", pCurrBssInfo->basicRateMap);
393 //FPRINT_V("supRateMap", pCurrBssInfo->supRateMap);
395 if (LastMacMode
!= PURE_A_MODE
&& pCurrBssInfo
->supRateMap
> 0x0f){ //support rates include OFDM rates
396 if (pCurrBssInfo
->basicRateMap
& ~0xf){ // basic rates include OFDM rates
397 pCurrBssInfo
->apMode
= PURE_G_AP
;
398 //FPRINT("PURE_G_AP");
401 pCurrBssInfo
->apMode
= MIXED_AP
;
402 //FPRINT("MIXED_AP");
405 else if(LastMacMode
== PURE_A_MODE
) {
406 pCurrBssInfo
->apMode
= PURE_A_AP
;
409 pCurrBssInfo
->apMode
= PURE_B_AP
;
410 //FPRINT("PURE_B_AP");
413 /* Get WPA IE Information */
414 //getElem(rdu, EID_WPA, (Element *)&pCurrBssInfo->WPAIe);
416 memset(&pCurrBssInfo
->WPAIe
,0x00, sizeof(pCurrBssInfo
->WPAIe
));
418 while(getElem(rdu
, EID_WPA
, (Element
*)&pCurrBssInfo
->WPAIe
,elemIdx
))
420 //if elemIdx++ doesn't execute, endless loop occur
421 if(loopCheck
++ > 100)
423 printk("infinite loop occurs in %s\n", __FUNCTION__
);
428 if((memcmp(pCurrBssInfo
->WPAIe
+2,WPA_OUI
, sizeof(WPA_OUI
)) != 0) ||
429 (pCurrBssInfo
->WPAIe
[1] < 20) )
431 memset(&pCurrBssInfo
->WPAIe
,0x00, sizeof(pCurrBssInfo
->WPAIe
));
439 memset(&pCurrBssInfo
->RSNIe
,0x00, sizeof(pCurrBssInfo
->RSNIe
));
440 getElem(rdu
, EID_RSN
, (Element
*)&pCurrBssInfo
->RSNIe
,1);
445 if(pCurrBssInfo
->WPAIe
[1] != 0) {
449 memcpy(SSID
, (u8
*)(&pCurrBssInfo
->ssid
.buf
[2]), pCurrBssInfo
->ssid
.buf
[1]);
450 SSID
[pCurrBssInfo
->ssid
.buf
[1]] = '\0';
452 printk(KERN_ERR
"WPA IE found in site survey, SSID: %s\n", SSID
);
454 for(ii
= 0; ii
< pCurrBssInfo
->WPAIe
[1]+2; ) {
455 printk(KERN_ERR
"0x%02x ", pCurrBssInfo
->WPAIe
[ii
]);
459 printk(KERN_ERR
"\n");
463 pCurrBssInfo
->signalStrength
= pfrmDesc
->signalStrength
;
464 pCurrBssInfo
->signalQuality
= pfrmDesc
->signalQuality
;
473 ZDEBUG("goto release");
479 BOOLEAN
SynchEntry(Signal_t
*signal
)
485 return Probe(signal
);
488 return ProbeReq(signal
);
490 case SIQ_PROBE_RSP_BEACON
:
491 return ProbeRsp_Beacon(signal
);
498 pfrmDesc
= signal
->frmInfo
.frmDesc
;