1 /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
3 #include <linux/slab.h>
4 #include <linux/types.h>
5 #include <linux/sched.h>
6 #include <linux/ethtool.h>
7 #include <linux/if_arp.h>
8 #include <net/lib80211.h>
10 #include "hostap_wlan.h"
12 #include "hostap_ap.h"
14 static struct iw_statistics
*hostap_get_wireless_stats(struct net_device
*dev
)
16 struct hostap_interface
*iface
;
18 struct iw_statistics
*wstats
;
20 iface
= netdev_priv(dev
);
23 /* Why are we doing that ? Jean II */
24 if (iface
->type
!= HOSTAP_INTERFACE_MAIN
)
27 wstats
= &local
->wstats
;
30 wstats
->discard
.code
=
31 local
->comm_tallies
.rx_discards_wep_undecryptable
;
32 wstats
->discard
.misc
=
33 local
->comm_tallies
.rx_fcs_errors
+
34 local
->comm_tallies
.rx_discards_no_buffer
+
35 local
->comm_tallies
.tx_discards_wrong_sa
;
37 wstats
->discard
.retries
=
38 local
->comm_tallies
.tx_retry_limit_exceeded
;
39 wstats
->discard
.fragment
=
40 local
->comm_tallies
.rx_message_in_bad_msg_fragments
;
42 if (local
->iw_mode
!= IW_MODE_MASTER
&&
43 local
->iw_mode
!= IW_MODE_REPEAT
) {
46 /* RID reading might sleep and it must not be called in
47 * interrupt context or while atomic. However, this
48 * function seems to be called while atomic (at least in Linux
49 * 2.5.59). Update signal quality values only if in suitable
50 * context. Otherwise, previous values read from tick timer
54 #endif /* in_atomic */
56 if (update
&& prism2_update_comms_qual(dev
) == 0)
57 wstats
->qual
.updated
= IW_QUAL_ALL_UPDATED
|
60 wstats
->qual
.qual
= local
->comms_qual
;
61 wstats
->qual
.level
= local
->avg_signal
;
62 wstats
->qual
.noise
= local
->avg_noise
;
64 wstats
->qual
.qual
= 0;
65 wstats
->qual
.level
= 0;
66 wstats
->qual
.noise
= 0;
67 wstats
->qual
.updated
= IW_QUAL_ALL_INVALID
;
74 static int prism2_get_datarates(struct net_device
*dev
, u8
*rates
)
76 struct hostap_interface
*iface
;
82 iface
= netdev_priv(dev
);
85 len
= local
->func
->get_rid(dev
, HFA384X_RID_SUPPORTEDDATARATES
, buf
,
90 val
= le16_to_cpu(*(__le16
*) buf
); /* string length */
92 if (len
- 2 < val
|| val
> 10)
95 memcpy(rates
, buf
+ 2, val
);
100 static int prism2_get_name(struct net_device
*dev
,
101 struct iw_request_info
*info
,
102 char *name
, char *extra
)
105 int len
, i
, over2
= 0;
107 len
= prism2_get_datarates(dev
, rates
);
109 for (i
= 0; i
< len
; i
++) {
110 if (rates
[i
] == 0x0b || rates
[i
] == 0x16) {
116 strcpy(name
, over2
? "IEEE 802.11b" : "IEEE 802.11-DS");
122 static int prism2_ioctl_siwencode(struct net_device
*dev
,
123 struct iw_request_info
*info
,
124 struct iw_point
*erq
, char *keybuf
)
126 struct hostap_interface
*iface
;
129 struct lib80211_crypt_data
**crypt
;
131 iface
= netdev_priv(dev
);
132 local
= iface
->local
;
134 i
= erq
->flags
& IW_ENCODE_INDEX
;
136 i
= local
->crypt_info
.tx_keyidx
;
139 if (i
< 0 || i
>= WEP_KEYS
)
142 crypt
= &local
->crypt_info
.crypt
[i
];
144 if (erq
->flags
& IW_ENCODE_DISABLED
) {
146 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
150 if (*crypt
!= NULL
&& (*crypt
)->ops
!= NULL
&&
151 strcmp((*crypt
)->ops
->name
, "WEP") != 0) {
152 /* changing to use WEP; deinit previously used algorithm */
153 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
156 if (*crypt
== NULL
) {
157 struct lib80211_crypt_data
*new_crypt
;
159 /* take WEP into use */
160 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
162 if (new_crypt
== NULL
)
164 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
165 if (!new_crypt
->ops
) {
166 request_module("lib80211_crypt_wep");
167 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
169 if (new_crypt
->ops
&& try_module_get(new_crypt
->ops
->owner
))
170 new_crypt
->priv
= new_crypt
->ops
->init(i
);
171 if (!new_crypt
->ops
|| !new_crypt
->priv
) {
175 printk(KERN_WARNING
"%s: could not initialize WEP: "
176 "load module hostap_crypt_wep.o\n",
183 if (erq
->length
> 0) {
184 int len
= erq
->length
<= 5 ? 5 : 13;
186 if (len
> erq
->length
)
187 memset(keybuf
+ erq
->length
, 0, len
- erq
->length
);
188 (*crypt
)->ops
->set_key(keybuf
, len
, NULL
, (*crypt
)->priv
);
189 for (j
= 0; j
< WEP_KEYS
; j
++) {
190 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
196 local
->crypt_info
.tx_keyidx
= i
;
198 /* No key data - just set the default TX key index */
199 local
->crypt_info
.tx_keyidx
= i
;
203 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
205 if (hostap_set_encryption(local
)) {
206 printk(KERN_DEBUG
"%s: set_encryption failed\n", dev
->name
);
210 /* Do not reset port0 if card is in Managed mode since resetting will
211 * generate new IEEE 802.11 authentication which may end up in looping
212 * with IEEE 802.1X. Prism2 documentation seem to require port reset
213 * after WEP configuration. However, keys are apparently changed at
214 * least in Managed mode. */
215 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->func
->reset_port(dev
)) {
216 printk(KERN_DEBUG
"%s: reset_port failed\n", dev
->name
);
224 static int prism2_ioctl_giwencode(struct net_device
*dev
,
225 struct iw_request_info
*info
,
226 struct iw_point
*erq
, char *key
)
228 struct hostap_interface
*iface
;
232 struct lib80211_crypt_data
*crypt
;
234 iface
= netdev_priv(dev
);
235 local
= iface
->local
;
237 i
= erq
->flags
& IW_ENCODE_INDEX
;
239 i
= local
->crypt_info
.tx_keyidx
;
242 if (i
< 0 || i
>= WEP_KEYS
)
245 crypt
= local
->crypt_info
.crypt
[i
];
248 if (crypt
== NULL
|| crypt
->ops
== NULL
) {
250 erq
->flags
|= IW_ENCODE_DISABLED
;
254 if (strcmp(crypt
->ops
->name
, "WEP") != 0) {
255 /* only WEP is supported with wireless extensions, so just
256 * report that encryption is used */
258 erq
->flags
|= IW_ENCODE_ENABLED
;
262 /* Reads from HFA384X_RID_CNFDEFAULTKEY* return bogus values, so show
263 * the keys from driver buffer */
264 len
= crypt
->ops
->get_key(key
, WEP_KEY_LEN
, NULL
, crypt
->priv
);
265 erq
->length
= (len
>= 0 ? len
: 0);
267 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFWEPFLAGS
, &val
, 2, 1) < 0)
269 printk("CNFWEPFLAGS reading failed\n");
273 if (val
& HFA384X_WEPFLAGS_PRIVACYINVOKED
)
274 erq
->flags
|= IW_ENCODE_ENABLED
;
276 erq
->flags
|= IW_ENCODE_DISABLED
;
277 if (val
& HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED
)
278 erq
->flags
|= IW_ENCODE_RESTRICTED
;
280 erq
->flags
|= IW_ENCODE_OPEN
;
286 static int hostap_set_rate(struct net_device
*dev
)
288 struct hostap_interface
*iface
;
290 int ret
, basic_rates
;
292 iface
= netdev_priv(dev
);
293 local
= iface
->local
;
295 basic_rates
= local
->basic_rates
& local
->tx_rate_control
;
296 if (!basic_rates
|| basic_rates
!= local
->basic_rates
) {
297 printk(KERN_INFO
"%s: updating basic rate set automatically "
298 "to match with the new supported rate set\n",
301 basic_rates
= local
->tx_rate_control
;
303 local
->basic_rates
= basic_rates
;
304 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
306 printk(KERN_WARNING
"%s: failed to set "
307 "cnfBasicRates\n", dev
->name
);
310 ret
= (hostap_set_word(dev
, HFA384X_RID_TXRATECONTROL
,
311 local
->tx_rate_control
) ||
312 hostap_set_word(dev
, HFA384X_RID_CNFSUPPORTEDRATES
,
313 local
->tx_rate_control
) ||
314 local
->func
->reset_port(dev
));
317 printk(KERN_WARNING
"%s: TXRateControl/cnfSupportedRates "
318 "setting to 0x%x failed\n",
319 dev
->name
, local
->tx_rate_control
);
322 /* Update TX rate configuration for all STAs based on new operational
324 hostap_update_rates(local
);
330 static int prism2_ioctl_siwrate(struct net_device
*dev
,
331 struct iw_request_info
*info
,
332 struct iw_param
*rrq
, char *extra
)
334 struct hostap_interface
*iface
;
337 iface
= netdev_priv(dev
);
338 local
= iface
->local
;
341 switch (rrq
->value
) {
343 local
->tx_rate_control
= HFA384X_RATES_11MBPS
;
346 local
->tx_rate_control
= HFA384X_RATES_5MBPS
;
349 local
->tx_rate_control
= HFA384X_RATES_2MBPS
;
352 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
355 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
356 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
357 HFA384X_RATES_11MBPS
;
361 switch (rrq
->value
) {
363 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
364 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
365 HFA384X_RATES_11MBPS
;
368 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
369 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
;
372 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
376 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
379 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
380 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
381 HFA384X_RATES_11MBPS
;
386 return hostap_set_rate(dev
);
390 static int prism2_ioctl_giwrate(struct net_device
*dev
,
391 struct iw_request_info
*info
,
392 struct iw_param
*rrq
, char *extra
)
395 struct hostap_interface
*iface
;
399 iface
= netdev_priv(dev
);
400 local
= iface
->local
;
402 if (local
->func
->get_rid(dev
, HFA384X_RID_TXRATECONTROL
, &val
, 2, 1) <
406 if ((val
& 0x1) && (val
> 1))
411 if (local
->iw_mode
== IW_MODE_MASTER
&& local
->ap
!= NULL
&&
412 !local
->fw_tx_rate_control
) {
413 /* HFA384X_RID_CURRENTTXRATE seems to always be 2 Mbps in
414 * Host AP mode, so use the recorded TX rate of the last sent
416 rrq
->value
= local
->ap
->last_tx_rate
> 0 ?
417 local
->ap
->last_tx_rate
* 100000 : 11000000;
421 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTTXRATE
, &val
, 2, 1) <
426 case HFA384X_RATES_1MBPS
:
427 rrq
->value
= 1000000;
429 case HFA384X_RATES_2MBPS
:
430 rrq
->value
= 2000000;
432 case HFA384X_RATES_5MBPS
:
433 rrq
->value
= 5500000;
435 case HFA384X_RATES_11MBPS
:
436 rrq
->value
= 11000000;
439 /* should not happen */
440 rrq
->value
= 11000000;
449 static int prism2_ioctl_siwsens(struct net_device
*dev
,
450 struct iw_request_info
*info
,
451 struct iw_param
*sens
, char *extra
)
453 struct hostap_interface
*iface
;
456 iface
= netdev_priv(dev
);
457 local
= iface
->local
;
459 /* Set the desired AP density */
460 if (sens
->value
< 1 || sens
->value
> 3)
463 if (hostap_set_word(dev
, HFA384X_RID_CNFSYSTEMSCALE
, sens
->value
) ||
464 local
->func
->reset_port(dev
))
470 static int prism2_ioctl_giwsens(struct net_device
*dev
,
471 struct iw_request_info
*info
,
472 struct iw_param
*sens
, char *extra
)
474 struct hostap_interface
*iface
;
478 iface
= netdev_priv(dev
);
479 local
= iface
->local
;
481 /* Get the current AP density */
482 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFSYSTEMSCALE
, &val
, 2, 1) <
486 sens
->value
= le16_to_cpu(val
);
493 /* Deprecated in new wireless extension API */
494 static int prism2_ioctl_giwaplist(struct net_device
*dev
,
495 struct iw_request_info
*info
,
496 struct iw_point
*data
, char *extra
)
498 struct hostap_interface
*iface
;
500 struct sockaddr
*addr
;
501 struct iw_quality
*qual
;
503 iface
= netdev_priv(dev
);
504 local
= iface
->local
;
506 if (local
->iw_mode
!= IW_MODE_MASTER
) {
507 printk(KERN_DEBUG
"SIOCGIWAPLIST is currently only supported "
508 "in Host AP mode\n");
513 addr
= kmalloc(sizeof(struct sockaddr
) * IW_MAX_AP
, GFP_KERNEL
);
514 qual
= kmalloc(sizeof(struct iw_quality
) * IW_MAX_AP
, GFP_KERNEL
);
515 if (addr
== NULL
|| qual
== NULL
) {
522 data
->length
= prism2_ap_get_sta_qual(local
, addr
, qual
, IW_MAX_AP
, 1);
524 memcpy(extra
, &addr
, sizeof(struct sockaddr
) * data
->length
);
525 data
->flags
= 1; /* has quality information */
526 memcpy(extra
+ sizeof(struct sockaddr
) * data
->length
, &qual
,
527 sizeof(struct iw_quality
) * data
->length
);
535 static int prism2_ioctl_siwrts(struct net_device
*dev
,
536 struct iw_request_info
*info
,
537 struct iw_param
*rts
, char *extra
)
539 struct hostap_interface
*iface
;
543 iface
= netdev_priv(dev
);
544 local
= iface
->local
;
547 val
= cpu_to_le16(2347);
548 else if (rts
->value
< 0 || rts
->value
> 2347)
551 val
= cpu_to_le16(rts
->value
);
553 if (local
->func
->set_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2) ||
554 local
->func
->reset_port(dev
))
557 local
->rts_threshold
= rts
->value
;
562 static int prism2_ioctl_giwrts(struct net_device
*dev
,
563 struct iw_request_info
*info
,
564 struct iw_param
*rts
, char *extra
)
566 struct hostap_interface
*iface
;
570 iface
= netdev_priv(dev
);
571 local
= iface
->local
;
573 if (local
->func
->get_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2, 1) <
577 rts
->value
= le16_to_cpu(val
);
578 rts
->disabled
= (rts
->value
== 2347);
585 static int prism2_ioctl_siwfrag(struct net_device
*dev
,
586 struct iw_request_info
*info
,
587 struct iw_param
*rts
, char *extra
)
589 struct hostap_interface
*iface
;
593 iface
= netdev_priv(dev
);
594 local
= iface
->local
;
597 val
= cpu_to_le16(2346);
598 else if (rts
->value
< 256 || rts
->value
> 2346)
601 val
= cpu_to_le16(rts
->value
& ~0x1); /* even numbers only */
603 local
->fragm_threshold
= rts
->value
& ~0x1;
604 if (local
->func
->set_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
, &val
,
606 || local
->func
->reset_port(dev
))
612 static int prism2_ioctl_giwfrag(struct net_device
*dev
,
613 struct iw_request_info
*info
,
614 struct iw_param
*rts
, char *extra
)
616 struct hostap_interface
*iface
;
620 iface
= netdev_priv(dev
);
621 local
= iface
->local
;
623 if (local
->func
->get_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
,
627 rts
->value
= le16_to_cpu(val
);
628 rts
->disabled
= (rts
->value
== 2346);
635 #ifndef PRISM2_NO_STATION_MODES
636 static int hostap_join_ap(struct net_device
*dev
)
638 struct hostap_interface
*iface
;
640 struct hfa384x_join_request req
;
643 struct hfa384x_hostscan_result
*entry
;
645 iface
= netdev_priv(dev
);
646 local
= iface
->local
;
648 memcpy(req
.bssid
, local
->preferred_ap
, ETH_ALEN
);
651 spin_lock_irqsave(&local
->lock
, flags
);
652 for (i
= 0; i
< local
->last_scan_results_count
; i
++) {
653 if (!local
->last_scan_results
)
655 entry
= &local
->last_scan_results
[i
];
656 if (memcmp(local
->preferred_ap
, entry
->bssid
, ETH_ALEN
) == 0) {
657 req
.channel
= entry
->chid
;
661 spin_unlock_irqrestore(&local
->lock
, flags
);
663 if (local
->func
->set_rid(dev
, HFA384X_RID_JOINREQUEST
, &req
,
665 printk(KERN_DEBUG
"%s: JoinRequest %pM failed\n",
666 dev
->name
, local
->preferred_ap
);
670 printk(KERN_DEBUG
"%s: Trying to join BSSID %pM\n",
671 dev
->name
, local
->preferred_ap
);
675 #endif /* PRISM2_NO_STATION_MODES */
678 static int prism2_ioctl_siwap(struct net_device
*dev
,
679 struct iw_request_info
*info
,
680 struct sockaddr
*ap_addr
, char *extra
)
682 #ifdef PRISM2_NO_STATION_MODES
684 #else /* PRISM2_NO_STATION_MODES */
685 struct hostap_interface
*iface
;
688 iface
= netdev_priv(dev
);
689 local
= iface
->local
;
691 memcpy(local
->preferred_ap
, &ap_addr
->sa_data
, ETH_ALEN
);
693 if (local
->host_roaming
== 1 && local
->iw_mode
== IW_MODE_INFRA
) {
694 struct hfa384x_scan_request scan_req
;
695 memset(&scan_req
, 0, sizeof(scan_req
));
696 scan_req
.channel_list
= cpu_to_le16(0x3fff);
697 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
698 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
,
699 &scan_req
, sizeof(scan_req
))) {
700 printk(KERN_DEBUG
"%s: ScanResults request failed - "
701 "preferred AP delayed to next unsolicited "
702 "scan\n", dev
->name
);
704 } else if (local
->host_roaming
== 2 &&
705 local
->iw_mode
== IW_MODE_INFRA
) {
706 if (hostap_join_ap(dev
))
709 printk(KERN_DEBUG
"%s: Preferred AP (SIOCSIWAP) is used only "
710 "in Managed mode when host_roaming is enabled\n",
715 #endif /* PRISM2_NO_STATION_MODES */
718 static int prism2_ioctl_giwap(struct net_device
*dev
,
719 struct iw_request_info
*info
,
720 struct sockaddr
*ap_addr
, char *extra
)
722 struct hostap_interface
*iface
;
725 iface
= netdev_priv(dev
);
726 local
= iface
->local
;
728 ap_addr
->sa_family
= ARPHRD_ETHER
;
729 switch (iface
->type
) {
730 case HOSTAP_INTERFACE_AP
:
731 memcpy(&ap_addr
->sa_data
, dev
->dev_addr
, ETH_ALEN
);
733 case HOSTAP_INTERFACE_STA
:
734 memcpy(&ap_addr
->sa_data
, local
->assoc_ap_addr
, ETH_ALEN
);
736 case HOSTAP_INTERFACE_WDS
:
737 memcpy(&ap_addr
->sa_data
, iface
->u
.wds
.remote_addr
, ETH_ALEN
);
740 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTBSSID
,
741 &ap_addr
->sa_data
, ETH_ALEN
, 1) < 0)
744 /* local->bssid is also updated in LinkStatus handler when in
746 memcpy(local
->bssid
, &ap_addr
->sa_data
, ETH_ALEN
);
754 static int prism2_ioctl_siwnickn(struct net_device
*dev
,
755 struct iw_request_info
*info
,
756 struct iw_point
*data
, char *nickname
)
758 struct hostap_interface
*iface
;
761 iface
= netdev_priv(dev
);
762 local
= iface
->local
;
764 memset(local
->name
, 0, sizeof(local
->name
));
765 memcpy(local
->name
, nickname
, data
->length
);
768 if (hostap_set_string(dev
, HFA384X_RID_CNFOWNNAME
, local
->name
) ||
769 local
->func
->reset_port(dev
))
775 static int prism2_ioctl_giwnickn(struct net_device
*dev
,
776 struct iw_request_info
*info
,
777 struct iw_point
*data
, char *nickname
)
779 struct hostap_interface
*iface
;
782 char name
[MAX_NAME_LEN
+ 3];
785 iface
= netdev_priv(dev
);
786 local
= iface
->local
;
788 len
= local
->func
->get_rid(dev
, HFA384X_RID_CNFOWNNAME
,
789 &name
, MAX_NAME_LEN
+ 2, 0);
790 val
= le16_to_cpu(*(__le16
*) name
);
791 if (len
> MAX_NAME_LEN
+ 2 || len
< 0 || val
> MAX_NAME_LEN
)
794 name
[val
+ 2] = '\0';
795 data
->length
= val
+ 1;
796 memcpy(nickname
, name
+ 2, val
+ 1);
802 static int prism2_ioctl_siwfreq(struct net_device
*dev
,
803 struct iw_request_info
*info
,
804 struct iw_freq
*freq
, char *extra
)
806 struct hostap_interface
*iface
;
809 iface
= netdev_priv(dev
);
810 local
= iface
->local
;
814 freq
->m
/ 100000 >= freq_list
[0] &&
815 freq
->m
/ 100000 <= freq_list
[FREQ_COUNT
- 1]) {
817 int fr
= freq
->m
/ 100000;
818 for (ch
= 0; ch
< FREQ_COUNT
; ch
++) {
819 if (fr
== freq_list
[ch
]) {
827 if (freq
->e
!= 0 || freq
->m
< 1 || freq
->m
> FREQ_COUNT
||
828 !(local
->channel_mask
& (1 << (freq
->m
- 1))))
831 local
->channel
= freq
->m
; /* channel is used in prism2_setup_rids() */
832 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNCHANNEL
, local
->channel
) ||
833 local
->func
->reset_port(dev
))
839 static int prism2_ioctl_giwfreq(struct net_device
*dev
,
840 struct iw_request_info
*info
,
841 struct iw_freq
*freq
, char *extra
)
843 struct hostap_interface
*iface
;
847 iface
= netdev_priv(dev
);
848 local
= iface
->local
;
850 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTCHANNEL
, &val
, 2, 1) <
855 if (val
< 1 || val
> FREQ_COUNT
)
858 freq
->m
= freq_list
[val
- 1] * 100000;
865 static void hostap_monitor_set_type(local_info_t
*local
)
867 struct net_device
*dev
= local
->ddev
;
872 if (local
->monitor_type
== PRISM2_MONITOR_PRISM
||
873 local
->monitor_type
== PRISM2_MONITOR_CAPHDR
) {
874 dev
->type
= ARPHRD_IEEE80211_PRISM
;
875 } else if (local
->monitor_type
== PRISM2_MONITOR_RADIOTAP
) {
876 dev
->type
= ARPHRD_IEEE80211_RADIOTAP
;
878 dev
->type
= ARPHRD_IEEE80211
;
883 static int prism2_ioctl_siwessid(struct net_device
*dev
,
884 struct iw_request_info
*info
,
885 struct iw_point
*data
, char *ssid
)
887 struct hostap_interface
*iface
;
890 iface
= netdev_priv(dev
);
891 local
= iface
->local
;
893 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
896 if (data
->flags
== 0)
897 ssid
[0] = '\0'; /* ANY */
899 if (local
->iw_mode
== IW_MODE_MASTER
&& ssid
[0] == '\0') {
900 /* Setting SSID to empty string seems to kill the card in
902 printk(KERN_DEBUG
"%s: Host AP mode does not support "
903 "'Any' essid\n", dev
->name
);
907 memcpy(local
->essid
, ssid
, data
->length
);
908 local
->essid
[data
->length
] = '\0';
910 if ((!local
->fw_ap
&&
911 hostap_set_string(dev
, HFA384X_RID_CNFDESIREDSSID
, local
->essid
))
912 || hostap_set_string(dev
, HFA384X_RID_CNFOWNSSID
, local
->essid
) ||
913 local
->func
->reset_port(dev
))
919 static int prism2_ioctl_giwessid(struct net_device
*dev
,
920 struct iw_request_info
*info
,
921 struct iw_point
*data
, char *essid
)
923 struct hostap_interface
*iface
;
927 iface
= netdev_priv(dev
);
928 local
= iface
->local
;
930 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
933 data
->flags
= 1; /* active */
934 if (local
->iw_mode
== IW_MODE_MASTER
) {
935 data
->length
= strlen(local
->essid
);
936 memcpy(essid
, local
->essid
, IW_ESSID_MAX_SIZE
);
939 char ssid
[MAX_SSID_LEN
+ 2];
940 memset(ssid
, 0, sizeof(ssid
));
941 len
= local
->func
->get_rid(dev
, HFA384X_RID_CURRENTSSID
,
942 &ssid
, MAX_SSID_LEN
+ 2, 0);
943 val
= le16_to_cpu(*(__le16
*) ssid
);
944 if (len
> MAX_SSID_LEN
+ 2 || len
< 0 || val
> MAX_SSID_LEN
) {
948 memcpy(essid
, ssid
+ 2, IW_ESSID_MAX_SIZE
);
955 static int prism2_ioctl_giwrange(struct net_device
*dev
,
956 struct iw_request_info
*info
,
957 struct iw_point
*data
, char *extra
)
959 struct hostap_interface
*iface
;
961 struct iw_range
*range
= (struct iw_range
*) extra
;
966 iface
= netdev_priv(dev
);
967 local
= iface
->local
;
969 data
->length
= sizeof(struct iw_range
);
970 memset(range
, 0, sizeof(struct iw_range
));
972 /* TODO: could fill num_txpower and txpower array with
973 * something; however, there are 128 different values.. */
975 range
->txpower_capa
= IW_TXPOW_DBM
;
977 if (local
->iw_mode
== IW_MODE_INFRA
|| local
->iw_mode
== IW_MODE_ADHOC
)
979 range
->min_pmp
= 1 * 1024;
980 range
->max_pmp
= 65535 * 1024;
981 range
->min_pmt
= 1 * 1024;
982 range
->max_pmt
= 1000 * 1024;
983 range
->pmp_flags
= IW_POWER_PERIOD
;
984 range
->pmt_flags
= IW_POWER_TIMEOUT
;
985 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
|
986 IW_POWER_UNICAST_R
| IW_POWER_ALL_R
;
989 range
->we_version_compiled
= WIRELESS_EXT
;
990 range
->we_version_source
= 18;
992 range
->retry_capa
= IW_RETRY_LIMIT
;
993 range
->retry_flags
= IW_RETRY_LIMIT
;
994 range
->min_retry
= 0;
995 range
->max_retry
= 255;
997 range
->num_channels
= FREQ_COUNT
;
1000 for (i
= 0; i
< FREQ_COUNT
; i
++) {
1001 if (local
->channel_mask
& (1 << i
)) {
1002 range
->freq
[val
].i
= i
+ 1;
1003 range
->freq
[val
].m
= freq_list
[i
] * 100000;
1004 range
->freq
[val
].e
= 1;
1007 if (val
== IW_MAX_FREQUENCIES
)
1010 range
->num_frequency
= val
;
1012 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1)) {
1013 range
->max_qual
.qual
= 70; /* what is correct max? This was not
1014 * documented exactly. At least
1015 * 69 has been observed. */
1016 range
->max_qual
.level
= 0; /* dB */
1017 range
->max_qual
.noise
= 0; /* dB */
1019 /* What would be suitable values for "average/typical" qual? */
1020 range
->avg_qual
.qual
= 20;
1021 range
->avg_qual
.level
= -60;
1022 range
->avg_qual
.noise
= -95;
1024 range
->max_qual
.qual
= 92; /* 0 .. 92 */
1025 range
->max_qual
.level
= 154; /* 27 .. 154 */
1026 range
->max_qual
.noise
= 154; /* 27 .. 154 */
1028 range
->sensitivity
= 3;
1030 range
->max_encoding_tokens
= WEP_KEYS
;
1031 range
->num_encoding_sizes
= 2;
1032 range
->encoding_size
[0] = 5;
1033 range
->encoding_size
[1] = 13;
1036 len
= prism2_get_datarates(dev
, rates
);
1037 range
->num_bitrates
= 0;
1038 for (i
= 0; i
< len
; i
++) {
1039 if (range
->num_bitrates
< IW_MAX_BITRATES
) {
1040 range
->bitrate
[range
->num_bitrates
] =
1042 range
->num_bitrates
++;
1044 if (rates
[i
] == 0x0b || rates
[i
] == 0x16)
1047 /* estimated maximum TCP throughput values (bps) */
1048 range
->throughput
= over2
? 5500000 : 1500000;
1051 range
->max_rts
= 2347;
1052 range
->min_frag
= 256;
1053 range
->max_frag
= 2346;
1055 /* Event capability (kernel + driver) */
1056 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
1057 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY
) |
1058 IW_EVENT_CAPA_MASK(SIOCGIWAP
) |
1059 IW_EVENT_CAPA_MASK(SIOCGIWSCAN
));
1060 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
1061 range
->event_capa
[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP
) |
1062 IW_EVENT_CAPA_MASK(IWEVCUSTOM
) |
1063 IW_EVENT_CAPA_MASK(IWEVREGISTERED
) |
1064 IW_EVENT_CAPA_MASK(IWEVEXPIRED
));
1066 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
1067 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
1069 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1070 range
->scan_capa
= IW_SCAN_CAPA_ESSID
;
1076 static int hostap_monitor_mode_enable(local_info_t
*local
)
1078 struct net_device
*dev
= local
->dev
;
1080 printk(KERN_DEBUG
"Enabling monitor mode\n");
1081 hostap_monitor_set_type(local
);
1083 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1084 HFA384X_PORTTYPE_PSEUDO_IBSS
)) {
1085 printk(KERN_DEBUG
"Port type setting for monitor mode "
1090 /* Host decrypt is needed to get the IV and ICV fields;
1091 * however, monitor mode seems to remove WEP flag from frame
1093 if (hostap_set_word(dev
, HFA384X_RID_CNFWEPFLAGS
,
1094 HFA384X_WEPFLAGS_HOSTENCRYPT
|
1095 HFA384X_WEPFLAGS_HOSTDECRYPT
)) {
1096 printk(KERN_DEBUG
"WEP flags setting failed\n");
1100 if (local
->func
->reset_port(dev
) ||
1101 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1102 (HFA384X_TEST_MONITOR
<< 8),
1104 printk(KERN_DEBUG
"Setting monitor mode failed\n");
1112 static int hostap_monitor_mode_disable(local_info_t
*local
)
1114 struct net_device
*dev
= local
->ddev
;
1119 printk(KERN_DEBUG
"%s: Disabling monitor mode\n", dev
->name
);
1120 dev
->type
= ARPHRD_ETHER
;
1122 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1123 (HFA384X_TEST_STOP
<< 8),
1126 return hostap_set_encryption(local
);
1130 static int prism2_ioctl_siwmode(struct net_device
*dev
,
1131 struct iw_request_info
*info
,
1132 __u32
*mode
, char *extra
)
1134 struct hostap_interface
*iface
;
1135 local_info_t
*local
;
1136 int double_reset
= 0;
1138 iface
= netdev_priv(dev
);
1139 local
= iface
->local
;
1141 if (*mode
!= IW_MODE_ADHOC
&& *mode
!= IW_MODE_INFRA
&&
1142 *mode
!= IW_MODE_MASTER
&& *mode
!= IW_MODE_REPEAT
&&
1143 *mode
!= IW_MODE_MONITOR
)
1146 #ifdef PRISM2_NO_STATION_MODES
1147 if (*mode
== IW_MODE_ADHOC
|| *mode
== IW_MODE_INFRA
)
1149 #endif /* PRISM2_NO_STATION_MODES */
1151 if (*mode
== local
->iw_mode
)
1154 if (*mode
== IW_MODE_MASTER
&& local
->essid
[0] == '\0') {
1155 printk(KERN_WARNING
"%s: empty SSID not allowed in Master "
1156 "mode\n", dev
->name
);
1160 if (local
->iw_mode
== IW_MODE_MONITOR
)
1161 hostap_monitor_mode_disable(local
);
1163 if ((local
->iw_mode
== IW_MODE_ADHOC
||
1164 local
->iw_mode
== IW_MODE_MONITOR
) && *mode
== IW_MODE_MASTER
) {
1168 printk(KERN_DEBUG
"prism2: %s: operating mode changed "
1169 "%d -> %d\n", dev
->name
, local
->iw_mode
, *mode
);
1170 local
->iw_mode
= *mode
;
1172 if (local
->iw_mode
== IW_MODE_MONITOR
)
1173 hostap_monitor_mode_enable(local
);
1174 else if (local
->iw_mode
== IW_MODE_MASTER
&& !local
->host_encrypt
&&
1175 !local
->fw_encrypt_ok
) {
1176 printk(KERN_DEBUG
"%s: defaulting to host-based encryption as "
1177 "a workaround for firmware bug in Host AP mode WEP\n",
1179 local
->host_encrypt
= 1;
1182 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1183 hostap_get_porttype(local
)))
1186 if (local
->func
->reset_port(dev
))
1188 if (double_reset
&& local
->func
->reset_port(dev
))
1191 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->iw_mode
!= IW_MODE_ADHOC
)
1193 /* netif_carrier is used only in client modes for now, so make
1194 * sure carrier is on when moving to non-client modes. */
1195 netif_carrier_on(local
->dev
);
1196 netif_carrier_on(local
->ddev
);
1202 static int prism2_ioctl_giwmode(struct net_device
*dev
,
1203 struct iw_request_info
*info
,
1204 __u32
*mode
, char *extra
)
1206 struct hostap_interface
*iface
;
1207 local_info_t
*local
;
1209 iface
= netdev_priv(dev
);
1210 local
= iface
->local
;
1212 switch (iface
->type
) {
1213 case HOSTAP_INTERFACE_STA
:
1214 *mode
= IW_MODE_INFRA
;
1216 case HOSTAP_INTERFACE_WDS
:
1217 *mode
= IW_MODE_REPEAT
;
1220 *mode
= local
->iw_mode
;
1227 static int prism2_ioctl_siwpower(struct net_device
*dev
,
1228 struct iw_request_info
*info
,
1229 struct iw_param
*wrq
, char *extra
)
1231 #ifdef PRISM2_NO_STATION_MODES
1233 #else /* PRISM2_NO_STATION_MODES */
1237 return hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 0);
1239 switch (wrq
->flags
& IW_POWER_MODE
) {
1240 case IW_POWER_UNICAST_R
:
1241 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 0);
1244 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1248 case IW_POWER_ALL_R
:
1249 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 1);
1252 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1262 if (wrq
->flags
& IW_POWER_TIMEOUT
) {
1263 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1266 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMHOLDOVERDURATION
,
1271 if (wrq
->flags
& IW_POWER_PERIOD
) {
1272 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1275 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1282 #endif /* PRISM2_NO_STATION_MODES */
1286 static int prism2_ioctl_giwpower(struct net_device
*dev
,
1287 struct iw_request_info
*info
,
1288 struct iw_param
*rrq
, char *extra
)
1290 #ifdef PRISM2_NO_STATION_MODES
1292 #else /* PRISM2_NO_STATION_MODES */
1293 struct hostap_interface
*iface
;
1294 local_info_t
*local
;
1295 __le16 enable
, mcast
;
1297 iface
= netdev_priv(dev
);
1298 local
= iface
->local
;
1300 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFPMENABLED
, &enable
, 2, 1)
1304 if (!le16_to_cpu(enable
)) {
1311 if ((rrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1313 if (local
->func
->get_rid(dev
,
1314 HFA384X_RID_CNFPMHOLDOVERDURATION
,
1315 &timeout
, 2, 1) < 0)
1318 rrq
->flags
= IW_POWER_TIMEOUT
;
1319 rrq
->value
= le16_to_cpu(timeout
) * 1024;
1322 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1326 rrq
->flags
= IW_POWER_PERIOD
;
1327 rrq
->value
= le16_to_cpu(period
) * 1024;
1330 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, &mcast
,
1334 if (le16_to_cpu(mcast
))
1335 rrq
->flags
|= IW_POWER_ALL_R
;
1337 rrq
->flags
|= IW_POWER_UNICAST_R
;
1340 #endif /* PRISM2_NO_STATION_MODES */
1344 static int prism2_ioctl_siwretry(struct net_device
*dev
,
1345 struct iw_request_info
*info
,
1346 struct iw_param
*rrq
, char *extra
)
1348 struct hostap_interface
*iface
;
1349 local_info_t
*local
;
1351 iface
= netdev_priv(dev
);
1352 local
= iface
->local
;
1357 /* setting retry limits is not supported with the current station
1358 * firmware code; simulate this with alternative retry count for now */
1359 if (rrq
->flags
== IW_RETRY_LIMIT
) {
1360 if (rrq
->value
< 0) {
1361 /* disable manual retry count setting and use firmware
1363 local
->manual_retry_count
= -1;
1364 local
->tx_control
&= ~HFA384X_TX_CTRL_ALT_RTRY
;
1366 if (hostap_set_word(dev
, HFA384X_RID_CNFALTRETRYCOUNT
,
1368 printk(KERN_DEBUG
"%s: Alternate retry count "
1369 "setting to %d failed\n",
1370 dev
->name
, rrq
->value
);
1374 local
->manual_retry_count
= rrq
->value
;
1375 local
->tx_control
|= HFA384X_TX_CTRL_ALT_RTRY
;
1384 static int prism2_ioctl_giwretry(struct net_device
*dev
,
1385 struct iw_request_info
*info
,
1386 struct iw_param
*rrq
, char *extra
)
1388 struct hostap_interface
*iface
;
1389 local_info_t
*local
;
1390 __le16 shortretry
, longretry
, lifetime
, altretry
;
1392 iface
= netdev_priv(dev
);
1393 local
= iface
->local
;
1395 if (local
->func
->get_rid(dev
, HFA384X_RID_SHORTRETRYLIMIT
, &shortretry
,
1397 local
->func
->get_rid(dev
, HFA384X_RID_LONGRETRYLIMIT
, &longretry
,
1399 local
->func
->get_rid(dev
, HFA384X_RID_MAXTRANSMITLIFETIME
,
1400 &lifetime
, 2, 1) < 0)
1405 if ((rrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1406 rrq
->flags
= IW_RETRY_LIFETIME
;
1407 rrq
->value
= le16_to_cpu(lifetime
) * 1024;
1409 if (local
->manual_retry_count
>= 0) {
1410 rrq
->flags
= IW_RETRY_LIMIT
;
1411 if (local
->func
->get_rid(dev
,
1412 HFA384X_RID_CNFALTRETRYCOUNT
,
1413 &altretry
, 2, 1) >= 0)
1414 rrq
->value
= le16_to_cpu(altretry
);
1416 rrq
->value
= local
->manual_retry_count
;
1417 } else if ((rrq
->flags
& IW_RETRY_LONG
)) {
1418 rrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
1419 rrq
->value
= le16_to_cpu(longretry
);
1421 rrq
->flags
= IW_RETRY_LIMIT
;
1422 rrq
->value
= le16_to_cpu(shortretry
);
1423 if (shortretry
!= longretry
)
1424 rrq
->flags
|= IW_RETRY_SHORT
;
1431 /* Note! This TX power controlling is experimental and should not be used in
1432 * production use. It just sets raw power register and does not use any kind of
1433 * feedback information from the measured TX power (CR58). This is now
1434 * commented out to make sure that it is not used by accident. TX power
1435 * configuration will be enabled again after proper algorithm using feedback
1436 * has been implemented. */
1438 #ifdef RAW_TXPOWER_SETTING
1439 /* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping..
1440 * This version assumes following mapping:
1441 * CR31 is 7-bit value with -64 to +63 range.
1442 * -64 is mapped into +20dBm and +63 into -43dBm.
1443 * This is certainly not an exact mapping for every card, but at least
1444 * increasing dBm value should correspond to increasing TX power.
1447 static int prism2_txpower_hfa386x_to_dBm(u16 val
)
1460 static u16
prism2_txpower_dBm_to_hfa386x(int val
)
1473 return (unsigned char) tmp
;
1475 #endif /* RAW_TXPOWER_SETTING */
1478 static int prism2_ioctl_siwtxpow(struct net_device
*dev
,
1479 struct iw_request_info
*info
,
1480 struct iw_param
*rrq
, char *extra
)
1482 struct hostap_interface
*iface
;
1483 local_info_t
*local
;
1484 #ifdef RAW_TXPOWER_SETTING
1490 iface
= netdev_priv(dev
);
1491 local
= iface
->local
;
1493 if (rrq
->disabled
) {
1494 if (local
->txpower_type
!= PRISM2_TXPOWER_OFF
) {
1495 val
= 0xff; /* use all standby and sleep modes */
1496 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1497 HFA386X_CR_A_D_TEST_MODES2
,
1499 printk(KERN_DEBUG
"%s: Turning radio off: %s\n",
1500 dev
->name
, ret
? "failed" : "OK");
1501 local
->txpower_type
= PRISM2_TXPOWER_OFF
;
1503 return (ret
? -EOPNOTSUPP
: 0);
1506 if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1507 val
= 0; /* disable all standby and sleep modes */
1508 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1509 HFA386X_CR_A_D_TEST_MODES2
, &val
, NULL
);
1510 printk(KERN_DEBUG
"%s: Turning radio on: %s\n",
1511 dev
->name
, ret
? "failed" : "OK");
1512 local
->txpower_type
= PRISM2_TXPOWER_UNKNOWN
;
1515 #ifdef RAW_TXPOWER_SETTING
1516 if (!rrq
->fixed
&& local
->txpower_type
!= PRISM2_TXPOWER_AUTO
) {
1517 printk(KERN_DEBUG
"Setting ALC on\n");
1518 val
= HFA384X_TEST_CFG_BIT_ALC
;
1519 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1520 (HFA384X_TEST_CFG_BITS
<< 8), 1, &val
, NULL
);
1521 local
->txpower_type
= PRISM2_TXPOWER_AUTO
;
1525 if (local
->txpower_type
!= PRISM2_TXPOWER_FIXED
) {
1526 printk(KERN_DEBUG
"Setting ALC off\n");
1527 val
= HFA384X_TEST_CFG_BIT_ALC
;
1528 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1529 (HFA384X_TEST_CFG_BITS
<< 8), 0, &val
, NULL
);
1530 local
->txpower_type
= PRISM2_TXPOWER_FIXED
;
1533 if (rrq
->flags
== IW_TXPOW_DBM
)
1535 else if (rrq
->flags
== IW_TXPOW_MWATT
)
1539 printk(KERN_DEBUG
"Setting TX power to %d %s\n", rrq
->value
, tmp
);
1541 if (rrq
->flags
!= IW_TXPOW_DBM
) {
1542 printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
1546 local
->txpower
= rrq
->value
;
1547 val
= prism2_txpower_dBm_to_hfa386x(local
->txpower
);
1548 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1549 HFA386X_CR_MANUAL_TX_POWER
, &val
, NULL
))
1551 #else /* RAW_TXPOWER_SETTING */
1554 #endif /* RAW_TXPOWER_SETTING */
1559 static int prism2_ioctl_giwtxpow(struct net_device
*dev
,
1560 struct iw_request_info
*info
,
1561 struct iw_param
*rrq
, char *extra
)
1563 #ifdef RAW_TXPOWER_SETTING
1564 struct hostap_interface
*iface
;
1565 local_info_t
*local
;
1568 iface
= netdev_priv(dev
);
1569 local
= iface
->local
;
1571 rrq
->flags
= IW_TXPOW_DBM
;
1575 if (local
->txpower_type
== PRISM2_TXPOWER_AUTO
) {
1576 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
,
1577 HFA386X_CR_MANUAL_TX_POWER
,
1578 NULL
, &resp0
) == 0) {
1579 rrq
->value
= prism2_txpower_hfa386x_to_dBm(resp0
);
1581 /* Could not get real txpower; guess 15 dBm */
1584 } else if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1587 } else if (local
->txpower_type
== PRISM2_TXPOWER_FIXED
) {
1588 rrq
->value
= local
->txpower
;
1591 printk("SIOCGIWTXPOW - unknown txpower_type=%d\n",
1592 local
->txpower_type
);
1595 #else /* RAW_TXPOWER_SETTING */
1597 #endif /* RAW_TXPOWER_SETTING */
1601 #ifndef PRISM2_NO_STATION_MODES
1603 /* HostScan request works with and without host_roaming mode. In addition, it
1604 * does not break current association. However, it requires newer station
1605 * firmware version (>= 1.3.1) than scan request. */
1606 static int prism2_request_hostscan(struct net_device
*dev
,
1607 u8
*ssid
, u8 ssid_len
)
1609 struct hostap_interface
*iface
;
1610 local_info_t
*local
;
1611 struct hfa384x_hostscan_request scan_req
;
1613 iface
= netdev_priv(dev
);
1614 local
= iface
->local
;
1616 memset(&scan_req
, 0, sizeof(scan_req
));
1617 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1618 local
->scan_channel_mask
);
1619 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1623 scan_req
.target_ssid_len
= cpu_to_le16(ssid_len
);
1624 memcpy(scan_req
.target_ssid
, ssid
, ssid_len
);
1627 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
1628 sizeof(scan_req
))) {
1629 printk(KERN_DEBUG
"%s: HOSTSCAN failed\n", dev
->name
);
1636 static int prism2_request_scan(struct net_device
*dev
)
1638 struct hostap_interface
*iface
;
1639 local_info_t
*local
;
1640 struct hfa384x_scan_request scan_req
;
1643 iface
= netdev_priv(dev
);
1644 local
= iface
->local
;
1646 memset(&scan_req
, 0, sizeof(scan_req
));
1647 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1648 local
->scan_channel_mask
);
1649 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1652 * It seems to be enough to set roaming mode for a short moment to
1653 * host-based and then setup scanrequest data and return the mode to
1656 * Master mode would need to drop to Managed mode for a short while
1657 * to make scanning work.. Or sweep through the different channels and
1658 * use passive scan based on beacons. */
1660 if (!local
->host_roaming
)
1661 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1662 HFA384X_ROAMING_HOST
);
1664 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
, &scan_req
,
1665 sizeof(scan_req
))) {
1666 printk(KERN_DEBUG
"SCANREQUEST failed\n");
1670 if (!local
->host_roaming
)
1671 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1672 HFA384X_ROAMING_FIRMWARE
);
1677 #else /* !PRISM2_NO_STATION_MODES */
1679 static inline int prism2_request_hostscan(struct net_device
*dev
,
1680 u8
*ssid
, u8 ssid_len
)
1686 static inline int prism2_request_scan(struct net_device
*dev
)
1691 #endif /* !PRISM2_NO_STATION_MODES */
1694 static int prism2_ioctl_siwscan(struct net_device
*dev
,
1695 struct iw_request_info
*info
,
1696 struct iw_point
*data
, char *extra
)
1698 struct hostap_interface
*iface
;
1699 local_info_t
*local
;
1701 u8
*ssid
= NULL
, ssid_len
= 0;
1702 struct iw_scan_req
*req
= (struct iw_scan_req
*) extra
;
1704 iface
= netdev_priv(dev
);
1705 local
= iface
->local
;
1707 if (data
->length
< sizeof(struct iw_scan_req
))
1710 if (local
->iw_mode
== IW_MODE_MASTER
) {
1711 /* In master mode, we just return the results of our local
1712 * tables, so we don't need to start anything...
1718 if (!local
->dev_enabled
)
1721 if (req
&& data
->flags
& IW_SCAN_THIS_ESSID
) {
1723 ssid_len
= req
->essid_len
;
1726 ((local
->iw_mode
!= IW_MODE_INFRA
&&
1727 local
->iw_mode
!= IW_MODE_ADHOC
) ||
1728 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1))))
1732 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1733 ret
= prism2_request_hostscan(dev
, ssid
, ssid_len
);
1735 ret
= prism2_request_scan(dev
);
1738 local
->scan_timestamp
= jiffies
;
1740 /* Could inquire F101, F103 or wait for SIOCGIWSCAN and read RID */
1746 #ifndef PRISM2_NO_STATION_MODES
1747 static char * __prism2_translate_scan(local_info_t
*local
,
1748 struct iw_request_info
*info
,
1749 struct hfa384x_hostscan_result
*scan
,
1750 struct hostap_bss_info
*bss
,
1751 char *current_ev
, char *end_buf
)
1754 struct iw_event iwe
;
1764 ssid_len
= bss
->ssid_len
;
1768 ssid_len
= le16_to_cpu(scan
->ssid_len
);
1769 bssid
= scan
->bssid
;
1774 /* First entry *MUST* be the AP MAC address */
1775 memset(&iwe
, 0, sizeof(iwe
));
1776 iwe
.cmd
= SIOCGIWAP
;
1777 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1778 memcpy(iwe
.u
.ap_addr
.sa_data
, bssid
, ETH_ALEN
);
1779 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
, &iwe
,
1782 /* Other entries will be displayed in the order we give them */
1784 memset(&iwe
, 0, sizeof(iwe
));
1785 iwe
.cmd
= SIOCGIWESSID
;
1786 iwe
.u
.data
.length
= ssid_len
;
1787 iwe
.u
.data
.flags
= 1;
1788 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1791 memset(&iwe
, 0, sizeof(iwe
));
1792 iwe
.cmd
= SIOCGIWMODE
;
1794 capabilities
= bss
->capab_info
;
1796 capabilities
= le16_to_cpu(scan
->capability
);
1798 if (capabilities
& (WLAN_CAPABILITY_ESS
|
1799 WLAN_CAPABILITY_IBSS
)) {
1800 if (capabilities
& WLAN_CAPABILITY_ESS
)
1801 iwe
.u
.mode
= IW_MODE_MASTER
;
1803 iwe
.u
.mode
= IW_MODE_ADHOC
;
1804 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1805 &iwe
, IW_EV_UINT_LEN
);
1808 memset(&iwe
, 0, sizeof(iwe
));
1809 iwe
.cmd
= SIOCGIWFREQ
;
1811 chan
= le16_to_cpu(scan
->chid
);
1819 iwe
.u
.freq
.m
= freq_list
[chan
- 1] * 100000;
1821 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1822 &iwe
, IW_EV_FREQ_LEN
);
1826 memset(&iwe
, 0, sizeof(iwe
));
1828 if (local
->last_scan_type
== PRISM2_HOSTSCAN
) {
1829 iwe
.u
.qual
.level
= le16_to_cpu(scan
->sl
);
1830 iwe
.u
.qual
.noise
= le16_to_cpu(scan
->anl
);
1833 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->sl
));
1835 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->anl
));
1837 iwe
.u
.qual
.updated
= IW_QUAL_LEVEL_UPDATED
1838 | IW_QUAL_NOISE_UPDATED
1839 | IW_QUAL_QUAL_INVALID
1841 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1842 &iwe
, IW_EV_QUAL_LEN
);
1845 memset(&iwe
, 0, sizeof(iwe
));
1846 iwe
.cmd
= SIOCGIWENCODE
;
1847 if (capabilities
& WLAN_CAPABILITY_PRIVACY
)
1848 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
1850 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
1851 iwe
.u
.data
.length
= 0;
1852 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
, &iwe
, "");
1854 /* TODO: add SuppRates into BSS table */
1856 memset(&iwe
, 0, sizeof(iwe
));
1857 iwe
.cmd
= SIOCGIWRATE
;
1858 current_val
= current_ev
+ iwe_stream_lcp_len(info
);
1859 pos
= scan
->sup_rates
;
1860 for (i
= 0; i
< sizeof(scan
->sup_rates
); i
++) {
1863 /* Bit rate given in 500 kb/s units (+ 0x80) */
1864 iwe
.u
.bitrate
.value
= ((pos
[i
] & 0x7f) * 500000);
1865 current_val
= iwe_stream_add_value(
1866 info
, current_ev
, current_val
, end_buf
, &iwe
,
1869 /* Check if we added any event */
1870 if ((current_val
- current_ev
) > iwe_stream_lcp_len(info
))
1871 current_ev
= current_val
;
1874 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
1875 buf
= kmalloc(MAX_WPA_IE_LEN
* 2 + 30, GFP_ATOMIC
);
1877 memset(&iwe
, 0, sizeof(iwe
));
1878 iwe
.cmd
= IWEVCUSTOM
;
1879 sprintf(buf
, "bcn_int=%d", le16_to_cpu(scan
->beacon_interval
));
1880 iwe
.u
.data
.length
= strlen(buf
);
1881 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1884 memset(&iwe
, 0, sizeof(iwe
));
1885 iwe
.cmd
= IWEVCUSTOM
;
1886 sprintf(buf
, "resp_rate=%d", le16_to_cpu(scan
->rate
));
1887 iwe
.u
.data
.length
= strlen(buf
);
1888 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1891 if (local
->last_scan_type
== PRISM2_HOSTSCAN
&&
1892 (capabilities
& WLAN_CAPABILITY_IBSS
)) {
1893 memset(&iwe
, 0, sizeof(iwe
));
1894 iwe
.cmd
= IWEVCUSTOM
;
1895 sprintf(buf
, "atim=%d", le16_to_cpu(scan
->atim
));
1896 iwe
.u
.data
.length
= strlen(buf
);
1897 current_ev
= iwe_stream_add_point(info
, current_ev
,
1898 end_buf
, &iwe
, buf
);
1903 if (bss
&& bss
->wpa_ie_len
> 0 && bss
->wpa_ie_len
<= MAX_WPA_IE_LEN
) {
1904 memset(&iwe
, 0, sizeof(iwe
));
1905 iwe
.cmd
= IWEVGENIE
;
1906 iwe
.u
.data
.length
= bss
->wpa_ie_len
;
1907 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1911 if (bss
&& bss
->rsn_ie_len
> 0 && bss
->rsn_ie_len
<= MAX_WPA_IE_LEN
) {
1912 memset(&iwe
, 0, sizeof(iwe
));
1913 iwe
.cmd
= IWEVGENIE
;
1914 iwe
.u
.data
.length
= bss
->rsn_ie_len
;
1915 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1923 /* Translate scan data returned from the card to a card independant
1924 * format that the Wireless Tools will understand - Jean II */
1925 static inline int prism2_translate_scan(local_info_t
*local
,
1926 struct iw_request_info
*info
,
1927 char *buffer
, int buflen
)
1929 struct hfa384x_hostscan_result
*scan
;
1930 int entry
, hostscan
;
1931 char *current_ev
= buffer
;
1932 char *end_buf
= buffer
+ buflen
;
1933 struct list_head
*ptr
;
1935 spin_lock_bh(&local
->lock
);
1937 list_for_each(ptr
, &local
->bss_list
) {
1938 struct hostap_bss_info
*bss
;
1939 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1943 hostscan
= local
->last_scan_type
== PRISM2_HOSTSCAN
;
1944 for (entry
= 0; entry
< local
->last_scan_results_count
; entry
++) {
1946 scan
= &local
->last_scan_results
[entry
];
1948 /* Report every SSID if the AP is using multiple SSIDs. If no
1949 * BSS record is found (e.g., when WPA mode is disabled),
1950 * report the AP once. */
1951 list_for_each(ptr
, &local
->bss_list
) {
1952 struct hostap_bss_info
*bss
;
1953 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1954 if (memcmp(bss
->bssid
, scan
->bssid
, ETH_ALEN
) == 0) {
1956 current_ev
= __prism2_translate_scan(
1957 local
, info
, scan
, bss
, current_ev
,
1963 current_ev
= __prism2_translate_scan(
1964 local
, info
, scan
, NULL
, current_ev
, end_buf
);
1966 /* Check if there is space for one more entry */
1967 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
1968 /* Ask user space to try again with a bigger buffer */
1969 spin_unlock_bh(&local
->lock
);
1974 /* Prism2 firmware has limits (32 at least in some versions) for number
1975 * of BSSes in scan results. Extend this limit by using local BSS list.
1977 list_for_each(ptr
, &local
->bss_list
) {
1978 struct hostap_bss_info
*bss
;
1979 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1982 current_ev
= __prism2_translate_scan(local
, info
, NULL
, bss
,
1983 current_ev
, end_buf
);
1984 /* Check if there is space for one more entry */
1985 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
1986 /* Ask user space to try again with a bigger buffer */
1987 spin_unlock_bh(&local
->lock
);
1992 spin_unlock_bh(&local
->lock
);
1994 return current_ev
- buffer
;
1996 #endif /* PRISM2_NO_STATION_MODES */
1999 static inline int prism2_ioctl_giwscan_sta(struct net_device
*dev
,
2000 struct iw_request_info
*info
,
2001 struct iw_point
*data
, char *extra
)
2003 #ifdef PRISM2_NO_STATION_MODES
2005 #else /* PRISM2_NO_STATION_MODES */
2006 struct hostap_interface
*iface
;
2007 local_info_t
*local
;
2010 iface
= netdev_priv(dev
);
2011 local
= iface
->local
;
2013 /* Wait until the scan is finished. We can probably do better
2014 * than that - Jean II */
2015 if (local
->scan_timestamp
&&
2016 time_before(jiffies
, local
->scan_timestamp
+ 3 * HZ
)) {
2017 /* Important note : we don't want to block the caller
2018 * until results are ready for various reasons.
2019 * First, managing wait queues is complex and racy
2020 * (there may be multiple simultaneous callers).
2021 * Second, we grab some rtnetlink lock before comming
2022 * here (in dev_ioctl()).
2023 * Third, the caller can wait on the Wireless Event
2027 local
->scan_timestamp
= 0;
2029 res
= prism2_translate_scan(local
, info
, extra
, data
->length
);
2038 #endif /* PRISM2_NO_STATION_MODES */
2042 static int prism2_ioctl_giwscan(struct net_device
*dev
,
2043 struct iw_request_info
*info
,
2044 struct iw_point
*data
, char *extra
)
2046 struct hostap_interface
*iface
;
2047 local_info_t
*local
;
2050 iface
= netdev_priv(dev
);
2051 local
= iface
->local
;
2053 if (local
->iw_mode
== IW_MODE_MASTER
) {
2054 /* In MASTER mode, it doesn't make sense to go around
2055 * scanning the frequencies and make the stations we serve
2056 * wait when what the user is really interested about is the
2057 * list of stations and access points we are talking to.
2058 * So, just extract results from our cache...
2061 /* Translate to WE format */
2062 res
= prism2_ap_translate_scan(dev
, info
, extra
);
2064 printk(KERN_DEBUG
"Scan result translation succeeded "
2065 "(length=%d)\n", res
);
2070 "Scan result translation failed (res=%d)\n",
2077 return prism2_ioctl_giwscan_sta(dev
, info
, data
, extra
);
2082 static const struct iw_priv_args prism2_priv
[] = {
2083 { PRISM2_IOCTL_MONITOR
,
2084 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor" },
2085 { PRISM2_IOCTL_READMIF
,
2086 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1,
2087 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1, "readmif" },
2088 { PRISM2_IOCTL_WRITEMIF
,
2089 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 2, 0, "writemif" },
2090 { PRISM2_IOCTL_RESET
,
2091 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "reset" },
2092 { PRISM2_IOCTL_INQUIRE
,
2093 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "inquire" },
2094 { PRISM2_IOCTL_SET_RID_WORD
,
2095 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "set_rid_word" },
2096 { PRISM2_IOCTL_MACCMD
,
2097 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "maccmd" },
2098 { PRISM2_IOCTL_WDS_ADD
,
2099 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_add" },
2100 { PRISM2_IOCTL_WDS_DEL
,
2101 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_del" },
2102 { PRISM2_IOCTL_ADDMAC
,
2103 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "addmac" },
2104 { PRISM2_IOCTL_DELMAC
,
2105 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "delmac" },
2106 { PRISM2_IOCTL_KICKMAC
,
2107 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "kickmac" },
2108 /* --- raw access to sub-ioctls --- */
2109 { PRISM2_IOCTL_PRISM2_PARAM
,
2110 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "prism2_param" },
2111 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2112 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
2113 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprism2_param" },
2114 /* --- sub-ioctls handlers --- */
2115 { PRISM2_IOCTL_PRISM2_PARAM
,
2116 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "" },
2117 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2118 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "" },
2119 /* --- sub-ioctls definitions --- */
2120 { PRISM2_PARAM_TXRATECTRL
,
2121 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "txratectrl" },
2122 { PRISM2_PARAM_TXRATECTRL
,
2123 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettxratectrl" },
2124 { PRISM2_PARAM_BEACON_INT
,
2125 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "beacon_int" },
2126 { PRISM2_PARAM_BEACON_INT
,
2127 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbeacon_int" },
2128 #ifndef PRISM2_NO_STATION_MODES
2129 { PRISM2_PARAM_PSEUDO_IBSS
,
2130 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "pseudo_ibss" },
2131 { PRISM2_PARAM_PSEUDO_IBSS
,
2132 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getpseudo_ibss" },
2133 #endif /* PRISM2_NO_STATION_MODES */
2135 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "alc" },
2137 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getalc" },
2138 { PRISM2_PARAM_DUMP
,
2139 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dump" },
2140 { PRISM2_PARAM_DUMP
,
2141 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdump" },
2142 { PRISM2_PARAM_OTHER_AP_POLICY
,
2143 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "other_ap_policy" },
2144 { PRISM2_PARAM_OTHER_AP_POLICY
,
2145 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getother_ap_pol" },
2146 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2147 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_inactivity" },
2148 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2149 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_inactivi" },
2150 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2151 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bridge_packets" },
2152 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2153 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbridge_packe" },
2154 { PRISM2_PARAM_DTIM_PERIOD
,
2155 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dtim_period" },
2156 { PRISM2_PARAM_DTIM_PERIOD
,
2157 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdtim_period" },
2158 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2159 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "nullfunc_ack" },
2160 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2161 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getnullfunc_ack" },
2162 { PRISM2_PARAM_MAX_WDS
,
2163 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_wds" },
2164 { PRISM2_PARAM_MAX_WDS
,
2165 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_wds" },
2166 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2167 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "autom_ap_wds" },
2168 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2169 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getautom_ap_wds" },
2170 { PRISM2_PARAM_AP_AUTH_ALGS
,
2171 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_auth_algs" },
2172 { PRISM2_PARAM_AP_AUTH_ALGS
,
2173 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_auth_algs" },
2174 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2175 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "allow_fcserr" },
2176 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2177 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getallow_fcserr" },
2178 { PRISM2_PARAM_HOST_ENCRYPT
,
2179 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_encrypt" },
2180 { PRISM2_PARAM_HOST_ENCRYPT
,
2181 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_encrypt" },
2182 { PRISM2_PARAM_HOST_DECRYPT
,
2183 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_decrypt" },
2184 { PRISM2_PARAM_HOST_DECRYPT
,
2185 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_decrypt" },
2186 #ifndef PRISM2_NO_STATION_MODES
2187 { PRISM2_PARAM_HOST_ROAMING
,
2188 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_roaming" },
2189 { PRISM2_PARAM_HOST_ROAMING
,
2190 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_roaming" },
2191 #endif /* PRISM2_NO_STATION_MODES */
2192 { PRISM2_PARAM_BCRX_STA_KEY
,
2193 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bcrx_sta_key" },
2194 { PRISM2_PARAM_BCRX_STA_KEY
,
2195 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbcrx_sta_key" },
2196 { PRISM2_PARAM_IEEE_802_1X
,
2197 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ieee_802_1x" },
2198 { PRISM2_PARAM_IEEE_802_1X
,
2199 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getieee_802_1x" },
2200 { PRISM2_PARAM_ANTSEL_TX
,
2201 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_tx" },
2202 { PRISM2_PARAM_ANTSEL_TX
,
2203 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_tx" },
2204 { PRISM2_PARAM_ANTSEL_RX
,
2205 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_rx" },
2206 { PRISM2_PARAM_ANTSEL_RX
,
2207 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_rx" },
2208 { PRISM2_PARAM_MONITOR_TYPE
,
2209 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor_type" },
2210 { PRISM2_PARAM_MONITOR_TYPE
,
2211 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmonitor_type" },
2212 { PRISM2_PARAM_WDS_TYPE
,
2213 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_type" },
2214 { PRISM2_PARAM_WDS_TYPE
,
2215 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwds_type" },
2216 { PRISM2_PARAM_HOSTSCAN
,
2217 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostscan" },
2218 { PRISM2_PARAM_HOSTSCAN
,
2219 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostscan" },
2220 { PRISM2_PARAM_AP_SCAN
,
2221 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_scan" },
2222 { PRISM2_PARAM_AP_SCAN
,
2223 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_scan" },
2224 { PRISM2_PARAM_ENH_SEC
,
2225 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "enh_sec" },
2226 { PRISM2_PARAM_ENH_SEC
,
2227 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getenh_sec" },
2228 #ifdef PRISM2_IO_DEBUG
2229 { PRISM2_PARAM_IO_DEBUG
,
2230 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "io_debug" },
2231 { PRISM2_PARAM_IO_DEBUG
,
2232 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getio_debug" },
2233 #endif /* PRISM2_IO_DEBUG */
2234 { PRISM2_PARAM_BASIC_RATES
,
2235 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "basic_rates" },
2236 { PRISM2_PARAM_BASIC_RATES
,
2237 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbasic_rates" },
2238 { PRISM2_PARAM_OPER_RATES
,
2239 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "oper_rates" },
2240 { PRISM2_PARAM_OPER_RATES
,
2241 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getoper_rates" },
2242 { PRISM2_PARAM_HOSTAPD
,
2243 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd" },
2244 { PRISM2_PARAM_HOSTAPD
,
2245 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd" },
2246 { PRISM2_PARAM_HOSTAPD_STA
,
2247 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd_sta" },
2248 { PRISM2_PARAM_HOSTAPD_STA
,
2249 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd_sta" },
2251 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wpa" },
2253 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwpa" },
2254 { PRISM2_PARAM_PRIVACY_INVOKED
,
2255 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "privacy_invoked" },
2256 { PRISM2_PARAM_PRIVACY_INVOKED
,
2257 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprivacy_invo" },
2258 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2259 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "tkip_countermea" },
2260 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2261 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettkip_counter" },
2262 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2263 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "drop_unencrypte" },
2264 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2265 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdrop_unencry" },
2266 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2267 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "scan_channels" },
2268 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2269 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getscan_channel" },
2273 static int prism2_ioctl_priv_inquire(struct net_device
*dev
, int *i
)
2275 struct hostap_interface
*iface
;
2276 local_info_t
*local
;
2278 iface
= netdev_priv(dev
);
2279 local
= iface
->local
;
2281 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_INQUIRE
, *i
, NULL
, NULL
))
2288 static int prism2_ioctl_priv_prism2_param(struct net_device
*dev
,
2289 struct iw_request_info
*info
,
2290 void *wrqu
, char *extra
)
2292 struct hostap_interface
*iface
;
2293 local_info_t
*local
;
2294 int *i
= (int *) extra
;
2296 int value
= *(i
+ 1);
2300 iface
= netdev_priv(dev
);
2301 local
= iface
->local
;
2304 case PRISM2_PARAM_TXRATECTRL
:
2305 local
->fw_tx_rate_control
= value
;
2308 case PRISM2_PARAM_BEACON_INT
:
2309 if (hostap_set_word(dev
, HFA384X_RID_CNFBEACONINT
, value
) ||
2310 local
->func
->reset_port(dev
))
2313 local
->beacon_int
= value
;
2316 #ifndef PRISM2_NO_STATION_MODES
2317 case PRISM2_PARAM_PSEUDO_IBSS
:
2318 if (value
== local
->pseudo_adhoc
)
2321 if (value
!= 0 && value
!= 1) {
2326 printk(KERN_DEBUG
"prism2: %s: pseudo IBSS change %d -> %d\n",
2327 dev
->name
, local
->pseudo_adhoc
, value
);
2328 local
->pseudo_adhoc
= value
;
2329 if (local
->iw_mode
!= IW_MODE_ADHOC
)
2332 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2333 hostap_get_porttype(local
))) {
2338 if (local
->func
->reset_port(dev
))
2341 #endif /* PRISM2_NO_STATION_MODES */
2343 case PRISM2_PARAM_ALC
:
2344 printk(KERN_DEBUG
"%s: %s ALC\n", dev
->name
,
2345 value
== 0 ? "Disabling" : "Enabling");
2346 val
= HFA384X_TEST_CFG_BIT_ALC
;
2347 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
2348 (HFA384X_TEST_CFG_BITS
<< 8),
2349 value
== 0 ? 0 : 1, &val
, NULL
);
2352 case PRISM2_PARAM_DUMP
:
2353 local
->frame_dump
= value
;
2356 case PRISM2_PARAM_OTHER_AP_POLICY
:
2357 if (value
< 0 || value
> 3) {
2361 if (local
->ap
!= NULL
)
2362 local
->ap
->ap_policy
= value
;
2365 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2366 if (value
< 0 || value
> 7 * 24 * 60 * 60) {
2370 if (local
->ap
!= NULL
)
2371 local
->ap
->max_inactivity
= value
* HZ
;
2374 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2375 if (local
->ap
!= NULL
)
2376 local
->ap
->bridge_packets
= value
;
2379 case PRISM2_PARAM_DTIM_PERIOD
:
2380 if (value
< 0 || value
> 65535) {
2384 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNDTIMPERIOD
, value
)
2385 || local
->func
->reset_port(dev
))
2388 local
->dtim_period
= value
;
2391 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2392 if (local
->ap
!= NULL
)
2393 local
->ap
->nullfunc_ack
= value
;
2396 case PRISM2_PARAM_MAX_WDS
:
2397 local
->wds_max_connections
= value
;
2400 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2401 if (local
->ap
!= NULL
) {
2402 if (!local
->ap
->autom_ap_wds
&& value
) {
2403 /* add WDS link to all APs in STA table */
2404 hostap_add_wds_links(local
);
2406 local
->ap
->autom_ap_wds
= value
;
2410 case PRISM2_PARAM_AP_AUTH_ALGS
:
2411 local
->auth_algs
= value
;
2412 if (hostap_set_auth_algs(local
))
2416 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2417 local
->monitor_allow_fcserr
= value
;
2420 case PRISM2_PARAM_HOST_ENCRYPT
:
2421 local
->host_encrypt
= value
;
2422 if (hostap_set_encryption(local
) ||
2423 local
->func
->reset_port(dev
))
2427 case PRISM2_PARAM_HOST_DECRYPT
:
2428 local
->host_decrypt
= value
;
2429 if (hostap_set_encryption(local
) ||
2430 local
->func
->reset_port(dev
))
2434 #ifndef PRISM2_NO_STATION_MODES
2435 case PRISM2_PARAM_HOST_ROAMING
:
2436 if (value
< 0 || value
> 2) {
2440 local
->host_roaming
= value
;
2441 if (hostap_set_roaming(local
) || local
->func
->reset_port(dev
))
2444 #endif /* PRISM2_NO_STATION_MODES */
2446 case PRISM2_PARAM_BCRX_STA_KEY
:
2447 local
->bcrx_sta_key
= value
;
2450 case PRISM2_PARAM_IEEE_802_1X
:
2451 local
->ieee_802_1x
= value
;
2454 case PRISM2_PARAM_ANTSEL_TX
:
2455 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2459 local
->antsel_tx
= value
;
2460 hostap_set_antsel(local
);
2463 case PRISM2_PARAM_ANTSEL_RX
:
2464 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2468 local
->antsel_rx
= value
;
2469 hostap_set_antsel(local
);
2472 case PRISM2_PARAM_MONITOR_TYPE
:
2473 if (value
!= PRISM2_MONITOR_80211
&&
2474 value
!= PRISM2_MONITOR_CAPHDR
&&
2475 value
!= PRISM2_MONITOR_PRISM
&&
2476 value
!= PRISM2_MONITOR_RADIOTAP
) {
2480 local
->monitor_type
= value
;
2481 if (local
->iw_mode
== IW_MODE_MONITOR
)
2482 hostap_monitor_set_type(local
);
2485 case PRISM2_PARAM_WDS_TYPE
:
2486 local
->wds_type
= value
;
2489 case PRISM2_PARAM_HOSTSCAN
:
2491 struct hfa384x_hostscan_request scan_req
;
2494 memset(&scan_req
, 0, sizeof(scan_req
));
2495 scan_req
.channel_list
= cpu_to_le16(0x3fff);
2497 case 1: rate
= HFA384X_RATES_1MBPS
; break;
2498 case 2: rate
= HFA384X_RATES_2MBPS
; break;
2499 case 3: rate
= HFA384X_RATES_5MBPS
; break;
2500 case 4: rate
= HFA384X_RATES_11MBPS
; break;
2501 default: rate
= HFA384X_RATES_1MBPS
; break;
2503 scan_req
.txrate
= cpu_to_le16(rate
);
2504 /* leave SSID empty to accept all SSIDs */
2506 if (local
->iw_mode
== IW_MODE_MASTER
) {
2507 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2508 HFA384X_PORTTYPE_BSS
) ||
2509 local
->func
->reset_port(dev
))
2510 printk(KERN_DEBUG
"Leaving Host AP mode "
2511 "for HostScan failed\n");
2514 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
2515 sizeof(scan_req
))) {
2516 printk(KERN_DEBUG
"HOSTSCAN failed\n");
2519 if (local
->iw_mode
== IW_MODE_MASTER
) {
2520 wait_queue_t __wait
;
2521 init_waitqueue_entry(&__wait
, current
);
2522 add_wait_queue(&local
->hostscan_wq
, &__wait
);
2523 set_current_state(TASK_INTERRUPTIBLE
);
2524 schedule_timeout(HZ
);
2525 if (signal_pending(current
))
2527 set_current_state(TASK_RUNNING
);
2528 remove_wait_queue(&local
->hostscan_wq
, &__wait
);
2530 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2531 HFA384X_PORTTYPE_HOSTAP
) ||
2532 local
->func
->reset_port(dev
))
2533 printk(KERN_DEBUG
"Returning to Host AP mode "
2534 "after HostScan failed\n");
2539 case PRISM2_PARAM_AP_SCAN
:
2540 local
->passive_scan_interval
= value
;
2541 if (timer_pending(&local
->passive_scan_timer
))
2542 del_timer(&local
->passive_scan_timer
);
2544 local
->passive_scan_timer
.expires
= jiffies
+
2545 local
->passive_scan_interval
* HZ
;
2546 add_timer(&local
->passive_scan_timer
);
2550 case PRISM2_PARAM_ENH_SEC
:
2551 if (value
< 0 || value
> 3) {
2555 local
->enh_sec
= value
;
2556 if (hostap_set_word(dev
, HFA384X_RID_CNFENHSECURITY
,
2558 local
->func
->reset_port(dev
)) {
2559 printk(KERN_INFO
"%s: cnfEnhSecurity requires STA f/w "
2560 "1.6.3 or newer\n", dev
->name
);
2565 #ifdef PRISM2_IO_DEBUG
2566 case PRISM2_PARAM_IO_DEBUG
:
2567 local
->io_debug_enabled
= value
;
2569 #endif /* PRISM2_IO_DEBUG */
2571 case PRISM2_PARAM_BASIC_RATES
:
2572 if ((value
& local
->tx_rate_control
) != value
|| value
== 0) {
2573 printk(KERN_INFO
"%s: invalid basic rate set - basic "
2574 "rates must be in supported rate set\n",
2579 local
->basic_rates
= value
;
2580 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
2581 local
->basic_rates
) ||
2582 local
->func
->reset_port(dev
))
2586 case PRISM2_PARAM_OPER_RATES
:
2587 local
->tx_rate_control
= value
;
2588 if (hostap_set_rate(dev
))
2592 case PRISM2_PARAM_HOSTAPD
:
2593 ret
= hostap_set_hostapd(local
, value
, 1);
2596 case PRISM2_PARAM_HOSTAPD_STA
:
2597 ret
= hostap_set_hostapd_sta(local
, value
, 1);
2600 case PRISM2_PARAM_WPA
:
2602 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2604 else if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
2609 case PRISM2_PARAM_PRIVACY_INVOKED
:
2610 local
->privacy_invoked
= value
;
2611 if (hostap_set_encryption(local
) ||
2612 local
->func
->reset_port(dev
))
2616 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2617 local
->tkip_countermeasures
= value
;
2620 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2621 local
->drop_unencrypted
= value
;
2624 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2625 local
->scan_channel_mask
= value
;
2629 printk(KERN_DEBUG
"%s: prism2_param: unknown param %d\n",
2639 static int prism2_ioctl_priv_get_prism2_param(struct net_device
*dev
,
2640 struct iw_request_info
*info
,
2641 void *wrqu
, char *extra
)
2643 struct hostap_interface
*iface
;
2644 local_info_t
*local
;
2645 int *param
= (int *) extra
;
2648 iface
= netdev_priv(dev
);
2649 local
= iface
->local
;
2652 case PRISM2_PARAM_TXRATECTRL
:
2653 *param
= local
->fw_tx_rate_control
;
2656 case PRISM2_PARAM_BEACON_INT
:
2657 *param
= local
->beacon_int
;
2660 case PRISM2_PARAM_PSEUDO_IBSS
:
2661 *param
= local
->pseudo_adhoc
;
2664 case PRISM2_PARAM_ALC
:
2665 ret
= -EOPNOTSUPP
; /* FIX */
2668 case PRISM2_PARAM_DUMP
:
2669 *param
= local
->frame_dump
;
2672 case PRISM2_PARAM_OTHER_AP_POLICY
:
2673 if (local
->ap
!= NULL
)
2674 *param
= local
->ap
->ap_policy
;
2679 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2680 if (local
->ap
!= NULL
)
2681 *param
= local
->ap
->max_inactivity
/ HZ
;
2686 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2687 if (local
->ap
!= NULL
)
2688 *param
= local
->ap
->bridge_packets
;
2693 case PRISM2_PARAM_DTIM_PERIOD
:
2694 *param
= local
->dtim_period
;
2697 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2698 if (local
->ap
!= NULL
)
2699 *param
= local
->ap
->nullfunc_ack
;
2704 case PRISM2_PARAM_MAX_WDS
:
2705 *param
= local
->wds_max_connections
;
2708 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2709 if (local
->ap
!= NULL
)
2710 *param
= local
->ap
->autom_ap_wds
;
2715 case PRISM2_PARAM_AP_AUTH_ALGS
:
2716 *param
= local
->auth_algs
;
2719 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2720 *param
= local
->monitor_allow_fcserr
;
2723 case PRISM2_PARAM_HOST_ENCRYPT
:
2724 *param
= local
->host_encrypt
;
2727 case PRISM2_PARAM_HOST_DECRYPT
:
2728 *param
= local
->host_decrypt
;
2731 case PRISM2_PARAM_HOST_ROAMING
:
2732 *param
= local
->host_roaming
;
2735 case PRISM2_PARAM_BCRX_STA_KEY
:
2736 *param
= local
->bcrx_sta_key
;
2739 case PRISM2_PARAM_IEEE_802_1X
:
2740 *param
= local
->ieee_802_1x
;
2743 case PRISM2_PARAM_ANTSEL_TX
:
2744 *param
= local
->antsel_tx
;
2747 case PRISM2_PARAM_ANTSEL_RX
:
2748 *param
= local
->antsel_rx
;
2751 case PRISM2_PARAM_MONITOR_TYPE
:
2752 *param
= local
->monitor_type
;
2755 case PRISM2_PARAM_WDS_TYPE
:
2756 *param
= local
->wds_type
;
2759 case PRISM2_PARAM_HOSTSCAN
:
2763 case PRISM2_PARAM_AP_SCAN
:
2764 *param
= local
->passive_scan_interval
;
2767 case PRISM2_PARAM_ENH_SEC
:
2768 *param
= local
->enh_sec
;
2771 #ifdef PRISM2_IO_DEBUG
2772 case PRISM2_PARAM_IO_DEBUG
:
2773 *param
= local
->io_debug_enabled
;
2775 #endif /* PRISM2_IO_DEBUG */
2777 case PRISM2_PARAM_BASIC_RATES
:
2778 *param
= local
->basic_rates
;
2781 case PRISM2_PARAM_OPER_RATES
:
2782 *param
= local
->tx_rate_control
;
2785 case PRISM2_PARAM_HOSTAPD
:
2786 *param
= local
->hostapd
;
2789 case PRISM2_PARAM_HOSTAPD_STA
:
2790 *param
= local
->hostapd_sta
;
2793 case PRISM2_PARAM_WPA
:
2794 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2796 *param
= local
->wpa
;
2799 case PRISM2_PARAM_PRIVACY_INVOKED
:
2800 *param
= local
->privacy_invoked
;
2803 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2804 *param
= local
->tkip_countermeasures
;
2807 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2808 *param
= local
->drop_unencrypted
;
2811 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2812 *param
= local
->scan_channel_mask
;
2816 printk(KERN_DEBUG
"%s: get_prism2_param: unknown param %d\n",
2826 static int prism2_ioctl_priv_readmif(struct net_device
*dev
,
2827 struct iw_request_info
*info
,
2828 void *wrqu
, char *extra
)
2830 struct hostap_interface
*iface
;
2831 local_info_t
*local
;
2834 iface
= netdev_priv(dev
);
2835 local
= iface
->local
;
2837 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
, *extra
, NULL
,
2847 static int prism2_ioctl_priv_writemif(struct net_device
*dev
,
2848 struct iw_request_info
*info
,
2849 void *wrqu
, char *extra
)
2851 struct hostap_interface
*iface
;
2852 local_info_t
*local
;
2855 iface
= netdev_priv(dev
);
2856 local
= iface
->local
;
2860 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
, cr
, &val
, NULL
))
2867 static int prism2_ioctl_priv_monitor(struct net_device
*dev
, int *i
)
2869 struct hostap_interface
*iface
;
2870 local_info_t
*local
;
2874 iface
= netdev_priv(dev
);
2875 local
= iface
->local
;
2877 printk(KERN_DEBUG
"%s: process %d (%s) used deprecated iwpriv monitor "
2878 "- update software to use iwconfig mode monitor\n",
2879 dev
->name
, task_pid_nr(current
), current
->comm
);
2881 /* Backward compatibility code - this can be removed at some point */
2884 /* Disable monitor mode - old mode was not saved, so go to
2886 mode
= IW_MODE_MASTER
;
2887 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2888 } else if (*i
== 1) {
2889 /* netlink socket mode is not supported anymore since it did
2890 * not separate different devices from each other and was not
2891 * best method for delivering large amount of packets to
2894 } else if (*i
== 2 || *i
== 3) {
2897 local
->monitor_type
= PRISM2_MONITOR_80211
;
2900 local
->monitor_type
= PRISM2_MONITOR_PRISM
;
2903 mode
= IW_MODE_MONITOR
;
2904 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2905 hostap_monitor_mode_enable(local
);
2913 static int prism2_ioctl_priv_reset(struct net_device
*dev
, int *i
)
2915 struct hostap_interface
*iface
;
2916 local_info_t
*local
;
2918 iface
= netdev_priv(dev
);
2919 local
= iface
->local
;
2921 printk(KERN_DEBUG
"%s: manual reset request(%d)\n", dev
->name
, *i
);
2924 /* Disable and enable card */
2925 local
->func
->hw_shutdown(dev
, 1);
2926 local
->func
->hw_config(dev
, 0);
2931 local
->func
->hw_reset(dev
);
2935 /* Disable and enable port 0 */
2936 local
->func
->reset_port(dev
);
2940 prism2_sta_deauth(local
, WLAN_REASON_DEAUTH_LEAVING
);
2941 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_DISABLE
, 0, NULL
,
2947 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_ENABLE
, 0, NULL
,
2953 printk(KERN_DEBUG
"Unknown reset request %d\n", *i
);
2961 static int prism2_ioctl_priv_set_rid_word(struct net_device
*dev
, int *i
)
2964 int value
= *(i
+ 1);
2966 printk(KERN_DEBUG
"%s: Set RID[0x%X] = %d\n", dev
->name
, rid
, value
);
2968 if (hostap_set_word(dev
, rid
, value
))
2975 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2976 static int ap_mac_cmd_ioctl(local_info_t
*local
, int *cmd
)
2981 case AP_MAC_CMD_POLICY_OPEN
:
2982 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_OPEN
;
2984 case AP_MAC_CMD_POLICY_ALLOW
:
2985 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_ALLOW
;
2987 case AP_MAC_CMD_POLICY_DENY
:
2988 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_DENY
;
2990 case AP_MAC_CMD_FLUSH
:
2991 ap_control_flush_macs(&local
->ap
->mac_restrictions
);
2993 case AP_MAC_CMD_KICKALL
:
2994 ap_control_kickall(local
->ap
);
2995 hostap_deauth_all_stas(local
->dev
, local
->ap
, 0);
3004 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3007 #ifdef PRISM2_DOWNLOAD_SUPPORT
3008 static int prism2_ioctl_priv_download(local_info_t
*local
, struct iw_point
*p
)
3010 struct prism2_download_param
*param
;
3013 if (p
->length
< sizeof(struct prism2_download_param
) ||
3014 p
->length
> 1024 || !p
->pointer
)
3017 param
= kmalloc(p
->length
, GFP_KERNEL
);
3021 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
3026 if (p
->length
< sizeof(struct prism2_download_param
) +
3027 param
->num_areas
* sizeof(struct prism2_download_area
)) {
3032 ret
= local
->func
->download(local
, param
);
3038 #endif /* PRISM2_DOWNLOAD_SUPPORT */
3041 static int prism2_set_genericelement(struct net_device
*dev
, u8
*elem
,
3044 struct hostap_interface
*iface
= netdev_priv(dev
);
3045 local_info_t
*local
= iface
->local
;
3049 * Add 16-bit length in the beginning of the buffer because Prism2 RID
3052 buf
= kmalloc(len
+ 2, GFP_KERNEL
);
3056 *((__le16
*) buf
) = cpu_to_le16(len
);
3057 memcpy(buf
+ 2, elem
, len
);
3059 kfree(local
->generic_elem
);
3060 local
->generic_elem
= buf
;
3061 local
->generic_elem_len
= len
+ 2;
3063 return local
->func
->set_rid(local
->dev
, HFA384X_RID_GENERICELEMENT
,
3068 static int prism2_ioctl_siwauth(struct net_device
*dev
,
3069 struct iw_request_info
*info
,
3070 struct iw_param
*data
, char *extra
)
3072 struct hostap_interface
*iface
= netdev_priv(dev
);
3073 local_info_t
*local
= iface
->local
;
3075 switch (data
->flags
& IW_AUTH_INDEX
) {
3076 case IW_AUTH_WPA_VERSION
:
3077 case IW_AUTH_CIPHER_PAIRWISE
:
3078 case IW_AUTH_CIPHER_GROUP
:
3079 case IW_AUTH_KEY_MGMT
:
3081 * Host AP driver does not use these parameters and allows
3082 * wpa_supplicant to control them internally.
3085 case IW_AUTH_TKIP_COUNTERMEASURES
:
3086 local
->tkip_countermeasures
= data
->value
;
3088 case IW_AUTH_DROP_UNENCRYPTED
:
3089 local
->drop_unencrypted
= data
->value
;
3091 case IW_AUTH_80211_AUTH_ALG
:
3092 local
->auth_algs
= data
->value
;
3094 case IW_AUTH_WPA_ENABLED
:
3095 if (data
->value
== 0) {
3097 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3099 prism2_set_genericelement(dev
, "", 0);
3100 local
->host_roaming
= 0;
3101 local
->privacy_invoked
= 0;
3102 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
3104 hostap_set_roaming(local
) ||
3105 hostap_set_encryption(local
) ||
3106 local
->func
->reset_port(dev
))
3110 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3112 local
->host_roaming
= 2;
3113 local
->privacy_invoked
= 1;
3115 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
, 1) ||
3116 hostap_set_roaming(local
) ||
3117 hostap_set_encryption(local
) ||
3118 local
->func
->reset_port(dev
))
3121 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3122 local
->ieee_802_1x
= data
->value
;
3124 case IW_AUTH_PRIVACY_INVOKED
:
3125 local
->privacy_invoked
= data
->value
;
3134 static int prism2_ioctl_giwauth(struct net_device
*dev
,
3135 struct iw_request_info
*info
,
3136 struct iw_param
*data
, char *extra
)
3138 struct hostap_interface
*iface
= netdev_priv(dev
);
3139 local_info_t
*local
= iface
->local
;
3141 switch (data
->flags
& IW_AUTH_INDEX
) {
3142 case IW_AUTH_WPA_VERSION
:
3143 case IW_AUTH_CIPHER_PAIRWISE
:
3144 case IW_AUTH_CIPHER_GROUP
:
3145 case IW_AUTH_KEY_MGMT
:
3147 * Host AP driver does not use these parameters and allows
3148 * wpa_supplicant to control them internally.
3151 case IW_AUTH_TKIP_COUNTERMEASURES
:
3152 data
->value
= local
->tkip_countermeasures
;
3154 case IW_AUTH_DROP_UNENCRYPTED
:
3155 data
->value
= local
->drop_unencrypted
;
3157 case IW_AUTH_80211_AUTH_ALG
:
3158 data
->value
= local
->auth_algs
;
3160 case IW_AUTH_WPA_ENABLED
:
3161 data
->value
= local
->wpa
;
3163 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3164 data
->value
= local
->ieee_802_1x
;
3173 static int prism2_ioctl_siwencodeext(struct net_device
*dev
,
3174 struct iw_request_info
*info
,
3175 struct iw_point
*erq
, char *extra
)
3177 struct hostap_interface
*iface
= netdev_priv(dev
);
3178 local_info_t
*local
= iface
->local
;
3179 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3181 struct lib80211_crypto_ops
*ops
;
3182 struct lib80211_crypt_data
**crypt
;
3185 const char *alg
, *module
;
3187 i
= erq
->flags
& IW_ENCODE_INDEX
;
3190 if (i
< 1 || i
> WEP_KEYS
)
3191 i
= local
->crypt_info
.tx_keyidx
;
3194 if (i
< 0 || i
>= WEP_KEYS
)
3197 addr
= ext
->addr
.sa_data
;
3198 if (addr
[0] == 0xff && addr
[1] == 0xff && addr
[2] == 0xff &&
3199 addr
[3] == 0xff && addr
[4] == 0xff && addr
[5] == 0xff) {
3201 crypt
= &local
->crypt_info
.crypt
[i
];
3205 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, addr
, 0, &crypt
);
3206 if (sta_ptr
== NULL
) {
3207 if (local
->iw_mode
== IW_MODE_INFRA
) {
3209 * TODO: add STA entry for the current AP so
3210 * that unicast key can be used. For now, this
3211 * is emulated by using default key idx 0.
3214 crypt
= &local
->crypt_info
.crypt
[i
];
3220 if ((erq
->flags
& IW_ENCODE_DISABLED
) ||
3221 ext
->alg
== IW_ENCODE_ALG_NONE
) {
3223 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3228 case IW_ENCODE_ALG_WEP
:
3230 module
= "lib80211_crypt_wep";
3232 case IW_ENCODE_ALG_TKIP
:
3234 module
= "lib80211_crypt_tkip";
3236 case IW_ENCODE_ALG_CCMP
:
3238 module
= "lib80211_crypt_ccmp";
3241 printk(KERN_DEBUG
"%s: unsupported algorithm %d\n",
3242 local
->dev
->name
, ext
->alg
);
3247 ops
= lib80211_get_crypto_ops(alg
);
3249 request_module(module
);
3250 ops
= lib80211_get_crypto_ops(alg
);
3253 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3254 local
->dev
->name
, alg
);
3259 if (sta_ptr
|| ext
->alg
!= IW_ENCODE_ALG_WEP
) {
3261 * Per station encryption and other than WEP algorithms
3262 * require host-based encryption, so force them on
3265 local
->host_decrypt
= local
->host_encrypt
= 1;
3268 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3269 struct lib80211_crypt_data
*new_crypt
;
3271 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3273 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3275 if (new_crypt
== NULL
) {
3279 new_crypt
->ops
= ops
;
3280 if (new_crypt
->ops
&& try_module_get(new_crypt
->ops
->owner
))
3281 new_crypt
->priv
= new_crypt
->ops
->init(i
);
3282 if (new_crypt
->priv
== NULL
) {
3292 * TODO: if ext_flags does not have IW_ENCODE_EXT_RX_SEQ_VALID, the
3293 * existing seq# should not be changed.
3294 * TODO: if ext_flags has IW_ENCODE_EXT_TX_SEQ_VALID, next TX seq#
3295 * should be changed to something else than zero.
3297 if ((!(ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) || ext
->key_len
> 0)
3298 && (*crypt
)->ops
->set_key
&&
3299 (*crypt
)->ops
->set_key(ext
->key
, ext
->key_len
, ext
->rx_seq
,
3300 (*crypt
)->priv
) < 0) {
3301 printk(KERN_DEBUG
"%s: key setting failed\n",
3307 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) {
3309 local
->crypt_info
.tx_keyidx
= i
;
3313 if (sta_ptr
== NULL
&& ext
->key_len
> 0) {
3315 for (j
= 0; j
< WEP_KEYS
; j
++) {
3316 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
3322 local
->crypt_info
.tx_keyidx
= i
;
3327 hostap_handle_sta_release(sta_ptr
);
3329 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
3332 * Do not reset port0 if card is in Managed mode since resetting will
3333 * generate new IEEE 802.11 authentication which may end up in looping
3334 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3335 * after WEP configuration. However, keys are apparently changed at
3336 * least in Managed mode.
3339 (hostap_set_encryption(local
) ||
3340 (local
->iw_mode
!= IW_MODE_INFRA
&&
3341 local
->func
->reset_port(local
->dev
))))
3348 static int prism2_ioctl_giwencodeext(struct net_device
*dev
,
3349 struct iw_request_info
*info
,
3350 struct iw_point
*erq
, char *extra
)
3352 struct hostap_interface
*iface
= netdev_priv(dev
);
3353 local_info_t
*local
= iface
->local
;
3354 struct lib80211_crypt_data
**crypt
;
3357 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3360 max_key_len
= erq
->length
- sizeof(*ext
);
3361 if (max_key_len
< 0)
3364 i
= erq
->flags
& IW_ENCODE_INDEX
;
3365 if (i
< 1 || i
> WEP_KEYS
)
3366 i
= local
->crypt_info
.tx_keyidx
;
3370 addr
= ext
->addr
.sa_data
;
3371 if (addr
[0] == 0xff && addr
[1] == 0xff && addr
[2] == 0xff &&
3372 addr
[3] == 0xff && addr
[4] == 0xff && addr
[5] == 0xff) {
3374 crypt
= &local
->crypt_info
.crypt
[i
];
3377 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, addr
, 0, &crypt
);
3378 if (sta_ptr
== NULL
)
3382 memset(ext
, 0, sizeof(*ext
));
3384 if (*crypt
== NULL
|| (*crypt
)->ops
== NULL
) {
3385 ext
->alg
= IW_ENCODE_ALG_NONE
;
3387 erq
->flags
|= IW_ENCODE_DISABLED
;
3389 if (strcmp((*crypt
)->ops
->name
, "WEP") == 0)
3390 ext
->alg
= IW_ENCODE_ALG_WEP
;
3391 else if (strcmp((*crypt
)->ops
->name
, "TKIP") == 0)
3392 ext
->alg
= IW_ENCODE_ALG_TKIP
;
3393 else if (strcmp((*crypt
)->ops
->name
, "CCMP") == 0)
3394 ext
->alg
= IW_ENCODE_ALG_CCMP
;
3398 if ((*crypt
)->ops
->get_key
) {
3400 (*crypt
)->ops
->get_key(ext
->key
,
3405 (ext
->alg
== IW_ENCODE_ALG_TKIP
||
3406 ext
->alg
== IW_ENCODE_ALG_CCMP
))
3407 ext
->ext_flags
|= IW_ENCODE_EXT_TX_SEQ_VALID
;
3412 hostap_handle_sta_release(sta_ptr
);
3418 static int prism2_ioctl_set_encryption(local_info_t
*local
,
3419 struct prism2_hostapd_param
*param
,
3423 struct lib80211_crypto_ops
*ops
;
3424 struct lib80211_crypt_data
**crypt
;
3427 param
->u
.crypt
.err
= 0;
3428 param
->u
.crypt
.alg
[HOSTAP_CRYPT_ALG_NAME_LEN
- 1] = '\0';
3431 (int) ((char *) param
->u
.crypt
.key
- (char *) param
) +
3432 param
->u
.crypt
.key_len
)
3435 if (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
3436 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
3437 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
3438 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3441 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3443 if (param
->u
.crypt
.idx
)
3445 sta_ptr
= ap_crypt_get_ptrs(
3446 local
->ap
, param
->sta_addr
,
3447 (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_PERMANENT
),
3450 if (sta_ptr
== NULL
) {
3451 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3456 if (strcmp(param
->u
.crypt
.alg
, "none") == 0) {
3458 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3462 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3463 if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "WEP") == 0) {
3464 request_module("lib80211_crypt_wep");
3465 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3466 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "TKIP") == 0) {
3467 request_module("lib80211_crypt_tkip");
3468 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3469 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "CCMP") == 0) {
3470 request_module("lib80211_crypt_ccmp");
3471 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3474 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3475 local
->dev
->name
, param
->u
.crypt
.alg
);
3476 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ALG
;
3481 /* station based encryption and other than WEP algorithms require
3482 * host-based encryption, so force them on automatically */
3483 local
->host_decrypt
= local
->host_encrypt
= 1;
3485 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3486 struct lib80211_crypt_data
*new_crypt
;
3488 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3490 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3492 if (new_crypt
== NULL
) {
3496 new_crypt
->ops
= ops
;
3497 new_crypt
->priv
= new_crypt
->ops
->init(param
->u
.crypt
.idx
);
3498 if (new_crypt
->priv
== NULL
) {
3500 param
->u
.crypt
.err
=
3501 HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED
;
3509 if ((!(param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) ||
3510 param
->u
.crypt
.key_len
> 0) && (*crypt
)->ops
->set_key
&&
3511 (*crypt
)->ops
->set_key(param
->u
.crypt
.key
,
3512 param
->u
.crypt
.key_len
, param
->u
.crypt
.seq
,
3513 (*crypt
)->priv
) < 0) {
3514 printk(KERN_DEBUG
"%s: key setting failed\n",
3516 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_KEY_SET_FAILED
;
3521 if (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) {
3523 local
->crypt_info
.tx_keyidx
= param
->u
.crypt
.idx
;
3524 else if (param
->u
.crypt
.idx
) {
3525 printk(KERN_DEBUG
"%s: TX key idx setting failed\n",
3527 param
->u
.crypt
.err
=
3528 HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED
;
3536 hostap_handle_sta_release(sta_ptr
);
3538 /* Do not reset port0 if card is in Managed mode since resetting will
3539 * generate new IEEE 802.11 authentication which may end up in looping
3540 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3541 * after WEP configuration. However, keys are apparently changed at
3542 * least in Managed mode. */
3544 (hostap_set_encryption(local
) ||
3545 (local
->iw_mode
!= IW_MODE_INFRA
&&
3546 local
->func
->reset_port(local
->dev
)))) {
3547 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_CARD_CONF_FAILED
;
3555 static int prism2_ioctl_get_encryption(local_info_t
*local
,
3556 struct prism2_hostapd_param
*param
,
3559 struct lib80211_crypt_data
**crypt
;
3563 param
->u
.crypt
.err
= 0;
3565 max_key_len
= param_len
-
3566 (int) ((char *) param
->u
.crypt
.key
- (char *) param
);
3567 if (max_key_len
< 0)
3570 if (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
3571 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
3572 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
3574 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3575 param
->u
.crypt
.idx
= local
->crypt_info
.tx_keyidx
;
3576 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3578 param
->u
.crypt
.idx
= 0;
3579 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, param
->sta_addr
, 0,
3582 if (sta_ptr
== NULL
) {
3583 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3588 if (*crypt
== NULL
|| (*crypt
)->ops
== NULL
) {
3589 memcpy(param
->u
.crypt
.alg
, "none", 5);
3590 param
->u
.crypt
.key_len
= 0;
3591 param
->u
.crypt
.idx
= 0xff;
3593 strncpy(param
->u
.crypt
.alg
, (*crypt
)->ops
->name
,
3594 HOSTAP_CRYPT_ALG_NAME_LEN
);
3595 param
->u
.crypt
.key_len
= 0;
3597 memset(param
->u
.crypt
.seq
, 0, 8);
3598 if ((*crypt
)->ops
->get_key
) {
3599 param
->u
.crypt
.key_len
=
3600 (*crypt
)->ops
->get_key(param
->u
.crypt
.key
,
3608 hostap_handle_sta_release(sta_ptr
);
3614 static int prism2_ioctl_get_rid(local_info_t
*local
,
3615 struct prism2_hostapd_param
*param
,
3620 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3624 res
= local
->func
->get_rid(local
->dev
, param
->u
.rid
.rid
,
3625 param
->u
.rid
.data
, param
->u
.rid
.len
, 0);
3627 param
->u
.rid
.len
= res
;
3635 static int prism2_ioctl_set_rid(local_info_t
*local
,
3636 struct prism2_hostapd_param
*param
,
3641 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3642 if (max_len
< 0 || max_len
< param
->u
.rid
.len
)
3645 return local
->func
->set_rid(local
->dev
, param
->u
.rid
.rid
,
3646 param
->u
.rid
.data
, param
->u
.rid
.len
);
3650 static int prism2_ioctl_set_assoc_ap_addr(local_info_t
*local
,
3651 struct prism2_hostapd_param
*param
,
3654 printk(KERN_DEBUG
"%ssta: associated as client with AP %pM\n",
3655 local
->dev
->name
, param
->sta_addr
);
3656 memcpy(local
->assoc_ap_addr
, param
->sta_addr
, ETH_ALEN
);
3661 static int prism2_ioctl_siwgenie(struct net_device
*dev
,
3662 struct iw_request_info
*info
,
3663 struct iw_point
*data
, char *extra
)
3665 return prism2_set_genericelement(dev
, extra
, data
->length
);
3669 static int prism2_ioctl_giwgenie(struct net_device
*dev
,
3670 struct iw_request_info
*info
,
3671 struct iw_point
*data
, char *extra
)
3673 struct hostap_interface
*iface
= netdev_priv(dev
);
3674 local_info_t
*local
= iface
->local
;
3675 int len
= local
->generic_elem_len
- 2;
3677 if (len
<= 0 || local
->generic_elem
== NULL
) {
3682 if (data
->length
< len
)
3686 memcpy(extra
, local
->generic_elem
+ 2, len
);
3692 static int prism2_ioctl_set_generic_element(local_info_t
*local
,
3693 struct prism2_hostapd_param
*param
,
3698 len
= param
->u
.generic_elem
.len
;
3699 max_len
= param_len
- PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN
;
3700 if (max_len
< 0 || max_len
< len
)
3703 return prism2_set_genericelement(local
->dev
,
3704 param
->u
.generic_elem
.data
, len
);
3708 static int prism2_ioctl_siwmlme(struct net_device
*dev
,
3709 struct iw_request_info
*info
,
3710 struct iw_point
*data
, char *extra
)
3712 struct hostap_interface
*iface
= netdev_priv(dev
);
3713 local_info_t
*local
= iface
->local
;
3714 struct iw_mlme
*mlme
= (struct iw_mlme
*) extra
;
3717 reason
= cpu_to_le16(mlme
->reason_code
);
3719 switch (mlme
->cmd
) {
3720 case IW_MLME_DEAUTH
:
3721 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3722 IEEE80211_STYPE_DEAUTH
,
3724 case IW_MLME_DISASSOC
:
3725 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3726 IEEE80211_STYPE_DISASSOC
,
3734 static int prism2_ioctl_mlme(local_info_t
*local
,
3735 struct prism2_hostapd_param
*param
)
3739 reason
= cpu_to_le16(param
->u
.mlme
.reason_code
);
3740 switch (param
->u
.mlme
.cmd
) {
3741 case MLME_STA_DEAUTH
:
3742 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3743 IEEE80211_STYPE_DEAUTH
,
3745 case MLME_STA_DISASSOC
:
3746 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3747 IEEE80211_STYPE_DISASSOC
,
3755 static int prism2_ioctl_scan_req(local_info_t
*local
,
3756 struct prism2_hostapd_param
*param
)
3758 #ifndef PRISM2_NO_STATION_MODES
3759 if ((local
->iw_mode
!= IW_MODE_INFRA
&&
3760 local
->iw_mode
!= IW_MODE_ADHOC
) ||
3761 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1)))
3764 if (!local
->dev_enabled
)
3767 return prism2_request_hostscan(local
->dev
, param
->u
.scan_req
.ssid
,
3768 param
->u
.scan_req
.ssid_len
);
3769 #else /* PRISM2_NO_STATION_MODES */
3771 #endif /* PRISM2_NO_STATION_MODES */
3775 static int prism2_ioctl_priv_hostapd(local_info_t
*local
, struct iw_point
*p
)
3777 struct prism2_hostapd_param
*param
;
3781 if (p
->length
< sizeof(struct prism2_hostapd_param
) ||
3782 p
->length
> PRISM2_HOSTAPD_MAX_BUF_SIZE
|| !p
->pointer
)
3785 param
= kmalloc(p
->length
, GFP_KERNEL
);
3789 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
3794 switch (param
->cmd
) {
3795 case PRISM2_SET_ENCRYPTION
:
3796 ret
= prism2_ioctl_set_encryption(local
, param
, p
->length
);
3798 case PRISM2_GET_ENCRYPTION
:
3799 ret
= prism2_ioctl_get_encryption(local
, param
, p
->length
);
3801 case PRISM2_HOSTAPD_GET_RID
:
3802 ret
= prism2_ioctl_get_rid(local
, param
, p
->length
);
3804 case PRISM2_HOSTAPD_SET_RID
:
3805 ret
= prism2_ioctl_set_rid(local
, param
, p
->length
);
3807 case PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR
:
3808 ret
= prism2_ioctl_set_assoc_ap_addr(local
, param
, p
->length
);
3810 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT
:
3811 ret
= prism2_ioctl_set_generic_element(local
, param
,
3814 case PRISM2_HOSTAPD_MLME
:
3815 ret
= prism2_ioctl_mlme(local
, param
);
3817 case PRISM2_HOSTAPD_SCAN_REQ
:
3818 ret
= prism2_ioctl_scan_req(local
, param
);
3821 ret
= prism2_hostapd(local
->ap
, param
);
3826 if (ret
== 1 || !ap_ioctl
) {
3827 if (copy_to_user(p
->pointer
, param
, p
->length
)) {
3830 } else if (ap_ioctl
)
3840 static void prism2_get_drvinfo(struct net_device
*dev
,
3841 struct ethtool_drvinfo
*info
)
3843 struct hostap_interface
*iface
;
3844 local_info_t
*local
;
3846 iface
= netdev_priv(dev
);
3847 local
= iface
->local
;
3849 strncpy(info
->driver
, "hostap", sizeof(info
->driver
) - 1);
3850 snprintf(info
->fw_version
, sizeof(info
->fw_version
) - 1,
3851 "%d.%d.%d", (local
->sta_fw_ver
>> 16) & 0xff,
3852 (local
->sta_fw_ver
>> 8) & 0xff,
3853 local
->sta_fw_ver
& 0xff);
3856 const struct ethtool_ops prism2_ethtool_ops
= {
3857 .get_drvinfo
= prism2_get_drvinfo
3861 /* Structures to export the Wireless Handlers */
3863 static const iw_handler prism2_handler
[] =
3865 (iw_handler
) NULL
, /* SIOCSIWCOMMIT */
3866 (iw_handler
) prism2_get_name
, /* SIOCGIWNAME */
3867 (iw_handler
) NULL
, /* SIOCSIWNWID */
3868 (iw_handler
) NULL
, /* SIOCGIWNWID */
3869 (iw_handler
) prism2_ioctl_siwfreq
, /* SIOCSIWFREQ */
3870 (iw_handler
) prism2_ioctl_giwfreq
, /* SIOCGIWFREQ */
3871 (iw_handler
) prism2_ioctl_siwmode
, /* SIOCSIWMODE */
3872 (iw_handler
) prism2_ioctl_giwmode
, /* SIOCGIWMODE */
3873 (iw_handler
) prism2_ioctl_siwsens
, /* SIOCSIWSENS */
3874 (iw_handler
) prism2_ioctl_giwsens
, /* SIOCGIWSENS */
3875 (iw_handler
) NULL
/* not used */, /* SIOCSIWRANGE */
3876 (iw_handler
) prism2_ioctl_giwrange
, /* SIOCGIWRANGE */
3877 (iw_handler
) NULL
/* not used */, /* SIOCSIWPRIV */
3878 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWPRIV */
3879 (iw_handler
) NULL
/* not used */, /* SIOCSIWSTATS */
3880 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWSTATS */
3881 iw_handler_set_spy
, /* SIOCSIWSPY */
3882 iw_handler_get_spy
, /* SIOCGIWSPY */
3883 iw_handler_set_thrspy
, /* SIOCSIWTHRSPY */
3884 iw_handler_get_thrspy
, /* SIOCGIWTHRSPY */
3885 (iw_handler
) prism2_ioctl_siwap
, /* SIOCSIWAP */
3886 (iw_handler
) prism2_ioctl_giwap
, /* SIOCGIWAP */
3887 (iw_handler
) prism2_ioctl_siwmlme
, /* SIOCSIWMLME */
3888 (iw_handler
) prism2_ioctl_giwaplist
, /* SIOCGIWAPLIST */
3889 (iw_handler
) prism2_ioctl_siwscan
, /* SIOCSIWSCAN */
3890 (iw_handler
) prism2_ioctl_giwscan
, /* SIOCGIWSCAN */
3891 (iw_handler
) prism2_ioctl_siwessid
, /* SIOCSIWESSID */
3892 (iw_handler
) prism2_ioctl_giwessid
, /* SIOCGIWESSID */
3893 (iw_handler
) prism2_ioctl_siwnickn
, /* SIOCSIWNICKN */
3894 (iw_handler
) prism2_ioctl_giwnickn
, /* SIOCGIWNICKN */
3895 (iw_handler
) NULL
, /* -- hole -- */
3896 (iw_handler
) NULL
, /* -- hole -- */
3897 (iw_handler
) prism2_ioctl_siwrate
, /* SIOCSIWRATE */
3898 (iw_handler
) prism2_ioctl_giwrate
, /* SIOCGIWRATE */
3899 (iw_handler
) prism2_ioctl_siwrts
, /* SIOCSIWRTS */
3900 (iw_handler
) prism2_ioctl_giwrts
, /* SIOCGIWRTS */
3901 (iw_handler
) prism2_ioctl_siwfrag
, /* SIOCSIWFRAG */
3902 (iw_handler
) prism2_ioctl_giwfrag
, /* SIOCGIWFRAG */
3903 (iw_handler
) prism2_ioctl_siwtxpow
, /* SIOCSIWTXPOW */
3904 (iw_handler
) prism2_ioctl_giwtxpow
, /* SIOCGIWTXPOW */
3905 (iw_handler
) prism2_ioctl_siwretry
, /* SIOCSIWRETRY */
3906 (iw_handler
) prism2_ioctl_giwretry
, /* SIOCGIWRETRY */
3907 (iw_handler
) prism2_ioctl_siwencode
, /* SIOCSIWENCODE */
3908 (iw_handler
) prism2_ioctl_giwencode
, /* SIOCGIWENCODE */
3909 (iw_handler
) prism2_ioctl_siwpower
, /* SIOCSIWPOWER */
3910 (iw_handler
) prism2_ioctl_giwpower
, /* SIOCGIWPOWER */
3911 (iw_handler
) NULL
, /* -- hole -- */
3912 (iw_handler
) NULL
, /* -- hole -- */
3913 (iw_handler
) prism2_ioctl_siwgenie
, /* SIOCSIWGENIE */
3914 (iw_handler
) prism2_ioctl_giwgenie
, /* SIOCGIWGENIE */
3915 (iw_handler
) prism2_ioctl_siwauth
, /* SIOCSIWAUTH */
3916 (iw_handler
) prism2_ioctl_giwauth
, /* SIOCGIWAUTH */
3917 (iw_handler
) prism2_ioctl_siwencodeext
, /* SIOCSIWENCODEEXT */
3918 (iw_handler
) prism2_ioctl_giwencodeext
, /* SIOCGIWENCODEEXT */
3919 (iw_handler
) NULL
, /* SIOCSIWPMKSA */
3920 (iw_handler
) NULL
, /* -- hole -- */
3923 static const iw_handler prism2_private_handler
[] =
3924 { /* SIOCIWFIRSTPRIV + */
3925 (iw_handler
) prism2_ioctl_priv_prism2_param
, /* 0 */
3926 (iw_handler
) prism2_ioctl_priv_get_prism2_param
, /* 1 */
3927 (iw_handler
) prism2_ioctl_priv_writemif
, /* 2 */
3928 (iw_handler
) prism2_ioctl_priv_readmif
, /* 3 */
3931 const struct iw_handler_def hostap_iw_handler_def
=
3933 .num_standard
= ARRAY_SIZE(prism2_handler
),
3934 .num_private
= ARRAY_SIZE(prism2_private_handler
),
3935 .num_private_args
= ARRAY_SIZE(prism2_priv
),
3936 .standard
= (iw_handler
*) prism2_handler
,
3937 .private = (iw_handler
*) prism2_private_handler
,
3938 .private_args
= (struct iw_priv_args
*) prism2_priv
,
3939 .get_wireless_stats
= hostap_get_wireless_stats
,
3943 int hostap_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
3945 struct iwreq
*wrq
= (struct iwreq
*) ifr
;
3946 struct hostap_interface
*iface
;
3947 local_info_t
*local
;
3950 iface
= netdev_priv(dev
);
3951 local
= iface
->local
;
3954 /* Private ioctls (iwpriv) that have not yet been converted
3955 * into new wireless extensions API */
3957 case PRISM2_IOCTL_INQUIRE
:
3958 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3959 else ret
= prism2_ioctl_priv_inquire(dev
, (int *) wrq
->u
.name
);
3962 case PRISM2_IOCTL_MONITOR
:
3963 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3964 else ret
= prism2_ioctl_priv_monitor(dev
, (int *) wrq
->u
.name
);
3967 case PRISM2_IOCTL_RESET
:
3968 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3969 else ret
= prism2_ioctl_priv_reset(dev
, (int *) wrq
->u
.name
);
3972 case PRISM2_IOCTL_WDS_ADD
:
3973 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3974 else ret
= prism2_wds_add(local
, wrq
->u
.ap_addr
.sa_data
, 1);
3977 case PRISM2_IOCTL_WDS_DEL
:
3978 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3979 else ret
= prism2_wds_del(local
, wrq
->u
.ap_addr
.sa_data
, 1, 0);
3982 case PRISM2_IOCTL_SET_RID_WORD
:
3983 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3984 else ret
= prism2_ioctl_priv_set_rid_word(dev
,
3985 (int *) wrq
->u
.name
);
3988 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3989 case PRISM2_IOCTL_MACCMD
:
3990 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3991 else ret
= ap_mac_cmd_ioctl(local
, (int *) wrq
->u
.name
);
3994 case PRISM2_IOCTL_ADDMAC
:
3995 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3996 else ret
= ap_control_add_mac(&local
->ap
->mac_restrictions
,
3997 wrq
->u
.ap_addr
.sa_data
);
3999 case PRISM2_IOCTL_DELMAC
:
4000 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4001 else ret
= ap_control_del_mac(&local
->ap
->mac_restrictions
,
4002 wrq
->u
.ap_addr
.sa_data
);
4004 case PRISM2_IOCTL_KICKMAC
:
4005 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4006 else ret
= ap_control_kick_mac(local
->ap
, local
->dev
,
4007 wrq
->u
.ap_addr
.sa_data
);
4009 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
4012 /* Private ioctls that are not used with iwpriv;
4013 * in SIOCDEVPRIVATE range */
4015 #ifdef PRISM2_DOWNLOAD_SUPPORT
4016 case PRISM2_IOCTL_DOWNLOAD
:
4017 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4018 else ret
= prism2_ioctl_priv_download(local
, &wrq
->u
.data
);
4020 #endif /* PRISM2_DOWNLOAD_SUPPORT */
4022 case PRISM2_IOCTL_HOSTAPD
:
4023 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4024 else ret
= prism2_ioctl_priv_hostapd(local
, &wrq
->u
.data
);