Commit | Line | Data |
---|---|---|
4bd43f50 LR |
1 | /* |
2 | * Copyright (c) 2007-2008 Atheros Communications Inc. | |
3 | * | |
4 | * Permission to use, copy, modify, and/or distribute this software for any | |
5 | * purpose with or without fee is hereby granted, provided that the above | |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 | */ | |
16 | /* */ | |
17 | /* Module Name : iod.c */ | |
18 | /* */ | |
19 | /* Abstract */ | |
20 | /* This module contains OID functions. */ | |
21 | /* */ | |
22 | /* NOTES */ | |
23 | /* None */ | |
24 | /* */ | |
25 | /************************************************************************/ | |
26 | #include "cprecomp.h" | |
27 | #include "../hal/hpreg.h" | |
28 | ||
29 | /************************************************************************/ | |
30 | /* */ | |
31 | /* FUNCTION DESCRIPTION zfiWlanQueryMacAddress */ | |
32 | /* Query OWN MAC address. */ | |
33 | /* */ | |
34 | /* INPUTS */ | |
35 | /* addr : for return MAC address */ | |
36 | /* */ | |
37 | /* OUTPUTS */ | |
38 | /* None */ | |
39 | /* */ | |
40 | /* AUTHOR */ | |
41 | /* Stephen Chen ZyDAS Technology Corporation 2005.10 */ | |
42 | /* */ | |
43 | /************************************************************************/ | |
44 | void zfiWlanQueryMacAddress(zdev_t* dev, u8_t* addr) | |
45 | { | |
46 | u16_t vapId = 0; | |
47 | zmw_get_wlan_dev(dev); | |
48 | ||
49 | vapId = zfwGetVapId(dev); | |
50 | ||
51 | addr[0] = (u8_t)(wd->macAddr[0] & 0xff); | |
52 | addr[1] = (u8_t)(wd->macAddr[0] >> 8); | |
53 | addr[2] = (u8_t)(wd->macAddr[1] & 0xff); | |
54 | addr[3] = (u8_t)(wd->macAddr[1] >> 8); | |
55 | addr[4] = (u8_t)(wd->macAddr[2] & 0xff); | |
56 | if (vapId == 0xffff) | |
57 | addr[5] = (u8_t)(wd->macAddr[2] >> 8); | |
58 | else | |
59 | { | |
60 | #ifdef ZM_VAPMODE_MULTILE_SSID | |
61 | addr[5] = (u8_t)(wd->macAddr[2] >> 8); // Multiple SSID | |
62 | #else | |
63 | addr[5] = vapId + 1 + (u8_t)(wd->macAddr[2] >> 8); //VAP | |
64 | #endif | |
65 | } | |
66 | ||
67 | return; | |
68 | } | |
69 | ||
70 | void zfiWlanQueryBssList(zdev_t* dev, struct zsBssList* pBssList) | |
71 | { | |
72 | struct zsBssInfo* pBssInfo; | |
73 | struct zsBssInfo* pDstBssInfo; | |
74 | u8_t i; | |
75 | u8_t* pMemList; | |
76 | u8_t* pMemInfo; | |
77 | ||
78 | zmw_get_wlan_dev(dev); | |
79 | ||
80 | zmw_declare_for_critical_section(); | |
81 | ||
82 | pMemList = (u8_t*) pBssList; | |
83 | pMemInfo = pMemList + sizeof(struct zsBssList); | |
84 | pBssList->head = (struct zsBssInfo*) pMemInfo; | |
85 | ||
86 | zmw_enter_critical_section(dev); | |
87 | ||
88 | pBssInfo = wd->sta.bssList.head; | |
89 | pDstBssInfo = (struct zsBssInfo*) pMemInfo; | |
90 | pBssList->bssCount = wd->sta.bssList.bssCount; | |
91 | ||
92 | for( i=0; i<wd->sta.bssList.bssCount; i++ ) | |
93 | { | |
94 | zfMemoryCopy((u8_t*)pDstBssInfo, (u8_t*)pBssInfo, | |
95 | sizeof(struct zsBssInfo)); | |
96 | ||
97 | if ( pBssInfo->next != NULL ) | |
98 | { | |
99 | pBssInfo = pBssInfo->next; | |
100 | pDstBssInfo->next = pDstBssInfo + 1; | |
101 | pDstBssInfo++; | |
102 | } | |
103 | else | |
104 | { | |
105 | zm_assert(i==(wd->sta.bssList.bssCount-1)); | |
106 | } | |
107 | } | |
108 | ||
109 | zmw_leave_critical_section(dev); | |
110 | ||
111 | zfScanMgrScanAck(dev); | |
112 | } | |
113 | ||
114 | void zfiWlanQueryBssListV1(zdev_t* dev, struct zsBssListV1* bssListV1) | |
115 | { | |
116 | struct zsBssInfo* pBssInfo; | |
117 | //struct zsBssInfo* pDstBssInfo; | |
118 | u8_t i, j, bdrop = 0, k = 0, Same_Count = 0; | |
119 | u8_t bssid[6]; | |
120 | //u8_t* pMemList; | |
121 | //u8_t* pMemInfo; | |
122 | zmw_get_wlan_dev(dev); | |
123 | zmw_declare_for_critical_section(); | |
124 | ||
125 | zmw_enter_critical_section(dev); | |
126 | ||
127 | bssListV1->bssCount = wd->sta.bssList.bssCount; | |
128 | ||
129 | pBssInfo = wd->sta.bssList.head; | |
130 | ZM_MAC_WORD_TO_BYTE(wd->sta.bssid, bssid); | |
131 | ||
132 | for( i=0; i<wd->sta.bssList.bssCount; i++ ) | |
133 | { | |
134 | bdrop = 0; | |
135 | if ( zfStaIsConnected(dev) | |
136 | && (wd->wlanMode == ZM_MODE_INFRASTRUCTURE ) ) | |
137 | { | |
138 | for (j = 0; j < 6; j++) | |
139 | { | |
140 | if ( pBssInfo->bssid[j] != bssid[j] ) | |
141 | { | |
142 | break; | |
143 | } | |
144 | } | |
145 | ||
146 | if ( (j == 6) | |
147 | &&((pBssInfo->ssid[1] == wd->sta.ssidLen) || (pBssInfo->ssid[1] == 0) )&& (pBssInfo->frequency == wd->frequency) ) | |
148 | { | |
149 | if(pBssInfo->ssid[1] == 0) | |
150 | pBssInfo->ssid[1] = wd->sta.ssidLen; | |
151 | ||
152 | if(Same_Count == 0) | |
153 | {//First meet | |
154 | Same_Count++; | |
155 | } | |
156 | else | |
157 | {//same one | |
158 | bdrop = 1; | |
159 | bssListV1->bssCount--; | |
160 | } | |
161 | ||
162 | } | |
163 | } | |
164 | ||
165 | if (bdrop == 0) | |
166 | { | |
167 | zfMemoryCopy((u8_t*)(&bssListV1->bssInfo[k]), (u8_t*)pBssInfo, | |
168 | sizeof(struct zsBssInfo)); | |
169 | ||
170 | if(Same_Count == 1) | |
171 | { | |
172 | zfMemoryCopy(&(bssListV1->bssInfo[k].ssid[2]), wd->sta.ssid, wd->sta.ssidLen); | |
173 | Same_Count++; | |
174 | } | |
175 | ||
176 | k++; | |
177 | } | |
178 | ||
179 | if ( pBssInfo->next != NULL ) | |
180 | { | |
181 | pBssInfo = pBssInfo->next; | |
182 | } | |
183 | else | |
184 | { | |
185 | zm_assert(i==(wd->sta.bssList.bssCount-1)); | |
186 | } | |
187 | } | |
188 | ||
189 | zmw_leave_critical_section(dev); | |
190 | ||
191 | zfScanMgrScanAck(dev); | |
192 | } | |
193 | ||
194 | void zfiWlanQueryAdHocCreatedBssDesc(zdev_t* dev, struct zsBssInfo *pBssInfo) | |
195 | { | |
196 | zmw_get_wlan_dev(dev); | |
197 | ||
198 | zfMemoryCopy((u8_t *)pBssInfo, (u8_t *)&wd->sta.ibssBssDesc, sizeof(struct zsBssInfo)); | |
199 | } | |
200 | ||
201 | u8_t zfiWlanQueryAdHocIsCreator(zdev_t* dev) | |
202 | { | |
203 | zmw_get_wlan_dev(dev); | |
204 | ||
205 | return wd->sta.ibssBssIsCreator; | |
206 | } | |
207 | ||
208 | u32_t zfiWlanQuerySupportMode(zdev_t* dev) | |
209 | { | |
210 | zmw_get_wlan_dev(dev); | |
211 | ||
212 | return wd->supportMode; | |
213 | } | |
214 | ||
215 | u32_t zfiWlanQueryTransmitPower(zdev_t* dev) | |
216 | { | |
4bd43f50 LR |
217 | u32_t ret = 0; |
218 | ||
0009e125 RD |
219 | zmw_get_wlan_dev(dev); |
220 | ||
4bd43f50 LR |
221 | if (zfStaIsConnected(dev)) { |
222 | ret = wd->sta.connPowerInHalfDbm; | |
223 | } else { | |
224 | ret = zfHpGetTransmitPower(dev); | |
225 | } | |
226 | ||
227 | return ret; | |
228 | } | |
229 | ||
230 | /************************************************************************/ | |
231 | /* */ | |
232 | /* FUNCTION DESCRIPTION zfiWlanFlushBssList */ | |
233 | /* Flush BSSID List. */ | |
234 | /* */ | |
235 | /* INPUTS */ | |
236 | /* dev : device pointer */ | |
237 | /* */ | |
238 | /* OUTPUTS */ | |
239 | /* none */ | |
240 | /* */ | |
241 | /* AUTHOR */ | |
242 | /* Stephen Chen Atheros Communications, INC. 2006.12 */ | |
243 | /* */ | |
244 | /************************************************************************/ | |
245 | void zfiWlanFlushBssList(zdev_t* dev) | |
246 | { | |
247 | zmw_declare_for_critical_section(); | |
248 | ||
249 | zmw_enter_critical_section(dev); | |
250 | /* Call zfBssInfoRefresh() twice to remove all entry */ | |
251 | zfBssInfoRefresh(dev, 1); | |
252 | zmw_leave_critical_section(dev); | |
253 | } | |
254 | ||
255 | void zfiWlanSetWlanMode(zdev_t* dev, u8_t wlanMode) | |
256 | { | |
257 | zmw_get_wlan_dev(dev); | |
258 | ||
259 | zmw_declare_for_critical_section(); | |
260 | ||
261 | zmw_enter_critical_section(dev); | |
262 | wd->ws.wlanMode = wlanMode; | |
263 | zmw_leave_critical_section(dev); | |
264 | } | |
265 | ||
266 | void zfiWlanSetAuthenticationMode(zdev_t* dev, u8_t authMode) | |
267 | { | |
268 | zmw_get_wlan_dev(dev); | |
269 | ||
270 | zmw_declare_for_critical_section(); | |
271 | ||
272 | zmw_enter_critical_section(dev); | |
273 | wd->ws.authMode = authMode; | |
274 | zmw_leave_critical_section(dev); | |
275 | } | |
276 | ||
277 | void zfiWlanSetWepStatus(zdev_t* dev, u8_t wepStatus) | |
278 | { | |
279 | zmw_get_wlan_dev(dev); | |
280 | ||
281 | zmw_declare_for_critical_section(); | |
282 | ||
283 | zmw_enter_critical_section(dev); | |
284 | wd->ws.wepStatus = wepStatus; | |
285 | zmw_leave_critical_section(dev); | |
286 | ||
287 | } | |
288 | ||
289 | void zfiWlanSetSSID(zdev_t* dev, u8_t* ssid, u8_t ssidLength) | |
290 | { | |
291 | u16_t i; | |
292 | zmw_get_wlan_dev(dev); | |
293 | ||
294 | zmw_declare_for_critical_section(); | |
295 | ||
296 | if ( ssidLength <= 32 ) | |
297 | { | |
298 | zmw_enter_critical_section(dev); | |
299 | ||
300 | wd->ws.ssidLen = ssidLength; | |
301 | zfMemoryCopy(wd->ws.ssid, ssid, ssidLength); | |
302 | ||
303 | if ( ssidLength < 32 ) | |
304 | { | |
305 | wd->ws.ssid[ssidLength] = 0; | |
306 | } | |
307 | ||
308 | wd->ws.probingSsidList[0].ssidLen = ssidLength; | |
309 | zfMemoryCopy(wd->ws.probingSsidList[0].ssid, ssid, ssidLength); | |
310 | for (i=1; i<ZM_MAX_PROBE_HIDDEN_SSID_SIZE; i++) | |
311 | { | |
312 | wd->ws.probingSsidList[i].ssidLen = 0; | |
313 | } | |
314 | ||
315 | zmw_leave_critical_section(dev); | |
316 | } | |
317 | } | |
318 | ||
319 | void zfiWlanSetFragThreshold(zdev_t* dev, u16_t fragThreshold) | |
320 | { | |
321 | zmw_get_wlan_dev(dev); | |
322 | ||
323 | zmw_declare_for_critical_section(); | |
324 | ||
325 | zmw_enter_critical_section(dev); | |
326 | ||
327 | if (fragThreshold == 0) | |
328 | { /* fragmentation is disabled */ | |
329 | wd->fragThreshold = 32767; | |
330 | } | |
331 | else if (fragThreshold < 256) | |
332 | { | |
333 | /* Minimum fragment threshold */ | |
334 | wd->fragThreshold = 256; | |
335 | } | |
336 | else if (fragThreshold > 2346) | |
337 | { | |
338 | wd->fragThreshold = 2346; | |
339 | } | |
340 | else | |
341 | { | |
342 | wd->fragThreshold = fragThreshold & 0xfffe; | |
343 | } | |
344 | ||
345 | zmw_leave_critical_section(dev); | |
346 | } | |
347 | ||
348 | void zfiWlanSetRtsThreshold(zdev_t* dev, u16_t rtsThreshold) | |
349 | { | |
350 | zmw_get_wlan_dev(dev); | |
351 | ||
352 | zmw_declare_for_critical_section(); | |
353 | ||
354 | zmw_enter_critical_section(dev); | |
355 | wd->rtsThreshold = rtsThreshold; | |
356 | zmw_leave_critical_section(dev); | |
357 | } | |
358 | ||
359 | void zfiWlanSetFrequency(zdev_t* dev, u32_t frequency, u8_t bImmediate) | |
360 | { | |
361 | zmw_get_wlan_dev(dev); | |
362 | ||
363 | zmw_declare_for_critical_section(); | |
364 | ||
365 | if ( bImmediate ) | |
366 | { | |
367 | zmw_enter_critical_section(dev); | |
368 | wd->frequency = (u16_t) (frequency/1000); | |
369 | zmw_leave_critical_section(dev); | |
370 | zfCoreSetFrequency(dev, wd->frequency); | |
371 | } | |
372 | else | |
373 | { | |
374 | zmw_enter_critical_section(dev); | |
375 | if( frequency == 0 ) | |
376 | { // Auto select clean channel depend on wireless environment ! | |
377 | wd->ws.autoSetFrequency = 0; | |
378 | } | |
379 | wd->ws.frequency = (u16_t) (frequency/1000); | |
380 | zmw_leave_critical_section(dev); | |
381 | } | |
382 | } | |
383 | ||
384 | void zfiWlanSetBssid(zdev_t* dev, u8_t* bssid) | |
385 | { | |
386 | u16_t i; | |
387 | zmw_get_wlan_dev(dev); | |
388 | ||
389 | zmw_declare_for_critical_section(); | |
390 | ||
391 | zmw_enter_critical_section(dev); | |
392 | for (i=0; i<6; i++) | |
393 | { | |
394 | wd->ws.desiredBssid[i] = bssid[i]; | |
395 | } | |
396 | wd->ws.bDesiredBssid = TRUE; | |
397 | zmw_leave_critical_section(dev); | |
398 | ||
399 | } | |
400 | ||
401 | void zfiWlanSetBeaconInterval(zdev_t* dev, | |
402 | u16_t beaconInterval, | |
403 | u8_t bImmediate) | |
404 | { | |
405 | zmw_get_wlan_dev(dev); | |
406 | ||
407 | zmw_declare_for_critical_section(); | |
408 | ||
409 | if ( bImmediate ) | |
410 | { | |
411 | zmw_enter_critical_section(dev); | |
412 | wd->beaconInterval = beaconInterval; | |
413 | zmw_leave_critical_section(dev); | |
414 | ||
415 | /* update beacon interval here */ | |
416 | } | |
417 | else | |
418 | { | |
419 | zmw_enter_critical_section(dev); | |
420 | wd->ws.beaconInterval = beaconInterval; | |
421 | zmw_leave_critical_section(dev); | |
422 | } | |
423 | } | |
424 | ||
425 | ||
426 | void zfiWlanSetDtimCount(zdev_t* dev, u8_t dtim) | |
427 | { | |
428 | zmw_get_wlan_dev(dev); | |
429 | ||
430 | zmw_declare_for_critical_section(); | |
431 | ||
432 | zmw_enter_critical_section(dev); | |
433 | if (dtim > 0) | |
434 | { | |
435 | wd->ws.dtim = dtim; | |
436 | } | |
437 | zmw_leave_critical_section(dev); | |
438 | } | |
439 | ||
440 | ||
441 | void zfiWlanSetAtimWindow(zdev_t* dev, u16_t atimWindow, u8_t bImmediate) | |
442 | { | |
443 | zmw_get_wlan_dev(dev); | |
444 | ||
445 | zmw_declare_for_critical_section(); | |
446 | ||
447 | if ( bImmediate ) | |
448 | { | |
449 | zmw_enter_critical_section(dev); | |
450 | wd->sta.atimWindow = atimWindow; | |
451 | zmw_leave_critical_section(dev); | |
452 | ||
453 | /* atim window here */ | |
454 | } | |
455 | else | |
456 | { | |
457 | zmw_enter_critical_section(dev); | |
458 | wd->ws.atimWindow = atimWindow; | |
459 | zmw_leave_critical_section(dev); | |
460 | } | |
461 | } | |
462 | ||
463 | ||
464 | void zfiWlanSetEncryMode(zdev_t* dev, u8_t encryMode) | |
465 | { | |
466 | zmw_get_wlan_dev(dev); | |
467 | ||
468 | zmw_declare_for_critical_section(); | |
469 | ||
470 | zmw_enter_critical_section(dev); | |
471 | if (wd->wlanMode == ZM_MODE_AP) | |
472 | { | |
473 | /* Hostapd Issue */ | |
474 | if ((wd->ws.encryMode != ZM_AES) && (wd->ws.encryMode != ZM_TKIP)) | |
475 | wd->ws.encryMode = encryMode; | |
476 | } | |
477 | else | |
478 | wd->ws.encryMode = encryMode; | |
479 | zmw_leave_critical_section(dev); | |
480 | } | |
481 | ||
482 | void zfiWlanSetDefaultKeyId(zdev_t* dev, u8_t keyId) | |
483 | { | |
484 | zmw_get_wlan_dev(dev); | |
485 | ||
486 | wd->sta.keyId = keyId; | |
487 | } | |
488 | ||
489 | u8_t zfiWlanQueryIsPKInstalled(zdev_t *dev, u8_t *staMacAddr) | |
490 | { | |
491 | u8_t isInstalled = 0; | |
492 | ||
493 | #if 1 | |
494 | //#ifdef ZM_ENABLE_IBSS_WPA2PSK | |
495 | u8_t res, peerIdx; | |
496 | ||
497 | zmw_get_wlan_dev(dev); | |
498 | ||
499 | zmw_declare_for_critical_section(); | |
500 | ||
501 | zmw_enter_critical_section(dev); | |
502 | res = zfStaFindOppositeByMACAddr(dev, (u16_t *)staMacAddr, &peerIdx); | |
503 | if( res == 0 ) | |
504 | { | |
505 | isInstalled = wd->sta.oppositeInfo[peerIdx].pkInstalled; | |
506 | } | |
507 | zmw_leave_critical_section(dev); | |
508 | //#endif | |
509 | #endif | |
510 | ||
511 | return isInstalled; | |
512 | } | |
513 | ||
514 | u8_t zfiWlanSetKey(zdev_t* dev, struct zsKeyInfo keyInfo) | |
515 | { | |
516 | u16_t broadcast[3] = {0xffff, 0xffff, 0xffff}; | |
517 | u32_t* key; | |
518 | u8_t encryMode = ZM_NO_WEP; | |
519 | #ifdef ZM_ENABLE_IBSS_WPA2PSK | |
520 | u8_t encryType = ZM_NO_WEP; | |
521 | #endif | |
522 | u8_t micKey[16]; | |
523 | u16_t id = 0; | |
524 | u8_t vapId, i, addr[6]; | |
525 | u8_t userIdx=0; | |
526 | ||
527 | #ifdef ZM_ENABLE_IBSS_WPA2PSK | |
528 | /* Determine opposite exist or not */ | |
529 | u8_t res, peerIdx; | |
530 | // u8_t userIdx=0; | |
531 | ||
532 | zmw_get_wlan_dev(dev); | |
533 | ||
534 | if ( wd->sta.ibssWpa2Psk == 1 ) | |
535 | { | |
536 | zmw_enter_critical_section(dev); | |
537 | res = zfStaFindOppositeByMACAddr(dev, (u16_t*)keyInfo.macAddr, &peerIdx); | |
538 | if( res == 0 ) | |
539 | { | |
540 | userIdx = peerIdx; | |
541 | if ( wd->sta.oppositeInfo[userIdx].camIdx == 0xff ) | |
542 | wd->sta.oppositeInfo[userIdx].camIdx = userIdx; | |
543 | } | |
544 | zmw_leave_critical_section(dev); | |
545 | } | |
546 | #else | |
547 | zmw_get_wlan_dev(dev); | |
548 | #endif | |
549 | ||
550 | if ( keyInfo.flag & ZM_KEY_FLAG_AUTHENTICATOR ) | |
551 | { /* set key by authenticator */ | |
552 | /* set pairwise key */ | |
553 | if (keyInfo.flag & ZM_KEY_FLAG_PK) | |
554 | { | |
555 | /* Find STA's information */ | |
92363b52 JP |
556 | id = zfApFindSta(dev, keyInfo.macAddr); |
557 | if (id == 0xffff) | |
4bd43f50 LR |
558 | { |
559 | /* Can't STA in the staTable */ | |
560 | return ZM_STATUS_FAILURE; | |
561 | } | |
562 | ||
563 | wd->ap.staTable[id].iv16 = 0; | |
564 | wd->ap.staTable[id].iv32 = 0; | |
565 | ||
566 | if (keyInfo.keyLength == 32) | |
567 | { /* TKIP */ | |
568 | //u8_t KeyRsc[6] = {0, 0, 0, 0, 0, 0}; | |
569 | ||
570 | /* In the current AP mode, we set KeyRsc to zero */ | |
571 | //zfTkipInit(keyInfo.key, (u8_t*) wd->macAddr, | |
572 | // &(wd->ap.staTable[id].txSeed), KeyRsc); | |
573 | //zfTkipInit(keyInfo.key, (u8_t*) keyInfo.macAddr, | |
574 | // &(wd->ap.staTable[id].rxSeed), KeyRsc); | |
575 | #ifdef ZM_ENABLE_CENC | |
576 | if (keyInfo.flag & ZM_KEY_FLAG_CENC) | |
577 | { | |
578 | zm_debug_msg0("Set CENC pairwise Key"); | |
579 | ||
580 | wd->ap.staTable[id].encryMode = ZM_CENC; | |
581 | ||
582 | /* Reset txiv and rxiv */ | |
583 | wd->ap.staTable[id].txiv[0] = 0x5c365c37; | |
584 | wd->ap.staTable[id].txiv[1] = 0x5c365c36; | |
585 | wd->ap.staTable[id].txiv[2] = 0x5c365c36; | |
586 | wd->ap.staTable[id].txiv[3] = 0x5c365c36; | |
587 | ||
588 | wd->ap.staTable[id].rxiv[0] = 0x5c365c36; | |
589 | wd->ap.staTable[id].rxiv[1] = 0x5c365c36; | |
590 | wd->ap.staTable[id].rxiv[2] = 0x5c365c36; | |
591 | wd->ap.staTable[id].rxiv[3] = 0x5c365c36; | |
592 | ||
593 | /* Set Key Index */ | |
594 | wd->ap.staTable[id].cencKeyIdx = keyInfo.keyIndex; | |
595 | ||
596 | //zfCoreSetKey(dev, id+1, 1, ZM_CENC, (u16_t *)keyInfo.macAddr, | |
597 | // (u32_t*) &keyInfo.key[16]); | |
598 | } | |
599 | else | |
600 | #endif //ZM_ENABLE_CENC | |
601 | { | |
602 | wd->ap.staTable[id].encryMode = ZM_TKIP; | |
603 | ||
604 | zfMemoryCopy(micKey, &keyInfo.key[16], 8); | |
605 | zfMemoryCopy(&micKey[8], &keyInfo.key[24], 8); | |
606 | ||
607 | //zfCoreSetKey(dev, id+1, 1, ZM_TKIP, (u16_t *)keyInfo.macAddr, | |
608 | // (u32_t*) micKey); | |
609 | ||
610 | /* For fragmentation, we use software MIC */ | |
611 | zfMemoryCopy((u8_t *)&(wd->ap.staTable[id].txMicKey), &(keyInfo.key[16]), 8); | |
612 | zfMemoryCopy((u8_t *)&(wd->ap.staTable[id].rxMicKey), &(keyInfo.key[24]), 8); | |
613 | ||
614 | } | |
615 | } | |
616 | else if (keyInfo.keyLength == 16) | |
617 | { /* AES */ | |
618 | wd->ap.staTable[id].encryMode = ZM_AES; | |
619 | } | |
620 | else if (keyInfo.keyLength == 0) | |
621 | { | |
622 | /* Clear Key Info */ | |
623 | zfApClearStaKey(dev, (u16_t *)keyInfo.macAddr); | |
624 | ||
625 | return ZM_STATUS_SUCCESS; | |
626 | } | |
627 | else | |
628 | { | |
629 | return ZM_STATUS_FAILURE; | |
630 | } | |
631 | ||
632 | //zfCoreSetKey(dev, id+1, 0, wd->ap.staTable[id].encryMode, | |
633 | // (u16_t *)keyInfo.macAddr, (u32_t*) keyInfo.key); | |
634 | zfHpSetApPairwiseKey(dev, (u16_t *)keyInfo.macAddr, | |
635 | wd->ap.staTable[id].encryMode, (u32_t*) keyInfo.key, | |
636 | (u32_t*) &keyInfo.key[16], id+1); | |
637 | wd->ap.staTable[id].keyIdx = id + 1 + 4; | |
638 | } | |
639 | else if (keyInfo.flag & ZM_KEY_FLAG_GK) | |
640 | { | |
641 | vapId = keyInfo.vapId; | |
642 | ||
643 | wd->ap.iv16[vapId] = 0; | |
644 | wd->ap.iv32[vapId] = 0; | |
645 | ||
646 | if (keyInfo.keyLength == 32) | |
647 | { /* TKIP */ | |
648 | //u8_t KeyRsc[6] = {0, 0, 0, 0, 0, 0}; | |
649 | ||
650 | //zfTkipInit(keyInfo.key, (u8_t*) wd->macAddr, | |
651 | // &(wd->ap.bcSeed), KeyRsc); | |
652 | #ifdef ZM_ENABLE_CENC | |
653 | if (keyInfo.flag & ZM_KEY_FLAG_CENC) | |
654 | { | |
655 | encryMode = ZM_CENC; | |
656 | zm_debug_msg0("Set CENC group Key"); | |
657 | ||
658 | /* Reset txiv and rxiv */ | |
659 | wd->ap.txiv[vapId][0] = 0x5c365c36; | |
660 | wd->ap.txiv[vapId][1] = 0x5c365c36; | |
661 | wd->ap.txiv[vapId][2] = 0x5c365c36; | |
662 | wd->ap.txiv[vapId][3] = 0x5c365c36; | |
663 | ||
664 | //zfCoreSetKey(dev, 0, 1, ZM_CENC, keyInfo.vapAddr, | |
665 | // (u32_t*) &keyInfo.key[16]); | |
666 | key = (u32_t*) keyInfo.key; | |
667 | } | |
668 | else | |
669 | #endif //ZM_ENABLE_CENC | |
670 | { | |
671 | encryMode = ZM_TKIP; | |
672 | key = (u32_t *)keyInfo.key; | |
673 | ||
674 | /* set MIC key to HMAC */ | |
675 | //zfCoreSetKey(dev, 0, 1, ZM_TKIP, broadcast, | |
676 | // (u32_t*) (&keyInfo.key[16])); | |
677 | //zfCoreSetKey(dev, 0, 1, ZM_TKIP, keyInfo.vapAddr, | |
678 | // (u32_t*) (&keyInfo.key[16])); | |
679 | ||
680 | zfMicSetKey(&(keyInfo.key[16]), &(wd->ap.bcMicKey[0])); | |
681 | key = (u32_t*) keyInfo.key; | |
682 | } | |
683 | } | |
684 | else if (keyInfo.keyLength == 16) | |
685 | { /* AES */ | |
686 | encryMode = ZM_AES; | |
687 | key = (u32_t *)keyInfo.key; | |
688 | zm_debug_msg0("CWY - Set AES Group Key"); | |
689 | } | |
690 | else if (keyInfo.keyLength == 0) | |
691 | { | |
692 | /* Clear Key Info */ | |
693 | zfApClearStaKey(dev, broadcast); | |
694 | ||
695 | /* Turn off WEP bit in the capability field */ | |
696 | wd->ap.capab[vapId] &= 0xffef; | |
697 | ||
698 | return ZM_STATUS_SUCCESS; | |
699 | } | |
700 | else | |
701 | { /* WEP */ | |
702 | if (keyInfo.keyLength == 5) | |
703 | { | |
704 | encryMode = ZM_WEP64; | |
705 | } | |
706 | else if (keyInfo.keyLength == 13) | |
707 | { | |
708 | encryMode = ZM_WEP128; | |
709 | } | |
710 | else if (keyInfo.keyLength == 29) | |
711 | { | |
712 | encryMode = ZM_WEP256; | |
713 | } | |
714 | ||
715 | key = (u32_t*) keyInfo.key; | |
716 | } | |
717 | ||
718 | // Modification for CAM not support VAP search | |
719 | //zfCoreSetKey(dev, 0, 0, encryMode, broadcast, key); | |
720 | //zfCoreSetKey(dev, 0, 0, encryMode, wd->macAddr, key); | |
721 | //zfCoreSetKey(dev, 0, 0, encryMode, keyInfo.vapAddr, key); | |
722 | zfHpSetApGroupKey(dev, wd->macAddr, encryMode, | |
723 | key, (u32_t*) &keyInfo.key[16], vapId); | |
724 | ||
725 | //zfiWlanSetEncryMode(dev, encryMode); | |
726 | wd->ws.encryMode = encryMode; | |
727 | ||
728 | /* set the multicast address encryption type */ | |
729 | wd->ap.encryMode[vapId] = encryMode; | |
730 | ||
731 | /* set the multicast key index */ | |
732 | wd->ap.bcKeyIndex[vapId] = keyInfo.keyIndex; | |
733 | wd->ap.bcHalKeyIdx[vapId] = vapId + 60; | |
734 | ||
735 | /* Turn on WEP bit in the capability field */ | |
736 | wd->ap.capab[vapId] |= 0x10; | |
737 | } | |
738 | } | |
739 | else | |
740 | { /* set by supplicant */ | |
741 | ||
742 | if ( keyInfo.flag & ZM_KEY_FLAG_PK ) | |
743 | { /* set pairwise key */ | |
744 | ||
745 | //zfTkipInit(keyInfo.key, (u8_t*) wd->macAddr, | |
746 | // &wd->sta.txSeed, keyInfo.initIv); | |
747 | //zfTkipInit(keyInfo.key, (u8_t*) wd->sta.bssid, | |
748 | // &wd->sta.rxSeed[keyInfo.keyIndex], keyInfo.initIv); | |
749 | ||
750 | #ifdef ZM_ENABLE_IBSS_WPA2PSK | |
751 | if ( wd->sta.ibssWpa2Psk == 1 ) | |
752 | { | |
753 | /* unicast -- > pairwise key */ | |
754 | wd->sta.oppositeInfo[userIdx].iv16 = 0; | |
755 | wd->sta.oppositeInfo[userIdx].iv32 = 0; | |
756 | } | |
757 | else | |
758 | { | |
759 | wd->sta.iv16 = 0; | |
760 | wd->sta.iv32 = 0; | |
761 | } | |
762 | ||
763 | wd->sta.oppositeInfo[userIdx].pkInstalled = 1; | |
764 | #else | |
765 | wd->sta.iv16 = 0; | |
766 | wd->sta.iv32 = 0; | |
767 | ||
768 | wd->sta.oppositeInfo[userIdx].pkInstalled = 1; | |
769 | #endif | |
770 | ||
771 | if ( keyInfo.keyLength == 32 ) | |
772 | { /* TKIP */ | |
773 | zfTkipInit(keyInfo.key, (u8_t*) wd->macAddr, | |
774 | &wd->sta.txSeed, keyInfo.initIv); | |
775 | zfTkipInit(keyInfo.key, (u8_t*) wd->sta.bssid, | |
776 | &wd->sta.rxSeed[keyInfo.keyIndex], keyInfo.initIv); | |
777 | ||
778 | #ifdef ZM_ENABLE_CENC | |
779 | if (keyInfo.flag & ZM_KEY_FLAG_CENC) | |
780 | { | |
781 | zm_debug_msg0("Set CENC pairwise Key"); | |
782 | ||
783 | wd->sta.encryMode = ZM_CENC; | |
784 | ||
785 | /* Reset txiv and rxiv */ | |
786 | wd->sta.txiv[0] = 0x5c365c36; | |
787 | wd->sta.txiv[1] = 0x5c365c36; | |
788 | wd->sta.txiv[2] = 0x5c365c36; | |
789 | wd->sta.txiv[3] = 0x5c365c36; | |
790 | ||
791 | wd->sta.rxiv[0] = 0x5c365c37; | |
792 | wd->sta.rxiv[1] = 0x5c365c36; | |
793 | wd->sta.rxiv[2] = 0x5c365c36; | |
794 | wd->sta.rxiv[3] = 0x5c365c36; | |
795 | ||
796 | /* Set Key Index */ | |
797 | wd->sta.cencKeyId = keyInfo.keyIndex; | |
798 | ||
799 | //zfCoreSetKey(dev, id+1, 1, ZM_CENC, (u16_t *)keyInfo.macAddr, | |
800 | // (u32_t*) &keyInfo.key[16]); | |
801 | } | |
802 | else | |
803 | #endif //ZM_ENABLE_CENC | |
804 | { | |
805 | wd->sta.encryMode = ZM_TKIP; | |
806 | ||
807 | //zfCoreSetKey(dev, 0, 1, ZM_TKIP, wd->sta.bssid, | |
808 | // (u32_t*) &keyInfo.key[16]); | |
809 | ||
810 | zfMicSetKey(&keyInfo.key[16], &wd->sta.txMicKey); | |
811 | zfMicSetKey(&keyInfo.key[24], | |
812 | &wd->sta.rxMicKey[keyInfo.keyIndex]); | |
813 | } | |
814 | } | |
815 | else if ( keyInfo.keyLength == 16 ) | |
816 | { /* AES */ | |
817 | #ifdef ZM_ENABLE_IBSS_WPA2PSK | |
818 | if ( wd->sta.ibssWpa2Psk == 1 ) | |
819 | { | |
820 | wd->sta.oppositeInfo[userIdx].encryMode = ZM_AES; | |
821 | encryType = wd->sta.oppositeInfo[userIdx].encryMode; | |
822 | } | |
823 | else | |
824 | { | |
825 | wd->sta.encryMode = ZM_AES; | |
826 | encryType = wd->sta.encryMode; | |
827 | } | |
828 | #else | |
829 | wd->sta.encryMode = ZM_AES; | |
830 | #endif | |
831 | } | |
832 | else | |
833 | { | |
834 | return ZM_STATUS_FAILURE; | |
835 | } | |
836 | ||
837 | /* user 0 */ | |
838 | //zfCoreSetKey(dev, 0, 0, wd->sta.encryMode, | |
839 | // wd->sta.bssid, (u32_t*) keyInfo.key); | |
840 | //zfHpSetStaPairwiseKey(dev, wd->sta.bssid, wd->sta.encryMode, | |
841 | // (u32_t*) keyInfo.key, (u32_t*) &keyInfo.key[16]); | |
842 | ||
843 | #ifdef ZM_ENABLE_IBSS_WPA2PSK | |
844 | if ( (keyInfo.keyLength==16) && (wd->sta.ibssWpa2Psk==1) ) | |
845 | { /* If not AES-CCMP and ibss network , use traditional */ | |
846 | zfHpSetPerUserKey(dev, | |
847 | userIdx, | |
848 | keyInfo.keyIndex, // key id == 0 ( Pairwise key = 0 ) | |
849 | (u8_t*)keyInfo.macAddr, // RX need Source Address ( Address 2 ) | |
850 | encryType, | |
851 | // wd->sta.encryMode, | |
852 | (u32_t*) keyInfo.key, (u32_t*) &keyInfo.key[16]); | |
853 | ||
854 | wd->sta.oppositeInfo[userIdx].wpaState = ZM_STA_WPA_STATE_PK_OK ; | |
855 | } | |
856 | else | |
857 | {/* Big Endian and Little Endian Compatibility */ | |
858 | for (i = 0; i < 3; i++) | |
859 | { | |
860 | addr[2 * i] = wd->sta.bssid[i] & 0xff; | |
861 | addr[2 * i + 1] = wd->sta.bssid[i] >> 8; | |
862 | } | |
863 | zfHpSetPerUserKey(dev, | |
864 | ZM_USER_KEY_PK, // user id | |
865 | 0, // key id | |
866 | addr,//(u8_t *)wd->sta.bssid, | |
867 | wd->sta.encryMode, | |
868 | (u32_t*) keyInfo.key, (u32_t*) &keyInfo.key[16]); | |
869 | ||
870 | wd->sta.keyId = 4; | |
871 | } | |
872 | #else | |
873 | /* Big Endian and Little Endian Compatibility */ | |
874 | for (i = 0; i < 3; i++) | |
875 | { | |
876 | addr[2 * i] = wd->sta.bssid[i] & 0xff; | |
877 | addr[2 * i + 1] = wd->sta.bssid[i] >> 8; | |
878 | } | |
879 | zfHpSetPerUserKey(dev, | |
880 | ZM_USER_KEY_PK, // user id | |
881 | 0, // key id | |
882 | addr,//(u8_t *)wd->sta.bssid, | |
883 | wd->sta.encryMode, | |
884 | (u32_t*) keyInfo.key, (u32_t*) &keyInfo.key[16]); | |
885 | ||
886 | wd->sta.keyId = 4; | |
887 | #endif | |
888 | ||
889 | wd->sta.wpaState = ZM_STA_WPA_STATE_PK_OK; | |
890 | } | |
891 | else if ( keyInfo.flag & ZM_KEY_FLAG_GK ) | |
892 | { /* set group key */ | |
893 | ||
894 | zfTkipInit(keyInfo.key, (u8_t*) wd->sta.bssid, | |
895 | &wd->sta.rxSeed[keyInfo.keyIndex], keyInfo.initIv); | |
896 | ||
897 | if ( keyInfo.keyLength == 32 ) | |
898 | { /* TKIP */ | |
899 | #ifdef ZM_ENABLE_CENC | |
900 | if (keyInfo.flag & ZM_KEY_FLAG_CENC) | |
901 | { | |
902 | encryMode = ZM_CENC; | |
903 | zm_debug_msg0("Set CENC group Key"); | |
904 | ||
905 | /* Reset txiv and rxiv */ | |
906 | wd->sta.rxivGK[0] = 0x5c365c36; | |
907 | wd->sta.rxivGK[1] = 0x5c365c36; | |
908 | wd->sta.rxivGK[2] = 0x5c365c36; | |
909 | wd->sta.rxivGK[3] = 0x5c365c36; | |
910 | ||
911 | //zfCoreSetKey(dev, 0, 1, ZM_CENC, keyInfo.vapAddr, | |
912 | // (u32_t*) &keyInfo.key[16]); | |
913 | key = (u32_t*) keyInfo.key; | |
914 | } | |
915 | else | |
916 | #endif //ZM_ENABLE_CENC | |
917 | { | |
918 | encryMode = ZM_TKIP; | |
919 | key = (u32_t*) wd->sta.rxSeed[keyInfo.keyIndex].tk; | |
920 | ||
921 | if ( !(keyInfo.flag & ZM_KEY_FLAG_INIT_IV) ) | |
922 | { | |
923 | wd->sta.rxSeed[keyInfo.keyIndex].iv16 = 0; | |
924 | wd->sta.rxSeed[keyInfo.keyIndex].iv32 = 0; | |
925 | } | |
926 | ||
927 | /* set MIC key to HMAC */ | |
928 | //zfCoreSetKey(dev, 8, 1, ZM_TKIP, broadcast, | |
929 | // (u32_t*) (&keyInfo.key[16])); | |
930 | ||
931 | zfMicSetKey(&keyInfo.key[24], | |
932 | &wd->sta.rxMicKey[keyInfo.keyIndex]); | |
933 | } | |
934 | } | |
935 | else if ( keyInfo.keyLength == 16 ) | |
936 | { /* AES */ | |
937 | encryMode = ZM_AES; | |
938 | //key = (u32_t*) wd->sta.rxSeed[keyInfo.keyIndex].tk; | |
939 | } | |
940 | else | |
941 | { /* WEP */ | |
942 | if ( keyInfo.keyLength == 5 ) | |
943 | { | |
944 | encryMode = ZM_WEP64; | |
945 | } | |
946 | else if ( keyInfo.keyLength == 13 ) | |
947 | { | |
948 | encryMode = ZM_WEP128; | |
949 | } | |
950 | else if ( keyInfo.keyLength == 29 ) | |
951 | { | |
952 | encryMode = ZM_WEP256; | |
953 | } | |
954 | ||
955 | key = (u32_t*) keyInfo.key; | |
956 | } | |
957 | ||
958 | /* user 8 */ | |
959 | //zfCoreSetKey(dev, 8, 0, encryMode, broadcast, key); | |
960 | //zfHpSetStaGroupKey(dev, broadcast, encryMode, | |
961 | // (u32_t*) keyInfo.key, (u32_t*) (&keyInfo.key[16])); | |
962 | ||
963 | #ifdef ZM_ENABLE_IBSS_WPA2PSK | |
964 | if ( (keyInfo.keyLength==16) && (wd->sta.ibssWpa2Psk==1) ) | |
965 | {/* If not AES-CCMP and ibss network , use traditional */ | |
966 | zfHpSetPerUserKey(dev, | |
967 | userIdx, | |
968 | keyInfo.keyIndex, // key id | |
969 | // (u8_t *)broadcast, // for only 2 stations IBSS netwrl ( A2 ) | |
970 | (u8_t*)keyInfo.macAddr, // for multiple ( > 2 ) stations IBSS network ( A2 ) | |
971 | encryMode, | |
972 | (u32_t*) keyInfo.key, (u32_t*) &keyInfo.key[16]); | |
973 | } | |
974 | else | |
975 | { | |
976 | zfHpSetPerUserKey(dev, | |
977 | ZM_USER_KEY_GK, // user id | |
978 | 0, // key id | |
979 | (u8_t *)broadcast, | |
980 | encryMode, | |
981 | (u32_t*) keyInfo.key, (u32_t*) &keyInfo.key[16]); | |
982 | ||
983 | wd->sta.wpaState = ZM_STA_WPA_STATE_GK_OK; | |
984 | } | |
985 | #else | |
986 | zfHpSetPerUserKey(dev, | |
987 | ZM_USER_KEY_GK, // user id | |
988 | 0, // key id | |
989 | (u8_t *)broadcast, | |
990 | encryMode, | |
991 | (u32_t*) keyInfo.key, (u32_t*) &keyInfo.key[16]); | |
992 | ||
993 | wd->sta.wpaState = ZM_STA_WPA_STATE_GK_OK; | |
994 | #endif | |
995 | } | |
996 | else | |
997 | { /* legacy WEP */ | |
998 | zm_debug_msg0("legacy WEP"); | |
999 | ||
1000 | if ( keyInfo.keyIndex >= 4 ) | |
1001 | { | |
1002 | return ZM_STATUS_FAILURE; | |
1003 | } | |
1004 | ||
1005 | if ( keyInfo.keyLength == 5 ) | |
1006 | { | |
1007 | zm_debug_msg0("WEP 64"); | |
1008 | ||
1009 | encryMode = ZM_WEP64; | |
1010 | } | |
1011 | else if ( keyInfo.keyLength == 13 ) | |
1012 | { | |
1013 | zm_debug_msg0("WEP 128"); | |
1014 | ||
1015 | encryMode = ZM_WEP128; | |
1016 | } | |
1017 | else if ( keyInfo.keyLength == 32 ) | |
1018 | { | |
1019 | /* TKIP */ | |
1020 | #if 0 | |
1021 | // Don't reset the IV since some AP would fail in IV check and drop our connection | |
1022 | if ( wd->sta.wpaState != ZM_STA_WPA_STATE_PK_OK ) | |
1023 | { | |
1024 | wd->sta.iv16 = 0; | |
1025 | wd->sta.iv32 = 0; | |
1026 | } | |
1027 | #endif | |
1028 | ||
1029 | encryMode = ZM_TKIP; | |
1030 | ||
1031 | zfTkipInit(keyInfo.key, (u8_t*) wd->sta.bssid, | |
1032 | &wd->sta.rxSeed[keyInfo.keyIndex], keyInfo.initIv); | |
1033 | zfMicSetKey(&keyInfo.key[24], | |
1034 | &wd->sta.rxMicKey[keyInfo.keyIndex]); | |
1035 | } | |
1036 | else if ( keyInfo.keyLength == 16 ) | |
1037 | { | |
1038 | /* AES */ | |
1039 | #if 0 | |
1040 | // Don't reset the IV since some AP would fail in IV check and drop our connection | |
1041 | if ( wd->sta.wpaState != ZM_STA_WPA_STATE_PK_OK ) | |
1042 | { | |
1043 | /* broadcast -- > group key */ | |
1044 | /* Only initialize when set our default key ! */ | |
1045 | wd->sta.iv16 = 0; | |
1046 | wd->sta.iv32 = 0; | |
1047 | } | |
1048 | #endif | |
1049 | ||
1050 | encryMode = ZM_AES; | |
1051 | } | |
1052 | else if ( keyInfo.keyLength == 29 ) | |
1053 | { | |
1054 | zm_debug_msg0("WEP 256"); | |
1055 | ||
1056 | encryMode = ZM_WEP256; | |
1057 | //zfCoreSetKey(dev, 64, 1, wd->sta.encryMode, | |
1058 | // wd->sta.bssid, (u32_t*) (&keyInfo.key[16])); | |
1059 | } | |
1060 | else | |
1061 | { | |
1062 | return ZM_STATUS_FAILURE; | |
1063 | } | |
1064 | ||
1065 | { | |
1066 | u8_t i; | |
1067 | ||
1068 | zm_debug_msg0("key = "); | |
1069 | for(i = 0; i < keyInfo.keyLength; i++) | |
1070 | { | |
1071 | zm_debug_msg2("", keyInfo.key[i]); | |
1072 | } | |
1073 | } | |
1074 | ||
1075 | if ( keyInfo.flag & ZM_KEY_FLAG_DEFAULT_KEY ) | |
1076 | { | |
1077 | //for WEP default key 1~3 and ATOM platform--CWYang(+) | |
1078 | vapId = 0; | |
1079 | wd->ap.bcHalKeyIdx[vapId] = keyInfo.keyIndex; | |
1080 | wd->ap.bcKeyIndex[vapId] = keyInfo.keyIndex; | |
1081 | wd->sta.keyId = keyInfo.keyIndex; | |
1082 | } | |
1083 | ||
1084 | if(encryMode == ZM_TKIP) | |
1085 | { | |
1086 | if(wd->TKIP_Group_KeyChanging == 0x1) | |
1087 | { | |
1088 | zm_debug_msg0("Countermeasure : Cancel Old Timer "); | |
1089 | zfTimerCancel(dev, ZM_EVENT_SKIP_COUNTERMEASURE); | |
1090 | } | |
1091 | else | |
1092 | { | |
1093 | zm_debug_msg0("Countermeasure : Create New Timer "); | |
1094 | } | |
1095 | ||
1096 | wd->TKIP_Group_KeyChanging = 0x1; | |
1097 | zfTimerSchedule(dev, ZM_EVENT_SKIP_COUNTERMEASURE, 150); | |
1098 | } | |
1099 | ||
1100 | ||
1101 | ||
1102 | //------------------------------------------------------------------------ | |
1103 | ||
1104 | /* use default key */ | |
1105 | //zfCoreSetKey(dev, ZM_USER_KEY_DEFAULT+keyInfo.keyIndex, 0, | |
1106 | // wd->sta.encryMode, wd->sta.bssid, (u32_t*) keyInfo.key); | |
1107 | ||
1108 | if ( encryMode == ZM_TKIP || | |
1109 | encryMode == ZM_AES ) | |
1110 | { | |
1111 | zfHpSetDefaultKey(dev, keyInfo.keyIndex, encryMode, | |
1112 | (u32_t*) keyInfo.key, (u32_t*) &keyInfo.key[16]); | |
1113 | ||
1114 | #ifdef ZM_ENABLE_IBSS_WPA2PSK | |
1115 | if ( (keyInfo.keyLength==16) && (wd->sta.ibssWpa2Psk==1) ) | |
1116 | {/* If not AES-CCMP and ibss network , use traditional */ | |
1117 | wd->sta.wpaState = ZM_STA_WPA_STATE_PK_OK; | |
1118 | } | |
1119 | else | |
1120 | { | |
1121 | if (wd->sta.wpaState == ZM_STA_WPA_STATE_PK_OK) | |
1122 | wd->sta.wpaState = ZM_STA_WPA_STATE_GK_OK; | |
1123 | else | |
1124 | { | |
1125 | wd->sta.wpaState = ZM_STA_WPA_STATE_PK_OK; | |
1126 | wd->sta.encryMode = encryMode; | |
1127 | wd->ws.encryMode = encryMode; | |
1128 | } | |
1129 | } | |
1130 | #else | |
1131 | if (wd->sta.wpaState == ZM_STA_WPA_STATE_PK_OK) | |
1132 | wd->sta.wpaState = ZM_STA_WPA_STATE_GK_OK; | |
1133 | else if ( wd->sta.wpaState == ZM_STA_WPA_STATE_INIT ) | |
1134 | { | |
1135 | wd->sta.wpaState = ZM_STA_WPA_STATE_PK_OK; | |
1136 | wd->sta.encryMode = encryMode; | |
1137 | wd->ws.encryMode = encryMode; | |
1138 | } | |
1139 | #endif | |
1140 | } | |
1141 | else | |
1142 | { | |
1143 | zfHpSetDefaultKey(dev, keyInfo.keyIndex, encryMode, | |
1144 | (u32_t*) keyInfo.key, NULL); | |
1145 | ||
1146 | /* Save key for software WEP */ | |
1147 | zfMemoryCopy(wd->sta.wepKey[keyInfo.keyIndex], keyInfo.key, | |
1148 | keyInfo.keyLength); | |
1149 | ||
1150 | /* TODO: Check whether we need to save the SWEncryMode */ | |
1151 | wd->sta.SWEncryMode[keyInfo.keyIndex] = encryMode; | |
1152 | ||
1153 | wd->sta.encryMode = encryMode; | |
1154 | wd->ws.encryMode = encryMode; | |
1155 | } | |
1156 | } | |
1157 | } | |
1158 | ||
1159 | // wd->sta.flagKeyChanging = 1; | |
1160 | return ZM_STATUS_SUCCESS; | |
1161 | } | |
1162 | ||
1163 | /* PSEUDO test */ | |
1164 | u8_t zfiWlanPSEUDOSetKey(zdev_t* dev, struct zsKeyInfo keyInfo) | |
1165 | { | |
1166 | //u16_t broadcast[3] = {0xffff, 0xffff, 0xffff}; | |
1167 | //u32_t* key; | |
1168 | u8_t micKey[16]; | |
1169 | ||
1170 | zmw_get_wlan_dev(dev); | |
1171 | ||
1172 | switch (keyInfo.keyLength) | |
1173 | { | |
1174 | case 5: | |
1175 | wd->sta.encryMode = ZM_WEP64; | |
1176 | /* use default key */ | |
1177 | zfCoreSetKey(dev, 64, 0, ZM_WEP64, (u16_t *)keyInfo.macAddr, (u32_t*) keyInfo.key); | |
1178 | break; | |
1179 | ||
1180 | case 13: | |
1181 | wd->sta.encryMode = ZM_WEP128; | |
1182 | /* use default key */ | |
1183 | zfCoreSetKey(dev, 64, 0, ZM_WEP128, (u16_t *)keyInfo.macAddr, (u32_t*) keyInfo.key); | |
1184 | break; | |
1185 | ||
1186 | case 29: | |
1187 | wd->sta.encryMode = ZM_WEP256; | |
1188 | /* use default key */ | |
1189 | zfCoreSetKey(dev, 64, 1, ZM_WEP256, (u16_t *)keyInfo.macAddr, (u32_t*) (&keyInfo.key[16])); | |
1190 | zfCoreSetKey(dev, 64, 0, ZM_WEP256, (u16_t *)keyInfo.macAddr, (u32_t*) keyInfo.key); | |
1191 | break; | |
1192 | ||
1193 | case 16: | |
1194 | wd->sta.encryMode = ZM_AES; | |
1195 | //zfCoreSetKey(dev, 0, 0, ZM_AES, (u16_t *)keyInfo.macAddr, (u32_t*) keyInfo.key); | |
1196 | zfCoreSetKey(dev, 64, 0, ZM_AES, (u16_t *)keyInfo.macAddr, (u32_t*) keyInfo.key); | |
1197 | break; | |
1198 | ||
1199 | case 32: | |
1200 | #ifdef ZM_ENABLE_CENC | |
1201 | if (keyInfo.flag & ZM_KEY_FLAG_CENC) | |
1202 | { | |
1203 | u16_t boardcastAddr[3] = {0xffff, 0xffff, 0xffff}; | |
1204 | u16_t Addr_a[] = { 0x0000, 0x0080, 0x0901}; | |
1205 | u16_t Addr_b[] = { 0x0000, 0x0080, 0x0902}; | |
1206 | /* CENC test: user0,1 and user2 for boardcast */ | |
1207 | wd->sta.encryMode = ZM_CENC; | |
1208 | zfCoreSetKey(dev, 0, 1, ZM_CENC, (u16_t *)Addr_a, (u32_t*) (&keyInfo.key[16])); | |
1209 | zfCoreSetKey(dev, 0, 0, ZM_CENC, (u16_t *)Addr_a, (u32_t*) keyInfo.key); | |
1210 | ||
1211 | zfCoreSetKey(dev, 1, 1, ZM_CENC, (u16_t *)Addr_b, (u32_t*) (&keyInfo.key[16])); | |
1212 | zfCoreSetKey(dev, 1, 0, ZM_CENC, (u16_t *)Addr_b, (u32_t*) keyInfo.key); | |
1213 | ||
1214 | zfCoreSetKey(dev, 2, 1, ZM_CENC, (u16_t *)boardcastAddr, (u32_t*) (&keyInfo.key[16])); | |
1215 | zfCoreSetKey(dev, 2, 0, ZM_CENC, (u16_t *)boardcastAddr, (u32_t*) keyInfo.key); | |
1216 | ||
1217 | /* Initialize PN sequence */ | |
1218 | wd->sta.txiv[0] = 0x5c365c36; | |
1219 | wd->sta.txiv[1] = 0x5c365c36; | |
1220 | wd->sta.txiv[2] = 0x5c365c36; | |
1221 | wd->sta.txiv[3] = 0x5c365c36; | |
1222 | } | |
1223 | else | |
1224 | #endif //ZM_ENABLE_CENC | |
1225 | { | |
1226 | wd->sta.encryMode = ZM_TKIP; | |
1227 | zfCoreSetKey(dev, 64, 1, ZM_TKIP, (u16_t *)keyInfo.macAddr, (u32_t*) micKey); | |
1228 | zfCoreSetKey(dev, 64, 0, ZM_TKIP, (u16_t *)keyInfo.macAddr, (u32_t*) keyInfo.key); | |
1229 | } | |
1230 | break; | |
1231 | default: | |
1232 | wd->sta.encryMode = ZM_NO_WEP; | |
1233 | } | |
1234 | ||
1235 | return ZM_STATUS_SUCCESS; | |
1236 | } | |
1237 | ||
1238 | void zfiWlanSetPowerSaveMode(zdev_t* dev, u8_t mode) | |
1239 | { | |
1240 | #if 0 | |
1241 | zmw_get_wlan_dev(dev); | |
1242 | ||
1243 | wd->sta.powerSaveMode = mode; | |
1244 | ||
1245 | /* send null data with PwrBit to inform AP */ | |
1246 | if ( mode > ZM_STA_PS_NONE ) | |
1247 | { | |
1248 | if ( wd->wlanMode == ZM_MODE_INFRASTRUCTURE ) | |
1249 | { | |
1250 | zfSendNullData(dev, 1); | |
1251 | } | |
1252 | ||
1253 | /* device into PS mode */ | |
1254 | zfPSDeviceSleep(dev); | |
1255 | } | |
1256 | #endif | |
1257 | ||
1258 | zfPowerSavingMgrSetMode(dev, mode); | |
1259 | } | |
1260 | ||
1261 | void zfiWlanSetMacAddress(zdev_t* dev, u16_t* mac) | |
1262 | { | |
1263 | zmw_get_wlan_dev(dev); | |
1264 | ||
1265 | wd->macAddr[0] = mac[0]; | |
1266 | wd->macAddr[1] = mac[1]; | |
1267 | wd->macAddr[2] = mac[2]; | |
1268 | ||
1269 | zfHpSetMacAddress(dev, mac, 0); | |
1270 | } | |
1271 | ||
1272 | u8_t zfiWlanQueryWlanMode(zdev_t* dev) | |
1273 | { | |
1274 | zmw_get_wlan_dev(dev); | |
1275 | ||
1276 | return wd->wlanMode; | |
1277 | } | |
1278 | ||
1279 | u8_t zfiWlanQueryAdapterState(zdev_t* dev) | |
1280 | { | |
1281 | zmw_get_wlan_dev(dev); | |
1282 | ||
1283 | return wd->state; | |
1284 | } | |
1285 | ||
1286 | u8_t zfiWlanQueryAuthenticationMode(zdev_t* dev, u8_t bWrapper) | |
1287 | { | |
1288 | u8_t authMode; | |
1289 | ||
1290 | zmw_get_wlan_dev(dev); | |
1291 | ||
1292 | if ( bWrapper ) | |
1293 | { | |
1294 | authMode = wd->ws.authMode; | |
1295 | } | |
1296 | else | |
1297 | { | |
1298 | //authMode = wd->sta.authMode; | |
1299 | authMode = wd->sta.currentAuthMode; | |
1300 | } | |
1301 | ||
1302 | return authMode; | |
1303 | } | |
1304 | ||
1305 | u8_t zfiWlanQueryWepStatus(zdev_t* dev, u8_t bWrapper) | |
1306 | { | |
1307 | u8_t wepStatus; | |
1308 | ||
1309 | zmw_get_wlan_dev(dev); | |
1310 | ||
1311 | if ( bWrapper ) | |
1312 | { | |
1313 | wepStatus = wd->ws.wepStatus; | |
1314 | } | |
1315 | else | |
1316 | { | |
1317 | wepStatus = wd->sta.wepStatus; | |
1318 | } | |
1319 | ||
1320 | return wepStatus; | |
1321 | } | |
1322 | ||
1323 | void zfiWlanQuerySSID(zdev_t* dev, u8_t* ssid, u8_t* pSsidLength) | |
1324 | { | |
1325 | u16_t vapId = 0; | |
1326 | zmw_get_wlan_dev(dev); | |
1327 | ||
1328 | if (wd->wlanMode == ZM_MODE_AP) | |
1329 | { | |
1330 | vapId = zfwGetVapId(dev); | |
1331 | ||
1332 | if (vapId == 0xffff) | |
1333 | { | |
1334 | *pSsidLength = wd->ap.ssidLen[0]; | |
1335 | zfMemoryCopy(ssid, wd->ap.ssid[0], wd->ap.ssidLen[0]); | |
1336 | } | |
1337 | else | |
1338 | { | |
1339 | *pSsidLength = wd->ap.ssidLen[vapId + 1]; | |
1340 | zfMemoryCopy(ssid, wd->ap.ssid[vapId + 1], wd->ap.ssidLen[vapId + 1]); | |
1341 | } | |
1342 | } | |
1343 | else | |
1344 | { | |
1345 | *pSsidLength = wd->sta.ssidLen; | |
1346 | zfMemoryCopy(ssid, wd->sta.ssid, wd->sta.ssidLen); | |
1347 | } | |
1348 | } | |
1349 | ||
1350 | u16_t zfiWlanQueryFragThreshold(zdev_t* dev) | |
1351 | { | |
1352 | zmw_get_wlan_dev(dev); | |
1353 | ||
1354 | return wd->fragThreshold; | |
1355 | } | |
1356 | ||
1357 | u16_t zfiWlanQueryRtsThreshold(zdev_t* dev) | |
1358 | { | |
1359 | zmw_get_wlan_dev(dev); | |
1360 | ||
1361 | return wd->rtsThreshold; | |
1362 | } | |
1363 | ||
1364 | u32_t zfiWlanQueryFrequency(zdev_t* dev) | |
1365 | { | |
1366 | zmw_get_wlan_dev(dev); | |
1367 | ||
1368 | return (wd->frequency*1000); | |
1369 | } | |
1370 | ||
1371 | /*********************************************************** | |
1372 | * Function: zfiWlanQueryCurrentFrequency | |
1373 | * Return value: | |
1374 | * - 0 : no validate current frequency | |
1375 | * - (>0): current frequency depend on "qmode" | |
1376 | * Input: | |
1377 | * - qmode: | |
1378 | * 0: return value depend on the support mode, this | |
1379 | qmode is use to solve the bug #31223 | |
1380 | * 1: return the actually current frequency | |
1381 | ***********************************************************/ | |
1382 | u32_t zfiWlanQueryCurrentFrequency(zdev_t* dev, u8_t qmode) | |
1383 | { | |
1384 | u32_t frequency; | |
1385 | ||
1386 | zmw_get_wlan_dev(dev); | |
1387 | ||
1388 | switch (qmode) | |
1389 | { | |
1390 | case 0: | |
1391 | if (wd->sta.currentFrequency > 3000) | |
1392 | { | |
1393 | if (wd->supportMode & ZM_WIRELESS_MODE_5) | |
1394 | { | |
1395 | frequency = wd->sta.currentFrequency; | |
1396 | } | |
1397 | else if (wd->supportMode & ZM_WIRELESS_MODE_24) | |
1398 | { | |
1399 | frequency = zfChGetFirst2GhzChannel(dev); | |
1400 | } | |
1401 | else | |
1402 | { | |
1403 | frequency = 0; | |
1404 | } | |
1405 | } | |
1406 | else | |
1407 | { | |
1408 | if (wd->supportMode & ZM_WIRELESS_MODE_24) | |
1409 | { | |
1410 | frequency = wd->sta.currentFrequency; | |
1411 | } | |
1412 | else if (wd->supportMode & ZM_WIRELESS_MODE_5) | |
1413 | { | |
1414 | frequency = zfChGetLast5GhzChannel(dev); | |
1415 | } | |
1416 | else | |
1417 | { | |
1418 | frequency = 0; | |
1419 | } | |
1420 | } | |
1421 | break; | |
1422 | ||
1423 | case 1: | |
1424 | frequency = wd->sta.currentFrequency; | |
1425 | break; | |
1426 | ||
1427 | default: | |
1428 | frequency = 0; | |
1429 | } | |
1430 | ||
1431 | return (frequency*1000); | |
1432 | } | |
1433 | ||
1434 | u32_t zfiWlanQueryFrequencyAttribute(zdev_t* dev, u32_t freq) | |
1435 | { | |
4bd43f50 LR |
1436 | u8_t i; |
1437 | u16_t frequency = (u16_t) (freq/1000); | |
1438 | u32_t ret = 0; | |
1439 | ||
0009e125 RD |
1440 | zmw_get_wlan_dev(dev); |
1441 | ||
4bd43f50 LR |
1442 | for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) |
1443 | { | |
1444 | if ( wd->regulationTable.allowChannel[i].channel == frequency ) | |
1445 | { | |
1446 | ret = wd->regulationTable.allowChannel[i].channelFlags; | |
1447 | } | |
1448 | } | |
1449 | ||
1450 | return ret; | |
1451 | } | |
1452 | ||
1453 | /* BandWidth 0=>20 1=>40 */ | |
1454 | /* ExtOffset 0=>20 1=>high control 40 3=>low control 40 */ | |
1455 | void zfiWlanQueryFrequencyHT(zdev_t* dev, u32_t *bandWidth, u32_t *extOffset) | |
1456 | { | |
1457 | zmw_get_wlan_dev(dev); | |
1458 | ||
1459 | *bandWidth = wd->BandWidth40; | |
1460 | *extOffset = wd->ExtOffset; | |
1461 | } | |
1462 | ||
1463 | u8_t zfiWlanQueryCWMode(zdev_t* dev) | |
1464 | { | |
1465 | zmw_get_wlan_dev(dev); | |
1466 | ||
1467 | return wd->cwm.cw_mode; | |
1468 | } | |
1469 | ||
1470 | u32_t zfiWlanQueryCWEnable(zdev_t* dev) | |
1471 | { | |
1472 | zmw_get_wlan_dev(dev); | |
1473 | ||
1474 | return wd->cwm.cw_enable; | |
1475 | } | |
1476 | ||
1477 | void zfiWlanQueryBssid(zdev_t* dev, u8_t* bssid) | |
1478 | { | |
1479 | u8_t addr[6]; | |
1480 | ||
1481 | zmw_get_wlan_dev(dev); | |
1482 | ||
1483 | ZM_MAC_WORD_TO_BYTE(wd->sta.bssid, addr); | |
1484 | zfMemoryCopy(bssid, addr, 6); | |
1485 | } | |
1486 | ||
1487 | u16_t zfiWlanQueryBeaconInterval(zdev_t* dev) | |
1488 | { | |
1489 | zmw_get_wlan_dev(dev); | |
1490 | ||
1491 | return wd->beaconInterval; | |
1492 | } | |
1493 | ||
1494 | u32_t zfiWlanQueryRxBeaconTotal(zdev_t* dev) | |
1495 | { | |
1496 | zmw_get_wlan_dev(dev); | |
1497 | wd->sta.rxBeaconTotal += wd->sta.rxBeaconCount; | |
1498 | ||
1499 | return wd->sta.rxBeaconTotal; | |
1500 | } | |
1501 | ||
1502 | u16_t zfiWlanQueryAtimWindow(zdev_t* dev) | |
1503 | { | |
1504 | u16_t atimWindow; | |
1505 | ||
1506 | zmw_get_wlan_dev(dev); | |
1507 | ||
1508 | atimWindow = wd->sta.atimWindow; | |
1509 | ||
1510 | return atimWindow; | |
1511 | } | |
1512 | ||
1513 | u8_t zfiWlanQueryEncryMode(zdev_t* dev) | |
1514 | { | |
1515 | zmw_get_wlan_dev(dev); | |
1516 | ||
1517 | if (wd->wlanMode == ZM_MODE_AP) | |
1518 | return wd->ap.encryMode[0]; | |
1519 | else | |
1520 | return wd->sta.encryMode; | |
1521 | } | |
1522 | ||
1523 | u16_t zfiWlanQueryCapability(zdev_t* dev) | |
1524 | { | |
1525 | u16_t capability; | |
1526 | ||
1527 | zmw_get_wlan_dev(dev); | |
1528 | ||
1529 | capability = wd->sta.capability[0] + | |
1530 | (((u16_t) wd->sta.capability[1]) << 8); | |
1531 | ||
1532 | return capability; | |
1533 | ||
1534 | } | |
1535 | ||
1536 | u16_t zfiWlanQueryAid(zdev_t* dev) | |
1537 | { | |
1538 | zmw_get_wlan_dev(dev); | |
1539 | ||
1540 | return wd->sta.aid; | |
1541 | } | |
1542 | ||
1543 | void zfiWlanQuerySupportRate(zdev_t* dev, u8_t* rateArray, u8_t* pLength) | |
1544 | { | |
1545 | u8_t i, j=0; | |
1546 | ||
1547 | zmw_get_wlan_dev(dev); | |
1548 | ||
1549 | for( i=0; i<4; i++ ) | |
1550 | { | |
1551 | if ( wd->bRate & (0x1 << i) ) | |
1552 | { | |
1553 | rateArray[j] = zg11bRateTbl[i] + | |
1554 | ((wd->bRateBasic & (0x1<<i))<<(7-i)); | |
1555 | j++; | |
1556 | } | |
1557 | } | |
1558 | ||
1559 | *pLength = j; | |
1560 | } | |
1561 | ||
1562 | void zfiWlanQueryExtSupportRate(zdev_t* dev, u8_t* rateArray, u8_t* pLength) | |
1563 | { | |
1564 | u8_t i, j=0; | |
1565 | ||
1566 | zmw_get_wlan_dev(dev); | |
1567 | ||
1568 | for( i=0; i<8; i++ ) | |
1569 | { | |
1570 | if ( wd->gRate & (0x1 << i) ) | |
1571 | { | |
1572 | rateArray[j] = zg11gRateTbl[i] + | |
1573 | ((wd->gRateBasic & (0x1<<i))<<(7-i)); | |
1574 | j++; | |
1575 | } | |
1576 | } | |
1577 | ||
1578 | *pLength = j; | |
1579 | } | |
1580 | ||
1581 | void zfiWlanQueryRsnIe(zdev_t* dev, u8_t* ie, u8_t* pLength) | |
1582 | { | |
1583 | u8_t len; | |
1584 | ||
1585 | zmw_get_wlan_dev(dev); | |
1586 | ||
1587 | len = wd->sta.rsnIe[1] + 2; | |
1588 | zfMemoryCopy(ie, wd->sta.rsnIe, len); | |
1589 | *pLength = len; | |
1590 | } | |
1591 | ||
1592 | void zfiWlanQueryWpaIe(zdev_t* dev, u8_t* ie, u8_t* pLength) | |
1593 | { | |
1594 | u8_t len; | |
1595 | ||
1596 | zmw_get_wlan_dev(dev); | |
1597 | ||
1598 | len = wd->sta.wpaIe[1] + 2; | |
1599 | zfMemoryCopy(ie, wd->sta.wpaIe, len); | |
1600 | *pLength = len; | |
1601 | ||
1602 | } | |
1603 | ||
1604 | u8_t zfiWlanQueryMulticastCipherAlgo(zdev_t *dev) | |
1605 | { | |
1606 | zmw_get_wlan_dev(dev); | |
1607 | ||
1608 | switch( wd->sta.currentAuthMode ) | |
1609 | { | |
1610 | case ZM_AUTH_MODE_WPA2PSK: | |
1611 | case ZM_AUTH_MODE_WPA2: | |
1612 | if ( wd->sta.rsnIe[7] == 2 ) | |
1613 | { | |
1614 | return ZM_TKIP; | |
1615 | } | |
1616 | else | |
1617 | { | |
1618 | return ZM_AES; | |
1619 | } | |
1620 | break; | |
1621 | ||
1622 | case ZM_AUTH_MODE_WPAPSK: | |
1623 | case ZM_AUTH_MODE_WPA: | |
1624 | if ( wd->sta.rsnIe[11] == 2 ) | |
1625 | { | |
1626 | return ZM_TKIP; | |
1627 | } | |
1628 | else | |
1629 | { | |
1630 | return ZM_AES; | |
1631 | } | |
1632 | break; | |
1633 | ||
1634 | default: | |
1635 | return wd->sta.encryMode; | |
1636 | } | |
1637 | } | |
1638 | ||
1639 | u8_t zfiWlanQueryHTMode(zdev_t* dev) | |
1640 | { | |
1641 | zmw_get_wlan_dev(dev); | |
1642 | // 0:Legancy, 1:N | |
1643 | return wd->sta.EnableHT; | |
1644 | } | |
1645 | ||
1646 | u8_t zfiWlanQueryBandWidth40(zdev_t* dev) | |
1647 | { | |
1648 | zmw_get_wlan_dev(dev); | |
1649 | // 0:20M, 1:40M | |
1650 | return wd->BandWidth40; | |
1651 | } | |
1652 | ||
1653 | u16_t zfiWlanQueryRegionCode(zdev_t* dev) | |
1654 | { | |
1655 | zmw_get_wlan_dev(dev); | |
1656 | ||
1657 | return wd->regulationTable.regionCode; | |
1658 | } | |
1659 | void zfiWlanSetWpaIe(zdev_t* dev, u8_t* ie, u8_t Length) | |
1660 | { | |
1661 | u16_t vapId = 0; | |
1662 | zmw_get_wlan_dev(dev); | |
1663 | ||
1664 | if (wd->wlanMode == ZM_MODE_AP) // AP Mode | |
1665 | { | |
1666 | vapId = zfwGetVapId(dev); | |
1667 | ||
1668 | if (vapId == 0xffff) | |
1669 | vapId = 0; | |
1670 | else | |
1671 | vapId++; | |
1672 | ||
1673 | zm_assert(Length < ZM_MAX_WPAIE_SIZE); | |
1674 | if (Length < ZM_MAX_WPAIE_SIZE) | |
1675 | { | |
1676 | wd->ap.wpaLen[vapId] = Length; | |
1677 | zfMemoryCopy(wd->ap.wpaIe[vapId], ie, wd->ap.wpaLen[vapId]); | |
1678 | } | |
1679 | ||
1680 | } | |
1681 | else | |
1682 | { | |
1683 | wd->sta.wpaLen = Length; | |
1684 | zfMemoryCopy(wd->sta.wpaIe, ie, wd->sta.wpaLen); | |
1685 | } | |
1686 | //zfiWlanSetWpaSupport(dev, 1); | |
1687 | if (wd->wlanMode == ZM_MODE_AP) // AP Mode | |
1688 | { | |
1689 | wd->ap.wpaSupport[vapId] = 1; | |
1690 | } | |
1691 | else | |
1692 | { | |
1693 | wd->sta.wpaSupport = 1; | |
1694 | } | |
1695 | ||
1696 | } | |
1697 | ||
1698 | void zfiWlanSetWpaSupport(zdev_t* dev, u8_t WpaSupport) | |
1699 | { | |
1700 | u16_t vapId = 0; | |
1701 | zmw_get_wlan_dev(dev); | |
1702 | ||
1703 | if (wd->wlanMode == ZM_MODE_AP) // AP Mode | |
1704 | { | |
1705 | vapId = zfwGetVapId(dev); | |
1706 | ||
1707 | if (vapId == 0xffff) | |
1708 | vapId = 0; | |
1709 | else | |
1710 | vapId++; | |
1711 | ||
1712 | wd->ap.wpaSupport[vapId] = WpaSupport; | |
1713 | } | |
1714 | else | |
1715 | { | |
1716 | wd->sta.wpaSupport = WpaSupport; | |
1717 | } | |
1718 | ||
1719 | } | |
1720 | ||
1721 | void zfiWlanSetProtectionMode(zdev_t* dev, u8_t mode) | |
1722 | { | |
1723 | zmw_get_wlan_dev(dev); | |
1724 | ||
1725 | wd->sta.bProtectionMode = mode; | |
1726 | if (wd->sta.bProtectionMode == TRUE) | |
1727 | { | |
1728 | zfHpSetSlotTime(dev, 0); | |
1729 | } | |
1730 | else | |
1731 | { | |
1732 | zfHpSetSlotTime(dev, 1); | |
1733 | } | |
1734 | ||
1735 | zm_msg1_mm(ZM_LV_1, "wd->protectionMode=", wd->sta.bProtectionMode); | |
1736 | } | |
1737 | ||
1738 | void zfiWlanSetBasicRate(zdev_t* dev, u8_t bRateSet, u8_t gRateSet, | |
1739 | u32_t nRateSet) | |
1740 | { | |
1741 | zmw_get_wlan_dev(dev); | |
1742 | ||
1743 | wd->ws.bRateBasic = bRateSet; | |
1744 | wd->ws.gRateBasic = gRateSet; | |
1745 | wd->ws.nRateBasic = nRateSet; | |
1746 | } | |
1747 | ||
1748 | void zfiWlanSetBGMode(zdev_t* dev, u8_t mode) | |
1749 | { | |
1750 | zmw_get_wlan_dev(dev); | |
1751 | ||
1752 | wd->ws.bgMode = mode; | |
1753 | } | |
1754 | ||
1755 | void zfiWlanSetpreambleType(zdev_t* dev, u8_t type) | |
1756 | { | |
1757 | zmw_get_wlan_dev(dev); | |
1758 | ||
1759 | wd->ws.preambleType = type; | |
1760 | } | |
1761 | ||
1762 | u8_t zfiWlanQuerypreambleType(zdev_t* dev) | |
1763 | { | |
1764 | zmw_get_wlan_dev(dev); | |
1765 | ||
1766 | return wd->ws.preambleType; | |
1767 | } | |
1768 | ||
1769 | u8_t zfiWlanQueryPowerSaveMode(zdev_t* dev) | |
1770 | { | |
1771 | zmw_get_wlan_dev(dev); | |
1772 | ||
1773 | return wd->sta.powerSaveMode; | |
1774 | } | |
1775 | ||
1776 | u8_t zfiWlanSetPmkidInfo(zdev_t* dev, u16_t* bssid, u8_t* pmkid) | |
1777 | { | |
1778 | u32_t i; | |
1779 | ||
1780 | zmw_get_wlan_dev(dev); | |
1781 | ||
1782 | for(i=0; i<wd->sta.pmkidInfo.bssidCount; i++) | |
1783 | { | |
1784 | if ( zfMemoryIsEqual((u8_t*) wd->sta.pmkidInfo.bssidInfo[i].bssid, | |
1785 | (u8_t*) bssid, 6) ) | |
1786 | { | |
1787 | /* matched */ | |
1788 | break; | |
1789 | } | |
1790 | } | |
1791 | ||
1792 | if ( i < wd->sta.pmkidInfo.bssidCount ) | |
1793 | { | |
1794 | /* overwrite the original one */ | |
1795 | zfMemoryCopy(wd->sta.pmkidInfo.bssidInfo[i].pmkid, pmkid, 16); | |
1796 | } | |
1797 | else | |
1798 | { | |
1799 | if ( i < ZM_PMKID_MAX_BSS_CNT ) | |
1800 | { | |
1801 | wd->sta.pmkidInfo.bssidInfo[i].bssid[0] = bssid[0]; | |
1802 | wd->sta.pmkidInfo.bssidInfo[i].bssid[1] = bssid[1]; | |
1803 | wd->sta.pmkidInfo.bssidInfo[i].bssid[2] = bssid[2]; | |
1804 | ||
1805 | zfMemoryCopy(wd->sta.pmkidInfo.bssidInfo[i].pmkid, pmkid, 16); | |
1806 | wd->sta.pmkidInfo.bssidCount++; | |
1807 | } | |
1808 | } | |
1809 | ||
1810 | return 0; | |
1811 | } | |
1812 | ||
1813 | u32_t zfiWlanQueryPmkidInfo(zdev_t* dev, u8_t* buf, u32_t len) | |
1814 | { | |
1815 | //struct zsPmkidInfo* pPmkidInfo = ( struct zsPmkidInfo* ) buf; | |
1816 | u32_t size; | |
1817 | ||
1818 | zmw_get_wlan_dev(dev); | |
1819 | ||
1820 | size = sizeof(u32_t) + | |
1821 | wd->sta.pmkidInfo.bssidCount * sizeof(struct zsPmkidBssidInfo); | |
1822 | ||
1823 | if ( len < size ) | |
1824 | { | |
1825 | return wd->sta.pmkidInfo.bssidCount; | |
1826 | } | |
1827 | ||
1828 | zfMemoryCopy(buf, (u8_t*) &wd->sta.pmkidInfo, (u16_t) size); | |
1829 | ||
1830 | return 0; | |
1831 | } | |
1832 | ||
1833 | void zfiWlanSetMulticastList(zdev_t* dev, u8_t size, u8_t* pList) | |
1834 | { | |
1835 | struct zsMulticastAddr* pMacList = (struct zsMulticastAddr*) pList; | |
1836 | u8_t i; | |
1837 | u8_t bAllMulticast = 0; | |
1838 | //u32_t value; | |
1839 | ||
1840 | zmw_get_wlan_dev(dev); | |
1841 | ||
1842 | wd->sta.multicastList.size = size; | |
1843 | for(i=0; i<size; i++) | |
1844 | { | |
1845 | zfMemoryCopy(wd->sta.multicastList.macAddr[i].addr, | |
1846 | pMacList[i].addr, 6); | |
1847 | } | |
1848 | ||
1849 | if ( wd->sta.osRxFilter & ZM_PACKET_TYPE_ALL_MULTICAST ) | |
1850 | bAllMulticast = 1; | |
1851 | zfHpSetMulticastList(dev, size, pList, bAllMulticast); | |
1852 | ||
1853 | } | |
1854 | ||
1855 | void zfiWlanRemoveKey(zdev_t* dev, u8_t keyType, u8_t keyId) | |
1856 | { | |
1857 | u16_t fakeMacAddr[3] = {0, 0, 0}; | |
1858 | u32_t fakeKey[4] = {0, 0, 0, 0}; | |
1859 | ||
1860 | zmw_get_wlan_dev(dev); | |
1861 | ||
1862 | if ( keyType == 0 ) | |
1863 | { | |
1864 | /* remove WEP key */ | |
1865 | zm_debug_msg0("remove WEP key"); | |
1866 | zfCoreSetKey(dev, ZM_USER_KEY_DEFAULT+keyId, 0, | |
1867 | ZM_NO_WEP, fakeMacAddr, fakeKey); | |
1868 | wd->sta.encryMode = ZM_NO_WEP; | |
1869 | } | |
1870 | else if ( keyType == 1 ) | |
1871 | { | |
1872 | /* remove pairwise key */ | |
1873 | zm_debug_msg0("remove pairwise key"); | |
1874 | zfHpRemoveKey(dev, ZM_USER_KEY_PK); | |
1875 | wd->sta.encryMode = ZM_NO_WEP; | |
1876 | } | |
1877 | else | |
1878 | { | |
1879 | /* remove group key */ | |
1880 | zm_debug_msg0("remove group key"); | |
1881 | zfHpRemoveKey(dev, ZM_USER_KEY_GK); | |
1882 | } | |
1883 | } | |
1884 | ||
1885 | ||
1886 | void zfiWlanQueryRegulationTable(zdev_t* dev, struct zsRegulationTable* pEntry) | |
1887 | { | |
1888 | zmw_get_wlan_dev(dev); | |
1889 | ||
1890 | zfMemoryCopy((u8_t*) pEntry, (u8_t*) &wd->regulationTable, | |
1891 | sizeof(struct zsRegulationTable)); | |
1892 | } | |
1893 | ||
1894 | /* parameter "time" is specified in ms */ | |
1895 | void zfiWlanSetScanTimerPerChannel(zdev_t* dev, u16_t time) | |
1896 | { | |
1897 | zmw_get_wlan_dev(dev); | |
1898 | ||
1899 | zm_debug_msg1("scan time (ms) = ", time); | |
1900 | ||
1901 | wd->sta.activescanTickPerChannel = time / ZM_MS_PER_TICK; | |
1902 | } | |
1903 | ||
1904 | void zfiWlanSetAutoReconnect(zdev_t* dev, u8_t enable) | |
1905 | { | |
1906 | zmw_get_wlan_dev(dev); | |
1907 | ||
1908 | wd->sta.bAutoReconnect = enable; | |
1909 | //wd->sta.bAutoReconnectEnabled = enable; | |
1910 | } | |
1911 | ||
1912 | void zfiWlanSetStaWme(zdev_t* dev, u8_t enable, u8_t uapsdInfo) | |
1913 | { | |
1914 | zmw_get_wlan_dev(dev); | |
1915 | ||
1916 | wd->ws.staWmeEnabled = enable & 0x3; | |
1917 | if ((enable & 0x2) != 0) | |
1918 | { | |
1919 | wd->ws.staWmeQosInfo = uapsdInfo & 0x6f; | |
1920 | } | |
1921 | else | |
1922 | { | |
1923 | wd->ws.staWmeQosInfo = 0; | |
1924 | } | |
1925 | } | |
1926 | ||
1927 | void zfiWlanSetApWme(zdev_t* dev, u8_t enable) | |
1928 | { | |
1929 | zmw_get_wlan_dev(dev); | |
1930 | ||
1931 | wd->ws.apWmeEnabled = enable; | |
1932 | } | |
1933 | ||
1934 | u8_t zfiWlanQuerywmeEnable(zdev_t* dev) | |
1935 | { | |
1936 | zmw_get_wlan_dev(dev); | |
1937 | ||
1938 | return wd->ws.staWmeEnabled; | |
1939 | } | |
1940 | ||
1941 | void zfiWlanSetProbingHiddenSsid(zdev_t* dev, u8_t* ssid, u8_t ssidLen, | |
1942 | u16_t entry) | |
1943 | { | |
1944 | zmw_get_wlan_dev(dev); | |
1945 | zmw_declare_for_critical_section(); | |
1946 | ||
1947 | ||
1948 | if ((ssidLen <= 32) && (entry < ZM_MAX_PROBE_HIDDEN_SSID_SIZE)) | |
1949 | { | |
1950 | zmw_enter_critical_section(dev); | |
1951 | wd->ws.probingSsidList[entry].ssidLen = ssidLen; | |
1952 | zfMemoryCopy(wd->ws.probingSsidList[entry].ssid, ssid, ssidLen); | |
1953 | zmw_leave_critical_section(dev); | |
1954 | } | |
1955 | ||
1956 | return; | |
1957 | } | |
1958 | ||
1959 | void zfiWlanSetDisableProbingWithSsid(zdev_t* dev, u8_t mode) | |
1960 | { | |
1961 | zmw_get_wlan_dev(dev); | |
1962 | ||
1963 | wd->sta.disableProbingWithSsid = mode; | |
1964 | ||
1965 | return; | |
1966 | } | |
1967 | ||
1968 | void zfiWlanSetDropUnencryptedPackets(zdev_t* dev, u8_t enable) | |
1969 | { | |
1970 | zmw_get_wlan_dev(dev); | |
1971 | ||
1972 | wd->ws.dropUnencryptedPkts = enable; | |
1973 | } | |
1974 | ||
1975 | void zfiWlanSetStaRxSecurityCheckCb(zdev_t* dev, zfpStaRxSecurityCheckCb pStaRxSecurityCheckCb) | |
1976 | { | |
1977 | zmw_get_wlan_dev(dev); | |
1978 | ||
1979 | wd->sta.pStaRxSecurityCheckCb = pStaRxSecurityCheckCb; | |
1980 | } | |
1981 | ||
1982 | void zfiWlanSetIBSSJoinOnly(zdev_t* dev, u8_t joinOnly) | |
1983 | { | |
1984 | zmw_get_wlan_dev(dev); | |
1985 | ||
1986 | wd->ws.ibssJoinOnly = joinOnly; | |
1987 | } | |
1988 | ||
1989 | /************************************************************************/ | |
1990 | /* */ | |
1991 | /* FUNCTION DESCRIPTION zfiConfigWdsPort */ | |
1992 | /* Configure WDS port. */ | |
1993 | /* */ | |
1994 | /* INPUTS */ | |
1995 | /* dev : device pointer */ | |
1996 | /* wdsPortId : WDS port ID, start from 0 */ | |
1997 | /* flag : 0=>disable WDS port, 1=>enable WDS port */ | |
1998 | /* wdsAddr : WDS neighbor MAC address */ | |
1999 | /* encType : encryption type for WDS port */ | |
2000 | /* wdsKey : encryption key for WDS port */ | |
2001 | /* */ | |
2002 | /* OUTPUTS */ | |
2003 | /* Error code */ | |
2004 | /* */ | |
2005 | /* AUTHOR */ | |
2006 | /* Stephen Chen ZyDAS Technology Corporation 2006.6 */ | |
2007 | /* */ | |
2008 | /************************************************************************/ | |
2009 | u16_t zfiConfigWdsPort(zdev_t* dev, u8_t wdsPortId, u16_t flag, u16_t* wdsAddr, | |
2010 | u16_t encType, u32_t* wdsKey) | |
2011 | { | |
2012 | u16_t addr[3]; | |
2013 | u32_t key[4]; | |
2014 | ||
2015 | zmw_get_wlan_dev(dev); | |
2016 | ||
5aaeab66 | 2017 | if (wdsPortId >= ZM_MAX_WDS_SUPPORT) |
4bd43f50 LR |
2018 | { |
2019 | return ZM_ERR_WDS_PORT_ID; | |
2020 | } | |
2021 | ||
2022 | if (flag == 1) | |
2023 | { | |
2024 | /* Enable WDS port */ | |
2025 | wd->ap.wds.macAddr[wdsPortId][0] = wdsAddr[0]; | |
2026 | wd->ap.wds.macAddr[wdsPortId][1] = wdsAddr[1]; | |
2027 | wd->ap.wds.macAddr[wdsPortId][2] = wdsAddr[2]; | |
2028 | ||
2029 | wd->ap.wds.wdsBitmap |= (1 << wdsPortId); | |
2030 | wd->ap.wds.encryMode[wdsPortId] = (u8_t) encType; | |
2031 | ||
2032 | zfCoreSetKey(dev, 10+ZM_MAX_WDS_SUPPORT, 0, (u8_t) encType, wdsAddr, wdsKey); | |
2033 | } | |
2034 | else | |
2035 | { | |
2036 | /* Disable WDS port */ | |
2037 | addr[0] = addr[1] = addr[2] = 0; | |
2038 | key[0] = key[1] = key[2] = key[3] = 0; | |
2039 | wd->ap.wds.wdsBitmap &= (~(1 << wdsPortId)); | |
2040 | zfCoreSetKey(dev, 10+ZM_MAX_WDS_SUPPORT, 0, ZM_NO_WEP, addr, key); | |
2041 | } | |
2042 | ||
2043 | return ZM_SUCCESS; | |
2044 | } | |
2045 | #ifdef ZM_ENABLE_CENC | |
2046 | /* CENC */ | |
2047 | void zfiWlanQueryGSN(zdev_t* dev, u8_t *gsn, u16_t vapId) | |
2048 | { | |
2049 | //struct zsWlanDev* wd = (struct zsWlanDev*) zmw_wlan_dev(dev); | |
2050 | u32_t txiv[4]; | |
2051 | zmw_get_wlan_dev(dev); | |
2052 | ||
2053 | /* convert little endian to big endian for 32 bits */ | |
2054 | txiv[3] = wd->ap.txiv[vapId][0]; | |
2055 | txiv[2] = wd->ap.txiv[vapId][1]; | |
2056 | txiv[1] = wd->ap.txiv[vapId][2]; | |
2057 | txiv[0] = wd->ap.txiv[vapId][3]; | |
2058 | ||
2059 | zfMemoryCopy(gsn, (u8_t*)txiv, 16); | |
2060 | } | |
2061 | #endif //ZM_ENABLE_CENC | |
2062 | //CWYang(+) | |
2063 | void zfiWlanQuerySignalInfo(zdev_t* dev, u8_t *buffer) | |
2064 | { | |
2065 | zmw_get_wlan_dev(dev); | |
2066 | ||
2067 | /*Change Signal Strength/Quality Value to Human Sense Here*/ | |
2068 | ||
2069 | buffer[0] = wd->SignalStrength; | |
2070 | buffer[1] = wd->SignalQuality; | |
2071 | } | |
2072 | ||
2073 | /* OS-XP */ | |
2074 | u16_t zfiStaAddIeWpaRsn(zdev_t* dev, zbuf_t* buf, u16_t offset, u8_t frameType) | |
2075 | { | |
2076 | return zfStaAddIeWpaRsn(dev, buf, offset, frameType); | |
2077 | } | |
2078 | ||
2079 | /* zfiDebugCmd */ | |
2080 | /* cmd value-description */ | |
2081 | /* 0 schedule timer */ | |
2082 | /* 1 cancel timer */ | |
2083 | /* 2 clear timer */ | |
2084 | /* 3 test timer */ | |
2085 | /* 4 */ | |
2086 | /* 5 */ | |
2087 | /* 6 checksum test 0/1 */ | |
2088 | /* 7 enableProtectionMode */ | |
2089 | /* 8 rx packet content dump 0/1 */ | |
2090 | ||
2091 | u32_t zfiDebugCmd(zdev_t* dev, u32_t cmd, u32_t value) | |
2092 | { | |
2093 | u16_t event; | |
2094 | u32_t tick; | |
2095 | zmw_get_wlan_dev(dev); | |
2096 | ||
2097 | zmw_declare_for_critical_section(); | |
2098 | ||
2099 | ||
2100 | zmw_enter_critical_section(dev); | |
2101 | ||
2102 | if ( cmd == 0 ) | |
2103 | { /* schedule timer */ | |
2104 | event = (u16_t) ((value >> 16) & 0xffff); | |
2105 | tick = value & 0xffff; | |
2106 | zfTimerSchedule(dev, event, tick); | |
2107 | } | |
2108 | else if ( cmd == 1 ) | |
2109 | { /* cancel timer */ | |
2110 | event = (u16_t) (value & 0xffff); | |
2111 | zfTimerCancel(dev, event); | |
2112 | } | |
2113 | else if ( cmd == 2 ) | |
2114 | { /* clear timer */ | |
2115 | zfTimerClear(dev); | |
2116 | } | |
2117 | else if ( cmd == 3 ) | |
2118 | { /* test timer */ | |
2119 | zfTimerSchedule(dev, 1, 500); | |
2120 | zfTimerSchedule(dev, 2, 1000); | |
2121 | zfTimerSchedule(dev, 3, 1000); | |
2122 | zfTimerSchedule(dev, 4, 1000); | |
2123 | zfTimerSchedule(dev, 5, 1500); | |
2124 | zfTimerSchedule(dev, 6, 2000); | |
2125 | zfTimerSchedule(dev, 7, 2200); | |
2126 | zfTimerSchedule(dev, 6, 2500); | |
2127 | zfTimerSchedule(dev, 8, 2800); | |
2128 | } | |
2129 | else if ( cmd == 4) | |
2130 | { | |
2131 | zfTimerSchedule(dev, 1, 500); | |
2132 | zfTimerSchedule(dev, 2, 1000); | |
2133 | zfTimerSchedule(dev, 3, 1000); | |
2134 | zfTimerSchedule(dev, 4, 1000); | |
2135 | zfTimerSchedule(dev, 5, 1500); | |
2136 | zfTimerSchedule(dev, 6, 2000); | |
2137 | zfTimerSchedule(dev, 7, 2200); | |
2138 | zfTimerSchedule(dev, 6, 2500); | |
2139 | zfTimerSchedule(dev, 8, 2800); | |
2140 | zfTimerCancel(dev, 1); | |
2141 | zfTimerCancel(dev, 3); | |
2142 | zfTimerCancel(dev, 6); | |
2143 | } | |
2144 | else if ( cmd == 5 ) | |
2145 | { | |
2146 | wd->sta.keyId = (u8_t) value; | |
2147 | } | |
2148 | else if ( cmd == 6 ) | |
2149 | { | |
2150 | /* 0: normal 1: always set TCP/UDP checksum zero */ | |
2151 | wd->checksumTest = value; | |
2152 | } | |
2153 | else if ( cmd == 7 ) | |
2154 | { | |
2155 | wd->enableProtectionMode = value; | |
2156 | zm_msg1_mm(ZM_LV_1, "wd->enableProtectionMode=", wd->enableProtectionMode); | |
2157 | } | |
2158 | else if ( cmd == 8 ) | |
2159 | { | |
2160 | /* rx packet content dump */ | |
2161 | if (value) | |
2162 | { | |
2163 | wd->rxPacketDump = 1; | |
2164 | } | |
2165 | else | |
2166 | { | |
2167 | wd->rxPacketDump = 0; | |
2168 | } | |
2169 | } | |
2170 | ||
2171 | ||
2172 | zmw_leave_critical_section(dev); | |
2173 | ||
2174 | return 0; | |
2175 | } | |
2176 | ||
2177 | #ifdef ZM_ENABLE_CENC | |
2178 | u8_t zfiWlanSetCencPairwiseKey(zdev_t* dev, u8_t keyid, u32_t *txiv, u32_t *rxiv, | |
2179 | u8_t *key, u8_t *mic) | |
2180 | { | |
2181 | struct zsKeyInfo keyInfo; | |
2182 | u8_t cencKey[32]; | |
2183 | u8_t i; | |
2184 | u16_t macAddr[3]; | |
2185 | ||
2186 | zmw_get_wlan_dev(dev); | |
2187 | ||
2188 | for (i = 0; i < 16; i++) | |
2189 | cencKey[i] = key[i]; | |
2190 | for (i = 0; i < 16; i++) | |
2191 | cencKey[i + 16] = mic[i]; | |
2192 | keyInfo.key = cencKey; | |
2193 | keyInfo.keyLength = 32; | |
2194 | keyInfo.keyIndex = keyid; | |
2195 | keyInfo.flag = ZM_KEY_FLAG_CENC | ZM_KEY_FLAG_PK; | |
2196 | for (i = 0; i < 3; i++) | |
2197 | macAddr[i] = wd->sta.bssid[i]; | |
2198 | keyInfo.macAddr = macAddr; | |
2199 | ||
2200 | zfiWlanSetKey(dev, keyInfo); | |
2201 | ||
2202 | /* Reset txiv and rxiv */ | |
2203 | //wd->sta.txiv[0] = txiv[0]; | |
2204 | //wd->sta.txiv[1] = txiv[1]; | |
2205 | //wd->sta.txiv[2] = txiv[2]; | |
2206 | //wd->sta.txiv[3] = txiv[3]; | |
2207 | // | |
2208 | //wd->sta.rxiv[0] = rxiv[0]; | |
2209 | //wd->sta.rxiv[1] = rxiv[1]; | |
2210 | //wd->sta.rxiv[2] = rxiv[2]; | |
2211 | //wd->sta.rxiv[3] = rxiv[3]; | |
2212 | ||
2213 | return 0; | |
2214 | } | |
2215 | ||
2216 | u8_t zfiWlanSetCencGroupKey(zdev_t* dev, u8_t keyid, u32_t *rxiv, | |
2217 | u8_t *key, u8_t *mic) | |
2218 | { | |
2219 | struct zsKeyInfo keyInfo; | |
2220 | u8_t cencKey[32]; | |
2221 | u8_t i; | |
2222 | u16_t macAddr[6] = {0xffff, 0xffff, 0xffff}; | |
2223 | ||
2224 | zmw_get_wlan_dev(dev); | |
2225 | ||
2226 | for (i = 0; i < 16; i++) | |
2227 | cencKey[i] = key[i]; | |
2228 | for (i = 0; i < 16; i++) | |
2229 | cencKey[i + 16] = mic[i]; | |
2230 | keyInfo.key = cencKey; | |
2231 | keyInfo.keyLength = 32; | |
2232 | keyInfo.keyIndex = keyid; | |
2233 | keyInfo.flag = ZM_KEY_FLAG_CENC | ZM_KEY_FLAG_GK; | |
2234 | keyInfo.vapId = 0; | |
2235 | for (i = 0; i < 3; i++) | |
2236 | keyInfo.vapAddr[i] = wd->macAddr[i]; | |
2237 | keyInfo.macAddr = macAddr; | |
2238 | ||
2239 | zfiWlanSetKey(dev, keyInfo); | |
2240 | ||
2241 | /* Reset txiv and rxiv */ | |
2242 | wd->sta.rxivGK[0] = ((rxiv[3] >> 24) & 0xFF) | |
2243 | + (((rxiv[3] >> 16) & 0xFF) << 8) | |
2244 | + (((rxiv[3] >> 8) & 0xFF) << 16) | |
2245 | + ((rxiv[3] & 0xFF) << 24); | |
2246 | wd->sta.rxivGK[1] = ((rxiv[2] >> 24) & 0xFF) | |
2247 | + (((rxiv[2] >> 16) & 0xFF) << 8) | |
2248 | + (((rxiv[2] >> 8) & 0xFF) << 16) | |
2249 | + ((rxiv[2] & 0xFF) << 24); | |
2250 | wd->sta.rxivGK[2] = ((rxiv[1] >> 24) & 0xFF) | |
2251 | + (((rxiv[1] >> 16) & 0xFF) << 8) | |
2252 | + (((rxiv[1] >> 8) & 0xFF) << 16) | |
2253 | + ((rxiv[1] & 0xFF) << 24); | |
2254 | wd->sta.rxivGK[3] = ((rxiv[0] >> 24) & 0xFF) | |
2255 | + (((rxiv[0] >> 16) & 0xFF) << 8) | |
2256 | + (((rxiv[0] >> 8) & 0xFF) << 16) | |
2257 | + ((rxiv[0] & 0xFF) << 24); | |
2258 | ||
2259 | wd->sta.authMode = ZM_AUTH_MODE_CENC; | |
2260 | wd->sta.currentAuthMode = ZM_AUTH_MODE_CENC; | |
2261 | ||
2262 | return 0; | |
2263 | } | |
2264 | #endif //ZM_ENABLE_CENC | |
2265 | ||
2266 | u8_t zfiWlanSetDot11DMode(zdev_t* dev, u8_t mode) | |
2267 | { | |
2268 | u8_t i; | |
2269 | ||
2270 | zmw_get_wlan_dev(dev); | |
2271 | ||
2272 | wd->sta.b802_11D = mode; | |
2273 | if (mode) //Enable 802.11d | |
2274 | { | |
2275 | wd->regulationTable.regionCode = NO_ENUMRD; | |
2276 | for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) | |
2277 | wd->regulationTable.allowChannel[i].channelFlags |= ZM_REG_FLAG_CHANNEL_PASSIVE; | |
2278 | } | |
2279 | else //Disable | |
2280 | { | |
2281 | for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) | |
2282 | wd->regulationTable.allowChannel[i].channelFlags &= ~ZM_REG_FLAG_CHANNEL_PASSIVE; | |
2283 | } | |
2284 | ||
2285 | return 0; | |
2286 | } | |
2287 | ||
2288 | u8_t zfiWlanSetDot11HDFSMode(zdev_t* dev, u8_t mode) | |
2289 | { | |
2290 | zmw_get_wlan_dev(dev); | |
2291 | ||
2292 | //zm_debug_msg0("CWY - Enable 802.11h DFS"); | |
2293 | ||
2294 | // TODO : DFS Enable in 5250 to 5350 MHz and 5470 to 5725 MHz . | |
2295 | //if ( Adapter->ZD80211HSupport && | |
2296 | // Adapter->CardSetting.NetworkTypeInUse == Ndis802_11OFDM5 && | |
2297 | // ((ChannelNo >=52 && ChannelNo <= 64) || //5250~5350 MHZ | |
2298 | // (ChannelNo >=100 && ChannelNo <= 140))) //5470~5725 MHZ | |
2299 | //{ | |
2300 | // Adapter->ZD80211HSetting.DFSEnable=TRUE; | |
2301 | //} | |
2302 | //else | |
2303 | //{ | |
2304 | // Adapter->ZD80211HSetting.DFSEnable=FALSE; | |
2305 | //} | |
2306 | ||
2307 | wd->sta.DFSEnable = mode; | |
2308 | if (mode) | |
2309 | wd->sta.capability[1] |= ZM_BIT_0; | |
2310 | else | |
2311 | wd->sta.capability[1] &= (~ZM_BIT_0); | |
2312 | ||
2313 | return 0; | |
2314 | } | |
2315 | ||
2316 | u8_t zfiWlanSetDot11HTPCMode(zdev_t* dev, u8_t mode) | |
2317 | { | |
2318 | zmw_get_wlan_dev(dev); | |
2319 | ||
2320 | // TODO : TPC Enable in 5150~5350 MHz and 5470~5725MHz. | |
2321 | //if ( Adapter->ZD80211HSupport && | |
2322 | // Adapter->CardSetting.NetworkTypeInUse == Ndis802_11OFDM5 && | |
2323 | // ((ChannelNo == 36 || ChannelNo == 40 || ChannelNo == 44 || ChannelNo == 48) || //5150~5250 MHZ , Not Japan | |
2324 | // (ChannelNo >=52 && ChannelNo <= 64) || //5250~5350 MHZ | |
2325 | // (ChannelNo >=100 && ChannelNo <= 140))) //5470~5725 MHZ | |
2326 | //{ | |
2327 | // Adapter->ZD80211HSetting.TPCEnable=TRUE; | |
2328 | //} | |
2329 | //else | |
2330 | //{ | |
2331 | // Adapter->ZD80211HSetting.TPCEnable=FALSE; | |
2332 | //} | |
2333 | ||
2334 | wd->sta.TPCEnable = mode; | |
2335 | if (mode) | |
2336 | wd->sta.capability[1] |= ZM_BIT_0; | |
2337 | else | |
2338 | wd->sta.capability[1] &= (~ZM_BIT_0); | |
2339 | ||
2340 | return 0; | |
2341 | } | |
2342 | ||
2343 | u8_t zfiWlanSetAniMode(zdev_t* dev, u8_t mode) | |
2344 | { | |
2345 | zmw_get_wlan_dev(dev); | |
2346 | ||
2347 | wd->aniEnable = mode; | |
2348 | if (mode) | |
2349 | zfHpAniAttach(dev); | |
2350 | ||
2351 | return 0; | |
2352 | } | |
2353 | ||
2354 | #ifdef ZM_OS_LINUX_FUNC | |
2355 | void zfiWlanShowTally(zdev_t* dev) | |
2356 | { | |
2357 | zmw_get_wlan_dev(dev); | |
2358 | ||
2359 | zm_msg1_mm(ZM_LV_0, "Hw_UnderrunCnt = ", wd->commTally.Hw_UnderrunCnt); | |
2360 | zm_msg1_mm(ZM_LV_0, "Hw_TotalRxFrm = ", wd->commTally.Hw_TotalRxFrm); | |
2361 | zm_msg1_mm(ZM_LV_0, "Hw_CRC32Cnt = ", wd->commTally.Hw_CRC32Cnt); | |
2362 | zm_msg1_mm(ZM_LV_0, "Hw_CRC16Cnt = ", wd->commTally.Hw_CRC16Cnt); | |
2363 | zm_msg1_mm(ZM_LV_1, "Hw_DecrypErr_UNI = ", wd->commTally.Hw_DecrypErr_UNI); | |
2364 | zm_msg1_mm(ZM_LV_0, "Hw_RxFIFOOverrun = ", wd->commTally.Hw_RxFIFOOverrun); | |
2365 | zm_msg1_mm(ZM_LV_1, "Hw_DecrypErr_Mul = ", wd->commTally.Hw_DecrypErr_Mul); | |
2366 | zm_msg1_mm(ZM_LV_1, "Hw_RetryCnt = ", wd->commTally.Hw_RetryCnt); | |
2367 | zm_msg1_mm(ZM_LV_0, "Hw_TotalTxFrm = ", wd->commTally.Hw_TotalTxFrm); | |
2368 | zm_msg1_mm(ZM_LV_0, "Hw_RxTimeOut = ", wd->commTally.Hw_RxTimeOut); | |
2369 | zm_msg1_mm(ZM_LV_0, "Tx_MPDU = ", wd->commTally.Tx_MPDU); | |
2370 | zm_msg1_mm(ZM_LV_0, "BA_Fail = ", wd->commTally.BA_Fail); | |
2371 | zm_msg1_mm(ZM_LV_0, "Hw_Tx_AMPDU = ", wd->commTally.Hw_Tx_AMPDU); | |
2372 | zm_msg1_mm(ZM_LV_0, "Hw_Tx_MPDU = ", wd->commTally.Hw_Tx_MPDU); | |
2373 | ||
2374 | zm_msg1_mm(ZM_LV_1, "Hw_RxMPDU = ", wd->commTally.Hw_RxMPDU); | |
2375 | zm_msg1_mm(ZM_LV_1, "Hw_RxDropMPDU = ", wd->commTally.Hw_RxDropMPDU); | |
2376 | zm_msg1_mm(ZM_LV_1, "Hw_RxDelMPDU = ", wd->commTally.Hw_RxDelMPDU); | |
2377 | zm_msg1_mm(ZM_LV_1, "Hw_RxPhyMiscError = ", wd->commTally.Hw_RxPhyMiscError); | |
2378 | zm_msg1_mm(ZM_LV_1, "Hw_RxPhyXRError = ", wd->commTally.Hw_RxPhyXRError); | |
2379 | zm_msg1_mm(ZM_LV_1, "Hw_RxPhyOFDMError = ", wd->commTally.Hw_RxPhyOFDMError); | |
2380 | zm_msg1_mm(ZM_LV_1, "Hw_RxPhyCCKError = ", wd->commTally.Hw_RxPhyCCKError); | |
2381 | zm_msg1_mm(ZM_LV_1, "Hw_RxPhyHTError = ", wd->commTally.Hw_RxPhyHTError); | |
2382 | zm_msg1_mm(ZM_LV_1, "Hw_RxPhyTotalCount = ", wd->commTally.Hw_RxPhyTotalCount); | |
2383 | ||
2384 | if (!((wd->commTally.Tx_MPDU == 0) && (wd->commTally.BA_Fail == 0))) | |
2385 | { | |
2386 | zm_debug_msg_p("BA Fail Ratio(%) = ", wd->commTally.BA_Fail * 100, | |
2387 | (wd->commTally.BA_Fail + wd->commTally.Tx_MPDU)); | |
2388 | } | |
2389 | ||
2390 | if (!((wd->commTally.Hw_Tx_MPDU == 0) && (wd->commTally.Hw_Tx_AMPDU == 0))) | |
2391 | { | |
2392 | zm_debug_msg_p("Avg Agg Number = ", | |
2393 | wd->commTally.Hw_Tx_MPDU, wd->commTally.Hw_Tx_AMPDU); | |
2394 | } | |
2395 | } | |
2396 | #endif | |
2397 | ||
2398 | void zfiWlanSetMaxTxPower(zdev_t* dev, u8_t power2, u8_t power5) | |
2399 | { | |
2400 | zmw_get_wlan_dev(dev); | |
2401 | ||
2402 | zmw_declare_for_critical_section(); | |
2403 | ||
2404 | zmw_enter_critical_section(dev); | |
2405 | wd->maxTxPower2 = power2; | |
2406 | wd->maxTxPower5 = power5; | |
2407 | zmw_leave_critical_section(dev); | |
2408 | } | |
2409 | ||
2410 | void zfiWlanQueryMaxTxPower(zdev_t* dev, u8_t *power2, u8_t *power5) | |
2411 | { | |
2412 | zmw_get_wlan_dev(dev); | |
2413 | ||
2414 | *power2 = wd->maxTxPower2; | |
2415 | *power5 = wd->maxTxPower5; | |
2416 | } | |
2417 | ||
2418 | void zfiWlanSetConnectMode(zdev_t* dev, u8_t mode) | |
2419 | { | |
2420 | zmw_get_wlan_dev(dev); | |
2421 | ||
2422 | zmw_declare_for_critical_section(); | |
2423 | ||
2424 | zmw_enter_critical_section(dev); | |
2425 | wd->connectMode = mode; | |
2426 | zmw_leave_critical_section(dev); | |
2427 | } | |
2428 | ||
2429 | void zfiWlanSetSupportMode(zdev_t* dev, u32_t mode) | |
2430 | { | |
2431 | zmw_get_wlan_dev(dev); | |
2432 | ||
2433 | zmw_declare_for_critical_section(); | |
2434 | ||
2435 | zmw_enter_critical_section(dev); | |
2436 | wd->supportMode = mode; | |
2437 | zmw_leave_critical_section(dev); | |
2438 | } | |
2439 | ||
2440 | void zfiWlanSetAdhocMode(zdev_t* dev, u32_t mode) | |
2441 | { | |
2442 | zmw_get_wlan_dev(dev); | |
2443 | ||
2444 | wd->ws.adhocMode = mode; | |
2445 | } | |
2446 | ||
2447 | u32_t zfiWlanQueryAdhocMode(zdev_t* dev, u8_t bWrapper) | |
2448 | { | |
2449 | u32_t adhocMode; | |
2450 | ||
2451 | zmw_get_wlan_dev(dev); | |
2452 | ||
2453 | if ( bWrapper ) | |
2454 | { | |
2455 | adhocMode = wd->ws.adhocMode; | |
2456 | } | |
2457 | else | |
2458 | { | |
2459 | adhocMode = wd->wfc.bIbssGMode; | |
2460 | } | |
2461 | ||
2462 | return adhocMode; | |
2463 | } | |
2464 | ||
2465 | ||
2466 | u8_t zfiWlanSetCountryIsoName(zdev_t* dev, u8_t *countryIsoName, u8_t length) | |
2467 | { | |
2468 | u8_t buf[5]; | |
2469 | zmw_get_wlan_dev(dev); | |
2470 | ||
2471 | if (length == 4) | |
2472 | { | |
2473 | buf[2] = wd->ws.countryIsoName[0] = countryIsoName[2]; | |
2474 | buf[3] = wd->ws.countryIsoName[1] = countryIsoName[1]; | |
2475 | buf[4] = wd->ws.countryIsoName[2] = countryIsoName[0]; | |
2476 | } | |
2477 | else if (length == 3) | |
2478 | { | |
2479 | buf[2] = wd->ws.countryIsoName[0] = countryIsoName[1]; | |
2480 | buf[3] = wd->ws.countryIsoName[1] = countryIsoName[0]; | |
2481 | buf[4] = wd->ws.countryIsoName[2] = '\0'; | |
2482 | } | |
2483 | else | |
2484 | { | |
2485 | return 1; | |
2486 | } | |
2487 | ||
2488 | return zfHpGetRegulationTablefromISO(dev, buf, length); | |
2489 | } | |
2490 | ||
2491 | ||
2492 | const char* zfiWlanQueryCountryIsoName(zdev_t* dev) | |
2493 | { | |
2494 | zmw_get_wlan_dev(dev); | |
2495 | ||
2496 | return wd->ws.countryIsoName; | |
2497 | } | |
2498 | ||
2499 | ||
2500 | ||
2501 | void zfiWlanSetRegulatory(zdev_t* dev, u8_t CCS, u16_t Code, u8_t bfirstChannel) | |
2502 | { | |
2503 | zmw_get_wlan_dev(dev); | |
2504 | ||
2505 | zmw_declare_for_critical_section(); | |
2506 | ||
2507 | if (CCS) | |
2508 | { | |
2509 | /* Reset Regulation Table by Country Code */ | |
2510 | zfHpGetRegulationTablefromCountry(dev, Code); | |
2511 | } | |
2512 | else | |
2513 | { | |
2514 | /* Reset Regulation Table by Region Code */ | |
2515 | zfHpGetRegulationTablefromRegionCode(dev, Code); | |
2516 | } | |
2517 | ||
2518 | if (bfirstChannel) { | |
2519 | zmw_enter_critical_section(dev); | |
2520 | wd->frequency = zfChGetFirstChannel(dev, NULL); | |
2521 | zmw_leave_critical_section(dev); | |
2522 | zfCoreSetFrequency(dev, wd->frequency); | |
2523 | } | |
2524 | } | |
2525 | ||
2526 | ||
2527 | const char* zfiHpGetisoNamefromregionCode(zdev_t* dev, u16_t regionCode) | |
2528 | { | |
2529 | return zfHpGetisoNamefromregionCode(dev, regionCode); | |
2530 | } | |
2531 | ||
2532 | u16_t zfiWlanChannelToFrequency(zdev_t* dev, u8_t channel) | |
2533 | { | |
2534 | return zfChNumToFreq(dev, channel, 0); | |
2535 | } | |
2536 | ||
2537 | u8_t zfiWlanFrequencyToChannel(zdev_t* dev, u16_t freq) | |
2538 | { | |
2539 | u8_t is5GBand = 0; | |
2540 | ||
2541 | return zfChFreqToNum(freq, &is5GBand); | |
2542 | } | |
2543 | ||
2544 | void zfiWlanDisableDfsChannel(zdev_t* dev, u8_t disableFlag) | |
2545 | { | |
2546 | zfHpDisableDfsChannel(dev, disableFlag); | |
2547 | return; | |
2548 | } | |
2549 | ||
2550 | void zfiWlanSetLEDCtrlParam(zdev_t* dev, u8_t type, u8_t flag) | |
2551 | { | |
2552 | zmw_get_wlan_dev(dev); | |
2553 | ||
2554 | zmw_declare_for_critical_section(); | |
2555 | ||
2556 | zmw_enter_critical_section(dev); | |
2557 | wd->ledStruct.LEDCtrlType = type; | |
2558 | wd->ledStruct.LEDCtrlFlagFromReg = flag; | |
2559 | zmw_leave_critical_section(dev); | |
2560 | } | |
2561 | ||
2562 | void zfiWlanEnableLeapConfig(zdev_t* dev, u8_t leapEnabled) | |
2563 | { | |
2564 | zmw_get_wlan_dev(dev); | |
2565 | ||
2566 | wd->sta.leapEnabled = leapEnabled; | |
2567 | } | |
2568 | ||
2569 | u32_t zfiWlanQueryHwCapability(zdev_t* dev) | |
2570 | { | |
2571 | return zfHpCapability(dev); | |
2572 | } | |
2573 | ||
2574 | u32_t zfiWlanQueryReceivedPacket(zdev_t* dev) | |
2575 | { | |
2576 | zmw_get_wlan_dev(dev); | |
2577 | ||
2578 | return wd->sta.ReceivedPktRatePerSecond; | |
2579 | } | |
2580 | ||
2581 | void zfiWlanCheckSWEncryption(zdev_t* dev) | |
2582 | { | |
2583 | zmw_get_wlan_dev(dev); | |
2584 | ||
2585 | if (wd->sta.SWEncryptEnable != 0) | |
2586 | { | |
2587 | zfHpSWDecrypt(dev, 1); | |
2588 | } | |
2589 | } | |
2590 | ||
2591 | u16_t zfiWlanQueryAllowChannels(zdev_t* dev, u16_t *channels) | |
2592 | { | |
2593 | u16_t ii; | |
2594 | zmw_get_wlan_dev(dev); | |
2595 | ||
2596 | for (ii = 0; ii < wd->regulationTable.allowChannelCnt; ii++) | |
2597 | { | |
2598 | channels[ii] = wd->regulationTable.allowChannel[ii].channel; | |
2599 | } | |
2600 | ||
2601 | return wd->regulationTable.allowChannelCnt; | |
2602 | } | |
2603 | ||
2604 | void zfiWlanSetDynamicSIFSParam(zdev_t* dev, u8_t val) | |
2605 | { | |
2606 | zmw_get_wlan_dev(dev); | |
2607 | ||
2608 | wd->dynamicSIFSEnable = val; | |
2609 | ||
2610 | zm_debug_msg1("wd->dynamicSIFSEnable = ", wd->dynamicSIFSEnable) | |
2611 | } | |
2612 | ||
2613 | u16_t zfiWlanGetMulticastAddressCount(zdev_t* dev) | |
2614 | { | |
2615 | zmw_get_wlan_dev(dev); | |
2616 | ||
2617 | return wd->sta.multicastList.size; | |
2618 | } | |
2619 | ||
2620 | void zfiWlanGetMulticastList(zdev_t* dev, u8_t* pMCList) | |
2621 | { | |
2622 | struct zsMulticastAddr* pMacList = (struct zsMulticastAddr*) pMCList; | |
2623 | u8_t i; | |
2624 | ||
2625 | zmw_get_wlan_dev(dev); | |
2626 | ||
2627 | for ( i=0; i<wd->sta.multicastList.size; i++ ) | |
2628 | { | |
2629 | zfMemoryCopy(pMacList[i].addr, wd->sta.multicastList.macAddr[i].addr, 6); | |
2630 | } | |
2631 | } | |
2632 | ||
2633 | void zfiWlanSetPacketFilter(zdev_t* dev, u32_t PacketFilter) | |
2634 | { | |
2635 | u8_t bAllMulticast = 0; | |
2636 | u32_t oldFilter; | |
2637 | ||
2638 | zmw_get_wlan_dev(dev); | |
2639 | ||
2640 | oldFilter = wd->sta.osRxFilter; | |
2641 | ||
2642 | wd->sta.osRxFilter = PacketFilter; | |
2643 | ||
2644 | if ((oldFilter & ZM_PACKET_TYPE_ALL_MULTICAST) != | |
2645 | (wd->sta.osRxFilter & ZM_PACKET_TYPE_ALL_MULTICAST)) | |
2646 | { | |
2647 | if ( wd->sta.osRxFilter & ZM_PACKET_TYPE_ALL_MULTICAST ) | |
2648 | bAllMulticast = 1; | |
2649 | zfHpSetMulticastList(dev, wd->sta.multicastList.size, | |
2650 | (u8_t*)wd->sta.multicastList.macAddr, bAllMulticast); | |
2651 | } | |
2652 | } | |
2653 | ||
2654 | u8_t zfiCompareWithMulticastListAddress(zdev_t* dev, u16_t* dstMacAddr) | |
2655 | { | |
2656 | u8_t i; | |
2657 | u8_t bIsInMCListAddr = 0; | |
2658 | ||
2659 | zmw_get_wlan_dev(dev); | |
2660 | ||
2661 | for ( i=0; i<wd->sta.multicastList.size; i++ ) | |
2662 | { | |
2663 | if ( zfwMemoryIsEqual((u8_t*)dstMacAddr, (u8_t*)wd->sta.multicastList.macAddr[i].addr, 6) ) | |
2664 | { | |
2665 | bIsInMCListAddr = 1; | |
2666 | break; | |
2667 | } | |
2668 | } | |
2669 | ||
2670 | return bIsInMCListAddr; | |
2671 | } | |
2672 | ||
2673 | void zfiWlanSetSafeModeEnabled(zdev_t* dev, u8_t safeMode) | |
2674 | { | |
2675 | zmw_get_wlan_dev(dev); | |
2676 | ||
2677 | wd->sta.bSafeMode = safeMode; | |
2678 | ||
2679 | if ( safeMode ) | |
2680 | zfStaEnableSWEncryption(dev, 1); | |
2681 | else | |
2682 | zfStaDisableSWEncryption(dev); | |
2683 | } | |
2684 | ||
2685 | void zfiWlanSetIBSSAdditionalIELength(zdev_t* dev, u32_t ibssAdditionalIESize, u8_t* ibssAdditionalIE) | |
2686 | { | |
2687 | zmw_get_wlan_dev(dev); | |
2688 | ||
2689 | if ( ibssAdditionalIESize ) | |
2690 | { | |
2691 | wd->sta.ibssAdditionalIESize = ibssAdditionalIESize; | |
2692 | zfMemoryCopy(wd->sta.ibssAdditionalIE, ibssAdditionalIE, (u16_t)ibssAdditionalIESize); | |
2693 | } | |
2694 | else | |
2695 | wd->sta.ibssAdditionalIESize = 0; | |
2696 | } |