1 /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
3 #include <linux/slab.h>
4 #include <linux/types.h>
5 #include <linux/sched.h>
6 #include <linux/ethtool.h>
7 #include <linux/if_arp.h>
8 #include <linux/module.h>
9 #include <linux/etherdevice.h>
10 #include <net/lib80211.h>
12 #include "hostap_wlan.h"
14 #include "hostap_ap.h"
16 static struct iw_statistics
*hostap_get_wireless_stats(struct net_device
*dev
)
18 struct hostap_interface
*iface
;
20 struct iw_statistics
*wstats
;
22 iface
= netdev_priv(dev
);
25 /* Why are we doing that ? Jean II */
26 if (iface
->type
!= HOSTAP_INTERFACE_MAIN
)
29 wstats
= &local
->wstats
;
32 wstats
->discard
.code
=
33 local
->comm_tallies
.rx_discards_wep_undecryptable
;
34 wstats
->discard
.misc
=
35 local
->comm_tallies
.rx_fcs_errors
+
36 local
->comm_tallies
.rx_discards_no_buffer
+
37 local
->comm_tallies
.tx_discards_wrong_sa
;
39 wstats
->discard
.retries
=
40 local
->comm_tallies
.tx_retry_limit_exceeded
;
41 wstats
->discard
.fragment
=
42 local
->comm_tallies
.rx_message_in_bad_msg_fragments
;
44 if (local
->iw_mode
!= IW_MODE_MASTER
&&
45 local
->iw_mode
!= IW_MODE_REPEAT
) {
48 /* RID reading might sleep and it must not be called in
49 * interrupt context or while atomic. However, this
50 * function seems to be called while atomic (at least in Linux
51 * 2.5.59). Update signal quality values only if in suitable
52 * context. Otherwise, previous values read from tick timer
56 #endif /* in_atomic */
58 if (update
&& prism2_update_comms_qual(dev
) == 0)
59 wstats
->qual
.updated
= IW_QUAL_ALL_UPDATED
|
62 wstats
->qual
.qual
= local
->comms_qual
;
63 wstats
->qual
.level
= local
->avg_signal
;
64 wstats
->qual
.noise
= local
->avg_noise
;
66 wstats
->qual
.qual
= 0;
67 wstats
->qual
.level
= 0;
68 wstats
->qual
.noise
= 0;
69 wstats
->qual
.updated
= IW_QUAL_ALL_INVALID
;
76 static int prism2_get_datarates(struct net_device
*dev
, u8
*rates
)
78 struct hostap_interface
*iface
;
84 iface
= netdev_priv(dev
);
87 len
= local
->func
->get_rid(dev
, HFA384X_RID_SUPPORTEDDATARATES
, buf
,
92 val
= le16_to_cpu(*(__le16
*) buf
); /* string length */
94 if (len
- 2 < val
|| val
> 10)
97 memcpy(rates
, buf
+ 2, val
);
102 static int prism2_get_name(struct net_device
*dev
,
103 struct iw_request_info
*info
,
104 char *name
, char *extra
)
107 int len
, i
, over2
= 0;
109 len
= prism2_get_datarates(dev
, rates
);
111 for (i
= 0; i
< len
; i
++) {
112 if (rates
[i
] == 0x0b || rates
[i
] == 0x16) {
118 strcpy(name
, over2
? "IEEE 802.11b" : "IEEE 802.11-DS");
124 static int prism2_ioctl_siwencode(struct net_device
*dev
,
125 struct iw_request_info
*info
,
126 struct iw_point
*erq
, char *keybuf
)
128 struct hostap_interface
*iface
;
131 struct lib80211_crypt_data
**crypt
;
133 iface
= netdev_priv(dev
);
134 local
= iface
->local
;
136 i
= erq
->flags
& IW_ENCODE_INDEX
;
138 i
= local
->crypt_info
.tx_keyidx
;
141 if (i
< 0 || i
>= WEP_KEYS
)
144 crypt
= &local
->crypt_info
.crypt
[i
];
146 if (erq
->flags
& IW_ENCODE_DISABLED
) {
148 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
152 if (*crypt
!= NULL
&& (*crypt
)->ops
!= NULL
&&
153 strcmp((*crypt
)->ops
->name
, "WEP") != 0) {
154 /* changing to use WEP; deinit previously used algorithm */
155 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
158 if (*crypt
== NULL
) {
159 struct lib80211_crypt_data
*new_crypt
;
161 /* take WEP into use */
162 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
164 if (new_crypt
== NULL
)
166 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
167 if (!new_crypt
->ops
) {
168 request_module("lib80211_crypt_wep");
169 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
171 if (new_crypt
->ops
&& try_module_get(new_crypt
->ops
->owner
))
172 new_crypt
->priv
= new_crypt
->ops
->init(i
);
173 if (!new_crypt
->ops
|| !new_crypt
->priv
) {
177 printk(KERN_WARNING
"%s: could not initialize WEP: "
178 "load module hostap_crypt_wep.o\n",
185 if (erq
->length
> 0) {
186 int len
= erq
->length
<= 5 ? 5 : 13;
188 if (len
> erq
->length
)
189 memset(keybuf
+ erq
->length
, 0, len
- erq
->length
);
190 (*crypt
)->ops
->set_key(keybuf
, len
, NULL
, (*crypt
)->priv
);
191 for (j
= 0; j
< WEP_KEYS
; j
++) {
192 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
198 local
->crypt_info
.tx_keyidx
= i
;
200 /* No key data - just set the default TX key index */
201 local
->crypt_info
.tx_keyidx
= i
;
205 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
207 if (hostap_set_encryption(local
)) {
208 printk(KERN_DEBUG
"%s: set_encryption failed\n", dev
->name
);
212 /* Do not reset port0 if card is in Managed mode since resetting will
213 * generate new IEEE 802.11 authentication which may end up in looping
214 * with IEEE 802.1X. Prism2 documentation seem to require port reset
215 * after WEP configuration. However, keys are apparently changed at
216 * least in Managed mode. */
217 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->func
->reset_port(dev
)) {
218 printk(KERN_DEBUG
"%s: reset_port failed\n", dev
->name
);
226 static int prism2_ioctl_giwencode(struct net_device
*dev
,
227 struct iw_request_info
*info
,
228 struct iw_point
*erq
, char *key
)
230 struct hostap_interface
*iface
;
234 struct lib80211_crypt_data
*crypt
;
236 iface
= netdev_priv(dev
);
237 local
= iface
->local
;
239 i
= erq
->flags
& IW_ENCODE_INDEX
;
241 i
= local
->crypt_info
.tx_keyidx
;
244 if (i
< 0 || i
>= WEP_KEYS
)
247 crypt
= local
->crypt_info
.crypt
[i
];
250 if (crypt
== NULL
|| crypt
->ops
== NULL
) {
252 erq
->flags
|= IW_ENCODE_DISABLED
;
256 if (strcmp(crypt
->ops
->name
, "WEP") != 0) {
257 /* only WEP is supported with wireless extensions, so just
258 * report that encryption is used */
260 erq
->flags
|= IW_ENCODE_ENABLED
;
264 /* Reads from HFA384X_RID_CNFDEFAULTKEY* return bogus values, so show
265 * the keys from driver buffer */
266 len
= crypt
->ops
->get_key(key
, WEP_KEY_LEN
, NULL
, crypt
->priv
);
267 erq
->length
= (len
>= 0 ? len
: 0);
269 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFWEPFLAGS
, &val
, 2, 1) < 0)
271 printk("CNFWEPFLAGS reading failed\n");
275 if (val
& HFA384X_WEPFLAGS_PRIVACYINVOKED
)
276 erq
->flags
|= IW_ENCODE_ENABLED
;
278 erq
->flags
|= IW_ENCODE_DISABLED
;
279 if (val
& HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED
)
280 erq
->flags
|= IW_ENCODE_RESTRICTED
;
282 erq
->flags
|= IW_ENCODE_OPEN
;
288 static int hostap_set_rate(struct net_device
*dev
)
290 struct hostap_interface
*iface
;
292 int ret
, basic_rates
;
294 iface
= netdev_priv(dev
);
295 local
= iface
->local
;
297 basic_rates
= local
->basic_rates
& local
->tx_rate_control
;
298 if (!basic_rates
|| basic_rates
!= local
->basic_rates
) {
299 printk(KERN_INFO
"%s: updating basic rate set automatically "
300 "to match with the new supported rate set\n",
303 basic_rates
= local
->tx_rate_control
;
305 local
->basic_rates
= basic_rates
;
306 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
308 printk(KERN_WARNING
"%s: failed to set "
309 "cnfBasicRates\n", dev
->name
);
312 ret
= (hostap_set_word(dev
, HFA384X_RID_TXRATECONTROL
,
313 local
->tx_rate_control
) ||
314 hostap_set_word(dev
, HFA384X_RID_CNFSUPPORTEDRATES
,
315 local
->tx_rate_control
) ||
316 local
->func
->reset_port(dev
));
319 printk(KERN_WARNING
"%s: TXRateControl/cnfSupportedRates "
320 "setting to 0x%x failed\n",
321 dev
->name
, local
->tx_rate_control
);
324 /* Update TX rate configuration for all STAs based on new operational
326 hostap_update_rates(local
);
332 static int prism2_ioctl_siwrate(struct net_device
*dev
,
333 struct iw_request_info
*info
,
334 struct iw_param
*rrq
, char *extra
)
336 struct hostap_interface
*iface
;
339 iface
= netdev_priv(dev
);
340 local
= iface
->local
;
343 switch (rrq
->value
) {
345 local
->tx_rate_control
= HFA384X_RATES_11MBPS
;
348 local
->tx_rate_control
= HFA384X_RATES_5MBPS
;
351 local
->tx_rate_control
= HFA384X_RATES_2MBPS
;
354 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
357 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
358 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
359 HFA384X_RATES_11MBPS
;
363 switch (rrq
->value
) {
365 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
366 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
367 HFA384X_RATES_11MBPS
;
370 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
371 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
;
374 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
378 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
381 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
382 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
383 HFA384X_RATES_11MBPS
;
388 return hostap_set_rate(dev
);
392 static int prism2_ioctl_giwrate(struct net_device
*dev
,
393 struct iw_request_info
*info
,
394 struct iw_param
*rrq
, char *extra
)
397 struct hostap_interface
*iface
;
401 iface
= netdev_priv(dev
);
402 local
= iface
->local
;
404 if (local
->func
->get_rid(dev
, HFA384X_RID_TXRATECONTROL
, &val
, 2, 1) <
408 if ((val
& 0x1) && (val
> 1))
413 if (local
->iw_mode
== IW_MODE_MASTER
&& local
->ap
!= NULL
&&
414 !local
->fw_tx_rate_control
) {
415 /* HFA384X_RID_CURRENTTXRATE seems to always be 2 Mbps in
416 * Host AP mode, so use the recorded TX rate of the last sent
418 rrq
->value
= local
->ap
->last_tx_rate
> 0 ?
419 local
->ap
->last_tx_rate
* 100000 : 11000000;
423 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTTXRATE
, &val
, 2, 1) <
428 case HFA384X_RATES_1MBPS
:
429 rrq
->value
= 1000000;
431 case HFA384X_RATES_2MBPS
:
432 rrq
->value
= 2000000;
434 case HFA384X_RATES_5MBPS
:
435 rrq
->value
= 5500000;
437 case HFA384X_RATES_11MBPS
:
438 rrq
->value
= 11000000;
441 /* should not happen */
442 rrq
->value
= 11000000;
451 static int prism2_ioctl_siwsens(struct net_device
*dev
,
452 struct iw_request_info
*info
,
453 struct iw_param
*sens
, char *extra
)
455 struct hostap_interface
*iface
;
458 iface
= netdev_priv(dev
);
459 local
= iface
->local
;
461 /* Set the desired AP density */
462 if (sens
->value
< 1 || sens
->value
> 3)
465 if (hostap_set_word(dev
, HFA384X_RID_CNFSYSTEMSCALE
, sens
->value
) ||
466 local
->func
->reset_port(dev
))
472 static int prism2_ioctl_giwsens(struct net_device
*dev
,
473 struct iw_request_info
*info
,
474 struct iw_param
*sens
, char *extra
)
476 struct hostap_interface
*iface
;
480 iface
= netdev_priv(dev
);
481 local
= iface
->local
;
483 /* Get the current AP density */
484 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFSYSTEMSCALE
, &val
, 2, 1) <
488 sens
->value
= le16_to_cpu(val
);
495 /* Deprecated in new wireless extension API */
496 static int prism2_ioctl_giwaplist(struct net_device
*dev
,
497 struct iw_request_info
*info
,
498 struct iw_point
*data
, char *extra
)
500 struct hostap_interface
*iface
;
502 struct sockaddr
*addr
;
503 struct iw_quality
*qual
;
505 iface
= netdev_priv(dev
);
506 local
= iface
->local
;
508 if (local
->iw_mode
!= IW_MODE_MASTER
) {
509 printk(KERN_DEBUG
"SIOCGIWAPLIST is currently only supported "
510 "in Host AP mode\n");
515 addr
= kmalloc(sizeof(struct sockaddr
) * IW_MAX_AP
, GFP_KERNEL
);
516 qual
= kmalloc(sizeof(struct iw_quality
) * IW_MAX_AP
, GFP_KERNEL
);
517 if (addr
== NULL
|| qual
== NULL
) {
524 data
->length
= prism2_ap_get_sta_qual(local
, addr
, qual
, IW_MAX_AP
, 1);
526 memcpy(extra
, &addr
, sizeof(struct sockaddr
) * data
->length
);
527 data
->flags
= 1; /* has quality information */
528 memcpy(extra
+ sizeof(struct sockaddr
) * data
->length
, &qual
,
529 sizeof(struct iw_quality
) * data
->length
);
537 static int prism2_ioctl_siwrts(struct net_device
*dev
,
538 struct iw_request_info
*info
,
539 struct iw_param
*rts
, char *extra
)
541 struct hostap_interface
*iface
;
545 iface
= netdev_priv(dev
);
546 local
= iface
->local
;
549 val
= cpu_to_le16(2347);
550 else if (rts
->value
< 0 || rts
->value
> 2347)
553 val
= cpu_to_le16(rts
->value
);
555 if (local
->func
->set_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2) ||
556 local
->func
->reset_port(dev
))
559 local
->rts_threshold
= rts
->value
;
564 static int prism2_ioctl_giwrts(struct net_device
*dev
,
565 struct iw_request_info
*info
,
566 struct iw_param
*rts
, char *extra
)
568 struct hostap_interface
*iface
;
572 iface
= netdev_priv(dev
);
573 local
= iface
->local
;
575 if (local
->func
->get_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2, 1) <
579 rts
->value
= le16_to_cpu(val
);
580 rts
->disabled
= (rts
->value
== 2347);
587 static int prism2_ioctl_siwfrag(struct net_device
*dev
,
588 struct iw_request_info
*info
,
589 struct iw_param
*rts
, char *extra
)
591 struct hostap_interface
*iface
;
595 iface
= netdev_priv(dev
);
596 local
= iface
->local
;
599 val
= cpu_to_le16(2346);
600 else if (rts
->value
< 256 || rts
->value
> 2346)
603 val
= cpu_to_le16(rts
->value
& ~0x1); /* even numbers only */
605 local
->fragm_threshold
= rts
->value
& ~0x1;
606 if (local
->func
->set_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
, &val
,
608 || local
->func
->reset_port(dev
))
614 static int prism2_ioctl_giwfrag(struct net_device
*dev
,
615 struct iw_request_info
*info
,
616 struct iw_param
*rts
, char *extra
)
618 struct hostap_interface
*iface
;
622 iface
= netdev_priv(dev
);
623 local
= iface
->local
;
625 if (local
->func
->get_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
,
629 rts
->value
= le16_to_cpu(val
);
630 rts
->disabled
= (rts
->value
== 2346);
637 #ifndef PRISM2_NO_STATION_MODES
638 static int hostap_join_ap(struct net_device
*dev
)
640 struct hostap_interface
*iface
;
642 struct hfa384x_join_request req
;
645 struct hfa384x_hostscan_result
*entry
;
647 iface
= netdev_priv(dev
);
648 local
= iface
->local
;
650 memcpy(req
.bssid
, local
->preferred_ap
, ETH_ALEN
);
653 spin_lock_irqsave(&local
->lock
, flags
);
654 for (i
= 0; i
< local
->last_scan_results_count
; i
++) {
655 if (!local
->last_scan_results
)
657 entry
= &local
->last_scan_results
[i
];
658 if (memcmp(local
->preferred_ap
, entry
->bssid
, ETH_ALEN
) == 0) {
659 req
.channel
= entry
->chid
;
663 spin_unlock_irqrestore(&local
->lock
, flags
);
665 if (local
->func
->set_rid(dev
, HFA384X_RID_JOINREQUEST
, &req
,
667 printk(KERN_DEBUG
"%s: JoinRequest %pM failed\n",
668 dev
->name
, local
->preferred_ap
);
672 printk(KERN_DEBUG
"%s: Trying to join BSSID %pM\n",
673 dev
->name
, local
->preferred_ap
);
677 #endif /* PRISM2_NO_STATION_MODES */
680 static int prism2_ioctl_siwap(struct net_device
*dev
,
681 struct iw_request_info
*info
,
682 struct sockaddr
*ap_addr
, char *extra
)
684 #ifdef PRISM2_NO_STATION_MODES
686 #else /* PRISM2_NO_STATION_MODES */
687 struct hostap_interface
*iface
;
690 iface
= netdev_priv(dev
);
691 local
= iface
->local
;
693 memcpy(local
->preferred_ap
, &ap_addr
->sa_data
, ETH_ALEN
);
695 if (local
->host_roaming
== 1 && local
->iw_mode
== IW_MODE_INFRA
) {
696 struct hfa384x_scan_request scan_req
;
697 memset(&scan_req
, 0, sizeof(scan_req
));
698 scan_req
.channel_list
= cpu_to_le16(0x3fff);
699 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
700 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
,
701 &scan_req
, sizeof(scan_req
))) {
702 printk(KERN_DEBUG
"%s: ScanResults request failed - "
703 "preferred AP delayed to next unsolicited "
704 "scan\n", dev
->name
);
706 } else if (local
->host_roaming
== 2 &&
707 local
->iw_mode
== IW_MODE_INFRA
) {
708 if (hostap_join_ap(dev
))
711 printk(KERN_DEBUG
"%s: Preferred AP (SIOCSIWAP) is used only "
712 "in Managed mode when host_roaming is enabled\n",
717 #endif /* PRISM2_NO_STATION_MODES */
720 static int prism2_ioctl_giwap(struct net_device
*dev
,
721 struct iw_request_info
*info
,
722 struct sockaddr
*ap_addr
, char *extra
)
724 struct hostap_interface
*iface
;
727 iface
= netdev_priv(dev
);
728 local
= iface
->local
;
730 ap_addr
->sa_family
= ARPHRD_ETHER
;
731 switch (iface
->type
) {
732 case HOSTAP_INTERFACE_AP
:
733 memcpy(&ap_addr
->sa_data
, dev
->dev_addr
, ETH_ALEN
);
735 case HOSTAP_INTERFACE_STA
:
736 memcpy(&ap_addr
->sa_data
, local
->assoc_ap_addr
, ETH_ALEN
);
738 case HOSTAP_INTERFACE_WDS
:
739 memcpy(&ap_addr
->sa_data
, iface
->u
.wds
.remote_addr
, ETH_ALEN
);
742 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTBSSID
,
743 &ap_addr
->sa_data
, ETH_ALEN
, 1) < 0)
746 /* local->bssid is also updated in LinkStatus handler when in
748 memcpy(local
->bssid
, &ap_addr
->sa_data
, ETH_ALEN
);
756 static int prism2_ioctl_siwnickn(struct net_device
*dev
,
757 struct iw_request_info
*info
,
758 struct iw_point
*data
, char *nickname
)
760 struct hostap_interface
*iface
;
763 iface
= netdev_priv(dev
);
764 local
= iface
->local
;
766 memset(local
->name
, 0, sizeof(local
->name
));
767 memcpy(local
->name
, nickname
, data
->length
);
770 if (hostap_set_string(dev
, HFA384X_RID_CNFOWNNAME
, local
->name
) ||
771 local
->func
->reset_port(dev
))
777 static int prism2_ioctl_giwnickn(struct net_device
*dev
,
778 struct iw_request_info
*info
,
779 struct iw_point
*data
, char *nickname
)
781 struct hostap_interface
*iface
;
784 char name
[MAX_NAME_LEN
+ 3];
787 iface
= netdev_priv(dev
);
788 local
= iface
->local
;
790 len
= local
->func
->get_rid(dev
, HFA384X_RID_CNFOWNNAME
,
791 &name
, MAX_NAME_LEN
+ 2, 0);
792 val
= le16_to_cpu(*(__le16
*) name
);
793 if (len
> MAX_NAME_LEN
+ 2 || len
< 0 || val
> MAX_NAME_LEN
)
796 name
[val
+ 2] = '\0';
797 data
->length
= val
+ 1;
798 memcpy(nickname
, name
+ 2, val
+ 1);
804 static int prism2_ioctl_siwfreq(struct net_device
*dev
,
805 struct iw_request_info
*info
,
806 struct iw_freq
*freq
, char *extra
)
808 struct hostap_interface
*iface
;
811 iface
= netdev_priv(dev
);
812 local
= iface
->local
;
816 freq
->m
/ 100000 >= freq_list
[0] &&
817 freq
->m
/ 100000 <= freq_list
[FREQ_COUNT
- 1]) {
819 int fr
= freq
->m
/ 100000;
820 for (ch
= 0; ch
< FREQ_COUNT
; ch
++) {
821 if (fr
== freq_list
[ch
]) {
829 if (freq
->e
!= 0 || freq
->m
< 1 || freq
->m
> FREQ_COUNT
||
830 !(local
->channel_mask
& (1 << (freq
->m
- 1))))
833 local
->channel
= freq
->m
; /* channel is used in prism2_setup_rids() */
834 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNCHANNEL
, local
->channel
) ||
835 local
->func
->reset_port(dev
))
841 static int prism2_ioctl_giwfreq(struct net_device
*dev
,
842 struct iw_request_info
*info
,
843 struct iw_freq
*freq
, char *extra
)
845 struct hostap_interface
*iface
;
849 iface
= netdev_priv(dev
);
850 local
= iface
->local
;
852 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTCHANNEL
, &val
, 2, 1) <
857 if (val
< 1 || val
> FREQ_COUNT
)
860 freq
->m
= freq_list
[val
- 1] * 100000;
867 static void hostap_monitor_set_type(local_info_t
*local
)
869 struct net_device
*dev
= local
->ddev
;
874 if (local
->monitor_type
== PRISM2_MONITOR_PRISM
||
875 local
->monitor_type
== PRISM2_MONITOR_CAPHDR
) {
876 dev
->type
= ARPHRD_IEEE80211_PRISM
;
877 } else if (local
->monitor_type
== PRISM2_MONITOR_RADIOTAP
) {
878 dev
->type
= ARPHRD_IEEE80211_RADIOTAP
;
880 dev
->type
= ARPHRD_IEEE80211
;
885 static int prism2_ioctl_siwessid(struct net_device
*dev
,
886 struct iw_request_info
*info
,
887 struct iw_point
*data
, char *ssid
)
889 struct hostap_interface
*iface
;
892 iface
= netdev_priv(dev
);
893 local
= iface
->local
;
895 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
898 if (data
->flags
== 0)
899 ssid
[0] = '\0'; /* ANY */
901 if (local
->iw_mode
== IW_MODE_MASTER
&& ssid
[0] == '\0') {
902 /* Setting SSID to empty string seems to kill the card in
904 printk(KERN_DEBUG
"%s: Host AP mode does not support "
905 "'Any' essid\n", dev
->name
);
909 memcpy(local
->essid
, ssid
, data
->length
);
910 local
->essid
[data
->length
] = '\0';
912 if ((!local
->fw_ap
&&
913 hostap_set_string(dev
, HFA384X_RID_CNFDESIREDSSID
, local
->essid
))
914 || hostap_set_string(dev
, HFA384X_RID_CNFOWNSSID
, local
->essid
) ||
915 local
->func
->reset_port(dev
))
921 static int prism2_ioctl_giwessid(struct net_device
*dev
,
922 struct iw_request_info
*info
,
923 struct iw_point
*data
, char *essid
)
925 struct hostap_interface
*iface
;
929 iface
= netdev_priv(dev
);
930 local
= iface
->local
;
932 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
935 data
->flags
= 1; /* active */
936 if (local
->iw_mode
== IW_MODE_MASTER
) {
937 data
->length
= strlen(local
->essid
);
938 memcpy(essid
, local
->essid
, IW_ESSID_MAX_SIZE
);
941 char ssid
[MAX_SSID_LEN
+ 2];
942 memset(ssid
, 0, sizeof(ssid
));
943 len
= local
->func
->get_rid(dev
, HFA384X_RID_CURRENTSSID
,
944 &ssid
, MAX_SSID_LEN
+ 2, 0);
945 val
= le16_to_cpu(*(__le16
*) ssid
);
946 if (len
> MAX_SSID_LEN
+ 2 || len
< 0 || val
> MAX_SSID_LEN
) {
950 memcpy(essid
, ssid
+ 2, IW_ESSID_MAX_SIZE
);
957 static int prism2_ioctl_giwrange(struct net_device
*dev
,
958 struct iw_request_info
*info
,
959 struct iw_point
*data
, char *extra
)
961 struct hostap_interface
*iface
;
963 struct iw_range
*range
= (struct iw_range
*) extra
;
968 iface
= netdev_priv(dev
);
969 local
= iface
->local
;
971 data
->length
= sizeof(struct iw_range
);
972 memset(range
, 0, sizeof(struct iw_range
));
974 /* TODO: could fill num_txpower and txpower array with
975 * something; however, there are 128 different values.. */
977 range
->txpower_capa
= IW_TXPOW_DBM
;
979 if (local
->iw_mode
== IW_MODE_INFRA
|| local
->iw_mode
== IW_MODE_ADHOC
)
981 range
->min_pmp
= 1 * 1024;
982 range
->max_pmp
= 65535 * 1024;
983 range
->min_pmt
= 1 * 1024;
984 range
->max_pmt
= 1000 * 1024;
985 range
->pmp_flags
= IW_POWER_PERIOD
;
986 range
->pmt_flags
= IW_POWER_TIMEOUT
;
987 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
|
988 IW_POWER_UNICAST_R
| IW_POWER_ALL_R
;
991 range
->we_version_compiled
= WIRELESS_EXT
;
992 range
->we_version_source
= 18;
994 range
->retry_capa
= IW_RETRY_LIMIT
;
995 range
->retry_flags
= IW_RETRY_LIMIT
;
996 range
->min_retry
= 0;
997 range
->max_retry
= 255;
999 range
->num_channels
= FREQ_COUNT
;
1002 for (i
= 0; i
< FREQ_COUNT
; i
++) {
1003 if (local
->channel_mask
& (1 << i
)) {
1004 range
->freq
[val
].i
= i
+ 1;
1005 range
->freq
[val
].m
= freq_list
[i
] * 100000;
1006 range
->freq
[val
].e
= 1;
1009 if (val
== IW_MAX_FREQUENCIES
)
1012 range
->num_frequency
= val
;
1014 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1)) {
1015 range
->max_qual
.qual
= 70; /* what is correct max? This was not
1016 * documented exactly. At least
1017 * 69 has been observed. */
1018 range
->max_qual
.level
= 0; /* dB */
1019 range
->max_qual
.noise
= 0; /* dB */
1021 /* What would be suitable values for "average/typical" qual? */
1022 range
->avg_qual
.qual
= 20;
1023 range
->avg_qual
.level
= -60;
1024 range
->avg_qual
.noise
= -95;
1026 range
->max_qual
.qual
= 92; /* 0 .. 92 */
1027 range
->max_qual
.level
= 154; /* 27 .. 154 */
1028 range
->max_qual
.noise
= 154; /* 27 .. 154 */
1030 range
->sensitivity
= 3;
1032 range
->max_encoding_tokens
= WEP_KEYS
;
1033 range
->num_encoding_sizes
= 2;
1034 range
->encoding_size
[0] = 5;
1035 range
->encoding_size
[1] = 13;
1038 len
= prism2_get_datarates(dev
, rates
);
1039 range
->num_bitrates
= 0;
1040 for (i
= 0; i
< len
; i
++) {
1041 if (range
->num_bitrates
< IW_MAX_BITRATES
) {
1042 range
->bitrate
[range
->num_bitrates
] =
1044 range
->num_bitrates
++;
1046 if (rates
[i
] == 0x0b || rates
[i
] == 0x16)
1049 /* estimated maximum TCP throughput values (bps) */
1050 range
->throughput
= over2
? 5500000 : 1500000;
1053 range
->max_rts
= 2347;
1054 range
->min_frag
= 256;
1055 range
->max_frag
= 2346;
1057 /* Event capability (kernel + driver) */
1058 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
1059 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY
) |
1060 IW_EVENT_CAPA_MASK(SIOCGIWAP
) |
1061 IW_EVENT_CAPA_MASK(SIOCGIWSCAN
));
1062 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
1063 range
->event_capa
[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP
) |
1064 IW_EVENT_CAPA_MASK(IWEVCUSTOM
) |
1065 IW_EVENT_CAPA_MASK(IWEVREGISTERED
) |
1066 IW_EVENT_CAPA_MASK(IWEVEXPIRED
));
1068 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
1069 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
1071 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1072 range
->scan_capa
= IW_SCAN_CAPA_ESSID
;
1078 static int hostap_monitor_mode_enable(local_info_t
*local
)
1080 struct net_device
*dev
= local
->dev
;
1082 printk(KERN_DEBUG
"Enabling monitor mode\n");
1083 hostap_monitor_set_type(local
);
1085 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1086 HFA384X_PORTTYPE_PSEUDO_IBSS
)) {
1087 printk(KERN_DEBUG
"Port type setting for monitor mode "
1092 /* Host decrypt is needed to get the IV and ICV fields;
1093 * however, monitor mode seems to remove WEP flag from frame
1095 if (hostap_set_word(dev
, HFA384X_RID_CNFWEPFLAGS
,
1096 HFA384X_WEPFLAGS_HOSTENCRYPT
|
1097 HFA384X_WEPFLAGS_HOSTDECRYPT
)) {
1098 printk(KERN_DEBUG
"WEP flags setting failed\n");
1102 if (local
->func
->reset_port(dev
) ||
1103 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1104 (HFA384X_TEST_MONITOR
<< 8),
1106 printk(KERN_DEBUG
"Setting monitor mode failed\n");
1114 static int hostap_monitor_mode_disable(local_info_t
*local
)
1116 struct net_device
*dev
= local
->ddev
;
1121 printk(KERN_DEBUG
"%s: Disabling monitor mode\n", dev
->name
);
1122 dev
->type
= ARPHRD_ETHER
;
1124 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1125 (HFA384X_TEST_STOP
<< 8),
1128 return hostap_set_encryption(local
);
1132 static int prism2_ioctl_siwmode(struct net_device
*dev
,
1133 struct iw_request_info
*info
,
1134 __u32
*mode
, char *extra
)
1136 struct hostap_interface
*iface
;
1137 local_info_t
*local
;
1138 int double_reset
= 0;
1140 iface
= netdev_priv(dev
);
1141 local
= iface
->local
;
1143 if (*mode
!= IW_MODE_ADHOC
&& *mode
!= IW_MODE_INFRA
&&
1144 *mode
!= IW_MODE_MASTER
&& *mode
!= IW_MODE_REPEAT
&&
1145 *mode
!= IW_MODE_MONITOR
)
1148 #ifdef PRISM2_NO_STATION_MODES
1149 if (*mode
== IW_MODE_ADHOC
|| *mode
== IW_MODE_INFRA
)
1151 #endif /* PRISM2_NO_STATION_MODES */
1153 if (*mode
== local
->iw_mode
)
1156 if (*mode
== IW_MODE_MASTER
&& local
->essid
[0] == '\0') {
1157 printk(KERN_WARNING
"%s: empty SSID not allowed in Master "
1158 "mode\n", dev
->name
);
1162 if (local
->iw_mode
== IW_MODE_MONITOR
)
1163 hostap_monitor_mode_disable(local
);
1165 if ((local
->iw_mode
== IW_MODE_ADHOC
||
1166 local
->iw_mode
== IW_MODE_MONITOR
) && *mode
== IW_MODE_MASTER
) {
1167 /* There seems to be a firmware bug in at least STA f/w v1.5.6
1168 * that leaves beacon frames to use IBSS type when moving from
1169 * IBSS to Host AP mode. Doing double Port0 reset seems to be
1170 * enough to workaround this. */
1174 printk(KERN_DEBUG
"prism2: %s: operating mode changed "
1175 "%d -> %d\n", dev
->name
, local
->iw_mode
, *mode
);
1176 local
->iw_mode
= *mode
;
1178 if (local
->iw_mode
== IW_MODE_MONITOR
)
1179 hostap_monitor_mode_enable(local
);
1180 else if (local
->iw_mode
== IW_MODE_MASTER
&& !local
->host_encrypt
&&
1181 !local
->fw_encrypt_ok
) {
1182 printk(KERN_DEBUG
"%s: defaulting to host-based encryption as "
1183 "a workaround for firmware bug in Host AP mode WEP\n",
1185 local
->host_encrypt
= 1;
1188 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1189 hostap_get_porttype(local
)))
1192 if (local
->func
->reset_port(dev
))
1194 if (double_reset
&& local
->func
->reset_port(dev
))
1197 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->iw_mode
!= IW_MODE_ADHOC
)
1199 /* netif_carrier is used only in client modes for now, so make
1200 * sure carrier is on when moving to non-client modes. */
1201 netif_carrier_on(local
->dev
);
1202 netif_carrier_on(local
->ddev
);
1208 static int prism2_ioctl_giwmode(struct net_device
*dev
,
1209 struct iw_request_info
*info
,
1210 __u32
*mode
, char *extra
)
1212 struct hostap_interface
*iface
;
1213 local_info_t
*local
;
1215 iface
= netdev_priv(dev
);
1216 local
= iface
->local
;
1218 switch (iface
->type
) {
1219 case HOSTAP_INTERFACE_STA
:
1220 *mode
= IW_MODE_INFRA
;
1222 case HOSTAP_INTERFACE_WDS
:
1223 *mode
= IW_MODE_REPEAT
;
1226 *mode
= local
->iw_mode
;
1233 static int prism2_ioctl_siwpower(struct net_device
*dev
,
1234 struct iw_request_info
*info
,
1235 struct iw_param
*wrq
, char *extra
)
1237 #ifdef PRISM2_NO_STATION_MODES
1239 #else /* PRISM2_NO_STATION_MODES */
1243 return hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 0);
1245 switch (wrq
->flags
& IW_POWER_MODE
) {
1246 case IW_POWER_UNICAST_R
:
1247 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 0);
1250 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1254 case IW_POWER_ALL_R
:
1255 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 1);
1258 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1268 if (wrq
->flags
& IW_POWER_TIMEOUT
) {
1269 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1272 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMHOLDOVERDURATION
,
1277 if (wrq
->flags
& IW_POWER_PERIOD
) {
1278 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1281 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1288 #endif /* PRISM2_NO_STATION_MODES */
1292 static int prism2_ioctl_giwpower(struct net_device
*dev
,
1293 struct iw_request_info
*info
,
1294 struct iw_param
*rrq
, char *extra
)
1296 #ifdef PRISM2_NO_STATION_MODES
1298 #else /* PRISM2_NO_STATION_MODES */
1299 struct hostap_interface
*iface
;
1300 local_info_t
*local
;
1301 __le16 enable
, mcast
;
1303 iface
= netdev_priv(dev
);
1304 local
= iface
->local
;
1306 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFPMENABLED
, &enable
, 2, 1)
1310 if (!le16_to_cpu(enable
)) {
1317 if ((rrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1319 if (local
->func
->get_rid(dev
,
1320 HFA384X_RID_CNFPMHOLDOVERDURATION
,
1321 &timeout
, 2, 1) < 0)
1324 rrq
->flags
= IW_POWER_TIMEOUT
;
1325 rrq
->value
= le16_to_cpu(timeout
) * 1024;
1328 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1332 rrq
->flags
= IW_POWER_PERIOD
;
1333 rrq
->value
= le16_to_cpu(period
) * 1024;
1336 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, &mcast
,
1340 if (le16_to_cpu(mcast
))
1341 rrq
->flags
|= IW_POWER_ALL_R
;
1343 rrq
->flags
|= IW_POWER_UNICAST_R
;
1346 #endif /* PRISM2_NO_STATION_MODES */
1350 static int prism2_ioctl_siwretry(struct net_device
*dev
,
1351 struct iw_request_info
*info
,
1352 struct iw_param
*rrq
, char *extra
)
1354 struct hostap_interface
*iface
;
1355 local_info_t
*local
;
1357 iface
= netdev_priv(dev
);
1358 local
= iface
->local
;
1363 /* setting retry limits is not supported with the current station
1364 * firmware code; simulate this with alternative retry count for now */
1365 if (rrq
->flags
== IW_RETRY_LIMIT
) {
1366 if (rrq
->value
< 0) {
1367 /* disable manual retry count setting and use firmware
1369 local
->manual_retry_count
= -1;
1370 local
->tx_control
&= ~HFA384X_TX_CTRL_ALT_RTRY
;
1372 if (hostap_set_word(dev
, HFA384X_RID_CNFALTRETRYCOUNT
,
1374 printk(KERN_DEBUG
"%s: Alternate retry count "
1375 "setting to %d failed\n",
1376 dev
->name
, rrq
->value
);
1380 local
->manual_retry_count
= rrq
->value
;
1381 local
->tx_control
|= HFA384X_TX_CTRL_ALT_RTRY
;
1389 /* what could be done, if firmware would support this.. */
1391 if (rrq
->flags
& IW_RETRY_LIMIT
) {
1392 if (rrq
->flags
& IW_RETRY_LONG
)
1393 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1394 else if (rrq
->flags
& IW_RETRY_SHORT
)
1395 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1397 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1398 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1403 if (rrq
->flags
& IW_RETRY_LIFETIME
) {
1404 HFA384X_RID_MAXTRANSMITLIFETIME
= rrq
->value
/ 1024;
1411 static int prism2_ioctl_giwretry(struct net_device
*dev
,
1412 struct iw_request_info
*info
,
1413 struct iw_param
*rrq
, char *extra
)
1415 struct hostap_interface
*iface
;
1416 local_info_t
*local
;
1417 __le16 shortretry
, longretry
, lifetime
, altretry
;
1419 iface
= netdev_priv(dev
);
1420 local
= iface
->local
;
1422 if (local
->func
->get_rid(dev
, HFA384X_RID_SHORTRETRYLIMIT
, &shortretry
,
1424 local
->func
->get_rid(dev
, HFA384X_RID_LONGRETRYLIMIT
, &longretry
,
1426 local
->func
->get_rid(dev
, HFA384X_RID_MAXTRANSMITLIFETIME
,
1427 &lifetime
, 2, 1) < 0)
1432 if ((rrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1433 rrq
->flags
= IW_RETRY_LIFETIME
;
1434 rrq
->value
= le16_to_cpu(lifetime
) * 1024;
1436 if (local
->manual_retry_count
>= 0) {
1437 rrq
->flags
= IW_RETRY_LIMIT
;
1438 if (local
->func
->get_rid(dev
,
1439 HFA384X_RID_CNFALTRETRYCOUNT
,
1440 &altretry
, 2, 1) >= 0)
1441 rrq
->value
= le16_to_cpu(altretry
);
1443 rrq
->value
= local
->manual_retry_count
;
1444 } else if ((rrq
->flags
& IW_RETRY_LONG
)) {
1445 rrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
1446 rrq
->value
= le16_to_cpu(longretry
);
1448 rrq
->flags
= IW_RETRY_LIMIT
;
1449 rrq
->value
= le16_to_cpu(shortretry
);
1450 if (shortretry
!= longretry
)
1451 rrq
->flags
|= IW_RETRY_SHORT
;
1458 /* Note! This TX power controlling is experimental and should not be used in
1459 * production use. It just sets raw power register and does not use any kind of
1460 * feedback information from the measured TX power (CR58). This is now
1461 * commented out to make sure that it is not used by accident. TX power
1462 * configuration will be enabled again after proper algorithm using feedback
1463 * has been implemented. */
1465 #ifdef RAW_TXPOWER_SETTING
1466 /* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping..
1467 * This version assumes following mapping:
1468 * CR31 is 7-bit value with -64 to +63 range.
1469 * -64 is mapped into +20dBm and +63 into -43dBm.
1470 * This is certainly not an exact mapping for every card, but at least
1471 * increasing dBm value should correspond to increasing TX power.
1474 static int prism2_txpower_hfa386x_to_dBm(u16 val
)
1487 static u16
prism2_txpower_dBm_to_hfa386x(int val
)
1500 return (unsigned char) tmp
;
1502 #endif /* RAW_TXPOWER_SETTING */
1505 static int prism2_ioctl_siwtxpow(struct net_device
*dev
,
1506 struct iw_request_info
*info
,
1507 struct iw_param
*rrq
, char *extra
)
1509 struct hostap_interface
*iface
;
1510 local_info_t
*local
;
1511 #ifdef RAW_TXPOWER_SETTING
1517 iface
= netdev_priv(dev
);
1518 local
= iface
->local
;
1520 if (rrq
->disabled
) {
1521 if (local
->txpower_type
!= PRISM2_TXPOWER_OFF
) {
1522 val
= 0xff; /* use all standby and sleep modes */
1523 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1524 HFA386X_CR_A_D_TEST_MODES2
,
1526 printk(KERN_DEBUG
"%s: Turning radio off: %s\n",
1527 dev
->name
, ret
? "failed" : "OK");
1528 local
->txpower_type
= PRISM2_TXPOWER_OFF
;
1530 return (ret
? -EOPNOTSUPP
: 0);
1533 if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1534 val
= 0; /* disable all standby and sleep modes */
1535 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1536 HFA386X_CR_A_D_TEST_MODES2
, &val
, NULL
);
1537 printk(KERN_DEBUG
"%s: Turning radio on: %s\n",
1538 dev
->name
, ret
? "failed" : "OK");
1539 local
->txpower_type
= PRISM2_TXPOWER_UNKNOWN
;
1542 #ifdef RAW_TXPOWER_SETTING
1543 if (!rrq
->fixed
&& local
->txpower_type
!= PRISM2_TXPOWER_AUTO
) {
1544 printk(KERN_DEBUG
"Setting ALC on\n");
1545 val
= HFA384X_TEST_CFG_BIT_ALC
;
1546 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1547 (HFA384X_TEST_CFG_BITS
<< 8), 1, &val
, NULL
);
1548 local
->txpower_type
= PRISM2_TXPOWER_AUTO
;
1552 if (local
->txpower_type
!= PRISM2_TXPOWER_FIXED
) {
1553 printk(KERN_DEBUG
"Setting ALC off\n");
1554 val
= HFA384X_TEST_CFG_BIT_ALC
;
1555 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1556 (HFA384X_TEST_CFG_BITS
<< 8), 0, &val
, NULL
);
1557 local
->txpower_type
= PRISM2_TXPOWER_FIXED
;
1560 if (rrq
->flags
== IW_TXPOW_DBM
)
1562 else if (rrq
->flags
== IW_TXPOW_MWATT
)
1566 printk(KERN_DEBUG
"Setting TX power to %d %s\n", rrq
->value
, tmp
);
1568 if (rrq
->flags
!= IW_TXPOW_DBM
) {
1569 printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
1573 local
->txpower
= rrq
->value
;
1574 val
= prism2_txpower_dBm_to_hfa386x(local
->txpower
);
1575 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1576 HFA386X_CR_MANUAL_TX_POWER
, &val
, NULL
))
1578 #else /* RAW_TXPOWER_SETTING */
1581 #endif /* RAW_TXPOWER_SETTING */
1586 static int prism2_ioctl_giwtxpow(struct net_device
*dev
,
1587 struct iw_request_info
*info
,
1588 struct iw_param
*rrq
, char *extra
)
1590 #ifdef RAW_TXPOWER_SETTING
1591 struct hostap_interface
*iface
;
1592 local_info_t
*local
;
1595 iface
= netdev_priv(dev
);
1596 local
= iface
->local
;
1598 rrq
->flags
= IW_TXPOW_DBM
;
1602 if (local
->txpower_type
== PRISM2_TXPOWER_AUTO
) {
1603 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
,
1604 HFA386X_CR_MANUAL_TX_POWER
,
1605 NULL
, &resp0
) == 0) {
1606 rrq
->value
= prism2_txpower_hfa386x_to_dBm(resp0
);
1608 /* Could not get real txpower; guess 15 dBm */
1611 } else if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1614 } else if (local
->txpower_type
== PRISM2_TXPOWER_FIXED
) {
1615 rrq
->value
= local
->txpower
;
1618 printk("SIOCGIWTXPOW - unknown txpower_type=%d\n",
1619 local
->txpower_type
);
1622 #else /* RAW_TXPOWER_SETTING */
1624 #endif /* RAW_TXPOWER_SETTING */
1628 #ifndef PRISM2_NO_STATION_MODES
1630 /* HostScan request works with and without host_roaming mode. In addition, it
1631 * does not break current association. However, it requires newer station
1632 * firmware version (>= 1.3.1) than scan request. */
1633 static int prism2_request_hostscan(struct net_device
*dev
,
1634 u8
*ssid
, u8 ssid_len
)
1636 struct hostap_interface
*iface
;
1637 local_info_t
*local
;
1638 struct hfa384x_hostscan_request scan_req
;
1640 iface
= netdev_priv(dev
);
1641 local
= iface
->local
;
1643 memset(&scan_req
, 0, sizeof(scan_req
));
1644 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1645 local
->scan_channel_mask
);
1646 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1650 scan_req
.target_ssid_len
= cpu_to_le16(ssid_len
);
1651 memcpy(scan_req
.target_ssid
, ssid
, ssid_len
);
1654 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
1655 sizeof(scan_req
))) {
1656 printk(KERN_DEBUG
"%s: HOSTSCAN failed\n", dev
->name
);
1663 static int prism2_request_scan(struct net_device
*dev
)
1665 struct hostap_interface
*iface
;
1666 local_info_t
*local
;
1667 struct hfa384x_scan_request scan_req
;
1670 iface
= netdev_priv(dev
);
1671 local
= iface
->local
;
1673 memset(&scan_req
, 0, sizeof(scan_req
));
1674 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1675 local
->scan_channel_mask
);
1676 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1679 * It seems to be enough to set roaming mode for a short moment to
1680 * host-based and then setup scanrequest data and return the mode to
1683 * Master mode would need to drop to Managed mode for a short while
1684 * to make scanning work.. Or sweep through the different channels and
1685 * use passive scan based on beacons. */
1687 if (!local
->host_roaming
)
1688 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1689 HFA384X_ROAMING_HOST
);
1691 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
, &scan_req
,
1692 sizeof(scan_req
))) {
1693 printk(KERN_DEBUG
"SCANREQUEST failed\n");
1697 if (!local
->host_roaming
)
1698 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1699 HFA384X_ROAMING_FIRMWARE
);
1704 #else /* !PRISM2_NO_STATION_MODES */
1706 static inline int prism2_request_hostscan(struct net_device
*dev
,
1707 u8
*ssid
, u8 ssid_len
)
1713 static inline int prism2_request_scan(struct net_device
*dev
)
1718 #endif /* !PRISM2_NO_STATION_MODES */
1721 static int prism2_ioctl_siwscan(struct net_device
*dev
,
1722 struct iw_request_info
*info
,
1723 struct iw_point
*data
, char *extra
)
1725 struct hostap_interface
*iface
;
1726 local_info_t
*local
;
1728 u8
*ssid
= NULL
, ssid_len
= 0;
1729 struct iw_scan_req
*req
= (struct iw_scan_req
*) extra
;
1731 iface
= netdev_priv(dev
);
1732 local
= iface
->local
;
1734 if (data
->length
< sizeof(struct iw_scan_req
))
1737 if (local
->iw_mode
== IW_MODE_MASTER
) {
1738 /* In master mode, we just return the results of our local
1739 * tables, so we don't need to start anything...
1745 if (!local
->dev_enabled
)
1748 if (req
&& data
->flags
& IW_SCAN_THIS_ESSID
) {
1750 ssid_len
= req
->essid_len
;
1753 ((local
->iw_mode
!= IW_MODE_INFRA
&&
1754 local
->iw_mode
!= IW_MODE_ADHOC
) ||
1755 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1))))
1759 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1760 ret
= prism2_request_hostscan(dev
, ssid
, ssid_len
);
1762 ret
= prism2_request_scan(dev
);
1765 local
->scan_timestamp
= jiffies
;
1767 /* Could inquire F101, F103 or wait for SIOCGIWSCAN and read RID */
1773 #ifndef PRISM2_NO_STATION_MODES
1774 static char * __prism2_translate_scan(local_info_t
*local
,
1775 struct iw_request_info
*info
,
1776 struct hfa384x_hostscan_result
*scan
,
1777 struct hostap_bss_info
*bss
,
1778 char *current_ev
, char *end_buf
)
1781 struct iw_event iwe
;
1791 ssid_len
= bss
->ssid_len
;
1795 ssid_len
= le16_to_cpu(scan
->ssid_len
);
1796 bssid
= scan
->bssid
;
1801 /* First entry *MUST* be the AP MAC address */
1802 memset(&iwe
, 0, sizeof(iwe
));
1803 iwe
.cmd
= SIOCGIWAP
;
1804 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1805 memcpy(iwe
.u
.ap_addr
.sa_data
, bssid
, ETH_ALEN
);
1806 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
, &iwe
,
1809 /* Other entries will be displayed in the order we give them */
1811 memset(&iwe
, 0, sizeof(iwe
));
1812 iwe
.cmd
= SIOCGIWESSID
;
1813 iwe
.u
.data
.length
= ssid_len
;
1814 iwe
.u
.data
.flags
= 1;
1815 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1818 memset(&iwe
, 0, sizeof(iwe
));
1819 iwe
.cmd
= SIOCGIWMODE
;
1821 capabilities
= bss
->capab_info
;
1823 capabilities
= le16_to_cpu(scan
->capability
);
1825 if (capabilities
& (WLAN_CAPABILITY_ESS
|
1826 WLAN_CAPABILITY_IBSS
)) {
1827 if (capabilities
& WLAN_CAPABILITY_ESS
)
1828 iwe
.u
.mode
= IW_MODE_MASTER
;
1830 iwe
.u
.mode
= IW_MODE_ADHOC
;
1831 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1832 &iwe
, IW_EV_UINT_LEN
);
1835 memset(&iwe
, 0, sizeof(iwe
));
1836 iwe
.cmd
= SIOCGIWFREQ
;
1838 chan
= le16_to_cpu(scan
->chid
);
1846 iwe
.u
.freq
.m
= freq_list
[chan
- 1] * 100000;
1848 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1849 &iwe
, IW_EV_FREQ_LEN
);
1853 memset(&iwe
, 0, sizeof(iwe
));
1855 if (local
->last_scan_type
== PRISM2_HOSTSCAN
) {
1856 iwe
.u
.qual
.level
= le16_to_cpu(scan
->sl
);
1857 iwe
.u
.qual
.noise
= le16_to_cpu(scan
->anl
);
1860 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->sl
));
1862 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->anl
));
1864 iwe
.u
.qual
.updated
= IW_QUAL_LEVEL_UPDATED
1865 | IW_QUAL_NOISE_UPDATED
1866 | IW_QUAL_QUAL_INVALID
1868 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1869 &iwe
, IW_EV_QUAL_LEN
);
1872 memset(&iwe
, 0, sizeof(iwe
));
1873 iwe
.cmd
= SIOCGIWENCODE
;
1874 if (capabilities
& WLAN_CAPABILITY_PRIVACY
)
1875 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
1877 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
1878 iwe
.u
.data
.length
= 0;
1879 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
, &iwe
, "");
1881 /* TODO: add SuppRates into BSS table */
1883 memset(&iwe
, 0, sizeof(iwe
));
1884 iwe
.cmd
= SIOCGIWRATE
;
1885 current_val
= current_ev
+ iwe_stream_lcp_len(info
);
1886 pos
= scan
->sup_rates
;
1887 for (i
= 0; i
< sizeof(scan
->sup_rates
); i
++) {
1890 /* Bit rate given in 500 kb/s units (+ 0x80) */
1891 iwe
.u
.bitrate
.value
= ((pos
[i
] & 0x7f) * 500000);
1892 current_val
= iwe_stream_add_value(
1893 info
, current_ev
, current_val
, end_buf
, &iwe
,
1896 /* Check if we added any event */
1897 if ((current_val
- current_ev
) > iwe_stream_lcp_len(info
))
1898 current_ev
= current_val
;
1901 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
1902 buf
= kmalloc(MAX_WPA_IE_LEN
* 2 + 30, GFP_ATOMIC
);
1904 memset(&iwe
, 0, sizeof(iwe
));
1905 iwe
.cmd
= IWEVCUSTOM
;
1906 sprintf(buf
, "bcn_int=%d", le16_to_cpu(scan
->beacon_interval
));
1907 iwe
.u
.data
.length
= strlen(buf
);
1908 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1911 memset(&iwe
, 0, sizeof(iwe
));
1912 iwe
.cmd
= IWEVCUSTOM
;
1913 sprintf(buf
, "resp_rate=%d", le16_to_cpu(scan
->rate
));
1914 iwe
.u
.data
.length
= strlen(buf
);
1915 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1918 if (local
->last_scan_type
== PRISM2_HOSTSCAN
&&
1919 (capabilities
& WLAN_CAPABILITY_IBSS
)) {
1920 memset(&iwe
, 0, sizeof(iwe
));
1921 iwe
.cmd
= IWEVCUSTOM
;
1922 sprintf(buf
, "atim=%d", le16_to_cpu(scan
->atim
));
1923 iwe
.u
.data
.length
= strlen(buf
);
1924 current_ev
= iwe_stream_add_point(info
, current_ev
,
1925 end_buf
, &iwe
, buf
);
1930 if (bss
&& bss
->wpa_ie_len
> 0 && bss
->wpa_ie_len
<= MAX_WPA_IE_LEN
) {
1931 memset(&iwe
, 0, sizeof(iwe
));
1932 iwe
.cmd
= IWEVGENIE
;
1933 iwe
.u
.data
.length
= bss
->wpa_ie_len
;
1934 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1938 if (bss
&& bss
->rsn_ie_len
> 0 && bss
->rsn_ie_len
<= MAX_WPA_IE_LEN
) {
1939 memset(&iwe
, 0, sizeof(iwe
));
1940 iwe
.cmd
= IWEVGENIE
;
1941 iwe
.u
.data
.length
= bss
->rsn_ie_len
;
1942 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1950 /* Translate scan data returned from the card to a card independent
1951 * format that the Wireless Tools will understand - Jean II */
1952 static inline int prism2_translate_scan(local_info_t
*local
,
1953 struct iw_request_info
*info
,
1954 char *buffer
, int buflen
)
1956 struct hfa384x_hostscan_result
*scan
;
1957 int entry
, hostscan
;
1958 char *current_ev
= buffer
;
1959 char *end_buf
= buffer
+ buflen
;
1960 struct list_head
*ptr
;
1962 spin_lock_bh(&local
->lock
);
1964 list_for_each(ptr
, &local
->bss_list
) {
1965 struct hostap_bss_info
*bss
;
1966 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1970 hostscan
= local
->last_scan_type
== PRISM2_HOSTSCAN
;
1971 for (entry
= 0; entry
< local
->last_scan_results_count
; entry
++) {
1973 scan
= &local
->last_scan_results
[entry
];
1975 /* Report every SSID if the AP is using multiple SSIDs. If no
1976 * BSS record is found (e.g., when WPA mode is disabled),
1977 * report the AP once. */
1978 list_for_each(ptr
, &local
->bss_list
) {
1979 struct hostap_bss_info
*bss
;
1980 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1981 if (memcmp(bss
->bssid
, scan
->bssid
, ETH_ALEN
) == 0) {
1983 current_ev
= __prism2_translate_scan(
1984 local
, info
, scan
, bss
, current_ev
,
1990 current_ev
= __prism2_translate_scan(
1991 local
, info
, scan
, NULL
, current_ev
, end_buf
);
1993 /* Check if there is space for one more entry */
1994 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
1995 /* Ask user space to try again with a bigger buffer */
1996 spin_unlock_bh(&local
->lock
);
2001 /* Prism2 firmware has limits (32 at least in some versions) for number
2002 * of BSSes in scan results. Extend this limit by using local BSS list.
2004 list_for_each(ptr
, &local
->bss_list
) {
2005 struct hostap_bss_info
*bss
;
2006 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
2009 current_ev
= __prism2_translate_scan(local
, info
, NULL
, bss
,
2010 current_ev
, end_buf
);
2011 /* Check if there is space for one more entry */
2012 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
2013 /* Ask user space to try again with a bigger buffer */
2014 spin_unlock_bh(&local
->lock
);
2019 spin_unlock_bh(&local
->lock
);
2021 return current_ev
- buffer
;
2023 #endif /* PRISM2_NO_STATION_MODES */
2026 static inline int prism2_ioctl_giwscan_sta(struct net_device
*dev
,
2027 struct iw_request_info
*info
,
2028 struct iw_point
*data
, char *extra
)
2030 #ifdef PRISM2_NO_STATION_MODES
2032 #else /* PRISM2_NO_STATION_MODES */
2033 struct hostap_interface
*iface
;
2034 local_info_t
*local
;
2037 iface
= netdev_priv(dev
);
2038 local
= iface
->local
;
2040 /* Wait until the scan is finished. We can probably do better
2041 * than that - Jean II */
2042 if (local
->scan_timestamp
&&
2043 time_before(jiffies
, local
->scan_timestamp
+ 3 * HZ
)) {
2044 /* Important note : we don't want to block the caller
2045 * until results are ready for various reasons.
2046 * First, managing wait queues is complex and racy
2047 * (there may be multiple simultaneous callers).
2048 * Second, we grab some rtnetlink lock before coming
2049 * here (in dev_ioctl()).
2050 * Third, the caller can wait on the Wireless Event
2054 local
->scan_timestamp
= 0;
2056 res
= prism2_translate_scan(local
, info
, extra
, data
->length
);
2065 #endif /* PRISM2_NO_STATION_MODES */
2069 static int prism2_ioctl_giwscan(struct net_device
*dev
,
2070 struct iw_request_info
*info
,
2071 struct iw_point
*data
, char *extra
)
2073 struct hostap_interface
*iface
;
2074 local_info_t
*local
;
2077 iface
= netdev_priv(dev
);
2078 local
= iface
->local
;
2080 if (local
->iw_mode
== IW_MODE_MASTER
) {
2081 /* In MASTER mode, it doesn't make sense to go around
2082 * scanning the frequencies and make the stations we serve
2083 * wait when what the user is really interested about is the
2084 * list of stations and access points we are talking to.
2085 * So, just extract results from our cache...
2088 /* Translate to WE format */
2089 res
= prism2_ap_translate_scan(dev
, info
, extra
);
2091 printk(KERN_DEBUG
"Scan result translation succeeded "
2092 "(length=%d)\n", res
);
2097 "Scan result translation failed (res=%d)\n",
2104 return prism2_ioctl_giwscan_sta(dev
, info
, data
, extra
);
2109 static const struct iw_priv_args prism2_priv
[] = {
2110 { PRISM2_IOCTL_MONITOR
,
2111 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor" },
2112 { PRISM2_IOCTL_READMIF
,
2113 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1,
2114 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1, "readmif" },
2115 { PRISM2_IOCTL_WRITEMIF
,
2116 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 2, 0, "writemif" },
2117 { PRISM2_IOCTL_RESET
,
2118 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "reset" },
2119 { PRISM2_IOCTL_INQUIRE
,
2120 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "inquire" },
2121 { PRISM2_IOCTL_SET_RID_WORD
,
2122 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "set_rid_word" },
2123 { PRISM2_IOCTL_MACCMD
,
2124 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "maccmd" },
2125 { PRISM2_IOCTL_WDS_ADD
,
2126 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_add" },
2127 { PRISM2_IOCTL_WDS_DEL
,
2128 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_del" },
2129 { PRISM2_IOCTL_ADDMAC
,
2130 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "addmac" },
2131 { PRISM2_IOCTL_DELMAC
,
2132 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "delmac" },
2133 { PRISM2_IOCTL_KICKMAC
,
2134 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "kickmac" },
2135 /* --- raw access to sub-ioctls --- */
2136 { PRISM2_IOCTL_PRISM2_PARAM
,
2137 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "prism2_param" },
2138 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2139 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
2140 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprism2_param" },
2141 /* --- sub-ioctls handlers --- */
2142 { PRISM2_IOCTL_PRISM2_PARAM
,
2143 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "" },
2144 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2145 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "" },
2146 /* --- sub-ioctls definitions --- */
2147 { PRISM2_PARAM_TXRATECTRL
,
2148 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "txratectrl" },
2149 { PRISM2_PARAM_TXRATECTRL
,
2150 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettxratectrl" },
2151 { PRISM2_PARAM_BEACON_INT
,
2152 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "beacon_int" },
2153 { PRISM2_PARAM_BEACON_INT
,
2154 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbeacon_int" },
2155 #ifndef PRISM2_NO_STATION_MODES
2156 { PRISM2_PARAM_PSEUDO_IBSS
,
2157 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "pseudo_ibss" },
2158 { PRISM2_PARAM_PSEUDO_IBSS
,
2159 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getpseudo_ibss" },
2160 #endif /* PRISM2_NO_STATION_MODES */
2162 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "alc" },
2164 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getalc" },
2165 { PRISM2_PARAM_DUMP
,
2166 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dump" },
2167 { PRISM2_PARAM_DUMP
,
2168 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdump" },
2169 { PRISM2_PARAM_OTHER_AP_POLICY
,
2170 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "other_ap_policy" },
2171 { PRISM2_PARAM_OTHER_AP_POLICY
,
2172 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getother_ap_pol" },
2173 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2174 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_inactivity" },
2175 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2176 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_inactivi" },
2177 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2178 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bridge_packets" },
2179 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2180 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbridge_packe" },
2181 { PRISM2_PARAM_DTIM_PERIOD
,
2182 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dtim_period" },
2183 { PRISM2_PARAM_DTIM_PERIOD
,
2184 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdtim_period" },
2185 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2186 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "nullfunc_ack" },
2187 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2188 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getnullfunc_ack" },
2189 { PRISM2_PARAM_MAX_WDS
,
2190 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_wds" },
2191 { PRISM2_PARAM_MAX_WDS
,
2192 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_wds" },
2193 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2194 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "autom_ap_wds" },
2195 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2196 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getautom_ap_wds" },
2197 { PRISM2_PARAM_AP_AUTH_ALGS
,
2198 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_auth_algs" },
2199 { PRISM2_PARAM_AP_AUTH_ALGS
,
2200 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_auth_algs" },
2201 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2202 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "allow_fcserr" },
2203 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2204 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getallow_fcserr" },
2205 { PRISM2_PARAM_HOST_ENCRYPT
,
2206 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_encrypt" },
2207 { PRISM2_PARAM_HOST_ENCRYPT
,
2208 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_encrypt" },
2209 { PRISM2_PARAM_HOST_DECRYPT
,
2210 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_decrypt" },
2211 { PRISM2_PARAM_HOST_DECRYPT
,
2212 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_decrypt" },
2213 #ifndef PRISM2_NO_STATION_MODES
2214 { PRISM2_PARAM_HOST_ROAMING
,
2215 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_roaming" },
2216 { PRISM2_PARAM_HOST_ROAMING
,
2217 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_roaming" },
2218 #endif /* PRISM2_NO_STATION_MODES */
2219 { PRISM2_PARAM_BCRX_STA_KEY
,
2220 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bcrx_sta_key" },
2221 { PRISM2_PARAM_BCRX_STA_KEY
,
2222 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbcrx_sta_key" },
2223 { PRISM2_PARAM_IEEE_802_1X
,
2224 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ieee_802_1x" },
2225 { PRISM2_PARAM_IEEE_802_1X
,
2226 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getieee_802_1x" },
2227 { PRISM2_PARAM_ANTSEL_TX
,
2228 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_tx" },
2229 { PRISM2_PARAM_ANTSEL_TX
,
2230 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_tx" },
2231 { PRISM2_PARAM_ANTSEL_RX
,
2232 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_rx" },
2233 { PRISM2_PARAM_ANTSEL_RX
,
2234 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_rx" },
2235 { PRISM2_PARAM_MONITOR_TYPE
,
2236 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor_type" },
2237 { PRISM2_PARAM_MONITOR_TYPE
,
2238 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmonitor_type" },
2239 { PRISM2_PARAM_WDS_TYPE
,
2240 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_type" },
2241 { PRISM2_PARAM_WDS_TYPE
,
2242 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwds_type" },
2243 { PRISM2_PARAM_HOSTSCAN
,
2244 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostscan" },
2245 { PRISM2_PARAM_HOSTSCAN
,
2246 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostscan" },
2247 { PRISM2_PARAM_AP_SCAN
,
2248 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_scan" },
2249 { PRISM2_PARAM_AP_SCAN
,
2250 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_scan" },
2251 { PRISM2_PARAM_ENH_SEC
,
2252 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "enh_sec" },
2253 { PRISM2_PARAM_ENH_SEC
,
2254 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getenh_sec" },
2255 #ifdef PRISM2_IO_DEBUG
2256 { PRISM2_PARAM_IO_DEBUG
,
2257 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "io_debug" },
2258 { PRISM2_PARAM_IO_DEBUG
,
2259 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getio_debug" },
2260 #endif /* PRISM2_IO_DEBUG */
2261 { PRISM2_PARAM_BASIC_RATES
,
2262 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "basic_rates" },
2263 { PRISM2_PARAM_BASIC_RATES
,
2264 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbasic_rates" },
2265 { PRISM2_PARAM_OPER_RATES
,
2266 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "oper_rates" },
2267 { PRISM2_PARAM_OPER_RATES
,
2268 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getoper_rates" },
2269 { PRISM2_PARAM_HOSTAPD
,
2270 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd" },
2271 { PRISM2_PARAM_HOSTAPD
,
2272 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd" },
2273 { PRISM2_PARAM_HOSTAPD_STA
,
2274 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd_sta" },
2275 { PRISM2_PARAM_HOSTAPD_STA
,
2276 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd_sta" },
2278 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wpa" },
2280 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwpa" },
2281 { PRISM2_PARAM_PRIVACY_INVOKED
,
2282 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "privacy_invoked" },
2283 { PRISM2_PARAM_PRIVACY_INVOKED
,
2284 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprivacy_invo" },
2285 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2286 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "tkip_countermea" },
2287 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2288 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettkip_counter" },
2289 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2290 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "drop_unencrypte" },
2291 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2292 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdrop_unencry" },
2293 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2294 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "scan_channels" },
2295 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2296 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getscan_channel" },
2300 static int prism2_ioctl_priv_inquire(struct net_device
*dev
, int *i
)
2302 struct hostap_interface
*iface
;
2303 local_info_t
*local
;
2305 iface
= netdev_priv(dev
);
2306 local
= iface
->local
;
2308 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_INQUIRE
, *i
, NULL
, NULL
))
2315 static int prism2_ioctl_priv_prism2_param(struct net_device
*dev
,
2316 struct iw_request_info
*info
,
2317 void *wrqu
, char *extra
)
2319 struct hostap_interface
*iface
;
2320 local_info_t
*local
;
2321 int *i
= (int *) extra
;
2323 int value
= *(i
+ 1);
2327 iface
= netdev_priv(dev
);
2328 local
= iface
->local
;
2331 case PRISM2_PARAM_TXRATECTRL
:
2332 local
->fw_tx_rate_control
= value
;
2335 case PRISM2_PARAM_BEACON_INT
:
2336 if (hostap_set_word(dev
, HFA384X_RID_CNFBEACONINT
, value
) ||
2337 local
->func
->reset_port(dev
))
2340 local
->beacon_int
= value
;
2343 #ifndef PRISM2_NO_STATION_MODES
2344 case PRISM2_PARAM_PSEUDO_IBSS
:
2345 if (value
== local
->pseudo_adhoc
)
2348 if (value
!= 0 && value
!= 1) {
2353 printk(KERN_DEBUG
"prism2: %s: pseudo IBSS change %d -> %d\n",
2354 dev
->name
, local
->pseudo_adhoc
, value
);
2355 local
->pseudo_adhoc
= value
;
2356 if (local
->iw_mode
!= IW_MODE_ADHOC
)
2359 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2360 hostap_get_porttype(local
))) {
2365 if (local
->func
->reset_port(dev
))
2368 #endif /* PRISM2_NO_STATION_MODES */
2370 case PRISM2_PARAM_ALC
:
2371 printk(KERN_DEBUG
"%s: %s ALC\n", dev
->name
,
2372 value
== 0 ? "Disabling" : "Enabling");
2373 val
= HFA384X_TEST_CFG_BIT_ALC
;
2374 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
2375 (HFA384X_TEST_CFG_BITS
<< 8),
2376 value
== 0 ? 0 : 1, &val
, NULL
);
2379 case PRISM2_PARAM_DUMP
:
2380 local
->frame_dump
= value
;
2383 case PRISM2_PARAM_OTHER_AP_POLICY
:
2384 if (value
< 0 || value
> 3) {
2388 if (local
->ap
!= NULL
)
2389 local
->ap
->ap_policy
= value
;
2392 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2393 if (value
< 0 || value
> 7 * 24 * 60 * 60) {
2397 if (local
->ap
!= NULL
)
2398 local
->ap
->max_inactivity
= value
* HZ
;
2401 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2402 if (local
->ap
!= NULL
)
2403 local
->ap
->bridge_packets
= value
;
2406 case PRISM2_PARAM_DTIM_PERIOD
:
2407 if (value
< 0 || value
> 65535) {
2411 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNDTIMPERIOD
, value
)
2412 || local
->func
->reset_port(dev
))
2415 local
->dtim_period
= value
;
2418 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2419 if (local
->ap
!= NULL
)
2420 local
->ap
->nullfunc_ack
= value
;
2423 case PRISM2_PARAM_MAX_WDS
:
2424 local
->wds_max_connections
= value
;
2427 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2428 if (local
->ap
!= NULL
) {
2429 if (!local
->ap
->autom_ap_wds
&& value
) {
2430 /* add WDS link to all APs in STA table */
2431 hostap_add_wds_links(local
);
2433 local
->ap
->autom_ap_wds
= value
;
2437 case PRISM2_PARAM_AP_AUTH_ALGS
:
2438 local
->auth_algs
= value
;
2439 if (hostap_set_auth_algs(local
))
2443 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2444 local
->monitor_allow_fcserr
= value
;
2447 case PRISM2_PARAM_HOST_ENCRYPT
:
2448 local
->host_encrypt
= value
;
2449 if (hostap_set_encryption(local
) ||
2450 local
->func
->reset_port(dev
))
2454 case PRISM2_PARAM_HOST_DECRYPT
:
2455 local
->host_decrypt
= value
;
2456 if (hostap_set_encryption(local
) ||
2457 local
->func
->reset_port(dev
))
2461 #ifndef PRISM2_NO_STATION_MODES
2462 case PRISM2_PARAM_HOST_ROAMING
:
2463 if (value
< 0 || value
> 2) {
2467 local
->host_roaming
= value
;
2468 if (hostap_set_roaming(local
) || local
->func
->reset_port(dev
))
2471 #endif /* PRISM2_NO_STATION_MODES */
2473 case PRISM2_PARAM_BCRX_STA_KEY
:
2474 local
->bcrx_sta_key
= value
;
2477 case PRISM2_PARAM_IEEE_802_1X
:
2478 local
->ieee_802_1x
= value
;
2481 case PRISM2_PARAM_ANTSEL_TX
:
2482 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2486 local
->antsel_tx
= value
;
2487 hostap_set_antsel(local
);
2490 case PRISM2_PARAM_ANTSEL_RX
:
2491 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2495 local
->antsel_rx
= value
;
2496 hostap_set_antsel(local
);
2499 case PRISM2_PARAM_MONITOR_TYPE
:
2500 if (value
!= PRISM2_MONITOR_80211
&&
2501 value
!= PRISM2_MONITOR_CAPHDR
&&
2502 value
!= PRISM2_MONITOR_PRISM
&&
2503 value
!= PRISM2_MONITOR_RADIOTAP
) {
2507 local
->monitor_type
= value
;
2508 if (local
->iw_mode
== IW_MODE_MONITOR
)
2509 hostap_monitor_set_type(local
);
2512 case PRISM2_PARAM_WDS_TYPE
:
2513 local
->wds_type
= value
;
2516 case PRISM2_PARAM_HOSTSCAN
:
2518 struct hfa384x_hostscan_request scan_req
;
2521 memset(&scan_req
, 0, sizeof(scan_req
));
2522 scan_req
.channel_list
= cpu_to_le16(0x3fff);
2524 case 1: rate
= HFA384X_RATES_1MBPS
; break;
2525 case 2: rate
= HFA384X_RATES_2MBPS
; break;
2526 case 3: rate
= HFA384X_RATES_5MBPS
; break;
2527 case 4: rate
= HFA384X_RATES_11MBPS
; break;
2528 default: rate
= HFA384X_RATES_1MBPS
; break;
2530 scan_req
.txrate
= cpu_to_le16(rate
);
2531 /* leave SSID empty to accept all SSIDs */
2533 if (local
->iw_mode
== IW_MODE_MASTER
) {
2534 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2535 HFA384X_PORTTYPE_BSS
) ||
2536 local
->func
->reset_port(dev
))
2537 printk(KERN_DEBUG
"Leaving Host AP mode "
2538 "for HostScan failed\n");
2541 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
2542 sizeof(scan_req
))) {
2543 printk(KERN_DEBUG
"HOSTSCAN failed\n");
2546 if (local
->iw_mode
== IW_MODE_MASTER
) {
2547 wait_queue_t __wait
;
2548 init_waitqueue_entry(&__wait
, current
);
2549 add_wait_queue(&local
->hostscan_wq
, &__wait
);
2550 set_current_state(TASK_INTERRUPTIBLE
);
2551 schedule_timeout(HZ
);
2552 if (signal_pending(current
))
2554 set_current_state(TASK_RUNNING
);
2555 remove_wait_queue(&local
->hostscan_wq
, &__wait
);
2557 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2558 HFA384X_PORTTYPE_HOSTAP
) ||
2559 local
->func
->reset_port(dev
))
2560 printk(KERN_DEBUG
"Returning to Host AP mode "
2561 "after HostScan failed\n");
2566 case PRISM2_PARAM_AP_SCAN
:
2567 local
->passive_scan_interval
= value
;
2568 if (timer_pending(&local
->passive_scan_timer
))
2569 del_timer(&local
->passive_scan_timer
);
2571 local
->passive_scan_timer
.expires
= jiffies
+
2572 local
->passive_scan_interval
* HZ
;
2573 add_timer(&local
->passive_scan_timer
);
2577 case PRISM2_PARAM_ENH_SEC
:
2578 if (value
< 0 || value
> 3) {
2582 local
->enh_sec
= value
;
2583 if (hostap_set_word(dev
, HFA384X_RID_CNFENHSECURITY
,
2585 local
->func
->reset_port(dev
)) {
2586 printk(KERN_INFO
"%s: cnfEnhSecurity requires STA f/w "
2587 "1.6.3 or newer\n", dev
->name
);
2592 #ifdef PRISM2_IO_DEBUG
2593 case PRISM2_PARAM_IO_DEBUG
:
2594 local
->io_debug_enabled
= value
;
2596 #endif /* PRISM2_IO_DEBUG */
2598 case PRISM2_PARAM_BASIC_RATES
:
2599 if ((value
& local
->tx_rate_control
) != value
|| value
== 0) {
2600 printk(KERN_INFO
"%s: invalid basic rate set - basic "
2601 "rates must be in supported rate set\n",
2606 local
->basic_rates
= value
;
2607 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
2608 local
->basic_rates
) ||
2609 local
->func
->reset_port(dev
))
2613 case PRISM2_PARAM_OPER_RATES
:
2614 local
->tx_rate_control
= value
;
2615 if (hostap_set_rate(dev
))
2619 case PRISM2_PARAM_HOSTAPD
:
2620 ret
= hostap_set_hostapd(local
, value
, 1);
2623 case PRISM2_PARAM_HOSTAPD_STA
:
2624 ret
= hostap_set_hostapd_sta(local
, value
, 1);
2627 case PRISM2_PARAM_WPA
:
2629 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2631 else if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
2636 case PRISM2_PARAM_PRIVACY_INVOKED
:
2637 local
->privacy_invoked
= value
;
2638 if (hostap_set_encryption(local
) ||
2639 local
->func
->reset_port(dev
))
2643 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2644 local
->tkip_countermeasures
= value
;
2647 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2648 local
->drop_unencrypted
= value
;
2651 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2652 local
->scan_channel_mask
= value
;
2656 printk(KERN_DEBUG
"%s: prism2_param: unknown param %d\n",
2666 static int prism2_ioctl_priv_get_prism2_param(struct net_device
*dev
,
2667 struct iw_request_info
*info
,
2668 void *wrqu
, char *extra
)
2670 struct hostap_interface
*iface
;
2671 local_info_t
*local
;
2672 int *param
= (int *) extra
;
2675 iface
= netdev_priv(dev
);
2676 local
= iface
->local
;
2679 case PRISM2_PARAM_TXRATECTRL
:
2680 *param
= local
->fw_tx_rate_control
;
2683 case PRISM2_PARAM_BEACON_INT
:
2684 *param
= local
->beacon_int
;
2687 case PRISM2_PARAM_PSEUDO_IBSS
:
2688 *param
= local
->pseudo_adhoc
;
2691 case PRISM2_PARAM_ALC
:
2692 ret
= -EOPNOTSUPP
; /* FIX */
2695 case PRISM2_PARAM_DUMP
:
2696 *param
= local
->frame_dump
;
2699 case PRISM2_PARAM_OTHER_AP_POLICY
:
2700 if (local
->ap
!= NULL
)
2701 *param
= local
->ap
->ap_policy
;
2706 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2707 if (local
->ap
!= NULL
)
2708 *param
= local
->ap
->max_inactivity
/ HZ
;
2713 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2714 if (local
->ap
!= NULL
)
2715 *param
= local
->ap
->bridge_packets
;
2720 case PRISM2_PARAM_DTIM_PERIOD
:
2721 *param
= local
->dtim_period
;
2724 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2725 if (local
->ap
!= NULL
)
2726 *param
= local
->ap
->nullfunc_ack
;
2731 case PRISM2_PARAM_MAX_WDS
:
2732 *param
= local
->wds_max_connections
;
2735 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2736 if (local
->ap
!= NULL
)
2737 *param
= local
->ap
->autom_ap_wds
;
2742 case PRISM2_PARAM_AP_AUTH_ALGS
:
2743 *param
= local
->auth_algs
;
2746 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2747 *param
= local
->monitor_allow_fcserr
;
2750 case PRISM2_PARAM_HOST_ENCRYPT
:
2751 *param
= local
->host_encrypt
;
2754 case PRISM2_PARAM_HOST_DECRYPT
:
2755 *param
= local
->host_decrypt
;
2758 case PRISM2_PARAM_HOST_ROAMING
:
2759 *param
= local
->host_roaming
;
2762 case PRISM2_PARAM_BCRX_STA_KEY
:
2763 *param
= local
->bcrx_sta_key
;
2766 case PRISM2_PARAM_IEEE_802_1X
:
2767 *param
= local
->ieee_802_1x
;
2770 case PRISM2_PARAM_ANTSEL_TX
:
2771 *param
= local
->antsel_tx
;
2774 case PRISM2_PARAM_ANTSEL_RX
:
2775 *param
= local
->antsel_rx
;
2778 case PRISM2_PARAM_MONITOR_TYPE
:
2779 *param
= local
->monitor_type
;
2782 case PRISM2_PARAM_WDS_TYPE
:
2783 *param
= local
->wds_type
;
2786 case PRISM2_PARAM_HOSTSCAN
:
2790 case PRISM2_PARAM_AP_SCAN
:
2791 *param
= local
->passive_scan_interval
;
2794 case PRISM2_PARAM_ENH_SEC
:
2795 *param
= local
->enh_sec
;
2798 #ifdef PRISM2_IO_DEBUG
2799 case PRISM2_PARAM_IO_DEBUG
:
2800 *param
= local
->io_debug_enabled
;
2802 #endif /* PRISM2_IO_DEBUG */
2804 case PRISM2_PARAM_BASIC_RATES
:
2805 *param
= local
->basic_rates
;
2808 case PRISM2_PARAM_OPER_RATES
:
2809 *param
= local
->tx_rate_control
;
2812 case PRISM2_PARAM_HOSTAPD
:
2813 *param
= local
->hostapd
;
2816 case PRISM2_PARAM_HOSTAPD_STA
:
2817 *param
= local
->hostapd_sta
;
2820 case PRISM2_PARAM_WPA
:
2821 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2823 *param
= local
->wpa
;
2826 case PRISM2_PARAM_PRIVACY_INVOKED
:
2827 *param
= local
->privacy_invoked
;
2830 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2831 *param
= local
->tkip_countermeasures
;
2834 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2835 *param
= local
->drop_unencrypted
;
2838 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2839 *param
= local
->scan_channel_mask
;
2843 printk(KERN_DEBUG
"%s: get_prism2_param: unknown param %d\n",
2853 static int prism2_ioctl_priv_readmif(struct net_device
*dev
,
2854 struct iw_request_info
*info
,
2855 void *wrqu
, char *extra
)
2857 struct hostap_interface
*iface
;
2858 local_info_t
*local
;
2861 iface
= netdev_priv(dev
);
2862 local
= iface
->local
;
2864 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
, *extra
, NULL
,
2874 static int prism2_ioctl_priv_writemif(struct net_device
*dev
,
2875 struct iw_request_info
*info
,
2876 void *wrqu
, char *extra
)
2878 struct hostap_interface
*iface
;
2879 local_info_t
*local
;
2882 iface
= netdev_priv(dev
);
2883 local
= iface
->local
;
2887 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
, cr
, &val
, NULL
))
2894 static int prism2_ioctl_priv_monitor(struct net_device
*dev
, int *i
)
2896 struct hostap_interface
*iface
;
2897 local_info_t
*local
;
2901 iface
= netdev_priv(dev
);
2902 local
= iface
->local
;
2904 printk(KERN_DEBUG
"%s: process %d (%s) used deprecated iwpriv monitor "
2905 "- update software to use iwconfig mode monitor\n",
2906 dev
->name
, task_pid_nr(current
), current
->comm
);
2908 /* Backward compatibility code - this can be removed at some point */
2911 /* Disable monitor mode - old mode was not saved, so go to
2913 mode
= IW_MODE_MASTER
;
2914 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2915 } else if (*i
== 1) {
2916 /* netlink socket mode is not supported anymore since it did
2917 * not separate different devices from each other and was not
2918 * best method for delivering large amount of packets to
2921 } else if (*i
== 2 || *i
== 3) {
2924 local
->monitor_type
= PRISM2_MONITOR_80211
;
2927 local
->monitor_type
= PRISM2_MONITOR_PRISM
;
2930 mode
= IW_MODE_MONITOR
;
2931 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2932 hostap_monitor_mode_enable(local
);
2940 static int prism2_ioctl_priv_reset(struct net_device
*dev
, int *i
)
2942 struct hostap_interface
*iface
;
2943 local_info_t
*local
;
2945 iface
= netdev_priv(dev
);
2946 local
= iface
->local
;
2948 printk(KERN_DEBUG
"%s: manual reset request(%d)\n", dev
->name
, *i
);
2951 /* Disable and enable card */
2952 local
->func
->hw_shutdown(dev
, 1);
2953 local
->func
->hw_config(dev
, 0);
2958 local
->func
->hw_reset(dev
);
2962 /* Disable and enable port 0 */
2963 local
->func
->reset_port(dev
);
2967 prism2_sta_deauth(local
, WLAN_REASON_DEAUTH_LEAVING
);
2968 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_DISABLE
, 0, NULL
,
2974 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_ENABLE
, 0, NULL
,
2980 printk(KERN_DEBUG
"Unknown reset request %d\n", *i
);
2988 static int prism2_ioctl_priv_set_rid_word(struct net_device
*dev
, int *i
)
2991 int value
= *(i
+ 1);
2993 printk(KERN_DEBUG
"%s: Set RID[0x%X] = %d\n", dev
->name
, rid
, value
);
2995 if (hostap_set_word(dev
, rid
, value
))
3002 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3003 static int ap_mac_cmd_ioctl(local_info_t
*local
, int *cmd
)
3008 case AP_MAC_CMD_POLICY_OPEN
:
3009 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_OPEN
;
3011 case AP_MAC_CMD_POLICY_ALLOW
:
3012 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_ALLOW
;
3014 case AP_MAC_CMD_POLICY_DENY
:
3015 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_DENY
;
3017 case AP_MAC_CMD_FLUSH
:
3018 ap_control_flush_macs(&local
->ap
->mac_restrictions
);
3020 case AP_MAC_CMD_KICKALL
:
3021 ap_control_kickall(local
->ap
);
3022 hostap_deauth_all_stas(local
->dev
, local
->ap
, 0);
3031 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3034 #ifdef PRISM2_DOWNLOAD_SUPPORT
3035 static int prism2_ioctl_priv_download(local_info_t
*local
, struct iw_point
*p
)
3037 struct prism2_download_param
*param
;
3040 if (p
->length
< sizeof(struct prism2_download_param
) ||
3041 p
->length
> 1024 || !p
->pointer
)
3044 param
= kmalloc(p
->length
, GFP_KERNEL
);
3048 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
3053 if (p
->length
< sizeof(struct prism2_download_param
) +
3054 param
->num_areas
* sizeof(struct prism2_download_area
)) {
3059 ret
= local
->func
->download(local
, param
);
3065 #endif /* PRISM2_DOWNLOAD_SUPPORT */
3068 static int prism2_set_genericelement(struct net_device
*dev
, u8
*elem
,
3071 struct hostap_interface
*iface
= netdev_priv(dev
);
3072 local_info_t
*local
= iface
->local
;
3076 * Add 16-bit length in the beginning of the buffer because Prism2 RID
3079 buf
= kmalloc(len
+ 2, GFP_KERNEL
);
3083 *((__le16
*) buf
) = cpu_to_le16(len
);
3084 memcpy(buf
+ 2, elem
, len
);
3086 kfree(local
->generic_elem
);
3087 local
->generic_elem
= buf
;
3088 local
->generic_elem_len
= len
+ 2;
3090 return local
->func
->set_rid(local
->dev
, HFA384X_RID_GENERICELEMENT
,
3095 static int prism2_ioctl_siwauth(struct net_device
*dev
,
3096 struct iw_request_info
*info
,
3097 struct iw_param
*data
, char *extra
)
3099 struct hostap_interface
*iface
= netdev_priv(dev
);
3100 local_info_t
*local
= iface
->local
;
3102 switch (data
->flags
& IW_AUTH_INDEX
) {
3103 case IW_AUTH_WPA_VERSION
:
3104 case IW_AUTH_CIPHER_PAIRWISE
:
3105 case IW_AUTH_CIPHER_GROUP
:
3106 case IW_AUTH_KEY_MGMT
:
3108 * Host AP driver does not use these parameters and allows
3109 * wpa_supplicant to control them internally.
3112 case IW_AUTH_TKIP_COUNTERMEASURES
:
3113 local
->tkip_countermeasures
= data
->value
;
3115 case IW_AUTH_DROP_UNENCRYPTED
:
3116 local
->drop_unencrypted
= data
->value
;
3118 case IW_AUTH_80211_AUTH_ALG
:
3119 local
->auth_algs
= data
->value
;
3121 case IW_AUTH_WPA_ENABLED
:
3122 if (data
->value
== 0) {
3124 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3126 prism2_set_genericelement(dev
, "", 0);
3127 local
->host_roaming
= 0;
3128 local
->privacy_invoked
= 0;
3129 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
3131 hostap_set_roaming(local
) ||
3132 hostap_set_encryption(local
) ||
3133 local
->func
->reset_port(dev
))
3137 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3139 local
->host_roaming
= 2;
3140 local
->privacy_invoked
= 1;
3142 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
, 1) ||
3143 hostap_set_roaming(local
) ||
3144 hostap_set_encryption(local
) ||
3145 local
->func
->reset_port(dev
))
3148 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3149 local
->ieee_802_1x
= data
->value
;
3151 case IW_AUTH_PRIVACY_INVOKED
:
3152 local
->privacy_invoked
= data
->value
;
3161 static int prism2_ioctl_giwauth(struct net_device
*dev
,
3162 struct iw_request_info
*info
,
3163 struct iw_param
*data
, char *extra
)
3165 struct hostap_interface
*iface
= netdev_priv(dev
);
3166 local_info_t
*local
= iface
->local
;
3168 switch (data
->flags
& IW_AUTH_INDEX
) {
3169 case IW_AUTH_WPA_VERSION
:
3170 case IW_AUTH_CIPHER_PAIRWISE
:
3171 case IW_AUTH_CIPHER_GROUP
:
3172 case IW_AUTH_KEY_MGMT
:
3174 * Host AP driver does not use these parameters and allows
3175 * wpa_supplicant to control them internally.
3178 case IW_AUTH_TKIP_COUNTERMEASURES
:
3179 data
->value
= local
->tkip_countermeasures
;
3181 case IW_AUTH_DROP_UNENCRYPTED
:
3182 data
->value
= local
->drop_unencrypted
;
3184 case IW_AUTH_80211_AUTH_ALG
:
3185 data
->value
= local
->auth_algs
;
3187 case IW_AUTH_WPA_ENABLED
:
3188 data
->value
= local
->wpa
;
3190 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3191 data
->value
= local
->ieee_802_1x
;
3200 static int prism2_ioctl_siwencodeext(struct net_device
*dev
,
3201 struct iw_request_info
*info
,
3202 struct iw_point
*erq
, char *extra
)
3204 struct hostap_interface
*iface
= netdev_priv(dev
);
3205 local_info_t
*local
= iface
->local
;
3206 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3208 struct lib80211_crypto_ops
*ops
;
3209 struct lib80211_crypt_data
**crypt
;
3212 const char *alg
, *module
;
3214 i
= erq
->flags
& IW_ENCODE_INDEX
;
3217 if (i
< 1 || i
> WEP_KEYS
)
3218 i
= local
->crypt_info
.tx_keyidx
;
3221 if (i
< 0 || i
>= WEP_KEYS
)
3224 addr
= ext
->addr
.sa_data
;
3225 if (is_broadcast_ether_addr(addr
)) {
3227 crypt
= &local
->crypt_info
.crypt
[i
];
3231 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, addr
, 0, &crypt
);
3232 if (sta_ptr
== NULL
) {
3233 if (local
->iw_mode
== IW_MODE_INFRA
) {
3235 * TODO: add STA entry for the current AP so
3236 * that unicast key can be used. For now, this
3237 * is emulated by using default key idx 0.
3240 crypt
= &local
->crypt_info
.crypt
[i
];
3246 if ((erq
->flags
& IW_ENCODE_DISABLED
) ||
3247 ext
->alg
== IW_ENCODE_ALG_NONE
) {
3249 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3254 case IW_ENCODE_ALG_WEP
:
3256 module
= "lib80211_crypt_wep";
3258 case IW_ENCODE_ALG_TKIP
:
3260 module
= "lib80211_crypt_tkip";
3262 case IW_ENCODE_ALG_CCMP
:
3264 module
= "lib80211_crypt_ccmp";
3267 printk(KERN_DEBUG
"%s: unsupported algorithm %d\n",
3268 local
->dev
->name
, ext
->alg
);
3273 ops
= lib80211_get_crypto_ops(alg
);
3275 request_module(module
);
3276 ops
= lib80211_get_crypto_ops(alg
);
3279 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3280 local
->dev
->name
, alg
);
3285 if (sta_ptr
|| ext
->alg
!= IW_ENCODE_ALG_WEP
) {
3287 * Per station encryption and other than WEP algorithms
3288 * require host-based encryption, so force them on
3291 local
->host_decrypt
= local
->host_encrypt
= 1;
3294 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3295 struct lib80211_crypt_data
*new_crypt
;
3297 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3299 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3301 if (new_crypt
== NULL
) {
3305 new_crypt
->ops
= ops
;
3306 if (new_crypt
->ops
&& try_module_get(new_crypt
->ops
->owner
))
3307 new_crypt
->priv
= new_crypt
->ops
->init(i
);
3308 if (new_crypt
->priv
== NULL
) {
3318 * TODO: if ext_flags does not have IW_ENCODE_EXT_RX_SEQ_VALID, the
3319 * existing seq# should not be changed.
3320 * TODO: if ext_flags has IW_ENCODE_EXT_TX_SEQ_VALID, next TX seq#
3321 * should be changed to something else than zero.
3323 if ((!(ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) || ext
->key_len
> 0)
3324 && (*crypt
)->ops
->set_key
&&
3325 (*crypt
)->ops
->set_key(ext
->key
, ext
->key_len
, ext
->rx_seq
,
3326 (*crypt
)->priv
) < 0) {
3327 printk(KERN_DEBUG
"%s: key setting failed\n",
3333 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) {
3335 local
->crypt_info
.tx_keyidx
= i
;
3339 if (sta_ptr
== NULL
&& ext
->key_len
> 0) {
3341 for (j
= 0; j
< WEP_KEYS
; j
++) {
3342 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
3348 local
->crypt_info
.tx_keyidx
= i
;
3353 hostap_handle_sta_release(sta_ptr
);
3355 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
3358 * Do not reset port0 if card is in Managed mode since resetting will
3359 * generate new IEEE 802.11 authentication which may end up in looping
3360 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3361 * after WEP configuration. However, keys are apparently changed at
3362 * least in Managed mode.
3365 (hostap_set_encryption(local
) ||
3366 (local
->iw_mode
!= IW_MODE_INFRA
&&
3367 local
->func
->reset_port(local
->dev
))))
3374 static int prism2_ioctl_giwencodeext(struct net_device
*dev
,
3375 struct iw_request_info
*info
,
3376 struct iw_point
*erq
, char *extra
)
3378 struct hostap_interface
*iface
= netdev_priv(dev
);
3379 local_info_t
*local
= iface
->local
;
3380 struct lib80211_crypt_data
**crypt
;
3383 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3386 max_key_len
= erq
->length
- sizeof(*ext
);
3387 if (max_key_len
< 0)
3390 i
= erq
->flags
& IW_ENCODE_INDEX
;
3391 if (i
< 1 || i
> WEP_KEYS
)
3392 i
= local
->crypt_info
.tx_keyidx
;
3396 addr
= ext
->addr
.sa_data
;
3397 if (is_broadcast_ether_addr(addr
)) {
3399 crypt
= &local
->crypt_info
.crypt
[i
];
3402 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, addr
, 0, &crypt
);
3403 if (sta_ptr
== NULL
)
3407 memset(ext
, 0, sizeof(*ext
));
3409 if (*crypt
== NULL
|| (*crypt
)->ops
== NULL
) {
3410 ext
->alg
= IW_ENCODE_ALG_NONE
;
3412 erq
->flags
|= IW_ENCODE_DISABLED
;
3414 if (strcmp((*crypt
)->ops
->name
, "WEP") == 0)
3415 ext
->alg
= IW_ENCODE_ALG_WEP
;
3416 else if (strcmp((*crypt
)->ops
->name
, "TKIP") == 0)
3417 ext
->alg
= IW_ENCODE_ALG_TKIP
;
3418 else if (strcmp((*crypt
)->ops
->name
, "CCMP") == 0)
3419 ext
->alg
= IW_ENCODE_ALG_CCMP
;
3423 if ((*crypt
)->ops
->get_key
) {
3425 (*crypt
)->ops
->get_key(ext
->key
,
3430 (ext
->alg
== IW_ENCODE_ALG_TKIP
||
3431 ext
->alg
== IW_ENCODE_ALG_CCMP
))
3432 ext
->ext_flags
|= IW_ENCODE_EXT_TX_SEQ_VALID
;
3437 hostap_handle_sta_release(sta_ptr
);
3443 static int prism2_ioctl_set_encryption(local_info_t
*local
,
3444 struct prism2_hostapd_param
*param
,
3448 struct lib80211_crypto_ops
*ops
;
3449 struct lib80211_crypt_data
**crypt
;
3452 param
->u
.crypt
.err
= 0;
3453 param
->u
.crypt
.alg
[HOSTAP_CRYPT_ALG_NAME_LEN
- 1] = '\0';
3456 (int) ((char *) param
->u
.crypt
.key
- (char *) param
) +
3457 param
->u
.crypt
.key_len
)
3460 if (is_broadcast_ether_addr(param
->sta_addr
)) {
3461 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3464 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3466 if (param
->u
.crypt
.idx
)
3468 sta_ptr
= ap_crypt_get_ptrs(
3469 local
->ap
, param
->sta_addr
,
3470 (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_PERMANENT
),
3473 if (sta_ptr
== NULL
) {
3474 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3479 if (strcmp(param
->u
.crypt
.alg
, "none") == 0) {
3481 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3485 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3486 if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "WEP") == 0) {
3487 request_module("lib80211_crypt_wep");
3488 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3489 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "TKIP") == 0) {
3490 request_module("lib80211_crypt_tkip");
3491 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3492 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "CCMP") == 0) {
3493 request_module("lib80211_crypt_ccmp");
3494 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3497 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3498 local
->dev
->name
, param
->u
.crypt
.alg
);
3499 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ALG
;
3504 /* station based encryption and other than WEP algorithms require
3505 * host-based encryption, so force them on automatically */
3506 local
->host_decrypt
= local
->host_encrypt
= 1;
3508 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3509 struct lib80211_crypt_data
*new_crypt
;
3511 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3513 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3515 if (new_crypt
== NULL
) {
3519 new_crypt
->ops
= ops
;
3520 new_crypt
->priv
= new_crypt
->ops
->init(param
->u
.crypt
.idx
);
3521 if (new_crypt
->priv
== NULL
) {
3523 param
->u
.crypt
.err
=
3524 HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED
;
3532 if ((!(param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) ||
3533 param
->u
.crypt
.key_len
> 0) && (*crypt
)->ops
->set_key
&&
3534 (*crypt
)->ops
->set_key(param
->u
.crypt
.key
,
3535 param
->u
.crypt
.key_len
, param
->u
.crypt
.seq
,
3536 (*crypt
)->priv
) < 0) {
3537 printk(KERN_DEBUG
"%s: key setting failed\n",
3539 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_KEY_SET_FAILED
;
3544 if (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) {
3546 local
->crypt_info
.tx_keyidx
= param
->u
.crypt
.idx
;
3547 else if (param
->u
.crypt
.idx
) {
3548 printk(KERN_DEBUG
"%s: TX key idx setting failed\n",
3550 param
->u
.crypt
.err
=
3551 HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED
;
3559 hostap_handle_sta_release(sta_ptr
);
3561 /* Do not reset port0 if card is in Managed mode since resetting will
3562 * generate new IEEE 802.11 authentication which may end up in looping
3563 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3564 * after WEP configuration. However, keys are apparently changed at
3565 * least in Managed mode. */
3567 (hostap_set_encryption(local
) ||
3568 (local
->iw_mode
!= IW_MODE_INFRA
&&
3569 local
->func
->reset_port(local
->dev
)))) {
3570 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_CARD_CONF_FAILED
;
3578 static int prism2_ioctl_get_encryption(local_info_t
*local
,
3579 struct prism2_hostapd_param
*param
,
3582 struct lib80211_crypt_data
**crypt
;
3586 param
->u
.crypt
.err
= 0;
3588 max_key_len
= param_len
-
3589 (int) ((char *) param
->u
.crypt
.key
- (char *) param
);
3590 if (max_key_len
< 0)
3593 if (is_broadcast_ether_addr(param
->sta_addr
)) {
3595 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3596 param
->u
.crypt
.idx
= local
->crypt_info
.tx_keyidx
;
3597 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3599 param
->u
.crypt
.idx
= 0;
3600 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, param
->sta_addr
, 0,
3603 if (sta_ptr
== NULL
) {
3604 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3609 if (*crypt
== NULL
|| (*crypt
)->ops
== NULL
) {
3610 memcpy(param
->u
.crypt
.alg
, "none", 5);
3611 param
->u
.crypt
.key_len
= 0;
3612 param
->u
.crypt
.idx
= 0xff;
3614 strncpy(param
->u
.crypt
.alg
, (*crypt
)->ops
->name
,
3615 HOSTAP_CRYPT_ALG_NAME_LEN
);
3616 param
->u
.crypt
.key_len
= 0;
3618 memset(param
->u
.crypt
.seq
, 0, 8);
3619 if ((*crypt
)->ops
->get_key
) {
3620 param
->u
.crypt
.key_len
=
3621 (*crypt
)->ops
->get_key(param
->u
.crypt
.key
,
3629 hostap_handle_sta_release(sta_ptr
);
3635 static int prism2_ioctl_get_rid(local_info_t
*local
,
3636 struct prism2_hostapd_param
*param
,
3641 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3645 res
= local
->func
->get_rid(local
->dev
, param
->u
.rid
.rid
,
3646 param
->u
.rid
.data
, param
->u
.rid
.len
, 0);
3648 param
->u
.rid
.len
= res
;
3656 static int prism2_ioctl_set_rid(local_info_t
*local
,
3657 struct prism2_hostapd_param
*param
,
3662 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3663 if (max_len
< 0 || max_len
< param
->u
.rid
.len
)
3666 return local
->func
->set_rid(local
->dev
, param
->u
.rid
.rid
,
3667 param
->u
.rid
.data
, param
->u
.rid
.len
);
3671 static int prism2_ioctl_set_assoc_ap_addr(local_info_t
*local
,
3672 struct prism2_hostapd_param
*param
,
3675 printk(KERN_DEBUG
"%ssta: associated as client with AP %pM\n",
3676 local
->dev
->name
, param
->sta_addr
);
3677 memcpy(local
->assoc_ap_addr
, param
->sta_addr
, ETH_ALEN
);
3682 static int prism2_ioctl_siwgenie(struct net_device
*dev
,
3683 struct iw_request_info
*info
,
3684 struct iw_point
*data
, char *extra
)
3686 return prism2_set_genericelement(dev
, extra
, data
->length
);
3690 static int prism2_ioctl_giwgenie(struct net_device
*dev
,
3691 struct iw_request_info
*info
,
3692 struct iw_point
*data
, char *extra
)
3694 struct hostap_interface
*iface
= netdev_priv(dev
);
3695 local_info_t
*local
= iface
->local
;
3696 int len
= local
->generic_elem_len
- 2;
3698 if (len
<= 0 || local
->generic_elem
== NULL
) {
3703 if (data
->length
< len
)
3707 memcpy(extra
, local
->generic_elem
+ 2, len
);
3713 static int prism2_ioctl_set_generic_element(local_info_t
*local
,
3714 struct prism2_hostapd_param
*param
,
3719 len
= param
->u
.generic_elem
.len
;
3720 max_len
= param_len
- PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN
;
3721 if (max_len
< 0 || max_len
< len
)
3724 return prism2_set_genericelement(local
->dev
,
3725 param
->u
.generic_elem
.data
, len
);
3729 static int prism2_ioctl_siwmlme(struct net_device
*dev
,
3730 struct iw_request_info
*info
,
3731 struct iw_point
*data
, char *extra
)
3733 struct hostap_interface
*iface
= netdev_priv(dev
);
3734 local_info_t
*local
= iface
->local
;
3735 struct iw_mlme
*mlme
= (struct iw_mlme
*) extra
;
3738 reason
= cpu_to_le16(mlme
->reason_code
);
3740 switch (mlme
->cmd
) {
3741 case IW_MLME_DEAUTH
:
3742 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3743 IEEE80211_STYPE_DEAUTH
,
3745 case IW_MLME_DISASSOC
:
3746 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3747 IEEE80211_STYPE_DISASSOC
,
3755 static int prism2_ioctl_mlme(local_info_t
*local
,
3756 struct prism2_hostapd_param
*param
)
3760 reason
= cpu_to_le16(param
->u
.mlme
.reason_code
);
3761 switch (param
->u
.mlme
.cmd
) {
3762 case MLME_STA_DEAUTH
:
3763 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3764 IEEE80211_STYPE_DEAUTH
,
3766 case MLME_STA_DISASSOC
:
3767 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3768 IEEE80211_STYPE_DISASSOC
,
3776 static int prism2_ioctl_scan_req(local_info_t
*local
,
3777 struct prism2_hostapd_param
*param
)
3779 #ifndef PRISM2_NO_STATION_MODES
3780 if ((local
->iw_mode
!= IW_MODE_INFRA
&&
3781 local
->iw_mode
!= IW_MODE_ADHOC
) ||
3782 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1)))
3785 if (!local
->dev_enabled
)
3788 return prism2_request_hostscan(local
->dev
, param
->u
.scan_req
.ssid
,
3789 param
->u
.scan_req
.ssid_len
);
3790 #else /* PRISM2_NO_STATION_MODES */
3792 #endif /* PRISM2_NO_STATION_MODES */
3796 static int prism2_ioctl_priv_hostapd(local_info_t
*local
, struct iw_point
*p
)
3798 struct prism2_hostapd_param
*param
;
3802 if (p
->length
< sizeof(struct prism2_hostapd_param
) ||
3803 p
->length
> PRISM2_HOSTAPD_MAX_BUF_SIZE
|| !p
->pointer
)
3806 param
= kmalloc(p
->length
, GFP_KERNEL
);
3810 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
3815 switch (param
->cmd
) {
3816 case PRISM2_SET_ENCRYPTION
:
3817 ret
= prism2_ioctl_set_encryption(local
, param
, p
->length
);
3819 case PRISM2_GET_ENCRYPTION
:
3820 ret
= prism2_ioctl_get_encryption(local
, param
, p
->length
);
3822 case PRISM2_HOSTAPD_GET_RID
:
3823 ret
= prism2_ioctl_get_rid(local
, param
, p
->length
);
3825 case PRISM2_HOSTAPD_SET_RID
:
3826 ret
= prism2_ioctl_set_rid(local
, param
, p
->length
);
3828 case PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR
:
3829 ret
= prism2_ioctl_set_assoc_ap_addr(local
, param
, p
->length
);
3831 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT
:
3832 ret
= prism2_ioctl_set_generic_element(local
, param
,
3835 case PRISM2_HOSTAPD_MLME
:
3836 ret
= prism2_ioctl_mlme(local
, param
);
3838 case PRISM2_HOSTAPD_SCAN_REQ
:
3839 ret
= prism2_ioctl_scan_req(local
, param
);
3842 ret
= prism2_hostapd(local
->ap
, param
);
3847 if (ret
== 1 || !ap_ioctl
) {
3848 if (copy_to_user(p
->pointer
, param
, p
->length
)) {
3851 } else if (ap_ioctl
)
3861 static void prism2_get_drvinfo(struct net_device
*dev
,
3862 struct ethtool_drvinfo
*info
)
3864 struct hostap_interface
*iface
;
3865 local_info_t
*local
;
3867 iface
= netdev_priv(dev
);
3868 local
= iface
->local
;
3870 strlcpy(info
->driver
, "hostap", sizeof(info
->driver
));
3871 snprintf(info
->fw_version
, sizeof(info
->fw_version
),
3872 "%d.%d.%d", (local
->sta_fw_ver
>> 16) & 0xff,
3873 (local
->sta_fw_ver
>> 8) & 0xff,
3874 local
->sta_fw_ver
& 0xff);
3877 const struct ethtool_ops prism2_ethtool_ops
= {
3878 .get_drvinfo
= prism2_get_drvinfo
3882 /* Structures to export the Wireless Handlers */
3884 static const iw_handler prism2_handler
[] =
3886 (iw_handler
) NULL
, /* SIOCSIWCOMMIT */
3887 (iw_handler
) prism2_get_name
, /* SIOCGIWNAME */
3888 (iw_handler
) NULL
, /* SIOCSIWNWID */
3889 (iw_handler
) NULL
, /* SIOCGIWNWID */
3890 (iw_handler
) prism2_ioctl_siwfreq
, /* SIOCSIWFREQ */
3891 (iw_handler
) prism2_ioctl_giwfreq
, /* SIOCGIWFREQ */
3892 (iw_handler
) prism2_ioctl_siwmode
, /* SIOCSIWMODE */
3893 (iw_handler
) prism2_ioctl_giwmode
, /* SIOCGIWMODE */
3894 (iw_handler
) prism2_ioctl_siwsens
, /* SIOCSIWSENS */
3895 (iw_handler
) prism2_ioctl_giwsens
, /* SIOCGIWSENS */
3896 (iw_handler
) NULL
/* not used */, /* SIOCSIWRANGE */
3897 (iw_handler
) prism2_ioctl_giwrange
, /* SIOCGIWRANGE */
3898 (iw_handler
) NULL
/* not used */, /* SIOCSIWPRIV */
3899 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWPRIV */
3900 (iw_handler
) NULL
/* not used */, /* SIOCSIWSTATS */
3901 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWSTATS */
3902 iw_handler_set_spy
, /* SIOCSIWSPY */
3903 iw_handler_get_spy
, /* SIOCGIWSPY */
3904 iw_handler_set_thrspy
, /* SIOCSIWTHRSPY */
3905 iw_handler_get_thrspy
, /* SIOCGIWTHRSPY */
3906 (iw_handler
) prism2_ioctl_siwap
, /* SIOCSIWAP */
3907 (iw_handler
) prism2_ioctl_giwap
, /* SIOCGIWAP */
3908 (iw_handler
) prism2_ioctl_siwmlme
, /* SIOCSIWMLME */
3909 (iw_handler
) prism2_ioctl_giwaplist
, /* SIOCGIWAPLIST */
3910 (iw_handler
) prism2_ioctl_siwscan
, /* SIOCSIWSCAN */
3911 (iw_handler
) prism2_ioctl_giwscan
, /* SIOCGIWSCAN */
3912 (iw_handler
) prism2_ioctl_siwessid
, /* SIOCSIWESSID */
3913 (iw_handler
) prism2_ioctl_giwessid
, /* SIOCGIWESSID */
3914 (iw_handler
) prism2_ioctl_siwnickn
, /* SIOCSIWNICKN */
3915 (iw_handler
) prism2_ioctl_giwnickn
, /* SIOCGIWNICKN */
3916 (iw_handler
) NULL
, /* -- hole -- */
3917 (iw_handler
) NULL
, /* -- hole -- */
3918 (iw_handler
) prism2_ioctl_siwrate
, /* SIOCSIWRATE */
3919 (iw_handler
) prism2_ioctl_giwrate
, /* SIOCGIWRATE */
3920 (iw_handler
) prism2_ioctl_siwrts
, /* SIOCSIWRTS */
3921 (iw_handler
) prism2_ioctl_giwrts
, /* SIOCGIWRTS */
3922 (iw_handler
) prism2_ioctl_siwfrag
, /* SIOCSIWFRAG */
3923 (iw_handler
) prism2_ioctl_giwfrag
, /* SIOCGIWFRAG */
3924 (iw_handler
) prism2_ioctl_siwtxpow
, /* SIOCSIWTXPOW */
3925 (iw_handler
) prism2_ioctl_giwtxpow
, /* SIOCGIWTXPOW */
3926 (iw_handler
) prism2_ioctl_siwretry
, /* SIOCSIWRETRY */
3927 (iw_handler
) prism2_ioctl_giwretry
, /* SIOCGIWRETRY */
3928 (iw_handler
) prism2_ioctl_siwencode
, /* SIOCSIWENCODE */
3929 (iw_handler
) prism2_ioctl_giwencode
, /* SIOCGIWENCODE */
3930 (iw_handler
) prism2_ioctl_siwpower
, /* SIOCSIWPOWER */
3931 (iw_handler
) prism2_ioctl_giwpower
, /* SIOCGIWPOWER */
3932 (iw_handler
) NULL
, /* -- hole -- */
3933 (iw_handler
) NULL
, /* -- hole -- */
3934 (iw_handler
) prism2_ioctl_siwgenie
, /* SIOCSIWGENIE */
3935 (iw_handler
) prism2_ioctl_giwgenie
, /* SIOCGIWGENIE */
3936 (iw_handler
) prism2_ioctl_siwauth
, /* SIOCSIWAUTH */
3937 (iw_handler
) prism2_ioctl_giwauth
, /* SIOCGIWAUTH */
3938 (iw_handler
) prism2_ioctl_siwencodeext
, /* SIOCSIWENCODEEXT */
3939 (iw_handler
) prism2_ioctl_giwencodeext
, /* SIOCGIWENCODEEXT */
3940 (iw_handler
) NULL
, /* SIOCSIWPMKSA */
3941 (iw_handler
) NULL
, /* -- hole -- */
3944 static const iw_handler prism2_private_handler
[] =
3945 { /* SIOCIWFIRSTPRIV + */
3946 (iw_handler
) prism2_ioctl_priv_prism2_param
, /* 0 */
3947 (iw_handler
) prism2_ioctl_priv_get_prism2_param
, /* 1 */
3948 (iw_handler
) prism2_ioctl_priv_writemif
, /* 2 */
3949 (iw_handler
) prism2_ioctl_priv_readmif
, /* 3 */
3952 const struct iw_handler_def hostap_iw_handler_def
=
3954 .num_standard
= ARRAY_SIZE(prism2_handler
),
3955 .num_private
= ARRAY_SIZE(prism2_private_handler
),
3956 .num_private_args
= ARRAY_SIZE(prism2_priv
),
3957 .standard
= (iw_handler
*) prism2_handler
,
3958 .private = (iw_handler
*) prism2_private_handler
,
3959 .private_args
= (struct iw_priv_args
*) prism2_priv
,
3960 .get_wireless_stats
= hostap_get_wireless_stats
,
3964 int hostap_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
3966 struct iwreq
*wrq
= (struct iwreq
*) ifr
;
3967 struct hostap_interface
*iface
;
3968 local_info_t
*local
;
3971 iface
= netdev_priv(dev
);
3972 local
= iface
->local
;
3975 /* Private ioctls (iwpriv) that have not yet been converted
3976 * into new wireless extensions API */
3978 case PRISM2_IOCTL_INQUIRE
:
3979 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3980 else ret
= prism2_ioctl_priv_inquire(dev
, (int *) wrq
->u
.name
);
3983 case PRISM2_IOCTL_MONITOR
:
3984 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3985 else ret
= prism2_ioctl_priv_monitor(dev
, (int *) wrq
->u
.name
);
3988 case PRISM2_IOCTL_RESET
:
3989 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3990 else ret
= prism2_ioctl_priv_reset(dev
, (int *) wrq
->u
.name
);
3993 case PRISM2_IOCTL_WDS_ADD
:
3994 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3995 else ret
= prism2_wds_add(local
, wrq
->u
.ap_addr
.sa_data
, 1);
3998 case PRISM2_IOCTL_WDS_DEL
:
3999 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4000 else ret
= prism2_wds_del(local
, wrq
->u
.ap_addr
.sa_data
, 1, 0);
4003 case PRISM2_IOCTL_SET_RID_WORD
:
4004 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4005 else ret
= prism2_ioctl_priv_set_rid_word(dev
,
4006 (int *) wrq
->u
.name
);
4009 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
4010 case PRISM2_IOCTL_MACCMD
:
4011 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4012 else ret
= ap_mac_cmd_ioctl(local
, (int *) wrq
->u
.name
);
4015 case PRISM2_IOCTL_ADDMAC
:
4016 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4017 else ret
= ap_control_add_mac(&local
->ap
->mac_restrictions
,
4018 wrq
->u
.ap_addr
.sa_data
);
4020 case PRISM2_IOCTL_DELMAC
:
4021 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4022 else ret
= ap_control_del_mac(&local
->ap
->mac_restrictions
,
4023 wrq
->u
.ap_addr
.sa_data
);
4025 case PRISM2_IOCTL_KICKMAC
:
4026 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4027 else ret
= ap_control_kick_mac(local
->ap
, local
->dev
,
4028 wrq
->u
.ap_addr
.sa_data
);
4030 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
4033 /* Private ioctls that are not used with iwpriv;
4034 * in SIOCDEVPRIVATE range */
4036 #ifdef PRISM2_DOWNLOAD_SUPPORT
4037 case PRISM2_IOCTL_DOWNLOAD
:
4038 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4039 else ret
= prism2_ioctl_priv_download(local
, &wrq
->u
.data
);
4041 #endif /* PRISM2_DOWNLOAD_SUPPORT */
4043 case PRISM2_IOCTL_HOSTAPD
:
4044 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4045 else ret
= prism2_ioctl_priv_hostapd(local
, &wrq
->u
.data
);