2 * Copyright (c) 2007-2008 Atheros Communications Inc.
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.
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.
17 /* Module Name : iod.c */
20 /* This module contains OID functions. */
25 /************************************************************************/
27 #include "../hal/hpreg.h"
29 /************************************************************************/
31 /* FUNCTION DESCRIPTION zfiWlanQueryMacAddress */
32 /* Query OWN MAC address. */
35 /* addr : for return MAC address */
41 /* Stephen Chen ZyDAS Technology Corporation 2005.10 */
43 /************************************************************************/
44 void zfiWlanQueryMacAddress(zdev_t
* dev
, u8_t
* addr
)
47 zmw_get_wlan_dev(dev
);
49 vapId
= zfwGetVapId(dev
);
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);
57 addr
[5] = (u8_t
)(wd
->macAddr
[2] >> 8);
60 #ifdef ZM_VAPMODE_MULTILE_SSID
61 addr
[5] = (u8_t
)(wd
->macAddr
[2] >> 8); // Multiple SSID
63 addr
[5] = vapId
+ 1 + (u8_t
)(wd
->macAddr
[2] >> 8); //VAP
70 void zfiWlanQueryBssList(zdev_t
* dev
, struct zsBssList
* pBssList
)
72 struct zsBssInfo
* pBssInfo
;
73 struct zsBssInfo
* pDstBssInfo
;
78 zmw_get_wlan_dev(dev
);
80 zmw_declare_for_critical_section();
82 pMemList
= (u8_t
*) pBssList
;
83 pMemInfo
= pMemList
+ sizeof(struct zsBssList
);
84 pBssList
->head
= (struct zsBssInfo
*) pMemInfo
;
86 zmw_enter_critical_section(dev
);
88 pBssInfo
= wd
->sta
.bssList
.head
;
89 pDstBssInfo
= (struct zsBssInfo
*) pMemInfo
;
90 pBssList
->bssCount
= wd
->sta
.bssList
.bssCount
;
92 for( i
=0; i
<wd
->sta
.bssList
.bssCount
; i
++ )
94 zfMemoryCopy((u8_t
*)pDstBssInfo
, (u8_t
*)pBssInfo
,
95 sizeof(struct zsBssInfo
));
97 if ( pBssInfo
->next
!= NULL
)
99 pBssInfo
= pBssInfo
->next
;
100 pDstBssInfo
->next
= pDstBssInfo
+ 1;
105 zm_assert(i
==(wd
->sta
.bssList
.bssCount
-1));
109 zmw_leave_critical_section(dev
);
111 zfScanMgrScanAck(dev
);
114 void zfiWlanQueryBssListV1(zdev_t
* dev
, struct zsBssListV1
* bssListV1
)
116 struct zsBssInfo
* pBssInfo
;
117 //struct zsBssInfo* pDstBssInfo;
118 u8_t i
, j
, bdrop
= 0, k
= 0, Same_Count
= 0;
122 zmw_get_wlan_dev(dev
);
123 zmw_declare_for_critical_section();
125 zmw_enter_critical_section(dev
);
127 bssListV1
->bssCount
= wd
->sta
.bssList
.bssCount
;
129 pBssInfo
= wd
->sta
.bssList
.head
;
130 ZM_MAC_WORD_TO_BYTE(wd
->sta
.bssid
, bssid
);
132 for( i
=0; i
<wd
->sta
.bssList
.bssCount
; i
++ )
135 if ( zfStaIsConnected(dev
)
136 && (wd
->wlanMode
== ZM_MODE_INFRASTRUCTURE
) )
138 for (j
= 0; j
< 6; j
++)
140 if ( pBssInfo
->bssid
[j
] != bssid
[j
] )
147 &&((pBssInfo
->ssid
[1] == wd
->sta
.ssidLen
) || (pBssInfo
->ssid
[1] == 0) )&& (pBssInfo
->frequency
== wd
->frequency
) )
149 if(pBssInfo
->ssid
[1] == 0)
150 pBssInfo
->ssid
[1] = wd
->sta
.ssidLen
;
159 bssListV1
->bssCount
--;
167 zfMemoryCopy((u8_t
*)(&bssListV1
->bssInfo
[k
]), (u8_t
*)pBssInfo
,
168 sizeof(struct zsBssInfo
));
172 zfMemoryCopy(&(bssListV1
->bssInfo
[k
].ssid
[2]), wd
->sta
.ssid
, wd
->sta
.ssidLen
);
179 if ( pBssInfo
->next
!= NULL
)
181 pBssInfo
= pBssInfo
->next
;
185 zm_assert(i
==(wd
->sta
.bssList
.bssCount
-1));
189 zmw_leave_critical_section(dev
);
191 zfScanMgrScanAck(dev
);
194 void zfiWlanQueryAdHocCreatedBssDesc(zdev_t
* dev
, struct zsBssInfo
*pBssInfo
)
196 zmw_get_wlan_dev(dev
);
198 zfMemoryCopy((u8_t
*)pBssInfo
, (u8_t
*)&wd
->sta
.ibssBssDesc
, sizeof(struct zsBssInfo
));
201 u8_t
zfiWlanQueryAdHocIsCreator(zdev_t
* dev
)
203 zmw_get_wlan_dev(dev
);
205 return wd
->sta
.ibssBssIsCreator
;
208 u32_t
zfiWlanQuerySupportMode(zdev_t
* dev
)
210 zmw_get_wlan_dev(dev
);
212 return wd
->supportMode
;
215 u32_t
zfiWlanQueryTransmitPower(zdev_t
* dev
)
219 zmw_get_wlan_dev(dev
);
221 if (zfStaIsConnected(dev
)) {
222 ret
= wd
->sta
.connPowerInHalfDbm
;
224 ret
= zfHpGetTransmitPower(dev
);
230 /************************************************************************/
232 /* FUNCTION DESCRIPTION zfiWlanFlushBssList */
233 /* Flush BSSID List. */
236 /* dev : device pointer */
242 /* Stephen Chen Atheros Communications, INC. 2006.12 */
244 /************************************************************************/
245 void zfiWlanFlushBssList(zdev_t
* dev
)
247 zmw_declare_for_critical_section();
249 zmw_enter_critical_section(dev
);
250 /* Call zfBssInfoRefresh() twice to remove all entry */
251 zfBssInfoRefresh(dev
, 1);
252 zmw_leave_critical_section(dev
);
255 void zfiWlanSetWlanMode(zdev_t
* dev
, u8_t wlanMode
)
257 zmw_get_wlan_dev(dev
);
259 zmw_declare_for_critical_section();
261 zmw_enter_critical_section(dev
);
262 wd
->ws
.wlanMode
= wlanMode
;
263 zmw_leave_critical_section(dev
);
266 void zfiWlanSetAuthenticationMode(zdev_t
* dev
, u8_t authMode
)
268 zmw_get_wlan_dev(dev
);
270 zmw_declare_for_critical_section();
272 zmw_enter_critical_section(dev
);
273 wd
->ws
.authMode
= authMode
;
274 zmw_leave_critical_section(dev
);
277 void zfiWlanSetWepStatus(zdev_t
* dev
, u8_t wepStatus
)
279 zmw_get_wlan_dev(dev
);
281 zmw_declare_for_critical_section();
283 zmw_enter_critical_section(dev
);
284 wd
->ws
.wepStatus
= wepStatus
;
285 zmw_leave_critical_section(dev
);
289 void zfiWlanSetSSID(zdev_t
* dev
, u8_t
* ssid
, u8_t ssidLength
)
292 zmw_get_wlan_dev(dev
);
294 zmw_declare_for_critical_section();
296 if ( ssidLength
<= 32 )
298 zmw_enter_critical_section(dev
);
300 wd
->ws
.ssidLen
= ssidLength
;
301 zfMemoryCopy(wd
->ws
.ssid
, ssid
, ssidLength
);
303 if ( ssidLength
< 32 )
305 wd
->ws
.ssid
[ssidLength
] = 0;
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
++)
312 wd
->ws
.probingSsidList
[i
].ssidLen
= 0;
315 zmw_leave_critical_section(dev
);
319 void zfiWlanSetFragThreshold(zdev_t
* dev
, u16_t fragThreshold
)
321 zmw_get_wlan_dev(dev
);
323 zmw_declare_for_critical_section();
325 zmw_enter_critical_section(dev
);
327 if (fragThreshold
== 0)
328 { /* fragmentation is disabled */
329 wd
->fragThreshold
= 32767;
331 else if (fragThreshold
< 256)
333 /* Minimum fragment threshold */
334 wd
->fragThreshold
= 256;
336 else if (fragThreshold
> 2346)
338 wd
->fragThreshold
= 2346;
342 wd
->fragThreshold
= fragThreshold
& 0xfffe;
345 zmw_leave_critical_section(dev
);
348 void zfiWlanSetRtsThreshold(zdev_t
* dev
, u16_t rtsThreshold
)
350 zmw_get_wlan_dev(dev
);
352 zmw_declare_for_critical_section();
354 zmw_enter_critical_section(dev
);
355 wd
->rtsThreshold
= rtsThreshold
;
356 zmw_leave_critical_section(dev
);
359 void zfiWlanSetFrequency(zdev_t
* dev
, u32_t frequency
, u8_t bImmediate
)
361 zmw_get_wlan_dev(dev
);
363 zmw_declare_for_critical_section();
367 zmw_enter_critical_section(dev
);
368 wd
->frequency
= (u16_t
) (frequency
/1000);
369 zmw_leave_critical_section(dev
);
370 zfCoreSetFrequency(dev
, wd
->frequency
);
374 zmw_enter_critical_section(dev
);
376 { // Auto select clean channel depend on wireless environment !
377 wd
->ws
.autoSetFrequency
= 0;
379 wd
->ws
.frequency
= (u16_t
) (frequency
/1000);
380 zmw_leave_critical_section(dev
);
384 void zfiWlanSetBssid(zdev_t
* dev
, u8_t
* bssid
)
387 zmw_get_wlan_dev(dev
);
389 zmw_declare_for_critical_section();
391 zmw_enter_critical_section(dev
);
394 wd
->ws
.desiredBssid
[i
] = bssid
[i
];
396 wd
->ws
.bDesiredBssid
= TRUE
;
397 zmw_leave_critical_section(dev
);
401 void zfiWlanSetBeaconInterval(zdev_t
* dev
,
402 u16_t beaconInterval
,
405 zmw_get_wlan_dev(dev
);
407 zmw_declare_for_critical_section();
411 zmw_enter_critical_section(dev
);
412 wd
->beaconInterval
= beaconInterval
;
413 zmw_leave_critical_section(dev
);
415 /* update beacon interval here */
419 zmw_enter_critical_section(dev
);
420 wd
->ws
.beaconInterval
= beaconInterval
;
421 zmw_leave_critical_section(dev
);
426 void zfiWlanSetDtimCount(zdev_t
* dev
, u8_t dtim
)
428 zmw_get_wlan_dev(dev
);
430 zmw_declare_for_critical_section();
432 zmw_enter_critical_section(dev
);
437 zmw_leave_critical_section(dev
);
441 void zfiWlanSetAtimWindow(zdev_t
* dev
, u16_t atimWindow
, u8_t bImmediate
)
443 zmw_get_wlan_dev(dev
);
445 zmw_declare_for_critical_section();
449 zmw_enter_critical_section(dev
);
450 wd
->sta
.atimWindow
= atimWindow
;
451 zmw_leave_critical_section(dev
);
453 /* atim window here */
457 zmw_enter_critical_section(dev
);
458 wd
->ws
.atimWindow
= atimWindow
;
459 zmw_leave_critical_section(dev
);
464 void zfiWlanSetEncryMode(zdev_t
* dev
, u8_t encryMode
)
466 zmw_get_wlan_dev(dev
);
468 zmw_declare_for_critical_section();
470 zmw_enter_critical_section(dev
);
471 if (wd
->wlanMode
== ZM_MODE_AP
)
474 if ((wd
->ws
.encryMode
!= ZM_AES
) && (wd
->ws
.encryMode
!= ZM_TKIP
))
475 wd
->ws
.encryMode
= encryMode
;
478 wd
->ws
.encryMode
= encryMode
;
479 zmw_leave_critical_section(dev
);
482 void zfiWlanSetDefaultKeyId(zdev_t
* dev
, u8_t keyId
)
484 zmw_get_wlan_dev(dev
);
486 wd
->sta
.keyId
= keyId
;
489 u8_t
zfiWlanQueryIsPKInstalled(zdev_t
*dev
, u8_t
*staMacAddr
)
491 u8_t isInstalled
= 0;
494 //#ifdef ZM_ENABLE_IBSS_WPA2PSK
497 zmw_get_wlan_dev(dev
);
499 zmw_declare_for_critical_section();
501 zmw_enter_critical_section(dev
);
502 res
= zfStaFindOppositeByMACAddr(dev
, (u16_t
*)staMacAddr
, &peerIdx
);
505 isInstalled
= wd
->sta
.oppositeInfo
[peerIdx
].pkInstalled
;
507 zmw_leave_critical_section(dev
);
514 u8_t
zfiWlanSetKey(zdev_t
* dev
, struct zsKeyInfo keyInfo
)
516 u16_t broadcast
[3] = {0xffff, 0xffff, 0xffff};
518 u8_t encryMode
= ZM_NO_WEP
;
519 #ifdef ZM_ENABLE_IBSS_WPA2PSK
520 u8_t encryType
= ZM_NO_WEP
;
524 u8_t vapId
, i
, addr
[6];
527 #ifdef ZM_ENABLE_IBSS_WPA2PSK
528 /* Determine opposite exist or not */
532 zmw_get_wlan_dev(dev
);
534 if ( wd
->sta
.ibssWpa2Psk
== 1 )
536 zmw_enter_critical_section(dev
);
537 res
= zfStaFindOppositeByMACAddr(dev
, (u16_t
*)keyInfo
.macAddr
, &peerIdx
);
541 if ( wd
->sta
.oppositeInfo
[userIdx
].camIdx
== 0xff )
542 wd
->sta
.oppositeInfo
[userIdx
].camIdx
= userIdx
;
544 zmw_leave_critical_section(dev
);
547 zmw_get_wlan_dev(dev
);
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
)
555 /* Find STA's information */
556 id
= zfApFindSta(dev
, keyInfo
.macAddr
);
559 /* Can't STA in the staTable */
560 return ZM_STATUS_FAILURE
;
563 wd
->ap
.staTable
[id
].iv16
= 0;
564 wd
->ap
.staTable
[id
].iv32
= 0;
566 if (keyInfo
.keyLength
== 32)
568 //u8_t KeyRsc[6] = {0, 0, 0, 0, 0, 0};
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
)
578 zm_debug_msg0("Set CENC pairwise Key");
580 wd
->ap
.staTable
[id
].encryMode
= ZM_CENC
;
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;
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;
594 wd
->ap
.staTable
[id
].cencKeyIdx
= keyInfo
.keyIndex
;
596 //zfCoreSetKey(dev, id+1, 1, ZM_CENC, (u16_t *)keyInfo.macAddr,
597 // (u32_t*) &keyInfo.key[16]);
600 #endif //ZM_ENABLE_CENC
602 wd
->ap
.staTable
[id
].encryMode
= ZM_TKIP
;
604 zfMemoryCopy(micKey
, &keyInfo
.key
[16], 8);
605 zfMemoryCopy(&micKey
[8], &keyInfo
.key
[24], 8);
607 //zfCoreSetKey(dev, id+1, 1, ZM_TKIP, (u16_t *)keyInfo.macAddr,
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);
616 else if (keyInfo
.keyLength
== 16)
618 wd
->ap
.staTable
[id
].encryMode
= ZM_AES
;
620 else if (keyInfo
.keyLength
== 0)
623 zfApClearStaKey(dev
, (u16_t
*)keyInfo
.macAddr
);
625 return ZM_STATUS_SUCCESS
;
629 return ZM_STATUS_FAILURE
;
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;
639 else if (keyInfo
.flag
& ZM_KEY_FLAG_GK
)
641 vapId
= keyInfo
.vapId
;
643 wd
->ap
.iv16
[vapId
] = 0;
644 wd
->ap
.iv32
[vapId
] = 0;
646 if (keyInfo
.keyLength
== 32)
648 //u8_t KeyRsc[6] = {0, 0, 0, 0, 0, 0};
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
)
656 zm_debug_msg0("Set CENC group Key");
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;
664 //zfCoreSetKey(dev, 0, 1, ZM_CENC, keyInfo.vapAddr,
665 // (u32_t*) &keyInfo.key[16]);
666 key
= (u32_t
*) keyInfo
.key
;
669 #endif //ZM_ENABLE_CENC
672 key
= (u32_t
*)keyInfo
.key
;
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]));
680 zfMicSetKey(&(keyInfo
.key
[16]), &(wd
->ap
.bcMicKey
[0]));
681 key
= (u32_t
*) keyInfo
.key
;
684 else if (keyInfo
.keyLength
== 16)
687 key
= (u32_t
*)keyInfo
.key
;
688 zm_debug_msg0("CWY - Set AES Group Key");
690 else if (keyInfo
.keyLength
== 0)
693 zfApClearStaKey(dev
, broadcast
);
695 /* Turn off WEP bit in the capability field */
696 wd
->ap
.capab
[vapId
] &= 0xffef;
698 return ZM_STATUS_SUCCESS
;
702 if (keyInfo
.keyLength
== 5)
704 encryMode
= ZM_WEP64
;
706 else if (keyInfo
.keyLength
== 13)
708 encryMode
= ZM_WEP128
;
710 else if (keyInfo
.keyLength
== 29)
712 encryMode
= ZM_WEP256
;
715 key
= (u32_t
*) keyInfo
.key
;
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
);
725 //zfiWlanSetEncryMode(dev, encryMode);
726 wd
->ws
.encryMode
= encryMode
;
728 /* set the multicast address encryption type */
729 wd
->ap
.encryMode
[vapId
] = encryMode
;
731 /* set the multicast key index */
732 wd
->ap
.bcKeyIndex
[vapId
] = keyInfo
.keyIndex
;
733 wd
->ap
.bcHalKeyIdx
[vapId
] = vapId
+ 60;
735 /* Turn on WEP bit in the capability field */
736 wd
->ap
.capab
[vapId
] |= 0x10;
740 { /* set by supplicant */
742 if ( keyInfo
.flag
& ZM_KEY_FLAG_PK
)
743 { /* set pairwise key */
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);
750 #ifdef ZM_ENABLE_IBSS_WPA2PSK
751 if ( wd
->sta
.ibssWpa2Psk
== 1 )
753 /* unicast -- > pairwise key */
754 wd
->sta
.oppositeInfo
[userIdx
].iv16
= 0;
755 wd
->sta
.oppositeInfo
[userIdx
].iv32
= 0;
763 wd
->sta
.oppositeInfo
[userIdx
].pkInstalled
= 1;
768 wd
->sta
.oppositeInfo
[userIdx
].pkInstalled
= 1;
771 if ( keyInfo
.keyLength
== 32 )
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
);
778 #ifdef ZM_ENABLE_CENC
779 if (keyInfo
.flag
& ZM_KEY_FLAG_CENC
)
781 zm_debug_msg0("Set CENC pairwise Key");
783 wd
->sta
.encryMode
= ZM_CENC
;
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;
791 wd
->sta
.rxiv
[0] = 0x5c365c37;
792 wd
->sta
.rxiv
[1] = 0x5c365c36;
793 wd
->sta
.rxiv
[2] = 0x5c365c36;
794 wd
->sta
.rxiv
[3] = 0x5c365c36;
797 wd
->sta
.cencKeyId
= keyInfo
.keyIndex
;
799 //zfCoreSetKey(dev, id+1, 1, ZM_CENC, (u16_t *)keyInfo.macAddr,
800 // (u32_t*) &keyInfo.key[16]);
803 #endif //ZM_ENABLE_CENC
805 wd
->sta
.encryMode
= ZM_TKIP
;
807 //zfCoreSetKey(dev, 0, 1, ZM_TKIP, wd->sta.bssid,
808 // (u32_t*) &keyInfo.key[16]);
810 zfMicSetKey(&keyInfo
.key
[16], &wd
->sta
.txMicKey
);
811 zfMicSetKey(&keyInfo
.key
[24],
812 &wd
->sta
.rxMicKey
[keyInfo
.keyIndex
]);
815 else if ( keyInfo
.keyLength
== 16 )
817 #ifdef ZM_ENABLE_IBSS_WPA2PSK
818 if ( wd
->sta
.ibssWpa2Psk
== 1 )
820 wd
->sta
.oppositeInfo
[userIdx
].encryMode
= ZM_AES
;
821 encryType
= wd
->sta
.oppositeInfo
[userIdx
].encryMode
;
825 wd
->sta
.encryMode
= ZM_AES
;
826 encryType
= wd
->sta
.encryMode
;
829 wd
->sta
.encryMode
= ZM_AES
;
834 return ZM_STATUS_FAILURE
;
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]);
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
,
848 keyInfo
.keyIndex
, // key id == 0 ( Pairwise key = 0 )
849 (u8_t
*)keyInfo
.macAddr
, // RX need Source Address ( Address 2 )
851 // wd->sta.encryMode,
852 (u32_t
*) keyInfo
.key
, (u32_t
*) &keyInfo
.key
[16]);
854 wd
->sta
.oppositeInfo
[userIdx
].wpaState
= ZM_STA_WPA_STATE_PK_OK
;
857 {/* Big Endian and Little Endian Compatibility */
858 for (i
= 0; i
< 3; i
++)
860 addr
[2 * i
] = wd
->sta
.bssid
[i
] & 0xff;
861 addr
[2 * i
+ 1] = wd
->sta
.bssid
[i
] >> 8;
863 zfHpSetPerUserKey(dev
,
864 ZM_USER_KEY_PK
, // user id
866 addr
,//(u8_t *)wd->sta.bssid,
868 (u32_t
*) keyInfo
.key
, (u32_t
*) &keyInfo
.key
[16]);
873 /* Big Endian and Little Endian Compatibility */
874 for (i
= 0; i
< 3; i
++)
876 addr
[2 * i
] = wd
->sta
.bssid
[i
] & 0xff;
877 addr
[2 * i
+ 1] = wd
->sta
.bssid
[i
] >> 8;
879 zfHpSetPerUserKey(dev
,
880 ZM_USER_KEY_PK
, // user id
882 addr
,//(u8_t *)wd->sta.bssid,
884 (u32_t
*) keyInfo
.key
, (u32_t
*) &keyInfo
.key
[16]);
889 wd
->sta
.wpaState
= ZM_STA_WPA_STATE_PK_OK
;
891 else if ( keyInfo
.flag
& ZM_KEY_FLAG_GK
)
892 { /* set group key */
894 zfTkipInit(keyInfo
.key
, (u8_t
*) wd
->sta
.bssid
,
895 &wd
->sta
.rxSeed
[keyInfo
.keyIndex
], keyInfo
.initIv
);
897 if ( keyInfo
.keyLength
== 32 )
899 #ifdef ZM_ENABLE_CENC
900 if (keyInfo
.flag
& ZM_KEY_FLAG_CENC
)
903 zm_debug_msg0("Set CENC group Key");
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;
911 //zfCoreSetKey(dev, 0, 1, ZM_CENC, keyInfo.vapAddr,
912 // (u32_t*) &keyInfo.key[16]);
913 key
= (u32_t
*) keyInfo
.key
;
916 #endif //ZM_ENABLE_CENC
919 key
= (u32_t
*) wd
->sta
.rxSeed
[keyInfo
.keyIndex
].tk
;
921 if ( !(keyInfo
.flag
& ZM_KEY_FLAG_INIT_IV
) )
923 wd
->sta
.rxSeed
[keyInfo
.keyIndex
].iv16
= 0;
924 wd
->sta
.rxSeed
[keyInfo
.keyIndex
].iv32
= 0;
927 /* set MIC key to HMAC */
928 //zfCoreSetKey(dev, 8, 1, ZM_TKIP, broadcast,
929 // (u32_t*) (&keyInfo.key[16]));
931 zfMicSetKey(&keyInfo
.key
[24],
932 &wd
->sta
.rxMicKey
[keyInfo
.keyIndex
]);
935 else if ( keyInfo
.keyLength
== 16 )
938 //key = (u32_t*) wd->sta.rxSeed[keyInfo.keyIndex].tk;
942 if ( keyInfo
.keyLength
== 5 )
944 encryMode
= ZM_WEP64
;
946 else if ( keyInfo
.keyLength
== 13 )
948 encryMode
= ZM_WEP128
;
950 else if ( keyInfo
.keyLength
== 29 )
952 encryMode
= ZM_WEP256
;
955 key
= (u32_t
*) keyInfo
.key
;
959 //zfCoreSetKey(dev, 8, 0, encryMode, broadcast, key);
960 //zfHpSetStaGroupKey(dev, broadcast, encryMode,
961 // (u32_t*) keyInfo.key, (u32_t*) (&keyInfo.key[16]));
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
,
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 )
972 (u32_t
*) keyInfo
.key
, (u32_t
*) &keyInfo
.key
[16]);
976 zfHpSetPerUserKey(dev
,
977 ZM_USER_KEY_GK
, // user id
981 (u32_t
*) keyInfo
.key
, (u32_t
*) &keyInfo
.key
[16]);
983 wd
->sta
.wpaState
= ZM_STA_WPA_STATE_GK_OK
;
986 zfHpSetPerUserKey(dev
,
987 ZM_USER_KEY_GK
, // user id
991 (u32_t
*) keyInfo
.key
, (u32_t
*) &keyInfo
.key
[16]);
993 wd
->sta
.wpaState
= ZM_STA_WPA_STATE_GK_OK
;
998 zm_debug_msg0("legacy WEP");
1000 if ( keyInfo
.keyIndex
>= 4 )
1002 return ZM_STATUS_FAILURE
;
1005 if ( keyInfo
.keyLength
== 5 )
1007 zm_debug_msg0("WEP 64");
1009 encryMode
= ZM_WEP64
;
1011 else if ( keyInfo
.keyLength
== 13 )
1013 zm_debug_msg0("WEP 128");
1015 encryMode
= ZM_WEP128
;
1017 else if ( keyInfo
.keyLength
== 32 )
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
)
1029 encryMode
= ZM_TKIP
;
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
]);
1036 else if ( keyInfo
.keyLength
== 16 )
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
)
1043 /* broadcast -- > group key */
1044 /* Only initialize when set our default key ! */
1052 else if ( keyInfo
.keyLength
== 29 )
1054 zm_debug_msg0("WEP 256");
1056 encryMode
= ZM_WEP256
;
1057 //zfCoreSetKey(dev, 64, 1, wd->sta.encryMode,
1058 // wd->sta.bssid, (u32_t*) (&keyInfo.key[16]));
1062 return ZM_STATUS_FAILURE
;
1068 zm_debug_msg0("key = ");
1069 for(i
= 0; i
< keyInfo
.keyLength
; i
++)
1071 zm_debug_msg2("", keyInfo
.key
[i
]);
1075 if ( keyInfo
.flag
& ZM_KEY_FLAG_DEFAULT_KEY
)
1077 //for WEP default key 1~3 and ATOM platform--CWYang(+)
1079 wd
->ap
.bcHalKeyIdx
[vapId
] = keyInfo
.keyIndex
;
1080 wd
->ap
.bcKeyIndex
[vapId
] = keyInfo
.keyIndex
;
1081 wd
->sta
.keyId
= keyInfo
.keyIndex
;
1084 if(encryMode
== ZM_TKIP
)
1086 if(wd
->TKIP_Group_KeyChanging
== 0x1)
1088 zm_debug_msg0("Countermeasure : Cancel Old Timer ");
1089 zfTimerCancel(dev
, ZM_EVENT_SKIP_COUNTERMEASURE
);
1093 zm_debug_msg0("Countermeasure : Create New Timer ");
1096 wd
->TKIP_Group_KeyChanging
= 0x1;
1097 zfTimerSchedule(dev
, ZM_EVENT_SKIP_COUNTERMEASURE
, 150);
1102 //------------------------------------------------------------------------
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);
1108 if ( encryMode
== ZM_TKIP
||
1109 encryMode
== ZM_AES
)
1111 zfHpSetDefaultKey(dev
, keyInfo
.keyIndex
, encryMode
,
1112 (u32_t
*) keyInfo
.key
, (u32_t
*) &keyInfo
.key
[16]);
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
;
1121 if (wd
->sta
.wpaState
== ZM_STA_WPA_STATE_PK_OK
)
1122 wd
->sta
.wpaState
= ZM_STA_WPA_STATE_GK_OK
;
1125 wd
->sta
.wpaState
= ZM_STA_WPA_STATE_PK_OK
;
1126 wd
->sta
.encryMode
= encryMode
;
1127 wd
->ws
.encryMode
= encryMode
;
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
)
1135 wd
->sta
.wpaState
= ZM_STA_WPA_STATE_PK_OK
;
1136 wd
->sta
.encryMode
= encryMode
;
1137 wd
->ws
.encryMode
= encryMode
;
1143 zfHpSetDefaultKey(dev
, keyInfo
.keyIndex
, encryMode
,
1144 (u32_t
*) keyInfo
.key
, NULL
);
1146 /* Save key for software WEP */
1147 zfMemoryCopy(wd
->sta
.wepKey
[keyInfo
.keyIndex
], keyInfo
.key
,
1150 /* TODO: Check whether we need to save the SWEncryMode */
1151 wd
->sta
.SWEncryMode
[keyInfo
.keyIndex
] = encryMode
;
1153 wd
->sta
.encryMode
= encryMode
;
1154 wd
->ws
.encryMode
= encryMode
;
1159 // wd->sta.flagKeyChanging = 1;
1160 return ZM_STATUS_SUCCESS
;
1164 u8_t
zfiWlanPSEUDOSetKey(zdev_t
* dev
, struct zsKeyInfo keyInfo
)
1166 //u16_t broadcast[3] = {0xffff, 0xffff, 0xffff};
1170 zmw_get_wlan_dev(dev
);
1172 switch (keyInfo
.keyLength
)
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
);
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
);
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
);
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
);
1200 #ifdef ZM_ENABLE_CENC
1201 if (keyInfo
.flag
& ZM_KEY_FLAG_CENC
)
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
);
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
);
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
);
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;
1224 #endif //ZM_ENABLE_CENC
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
);
1232 wd
->sta
.encryMode
= ZM_NO_WEP
;
1235 return ZM_STATUS_SUCCESS
;
1238 void zfiWlanSetPowerSaveMode(zdev_t
* dev
, u8_t mode
)
1241 zmw_get_wlan_dev(dev
);
1243 wd
->sta
.powerSaveMode
= mode
;
1245 /* send null data with PwrBit to inform AP */
1246 if ( mode
> ZM_STA_PS_NONE
)
1248 if ( wd
->wlanMode
== ZM_MODE_INFRASTRUCTURE
)
1250 zfSendNullData(dev
, 1);
1253 /* device into PS mode */
1254 zfPSDeviceSleep(dev
);
1258 zfPowerSavingMgrSetMode(dev
, mode
);
1261 void zfiWlanSetMacAddress(zdev_t
* dev
, u16_t
* mac
)
1263 zmw_get_wlan_dev(dev
);
1265 wd
->macAddr
[0] = mac
[0];
1266 wd
->macAddr
[1] = mac
[1];
1267 wd
->macAddr
[2] = mac
[2];
1269 zfHpSetMacAddress(dev
, mac
, 0);
1272 u8_t
zfiWlanQueryWlanMode(zdev_t
* dev
)
1274 zmw_get_wlan_dev(dev
);
1276 return wd
->wlanMode
;
1279 u8_t
zfiWlanQueryAdapterState(zdev_t
* dev
)
1281 zmw_get_wlan_dev(dev
);
1286 u8_t
zfiWlanQueryAuthenticationMode(zdev_t
* dev
, u8_t bWrapper
)
1290 zmw_get_wlan_dev(dev
);
1294 authMode
= wd
->ws
.authMode
;
1298 //authMode = wd->sta.authMode;
1299 authMode
= wd
->sta
.currentAuthMode
;
1305 u8_t
zfiWlanQueryWepStatus(zdev_t
* dev
, u8_t bWrapper
)
1309 zmw_get_wlan_dev(dev
);
1313 wepStatus
= wd
->ws
.wepStatus
;
1317 wepStatus
= wd
->sta
.wepStatus
;
1323 void zfiWlanQuerySSID(zdev_t
* dev
, u8_t
* ssid
, u8_t
* pSsidLength
)
1326 zmw_get_wlan_dev(dev
);
1328 if (wd
->wlanMode
== ZM_MODE_AP
)
1330 vapId
= zfwGetVapId(dev
);
1332 if (vapId
== 0xffff)
1334 *pSsidLength
= wd
->ap
.ssidLen
[0];
1335 zfMemoryCopy(ssid
, wd
->ap
.ssid
[0], wd
->ap
.ssidLen
[0]);
1339 *pSsidLength
= wd
->ap
.ssidLen
[vapId
+ 1];
1340 zfMemoryCopy(ssid
, wd
->ap
.ssid
[vapId
+ 1], wd
->ap
.ssidLen
[vapId
+ 1]);
1345 *pSsidLength
= wd
->sta
.ssidLen
;
1346 zfMemoryCopy(ssid
, wd
->sta
.ssid
, wd
->sta
.ssidLen
);
1350 u16_t
zfiWlanQueryFragThreshold(zdev_t
* dev
)
1352 zmw_get_wlan_dev(dev
);
1354 return wd
->fragThreshold
;
1357 u16_t
zfiWlanQueryRtsThreshold(zdev_t
* dev
)
1359 zmw_get_wlan_dev(dev
);
1361 return wd
->rtsThreshold
;
1364 u32_t
zfiWlanQueryFrequency(zdev_t
* dev
)
1366 zmw_get_wlan_dev(dev
);
1368 return (wd
->frequency
*1000);
1371 /***********************************************************
1372 * Function: zfiWlanQueryCurrentFrequency
1374 * - 0 : no validate current frequency
1375 * - (>0): current frequency depend on "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
)
1386 zmw_get_wlan_dev(dev
);
1391 if (wd
->sta
.currentFrequency
> 3000)
1393 if (wd
->supportMode
& ZM_WIRELESS_MODE_5
)
1395 frequency
= wd
->sta
.currentFrequency
;
1397 else if (wd
->supportMode
& ZM_WIRELESS_MODE_24
)
1399 frequency
= zfChGetFirst2GhzChannel(dev
);
1408 if (wd
->supportMode
& ZM_WIRELESS_MODE_24
)
1410 frequency
= wd
->sta
.currentFrequency
;
1412 else if (wd
->supportMode
& ZM_WIRELESS_MODE_5
)
1414 frequency
= zfChGetLast5GhzChannel(dev
);
1424 frequency
= wd
->sta
.currentFrequency
;
1431 return (frequency
*1000);
1434 u32_t
zfiWlanQueryFrequencyAttribute(zdev_t
* dev
, u32_t freq
)
1437 u16_t frequency
= (u16_t
) (freq
/1000);
1440 zmw_get_wlan_dev(dev
);
1442 for (i
= 0; i
< wd
->regulationTable
.allowChannelCnt
; i
++)
1444 if ( wd
->regulationTable
.allowChannel
[i
].channel
== frequency
)
1446 ret
= wd
->regulationTable
.allowChannel
[i
].channelFlags
;
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
)
1457 zmw_get_wlan_dev(dev
);
1459 *bandWidth
= wd
->BandWidth40
;
1460 *extOffset
= wd
->ExtOffset
;
1463 u8_t
zfiWlanQueryCWMode(zdev_t
* dev
)
1465 zmw_get_wlan_dev(dev
);
1467 return wd
->cwm
.cw_mode
;
1470 u32_t
zfiWlanQueryCWEnable(zdev_t
* dev
)
1472 zmw_get_wlan_dev(dev
);
1474 return wd
->cwm
.cw_enable
;
1477 void zfiWlanQueryBssid(zdev_t
* dev
, u8_t
* bssid
)
1481 zmw_get_wlan_dev(dev
);
1483 ZM_MAC_WORD_TO_BYTE(wd
->sta
.bssid
, addr
);
1484 zfMemoryCopy(bssid
, addr
, 6);
1487 u16_t
zfiWlanQueryBeaconInterval(zdev_t
* dev
)
1489 zmw_get_wlan_dev(dev
);
1491 return wd
->beaconInterval
;
1494 u32_t
zfiWlanQueryRxBeaconTotal(zdev_t
* dev
)
1496 zmw_get_wlan_dev(dev
);
1497 wd
->sta
.rxBeaconTotal
+= wd
->sta
.rxBeaconCount
;
1499 return wd
->sta
.rxBeaconTotal
;
1502 u16_t
zfiWlanQueryAtimWindow(zdev_t
* dev
)
1506 zmw_get_wlan_dev(dev
);
1508 atimWindow
= wd
->sta
.atimWindow
;
1513 u8_t
zfiWlanQueryEncryMode(zdev_t
* dev
)
1515 zmw_get_wlan_dev(dev
);
1517 if (wd
->wlanMode
== ZM_MODE_AP
)
1518 return wd
->ap
.encryMode
[0];
1520 return wd
->sta
.encryMode
;
1523 u16_t
zfiWlanQueryCapability(zdev_t
* dev
)
1527 zmw_get_wlan_dev(dev
);
1529 capability
= wd
->sta
.capability
[0] +
1530 (((u16_t
) wd
->sta
.capability
[1]) << 8);
1536 u16_t
zfiWlanQueryAid(zdev_t
* dev
)
1538 zmw_get_wlan_dev(dev
);
1543 void zfiWlanQuerySupportRate(zdev_t
* dev
, u8_t
* rateArray
, u8_t
* pLength
)
1547 zmw_get_wlan_dev(dev
);
1549 for( i
=0; i
<4; i
++ )
1551 if ( wd
->bRate
& (0x1 << i
) )
1553 rateArray
[j
] = zg11bRateTbl
[i
] +
1554 ((wd
->bRateBasic
& (0x1<<i
))<<(7-i
));
1562 void zfiWlanQueryExtSupportRate(zdev_t
* dev
, u8_t
* rateArray
, u8_t
* pLength
)
1566 zmw_get_wlan_dev(dev
);
1568 for( i
=0; i
<8; i
++ )
1570 if ( wd
->gRate
& (0x1 << i
) )
1572 rateArray
[j
] = zg11gRateTbl
[i
] +
1573 ((wd
->gRateBasic
& (0x1<<i
))<<(7-i
));
1581 void zfiWlanQueryRsnIe(zdev_t
* dev
, u8_t
* ie
, u8_t
* pLength
)
1585 zmw_get_wlan_dev(dev
);
1587 len
= wd
->sta
.rsnIe
[1] + 2;
1588 zfMemoryCopy(ie
, wd
->sta
.rsnIe
, len
);
1592 void zfiWlanQueryWpaIe(zdev_t
* dev
, u8_t
* ie
, u8_t
* pLength
)
1596 zmw_get_wlan_dev(dev
);
1598 len
= wd
->sta
.wpaIe
[1] + 2;
1599 zfMemoryCopy(ie
, wd
->sta
.wpaIe
, len
);
1604 u8_t
zfiWlanQueryMulticastCipherAlgo(zdev_t
*dev
)
1606 zmw_get_wlan_dev(dev
);
1608 switch( wd
->sta
.currentAuthMode
)
1610 case ZM_AUTH_MODE_WPA2PSK
:
1611 case ZM_AUTH_MODE_WPA2
:
1612 if ( wd
->sta
.rsnIe
[7] == 2 )
1622 case ZM_AUTH_MODE_WPAPSK
:
1623 case ZM_AUTH_MODE_WPA
:
1624 if ( wd
->sta
.rsnIe
[11] == 2 )
1635 return wd
->sta
.encryMode
;
1639 u8_t
zfiWlanQueryHTMode(zdev_t
* dev
)
1641 zmw_get_wlan_dev(dev
);
1643 return wd
->sta
.EnableHT
;
1646 u8_t
zfiWlanQueryBandWidth40(zdev_t
* dev
)
1648 zmw_get_wlan_dev(dev
);
1650 return wd
->BandWidth40
;
1653 u16_t
zfiWlanQueryRegionCode(zdev_t
* dev
)
1655 zmw_get_wlan_dev(dev
);
1657 return wd
->regulationTable
.regionCode
;
1659 void zfiWlanSetWpaIe(zdev_t
* dev
, u8_t
* ie
, u8_t Length
)
1662 zmw_get_wlan_dev(dev
);
1664 if (wd
->wlanMode
== ZM_MODE_AP
) // AP Mode
1666 vapId
= zfwGetVapId(dev
);
1668 if (vapId
== 0xffff)
1673 zm_assert(Length
< ZM_MAX_WPAIE_SIZE
);
1674 if (Length
< ZM_MAX_WPAIE_SIZE
)
1676 wd
->ap
.wpaLen
[vapId
] = Length
;
1677 zfMemoryCopy(wd
->ap
.wpaIe
[vapId
], ie
, wd
->ap
.wpaLen
[vapId
]);
1683 wd
->sta
.wpaLen
= Length
;
1684 zfMemoryCopy(wd
->sta
.wpaIe
, ie
, wd
->sta
.wpaLen
);
1686 //zfiWlanSetWpaSupport(dev, 1);
1687 if (wd
->wlanMode
== ZM_MODE_AP
) // AP Mode
1689 wd
->ap
.wpaSupport
[vapId
] = 1;
1693 wd
->sta
.wpaSupport
= 1;
1698 void zfiWlanSetWpaSupport(zdev_t
* dev
, u8_t WpaSupport
)
1701 zmw_get_wlan_dev(dev
);
1703 if (wd
->wlanMode
== ZM_MODE_AP
) // AP Mode
1705 vapId
= zfwGetVapId(dev
);
1707 if (vapId
== 0xffff)
1712 wd
->ap
.wpaSupport
[vapId
] = WpaSupport
;
1716 wd
->sta
.wpaSupport
= WpaSupport
;
1721 void zfiWlanSetProtectionMode(zdev_t
* dev
, u8_t mode
)
1723 zmw_get_wlan_dev(dev
);
1725 wd
->sta
.bProtectionMode
= mode
;
1726 if (wd
->sta
.bProtectionMode
== TRUE
)
1728 zfHpSetSlotTime(dev
, 0);
1732 zfHpSetSlotTime(dev
, 1);
1735 zm_msg1_mm(ZM_LV_1
, "wd->protectionMode=", wd
->sta
.bProtectionMode
);
1738 void zfiWlanSetBasicRate(zdev_t
* dev
, u8_t bRateSet
, u8_t gRateSet
,
1741 zmw_get_wlan_dev(dev
);
1743 wd
->ws
.bRateBasic
= bRateSet
;
1744 wd
->ws
.gRateBasic
= gRateSet
;
1745 wd
->ws
.nRateBasic
= nRateSet
;
1748 void zfiWlanSetBGMode(zdev_t
* dev
, u8_t mode
)
1750 zmw_get_wlan_dev(dev
);
1752 wd
->ws
.bgMode
= mode
;
1755 void zfiWlanSetpreambleType(zdev_t
* dev
, u8_t type
)
1757 zmw_get_wlan_dev(dev
);
1759 wd
->ws
.preambleType
= type
;
1762 u8_t
zfiWlanQuerypreambleType(zdev_t
* dev
)
1764 zmw_get_wlan_dev(dev
);
1766 return wd
->ws
.preambleType
;
1769 u8_t
zfiWlanQueryPowerSaveMode(zdev_t
* dev
)
1771 zmw_get_wlan_dev(dev
);
1773 return wd
->sta
.powerSaveMode
;
1776 u8_t
zfiWlanSetPmkidInfo(zdev_t
* dev
, u16_t
* bssid
, u8_t
* pmkid
)
1780 zmw_get_wlan_dev(dev
);
1782 for(i
=0; i
<wd
->sta
.pmkidInfo
.bssidCount
; i
++)
1784 if ( zfMemoryIsEqual((u8_t
*) wd
->sta
.pmkidInfo
.bssidInfo
[i
].bssid
,
1792 if ( i
< wd
->sta
.pmkidInfo
.bssidCount
)
1794 /* overwrite the original one */
1795 zfMemoryCopy(wd
->sta
.pmkidInfo
.bssidInfo
[i
].pmkid
, pmkid
, 16);
1799 if ( i
< ZM_PMKID_MAX_BSS_CNT
)
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];
1805 zfMemoryCopy(wd
->sta
.pmkidInfo
.bssidInfo
[i
].pmkid
, pmkid
, 16);
1806 wd
->sta
.pmkidInfo
.bssidCount
++;
1813 u32_t
zfiWlanQueryPmkidInfo(zdev_t
* dev
, u8_t
* buf
, u32_t len
)
1815 //struct zsPmkidInfo* pPmkidInfo = ( struct zsPmkidInfo* ) buf;
1818 zmw_get_wlan_dev(dev
);
1820 size
= sizeof(u32_t
) +
1821 wd
->sta
.pmkidInfo
.bssidCount
* sizeof(struct zsPmkidBssidInfo
);
1825 return wd
->sta
.pmkidInfo
.bssidCount
;
1828 zfMemoryCopy(buf
, (u8_t
*) &wd
->sta
.pmkidInfo
, (u16_t
) size
);
1833 void zfiWlanSetMulticastList(zdev_t
* dev
, u8_t size
, u8_t
* pList
)
1835 struct zsMulticastAddr
* pMacList
= (struct zsMulticastAddr
*) pList
;
1837 u8_t bAllMulticast
= 0;
1840 zmw_get_wlan_dev(dev
);
1842 wd
->sta
.multicastList
.size
= size
;
1843 for(i
=0; i
<size
; i
++)
1845 zfMemoryCopy(wd
->sta
.multicastList
.macAddr
[i
].addr
,
1846 pMacList
[i
].addr
, 6);
1849 if ( wd
->sta
.osRxFilter
& ZM_PACKET_TYPE_ALL_MULTICAST
)
1851 zfHpSetMulticastList(dev
, size
, pList
, bAllMulticast
);
1855 void zfiWlanRemoveKey(zdev_t
* dev
, u8_t keyType
, u8_t keyId
)
1857 u16_t fakeMacAddr
[3] = {0, 0, 0};
1858 u32_t fakeKey
[4] = {0, 0, 0, 0};
1860 zmw_get_wlan_dev(dev
);
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
;
1870 else if ( keyType
== 1 )
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
;
1879 /* remove group key */
1880 zm_debug_msg0("remove group key");
1881 zfHpRemoveKey(dev
, ZM_USER_KEY_GK
);
1886 void zfiWlanQueryRegulationTable(zdev_t
* dev
, struct zsRegulationTable
* pEntry
)
1888 zmw_get_wlan_dev(dev
);
1890 zfMemoryCopy((u8_t
*) pEntry
, (u8_t
*) &wd
->regulationTable
,
1891 sizeof(struct zsRegulationTable
));
1894 /* parameter "time" is specified in ms */
1895 void zfiWlanSetScanTimerPerChannel(zdev_t
* dev
, u16_t time
)
1897 zmw_get_wlan_dev(dev
);
1899 zm_debug_msg1("scan time (ms) = ", time
);
1901 wd
->sta
.activescanTickPerChannel
= time
/ ZM_MS_PER_TICK
;
1904 void zfiWlanSetAutoReconnect(zdev_t
* dev
, u8_t enable
)
1906 zmw_get_wlan_dev(dev
);
1908 wd
->sta
.bAutoReconnect
= enable
;
1909 //wd->sta.bAutoReconnectEnabled = enable;
1912 void zfiWlanSetStaWme(zdev_t
* dev
, u8_t enable
, u8_t uapsdInfo
)
1914 zmw_get_wlan_dev(dev
);
1916 wd
->ws
.staWmeEnabled
= enable
& 0x3;
1917 if ((enable
& 0x2) != 0)
1919 wd
->ws
.staWmeQosInfo
= uapsdInfo
& 0x6f;
1923 wd
->ws
.staWmeQosInfo
= 0;
1927 void zfiWlanSetApWme(zdev_t
* dev
, u8_t enable
)
1929 zmw_get_wlan_dev(dev
);
1931 wd
->ws
.apWmeEnabled
= enable
;
1934 u8_t
zfiWlanQuerywmeEnable(zdev_t
* dev
)
1936 zmw_get_wlan_dev(dev
);
1938 return wd
->ws
.staWmeEnabled
;
1941 void zfiWlanSetProbingHiddenSsid(zdev_t
* dev
, u8_t
* ssid
, u8_t ssidLen
,
1944 zmw_get_wlan_dev(dev
);
1945 zmw_declare_for_critical_section();
1948 if ((ssidLen
<= 32) && (entry
< ZM_MAX_PROBE_HIDDEN_SSID_SIZE
))
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
);
1959 void zfiWlanSetDisableProbingWithSsid(zdev_t
* dev
, u8_t mode
)
1961 zmw_get_wlan_dev(dev
);
1963 wd
->sta
.disableProbingWithSsid
= mode
;
1968 void zfiWlanSetDropUnencryptedPackets(zdev_t
* dev
, u8_t enable
)
1970 zmw_get_wlan_dev(dev
);
1972 wd
->ws
.dropUnencryptedPkts
= enable
;
1975 void zfiWlanSetStaRxSecurityCheckCb(zdev_t
* dev
, zfpStaRxSecurityCheckCb pStaRxSecurityCheckCb
)
1977 zmw_get_wlan_dev(dev
);
1979 wd
->sta
.pStaRxSecurityCheckCb
= pStaRxSecurityCheckCb
;
1982 void zfiWlanSetIBSSJoinOnly(zdev_t
* dev
, u8_t joinOnly
)
1984 zmw_get_wlan_dev(dev
);
1986 wd
->ws
.ibssJoinOnly
= joinOnly
;
1989 /************************************************************************/
1991 /* FUNCTION DESCRIPTION zfiConfigWdsPort */
1992 /* Configure WDS port. */
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 */
2006 /* Stephen Chen ZyDAS Technology Corporation 2006.6 */
2008 /************************************************************************/
2009 u16_t
zfiConfigWdsPort(zdev_t
* dev
, u8_t wdsPortId
, u16_t flag
, u16_t
* wdsAddr
,
2010 u16_t encType
, u32_t
* wdsKey
)
2015 zmw_get_wlan_dev(dev
);
2017 if (wdsPortId
>= ZM_MAX_WDS_SUPPORT
)
2019 return ZM_ERR_WDS_PORT_ID
;
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];
2029 wd
->ap
.wds
.wdsBitmap
|= (1 << wdsPortId
);
2030 wd
->ap
.wds
.encryMode
[wdsPortId
] = (u8_t
) encType
;
2032 zfCoreSetKey(dev
, 10+ZM_MAX_WDS_SUPPORT
, 0, (u8_t
) encType
, wdsAddr
, wdsKey
);
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
);
2045 #ifdef ZM_ENABLE_CENC
2047 void zfiWlanQueryGSN(zdev_t
* dev
, u8_t
*gsn
, u16_t vapId
)
2049 //struct zsWlanDev* wd = (struct zsWlanDev*) zmw_wlan_dev(dev);
2051 zmw_get_wlan_dev(dev
);
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];
2059 zfMemoryCopy(gsn
, (u8_t
*)txiv
, 16);
2061 #endif //ZM_ENABLE_CENC
2063 void zfiWlanQuerySignalInfo(zdev_t
* dev
, u8_t
*buffer
)
2065 zmw_get_wlan_dev(dev
);
2067 /*Change Signal Strength/Quality Value to Human Sense Here*/
2069 buffer
[0] = wd
->SignalStrength
;
2070 buffer
[1] = wd
->SignalQuality
;
2074 u16_t
zfiStaAddIeWpaRsn(zdev_t
* dev
, zbuf_t
* buf
, u16_t offset
, u8_t frameType
)
2076 return zfStaAddIeWpaRsn(dev
, buf
, offset
, frameType
);
2080 /* cmd value-description */
2081 /* 0 schedule timer */
2082 /* 1 cancel timer */
2087 /* 6 checksum test 0/1 */
2088 /* 7 enableProtectionMode */
2089 /* 8 rx packet content dump 0/1 */
2091 u32_t
zfiDebugCmd(zdev_t
* dev
, u32_t cmd
, u32_t value
)
2095 zmw_get_wlan_dev(dev
);
2097 zmw_declare_for_critical_section();
2100 zmw_enter_critical_section(dev
);
2103 { /* schedule timer */
2104 event
= (u16_t
) ((value
>> 16) & 0xffff);
2105 tick
= value
& 0xffff;
2106 zfTimerSchedule(dev
, event
, tick
);
2108 else if ( cmd
== 1 )
2109 { /* cancel timer */
2110 event
= (u16_t
) (value
& 0xffff);
2111 zfTimerCancel(dev
, event
);
2113 else if ( cmd
== 2 )
2117 else if ( cmd
== 3 )
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);
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);
2144 else if ( cmd
== 5 )
2146 wd
->sta
.keyId
= (u8_t
) value
;
2148 else if ( cmd
== 6 )
2150 /* 0: normal 1: always set TCP/UDP checksum zero */
2151 wd
->checksumTest
= value
;
2153 else if ( cmd
== 7 )
2155 wd
->enableProtectionMode
= value
;
2156 zm_msg1_mm(ZM_LV_1
, "wd->enableProtectionMode=", wd
->enableProtectionMode
);
2158 else if ( cmd
== 8 )
2160 /* rx packet content dump */
2163 wd
->rxPacketDump
= 1;
2167 wd
->rxPacketDump
= 0;
2172 zmw_leave_critical_section(dev
);
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
)
2181 struct zsKeyInfo keyInfo
;
2186 zmw_get_wlan_dev(dev
);
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
;
2200 zfiWlanSetKey(dev
, keyInfo
);
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];
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];
2216 u8_t
zfiWlanSetCencGroupKey(zdev_t
* dev
, u8_t keyid
, u32_t
*rxiv
,
2217 u8_t
*key
, u8_t
*mic
)
2219 struct zsKeyInfo keyInfo
;
2222 u16_t macAddr
[6] = {0xffff, 0xffff, 0xffff};
2224 zmw_get_wlan_dev(dev
);
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
;
2235 for (i
= 0; i
< 3; i
++)
2236 keyInfo
.vapAddr
[i
] = wd
->macAddr
[i
];
2237 keyInfo
.macAddr
= macAddr
;
2239 zfiWlanSetKey(dev
, keyInfo
);
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);
2259 wd
->sta
.authMode
= ZM_AUTH_MODE_CENC
;
2260 wd
->sta
.currentAuthMode
= ZM_AUTH_MODE_CENC
;
2264 #endif //ZM_ENABLE_CENC
2266 u8_t
zfiWlanSetDot11DMode(zdev_t
* dev
, u8_t mode
)
2270 zmw_get_wlan_dev(dev
);
2272 wd
->sta
.b802_11D
= mode
;
2273 if (mode
) //Enable 802.11d
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
;
2281 for (i
= 0; i
< wd
->regulationTable
.allowChannelCnt
; i
++)
2282 wd
->regulationTable
.allowChannel
[i
].channelFlags
&= ~ZM_REG_FLAG_CHANNEL_PASSIVE
;
2288 u8_t
zfiWlanSetDot11HDFSMode(zdev_t
* dev
, u8_t mode
)
2290 zmw_get_wlan_dev(dev
);
2292 //zm_debug_msg0("CWY - Enable 802.11h DFS");
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
2300 // Adapter->ZD80211HSetting.DFSEnable=TRUE;
2304 // Adapter->ZD80211HSetting.DFSEnable=FALSE;
2307 wd
->sta
.DFSEnable
= mode
;
2309 wd
->sta
.capability
[1] |= ZM_BIT_0
;
2311 wd
->sta
.capability
[1] &= (~ZM_BIT_0
);
2316 u8_t
zfiWlanSetDot11HTPCMode(zdev_t
* dev
, u8_t mode
)
2318 zmw_get_wlan_dev(dev
);
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
2327 // Adapter->ZD80211HSetting.TPCEnable=TRUE;
2331 // Adapter->ZD80211HSetting.TPCEnable=FALSE;
2334 wd
->sta
.TPCEnable
= mode
;
2336 wd
->sta
.capability
[1] |= ZM_BIT_0
;
2338 wd
->sta
.capability
[1] &= (~ZM_BIT_0
);
2343 u8_t
zfiWlanSetAniMode(zdev_t
* dev
, u8_t mode
)
2345 zmw_get_wlan_dev(dev
);
2347 wd
->aniEnable
= mode
;
2354 #ifdef ZM_OS_LINUX_FUNC
2355 void zfiWlanShowTally(zdev_t
* dev
)
2357 zmw_get_wlan_dev(dev
);
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
);
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
);
2384 if (!((wd
->commTally
.Tx_MPDU
== 0) && (wd
->commTally
.BA_Fail
== 0)))
2386 zm_debug_msg_p("BA Fail Ratio(%) = ", wd
->commTally
.BA_Fail
* 100,
2387 (wd
->commTally
.BA_Fail
+ wd
->commTally
.Tx_MPDU
));
2390 if (!((wd
->commTally
.Hw_Tx_MPDU
== 0) && (wd
->commTally
.Hw_Tx_AMPDU
== 0)))
2392 zm_debug_msg_p("Avg Agg Number = ",
2393 wd
->commTally
.Hw_Tx_MPDU
, wd
->commTally
.Hw_Tx_AMPDU
);
2398 void zfiWlanSetMaxTxPower(zdev_t
* dev
, u8_t power2
, u8_t power5
)
2400 zmw_get_wlan_dev(dev
);
2402 zmw_declare_for_critical_section();
2404 zmw_enter_critical_section(dev
);
2405 wd
->maxTxPower2
= power2
;
2406 wd
->maxTxPower5
= power5
;
2407 zmw_leave_critical_section(dev
);
2410 void zfiWlanQueryMaxTxPower(zdev_t
* dev
, u8_t
*power2
, u8_t
*power5
)
2412 zmw_get_wlan_dev(dev
);
2414 *power2
= wd
->maxTxPower2
;
2415 *power5
= wd
->maxTxPower5
;
2418 void zfiWlanSetConnectMode(zdev_t
* dev
, u8_t mode
)
2420 zmw_get_wlan_dev(dev
);
2422 zmw_declare_for_critical_section();
2424 zmw_enter_critical_section(dev
);
2425 wd
->connectMode
= mode
;
2426 zmw_leave_critical_section(dev
);
2429 void zfiWlanSetSupportMode(zdev_t
* dev
, u32_t mode
)
2431 zmw_get_wlan_dev(dev
);
2433 zmw_declare_for_critical_section();
2435 zmw_enter_critical_section(dev
);
2436 wd
->supportMode
= mode
;
2437 zmw_leave_critical_section(dev
);
2440 void zfiWlanSetAdhocMode(zdev_t
* dev
, u32_t mode
)
2442 zmw_get_wlan_dev(dev
);
2444 wd
->ws
.adhocMode
= mode
;
2447 u32_t
zfiWlanQueryAdhocMode(zdev_t
* dev
, u8_t bWrapper
)
2451 zmw_get_wlan_dev(dev
);
2455 adhocMode
= wd
->ws
.adhocMode
;
2459 adhocMode
= wd
->wfc
.bIbssGMode
;
2466 u8_t
zfiWlanSetCountryIsoName(zdev_t
* dev
, u8_t
*countryIsoName
, u8_t length
)
2469 zmw_get_wlan_dev(dev
);
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];
2477 else if (length
== 3)
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';
2488 return zfHpGetRegulationTablefromISO(dev
, buf
, length
);
2492 const char* zfiWlanQueryCountryIsoName(zdev_t
* dev
)
2494 zmw_get_wlan_dev(dev
);
2496 return wd
->ws
.countryIsoName
;
2501 void zfiWlanSetRegulatory(zdev_t
* dev
, u8_t CCS
, u16_t Code
, u8_t bfirstChannel
)
2503 zmw_get_wlan_dev(dev
);
2505 zmw_declare_for_critical_section();
2509 /* Reset Regulation Table by Country Code */
2510 zfHpGetRegulationTablefromCountry(dev
, Code
);
2514 /* Reset Regulation Table by Region Code */
2515 zfHpGetRegulationTablefromRegionCode(dev
, Code
);
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
);
2527 const char* zfiHpGetisoNamefromregionCode(zdev_t
* dev
, u16_t regionCode
)
2529 return zfHpGetisoNamefromregionCode(dev
, regionCode
);
2532 u16_t
zfiWlanChannelToFrequency(zdev_t
* dev
, u8_t channel
)
2534 return zfChNumToFreq(dev
, channel
, 0);
2537 u8_t
zfiWlanFrequencyToChannel(zdev_t
* dev
, u16_t freq
)
2541 return zfChFreqToNum(freq
, &is5GBand
);
2544 void zfiWlanDisableDfsChannel(zdev_t
* dev
, u8_t disableFlag
)
2546 zfHpDisableDfsChannel(dev
, disableFlag
);
2550 void zfiWlanSetLEDCtrlParam(zdev_t
* dev
, u8_t type
, u8_t flag
)
2552 zmw_get_wlan_dev(dev
);
2554 zmw_declare_for_critical_section();
2556 zmw_enter_critical_section(dev
);
2557 wd
->ledStruct
.LEDCtrlType
= type
;
2558 wd
->ledStruct
.LEDCtrlFlagFromReg
= flag
;
2559 zmw_leave_critical_section(dev
);
2562 void zfiWlanEnableLeapConfig(zdev_t
* dev
, u8_t leapEnabled
)
2564 zmw_get_wlan_dev(dev
);
2566 wd
->sta
.leapEnabled
= leapEnabled
;
2569 u32_t
zfiWlanQueryHwCapability(zdev_t
* dev
)
2571 return zfHpCapability(dev
);
2574 u32_t
zfiWlanQueryReceivedPacket(zdev_t
* dev
)
2576 zmw_get_wlan_dev(dev
);
2578 return wd
->sta
.ReceivedPktRatePerSecond
;
2581 void zfiWlanCheckSWEncryption(zdev_t
* dev
)
2583 zmw_get_wlan_dev(dev
);
2585 if (wd
->sta
.SWEncryptEnable
!= 0)
2587 zfHpSWDecrypt(dev
, 1);
2591 u16_t
zfiWlanQueryAllowChannels(zdev_t
* dev
, u16_t
*channels
)
2594 zmw_get_wlan_dev(dev
);
2596 for (ii
= 0; ii
< wd
->regulationTable
.allowChannelCnt
; ii
++)
2598 channels
[ii
] = wd
->regulationTable
.allowChannel
[ii
].channel
;
2601 return wd
->regulationTable
.allowChannelCnt
;
2604 void zfiWlanSetDynamicSIFSParam(zdev_t
* dev
, u8_t val
)
2606 zmw_get_wlan_dev(dev
);
2608 wd
->dynamicSIFSEnable
= val
;
2610 zm_debug_msg1("wd->dynamicSIFSEnable = ", wd
->dynamicSIFSEnable
)
2613 u16_t
zfiWlanGetMulticastAddressCount(zdev_t
* dev
)
2615 zmw_get_wlan_dev(dev
);
2617 return wd
->sta
.multicastList
.size
;
2620 void zfiWlanGetMulticastList(zdev_t
* dev
, u8_t
* pMCList
)
2622 struct zsMulticastAddr
* pMacList
= (struct zsMulticastAddr
*) pMCList
;
2625 zmw_get_wlan_dev(dev
);
2627 for ( i
=0; i
<wd
->sta
.multicastList
.size
; i
++ )
2629 zfMemoryCopy(pMacList
[i
].addr
, wd
->sta
.multicastList
.macAddr
[i
].addr
, 6);
2633 void zfiWlanSetPacketFilter(zdev_t
* dev
, u32_t PacketFilter
)
2635 u8_t bAllMulticast
= 0;
2638 zmw_get_wlan_dev(dev
);
2640 oldFilter
= wd
->sta
.osRxFilter
;
2642 wd
->sta
.osRxFilter
= PacketFilter
;
2644 if ((oldFilter
& ZM_PACKET_TYPE_ALL_MULTICAST
) !=
2645 (wd
->sta
.osRxFilter
& ZM_PACKET_TYPE_ALL_MULTICAST
))
2647 if ( wd
->sta
.osRxFilter
& ZM_PACKET_TYPE_ALL_MULTICAST
)
2649 zfHpSetMulticastList(dev
, wd
->sta
.multicastList
.size
,
2650 (u8_t
*)wd
->sta
.multicastList
.macAddr
, bAllMulticast
);
2654 u8_t
zfiCompareWithMulticastListAddress(zdev_t
* dev
, u16_t
* dstMacAddr
)
2657 u8_t bIsInMCListAddr
= 0;
2659 zmw_get_wlan_dev(dev
);
2661 for ( i
=0; i
<wd
->sta
.multicastList
.size
; i
++ )
2663 if ( zfwMemoryIsEqual((u8_t
*)dstMacAddr
, (u8_t
*)wd
->sta
.multicastList
.macAddr
[i
].addr
, 6) )
2665 bIsInMCListAddr
= 1;
2670 return bIsInMCListAddr
;
2673 void zfiWlanSetSafeModeEnabled(zdev_t
* dev
, u8_t safeMode
)
2675 zmw_get_wlan_dev(dev
);
2677 wd
->sta
.bSafeMode
= safeMode
;
2680 zfStaEnableSWEncryption(dev
, 1);
2682 zfStaDisableSWEncryption(dev
);
2685 void zfiWlanSetIBSSAdditionalIELength(zdev_t
* dev
, u32_t ibssAdditionalIESize
, u8_t
* ibssAdditionalIE
)
2687 zmw_get_wlan_dev(dev
);
2689 if ( ibssAdditionalIESize
)
2691 wd
->sta
.ibssAdditionalIESize
= ibssAdditionalIESize
;
2692 zfMemoryCopy(wd
->sta
.ibssAdditionalIE
, ibssAdditionalIE
, (u16_t
)ibssAdditionalIESize
);
2695 wd
->sta
.ibssAdditionalIESize
= 0;