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
;
106 const struct net_device_ops apdev_netdev_ops
= {
107 .ndo_start_xmit
= pDevice
->tx_80211
,
110 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Enabling hostapd mode\n", dev
->name
);
112 pDevice
->apdev
= (struct net_device
*)kmalloc(sizeof(struct net_device
), GFP_KERNEL
);
113 if (pDevice
->apdev
== NULL
)
115 memset(pDevice
->apdev
, 0, sizeof(struct net_device
));
117 apdev_priv
= netdev_priv(pDevice
->apdev
);
118 *apdev_priv
= *pDevice
;
119 memcpy(pDevice
->apdev
->dev_addr
, dev
->dev_addr
, ETH_ALEN
);
121 pDevice
->apdev
->netdev_ops
= &apdev_netdev_ops
;
123 pDevice
->apdev
->type
= ARPHRD_IEEE80211
;
125 pDevice
->apdev
->base_addr
= dev
->base_addr
;
126 pDevice
->apdev
->irq
= dev
->irq
;
127 pDevice
->apdev
->mem_start
= dev
->mem_start
;
128 pDevice
->apdev
->mem_end
= dev
->mem_end
;
129 sprintf(pDevice
->apdev
->name
, "%sap", dev
->name
);
131 ret
= register_netdevice(pDevice
->apdev
);
133 ret
= register_netdev(pDevice
->apdev
);
135 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: register_netdevice(AP) failed!\n",
140 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Registered netdevice %s for AP management\n",
141 dev
->name
, pDevice
->apdev
->name
);
143 KeyvInitTable(&pDevice
->sKey
, pDevice
->PortOffset
);
150 * unregister net_device(AP)
162 static int hostap_disable_hostapd(PSDevice pDevice
, int rtnl_locked
)
165 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: disabling hostapd mode\n", pDevice
->dev
->name
);
167 if (pDevice
->apdev
&& pDevice
->apdev
->name
&& pDevice
->apdev
->name
[0]) {
169 unregister_netdevice(pDevice
->apdev
);
171 unregister_netdev(pDevice
->apdev
);
172 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Netdevice %s unregistered\n",
173 pDevice
->dev
->name
, pDevice
->apdev
->name
);
175 kfree(pDevice
->apdev
);
176 pDevice
->apdev
= NULL
;
177 pDevice
->bEnable8021x
= FALSE
;
178 pDevice
->bEnableHostWEP
= FALSE
;
179 pDevice
->bEncryptionEnable
= FALSE
;
181 //4.2007-0118-03,<Add> by EinsnLiu
182 //execute some clear work
183 pDevice
->pMgmt
->byCSSPK
=KEY_CTL_NONE
;
184 pDevice
->pMgmt
->byCSSGK
=KEY_CTL_NONE
;
185 KeyvInitTable(&pDevice
->sKey
,pDevice
->PortOffset
);
193 * Set enable/disable hostapd mode
205 int hostap_set_hostapd(PSDevice pDevice
, int val
, int rtnl_locked
)
207 if (val
< 0 || val
> 1)
210 if (pDevice
->bEnableHostapd
== val
)
213 pDevice
->bEnableHostapd
= val
;
216 return hostap_enable_hostapd(pDevice
, rtnl_locked
);
218 return hostap_disable_hostapd(pDevice
, rtnl_locked
);
224 * remove station function supported for hostap deamon
235 static int hostap_remove_sta(PSDevice pDevice
,
236 struct viawget_hostapd_param
*param
)
241 if (BSSDBbIsSTAInNodeDB(pDevice
->pMgmt
, param
->sta_addr
, &uNodeIndex
)) {
242 BSSvRemoveOneNode(pDevice
, uNodeIndex
);
252 * add a station from hostap deamon
263 static int hostap_add_sta(PSDevice pDevice
,
264 struct viawget_hostapd_param
*param
)
266 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
270 if (!BSSDBbIsSTAInNodeDB(pMgmt
, param
->sta_addr
, &uNodeIndex
)) {
271 BSSvCreateOneNode((PSDevice
)pDevice
, &uNodeIndex
);
273 memcpy(pMgmt
->sNodeDBTable
[uNodeIndex
].abyMACAddr
, param
->sta_addr
, WLAN_ADDR_LEN
);
274 pMgmt
->sNodeDBTable
[uNodeIndex
].eNodeState
= NODE_ASSOC
;
275 pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
= param
->u
.add_sta
.capability
;
276 // TODO listenInterval
277 // pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = 1;
278 pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
= FALSE
;
279 pMgmt
->sNodeDBTable
[uNodeIndex
].bySuppRate
= param
->u
.add_sta
.tx_supp_rates
;
282 pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
=
283 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
;
284 // set max basic rate
285 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxBasicRate
= RATE_2M
;
286 // Todo: check sta preamble, if ap can't support, set status code
287 pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
=
288 WLAN_GET_CAP_INFO_SHORTPREAMBLE(pMgmt
->sNodeDBTable
[uNodeIndex
].wCapInfo
);
290 pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
= (WORD
)param
->u
.add_sta
.aid
;
292 pMgmt
->sNodeDBTable
[uNodeIndex
].ulLastRxJiffer
= jiffies
;
294 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Add STA AID= %d \n", pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
);
295 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",
303 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Max Support rate = %d \n",
304 pMgmt
->sNodeDBTable
[uNodeIndex
].wMaxSuppRate
);
323 static int hostap_get_info_sta(PSDevice pDevice
,
324 struct viawget_hostapd_param
*param
)
326 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
329 if (BSSDBbIsSTAInNodeDB(pMgmt
, param
->sta_addr
, &uNodeIndex
)) {
330 param
->u
.get_info_sta
.inactive_sec
=
331 (jiffies
- pMgmt
->sNodeDBTable
[uNodeIndex
].ulLastRxJiffer
) / HZ
;
333 //param->u.get_info_sta.txexc = pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts;
357 static int hostap_reset_txexc_sta(PSDevice pDevice,
358 struct viawget_hostapd_param *param)
360 PSMgmtObject pMgmt = pDevice->pMgmt;
363 if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) {
364 pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts = 0;
387 static int hostap_set_flags_sta(PSDevice pDevice
,
388 struct viawget_hostapd_param
*param
)
390 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
393 if (BSSDBbIsSTAInNodeDB(pMgmt
, param
->sta_addr
, &uNodeIndex
)) {
394 pMgmt
->sNodeDBTable
[uNodeIndex
].dwFlags
|= param
->u
.set_flags_sta
.flags_or
;
395 pMgmt
->sNodeDBTable
[uNodeIndex
].dwFlags
&= param
->u
.set_flags_sta
.flags_and
;
396 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" dwFlags = %x \n",
397 (UINT
)pMgmt
->sNodeDBTable
[uNodeIndex
].dwFlags
);
410 * set generic element (wpa ie)
421 static int hostap_set_generic_element(PSDevice pDevice
,
422 struct viawget_hostapd_param
*param
)
424 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
428 memcpy( pMgmt
->abyWPAIE
,
429 param
->u
.generic_elem
.data
,
430 param
->u
.generic_elem
.len
433 pMgmt
->wWPAIELen
= param
->u
.generic_elem
.len
;
435 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"pMgmt->wWPAIELen = %d\n", pMgmt
->wWPAIELen
);
438 if (pMgmt
->wWPAIELen
== 0) {
439 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
440 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" No WPAIE, Disable WPA \n");
443 if ((pMgmt
->abyWPAIE
[0] == WLAN_EID_RSN_WPA
) ||
444 (pMgmt
->abyWPAIE
[0] == WLAN_EID_RSN
)) {
445 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
446 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set WPAIE enable WPA\n");
456 * flush station nodes table.
467 static void hostap_flush_sta(PSDevice pDevice
)
469 // reserved node index =0 for multicast node.
470 BSSvClearNodeDBTable(pDevice
, 1);
471 pDevice
->uAssocCount
= 0;
478 * set each stations encryption key
489 static int hostap_set_encryption(PSDevice pDevice
,
490 struct viawget_hostapd_param
*param
,
493 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
494 DWORD dwKeyIndex
= 0;
495 BYTE abyKey
[MAX_KEY_LEN
];
496 BYTE abySeq
[MAX_KEY_LEN
];
497 NDIS_802_11_KEY_RSC KeyRSC
;
498 BYTE byKeyDecMode
= KEY_CTL_WEP
;
502 BOOL bKeyTableFull
= FALSE
;
506 param
->u
.crypt
.err
= 0;
509 (int) ((char *) param->u.crypt.key - (char *) param) +
510 param->u.crypt.key_len)
514 if (param
->u
.crypt
.alg
> WPA_ALG_CCMP
)
518 if ((param
->u
.crypt
.idx
> 3) || (param
->u
.crypt
.key_len
> MAX_KEY_LEN
)) {
519 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_KEY_SET_FAILED
;
520 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" HOSTAP_CRYPT_ERR_KEY_SET_FAILED\n");
524 if (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
525 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
526 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
527 if (param
->u
.crypt
.idx
>= MAX_GROUP_KEY
)
532 if (BSSDBbIsSTAInNodeDB(pMgmt
, param
->sta_addr
, &iNodeIndex
) == FALSE
) {
533 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
534 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
538 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" hostap_set_encryption: sta_index %d \n", iNodeIndex
);
539 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" hostap_set_encryption: alg %d \n", param
->u
.crypt
.alg
);
541 if (param
->u
.crypt
.alg
== WPA_ALG_NONE
) {
543 if (pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
== TRUE
) {
544 if (KeybRemoveKey(&(pDevice
->sKey
),
546 pMgmt
->sNodeDBTable
[iNodeIndex
].dwKeyIndex
,
547 pDevice
->PortOffset
) == FALSE
) {
548 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"KeybRemoveKey fail \n");
550 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= FALSE
;
552 pMgmt
->sNodeDBTable
[iNodeIndex
].byKeyIndex
= 0;
553 pMgmt
->sNodeDBTable
[iNodeIndex
].dwKeyIndex
= 0;
554 pMgmt
->sNodeDBTable
[iNodeIndex
].uWepKeyLength
= 0;
555 pMgmt
->sNodeDBTable
[iNodeIndex
].KeyRSC
= 0;
556 pMgmt
->sNodeDBTable
[iNodeIndex
].dwTSC47_16
= 0;
557 pMgmt
->sNodeDBTable
[iNodeIndex
].wTSC15_0
= 0;
558 pMgmt
->sNodeDBTable
[iNodeIndex
].byCipherSuite
= 0;
559 memset(&pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[0],
567 memcpy(abyKey
, param
->u
.crypt
.key
, param
->u
.crypt
.key_len
);
568 // copy to node key tbl
569 pMgmt
->sNodeDBTable
[iNodeIndex
].byKeyIndex
= param
->u
.crypt
.idx
;
570 pMgmt
->sNodeDBTable
[iNodeIndex
].uWepKeyLength
= param
->u
.crypt
.key_len
;
571 memcpy(&pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[0],
573 param
->u
.crypt
.key_len
576 dwKeyIndex
= (DWORD
)(param
->u
.crypt
.idx
);
577 if (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) {
578 pDevice
->byKeyIndex
= (BYTE
)dwKeyIndex
;
579 pDevice
->bTransmitKey
= TRUE
;
580 dwKeyIndex
|= (1 << 31);
583 if (param
->u
.crypt
.alg
== WPA_ALG_WEP
) {
585 if ((pDevice
->bEnable8021x
== FALSE
) || (iNodeIndex
== 0)) {
586 KeybSetDefaultKey(&(pDevice
->sKey
),
587 dwKeyIndex
& ~(BIT30
| USE_KEYRSC
),
588 param
->u
.crypt
.key_len
,
596 // 8021x enable, individual key
597 dwKeyIndex
|= (1 << 30); // set pairwise key
598 if (KeybSetKey(&(pDevice
->sKey
),
600 dwKeyIndex
& ~(USE_KEYRSC
),
601 param
->u
.crypt
.key_len
,
606 pDevice
->byLocalID
) == TRUE
) {
608 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= TRUE
;
612 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= FALSE
;
613 bKeyTableFull
= TRUE
;
616 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
617 pDevice
->bEncryptionEnable
= TRUE
;
618 pMgmt
->byCSSPK
= KEY_CTL_WEP
;
619 pMgmt
->byCSSGK
= KEY_CTL_WEP
;
620 pMgmt
->sNodeDBTable
[iNodeIndex
].byCipherSuite
= KEY_CTL_WEP
;
621 pMgmt
->sNodeDBTable
[iNodeIndex
].dwKeyIndex
= dwKeyIndex
;
625 if (param
->u
.crypt
.seq
) {
626 memcpy(&abySeq
, param
->u
.crypt
.seq
, 8);
627 for (ii
= 0 ; ii
< 8 ; ii
++) {
628 KeyRSC
|= (abySeq
[ii
] << (ii
* 8));
630 dwKeyIndex
|= 1 << 29;
631 pMgmt
->sNodeDBTable
[iNodeIndex
].KeyRSC
= KeyRSC
;
634 if (param
->u
.crypt
.alg
== WPA_ALG_TKIP
) {
635 if (param
->u
.crypt
.key_len
!= MAX_KEY_LEN
)
637 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
638 byKeyDecMode
= KEY_CTL_TKIP
;
639 pMgmt
->byCSSPK
= KEY_CTL_TKIP
;
640 pMgmt
->byCSSGK
= KEY_CTL_TKIP
;
643 if (param
->u
.crypt
.alg
== WPA_ALG_CCMP
) {
644 if ((param
->u
.crypt
.key_len
!= AES_KEY_LEN
) ||
645 (pDevice
->byLocalID
<= REV_ID_VT3253_A1
))
647 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
648 byKeyDecMode
= KEY_CTL_CCMP
;
649 pMgmt
->byCSSPK
= KEY_CTL_CCMP
;
650 pMgmt
->byCSSGK
= KEY_CTL_CCMP
;
654 if (iNodeIndex
== 0) {
655 KeybSetDefaultKey(&(pDevice
->sKey
),
657 param
->u
.crypt
.key_len
,
663 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= TRUE
;
666 dwKeyIndex
|= (1 << 30); // set pairwise key
667 if (KeybSetKey(&(pDevice
->sKey
),
670 param
->u
.crypt
.key_len
,
675 pDevice
->byLocalID
) == TRUE
) {
677 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= TRUE
;
681 pMgmt
->sNodeDBTable
[iNodeIndex
].bOnFly
= FALSE
;
682 bKeyTableFull
= TRUE
;
683 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Key Table Full\n");
688 if (bKeyTableFull
== TRUE
) {
689 wKeyCtl
&= 0x7F00; // clear all key control filed
690 wKeyCtl
|= (byKeyDecMode
<< 4);
691 wKeyCtl
|= (byKeyDecMode
);
692 wKeyCtl
|= 0x0044; // use group key for all address
693 wKeyCtl
|= 0x4000; // disable KeyTable[MAX_KEY_TABLE-1] on-fly to genernate rx int
694 MACvSetDefaultKeyCtl(pDevice
->PortOffset
, wKeyCtl
, MAX_KEY_TABLE
-1, pDevice
->byLocalID
);
697 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Set key sta_index= %d \n", iNodeIndex
);
698 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" tx_index=%d len=%d \n", param
->u
.crypt
.idx
,
699 param
->u
.crypt
.key_len
);
700 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" key=%x-%x-%x-%x-%x-xxxxx \n",
701 pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[0],
702 pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[1],
703 pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[2],
704 pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[3],
705 pMgmt
->sNodeDBTable
[iNodeIndex
].abyWepKey
[4]
709 pDevice
->bEncryptionEnable
= TRUE
;
710 pMgmt
->sNodeDBTable
[iNodeIndex
].byCipherSuite
= byKeyDecMode
;
711 pMgmt
->sNodeDBTable
[iNodeIndex
].dwKeyIndex
= dwKeyIndex
;
712 pMgmt
->sNodeDBTable
[iNodeIndex
].dwTSC47_16
= 0;
713 pMgmt
->sNodeDBTable
[iNodeIndex
].wTSC15_0
= 0;
722 * get each stations encryption key
733 static int hostap_get_encryption(PSDevice pDevice
,
734 struct viawget_hostapd_param
*param
,
737 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
743 param
->u
.crypt
.err
= 0;
745 if (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
746 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
747 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
750 if (BSSDBbIsSTAInNodeDB(pMgmt
, param
->sta_addr
, &iNodeIndex
) == FALSE
) {
751 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
752 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"hostap_get_encryption: HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
756 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"hostap_get_encryption: %d\n", iNodeIndex
);
757 memset(param
->u
.crypt
.seq
, 0, 8);
758 for (ii
= 0 ; ii
< 8 ; ii
++) {
759 param
->u
.crypt
.seq
[ii
] = (BYTE
)pMgmt
->sNodeDBTable
[iNodeIndex
].KeyRSC
>> (ii
* 8);
768 * hostap_ioctl main function supported for hostap deamon.
780 int hostap_ioctl(PSDevice pDevice
, struct iw_point
*p
)
782 struct viawget_hostapd_param
*param
;
786 if (p
->length
< sizeof(struct viawget_hostapd_param
) ||
787 p
->length
> VIAWGET_HOSTAPD_MAX_BUF_SIZE
|| !p
->pointer
)
790 param
= (struct viawget_hostapd_param
*) kmalloc((int)p
->length
, (int)GFP_KERNEL
);
794 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
799 switch (param
->cmd
) {
800 case VIAWGET_HOSTAPD_SET_ENCRYPTION
:
801 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_SET_ENCRYPTION \n");
802 spin_lock_irq(&pDevice
->lock
);
803 ret
= hostap_set_encryption(pDevice
, param
, p
->length
);
804 spin_unlock_irq(&pDevice
->lock
);
806 case VIAWGET_HOSTAPD_GET_ENCRYPTION
:
807 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_GET_ENCRYPTION \n");
808 spin_lock_irq(&pDevice
->lock
);
809 ret
= hostap_get_encryption(pDevice
, param
, p
->length
);
810 spin_unlock_irq(&pDevice
->lock
);
812 case VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR
:
813 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR \n");
816 case VIAWGET_HOSTAPD_FLUSH
:
817 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_FLUSH \n");
818 spin_lock_irq(&pDevice
->lock
);
819 hostap_flush_sta(pDevice
);
820 spin_unlock_irq(&pDevice
->lock
);
822 case VIAWGET_HOSTAPD_ADD_STA
:
823 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_ADD_STA \n");
824 spin_lock_irq(&pDevice
->lock
);
825 ret
= hostap_add_sta(pDevice
, param
);
826 spin_unlock_irq(&pDevice
->lock
);
828 case VIAWGET_HOSTAPD_REMOVE_STA
:
829 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_REMOVE_STA \n");
830 spin_lock_irq(&pDevice
->lock
);
831 ret
= hostap_remove_sta(pDevice
, param
);
832 spin_unlock_irq(&pDevice
->lock
);
834 case VIAWGET_HOSTAPD_GET_INFO_STA
:
835 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_GET_INFO_STA \n");
836 ret
= hostap_get_info_sta(pDevice
, param
);
840 case VIAWGET_HOSTAPD_RESET_TXEXC_STA:
841 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_RESET_TXEXC_STA \n");
842 ret = hostap_reset_txexc_sta(pDevice, param);
845 case VIAWGET_HOSTAPD_SET_FLAGS_STA
:
846 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_SET_FLAGS_STA \n");
847 ret
= hostap_set_flags_sta(pDevice
, param
);
850 case VIAWGET_HOSTAPD_MLME
:
851 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_MLME \n");
854 case VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT
:
855 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT \n");
856 ret
= hostap_set_generic_element(pDevice
, param
);
859 case VIAWGET_HOSTAPD_SCAN_REQ
:
860 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_SCAN_REQ \n");
863 case VIAWGET_HOSTAPD_STA_CLEAR_STATS
:
864 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_HOSTAPD_STA_CLEAR_STATS \n");
868 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"hostap_ioctl: unknown cmd=%d\n",
875 if ((ret
== 0) && ap_ioctl
) {
876 if (copy_to_user(p
->pointer
, param
, p
->length
)) {