1 // SPDX-License-Identifier: GPL-2.0
2 /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
4 #include <linux/slab.h>
5 #include <linux/types.h>
6 #include <linux/sched/signal.h>
7 #include <linux/ethtool.h>
8 #include <linux/if_arp.h>
9 #include <linux/module.h>
10 #include <linux/etherdevice.h>
11 #include <net/lib80211.h>
13 #include "hostap_wlan.h"
15 #include "hostap_ap.h"
17 static struct iw_statistics
*hostap_get_wireless_stats(struct net_device
*dev
)
19 struct hostap_interface
*iface
;
21 struct iw_statistics
*wstats
;
23 iface
= netdev_priv(dev
);
26 /* Why are we doing that ? Jean II */
27 if (iface
->type
!= HOSTAP_INTERFACE_MAIN
)
30 wstats
= &local
->wstats
;
33 wstats
->discard
.code
=
34 local
->comm_tallies
.rx_discards_wep_undecryptable
;
35 wstats
->discard
.misc
=
36 local
->comm_tallies
.rx_fcs_errors
+
37 local
->comm_tallies
.rx_discards_no_buffer
+
38 local
->comm_tallies
.tx_discards_wrong_sa
;
40 wstats
->discard
.retries
=
41 local
->comm_tallies
.tx_retry_limit_exceeded
;
42 wstats
->discard
.fragment
=
43 local
->comm_tallies
.rx_message_in_bad_msg_fragments
;
45 if (local
->iw_mode
!= IW_MODE_MASTER
&&
46 local
->iw_mode
!= IW_MODE_REPEAT
) {
49 /* RID reading might sleep and it must not be called in
50 * interrupt context or while atomic. However, this
51 * function seems to be called while atomic (at least in Linux
52 * 2.5.59). Update signal quality values only if in suitable
53 * context. Otherwise, previous values read from tick timer
57 #endif /* in_atomic */
59 if (update
&& prism2_update_comms_qual(dev
) == 0)
60 wstats
->qual
.updated
= IW_QUAL_ALL_UPDATED
|
63 wstats
->qual
.qual
= local
->comms_qual
;
64 wstats
->qual
.level
= local
->avg_signal
;
65 wstats
->qual
.noise
= local
->avg_noise
;
67 wstats
->qual
.qual
= 0;
68 wstats
->qual
.level
= 0;
69 wstats
->qual
.noise
= 0;
70 wstats
->qual
.updated
= IW_QUAL_ALL_INVALID
;
77 static int prism2_get_datarates(struct net_device
*dev
, u8
*rates
)
79 struct hostap_interface
*iface
;
85 iface
= netdev_priv(dev
);
88 len
= local
->func
->get_rid(dev
, HFA384X_RID_SUPPORTEDDATARATES
, buf
,
93 val
= le16_to_cpu(*(__le16
*) buf
); /* string length */
95 if (len
- 2 < val
|| val
> 10)
98 memcpy(rates
, buf
+ 2, val
);
103 static int prism2_get_name(struct net_device
*dev
,
104 struct iw_request_info
*info
,
105 char *name
, char *extra
)
108 int len
, i
, over2
= 0;
110 len
= prism2_get_datarates(dev
, rates
);
112 for (i
= 0; i
< len
; i
++) {
113 if (rates
[i
] == 0x0b || rates
[i
] == 0x16) {
119 strcpy(name
, over2
? "IEEE 802.11b" : "IEEE 802.11-DS");
125 static int prism2_ioctl_siwencode(struct net_device
*dev
,
126 struct iw_request_info
*info
,
127 struct iw_point
*erq
, char *keybuf
)
129 struct hostap_interface
*iface
;
132 struct lib80211_crypt_data
**crypt
;
134 iface
= netdev_priv(dev
);
135 local
= iface
->local
;
137 i
= erq
->flags
& IW_ENCODE_INDEX
;
139 i
= local
->crypt_info
.tx_keyidx
;
142 if (i
< 0 || i
>= WEP_KEYS
)
145 crypt
= &local
->crypt_info
.crypt
[i
];
147 if (erq
->flags
& IW_ENCODE_DISABLED
) {
149 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
153 if (*crypt
!= NULL
&& (*crypt
)->ops
!= NULL
&&
154 strcmp((*crypt
)->ops
->name
, "WEP") != 0) {
155 /* changing to use WEP; deinit previously used algorithm */
156 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
159 if (*crypt
== NULL
) {
160 struct lib80211_crypt_data
*new_crypt
;
162 /* take WEP into use */
163 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
165 if (new_crypt
== NULL
)
167 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
168 if (!new_crypt
->ops
) {
169 request_module("lib80211_crypt_wep");
170 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
172 if (new_crypt
->ops
&& try_module_get(new_crypt
->ops
->owner
))
173 new_crypt
->priv
= new_crypt
->ops
->init(i
);
174 if (!new_crypt
->ops
|| !new_crypt
->priv
) {
178 printk(KERN_WARNING
"%s: could not initialize WEP: "
179 "load module hostap_crypt_wep.o\n",
186 if (erq
->length
> 0) {
187 int len
= erq
->length
<= 5 ? 5 : 13;
189 if (len
> erq
->length
)
190 memset(keybuf
+ erq
->length
, 0, len
- erq
->length
);
191 (*crypt
)->ops
->set_key(keybuf
, len
, NULL
, (*crypt
)->priv
);
192 for (j
= 0; j
< WEP_KEYS
; j
++) {
193 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
199 local
->crypt_info
.tx_keyidx
= i
;
201 /* No key data - just set the default TX key index */
202 local
->crypt_info
.tx_keyidx
= i
;
206 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
208 if (hostap_set_encryption(local
)) {
209 printk(KERN_DEBUG
"%s: set_encryption failed\n", dev
->name
);
213 /* Do not reset port0 if card is in Managed mode since resetting will
214 * generate new IEEE 802.11 authentication which may end up in looping
215 * with IEEE 802.1X. Prism2 documentation seem to require port reset
216 * after WEP configuration. However, keys are apparently changed at
217 * least in Managed mode. */
218 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->func
->reset_port(dev
)) {
219 printk(KERN_DEBUG
"%s: reset_port failed\n", dev
->name
);
227 static int prism2_ioctl_giwencode(struct net_device
*dev
,
228 struct iw_request_info
*info
,
229 struct iw_point
*erq
, char *key
)
231 struct hostap_interface
*iface
;
235 struct lib80211_crypt_data
*crypt
;
237 iface
= netdev_priv(dev
);
238 local
= iface
->local
;
240 i
= erq
->flags
& IW_ENCODE_INDEX
;
242 i
= local
->crypt_info
.tx_keyidx
;
245 if (i
< 0 || i
>= WEP_KEYS
)
248 crypt
= local
->crypt_info
.crypt
[i
];
251 if (crypt
== NULL
|| crypt
->ops
== NULL
) {
253 erq
->flags
|= IW_ENCODE_DISABLED
;
257 if (strcmp(crypt
->ops
->name
, "WEP") != 0) {
258 /* only WEP is supported with wireless extensions, so just
259 * report that encryption is used */
261 erq
->flags
|= IW_ENCODE_ENABLED
;
265 /* Reads from HFA384X_RID_CNFDEFAULTKEY* return bogus values, so show
266 * the keys from driver buffer */
267 len
= crypt
->ops
->get_key(key
, WEP_KEY_LEN
, NULL
, crypt
->priv
);
268 erq
->length
= (len
>= 0 ? len
: 0);
270 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFWEPFLAGS
, &val
, 2, 1) < 0)
272 printk("CNFWEPFLAGS reading failed\n");
276 if (val
& HFA384X_WEPFLAGS_PRIVACYINVOKED
)
277 erq
->flags
|= IW_ENCODE_ENABLED
;
279 erq
->flags
|= IW_ENCODE_DISABLED
;
280 if (val
& HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED
)
281 erq
->flags
|= IW_ENCODE_RESTRICTED
;
283 erq
->flags
|= IW_ENCODE_OPEN
;
289 static int hostap_set_rate(struct net_device
*dev
)
291 struct hostap_interface
*iface
;
293 int ret
, basic_rates
;
295 iface
= netdev_priv(dev
);
296 local
= iface
->local
;
298 basic_rates
= local
->basic_rates
& local
->tx_rate_control
;
299 if (!basic_rates
|| basic_rates
!= local
->basic_rates
) {
300 printk(KERN_INFO
"%s: updating basic rate set automatically "
301 "to match with the new supported rate set\n",
304 basic_rates
= local
->tx_rate_control
;
306 local
->basic_rates
= basic_rates
;
307 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
309 printk(KERN_WARNING
"%s: failed to set "
310 "cnfBasicRates\n", dev
->name
);
313 ret
= (hostap_set_word(dev
, HFA384X_RID_TXRATECONTROL
,
314 local
->tx_rate_control
) ||
315 hostap_set_word(dev
, HFA384X_RID_CNFSUPPORTEDRATES
,
316 local
->tx_rate_control
) ||
317 local
->func
->reset_port(dev
));
320 printk(KERN_WARNING
"%s: TXRateControl/cnfSupportedRates "
321 "setting to 0x%x failed\n",
322 dev
->name
, local
->tx_rate_control
);
325 /* Update TX rate configuration for all STAs based on new operational
327 hostap_update_rates(local
);
333 static int prism2_ioctl_siwrate(struct net_device
*dev
,
334 struct iw_request_info
*info
,
335 struct iw_param
*rrq
, char *extra
)
337 struct hostap_interface
*iface
;
340 iface
= netdev_priv(dev
);
341 local
= iface
->local
;
344 switch (rrq
->value
) {
346 local
->tx_rate_control
= HFA384X_RATES_11MBPS
;
349 local
->tx_rate_control
= HFA384X_RATES_5MBPS
;
352 local
->tx_rate_control
= HFA384X_RATES_2MBPS
;
355 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
358 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
359 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
360 HFA384X_RATES_11MBPS
;
364 switch (rrq
->value
) {
366 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
367 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
368 HFA384X_RATES_11MBPS
;
371 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
372 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
;
375 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
379 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
382 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
383 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
384 HFA384X_RATES_11MBPS
;
389 return hostap_set_rate(dev
);
393 static int prism2_ioctl_giwrate(struct net_device
*dev
,
394 struct iw_request_info
*info
,
395 struct iw_param
*rrq
, char *extra
)
398 struct hostap_interface
*iface
;
402 iface
= netdev_priv(dev
);
403 local
= iface
->local
;
405 if (local
->func
->get_rid(dev
, HFA384X_RID_TXRATECONTROL
, &val
, 2, 1) <
409 if ((val
& 0x1) && (val
> 1))
414 if (local
->iw_mode
== IW_MODE_MASTER
&& local
->ap
!= NULL
&&
415 !local
->fw_tx_rate_control
) {
416 /* HFA384X_RID_CURRENTTXRATE seems to always be 2 Mbps in
417 * Host AP mode, so use the recorded TX rate of the last sent
419 rrq
->value
= local
->ap
->last_tx_rate
> 0 ?
420 local
->ap
->last_tx_rate
* 100000 : 11000000;
424 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTTXRATE
, &val
, 2, 1) <
429 case HFA384X_RATES_1MBPS
:
430 rrq
->value
= 1000000;
432 case HFA384X_RATES_2MBPS
:
433 rrq
->value
= 2000000;
435 case HFA384X_RATES_5MBPS
:
436 rrq
->value
= 5500000;
438 case HFA384X_RATES_11MBPS
:
439 rrq
->value
= 11000000;
442 /* should not happen */
443 rrq
->value
= 11000000;
452 static int prism2_ioctl_siwsens(struct net_device
*dev
,
453 struct iw_request_info
*info
,
454 struct iw_param
*sens
, char *extra
)
456 struct hostap_interface
*iface
;
459 iface
= netdev_priv(dev
);
460 local
= iface
->local
;
462 /* Set the desired AP density */
463 if (sens
->value
< 1 || sens
->value
> 3)
466 if (hostap_set_word(dev
, HFA384X_RID_CNFSYSTEMSCALE
, sens
->value
) ||
467 local
->func
->reset_port(dev
))
473 static int prism2_ioctl_giwsens(struct net_device
*dev
,
474 struct iw_request_info
*info
,
475 struct iw_param
*sens
, char *extra
)
477 struct hostap_interface
*iface
;
481 iface
= netdev_priv(dev
);
482 local
= iface
->local
;
484 /* Get the current AP density */
485 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFSYSTEMSCALE
, &val
, 2, 1) <
489 sens
->value
= le16_to_cpu(val
);
496 /* Deprecated in new wireless extension API */
497 static int prism2_ioctl_giwaplist(struct net_device
*dev
,
498 struct iw_request_info
*info
,
499 struct iw_point
*data
, char *extra
)
501 struct hostap_interface
*iface
;
503 struct sockaddr
*addr
;
504 struct iw_quality
*qual
;
506 iface
= netdev_priv(dev
);
507 local
= iface
->local
;
509 if (local
->iw_mode
!= IW_MODE_MASTER
) {
510 printk(KERN_DEBUG
"SIOCGIWAPLIST is currently only supported "
511 "in Host AP mode\n");
516 addr
= kmalloc(sizeof(struct sockaddr
) * IW_MAX_AP
, GFP_KERNEL
);
517 qual
= kmalloc(sizeof(struct iw_quality
) * IW_MAX_AP
, GFP_KERNEL
);
518 if (addr
== NULL
|| qual
== NULL
) {
525 data
->length
= prism2_ap_get_sta_qual(local
, addr
, qual
, IW_MAX_AP
, 1);
527 memcpy(extra
, addr
, sizeof(struct sockaddr
) * data
->length
);
528 data
->flags
= 1; /* has quality information */
529 memcpy(extra
+ sizeof(struct sockaddr
) * data
->length
, qual
,
530 sizeof(struct iw_quality
) * data
->length
);
538 static int prism2_ioctl_siwrts(struct net_device
*dev
,
539 struct iw_request_info
*info
,
540 struct iw_param
*rts
, char *extra
)
542 struct hostap_interface
*iface
;
546 iface
= netdev_priv(dev
);
547 local
= iface
->local
;
550 val
= cpu_to_le16(2347);
551 else if (rts
->value
< 0 || rts
->value
> 2347)
554 val
= cpu_to_le16(rts
->value
);
556 if (local
->func
->set_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2) ||
557 local
->func
->reset_port(dev
))
560 local
->rts_threshold
= rts
->value
;
565 static int prism2_ioctl_giwrts(struct net_device
*dev
,
566 struct iw_request_info
*info
,
567 struct iw_param
*rts
, char *extra
)
569 struct hostap_interface
*iface
;
573 iface
= netdev_priv(dev
);
574 local
= iface
->local
;
576 if (local
->func
->get_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2, 1) <
580 rts
->value
= le16_to_cpu(val
);
581 rts
->disabled
= (rts
->value
== 2347);
588 static int prism2_ioctl_siwfrag(struct net_device
*dev
,
589 struct iw_request_info
*info
,
590 struct iw_param
*rts
, char *extra
)
592 struct hostap_interface
*iface
;
596 iface
= netdev_priv(dev
);
597 local
= iface
->local
;
600 val
= cpu_to_le16(2346);
601 else if (rts
->value
< 256 || rts
->value
> 2346)
604 val
= cpu_to_le16(rts
->value
& ~0x1); /* even numbers only */
606 local
->fragm_threshold
= rts
->value
& ~0x1;
607 if (local
->func
->set_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
, &val
,
609 || local
->func
->reset_port(dev
))
615 static int prism2_ioctl_giwfrag(struct net_device
*dev
,
616 struct iw_request_info
*info
,
617 struct iw_param
*rts
, char *extra
)
619 struct hostap_interface
*iface
;
623 iface
= netdev_priv(dev
);
624 local
= iface
->local
;
626 if (local
->func
->get_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
,
630 rts
->value
= le16_to_cpu(val
);
631 rts
->disabled
= (rts
->value
== 2346);
638 #ifndef PRISM2_NO_STATION_MODES
639 static int hostap_join_ap(struct net_device
*dev
)
641 struct hostap_interface
*iface
;
643 struct hfa384x_join_request req
;
646 struct hfa384x_hostscan_result
*entry
;
648 iface
= netdev_priv(dev
);
649 local
= iface
->local
;
651 memcpy(req
.bssid
, local
->preferred_ap
, ETH_ALEN
);
654 spin_lock_irqsave(&local
->lock
, flags
);
655 for (i
= 0; i
< local
->last_scan_results_count
; i
++) {
656 if (!local
->last_scan_results
)
658 entry
= &local
->last_scan_results
[i
];
659 if (ether_addr_equal(local
->preferred_ap
, entry
->bssid
)) {
660 req
.channel
= entry
->chid
;
664 spin_unlock_irqrestore(&local
->lock
, flags
);
666 if (local
->func
->set_rid(dev
, HFA384X_RID_JOINREQUEST
, &req
,
668 printk(KERN_DEBUG
"%s: JoinRequest %pM failed\n",
669 dev
->name
, local
->preferred_ap
);
673 printk(KERN_DEBUG
"%s: Trying to join BSSID %pM\n",
674 dev
->name
, local
->preferred_ap
);
678 #endif /* PRISM2_NO_STATION_MODES */
681 static int prism2_ioctl_siwap(struct net_device
*dev
,
682 struct iw_request_info
*info
,
683 struct sockaddr
*ap_addr
, char *extra
)
685 #ifdef PRISM2_NO_STATION_MODES
687 #else /* PRISM2_NO_STATION_MODES */
688 struct hostap_interface
*iface
;
691 iface
= netdev_priv(dev
);
692 local
= iface
->local
;
694 memcpy(local
->preferred_ap
, &ap_addr
->sa_data
, ETH_ALEN
);
696 if (local
->host_roaming
== 1 && local
->iw_mode
== IW_MODE_INFRA
) {
697 struct hfa384x_scan_request scan_req
;
698 memset(&scan_req
, 0, sizeof(scan_req
));
699 scan_req
.channel_list
= cpu_to_le16(0x3fff);
700 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
701 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
,
702 &scan_req
, sizeof(scan_req
))) {
703 printk(KERN_DEBUG
"%s: ScanResults request failed - "
704 "preferred AP delayed to next unsolicited "
705 "scan\n", dev
->name
);
707 } else if (local
->host_roaming
== 2 &&
708 local
->iw_mode
== IW_MODE_INFRA
) {
709 if (hostap_join_ap(dev
))
712 printk(KERN_DEBUG
"%s: Preferred AP (SIOCSIWAP) is used only "
713 "in Managed mode when host_roaming is enabled\n",
718 #endif /* PRISM2_NO_STATION_MODES */
721 static int prism2_ioctl_giwap(struct net_device
*dev
,
722 struct iw_request_info
*info
,
723 struct sockaddr
*ap_addr
, char *extra
)
725 struct hostap_interface
*iface
;
728 iface
= netdev_priv(dev
);
729 local
= iface
->local
;
731 ap_addr
->sa_family
= ARPHRD_ETHER
;
732 switch (iface
->type
) {
733 case HOSTAP_INTERFACE_AP
:
734 memcpy(&ap_addr
->sa_data
, dev
->dev_addr
, ETH_ALEN
);
736 case HOSTAP_INTERFACE_STA
:
737 memcpy(&ap_addr
->sa_data
, local
->assoc_ap_addr
, ETH_ALEN
);
739 case HOSTAP_INTERFACE_WDS
:
740 memcpy(&ap_addr
->sa_data
, iface
->u
.wds
.remote_addr
, ETH_ALEN
);
743 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTBSSID
,
744 &ap_addr
->sa_data
, ETH_ALEN
, 1) < 0)
747 /* local->bssid is also updated in LinkStatus handler when in
749 memcpy(local
->bssid
, &ap_addr
->sa_data
, ETH_ALEN
);
757 static int prism2_ioctl_siwnickn(struct net_device
*dev
,
758 struct iw_request_info
*info
,
759 struct iw_point
*data
, char *nickname
)
761 struct hostap_interface
*iface
;
764 iface
= netdev_priv(dev
);
765 local
= iface
->local
;
767 memset(local
->name
, 0, sizeof(local
->name
));
768 memcpy(local
->name
, nickname
, data
->length
);
771 if (hostap_set_string(dev
, HFA384X_RID_CNFOWNNAME
, local
->name
) ||
772 local
->func
->reset_port(dev
))
778 static int prism2_ioctl_giwnickn(struct net_device
*dev
,
779 struct iw_request_info
*info
,
780 struct iw_point
*data
, char *nickname
)
782 struct hostap_interface
*iface
;
785 char name
[MAX_NAME_LEN
+ 3];
788 iface
= netdev_priv(dev
);
789 local
= iface
->local
;
791 len
= local
->func
->get_rid(dev
, HFA384X_RID_CNFOWNNAME
,
792 &name
, MAX_NAME_LEN
+ 2, 0);
793 val
= le16_to_cpu(*(__le16
*) name
);
794 if (len
> MAX_NAME_LEN
+ 2 || len
< 0 || val
> MAX_NAME_LEN
)
797 name
[val
+ 2] = '\0';
798 data
->length
= val
+ 1;
799 memcpy(nickname
, name
+ 2, val
+ 1);
805 static int prism2_ioctl_siwfreq(struct net_device
*dev
,
806 struct iw_request_info
*info
,
807 struct iw_freq
*freq
, char *extra
)
809 struct hostap_interface
*iface
;
812 iface
= netdev_priv(dev
);
813 local
= iface
->local
;
817 freq
->m
/ 100000 >= freq_list
[0] &&
818 freq
->m
/ 100000 <= freq_list
[FREQ_COUNT
- 1]) {
820 int fr
= freq
->m
/ 100000;
821 for (ch
= 0; ch
< FREQ_COUNT
; ch
++) {
822 if (fr
== freq_list
[ch
]) {
830 if (freq
->e
!= 0 || freq
->m
< 1 || freq
->m
> FREQ_COUNT
||
831 !(local
->channel_mask
& (1 << (freq
->m
- 1))))
834 local
->channel
= freq
->m
; /* channel is used in prism2_setup_rids() */
835 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNCHANNEL
, local
->channel
) ||
836 local
->func
->reset_port(dev
))
842 static int prism2_ioctl_giwfreq(struct net_device
*dev
,
843 struct iw_request_info
*info
,
844 struct iw_freq
*freq
, char *extra
)
846 struct hostap_interface
*iface
;
850 iface
= netdev_priv(dev
);
851 local
= iface
->local
;
853 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTCHANNEL
, &val
, 2, 1) <
858 if (val
< 1 || val
> FREQ_COUNT
)
861 freq
->m
= freq_list
[val
- 1] * 100000;
868 static void hostap_monitor_set_type(local_info_t
*local
)
870 struct net_device
*dev
= local
->ddev
;
875 if (local
->monitor_type
== PRISM2_MONITOR_PRISM
||
876 local
->monitor_type
== PRISM2_MONITOR_CAPHDR
) {
877 dev
->type
= ARPHRD_IEEE80211_PRISM
;
878 } else if (local
->monitor_type
== PRISM2_MONITOR_RADIOTAP
) {
879 dev
->type
= ARPHRD_IEEE80211_RADIOTAP
;
881 dev
->type
= ARPHRD_IEEE80211
;
886 static int prism2_ioctl_siwessid(struct net_device
*dev
,
887 struct iw_request_info
*info
,
888 struct iw_point
*data
, char *ssid
)
890 struct hostap_interface
*iface
;
893 iface
= netdev_priv(dev
);
894 local
= iface
->local
;
896 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
899 if (data
->flags
== 0)
900 ssid
[0] = '\0'; /* ANY */
902 if (local
->iw_mode
== IW_MODE_MASTER
&& ssid
[0] == '\0') {
903 /* Setting SSID to empty string seems to kill the card in
905 printk(KERN_DEBUG
"%s: Host AP mode does not support "
906 "'Any' essid\n", dev
->name
);
910 memcpy(local
->essid
, ssid
, data
->length
);
911 local
->essid
[data
->length
] = '\0';
913 if ((!local
->fw_ap
&&
914 hostap_set_string(dev
, HFA384X_RID_CNFDESIREDSSID
, local
->essid
))
915 || hostap_set_string(dev
, HFA384X_RID_CNFOWNSSID
, local
->essid
) ||
916 local
->func
->reset_port(dev
))
922 static int prism2_ioctl_giwessid(struct net_device
*dev
,
923 struct iw_request_info
*info
,
924 struct iw_point
*data
, char *essid
)
926 struct hostap_interface
*iface
;
930 iface
= netdev_priv(dev
);
931 local
= iface
->local
;
933 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
936 data
->flags
= 1; /* active */
937 if (local
->iw_mode
== IW_MODE_MASTER
) {
938 data
->length
= strlen(local
->essid
);
939 memcpy(essid
, local
->essid
, IW_ESSID_MAX_SIZE
);
942 char ssid
[MAX_SSID_LEN
+ 2];
943 memset(ssid
, 0, sizeof(ssid
));
944 len
= local
->func
->get_rid(dev
, HFA384X_RID_CURRENTSSID
,
945 &ssid
, MAX_SSID_LEN
+ 2, 0);
946 val
= le16_to_cpu(*(__le16
*) ssid
);
947 if (len
> MAX_SSID_LEN
+ 2 || len
< 0 || val
> MAX_SSID_LEN
) {
951 memcpy(essid
, ssid
+ 2, IW_ESSID_MAX_SIZE
);
958 static int prism2_ioctl_giwrange(struct net_device
*dev
,
959 struct iw_request_info
*info
,
960 struct iw_point
*data
, char *extra
)
962 struct hostap_interface
*iface
;
964 struct iw_range
*range
= (struct iw_range
*) extra
;
969 iface
= netdev_priv(dev
);
970 local
= iface
->local
;
972 data
->length
= sizeof(struct iw_range
);
973 memset(range
, 0, sizeof(struct iw_range
));
975 /* TODO: could fill num_txpower and txpower array with
976 * something; however, there are 128 different values.. */
978 range
->txpower_capa
= IW_TXPOW_DBM
;
980 if (local
->iw_mode
== IW_MODE_INFRA
|| local
->iw_mode
== IW_MODE_ADHOC
)
982 range
->min_pmp
= 1 * 1024;
983 range
->max_pmp
= 65535 * 1024;
984 range
->min_pmt
= 1 * 1024;
985 range
->max_pmt
= 1000 * 1024;
986 range
->pmp_flags
= IW_POWER_PERIOD
;
987 range
->pmt_flags
= IW_POWER_TIMEOUT
;
988 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
|
989 IW_POWER_UNICAST_R
| IW_POWER_ALL_R
;
992 range
->we_version_compiled
= WIRELESS_EXT
;
993 range
->we_version_source
= 18;
995 range
->retry_capa
= IW_RETRY_LIMIT
;
996 range
->retry_flags
= IW_RETRY_LIMIT
;
997 range
->min_retry
= 0;
998 range
->max_retry
= 255;
1000 range
->num_channels
= FREQ_COUNT
;
1003 for (i
= 0; i
< FREQ_COUNT
; i
++) {
1004 if (local
->channel_mask
& (1 << i
)) {
1005 range
->freq
[val
].i
= i
+ 1;
1006 range
->freq
[val
].m
= freq_list
[i
] * 100000;
1007 range
->freq
[val
].e
= 1;
1010 if (val
== IW_MAX_FREQUENCIES
)
1013 range
->num_frequency
= val
;
1015 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1)) {
1016 range
->max_qual
.qual
= 70; /* what is correct max? This was not
1017 * documented exactly. At least
1018 * 69 has been observed. */
1019 range
->max_qual
.level
= 0; /* dB */
1020 range
->max_qual
.noise
= 0; /* dB */
1022 /* What would be suitable values for "average/typical" qual? */
1023 range
->avg_qual
.qual
= 20;
1024 range
->avg_qual
.level
= -60;
1025 range
->avg_qual
.noise
= -95;
1027 range
->max_qual
.qual
= 92; /* 0 .. 92 */
1028 range
->max_qual
.level
= 154; /* 27 .. 154 */
1029 range
->max_qual
.noise
= 154; /* 27 .. 154 */
1031 range
->sensitivity
= 3;
1033 range
->max_encoding_tokens
= WEP_KEYS
;
1034 range
->num_encoding_sizes
= 2;
1035 range
->encoding_size
[0] = 5;
1036 range
->encoding_size
[1] = 13;
1039 len
= prism2_get_datarates(dev
, rates
);
1040 range
->num_bitrates
= 0;
1041 for (i
= 0; i
< len
; i
++) {
1042 if (range
->num_bitrates
< IW_MAX_BITRATES
) {
1043 range
->bitrate
[range
->num_bitrates
] =
1045 range
->num_bitrates
++;
1047 if (rates
[i
] == 0x0b || rates
[i
] == 0x16)
1050 /* estimated maximum TCP throughput values (bps) */
1051 range
->throughput
= over2
? 5500000 : 1500000;
1054 range
->max_rts
= 2347;
1055 range
->min_frag
= 256;
1056 range
->max_frag
= 2346;
1058 /* Event capability (kernel + driver) */
1059 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
1060 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY
) |
1061 IW_EVENT_CAPA_MASK(SIOCGIWAP
) |
1062 IW_EVENT_CAPA_MASK(SIOCGIWSCAN
));
1063 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
1064 range
->event_capa
[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP
) |
1065 IW_EVENT_CAPA_MASK(IWEVCUSTOM
) |
1066 IW_EVENT_CAPA_MASK(IWEVREGISTERED
) |
1067 IW_EVENT_CAPA_MASK(IWEVEXPIRED
));
1069 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
1070 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
1072 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1073 range
->scan_capa
= IW_SCAN_CAPA_ESSID
;
1079 static int hostap_monitor_mode_enable(local_info_t
*local
)
1081 struct net_device
*dev
= local
->dev
;
1083 printk(KERN_DEBUG
"Enabling monitor mode\n");
1084 hostap_monitor_set_type(local
);
1086 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1087 HFA384X_PORTTYPE_PSEUDO_IBSS
)) {
1088 printk(KERN_DEBUG
"Port type setting for monitor mode "
1093 /* Host decrypt is needed to get the IV and ICV fields;
1094 * however, monitor mode seems to remove WEP flag from frame
1096 if (hostap_set_word(dev
, HFA384X_RID_CNFWEPFLAGS
,
1097 HFA384X_WEPFLAGS_HOSTENCRYPT
|
1098 HFA384X_WEPFLAGS_HOSTDECRYPT
)) {
1099 printk(KERN_DEBUG
"WEP flags setting failed\n");
1103 if (local
->func
->reset_port(dev
) ||
1104 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1105 (HFA384X_TEST_MONITOR
<< 8),
1107 printk(KERN_DEBUG
"Setting monitor mode failed\n");
1115 static int hostap_monitor_mode_disable(local_info_t
*local
)
1117 struct net_device
*dev
= local
->ddev
;
1122 printk(KERN_DEBUG
"%s: Disabling monitor mode\n", dev
->name
);
1123 dev
->type
= ARPHRD_ETHER
;
1125 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1126 (HFA384X_TEST_STOP
<< 8),
1129 return hostap_set_encryption(local
);
1133 static int prism2_ioctl_siwmode(struct net_device
*dev
,
1134 struct iw_request_info
*info
,
1135 __u32
*mode
, char *extra
)
1137 struct hostap_interface
*iface
;
1138 local_info_t
*local
;
1139 int double_reset
= 0;
1141 iface
= netdev_priv(dev
);
1142 local
= iface
->local
;
1144 if (*mode
!= IW_MODE_ADHOC
&& *mode
!= IW_MODE_INFRA
&&
1145 *mode
!= IW_MODE_MASTER
&& *mode
!= IW_MODE_REPEAT
&&
1146 *mode
!= IW_MODE_MONITOR
)
1149 #ifdef PRISM2_NO_STATION_MODES
1150 if (*mode
== IW_MODE_ADHOC
|| *mode
== IW_MODE_INFRA
)
1152 #endif /* PRISM2_NO_STATION_MODES */
1154 if (*mode
== local
->iw_mode
)
1157 if (*mode
== IW_MODE_MASTER
&& local
->essid
[0] == '\0') {
1158 printk(KERN_WARNING
"%s: empty SSID not allowed in Master "
1159 "mode\n", dev
->name
);
1163 if (local
->iw_mode
== IW_MODE_MONITOR
)
1164 hostap_monitor_mode_disable(local
);
1166 if ((local
->iw_mode
== IW_MODE_ADHOC
||
1167 local
->iw_mode
== IW_MODE_MONITOR
) && *mode
== IW_MODE_MASTER
) {
1168 /* There seems to be a firmware bug in at least STA f/w v1.5.6
1169 * that leaves beacon frames to use IBSS type when moving from
1170 * IBSS to Host AP mode. Doing double Port0 reset seems to be
1171 * enough to workaround this. */
1175 printk(KERN_DEBUG
"prism2: %s: operating mode changed "
1176 "%d -> %d\n", dev
->name
, local
->iw_mode
, *mode
);
1177 local
->iw_mode
= *mode
;
1179 if (local
->iw_mode
== IW_MODE_MONITOR
)
1180 hostap_monitor_mode_enable(local
);
1181 else if (local
->iw_mode
== IW_MODE_MASTER
&& !local
->host_encrypt
&&
1182 !local
->fw_encrypt_ok
) {
1183 printk(KERN_DEBUG
"%s: defaulting to host-based encryption as "
1184 "a workaround for firmware bug in Host AP mode WEP\n",
1186 local
->host_encrypt
= 1;
1189 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1190 hostap_get_porttype(local
)))
1193 if (local
->func
->reset_port(dev
))
1195 if (double_reset
&& local
->func
->reset_port(dev
))
1198 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->iw_mode
!= IW_MODE_ADHOC
)
1200 /* netif_carrier is used only in client modes for now, so make
1201 * sure carrier is on when moving to non-client modes. */
1202 netif_carrier_on(local
->dev
);
1203 netif_carrier_on(local
->ddev
);
1209 static int prism2_ioctl_giwmode(struct net_device
*dev
,
1210 struct iw_request_info
*info
,
1211 __u32
*mode
, char *extra
)
1213 struct hostap_interface
*iface
;
1214 local_info_t
*local
;
1216 iface
= netdev_priv(dev
);
1217 local
= iface
->local
;
1219 switch (iface
->type
) {
1220 case HOSTAP_INTERFACE_STA
:
1221 *mode
= IW_MODE_INFRA
;
1223 case HOSTAP_INTERFACE_WDS
:
1224 *mode
= IW_MODE_REPEAT
;
1227 *mode
= local
->iw_mode
;
1234 static int prism2_ioctl_siwpower(struct net_device
*dev
,
1235 struct iw_request_info
*info
,
1236 struct iw_param
*wrq
, char *extra
)
1238 #ifdef PRISM2_NO_STATION_MODES
1240 #else /* PRISM2_NO_STATION_MODES */
1244 return hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 0);
1246 switch (wrq
->flags
& IW_POWER_MODE
) {
1247 case IW_POWER_UNICAST_R
:
1248 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 0);
1251 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1255 case IW_POWER_ALL_R
:
1256 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 1);
1259 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1269 if (wrq
->flags
& IW_POWER_TIMEOUT
) {
1270 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1273 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMHOLDOVERDURATION
,
1278 if (wrq
->flags
& IW_POWER_PERIOD
) {
1279 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1282 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1289 #endif /* PRISM2_NO_STATION_MODES */
1293 static int prism2_ioctl_giwpower(struct net_device
*dev
,
1294 struct iw_request_info
*info
,
1295 struct iw_param
*rrq
, char *extra
)
1297 #ifdef PRISM2_NO_STATION_MODES
1299 #else /* PRISM2_NO_STATION_MODES */
1300 struct hostap_interface
*iface
;
1301 local_info_t
*local
;
1302 __le16 enable
, mcast
;
1304 iface
= netdev_priv(dev
);
1305 local
= iface
->local
;
1307 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFPMENABLED
, &enable
, 2, 1)
1311 if (!le16_to_cpu(enable
)) {
1318 if ((rrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1320 if (local
->func
->get_rid(dev
,
1321 HFA384X_RID_CNFPMHOLDOVERDURATION
,
1322 &timeout
, 2, 1) < 0)
1325 rrq
->flags
= IW_POWER_TIMEOUT
;
1326 rrq
->value
= le16_to_cpu(timeout
) * 1024;
1329 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1333 rrq
->flags
= IW_POWER_PERIOD
;
1334 rrq
->value
= le16_to_cpu(period
) * 1024;
1337 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, &mcast
,
1341 if (le16_to_cpu(mcast
))
1342 rrq
->flags
|= IW_POWER_ALL_R
;
1344 rrq
->flags
|= IW_POWER_UNICAST_R
;
1347 #endif /* PRISM2_NO_STATION_MODES */
1351 static int prism2_ioctl_siwretry(struct net_device
*dev
,
1352 struct iw_request_info
*info
,
1353 struct iw_param
*rrq
, char *extra
)
1355 struct hostap_interface
*iface
;
1356 local_info_t
*local
;
1358 iface
= netdev_priv(dev
);
1359 local
= iface
->local
;
1364 /* setting retry limits is not supported with the current station
1365 * firmware code; simulate this with alternative retry count for now */
1366 if (rrq
->flags
== IW_RETRY_LIMIT
) {
1367 if (rrq
->value
< 0) {
1368 /* disable manual retry count setting and use firmware
1370 local
->manual_retry_count
= -1;
1371 local
->tx_control
&= ~HFA384X_TX_CTRL_ALT_RTRY
;
1373 if (hostap_set_word(dev
, HFA384X_RID_CNFALTRETRYCOUNT
,
1375 printk(KERN_DEBUG
"%s: Alternate retry count "
1376 "setting to %d failed\n",
1377 dev
->name
, rrq
->value
);
1381 local
->manual_retry_count
= rrq
->value
;
1382 local
->tx_control
|= HFA384X_TX_CTRL_ALT_RTRY
;
1390 /* what could be done, if firmware would support this.. */
1392 if (rrq
->flags
& IW_RETRY_LIMIT
) {
1393 if (rrq
->flags
& IW_RETRY_LONG
)
1394 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1395 else if (rrq
->flags
& IW_RETRY_SHORT
)
1396 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1398 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1399 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1404 if (rrq
->flags
& IW_RETRY_LIFETIME
) {
1405 HFA384X_RID_MAXTRANSMITLIFETIME
= rrq
->value
/ 1024;
1412 static int prism2_ioctl_giwretry(struct net_device
*dev
,
1413 struct iw_request_info
*info
,
1414 struct iw_param
*rrq
, char *extra
)
1416 struct hostap_interface
*iface
;
1417 local_info_t
*local
;
1418 __le16 shortretry
, longretry
, lifetime
, altretry
;
1420 iface
= netdev_priv(dev
);
1421 local
= iface
->local
;
1423 if (local
->func
->get_rid(dev
, HFA384X_RID_SHORTRETRYLIMIT
, &shortretry
,
1425 local
->func
->get_rid(dev
, HFA384X_RID_LONGRETRYLIMIT
, &longretry
,
1427 local
->func
->get_rid(dev
, HFA384X_RID_MAXTRANSMITLIFETIME
,
1428 &lifetime
, 2, 1) < 0)
1433 if ((rrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1434 rrq
->flags
= IW_RETRY_LIFETIME
;
1435 rrq
->value
= le16_to_cpu(lifetime
) * 1024;
1437 if (local
->manual_retry_count
>= 0) {
1438 rrq
->flags
= IW_RETRY_LIMIT
;
1439 if (local
->func
->get_rid(dev
,
1440 HFA384X_RID_CNFALTRETRYCOUNT
,
1441 &altretry
, 2, 1) >= 0)
1442 rrq
->value
= le16_to_cpu(altretry
);
1444 rrq
->value
= local
->manual_retry_count
;
1445 } else if ((rrq
->flags
& IW_RETRY_LONG
)) {
1446 rrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
1447 rrq
->value
= le16_to_cpu(longretry
);
1449 rrq
->flags
= IW_RETRY_LIMIT
;
1450 rrq
->value
= le16_to_cpu(shortretry
);
1451 if (shortretry
!= longretry
)
1452 rrq
->flags
|= IW_RETRY_SHORT
;
1459 /* Note! This TX power controlling is experimental and should not be used in
1460 * production use. It just sets raw power register and does not use any kind of
1461 * feedback information from the measured TX power (CR58). This is now
1462 * commented out to make sure that it is not used by accident. TX power
1463 * configuration will be enabled again after proper algorithm using feedback
1464 * has been implemented. */
1466 #ifdef RAW_TXPOWER_SETTING
1467 /* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping..
1468 * This version assumes following mapping:
1469 * CR31 is 7-bit value with -64 to +63 range.
1470 * -64 is mapped into +20dBm and +63 into -43dBm.
1471 * This is certainly not an exact mapping for every card, but at least
1472 * increasing dBm value should correspond to increasing TX power.
1475 static int prism2_txpower_hfa386x_to_dBm(u16 val
)
1488 static u16
prism2_txpower_dBm_to_hfa386x(int val
)
1501 return (unsigned char) tmp
;
1503 #endif /* RAW_TXPOWER_SETTING */
1506 static int prism2_ioctl_siwtxpow(struct net_device
*dev
,
1507 struct iw_request_info
*info
,
1508 struct iw_param
*rrq
, char *extra
)
1510 struct hostap_interface
*iface
;
1511 local_info_t
*local
;
1512 #ifdef RAW_TXPOWER_SETTING
1518 iface
= netdev_priv(dev
);
1519 local
= iface
->local
;
1521 if (rrq
->disabled
) {
1522 if (local
->txpower_type
!= PRISM2_TXPOWER_OFF
) {
1523 val
= 0xff; /* use all standby and sleep modes */
1524 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1525 HFA386X_CR_A_D_TEST_MODES2
,
1527 printk(KERN_DEBUG
"%s: Turning radio off: %s\n",
1528 dev
->name
, ret
? "failed" : "OK");
1529 local
->txpower_type
= PRISM2_TXPOWER_OFF
;
1531 return (ret
? -EOPNOTSUPP
: 0);
1534 if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1535 val
= 0; /* disable all standby and sleep modes */
1536 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1537 HFA386X_CR_A_D_TEST_MODES2
, &val
, NULL
);
1538 printk(KERN_DEBUG
"%s: Turning radio on: %s\n",
1539 dev
->name
, ret
? "failed" : "OK");
1540 local
->txpower_type
= PRISM2_TXPOWER_UNKNOWN
;
1543 #ifdef RAW_TXPOWER_SETTING
1544 if (!rrq
->fixed
&& local
->txpower_type
!= PRISM2_TXPOWER_AUTO
) {
1545 printk(KERN_DEBUG
"Setting ALC on\n");
1546 val
= HFA384X_TEST_CFG_BIT_ALC
;
1547 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1548 (HFA384X_TEST_CFG_BITS
<< 8), 1, &val
, NULL
);
1549 local
->txpower_type
= PRISM2_TXPOWER_AUTO
;
1553 if (local
->txpower_type
!= PRISM2_TXPOWER_FIXED
) {
1554 printk(KERN_DEBUG
"Setting ALC off\n");
1555 val
= HFA384X_TEST_CFG_BIT_ALC
;
1556 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1557 (HFA384X_TEST_CFG_BITS
<< 8), 0, &val
, NULL
);
1558 local
->txpower_type
= PRISM2_TXPOWER_FIXED
;
1561 if (rrq
->flags
== IW_TXPOW_DBM
)
1563 else if (rrq
->flags
== IW_TXPOW_MWATT
)
1567 printk(KERN_DEBUG
"Setting TX power to %d %s\n", rrq
->value
, tmp
);
1569 if (rrq
->flags
!= IW_TXPOW_DBM
) {
1570 printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
1574 local
->txpower
= rrq
->value
;
1575 val
= prism2_txpower_dBm_to_hfa386x(local
->txpower
);
1576 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1577 HFA386X_CR_MANUAL_TX_POWER
, &val
, NULL
))
1579 #else /* RAW_TXPOWER_SETTING */
1582 #endif /* RAW_TXPOWER_SETTING */
1587 static int prism2_ioctl_giwtxpow(struct net_device
*dev
,
1588 struct iw_request_info
*info
,
1589 struct iw_param
*rrq
, char *extra
)
1591 #ifdef RAW_TXPOWER_SETTING
1592 struct hostap_interface
*iface
;
1593 local_info_t
*local
;
1596 iface
= netdev_priv(dev
);
1597 local
= iface
->local
;
1599 rrq
->flags
= IW_TXPOW_DBM
;
1603 if (local
->txpower_type
== PRISM2_TXPOWER_AUTO
) {
1604 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
,
1605 HFA386X_CR_MANUAL_TX_POWER
,
1606 NULL
, &resp0
) == 0) {
1607 rrq
->value
= prism2_txpower_hfa386x_to_dBm(resp0
);
1609 /* Could not get real txpower; guess 15 dBm */
1612 } else if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1615 } else if (local
->txpower_type
== PRISM2_TXPOWER_FIXED
) {
1616 rrq
->value
= local
->txpower
;
1619 printk("SIOCGIWTXPOW - unknown txpower_type=%d\n",
1620 local
->txpower_type
);
1623 #else /* RAW_TXPOWER_SETTING */
1625 #endif /* RAW_TXPOWER_SETTING */
1629 #ifndef PRISM2_NO_STATION_MODES
1631 /* HostScan request works with and without host_roaming mode. In addition, it
1632 * does not break current association. However, it requires newer station
1633 * firmware version (>= 1.3.1) than scan request. */
1634 static int prism2_request_hostscan(struct net_device
*dev
,
1635 u8
*ssid
, u8 ssid_len
)
1637 struct hostap_interface
*iface
;
1638 local_info_t
*local
;
1639 struct hfa384x_hostscan_request scan_req
;
1641 iface
= netdev_priv(dev
);
1642 local
= iface
->local
;
1644 memset(&scan_req
, 0, sizeof(scan_req
));
1645 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1646 local
->scan_channel_mask
);
1647 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1651 scan_req
.target_ssid_len
= cpu_to_le16(ssid_len
);
1652 memcpy(scan_req
.target_ssid
, ssid
, ssid_len
);
1655 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
1656 sizeof(scan_req
))) {
1657 printk(KERN_DEBUG
"%s: HOSTSCAN failed\n", dev
->name
);
1664 static int prism2_request_scan(struct net_device
*dev
)
1666 struct hostap_interface
*iface
;
1667 local_info_t
*local
;
1668 struct hfa384x_scan_request scan_req
;
1671 iface
= netdev_priv(dev
);
1672 local
= iface
->local
;
1674 memset(&scan_req
, 0, sizeof(scan_req
));
1675 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1676 local
->scan_channel_mask
);
1677 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1680 * It seems to be enough to set roaming mode for a short moment to
1681 * host-based and then setup scanrequest data and return the mode to
1684 * Master mode would need to drop to Managed mode for a short while
1685 * to make scanning work.. Or sweep through the different channels and
1686 * use passive scan based on beacons. */
1688 if (!local
->host_roaming
)
1689 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1690 HFA384X_ROAMING_HOST
);
1692 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
, &scan_req
,
1693 sizeof(scan_req
))) {
1694 printk(KERN_DEBUG
"SCANREQUEST failed\n");
1698 if (!local
->host_roaming
)
1699 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1700 HFA384X_ROAMING_FIRMWARE
);
1705 #else /* !PRISM2_NO_STATION_MODES */
1707 static inline int prism2_request_hostscan(struct net_device
*dev
,
1708 u8
*ssid
, u8 ssid_len
)
1714 static inline int prism2_request_scan(struct net_device
*dev
)
1719 #endif /* !PRISM2_NO_STATION_MODES */
1722 static int prism2_ioctl_siwscan(struct net_device
*dev
,
1723 struct iw_request_info
*info
,
1724 struct iw_point
*data
, char *extra
)
1726 struct hostap_interface
*iface
;
1727 local_info_t
*local
;
1729 u8
*ssid
= NULL
, ssid_len
= 0;
1730 struct iw_scan_req
*req
= (struct iw_scan_req
*) extra
;
1732 iface
= netdev_priv(dev
);
1733 local
= iface
->local
;
1735 if (data
->length
< sizeof(struct iw_scan_req
))
1738 if (local
->iw_mode
== IW_MODE_MASTER
) {
1739 /* In master mode, we just return the results of our local
1740 * tables, so we don't need to start anything...
1746 if (!local
->dev_enabled
)
1749 if (req
&& data
->flags
& IW_SCAN_THIS_ESSID
) {
1751 ssid_len
= req
->essid_len
;
1754 ((local
->iw_mode
!= IW_MODE_INFRA
&&
1755 local
->iw_mode
!= IW_MODE_ADHOC
) ||
1756 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1))))
1760 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1761 ret
= prism2_request_hostscan(dev
, ssid
, ssid_len
);
1763 ret
= prism2_request_scan(dev
);
1766 local
->scan_timestamp
= jiffies
;
1768 /* Could inquire F101, F103 or wait for SIOCGIWSCAN and read RID */
1774 #ifndef PRISM2_NO_STATION_MODES
1775 static char * __prism2_translate_scan(local_info_t
*local
,
1776 struct iw_request_info
*info
,
1777 struct hfa384x_hostscan_result
*scan
,
1778 struct hostap_bss_info
*bss
,
1779 char *current_ev
, char *end_buf
)
1782 struct iw_event iwe
;
1792 ssid_len
= bss
->ssid_len
;
1796 ssid_len
= le16_to_cpu(scan
->ssid_len
);
1797 bssid
= scan
->bssid
;
1802 /* First entry *MUST* be the AP MAC address */
1803 memset(&iwe
, 0, sizeof(iwe
));
1804 iwe
.cmd
= SIOCGIWAP
;
1805 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1806 memcpy(iwe
.u
.ap_addr
.sa_data
, bssid
, ETH_ALEN
);
1807 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
, &iwe
,
1810 /* Other entries will be displayed in the order we give them */
1812 memset(&iwe
, 0, sizeof(iwe
));
1813 iwe
.cmd
= SIOCGIWESSID
;
1814 iwe
.u
.data
.length
= ssid_len
;
1815 iwe
.u
.data
.flags
= 1;
1816 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1819 memset(&iwe
, 0, sizeof(iwe
));
1820 iwe
.cmd
= SIOCGIWMODE
;
1822 capabilities
= bss
->capab_info
;
1824 capabilities
= le16_to_cpu(scan
->capability
);
1826 if (capabilities
& (WLAN_CAPABILITY_ESS
|
1827 WLAN_CAPABILITY_IBSS
)) {
1828 if (capabilities
& WLAN_CAPABILITY_ESS
)
1829 iwe
.u
.mode
= IW_MODE_MASTER
;
1831 iwe
.u
.mode
= IW_MODE_ADHOC
;
1832 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1833 &iwe
, IW_EV_UINT_LEN
);
1836 memset(&iwe
, 0, sizeof(iwe
));
1837 iwe
.cmd
= SIOCGIWFREQ
;
1839 chan
= le16_to_cpu(scan
->chid
);
1847 iwe
.u
.freq
.m
= freq_list
[chan
- 1] * 100000;
1849 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1850 &iwe
, IW_EV_FREQ_LEN
);
1854 memset(&iwe
, 0, sizeof(iwe
));
1856 if (local
->last_scan_type
== PRISM2_HOSTSCAN
) {
1857 iwe
.u
.qual
.level
= le16_to_cpu(scan
->sl
);
1858 iwe
.u
.qual
.noise
= le16_to_cpu(scan
->anl
);
1861 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->sl
));
1863 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->anl
));
1865 iwe
.u
.qual
.updated
= IW_QUAL_LEVEL_UPDATED
1866 | IW_QUAL_NOISE_UPDATED
1867 | IW_QUAL_QUAL_INVALID
1869 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1870 &iwe
, IW_EV_QUAL_LEN
);
1873 memset(&iwe
, 0, sizeof(iwe
));
1874 iwe
.cmd
= SIOCGIWENCODE
;
1875 if (capabilities
& WLAN_CAPABILITY_PRIVACY
)
1876 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
1878 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
1879 iwe
.u
.data
.length
= 0;
1880 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
, &iwe
, "");
1882 /* TODO: add SuppRates into BSS table */
1884 memset(&iwe
, 0, sizeof(iwe
));
1885 iwe
.cmd
= SIOCGIWRATE
;
1886 current_val
= current_ev
+ iwe_stream_lcp_len(info
);
1887 pos
= scan
->sup_rates
;
1888 for (i
= 0; i
< sizeof(scan
->sup_rates
); i
++) {
1891 /* Bit rate given in 500 kb/s units (+ 0x80) */
1892 iwe
.u
.bitrate
.value
= ((pos
[i
] & 0x7f) * 500000);
1893 current_val
= iwe_stream_add_value(
1894 info
, current_ev
, current_val
, end_buf
, &iwe
,
1897 /* Check if we added any event */
1898 if ((current_val
- current_ev
) > iwe_stream_lcp_len(info
))
1899 current_ev
= current_val
;
1902 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
1903 buf
= kmalloc(MAX_WPA_IE_LEN
* 2 + 30, GFP_ATOMIC
);
1905 memset(&iwe
, 0, sizeof(iwe
));
1906 iwe
.cmd
= IWEVCUSTOM
;
1907 sprintf(buf
, "bcn_int=%d", le16_to_cpu(scan
->beacon_interval
));
1908 iwe
.u
.data
.length
= strlen(buf
);
1909 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1912 memset(&iwe
, 0, sizeof(iwe
));
1913 iwe
.cmd
= IWEVCUSTOM
;
1914 sprintf(buf
, "resp_rate=%d", le16_to_cpu(scan
->rate
));
1915 iwe
.u
.data
.length
= strlen(buf
);
1916 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1919 if (local
->last_scan_type
== PRISM2_HOSTSCAN
&&
1920 (capabilities
& WLAN_CAPABILITY_IBSS
)) {
1921 memset(&iwe
, 0, sizeof(iwe
));
1922 iwe
.cmd
= IWEVCUSTOM
;
1923 sprintf(buf
, "atim=%d", le16_to_cpu(scan
->atim
));
1924 iwe
.u
.data
.length
= strlen(buf
);
1925 current_ev
= iwe_stream_add_point(info
, current_ev
,
1926 end_buf
, &iwe
, buf
);
1931 if (bss
&& bss
->wpa_ie_len
> 0 && bss
->wpa_ie_len
<= MAX_WPA_IE_LEN
) {
1932 memset(&iwe
, 0, sizeof(iwe
));
1933 iwe
.cmd
= IWEVGENIE
;
1934 iwe
.u
.data
.length
= bss
->wpa_ie_len
;
1935 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1939 if (bss
&& bss
->rsn_ie_len
> 0 && bss
->rsn_ie_len
<= MAX_WPA_IE_LEN
) {
1940 memset(&iwe
, 0, sizeof(iwe
));
1941 iwe
.cmd
= IWEVGENIE
;
1942 iwe
.u
.data
.length
= bss
->rsn_ie_len
;
1943 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1951 /* Translate scan data returned from the card to a card independent
1952 * format that the Wireless Tools will understand - Jean II */
1953 static inline int prism2_translate_scan(local_info_t
*local
,
1954 struct iw_request_info
*info
,
1955 char *buffer
, int buflen
)
1957 struct hfa384x_hostscan_result
*scan
;
1958 int entry
, hostscan
;
1959 char *current_ev
= buffer
;
1960 char *end_buf
= buffer
+ buflen
;
1961 struct list_head
*ptr
;
1963 spin_lock_bh(&local
->lock
);
1965 list_for_each(ptr
, &local
->bss_list
) {
1966 struct hostap_bss_info
*bss
;
1967 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1971 hostscan
= local
->last_scan_type
== PRISM2_HOSTSCAN
;
1972 for (entry
= 0; entry
< local
->last_scan_results_count
; entry
++) {
1974 scan
= &local
->last_scan_results
[entry
];
1976 /* Report every SSID if the AP is using multiple SSIDs. If no
1977 * BSS record is found (e.g., when WPA mode is disabled),
1978 * report the AP once. */
1979 list_for_each(ptr
, &local
->bss_list
) {
1980 struct hostap_bss_info
*bss
;
1981 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1982 if (ether_addr_equal(bss
->bssid
, scan
->bssid
)) {
1984 current_ev
= __prism2_translate_scan(
1985 local
, info
, scan
, bss
, current_ev
,
1991 current_ev
= __prism2_translate_scan(
1992 local
, info
, scan
, NULL
, current_ev
, end_buf
);
1994 /* Check if there is space for one more entry */
1995 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
1996 /* Ask user space to try again with a bigger buffer */
1997 spin_unlock_bh(&local
->lock
);
2002 /* Prism2 firmware has limits (32 at least in some versions) for number
2003 * of BSSes in scan results. Extend this limit by using local BSS list.
2005 list_for_each(ptr
, &local
->bss_list
) {
2006 struct hostap_bss_info
*bss
;
2007 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
2010 current_ev
= __prism2_translate_scan(local
, info
, NULL
, bss
,
2011 current_ev
, end_buf
);
2012 /* Check if there is space for one more entry */
2013 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
2014 /* Ask user space to try again with a bigger buffer */
2015 spin_unlock_bh(&local
->lock
);
2020 spin_unlock_bh(&local
->lock
);
2022 return current_ev
- buffer
;
2024 #endif /* PRISM2_NO_STATION_MODES */
2027 static inline int prism2_ioctl_giwscan_sta(struct net_device
*dev
,
2028 struct iw_request_info
*info
,
2029 struct iw_point
*data
, char *extra
)
2031 #ifdef PRISM2_NO_STATION_MODES
2033 #else /* PRISM2_NO_STATION_MODES */
2034 struct hostap_interface
*iface
;
2035 local_info_t
*local
;
2038 iface
= netdev_priv(dev
);
2039 local
= iface
->local
;
2041 /* Wait until the scan is finished. We can probably do better
2042 * than that - Jean II */
2043 if (local
->scan_timestamp
&&
2044 time_before(jiffies
, local
->scan_timestamp
+ 3 * HZ
)) {
2045 /* Important note : we don't want to block the caller
2046 * until results are ready for various reasons.
2047 * First, managing wait queues is complex and racy
2048 * (there may be multiple simultaneous callers).
2049 * Second, we grab some rtnetlink lock before coming
2050 * here (in dev_ioctl()).
2051 * Third, the caller can wait on the Wireless Event
2055 local
->scan_timestamp
= 0;
2057 res
= prism2_translate_scan(local
, info
, extra
, data
->length
);
2066 #endif /* PRISM2_NO_STATION_MODES */
2070 static int prism2_ioctl_giwscan(struct net_device
*dev
,
2071 struct iw_request_info
*info
,
2072 struct iw_point
*data
, char *extra
)
2074 struct hostap_interface
*iface
;
2075 local_info_t
*local
;
2078 iface
= netdev_priv(dev
);
2079 local
= iface
->local
;
2081 if (local
->iw_mode
== IW_MODE_MASTER
) {
2082 /* In MASTER mode, it doesn't make sense to go around
2083 * scanning the frequencies and make the stations we serve
2084 * wait when what the user is really interested about is the
2085 * list of stations and access points we are talking to.
2086 * So, just extract results from our cache...
2089 /* Translate to WE format */
2090 res
= prism2_ap_translate_scan(dev
, info
, extra
);
2092 printk(KERN_DEBUG
"Scan result translation succeeded "
2093 "(length=%d)\n", res
);
2098 "Scan result translation failed (res=%d)\n",
2105 return prism2_ioctl_giwscan_sta(dev
, info
, data
, extra
);
2110 static const struct iw_priv_args prism2_priv
[] = {
2111 { PRISM2_IOCTL_MONITOR
,
2112 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor" },
2113 { PRISM2_IOCTL_READMIF
,
2114 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1,
2115 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1, "readmif" },
2116 { PRISM2_IOCTL_WRITEMIF
,
2117 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 2, 0, "writemif" },
2118 { PRISM2_IOCTL_RESET
,
2119 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "reset" },
2120 { PRISM2_IOCTL_INQUIRE
,
2121 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "inquire" },
2122 { PRISM2_IOCTL_SET_RID_WORD
,
2123 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "set_rid_word" },
2124 { PRISM2_IOCTL_MACCMD
,
2125 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "maccmd" },
2126 { PRISM2_IOCTL_WDS_ADD
,
2127 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_add" },
2128 { PRISM2_IOCTL_WDS_DEL
,
2129 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_del" },
2130 { PRISM2_IOCTL_ADDMAC
,
2131 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "addmac" },
2132 { PRISM2_IOCTL_DELMAC
,
2133 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "delmac" },
2134 { PRISM2_IOCTL_KICKMAC
,
2135 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "kickmac" },
2136 /* --- raw access to sub-ioctls --- */
2137 { PRISM2_IOCTL_PRISM2_PARAM
,
2138 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "prism2_param" },
2139 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2140 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
2141 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprism2_param" },
2142 /* --- sub-ioctls handlers --- */
2143 { PRISM2_IOCTL_PRISM2_PARAM
,
2144 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "" },
2145 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2146 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "" },
2147 /* --- sub-ioctls definitions --- */
2148 { PRISM2_PARAM_TXRATECTRL
,
2149 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "txratectrl" },
2150 { PRISM2_PARAM_TXRATECTRL
,
2151 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettxratectrl" },
2152 { PRISM2_PARAM_BEACON_INT
,
2153 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "beacon_int" },
2154 { PRISM2_PARAM_BEACON_INT
,
2155 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbeacon_int" },
2156 #ifndef PRISM2_NO_STATION_MODES
2157 { PRISM2_PARAM_PSEUDO_IBSS
,
2158 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "pseudo_ibss" },
2159 { PRISM2_PARAM_PSEUDO_IBSS
,
2160 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getpseudo_ibss" },
2161 #endif /* PRISM2_NO_STATION_MODES */
2163 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "alc" },
2165 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getalc" },
2166 { PRISM2_PARAM_DUMP
,
2167 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dump" },
2168 { PRISM2_PARAM_DUMP
,
2169 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdump" },
2170 { PRISM2_PARAM_OTHER_AP_POLICY
,
2171 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "other_ap_policy" },
2172 { PRISM2_PARAM_OTHER_AP_POLICY
,
2173 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getother_ap_pol" },
2174 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2175 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_inactivity" },
2176 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2177 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_inactivi" },
2178 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2179 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bridge_packets" },
2180 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2181 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbridge_packe" },
2182 { PRISM2_PARAM_DTIM_PERIOD
,
2183 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dtim_period" },
2184 { PRISM2_PARAM_DTIM_PERIOD
,
2185 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdtim_period" },
2186 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2187 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "nullfunc_ack" },
2188 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2189 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getnullfunc_ack" },
2190 { PRISM2_PARAM_MAX_WDS
,
2191 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_wds" },
2192 { PRISM2_PARAM_MAX_WDS
,
2193 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_wds" },
2194 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2195 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "autom_ap_wds" },
2196 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2197 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getautom_ap_wds" },
2198 { PRISM2_PARAM_AP_AUTH_ALGS
,
2199 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_auth_algs" },
2200 { PRISM2_PARAM_AP_AUTH_ALGS
,
2201 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_auth_algs" },
2202 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2203 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "allow_fcserr" },
2204 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2205 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getallow_fcserr" },
2206 { PRISM2_PARAM_HOST_ENCRYPT
,
2207 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_encrypt" },
2208 { PRISM2_PARAM_HOST_ENCRYPT
,
2209 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_encrypt" },
2210 { PRISM2_PARAM_HOST_DECRYPT
,
2211 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_decrypt" },
2212 { PRISM2_PARAM_HOST_DECRYPT
,
2213 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_decrypt" },
2214 #ifndef PRISM2_NO_STATION_MODES
2215 { PRISM2_PARAM_HOST_ROAMING
,
2216 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_roaming" },
2217 { PRISM2_PARAM_HOST_ROAMING
,
2218 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_roaming" },
2219 #endif /* PRISM2_NO_STATION_MODES */
2220 { PRISM2_PARAM_BCRX_STA_KEY
,
2221 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bcrx_sta_key" },
2222 { PRISM2_PARAM_BCRX_STA_KEY
,
2223 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbcrx_sta_key" },
2224 { PRISM2_PARAM_IEEE_802_1X
,
2225 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ieee_802_1x" },
2226 { PRISM2_PARAM_IEEE_802_1X
,
2227 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getieee_802_1x" },
2228 { PRISM2_PARAM_ANTSEL_TX
,
2229 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_tx" },
2230 { PRISM2_PARAM_ANTSEL_TX
,
2231 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_tx" },
2232 { PRISM2_PARAM_ANTSEL_RX
,
2233 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_rx" },
2234 { PRISM2_PARAM_ANTSEL_RX
,
2235 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_rx" },
2236 { PRISM2_PARAM_MONITOR_TYPE
,
2237 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor_type" },
2238 { PRISM2_PARAM_MONITOR_TYPE
,
2239 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmonitor_type" },
2240 { PRISM2_PARAM_WDS_TYPE
,
2241 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_type" },
2242 { PRISM2_PARAM_WDS_TYPE
,
2243 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwds_type" },
2244 { PRISM2_PARAM_HOSTSCAN
,
2245 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostscan" },
2246 { PRISM2_PARAM_HOSTSCAN
,
2247 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostscan" },
2248 { PRISM2_PARAM_AP_SCAN
,
2249 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_scan" },
2250 { PRISM2_PARAM_AP_SCAN
,
2251 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_scan" },
2252 { PRISM2_PARAM_ENH_SEC
,
2253 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "enh_sec" },
2254 { PRISM2_PARAM_ENH_SEC
,
2255 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getenh_sec" },
2256 #ifdef PRISM2_IO_DEBUG
2257 { PRISM2_PARAM_IO_DEBUG
,
2258 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "io_debug" },
2259 { PRISM2_PARAM_IO_DEBUG
,
2260 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getio_debug" },
2261 #endif /* PRISM2_IO_DEBUG */
2262 { PRISM2_PARAM_BASIC_RATES
,
2263 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "basic_rates" },
2264 { PRISM2_PARAM_BASIC_RATES
,
2265 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbasic_rates" },
2266 { PRISM2_PARAM_OPER_RATES
,
2267 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "oper_rates" },
2268 { PRISM2_PARAM_OPER_RATES
,
2269 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getoper_rates" },
2270 { PRISM2_PARAM_HOSTAPD
,
2271 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd" },
2272 { PRISM2_PARAM_HOSTAPD
,
2273 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd" },
2274 { PRISM2_PARAM_HOSTAPD_STA
,
2275 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd_sta" },
2276 { PRISM2_PARAM_HOSTAPD_STA
,
2277 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd_sta" },
2279 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wpa" },
2281 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwpa" },
2282 { PRISM2_PARAM_PRIVACY_INVOKED
,
2283 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "privacy_invoked" },
2284 { PRISM2_PARAM_PRIVACY_INVOKED
,
2285 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprivacy_invo" },
2286 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2287 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "tkip_countermea" },
2288 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2289 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettkip_counter" },
2290 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2291 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "drop_unencrypte" },
2292 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2293 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdrop_unencry" },
2294 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2295 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "scan_channels" },
2296 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2297 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getscan_channel" },
2301 static int prism2_ioctl_priv_inquire(struct net_device
*dev
, int *i
)
2303 struct hostap_interface
*iface
;
2304 local_info_t
*local
;
2306 iface
= netdev_priv(dev
);
2307 local
= iface
->local
;
2309 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_INQUIRE
, *i
, NULL
, NULL
))
2316 static int prism2_ioctl_priv_prism2_param(struct net_device
*dev
,
2317 struct iw_request_info
*info
,
2318 void *wrqu
, char *extra
)
2320 struct hostap_interface
*iface
;
2321 local_info_t
*local
;
2322 int *i
= (int *) extra
;
2324 int value
= *(i
+ 1);
2328 iface
= netdev_priv(dev
);
2329 local
= iface
->local
;
2332 case PRISM2_PARAM_TXRATECTRL
:
2333 local
->fw_tx_rate_control
= value
;
2336 case PRISM2_PARAM_BEACON_INT
:
2337 if (hostap_set_word(dev
, HFA384X_RID_CNFBEACONINT
, value
) ||
2338 local
->func
->reset_port(dev
))
2341 local
->beacon_int
= value
;
2344 #ifndef PRISM2_NO_STATION_MODES
2345 case PRISM2_PARAM_PSEUDO_IBSS
:
2346 if (value
== local
->pseudo_adhoc
)
2349 if (value
!= 0 && value
!= 1) {
2354 printk(KERN_DEBUG
"prism2: %s: pseudo IBSS change %d -> %d\n",
2355 dev
->name
, local
->pseudo_adhoc
, value
);
2356 local
->pseudo_adhoc
= value
;
2357 if (local
->iw_mode
!= IW_MODE_ADHOC
)
2360 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2361 hostap_get_porttype(local
))) {
2366 if (local
->func
->reset_port(dev
))
2369 #endif /* PRISM2_NO_STATION_MODES */
2371 case PRISM2_PARAM_ALC
:
2372 printk(KERN_DEBUG
"%s: %s ALC\n", dev
->name
,
2373 value
== 0 ? "Disabling" : "Enabling");
2374 val
= HFA384X_TEST_CFG_BIT_ALC
;
2375 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
2376 (HFA384X_TEST_CFG_BITS
<< 8),
2377 value
== 0 ? 0 : 1, &val
, NULL
);
2380 case PRISM2_PARAM_DUMP
:
2381 local
->frame_dump
= value
;
2384 case PRISM2_PARAM_OTHER_AP_POLICY
:
2385 if (value
< 0 || value
> 3) {
2389 if (local
->ap
!= NULL
)
2390 local
->ap
->ap_policy
= value
;
2393 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2394 if (value
< 0 || value
> 7 * 24 * 60 * 60) {
2398 if (local
->ap
!= NULL
)
2399 local
->ap
->max_inactivity
= value
* HZ
;
2402 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2403 if (local
->ap
!= NULL
)
2404 local
->ap
->bridge_packets
= value
;
2407 case PRISM2_PARAM_DTIM_PERIOD
:
2408 if (value
< 0 || value
> 65535) {
2412 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNDTIMPERIOD
, value
)
2413 || local
->func
->reset_port(dev
))
2416 local
->dtim_period
= value
;
2419 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2420 if (local
->ap
!= NULL
)
2421 local
->ap
->nullfunc_ack
= value
;
2424 case PRISM2_PARAM_MAX_WDS
:
2425 local
->wds_max_connections
= value
;
2428 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2429 if (local
->ap
!= NULL
) {
2430 if (!local
->ap
->autom_ap_wds
&& value
) {
2431 /* add WDS link to all APs in STA table */
2432 hostap_add_wds_links(local
);
2434 local
->ap
->autom_ap_wds
= value
;
2438 case PRISM2_PARAM_AP_AUTH_ALGS
:
2439 local
->auth_algs
= value
;
2440 if (hostap_set_auth_algs(local
))
2444 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2445 local
->monitor_allow_fcserr
= value
;
2448 case PRISM2_PARAM_HOST_ENCRYPT
:
2449 local
->host_encrypt
= value
;
2450 if (hostap_set_encryption(local
) ||
2451 local
->func
->reset_port(dev
))
2455 case PRISM2_PARAM_HOST_DECRYPT
:
2456 local
->host_decrypt
= value
;
2457 if (hostap_set_encryption(local
) ||
2458 local
->func
->reset_port(dev
))
2462 #ifndef PRISM2_NO_STATION_MODES
2463 case PRISM2_PARAM_HOST_ROAMING
:
2464 if (value
< 0 || value
> 2) {
2468 local
->host_roaming
= value
;
2469 if (hostap_set_roaming(local
) || local
->func
->reset_port(dev
))
2472 #endif /* PRISM2_NO_STATION_MODES */
2474 case PRISM2_PARAM_BCRX_STA_KEY
:
2475 local
->bcrx_sta_key
= value
;
2478 case PRISM2_PARAM_IEEE_802_1X
:
2479 local
->ieee_802_1x
= value
;
2482 case PRISM2_PARAM_ANTSEL_TX
:
2483 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2487 local
->antsel_tx
= value
;
2488 hostap_set_antsel(local
);
2491 case PRISM2_PARAM_ANTSEL_RX
:
2492 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2496 local
->antsel_rx
= value
;
2497 hostap_set_antsel(local
);
2500 case PRISM2_PARAM_MONITOR_TYPE
:
2501 if (value
!= PRISM2_MONITOR_80211
&&
2502 value
!= PRISM2_MONITOR_CAPHDR
&&
2503 value
!= PRISM2_MONITOR_PRISM
&&
2504 value
!= PRISM2_MONITOR_RADIOTAP
) {
2508 local
->monitor_type
= value
;
2509 if (local
->iw_mode
== IW_MODE_MONITOR
)
2510 hostap_monitor_set_type(local
);
2513 case PRISM2_PARAM_WDS_TYPE
:
2514 local
->wds_type
= value
;
2517 case PRISM2_PARAM_HOSTSCAN
:
2519 struct hfa384x_hostscan_request scan_req
;
2522 memset(&scan_req
, 0, sizeof(scan_req
));
2523 scan_req
.channel_list
= cpu_to_le16(0x3fff);
2525 case 1: rate
= HFA384X_RATES_1MBPS
; break;
2526 case 2: rate
= HFA384X_RATES_2MBPS
; break;
2527 case 3: rate
= HFA384X_RATES_5MBPS
; break;
2528 case 4: rate
= HFA384X_RATES_11MBPS
; break;
2529 default: rate
= HFA384X_RATES_1MBPS
; break;
2531 scan_req
.txrate
= cpu_to_le16(rate
);
2532 /* leave SSID empty to accept all SSIDs */
2534 if (local
->iw_mode
== IW_MODE_MASTER
) {
2535 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2536 HFA384X_PORTTYPE_BSS
) ||
2537 local
->func
->reset_port(dev
))
2538 printk(KERN_DEBUG
"Leaving Host AP mode "
2539 "for HostScan failed\n");
2542 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
2543 sizeof(scan_req
))) {
2544 printk(KERN_DEBUG
"HOSTSCAN failed\n");
2547 if (local
->iw_mode
== IW_MODE_MASTER
) {
2548 wait_queue_entry_t __wait
;
2549 init_waitqueue_entry(&__wait
, current
);
2550 add_wait_queue(&local
->hostscan_wq
, &__wait
);
2551 set_current_state(TASK_INTERRUPTIBLE
);
2552 schedule_timeout(HZ
);
2553 if (signal_pending(current
))
2555 set_current_state(TASK_RUNNING
);
2556 remove_wait_queue(&local
->hostscan_wq
, &__wait
);
2558 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2559 HFA384X_PORTTYPE_HOSTAP
) ||
2560 local
->func
->reset_port(dev
))
2561 printk(KERN_DEBUG
"Returning to Host AP mode "
2562 "after HostScan failed\n");
2567 case PRISM2_PARAM_AP_SCAN
:
2568 local
->passive_scan_interval
= value
;
2569 if (timer_pending(&local
->passive_scan_timer
))
2570 del_timer(&local
->passive_scan_timer
);
2571 if (value
> 0 && value
< INT_MAX
/ HZ
) {
2572 local
->passive_scan_timer
.expires
= jiffies
+
2573 local
->passive_scan_interval
* HZ
;
2574 add_timer(&local
->passive_scan_timer
);
2578 case PRISM2_PARAM_ENH_SEC
:
2579 if (value
< 0 || value
> 3) {
2583 local
->enh_sec
= value
;
2584 if (hostap_set_word(dev
, HFA384X_RID_CNFENHSECURITY
,
2586 local
->func
->reset_port(dev
)) {
2587 printk(KERN_INFO
"%s: cnfEnhSecurity requires STA f/w "
2588 "1.6.3 or newer\n", dev
->name
);
2593 #ifdef PRISM2_IO_DEBUG
2594 case PRISM2_PARAM_IO_DEBUG
:
2595 local
->io_debug_enabled
= value
;
2597 #endif /* PRISM2_IO_DEBUG */
2599 case PRISM2_PARAM_BASIC_RATES
:
2600 if ((value
& local
->tx_rate_control
) != value
|| value
== 0) {
2601 printk(KERN_INFO
"%s: invalid basic rate set - basic "
2602 "rates must be in supported rate set\n",
2607 local
->basic_rates
= value
;
2608 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
2609 local
->basic_rates
) ||
2610 local
->func
->reset_port(dev
))
2614 case PRISM2_PARAM_OPER_RATES
:
2615 local
->tx_rate_control
= value
;
2616 if (hostap_set_rate(dev
))
2620 case PRISM2_PARAM_HOSTAPD
:
2621 ret
= hostap_set_hostapd(local
, value
, 1);
2624 case PRISM2_PARAM_HOSTAPD_STA
:
2625 ret
= hostap_set_hostapd_sta(local
, value
, 1);
2628 case PRISM2_PARAM_WPA
:
2630 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2632 else if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
2637 case PRISM2_PARAM_PRIVACY_INVOKED
:
2638 local
->privacy_invoked
= value
;
2639 if (hostap_set_encryption(local
) ||
2640 local
->func
->reset_port(dev
))
2644 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2645 local
->tkip_countermeasures
= value
;
2648 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2649 local
->drop_unencrypted
= value
;
2652 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2653 local
->scan_channel_mask
= value
;
2657 printk(KERN_DEBUG
"%s: prism2_param: unknown param %d\n",
2667 static int prism2_ioctl_priv_get_prism2_param(struct net_device
*dev
,
2668 struct iw_request_info
*info
,
2669 void *wrqu
, char *extra
)
2671 struct hostap_interface
*iface
;
2672 local_info_t
*local
;
2673 int *param
= (int *) extra
;
2676 iface
= netdev_priv(dev
);
2677 local
= iface
->local
;
2680 case PRISM2_PARAM_TXRATECTRL
:
2681 *param
= local
->fw_tx_rate_control
;
2684 case PRISM2_PARAM_BEACON_INT
:
2685 *param
= local
->beacon_int
;
2688 case PRISM2_PARAM_PSEUDO_IBSS
:
2689 *param
= local
->pseudo_adhoc
;
2692 case PRISM2_PARAM_ALC
:
2693 ret
= -EOPNOTSUPP
; /* FIX */
2696 case PRISM2_PARAM_DUMP
:
2697 *param
= local
->frame_dump
;
2700 case PRISM2_PARAM_OTHER_AP_POLICY
:
2701 if (local
->ap
!= NULL
)
2702 *param
= local
->ap
->ap_policy
;
2707 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2708 if (local
->ap
!= NULL
)
2709 *param
= local
->ap
->max_inactivity
/ HZ
;
2714 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2715 if (local
->ap
!= NULL
)
2716 *param
= local
->ap
->bridge_packets
;
2721 case PRISM2_PARAM_DTIM_PERIOD
:
2722 *param
= local
->dtim_period
;
2725 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2726 if (local
->ap
!= NULL
)
2727 *param
= local
->ap
->nullfunc_ack
;
2732 case PRISM2_PARAM_MAX_WDS
:
2733 *param
= local
->wds_max_connections
;
2736 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2737 if (local
->ap
!= NULL
)
2738 *param
= local
->ap
->autom_ap_wds
;
2743 case PRISM2_PARAM_AP_AUTH_ALGS
:
2744 *param
= local
->auth_algs
;
2747 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2748 *param
= local
->monitor_allow_fcserr
;
2751 case PRISM2_PARAM_HOST_ENCRYPT
:
2752 *param
= local
->host_encrypt
;
2755 case PRISM2_PARAM_HOST_DECRYPT
:
2756 *param
= local
->host_decrypt
;
2759 case PRISM2_PARAM_HOST_ROAMING
:
2760 *param
= local
->host_roaming
;
2763 case PRISM2_PARAM_BCRX_STA_KEY
:
2764 *param
= local
->bcrx_sta_key
;
2767 case PRISM2_PARAM_IEEE_802_1X
:
2768 *param
= local
->ieee_802_1x
;
2771 case PRISM2_PARAM_ANTSEL_TX
:
2772 *param
= local
->antsel_tx
;
2775 case PRISM2_PARAM_ANTSEL_RX
:
2776 *param
= local
->antsel_rx
;
2779 case PRISM2_PARAM_MONITOR_TYPE
:
2780 *param
= local
->monitor_type
;
2783 case PRISM2_PARAM_WDS_TYPE
:
2784 *param
= local
->wds_type
;
2787 case PRISM2_PARAM_HOSTSCAN
:
2791 case PRISM2_PARAM_AP_SCAN
:
2792 *param
= local
->passive_scan_interval
;
2795 case PRISM2_PARAM_ENH_SEC
:
2796 *param
= local
->enh_sec
;
2799 #ifdef PRISM2_IO_DEBUG
2800 case PRISM2_PARAM_IO_DEBUG
:
2801 *param
= local
->io_debug_enabled
;
2803 #endif /* PRISM2_IO_DEBUG */
2805 case PRISM2_PARAM_BASIC_RATES
:
2806 *param
= local
->basic_rates
;
2809 case PRISM2_PARAM_OPER_RATES
:
2810 *param
= local
->tx_rate_control
;
2813 case PRISM2_PARAM_HOSTAPD
:
2814 *param
= local
->hostapd
;
2817 case PRISM2_PARAM_HOSTAPD_STA
:
2818 *param
= local
->hostapd_sta
;
2821 case PRISM2_PARAM_WPA
:
2822 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2824 *param
= local
->wpa
;
2827 case PRISM2_PARAM_PRIVACY_INVOKED
:
2828 *param
= local
->privacy_invoked
;
2831 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2832 *param
= local
->tkip_countermeasures
;
2835 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2836 *param
= local
->drop_unencrypted
;
2839 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2840 *param
= local
->scan_channel_mask
;
2844 printk(KERN_DEBUG
"%s: get_prism2_param: unknown param %d\n",
2854 static int prism2_ioctl_priv_readmif(struct net_device
*dev
,
2855 struct iw_request_info
*info
,
2856 void *wrqu
, char *extra
)
2858 struct hostap_interface
*iface
;
2859 local_info_t
*local
;
2862 iface
= netdev_priv(dev
);
2863 local
= iface
->local
;
2865 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
, *extra
, NULL
,
2875 static int prism2_ioctl_priv_writemif(struct net_device
*dev
,
2876 struct iw_request_info
*info
,
2877 void *wrqu
, char *extra
)
2879 struct hostap_interface
*iface
;
2880 local_info_t
*local
;
2883 iface
= netdev_priv(dev
);
2884 local
= iface
->local
;
2888 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
, cr
, &val
, NULL
))
2895 static int prism2_ioctl_priv_monitor(struct net_device
*dev
, int *i
)
2897 struct hostap_interface
*iface
;
2898 local_info_t
*local
;
2902 iface
= netdev_priv(dev
);
2903 local
= iface
->local
;
2905 printk(KERN_DEBUG
"%s: process %d (%s) used deprecated iwpriv monitor "
2906 "- update software to use iwconfig mode monitor\n",
2907 dev
->name
, task_pid_nr(current
), current
->comm
);
2909 /* Backward compatibility code - this can be removed at some point */
2912 /* Disable monitor mode - old mode was not saved, so go to
2914 mode
= IW_MODE_MASTER
;
2915 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2916 } else if (*i
== 1) {
2917 /* netlink socket mode is not supported anymore since it did
2918 * not separate different devices from each other and was not
2919 * best method for delivering large amount of packets to
2922 } else if (*i
== 2 || *i
== 3) {
2925 local
->monitor_type
= PRISM2_MONITOR_80211
;
2928 local
->monitor_type
= PRISM2_MONITOR_PRISM
;
2931 mode
= IW_MODE_MONITOR
;
2932 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2933 hostap_monitor_mode_enable(local
);
2941 static int prism2_ioctl_priv_reset(struct net_device
*dev
, int *i
)
2943 struct hostap_interface
*iface
;
2944 local_info_t
*local
;
2946 iface
= netdev_priv(dev
);
2947 local
= iface
->local
;
2949 printk(KERN_DEBUG
"%s: manual reset request(%d)\n", dev
->name
, *i
);
2952 /* Disable and enable card */
2953 local
->func
->hw_shutdown(dev
, 1);
2954 local
->func
->hw_config(dev
, 0);
2959 local
->func
->hw_reset(dev
);
2963 /* Disable and enable port 0 */
2964 local
->func
->reset_port(dev
);
2968 prism2_sta_deauth(local
, WLAN_REASON_DEAUTH_LEAVING
);
2969 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_DISABLE
, 0, NULL
,
2975 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_ENABLE
, 0, NULL
,
2981 printk(KERN_DEBUG
"Unknown reset request %d\n", *i
);
2989 static int prism2_ioctl_priv_set_rid_word(struct net_device
*dev
, int *i
)
2992 int value
= *(i
+ 1);
2994 printk(KERN_DEBUG
"%s: Set RID[0x%X] = %d\n", dev
->name
, rid
, value
);
2996 if (hostap_set_word(dev
, rid
, value
))
3003 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3004 static int ap_mac_cmd_ioctl(local_info_t
*local
, int *cmd
)
3009 case AP_MAC_CMD_POLICY_OPEN
:
3010 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_OPEN
;
3012 case AP_MAC_CMD_POLICY_ALLOW
:
3013 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_ALLOW
;
3015 case AP_MAC_CMD_POLICY_DENY
:
3016 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_DENY
;
3018 case AP_MAC_CMD_FLUSH
:
3019 ap_control_flush_macs(&local
->ap
->mac_restrictions
);
3021 case AP_MAC_CMD_KICKALL
:
3022 ap_control_kickall(local
->ap
);
3023 hostap_deauth_all_stas(local
->dev
, local
->ap
, 0);
3032 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3035 #ifdef PRISM2_DOWNLOAD_SUPPORT
3036 static int prism2_ioctl_priv_download(local_info_t
*local
, struct iw_point
*p
)
3038 struct prism2_download_param
*param
;
3041 if (p
->length
< sizeof(struct prism2_download_param
) ||
3042 p
->length
> 1024 || !p
->pointer
)
3045 param
= memdup_user(p
->pointer
, p
->length
);
3046 if (IS_ERR(param
)) {
3047 return PTR_ERR(param
);
3050 if (p
->length
< sizeof(struct prism2_download_param
) +
3051 param
->num_areas
* sizeof(struct prism2_download_area
)) {
3056 ret
= local
->func
->download(local
, param
);
3062 #endif /* PRISM2_DOWNLOAD_SUPPORT */
3065 static int prism2_set_genericelement(struct net_device
*dev
, u8
*elem
,
3068 struct hostap_interface
*iface
= netdev_priv(dev
);
3069 local_info_t
*local
= iface
->local
;
3073 * Add 16-bit length in the beginning of the buffer because Prism2 RID
3076 buf
= kmalloc(len
+ 2, GFP_KERNEL
);
3080 *((__le16
*) buf
) = cpu_to_le16(len
);
3081 memcpy(buf
+ 2, elem
, len
);
3083 kfree(local
->generic_elem
);
3084 local
->generic_elem
= buf
;
3085 local
->generic_elem_len
= len
+ 2;
3087 return local
->func
->set_rid(local
->dev
, HFA384X_RID_GENERICELEMENT
,
3092 static int prism2_ioctl_siwauth(struct net_device
*dev
,
3093 struct iw_request_info
*info
,
3094 struct iw_param
*data
, char *extra
)
3096 struct hostap_interface
*iface
= netdev_priv(dev
);
3097 local_info_t
*local
= iface
->local
;
3099 switch (data
->flags
& IW_AUTH_INDEX
) {
3100 case IW_AUTH_WPA_VERSION
:
3101 case IW_AUTH_CIPHER_PAIRWISE
:
3102 case IW_AUTH_CIPHER_GROUP
:
3103 case IW_AUTH_KEY_MGMT
:
3105 * Host AP driver does not use these parameters and allows
3106 * wpa_supplicant to control them internally.
3109 case IW_AUTH_TKIP_COUNTERMEASURES
:
3110 local
->tkip_countermeasures
= data
->value
;
3112 case IW_AUTH_DROP_UNENCRYPTED
:
3113 local
->drop_unencrypted
= data
->value
;
3115 case IW_AUTH_80211_AUTH_ALG
:
3116 local
->auth_algs
= data
->value
;
3118 case IW_AUTH_WPA_ENABLED
:
3119 if (data
->value
== 0) {
3121 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3123 prism2_set_genericelement(dev
, "", 0);
3124 local
->host_roaming
= 0;
3125 local
->privacy_invoked
= 0;
3126 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
3128 hostap_set_roaming(local
) ||
3129 hostap_set_encryption(local
) ||
3130 local
->func
->reset_port(dev
))
3134 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3136 local
->host_roaming
= 2;
3137 local
->privacy_invoked
= 1;
3139 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
, 1) ||
3140 hostap_set_roaming(local
) ||
3141 hostap_set_encryption(local
) ||
3142 local
->func
->reset_port(dev
))
3145 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3146 local
->ieee_802_1x
= data
->value
;
3148 case IW_AUTH_PRIVACY_INVOKED
:
3149 local
->privacy_invoked
= data
->value
;
3158 static int prism2_ioctl_giwauth(struct net_device
*dev
,
3159 struct iw_request_info
*info
,
3160 struct iw_param
*data
, char *extra
)
3162 struct hostap_interface
*iface
= netdev_priv(dev
);
3163 local_info_t
*local
= iface
->local
;
3165 switch (data
->flags
& IW_AUTH_INDEX
) {
3166 case IW_AUTH_WPA_VERSION
:
3167 case IW_AUTH_CIPHER_PAIRWISE
:
3168 case IW_AUTH_CIPHER_GROUP
:
3169 case IW_AUTH_KEY_MGMT
:
3171 * Host AP driver does not use these parameters and allows
3172 * wpa_supplicant to control them internally.
3175 case IW_AUTH_TKIP_COUNTERMEASURES
:
3176 data
->value
= local
->tkip_countermeasures
;
3178 case IW_AUTH_DROP_UNENCRYPTED
:
3179 data
->value
= local
->drop_unencrypted
;
3181 case IW_AUTH_80211_AUTH_ALG
:
3182 data
->value
= local
->auth_algs
;
3184 case IW_AUTH_WPA_ENABLED
:
3185 data
->value
= local
->wpa
;
3187 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3188 data
->value
= local
->ieee_802_1x
;
3197 static int prism2_ioctl_siwencodeext(struct net_device
*dev
,
3198 struct iw_request_info
*info
,
3199 struct iw_point
*erq
, char *extra
)
3201 struct hostap_interface
*iface
= netdev_priv(dev
);
3202 local_info_t
*local
= iface
->local
;
3203 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3205 struct lib80211_crypto_ops
*ops
;
3206 struct lib80211_crypt_data
**crypt
;
3209 const char *alg
, *module
;
3211 i
= erq
->flags
& IW_ENCODE_INDEX
;
3214 if (i
< 1 || i
> WEP_KEYS
)
3215 i
= local
->crypt_info
.tx_keyidx
;
3218 if (i
< 0 || i
>= WEP_KEYS
)
3221 addr
= ext
->addr
.sa_data
;
3222 if (is_broadcast_ether_addr(addr
)) {
3224 crypt
= &local
->crypt_info
.crypt
[i
];
3228 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, addr
, 0, &crypt
);
3229 if (sta_ptr
== NULL
) {
3230 if (local
->iw_mode
== IW_MODE_INFRA
) {
3232 * TODO: add STA entry for the current AP so
3233 * that unicast key can be used. For now, this
3234 * is emulated by using default key idx 0.
3237 crypt
= &local
->crypt_info
.crypt
[i
];
3243 if ((erq
->flags
& IW_ENCODE_DISABLED
) ||
3244 ext
->alg
== IW_ENCODE_ALG_NONE
) {
3246 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3251 case IW_ENCODE_ALG_WEP
:
3253 module
= "lib80211_crypt_wep";
3255 case IW_ENCODE_ALG_TKIP
:
3257 module
= "lib80211_crypt_tkip";
3259 case IW_ENCODE_ALG_CCMP
:
3261 module
= "lib80211_crypt_ccmp";
3264 printk(KERN_DEBUG
"%s: unsupported algorithm %d\n",
3265 local
->dev
->name
, ext
->alg
);
3270 ops
= lib80211_get_crypto_ops(alg
);
3272 request_module(module
);
3273 ops
= lib80211_get_crypto_ops(alg
);
3276 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3277 local
->dev
->name
, alg
);
3282 if (sta_ptr
|| ext
->alg
!= IW_ENCODE_ALG_WEP
) {
3284 * Per station encryption and other than WEP algorithms
3285 * require host-based encryption, so force them on
3288 local
->host_decrypt
= local
->host_encrypt
= 1;
3291 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3292 struct lib80211_crypt_data
*new_crypt
;
3294 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3296 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3298 if (new_crypt
== NULL
) {
3302 new_crypt
->ops
= ops
;
3303 if (new_crypt
->ops
&& try_module_get(new_crypt
->ops
->owner
))
3304 new_crypt
->priv
= new_crypt
->ops
->init(i
);
3305 if (new_crypt
->priv
== NULL
) {
3315 * TODO: if ext_flags does not have IW_ENCODE_EXT_RX_SEQ_VALID, the
3316 * existing seq# should not be changed.
3317 * TODO: if ext_flags has IW_ENCODE_EXT_TX_SEQ_VALID, next TX seq#
3318 * should be changed to something else than zero.
3320 if ((!(ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) || ext
->key_len
> 0)
3321 && (*crypt
)->ops
->set_key
&&
3322 (*crypt
)->ops
->set_key(ext
->key
, ext
->key_len
, ext
->rx_seq
,
3323 (*crypt
)->priv
) < 0) {
3324 printk(KERN_DEBUG
"%s: key setting failed\n",
3330 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) {
3332 local
->crypt_info
.tx_keyidx
= i
;
3336 if (sta_ptr
== NULL
&& ext
->key_len
> 0) {
3338 for (j
= 0; j
< WEP_KEYS
; j
++) {
3339 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
3345 local
->crypt_info
.tx_keyidx
= i
;
3350 hostap_handle_sta_release(sta_ptr
);
3352 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
3355 * Do not reset port0 if card is in Managed mode since resetting will
3356 * generate new IEEE 802.11 authentication which may end up in looping
3357 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3358 * after WEP configuration. However, keys are apparently changed at
3359 * least in Managed mode.
3362 (hostap_set_encryption(local
) ||
3363 (local
->iw_mode
!= IW_MODE_INFRA
&&
3364 local
->func
->reset_port(local
->dev
))))
3371 static int prism2_ioctl_giwencodeext(struct net_device
*dev
,
3372 struct iw_request_info
*info
,
3373 struct iw_point
*erq
, char *extra
)
3375 struct hostap_interface
*iface
= netdev_priv(dev
);
3376 local_info_t
*local
= iface
->local
;
3377 struct lib80211_crypt_data
**crypt
;
3380 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3383 max_key_len
= erq
->length
- sizeof(*ext
);
3384 if (max_key_len
< 0)
3387 i
= erq
->flags
& IW_ENCODE_INDEX
;
3388 if (i
< 1 || i
> WEP_KEYS
)
3389 i
= local
->crypt_info
.tx_keyidx
;
3393 addr
= ext
->addr
.sa_data
;
3394 if (is_broadcast_ether_addr(addr
)) {
3396 crypt
= &local
->crypt_info
.crypt
[i
];
3399 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, addr
, 0, &crypt
);
3400 if (sta_ptr
== NULL
)
3404 memset(ext
, 0, sizeof(*ext
));
3406 if (*crypt
== NULL
|| (*crypt
)->ops
== NULL
) {
3407 ext
->alg
= IW_ENCODE_ALG_NONE
;
3409 erq
->flags
|= IW_ENCODE_DISABLED
;
3411 if (strcmp((*crypt
)->ops
->name
, "WEP") == 0)
3412 ext
->alg
= IW_ENCODE_ALG_WEP
;
3413 else if (strcmp((*crypt
)->ops
->name
, "TKIP") == 0)
3414 ext
->alg
= IW_ENCODE_ALG_TKIP
;
3415 else if (strcmp((*crypt
)->ops
->name
, "CCMP") == 0)
3416 ext
->alg
= IW_ENCODE_ALG_CCMP
;
3420 if ((*crypt
)->ops
->get_key
) {
3422 (*crypt
)->ops
->get_key(ext
->key
,
3427 (ext
->alg
== IW_ENCODE_ALG_TKIP
||
3428 ext
->alg
== IW_ENCODE_ALG_CCMP
))
3429 ext
->ext_flags
|= IW_ENCODE_EXT_TX_SEQ_VALID
;
3434 hostap_handle_sta_release(sta_ptr
);
3440 static int prism2_ioctl_set_encryption(local_info_t
*local
,
3441 struct prism2_hostapd_param
*param
,
3445 struct lib80211_crypto_ops
*ops
;
3446 struct lib80211_crypt_data
**crypt
;
3449 param
->u
.crypt
.err
= 0;
3450 param
->u
.crypt
.alg
[HOSTAP_CRYPT_ALG_NAME_LEN
- 1] = '\0';
3453 (int) ((char *) param
->u
.crypt
.key
- (char *) param
) +
3454 param
->u
.crypt
.key_len
)
3457 if (is_broadcast_ether_addr(param
->sta_addr
)) {
3458 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3461 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3463 if (param
->u
.crypt
.idx
)
3465 sta_ptr
= ap_crypt_get_ptrs(
3466 local
->ap
, param
->sta_addr
,
3467 (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_PERMANENT
),
3470 if (sta_ptr
== NULL
) {
3471 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3476 if (strcmp(param
->u
.crypt
.alg
, "none") == 0) {
3478 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3482 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3483 if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "WEP") == 0) {
3484 request_module("lib80211_crypt_wep");
3485 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3486 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "TKIP") == 0) {
3487 request_module("lib80211_crypt_tkip");
3488 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3489 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "CCMP") == 0) {
3490 request_module("lib80211_crypt_ccmp");
3491 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3494 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3495 local
->dev
->name
, param
->u
.crypt
.alg
);
3496 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ALG
;
3501 /* station based encryption and other than WEP algorithms require
3502 * host-based encryption, so force them on automatically */
3503 local
->host_decrypt
= local
->host_encrypt
= 1;
3505 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3506 struct lib80211_crypt_data
*new_crypt
;
3508 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3510 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3512 if (new_crypt
== NULL
) {
3516 new_crypt
->ops
= ops
;
3517 new_crypt
->priv
= new_crypt
->ops
->init(param
->u
.crypt
.idx
);
3518 if (new_crypt
->priv
== NULL
) {
3520 param
->u
.crypt
.err
=
3521 HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED
;
3529 if ((!(param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) ||
3530 param
->u
.crypt
.key_len
> 0) && (*crypt
)->ops
->set_key
&&
3531 (*crypt
)->ops
->set_key(param
->u
.crypt
.key
,
3532 param
->u
.crypt
.key_len
, param
->u
.crypt
.seq
,
3533 (*crypt
)->priv
) < 0) {
3534 printk(KERN_DEBUG
"%s: key setting failed\n",
3536 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_KEY_SET_FAILED
;
3541 if (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) {
3543 local
->crypt_info
.tx_keyidx
= param
->u
.crypt
.idx
;
3544 else if (param
->u
.crypt
.idx
) {
3545 printk(KERN_DEBUG
"%s: TX key idx setting failed\n",
3547 param
->u
.crypt
.err
=
3548 HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED
;
3556 hostap_handle_sta_release(sta_ptr
);
3558 /* Do not reset port0 if card is in Managed mode since resetting will
3559 * generate new IEEE 802.11 authentication which may end up in looping
3560 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3561 * after WEP configuration. However, keys are apparently changed at
3562 * least in Managed mode. */
3564 (hostap_set_encryption(local
) ||
3565 (local
->iw_mode
!= IW_MODE_INFRA
&&
3566 local
->func
->reset_port(local
->dev
)))) {
3567 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_CARD_CONF_FAILED
;
3575 static int prism2_ioctl_get_encryption(local_info_t
*local
,
3576 struct prism2_hostapd_param
*param
,
3579 struct lib80211_crypt_data
**crypt
;
3583 param
->u
.crypt
.err
= 0;
3585 max_key_len
= param_len
-
3586 (int) ((char *) param
->u
.crypt
.key
- (char *) param
);
3587 if (max_key_len
< 0)
3590 if (is_broadcast_ether_addr(param
->sta_addr
)) {
3592 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3593 param
->u
.crypt
.idx
= local
->crypt_info
.tx_keyidx
;
3594 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3596 param
->u
.crypt
.idx
= 0;
3597 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, param
->sta_addr
, 0,
3600 if (sta_ptr
== NULL
) {
3601 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3606 if (*crypt
== NULL
|| (*crypt
)->ops
== NULL
) {
3607 memcpy(param
->u
.crypt
.alg
, "none", 5);
3608 param
->u
.crypt
.key_len
= 0;
3609 param
->u
.crypt
.idx
= 0xff;
3611 strncpy(param
->u
.crypt
.alg
, (*crypt
)->ops
->name
,
3612 HOSTAP_CRYPT_ALG_NAME_LEN
);
3613 param
->u
.crypt
.key_len
= 0;
3615 memset(param
->u
.crypt
.seq
, 0, 8);
3616 if ((*crypt
)->ops
->get_key
) {
3617 param
->u
.crypt
.key_len
=
3618 (*crypt
)->ops
->get_key(param
->u
.crypt
.key
,
3626 hostap_handle_sta_release(sta_ptr
);
3632 static int prism2_ioctl_get_rid(local_info_t
*local
,
3633 struct prism2_hostapd_param
*param
,
3638 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3642 res
= local
->func
->get_rid(local
->dev
, param
->u
.rid
.rid
,
3643 param
->u
.rid
.data
, param
->u
.rid
.len
, 0);
3645 param
->u
.rid
.len
= res
;
3653 static int prism2_ioctl_set_rid(local_info_t
*local
,
3654 struct prism2_hostapd_param
*param
,
3659 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3660 if (max_len
< 0 || max_len
< param
->u
.rid
.len
)
3663 return local
->func
->set_rid(local
->dev
, param
->u
.rid
.rid
,
3664 param
->u
.rid
.data
, param
->u
.rid
.len
);
3668 static int prism2_ioctl_set_assoc_ap_addr(local_info_t
*local
,
3669 struct prism2_hostapd_param
*param
,
3672 printk(KERN_DEBUG
"%ssta: associated as client with AP %pM\n",
3673 local
->dev
->name
, param
->sta_addr
);
3674 memcpy(local
->assoc_ap_addr
, param
->sta_addr
, ETH_ALEN
);
3679 static int prism2_ioctl_siwgenie(struct net_device
*dev
,
3680 struct iw_request_info
*info
,
3681 struct iw_point
*data
, char *extra
)
3683 return prism2_set_genericelement(dev
, extra
, data
->length
);
3687 static int prism2_ioctl_giwgenie(struct net_device
*dev
,
3688 struct iw_request_info
*info
,
3689 struct iw_point
*data
, char *extra
)
3691 struct hostap_interface
*iface
= netdev_priv(dev
);
3692 local_info_t
*local
= iface
->local
;
3693 int len
= local
->generic_elem_len
- 2;
3695 if (len
<= 0 || local
->generic_elem
== NULL
) {
3700 if (data
->length
< len
)
3704 memcpy(extra
, local
->generic_elem
+ 2, len
);
3710 static int prism2_ioctl_set_generic_element(local_info_t
*local
,
3711 struct prism2_hostapd_param
*param
,
3716 len
= param
->u
.generic_elem
.len
;
3717 max_len
= param_len
- PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN
;
3718 if (max_len
< 0 || max_len
< len
)
3721 return prism2_set_genericelement(local
->dev
,
3722 param
->u
.generic_elem
.data
, len
);
3726 static int prism2_ioctl_siwmlme(struct net_device
*dev
,
3727 struct iw_request_info
*info
,
3728 struct iw_point
*data
, char *extra
)
3730 struct hostap_interface
*iface
= netdev_priv(dev
);
3731 local_info_t
*local
= iface
->local
;
3732 struct iw_mlme
*mlme
= (struct iw_mlme
*) extra
;
3735 reason
= cpu_to_le16(mlme
->reason_code
);
3737 switch (mlme
->cmd
) {
3738 case IW_MLME_DEAUTH
:
3739 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3740 IEEE80211_STYPE_DEAUTH
,
3742 case IW_MLME_DISASSOC
:
3743 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3744 IEEE80211_STYPE_DISASSOC
,
3752 static int prism2_ioctl_mlme(local_info_t
*local
,
3753 struct prism2_hostapd_param
*param
)
3757 reason
= cpu_to_le16(param
->u
.mlme
.reason_code
);
3758 switch (param
->u
.mlme
.cmd
) {
3759 case MLME_STA_DEAUTH
:
3760 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3761 IEEE80211_STYPE_DEAUTH
,
3763 case MLME_STA_DISASSOC
:
3764 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3765 IEEE80211_STYPE_DISASSOC
,
3773 static int prism2_ioctl_scan_req(local_info_t
*local
,
3774 struct prism2_hostapd_param
*param
)
3776 #ifndef PRISM2_NO_STATION_MODES
3777 if ((local
->iw_mode
!= IW_MODE_INFRA
&&
3778 local
->iw_mode
!= IW_MODE_ADHOC
) ||
3779 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1)))
3782 if (!local
->dev_enabled
)
3785 return prism2_request_hostscan(local
->dev
, param
->u
.scan_req
.ssid
,
3786 param
->u
.scan_req
.ssid_len
);
3787 #else /* PRISM2_NO_STATION_MODES */
3789 #endif /* PRISM2_NO_STATION_MODES */
3793 static int prism2_ioctl_priv_hostapd(local_info_t
*local
, struct iw_point
*p
)
3795 struct prism2_hostapd_param
*param
;
3799 if (p
->length
< sizeof(struct prism2_hostapd_param
) ||
3800 p
->length
> PRISM2_HOSTAPD_MAX_BUF_SIZE
|| !p
->pointer
)
3803 param
= memdup_user(p
->pointer
, p
->length
);
3804 if (IS_ERR(param
)) {
3805 return PTR_ERR(param
);
3808 switch (param
->cmd
) {
3809 case PRISM2_SET_ENCRYPTION
:
3810 ret
= prism2_ioctl_set_encryption(local
, param
, p
->length
);
3812 case PRISM2_GET_ENCRYPTION
:
3813 ret
= prism2_ioctl_get_encryption(local
, param
, p
->length
);
3815 case PRISM2_HOSTAPD_GET_RID
:
3816 ret
= prism2_ioctl_get_rid(local
, param
, p
->length
);
3818 case PRISM2_HOSTAPD_SET_RID
:
3819 ret
= prism2_ioctl_set_rid(local
, param
, p
->length
);
3821 case PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR
:
3822 ret
= prism2_ioctl_set_assoc_ap_addr(local
, param
, p
->length
);
3824 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT
:
3825 ret
= prism2_ioctl_set_generic_element(local
, param
,
3828 case PRISM2_HOSTAPD_MLME
:
3829 ret
= prism2_ioctl_mlme(local
, param
);
3831 case PRISM2_HOSTAPD_SCAN_REQ
:
3832 ret
= prism2_ioctl_scan_req(local
, param
);
3835 ret
= prism2_hostapd(local
->ap
, param
);
3840 if (ret
== 1 || !ap_ioctl
) {
3841 if (copy_to_user(p
->pointer
, param
, p
->length
)) {
3844 } else if (ap_ioctl
)
3854 static void prism2_get_drvinfo(struct net_device
*dev
,
3855 struct ethtool_drvinfo
*info
)
3857 struct hostap_interface
*iface
;
3858 local_info_t
*local
;
3860 iface
= netdev_priv(dev
);
3861 local
= iface
->local
;
3863 strlcpy(info
->driver
, "hostap", sizeof(info
->driver
));
3864 snprintf(info
->fw_version
, sizeof(info
->fw_version
),
3865 "%d.%d.%d", (local
->sta_fw_ver
>> 16) & 0xff,
3866 (local
->sta_fw_ver
>> 8) & 0xff,
3867 local
->sta_fw_ver
& 0xff);
3870 const struct ethtool_ops prism2_ethtool_ops
= {
3871 .get_drvinfo
= prism2_get_drvinfo
3875 /* Structures to export the Wireless Handlers */
3877 static const iw_handler prism2_handler
[] =
3879 (iw_handler
) NULL
, /* SIOCSIWCOMMIT */
3880 (iw_handler
) prism2_get_name
, /* SIOCGIWNAME */
3881 (iw_handler
) NULL
, /* SIOCSIWNWID */
3882 (iw_handler
) NULL
, /* SIOCGIWNWID */
3883 (iw_handler
) prism2_ioctl_siwfreq
, /* SIOCSIWFREQ */
3884 (iw_handler
) prism2_ioctl_giwfreq
, /* SIOCGIWFREQ */
3885 (iw_handler
) prism2_ioctl_siwmode
, /* SIOCSIWMODE */
3886 (iw_handler
) prism2_ioctl_giwmode
, /* SIOCGIWMODE */
3887 (iw_handler
) prism2_ioctl_siwsens
, /* SIOCSIWSENS */
3888 (iw_handler
) prism2_ioctl_giwsens
, /* SIOCGIWSENS */
3889 (iw_handler
) NULL
/* not used */, /* SIOCSIWRANGE */
3890 (iw_handler
) prism2_ioctl_giwrange
, /* SIOCGIWRANGE */
3891 (iw_handler
) NULL
/* not used */, /* SIOCSIWPRIV */
3892 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWPRIV */
3893 (iw_handler
) NULL
/* not used */, /* SIOCSIWSTATS */
3894 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWSTATS */
3895 iw_handler_set_spy
, /* SIOCSIWSPY */
3896 iw_handler_get_spy
, /* SIOCGIWSPY */
3897 iw_handler_set_thrspy
, /* SIOCSIWTHRSPY */
3898 iw_handler_get_thrspy
, /* SIOCGIWTHRSPY */
3899 (iw_handler
) prism2_ioctl_siwap
, /* SIOCSIWAP */
3900 (iw_handler
) prism2_ioctl_giwap
, /* SIOCGIWAP */
3901 (iw_handler
) prism2_ioctl_siwmlme
, /* SIOCSIWMLME */
3902 (iw_handler
) prism2_ioctl_giwaplist
, /* SIOCGIWAPLIST */
3903 (iw_handler
) prism2_ioctl_siwscan
, /* SIOCSIWSCAN */
3904 (iw_handler
) prism2_ioctl_giwscan
, /* SIOCGIWSCAN */
3905 (iw_handler
) prism2_ioctl_siwessid
, /* SIOCSIWESSID */
3906 (iw_handler
) prism2_ioctl_giwessid
, /* SIOCGIWESSID */
3907 (iw_handler
) prism2_ioctl_siwnickn
, /* SIOCSIWNICKN */
3908 (iw_handler
) prism2_ioctl_giwnickn
, /* SIOCGIWNICKN */
3909 (iw_handler
) NULL
, /* -- hole -- */
3910 (iw_handler
) NULL
, /* -- hole -- */
3911 (iw_handler
) prism2_ioctl_siwrate
, /* SIOCSIWRATE */
3912 (iw_handler
) prism2_ioctl_giwrate
, /* SIOCGIWRATE */
3913 (iw_handler
) prism2_ioctl_siwrts
, /* SIOCSIWRTS */
3914 (iw_handler
) prism2_ioctl_giwrts
, /* SIOCGIWRTS */
3915 (iw_handler
) prism2_ioctl_siwfrag
, /* SIOCSIWFRAG */
3916 (iw_handler
) prism2_ioctl_giwfrag
, /* SIOCGIWFRAG */
3917 (iw_handler
) prism2_ioctl_siwtxpow
, /* SIOCSIWTXPOW */
3918 (iw_handler
) prism2_ioctl_giwtxpow
, /* SIOCGIWTXPOW */
3919 (iw_handler
) prism2_ioctl_siwretry
, /* SIOCSIWRETRY */
3920 (iw_handler
) prism2_ioctl_giwretry
, /* SIOCGIWRETRY */
3921 (iw_handler
) prism2_ioctl_siwencode
, /* SIOCSIWENCODE */
3922 (iw_handler
) prism2_ioctl_giwencode
, /* SIOCGIWENCODE */
3923 (iw_handler
) prism2_ioctl_siwpower
, /* SIOCSIWPOWER */
3924 (iw_handler
) prism2_ioctl_giwpower
, /* SIOCGIWPOWER */
3925 (iw_handler
) NULL
, /* -- hole -- */
3926 (iw_handler
) NULL
, /* -- hole -- */
3927 (iw_handler
) prism2_ioctl_siwgenie
, /* SIOCSIWGENIE */
3928 (iw_handler
) prism2_ioctl_giwgenie
, /* SIOCGIWGENIE */
3929 (iw_handler
) prism2_ioctl_siwauth
, /* SIOCSIWAUTH */
3930 (iw_handler
) prism2_ioctl_giwauth
, /* SIOCGIWAUTH */
3931 (iw_handler
) prism2_ioctl_siwencodeext
, /* SIOCSIWENCODEEXT */
3932 (iw_handler
) prism2_ioctl_giwencodeext
, /* SIOCGIWENCODEEXT */
3933 (iw_handler
) NULL
, /* SIOCSIWPMKSA */
3934 (iw_handler
) NULL
, /* -- hole -- */
3937 static const iw_handler prism2_private_handler
[] =
3938 { /* SIOCIWFIRSTPRIV + */
3939 (iw_handler
) prism2_ioctl_priv_prism2_param
, /* 0 */
3940 (iw_handler
) prism2_ioctl_priv_get_prism2_param
, /* 1 */
3941 (iw_handler
) prism2_ioctl_priv_writemif
, /* 2 */
3942 (iw_handler
) prism2_ioctl_priv_readmif
, /* 3 */
3945 const struct iw_handler_def hostap_iw_handler_def
=
3947 .num_standard
= ARRAY_SIZE(prism2_handler
),
3948 .num_private
= ARRAY_SIZE(prism2_private_handler
),
3949 .num_private_args
= ARRAY_SIZE(prism2_priv
),
3950 .standard
= (iw_handler
*) prism2_handler
,
3951 .private = (iw_handler
*) prism2_private_handler
,
3952 .private_args
= (struct iw_priv_args
*) prism2_priv
,
3953 .get_wireless_stats
= hostap_get_wireless_stats
,
3957 int hostap_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
3959 struct iwreq
*wrq
= (struct iwreq
*) ifr
;
3960 struct hostap_interface
*iface
;
3961 local_info_t
*local
;
3964 iface
= netdev_priv(dev
);
3965 local
= iface
->local
;
3968 /* Private ioctls (iwpriv) that have not yet been converted
3969 * into new wireless extensions API */
3971 case PRISM2_IOCTL_INQUIRE
:
3972 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3973 else ret
= prism2_ioctl_priv_inquire(dev
, (int *) wrq
->u
.name
);
3976 case PRISM2_IOCTL_MONITOR
:
3977 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3978 else ret
= prism2_ioctl_priv_monitor(dev
, (int *) wrq
->u
.name
);
3981 case PRISM2_IOCTL_RESET
:
3982 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3983 else ret
= prism2_ioctl_priv_reset(dev
, (int *) wrq
->u
.name
);
3986 case PRISM2_IOCTL_WDS_ADD
:
3987 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3988 else ret
= prism2_wds_add(local
, wrq
->u
.ap_addr
.sa_data
, 1);
3991 case PRISM2_IOCTL_WDS_DEL
:
3992 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3993 else ret
= prism2_wds_del(local
, wrq
->u
.ap_addr
.sa_data
, 1, 0);
3996 case PRISM2_IOCTL_SET_RID_WORD
:
3997 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3998 else ret
= prism2_ioctl_priv_set_rid_word(dev
,
3999 (int *) wrq
->u
.name
);
4002 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
4003 case PRISM2_IOCTL_MACCMD
:
4004 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4005 else ret
= ap_mac_cmd_ioctl(local
, (int *) wrq
->u
.name
);
4008 case PRISM2_IOCTL_ADDMAC
:
4009 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4010 else ret
= ap_control_add_mac(&local
->ap
->mac_restrictions
,
4011 wrq
->u
.ap_addr
.sa_data
);
4013 case PRISM2_IOCTL_DELMAC
:
4014 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4015 else ret
= ap_control_del_mac(&local
->ap
->mac_restrictions
,
4016 wrq
->u
.ap_addr
.sa_data
);
4018 case PRISM2_IOCTL_KICKMAC
:
4019 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4020 else ret
= ap_control_kick_mac(local
->ap
, local
->dev
,
4021 wrq
->u
.ap_addr
.sa_data
);
4023 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
4026 /* Private ioctls that are not used with iwpriv;
4027 * in SIOCDEVPRIVATE range */
4029 #ifdef PRISM2_DOWNLOAD_SUPPORT
4030 case PRISM2_IOCTL_DOWNLOAD
:
4031 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4032 else ret
= prism2_ioctl_priv_download(local
, &wrq
->u
.data
);
4034 #endif /* PRISM2_DOWNLOAD_SUPPORT */
4036 case PRISM2_IOCTL_HOSTAPD
:
4037 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4038 else ret
= prism2_ioctl_priv_hostapd(local
, &wrq
->u
.data
);