2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Purpose: handle hostap deamon ioctl input/out functions
34 #if !defined(__HOSTAP_H__)
37 #if !defined(__IOCMD_H__)
40 #if !defined(__MAC_H__)
43 #if !defined(__CARD_H__)
46 #if !defined(__BASEBAND_H__)
49 #if !defined(__WPACTL_H__)
52 #if !defined(__KEY_H__)
55 #if !defined(__MAC_H__)
60 #define VIAWGET_HOSTAPD_MAX_BUF_SIZE 1024
61 #define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT0
62 #define HOSTAP_CRYPT_FLAG_PERMANENT BIT1
63 #define HOSTAP_CRYPT_ERR_UNKNOWN_ALG 2
64 #define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3
65 #define HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED 4
66 #define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5
67 #define HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED 6
68 #define HOSTAP_CRYPT_ERR_CARD_CONF_FAILED 7
71 /*--------------------- Static Definitions -------------------------*/
73 /*--------------------- Static Classes ----------------------------*/
75 /*--------------------- Static Variables --------------------------*/
76 //static int msglevel =MSG_LEVEL_DEBUG;
77 static int msglevel
=MSG_LEVEL_INFO
;
79 /*--------------------- Static Functions --------------------------*/
84 /*--------------------- Export Variables --------------------------*/
89 * register net_device (AP) for hostap deamon
101 static int hostap_enable_hostapd(PSDevice pDevice
, int rtnl_locked
)
104 struct net_device
*dev
= pDevice
->dev
;
107 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Enabling hostapd mode\n", dev
->name
);
110 pDevice
->apdev
= ref_init_apdev(dev
);
112 if (pDevice
->apdev
== NULL
)
116 ret
= register_netdevice(pDevice
->apdev
);
118 ret
= register_netdev(pDevice
->apdev
);
120 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: register_netdevice(AP) failed!\n",
124 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Registered netdevice %s for AP management\n",
125 dev
->name
, pDevice
->apdev
->name
);
128 pDevice
->apdev
= (struct net_device
*)kmalloc(sizeof(struct net_device
), GFP_KERNEL
);
129 if (pDevice
->apdev
== NULL
)
131 memset(pDevice
->apdev
, 0, sizeof(struct net_device
));
133 apdev_priv
= netdev_priv(pDevice
->apdev
);
134 *apdev_priv
= *pDevice
;
135 memcpy(pDevice
->apdev
->dev_addr
, dev
->dev_addr
, ETH_ALEN
);
137 const struct net_device_ops apdev_netdev_ops
= {
138 .ndo_start_xmit
= pDevice
->tx_80211
,
140 pDevice
->apdev
->netdev_ops
= &apdev_netdev_ops
;
142 pDevice
->apdev
->type
= ARPHRD_IEEE80211
;
144 pDevice
->apdev
->base_addr
= dev
->base_addr
;
145 pDevice
->apdev
->irq
= dev
->irq
;
146 pDevice
->apdev
->mem_start
= dev
->mem_start
;
147 pDevice
->apdev
->mem_end
= dev
->mem_end
;
148 sprintf(pDevice
->apdev
->name
, "%sap", dev
->name
);
150 ret
= register_netdevice(pDevice
->apdev
);
152 ret
= register_netdev(pDevice
->apdev
);
154 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: register_netdevice(AP) failed!\n",
159 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Registered netdevice %s for AP management\n",
160 dev
->name
, pDevice
->apdev
->name
);
162 KeyvInitTable(&pDevice
->sKey
, pDevice
->PortOffset
);
170 * unregister net_device(AP)
182 static int hostap_disable_hostapd(PSDevice pDevice
, int rtnl_locked
)
185 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: disabling hostapd mode\n", pDevice
->dev
->name
);
187 if (pDevice
->apdev
&& pDevice
->apdev
->name
&& pDevice
->apdev
->name
[0]) {
189 unregister_netdevice(pDevice
->apdev
);
191 unregister_netdev(pDevice
->apdev
);
192 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Netdevice %s unregistered\n",
193 pDevice
->dev
->name
, pDevice
->apdev
->name
);
195 kfree(pDevice
->apdev
);
196 pDevice
->apdev
= NULL
;
197 pDevice
->bEnable8021x
= FALSE
;
198 pDevice
->bEnableHostWEP
= FALSE
;
199 pDevice
->bEncryptionEnable
= FALSE
;
201 //4.2007-0118-03,<Add> by EinsnLiu
202 //execute some clear work
203 pDevice
->pMgmt
->byCSSPK
=KEY_CTL_NONE
;
204 pDevice
->pMgmt
->byCSSGK
=KEY_CTL_NONE
;
205 KeyvInitTable(&pDevice
->sKey
,pDevice
->PortOffset
);
213 * Set enable/disable hostapd mode
225 int hostap_set_hostapd(PSDevice pDevice
, int val
, int rtnl_locked
)
227 if (val
< 0 || val
> 1)
230 if (pDevice
->bEnableHostapd
== val
)
233 pDevice
->bEnableHostapd
= val
;
236 return hostap_enable_hostapd(pDevice
, rtnl_locked
);
238 return hostap_disable_hostapd(pDevice
, rtnl_locked
);
244 * remove station function supported for hostap deamon
255 static int hostap_remove_sta(PSDevice pDevice
,
256 struct viawget_hostapd_param
*param
)
261 if (BSSDBbIsSTAInNodeDB(pDevice
->pMgmt
, param
->sta_addr
, &uNodeIndex
)) {
262 BSSvRemoveOneNode(pDevice
, uNodeIndex
);
272 * add a station from hostap deamon
283 static int hostap_add_sta(PSDevice pDevice
,
284 struct viawget_hostapd_param
*param
)
286 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
290 if (!BSSDBbIsSTAInNodeDB(pMgmt
, param
->sta_addr
, &uNodeIndex
)) {
291 BSSvCreateOneNode((PSDevice
)pDevice
, &uNodeIndex
);
293 memcpy(pMgmt
->sNodeDBTable
[uNodeIndex
].abyMACAddr
, param
->sta_addr
, WLAN_ADDR_LEN
);
294 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_ASSOC
;
295 pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
= param
->u
.add_sta
.capability
;
296 // TODO listenInterval
297 // pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = 1;
298 pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
= FALSE
;
299 pMgmt
->sNodeDBTable
[uNodeIndex
].bySuppRate
= param
->u
.add_sta
.tx_supp_rates
;
302 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
=
303 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
304 // set max basic rate
305 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
= RATE_2M
;
306 // Todo: check sta preamble, if ap can't support, set status code
307 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
=
308 WLAN_GET_CAP_INFO_SHORTPREAMBLE(pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
);
310 pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
= (WORD
)param
->u
.add_sta
.aid
;
312 pMgmt
->sNodeDBTable
[uNodeIndex
].ulLastRxJiffer
= get_jiffies();
314 pMgmt
->sNodeDBTable
[uNodeIndex
].ulLastRxJiffer
= jiffies
;
316 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Add STA AID= %d \n", pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
);
317 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
325 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Max Support rate = %d \n",
326 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
);
345 static int hostap_get_info_sta(PSDevice pDevice
,
346 struct viawget_hostapd_param
*param
)
348 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
351 if (BSSDBbIsSTAInNodeDB(pMgmt
, param
->sta_addr
, &uNodeIndex
)) {
353 param
->u
.get_info_sta
.inactive_sec
=
354 (get_jiffies() - pMgmt
->sNodeDBTable
[uNodeIndex
].ulLastRxJiffer
) / HZ
;
356 param
->u
.get_info_sta
.inactive_sec
=
357 (jiffies
- pMgmt
->sNodeDBTable
[uNodeIndex
].ulLastRxJiffer
) / HZ
;
359 //param->u.get_info_sta.txexc = pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts;
383 static int hostap_reset_txexc_sta(PSDevice pDevice,
384 struct viawget_hostapd_param *param)
386 PSMgmtObject pMgmt = pDevice->pMgmt;
389 if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
390 pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts = 0;
413 static int hostap_set_flags_sta(PSDevice pDevice
,
414 struct viawget_hostapd_param
*param
)
416 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
419 if (BSSDBbIsSTAInNodeDB(pMgmt
, param
->sta_addr
, &uNodeIndex
)) {
420 pMgmt
->sNodeDBTable
[uNodeIndex
].dwFlags
|= param
->u
.set_flags_sta
.flags_or
;
421 pMgmt
->sNodeDBTable
[uNodeIndex
].dwFlags
&= param
->u
.set_flags_sta
.flags_and
;
422 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" dwFlags = %x \n",
423 (UINT
)pMgmt
->sNodeDBTable
[uNodeIndex
].dwFlags
);
436 * set generic element (wpa ie)
447 static int hostap_set_generic_element(PSDevice pDevice
,
448 struct viawget_hostapd_param
*param
)
450 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
454 memcpy( pMgmt
->abyWPAIE
,
455 param
->u
.generic_elem
.data
,
456 param
->u
.generic_elem
.len
459 pMgmt
->wWPAIELen
= param
->u
.generic_elem
.len
;
461 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"pMgmt->wWPAIELen = %d\n", pMgmt
->wWPAIELen
);
464 if (pMgmt
->wWPAIELen
== 0) {
465 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
466 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" No WPAIE, Disable WPA \n");
469 if ((pMgmt
->abyWPAIE
[0] == WLAN_EID_RSN_WPA
) ||
470 (pMgmt
->abyWPAIE
[0] == WLAN_EID_RSN
)) {
471 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
472 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set WPAIE enable WPA\n");
482 * flush station nodes table.
493 static void hostap_flush_sta(PSDevice pDevice
)
495 // reserved node index =0 for multicast node.
496 BSSvClearNodeDBTable(pDevice
, 1);
497 pDevice
->uAssocCount
= 0;
504 * set each stations encryption key
515 static int hostap_set_encryption(PSDevice pDevice
,
516 struct viawget_hostapd_param
*param
,
519 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
520 DWORD dwKeyIndex
= 0;
521 BYTE abyKey
[MAX_KEY_LEN
];
522 BYTE abySeq
[MAX_KEY_LEN
];
523 NDIS_802_11_KEY_RSC KeyRSC
;
524 BYTE byKeyDecMode
= KEY_CTL_WEP
;
528 BOOL bKeyTableFull
= FALSE
;
532 param
->u
.crypt
.err
= 0;
535 (int) ((char *) param->u.crypt.key - (char *) param) +
536 param->u.crypt.key_len)
540 if (param
->u
.crypt
.alg
> WPA_ALG_CCMP
)
544 if ((param
->u
.crypt
.idx
> 3) || (param
->u
.crypt
.key_len
> MAX_KEY_LEN
)) {
545 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_KEY_SET_FAILED
;
546 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" HOSTAP_CRYPT_ERR_KEY_SET_FAILED\n");
550 if (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
551 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
552 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
553 if (param
->u
.crypt
.idx
>= MAX_GROUP_KEY
)
558 if (BSSDBbIsSTAInNodeDB(pMgmt
, param
->sta_addr
, &iNodeIndex
) == FALSE
) {
559 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
560 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
564 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" hostap_set_encryption: sta_index %d \n", iNodeIndex
);
565 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" hostap_set_encryption: alg %d \n", param
->u
.crypt
.alg
);
567 if (param
->u
.crypt
.alg
== WPA_ALG_NONE
) {
569 if (pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
== TRUE
) {
570 if (KeybRemoveKey(&(pDevice
->sKey
),
572 pMgmt
->sNodeDBTable
[iNodeIndex
].dwKeyIndex
,
573 pDevice
->PortOffset
) == FALSE
) {
574 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"KeybRemoveKey fail \n");
576 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= FALSE
;
578 pMgmt
->sNodeDBTable
[iNodeIndex
].byKeyIndex
= 0;
579 pMgmt
->sNodeDBTable
[iNodeIndex
].dwKeyIndex
= 0;
580 pMgmt
->sNodeDBTable
[iNodeIndex
].uWepKeyLength
= 0;
581 pMgmt
->sNodeDBTable
[iNodeIndex
].KeyRSC
= 0;
582 pMgmt
->sNodeDBTable
[iNodeIndex
].dwTSC47_16
= 0;
583 pMgmt
->sNodeDBTable
[iNodeIndex
].wTSC15_0
= 0;
584 pMgmt
->sNodeDBTable
[iNodeIndex
].byCipherSuite
= 0;
585 memset(&pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[0],
593 memcpy(abyKey
, param
->u
.crypt
.key
, param
->u
.crypt
.key_len
);
594 // copy to node key tbl
595 pMgmt
->sNodeDBTable
[iNodeIndex
].byKeyIndex
= param
->u
.crypt
.idx
;
596 pMgmt
->sNodeDBTable
[iNodeIndex
].uWepKeyLength
= param
->u
.crypt
.key_len
;
597 memcpy(&pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[0],
599 param
->u
.crypt
.key_len
602 dwKeyIndex
= (DWORD
)(param
->u
.crypt
.idx
);
603 if (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) {
604 pDevice
->byKeyIndex
= (BYTE
)dwKeyIndex
;
605 pDevice
->bTransmitKey
= TRUE
;
606 dwKeyIndex
|= (1 << 31);
609 if (param
->u
.crypt
.alg
== WPA_ALG_WEP
) {
611 if ((pDevice
->bEnable8021x
== FALSE
) || (iNodeIndex
== 0)) {
612 KeybSetDefaultKey(&(pDevice
->sKey
),
613 dwKeyIndex
& ~(BIT30
| USE_KEYRSC
),
614 param
->u
.crypt
.key_len
,
622 // 8021x enable, individual key
623 dwKeyIndex
|= (1 << 30); // set pairwise key
624 if (KeybSetKey(&(pDevice
->sKey
),
626 dwKeyIndex
& ~(USE_KEYRSC
),
627 param
->u
.crypt
.key_len
,
632 pDevice
->byLocalID
) == TRUE
) {
634 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= TRUE
;
638 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= FALSE
;
639 bKeyTableFull
= TRUE
;
642 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
643 pDevice
->bEncryptionEnable
= TRUE
;
644 pMgmt
->byCSSPK
= KEY_CTL_WEP
;
645 pMgmt
->byCSSGK
= KEY_CTL_WEP
;
646 pMgmt
->sNodeDBTable
[iNodeIndex
].byCipherSuite
= KEY_CTL_WEP
;
647 pMgmt
->sNodeDBTable
[iNodeIndex
].dwKeyIndex
= dwKeyIndex
;
651 if (param
->u
.crypt
.seq
) {
652 memcpy(&abySeq
, param
->u
.crypt
.seq
, 8);
653 for (ii
= 0 ; ii
< 8 ; ii
++) {
654 KeyRSC
|= (abySeq
[ii
] << (ii
* 8));
656 dwKeyIndex
|= 1 << 29;
657 pMgmt
->sNodeDBTable
[iNodeIndex
].KeyRSC
= KeyRSC
;
660 if (param
->u
.crypt
.alg
== WPA_ALG_TKIP
) {
661 if (param
->u
.crypt
.key_len
!= MAX_KEY_LEN
)
663 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
664 byKeyDecMode
= KEY_CTL_TKIP
;
665 pMgmt
->byCSSPK
= KEY_CTL_TKIP
;
666 pMgmt
->byCSSGK
= KEY_CTL_TKIP
;
669 if (param
->u
.crypt
.alg
== WPA_ALG_CCMP
) {
670 if ((param
->u
.crypt
.key_len
!= AES_KEY_LEN
) ||
671 (pDevice
->byLocalID
<= REV_ID_VT3253_A1
))
673 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
674 byKeyDecMode
= KEY_CTL_CCMP
;
675 pMgmt
->byCSSPK
= KEY_CTL_CCMP
;
676 pMgmt
->byCSSGK
= KEY_CTL_CCMP
;
680 if (iNodeIndex
== 0) {
681 KeybSetDefaultKey(&(pDevice
->sKey
),
683 param
->u
.crypt
.key_len
,
689 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= TRUE
;
692 dwKeyIndex
|= (1 << 30); // set pairwise key
693 if (KeybSetKey(&(pDevice
->sKey
),
696 param
->u
.crypt
.key_len
,
701 pDevice
->byLocalID
) == TRUE
) {
703 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= TRUE
;
707 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= FALSE
;
708 bKeyTableFull
= TRUE
;
709 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Key Table Full\n");
714 if (bKeyTableFull
== TRUE
) {
715 wKeyCtl
&= 0x7F00; // clear all key control filed
716 wKeyCtl
|= (byKeyDecMode
<< 4);
717 wKeyCtl
|= (byKeyDecMode
);
718 wKeyCtl
|= 0x0044; // use group key for all address
719 wKeyCtl
|= 0x4000; // disable KeyTable[MAX_KEY_TABLE-1] on-fly to genernate rx int
720 MACvSetDefaultKeyCtl(pDevice
->PortOffset
, wKeyCtl
, MAX_KEY_TABLE
-1, pDevice
->byLocalID
);
723 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Set key sta_index= %d \n", iNodeIndex
);
724 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" tx_index=%d len=%d \n", param
->u
.crypt
.idx
,
725 param
->u
.crypt
.key_len
);
726 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" key=%x-%x-%x-%x-%x-xxxxx \n",
727 pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[0],
728 pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[1],
729 pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[2],
730 pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[3],
731 pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[4]
735 pDevice
->bEncryptionEnable
= TRUE
;
736 pMgmt
->sNodeDBTable
[iNodeIndex
].byCipherSuite
= byKeyDecMode
;
737 pMgmt
->sNodeDBTable
[iNodeIndex
].dwKeyIndex
= dwKeyIndex
;
738 pMgmt
->sNodeDBTable
[iNodeIndex
].dwTSC47_16
= 0;
739 pMgmt
->sNodeDBTable
[iNodeIndex
].wTSC15_0
= 0;
748 * get each stations encryption key
759 static int hostap_get_encryption(PSDevice pDevice
,
760 struct viawget_hostapd_param
*param
,
763 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
769 param
->u
.crypt
.err
= 0;
771 if (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
772 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
773 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
776 if (BSSDBbIsSTAInNodeDB(pMgmt
, param
->sta_addr
, &iNodeIndex
) == FALSE
) {
777 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
778 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"hostap_get_encryption: HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
782 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"hostap_get_encryption: %d\n", iNodeIndex
);
783 memset(param
->u
.crypt
.seq
, 0, 8);
784 for (ii
= 0 ; ii
< 8 ; ii
++) {
785 param
->u
.crypt
.seq
[ii
] = (BYTE
)pMgmt
->sNodeDBTable
[iNodeIndex
].KeyRSC
>> (ii
* 8);
794 * hostap_ioctl main function supported for hostap deamon.
806 int hostap_ioctl(PSDevice pDevice
, struct iw_point
*p
)
808 struct viawget_hostapd_param
*param
;
812 if (p
->length
< sizeof(struct viawget_hostapd_param
) ||
813 p
->length
> VIAWGET_HOSTAPD_MAX_BUF_SIZE
|| !p
->pointer
)
816 param
= (struct viawget_hostapd_param
*) kmalloc((int)p
->length
, (int)GFP_KERNEL
);
820 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
825 switch (param
->cmd
) {
826 case VIAWGET_HOSTAPD_SET_ENCRYPTION
:
827 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_SET_ENCRYPTION \n");
828 spin_lock_irq(&pDevice
->lock
);
829 ret
= hostap_set_encryption(pDevice
, param
, p
->length
);
830 spin_unlock_irq(&pDevice
->lock
);
832 case VIAWGET_HOSTAPD_GET_ENCRYPTION
:
833 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_GET_ENCRYPTION \n");
834 spin_lock_irq(&pDevice
->lock
);
835 ret
= hostap_get_encryption(pDevice
, param
, p
->length
);
836 spin_unlock_irq(&pDevice
->lock
);
838 case VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR
:
839 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR \n");
842 case VIAWGET_HOSTAPD_FLUSH
:
843 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_FLUSH \n");
844 spin_lock_irq(&pDevice
->lock
);
845 hostap_flush_sta(pDevice
);
846 spin_unlock_irq(&pDevice
->lock
);
848 case VIAWGET_HOSTAPD_ADD_STA
:
849 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_ADD_STA \n");
850 spin_lock_irq(&pDevice
->lock
);
851 ret
= hostap_add_sta(pDevice
, param
);
852 spin_unlock_irq(&pDevice
->lock
);
854 case VIAWGET_HOSTAPD_REMOVE_STA
:
855 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_REMOVE_STA \n");
856 spin_lock_irq(&pDevice
->lock
);
857 ret
= hostap_remove_sta(pDevice
, param
);
858 spin_unlock_irq(&pDevice
->lock
);
860 case VIAWGET_HOSTAPD_GET_INFO_STA
:
861 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_GET_INFO_STA \n");
862 ret
= hostap_get_info_sta(pDevice
, param
);
866 case VIAWGET_HOSTAPD_RESET_TXEXC_STA:
867 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_RESET_TXEXC_STA \n");
868 ret = hostap_reset_txexc_sta(pDevice, param);
871 case VIAWGET_HOSTAPD_SET_FLAGS_STA
:
872 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_SET_FLAGS_STA \n");
873 ret
= hostap_set_flags_sta(pDevice
, param
);
876 case VIAWGET_HOSTAPD_MLME
:
877 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_MLME \n");
880 case VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT
:
881 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT \n");
882 ret
= hostap_set_generic_element(pDevice
, param
);
885 case VIAWGET_HOSTAPD_SCAN_REQ
:
886 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_SCAN_REQ \n");
889 case VIAWGET_HOSTAPD_STA_CLEAR_STATS
:
890 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_STA_CLEAR_STATS \n");
894 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"hostap_ioctl: unknown cmd=%d\n",
901 if ((ret
== 0) && ap_ioctl
) {
902 if (copy_to_user(p
->pointer
, param
, p
->length
)) {